demand: 定时扫描漏组批次添加treeId
committer: heyu
This commit is contained in:
parent
83fba12bba
commit
fac835bcb2
@ -25,8 +25,11 @@ public class EmisTransPlanRule extends BaseEntity {
|
||||
/** id */
|
||||
private Long id;
|
||||
|
||||
/** tree唯一id */
|
||||
private String treeId;
|
||||
|
||||
/** 父id */
|
||||
private Long parentId;
|
||||
private String parentId;
|
||||
|
||||
/** 祖先节点 */
|
||||
private String ancestors;
|
||||
|
||||
@ -4126,7 +4126,7 @@ public class EmisBaseService {
|
||||
}
|
||||
}
|
||||
|
||||
// 递归设置父ID和祖先节点ID
|
||||
// 递归设置父ID和祖先节点ID(以treeId为准)
|
||||
for (EmisTransPlanRule root : result) {
|
||||
setParentAndAncestors(root, null, "");
|
||||
}
|
||||
@ -4141,23 +4141,20 @@ public class EmisBaseService {
|
||||
* @param parentId 父节点ID
|
||||
* @param ancestors 祖先节点ID字符串
|
||||
*/
|
||||
private void setParentAndAncestors(EmisTransPlanRule node, Long parentId, String ancestors) {
|
||||
private void setParentAndAncestors(EmisTransPlanRule node, String parentId, String ancestors) {
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置父ID
|
||||
node.setParentId(parentId);
|
||||
|
||||
// 设置祖先节点ID
|
||||
node.setAncestors(ancestors);
|
||||
|
||||
// 处理子节点,子节点的祖先包含当前节点和当前节点的所有祖先
|
||||
if (node.getChildren() != null && !node.getChildren().isEmpty()) {
|
||||
String childAncestors = ancestors.isEmpty() ? node.getId().toString() : ancestors + "," + node.getId();
|
||||
|
||||
String childAncestors = ancestors.isEmpty() ? node.getTreeId() : ancestors + "," + node.getTreeId();
|
||||
for (EmisTransPlanRule child : node.getChildren()) {
|
||||
setParentAndAncestors(child, node.getId(), childAncestors);
|
||||
setParentAndAncestors(child, node.getTreeId(), childAncestors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4217,6 +4214,9 @@ public class EmisBaseService {
|
||||
EmisTransPlanRule copy = new EmisTransPlanRule();
|
||||
BeanUtils.copyProperties(source, copy);
|
||||
|
||||
// 为每个新节点生成唯一treeId
|
||||
copy.setTreeId(com.xdadan.erp.common.utils.idgen.UUID.fastUUID().toString());
|
||||
|
||||
// 递归复制子节点
|
||||
if (source.getChildren() != null) {
|
||||
List<EmisTransPlanRule> copiedChildren = new ArrayList<>();
|
||||
@ -4573,6 +4573,10 @@ public class EmisBaseService {
|
||||
allNodeMatched = true;
|
||||
break;
|
||||
}
|
||||
list = list.stream()
|
||||
.collect(Collectors.collectingAndThen(
|
||||
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(EmisTransPlanRule::getId))),
|
||||
ArrayList::new));
|
||||
if (list.size() > filterRules.size()) {
|
||||
filterRules = list;
|
||||
}
|
||||
@ -4591,15 +4595,15 @@ public class EmisBaseService {
|
||||
return false;
|
||||
}
|
||||
EmisTransPlanRule filterRule = filterRules.get(0);
|
||||
Long ancestor;
|
||||
String ancestor;
|
||||
if (StringUtils.isEmpty(filterRule.getAncestors())) {
|
||||
ancestor = filterRule.getId();
|
||||
ancestor = filterRule.getTreeId();
|
||||
} else {
|
||||
String[] ancestors = filterRule.getAncestors().split(",");
|
||||
ancestor = Long.valueOf(ancestors[0]);
|
||||
ancestor = ancestors[0];
|
||||
}
|
||||
|
||||
List<EmisTransPlanRule> rules = ruleList.stream().filter(i -> i.getId().equals(ancestor))
|
||||
List<EmisTransPlanRule> rules = ruleList.stream().filter(i -> i.getTreeId().equals(ancestor))
|
||||
.collect(Collectors.toList());
|
||||
EmisTransPlanRule rule = rules.get(0);
|
||||
setMissRecords(missRecords, rule, filterRules, waybill);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user