1、装配设置重复添加配置序列不断累加修复;2、新增装配清单专用多订单cad视图板件分页和所有接口;

This commit is contained in:
gaoqr
2026-03-09 09:26:58 +08:00
parent 7955e3d318
commit e082313db2
12 changed files with 323 additions and 37 deletions
@@ -1,13 +1,16 @@
package com.cf.imes.module.executor.controller.admin.assemblylist;
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.ordercomponent.vo.OrderComponentRespVO;
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderDetailComponentListReqVO;
import com.cf.imes.module.executor.controller.admin.plate.vo.OrderViewPlatePageRespVO;
import com.cf.imes.module.executor.service.assemblylist.AssemblyListService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -17,6 +20,8 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static com.cf.imes.framework.common.pojo.CommonResult.success;
/**
*
*
@@ -33,10 +38,22 @@ public class AssemblyListController {
@PostMapping("/list")
@Operation(summary = "装配清单-获取部件列表")
public CommonResult<List<OrderComponentRespVO>> getComponentList(@RequestBody OrderDetailComponentListReqVO reqVO) {
public CommonResult<List<OrderComponentRespVO>> getComponentList(@RequestBody AssemblyListComponentPageReqVO reqVO) {
return CommonResult.success(assemblyListService.getComponentList(reqVO));
}
@PostMapping("/list/view/plate/page")
@Operation(summary = "装配清单-获取订单部件下的板件视图分页列表数据")
public CommonResult<PageResult<OrderViewPlatePageRespVO>> getComponentViewPlatesPage(@Valid @RequestBody AssemblyListComponentPageReqVO pageReqVO) {
return success(assemblyListService.getViewComponentPage(pageReqVO));
}
@PostMapping("/list/view/plate/cadinfo")
@Operation(summary = "装配清单-获取订单部件下的所有板件视图列表数据")
public CommonResult<List<OrderViewPlatePageRespVO>> getComponentViewPlates(@Valid @RequestBody AssemblyListComponentPageReqVO pageReqVO) {
return success(assemblyListService.getViewComponentPlatesCadInfo(pageReqVO));
}
@PostMapping("/process/{id}")
@Operation(summary = "装配清单-加工部件")
@Parameter(name = "id", description = "部件编号", required = true, example = "1024")
@@ -0,0 +1,46 @@
package com.cf.imes.module.executor.controller.admin.assemblylist.vo;
import com.cf.imes.framework.common.pojo.PageParam;
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.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;
import java.util.List;
import java.util.Set;
/**
*
*
* @author Gqr
* @since 2026/2/2 11:34
*/
@Schema(description = "管理后台 - 装配清单 - 订单部件视图分页查询 Request VO")
@Data
@ToString(callSuper = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AssemblyListComponentPageReqVO extends PageParam {
@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 = "部件")
@Length(max = 64, message = "{order.component.assemble.req.name.max}")
private String name;
@Schema(description = "加工状态:0不加工、1未加工、2已加工", example = "1")
@InEnum(OrderComponentProcessStatusEnum.class)
private Integer processStatus;
}
@@ -204,4 +204,18 @@ public interface OrderItemMapper extends BaseMapperX<OrderItemDO> {
@Param("groupId") Long groupId,
@Param("componentIds") Set<Long> componentIds,
@Param("cadView") boolean cadView);
/**
* 分页查询订单板件视图数据
*
* @param page 分页参数
* @param orderId 订单ID
* @param componentIds 部件ID列表
* @param cadView 是否需要cad图纸内信息:cad_view_id、seal_left、seal_down、seal_right、seal_up
* @return
*/
IPage<OrderBodyViewPlatesPageDO> selectOrdersViewPlatesPage(@Param("page") IPage<OrderBodyViewPlatesPageDO> page,
@Param("orderIds") List<Long> orderId,
@Param("componentIds") Set<Long> componentIds,
@Param("cadView") boolean cadView);
}
@@ -1,7 +1,9 @@
package com.cf.imes.module.executor.service.assemblylist;
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.ordercomponent.vo.OrderComponentRespVO;
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderDetailComponentListReqVO;
import com.cf.imes.module.executor.controller.admin.plate.vo.OrderViewPlatePageRespVO;
import java.util.List;
@@ -18,7 +20,21 @@ public interface AssemblyListService {
* @param reqVO
* @return
*/
List<OrderComponentRespVO> getComponentList(OrderDetailComponentListReqVO reqVO);
List<OrderComponentRespVO> getComponentList(AssemblyListComponentPageReqVO reqVO);
/**
* 获取订单下板件视图分页列表
* @param reqVO
* @return
*/
PageResult<OrderViewPlatePageRespVO> getViewComponentPage(AssemblyListComponentPageReqVO reqVO);
/**
* 获取部件和下级所有的板件视图列表
* @param reqVO
* @return
*/
List<OrderViewPlatePageRespVO> getViewComponentPlatesCadInfo(AssemblyListComponentPageReqVO reqVO);
/**
* 加工部件
@@ -8,18 +8,24 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.crypto.digest.DigestUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
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;
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentPageReqVO;
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.OrderDetailComponentListReqVO;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.controller.admin.plate.vo.OrderViewPlatePageRespVO;
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderBodyViewPlatesPageDO;
import com.cf.imes.module.executor.dal.dataobject.ordercomponent.OrderComponentDO;
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
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.enums.ordercomponent.OrderComponentProcessStatusEnum;
import com.cf.imes.module.system.api.assemblyconfig.AssemblyConfigApi;
@@ -33,6 +39,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -43,7 +50,6 @@ import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_COMPONE
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_COMPONENT_NOT_EXIST;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_COMPONENT_NOT_PROCESS;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_COMPONENT_PROCESSED_REPEAT;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_NOT_EXISTS;
/**
* 装配清单 ServiceImpl 实现类
@@ -62,16 +68,15 @@ public class AssemblyListServiceImpl implements AssemblyListService {
@Resource
private AssemblyConfigApi assemblyConfigApi;
@Resource
private OrderItemMapper orderItemMapper;
@Override
public List<OrderComponentRespVO> getComponentList(OrderDetailComponentListReqVO reqVO) {
public List<OrderComponentRespVO> getComponentList(AssemblyListComponentPageReqVO reqVO) {
Set<Long> componentIds = reqVO.getComponentIds();
if (CollUtil.isEmpty(componentIds)) {
return Collections.emptyList();
}
// 校验订单
Long orderId = reqVO.getOrderId();
OrderDO orderDO = orderMapper.selectById(orderId);
AssertUtils.notEmpty(orderDO, ORDER_NOT_EXISTS);
// 查询入参部件
List<OrderComponentDO> componentDOS = orderComponentMapper.selectByIds(componentIds);
@@ -163,14 +168,13 @@ public class AssemblyListServiceImpl implements AssemblyListService {
*
* @return
*/
private List<OrderComponentRespVO> getProcessedComponentList(OrderDetailComponentListReqVO reqVO, List<Long> topIds) {
private List<OrderComponentRespVO> getProcessedComponentList(AssemblyListComponentPageReqVO reqVO, List<Long> topIds) {
// 根据部件的topid查询树上所有已加工节点
List<OrderComponentDO> topProcessedComponentList = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
.in(OrderComponentDO::getTopId, topIds)
.eq(OrderComponentDO::getOrderId, reqVO.getOrderId())
.eqIfPresent(OrderComponentDO::getDeleted, reqVO.isDeleted())
.in(OrderComponentDO::getOrderId, reqVO.getOrderIds())
.likeIfPresent(OrderComponentDO::getName, reqVO.getName())
.eqIfPresent(OrderComponentDO::getProcessStatus, reqVO.getProcessStatus())
.eqIfPresent(OrderComponentDO::getProcessStatus, OrderComponentProcessStatusEnum.PROCESSED.getStatus())
.select(OrderComponentDO::getId, OrderComponentDO::getPid, OrderComponentDO::getName, OrderComponentDO::getProcessStatus));
return BeanUtil.copyToList(topProcessedComponentList, OrderComponentRespVO.class);
}
@@ -182,12 +186,11 @@ public class AssemblyListServiceImpl implements AssemblyListService {
* @param reqVO
* @return
*/
private List<OrderComponentRespVO> getUnProcessedComponentList(OrderDetailComponentListReqVO reqVO, List<Long> topIds, boolean showAll) {
private List<OrderComponentRespVO> getUnProcessedComponentList(AssemblyListComponentPageReqVO reqVO, List<Long> topIds, boolean showAll) {
// 根据部件的topid查询树上所有已加工节点
List<OrderComponentDO> topUnProcessedComponentList = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
.in(OrderComponentDO::getTopId, topIds)
.eq(OrderComponentDO::getOrderId, reqVO.getOrderId())
.eqIfPresent(OrderComponentDO::getDeleted, reqVO.isDeleted())
.in(OrderComponentDO::getOrderId, reqVO.getOrderIds())
.likeIfPresent(OrderComponentDO::getName, reqVO.getName())
.neIfPresent(OrderComponentDO::getProcessStatus, showAll ? null : OrderComponentProcessStatusEnum.PROCESSED.getStatus())
.select(OrderComponentDO::getId, OrderComponentDO::getPid, OrderComponentDO::getName, OrderComponentDO::getProcessStatus));
@@ -210,12 +213,11 @@ public class AssemblyListServiceImpl implements AssemblyListService {
* @param reqVO
* @return
*/
private List<OrderComponentRespVO> getNotProcessComponentList(OrderDetailComponentListReqVO reqVO, List<Long> topIds) {
private List<OrderComponentRespVO> getNotProcessComponentList(AssemblyListComponentPageReqVO reqVO, List<Long> topIds) {
// 根据部件的topid查询树上所有节点
List<OrderComponentDO> topComponentList = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
.in(OrderComponentDO::getTopId, topIds)
.eq(OrderComponentDO::getOrderId, reqVO.getOrderId())
.eqIfPresent(OrderComponentDO::getDeleted, reqVO.isDeleted())
.in(OrderComponentDO::getOrderId, reqVO.getOrderIds())
.likeIfPresent(OrderComponentDO::getName, reqVO.getName())
.select(OrderComponentDO::getId, OrderComponentDO::getPid, OrderComponentDO::getName, OrderComponentDO::getProcessStatus));
@@ -618,4 +620,165 @@ public class AssemblyListServiceImpl implements AssemblyListService {
this.level = level;
}
}
@Override
public PageResult<OrderViewPlatePageRespVO> getViewComponentPage(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()
.collect(Collectors.toMap(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId));
// 分页查询板件
PageDTO<OrderBodyViewPlatesPageDO> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
IPage<OrderBodyViewPlatesPageDO> pageRes = orderItemMapper.selectOrdersViewPlatesPage(page, orderIds, queryComponentIds, false);
long total = pageRes.getTotal();
List<OrderBodyViewPlatesPageDO> 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 List<OrderViewPlatePageRespVO> getViewComponentPlatesCadInfo(AssemblyListComponentPageReqVO pageReqVO) {
List<OrderViewPlatePageRespVO> emptyList = Collections.emptyList();
Set<Long> componentIds = pageReqVO.getComponentIds();
if (CollUtil.isEmpty(componentIds)) {
return emptyList;
}
// 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 emptyList;
}
// 整理出id和cadViewFileId的对应关系
Map<Long, Long> cadViewFileIdMap = orderComponentDOS.stream()
.collect(Collectors.toMap(OrderComponentDO::getId, OrderComponentDO::getCadViewFileId));
// 查询所有板件的视图所需信息
PageDTO<OrderBodyViewPlatesPageDO> page = new PageDTO<>(1, PageParam.PAGE_SIZE_NONE);
IPage<OrderBodyViewPlatesPageDO> viewPlatesPage = orderItemMapper.selectOrdersViewPlatesPage(page, orderIds, queryComponentIds, true);
List<OrderBodyViewPlatesPageDO> records = viewPlatesPage.getRecords();
List<OrderViewPlatePageRespVO> resultList = new ArrayList<>();
if(CollUtil.isNotEmpty(records)) {
resultList = records.stream().map(item -> {
OrderViewPlatePageRespVO vo = new OrderViewPlatePageRespVO();
BeanUtil.copyProperties(item, vo);
vo.setCadViewFileId(cadViewFileIdMap.get(item.getCompId()));
return vo;
}).toList();
}
return resultList;
}
/**
* 整理出需要删除的部件id列表
*
* @param componentDO
* @param componentOnTop
* @return
*/
private Set<Long> getChildrenIds(OrderComponentDO componentDO, List<OrderComponentDO> componentOnTop) {
// 3、整理出真正的下级(通过 pid 逐级确认)
Set<Long> needDeleteIds = new HashSet<>();
needDeleteIds.add(componentDO.getId());
if (CollUtil.isNotEmpty(componentOnTop)) {
// 先构建 pid -> children 映射
Map<Long, List<OrderComponentDO>> childrenMap = componentOnTop.stream()
.collect(Collectors.groupingBy(OrderComponentDO::getPid));
// 用队列逐级往下找
Deque<Long> queue = new ArrayDeque<>();
queue.add(componentDO.getId());
while (!queue.isEmpty()) {
Long parentId = queue.poll();
List<OrderComponentDO> children = childrenMap.get(parentId);
if (CollUtil.isEmpty(children)) {
continue;
}
for (OrderComponentDO child : children) {
Long childId = child.getId();
if (needDeleteIds.add(childId)) { // 防重复
queue.add(childId); // 继续往下找
}
}
}
}
return needDeleteIds;
}
}
@@ -567,4 +567,35 @@
</foreach>
</if>
</select>
<select id="selectOrdersViewPlatesPage" resultType="com.cf.imes.module.executor.dal.dataobject.orderItem.OrderBodyViewPlatesPageDO">
SELECT p.order_id, p.plate_no, p.name, p.width, p.height, p.thickness, g.material, g.color, p.custom_plate_no, p.cad_plate_no as customNumber, p.id, i.body_id, p.cad_view_id
<choose>
<when test="cadView">
, p.seal_left, p.seal_down, p.seal_right, p.seal_up
</when>
<otherwise>
, 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_row_hole, p.remark
</otherwise>
</choose>
<if test="componentIds != null and componentIds.size() > 0">
, i.comp_id
</if>
FROM order_item i
LEFT JOIN `order_plate` p ON i.plate_id = p.id
LEFT JOIN `order_goods` g ON g.id = p.goods_id
WHERE p.deleted = false and i.plate_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="componentIds != null and componentIds.size() > 0">
AND i.comp_id in
<foreach item="componentId" collection="componentIds" open="(" separator="," close=")">
#{componentId}
</foreach>
</if>
</select>
</mapper>