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
@@ -44,6 +44,16 @@ public interface OrderComponentMapper extends BaseMapperX<OrderComponentDO> {
*/
List<OrderComponentDO> getOrderTopComponentList(@Param("orderIds")List<Long> orderIds, @Param("name") String name);
/**
* 查询订单顶级部件,关联order_item,如果被移除了就不展示了
*
* @param orderIds
* @param processStatus
* @param name
* @return
*/
List<OrderComponentDO> getOrderTopComponentListByAssemblyStatus(@Param("orderIds") List<Long> orderIds, @Param("assemblyStatusList") List<Integer> processStatus, @Param("name") String name);
/**
* 查询订单topid下的所有大于level层级的部件列表
* @param orderId
@@ -98,21 +98,20 @@ public class AssemblyListServiceImpl implements AssemblyListService {
.map(OrderComponentDO::getTopId)
.toList();
// 根据部件的topid查询树上所有已加工节点
List<OrderComponentDO> topUnProcessedComponentList = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
// 查询所有top节点下的子节点
List<OrderComponentDO> allNodesOnTopIds = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
.in(OrderComponentDO::getTopId, topIds)
.in(OrderComponentDO::getOrderId, orderIds)
.select(OrderComponentDO::getId, OrderComponentDO::getPid, OrderComponentDO::getName, OrderComponentDO::getProcessStatus));
.select(OrderComponentDO::getId, OrderComponentDO::getPid, OrderComponentDO::getName, OrderComponentDO::getProcessStatus, OrderComponentDO::getExtraProcessStatus));
// 计算部件状态
List<OrderComponentTreeCompareVO> treeCompareVOS = calculateProcessingStatusAccordingToAssemblyConfig(topUnProcessedComponentList);
List<OrderComponentRespVO> result = new ArrayList<>();
// 树形扁平化
for (OrderComponentTreeCompareVO vo : treeCompareVOS) {
flatTree(vo, result);
// 遍历处理状态
for (OrderComponentDO orderComponent : allNodesOnTopIds) {
// extraProcessStatus不为空时替代processStatus
if (ObjectUtil.isNotEmpty(orderComponent.getExtraProcessStatus())) {
orderComponent.setProcessStatus(orderComponent.getExtraProcessStatus());
}
}
return result;
return BeanUtil.copyToList(allNodesOnTopIds, OrderComponentRespVO.class);
}
/**
@@ -386,8 +385,8 @@ public class AssemblyListServiceImpl implements AssemblyListService {
);
// 不加工不可操作
AssertUtils.notEquals(
componentDO.getProcessStatus(),
AssertUtils.equals(
componentDO.getExtraProcessStatus(),
OrderComponentProcessStatusEnum.NOT_PROCESS.getStatus(),
ORDER_COMPONENT_NOT_PROCESS
);
@@ -415,7 +414,7 @@ public class AssemblyListServiceImpl implements AssemblyListService {
AssertUtils.equals(
componentDO.getProcessStatus(),
OrderComponentProcessStatusEnum.UNPROCESSED.getStatus(),
OrderComponentProcessStatusEnum.PROCESSED.getStatus(),
ORDER_COMPONENT_PROCESSED_REPEAT
);
}
@@ -425,7 +424,7 @@ public class AssemblyListServiceImpl implements AssemblyListService {
AssertUtils.equals(
componentDO.getProcessStatus(),
OrderComponentProcessStatusEnum.PROCESSED.getStatus(),
OrderComponentProcessStatusEnum.UNPROCESSED.getStatus(),
ORDER_COMPONENT_RESTORE_REPEAT
);
}
@@ -783,24 +782,8 @@ public class AssemblyListServiceImpl implements AssemblyListService {
return Collections.emptyList();
}
List<TopComponentState> states = buildTopComponentStates(reqVO);
if (CollUtil.isEmpty(states)) {
return Collections.emptyList();
}
Set<OrderComponentProcessStatusEnum> statusSet =
Optional.ofNullable(reqVO.getProcessStatus())
.orElse(Collections.emptyList())
.stream()
.map(OrderComponentProcessStatusEnum::fromValue)
.collect(Collectors.toSet());
List<OrderComponentTreeCompareVO> result = states.stream()
.filter(state -> matchAnyStatus(state, statusSet))
.map(state -> state.node)
.toList();
// 查询顶级部件
List<OrderComponentDO> result = orderComponentMapper.getOrderTopComponentListByAssemblyStatus(reqVO.getOrderIds(), reqVO.getProcessStatus(), reqVO.getName());
return BeanUtil.copyToList(result, OrderComponentRespVO.class);
}
@@ -812,7 +795,7 @@ public class AssemblyListServiceImpl implements AssemblyListService {
*/
private List<TopComponentState> buildTopComponentStates(OrdersTopComponentListReqVO reqVO) {
// 查询顶级部件
List<OrderComponentDO> topComponents = orderComponentMapper.getOrderTopComponentList(reqVO.getOrderIds(), reqVO.getName());
List<OrderComponentDO> topComponents = orderComponentMapper.getOrderTopComponentListByAssemblyStatus(reqVO.getOrderIds(), reqVO.getProcessStatus(), reqVO.getName());
if (CollUtil.isEmpty(topComponents)) {
return Collections.emptyList();
@@ -57,6 +57,58 @@
);
</select>
<select id="getOrderTopComponentListByAssemblyStatus"
resultType="com.cf.imes.module.executor.dal.dataobject.ordercomponent.OrderComponentDO">
SELECT * FROM (
SELECT
top.id,
top.name,
top.pid,
top.cad_view_file_id,
CASE
<!-- 1. 不加工:extra_process_status = 0 -->
WHEN top.pid = 0 AND top.extra_process_status = 0 THEN 0
<!-- 2. 部分加工:extra_process_status = 3 -->
WHEN top.pid = 0 AND top.extra_process_status = 3 THEN 3
<!-- 3. 已加工:process_status = 2 -->
WHEN top.pid = 0 AND top.process_status = 2 THEN 2
<!-- 4. 未加工:process_status = 1 且 extra_process_status IS NULL -->
WHEN top.pid = 0 AND top.process_status = 1 AND (top.extra_process_status IS NULL OR top.extra_process_status != 0) THEN 1
ELSE -1
END AS processStatus
FROM order_component top
WHERE top.pid = 0
<if test="name != null and name != ''">
AND top.name LIKE CONCAT('%', #{name}, '%')
</if>
AND top.order_id IN
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
#{orderId}
</foreach>
AND EXISTS (
SELECT 1
FROM order_component oc
JOIN order_item oi
ON oi.comp_id = oc.id
AND oi.order_id = oc.order_id
AND oi.organ_id = oc.organ_id
WHERE oc.top_id = top.id
AND oc.order_id = top.order_id
AND oc.organ_id = top.organ_id
)
) t
<if test="assemblyStatusList != null and assemblyStatusList.size() > 0">
WHERE t.processStatus IN
<foreach item="status" collection="assemblyStatusList" open="(" separator="," close=")">
#{status}
</foreach>
</if>
</select>
<select id="getComponentListOnTopLevel"
resultType="com.cf.imes.module.executor.dal.dataobject.ordercomponent.OrderComponentDO">
select * from order_component oc
@@ -1801,7 +1801,7 @@ public class WebCadOrderImportAsyncFactory {
// 3. hash计算
for (OrderComponentTreeCompareVO root : roots) {
computeHashRecursively(root);
buildAndSetRootHash(root);
}
// 4. 状态刷新
@@ -1945,7 +1945,6 @@ public class WebCadOrderImportAsyncFactory {
node.setId(groupId == null ? null : groupId);
node.setName(name);
node.setChildren(children);
node.setProcessStatus(OrderComponentProcessStatusEnum.UNPROCESSED.getStatus());
if (boxSize != null) {
node.setWidth(boxSize.getWidth());
@@ -1979,13 +1978,50 @@ public class WebCadOrderImportAsyncFactory {
);
}
private void buildAndSetRootHash(
OrderComponentTreeCompareVO root) {
private String buildStructureString(OrderComponentTreeCompareVO node) {
sortRecursively(root);
String structureStr =
buildStructureString(root);
root.setStructureHash(
DigestUtil.sha256Hex(structureStr)
);
}
private void sortRecursively(
OrderComponentTreeCompareVO node) {
List<OrderComponentTreeCompareVO> children =
node.getChildren();
if (CollUtil.isEmpty(children)) {
return;
}
children.sort(
Comparator.comparing(
OrderComponentTreeCompareVO::getName
)
);
for (OrderComponentTreeCompareVO child : children) {
sortRecursively(child);
}
}
private String buildStructureString(
OrderComponentTreeCompareVO node) {
StringBuilder sb = new StringBuilder();
sb.append(node.getName());
List<OrderComponentTreeCompareVO> children = node.getChildren();
List<OrderComponentTreeCompareVO> children =
node.getChildren();
if (CollUtil.isNotEmpty(children)) {
@@ -1997,7 +2033,11 @@ public class WebCadOrderImportAsyncFactory {
sb.append(",");
}
sb.append(buildStructureString(children.get(i)));
sb.append(
buildStructureString(
children.get(i)
)
);
}
sb.append(")");
@@ -589,11 +589,6 @@ public class WebCadOrderImportFactory {
vo.setDepth(node.getBoxSize().getDepth());
}
// 默认未加工
vo.setProcessStatus(
OrderComponentProcessStatusEnum.UNPROCESSED.getStatus()
);
List<OrderComponentTreeCompareVO> children =
new ArrayList<>();
@@ -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();
// 更新状态和名称