|
@@ -1,11 +1,26 @@
|
|
|
package org.jeecg.modules.summary.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.jeecg.modules.base.mapper.InterlockBaseMapper;
|
|
|
+import org.jeecg.modules.base.service.IInterlockBaseService;
|
|
|
+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.summary.convert.InterlockSummaryConvert;
|
|
|
+import org.jeecg.modules.summary.dto.InterlockAddDTO;
|
|
|
import org.jeecg.modules.summary.entity.InterlockSummary;
|
|
|
import org.jeecg.modules.summary.mapper.InterlockSummaryMapper;
|
|
|
import org.jeecg.modules.summary.service.IInterlockSummaryService;
|
|
|
+import org.jeecg.modules.tag.entity.InterlockTag;
|
|
|
+import org.jeecg.modules.tag.service.IInterlockTagService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @Description: 联锁总表
|
|
@@ -16,4 +31,238 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@Service
|
|
|
public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMapper, InterlockSummary> implements IInterlockSummaryService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private InterlockSummaryMapper interlockSummaryMapper;
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private InterlockDetailMapper interlockDetailMapper;
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private InterlockBaseMapper interlockBaseMapper;
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private IInterlockBaseService interlockBaseService;
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private IInterlockTagService interlockTagService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 联锁及详细信息——用于编辑
|
|
|
+ */
|
|
|
+ public InterlockAddDTO xxxxLS(String id){
|
|
|
+
|
|
|
+
|
|
|
+ InterlockSummary summary = interlockSummaryMapper.selectById(id);
|
|
|
+
|
|
|
+ List<InterlockDetailAddDTO> interlockDetailAddDTOList = new ArrayList<>();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<InterlockDetail> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(InterlockDetail::getSummaryid,id);
|
|
|
+ List<InterlockDetail> detailList = interlockDetailMapper.selectList(queryWrapper);
|
|
|
+ for (InterlockDetail detail : detailList){
|
|
|
+ LambdaQueryWrapper<InterlockTag> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper1.eq(InterlockTag::getInterlockConditionId,id);
|
|
|
+ List<InterlockTag> tagList = interlockTagService.list(queryWrapper1);
|
|
|
+
|
|
|
+ interlockDetailAddDTOList.add(InterlockDetailConvert.INSTANCE.toDTO(detail));
|
|
|
+ }
|
|
|
+
|
|
|
+ InterlockAddDTO dto = InterlockSummaryConvert.INSTANCE.toDTO(summary,interlockDetailAddDTOList);
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 联锁管理——编辑联锁
|
|
|
+ */
|
|
|
+ public void editLS(InterlockAddDTO interlockAddDTO){
|
|
|
+ String summaryId = interlockAddDTO.getId();
|
|
|
+
|
|
|
+ List<InterlockDetailAddDTO> interlockDetailAddDTOList = interlockAddDTO.getInterlockDetailAddDTOList();
|
|
|
+
|
|
|
+ String interlockStatus = "1";// 联锁状态 0未投用1投用
|
|
|
+ String loopHealthLevel = "";// 回路健康级别
|
|
|
+
|
|
|
+ String controlSystemStatus = "0";// 总体 控制系统状态 0正常1非正常
|
|
|
+ String instrumentStatus = "0";// 总体 仪表状态 0正常1故障
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ //查该系统下有无相同名称联锁,无则新增 //0装置1系统2联锁 //1是0否
|
|
|
+ interlockBaseService.judgeAndAdd(interlockAddDTO.getInterlockSystemId(), "2", interlockAddDTO.getInterlockName(), "0");
|
|
|
+
|
|
|
+ //删除该联锁对应的点位
|
|
|
+ LambdaQueryWrapper<InterlockTag> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper3.eq(InterlockTag::getInterlockConditionId, summaryId);
|
|
|
+ interlockTagService.remove(queryWrapper3);
|
|
|
+ //删除该联锁下所有联锁详细信息的所有点位
|
|
|
+ LambdaQueryWrapper<InterlockDetail> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper1.eq(InterlockDetail::getSummaryid,summaryId);
|
|
|
+ List<InterlockDetail> details = interlockDetailMapper.selectList(queryWrapper1);
|
|
|
+ for (InterlockDetail detail : details){
|
|
|
+ LambdaQueryWrapper<InterlockTag> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper2.eq(InterlockTag::getInterlockConditionId, detail.getId());
|
|
|
+ interlockTagService.remove(queryWrapper2);
|
|
|
+ }
|
|
|
+ //删除该联锁下所有联锁详细信息
|
|
|
+ interlockDetailMapper.delete(queryWrapper1);
|
|
|
+
|
|
|
+
|
|
|
+ //新增——联锁输出值点位
|
|
|
+ interlockTagService.save(createInterlockTag(interlockAddDTO.getDeviceId(),interlockAddDTO.getModuleName(), interlockAddDTO.getInterlockOutValueTag(), interlockAddDTO.getInterlockOutValue(), "联锁输出值",summaryId));
|
|
|
+
|
|
|
+ for (InterlockDetailAddDTO dto : interlockDetailAddDTOList){
|
|
|
+ dto.setSummaryid(summaryId);
|
|
|
+ //旁路
|
|
|
+ if(dto.getIfBypass()!=null && "1".equals(dto.getIfBypass())){ //是否旁路,0否(手动输入)1是(再看点位)
|
|
|
+ if(dto.getBypassstatus()!=null && "1".equals(dto.getBypassstatus())) interlockStatus = "0";
|
|
|
+ }
|
|
|
+ //仪表状态:0正常1故障
|
|
|
+ if(dto.getInstrumentStatusJuge()!=null){
|
|
|
+ if("0".equals(dto.getInstrumentStatusJuge())){ //0直接读取位号
|
|
|
+ dto.setInstrumentStatus(dto.getInstrumentStatusValue());
|
|
|
+ } else if("1".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) == 1 && ysmnlValue.compareTo(upperLimit) == 1) dto.setInstrumentStatus("0");
|
|
|
+ else dto.setInstrumentStatus("1");
|
|
|
+ } else if("2".equals(dto.getInstrumentStatusJuge())){ //2突变超限判断
|
|
|
+ //?????????????????????????????????????????
|
|
|
+ }
|
|
|
+ if(dto.getInstrumentStatus().equals("1")) instrumentStatus = "1";
|
|
|
+ }
|
|
|
+ //控制系统状态
|
|
|
+ if("非正常".equals(dto.getMpStatus()) || "非正常".equals(dto.getMpStatus()) || "非正常".equals(dto.getMpStatus())) {
|
|
|
+ dto.setControlSystemStatus("1");
|
|
|
+ controlSystemStatus = "1";
|
|
|
+ } else dto.setControlSystemStatus("0");
|
|
|
+
|
|
|
+ InterlockDetail detail = InterlockDetailConvert.INSTANCE.toEntity(dto);
|
|
|
+
|
|
|
+ //新增联锁详细信息表数据
|
|
|
+ interlockDetailMapper.insert(detail);
|
|
|
+
|
|
|
+ //新增对应联锁详细信息的点位列表
|
|
|
+ interlockTagService.saveBatch(toTagList(dto,summaryId));
|
|
|
+ }
|
|
|
+
|
|
|
+ if("1".equals(instrumentStatus)) i++; //???投用未投用哪个算正常状态
|
|
|
+ if("1".equals(interlockStatus)) i++;
|
|
|
+ if("1".equals(controlSystemStatus)) i++;
|
|
|
+ if(i==0) loopHealthLevel="A";
|
|
|
+ else if(i==1) loopHealthLevel="B";
|
|
|
+ else if(i==2) loopHealthLevel="C";
|
|
|
+ else if(i==3) loopHealthLevel="D";
|
|
|
+
|
|
|
+ InterlockSummary interlockSummary = InterlockSummaryConvert.INSTANCE.toInterlockSummary(interlockAddDTO,interlockStatus,loopHealthLevel);
|
|
|
+ //修改联锁总表数据
|
|
|
+ interlockSummaryMapper.updateById(interlockSummary);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 联锁管理——新增联锁
|
|
|
+ */
|
|
|
+ public void addLS(InterlockAddDTO interlockAddDTO){
|
|
|
+
|
|
|
+ List<InterlockDetailAddDTO> interlockDetailAddDTOList = interlockAddDTO.getInterlockDetailAddDTOList();
|
|
|
+
|
|
|
+ String interlockStatus = "1";// 联锁状态 0未投用1投用
|
|
|
+ String loopHealthLevel = "";// 回路健康级别
|
|
|
+
|
|
|
+ String controlSystemStatus = "0";// 总体 控制系统状态 0正常1非正常
|
|
|
+ String instrumentStatus = "0";// 总体 仪表状态 0正常1故障
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ //查该系统下有无相同名称联锁,无则新增 //0装置1系统2联锁 //1是0否
|
|
|
+ interlockBaseService.judgeAndAdd(interlockAddDTO.getInterlockSystemId(), "2", interlockAddDTO.getInterlockName(), "0");
|
|
|
+
|
|
|
+ //新增——联锁总表数据
|
|
|
+ InterlockSummary interlockSummary = InterlockSummaryConvert.INSTANCE.toInterlockSummary(interlockAddDTO,interlockStatus,loopHealthLevel);
|
|
|
+ interlockSummaryMapper.insert(interlockSummary);
|
|
|
+
|
|
|
+ String summaryId = interlockSummary.getId();
|
|
|
+
|
|
|
+ //新增——联锁输出值点位
|
|
|
+ interlockTagService.save(createInterlockTag(interlockAddDTO.getDeviceId(),interlockAddDTO.getModuleName(), interlockAddDTO.getInterlockOutValueTag(), interlockAddDTO.getInterlockOutValue(), "联锁输出值",summaryId));
|
|
|
+
|
|
|
+ for (InterlockDetailAddDTO dto : interlockDetailAddDTOList){
|
|
|
+ dto.setSummaryid(summaryId);
|
|
|
+ //旁路
|
|
|
+ if(dto.getIfBypass()!=null && "1".equals(dto.getIfBypass())){ //是否旁路,0否(手动输入)1是(再看点位)
|
|
|
+ if(dto.getBypassstatus()!=null && "1".equals(dto.getBypassstatus())) interlockStatus = "0";
|
|
|
+ }
|
|
|
+ //仪表状态:0正常1故障
|
|
|
+ if(dto.getInstrumentStatusJuge()!=null){
|
|
|
+ if("0".equals(dto.getInstrumentStatusJuge())){ //0直接读取位号
|
|
|
+ dto.setInstrumentStatus(dto.getInstrumentStatusValue());
|
|
|
+ } else if("1".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) == 1 && ysmnlValue.compareTo(upperLimit) == 1) dto.setInstrumentStatus("0");
|
|
|
+ else dto.setInstrumentStatus("1");
|
|
|
+ } else if("2".equals(dto.getInstrumentStatusJuge())){ //2突变超限判断
|
|
|
+ //?????????????????????????????????????????
|
|
|
+ }
|
|
|
+ if(dto.getInstrumentStatus().equals("1")) instrumentStatus = "1";
|
|
|
+ }
|
|
|
+ //控制系统状态
|
|
|
+ if("非正常".equals(dto.getMpStatus()) || "非正常".equals(dto.getMpStatus()) || "非正常".equals(dto.getMpStatus())) {
|
|
|
+ dto.setControlSystemStatus("1");
|
|
|
+ controlSystemStatus = "1";
|
|
|
+ } else dto.setControlSystemStatus("0");
|
|
|
+
|
|
|
+ InterlockDetail detail = InterlockDetailConvert.INSTANCE.toEntity(dto);
|
|
|
+
|
|
|
+ //新增联锁详细信息表数据
|
|
|
+ interlockDetailMapper.insert(detail);
|
|
|
+
|
|
|
+ //新增对应联锁详细信息的点位列表
|
|
|
+ interlockTagService.saveBatch(toTagList(dto,summaryId));
|
|
|
+ }
|
|
|
+
|
|
|
+ if("1".equals(instrumentStatus)) i++; //???投用未投用哪个算正常状态
|
|
|
+ if("1".equals(interlockStatus)) i++;
|
|
|
+ if("1".equals(controlSystemStatus)) i++;
|
|
|
+ if(i==0) loopHealthLevel="A";
|
|
|
+ else if(i==1) loopHealthLevel="B";
|
|
|
+ else if(i==2) loopHealthLevel="C";
|
|
|
+ else if(i==3) loopHealthLevel="D";
|
|
|
+
|
|
|
+ interlockSummary = InterlockSummaryConvert.INSTANCE.toInterlockSummary(interlockAddDTO,interlockStatus,loopHealthLevel);
|
|
|
+ //修改联锁总表数据
|
|
|
+ interlockSummaryMapper.updateById(interlockSummary);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<InterlockTag> toTagList(InterlockDetailAddDTO dto,String interlockConditionId){
|
|
|
+ List<InterlockTag> interlockTagList = new ArrayList<>();
|
|
|
+
|
|
|
+ //联锁条件
|
|
|
+ interlockTagList.add(createInterlockTag(dto.getInterlockConditionDeviceId(), dto.getInterlockConditionModuleName(), dto.getInterlockConditionTag(), dto.getInterlockCondition(), "联锁条件",interlockConditionId));
|
|
|
+ //仪表状态 0直接读取位号
|
|
|
+ if("0".equals(dto.getInstrumentStatusJuge())){
|
|
|
+ interlockTagList.add(createInterlockTag(dto.getInstrumentStatusDeviceId(), dto.getInstrumentStatusModuleName(), dto.getInstrumentStatusTag(), dto.getInstrumentStatus(), "仪表状态",interlockConditionId));
|
|
|
+ }
|
|
|
+ //原始模拟量
|
|
|
+ interlockTagList.add(createInterlockTag(dto.getYsmnlDeviceId(),dto.getYsmnlModuleName(),dto.getYsmnlTag(),dto.getYsmnlValue(),"原始模拟量",interlockConditionId));
|
|
|
+ //联锁设定值
|
|
|
+ interlockTagList.add(createInterlockTag(dto.getInterlockSetDeviceId(),dto.getInterlockSetModuleName(),dto.getInterlockSetTag(),dto.getInterlockSetValue(),"联锁设定值",interlockConditionId));
|
|
|
+ //当前值
|
|
|
+ interlockTagList.add(createInterlockTag(dto.getCurrentValueDeviceId(),dto.getCurrentValueModuleName(),dto.getCurrentValueTag(),dto.getCurrentValue(),"当前值",interlockConditionId));
|
|
|
+ //旁路状态、、、、、、、、、、、、、、、、、、、
|
|
|
+ interlockTagList.add(createInterlockTag(dto.getBypassDeviceId(),dto.getBypassModuleName(),dto.getIfBypassTag(),dto.getIfBypass(),"旁路状态",interlockConditionId));
|
|
|
+ //输入卡件状态
|
|
|
+ interlockTagList.add(createInterlockTag(dto.getInputStatusDeviceId(),dto.getInputStatusModuleName(),dto.getInputStatusTag(),dto.getInputStatus(),"输入卡件状态",interlockConditionId));
|
|
|
+ //输出卡件状态
|
|
|
+ interlockTagList.add(createInterlockTag(dto.getOutputStatusDeviceId(),dto.getOutputStatusModuleName(),dto.getOutputStatusTag(),dto.getOutputStatus(),"输出卡件状态",interlockConditionId));
|
|
|
+ //MP状态
|
|
|
+ interlockTagList.add(createInterlockTag(dto.getMpStatusDeviceId(),dto.getMpStatusModuleName(),dto.getMpStatusTag(),dto.getMpStatus(),"MP状态",interlockConditionId));
|
|
|
+
|
|
|
+ return interlockTagList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private InterlockTag createInterlockTag(String deviceId, String moduleName, String tag, String value, String type,String interlockConditionId) {
|
|
|
+ return new InterlockTag(deviceId, moduleName, tag, value, type,interlockConditionId);
|
|
|
+ }
|
|
|
+
|
|
|
}
|