Explorar el Código

[Wip 0000] 项目各个页面数据对接

houzekong hace 2 días
padre
commit
35c05eae39

+ 5 - 1
src/api/sys/map.ts

@@ -13,7 +13,11 @@ enum Api {
  * @param params
  */
 export function getMarkers(params: any): Promise<any> {
-  return defHttp.post({ url: Api.list, params: omitBy(params, isNil) }, { joinParamsToUrl: true });
+  return defHttp.post({
+    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
+    url: Api.list,
+    params,
+  });
 }
 
 export function getGoafAlarmLevel(params: any): Promise<any> {

+ 1 - 0
src/layouts/default/feature/SimpleMap.vue

@@ -273,6 +273,7 @@
       if (!props.silence) {
         const [records, mks] = await getMarkerCollection({
           deptId: mineStore.getRootId,
+          pageNo: 1,
           pageSize: 9999,
         });
         markerCollection = listToTree(records, DEFAULT_TREE_CONFIG);

+ 76 - 55
src/views/analysis/warningAnalysis/windPointManage/windTopology/hooks/useTopology.ts

@@ -33,6 +33,8 @@ export function useTopology() {
   /** 绑定选择态:双击「测风点位/数据布点」后等待单击目标 */
   const selectMode = ref(false);
   const selectedSourceId = ref('');
+  /** 待绑定源节点 id(放大+描边标记,进入选择态后生效,退出后清除) */
+  const markedSourceId = ref('');
   /** 操作栏部门选择:选中任意层级部门后过滤部门树(该部门及其后代)并按该部门查询数据;空=全局 */
   const selectedDeptId = ref('');
 
@@ -185,14 +187,21 @@ export function useTopology() {
       seenIds.add(n.id);
       const cat = categories[n.category] || categories[0];
       const statusColor = statusColorMap[n.status || 'normal'];
+      const isMarked = n.id === markedSourceId.value;
+      const itemStyle: any = { color: statusColor || cat.color };
+      // 待绑定源节点:放大 + 红色描边,让用户明确当前正在操作哪个节点
+      if (isMarked) {
+        itemStyle.borderColor = '#ff4d4f';
+        itemStyle.borderWidth = 3;
+      }
       echartsNodes.push({
         id: n.id,
         name: n.name,
         category: n.category,
         value: n.name,
         symbol: cat.symbol,
-        symbolSize: cat.symbolSize,
-        itemStyle: { color: statusColor || cat.color },
+        symbolSize: isMarked ? cat.symbolSize + 8 : cat.symbolSize,
+        itemStyle,
         raw: n,
       });
     }
@@ -225,7 +234,14 @@ export function useTopology() {
 
     // ——— 单击 ———
     chartInstance.on('click', (params: any) => {
-      if (!params.data) return;
+      // 待绑定态下单击空白处 → 取消选择
+      if (!params.data) {
+        if (selectMode.value) {
+          exitSelectMode();
+          message.info('已取消绑定');
+        }
+        return;
+      }
 
       if (params.dataType === 'node') {
         if (editMode.value && selectMode.value) {
@@ -277,22 +293,53 @@ export function useTopology() {
     }
     selectMode.value = true;
     selectedSourceId.value = sourceId;
+    markedSourceId.value = sourceId;
+    // 重绘应用放大 + 描边标记,并高亮关联连线
+    renderTopology(topologyData);
     highlightPath(sourceId);
     const tip =
       src.category === CAT_POINT
-        ? `已选中"${src.name}",请单击一个「矿井」绑定所属矿。双击空白处取消。`
-        : `已选中"${src.name}",请单击一个「测风点位」绑定。击空白处取消。`;
+        ? `已选中"${src.name}",请单击一个「矿井」或「数据布点」绑定。单击空白处取消。`
+        : `已选中"${src.name}",请单击一个「测风点位」绑定。击空白处取消。`;
     message.info(tip);
   }
 
   function exitSelectMode() {
     selectMode.value = false;
     selectedSourceId.value = '';
+    markedSourceId.value = '';
     chartInstance?.dispatchAction({ type: 'downplay' });
+    // 重绘移除待绑定源节点的放大/描边标记
+    renderTopology(topologyData);
   }
 
   // ==================== 绑定逻辑 ====================
 
+  /** 按数据布点原始 id 解析其显示名(用于确认文案,避免直接展示 id) */
+  function deviceNameOf(rawId?: string) {
+    const dev = topologyData.nodes.find((n) => n.category === CAT_DEVICE && n.rawId === rawId);
+    return dev?.name || rawId || '';
+  }
+
+  /** 统一确认弹窗并执行编辑(一次 updateArea 调用,后端负责用新 id 替换旧绑定) */
+  function confirmBind(confirmText: string, params: any) {
+    Modal.confirm({
+      title: '确认绑定',
+      content: confirmText,
+      okText: '确认绑定',
+      cancelText: '取消',
+      onOk: async () => {
+        try {
+          await updateArea(params);
+          await loadTopology();
+          message.success('绑定成功');
+        } catch {
+          message.error('绑定失败');
+        }
+      },
+    });
+  }
+
   async function attemptBind(sourceId: string, targetId: string) {
     exitSelectMode();
     if (sourceId === targetId) {
@@ -303,8 +350,8 @@ export function useTopology() {
     const tgt = topologyData.nodes.find((n) => n.id === targetId);
     if (!src || !tgt) return;
 
+    // 测风点位 → 矿井:编辑测风点位的 mineCode(允许改绑)
     if (src.category === CAT_POINT && tgt.category === CAT_ORG) {
-      // 测风点位 → 矿井:编辑测风点位的 mineCode
       if (!tgt.isLeaf) {
         message.warning('仅支持绑定到矿井(叶子节点)');
         return;
@@ -321,60 +368,34 @@ export function useTopology() {
       const confirmText = src.mineCode
         ? `该测风点位已绑定到矿编码"${src.mineCode}",确认改绑到"${tgt.name}"?`
         : `确认将"${src.name}"绑定到"${tgt.name}"?`;
-      Modal.confirm({
-        title: '确认绑定',
-        content: confirmText,
-        okText: '确认绑定',
-        cancelText: '取消',
-        onOk: async () => {
-          try {
-            await updateArea({ id: src.rawId, mineCode: fax });
-            await loadTopology();
-            message.success('绑定成功');
-          } catch {
-            message.error('绑定失败');
-          }
-        },
-      });
+      confirmBind(confirmText, { id: src.rawId, mineCode: fax });
       return;
     }
 
-    if (src.category === CAT_DEVICE && tgt.category === CAT_POINT) {
-      // 数据布点 → 测风点位:编辑测风点位的 windrectId
-      // 一对一:该数据布点已被其他测风点位绑定则拦截
-      const boundPoint = topologyData.links.find((l) => l.target === src.id && l.source !== tgt.id && l.kind === 'sensor');
-      if (boundPoint) {
-        const other = topologyData.nodes.find((n) => n.id === boundPoint.source);
-        message.warning(`该数据布点已被测风点位"${other?.name || boundPoint.source}"绑定`);
-        return;
-      }
-      const alreadyLinked = topologyData.links.some((l) => l.kind === 'sensor' && l.source === tgt.id && l.target === src.id);
-      if (alreadyLinked) {
-        message.warning('已存在该绑定关系');
-        return;
-      }
-      const confirmText = tgt.windrectId
-        ? `该测风点位已绑定数据布点"${tgt.windrectId}",确认改绑到"${src.name}"?`
-        : `确认将"${src.name}"绑定到测风点位"${tgt.name}"?`;
-      Modal.confirm({
-        title: '确认绑定',
-        content: confirmText,
-        okText: '确认绑定',
-        cancelText: '取消',
-        onOk: async () => {
-          try {
-            await updateArea({ id: tgt.rawId, windrectId: src.rawId });
-            await loadTopology();
-            message.success('绑定成功');
-          } catch {
-            message.error('绑定失败');
-          }
-        },
-      });
+    // 测风点位 → 数据布点 / 数据布点 → 测风点位:均编辑测风点位的 windrectId(后端一次调用替换旧绑定)
+    let pointNode: TopoNodeData;
+    let deviceNode: TopoNodeData;
+    if (src.category === CAT_POINT && tgt.category === CAT_DEVICE) {
+      pointNode = src;
+      deviceNode = tgt;
+    } else if (src.category === CAT_DEVICE && tgt.category === CAT_POINT) {
+      pointNode = tgt;
+      deviceNode = src;
+    } else {
+      message.warning('仅支持「测风点位→矿井/数据布点」或「数据布点→测风点位」的绑定');
       return;
     }
 
-    message.warning('仅支持「测风点位→矿井」或「数据布点→测风点位」的绑定');
+    const alreadyLinked = topologyData.links.some((l) => l.kind === 'sensor' && l.source === pointNode.id && l.target === deviceNode.id);
+    if (alreadyLinked) {
+      message.warning('已存在该绑定关系');
+      return;
+    }
+    const oldDeviceName = deviceNameOf(pointNode.windrectId);
+    const confirmText = pointNode.windrectId
+      ? `该测风点位已绑定数据布点"${oldDeviceName}",确认改绑到"${deviceNode.name}"?`
+      : `确认将"${deviceNode.name}"绑定到测风点位"${pointNode.name}"?`;
+    confirmBind(confirmText, { id: pointNode.rawId, windrectId: deviceNode.rawId });
   }
 
   // ==================== 解绑逻辑 ====================
@@ -484,7 +505,7 @@ export function useTopology() {
     if (on) {
       renderTopology(topologyData, true);
       chartInstance.setOption({ series: [{ roam: false }] as any });
-      message.info('绑定模式已开启:双击「测风点位」→ 单击「矿井」绑定所属矿;双击「数据布点」→ 单击「测风点位」绑定;双击连线解绑');
+      message.info('绑定模式已开启:双击「测风点位」→ 单击「矿井」或「数据布点」绑定;双击「数据布点」→ 单击「测风点位」绑定;双击连线解绑');
     } else {
       renderTopology(topologyData);
       message.info('已退出绑定模式');

+ 1 - 1
src/views/analysis/warningAnalysis/windPointManage/windTopology/index.vue

@@ -32,7 +32,7 @@
         </a-button>
         <a-divider type="vertical" />
         <span v-if="editMode" class="select-text"
-          >双击「测风点位」→ 单击「矿井」绑定所属矿;双击「数据布点」→ 单击「测风点位」绑定;双击连线解绑</span
+          >双击「测风点位」→ 单击「矿井」或「数据布点」绑定;双击「数据布点」→ 单击「测风点位」绑定;双击连线解绑</span
         >
       </div>
 

+ 3 - 0
src/views/analysis/warningAnalysis/windPointManage/windTopology/windTopology.data.ts

@@ -108,6 +108,8 @@ export interface TopoNodeData {
   parentId?: string | null;
   isLeaf?: boolean;
   isLeafText?: string;
+  /** 矿井编码(仅部门叶子节点(矿点)有值,测风点位→矿井绑定时取矿编码) */
+  fax?: string;
   status?: string; // normal / abnormal / offline
   airVolume?: number;
   childCount?: number;
@@ -298,6 +300,7 @@ export function transformToTopologyData(
       parentId: o.parentId,
       isLeaf: o.isLeaf,
       isLeafText: o.isLeaf ? '是' : '否',
+      fax: o.fax,
       depth: o.depth ?? 0,
     })),
     // 测风点位节点

+ 15 - 18
src/views/dashboard/HiddenSurface/configurable.data.ts

@@ -99,7 +99,7 @@ export const testConfigProvinceMonitor: Config[] = [
             { name: '执法处', prop: 'name' },
             { name: '矿井数', prop: 'mineNum' },
             { name: '风量异常', prop: 'exceptionNum' },
-            { name: '疑似', prop: 'suspectedNum' },
+            { name: '疑似隐蔽工作面', prop: 'suspectedNum' },
           ],
         },
       ],
@@ -113,7 +113,7 @@ export const testConfigProvinceMonitor: Config[] = [
       position: 'top:30px;right:25px;',
     },
   },
-  // 3. 风速风量传感器(左下角,表格展示传感器返回数据
+  // 3. 风速风量传感器(左下角,饼图统计 getMineData 中风量闭合/风量异常矿井数
   {
     deviceType: 'wind_speed_sensor',
     moduleName: '风速风量传感器',
@@ -126,30 +126,27 @@ export const testConfigProvinceMonitor: Config[] = [
         slot: { show: false, value: '' },
       },
       background: { show: false, type: 'video', link: '' },
-      layout: { direction: 'column', items: [{ name: 'table', basis: '100%', overflow: true }] },
+      layout: { direction: 'column', items: [{ name: 'chart', basis: '100%' }] },
       board: [],
-      chart: [],
+      chart: [
+        {
+          type: 'pie',
+          readFrom: 'windClosedStats',
+          legend: { show: true },
+          xAxis: [{ show: false }],
+          yAxis: [{ show: false, name: '', position: 'left' }],
+          series: [{ readFrom: '', xprop: 'name', yprop: 'value', label: '' }],
+        },
+      ],
       gallery: [],
       gallery_list: [],
       list: [],
       complex_list: [],
       preset: [],
-      table: [
-        {
-          type: 'D',
-          readFrom: 'windSensors',
-          columns: [
-            { name: '矿井名称', prop: 'mineName' },
-            { name: '测风地点', prop: 'mineAreaName' },
-            { name: '风速(m/s)', prop: 'va' },
-            { name: '风量(m³/min)', prop: 'm3' },
-            // { name: '状态', prop: 'status' },
-          ],
-        },
-      ],
+      table: [],
     },
     showStyle: {
-      size: 'width:400px;height:580px;',
+      size: 'width:400px;height:400px;',
       version: '原版',
       position: 'top:300px;left:25px;',
     },

+ 27 - 15
src/views/dashboard/HiddenSurface/index.vue

@@ -55,7 +55,7 @@
   const cfgs = computed(() => configs.value);
   const { configs } = useInitConfigs();
 
-  // 省域级数据汇总(getCurrentStatistics + getMineJudgeCount + getWindrectData + getMineData)
+  // 省域级数据汇总(getCurrentStatistics + getMineJudgeCount + getMineData)
   const provinceData = shallowRef({
     accessMineNum: 0, // 接入矿井总数
     areaNum: 0, // 测风点总数
@@ -67,7 +67,7 @@
     m3NotClosedNum: 0, // 风量不闭合异常数量
     disconnectNum: [] as any[], // 数据掉线点列表
     enforceOffices: null, // 执法处判识情况列表
-    windSensors: [] as any[], // 风速风量传感器实时数据
+    windClosedStats: [] as any[], // 风量闭合/风量异常饼图统计(getMineData)
     hiddenWorkfaces: [] as any[], // 疑似隐蔽工作面列表
   });
 
@@ -124,10 +124,21 @@
       }));
   }
 
+  /** Mine 分页记录 → 风量闭合/风量异常饼图统计(闭合矿井数 m3Closed==2;风量异常矿井数 m3Exception>0) */
+  function countWindClosedStats(records: any[]) {
+    const list = records || [];
+    const closedNum = list.filter((r) => Number(r.m3Closed) === 2).length;
+    const exceptionNum = list.filter((r) => Number(r.m3Exception) > 0).length;
+    return [
+      { name: '风量闭合', value: closedNum },
+      { name: '风量异常', value: exceptionNum },
+    ];
+  }
+
   async function fetchHomeData() {
     try {
       const deptId = appStore.getSimpleMapParams?.deptId;
-      const [statistics, judgeList, windrectPage, minePage] = await Promise.all([
+      const [statistics, judgeList, mineStats] = await Promise.all([
         getCurrentStatistics({ deptId })
           .then((r) => r || {})
           .catch((e) => {
@@ -140,17 +151,18 @@
             console.error('执法处判识情况获取失败:', e);
             return null;
           }),
-        getWindrectData({ deptId, pageNo: 1, pageSize: 20 })
-          .then((r) => mapWindrectRecords(r?.records))
-          .catch((e) => {
-            console.error('风速风量传感器数据获取失败:', e);
-            return [];
-          }),
-        getMineData({ deptId, pageNo: 1, pageSize: 20, judgeResult: 1 })
-          .then((r) => mapSuspectedMines(r?.records))
+        // 一次 getMineData 同时派生:左下角饼图(风量闭合/风量异常)+ 右下角疑似隐蔽工作面表格
+        getMineData({ deptId, pageNo: 1, pageSize: 100 })
+          .then((r) => {
+            const records = r?.records || [];
+            return {
+              windClosedStats: countWindClosedStats(records),
+              hiddenWorkfaces: mapSuspectedMines(records).slice(0, 20),
+            };
+          })
           .catch((e) => {
-            console.error('隐蔽工作面数据获取失败:', e);
-            return [];
+            console.error('隐蔽工作面/风量闭合风量异常数据获取失败:', e);
+            return { windClosedStats: [], hiddenWorkfaces: [] };
           }),
       ]);
 
@@ -165,8 +177,8 @@
         m3NotClosedNum: statistics.m3NotClosedNum ?? 0,
         disconnectNum: Array.isArray(statistics.disconnectNum) ? statistics.disconnectNum : [],
         enforceOffices: judgeList,
-        windSensors: windrectPage,
-        hiddenWorkfaces: minePage,
+        windClosedStats: mineStats.windClosedStats,
+        hiddenWorkfaces: mineStats.hiddenWorkfaces,
       };
       updateData(provinceData.value);
     } catch (error) {

+ 5 - 5
src/views/monitor/sensorMonitor/sensorMonitor.data.ts

@@ -26,11 +26,11 @@ export const columns: BasicColumn[] = [
     fixed: 'left',
     width: 180,
   },
-  {
-    title: '矿编码',
-    dataIndex: 'mineCode',
-    width: 110,
-  },
+  // {
+  //   title: '矿编码',
+  //   dataIndex: 'mineCode',
+  //   width: 110,
+  // },
   {
     title: '测风地点',
     dataIndex: 'mineAreaName',

+ 6 - 1
src/views/monitor/surfaceMonitor/surfaceMonitor.api.ts

@@ -5,5 +5,10 @@ enum Api {
 }
 
 /** 煤矿列表查询(MineDataController.getMineData,分页,deptId 必填) */
+
 export const getMineData = (params?: any) =>
-  defHttp.post({ url: Api.getMineData, params }, { joinParamsToUrl: true });
+  defHttp.post({
+    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
+    url: Api.getMineData,
+    params,
+  });

+ 10 - 10
src/views/monitor/surfaceMonitor/surfaceMonitor.data.ts

@@ -38,11 +38,11 @@ export const columns: BasicColumn[] = [
     fixed: 'left',
     width: 220,
   },
-  {
-    title: '矿编码',
-    dataIndex: 'mineCode',
-    width: 110,
-  },
+  // {
+  //   title: '矿编码',
+  //   dataIndex: 'mineCode',
+  //   width: 110,
+  // },
   // {
   //   title: '矿井全称',
   //   dataIndex: 'corpName',
@@ -127,11 +127,11 @@ export const historyColumns: BasicColumn[] = [
     fixed: 'left',
     width: 180,
   },
-  {
-    title: '矿编码',
-    dataIndex: 'mineCode',
-    width: 110,
-  },
+  // {
+  //   title: '矿编码',
+  //   dataIndex: 'mineCode',
+  //   width: 110,
+  // },
   {
     title: '接入状态',
     dataIndex: 'accessStatus',

+ 4 - 4
src/views/system/cadFile/app.ts

@@ -366,8 +366,8 @@ export function useMap2D(): UseMap2DReturn {
       const id = props?.id;
       if (!id) {
         marker.remove();
-        message.error('缺少密闭ID,无法同步布点信息到服务器');
-        throw new Error('缺少密闭ID,无法同步布点信息到服务器');
+        message.error('缺少隐蔽工作面ID,无法同步布点信息到服务器');
+        throw new Error('缺少隐蔽工作面ID,无法同步布点信息到服务器');
       }
 
       try {
@@ -448,7 +448,7 @@ export function useMap2D(): UseMap2DReturn {
 
     const validGoafList = goafList.filter((item) => getGoafIsPositioned(item));
     if (validGoafList.length === 0) {
-      console.info('当前密闭列表无有效布点坐标,暂无标记可渲染');
+      console.info('当前隐蔽工作面列表无有效布点坐标,暂无标记可渲染');
       return;
     }
 
@@ -474,7 +474,7 @@ export function useMap2D(): UseMap2DReturn {
         bindMarkerEvents(marker, goafItem.id);
         allMarkers.push(marker);
       } catch (err) {
-        console.error(`渲染密闭${goafItem.id}标记失败:`, err);
+        console.error(`渲染隐蔽工作面${goafItem.id}标记失败:`, err);
       }
     }
   }

+ 2 - 2
src/views/system/cadFile/cad.api.ts

@@ -19,12 +19,12 @@ export function getMineAreaList(params: any) {
 export function updateMineArea(params: any) {
   return defHttp.post({ url: Api.updateMineArea, params });
 }
-// 查询密闭监测数据
+// 查询隐蔽工作面监测数据
 export function getGoafData(params: any) {
   return defHttp.post({ url: Api.getGoafData, params }, { joinParamsToUrl: true });
 }
 
-// 查询密闭监测数据
+// 查询隐蔽工作面监测数据
 export function getMineFileList(params: any) {
   return defHttp.post({ url: Api.getMineFileList, params }, { joinParamsToUrl: true });
 }

+ 3 - 3
src/views/system/cadFile/components/SideDrawer.vue

@@ -42,7 +42,7 @@
           </a-button>
         </div> -->
       <div class="mb-5px">
-        <a-input v-model:value="searchValue" placeholder="密闭位置" style="width: 60%; margin-right: 8px" />
+        <a-input v-model:value="searchValue" placeholder="隐蔽工作面位置" style="width: 60%; margin-right: 8px" />
       </div>
 
       <!-- 传感器数据表格 -->
@@ -94,7 +94,7 @@
   //   total: 0, // 初始化为0,由接口数据决定
   // });
   const selectedMineId = ref(props.mineCode);
-  // 新增:存储接口返回的密闭数据
+  // 新增:存储接口返回的隐蔽工作面数据
   const goafList = ref<any[]>([]);
 
   // 表格列配置 - 修复字段拼写错误(devicePos → devicePos)
@@ -108,7 +108,7 @@
     },
     {
       title: '区域名称',
-      dataIndex: 'name', // MineArea.name(原密闭位置 devicePos)
+      dataIndex: 'name', // MineArea.name(原隐蔽工作面位置 devicePos)
       key: 'name',
       ellipsis: true,
       // tooltip: true,