1、工作台今日完成订单、逾期订单列表支持子单;2、未排订单-订单分组分页列表支持子单;

This commit is contained in:
gaoqr
2026-04-20 11:38:05 +08:00
parent bca08afedb
commit e1810a41ec
9 changed files with 193 additions and 75 deletions
@@ -561,27 +561,21 @@ public class OrderController {
return success(true);
}
// 统计
// 订单超期(工作台)
@GetMapping("/getOrderOverdue")
@Operation(summary = "订单超期 (工作台)")
@Operation(summary = " 工作台 - 逾期订单")
@PreAuthorize("@ss.hasPermission('homePage:work:be-overdue')")
public CommonResult<PageResult<OrderOverdueRespVO>> getOrderOverdue(@Valid PageParam pageParam) {
return success(orderService.getOrderOverdue(pageParam));
}
// 订单到期告警 (工作台)
@GetMapping("/getOrderWarn")
@Operation(summary = "订单到期告警 (工作台)")
@Operation(summary = "工作台 - 今日要完成订单")
@PreAuthorize("@ss.hasPermission('homePage:work:completed-today')")
public CommonResult<PageResult<OrderOverdueRespVO>> getOrderNear(@Valid PageParam pageParam) {
return success(orderService.getOrderNear(pageParam));
}
@GetMapping("/getAllData")
@Operation(summary = "获取订单的所有数据")
public CommonResult<OrderAllData> getOrderAllData(@Schema(description = "订单id") @RequestParam(required = false) Long orderId,
@@ -1,11 +1,11 @@
package com.cf.imes.module.executor.controller.admin.order.vo.order;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 订单逾期列表")
@Data
@@ -13,16 +13,14 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class OrderOverdueRespVO {
@Schema(description = "订单号")
private Long id;
@Schema(description = "父单号")
private Long parentNo;
@Schema(description = "源订单号")
private String apiOrderId;
private Long parentId;
@Schema(description = "订单日期", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime orderDate;
@@ -33,12 +31,6 @@ public class OrderOverdueRespVO {
@Schema(description = "订单类型,1主单 2子单", example = "1")
private Integer orderType;
@Schema(description = "订单排序号")
private Integer orderSort;
@Schema(description = "CAD数据类型,1CAD 2WebCAD 3Excel", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer dataType;
@Schema(description = "订单状态,订单状态,0空订单1新单2生产中3生产完成", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
@@ -57,22 +49,12 @@ public class OrderOverdueRespVO {
@Schema(description = "经销商", requiredMode = Schema.RequiredMode.REQUIRED)
private String dealer;
@Schema(description = "经销商电话", requiredMode = Schema.RequiredMode.REQUIRED)
private String dealerPhoneNumber;
@Schema(description = "业务员")
private String salesman;
@Schema(description = "拆单员")
private String splitter;
@Schema(description = "备注", example = "你猜")
private String remark;
@Schema(description = "距离到期时间")
private String becomeDue;
@Schema(description = "逾期时间")
private String beOverdue;
@Schema(description = "子单列表")
private List<OrderOverdueRespVO> child;
}
@@ -1,6 +1,7 @@
package com.cf.imes.module.executor.controller.admin.plan.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -22,9 +23,14 @@ import static com.cf.imes.framework.common.util.date.DateUtils.*;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class OrderRespVOCopy {
@Schema(description = "订单id")
private Long orderId;
@Schema(description = "父订单号")
private Long parentId;
@Schema(description = "订单状态")
private Integer status;
@Schema(description = "自定义单号")
@@ -54,4 +60,7 @@ public class OrderRespVOCopy {
@Schema(description = "订单对应的板件的信息")
private List<PlatePage> platePages;
@Schema(description = "子单列表")
private List<OrderRespVOCopy> child;
}
@@ -159,12 +159,34 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
List<OrderRespVOCopy> selectOrderListByIds(@Param("orderIds") List<Long> orderIds, @Param("organId") Long organId);
/**
* 查询今日要完成订单
*
* @param orderDate
* @param organId
* @param page
* @param orderIds 父级订单数组
* @return
*/
IPage<OrderOverdueRespVO> selectOrderNear(@Param("orderDate") LocalDate orderDate,
@Param("organId") Long organId,
@Param("page") IPage<OrderOverdueRespVO> page,
@Param("orderIds") Long... orderIds);
// 订单预警统计
IPage<OrderOverdueRespVO> selectOrderNear(@Param("orderDate") LocalDate orderDate, @Param("organId") Long organId, @Param("page") IPage<OrderOverdueRespVO> page);
// 订单逾期统计
IPage<OrderOverdueRespVO> selectOrderOverdue(@Param("today") LocalDate today, @Param("organId") Long organId, @Param("page") IPage<OrderOverdueRespVO> page);
/**
* 查询预期订单
*
* @param today
* @param organId
* @param page
* @param orderIds 父级订单数组
* @return
*/
IPage<OrderOverdueRespVO> selectOrderOverdue(@Param("today") LocalDate today,
@Param("organId") Long organId,
@Param("page") IPage<OrderOverdueRespVO> page,
@Param("orderIds") Long... orderIds);
/**
* 订单数量统计
@@ -21,9 +21,19 @@ import java.util.List;
@Mapper
public interface PlanItemMapper extends BaseMapperX<PlanItemDO> {
IPage<OrderRespVOCopy> selectOrderList(@Param("page") IPage page, @Param(Constants.WRAPPER) Wrapper<OrderDO> wrapper,@Param("type")int type);
/**
* 未排单订单查询
*
* @param page
* @param wrapper
* @param type
* @param orderIds 父级订单数组
* @return
*/
IPage<OrderRespVOCopy> selectOrderList(@Param("page") IPage<OrderRespVOCopy> page,
@Param(Constants.WRAPPER) Wrapper<OrderDO> wrapper,
@Param("type") int type,
@Param("orderIds") Long... orderIds);
List<PlateDetailRespVO> selectPlanPlateDetailList(@Param("planId") Long planId, @Param("organId") Long organId);
@@ -332,7 +332,7 @@ public class OrderServiceImpl implements OrderService {
// 4、 回填 child
for (OrderDO order : orderDOS) {
order.setChild(childMap.getOrDefault(order.getId(), Collections.emptyList()));
order.setChild(childMap.getOrDefault(order.getId(), null));
}
return new PageResult<>(orderDOS, pageResultTotal);
}
@@ -775,20 +775,74 @@ public class OrderServiceImpl implements OrderService {
@Override
public PageResult<OrderOverdueRespVO> getOrderOverdue(PageParam pageParam) {
Long organId = OrganContextHolder.getOrganId();
LocalDate todayDate = LocalDate.now();
PageDTO<OrderOverdueRespVO> page = new PageDTO<>(pageParam.getPageNo(), pageParam.getPageSize());
// 查询超时单
IPage<OrderOverdueRespVO> orderOverdueVOS = orderMapper.selectOrderOverdue(todayDate, OrganContextHolder.getOrganId(), page);
return new PageResult<OrderOverdueRespVO>(orderOverdueVOS.getRecords(), orderOverdueVOS.getTotal());
IPage<OrderOverdueRespVO> orderOverdueVOS = orderMapper.selectOrderOverdue(todayDate, organId, page);
List<OrderOverdueRespVO> records = orderOverdueVOS.getRecords();
long total = orderOverdueVOS.getTotal();
// 查询子单
if (CollUtil.isNotEmpty(records)) {
// 主单id列表
Long[] mainOrderIds = records.stream().map(OrderOverdueRespVO::getId).toArray(Long[]::new);
PageDTO<OrderOverdueRespVO> childPage = new PageDTO<>(pageParam.getPageNo(), PageParam.PAGE_SIZE_NONE);
IPage<OrderOverdueRespVO> childOrderOverdueVOS = orderMapper.selectOrderOverdue(todayDate, organId, childPage, mainOrderIds);
List<OrderOverdueRespVO> childList = childOrderOverdueVOS.getRecords();
if (CollUtil.isNotEmpty(childList)) {
// 按 parentId 分组
Map<Long, List<OrderOverdueRespVO>> childMap = childList.stream()
.collect(Collectors.groupingBy(OrderOverdueRespVO::getParentId));
// 回填 child
for (OrderOverdueRespVO order : records) {
order.setChild(childMap.getOrDefault(order.getId(), null));
}
}
return new PageResult<>(records, total);
}
return new PageResult<>(orderOverdueVOS.getRecords(), total);
}
@Override
public PageResult<OrderOverdueRespVO> getOrderNear(PageParam pageParam) {
Long organId = OrganContextHolder.getOrganId();
PageDTO<OrderOverdueRespVO> page = new PageDTO<>(pageParam.getPageNo(), pageParam.getPageSize());
LocalDate tomorrow = LocalDate.now().plus(1, ChronoUnit.DAYS);
// 查询预警单
IPage<OrderOverdueRespVO> orderNearVOS = orderMapper.selectOrderNear(tomorrow, OrganContextHolder.getOrganId(), page);
return new PageResult<OrderOverdueRespVO>(orderNearVOS.getRecords(), orderNearVOS.getTotal());
IPage<OrderOverdueRespVO> orderNearVOS = orderMapper.selectOrderNear(tomorrow, organId, page);
List<OrderOverdueRespVO> records = orderNearVOS.getRecords();
// 查询子单
if (CollUtil.isNotEmpty(records)) {
// 主单id列表
Long[] mainOrderIds = records.stream().map(OrderOverdueRespVO::getId).toArray(Long[]::new);
PageDTO<OrderOverdueRespVO> childPage = new PageDTO<>(pageParam.getPageNo(), PageParam.PAGE_SIZE_NONE);
IPage<OrderOverdueRespVO> childOrderNearVOS = orderMapper.selectOrderNear(tomorrow, organId, childPage, mainOrderIds);
List<OrderOverdueRespVO> childList = childOrderNearVOS.getRecords();
if (CollUtil.isNotEmpty(childList)) {
// 按 parentId 分组
Map<Long, List<OrderOverdueRespVO>> childMap = childList.stream()
.collect(Collectors.groupingBy(OrderOverdueRespVO::getParentId));
// 回填 child
for (OrderOverdueRespVO order : records) {
order.setChild(childMap.getOrDefault(order.getId(), null));
}
}
return new PageResult<>(records, orderNearVOS.getTotal());
}
return new PageResult<>(records, orderNearVOS.getTotal());
}
@Override
@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.cf.imes.framework.common.enums.*;
import com.cf.imes.framework.common.exception.ServiceException;
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.object.BeanUtils;
@@ -550,6 +551,7 @@ public class PlanServiceImpl implements PlanService {
@Override
public PageResult<OrderRespVOCopy> getOrderPage(OrderPageReqVOCopy pageReqVO) {
Long organId = getUserOrganId();
List<Integer> statusList = new ArrayList<>();
@@ -566,19 +568,19 @@ public class PlanServiceImpl implements PlanService {
List<Long> orderIdList = Optional.ofNullable(pageReqVO.getOrderIds()).orElse(new ArrayList<>());
List<GoodsDO> goodsDOS = goodsMapper.selectListByGoodsId(orderIdList,goodsId, getUserOrganId());
List<GoodsDO> goodsDOS = goodsMapper.selectListByGoodsId(orderIdList, goodsId, organId);
ids.addAll(goodsDOS.stream().map(GoodsDO::getId).toList());
type = OrderPlanQueryTypeEnum.GOODS_GROUP.getType();
}
QueryWrapperX<OrderDO> queryWrapperX = new QueryWrapperX<>();
queryWrapperX
.eq(FIELD_ORGAN_ID,getUserOrganId())
.eq(FIELD_DELETED,false)
.in(FIELD_STATUS,statusList)
.eq(FIELD_ORGAN_ID, organId)
.eq(FIELD_DELETED, false)
.in(FIELD_STATUS, statusList)
.inIfPresent("og.id",ids)
.inIfPresent("o.id",pageReqVO.getOrderIds())
.inIfPresent("og.id", ids)
.inIfPresent("o.id", pageReqVO.getOrderIds())
.likeIfPresent("o.id", pageReqVO.getOrderId() != null ? pageReqVO.getOrderId() : null)
.likeIfPresent(FIELD_CUSTOMER, pageReqVO.getConsignee())
.likeIfPresent(FIELD_CUSTOM_ORDER_NO, pageReqVO.getDefaultId())
@@ -586,7 +588,32 @@ public class PlanServiceImpl implements PlanService {
.betweenIfPresent(FIELD_ORDER_DATE, pageReqVO.getCreateTime());
PageDTO<OrderRespVOCopy> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
IPage<OrderRespVOCopy> orderList = planItemMapper.selectOrderList(page, queryWrapperX, type);
return new PageResult<>(orderList.getRecords(), orderList.getTotal());
List<OrderRespVOCopy> mainOrderList = orderList.getRecords();
long total = orderList.getTotal();
// 订单分组查询子单
if (ObjectUtil.equals(OrderPlanQueryTypeEnum.ORDER_GROUP.getType(), type) && CollUtil.isNotEmpty(mainOrderList)) {
// 主单id列表
Long[] mainOrderIds = mainOrderList.stream().map(OrderRespVOCopy::getOrderId).toArray(Long[]::new);
PageDTO<OrderRespVOCopy> childPage = new PageDTO<>(pageReqVO.getPageNo(), PageParam.PAGE_SIZE_NONE);
IPage<OrderRespVOCopy> childOrderList = planItemMapper.selectOrderList(childPage, queryWrapperX, type, mainOrderIds);
List<OrderRespVOCopy> childList = childOrderList.getRecords();
if (CollUtil.isNotEmpty(childList)) {
// 按 parentId 分组
Map<Long, List<OrderRespVOCopy>> childMap = childList.stream()
.collect(Collectors.groupingBy(OrderRespVOCopy::getParentId));
// 回填 child
for (OrderRespVOCopy order : mainOrderList) {
order.setChild(childMap.getOrDefault(order.getOrderId(), null));
}
}
return new PageResult<>(mainOrderList, total);
}
return new PageResult<>(mainOrderList, total);
}
@@ -103,58 +103,67 @@
<select id="selectOrderNear" resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderOverdueRespVO">
select
o.id,
o.api_order_id,
o.customer,
o.parent_id,
o.organ_id,
o.status,
o.order_date,
o.order_sort,
o.delivery_date,
o.order_type,
o.custom_order_no,
o.address,
o.data_type,
o.phone_number,
o.dealer,
o.dealer_phone_number,
o.salesman,
o.splitter,
o.remark
o.splitter
from orders o
where o.organ_id = #{organId}
and o.deleted = 0
and o.status != 4
and o.delivery_date = #{orderDate}
and o.deleted = 0
and o.status != 4
and o.delivery_date = #{orderDate}
<choose>
<when test="orderIds != null and orderIds.length > 0">
AND parent_id IN
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
#{orderId}
</foreach>
</when>
<otherwise>
AND parent_id = 0
</otherwise>
</choose>
</select>
<select id="selectOrderOverdue" resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderOverdueRespVO">
select
o.id,
o.api_order_id,
o.customer,
o.parent_id,
o.organ_id,
o.status,
o.order_date,
o.delivery_date,
o.order_type,
o.order_sort,
o.custom_order_no,
o.data_type,
o.address,
o.phone_number,
o.dealer,
o.dealer_phone_number,
o.salesman,
o.splitter,
o.remark,
LPAD(FLOOR(TIMESTAMPDIFF(DAY, o.delivery_date, #{today})), 2, '0') AS beOverdue
o.splitter
from orders o
where o.organ_id = #{organId}
and o.deleted = 0
and o.status != 4
and #{today} >= DATE(o.delivery_date)
and o.deleted = 0
and o.status != 4
and #{today} >= DATE(o.delivery_date)
<choose>
<when test="orderIds != null and orderIds.length > 0">
AND parent_id IN
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
#{orderId}
</foreach>
</when>
<otherwise>
AND parent_id = 0
</otherwise>
</choose>
</select>
<select id="selectOrderCountProducePeriod" resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderCountProducePeriodRespVO">
@@ -20,13 +20,11 @@
<select id="selectOrderList" resultMap="OrderPageMap">
select
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@ORDER_GROUP.getType()">
distinct
</if>
o.id as orderId,
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@ORDER_GROUP.getType()">
o.plate_num - o.planned_plate_num as num,
o.area - o.planned_plate_area as area,
o.parent_id as parentId,
</if>
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@GOODS_GROUP.getType()">
sum(og.plate_num - og.planned_plate_num) as num,
@@ -46,6 +44,19 @@
${ew.customSqlSegment}
and o.plate_num - o.planned_plate_num > 0
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@ORDER_GROUP.getType()">
<choose>
<when test="orderIds != null and orderIds.length > 0">
AND o.parent_id IN
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
#{orderId}
</foreach>
</when>
<otherwise>
AND o.parent_id = 0
</otherwise>
</choose>
</if>
<if test="type != null and type == @com.cf.imes.module.executor.enums.OrderPlanQueryTypeEnum@GOODS_GROUP.getType()">
and og.plate_num - og.planned_plate_num > 0
group by orderId,orderDate,deliveryDate,customer,address,defineId,status