|
|
|
@ -3746,6 +3746,16 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
|
|
|
|
String currentWorkCenterNo = normalizeWorkCenterNo(inData.getWorkCenterNo()); |
|
|
|
if (!StringUtils.hasText(currentWorkCenterNo)) { |
|
|
|
currentWorkCenterNo = resolveSplitRuleWorkCenterNo(inData); |
|
|
|
inData.setWorkCenterNo(currentWorkCenterNo); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(currentWorkCenterNo)) { |
|
|
|
// 无法确定当前工单加工中心时,不触发异常规则 |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
|
|
|
|
List<SplitRollMetricContext> metricContextList = buildSplitRollMetricContexts(inData); |
|
|
|
for (SysSceneExceptionRuleEntity rule : ruleList) { |
|
|
|
SysSceneExceptionRuleConditionEntity query = new SysSceneExceptionRuleConditionEntity(); |
|
|
|
@ -3756,6 +3766,9 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
if (CollectionUtils.isEmpty(conditionList)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (!containsWorkCenterForRule(conditionList, currentWorkCenterNo)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, List<SysSceneExceptionRuleConditionEntity>> childMap = new LinkedHashMap<>(); |
|
|
|
List<SysSceneExceptionRuleConditionEntity> rootList = new ArrayList<>(); |
|
|
|
@ -3779,6 +3792,12 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
continue; |
|
|
|
} |
|
|
|
for (SysSceneExceptionRuleConditionEntity child : childList) { |
|
|
|
String triggerWorkCenter = StringUtils.hasText(child.getTriggerWorkCenter()) |
|
|
|
? child.getTriggerWorkCenter() |
|
|
|
: root.getTriggerWorkCenter(); |
|
|
|
if (!matchesTriggerWorkCenter(triggerWorkCenter, currentWorkCenterNo)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (!isConditionMatched(child, metricMap)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
@ -4148,6 +4167,61 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
return metricMap; |
|
|
|
} |
|
|
|
|
|
|
|
private String normalizeWorkCenterNo(String workCenterNo) { |
|
|
|
if (!StringUtils.hasText(workCenterNo)) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
return workCenterNo.trim(); |
|
|
|
} |
|
|
|
|
|
|
|
private String resolveSplitRuleWorkCenterNo(SearchScheduleData inData) { |
|
|
|
if (inData == null || !StringUtils.hasText(inData.getSeqNo())) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
try { |
|
|
|
ScheduleData scheduleData = scheduleMapper.getScheduleDataBySeqNo(inData.getSeqNo()); |
|
|
|
if (scheduleData == null) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
return normalizeWorkCenterNo(scheduleData.getWorkCenterNo()); |
|
|
|
} catch (Exception ex) { |
|
|
|
logger.warn("查询创建分卷规则校验加工中心失败,seqNo={}", inData.getSeqNo(), ex); |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private boolean containsWorkCenterForRule(List<SysSceneExceptionRuleConditionEntity> conditionList, String workCenterNo) { |
|
|
|
if (CollectionUtils.isEmpty(conditionList) || !StringUtils.hasText(workCenterNo)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
for (SysSceneExceptionRuleConditionEntity condition : conditionList) { |
|
|
|
if (condition == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (matchesTriggerWorkCenter(condition.getTriggerWorkCenter(), workCenterNo)) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean matchesTriggerWorkCenter(String triggerWorkCenter, String workCenterNo) { |
|
|
|
if (!StringUtils.hasText(triggerWorkCenter) || !StringUtils.hasText(workCenterNo)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
String targetWorkCenter = normalizeWorkCenterNo(workCenterNo); |
|
|
|
String[] workCenterArr = triggerWorkCenter.split("[,;,;]"); |
|
|
|
for (String workCenter : workCenterArr) { |
|
|
|
if (!StringUtils.hasText(workCenter)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (targetWorkCenter.equalsIgnoreCase(workCenter.trim())) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean isConditionMatched(SysSceneExceptionRuleConditionEntity condition, Map<String, BigDecimal> metricMap) { |
|
|
|
if (condition == null || !StringUtils.hasText(condition.getRelationField()) |
|
|
|
|| !StringUtils.hasText(condition.getCompareSymbol()) || condition.getConditionParam() == null) { |
|
|
|
|