mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
合并下级部件接口和部件下板件配件接口
This commit is contained in:
+6
-3
@@ -8,6 +8,8 @@ import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyList
|
|||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderRespVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.AssemblyComponentChildPrintReqVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.AssemblyComponentChildPrintRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderComponentRespVO;
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderComponentRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderDetailComponentPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderDetailComponentPageReqVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.plate.vo.OrderViewPartPageRespVO;
|
import com.cf.imes.module.executor.controller.admin.plate.vo.OrderViewPartPageRespVO;
|
||||||
@@ -63,12 +65,13 @@ public class AssemblyListController {
|
|||||||
return CommonResult.success(assemblyListService.getComponentList(reqVO));
|
return CommonResult.success(assemblyListService.getComponentList(reqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/component/{componentId}/children")
|
@PostMapping("/component/direct-children")
|
||||||
@Operation(summary = "装配清单-获取部件直接下级列表")
|
@Operation(summary = "装配清单-获取部件直接下级列表")
|
||||||
@Parameter(name = "componentId", description = "部件 ID", required = true, example = "1024")
|
@Parameter(name = "componentId", description = "部件 ID", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('production:assemblyList:query')")
|
@PreAuthorize("@ss.hasPermission('production:assemblyList:query')")
|
||||||
public CommonResult<List<OrderComponentRespVO>> getDirectChildComponentList(@PathVariable Long componentId) {
|
public CommonResult<List<AssemblyComponentChildPrintRespVO>> getDirectChildComponentList(
|
||||||
return success(assemblyListService.getDirectChildComponentList(componentId));
|
@Valid @RequestBody AssemblyComponentChildPrintReqVO reqVO) {
|
||||||
|
return success(assemblyListService.getDirectChildComponentList(reqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/list/view/plate/page")
|
@PostMapping("/list/view/plate/page")
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package com.cf.imes.module.executor.controller.admin.ordercomponent.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2026/7/13 10:24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "装配清单 - 查询部件子元素表格请求")
|
||||||
|
public class AssemblyComponentChildPrintReqVO {
|
||||||
|
@Schema(description = "上级部件ID列表", example = "[1001, 1002]")
|
||||||
|
@Size(max = 200)
|
||||||
|
private List<Long> componentIds;
|
||||||
|
|
||||||
|
@Schema(description = "底层部件ID列表", example = "[1003, 1004]")
|
||||||
|
@Size(max = 200)
|
||||||
|
private List<Long> bottomComponentIds;
|
||||||
|
|
||||||
|
@Schema(description = "订单 ID 列表", example = "[10001, 10002]", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "订单 ID 不能为空")
|
||||||
|
@Size(max = 100)
|
||||||
|
private List<Long> orderIds;
|
||||||
|
}
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
package com.cf.imes.module.executor.controller.admin.ordercomponent.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2026/7/13 10:17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@Schema(description = "装配清单 - 部件表格数据查询")
|
||||||
|
public class AssemblyComponentChildPrintRespVO {
|
||||||
|
@Schema(description = "编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "长")
|
||||||
|
private BigDecimal length;
|
||||||
|
|
||||||
|
@Schema(description = "宽")
|
||||||
|
private BigDecimal width;
|
||||||
|
|
||||||
|
@Schema(description = "厚")
|
||||||
|
private BigDecimal thickness;
|
||||||
|
|
||||||
|
@Schema(description = "数量")
|
||||||
|
private BigDecimal quantity;
|
||||||
|
|
||||||
|
@Schema(description = "房名")
|
||||||
|
private String roomName;
|
||||||
|
|
||||||
|
@Schema(description = "柜名")
|
||||||
|
private String bodyName;
|
||||||
|
|
||||||
|
@Schema(description = "子元素")
|
||||||
|
private List<AssemblyComponentChildPrintRespVO> children;
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package com.cf.imes.module.executor.dal.dataobject.orderItem;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2026/7/13 10:50
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AssemblyComponentChildPrintItemDO {
|
||||||
|
private Long compId;
|
||||||
|
private Long bodyId;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private BigDecimal length;
|
||||||
|
private BigDecimal width;
|
||||||
|
private BigDecimal thickness;
|
||||||
|
|
||||||
|
private BigDecimal quantity;
|
||||||
|
private String roomName;
|
||||||
|
private String bodyName;
|
||||||
|
}
|
||||||
+23
@@ -11,6 +11,7 @@ import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPlatesDe
|
|||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPrintDetailRespVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPrintDetailRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRespVO;
|
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateRespVO;
|
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateRespVO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderItem.AssemblyComponentChildPrintItemDO;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO;
|
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPartsPageDO;
|
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPartsPageDO;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPlatesPageDO;
|
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPlatesPageDO;
|
||||||
@@ -366,4 +367,26 @@ public interface OrderItemMapper extends BaseMapperX<OrderItemDO> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int physicalDeleteByOrderIds(@Param("ids") List<Long> ids);
|
int physicalDeleteByOrderIds(@Param("ids") List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询部件板件列表
|
||||||
|
*
|
||||||
|
* @param orderIds
|
||||||
|
* @param componentIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<AssemblyComponentChildPrintItemDO> selectAssemblyComponentPrintPlates(
|
||||||
|
@Param("orderIds") List<Long> orderIds,
|
||||||
|
@Param("componentIds") Set<Long> componentIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询部件配件列表
|
||||||
|
*
|
||||||
|
* @param orderIds
|
||||||
|
* @param componentIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<AssemblyComponentChildPrintItemDO> selectAssemblyComponentPrintParts(
|
||||||
|
@Param("orderIds") List<Long> orderIds,
|
||||||
|
@Param("componentIds") Set<Long> componentIds);
|
||||||
}
|
}
|
||||||
+5
-3
@@ -4,6 +4,8 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
|||||||
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentPageReqVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.AssemblyComponentChildPrintReqVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.AssemblyComponentChildPrintRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderComponentRespVO;
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderComponentRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrdersTopComponentListReqVO;
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrdersTopComponentListReqVO;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||||
@@ -36,10 +38,10 @@ public interface AssemblyListService {
|
|||||||
/**
|
/**
|
||||||
* 获取部件的直接下级列表。
|
* 获取部件的直接下级列表。
|
||||||
*
|
*
|
||||||
* @param componentId 部件 ID
|
* @param assemblyComponentChildPrintReqVO
|
||||||
* @return 当前部件及其直接下级部件列表
|
* @return 当前部件及其直接下级列表
|
||||||
*/
|
*/
|
||||||
List<OrderComponentRespVO> getDirectChildComponentList(Long componentId);
|
List<AssemblyComponentChildPrintRespVO> getDirectChildComponentList(AssemblyComponentChildPrintReqVO assemblyComponentChildPrintReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部件和下级所有的板件视图列表
|
* 获取部件和下级所有的板件视图列表
|
||||||
|
|||||||
+299
-17
@@ -21,12 +21,15 @@ import com.cf.imes.framework.mybatis.core.query.LambdaUpdateWrapperX;
|
|||||||
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentPageReqVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.AssemblyComponentChildPrintReqVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.AssemblyComponentChildPrintRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderComponentRespVO;
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderComponentRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderComponentTreeCompareVO;
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderComponentTreeCompareVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrdersTopComponentListReqVO;
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrdersTopComponentListReqVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.plate.vo.OrderViewPartPageRespVO;
|
import com.cf.imes.module.executor.controller.admin.plate.vo.OrderViewPartPageRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.plate.vo.OrderViewPlatePageRespVO;
|
import com.cf.imes.module.executor.controller.admin.plate.vo.OrderViewPlatePageRespVO;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderItem.AssemblyComponentChildPrintItemDO;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPartsPageDO;
|
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPartsPageDO;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPlatesPageDO;
|
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPlatesPageDO;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.ordercomponent.OrderComponentDO;
|
import com.cf.imes.module.executor.dal.dataobject.ordercomponent.OrderComponentDO;
|
||||||
@@ -40,6 +43,7 @@ import jakarta.annotation.Resource;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -47,9 +51,12 @@ import java.util.Comparator;
|
|||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -173,30 +180,305 @@ public class AssemblyListServiceImpl implements AssemblyListService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OrderComponentRespVO> getDirectChildComponentList(Long componentId) {
|
public List<AssemblyComponentChildPrintRespVO> getDirectChildComponentList(AssemblyComponentChildPrintReqVO reqVO) {
|
||||||
OrderComponentDO parent = orderComponentMapper.selectOne(new LambdaQueryWrapperX<OrderComponentDO>()
|
|
||||||
.eq(OrderComponentDO::getId, componentId)
|
/*
|
||||||
.eq(OrderComponentDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
|
* componentIds:
|
||||||
.select(OrderComponentDO::getId, OrderComponentDO::getPid, OrderComponentDO::getName,
|
* 查询这些部件的“直接下级部件”。
|
||||||
OrderComponentDO::getWidth, OrderComponentDO::getHeight, OrderComponentDO::getDepth,
|
*
|
||||||
OrderComponentDO::getCadViewFileId));
|
* bottomComponentIds:
|
||||||
if (parent == null) {
|
* 查询这些部件直属的“板件、配件”。
|
||||||
|
*
|
||||||
|
* 两个集合之间允许存在相同 ID。
|
||||||
|
* 相同 ID 在两个集合中时,必须返回两个独立父节点:
|
||||||
|
* 1. 一个节点只承载直接下级部件;
|
||||||
|
* 2. 一个节点只承载板件、配件。
|
||||||
|
*/
|
||||||
|
List<Long> componentIds = new ArrayList<>(new LinkedHashSet<>(
|
||||||
|
Optional.ofNullable(reqVO.getComponentIds()).orElseGet(Collections::emptyList)));
|
||||||
|
|
||||||
|
List<Long> bottomComponentIds = new ArrayList<>(new LinkedHashSet<>(
|
||||||
|
Optional.ofNullable(reqVO.getBottomComponentIds()).orElseGet(Collections::emptyList)));
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(componentIds) && CollUtil.isEmpty(bottomComponentIds)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<OrderComponentDO> children = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
|
/*
|
||||||
.eq(OrderComponentDO::getPid, componentId)
|
* 数据库查询时可合并去重,减少重复查库;
|
||||||
.eq(OrderComponentDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
|
* 但仅用于查询,绝不能直接作为最终结果集。
|
||||||
.select(OrderComponentDO::getId, OrderComponentDO::getPid, OrderComponentDO::getName,
|
*
|
||||||
OrderComponentDO::getWidth, OrderComponentDO::getHeight, OrderComponentDO::getDepth,
|
* 原因:同一个部件同时出现在两个入参集合时,
|
||||||
OrderComponentDO::getBodyName, OrderComponentDO::getRoomName));
|
* 最终需要返回两份不同用途的父节点数据。
|
||||||
|
*/
|
||||||
|
Set<Long> queryParentIds = new LinkedHashSet<>();
|
||||||
|
queryParentIds.addAll(componentIds);
|
||||||
|
queryParentIds.addAll(bottomComponentIds);
|
||||||
|
|
||||||
List<OrderComponentRespVO> result = new ArrayList<>(children.size() + 1);
|
|
||||||
result.add(BeanUtil.toBean(parent, OrderComponentRespVO.class));
|
/*
|
||||||
result.addAll(BeanUtil.copyToList(children, OrderComponentRespVO.class));
|
* 部件与订单强关联:
|
||||||
|
* orderIds 必须参与查询,既限制本次查询范围,
|
||||||
|
* 也便于 MyCAT 按订单分片路由。
|
||||||
|
*/
|
||||||
|
List<OrderComponentDO> parentComponents = orderComponentMapper.selectList(
|
||||||
|
new LambdaQueryWrapperX<OrderComponentDO>()
|
||||||
|
.in(OrderComponentDO::getId, queryParentIds)
|
||||||
|
.in(OrderComponentDO::getOrderId, reqVO.getOrderIds())
|
||||||
|
.eq(OrderComponentDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
|
||||||
|
.select(
|
||||||
|
OrderComponentDO::getId,
|
||||||
|
OrderComponentDO::getOrderId,
|
||||||
|
OrderComponentDO::getName,
|
||||||
|
OrderComponentDO::getWidth,
|
||||||
|
OrderComponentDO::getHeight,
|
||||||
|
OrderComponentDO::getDepth
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 若数量不一致,说明存在以下任一情况:
|
||||||
|
* 1. 部件不存在;
|
||||||
|
* 2. 部件已删除;
|
||||||
|
* 3. 部件不属于前端传入的订单范围。
|
||||||
|
*/
|
||||||
|
if (parentComponents.size() != queryParentIds.size()) {
|
||||||
|
throw new ServiceException(ORDER_COMPONENT_NOT_EXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Long, OrderComponentDO> componentDOMap = parentComponents.stream()
|
||||||
|
.collect(Collectors.toMap(OrderComponentDO::getId, Function.identity()));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 必须创建两份独立的父节点 Map。
|
||||||
|
*
|
||||||
|
* 即使 componentIds 和 bottomComponentIds 中包含相同的部件 ID,
|
||||||
|
* 两个 Map 中也会存在两个不同的 RespVO 实例,防止子数据混合。
|
||||||
|
*/
|
||||||
|
Map<Long, AssemblyComponentChildPrintRespVO> directChildParentMap =
|
||||||
|
createPrintParentMap(componentIds, componentDOMap);
|
||||||
|
|
||||||
|
Map<Long, AssemblyComponentChildPrintRespVO> bottomComponentParentMap =
|
||||||
|
createPrintParentMap(bottomComponentIds, componentDOMap);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 第一类父节点:
|
||||||
|
* 仅查询并挂载“直接下级部件”。
|
||||||
|
*
|
||||||
|
* 这里按 pid 查询,只查一层,不递归查询孙级部件。
|
||||||
|
*/
|
||||||
|
if (CollUtil.isNotEmpty(componentIds)) {
|
||||||
|
List<OrderComponentDO> childComponents = orderComponentMapper.selectList(
|
||||||
|
new LambdaQueryWrapperX<OrderComponentDO>()
|
||||||
|
.in(OrderComponentDO::getPid, componentIds)
|
||||||
|
.in(OrderComponentDO::getOrderId, reqVO.getOrderIds())
|
||||||
|
.eq(OrderComponentDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
|
||||||
|
.orderByAsc(OrderComponentDO::getId)
|
||||||
|
.select(
|
||||||
|
OrderComponentDO::getId,
|
||||||
|
OrderComponentDO::getPid,
|
||||||
|
OrderComponentDO::getName,
|
||||||
|
OrderComponentDO::getWidth,
|
||||||
|
OrderComponentDO::getHeight,
|
||||||
|
OrderComponentDO::getDepth,
|
||||||
|
OrderComponentDO::getRoomName,
|
||||||
|
OrderComponentDO::getBodyName
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
for (OrderComponentDO child : childComponents) {
|
||||||
|
AssemblyComponentChildPrintRespVO parent =
|
||||||
|
directChildParentMap.get(child.getPid());
|
||||||
|
|
||||||
|
if (parent != null) {
|
||||||
|
// false:子部件不创建 children
|
||||||
|
parent.getChildren().add(convertPrintComponent(child, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 第二类父节点:
|
||||||
|
* 仅查询并挂载直属板件、配件。
|
||||||
|
*/
|
||||||
|
if (CollUtil.isNotEmpty(bottomComponentIds)) {
|
||||||
|
/*
|
||||||
|
* 板件数量在业务上固定为 1。
|
||||||
|
* SQL 已根据 order_item.comp_id 取得板件归属部件,
|
||||||
|
* 并根据 order_item.body_id 取得实际房间、柜体。
|
||||||
|
*/
|
||||||
|
List<AssemblyComponentChildPrintItemDO> plates =
|
||||||
|
orderItemMapper.selectAssemblyComponentPrintPlates(
|
||||||
|
reqVO.getOrderIds(), new LinkedHashSet<>(bottomComponentIds));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 配件可能对应多条 order_item 明细。
|
||||||
|
* 先查明细,再在内存中按“部件 + 柜体 + 配件”聚合数量。
|
||||||
|
*/
|
||||||
|
List<AssemblyComponentChildPrintItemDO> partRows =
|
||||||
|
orderItemMapper.selectAssemblyComponentPrintParts(
|
||||||
|
reqVO.getOrderIds(), new LinkedHashSet<>(bottomComponentIds));
|
||||||
|
|
||||||
|
List<AssemblyComponentChildPrintItemDO> parts =
|
||||||
|
mergeAssemblyComponentPrintParts(partRows);
|
||||||
|
|
||||||
|
for (AssemblyComponentChildPrintItemDO plate : plates) {
|
||||||
|
AssemblyComponentChildPrintRespVO parent =
|
||||||
|
bottomComponentParentMap.get(plate.getCompId());
|
||||||
|
|
||||||
|
if (parent != null) {
|
||||||
|
parent.getChildren().add(convertPrintItem(plate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AssemblyComponentChildPrintItemDO part : parts) {
|
||||||
|
AssemblyComponentChildPrintRespVO parent =
|
||||||
|
bottomComponentParentMap.get(part.getCompId());
|
||||||
|
|
||||||
|
if (parent != null) {
|
||||||
|
parent.getChildren().add(convertPrintItem(part));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 两类父节点分段返回,不能合并。
|
||||||
|
*
|
||||||
|
* 若同一部件 ID 同时位于两个集合:
|
||||||
|
* - 第一段:展示其直接下级部件;
|
||||||
|
* - 第二段:展示其板件、配件。
|
||||||
|
*/
|
||||||
|
List<AssemblyComponentChildPrintRespVO> result = new ArrayList<>(
|
||||||
|
directChildParentMap.size() + bottomComponentParentMap.size());
|
||||||
|
|
||||||
|
result.addAll(directChildParentMap.values());
|
||||||
|
result.addAll(bottomComponentParentMap.values());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按请求 ID 顺序创建父节点。
|
||||||
|
*
|
||||||
|
* 父节点是树的唯一可展开层级,因此统一初始化 children。
|
||||||
|
* 同一部件在不同查询类型中调用本方法时,会创建不同的 RespVO 实例。
|
||||||
|
*/
|
||||||
|
private Map<Long, AssemblyComponentChildPrintRespVO> createPrintParentMap(
|
||||||
|
List<Long> componentIds,
|
||||||
|
Map<Long, OrderComponentDO> componentDOMap) {
|
||||||
|
|
||||||
|
Map<Long, AssemblyComponentChildPrintRespVO> result = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
for (Long componentId : componentIds) {
|
||||||
|
OrderComponentDO component = componentDOMap.get(componentId);
|
||||||
|
if (component != null) {
|
||||||
|
// true:父节点才初始化 children
|
||||||
|
result.put(componentId, convertPrintComponent(component, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部件节点转换。
|
||||||
|
*
|
||||||
|
* 部件原始字段是:width、height、depth;
|
||||||
|
* 打印展示统一为:length、width、thickness。
|
||||||
|
*
|
||||||
|
* @param hasChildren true 表示父节点,初始化 children;
|
||||||
|
* false 表示子部件,children 必须为 null。
|
||||||
|
*/
|
||||||
|
private AssemblyComponentChildPrintRespVO convertPrintComponent(
|
||||||
|
OrderComponentDO source, boolean hasChildren) {
|
||||||
|
|
||||||
|
AssemblyComponentChildPrintRespVO target = new AssemblyComponentChildPrintRespVO();
|
||||||
|
target.setId(source.getId());
|
||||||
|
target.setName(source.getName());
|
||||||
|
target.setLength(toBigDecimal(source.getHeight()));
|
||||||
|
target.setWidth(toBigDecimal(source.getWidth()));
|
||||||
|
target.setThickness(toBigDecimal(source.getDepth()));
|
||||||
|
target.setRoomName(source.getRoomName());
|
||||||
|
target.setBodyName(source.getBodyName());
|
||||||
|
|
||||||
|
// 仅父节点存在 children;叶子子部件明确设置为 null。
|
||||||
|
target.setChildren(hasChildren ? new ArrayList<>() : null);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 板件、配件节点转换。
|
||||||
|
*
|
||||||
|
* 板件和配件均为叶子节点,不设置 children。
|
||||||
|
* JsonInclude(NON_NULL) 会使响应 JSON 中不输出 children 字段。
|
||||||
|
*/
|
||||||
|
private AssemblyComponentChildPrintRespVO convertPrintItem(
|
||||||
|
AssemblyComponentChildPrintItemDO source) {
|
||||||
|
|
||||||
|
AssemblyComponentChildPrintRespVO target = new AssemblyComponentChildPrintRespVO();
|
||||||
|
target.setId(source.getId());
|
||||||
|
target.setName(source.getName());
|
||||||
|
target.setLength(source.getLength());
|
||||||
|
target.setWidth(source.getWidth());
|
||||||
|
target.setThickness(source.getThickness());
|
||||||
|
target.setQuantity(source.getQuantity());
|
||||||
|
target.setRoomName(source.getRoomName());
|
||||||
|
target.setBodyName(source.getBodyName());
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal toBigDecimal(Double value) {
|
||||||
|
return value == null ? null : BigDecimal.valueOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配件明细内存聚合。
|
||||||
|
*
|
||||||
|
* 分组维度:
|
||||||
|
* - compId:所属部件;
|
||||||
|
* - bodyId:实际所属柜体;
|
||||||
|
* - id:配件 ID。
|
||||||
|
*
|
||||||
|
* 同一配件在不同柜体、房间中出现时,不应合并;
|
||||||
|
* 同一部件、同一柜体下存在多条相同配件明细时,数量需要累加。
|
||||||
|
*/
|
||||||
|
private List<AssemblyComponentChildPrintItemDO> mergeAssemblyComponentPrintParts(
|
||||||
|
List<AssemblyComponentChildPrintItemDO> rows) {
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(rows)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, AssemblyComponentChildPrintItemDO> mergedMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
for (AssemblyComponentChildPrintItemDO row : rows) {
|
||||||
|
// 同一部件、同一柜体、同一配件才合并数量
|
||||||
|
String key = row.getCompId() + "_" + row.getBodyId() + "_" + row.getId();
|
||||||
|
|
||||||
|
AssemblyComponentChildPrintItemDO merged = mergedMap.computeIfAbsent(key, ignored -> {
|
||||||
|
AssemblyComponentChildPrintItemDO target = new AssemblyComponentChildPrintItemDO();
|
||||||
|
target.setCompId(row.getCompId());
|
||||||
|
target.setBodyId(row.getBodyId());
|
||||||
|
target.setId(row.getId());
|
||||||
|
target.setName(row.getName());
|
||||||
|
target.setLength(row.getLength());
|
||||||
|
target.setWidth(row.getWidth());
|
||||||
|
target.setThickness(row.getThickness());
|
||||||
|
target.setRoomName(row.getRoomName());
|
||||||
|
target.setBodyName(row.getBodyName());
|
||||||
|
target.setQuantity(BigDecimal.ZERO);
|
||||||
|
return target;
|
||||||
|
});
|
||||||
|
|
||||||
|
BigDecimal quantity = row.getQuantity() == null
|
||||||
|
? BigDecimal.ZERO
|
||||||
|
: row.getQuantity();
|
||||||
|
|
||||||
|
merged.setQuantity(merged.getQuantity().add(quantity));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ArrayList<>(mergedMap.values());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据装配设置计算部件节点的加工状态
|
* 根据装配设置计算部件节点的加工状态
|
||||||
*
|
*
|
||||||
|
|||||||
+86
@@ -1168,4 +1168,90 @@
|
|||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectAssemblyComponentPrintPlates"
|
||||||
|
resultType="com.cf.imes.module.executor.dal.dataobject.orderItem.AssemblyComponentChildPrintItemDO">
|
||||||
|
|
||||||
|
SELECT DISTINCT
|
||||||
|
oc.id AS compId,
|
||||||
|
p.id AS id,
|
||||||
|
p.name AS name,
|
||||||
|
p.height AS length,
|
||||||
|
p.width AS width,
|
||||||
|
p.thickness AS thickness,
|
||||||
|
1 AS quantity,
|
||||||
|
ob.room_name AS roomName,
|
||||||
|
ob.name AS bodyName
|
||||||
|
FROM order_component oc
|
||||||
|
INNER JOIN order_item i
|
||||||
|
ON i.comp_id = oc.id
|
||||||
|
AND i.order_id = oc.order_id
|
||||||
|
AND i.organ_id = oc.organ_id
|
||||||
|
AND i.body_id = oc.body_id
|
||||||
|
INNER JOIN order_plate p
|
||||||
|
ON p.id = i.plate_id
|
||||||
|
AND p.order_id = i.order_id
|
||||||
|
AND p.organ_id = i.organ_id
|
||||||
|
AND p.deleted = FALSE
|
||||||
|
LEFT JOIN order_body ob
|
||||||
|
ON ob.id = oc.body_id
|
||||||
|
AND ob.order_id = oc.order_id
|
||||||
|
AND ob.organ_id = oc.organ_id
|
||||||
|
WHERE oc.deleted = FALSE
|
||||||
|
AND i.plate_id != 0
|
||||||
|
AND i.source_id = 0
|
||||||
|
AND oc.id IN
|
||||||
|
<foreach collection="componentIds" item="componentId" open="(" separator="," close=")">
|
||||||
|
#{componentId}
|
||||||
|
</foreach>
|
||||||
|
AND oc.order_id IN
|
||||||
|
<foreach collection="orderIds" item="orderId" open="(" separator="," close=")">
|
||||||
|
#{orderId}
|
||||||
|
</foreach>
|
||||||
|
ORDER BY oc.id, p.id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAssemblyComponentPrintParts"
|
||||||
|
resultType="com.cf.imes.module.executor.dal.dataobject.orderItem.AssemblyComponentChildPrintItemDO">
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
oc.id AS compId,
|
||||||
|
oc.body_id AS bodyId,
|
||||||
|
op.id AS id,
|
||||||
|
op.name AS name,
|
||||||
|
op.length AS length,
|
||||||
|
op.width AS width,
|
||||||
|
op.thickness AS thickness,
|
||||||
|
i.num AS quantity,
|
||||||
|
ob.room_name AS roomName,
|
||||||
|
ob.name AS bodyName
|
||||||
|
FROM order_component oc
|
||||||
|
INNER JOIN order_item i
|
||||||
|
ON i.comp_id = oc.id
|
||||||
|
AND i.order_id = oc.order_id
|
||||||
|
AND i.organ_id = oc.organ_id
|
||||||
|
AND i.body_id = oc.body_id
|
||||||
|
INNER JOIN order_parts op
|
||||||
|
ON op.id = i.parts_id
|
||||||
|
AND op.order_id = i.order_id
|
||||||
|
AND op.organ_id = i.organ_id
|
||||||
|
AND op.deleted = FALSE
|
||||||
|
LEFT JOIN order_body ob
|
||||||
|
ON ob.id = oc.body_id
|
||||||
|
AND ob.order_id = oc.order_id
|
||||||
|
AND ob.organ_id = oc.organ_id
|
||||||
|
WHERE oc.deleted = FALSE
|
||||||
|
AND i.plate_id = 0
|
||||||
|
AND i.parts_id != 0
|
||||||
|
AND i.source_id = 0
|
||||||
|
AND oc.id IN
|
||||||
|
<foreach collection="componentIds" item="componentId" open="(" separator="," close=")">
|
||||||
|
#{componentId}
|
||||||
|
</foreach>
|
||||||
|
AND oc.order_id IN
|
||||||
|
<foreach collection="orderIds" item="orderId" open="(" separator="," close=")">
|
||||||
|
#{orderId}
|
||||||
|
</foreach>
|
||||||
|
ORDER BY oc.id, oc.body_id, op.id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user