Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

丁治程 2 kuukautta sitten
vanhempi
commit
409081eff9

+ 211 - 19
jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/service/impl/InterlockSummaryServiceImpl.java

@@ -11,6 +11,7 @@ import org.jeecg.modules.detail.convert.InterlockDetailConvert;
 import org.jeecg.modules.detail.dto.InterlockDetailAddDTO;
 import org.jeecg.modules.detail.entity.InterlockDetail;
 import org.jeecg.modules.detail.mapper.InterlockDetailMapper;
+import org.jeecg.modules.detail.service.IInterlockDetailService;
 import org.jeecg.modules.detail.vo.InterlockDetailEditQueryVO;
 import org.jeecg.modules.iotedgeCollectData.entity.IotedgeCollectData;
 import org.jeecg.modules.iotedgeCollectData.service.IIotedgeCollectDataService;
@@ -29,6 +30,7 @@ import org.jeecg.modules.temp.entity.InterlockDetailTemp;
 import org.jeecg.modules.temp.entity.InterlockSummaryTemp;
 import org.jeecg.modules.temp.mapper.InterlockDetailTempMapper;
 import org.jeecg.modules.temp.mapper.InterlockSummaryTempMapper;
+import org.jeecg.modules.temp.service.IInterlockDetailTempService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -62,9 +64,15 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
     private InterlockDetailTempMapper detailTempMapper;
     @Autowired
     @SuppressWarnings("all")
+    private IInterlockDetailTempService interlockDetailTempService;
+    @Autowired
+    @SuppressWarnings("all")
     private InterlockDetailMapper interlockDetailMapper;
     @Autowired
     @SuppressWarnings("all")
+    private IInterlockDetailService interlockDetailService;
+    @Autowired
+    @SuppressWarnings("all")
     private InterlockBaseMapper interlockBaseMapper;
     @Autowired
     @SuppressWarnings("all")
@@ -200,7 +208,6 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
     /**
      *   联锁管理——编辑联锁
      */
-
     @Transactional(rollbackFor = Exception.class)
     public void editLS(InterlockAddDTO interlockAddDTO){
         // 获取当前日期时间
@@ -236,22 +243,37 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
         String instrumentStatus = instrumentStatusNormal;// 总体 先设置为 仪表状态-正常
 
 
-        //删除该联锁的所有联锁详细信息的所有点位
-        LambdaQueryWrapper<InterlockTag> queryWrapper3 = new LambdaQueryWrapper<>();
-        queryWrapper3.eq(InterlockTag::getInterlockSummaryId, summaryId);
-        interlockTagService.remove(queryWrapper3);
-        //删除该联锁下所有联锁详细信息
-        LambdaQueryWrapper<InterlockDetail> queryWrapper1 = new LambdaQueryWrapper<>();
-        queryWrapper1.eq(InterlockDetail::getSummaryid,summaryId);
-        interlockDetailMapper.delete(queryWrapper1);
-        //删除该联锁对应的联锁详细信息临时表数据
-        LambdaQueryWrapper<InterlockDetailTemp> queryWrapper2= new LambdaQueryWrapper<>();
-        queryWrapper2.eq(InterlockDetailTemp::getSummaryid,summaryId);
-        detailTempMapper.delete(queryWrapper2);
-
+//        //删除该联锁的所有联锁详细信息的所有点位
+//        LambdaQueryWrapper<InterlockTag> queryWrapper3 = new LambdaQueryWrapper<>();
+//        queryWrapper3.eq(InterlockTag::getInterlockSummaryId, summaryId);
+//        interlockTagService.remove(queryWrapper3);
+//        //删除该联锁下所有联锁详细信息
+//        LambdaQueryWrapper<InterlockDetail> queryWrapper1 = new LambdaQueryWrapper<>();
+//        queryWrapper1.eq(InterlockDetail::getSummaryid,summaryId);
+//        interlockDetailMapper.delete(queryWrapper1);
+//        //删除该联锁对应的联锁详细信息临时表数据
+//        LambdaQueryWrapper<InterlockDetailTemp> queryWrapper2= new LambdaQueryWrapper<>();
+//        queryWrapper2.eq(InterlockDetailTemp::getSummaryid,summaryId);
+//        detailTempMapper.delete(queryWrapper2);
+
+        //修改之后的数据列表
+        List<InterlockTag> interlockTagListNew = new ArrayList<>();
+        List<InterlockDetail> interlockDetailListNew = new ArrayList<>();
+        List<InterlockDetailTemp> interlockDetailTempListNew = new ArrayList<>();
+
+        //修改——联锁输出值点位
+//        for(InterlockTag interlockTag:interlockTagListOrg){
+//            if(InterlockConstants.INTERLOCK_OUT_VALUE.equals(interlockTag.getParameterType())){
+//                interlockTag.setDeviceId(interlockAddDTO.getDeviceId());
+//                interlockTag.setModuleName(interlockAddDTO.getModuleName());
+//                interlockTag.setTagValue(interlockAddDTO.getInterlockOutValueTag());
+//                interlockTagListNew.add(interlockTag);//添加修改之后的联锁输出值点位信息
+//                break;
+//            }
+//        }
+//        interlockTagService.save(createInterlockTag(interlockAddDTO.getDeviceId(),interlockAddDTO.getModuleName(), interlockAddDTO.getInterlockOutValueTag(), interlockAddDTO.getInterlockOutValue(), InterlockConstants.INTERLOCK_OUT_VALUE,summaryId,summaryId));
+        interlockTagListNew.add(createInterlockTag(interlockAddDTO.getDeviceId(),interlockAddDTO.getModuleName(), interlockAddDTO.getInterlockOutValueTag(), interlockAddDTO.getInterlockOutValue(), InterlockConstants.INTERLOCK_OUT_VALUE,summaryId,summaryId));
 
-        //新增——联锁输出值点位
-        interlockTagService.save(createInterlockTag(interlockAddDTO.getDeviceId(),interlockAddDTO.getModuleName(), interlockAddDTO.getInterlockOutValueTag(), interlockAddDTO.getInterlockOutValue(), InterlockConstants.INTERLOCK_OUT_VALUE,summaryId,summaryId));
 
         for (InterlockDetailAddDTO dto : interlockDetailAddDTOList){
 
@@ -331,15 +353,35 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
             InterlockDetail detail = InterlockDetailConvert.INSTANCE.toEntity(dto, interlockAddDTO.getInterlockName(),formattedDateTime, interlockAddDTO.getInterlockSystemId());
 
             //新增联锁详细信息表数据
-            interlockDetailMapper.insert(detail);
+//            interlockDetailMapper.insert(detail);
+            interlockDetailListNew.add(detail);
             //新增联锁详细信息表临时表数据
             InterlockDetailTemp detailTemp = TempConvert.INSTANCE.toInterlockDetailTemp(detail);
-            detailTempMapper.insert(detailTemp);
+//            detailTempMapper.insert(detailTemp);
+            interlockDetailTempListNew.add(detailTemp);
 
             //新增对应联锁详细信息的点位列表
-            interlockTagService.saveBatch(toTagList(instrumentStatusNormal, dto,detail.getId(),summaryId));
+//            interlockTagService.saveBatch(toTagList(instrumentStatusNormal, dto,detail.getId(),summaryId));
+            interlockTagListNew.addAll(toTagList(instrumentStatusNormal, dto,detail.getId(),summaryId));
         }
 
+        //删除该联锁的所有联锁详细信息的所有点位
+        LambdaQueryWrapper<InterlockTag> queryWrapper3 = new LambdaQueryWrapper<>();
+        queryWrapper3.eq(InterlockTag::getInterlockSummaryId, summaryId);
+        interlockTagService.remove(queryWrapper3);
+        //删除该联锁下所有联锁详细信息
+        LambdaQueryWrapper<InterlockDetail> queryWrapper1 = new LambdaQueryWrapper<>();
+        queryWrapper1.eq(InterlockDetail::getSummaryid,summaryId);
+        interlockDetailMapper.delete(queryWrapper1);
+        //删除该联锁对应的联锁详细信息临时表数据
+        LambdaQueryWrapper<InterlockDetailTemp> queryWrapper2= new LambdaQueryWrapper<>();
+        queryWrapper2.eq(InterlockDetailTemp::getSummaryid,summaryId);
+        detailTempMapper.delete(queryWrapper2);
+
+        interlockTagService.saveBatch(interlockTagListNew);
+        interlockDetailService.saveBatch(interlockDetailListNew);
+        interlockDetailTempService.saveBatch(interlockDetailTempListNew);
+
         //回路健康等级
         loopHealthLevel = getLHL(instrumentStatus, instrumentStatusAbnormal,interlockStatus, interlockStatusWty, controlSystemStatus, controlSystemStatusAbnormal);
 
@@ -351,6 +393,156 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
         summaryTempMapper.updateById(interlockSummaryTemp);
     }
 
+//    @Transactional(rollbackFor = Exception.class)
+//    public void editLS(InterlockAddDTO interlockAddDTO){
+//        // 获取当前日期时间
+//        LocalDateTime currentDateTime = LocalDateTime.now();
+//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+//        String formattedDateTime = currentDateTime.format(formatter);
+//        interlockAddDTO.setTagTime(formattedDateTime);
+//
+//        String summaryId = interlockAddDTO.getId();
+//
+//        List<InterlockDetailAddDTO> interlockDetailAddDTOList = interlockAddDTO.getInterlockDetailAddDTOList();
+//
+//        // 系统设置的各状态
+//        InterlockBase base = interlockBaseService.getById(interlockAddDTO.getInterlockSystemId());
+//        // 控制系统状态(输入卡件状态、输出卡件状态、MP状态)
+//        String controlSystemStatusNormal = base.getControlSystemStatusNormal(); // 正常
+//        String controlSystemStatusAbnormal = editStatus(base.getControlSystemStatusNormal()); // 非正常
+//        // 旁路状态
+//        String bypassYes = base.getBypassYes(); // 否 无旁路
+//        String bypassNo = editStatus(base.getBypassYes()); // 是  有旁路
+//        // 仪表状态
+//        String instrumentStatusNormal = base.getInstrumentStatusNormal(); // 正常
+//        String instrumentStatusAbnormal = editStatus(base.getInstrumentStatusNormal()); // 正常
+//        // 联锁状态
+//        String interlockStatusTy = base.getInterlockStatusTy(); // 投用
+//        String interlockStatusWty = editStatus(base.getInterlockStatusTy()); // 未投用
+//
+//
+//        String interlockStatus = interlockStatusTy;;//	先设置为 联锁状态-投用
+//        String loopHealthLevel = "A";// 回路健康级别
+//
+//        String controlSystemStatus = controlSystemStatusNormal;// 总体 先设置为 控制系统状态-正常
+//        String instrumentStatus = instrumentStatusNormal;// 总体 先设置为 仪表状态-正常
+//
+//
+//        //删除该联锁的所有联锁详细信息的所有点位
+//        LambdaQueryWrapper<InterlockTag> queryWrapper3 = new LambdaQueryWrapper<>();
+//        queryWrapper3.eq(InterlockTag::getInterlockSummaryId, summaryId);
+//        interlockTagService.remove(queryWrapper3);
+//        //删除该联锁下所有联锁详细信息
+//        LambdaQueryWrapper<InterlockDetail> queryWrapper1 = new LambdaQueryWrapper<>();
+//        queryWrapper1.eq(InterlockDetail::getSummaryid,summaryId);
+//        interlockDetailMapper.delete(queryWrapper1);
+//        //删除该联锁对应的联锁详细信息临时表数据
+//        LambdaQueryWrapper<InterlockDetailTemp> queryWrapper2= new LambdaQueryWrapper<>();
+//        queryWrapper2.eq(InterlockDetailTemp::getSummaryid,summaryId);
+//        detailTempMapper.delete(queryWrapper2);
+//
+//
+//        //新增——联锁输出值点位
+//        interlockTagService.save(createInterlockTag(interlockAddDTO.getDeviceId(),interlockAddDTO.getModuleName(), interlockAddDTO.getInterlockOutValueTag(), interlockAddDTO.getInterlockOutValue(), InterlockConstants.INTERLOCK_OUT_VALUE,summaryId,summaryId));
+//
+//        for (InterlockDetailAddDTO dto : interlockDetailAddDTOList){
+//
+//            dto.setThresholdTimeUnit("s"); // TODO 暂定单位为秒
+//            dto.setSummaryid(summaryId);
+//
+//
+////            //联锁状态; 旁路状态是多个的话,任何一个旁路状态为“是”,则联锁状态是“未投用(摘除)”,旁路状态都为“否”,则联锁状态是“投用”。
+////            if(dto.getBypass()!=null && bypassYes.equals(dto.getBypass())) interlockStatus = interlockStatusWty;
+//            //联锁状态:旁路状态多个的话,任何一个旁路状态是故障状态,则联锁状态是故障状态,如果旁路状态都是正常状态,则联锁状态是正常状态
+//            if(dto.getBypass()!=null && bypassNo.equals(dto.getBypass())) interlockStatus = interlockStatusWty;
+//
+//            //仪表状态
+//            if(dto.getInstrumentStatusJuge()!=null){
+//                if(InterlockAllStatus.INSTRUMENT_STATUS_JUDGE0.equals(dto.getInstrumentStatusJuge())){
+//                    //0直接读取位号
+//                    dto.setInstrumentStatus(dto.getInstrumentStatusValue());
+//                } else if(InterlockAllStatus.INSTRUMENT_STATUS_JUDGE1.equals(dto.getInstrumentStatusJuge())){
+//                    //1高低限判断
+//                    BigDecimal ysmnlValue = new BigDecimal(dto.getYsmnlValue());
+//                    BigDecimal lowerLimit = new BigDecimal(dto.getLowerLimit());
+//                    BigDecimal upperLimit = new BigDecimal(dto.getUpperLimit());
+//                    if(ysmnlValue.compareTo(lowerLimit) >= 0 && ysmnlValue.compareTo(upperLimit) <= 0) dto.setInstrumentStatus(instrumentStatusNormal); // 正常
+//                    else dto.setInstrumentStatus(instrumentStatusAbnormal); // 故障
+//
+//                } else if(InterlockAllStatus.INSTRUMENT_STATUS_JUDGE2.equals(dto.getInstrumentStatusJuge())){ //2突变超限判断
+//                    //通过判断原始模拟量位号突变(与iotedge_collect_data表的数据进行比较)超过某阈值得出值
+//                    // 去采集数据表中根据 设备id+模块名称+点位名称 查询设置的s之前的数据
+//                    String yz = dto.getThresholdValue();  // 阈值
+//                    String time = dto.getThresholdTime();  // 规定的时间
+//                    String dw = dto.getThresholdTimeUnit();   // 时间单位
+//
+//                    if ("s".equals(dw)){
+//                        // 本次原始模拟量值
+//                        BigDecimal ysmnlValue = new BigDecimal(dto.getYsmnlValue());
+//
+//                        // 查询上一次原始模拟量值
+//                        String endDate = DateUtils.getDate("yyyy-MM-dd HH:mm:ss");  // 当前时间 规定时间的结束时间
+//                        LocalDateTime endDateTime = LocalDateTime.parse(endDate, formatter);
+//                        LocalDateTime beginDateTime = endDateTime.minus(Duration.ofSeconds(Long.parseLong(time)));
+//                        String beginDate = beginDateTime.format(formatter);  // 开始时间 规定时间的开始时间
+//
+//                        IotedgeCollectData iotedgeData = iotedgeCollectDataService.getOneInfo(dto.getYsmnlDeviceId(),dto.getYsmnlModuleName(),dto.getYsmnlTag(),beginDate);
+//                        BigDecimal beginValue = new BigDecimal(iotedgeData.getValue());
+//                        BigDecimal num = ysmnlValue.subtract(beginValue);
+//
+//                        // (高限-底限) * 阈值  (数据库中的阈值是去掉百分比的直接乘即可)
+//                        BigDecimal lowerLimit = new BigDecimal(dto.getLowerLimit());
+//                        BigDecimal upperLimit = new BigDecimal(dto.getUpperLimit());
+//
+//                        BigDecimal number = upperLimit.subtract(lowerLimit);
+//                        BigDecimal newYz = number.multiply(new BigDecimal(yz));
+////                        if ((num.divide(beginValue).compareTo(newYz)) > 0){
+////                            dto.setInstrumentStatus(instrumentStatusAbnormal); // 故障
+////                        }else dto.setInstrumentStatus(instrumentStatusNormal); // 正常
+//                        //有可能出现无限循环小数,保留三位小数
+//                        if ((num.divide(beginValue,2,RoundingMode.HALF_UP).compareTo(newYz)) > 0){
+//                            dto.setInstrumentStatus(instrumentStatusAbnormal); // 故障
+//                        }else dto.setInstrumentStatus(instrumentStatusNormal); // 正常
+//                    }
+//
+//
+//                } else if(InterlockAllStatus.INSTRUMENT_STATUS_JUDGE3.equals(dto.getInstrumentStatusJuge())){
+//                    //3默认正常
+//                    dto.setInstrumentStatus(instrumentStatusNormal);
+//                }
+//
+//                if(dto.getInstrumentStatus()!=null && dto.getInstrumentStatus().equals(instrumentStatusAbnormal)) instrumentStatus = instrumentStatusAbnormal;
+//            }
+//
+//            //控制系统状态 ——  MP状态、输入卡件状态、输出卡件状态任何一个非正常则控制系统状态非正常。
+//            if(controlSystemStatusAbnormal.equals(dto.getMpStatus()) || controlSystemStatusAbnormal.equals(dto.getInputStatus()) || controlSystemStatusAbnormal.equals(dto.getOutputStatus())) {
+//                dto.setControlSystemStatus(controlSystemStatusAbnormal); // 非正常
+//                controlSystemStatus = controlSystemStatusAbnormal;
+//            } else dto.setControlSystemStatus(controlSystemStatusNormal); // 正常
+//
+//            InterlockDetail detail = InterlockDetailConvert.INSTANCE.toEntity(dto, interlockAddDTO.getInterlockName(),formattedDateTime, interlockAddDTO.getInterlockSystemId());
+//
+//            //新增联锁详细信息表数据
+//            interlockDetailMapper.insert(detail);
+//            //新增联锁详细信息表临时表数据
+//            InterlockDetailTemp detailTemp = TempConvert.INSTANCE.toInterlockDetailTemp(detail);
+//            detailTempMapper.insert(detailTemp);
+//
+//            //新增对应联锁详细信息的点位列表
+//            interlockTagService.saveBatch(toTagList(instrumentStatusNormal, dto,detail.getId(),summaryId));
+//        }
+//
+//        //回路健康等级
+//        loopHealthLevel = getLHL(instrumentStatus, instrumentStatusAbnormal,interlockStatus, interlockStatusWty, controlSystemStatus, controlSystemStatusAbnormal);
+//
+//        InterlockSummary interlockSummary = InterlockSummaryConvert.INSTANCE.toInterlockSummary1(interlockAddDTO,interlockStatus,loopHealthLevel);
+//        //修改联锁总表数据
+//        interlockSummaryMapper.updateById(interlockSummary);
+//        //修改联锁总表临时表数据
+//        InterlockSummaryTemp interlockSummaryTemp = TempConvert.INSTANCE.toInterlockSummaryTemp(interlockSummary);
+//        summaryTempMapper.updateById(interlockSummaryTemp);
+//    }
+
     /**
      *   联锁管理——新增联锁
      */