|
|
|
@ -4,9 +4,11 @@ import com.thing.calculation.dto.CalcTargetConfigDTO; |
|
|
|
import com.thing.calculation.dto.ExecuteCalcRequest; |
|
|
|
import com.thing.calculation.dto.LogSourceInfoValue; |
|
|
|
import com.thing.calculation.entity.CalcLogEntity; |
|
|
|
import com.thing.calculation.entity.CalcSourceConfigEntity; |
|
|
|
import com.thing.calculation.enumeration.CalcConfigType; |
|
|
|
import com.thing.calculation.enumeration.CalcStatus; |
|
|
|
import com.thing.calculation.service.CalcLogService; |
|
|
|
import com.thing.calculation.service.CalcSourceConfigService; |
|
|
|
import com.thing.calculation.service.CalcTargetConfigService; |
|
|
|
import com.thing.common.core.utils.FormulaUtil; |
|
|
|
import com.thing.common.data.event.QueueConsumerEvent; |
|
|
|
@ -40,6 +42,7 @@ public class CalcExecuteHandler { |
|
|
|
private final CalcLogService calcLogService; |
|
|
|
private final ApplicationEventPublisher publisher; |
|
|
|
@Lazy @Resource private CalcTargetConfigService calcTargetConfigService; |
|
|
|
@Lazy @Resource private CalcSourceConfigService calcSourceConfigService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 执行计算的入口:<br> |
|
|
|
@ -141,6 +144,17 @@ public class CalcExecuteHandler { |
|
|
|
/** 映射计算:无论是一个还是多个,统统加起来总是不会错的 */ |
|
|
|
private void doMapping(CalcLogEntity calcLog) { |
|
|
|
Map<String, LogSourceInfoValue> data = calcLog.parseSourceInfo(); |
|
|
|
if(calcLog.getCalcCount()>= 5){ |
|
|
|
String formula = calcLog.getFormula(); |
|
|
|
String[] split = formula.split("\\+"); |
|
|
|
List<CalcSourceConfigEntity> calcSourceConfigEntities = calcSourceConfigService.findByTargetId(calcLog.getCalcTargetConfigId()); |
|
|
|
for (String s : split) { |
|
|
|
Optional<CalcSourceConfigEntity> first = calcSourceConfigEntities.stream().filter(config -> config.getSourceAttrAlias().equals(s)).findFirst(); |
|
|
|
if (first.isPresent() && !data.containsKey(s)) { |
|
|
|
data.put(s, new LogSourceInfoValue(first.get().getSourceThingCode(), first.get().getSourceAttrCode(),"0")); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
BigDecimal totalVal = |
|
|
|
data.values().stream() |
|
|
|
|