Browse Source

限制重复配置

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

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

@ -184,17 +184,30 @@ public class CalcTargetConfigServiceImpl
*/ */
private void generateDefaultInfo(CalcTargetConfigDTO targetConfig) { private void generateDefaultInfo(CalcTargetConfigDTO targetConfig) {
boolean flag = ObjectUtil.isEmpty(targetConfig.getId()); boolean flag = ObjectUtil.isEmpty(targetConfig.getId());
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);
if(!Objects.isNull(calcTargetConfigEntity)){
//calcSourceConfigService.findByTargetId(calcTargetConfigEntity.getId());
throw new SysException(targetConfig.getTargetThingCode()+"-"+targetConfig.getTargetAttrCode()+"目标物配置已存在!不要重复配置");
}
}
// 目标物配置默认设置 // 目标物配置默认设置
targetConfig.setId(flag? IdGenerator.nextId() : targetConfig.getId()); targetConfig.setId(flag? IdGenerator.nextId() : targetConfig.getId());
targetConfig.setEnable(Optional.ofNullable(targetConfig.getEnable()).orElse(true)); targetConfig.setEnable(Optional.ofNullable(targetConfig.getEnable()).orElse(true));
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()+"目标物配置已存在!不要重复配置");
}
// 目标物公式描述生成计算物配置默认信息设置 // 目标物公式描述生成计算物配置默认信息设置
List<CalcSourceConfigDTO> sourceConfigs = targetConfig.getSourceConfigs(); List<CalcSourceConfigDTO> sourceConfigs = targetConfig.getSourceConfigs();

Loading…
Cancel
Save