|
@@ -4,9 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.common.system.vo.SelectTreeModel;
|
|
|
+import org.jeecg.modules.base.convert.InterlockBaseConvert;
|
|
|
import org.jeecg.modules.base.entity.InterlockBase;
|
|
|
+import org.jeecg.modules.base.entity.InterlockBaseHy;
|
|
|
+import org.jeecg.modules.base.mapper.InterlockBaseHyMapper;
|
|
|
import org.jeecg.modules.base.mapper.InterlockBaseMapper;
|
|
|
+import org.jeecg.modules.base.service.IInterlockBaseHyService;
|
|
|
import org.jeecg.modules.base.service.IInterlockBaseService;
|
|
|
+import org.jeecg.modules.summary.constants.InterlockAllStatus;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -29,6 +34,9 @@ public class InterlockBaseServiceImpl extends ServiceImpl<InterlockBaseMapper, I
|
|
|
@Autowired
|
|
|
@SuppressWarnings("all")
|
|
|
private InterlockBaseMapper interlockBaseMapper;
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private IInterlockBaseHyService hyService;
|
|
|
|
|
|
/**查表中有无该系统下的联锁,无则新增*/
|
|
|
public void judgeAndAdd(String pid, String interlockType, String interlockName, String hasChild){
|
|
@@ -58,6 +66,7 @@ public class InterlockBaseServiceImpl extends ServiceImpl<InterlockBaseMapper, I
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void addInterlockBase(InterlockBase interlockBase) {
|
|
|
//新增时设置hasChild为0
|
|
|
interlockBase.setHasChild(IInterlockBaseService.NOCHILD);
|
|
@@ -72,9 +81,52 @@ public class InterlockBaseServiceImpl extends ServiceImpl<InterlockBaseMapper, I
|
|
|
}
|
|
|
}
|
|
|
baseMapper.insert(interlockBase);
|
|
|
+
|
|
|
+ // 如果新增的是系统, 同时新增base_hy
|
|
|
+ if(interlockBase.getInterlockType().equals(InterlockAllStatus.INTERLOCK_TYPE_XT)){
|
|
|
+ List<InterlockBaseHy> baseHyList = toBaseHy(interlockBase);
|
|
|
+ hyService.saveBatch(baseHyList);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ private List<InterlockBaseHy> toBaseHy(InterlockBase base){
|
|
|
+ List<InterlockBaseHy> list = new ArrayList<>();
|
|
|
+ InterlockBaseHy yhy = InterlockBaseConvert.INSTANCE.toInterlockBaseHy(
|
|
|
+ base.getId(),
|
|
|
+ base.getInterlockStatusTy(),
|
|
|
+ base.getInterlockStatusTyName(),
|
|
|
+ base.getBypassYes(),
|
|
|
+ base.getBypassYesName(),
|
|
|
+ base.getInstrumentStatusNormal(),
|
|
|
+ base.getInstrumentStatusNormalName(),
|
|
|
+ base.getControlSystemStatusNormal(),
|
|
|
+ base.getControlSystemStatusNormalName()
|
|
|
+ );
|
|
|
+ list.add(yhy);
|
|
|
+ InterlockBaseHy zhhy = InterlockBaseConvert.INSTANCE.toInterlockBaseHy(
|
|
|
+ base.getId(),
|
|
|
+ zh(base.getInterlockStatusTy()),
|
|
|
+ base.getInterlockStatusWtyName(),
|
|
|
+ zh(base.getBypassYes()),
|
|
|
+ base.getBypassNoName(),
|
|
|
+ zh(base.getInstrumentStatusNormal()),
|
|
|
+ base.getInstrumentStatusAbnormalName(),
|
|
|
+ zh(base.getControlSystemStatusNormal()),
|
|
|
+ base.getControlSystemStatusAbnormalName()
|
|
|
+ );
|
|
|
+ list.add(zhhy);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String zh(String status){
|
|
|
+ if("0".equals(status)) return "1";
|
|
|
+ else if("1".equals(status)) return "0";
|
|
|
+ else return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void updateInterlockBase(InterlockBase interlockBase) {
|
|
|
InterlockBase entity = this.getById(interlockBase.getId());
|
|
|
if(entity==null) {
|
|
@@ -92,6 +144,17 @@ public class InterlockBaseServiceImpl extends ServiceImpl<InterlockBaseMapper, I
|
|
|
}
|
|
|
}
|
|
|
baseMapper.updateById(interlockBase);
|
|
|
+
|
|
|
+ // 如果修改的是系统, 同时修改base_hy(直接删掉原来的,新增修改后的)
|
|
|
+ if(interlockBase.getInterlockType().equals(InterlockAllStatus.INTERLOCK_TYPE_XT)){
|
|
|
+ // 删除原InterlockBaseHy
|
|
|
+ LambdaQueryWrapper<InterlockBaseHy> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(InterlockBaseHy::getInterlockSystemId,interlockBase.getId());
|
|
|
+ hyService.remove(wrapper);
|
|
|
+ // 新增InterlockBaseHy
|
|
|
+ List<InterlockBaseHy> baseHyList = toBaseHy(interlockBase);
|
|
|
+ hyService.saveBatch(baseHyList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -113,6 +176,12 @@ public class InterlockBaseServiceImpl extends ServiceImpl<InterlockBaseMapper, I
|
|
|
//如果当前节点原本有子节点 现在木有了,更新状态
|
|
|
sb.append(pidVal).append(",");
|
|
|
}
|
|
|
+
|
|
|
+ //删除对应的base_hy数据
|
|
|
+ LambdaQueryWrapper<InterlockBaseHy> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(InterlockBaseHy::getInterlockSystemId,interlockBase.getId());
|
|
|
+ hyService.remove(wrapper);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
//批量删除节点
|
|
@@ -129,6 +198,11 @@ public class InterlockBaseServiceImpl extends ServiceImpl<InterlockBaseMapper, I
|
|
|
}
|
|
|
updateOldParentNode(interlockBase.getPid());
|
|
|
baseMapper.deleteById(id);
|
|
|
+
|
|
|
+ //删除对应的base_hy数据
|
|
|
+ LambdaQueryWrapper<InterlockBaseHy> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(InterlockBaseHy::getInterlockSystemId,interlockBase.getId());
|
|
|
+ hyService.remove(wrapper);
|
|
|
}
|
|
|
}
|
|
|
|