Преглед изворни кода

fix(configuratePage):修复组态页面数据显示问题

HMY пре 10 месеци
родитељ
комит
3b35c847b3

+ 5 - 3
admin/src/main/java/com/dcs/hnyz/service/impl/EquipmentParamServiceImpl.java

@@ -254,8 +254,9 @@ public class EquipmentParamServiceImpl implements IEquipmentParamService {
                 paramTypes.add(RegisterTypeEnum.MASTER_SET.getCode());
                 break;
             case PUMP://泵
-                paramTypes.add(RegisterTypeEnum.MASTER_DATA.getCode());//频率
-                paramTypes.add(RegisterTypeEnum.SLAVE_DATA.getCode());//状态
+                paramTypes.add(RegisterTypeEnum.MASTER_DATA.getCode());//状态
+                paramTypes.add(RegisterTypeEnum.SLAVE_DATA.getCode());//频率
+                break;
             default:
                 return Collections.emptyList();
         }
@@ -263,7 +264,8 @@ public class EquipmentParamServiceImpl implements IEquipmentParamService {
         // 查询所有符合条件的寄存器
         wrapper.in(EquipmentParam::getParamType, paramTypes);
         List<EquipmentParam> paramList = equipmentParamMapper.selectList(wrapper);
-
+        // 根据 paramTypes 顺序排序
+        paramList.sort(Comparator.comparingInt(p -> paramTypes.indexOf(p.getParamType())));
         if (CollectionUtils.isEmpty(paramList)) {
             log.warn("根据 parentId:{} 没有查询到对应类型的寄存器", parentId);
             return Collections.emptyList();

+ 7 - 4
ui/src/components/DCS/PumpComponent.vue

@@ -34,15 +34,18 @@ const props = defineProps({
     },
     pumpDataArr:{
         type:Array,
-        default:[0,3]
+        default:[3,0]
     }
 })
-
-const hzValue = computed(() => `${props.pumpDataArr[0]}` * 0.01);
+// 频率值 保留两位小数
+const hzValue = computed(() => {
+  const raw = Number(props.pumpDataArr[1]) * 0.01;
+  return Math.floor(raw * 100) / 100;
+});
 
 //状态启动字
 const getStartStatus = computed(() => {
-    switch (props.pumpDataArr[1]) {
+    switch (props.pumpDataArr[0]) {
         case 1:
             return '正转'
         case 2:

+ 1 - 1
ui/src/components/DCS/ValveProgressComponent.vue

@@ -53,7 +53,7 @@ const props = defineProps({
         type: Number,
         default: 50
     },
-    //进度条颜色
+    //进度条类型
     progressType: {
         type: String,
         default: 'red'

+ 26 - 33
ui/src/components/DCS/WaterTankComponent.vue

@@ -17,7 +17,7 @@
             </div>
         </i>
         <!-- 压力  -->
-        <div class="pressure_block" v-if="pressureValue >= 0"
+        <div class="pressure_block" v-if="pressureValueRef"
             :style="{ width: iconSize * 0.375 + 'px', height: iconSize * 0.375 + 'px' }">
             <div ref="chartRef" :style="{ width: iconSize * 0.5 + 'px', height: iconSize * 0.5 + 'px' }"
                 class="pressure_chart"></div>
@@ -30,8 +30,7 @@
 </template>
 
 <script setup>
-import { computed } from 'vue'
-import { ref, onMounted, onBeforeUnmount, watch } from 'vue'
+import { ref, onMounted, onBeforeUnmount, watch, computed, toRef } from 'vue'
 import * as echarts from 'echarts'
 //图表
 
@@ -65,7 +64,7 @@ const props = defineProps({
     },
     pressureValue: {// 压力值
         type: Number,
-        default: -1,// -1表示未传压力值
+        // default: -1,// -1表示未传压力值
     },
     weightValue: {// 重量值
         type: Number,
@@ -155,7 +154,7 @@ const option = ref({
             },
             data: [
                 {
-                    value: props.pressureValue.toFixed(3),
+                    value: props.pressureValue?.toFixed(3),
                 }
             ],
         }
@@ -180,14 +179,17 @@ const getTempClass = computed(() => {
         return 'temp_green'
     }
 })
-// 监听压力变化
-watch(props?.pressureValue, (newVal) => {
-    if (myChart) {
+// 取出 pressureValue 的响应式引用
+const pressureValueRef = toRef(props, 'pressureValue')
+
+// 正确 watch 用法
+watch(pressureValueRef, (newVal) => {
+    if (myChart && typeof newVal === 'number' && newVal >= 0) {
         myChart.setOption({
             series: [
                 {
                     type: 'gauge',
-                    data: [{ name: '压力数据', value: newVal.toFixed(2) }]
+                    data: [{ name: '', value: newVal.toFixed(3) }]
                 }
             ]
         })
@@ -206,30 +208,21 @@ const waterLevelPosClass = computed(() =>
 const tempPosClass = computed(() =>
     'temp_pos' + props.tankType
 )
-//温度计数值显示
-const marks = computed(() => ({
-    // 80: '80°C',
-    // 75: {
-    //     style: {
-    //         color: '#fb8a1c',
-    //     },
-    //     label: '75°C',
-    // },
-    // 120: {
-    //     style: {
-    //         color: '#ff0000',
-    //         // fontWeight: 'bold',
-    //     },
-    //     label: '120°C',
-    // },
-    [temperatureValue.value]: {
-        style: {
-            color: temperatureValue.value < 75 ? '#4CAF50' : (temperatureValue.value < 120 ? '#FFC107' : '#ff0000'),
-            fontWeight: 'bold',
-        },
-        label: `${temperatureValue.value}°C`
-    }
-}))
+//温度
+const marks = computed(() => {
+    const val = parseFloat(temperatureValue.value);
+    const displayVal = val % 1 === 0 ? val.toFixed(0) : val.toFixed(1);
+    return {
+        [temperatureValue.value]: {
+            style: {
+                color: val < 75 ? '#4CAF50' : (val < 120 ? '#FFC107' : '#ff0000'),
+                fontWeight: 'bold',
+            },
+            label: `${displayVal}°C`
+        }
+    };
+});
+
 
 
 // 仅传 waterLevelValue,内部组装 config

+ 6 - 4
ui/src/views/configuratePage/m2OutMaterial/index.vue

@@ -301,10 +301,6 @@ const valveArr_S3 = [
 ]
 //传感器状态
 const sensorArr = [
-    {
-        code: 'M2yl',
-        value: [0.5],
-    },
     {
         code: 'M2cz',
         value: [100],
@@ -381,6 +377,12 @@ onMounted(() => {
     });
 });
 
+// // 随机模拟泵数据[0,100],前面0-3的整数,后面1-5000的整数
+// const simulatePumpData = ref([0, 0]);
+// setInterval(() => {
+//     simulatePumpData.value = [Math.floor(Math.random() * 4)+1, Math.floor(Math.random() * 5000) + 1];
+//     console.log('模拟泵数据:', simulatePumpData.value);
+// }, 1000);
 onBeforeUnmount(() => {
     // 页面销毁时取消订阅
     stompClient.unsubscribeFromPage(pageCode);