Merge pull request 'demand: 定时扫描漏组批次添加treeId' (#75) from develop into master

Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/75
This commit is contained in:
heyu 2025-06-26 18:45:17 +08:00
commit 53c263d6dc
2 changed files with 19 additions and 12 deletions

View File

@ -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;

View File

@ -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);