Browse Source

限制重复配置

2025年3月5日17:17:03
qingyuan_dev_new
lishuai 10 months ago
parent
commit
e3b43164ab
  1. 19
      modules/calculation/src/main/java/com/thing/calculation/service/impl/CalcTargetConfigServiceImpl.java

19
modules/calculation/src/main/java/com/thing/calculation/service/impl/CalcTargetConfigServiceImpl.java

@ -184,10 +184,18 @@ public class CalcTargetConfigServiceImpl
*/
private void generateDefaultInfo(CalcTargetConfigDTO targetConfig) {
boolean flag = ObjectUtil.isEmpty(targetConfig.getId());
// 目标物配置默认设置
targetConfig.setId(flag? IdGenerator.nextId() : targetConfig.getId());
targetConfig.setEnable(Optional.ofNullable(targetConfig.getEnable()).orElse(true));
if(flag){
QueryWrapper eq = QueryWrapper.create().eq(CalcTargetConfigEntity::getTargetThingCode, targetConfig.getTargetThingCode())
.eq(CalcTargetConfigEntity::getTargetAttrCode, targetConfig.getTargetAttrCode())
.eq(CalcTargetConfigEntity::getTenantCode, UserContext.getRealTenantCode());
CalcTargetConfigEntity calcTargetConfigEntity = mapper.selectOneByQuery(eq);
if(!Objects.isNull(calcTargetConfigEntity)){
//calcSourceConfigService.findByTargetId(calcTargetConfigEntity.getId());
throw new SysException(targetConfig.getTargetThingCode()+"-"+targetConfig.getTargetAttrCode()+"目标物配置已存在!不要重复配置");
}
}else{
QueryWrapper eq = QueryWrapper.create().eq(CalcTargetConfigEntity::getTargetThingCode, targetConfig.getTargetThingCode())
.eq(CalcTargetConfigEntity::getId, targetConfig.getId())
.eq(CalcTargetConfigEntity::getTargetAttrCode, targetConfig.getTargetAttrCode())
.eq(CalcTargetConfigEntity::getTenantCode, UserContext.getRealTenantCode());
CalcTargetConfigEntity calcTargetConfigEntity = mapper.selectOneByQuery(eq);
@ -195,6 +203,11 @@ public class CalcTargetConfigServiceImpl
//calcSourceConfigService.findByTargetId(calcTargetConfigEntity.getId());
throw new SysException(targetConfig.getTargetThingCode()+"-"+targetConfig.getTargetAttrCode()+"目标物配置已存在!不要重复配置");
}
}
// 目标物配置默认设置
targetConfig.setId(flag? IdGenerator.nextId() : targetConfig.getId());
targetConfig.setEnable(Optional.ofNullable(targetConfig.getEnable()).orElse(true));
// 目标物公式描述生成计算物配置默认信息设置
List<CalcSourceConfigDTO> sourceConfigs = targetConfig.getSourceConfigs();

Loading…
Cancel
Save