mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
/assembly/flat-list和/assembly/component/direct-children支持加工状态的入参过滤
This commit is contained in:
+6
@@ -1,5 +1,7 @@
|
||||
package com.cf.imes.module.executor.controller.admin.assemblylist.vo;
|
||||
|
||||
import com.cf.imes.framework.common.validation.InEnum;
|
||||
import com.cf.imes.module.executor.enums.ordercomponent.OrderComponentProcessStatusEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
@@ -13,4 +15,8 @@ public class AssemblyListComponentFlatReqVO {
|
||||
@NotEmpty
|
||||
@Schema(description = "订单 ID 列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<Long> orderIds;
|
||||
|
||||
@Schema(description = "加工状态:0不加工、1未加工、2已加工、3部分加工", example = "[1, 2]")
|
||||
@InEnum(OrderComponentProcessStatusEnum.class)
|
||||
private List<Integer> processStatus;
|
||||
}
|
||||
|
||||
+6
@@ -1,5 +1,7 @@
|
||||
package com.cf.imes.module.executor.controller.admin.ordercomponent.vo;
|
||||
|
||||
import com.cf.imes.framework.common.validation.InEnum;
|
||||
import com.cf.imes.module.executor.enums.ordercomponent.OrderComponentProcessStatusEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -24,4 +26,8 @@ public class AssemblyComponentChildPrintReqVO {
|
||||
@NotEmpty(message = "订单 ID 不能为空")
|
||||
@Size(max = 100)
|
||||
private List<Long> orderIds;
|
||||
|
||||
@Schema(description = "加工状态:0不加工、1未加工、2已加工、3部分加工", example = "[1, 2]")
|
||||
@InEnum(OrderComponentProcessStatusEnum.class)
|
||||
private List<Integer> processStatus;
|
||||
}
|
||||
|
||||
+2
-1
@@ -22,7 +22,8 @@ public interface OrderComponentMapper extends BaseMapperX<OrderComponentDO> {
|
||||
* @param orderIds
|
||||
* @return
|
||||
*/
|
||||
List<OrderComponentDO> selectAllForFlatList(@Param("orderIds") List<Long> orderIds);
|
||||
List<OrderComponentDO> selectAllForFlatList(@Param("orderIds") List<Long> orderIds,
|
||||
@Param("processStatus") List<Integer> processStatus);
|
||||
|
||||
/**
|
||||
* 订单详情部件列表查询
|
||||
|
||||
+76
-6
@@ -185,7 +185,7 @@ public class AssemblyListServiceImpl implements AssemblyListService {
|
||||
public List<AssemblyListComponentFlatRespVO> getComponentFlatList(
|
||||
AssemblyListComponentFlatReqVO reqVO) {
|
||||
List<OrderComponentDO> components =
|
||||
orderComponentMapper.selectAllForFlatList(reqVO.getOrderIds());
|
||||
orderComponentMapper.selectAllForFlatList(reqVO.getOrderIds(), reqVO.getProcessStatus());
|
||||
if (CollUtil.isEmpty(components)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -259,6 +259,36 @@ public class AssemblyListServiceImpl implements AssemblyListService {
|
||||
throw new ServiceException(ORDER_COMPONENT_NOT_EXIST);
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(reqVO.getProcessStatus())) {
|
||||
LambdaQueryWrapperX<OrderComponentDO> filteredParentQuery =
|
||||
new LambdaQueryWrapperX<OrderComponentDO>()
|
||||
.in(OrderComponentDO::getId, queryIds)
|
||||
.eq(OrderComponentDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
|
||||
.selectX(
|
||||
OrderComponentDO::getId,
|
||||
OrderComponentDO::getPid,
|
||||
OrderComponentDO::getOrderId,
|
||||
OrderComponentDO::getName,
|
||||
OrderComponentDO::getWidth,
|
||||
OrderComponentDO::getHeight,
|
||||
OrderComponentDO::getDepth,
|
||||
OrderComponentDO::getProcessStatus,
|
||||
OrderComponentDO::getExtraProcessStatus
|
||||
);
|
||||
appendProcessStatusCondition(filteredParentQuery, reqVO.getProcessStatus());
|
||||
parentComponents = orderComponentMapper.selectList(filteredParentQuery);
|
||||
if (CollUtil.isEmpty(parentComponents)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Set<Long> matchedParentIds = parentComponents.stream()
|
||||
.map(OrderComponentDO::getId)
|
||||
.collect(Collectors.toSet());
|
||||
componentIds = componentIds.stream()
|
||||
.filter(matchedParentIds::contains)
|
||||
.toList();
|
||||
}
|
||||
|
||||
// 只有顶级节点才允许使用 extraProcessStatus;非顶级节点始终返回自身 processStatus。
|
||||
for (OrderComponentDO parentComponent : parentComponents) {
|
||||
if (Objects.equals(parentComponent.getPid(), OrderComponentDO.PARENT_ID_ROOT)
|
||||
@@ -277,13 +307,13 @@ public class AssemblyListServiceImpl implements AssemblyListService {
|
||||
Map<Long, AssemblyComponentChildPrintRespVO> parentMap =
|
||||
createPrintParentMap(componentIds, componentDOMap);
|
||||
if (CollUtil.isNotEmpty(componentIds)) {
|
||||
List<OrderComponentDO> childComponents = orderComponentMapper.selectList(
|
||||
LambdaQueryWrapperX<OrderComponentDO> childQuery =
|
||||
new LambdaQueryWrapperX<OrderComponentDO>()
|
||||
.in(OrderComponentDO::getPid, componentIds)
|
||||
.in(OrderComponentDO::getOrderId, orderIds)
|
||||
.eq(OrderComponentDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
|
||||
.orderByAsc(OrderComponentDO::getId)
|
||||
.select(
|
||||
.selectX(
|
||||
OrderComponentDO::getId,
|
||||
OrderComponentDO::getPid,
|
||||
OrderComponentDO::getName,
|
||||
@@ -291,9 +321,12 @@ public class AssemblyListServiceImpl implements AssemblyListService {
|
||||
OrderComponentDO::getHeight,
|
||||
OrderComponentDO::getDepth,
|
||||
OrderComponentDO::getRoomName,
|
||||
OrderComponentDO::getBodyName
|
||||
)
|
||||
);
|
||||
OrderComponentDO::getBodyName,
|
||||
OrderComponentDO::getProcessStatus,
|
||||
OrderComponentDO::getExtraProcessStatus
|
||||
);
|
||||
appendProcessStatusCondition(childQuery, reqVO.getProcessStatus());
|
||||
List<OrderComponentDO> childComponents = orderComponentMapper.selectList(childQuery);
|
||||
|
||||
for (OrderComponentDO child : childComponents) {
|
||||
AssemblyComponentChildPrintRespVO parent =
|
||||
@@ -349,6 +382,43 @@ public class AssemblyListServiceImpl implements AssemblyListService {
|
||||
return new ArrayList<>(parentMap.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将加工状态转换为部件查询条件。
|
||||
* 0、3 仅匹配顶级节点的 extraProcessStatus;1、2 匹配节点的 processStatus。
|
||||
*/
|
||||
private void appendProcessStatusCondition(LambdaQueryWrapperX<OrderComponentDO> query,
|
||||
List<Integer> processStatus) {
|
||||
if (CollUtil.isEmpty(processStatus)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Integer> topStatuses = processStatus.stream()
|
||||
.filter(status -> Objects.equals(status, OrderComponentProcessStatusEnum.NOT_PROCESS.getStatus())
|
||||
|| Objects.equals(status, OrderComponentProcessStatusEnum.PART_PROCESSED.getStatus()))
|
||||
.toList();
|
||||
List<Integer> commonStatuses = processStatus.stream()
|
||||
.filter(status -> Objects.equals(status, OrderComponentProcessStatusEnum.UNPROCESSED.getStatus())
|
||||
|| Objects.equals(status, OrderComponentProcessStatusEnum.PROCESSED.getStatus()))
|
||||
.toList();
|
||||
|
||||
query.and(wrapper -> {
|
||||
if (CollUtil.isNotEmpty(topStatuses)) {
|
||||
wrapper.eq(OrderComponentDO::getPid, OrderComponentDO.PARENT_ID_ROOT)
|
||||
.in(OrderComponentDO::getExtraProcessStatus, topStatuses);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(topStatuses) && CollUtil.isNotEmpty(commonStatuses)) {
|
||||
wrapper.or();
|
||||
}
|
||||
if (CollUtil.isNotEmpty(commonStatuses)) {
|
||||
wrapper.in(OrderComponentDO::getProcessStatus, commonStatuses)
|
||||
.and(statusWrapper -> statusWrapper
|
||||
.ne(OrderComponentDO::getPid, OrderComponentDO.PARENT_ID_ROOT)
|
||||
.or()
|
||||
.isNull(OrderComponentDO::getExtraProcessStatus));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 按请求 ID 顺序创建父节点。
|
||||
*
|
||||
|
||||
+29
-10
@@ -3,16 +3,35 @@
|
||||
<mapper namespace="com.cf.imes.module.executor.dal.mysql.ordercomponent.OrderComponentMapper">
|
||||
<select id="selectAllForFlatList"
|
||||
resultType="com.cf.imes.module.executor.dal.dataobject.ordercomponent.OrderComponentDO">
|
||||
SELECT oc.id,
|
||||
oc.level,
|
||||
oc.name
|
||||
FROM order_component oc
|
||||
WHERE oc.deleted = 0
|
||||
AND oc.order_id IN
|
||||
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
ORDER BY oc.level DESC, oc.id ASC
|
||||
SELECT component.id,
|
||||
component.level,
|
||||
component.name
|
||||
FROM (
|
||||
SELECT oc.id,
|
||||
oc.level,
|
||||
oc.name,
|
||||
CASE
|
||||
WHEN oc.pid = 0 AND oc.extra_process_status = 0 THEN 0
|
||||
WHEN oc.pid = 0 AND oc.extra_process_status = 3 THEN 3
|
||||
WHEN oc.process_status = 2 THEN 2
|
||||
WHEN oc.process_status = 1
|
||||
AND (oc.extra_process_status IS NULL OR oc.extra_process_status != 0) THEN 1
|
||||
ELSE -1
|
||||
END AS process_status
|
||||
FROM order_component oc
|
||||
WHERE oc.deleted = 0
|
||||
AND oc.order_id IN
|
||||
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
) component
|
||||
<if test="processStatus != null and processStatus.size() > 0">
|
||||
WHERE component.process_status IN
|
||||
<foreach item="status" collection="processStatus" open="(" separator="," close=")">
|
||||
#{status}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY component.level DESC, component.id ASC
|
||||
</select>
|
||||
|
||||
<select id="getOrderDetailComponentIds" resultType="java.lang.Long">
|
||||
|
||||
Reference in New Issue
Block a user