瀏覽代碼

opc完善

hfxc226 2 年之前
父節點
當前提交
a9acdd5171

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

@@ -1114,8 +1114,8 @@ public class CustomExcelImportUtil {
                     continue;
                 }
                 record.setSbName(getCellValue(row.getCell(1)));
-                record.setRemark(getCellValue(row.getCell(2)));
-                //record.setDescription(getCellValue(row.getCell(3)));
+                record.setHigh(new BigDecimal(getCellValue(row.getCell(2))));
+                record.setLow(new BigDecimal(getCellValue(row.getCell(3))));
                 record.setUnit(getCellValue(row.getCell(4)).trim());
             } catch (Exception e) {
                 e.printStackTrace();

+ 0 - 2
platform-opc/src/main/java/com/platform/opc/servie/OpcService.java

@@ -94,8 +94,6 @@ public class OpcService {
         if (!CollectionUtils.isEmpty(remoteOpcFailList)) {
             remoteOpcMapper.updateBatch(remoteOpcFailList);
         }
-        // 启动分组,按照车间line分组
-        RedisUtils.set("test", 1);
     }
 
     public static void main(String[] args) {

+ 50 - 19
platform-service/src/main/java/com/platform/service/remote/impl/RemoteOpcServiceImpl.java

@@ -45,19 +45,37 @@ public class RemoteOpcServiceImpl extends BaseServiceImpl<RemoteOpcMapper, Remot
      * 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){
+        // 新增判断点位是否已经存在了
+        Weekend<RemoteOpc> weekend = new Weekend<>(RemoteOpc.class);
+        WeekendCriteria<RemoteOpc, Object> weekendCriteria = weekend.weekendCriteria();
+        weekendCriteria.andEqualTo(RemoteOpc::getDescription, model.getDescription());
+        int count = mapper.selectCountByExample(weekend);
+        // 不存在在设置点位信息
+        if (count > 0) {
+            throw new BusinessException("该点位已经存在,无法新增,数量:" + count);
+        }
+        if (model.getAvFlag() == YesNoEnum.YES.getValue()) {
+            model.setPositionNum(model.getDescription() + "_AV");
+              /* if (model.getPositionNum().lastIndexOf("_AV") < 0) {
                 throw new BusinessException("模拟量的点位后缀必须是_AV,请检查");
-            }
-        }else{
-            if(model.getPositionNum().lastIndexOf("_DV")<0){
+            }*/
+        } else {
+            model.setPositionNum(model.getDescription() + "_DV");
+           /* if (model.getPositionNum().lastIndexOf("_DV") < 0) {
                 throw new BusinessException("数字量的点位后缀必须是_DV,请检查");
-            }
+            }*/
+        }
+        if (model.getXPosition() == null) {
+            model.setXPosition(50);
+        }
+        if (model.getYPosition() == null) {
+            model.setYPosition(50);
         }
         return super.saveModelByDTO(model);
     }
@@ -67,20 +85,32 @@ public class RemoteOpcServiceImpl extends BaseServiceImpl<RemoteOpcMapper, Remot
      * 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,请检查");
+        // 新增判断点位是否已经存在了
+        Weekend<RemoteOpc> weekend = new Weekend<>(RemoteOpc.class);
+        WeekendCriteria<RemoteOpc, Object> weekendCriteria = weekend.weekendCriteria();
+        weekendCriteria.andEqualTo(RemoteOpc::getDescription, model.getDescription());
+        List<RemoteOpc> list = mapper.selectByExample(weekend);
+        // 不存在在设置点位信息
+        if (!CollectionUtils.isEmpty(list)) {
+            if (list.size() > 1) {
+                throw new BusinessException("该点位已经重复,无法修改:" + list.size());
+            } else {
+                if (!list.get(0).getId().equals(model.getId())) {
+                    throw new BusinessException("该点位已经重复,无法修改");
+                }
             }
         }
+        if (model.getAvFlag() == YesNoEnum.YES.getValue()) {
+            model.setPositionNum(model.getDescription() + "_AV");
+        } else {
+            model.setPositionNum(model.getDescription() + "_DV");
+        }
         super.modModelByDTO(model);
     }
 
@@ -124,7 +154,7 @@ public class RemoteOpcServiceImpl extends BaseServiceImpl<RemoteOpcMapper, Remot
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String importListByAdd(MultipartFile file, String line) {
-        if(line == null){
+        if (line == null) {
             line = "1";
         }
         Weekend<SysDict> weekend = new Weekend<>(SysDict.class);
@@ -160,7 +190,7 @@ public class RemoteOpcServiceImpl extends BaseServiceImpl<RemoteOpcMapper, Remot
                         throw new BusinessException("opc数据类型未配置,请配置数据字典:" + remoteOpc.getRemark());
                     }*/
                 }
-               // sbInfoMapper.insertListforComplex(addSbInfoList);
+                // sbInfoMapper.insertListforComplex(addSbInfoList);
                 mapper.insertListforComplex(items);
             }
             return "总计新增导入:" + (items.size());
@@ -173,6 +203,7 @@ public class RemoteOpcServiceImpl extends BaseServiceImpl<RemoteOpcMapper, Remot
     /**
      * 批量更新
      * updateType 1:更新模拟,其他:更新是否配置
+     *
      * @param ids
      * @param updateType
      * @param value
@@ -183,17 +214,17 @@ public class RemoteOpcServiceImpl extends BaseServiceImpl<RemoteOpcMapper, Remot
         WeekendCriteria<RemoteOpc, Object> weekendCriteria = weekend.weekendCriteria();
         weekendCriteria.andIn(RemoteOpc::getId, ids);
         RemoteOpc remoteOpc = new RemoteOpc();
-        if(updateType==1){
+        if (updateType == 1) {
             remoteOpc.setAvFlag(value);
-        }else{
+        } else {
             remoteOpc.setCreatedFlag(value);
         }
         mapper.updateByExampleSelective(remoteOpc, weekend);
     }
 
     public static void main(String[] args) {
-        for(int i=0;i<100;i++){
-            System.out.println((int)((Math.random()*6)+1));
+        for (int i = 0; i < 100; i++) {
+            System.out.println((int) ((Math.random() * 6) + 1));
         }
     }
 }