Browse Source

限制重复配置

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

2
modules/calculation/src/main/java/com/thing/calculation/handler/CalcExecuteHandler.java

@ -175,7 +175,7 @@ public class CalcExecuteHandler {
calcLog.setStatus(CalcStatus.CALCULATED.getCode());
}
} catch (Exception e) {
log.error("物计算:计算错误 => ", e);
log.error("物计算:计算错误 =>: "+calcLog.getId(), e);
calcLog.setStatus(CalcStatus.CALCULATE_EXCEPTION.getCode());
calcLog.setErrorInfo(e.getMessage());
}

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

@ -187,7 +187,14 @@ public class CalcTargetConfigServiceImpl
// 目标物配置默认设置
targetConfig.setId(flag? IdGenerator.nextId() : targetConfig.getId());
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();

Loading…
Cancel
Save