Browse Source

[Feat 0000] 调整保德配置

houzekong 5 months ago
parent
commit
544e4791c6

+ 23 - 23
src/views/vent/home/configurable/components/detail/CustomChart.vue

@@ -392,6 +392,27 @@
 
     // 折线图和上面的柱状图类似
     if (type === 'line_smooth_complex') {
+      // 基于以下情况作处理:
+      // 数据示例:arr1: [ { arr2: [ { val: 2 } ] } ]
+      // readFrom 指向 arr1,即 sorttedData 指向 arr1,则 prop 配置应为 arr2|val
+      const seriesData = sorttedData.map((data) => {
+        const serie = series[0];
+        const [p1, p2] = serie.prop.split('|');
+        // 从 readFrom 指向的数组项中,取出指定的子数组
+        const arr = get(data, p1);
+
+        return {
+          type: 'line',
+          data: arr.map((e) => {
+            return {
+              name: getFormattedText(e, serie.label),
+              value: get(e, p2, 0),
+            };
+          }),
+          smooth: true,
+        };
+      });
+
       return {
         legend: {
           top: 10,
@@ -413,9 +434,7 @@
         xAxis: xAxis.map(() => {
           return {
             type: 'category',
-            // data: sorttedData.map((d) => {
-            //   return getFormattedText(d, e.label);
-            // }),
+            data: get(seriesData, '[0].data', []).map((d: any) => d.name),
           };
         }),
         yAxis: yAxis.map((e) => {
@@ -429,26 +448,7 @@
             },
           };
         }),
-        // 基于以下情况作处理:
-        // 数据示例:arr1: [ { arr2: [ { val: 2 } ] } ]
-        // readFrom 指向 arr1,则 prop 配置应为 arr2|val
-        series: sorttedData.map((data) => {
-          const serie = series[0];
-          const [p1, p2] = serie.prop.split('|');
-          // 从 readFrom 指向的数组项中,取出指定的子数组
-          const arr = get(data, p1);
-
-          return {
-            type: 'line',
-            data: arr.map((e) => {
-              return {
-                name: get(e, serie.label),
-                value: get(e, p2, 0),
-              };
-            }),
-            smooth: true,
-          };
-        }),
+        series: seriesData,
       };
     }
 

+ 11 - 1
src/views/vent/home/configurable/configurable.api.ts

@@ -51,5 +51,15 @@ export const getBDFireData = (params) => {
       })
     );
   }
-  return cache.get(key) as Promise<any>;
+  return (cache.get(key) as Promise<any>).then((res) => {
+    res.pdArray.forEach((e) => {
+      e.arrayFiber.forEach((j) => {
+        j.fibreTemperatureArr = JSON.parse(j.fibreTemperature);
+      });
+    });
+    res.sgGxObj.devGxcw.forEach((e) => {
+      e.fibreTemperatureArr = JSON.parse(e.fibreTemperature);
+    });
+    return res;
+  });
 };

+ 30 - 102
src/views/vent/home/configurable/configurable.data.ts

@@ -1904,18 +1904,8 @@ const BDfireMock = {
         fmax: '0', //最高浓度
         fmin: '0', //最低温度
         favg: '0', //平均温度
-        fibreTemperature: [
-          {
-            fmax: '0', //最高浓度
-            fmin: '1', //最低温度
-            time: '1',
-          },
-          {
-            fmax: '1', //最高浓度
-            fmin: '0', //最低温度
-            time: '1',
-          },
-        ], //曲线图数据
+        fibreTemperature:
+          '[{"pos":1,"value":"17.8"},{"pos":2,"value":"18.0"},{"pos":3,"value":"18.5"},{"pos":4,"value":"18.6"},{"pos":5,"value":"18.4"},{"pos":6,"value":"18.1"}]',
         warnLevel: '低风险', //风险监测
       },
       {
@@ -1923,18 +1913,8 @@ const BDfireMock = {
         fmax: '0', //最高浓度
         fmin: '0', //最低温度
         favg: '0', //平均温度
-        fibreTemperature: [
-          {
-            fmax: '0', //最高浓度
-            fmin: '0', //最低温度
-            time: '1',
-          },
-          {
-            fmax: '1', //最高浓度
-            fmin: '1', //最低温度
-            time: '1',
-          },
-        ], //曲线图数据
+        fibreTemperature:
+          '[{"pos":1,"value":"7.8"},{"pos":2,"value":"18.0"},{"pos":3,"value":"18.5"},{"pos":4,"value":"18.6"},{"pos":5,"value":"18.4"},{"pos":6,"value":"18.1"}]',
         warnLevel: '低风险', //风险监测
       },
     ],
@@ -1950,7 +1930,7 @@ const BDfireMock = {
         o2Val: '0', //氧气值
         connectSta: '连接', //连接状态
         warnLevel: '低风险', //风险监测
-        btTriBlast: '', //爆炸三角信息
+        btTriBlast: '{"G_y":10.53,"G_x":0,"F_y":0,"A_x":5.0,"B_x":15.0,"A_y":19.93,"B_y":17.83,"E_y":10.0,"F_x":9.55,"E_x":5.0}', //爆炸三角信息
       },
       {
         strinstallpos: '位置2', //安装位置
@@ -1962,7 +1942,7 @@ const BDfireMock = {
         o2Val: '0', //氧气值
         connectSta: '连接', //连接状态
         warnLevel: '低风险', //风险监测
-        btTriBlast: '', //爆炸三角信息
+        btTriBlast: '{"G_y":10.53,"G_x":0,"F_y":0,"A_x":5.0,"B_x":15.0,"A_y":19.93,"B_y":17.83,"E_y":10.0,"F_x":9.55,"E_x":5.0}', //爆炸三角信息
       },
     ],
   },
@@ -1995,20 +1975,8 @@ const BDfireMock = {
           fmax: '0', //最高浓度
           fmin: '0', //最低温度
           favg: '0', //平均温度
-          fibreTemperature: [
-            {
-              favg: '20',
-              time: '2024-09-10 17:04:50',
-              fmin: '19.01',
-              fmax: '32.0',
-            },
-            {
-              favg: '24',
-              time: '2024-09-11 00:00:00',
-              fmin: '19.01',
-              fmax: '31.99',
-            },
-          ], //曲线图数据
+          fibreTemperature:
+            '[{"pos":1,"value":"17.8"},{"pos":2,"value":"18.0"},{"pos":3,"value":"18.5"},{"pos":4,"value":"18.6"},{"pos":5,"value":"18.4"},{"pos":6,"value":"18.1"}]',
           warnLevel: '低风险', //风险监测
         },
         {
@@ -2016,20 +1984,8 @@ const BDfireMock = {
           fmax: '0', //最高浓度
           fmin: '0', //最低温度
           favg: '0', //平均温度
-          fibreTemperature: [
-            {
-              favg: '23',
-              time: '2024-09-10 17:04:50',
-              fmin: '19.01',
-              fmax: '32.0',
-            },
-            {
-              favg: '30',
-              time: '2024-09-11 00:00:00',
-              fmin: '19.01',
-              fmax: '31.99',
-            },
-          ], //曲线图数据
+          fibreTemperature:
+            '[{"pos":1,"value":"17.8"},{"pos":2,"value":"18.0"},{"pos":3,"value":"18.5"},{"pos":4,"value":"18.6"},{"pos":5,"value":"18.4"},{"pos":6,"value":"18.1"}]',
           warnLevel: '低风险', //风险监测
         },
         {
@@ -2037,20 +1993,8 @@ const BDfireMock = {
           fmax: '0', //最高浓度
           fmin: '0', //最低温度
           favg: '0', //平均温度
-          fibreTemperature: [
-            {
-              favg: '10',
-              time: '2024-09-10 17:04:50',
-              fmin: '19.01',
-              fmax: '32.0',
-            },
-            {
-              favg: '13',
-              time: '2024-09-11 00:00:00',
-              fmin: '19.01',
-              fmax: '31.99',
-            },
-          ], //曲线图数据
+          fibreTemperature:
+            '[{"pos":1,"value":"19.8"},{"pos":2,"value":"18.0"},{"pos":3,"value":"18.5"},{"pos":4,"value":"18.6"},{"pos":5,"value":"18.4"},{"pos":6,"value":"18.1"}]',
           warnLevel: '低风险', //风险监测
         },
         {
@@ -2058,20 +2002,8 @@ const BDfireMock = {
           fmax: '0', //最高浓度
           fmin: '0', //最低温度
           favg: '0', //平均温度
-          fibreTemperature: [
-            {
-              favg: '30',
-              time: '2024-09-10 17:04:50',
-              fmin: '19.01',
-              fmax: '32.0',
-            },
-            {
-              favg: '27',
-              time: '2024-09-11 00:00:00',
-              fmin: '19.01',
-              fmax: '31.99',
-            },
-          ], //曲线图数据
+          fibreTemperature:
+            '[{"pos":1,"value":"17.8"},{"pos":2,"value":"18.0"},{"pos":3,"value":"18.5"},{"pos":4,"value":"18.6"},{"pos":5,"value":"18.4"},{"pos":6,"value":"18.1"}]',
           warnLevel: '低风险', //风险监测
         },
       ],
@@ -2103,7 +2035,8 @@ const BDfireMock = {
           fmax: '0', //最高浓度
           fmin: '0', //最低温度
           favg: '0', //平均温度
-          fibreTemperature: [], //曲线图数据
+          fibreTemperature:
+            '[{"pos":1,"value":"17.8"},{"pos":2,"value":"18.0"},{"pos":3,"value":"18.5"},{"pos":4,"value":"18.6"},{"pos":5,"value":"18.4"},{"pos":6,"value":"18.1"}]',
           warnLevel: '低风险', //风险监测
         },
         {
@@ -2111,7 +2044,8 @@ const BDfireMock = {
           fmax: '0', //最高浓度
           fmin: '0', //最低温度
           favg: '0', //平均温度
-          fibreTemperature: [], //曲线图数据
+          fibreTemperature:
+            '[{"pos":1,"value":"17.8"},{"pos":2,"value":"18.0"},{"pos":3,"value":"18.5"},{"pos":4,"value":"18.6"},{"pos":5,"value":"18.4"},{"pos":6,"value":"18.1"}]',
           warnLevel: '低风险', //风险监测
         },
         {
@@ -2119,7 +2053,8 @@ const BDfireMock = {
           fmax: '0', //最高浓度
           fmin: '0', //最低温度
           favg: '0', //平均温度
-          fibreTemperature: [], //曲线图数据
+          fibreTemperature:
+            '[{"pos":1,"value":"17.8"},{"pos":2,"value":"18.0"},{"pos":3,"value":"18.5"},{"pos":4,"value":"18.6"},{"pos":5,"value":"18.4"},{"pos":6,"value":"18.1"}]',
           warnLevel: '低风险', //风险监测
         },
         {
@@ -2127,7 +2062,8 @@ const BDfireMock = {
           fmax: '0', //最高浓度
           fmin: '0', //最低温度
           favg: '0', //平均温度
-          fibreTemperature: [], //曲线图数据
+          fibreTemperature:
+            '[{"pos":1,"value":"17.8"},{"pos":2,"value":"18.0"},{"pos":3,"value":"18.5"},{"pos":4,"value":"18.6"},{"pos":5,"value":"18.4"},{"pos":6,"value":"18.1"}]',
           warnLevel: '低风险', //风险监测
         },
       ],
@@ -2715,12 +2651,12 @@ export const testConfigBDFire: Config[] = [
         {
           type: 'line_smooth_complex',
           readFrom: 'arrayFiber',
-          xAxis: [{ label: '${position}' }],
+          xAxis: [{ label: '' }],
           yAxis: [{ label: '温度(℃)', align: 'left' }],
           series: [
             {
-              label: '${position}',
-              prop: 'fibreTemperature|favg',
+              label: '${pos}',
+              prop: 'fibreTemperatureArr|value',
             },
           ],
         },
@@ -2831,7 +2767,7 @@ export const testConfigBDFire: Config[] = [
       complex_list: [],
       preset: [
         {
-          readFrom: 'btTriBlast',
+          readFrom: '',
         },
       ],
       // mock: BDfireMock,
@@ -2872,21 +2808,13 @@ export const testConfigBDFire: Config[] = [
       chart: [
         {
           type: 'line_smooth',
-          readFrom: 'fibreTemperature',
-          xAxis: [{ label: '${position}' }],
+          readFrom: 'fibreTemperatureArr',
+          xAxis: [{ label: '${pos}' }],
           yAxis: [{ label: '温度(℃)', align: 'left' }],
           series: [
             {
-              label: '最高温度',
-              prop: 'fmax',
-            },
-            {
-              label: '最低温度',
-              prop: 'fmin',
-            },
-            {
-              label: '平均温度',
-              prop: 'favg',
+              label: '${pos}',
+              prop: 'value',
             },
           ],
         },