hfxc226 2 роки тому
батько
коміт
dc5d5b39eb

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

@@ -57,7 +57,7 @@ public class RemoteOpcDTO extends BaseDTO implements Serializable {
      * id
      */
     @NotNull(groups = {UpdateGroup.class}, message = "ID不能为空")
-    private String id;
+    private Integer id;
     /**
      * 设备id
      */

+ 1 - 1
platform-dao/src/main/java/com/platform/dao/dto/remote/RemoteOpcLogDTO.java

@@ -43,7 +43,7 @@ public class RemoteOpcLogDTO extends BaseDTO implements Serializable {
     /**
      * 点位
      */
-    private Integer positionNum;
+    private String positionNum;
     /**
      * 年
      */

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

@@ -57,7 +57,7 @@ public class RemoteOpc implements Serializable {
      * id
      */
     @Id
-    private String id;
+    private Integer id;
     /**
      * 设备id
      */

+ 1 - 1
platform-dao/src/main/java/com/platform/dao/entity/remote/RemoteOpcLog.java

@@ -38,7 +38,7 @@ public class RemoteOpcLog implements Serializable {
     /**
      * 点位
      */
-    private Integer positionNum;
+    private String positionNum;
     /**
      * 年
      */

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

@@ -1109,13 +1109,13 @@ public class CustomExcelImportUtil {
             try {
                 //i,j i:行 j:列
                 record.setId(IdGeneratorUtils.getObjectId());
-                record.setPositionNum(getCellValue(row.getCell(0)));
+                record.setDescription(getCellValue(row.getCell(0)));// 加上后缀才是点位positionNum
                 if(StringUtils.isBlank(record.getPositionNum())){
                     continue;
                 }
                 record.setSbName(getCellValue(row.getCell(1)));
                 record.setRemark(getCellValue(row.getCell(2)));
-                record.setDescription(getCellValue(row.getCell(3)));
+                //record.setDescription(getCellValue(row.getCell(3)));
                 record.setUnit(getCellValue(row.getCell(4)).trim());
             } catch (Exception e) {
                 e.printStackTrace();

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

@@ -22,7 +22,7 @@ public class ExportRemoteOpcVO implements Serializable {
      * id
      */
     @Excel(name = "id")
-    private String id;
+    private Integer id;
 
     /**
      * 设备id

+ 1 - 1
platform-dao/src/main/java/com/platform/dao/vo/query/remote/RemoteOpcLogVO.java

@@ -43,7 +43,7 @@ public class RemoteOpcLogVO extends BaseVO implements Serializable {
     /**
      * 点位
      */
-    private Integer positionNum;
+    private String positionNum;
     /**
      * 类型:1正向有功,2正向无功
      */

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

@@ -54,7 +54,7 @@ public class RemoteOpcVO extends BaseVO implements Serializable {
     /**
      * id
      */
-    private String id;
+    private Integer id;
     /**
      * 设备id
      */

+ 8 - 0
platform-opc/src/main/java/com/platform/opc/servie/OpcTaskService.java

@@ -6,6 +6,7 @@ import com.platform.common.util.BeanUtils;
 import com.platform.common.util.RedisUtils;
 import com.platform.common.util.StringUtils;
 import com.platform.dao.entity.remote.RemoteOpc;
+import com.platform.dao.entity.remote.RemoteOpcLog;
 import com.platform.dao.mapper.remote.RemoteOpcMapper;
 import com.platform.dao.mapper.upms.SysDictMapper;
 import com.platform.opc.entity.OpcResult;
@@ -70,6 +71,13 @@ public class OpcTaskService {
             /*for(OpcResult result: resultList){
                 log.info("id: " + result.getId() + ", value: " + result.getValue() + ", time: " + result.getTime());
             }*/
+            // 保存入库
+            for(OpcResult result: resultList){
+                RemoteOpcLog remoteOpcLog = new RemoteOpcLog();
+                remoteOpcLog.setPositionNum(result.getId());
+                log.info("id: " + result.getId() + ", value: " + result.getValue() + ", time: " + result.getTime());
+            }
+
         }
         log.info("结束读取redis");
     }

+ 45 - 0
platform-service/src/main/java/com/platform/service/remote/impl/RemoteOpcServiceImpl.java

@@ -40,6 +40,50 @@ public class RemoteOpcServiceImpl extends BaseServiceImpl<RemoteOpcMapper, Remot
 
     private final SysDictMapper sysDictMapper;
 
+    /**
+     * 检查av状态和点位后缀是否一致
+     * 1: avFalg=1,则点位后缀必须是_AV
+     * 2: avFalg=0,则点位后缀必须是_DV
+     * *
+     * @param model
+     * @return
+     */
+    @Override
+    public RemoteOpc saveModelByDTO(RemoteOpcDTO model) {
+        if(model.getAvFlag()==1){
+            if(model.getPositionNum().lastIndexOf("_AV")<0){
+                throw new BusinessException("模拟量的点位后缀必须是_AV,请检查");
+            }
+        }else{
+            if(model.getPositionNum().lastIndexOf("_DV")<0){
+                throw new BusinessException("数字量的点位后缀必须是_DV,请检查");
+            }
+        }
+        return super.saveModelByDTO(model);
+    }
+
+    /**
+     * 检查av状态和点位后缀是否一致
+     * 1: avFalg=1,则点位后缀必须是_AV
+     * 2: avFalg=0,则点位后缀必须是_DV
+     * *
+     * @param model
+     * @return
+     */
+    @Override
+    public void modModelByDTO(RemoteOpcDTO model) {
+        if(model.getAvFlag()==1){
+            if(model.getPositionNum().lastIndexOf("_AV")<0){
+                throw new BusinessException("模拟量的点位后缀必须是_AV,请检查");
+            }
+        }else{
+            if(model.getPositionNum().lastIndexOf("_DV")<0){
+                throw new BusinessException("数字量的点位后缀必须是_DV,请检查");
+            }
+        }
+        super.modModelByDTO(model);
+    }
+
     @Override
     public int batchDelete(List<String> ids) {
         Weekend<RemoteOpc> weekend = new Weekend<>(RemoteOpc.class);
@@ -91,6 +135,7 @@ public class RemoteOpcServiceImpl extends BaseServiceImpl<RemoteOpcMapper, Remot
                     remoteOpc.setType(1);
                     remoteOpc.setLine(line);
                     remoteOpc.setAvFlag(YesNoEnum.YES.getValue());
+                    remoteOpc.setPositionNum(remoteOpc.getDescription() + "_AV");// 初始化都是AV,也可以导入的时候配置好
                     remoteOpc.setCreatedFlag(YesNoEnum.NO.getValue());
                     remoteOpc.setPositionFlag(YesNoEnum.NO.getValue());
                    /* boolean find = false;