Merge pull request 'demand: 组批次规则图查询添加去重逻辑' (#97) from develop into master
Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/97
This commit is contained in:
commit
d843be726d
@ -151,6 +151,7 @@ public class EmisTransPlanRuleServiceImpl extends EmisBaseService implements IEm
|
||||
trees = trees.stream().filter(i -> lineStartSiteCode.equals(i.getStartSiteCode()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
trees = deduplicate(trees);
|
||||
return trees;
|
||||
}
|
||||
|
||||
@ -629,4 +630,46 @@ public class EmisTransPlanRuleServiceImpl extends EmisBaseService implements IEm
|
||||
globalVisited.add(node.getId());
|
||||
}
|
||||
|
||||
private boolean isSupplierCodeEqual(String s1, String s2) {
|
||||
if (s1 == null || s2 == null)
|
||||
return s1 == s2;
|
||||
Set<String> set1 = new HashSet<>(Arrays.asList(s1.split(",")));
|
||||
Set<String> set2 = new HashSet<>(Arrays.asList(s2.split(",")));
|
||||
return set1.equals(set2);
|
||||
}
|
||||
|
||||
private boolean hasProductTypeIntersection(String p1, String p2) {
|
||||
if (p1 == null || p2 == null)
|
||||
return false;
|
||||
Set<String> set1 = new HashSet<>(Arrays.asList(p1.split(",")));
|
||||
Set<String> set2 = new HashSet<>(Arrays.asList(p2.split(",")));
|
||||
set1.retainAll(set2);
|
||||
return !set1.isEmpty();
|
||||
}
|
||||
|
||||
private boolean isDuplicate(EmisTransPlanRule a, EmisTransPlanRule b) {
|
||||
return Objects.equals(a.getLineCode(), b.getLineCode())
|
||||
&& Objects.equals(a.getStartSiteCode(), b.getStartSiteCode())
|
||||
&& Objects.equals(a.getNextSiteCode(), b.getNextSiteCode())
|
||||
&& isSupplierCodeEqual(a.getSupplierCode(), b.getSupplierCode())
|
||||
&& Objects.equals(a.getProductType(), b.getProductType());
|
||||
}
|
||||
|
||||
private List<EmisTransPlanRule> deduplicate(List<EmisTransPlanRule> trees) {
|
||||
List<EmisTransPlanRule> result = new ArrayList<>();
|
||||
for (EmisTransPlanRule rule : trees) {
|
||||
boolean duplicate = false;
|
||||
for (EmisTransPlanRule exist : result) {
|
||||
if (isDuplicate(rule, exist)) {
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!duplicate) {
|
||||
result.add(rule);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user