demand: 定时扫描任务优化
committer: heyu
This commit is contained in:
parent
61bcf29a97
commit
318e635cce
@ -244,7 +244,8 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
||||
}
|
||||
}
|
||||
|
||||
private void saveRecord(int totalProcessed, int successCount, int failCount, long processTime, List<String> failedBillCodes) {
|
||||
private void saveRecord(int totalProcessed, int successCount, int failCount, long processTime,
|
||||
List<String> failedBillCodes) {
|
||||
EmisTmsSiteBatchMissRecord record = new EmisTmsSiteBatchMissRecord();
|
||||
record.setTotalProcessed(totalProcessed);
|
||||
record.setSuccessCount(successCount);
|
||||
@ -299,7 +300,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
||||
}
|
||||
|
||||
private ProcessResult processWaybillBatch(List<EmisWaybill> waybills,
|
||||
Map<String, List<EmisTransPlanRule>> transPlanRulesByLineCode) {
|
||||
Map<String, List<EmisTransPlanRule>> transPlanRulesByLineCode) {
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
List<String> failedBillCodes = new ArrayList<>();
|
||||
@ -328,7 +329,8 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
||||
for (EmisWaybill waybill : waybills) {
|
||||
try {
|
||||
// 获取运单对应的线路规划
|
||||
List<EmisTransPlanRule> ruleListByTransLineType = transPlanRulesByLineCode.get(waybill.getTransLineType());
|
||||
List<EmisTransPlanRule> ruleListByTransLineType = transPlanRulesByLineCode
|
||||
.get(waybill.getTransLineType());
|
||||
if (CollectionUtil.isEmpty(ruleListByTransLineType)) {
|
||||
// 创建漏组记录
|
||||
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
|
||||
@ -358,9 +360,6 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
||||
// 创建漏组记录
|
||||
EmisTmsSiteBatchMiss miss = createMissRecord(waybill);
|
||||
miss.setMissReason("当前运单没有组批次");
|
||||
// miss.setTransPlanRuleId(ruleListByTransLineType.stream()
|
||||
// .sorted(Comparator.comparing(EmisTransPlanRule::getId))
|
||||
// .collect(Collectors.toList()).get(0).getId());
|
||||
missRecords.add(miss);
|
||||
successCount++;
|
||||
continue;
|
||||
@ -476,6 +475,26 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较两个供应商代码字符串是否包含相同的供应商(忽略顺序)
|
||||
*
|
||||
* @param supplierCode1 第一个供应商代码字符串
|
||||
* @param supplierCode2 第二个供应商代码字符串
|
||||
* @return 如果包含相同的供应商返回true,否则返回false
|
||||
*/
|
||||
private boolean compareSupplierCodes(String supplierCode1, String supplierCode2) {
|
||||
if (supplierCode1 == null || supplierCode2 == null) {
|
||||
return supplierCode1 == supplierCode2;
|
||||
}
|
||||
Set<String> suppliers1 = Arrays.stream(supplierCode1.split(","))
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toSet());
|
||||
Set<String> suppliers2 = Arrays.stream(supplierCode2.split(","))
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toSet());
|
||||
return suppliers1.equals(suppliers2);
|
||||
}
|
||||
|
||||
private boolean checkRule(EmisTransPlanRule rule, List<EmisTmsSiteBatch> waybillBatches,
|
||||
List<EmisTransPlanRule> list) {
|
||||
// 检查当前节点是否匹配
|
||||
@ -483,7 +502,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
||||
for (EmisTmsSiteBatch batch : waybillBatches) {
|
||||
if (rule.getStartSiteCode().equals(batch.getStartSiteCode()) &&
|
||||
rule.getNextSiteCode().equals(batch.getNextSiteCode()) &&
|
||||
rule.getSupplierCode().equals(batch.getSupplierCode())
|
||||
compareSupplierCodes(rule.getSupplierCode(), batch.getSupplierCode())
|
||||
&& batch.getEtd().before(rule.getEndDate())
|
||||
&& !batch.getEtd().before(rule.getStartDate())) {
|
||||
currentMatch = true;
|
||||
@ -514,7 +533,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
||||
boolean isMatched = filterRules.stream()
|
||||
.anyMatch(filterRule -> filterRule.getStartSiteCode().equals(rule.getStartSiteCode()) &&
|
||||
filterRule.getNextSiteCode().equals(rule.getNextSiteCode()) &&
|
||||
filterRule.getSupplierCode().equals(rule.getSupplierCode()));
|
||||
compareSupplierCodes(filterRule.getSupplierCode(), rule.getSupplierCode()));
|
||||
|
||||
if (!isMatched) {
|
||||
// 创建漏组记录
|
||||
@ -543,7 +562,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
|
||||
.anyMatch(
|
||||
filterRule -> filterRule.getStartSiteCode().equals(childRule.getStartSiteCode()) &&
|
||||
filterRule.getNextSiteCode().equals(childRule.getNextSiteCode()) &&
|
||||
filterRule.getSupplierCode().equals(childRule.getSupplierCode())));
|
||||
compareSupplierCodes(filterRule.getSupplierCode(), childRule.getSupplierCode())));
|
||||
|
||||
if (!hasMatchedChild) {
|
||||
// 如果所有子节点都不匹配,为每个子节点创建漏组记录
|
||||
|
||||
Loading…
Reference in New Issue
Block a user