Bladeren bron

opc增加量程信息

hfxc226 2 jaren geleden
bovenliggende
commit
67248353e3

+ 9 - 0
platform-dao/src/main/java/com/platform/dao/dto/remote/RemoteOpcDTO.java

@@ -53,6 +53,15 @@ public class RemoteOpcDTO extends BaseDTO implements Serializable {
      * json数据
      */
     private String info;
+    /**
+     * 量程:最低
+     */
+    private BigDecimal low;
+    /**
+     * 量程:最高
+     */
+    private BigDecimal high;
+
     /**
      * id
      */

+ 8 - 0
platform-dao/src/main/java/com/platform/dao/entity/remote/RemoteOpc.java

@@ -41,6 +41,14 @@ public class RemoteOpc implements Serializable {
      * 位置高度
      */
     private Integer height;
+    /**
+     * 量程:最低
+     */
+    private BigDecimal low;
+    /**
+     * 量程:最高
+     */
+    private BigDecimal high;
     /**
      * 是否模拟量:0否1是
      */

+ 1 - 1
platform-dao/src/main/java/com/platform/dao/util/CustomExcelImportUtil.java

@@ -1108,7 +1108,7 @@ public class CustomExcelImportUtil {
             String index = getCellValue(row.getCell(0)) + "";
             try {
                 //i,j i:行 j:列
-                record.setId(IdGeneratorUtils.getObjectId());
+                // record.setId(IdGeneratorUtils.getObjectId());
                 record.setDescription(getCellValue(row.getCell(0)));// 加上后缀才是点位positionNum
                 if(StringUtils.isBlank(record.getPositionNum())){
                     continue;

+ 17 - 6
platform-dao/src/main/java/com/platform/dao/vo/export/remote/ExportRemoteOpcVO.java

@@ -9,7 +9,7 @@ import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
 /**
- * @Description 设备遥测对应表导出VO
+ * @Description 遥测对应表导出VO
  * @Author xc
  * @Date 2022-09-13 14:15:40
  * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
@@ -25,15 +25,15 @@ public class ExportRemoteOpcVO implements Serializable {
     private Integer id;
 
     /**
-     * 设备id
+     * id
      */
-    @Excel(name = "设备id")
+    @Excel(name = "id")
     private String sbId;
 
     /**
-     * 设备名称
+     * 名称
      */
-    @Excel(name = "设备名称")
+    @Excel(name = "名称")
     private String sbName;
 
     /**
@@ -45,7 +45,7 @@ public class ExportRemoteOpcVO implements Serializable {
     /**
      * 线路
      */
-    @Excel(name = "线路")
+    @Excel(name = "车间")
     private Integer line;
 
     /**
@@ -77,6 +77,17 @@ public class ExportRemoteOpcVO implements Serializable {
      */
     @Excel(name = "单位")
     private String unit;
+
+    /**
+     * 量程:最低
+     */
+    @Excel(name = "量程下限")
+    private BigDecimal low;
+    /**
+     * 量程:最高
+     */
+    @Excel(name = "量程上限")
+    private BigDecimal high;
     /**
      * 是否模拟量:0否1是
      */

+ 8 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/remote/RemoteOpcVO.java

@@ -39,6 +39,14 @@ public class RemoteOpcVO extends BaseVO implements Serializable {
      * 位置高度
      */
     private Integer height;
+    /**
+     * 量程:最低
+     */
+    private BigDecimal low;
+    /**
+     * 量程:最高
+     */
+    private BigDecimal high;
     /**
      * 是否模拟量:0否1是
      */

+ 4 - 0
platform-dao/src/main/resources/mapper/remote/RemoteOpcMapper.xml

@@ -11,6 +11,8 @@
                                      opc.position_num,
                                      opc.line,
                                      opc.type,
+                                     opc.low,
+                                     opc.high,
                                      opc.description,
                                      opc.result,
                                      opc.av_flag,
@@ -36,6 +38,8 @@
                                      opc.line,
                                      opc.type,
                                      opc.info,
+                                     opc.low,
+                                     opc.high,
                                      opc.description,
                                      opc.result,
                                      opc.av_flag,

+ 14 - 6
platform-opc/src/main/java/com/platform/opc/servie/OpcTaskService.java

@@ -39,6 +39,7 @@ import java.util.stream.Collectors;
 @EnableAsync
 public class OpcTaskService {
 
+    private final RemoteOpcMapper remoteOpcMapper;
     private final RemoteOpcLogMapper remoteOpcLogMapper;
 
     /**
@@ -51,10 +52,19 @@ public class OpcTaskService {
         log.info("开始定时任务");
         List<OpcResult> resultList = OpcDAClient.getItemValuesList();
         if (!CollectionUtils.isEmpty(resultList)) {
-            log.info("resultList数量:" + resultList.size());
-            String str = JSON.toJSONString(resultList);
-            //log.info("str: " + str);
-            RedisUtils.setString("opcList", str);
+            //log.info("resultList数量:" + resultList.size());
+            RedisUtils.setString("opcList", JSON.toJSONString(resultList));
+            // 更新数据库实时数据
+            List<RemoteOpc> remoteOpcList = new ArrayList<>();
+            LocalDateTime localDateTime = LocalDateTime.now();
+            for (OpcResult result : resultList) {
+                RemoteOpc remoteOpc = new RemoteOpc();
+                remoteOpc.setResult(result.getValue());
+                remoteOpc.setPositionNum(result.getId());
+                remoteOpc.setUpdateTime(localDateTime);
+                remoteOpcList.add(remoteOpc);
+            }
+            remoteOpcMapper.updateBatch(remoteOpcList);
         }
         log.info("结束定时任务");
     }
@@ -72,9 +82,7 @@ public class OpcTaskService {
         log.info("开始读取redis");
         String jsonStr = RedisUtils.getString("opcList");
         if (StringUtils.isNotBlank(jsonStr)) {
-            log.info("jsonStr2:" + jsonStr);
             List<OpcResult> resultList = JSON.parseArray(jsonStr, OpcResult.class);
-            log.info("resultList数量:" + resultList.size());
             /*for(OpcResult result: resultList){
                 log.info("id: " + result.getId() + ", value: " + result.getValue() + ", time: " + result.getTime());
             }*/