订单详情、装配设置查看板件/配件分页优化和字段补充

This commit is contained in:
gaoqr
2026-05-25 13:45:12 +08:00
parent 960fb311cf
commit 69d3340f06
15 changed files with 930 additions and 242 deletions
@@ -1,13 +1,16 @@
package com.cf.imes.module.executor.controller.admin.assemblylist;
import cn.hutool.core.bean.BeanUtil;
import com.cf.imes.framework.common.pojo.CommonResult;
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.order.vo.order.OrdersViewCadViewInfoRespVO;
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.plate.vo.OrderViewPartPageRespVO;
import com.cf.imes.module.executor.controller.admin.plate.vo.OrderViewPlatePageRespVO;
import com.cf.imes.module.executor.service.assemblylist.AssemblyListService;
import com.cf.imes.module.executor.service.ordercomponent.OrderComponentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -39,6 +42,9 @@ public class AssemblyListController {
@Resource
private AssemblyListService assemblyListService;
@Resource
private OrderComponentService orderComponentService;
@PostMapping("/list")
@Operation(summary = "装配清单-获取部件列表")
@PreAuthorize("@ss.hasPermission('production:assemblyList:query')")
@@ -50,14 +56,16 @@ public class AssemblyListController {
@Operation(summary = "装配清单-获取订单部件下的板件视图分页列表数据")
@PreAuthorize("@ss.hasPermission('production:assemblyList:query')")
public CommonResult<PageResult<OrderViewPlatePageRespVO>> getComponentViewPlatesPage(@Valid @RequestBody AssemblyListComponentPageReqVO pageReqVO) {
return success(assemblyListService.getViewComponentPlatePage(pageReqVO));
OrderDetailComponentPageReqVO req = BeanUtil.copyProperties(pageReqVO, OrderDetailComponentPageReqVO.class);
return success(orderComponentService.getViewComponentPlatesPage(req));
}
@PostMapping("/list/view/part/page")
@Operation(summary = "装配清单-获取订单部件下的配件视图分页列表数据")
@PreAuthorize("@ss.hasPermission('production:assemblyList:query')")
public CommonResult<PageResult<OrderViewPartPageRespVO>> getComponentViewPartsPage(@Valid @RequestBody AssemblyListComponentPageReqVO pageReqVO) {
return success(assemblyListService.getViewComponentPartPage(pageReqVO));
OrderDetailComponentPageReqVO req = BeanUtil.copyProperties(pageReqVO, OrderDetailComponentPageReqVO.class);
return success(orderComponentService.getViewComponentPartsPage(req));
}
@PostMapping("/list/view/cadinfo")
@@ -35,4 +35,7 @@ public class OrderCadViewPlatePageReqVO extends PageParam {
@Schema(description = "名称")
private String name;
@Schema(description = "是否删除", example = "false")
private Boolean deleted = false;
}
@@ -76,6 +76,8 @@ public class OrderComponentController {
@Operation(summary = "获取部件下的板件视图分页列表数据")
@PreAuthorize("@ss.hasPermission('production:manager-list:detail')")
public CommonResult<PageResult<OrderViewPlatePageRespVO>> getComponentViewPlatesPage(@Valid @RequestBody OrderDetailComponentPageReqVO pageReqVO) {
Long orderId = pageReqVO.getOrderId();
pageReqVO.setOrderIds(List.of(orderId));
return success(orderComponentService.getViewComponentPlatesPage(pageReqVO));
}
@@ -83,6 +85,8 @@ public class OrderComponentController {
@Operation(summary = "获取部件下的配件视图分页列表数据")
@PreAuthorize("@ss.hasPermission('production:manager-list:detail')")
public CommonResult<PageResult<OrderViewPartPageRespVO>> getComponentViewPartsPage(@Valid @RequestBody OrderDetailComponentPageReqVO pageReqVO) {
Long orderId = pageReqVO.getOrderId();
pageReqVO.setOrderIds(List.of(orderId));
return success(orderComponentService.getViewComponentPartsPage(pageReqVO));
}
@@ -10,6 +10,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.util.List;
import java.util.Set;
/**
@@ -29,12 +30,16 @@ public class OrderDetailComponentPageReqVO extends PageParam {
@NotNull(message = "{order.detail.component.list.query.orderId.not.null}")
private Long orderId;
@Schema(description = "订单编号", example = "[1,2]")
@Size(max = 100, message = "{order.component.assemble.req.orderIds.max}")
private List<Long> orderIds;
@Schema(description = "部件编号", example = "[1,2]")
@Size(max = 200, message = "{order.detail.component.list.query.componentIds.max}")
private Set<Long> componentIds;
@Schema(description = "是否删除", example = "false")
private boolean deleted;
private Boolean deleted = false;;
@Schema(description = "柜体编号", example = "[1,2]")
@Size(max = 200, message = "{order.detail.component.list.query.bodyIds.max}")
@@ -84,4 +84,10 @@ public class OrderViewPartPageRespVO {
@Schema(description = "柜体id")
private Long bodyId;
@Schema(description = "加工组名称")
private String processGroupName;
@Schema(description = "部件名称")
private String componentName;
}
@@ -85,6 +85,12 @@ public class OrderViewPlatePageRespVO {
@Schema(description = "是否排孔")
private Boolean isRowHole;
@Schema(description = "排版面")
private Integer holeFace;
@Schema(description = "开门类型")
private Integer openDoorType;
@Schema(description = "备注")
private String remark;
@@ -94,6 +100,39 @@ public class OrderViewPlatePageRespVO {
@Schema(description = "柜体名称")
private String bodyName;
@Schema(description = "柜体id")
private Long bodyId;
@Schema(description = "加工组名称")
private String processGroupName;
@Schema(description = "部件名称")
private String componentName;
@Schema(description = "是否二维刀路")
private Boolean is2v;
@Schema(description = "是否双面造型")
private Boolean doubleSideModel;
@Schema(description = "是否双面排孔")
private Boolean doubleSideHole;
@Schema(description = "是否正面造型")
private Boolean frontModel;
@Schema(description = "是否侧面造型")
private Boolean backModel;
@Schema(description = "是否正面排孔")
private Boolean frontHole;
@Schema(description = "是否反面排孔")
private Boolean backHole;
@Schema(description = "是否侧面造型")
private Boolean sideModel;
@Schema(description = "是否侧面排孔")
private Boolean sideHole;
@Schema(description = "是否侧面二维刀路")
private Boolean isSide2v;
}
@@ -77,6 +77,11 @@ public class OrdersViewPlatesPageDO {
*/
private String color;
/**
* 品牌
*/
private String brand;
/**
* cad设计板编号
*/
@@ -122,6 +127,16 @@ public class OrdersViewPlatesPageDO {
*/
private Boolean isRowHole;
/**
* 排版面
*/
private Integer holeFace;
/**
* 开门类型
*/
private Integer openDoorType;
/**
* 备注
*/
@@ -141,4 +156,54 @@ public class OrdersViewPlatesPageDO {
* 柜体名称
*/
private String bodyName;
/**
* 是否二维刀路
*/
private Boolean is2v;
/**
* 是否双面造型
*/
private Boolean doubleSideModel;
/**
* 是否双面排孔
*/
private Boolean doubleSideHole;
/**
* 是否正面造型
*/
private Boolean frontModel;
/**
* 是否侧面造型
*/
private Boolean backModel;
/**
* 正面排孔
*/
private Boolean frontHole;
/**
* 反面排孔
*/
private Boolean backHole;
/**
* 是否侧面造型
*/
private Boolean sideModel;
/**
* 是否侧面排孔
*/
private Boolean sideHole;
/**
* 是否侧面二维刀路
*/
private Boolean isSide2v;
}
@@ -218,6 +218,22 @@ public interface OrderItemMapper extends BaseMapperX<OrderItemDO> {
@Param("componentIds") Set<Long> componentIds,
@Param("cadView") boolean cadView);
/**
* 分页查询订单板件id
*
* @param page
* @param orderIds
* @param bodyIds
* @param groupId
* @param componentIds
* @return
*/
IPage<Long> selectOrdersViewPlateIdsPage(@Param("page") IPage<Long> page,
@Param("orderIds") List<Long> orderIds,
@Param("bodyIds") Set<Long> bodyIds,
@Param("groupIds") Set<Long> groupId,
@Param("componentIds") Set<Long> componentIds);
/**
* 分页查询订单配件视图数据
*
@@ -237,6 +253,23 @@ public interface OrderItemMapper extends BaseMapperX<OrderItemDO> {
@Param("name") String name,
@Param("cadView") boolean cadView);
/**
* 分页查询订单板件id
*
* @param page
* @param orderIds
* @param bodyIds
* @param groupId
* @param componentIds
* @return
*/
IPage<OrdersViewPartsPageDO> selectOrdersViewPartsIdsPage(@Param("page") IPage<OrdersViewPartsPageDO> page,
@Param("orderIds") List<Long> orderIds,
@Param("bodyIds") Set<Long> bodyIds,
@Param("groupIds") Set<Long> groupId,
@Param("componentIds") Set<Long> componentIds,
@Param("name") String name);
/**
* 查询部件关联的板件ID列表
*
@@ -17,6 +17,7 @@ import com.cf.imes.module.executor.controller.admin.plate.vo.PlateGoodsIdVO;
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateGoodsRespVO;
import com.cf.imes.module.executor.controller.admin.plate.vo.PlatePageReqVO;
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateRespVO;
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPlatesPageDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDetailDO;
import org.apache.ibatis.annotations.Mapper;
@@ -391,4 +392,14 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
* @return
*/
List<Long> selectOrderComponentBodyIds(@Param("orderId") Long orderId, @Param("componentIds") List<Long> componentIds, @Param("deleted") boolean deleted);
/**
* 根据板件id列表查询板件信息
*
* @param orderIds
* @param plateIds
* @param deleted
* @return
*/
List<OrdersViewPlatesPageDO> selectPlateGoodsByIds(@Param("orderIds") List<Long> orderIds, @Param("plateIds") List<Long> plateIds, @Param("deleted") boolean deleted);
}
@@ -25,21 +25,6 @@ public interface AssemblyListService {
*/
List<OrderComponentRespVO> getComponentList(AssemblyListComponentPageReqVO reqVO);
/**
* 获取订单下板件视图分页列表
* @param reqVO
* @return
*/
PageResult<OrderViewPlatePageRespVO> getViewComponentPlatePage(AssemblyListComponentPageReqVO reqVO);
/**
* 获取订单下配件视图分页列表
*
* @param reqVO
* @return
*/
PageResult<OrderViewPartPageRespVO> getViewComponentPartPage(AssemblyListComponentPageReqVO reqVO);
/**
* 获取部件和下级所有的板件视图列表
* @param reqVO
@@ -14,7 +14,6 @@ import com.cf.imes.framework.common.enums.DeletedCodeEnum;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.Assert.AssertUtils;
import com.cf.imes.framework.common.util.json.JsonUtils;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
@@ -557,128 +556,6 @@ public class AssemblyListServiceImpl implements AssemblyListService {
}
}
@Override
public PageResult<OrderViewPlatePageRespVO> getViewComponentPlatePage(AssemblyListComponentPageReqVO pageReqVO) {
Set<Long> componentIds = pageReqVO.getComponentIds();
if (CollUtil.isEmpty(componentIds)) {
return new PageResult<>(Collections.emptyList(), 0L);
}
// 1、查询顶级
List<OrderComponentDO> componentDOS = orderComponentMapper.selectByIds(componentIds);
if (CollUtil.isEmpty(componentDOS) || componentDOS.size() != componentIds.size()) {
throw new ServiceException(ORDER_COMPONENT_NOT_EXIST);
}
// 整理所在订单id列表
List<Long> orderIds = componentDOS.stream()
.map(OrderComponentDO::getOrderId)
.distinct()
.toList();
// 整理所在顶级配件id列表
List<Long> topIds = componentDOS.stream()
.map(OrderComponentDO::getTopId)
.toList();
// 2、把下级部件id作为查询条件
List<OrderComponentDO> orderComponentDOS = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
.in(OrderComponentDO::getTopId, topIds)
.in(OrderComponentDO::getOrderId, orderIds)
.eq(OrderComponentDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
.select(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId, OrderComponentDO::getPid));
Set<Long> queryComponentIds = new HashSet<>();
if (CollUtil.isNotEmpty(orderComponentDOS)) {
for (OrderComponentDO co : componentDOS) {
queryComponentIds.addAll(getChildrenIds(co, orderComponentDOS));
}
} else {
return new PageResult<>();
}
// 整理出id和cadViewFileId的对应关系
Map<Long, Long> cadViewFileIdMap = orderComponentDOS.stream()
.filter(item -> item.getCadViewFileId() != null)
.collect(Collectors.toMap(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId));
// 分页查询板件
PageDTO<OrdersViewPlatesPageDO> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
IPage<OrdersViewPlatesPageDO> pageRes = orderItemMapper.selectOrdersViewPlatesPage(page, orderIds, null, null, queryComponentIds, false);
long total = pageRes.getTotal();
List<OrdersViewPlatesPageDO> records = pageRes.getRecords();
List<OrderViewPlatePageRespVO> resultList = new ArrayList<>();
if (total > 0) {
resultList = records.stream().map(item -> {
OrderViewPlatePageRespVO vo = new OrderViewPlatePageRespVO();
BeanUtil.copyProperties(item, vo);
vo.setCadViewFileId(cadViewFileIdMap.get(item.getCompId()));
return vo;
}).toList();
}
return new PageResult<>(resultList, total);
}
@Override
public PageResult<OrderViewPartPageRespVO> getViewComponentPartPage(AssemblyListComponentPageReqVO pageReqVO) {
Set<Long> componentIds = pageReqVO.getComponentIds();
if (CollUtil.isEmpty(componentIds)) {
return new PageResult<>(Collections.emptyList(), 0L);
}
// 1、查询顶级
List<OrderComponentDO> componentDOS = orderComponentMapper.selectByIds(componentIds);
if (CollUtil.isEmpty(componentDOS) || componentDOS.size() != componentIds.size()) {
throw new ServiceException(ORDER_COMPONENT_NOT_EXIST);
}
// 整理所在订单id列表
List<Long> orderIds = componentDOS.stream()
.map(OrderComponentDO::getOrderId)
.distinct()
.toList();
// 整理所在顶级配件id列表
List<Long> topIds = componentDOS.stream()
.map(OrderComponentDO::getTopId)
.toList();
// 2、把下级部件id作为查询条件
List<OrderComponentDO> orderComponentDOS = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
.in(OrderComponentDO::getTopId, topIds)
.in(OrderComponentDO::getOrderId, orderIds)
.eq(OrderComponentDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
.select(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId, OrderComponentDO::getPid));
Set<Long> queryComponentIds = new HashSet<>();
if (CollUtil.isNotEmpty(orderComponentDOS)) {
for (OrderComponentDO co : componentDOS) {
queryComponentIds.addAll(getChildrenIds(co, orderComponentDOS));
}
} else {
return new PageResult<>();
}
// 整理出id和cadViewFileId的对应关系
Map<Long, Long> cadViewFileIdMap = orderComponentDOS.stream()
.filter(item -> item.getCadViewFileId() != null)
.collect(Collectors.toMap(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId));
// 分页查询板件
PageDTO<OrdersViewPartsPageDO> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
IPage<OrdersViewPartsPageDO> pageRes = orderItemMapper.selectOrdersViewPartsPage(page, orderIds, null, null, queryComponentIds, null, false);
long total = pageRes.getTotal();
List<OrdersViewPartsPageDO> records = pageRes.getRecords();
List<OrderViewPartPageRespVO> resultList = new ArrayList<>();
if (total > 0) {
resultList = records.stream().map(item -> {
OrderViewPartPageRespVO vo = new OrderViewPartPageRespVO();
BeanUtil.copyProperties(item, vo);
vo.setCadViewFileId(cadViewFileIdMap.get(item.getCompId()));
return vo;
}).toList();
}
return new PageResult<>(resultList, total);
}
@Override
public OrdersViewCadViewInfoRespVO getViewComponentPlatesCadInfo(AssemblyListComponentPageReqVO pageReqVO) {
OrdersViewCadViewInfoRespVO assemblyListComponentCadViewInfoRespVO = new OrdersViewCadViewInfoRespVO();
@@ -2,6 +2,7 @@ package com.cf.imes.module.executor.service.ordercomponent;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -26,6 +27,7 @@ import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderDetai
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.OrderViewPlatePageRespVO;
import com.cf.imes.module.executor.dal.dataobject.orderGroup.OrderGroupDO;
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO;
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemTempDO;
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPartsPageDO;
@@ -35,6 +37,7 @@ import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
import com.cf.imes.module.executor.dal.mysql.orderBody.OrderBodyMapper;
import com.cf.imes.module.executor.dal.mysql.orderGroup.OrderGroupMapper;
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemBatchMapper;
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper;
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemTempBatchMapper;
@@ -50,6 +53,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
@@ -60,6 +64,7 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -104,6 +109,9 @@ public class OrderComponentServiceImpl implements OrderComponentService {
@Resource
private OrderItemTempBatchMapper orderItemTempBatchMapper;
@Resource
private OrderGroupMapper orderGroupMapper;
@Resource
private FileApi fileApi;
@@ -203,57 +211,169 @@ public class OrderComponentServiceImpl implements OrderComponentService {
return new PageResult<>(Collections.emptyList(), 0L);
}
// 校验订单
Long orderId = pageReqVO.getOrderId();
OrderDO orderDO = orderMapper.selectById(orderId);
AssertUtils.notEmpty(orderDO,ORDER_NOT_EXISTS);
List<Long> orderIds = pageReqVO.getOrderIds();
List<OrderDO> orderDOS = orderMapper.selectByIds(orderIds);
AssertUtils.notEmpty(orderDOS, ORDER_NOT_EXISTS);
// 1、查询顶级
// 查询部件
List<OrderComponentDO> componentDOS = orderComponentMapper.selectByIds(componentIds);
if (CollUtil.isEmpty(componentDOS) || componentDOS.size() != componentIds.size()) {
throw new ServiceException(ORDER_COMPONENT_NOT_EXIST);
}
List<Long> topIds = componentDOS.stream()
.map(OrderComponentDO::getTopId)
.toList();
// 2、把下级部件id作为查询条件
List<OrderComponentDO> orderComponentDOS = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
.in(OrderComponentDO::getTopId, topIds)
.eq(OrderComponentDO::getOrderId, orderId)
.eqIfPresent(OrderComponentDO::getDeleted, pageReqVO.isDeleted())
.select(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId, OrderComponentDO::getPid));
Set<Long> queryComponentIds = new HashSet<>();
if (CollUtil.isNotEmpty(orderComponentDOS)) {
for (OrderComponentDO co : componentDOS) {
queryComponentIds.addAll(getChildrenIds(co, orderComponentDOS));
}
} else {
if (CollUtil.isEmpty(componentDOS)) {
return new PageResult<>();
}
Set<Long> queryComponentIds = componentDOS.stream().map(OrderComponentDO::getId).collect(Collectors.toSet());
// 整理出id和cadViewFileId的对应关系
Map<Long, Long> cadViewFileIdMap = orderComponentDOS.stream()
Map<Long, OrderComponentDO> cadViewFileIdMap = componentDOS.stream()
.filter(item -> item.getCadViewFileId() != null)
.collect(Collectors.toMap(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId));
.collect(Collectors.toMap(
OrderComponentDO::getId,
Function.identity(),
(a, b) -> a
));
// 分页查询板件
PageDTO<OrdersViewPlatesPageDO> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
IPage<OrdersViewPlatesPageDO> pageRes = orderItemMapper.selectOrdersViewPlatesPage(page, List.of(orderId), null,
null, queryComponentIds, false);
long total = pageRes.getTotal();
List<OrdersViewPlatesPageDO> records = pageRes.getRecords();
// 分页获取板件id
IPage<Long> plateIdPage = orderItemMapper.selectOrdersViewPlateIdsPage(new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()),
orderIds, null, null, queryComponentIds);
List<OrderViewPlatePageRespVO> resultList = new ArrayList<>();
if(total > 0) {
resultList = records.stream().map(item -> {
OrderViewPlatePageRespVO vo = new OrderViewPlatePageRespVO();
BeanUtil.copyProperties(item, vo);
vo.setCadViewFileId(cadViewFileIdMap.get(item.getCompId()));
return vo;
}).toList();
List<Long> plateIdPageRecords = plateIdPage.getRecords();
if(CollUtil.isEmpty(plateIdPageRecords)) {
return new PageResult<>(Collections.emptyList(), 0L);
}
return new PageResult<>(resultList, total);
// 查询板件+板材信息
List<OrdersViewPlatesPageDO> ordersViewPlatesPageDOS = plateMapper.selectPlateGoodsByIds(orderIds, plateIdPageRecords, pageReqVO.getDeleted());
// 查询关联关系
List<OrderItemDO> orderItemRelation = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
.in(OrderItemDO::getOrderId, pageReqVO.getOrderIds())
.in(OrderItemDO::getPlateId, plateIdPageRecords)
.select(OrderItemDO::getPlateId, OrderItemDO::getRoomId, OrderItemDO::getBodyId, OrderItemDO::getCadViewId, OrderItemDO::getGroupId, OrderItemDO::getCompId)
);
// 暂存plateId:set<groupId>
Map<Long, Set<Long>> plateGroupMap = new HashMap<>();
// 暂存plateId:set<compId>
Map<Long, Set<Long>> plateCompMap = new HashMap<>();
// 暂存plateId:bodyId
Map<Long, Long> plateBodyMap = new HashMap<>();
Map<Long, OrdersViewPlatesPageDO> plateMap =
ordersViewPlatesPageDOS.stream()
.collect(Collectors.toMap(
OrdersViewPlatesPageDO::getId,
Function.identity(),
(a, b) -> a
));
for (OrderItemDO item : orderItemRelation) {
Long plateId = item.getPlateId();
// 累计plateId下group_id
if (item.getGroupId() != null) {
plateGroupMap
.computeIfAbsent(plateId, k -> new HashSet<>())
.add(item.getGroupId());
}
// 记录plateId下body_id
if (item.getBodyId() != null) {
plateBodyMap
.computeIfAbsent(plateId, k -> item.getBodyId());
}
// 累计plateId下comp_id
if (item.getCompId() != null) {
plateCompMap
.computeIfAbsent(plateId, k -> new HashSet<>())
.add(item.getCompId());
}
// 单值字段
OrdersViewPlatesPageDO plate = plateMap.get(plateId);
if (plate != null) {
plate.setCadViewId(item.getCadViewId());
}
}
// 查询加工组
Set<Long> allGroupIds = plateGroupMap.values()
.stream()
.flatMap(Set::stream)
.collect(Collectors.toSet());
Map<Long, String> groupNameMap = Collections.emptyMap();
if (!allGroupIds.isEmpty()) {
groupNameMap = orderGroupMapper.selectByIds(allGroupIds)
.stream()
.collect(Collectors.toMap(
OrderGroupDO::getId,
OrderGroupDO::getName,
(a, b) -> a
));
}
// 查询房间
Set<Long> allBodyIds = plateBodyMap.values()
.stream()
.collect(Collectors.toSet());
Map<Long, OrderBodyDO> bodyMap = Collections.emptyMap();
if (!allBodyIds.isEmpty()) {
bodyMap = orderBodyMapper.selectByIds(allBodyIds)
.stream()
.collect(Collectors.toMap(
OrderBodyDO::getId,
Function.identity(),
(a, b) -> a
));
}
List<OrderViewPlatePageRespVO> records = new ArrayList<>();
for (Map.Entry<Long, OrdersViewPlatesPageDO> entry : plateMap.entrySet()) {
Long plateId = entry.getKey();
OrdersViewPlatesPageDO plate = entry.getValue();
OrderViewPlatePageRespVO plateRespVO = BeanUtil.copyProperties(plate, OrderViewPlatePageRespVO.class);
// 用逗号拼接加工组名称
Set<Long> groupIds = plateGroupMap.getOrDefault(plateId, Collections.emptySet());
List<String> groupNames = groupIds.stream()
.map(groupNameMap::get)
.filter(Objects::nonNull)
.toList();
plateRespVO.setProcessGroupName(String.join(",", groupNames));
// 用逗号拼接部件组名称
Set<Long> compIds = plateCompMap.getOrDefault(plateId, Collections.emptySet());
List<OrderComponentDO> comps = compIds.stream()
.map(cadViewFileIdMap::get)
.filter(Objects::nonNull)
.toList();
if (CollUtil.isNotEmpty(comps)) {
plateRespVO.setComponentName(String.join(",", comps.stream().map(OrderComponentDO::getName).collect(Collectors.toSet())));
plateRespVO.setCadViewFileId(comps.get(0).getCadViewFileId());
}
// 匹配房间名、柜体名、图纸id
OrderBodyDO orderBodyDO = bodyMap.get(plate.getBodyId());
if(ObjectUtil.isNotNull(orderBodyDO)) {
plateRespVO.setBodyName(orderBodyDO.getName());
plateRespVO.setRoomName(orderBodyDO.getRoomName());
}
records.add(plateRespVO);
}
return new PageResult<>(records, plateIdPage.getTotal());
}
@Override
@@ -263,57 +383,149 @@ public class OrderComponentServiceImpl implements OrderComponentService {
return new PageResult<>(Collections.emptyList(), 0L);
}
// 校验订单
Long orderId = pageReqVO.getOrderId();
OrderDO orderDO = orderMapper.selectById(orderId);
AssertUtils.notEmpty(orderDO, ORDER_NOT_EXISTS);
List<Long> orderIds = pageReqVO.getOrderIds();
List<OrderDO> orderDOS = orderMapper.selectByIds(orderIds);
AssertUtils.notEmpty(orderDOS, ORDER_NOT_EXISTS);
// 1、查询顶级
// 查询部件
List<OrderComponentDO> componentDOS = orderComponentMapper.selectByIds(componentIds);
if (CollUtil.isEmpty(componentDOS) || componentDOS.size() != componentIds.size()) {
throw new ServiceException(ORDER_COMPONENT_NOT_EXIST);
}
List<Long> topIds = componentDOS.stream()
.map(OrderComponentDO::getTopId)
.toList();
// 2、把下级部件id作为查询条件
List<OrderComponentDO> orderComponentDOS = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
.in(OrderComponentDO::getTopId, topIds)
.eq(OrderComponentDO::getOrderId, orderId)
.eqIfPresent(OrderComponentDO::getDeleted, pageReqVO.isDeleted())
.select(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId, OrderComponentDO::getPid));
Set<Long> queryComponentIds = new HashSet<>();
if (CollUtil.isNotEmpty(orderComponentDOS)) {
for (OrderComponentDO co : componentDOS) {
queryComponentIds.addAll(getChildrenIds(co, orderComponentDOS));
}
} else {
if (CollUtil.isEmpty(componentDOS)) {
return new PageResult<>();
}
Set<Long> queryComponentIds = componentDOS.stream().map(OrderComponentDO::getId).collect(Collectors.toSet());
// 整理出id和cadViewFileId的对应关系
Map<Long, Long> cadViewFileIdMap = orderComponentDOS.stream()
Map<Long, OrderComponentDO> cadViewFileIdMap = componentDOS.stream()
.filter(item -> item.getCadViewFileId() != null)
.collect(Collectors.toMap(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId));
.collect(Collectors.toMap(
OrderComponentDO::getId,
Function.identity(),
(a, b) -> a
));
// 分页查询板件
// 查询配件编号+信息
PageDTO<OrdersViewPartsPageDO> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
IPage<OrdersViewPartsPageDO> pageRes = orderItemMapper.selectOrdersViewPartsPage(page, List.of(orderId), null,
null, queryComponentIds, null, false);
long total = pageRes.getTotal();
List<OrdersViewPartsPageDO> records = pageRes.getRecords();
IPage<OrdersViewPartsPageDO> pageRes = orderItemMapper.selectOrdersViewPartsIdsPage(page, orderIds, null, null, queryComponentIds, null);
List<OrderViewPartPageRespVO> resultList = new ArrayList<>();
if (total > 0) {
resultList = records.stream().map(item -> {
OrderViewPartPageRespVO vo = new OrderViewPartPageRespVO();
BeanUtil.copyProperties(item, vo);
vo.setCadViewFileId(cadViewFileIdMap.get(item.getCompId()));
return vo;
}).toList();
List<OrdersViewPartsPageDO> partsPageRecords = pageRes.getRecords();
if(CollUtil.isEmpty(partsPageRecords)) {
return new PageResult<>(Collections.emptyList(), 0L);
}
return new PageResult<>(resultList, total);
List<Long> partsIds = partsPageRecords.stream().map(OrdersViewPartsPageDO::getId).toList();
// 查询关联关系
List<OrderItemDO> orderItemRelation = orderItemMapper.selectList(new LambdaQueryWrapperX<OrderItemDO>()
.in(OrderItemDO::getOrderId, pageReqVO.getOrderIds())
.inIfPresent(OrderItemDO::getCompId, queryComponentIds)
.in(OrderItemDO::getPartsId, partsIds)
.select(OrderItemDO::getPartsId, OrderItemDO::getCadViewId, OrderItemDO::getGroupId, OrderItemDO::getCompId, OrderItemDO::getNum)
);
// 暂存 partsId:set<groupId>
Map<Pair<Long, Integer>, Set<Long>> partsGroupMap = new HashMap<>();
// 暂存 partsId:set<compId>
Map<Pair<Long, Integer>, Set<Long>> partsCompMap = new HashMap<>();
// 暂存 partsId:num
Map<Pair<Long, Integer>, Double> partsNumMap = new HashMap<>();
for (OrderItemDO item : orderItemRelation) {
Long partsId = item.getPartsId();
Integer cadViewId = item.getCadViewId();
Pair<Long, Integer> pair = new Pair<>(partsId, cadViewId);
// group_id
if (item.getGroupId() != null) {
partsGroupMap
.computeIfAbsent(pair, k -> new HashSet<>())
.add(item.getGroupId());
}
// comp_id
if (item.getCompId() != null) {
partsCompMap
.computeIfAbsent(pair, k -> new HashSet<>())
.add(item.getCompId());
}
// num 汇总
if (item.getNum() != null) {
partsNumMap.merge(
pair,
item.getNum(),
Double::sum
);
}
}
// 查询加工组
Set<Long> allGroupIds = partsGroupMap.values()
.stream()
.flatMap(Set::stream)
.collect(Collectors.toSet());
Map<Long, String> groupNameMap = Collections.emptyMap();
if (!allGroupIds.isEmpty()) {
groupNameMap = orderGroupMapper.selectByIds(allGroupIds)
.stream()
.collect(Collectors.toMap(
OrderGroupDO::getId,
OrderGroupDO::getName,
(a, b) -> a
));
}
// 最终组装
List<OrderViewPartPageRespVO> records = new ArrayList<>();
for (OrdersViewPartsPageDO part : partsPageRecords) {
Pair<Long, Integer> pair = new Pair<>(part.getId(), part.getCadViewId());
OrderViewPartPageRespVO partRespVO = BeanUtil.copyProperties(part, OrderViewPartPageRespVO.class);
// 设置数量
partRespVO.setNum(
BigDecimal.valueOf(partsNumMap.getOrDefault(pair, 0.0))
);
// 拼接加工组名称
Set<Long> groupIdsSet = partsGroupMap.getOrDefault(
pair,
Collections.emptySet()
);
String processGroupName = groupIdsSet.stream()
.map(groupNameMap::get)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.joining(","));
partRespVO.setProcessGroupName(processGroupName);
// 用逗号拼接部件组名称
Set<Long> compIds = partsCompMap.getOrDefault(pair, Collections.emptySet());
List<OrderComponentDO> comps = compIds.stream()
.map(cadViewFileIdMap::get)
.filter(Objects::nonNull)
.toList();
if (CollUtil.isNotEmpty(comps)) {
partRespVO.setComponentName(String.join(",", comps.stream().map(OrderComponentDO::getName).collect(Collectors.toSet())));
partRespVO.setCadViewFileId(comps.get(0).getCadViewFileId());
}
records.add(partRespVO);
}
return new PageResult<>(records, pageRes.getTotal());
}
@Override
@@ -335,7 +547,7 @@ public class OrderComponentServiceImpl implements OrderComponentService {
List<OrderComponentDO> orderComponentDOS = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
.in(OrderComponentDO::getTopId, topIds)
.eq(OrderComponentDO::getOrderId, orderId)
.eqIfPresent(OrderComponentDO::getDeleted, pageReqVO.isDeleted())
.eqIfPresent(OrderComponentDO::getDeleted, pageReqVO.getDeleted())
.select(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId, OrderComponentDO::getPid));
Set<Long> queryComponentIds = new HashSet<>();
if (CollUtil.isNotEmpty(orderComponentDOS)) {
@@ -875,7 +1087,7 @@ public class OrderComponentServiceImpl implements OrderComponentService {
List<OrderComponentDO> orderComponentDOS = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
.in(OrderComponentDO::getTopId, topIds)
.eq(OrderComponentDO::getOrderId, orderId)
.eqIfPresent(OrderComponentDO::getDeleted, pageReqVO.isDeleted())
.eqIfPresent(OrderComponentDO::getDeleted, pageReqVO.getDeleted())
.select(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId, OrderComponentDO::getPid));
if (CollUtil.isNotEmpty(orderComponentDOS)) {
for (OrderComponentDO co : componentDOS) {
@@ -2,6 +2,7 @@ package com.cf.imes.module.executor.service.plate;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.ObjectUtil;
import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.FieldValue;
@@ -35,9 +36,11 @@ import com.cf.imes.module.executor.controller.admin.plate.vo.*;
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
import com.cf.imes.module.executor.dal.dataobject.orderGroup.OrderGroupDO;
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.OrdersViewPlatesPageDO;
import com.cf.imes.module.executor.dal.dataobject.ordercomponent.OrderComponentDO;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
@@ -46,7 +49,9 @@ import com.cf.imes.module.executor.dal.dataobject.plate.PlateGoodDO;
import com.cf.imes.module.executor.dal.mysql.goods.GoodsMapper;
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
import com.cf.imes.module.executor.dal.mysql.orderBody.OrderBodyMapper;
import com.cf.imes.module.executor.dal.mysql.orderGroup.OrderGroupMapper;
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper;
import com.cf.imes.module.executor.dal.mysql.ordercomponent.OrderComponentMapper;
import com.cf.imes.module.executor.dal.mysql.plan.PlanMapper;
import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper;
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
@@ -69,6 +74,7 @@ import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
@@ -135,12 +141,13 @@ public class PlateServiceImpl implements PlateService {
@Resource
private OrderItemService orderItemService;
@Resource
private OrderGroupMapper orderGroupMapper;
@Resource
private OrderComponentMapper orderComponentMapper;
private static final String FIELD_PLATE_ID = "plateId";
private static final String FIELD_OG_MATERIAL = "og.material";
private static final String FIELD_OG_BRAND = "og.brand";
private static final String FIELD_OG_COLOR = "og.color";
private static final String FIELD_OP_THICKNESS = "op.thickness";
private static final String FIELD_OG_TEXTURE = "og.texture";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -834,6 +841,7 @@ public class PlateServiceImpl implements PlateService {
@Override
public PageResult<OrderViewPlatePageRespVO> getBodyViewPlatesPage(OrderCadViewPlatePageReqVO pageReqVO) {
Set<Long> bodyIds = pageReqVO.getBodyIds();
Set<Long> groupIds = pageReqVO.getGroupIds();
if (CollUtil.isEmpty(bodyIds)) {
return new PageResult<>(Collections.emptyList(), 0L);
}
@@ -843,25 +851,156 @@ public class PlateServiceImpl implements PlateService {
}
// 整理出body_id和cad图纸id的关系
Map<Long, Long> bodyIdAndCadViewFileIdMap = orderBodyDOList.stream()
Map<Long, OrderBodyDO> bodyIdAndCadViewFileIdMap = orderBodyDOList.stream()
.filter(item -> item.getCadViewFileId() != null)
.collect(Collectors.toMap(OrderBodyDO::getId, OrderBodyDO::getCadViewFileId));
.collect(Collectors.toMap(
OrderBodyDO::getId,
Function.identity(),
(a, b) -> a
));
PageDTO<OrdersViewPlatesPageDO> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
IPage<OrdersViewPlatesPageDO> pageRes = orderItemMapper.selectOrdersViewPlatesPage(page, List.of(pageReqVO.getOrderId()),
bodyIds, pageReqVO.getGroupIds(), null, false);
List<Long> orderIds = List.of(pageReqVO.getOrderId());
List<OrdersViewPlatesPageDO> records = pageRes.getRecords();
// cad图纸id赋到每块板上
if(CollUtil.isNotEmpty(records)) {
records.forEach(item -> item.setCadViewFileId(bodyIdAndCadViewFileIdMap.get(item.getBodyId())));
// 分页获取板件id
IPage<Long> plateIdPage = orderItemMapper.selectOrdersViewPlateIdsPage(new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()),
orderIds, bodyIds, groupIds, null);
List<Long> plateIdPageRecords = plateIdPage.getRecords();
if(CollUtil.isEmpty(plateIdPageRecords)) {
return new PageResult<>(Collections.emptyList(), 0L);
}
return new PageResult<>(BeanUtil.copyToList(records, OrderViewPlatePageRespVO.class), pageRes.getTotal());
// 查询板件+板材信息
List<OrdersViewPlatesPageDO> ordersViewPlatesPageDOS = plateMapper.selectPlateGoodsByIds(orderIds, plateIdPageRecords, pageReqVO.getDeleted());
// 查询关联关系
List<OrderItemDO> orderItemRelation = orderItemMapper.selectList(new LambdaQueryWrapperX<OrderItemDO>()
.eq(OrderItemDO::getOrderId, pageReqVO.getOrderId())
.inIfPresent(OrderItemDO::getBodyId, bodyIds)
.inIfPresent(OrderItemDO::getGroupId, groupIds)
.in(OrderItemDO::getPlateId, plateIdPageRecords)
.select(OrderItemDO::getPlateId, OrderItemDO::getRoomId, OrderItemDO::getBodyId, OrderItemDO::getCadViewId, OrderItemDO::getGroupId, OrderItemDO::getCompId)
);
// 暂存plateId:set<groupId>
Map<Long, Set<Long>> plateGroupMap = new HashMap<>();
// 暂存plateId:set<compId>
Map<Long, Set<Long>> plateCompMap = new HashMap<>();
Map<Long, OrdersViewPlatesPageDO> plateMap =
ordersViewPlatesPageDOS.stream()
.collect(Collectors.toMap(
OrdersViewPlatesPageDO::getId,
Function.identity(),
(a, b) -> a
));
for (OrderItemDO item : orderItemRelation) {
Long plateId = item.getPlateId();
// 累计plateId下group_id
if (item.getGroupId() != null) {
plateGroupMap
.computeIfAbsent(plateId, k -> new HashSet<>())
.add(item.getGroupId());
}
// 累计plateId下comp_id
if (item.getCompId() != null) {
plateCompMap
.computeIfAbsent(plateId, k -> new HashSet<>())
.add(item.getCompId());
}
// 单值字段
OrdersViewPlatesPageDO plate = plateMap.get(plateId);
if (plate != null) {
plate.setBodyId(item.getBodyId());
plate.setCadViewId(item.getCadViewId());
}
}
// 查询加工组
Set<Long> allGroupIds = plateGroupMap.values()
.stream()
.flatMap(Set::stream)
.collect(Collectors.toSet());
Map<Long, String> groupNameMap = Collections.emptyMap();
if (!allGroupIds.isEmpty()) {
groupNameMap = orderGroupMapper.selectByIds(allGroupIds)
.stream()
.collect(Collectors.toMap(
OrderGroupDO::getId,
OrderGroupDO::getName,
(a, b) -> a
));
}
// 查询部件
Set<Long> allCompIds = plateCompMap.values()
.stream()
.flatMap(Set::stream)
.collect(Collectors.toSet());
Map<Long, String> compNameMap = Collections.emptyMap();
if (!allCompIds.isEmpty()) {
compNameMap = orderComponentMapper.selectByIds(allCompIds)
.stream()
.collect(Collectors.toMap(
OrderComponentDO::getId,
OrderComponentDO::getName,
(a, b) -> a
));
}
List<OrderViewPlatePageRespVO> records = new ArrayList<>();
for (Map.Entry<Long, OrdersViewPlatesPageDO> entry : plateMap.entrySet()) {
Long plateId = entry.getKey();
OrdersViewPlatesPageDO plate = entry.getValue();
OrderViewPlatePageRespVO plateRespVO = BeanUtil.copyProperties(plate, OrderViewPlatePageRespVO.class);
// 用逗号拼接加工组名称
Set<Long> plateGroupIds = plateGroupMap.getOrDefault(plateId, Collections.emptySet());
List<String> groupNames = plateGroupIds.stream()
.map(groupNameMap::get)
.filter(Objects::nonNull)
.toList();
plateRespVO.setProcessGroupName(String.join(",", groupNames));
// 用逗号拼接部件组名称
Set<Long> plateCompIds = plateCompMap.getOrDefault(plateId, Collections.emptySet());
List<String> compNames = plateCompIds.stream()
.map(compNameMap::get)
.filter(Objects::nonNull)
.toList();
plateRespVO.setComponentName(String.join(",", compNames));
// 匹配房间名、柜体名、图纸id
OrderBodyDO orderBodyDO = bodyIdAndCadViewFileIdMap.get(plate.getBodyId());
if(ObjectUtil.isNotNull(orderBodyDO)) {
plateRespVO.setBodyName(orderBodyDO.getName());
plateRespVO.setRoomName(orderBodyDO.getRoomName());
plateRespVO.setCadViewFileId(orderBodyDO.getCadViewFileId());
}
records.add(plateRespVO);
}
return new PageResult<>(records, plateIdPage.getTotal());
}
@Override
public PageResult<OrderViewPartPageRespVO> getBodyViewPartsPage(OrderCadViewPlatePageReqVO pageReqVO) {
Set<Long> bodyIds = pageReqVO.getBodyIds();
Set<Long> groupIds = pageReqVO.getGroupIds();
if (CollUtil.isEmpty(bodyIds)) {
return new PageResult<>(Collections.emptyList(), 0L);
}
@@ -870,21 +1009,167 @@ public class PlateServiceImpl implements PlateService {
throw new ServiceException(ORDER_BODY_NOT_EXISTS);
}
List<Long> orderIds = List.of(pageReqVO.getOrderId());
// 整理出body_id和cad图纸id的关系
Map<Long, Long> bodyIdAndCadViewFileIdMap = orderBodyDOList.stream()
.filter(item -> item.getCadViewFileId() != null)
.collect(Collectors.toMap(OrderBodyDO::getId, OrderBodyDO::getCadViewFileId));
// 查询配件编号+信息
PageDTO<OrdersViewPartsPageDO> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
IPage<OrdersViewPartsPageDO> pageRes = orderItemMapper.selectOrdersViewPartsPage(page, List.of(pageReqVO.getOrderId()),
bodyIds, pageReqVO.getGroupIds(), null, pageReqVO.getName(), false);
IPage<OrdersViewPartsPageDO> pageRes = orderItemMapper.selectOrdersViewPartsIdsPage(page, orderIds, bodyIds, groupIds, null, pageReqVO.getName());
List<OrdersViewPartsPageDO> records = pageRes.getRecords();
// cad图纸id赋到每个配件上
if (CollUtil.isNotEmpty(records)) {
records.forEach(item -> item.setCadViewFileId(bodyIdAndCadViewFileIdMap.get(item.getBodyId())));
List<OrdersViewPartsPageDO> partsPageRecords = pageRes.getRecords();
if(CollUtil.isEmpty(partsPageRecords)) {
return new PageResult<>(Collections.emptyList(), 0L);
}
return new PageResult<>(BeanUtil.copyToList(records, OrderViewPartPageRespVO.class), pageRes.getTotal());
List<Long> partsIds = partsPageRecords.stream().map(OrdersViewPartsPageDO::getId).toList();
// 查询关联关系
List<OrderItemDO> orderItemRelation = orderItemMapper.selectList(new LambdaQueryWrapperX<OrderItemDO>()
.eq(OrderItemDO::getOrderId, pageReqVO.getOrderId())
.inIfPresent(OrderItemDO::getBodyId, bodyIds)
.inIfPresent(OrderItemDO::getGroupId, groupIds)
.in(OrderItemDO::getPartsId, partsIds)
.select(OrderItemDO::getPartsId, OrderItemDO::getBodyId, OrderItemDO::getCadViewId, OrderItemDO::getGroupId, OrderItemDO::getCompId, OrderItemDO::getNum)
);
// 暂存 partsId:set<groupId>
Map<Pair<Long, Integer>, Set<Long>> partsGroupMap = new HashMap<>();
// 暂存 partsId:set<compId>
Map<Pair<Long, Integer>, Set<Long>> partsCompMap = new HashMap<>();
// 暂存 partsId:num
Map<Pair<Long, Integer>, Double> partsNumMap = new HashMap<>();
// 暂存 partsId:bodyId
Map<Pair<Long, Integer>, Long> partsBodyIdMap = new HashMap<>();
for (OrderItemDO item : orderItemRelation) {
Long partsId = item.getPartsId();
Integer cadViewId = item.getCadViewId();
Pair<Long, Integer> pair = new Pair<>(partsId, cadViewId);
// group_id
if (item.getGroupId() != null) {
partsGroupMap
.computeIfAbsent(pair, k -> new HashSet<>())
.add(item.getGroupId());
}
// comp_id
if (item.getCompId() != null) {
partsCompMap
.computeIfAbsent(pair, k -> new HashSet<>())
.add(item.getCompId());
}
// num 汇总
if (item.getNum() != null) {
partsNumMap.merge(
pair,
item.getNum(),
Double::sum
);
}
partsBodyIdMap.putIfAbsent(pair, item.getBodyId());
}
// 查询加工组
Set<Long> allGroupIds = partsGroupMap.values()
.stream()
.flatMap(Set::stream)
.collect(Collectors.toSet());
Map<Long, String> groupNameMap = Collections.emptyMap();
if (!allGroupIds.isEmpty()) {
groupNameMap = orderGroupMapper.selectByIds(allGroupIds)
.stream()
.collect(Collectors.toMap(
OrderGroupDO::getId,
OrderGroupDO::getName,
(a, b) -> a
));
}
// 查询部件
Set<Long> allCompIds = partsCompMap.values()
.stream()
.flatMap(Set::stream)
.collect(Collectors.toSet());
Map<Long, String> compNameMap = Collections.emptyMap();
if (!allCompIds.isEmpty()) {
compNameMap = orderComponentMapper.selectByIds(allCompIds)
.stream()
.collect(Collectors.toMap(
OrderComponentDO::getId,
OrderComponentDO::getName,
(a, b) -> a
));
}
// 最终组装
List<OrderViewPartPageRespVO> records = new ArrayList<>();
for (OrdersViewPartsPageDO part : partsPageRecords) {
Pair<Long, Integer> pair = new Pair<>(part.getId(), part.getCadViewId());
OrderViewPartPageRespVO partRespVO = BeanUtil.copyProperties(part, OrderViewPartPageRespVO.class);
// 设置数量
partRespVO.setNum(
BigDecimal.valueOf(partsNumMap.getOrDefault(pair, 0.0))
);
// 拼接加工组名称
Set<Long> groupIdsSet = partsGroupMap.getOrDefault(
pair,
Collections.emptySet()
);
String processGroupName = groupIdsSet.stream()
.map(groupNameMap::get)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.joining(","));
partRespVO.setProcessGroupName(processGroupName);
// 拼接部件名称
Set<Long> compIdsSet = partsCompMap.getOrDefault(
pair,
Collections.emptySet()
);
String componentName = compIdsSet.stream()
.map(compNameMap::get)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.joining(","));
partRespVO.setComponentName(componentName);
// 匹配图纸id
Long bodyId = partsBodyIdMap.get(pair);
partRespVO.setBodyId(bodyId);
Long cadViewFileId = bodyIdAndCadViewFileIdMap.get(bodyId);
if (ObjectUtil.isNotNull(cadViewFileId)) {
partRespVO.setCadViewFileId(cadViewFileId);
}
records.add(partRespVO);
}
return new PageResult<>(records, pageRes.getTotal());
}
@Override
@@ -530,6 +530,39 @@
WHERE p.deleted = false
</select>
<select id="selectOrdersViewPlateIdsPage" resultType="java.lang.Long">
SELECT
i.plate_id
FROM order_item i
WHERE i.plate_id != 0 and source_id = 0
<if test="bodyIds != null and bodyIds.size() > 0">
AND body_id IN
<foreach item="bodyId" collection="bodyIds" open="(" separator="," close=")">
#{bodyId}
</foreach>
</if>
<if test="groupIds != null and groupIds.size() > 0">
AND group_id IN
<foreach item="groupId" collection="groupIds" open="(" separator="," close=")">
#{groupId}
</foreach>
</if>
<if test="orderIds != null and orderIds.size() > 0">
AND order_id IN
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
#{orderId}
</foreach>
</if>
<if test="componentIds != null and componentIds.size() > 0">
AND comp_id IN
<foreach item="componentId" collection="componentIds" open="(" separator="," close=")">
#{componentId}
</foreach>
</if>
GROUP BY i.plate_id
ORDER BY MAX(i.id) DESC
</select>
<select id="selectOrdersViewPartsPage" resultType="com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPartsPageDO">
SELECT
op.id,
@@ -600,6 +633,80 @@
ORDER BY op.id, op.type
</select>
<select id="selectOrdersViewPartsIdsPage" resultType="com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPartsPageDO">
SELECT
t.parts_id as id,
t.cad_view_id,
op.type,
op.name,
op.material,
op.color,
op.model,
op.spec,
op.unit,
op.brand,
op.factory,
op.remark,
op.width,
op.length,
op.thickness
FROM (
SELECT
i.parts_id,
i.cad_view_id
FROM order_item i
WHERE i.plate_id = 0
AND i.source_id = 0
<if test="orderIds != null and orderIds.size() > 0">
AND i.order_id IN
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
#{orderId}
</foreach>
</if>
<if test="bodyIds != null and bodyIds.size() > 0">
AND i.body_id IN
<foreach item="bodyId" collection="bodyIds" open="(" separator="," close=")">
#{bodyId}
</foreach>
</if>
<if test="groupIds != null and groupIds.size() > 0">
AND i.group_id IN
<foreach item="groupId" collection="groupIds" open="(" separator="," close=")">
#{groupId}
</foreach>
</if>
<if test="componentIds != null and componentIds.size() > 0">
AND i.comp_id IN
<foreach item="componentId" collection="componentIds" open="(" separator="," close=")">
#{componentId}
</foreach>
</if>
GROUP BY
i.parts_id,
i.cad_view_id
) t
JOIN order_parts op
ON op.id = t.parts_id
WHERE op.deleted = false
<if test="orderIds != null and orderIds.size() > 0">
AND op.order_id IN
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
#{orderId}
</foreach>
</if>
<if test="name != null and name != ''">
AND op.name = #{name}
</if>
ORDER BY op.type, op.id
</select>
<select id="selectComponentCorrelationPlateIds" resultType="java.lang.Long">
SELECT DISTINCT op.plate_no
FROM order_item oi
@@ -1429,6 +1429,54 @@
GROUP BY oi.body_id
</select>
<select id="selectPlateGoodsByIds"
resultType="com.cf.imes.module.executor.dal.dataobject.orderItem.OrdersViewPlatesPageDO">
SELECT
p.id,
p.plate_no,
p.name,
p.width,
p.height,
p.thickness,
p.custom_plate_no,
p.cad_plate_no AS customNumber,
p.remark,
p.seal_left,
p.seal_down,
p.seal_right,
p.seal_up,
p.area,
p.texture,
p.is_special_shaped,
p.is_sculpt ,
p.is_side_sculpt AS sideModel,
p.is_row_hole,
p.hole_face,
p.open_door_type,
p.is_2v as is2v,
p.is_side_2v as isSide2v,
(p.front_model_count > 0 AND p.back_model_count > 0) AS doubleSideModel,
(p.front_hole_count > 0 AND p.back_hole_count > 0) AS doubleSideHole,
(p.front_model_count > 0) AS frontModel,
(p.back_model_count > 0) AS backModel,
(p.front_hole_count > 0) AS frontHole,
(p.back_hole_count > 0) AS backHole,
(p.side_hole_count > 0) AS sideHole,
og.material,
og.color,
og.brand
FROM order_plate p
INNER JOIN order_goods og ON p.order_id = og.order_id and og.organ_id = p.organ_id AND p.goods_id = og.id
WHERE p.id IN
<foreach item="plateId" collection="plateIds" open="(" separator="," close=")">
#{plateId}
</foreach>
and p.order_id in
<foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
#{orderId}
</foreach>
</select>
<resultMap id="orderItemMap" type="com.cf.imes.module.executor.controller.admin.manage.query.vo.pack.PackageDetailsRespVO">
<result property="packageNo" column="packageId"/>
<result property="roomName" column="roomName"/>