yangjunfeng 5 днів тому
батько
коміт
481c83eea7

+ 5 - 0
tofly-zhongmou-gas/service/zmourq/src/main/java/com/tofly/zmrq/custom/entity/ScadaStationDtuResult.java

@@ -32,6 +32,11 @@ public class ScadaStationDtuResult {
      */
     @ApiModelProperty(value = "站点名称|站点显示名称")
     private String dtuName;
+    /**
+     * 设备类型
+     */
+    @ApiModelProperty(value = "设备类型")
+    private String deviceType;
     /**
      * 站点描述|站点描述信息
      */

+ 1 - 1
tofly-zhongmou-gas/service/zmourq/src/main/java/com/tofly/zmrq/entity/DeviceArchiveManage.java

@@ -22,7 +22,7 @@ public class DeviceArchiveManage implements Serializable {
     /**
      * 
      */
-    @TableId(value = "ID",type= IdType.INPUT)
+    @TableId(value = "ID",type= IdType.ASSIGN_ID)
     private Long id;
 
     /**

+ 30 - 12
tofly-zhongmou-gas/service/zmourq/src/main/java/com/tofly/zmrq/mqtt/MqttMessageHandler.java

@@ -342,7 +342,11 @@ public class MqttMessageHandler implements MessageHandler {
         if (CollUtil.isNotEmpty(indexAllocationList)) {
             List<TfIndexAllocation> indexAllocationAll = indexAllocationService.list();
             List<String> indexCodeList = indexAllocationAll.stream().map(TfIndexAllocation::getVariableCode).collect(Collectors.toList());
-            indexAllocationList.forEach(info -> {
+            List<TfIndexAllocation> newIndexAllocationList = new ArrayList<>(indexAllocationList);
+            newIndexAllocationList = newIndexAllocationList.stream()
+                    .sorted(Comparator.comparing(TfIndexAllocation::getCreateTime).reversed())
+                    .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TfIndexAllocation::getVariableCode))), ArrayList::new));
+            newIndexAllocationList.forEach(info -> {
                 if (!indexCodeList.contains(info.getVariableCode())) {
                     indexAllocationService.save(info);
                 } else {
@@ -354,13 +358,18 @@ public class MqttMessageHandler implements MessageHandler {
 
         if (CollUtil.isNotEmpty(scadaDtuParModelList)) {
             List<ScadaDtuParModel> scadaDtuParModelAll = scadaDtuParModelService.list();
-            List<String> scadaDtuParModelDtuIdList = scadaDtuParModelAll.stream().map(ScadaDtuParModel::getDtuId).collect(Collectors.toList());
-            scadaDtuParModelList.forEach(info -> {
-                if (!scadaDtuParModelDtuIdList.contains(info.getDtuId())) {
+            List<String> scadaDtuParModelDtuIdList = scadaDtuParModelAll.stream().map(o -> o.getDtuId() + "-" + o.getFieldName()).collect(Collectors.toList());
+            List<ScadaDtuParModel> newScadaDtuParModelList = new ArrayList<>(scadaDtuParModelList);
+            newScadaDtuParModelList = newScadaDtuParModelList.stream()
+                    .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getDtuId() + "-" + o.getFieldName()))), ArrayList::new));
+            newScadaDtuParModelList.forEach(info -> {
+                if (!scadaDtuParModelDtuIdList.contains(info.getDtuId() + "-" + info.getFieldName())) {
                     scadaDtuParModelService.save(info);
                 } else {
                     scadaDtuParModelService.update(info,
-                            new QueryWrapper<ScadaDtuParModel>().lambda().eq(ScadaDtuParModel::getDtuId, info.getDtuId()));
+                            new QueryWrapper<ScadaDtuParModel>().lambda()
+                                    .eq(ScadaDtuParModel::getDtuId, info.getDtuId())
+                                    .eq(ScadaDtuParModel::getFieldName, info.getFieldName()));
                 }
             });
         }
@@ -375,7 +384,7 @@ public class MqttMessageHandler implements MessageHandler {
             scadaMapper.insertMouth(scadaHistoryList, tableName);
 
             // 更新实时数据
-            List<Scada> list = scadaHistoryList;
+            List<Scada> list = new ArrayList<>(scadaHistoryList);
             list = list.stream()
                     .sorted(Comparator.comparing(Scada::getScadaTime).reversed())
                     .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Scada::getCode))), ArrayList::new));
@@ -812,7 +821,11 @@ public class MqttMessageHandler implements MessageHandler {
         if (CollUtil.isNotEmpty(indexAllocationList)) {
             List<TfIndexAllocation> indexAllocationAll = indexAllocationService.list();
             List<String> indexCodeList = indexAllocationAll.stream().map(TfIndexAllocation::getVariableCode).collect(Collectors.toList());
-            indexAllocationList.forEach(info -> {
+            List<TfIndexAllocation> newIndexAllocationList = new ArrayList<>(indexAllocationList);
+            newIndexAllocationList = newIndexAllocationList.stream()
+                    .sorted(Comparator.comparing(TfIndexAllocation::getCreateTime).reversed())
+                    .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TfIndexAllocation::getVariableCode))), ArrayList::new));
+            newIndexAllocationList.forEach(info -> {
                 if (!indexCodeList.contains(info.getVariableCode())) {
                     indexAllocationService.save(info);
                 } else {
@@ -824,13 +837,18 @@ public class MqttMessageHandler implements MessageHandler {
 
         if (CollUtil.isNotEmpty(scadaDtuParModelList)) {
             List<ScadaDtuParModel> scadaDtuParModelAll = scadaDtuParModelService.list();
-            List<String> scadaDtuParModelDtuIdList = scadaDtuParModelAll.stream().map(ScadaDtuParModel::getDtuId).collect(Collectors.toList());
-            scadaDtuParModelList.forEach(info -> {
-                if (!scadaDtuParModelDtuIdList.contains(info.getDtuId())) {
+            List<String> scadaDtuParModelDtuIdList = scadaDtuParModelAll.stream().map(o -> o.getDtuId() + "-" + o.getFieldName()).collect(Collectors.toList());
+            List<ScadaDtuParModel> newScadaDtuParModelList = new ArrayList<>(scadaDtuParModelList);
+            newScadaDtuParModelList = newScadaDtuParModelList.stream()
+                    .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getDtuId() + "-" + o.getFieldName()))), ArrayList::new));
+            newScadaDtuParModelList.forEach(info -> {
+                if (!scadaDtuParModelDtuIdList.contains(info.getDtuId() + "-" + info.getFieldName())) {
                     scadaDtuParModelService.save(info);
                 } else {
                     scadaDtuParModelService.update(info,
-                            new QueryWrapper<ScadaDtuParModel>().lambda().eq(ScadaDtuParModel::getDtuId, info.getDtuId()));
+                            new QueryWrapper<ScadaDtuParModel>().lambda()
+                                    .eq(ScadaDtuParModel::getDtuId, info.getDtuId())
+                                    .eq(ScadaDtuParModel::getFieldName, info.getFieldName()));
                 }
             });
         }
@@ -845,7 +863,7 @@ public class MqttMessageHandler implements MessageHandler {
             scadaMapper.insertMouth(scadaHistoryList, tableName);
 
             // 更新实时数据
-            List<Scada> list = scadaHistoryList;
+            List<Scada> list = new ArrayList<>(scadaHistoryList);
             list = list.stream()
                     .sorted(Comparator.comparing(Scada::getScadaTime).reversed())
                     .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Scada::getCode))), ArrayList::new));

+ 9 - 0
tofly-zhongmou-gas/service/zmourq/src/main/java/com/tofly/zmrq/service/impl/ScadaDtuServiceImpl.java

@@ -61,6 +61,15 @@ public class ScadaDtuServiceImpl extends ServiceImpl<ScadaDtuMapper, ScadaDtu> i
                 if (data.getFieldName().contains("pressureMin")) {
                     data.setFieldShortDesc("压⼒最⼩值");
                 }
+                if (data.getFieldName().contains("ch4con")) {
+                    data.setFieldShortDesc("甲烷浓度");
+                }
+                if (data.getFieldName().contains("humidity")) {
+                    data.setFieldShortDesc("湿度");
+                }
+                if (data.getFieldName().contains("batteryVoltage")) {
+                    data.setFieldShortDesc("电池电压");
+                }
                 // 判断是否自定义报警开启
                 String flag = data.getFlag();
                 if (ComConstans.YES.equals(flag)) {

+ 3 - 0
tofly-zhongmou-gas/service/zmourq/src/main/resources/mapper/ScadaDtuMapper.xml

@@ -18,6 +18,7 @@
     <resultMap id="getRealDataMap" type="com.tofly.zmrq.custom.entity.ScadaStationDtuResult">
         <result property="dtuId" column="DTU_ID"/>
         <result property="deviceId" column="DEVICE_ID"/>
+        <result property="deviceType" column="DEVICE_TYPE"/>
         <result property="dtuName" column="DTU_NAME"/>
         <result property="dtuDesc" column="DTU_DESC"/>
         <result property="longitude" column="LONGITUDE"/>
@@ -70,10 +71,12 @@
                b.y LATITUDE,
                b.ptid DTU_ID,
                b.ptname DTU_NAME,
+               d.DEVICE_TYPE,
                c.FLAG,
                c.THRESHOLD_VALUE_MIN,
                c.THRESHOLD_VALUE_MAX
         from SCADAPNTS_STATIONS b
+        inner join TF_DEVICE_ARCHIVE_MANAGE d on d.CODE = b.PTID
         left join SCADA_REALDATA a on a.tag_explain = b.PTID
         left join SCADA_CUSTOM_ALARM c on c.FIELD_NAME = a.TAG
         where 1=1