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:
+11
@@ -3,7 +3,10 @@ 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.framework.common.util.object.BeanUtils;
|
||||
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.OrderRespVO;
|
||||
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;
|
||||
@@ -18,6 +21,7 @@ import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -45,6 +49,13 @@ public class AssemblyListController {
|
||||
@Resource
|
||||
private OrderComponentService orderComponentService;
|
||||
|
||||
@GetMapping("/order/page")
|
||||
@Operation(summary = "获得装配清单订单分页")
|
||||
@PreAuthorize("@ss.hasPermission('productManager:List')")
|
||||
public CommonResult<PageResult<OrderRespVO>> getMainOrderPage(@Valid OrderPageReqVO pageReqVO) {
|
||||
return success(BeanUtils.toBean(assemblyListService.getMainOrderPage(pageReqVO), OrderRespVO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
@Operation(summary = "装配清单-获取部件列表")
|
||||
@PreAuthorize("@ss.hasPermission('production:assemblyList:query')")
|
||||
|
||||
+2
@@ -106,4 +106,6 @@ public class OrderPageReqVO extends PageParam {
|
||||
@Schema(description = "加工状态")
|
||||
@InEnum(OrderComponentProcessStatusEnum.class)
|
||||
private Integer processStatus;
|
||||
|
||||
private Boolean assembly = false;
|
||||
}
|
||||
+2
-2
@@ -104,13 +104,13 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询主单(带子单过滤)
|
||||
* 分页查询主单id(带子单过滤)
|
||||
*
|
||||
* @param page
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
IPage<OrderDO> selectMainPage(@Param("page") IPage<OrderDO> page, @Param("reqVO") OrderPageReqVO reqVO);
|
||||
IPage<Long> selectMainOrderIds(@Param("page") IPage<OrderDO> page, @Param("reqVO") OrderPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 查询子单列表
|
||||
|
||||
+10
-2
@@ -2,11 +2,11 @@ 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.order.vo.order.OrderPageReqVO;
|
||||
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.OrdersTopComponentListReqVO;
|
||||
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.order.OrderDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,6 +17,14 @@ import java.util.List;
|
||||
* @since 2026/2/28 11:16
|
||||
*/
|
||||
public interface AssemblyListService {
|
||||
/**
|
||||
* 查询装配清单订单分页
|
||||
*
|
||||
* @param pageReqVO
|
||||
* @return
|
||||
*/
|
||||
PageResult<OrderDO> getMainOrderPage(OrderPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获取部件列表,根据装配设置对应加工状态
|
||||
*
|
||||
|
||||
+51
-1
@@ -14,17 +14,20 @@ 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.framework.mybatis.core.query.LambdaUpdateWrapperX;
|
||||
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.OrdersViewCadViewInfoRespVO;
|
||||
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.OrdersTopComponentListReqVO;
|
||||
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.order.OrderDO;
|
||||
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;
|
||||
@@ -47,9 +50,10 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_COMPONENT_ASSEMBLY_CONFIG_QUERY_ERROR;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_COMPONENT_NOT_EXIST;
|
||||
@@ -77,6 +81,52 @@ public class AssemblyListServiceImpl implements AssemblyListService {
|
||||
@Resource
|
||||
private OrderItemMapper orderItemMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<OrderDO> getMainOrderPage(OrderPageReqVO pageReqVO) {
|
||||
pageReqVO.setAssembly(true);
|
||||
IPage<OrderDO> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||
// 1. 查询主单ID分页
|
||||
IPage<Long> pageResult = orderMapper.selectMainOrderIds(page, pageReqVO);
|
||||
Long pageResultTotal = pageResult.getTotal();
|
||||
|
||||
if (pageResultTotal == 0) {
|
||||
return PageResult.empty();
|
||||
}
|
||||
|
||||
List<Long> orderIds = pageResult.getRecords();
|
||||
// 2. 查询主单
|
||||
List<OrderDO> orderDOS = orderMapper.selectByIds(orderIds);
|
||||
if (CollUtil.isEmpty(orderDOS)) {
|
||||
return new PageResult<>(Collections.emptyList(), pageResultTotal);
|
||||
}
|
||||
|
||||
// 保持分页顺序
|
||||
Map<Long, Integer> sortMap = IntStream.range(0, orderIds.size())
|
||||
.boxed()
|
||||
.collect(Collectors.toMap(orderIds::get, Function.identity()));
|
||||
|
||||
orderDOS.sort(Comparator.comparing(o -> sortMap.get(o.getId())));
|
||||
|
||||
// 3. 查询子单
|
||||
List<OrderDO> childList =
|
||||
orderMapper.selectChildList(pageReqVO, orderIds);
|
||||
|
||||
if (CollUtil.isEmpty(childList)) {
|
||||
return new PageResult<>(orderDOS, pageResultTotal);
|
||||
}
|
||||
|
||||
// 4. parentId分组
|
||||
Map<Long, List<OrderDO>> childMap = childList.stream()
|
||||
.collect(Collectors.groupingBy(OrderDO::getParentId));
|
||||
|
||||
// 5. 挂载子单
|
||||
for (OrderDO order : orderDOS) {
|
||||
order.setChild(childMap.get(order.getId()));
|
||||
}
|
||||
|
||||
return new PageResult<>(orderDOS, pageResultTotal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderComponentRespVO> getComponentList(AssemblyListComponentPageReqVO reqVO) {
|
||||
Set<Long> componentIds = reqVO.getComponentIds();
|
||||
|
||||
+34
-19
@@ -100,6 +100,7 @@ import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static com.cf.imes.framework.common.util.json.JsonUtils.unzipString;
|
||||
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
|
||||
@@ -310,32 +311,46 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Override
|
||||
public PageResult<OrderDO> getMainOrderPage(OrderPageReqVO pageReqVO) {
|
||||
IPage<OrderDO> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
|
||||
IPage<OrderDO> pageResult = orderMapper.selectMainPage(page, pageReqVO);
|
||||
// 1. 查询主单ID分页
|
||||
IPage<Long> pageResult = orderMapper.selectMainOrderIds(page, pageReqVO);
|
||||
Long pageResultTotal = pageResult.getTotal();
|
||||
if (pageResultTotal > 0) {
|
||||
List<OrderDO> orderDOS = pageResult.getRecords();
|
||||
// 1、整理所有订单id
|
||||
List<Long> orderIds = orderDOS.stream().map(OrderDO::getId).toList();
|
||||
|
||||
// 2、查询订单id列表对应的子单
|
||||
List<OrderDO> childList =
|
||||
orderMapper.selectChildList(pageReqVO, orderIds);
|
||||
if (pageResultTotal == 0) {
|
||||
return PageResult.empty();
|
||||
}
|
||||
|
||||
if (CollUtil.isEmpty(childList)) {
|
||||
return new PageResult<>(pageResult.getRecords(), pageResultTotal);
|
||||
}
|
||||
List<Long> orderIds = pageResult.getRecords();
|
||||
// 2. 查询主单
|
||||
List<OrderDO> orderDOS = orderMapper.selectByIds(orderIds);
|
||||
if (CollUtil.isEmpty(orderDOS)) {
|
||||
return new PageResult<>(Collections.emptyList(), pageResultTotal);
|
||||
}
|
||||
|
||||
// 3、 按 parentId 分组
|
||||
Map<Long, List<OrderDO>> childMap = childList.stream()
|
||||
.collect(Collectors.groupingBy(OrderDO::getParentId));
|
||||
// 保持分页顺序
|
||||
Map<Long, Integer> sortMap = IntStream.range(0, orderIds.size())
|
||||
.boxed()
|
||||
.collect(Collectors.toMap(orderIds::get, Function.identity()));
|
||||
|
||||
// 4、 回填 child
|
||||
for (OrderDO order : orderDOS) {
|
||||
order.setChild(childMap.getOrDefault(order.getId(), null));
|
||||
}
|
||||
orderDOS.sort(Comparator.comparing(o -> sortMap.get(o.getId())));
|
||||
|
||||
// 3. 查询子单
|
||||
List<OrderDO> childList =
|
||||
orderMapper.selectChildList(pageReqVO, orderIds);
|
||||
|
||||
if (CollUtil.isEmpty(childList)) {
|
||||
return new PageResult<>(orderDOS, pageResultTotal);
|
||||
}
|
||||
return new PageResult<>(pageResult.getRecords(), pageResultTotal);
|
||||
|
||||
// 4. parentId分组
|
||||
Map<Long, List<OrderDO>> childMap = childList.stream()
|
||||
.collect(Collectors.groupingBy(OrderDO::getParentId));
|
||||
|
||||
// 5. 挂载子单
|
||||
for (OrderDO order : orderDOS) {
|
||||
order.setChild(childMap.get(order.getId()));
|
||||
}
|
||||
|
||||
return new PageResult<>(orderDOS, pageResultTotal);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+16
-65
@@ -28,27 +28,32 @@
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectMainPage" resultType="com.cf.imes.module.executor.dal.dataobject.order.OrderDO">
|
||||
<select id="selectMainOrderIds" resultType="java.lang.Long">
|
||||
|
||||
SELECT o.*
|
||||
FROM orders o
|
||||
JOIN (
|
||||
SELECT DISTINCT
|
||||
IF(t.parent_id = 0, t.id, t.parent_id) AS root_id
|
||||
t.root_id
|
||||
|
||||
FROM orders t
|
||||
|
||||
<!-- ✅ 只有需要 processStatus 才 join oc -->
|
||||
<if test="reqVO.processStatus != null">
|
||||
JOIN order_component oc
|
||||
ON oc.order_id = t.id
|
||||
AND oc.deleted = 0
|
||||
AND oc.pid = 0
|
||||
AND oc.organ_id = 1
|
||||
</if>
|
||||
|
||||
WHERE 1 = 1
|
||||
|
||||
<!-- ===== 订单条件 ===== -->
|
||||
<if test="reqVO.assembly and reqVO.processStatus == null">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM order_component oc
|
||||
WHERE oc.order_id = t.id
|
||||
AND oc.deleted = 0
|
||||
AND oc.pid = 0
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="reqVO.id != null and reqVO.id != ''">
|
||||
AND CAST(t.id AS CHAR) LIKE CONCAT('%', #{reqVO.id}, '%')
|
||||
</if>
|
||||
@@ -129,7 +134,6 @@
|
||||
AND t.create_time BETWEEN #{reqVO.createTime[0]} AND #{reqVO.createTime[1]}
|
||||
</if>
|
||||
|
||||
<!-- ===== 只有存在 processStatus 才加过滤 ===== -->
|
||||
<if test="reqVO.processStatus != null">
|
||||
|
||||
<choose>
|
||||
@@ -157,11 +161,6 @@
|
||||
|
||||
AND t.deleted = #{reqVO.deleted}
|
||||
|
||||
) tmp
|
||||
ON tmp.root_id = o.id
|
||||
|
||||
WHERE o.parent_id = 0
|
||||
|
||||
<choose>
|
||||
|
||||
<when test="reqVO.order != null and reqVO.order == 'ascend'">
|
||||
@@ -169,59 +168,11 @@
|
||||
<choose>
|
||||
|
||||
<when test="reqVO.field == 'id'">
|
||||
ORDER BY o.id ASC
|
||||
</when>
|
||||
|
||||
<when test="reqVO.field == 'customOrderNo'">
|
||||
ORDER BY o.custom_order_no ASC
|
||||
</when>
|
||||
|
||||
<when test="reqVO.field == 'orderDate'">
|
||||
ORDER BY o.order_date ASC
|
||||
</when>
|
||||
|
||||
<when test="reqVO.field == 'deliveryDate'">
|
||||
ORDER BY o.delivery_date ASC
|
||||
</when>
|
||||
|
||||
<when test="reqVO.field == 'apiOrderId'">
|
||||
ORDER BY o.api_order_id ASC
|
||||
ORDER BY root_id ASC
|
||||
</when>
|
||||
|
||||
<otherwise>
|
||||
ORDER BY o.id DESC
|
||||
</otherwise>
|
||||
|
||||
</choose>
|
||||
|
||||
</when>
|
||||
|
||||
<when test="reqVO.order != null and reqVO.order == 'descend'">
|
||||
|
||||
<choose>
|
||||
|
||||
<when test="reqVO.field == 'id'">
|
||||
ORDER BY o.id DESC
|
||||
</when>
|
||||
|
||||
<when test="reqVO.field == 'customOrderNo'">
|
||||
ORDER BY o.custom_order_no DESC
|
||||
</when>
|
||||
|
||||
<when test="reqVO.field == 'orderDate'">
|
||||
ORDER BY o.order_date DESC
|
||||
</when>
|
||||
|
||||
<when test="reqVO.field == 'deliveryDate'">
|
||||
ORDER BY o.delivery_date DESC
|
||||
</when>
|
||||
|
||||
<when test="reqVO.field == 'apiOrderId'">
|
||||
ORDER BY o.api_order_id DESC
|
||||
</when>
|
||||
|
||||
<otherwise>
|
||||
ORDER BY o.id DESC
|
||||
ORDER BY root_id ASC
|
||||
</otherwise>
|
||||
|
||||
</choose>
|
||||
@@ -229,7 +180,7 @@
|
||||
</when>
|
||||
|
||||
<otherwise>
|
||||
ORDER BY o.id DESC
|
||||
ORDER BY root_id DESC
|
||||
</otherwise>
|
||||
|
||||
</choose>
|
||||
|
||||
Reference in New Issue
Block a user