1、webcad拆单部件状态设置修正;2、装配设置详情页状态过滤修改;

This commit is contained in:
gaoqr
2026-06-01 12:00:48 +08:00
parent 8fe8b94dec
commit e31594c5d4
6 changed files with 177 additions and 62 deletions
@@ -178,7 +178,7 @@ public class AssemblyConfigServiceImpl implements AssemblyConfigService {
// 3、递归排序 + 生成 hash
for (AssemblyConfigStructureVO root : roots) {
computeHashRecursively(root);
buildAndSetRootHash(root);
}
return roots;
@@ -187,23 +187,43 @@ public class AssemblyConfigServiceImpl implements AssemblyConfigService {
/**
* 递归排序 children + 生成结构 hash
*
* @param root
*/
private void buildAndSetRootHash(AssemblyConfigStructureVO root) {
sortRecursively(root);
String structureStr = buildStructureString(root);
root.setStructureHash(
DigestUtil.sha256Hex(structureStr)
);
root.setProcess(true);
}
/**
* 递归排序
*
* @param node
*/
private void computeHashRecursively(AssemblyConfigStructureVO node) {
private void sortRecursively(AssemblyConfigStructureVO node) {
List<AssemblyConfigStructureVO> children = node.getChildren();
if (children != null && !children.isEmpty()) {
// 按 name 排序保证 hash 稳定
children.sort(Comparator.comparing(AssemblyConfigStructureVO::getName));
// 递归处理
for (AssemblyConfigStructureVO child : children) {
computeHashRecursively(child);
}
if (children == null || children.isEmpty()) {
return;
}
children.sort(
Comparator.comparing(
AssemblyConfigStructureVO::getName
)
);
for (AssemblyConfigStructureVO child : children) {
sortRecursively(child);
}
// 生成结构字符串并 hash
String structureStr = buildStructureString(node);
node.setStructureHash(DigestUtil.sha256Hex(structureStr));
// 默认是加工的
node.setProcess(true);
}
/**
@@ -212,18 +232,33 @@ public class AssemblyConfigServiceImpl implements AssemblyConfigService {
* @param node
* @return
*/
private String buildStructureString(AssemblyConfigStructureVO node) {
private String buildStructureString(
AssemblyConfigStructureVO node) {
StringBuilder sb = new StringBuilder();
sb.append(node.getName());
List<AssemblyConfigStructureVO> children = node.getChildren();
if (children != null && !children.isEmpty()) {
sb.append("(");
for (AssemblyConfigStructureVO child : children) {
sb.append(buildStructureString(child));
for (int i = 0; i < children.size(); i++) {
if (i > 0) {
sb.append(",");
}
sb.append(
buildStructureString(children.get(i))
);
}
sb.append(")");
}
return sb.toString();
}
@@ -355,7 +390,7 @@ public class AssemblyConfigServiceImpl implements AssemblyConfigService {
String newJson = JsonUtils.zipString(JsonUtils.toJsonString(structureVO));
// 重算hash
computeHashRecursively(structureVO);
buildAndSetRootHash(structureVO);
String newHash = structureVO.getStructureHash();
// 更新状态和名称