mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、删除柜体、部件改造;2、分堆打包扫描关联-部件父级逻辑修复;3、新增分堆打包details返回订单列表orders;
This commit is contained in:
+4
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.executor.controller.admin.manage.pack.heapsplit;
|
||||
|
||||
import com.cf.imes.module.executor.controller.admin.manage.pack.vo.OrderPartsRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.pack.vo.PackOrdersInfoRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.pack.vo.PlateDetailsRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@@ -24,4 +25,7 @@ public class OrdersHeapSplitDetailRespVO {
|
||||
|
||||
@Schema(description = "配件列表")
|
||||
private List<OrderPartsRespVO> parts;
|
||||
|
||||
@Schema(description = "订单列表")
|
||||
private List<PackOrdersInfoRespVO> orders;
|
||||
}
|
||||
|
||||
+3
@@ -24,4 +24,7 @@ public class OrdersUnpackDetailRespVO {
|
||||
|
||||
@Schema(description = "未打包配件列表")
|
||||
private List<OrderPartsRespVO> parts;
|
||||
|
||||
@Schema(description = "订单列表")
|
||||
private List<PackOrdersInfoRespVO> orders;
|
||||
}
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.cf.imes.module.executor.controller.admin.manage.pack.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2026/4/15 16:02
|
||||
*/
|
||||
@Schema(description = "管理后台 - 分堆打包订单信息 Response VO")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class PackOrdersInfoRespVO {
|
||||
@Schema(description = "订单编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "自定义单号")
|
||||
private String customOrderNo;
|
||||
|
||||
@Schema(description = "经销商")
|
||||
private String dealer;
|
||||
|
||||
@Schema(description = "客户")
|
||||
private String customer;
|
||||
|
||||
@Schema(description = "地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
}
|
||||
+1
-8
@@ -5,8 +5,6 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2025/6/26 16:30
|
||||
@@ -15,7 +13,7 @@ import java.math.BigDecimal;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class OrderBodyPlateNumAndAreaDO {
|
||||
public class OrderBodyPlateNumDO {
|
||||
/**
|
||||
* 柜体id
|
||||
*/
|
||||
@@ -25,9 +23,4 @@ public class OrderBodyPlateNumAndAreaDO {
|
||||
* 板件数量
|
||||
*/
|
||||
private Integer num;
|
||||
|
||||
/**
|
||||
* 板件面积
|
||||
*/
|
||||
private BigDecimal area;
|
||||
}
|
||||
+3
-2
@@ -93,7 +93,8 @@ public class OrderItemDO {
|
||||
*/
|
||||
private Integer heapSplitStatus;
|
||||
|
||||
private Boolean source;
|
||||
|
||||
/**
|
||||
* 源item id
|
||||
*/
|
||||
private Long sourceId;
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package com.cf.imes.module.executor.dal.dataobject.orderItem;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 订单明细临时表 order_item DO
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@TableName("order_item_temp")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OrderItemTempDO {
|
||||
|
||||
/**
|
||||
* 明细编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private Long orderId;
|
||||
/**
|
||||
* 明细类型,1 板材 2 五金/配件 3 其他 4 报价配件
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 房间 ID
|
||||
*/
|
||||
private Long roomId;
|
||||
/**
|
||||
* 柜体 ID
|
||||
*/
|
||||
private Long bodyId;
|
||||
/**
|
||||
* 排单 ID
|
||||
*/
|
||||
private Long planId;
|
||||
/**
|
||||
* 包裹 ID
|
||||
*/
|
||||
private Long packageId;
|
||||
/**
|
||||
* 加工组 ID
|
||||
*/
|
||||
private Long groupId;
|
||||
/**
|
||||
* 订单板件id
|
||||
*/
|
||||
private Long plateId;
|
||||
/**
|
||||
* 五金配件id
|
||||
*/
|
||||
private Long partsId;
|
||||
/**
|
||||
* 部件数量
|
||||
*/
|
||||
private Double num;
|
||||
|
||||
/**
|
||||
* 已打包数量
|
||||
*/
|
||||
private Double packNum;
|
||||
|
||||
/**
|
||||
* 已分堆数量
|
||||
*/
|
||||
private Double heapNum;
|
||||
|
||||
// 组织 ID
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Long organId;
|
||||
|
||||
/**
|
||||
* 部件id
|
||||
*/
|
||||
private Long compId;
|
||||
|
||||
/**
|
||||
* cad视图id
|
||||
*/
|
||||
private Integer cadViewId;
|
||||
|
||||
/**
|
||||
* 分堆状态
|
||||
*/
|
||||
private Integer heapSplitStatus;
|
||||
|
||||
/**
|
||||
* 源item id
|
||||
*/
|
||||
private Long sourceId;
|
||||
}
|
||||
+12
-7
@@ -22,7 +22,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
|
||||
|
||||
@@ -154,14 +153,20 @@ public interface GoodsMapper extends BaseMapperX<GoodsDO> {
|
||||
|
||||
List<Long> selectPlanGroupListDataSource(@Param("planId") Long planId,@Param("organId") Long organId);
|
||||
|
||||
|
||||
|
||||
default List<GoodsDO> selectGoodsListByStatus(Long orderId, List<Long> goodsIds, Long organId) {
|
||||
/**
|
||||
* 查询订单商品编号下已删除的商品
|
||||
*
|
||||
* @param orderId
|
||||
* @param goodsIds
|
||||
* @param organId
|
||||
* @return
|
||||
*/
|
||||
default List<GoodsDO> selectGoodsListByStatus(Long orderId, Collection<Long> goodsIds, Long organId) {
|
||||
return selectList(new LambdaQueryWrapperX<GoodsDO>()
|
||||
.eq(GoodsDO::getOrganId, organId)
|
||||
.eq(GoodsDO::getDeleted, true)
|
||||
.eqIfPresent(GoodsDO::getOrderId,orderId)
|
||||
.inIfPresent(GoodsDO::getId,goodsIds));
|
||||
.eqIfPresent(GoodsDO::getOrderId, orderId)
|
||||
.inIfPresent(GoodsDO::getId, goodsIds));
|
||||
|
||||
}
|
||||
|
||||
@@ -209,5 +214,5 @@ public interface GoodsMapper extends BaseMapperX<GoodsDO> {
|
||||
* @param orderGoodsIds
|
||||
* @return
|
||||
*/
|
||||
List<OrderGoodsPlateNumAndAreaDO> selectPlateNumAndArea(@Param("orderGoodsIds") Set<Long> orderGoodsIds);
|
||||
List<OrderGoodsPlateNumAndAreaDO> selectPlateNumAndArea(@Param("orderGoodsIds") Collection<Long> orderGoodsIds, @Param("delete") Boolean delete);
|
||||
}
|
||||
+2
-1
@@ -319,7 +319,8 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
||||
* 查询订单下板件数量和面积
|
||||
*
|
||||
* @param orderId
|
||||
* @param delete 是否删除
|
||||
* @return
|
||||
*/
|
||||
OrderPlateNumAndAreaDO selectPlateNumAndArea(@Param("orderId") Long orderId);
|
||||
OrderPlateNumAndAreaDO selectPlateNumAndArea(@Param("orderId") Long orderId, @Param("delete") Boolean delete);
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderModuleRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyPlateNumAndAreaDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyPlateNumDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -203,5 +203,5 @@ public interface OrderBodyMapper extends BaseMapperX<OrderBodyDO> {
|
||||
* @param orderBodyIds
|
||||
* @return
|
||||
*/
|
||||
List<OrderBodyPlateNumAndAreaDO> selectPlateNumAndArea(@Param("orderBodyIds") Set<Long> orderBodyIds);
|
||||
List<OrderBodyPlateNumDO> selectPlateNumAndArea(@Param("orderBodyIds") Collection<Long> orderBodyIds, @Param("delete") Boolean delete);
|
||||
}
|
||||
+30
-7
@@ -104,17 +104,31 @@ public interface OrderItemMapper extends BaseMapperX<OrderItemDO> {
|
||||
}
|
||||
|
||||
|
||||
default List<OrderItemDO> selectPackId(Long orderId,List<Long> bodyIds, Long organId) {
|
||||
/**
|
||||
* 查询订单条件下的包裹id
|
||||
*
|
||||
* @param orderId
|
||||
* @param bodyIds
|
||||
* @param organId
|
||||
* @return
|
||||
*/
|
||||
default List<OrderItemDO> selectPackId(Long orderId, List<Long> bodyIds, Long organId) {
|
||||
return selectList(new LambdaQueryWrapperX<OrderItemDO>()
|
||||
.eq(OrderItemDO::getOrganId,organId)
|
||||
.eq(OrderItemDO::getOrderId,orderId)
|
||||
.inIfPresent(OrderItemDO::getBodyId,bodyIds)
|
||||
.eq(OrderItemDO::getOrganId, organId)
|
||||
.eq(OrderItemDO::getOrderId, orderId)
|
||||
.inIfPresent(OrderItemDO::getBodyId, bodyIds)
|
||||
.select(OrderItemDO::getPackageId));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void deletePackList(@Param("orderId") Long orderId,@Param("packIds") List<Long> packIds,@Param("organId") Long organId);
|
||||
/**
|
||||
* 重置订单包裹编号下的包裹号、分堆打包状态和数量
|
||||
*
|
||||
* @param orderId
|
||||
* @param packIds
|
||||
* @param organId
|
||||
*/
|
||||
void deletePackList(@Param("orderId") Long orderId, @Param("packIds") Set<String> packIds, @Param("organId") Long organId);
|
||||
|
||||
List<OrderGoodsRespVO> selectGoodsByOrderId(@Param("orderId") Long orderId,
|
||||
@Param("organId") Long organId,
|
||||
@@ -127,7 +141,16 @@ public interface OrderItemMapper extends BaseMapperX<OrderItemDO> {
|
||||
Integer countPartsNotId(@Param("orderId") Long orderId, @Param("bodyId") Set<Long> bodyIds, @Param("goodsId") Long partsId,
|
||||
@Param("organId") Long organId, @Param("deleted") Integer deleted);
|
||||
|
||||
List<Long> selectOrderPlanList(@Param("orderId") Long orderId,@Param("roomIds") Set<Long> roomIds, @Param("bodyId") Long bodyId,@Param("organId") Long organId);
|
||||
/**
|
||||
* 查询订单条件下是否有已排单的板件
|
||||
*
|
||||
* @param orderId
|
||||
* @param roomIds
|
||||
* @param bodyId
|
||||
* @param organId
|
||||
* @return
|
||||
*/
|
||||
List<Integer> selectExistOrderPlan(@Param("orderId") Long orderId, @Param("roomIds") Set<Long> roomIds, @Param("bodyId") Long bodyId, @Param("organId") Long organId);
|
||||
|
||||
List<PlateDetailsRespVO> selectPrintPlateList(@Param("orderNo")Long orderNo, @Param("packageNo") Long packageNo, @Param("organId") Long organId);
|
||||
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.cf.imes.module.executor.dal.mysql.orderItem;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemTempDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单明细临时表 order_item_temp Mapper
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2026/4/10 11:46
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderItemTempMapper extends BaseMapper<OrderItemTempDO> {
|
||||
/**
|
||||
* 查询订单明细插入到明细临时表
|
||||
*
|
||||
* @param orderId
|
||||
* @param bodyIds
|
||||
* @param compIds
|
||||
*/
|
||||
void selectInsertOrderItemTemp(@Param("orderId") Long orderId, @Param("organId") Long organId, @Param("bodyIds") List<Long> bodyIds, @Param("compIds") List<Long> compIds);
|
||||
|
||||
/**
|
||||
* 查询订单明细临时插入到明细表
|
||||
*
|
||||
* @param orderId
|
||||
* @param bodyIds
|
||||
* @param compIds
|
||||
*/
|
||||
void selectInsertOrderItem(@Param("orderId") Long orderId, @Param("organId") Long organId, @Param("bodyIds") List<Long> bodyIds, @Param("compIds") List<Long> compIds);
|
||||
|
||||
}
|
||||
+4
-3
@@ -30,9 +30,10 @@ public interface OrderComponentMapper extends BaseMapperX<OrderComponentDO> {
|
||||
* 查询id列表中每个节点上同一棵树的所有父级
|
||||
*
|
||||
* @param ids
|
||||
* @param deleted
|
||||
* @return
|
||||
*/
|
||||
List<OrderComponentDO> getTopComponentListIn(@Param("ids") List<Long> ids);
|
||||
List<OrderComponentDO> getTopComponentListIn(@Param("ids") List<Long> ids, boolean deleted);
|
||||
|
||||
/**
|
||||
* 查询订单topid下的所有大于level层级的部件列表
|
||||
@@ -63,9 +64,9 @@ public interface OrderComponentMapper extends BaseMapperX<OrderComponentDO> {
|
||||
OrderComponentDO selectByIdIgnoreDeleted(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 恢复部件
|
||||
* 更新部件删除状态
|
||||
*
|
||||
* @param componentIds
|
||||
*/
|
||||
void restoreOrderComponents(@Param("orderId") Long orderId, @Param("componentIds") List<Long> componentIds);
|
||||
void updateOrderComponentsDeletedStatus(@Param("orderId") Long orderId, @Param("componentIds") List<Long> componentIds, @Param("delete") boolean delete);
|
||||
}
|
||||
+37
-6
@@ -100,9 +100,21 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
|
||||
|
||||
void updateDeletedById(@Param("plateIds") List<Long> plateIds, @Param("deleted") Integer deleted, @Param("organId") Long organId, @Param("orderId") Long orderId);
|
||||
|
||||
|
||||
/**
|
||||
* 删除小板,重置开料状态
|
||||
*
|
||||
* @param plateIds
|
||||
* @param organId
|
||||
* @param orderId
|
||||
*/
|
||||
void updateDeletedPlate(@Param("plateIds") List<Long> plateIds, @Param("organId") Long organId, @Param("orderId") Long orderId);
|
||||
|
||||
/**
|
||||
* 恢复小板,重置开料状态
|
||||
* @param plateIds
|
||||
* @param organId
|
||||
* @param orderId
|
||||
*/
|
||||
void updateNoDeletedPlate(@Param("plateIds") List<Long> plateIds, @Param("organId") Long organId, @Param("orderId") Long orderId);
|
||||
|
||||
int countPlateByOrderId(@Param("orderId") Long orderId, @Param("organId") Long organId, @Param("deleted") Integer deleted);
|
||||
@@ -125,12 +137,22 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
|
||||
Integer selectPlateNum(@Param("orderId") Long orderId,@Param("organId") Long organId);
|
||||
|
||||
|
||||
default List<PlateDO> selectPlateDeletedStatus(Long orderId,List<Long> goodsIds, Long organId) {
|
||||
/**
|
||||
* 查询商品id下未删除的板件
|
||||
*
|
||||
* @param orderId
|
||||
* @param goodsIds
|
||||
* @param organId
|
||||
* @return
|
||||
*/
|
||||
default List<PlateDO> selectPlateDeletedStatus(Long orderId, Collection<Long> goodsIds, Long organId) {
|
||||
return selectList(new LambdaQueryWrapperX<PlateDO>()
|
||||
.eq(PlateDO::getOrganId,organId)
|
||||
.eq(PlateDO::getDeleted,false)
|
||||
.in(PlateDO::getGoodsId,goodsIds)
|
||||
.eqIfPresent(PlateDO::getOrderId, orderId));
|
||||
.eq(PlateDO::getOrganId, organId)
|
||||
.eq(PlateDO::getDeleted, false)
|
||||
.in(PlateDO::getGoodsId, goodsIds)
|
||||
.eqIfPresent(PlateDO::getOrderId, orderId)
|
||||
.select(PlateDO::getGoodsId)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +163,14 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
|
||||
|
||||
List<PlateDO> selectNoDeletedPlate(@Param("orderId") Long orderId, @Param("bodyIds") Collection<Long> bodyIds,@Param("organId") Long organId);
|
||||
|
||||
/**
|
||||
* 查询订单条件下被删除的板件
|
||||
*
|
||||
* @param orderId
|
||||
* @param bodyIds
|
||||
* @param organId
|
||||
* @return
|
||||
*/
|
||||
List<PlateDO> selectDeletedPlate(@Param("orderId") Long orderId, @Param("bodyIds") Collection<Long> bodyIds,@Param("organId") Long organId);
|
||||
|
||||
// 根据订单id删除
|
||||
@@ -335,6 +365,7 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
|
||||
* 查询部件下板件用到的order_goods id
|
||||
*
|
||||
* @param componentIds
|
||||
* @param deleted true:查order_item_temp、false:查order_item
|
||||
* @return
|
||||
*/
|
||||
List<Long> selectOrderComponentGoodsIds(@Param("orderId") Long orderId, @Param("componentIds") List<Long> componentIds, @Param("deleted") boolean deleted);
|
||||
|
||||
+5
-2
@@ -4,8 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.exception.ErrorCode;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.pack.heapsplit.HeapSplitSaveReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.pack.heapsplit.OrdersHeapSplitDetailRespVO;
|
||||
@@ -16,6 +14,7 @@ import com.cf.imes.module.executor.dal.mysql.orderParts.OrderPartsMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||
import com.cf.imes.module.executor.enums.OrderPackageMethodEnum;
|
||||
import com.cf.imes.module.executor.enums.heapsplit.HeapSplitStatusEnum;
|
||||
import com.cf.imes.module.executor.service.order.OrderService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -48,6 +47,9 @@ public class HeapSplitServiceImpl implements HeapSplitService {
|
||||
@Resource
|
||||
private OrderPartsMapper orderPartsMapper;
|
||||
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveHeapsplit(HeapSplitSaveReqVO reqVO) {
|
||||
@@ -183,6 +185,7 @@ public class HeapSplitServiceImpl implements HeapSplitService {
|
||||
@Override
|
||||
public OrdersHeapSplitDetailRespVO getOrdersHeapSplitedDetail(List<Long> orderIds) {
|
||||
OrdersHeapSplitDetailRespVO respVO = new OrdersHeapSplitDetailRespVO();
|
||||
respVO.setOrders(orderService.getPackOrdersInfo(orderIds));
|
||||
respVO.setParts(orderPartsMapper.selectOrdersHeapSplitPartsList(orderIds));
|
||||
respVO.setPlates(plateMapper.selectOrdersHeapSplitPlateList(orderIds));
|
||||
return respVO;
|
||||
|
||||
+20
-1
@@ -6,7 +6,10 @@ import com.cf.imes.module.executor.controller.admin.manage.pack.vo.*;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.query.vo.pack.OrderPackageVO;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.query.vo.pack.PackageDetailsRespVO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface PackService {
|
||||
|
||||
@@ -53,7 +56,7 @@ public interface PackService {
|
||||
|
||||
|
||||
/**
|
||||
* 删除包裹
|
||||
* 删除包裹并还原包裹中的内容
|
||||
*
|
||||
* @param reqVO
|
||||
*/
|
||||
@@ -91,4 +94,20 @@ public interface PackService {
|
||||
* @return
|
||||
*/
|
||||
List<PackageDetailsRespVO> getOrderPackageDetails(Long orderId, String packageNo);
|
||||
|
||||
/**
|
||||
* 根据包裹编号列表获取对应订单编号
|
||||
*
|
||||
* @param packageNo
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<Long>> getOrderIdsByPackageNo(Collection<Long> packageNo);
|
||||
|
||||
/**
|
||||
* 批量删除订单包裹
|
||||
*
|
||||
* @param orderId
|
||||
* @param packageNo
|
||||
*/
|
||||
void deletePackageByPackageNo(Long orderId, Set<String> packageNo);
|
||||
}
|
||||
|
||||
+29
-5
@@ -29,7 +29,6 @@ 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.orderParts.OrderPartsMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.pack.OrderPackageMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.pack.OrderPrepackagedMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||
import com.cf.imes.module.executor.enums.OrderPackageMethodEnum;
|
||||
import com.cf.imes.module.executor.enums.pack.PackScanComponentCorrelationTypeEnum;
|
||||
@@ -46,6 +45,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -91,9 +91,6 @@ public class PackServiceImpl implements PackService {
|
||||
@Resource
|
||||
private SnowflakeIdWorker3rd idWorker;
|
||||
|
||||
@Resource
|
||||
private OrderPrepackagedMapper orderPrepackagedMapper;
|
||||
|
||||
@Resource
|
||||
private OrderPlanApi orderPlanApi;
|
||||
|
||||
@@ -1038,7 +1035,7 @@ public class PackServiceImpl implements PackService {
|
||||
componentIdList = null;
|
||||
} else if (PackScanComponentCorrelationTypeEnum.PARENT.getType().equals(type)) {
|
||||
// 部件父级
|
||||
componentIdList = orderComponentService.getChildComponentIdsOnMyParent(compId);
|
||||
componentIdList = orderComponentService.getChildComponentIdsOnMy(compId);
|
||||
} else {
|
||||
// 部件顶级
|
||||
componentIdList = orderComponentService.getChildComponentIdsOnTopId(compId);
|
||||
@@ -1061,6 +1058,7 @@ public class PackServiceImpl implements PackService {
|
||||
@Override
|
||||
public OrdersUnpackDetailRespVO getOrdersUnpackDetails(List<Long> orderIds) {
|
||||
OrdersUnpackDetailRespVO ordersUnpackDetailRespVO = new OrdersUnpackDetailRespVO();
|
||||
ordersUnpackDetailRespVO.setOrders(orderService.getPackOrdersInfo(orderIds));
|
||||
ordersUnpackDetailRespVO.setPlates(orderPlateMapper.selectOrdersPackPlateList(orderIds));
|
||||
ordersUnpackDetailRespVO.setParts(orderPartsMapper.selectOrdersPartsList(orderIds));
|
||||
return ordersUnpackDetailRespVO;
|
||||
@@ -1097,4 +1095,30 @@ public class PackServiceImpl implements PackService {
|
||||
packPlateList.addAll(packPartsList);
|
||||
return packPlateList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<Long>> getOrderIdsByPackageNo(Collection<Long> packageNo) {
|
||||
List<OrderPackagDO> orderPackagDOS = orderPackageMapper.selectList(new LambdaQueryWrapper<OrderPackagDO>()
|
||||
.in(OrderPackagDO::getPackageNo, packageNo)
|
||||
.eq(OrderPackagDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
|
||||
.select(OrderPackagDO::getPackageNo, OrderPackagDO::getOrderId)
|
||||
);
|
||||
if (CollUtil.isEmpty(orderPackagDOS)) {
|
||||
// 按照packageNo分组,value是订单列表
|
||||
return orderPackagDOS.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
OrderPackagDO::getPackageNo,
|
||||
Collectors.mapping(OrderPackagDO::getOrderId, Collectors.toList())
|
||||
));
|
||||
}
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePackageByPackageNo(Long orderId, Set<String> packageNo) {
|
||||
orderPackageMapper.delete(new LambdaQueryWrapper<OrderPackagDO>()
|
||||
.eq(OrderPackagDO::getOrderId, orderId)
|
||||
.in(OrderPackagDO::getPackageNo, packageNo)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.cf.imes.module.executor.service.order;
|
||||
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 订单信息版本控制服务 Service
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2026/4/14 14:11
|
||||
*/
|
||||
public interface OrderInfoVersionControlService {
|
||||
/**
|
||||
* 更新订单的板件数量和面积
|
||||
*
|
||||
* @param orderDO
|
||||
* @param delete
|
||||
*/
|
||||
void updateOrderPlateNumAndArea(OrderDO orderDO, Boolean delete);
|
||||
|
||||
/**
|
||||
* 更新订单柜体板件数量
|
||||
*
|
||||
* @param orderBodyIds
|
||||
* @param delete
|
||||
*/
|
||||
void updateOrderBodyPlateNum(Collection<Long> orderBodyIds, Boolean delete);
|
||||
|
||||
/**
|
||||
* 更新影响的订单商品的 板件数量和面积
|
||||
*
|
||||
* @param orderGoodsIds
|
||||
* @param delete
|
||||
*/
|
||||
void updateOrderGoodsPlateNumAndArea(Collection<Long> orderGoodsIds, Boolean delete);
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
package com.cf.imes.module.executor.service.order;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaUpdateWrapperX;
|
||||
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.goods.OrderGoodsPlateNumAndAreaDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderPlateNumAndAreaDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyPlateNumDO;
|
||||
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.enums.ErrorCodeConstants;
|
||||
import com.cf.imes.module.executor.enums.OrderStatusEnum;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 订单信息版本控制服务实现类 ServiceImpl
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2026/4/14 14:17
|
||||
*/
|
||||
@Service
|
||||
public class OrderInfoVersionControlServiceImpl implements OrderInfoVersionControlService {
|
||||
@Resource
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@Resource
|
||||
private OrderBodyMapper orderBodyMapper;
|
||||
|
||||
@Resource
|
||||
private GoodsMapper goodsMapper;
|
||||
|
||||
@Override
|
||||
public void updateOrderPlateNumAndArea(OrderDO orderDO, Boolean delete) {
|
||||
Long orderId = orderDO.getId();
|
||||
// 重新计算订单数量
|
||||
// 统计每个orders下的未排单面积,更新到orders中
|
||||
OrderPlateNumAndAreaDO orderPlateNumAndAreaDO = orderMapper.selectPlateNumAndArea(orderId, delete);
|
||||
|
||||
// 当前订单下排单的板件数量
|
||||
Integer num = orderPlateNumAndAreaDO.getNum();
|
||||
|
||||
int version = orderDO.getVersion();
|
||||
LambdaUpdateWrapper<OrderDO> updateWrapper = new LambdaUpdateWrapperX<OrderDO>()
|
||||
.eq(OrderDO::getId, orderId)
|
||||
.eq(OrderDO::getVersion, version)
|
||||
.setIfPresent(OrderDO::getStatus, num == 0 ? OrderStatusEnum.EMPTY.getStatus() : OrderStatusEnum.NEW_ORDER.getStatus())
|
||||
.set(OrderDO::getPlannedPlateArea, orderPlateNumAndAreaDO.getArea())
|
||||
.set(OrderDO::getPlannedPlateNum, num)
|
||||
.set(OrderDO::getVersion, version + 1);
|
||||
int update = orderMapper.update(updateWrapper);
|
||||
if (update == 0) {
|
||||
throw new ServiceException(com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_PLATE_UPDATE_CONCURRENCY_ERROR, orderId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOrderBodyPlateNum(Collection<Long> orderBodyIds, Boolean delete) {
|
||||
// 查询删除涉及的柜体
|
||||
Map<Long, OrderBodyDO> bodyMap = orderBodyMapper.selectByIds(orderBodyIds)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(OrderBodyDO::getId, Function.identity()));
|
||||
|
||||
// 统计删除涉及的柜体下的数量和面积、更新到order_body
|
||||
Map<Long, OrderBodyPlateNumDO> bodyStatMap = orderBodyMapper.selectPlateNumAndArea(orderBodyIds, delete)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
OrderBodyPlateNumDO::getOrderBodyId,
|
||||
Function.identity()
|
||||
));
|
||||
for (Map.Entry<Long, OrderBodyPlateNumDO> entry : bodyStatMap.entrySet()) {
|
||||
Long orderBodyId = entry.getKey();
|
||||
|
||||
OrderBodyDO orderBodyDO = bodyMap.get(orderBodyId);
|
||||
int version = orderBodyDO.getVersion();
|
||||
OrderBodyPlateNumDO stat =
|
||||
bodyStatMap.getOrDefault(orderBodyId,
|
||||
new OrderBodyPlateNumDO(orderBodyId, 0));
|
||||
|
||||
int update = orderBodyMapper.update(new LambdaUpdateWrapper<OrderBodyDO>()
|
||||
.eq(OrderBodyDO::getId, orderBodyId)
|
||||
.eq(OrderBodyDO::getVersion, version)
|
||||
.set(OrderBodyDO::getPlateNum, stat.getNum())
|
||||
.set(OrderBodyDO::getVersion, version + 1));
|
||||
|
||||
if (update == 0) {
|
||||
throw new ServiceException(ErrorCodeConstants.BODY_PLATE_UPDATE_CONCURRENCY_ERROR, orderBodyId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOrderGoodsPlateNumAndArea(Collection<Long> orderGoodsIds, Boolean delete) {
|
||||
// 查询删除涉及的order_goods
|
||||
Map<Long, GoodsDO> goodsMap =
|
||||
goodsMapper.selectByIds(orderGoodsIds)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(GoodsDO::getId, Function.identity()));
|
||||
|
||||
// 统计删除涉及的order_goods下的数量和面积、更新到order_goods
|
||||
Map<Long, OrderGoodsPlateNumAndAreaDO> goodStatMap =
|
||||
goodsMapper.selectPlateNumAndArea(orderGoodsIds, delete)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
OrderGoodsPlateNumAndAreaDO::getOrderGoodsId,
|
||||
Function.identity()
|
||||
));
|
||||
|
||||
for (Long orderGoodsId : orderGoodsIds) {
|
||||
|
||||
GoodsDO goodsDO = goodsMap.get(orderGoodsId);
|
||||
|
||||
OrderGoodsPlateNumAndAreaDO stat =
|
||||
goodStatMap.getOrDefault(orderGoodsId,
|
||||
new OrderGoodsPlateNumAndAreaDO(orderGoodsId, 0, BigDecimal.ZERO));
|
||||
|
||||
int version = goodsDO.getVersion();
|
||||
int update = goodsMapper.update(new LambdaUpdateWrapper<GoodsDO>()
|
||||
.eq(GoodsDO::getId, orderGoodsId)
|
||||
.eq(GoodsDO::getVersion, version)
|
||||
.set(GoodsDO::getArea, stat.getArea())
|
||||
.set(GoodsDO::getPlateNum, stat.getNum())
|
||||
.set(GoodsDO::getVersion, version + 1));
|
||||
|
||||
if (update == 0) {
|
||||
throw new ServiceException(ErrorCodeConstants.GOODS_PLATE_UPDATE_CONCURRENCY_ERROR, orderGoodsId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-1
@@ -3,6 +3,7 @@ package com.cf.imes.module.executor.service.order;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.pack.vo.PackOrdersInfoRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO;
|
||||
@@ -109,7 +110,7 @@ public interface OrderService {
|
||||
PageResult<OrderGoodsDetailRespVO> getGoodsDetail(Long orderId, Set<Long> roomId, Set<Long> bodyId, Set<Long> groupId, Set<Long> goodsId, Integer pageNo, Integer pageSize, Integer deleted);
|
||||
|
||||
/**
|
||||
* 删除柜体/柜体还原
|
||||
* 柜体还原
|
||||
*
|
||||
* @param orderId: 订单id
|
||||
* @param roomId: 房间id
|
||||
@@ -117,6 +118,14 @@ public interface OrderService {
|
||||
*/
|
||||
void updateDeleteBody(Long orderId, Set<Long> roomId, Long bodyId, Integer status);
|
||||
|
||||
/**
|
||||
* 还原柜体
|
||||
*
|
||||
* @param orderId
|
||||
* @param roomId
|
||||
* @param bodyId
|
||||
* @param status
|
||||
*/
|
||||
void updateRestoreBody(Long orderId, Set<Long> roomId, Long bodyId, Integer status);
|
||||
|
||||
/**
|
||||
@@ -197,4 +206,12 @@ public interface OrderService {
|
||||
* @return
|
||||
*/
|
||||
List<Long> getFatherAndSonOrderIds(List<Long> orderIds);
|
||||
|
||||
/**
|
||||
* 查询分堆打包订单信息列表
|
||||
*
|
||||
* @param orderIds
|
||||
* @return
|
||||
*/
|
||||
List<PackOrdersInfoRespVO> getPackOrdersInfo(List<Long> orderIds);
|
||||
}
|
||||
+191
-209
@@ -22,6 +22,7 @@ import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.pack.vo.PackOrdersInfoRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO;
|
||||
@@ -41,6 +42,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.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.orderParts.OrderPartsDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderParts.PartsDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
|
||||
@@ -53,10 +55,9 @@ 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.orderItem.OrderItemTempMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.orderParts.OrderPartsMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.orderParts.PartsMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.pack.OrderPackageMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.pack.OrderPrepackagedMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plan.PlanMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.planitem.PlanItemMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper;
|
||||
@@ -67,6 +68,7 @@ import com.cf.imes.module.executor.enums.DataTypeEnum;
|
||||
import com.cf.imes.module.executor.enums.OrderDeletedEnum;
|
||||
import com.cf.imes.module.executor.enums.OrderStatusEnum;
|
||||
import com.cf.imes.module.executor.service.customplateno.CustomPlateNoGenerateService;
|
||||
import com.cf.imes.module.executor.service.manage.pack.PackService;
|
||||
import com.cf.imes.module.executor.service.orderImport.OrderImportHandler;
|
||||
import com.cf.imes.module.executor.service.orderImport.factory.OrderImportHandlerFactory;
|
||||
import com.cf.imes.module.executor.service.ordercomponent.OrderComponentService;
|
||||
@@ -78,6 +80,7 @@ import com.cf.imes.module.infra.api.file.FileApi;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.aop.framework.AopContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -97,7 +100,6 @@ import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.cf.imes.framework.common.util.json.JsonUtils.unzipString;
|
||||
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
|
||||
@@ -144,12 +146,6 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Resource
|
||||
private OrderItemMapper orderItemMapper;
|
||||
|
||||
@Resource
|
||||
private OrderPackageMapper orderPackageMapper;
|
||||
|
||||
@Resource
|
||||
private OrderPrepackagedMapper orderPrepackagedMapper;
|
||||
|
||||
@Resource
|
||||
private OrderInputProcessor orderInputProcessor;
|
||||
|
||||
@@ -172,6 +168,16 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Resource
|
||||
private OrderComponentService orderComponentService;
|
||||
|
||||
@Resource
|
||||
private OrderItemTempMapper orderItemTempMapper;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private PackService packService;
|
||||
|
||||
@Resource
|
||||
private OrderInfoVersionControlService orderInfoVersionControlService;
|
||||
|
||||
private static final String SUBMIT_STATE = "1"; // 空订单 原生产系统
|
||||
|
||||
|
||||
@@ -255,7 +261,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
@Override
|
||||
public OrderDO getOrder(Long id, Long... organIds) {
|
||||
Long userOrganId = SecurityFrameworkUtils.getUserOrganId();
|
||||
Long userOrganId = getUserOrganId();
|
||||
if (ObjectUtil.isNull(userOrganId) && ArrayUtil.isNotEmpty(organIds)) {
|
||||
userOrganId = organIds[0];
|
||||
}
|
||||
@@ -405,116 +411,115 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDeleteBody(Long orderId, Set<Long> roomIds, Long bodyId, Integer status) { // 要删除传1,还原传0
|
||||
Long organId = getUserOrganId();
|
||||
|
||||
// 判断订单的状态和订单柜体对应的板材是否已经排单
|
||||
validateOrderStatus(orderId, roomIds, bodyId, getUserOrganId());
|
||||
OrderDO orderDO = validateOrderStatus(orderId, roomIds, bodyId, organId);
|
||||
|
||||
List<Long> bodyIds = validateOrderBodyExists(orderId, bodyId, getUserOrganId(), roomIds, OrderDeletedEnum.NOT_DELETED.getStatus());
|
||||
// 获取对应柜体id列表
|
||||
List<Long> bodyIds = validateOrderBodyExists(orderId, bodyId, organId, roomIds, OrderDeletedEnum.NOT_DELETED.getStatus());
|
||||
|
||||
// 受影响的ordergoodsId
|
||||
List<Long> goodsIdDeleted = null;
|
||||
if (CollUtil.isNotEmpty(bodyIds)) {
|
||||
|
||||
// 删除柜体
|
||||
orderBodyMapper.updateDeletedBody(bodyIds, organId, orderId);
|
||||
|
||||
// 删除加工组
|
||||
orderGroupMapper.updateDeletedGroup(bodyIds, organId, orderId);
|
||||
|
||||
|
||||
if (!bodyIds.isEmpty()){
|
||||
|
||||
orderBodyMapper.updateDeletedBody(bodyIds, getUserOrganId(), orderId);// 柜体
|
||||
|
||||
orderGroupMapper.updateDeletedGroup(bodyIds, getUserOrganId(), orderId);// 加工组
|
||||
|
||||
List<PlateDO> plateDOList = plateMapper.selectNoDeletedPlate(orderId, bodyIds, getUserOrganId());
|
||||
List<PlateDO> plateDOList = plateMapper.selectNoDeletedPlate(orderId, bodyIds, organId);
|
||||
|
||||
|
||||
if (!plateDOList.isEmpty()) {
|
||||
if (CollUtil.isNotEmpty(plateDOList)) {
|
||||
|
||||
// 删除小板,大板,包裹,目前只要小板排单,就不能删除小板信息
|
||||
OrderServiceImpl o = (OrderServiceImpl) AopContext.currentProxy();
|
||||
o.updateDeletePlate(plateDOList, orderId, bodyIds);
|
||||
goodsIdDeleted = o.updateDeletePlate(plateDOList, orderId, bodyIds);
|
||||
|
||||
}
|
||||
|
||||
// 删除配件信息
|
||||
List<Long> partsList = orderPartsMapper.selectPartsIdListByBodyId(bodyIds, getUserOrganId(), orderId);
|
||||
// order_item记录临时表
|
||||
orderItemTempMapper.selectInsertOrderItemTemp(orderId, organId, bodyIds, null);
|
||||
|
||||
if (!partsList.isEmpty()){
|
||||
// 判断是否含有重复的配件
|
||||
Iterator<Long> iterator = partsList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Long id = iterator.next(); // 配件id判断是否重复
|
||||
// 判断不符合删除配件的规则
|
||||
Integer partsCount = orderItemMapper.countPartsNotId(orderId, new HashSet<>(bodyIds), id, getUserOrganId(), 0);
|
||||
if (partsCount > 0){
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!partsList.isEmpty()) {
|
||||
orderPartsMapper.updateDeletedParts(partsList, getUserOrganId(),orderId);
|
||||
}
|
||||
// order_item删除记录
|
||||
orderItemMapper.delete(new LambdaQueryWrapper<OrderItemDO>()
|
||||
.eq(OrderItemDO::getOrderId, orderId)
|
||||
.in(OrderItemDO::getBodyId, bodyIds)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
int bodyCount = orderBodyMapper.selectBodyCountByDeleted(orderId, getUserOrganId(), 0);
|
||||
|
||||
// 订单柜体数量判断
|
||||
if ( bodyCount == 0 ) {
|
||||
orderMapper.updateOrderStatus(orderId, OrderStatusEnum.EMPTY.getStatus(), getUserOrganId());
|
||||
// 更新影响的柜体的板件数量和面积
|
||||
orderInfoVersionControlService.updateOrderBodyPlateNum(bodyIds, true);
|
||||
// 更新影响的订单商品的板件数量和面积
|
||||
if (CollUtil.isNotEmpty(goodsIdDeleted)) {
|
||||
orderInfoVersionControlService.updateOrderGoodsPlateNumAndArea(goodsIdDeleted, true);
|
||||
}
|
||||
|
||||
// 更新订单的板件数量和面积
|
||||
orderInfoVersionControlService.updateOrderPlateNumAndArea(orderDO, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateRestoreBody(Long orderId, Set<Long> roomIds, Long bodyId, Integer status) { // 要删除传1,还原传0
|
||||
Long organId = getUserOrganId();
|
||||
|
||||
// 校验存在
|
||||
OrderDO orderDO = orderMapper.selectOrderOne(orderId, getUserOrganId());
|
||||
// 校验订单
|
||||
OrderDO orderDO = orderMapper.selectOrderOne(orderId, organId);
|
||||
|
||||
AssertUtils.notEmpty(orderDO,ORDER_NOT_EXISTS);
|
||||
|
||||
List<Long> bodyIds = validateOrderBodyExists(orderId, bodyId, organId, roomIds, OrderDeletedEnum.DELETED.getStatus());
|
||||
|
||||
List<Long> bodyIds = validateOrderBodyExists(orderId, bodyId, getUserOrganId(), roomIds, OrderDeletedEnum.DELETED.getStatus());
|
||||
|
||||
|
||||
// 受影响的ordergoodsId
|
||||
Set<Long> goodsIdRestore = null;
|
||||
if (!bodyIds.isEmpty()){
|
||||
// 恢复柜体
|
||||
orderBodyMapper.updateNoDeletedBody(bodyIds, organId, orderId);
|
||||
|
||||
orderBodyMapper.updateNoDeletedBody(bodyIds, getUserOrganId(), orderId);// 柜体
|
||||
orderGroupMapper.updateNoDeletedGroup(bodyIds, getUserOrganId(), orderId);// 加工组
|
||||
// 恢复加工组
|
||||
orderGroupMapper.updateNoDeletedGroup(bodyIds, organId, orderId);
|
||||
|
||||
List<PlateDO> plateDOList = plateMapper.selectDeletedPlate(orderId, bodyIds, getUserOrganId());
|
||||
// 查询柜体下删除的板件
|
||||
List<PlateDO> plateDOList = plateMapper.selectDeletedPlate(orderId, bodyIds, organId);
|
||||
|
||||
// 小板还原
|
||||
if (!plateDOList.isEmpty()) {
|
||||
if (CollUtil.isNotEmpty(plateDOList)) {
|
||||
|
||||
// 还原小板,小板对应的大板信息
|
||||
OrderServiceImpl o = (OrderServiceImpl) AopContext.currentProxy();
|
||||
o.updateRestorePlate(orderId,plateDOList);
|
||||
goodsIdRestore = o.updateRestorePlate(orderId, plateDOList);
|
||||
|
||||
}
|
||||
|
||||
List<Long> partsList = orderPartsMapper.selectPartsIdListByBodyId(bodyIds, getUserOrganId(), orderId); // 配件
|
||||
if (partsList != null && !partsList.isEmpty()){
|
||||
orderPartsMapper.updateNoDeletedParts(partsList, getUserOrganId(),orderId);
|
||||
}
|
||||
// order_item恢复临时记录
|
||||
orderItemTempMapper.selectInsertOrderItem(orderId, organId, bodyIds, null);
|
||||
|
||||
// order_item_temp删除记录
|
||||
orderItemTempMapper.delete(new LambdaQueryWrapper<OrderItemTempDO>()
|
||||
.eq(OrderItemTempDO::getOrderId, orderId)
|
||||
.in(OrderItemTempDO::getBodyId, bodyIds)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
List<PlateDO> plateDOS = plateMapper.selectPlateIsOptimized(Collections.singletonList(orderId), getUserOrganId());
|
||||
List<PlateDO> plateDOS = plateMapper.selectPlateIsOptimized(Collections.singletonList(orderId), organId);
|
||||
|
||||
if(!plateDOS.isEmpty()){
|
||||
if (CollUtil.isNotEmpty(plateDOS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int bodyCount = orderBodyMapper.selectBodyCountByDeleted(orderId, getUserOrganId(), 0);
|
||||
|
||||
// 订单柜体数量判断
|
||||
if ( bodyCount != 0 ) {
|
||||
orderMapper.updateOrderStatus(orderId, OrderStatusEnum.NEW_ORDER.getStatus(), getUserOrganId());
|
||||
// 更新影响的柜体的板件数量和面积
|
||||
orderInfoVersionControlService.updateOrderBodyPlateNum(bodyIds, false);
|
||||
// 更新影响的订单商品的板件数量和面积
|
||||
if (CollUtil.isNotEmpty(goodsIdRestore)) {
|
||||
orderInfoVersionControlService.updateOrderGoodsPlateNumAndArea(goodsIdRestore, false);
|
||||
}
|
||||
|
||||
|
||||
// 更新订单的板件数量和面积
|
||||
orderInfoVersionControlService.updateOrderPlateNumAndArea(orderDO, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -855,13 +860,22 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
}
|
||||
|
||||
// 验证柜体是否存在
|
||||
/**
|
||||
* 校验查询柜体,优先roomIds下的所有柜体
|
||||
*
|
||||
* @param orderId
|
||||
* @param bodyId
|
||||
* @param organId
|
||||
* @param roomIds
|
||||
* @param deleted
|
||||
* @return
|
||||
*/
|
||||
private List<Long> validateOrderBodyExists(Long orderId, Long bodyId, Long organId, Set<Long> roomIds, Integer deleted) {
|
||||
|
||||
List<Long> bodyIds = new ArrayList<>();
|
||||
|
||||
if (roomIds != null && !roomIds.isEmpty()) {
|
||||
bodyIds.addAll(orderBodyMapper.selectBodyIdByRoomId(orderId, roomIds, getUserOrganId(),deleted));
|
||||
if (CollUtil.isNotEmpty(roomIds)) {
|
||||
bodyIds.addAll(orderBodyMapper.selectBodyIdByRoomId(orderId, roomIds, organId, deleted));
|
||||
}
|
||||
|
||||
if (bodyId != null && bodyId != 0) {
|
||||
@@ -1314,188 +1328,145 @@ public class OrderServiceImpl implements OrderService {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 判断订单状态是否符合(如果已开料,不允许删除)
|
||||
private void validateOrderStatus(Long orderId,Set<Long> roomIds, Long bodyId, Long organId) {
|
||||
/**
|
||||
* 校验订单状态 和 是否排单
|
||||
*
|
||||
* @param orderId
|
||||
* @param roomIds
|
||||
* @param bodyId
|
||||
* @param organId
|
||||
*/
|
||||
private OrderDO validateOrderStatus(Long orderId, Set<Long> roomIds, Long bodyId, Long organId) {
|
||||
// 校验存在
|
||||
OrderDO orderDO = orderMapper.selectOrderOne(orderId, organId);
|
||||
if (orderDO == null)
|
||||
throw new ServiceException(ORDER_NOT_EXISTS);
|
||||
|
||||
|
||||
if (ObjectUtils.isEmpty(roomIds) && ObjectUtils.isEmpty(bodyId)) {
|
||||
if (CollUtil.isEmpty(roomIds) && ObjectUtils.isEmpty(bodyId)) {
|
||||
throw new ServiceException(ORDER_ERROR);
|
||||
}
|
||||
|
||||
// 判断小板是否已开料,已开料不允许删除
|
||||
List<Long> planIds = orderItemMapper.selectOrderPlanList(orderId,roomIds,bodyId,organId);
|
||||
Boolean orderPlanExist = CollUtil.isNotEmpty(orderItemMapper.selectExistOrderPlan(orderId, roomIds, bodyId, organId));
|
||||
|
||||
AssertUtils.empty(planIds, PLATE_IS_PLAN);
|
||||
|
||||
// if(CollUtil.isNotEmpty(planIds)) {
|
||||
//
|
||||
// List<PlanDO> planDOS = planMapper.selectPlanStatus(planIds, organId);
|
||||
//
|
||||
// AssertUtils.empty(planDOS, ORDER_PLAN_ERROR);
|
||||
//
|
||||
// }
|
||||
AssertUtils.notEquals(Boolean.FALSE, orderPlanExist, PLATE_IS_PLAN);
|
||||
|
||||
return orderDO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 删除小板,大板,包裹
|
||||
/**
|
||||
* 删除小板,大板,包裹
|
||||
*
|
||||
* @param plateDOList
|
||||
* @param orderId
|
||||
* @param bodyIds
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDeletePlate(List<PlateDO> plateDOList, Long orderId ,List<Long> bodyIds) {
|
||||
public List<Long> updateDeletePlate(List<PlateDO> plateDOList, Long orderId ,List<Long> bodyIds) {
|
||||
Long organId = getUserOrganId();
|
||||
|
||||
Set<Long> goodsIds = new HashSet<>();
|
||||
|
||||
List<Long> plateIds = plateDOList.stream().map(PlateDO::getId).toList();
|
||||
|
||||
List<Long> goodsIds = plateDOList.stream().map(PlateDO::getGoodsId).distinct().toList();
|
||||
|
||||
// 删除小板的信息 和 排单小板关联表中的小板信息
|
||||
plateMapper.updateDeletedPlate(plateIds, getUserOrganId(), orderId);
|
||||
// 分批删除小板
|
||||
List<List<PlateDO>> plateSplit = CollUtil.split(plateDOList, 500);
|
||||
for (List<PlateDO> plateBatch : plateSplit) {
|
||||
// 板件id列表
|
||||
List<Long> plateIdBatch = plateBatch.stream().map(PlateDO::getId).toList();
|
||||
// 记录商品id列表
|
||||
goodsIds.addAll(plateBatch.stream().map(PlateDO::getGoodsId).toList());
|
||||
// 删除小板
|
||||
plateMapper.updateDeletedPlate(plateIdBatch, organId, orderId);
|
||||
}
|
||||
|
||||
|
||||
// 删除包裹,只需删除,无需还原
|
||||
List<OrderItemDO> orderItemDOS = orderItemMapper.selectPackId(orderId, bodyIds, getUserOrganId());
|
||||
List<OrderItemDO> orderItemDOS = orderItemMapper.selectPackId(orderId, bodyIds, organId);
|
||||
|
||||
if(CollUtil.isNotEmpty(orderItemDOS)) {
|
||||
|
||||
// 条件下涉及到的包裹号
|
||||
List<Long> packIds = orderItemDOS.stream().map(OrderItemDO::getPackageId).distinct().toList();
|
||||
|
||||
// todo 删除打包内容
|
||||
// orderPackageMapper.updatePackList(orderId, packIds, getUserOrganId());
|
||||
// 包裹号和订单号的对应关系
|
||||
Map<String, List<Long>> orderIdsByPackageNo = packService.getOrderIdsByPackageNo(packIds);
|
||||
|
||||
orderItemMapper.deletePackList(orderId, packIds, getUserOrganId());
|
||||
Set<String> needDeletePackNoSet = new HashSet<>();
|
||||
|
||||
orderPrepackagedMapper.deletePacked(orderId, getUserOrganId());
|
||||
for (Map.Entry<String, List<Long>> entry : orderIdsByPackageNo.entrySet()) {
|
||||
String packNoKey = entry.getKey();
|
||||
List<Long> orderIds = entry.getValue();
|
||||
|
||||
OrderDO orderDO = orderMapper.selectById(orderId);
|
||||
// 当这个包裹只属于这个订单时,删除这个包裹
|
||||
if (CollUtil.isNotEmpty(orderIds) && orderIds.size() == 1 && ObjectUtil.equals(orderId, orderIds.get(0))) {
|
||||
needDeletePackNoSet.add(packNoKey);
|
||||
}
|
||||
}
|
||||
|
||||
AssertUtils.notEmpty(orderDO,ORDER_NOT_EXISTS);
|
||||
if (CollUtil.isNotEmpty(needDeletePackNoSet)) {
|
||||
// 删除订单下对应编号的包裹
|
||||
packService.deletePackageByPackageNo(orderId, needDeletePackNoSet);
|
||||
|
||||
orderDO.setPackaged(OrderPackageStatusEnum.UNPACKED.getStatus());
|
||||
// 重置明细的包裹编号
|
||||
orderItemMapper.deletePackList(orderId, needDeletePackNoSet, organId);
|
||||
|
||||
orderMapper.updateById(orderDO);
|
||||
OrderDO orderDO = orderMapper.selectById(orderId);
|
||||
|
||||
AssertUtils.notEmpty(orderDO, ORDER_NOT_EXISTS);
|
||||
|
||||
orderDO.setPackaged(OrderPackageStatusEnum.UNPACKED.getStatus());
|
||||
|
||||
orderMapper.updateById(orderDO);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除大板
|
||||
List<PlateDO> goodsList = plateMapper.selectPlateDeletedStatus(orderId, goodsIds, getUserOrganId());
|
||||
// 查询商品id下还有的板件
|
||||
List<PlateDO> goodsPlateList = plateMapper.selectPlateDeletedStatus(orderId, goodsIds, organId);
|
||||
Set<Long> goodsIdNotAllDeletedSet = goodsPlateList.stream().map(PlateDO::getGoodsId).collect(Collectors.toSet());
|
||||
|
||||
List<Long> goodsIdList = goodsList.stream().map(PlateDO::getGoodsId).distinct().toList();
|
||||
|
||||
List<Long> goodsIdDeleted = Stream.concat(
|
||||
goodsIds.stream().filter(str -> !goodsIdList.contains(str)),
|
||||
goodsIdList.stream().filter(str -> !goodsIds.contains(str)))
|
||||
// 获取删除掉的板件所属商品id 和 还有未删除的商品id的差集
|
||||
List<Long> goodsIdDeleted = goodsIds.stream()
|
||||
.filter(id -> !goodsIdNotAllDeletedSet.contains(id))
|
||||
.toList();
|
||||
|
||||
if (!goodsIdDeleted.isEmpty()) {
|
||||
|
||||
goodsMapper.updateDeletedById(orderId,goodsIdDeleted, getUserOrganId());
|
||||
|
||||
if (CollUtil.isNotEmpty(goodsIdDeleted)) {
|
||||
// 删除大板
|
||||
goodsMapper.updateDeletedById(orderId, goodsIdDeleted, organId);
|
||||
}
|
||||
|
||||
|
||||
// if (CollUtil.isNotEmpty(planIds)) {
|
||||
//
|
||||
// planItemMapper.delete(new LambdaQueryWrapperX<PlanItemDO>()
|
||||
// .eq(PlanItemDO::getOrganId, getUserOrganId())
|
||||
// .eq(PlanItemDO::getOrderId, orderId)
|
||||
// .in(PlanItemDO::getPlateId, plateIds)
|
||||
// .in(PlanItemDO::getPlanId, planIds));
|
||||
//
|
||||
// // 删除小板信息需要确认:优化画图的信息是否都在 余料的那个字段里
|
||||
//
|
||||
// // 判断删除的柜体对应的板材是否和排单板材一样
|
||||
// List<GoodsDO> goodsDOS = goodsMapper.selectPlanGoodsListByPlanIdList(null,planIds, getUserOrganId());
|
||||
//
|
||||
// // 一样,同时删除排单的信息
|
||||
// if (goodsDOS.isEmpty()) {
|
||||
// planService.deletePlan(planIds);
|
||||
// } else {
|
||||
// // 只要有排单,不管删除的柜体的板材数和排单数一样,都要删除排单对应的优化数据(不用这种写法进行删除时,有时会报错,原因目前还没找到)
|
||||
// esUtils.deleteEsDocument("planId",planIds,ORDER_REMAIN_PLATE_MODEL);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
return goodsIdDeleted;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 还原小板,小板对应的大板信息
|
||||
/**
|
||||
* 还原小板,小板对应的大板信息
|
||||
*
|
||||
* @param orderId
|
||||
* @param plateDOList
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateRestorePlate(Long orderId, List<PlateDO> plateDOList){
|
||||
public Set<Long> updateRestorePlate(Long orderId, List<PlateDO> plateDOList) {
|
||||
Long organId = getUserOrganId();
|
||||
|
||||
List<Long> plateIds = plateDOList.stream().map(PlateDO::getId).toList();
|
||||
|
||||
List<Long> goodsIds = plateDOList.stream().map(PlateDO::getGoodsId).distinct().toList();
|
||||
|
||||
|
||||
plateMapper.updateNoDeletedPlate(plateIds, getUserOrganId(), orderId);
|
||||
Set<Long> goodsIds = new HashSet<>();
|
||||
|
||||
// 分批删除小板
|
||||
List<List<PlateDO>> plateSplit = CollUtil.split(plateDOList, 1000);
|
||||
for (List<PlateDO> plateBatch : plateSplit) {
|
||||
// 板件id列表
|
||||
List<Long> plateIdBatch = plateBatch.stream().map(PlateDO::getId).toList();
|
||||
// 记录商品id列表
|
||||
goodsIds.addAll(plateBatch.stream().map(PlateDO::getGoodsId).toList());
|
||||
// 删除小板
|
||||
plateMapper.updateNoDeletedPlate(plateIdBatch, organId, orderId);
|
||||
}
|
||||
|
||||
// 还原大板
|
||||
List<GoodsDO> goodsDOS = goodsMapper.selectGoodsListByStatus(orderId, goodsIds, getUserOrganId());
|
||||
List<GoodsDO> goodsDOS = goodsMapper.selectGoodsListByStatus(orderId, goodsIds, organId);
|
||||
if (!goodsDOS.isEmpty()) {
|
||||
goodsMapper.updateBatch(goodsDOS.stream().map(m -> m.setDeleted(false)).toList());
|
||||
}
|
||||
|
||||
|
||||
// // 当大板对应的小板已经排单时,新建相同类型的大板,并将其他未排单的小板对应的大板ID修改为新的大板ID
|
||||
// List<GoodsDO> goodsDOList = goodsMapper.selectNoPlanGoodsList(orderId, goodsIds, getUserOrganId());
|
||||
//
|
||||
// List<GoodsDO> goodsList = BeanUtils.toBean(goodsDOList, GoodsDO.class);
|
||||
//
|
||||
// if (!goodsDOList.isEmpty()) {
|
||||
//
|
||||
// // 新增的大板信息
|
||||
// List<GoodsDO> list = goodsDOList.stream()
|
||||
// .peek(m -> {
|
||||
// m.setId(null);
|
||||
// m.setPlanId(0L);
|
||||
// m.setCreateTime(LocalDateTime.now());
|
||||
// m.setUpdateTime(LocalDateTime.now());
|
||||
// })
|
||||
// .toList();
|
||||
//
|
||||
// goodsMapper.insertBatch(list);
|
||||
//
|
||||
// // 构建新的数据集,保存新的大板ID和旧的大板ID,大板的实际ID关联这两个信息
|
||||
// List<OrderGoodsIds> orderGoodsIds = BeanUtils.toBean(list, OrderGoodsIds.class);
|
||||
//
|
||||
// List<OrderGoodsIds> orderGoodsIdsList = new ArrayList<>();
|
||||
//
|
||||
// for (GoodsDO goodsDO : goodsList) {
|
||||
// orderGoodsIdsList.addAll(orderGoodsIds.stream()
|
||||
// .filter(f -> f.getGoodsId().equals(goodsDO.getGoodsId()))
|
||||
// .map(m -> m.setOldId(goodsDO.getId())).toList());
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // 需要修改的小板为未排单的部分,无论其是否删除,都需要修改,但只需修改大板ID即可,其他信息无需修改
|
||||
// List<PlateDO> plateDOS = plateMapper.selectNoPlanPlate(orderId, goodsIds, getUserOrganId());
|
||||
//
|
||||
// List<PlateDO> plateList = new ArrayList<>();
|
||||
//
|
||||
// for (OrderGoodsIds ids : orderGoodsIdsList) {
|
||||
//
|
||||
// plateList.addAll(plateDOS.stream()
|
||||
// .filter(f -> f.getGoodsId().equals(ids.getOldId()))
|
||||
// .peek(m -> {
|
||||
// m.setGoodsId(ids.getId());
|
||||
// })
|
||||
// .toList());
|
||||
// }
|
||||
//
|
||||
// plateMapper.updateBatch(plateList);
|
||||
//
|
||||
// }
|
||||
|
||||
return goodsIds;
|
||||
}
|
||||
|
||||
|
||||
@@ -1765,4 +1736,15 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
return new ArrayList<>(allIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PackOrdersInfoRespVO> getPackOrdersInfo(List<Long> orderIds) {
|
||||
// 查询订单
|
||||
List<OrderDO> orderDOS = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>()
|
||||
.in(OrderDO::getId, orderIds)
|
||||
.eq(OrderDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
|
||||
.select(OrderDO::getId, OrderDO::getCustomOrderNo, OrderDO::getDealer, OrderDO::getCustomer, OrderDO::getAddress, OrderDO::getRemark)
|
||||
);
|
||||
return BeanUtil.copyToList(orderDOS, PackOrdersInfoRespVO.class);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -97,12 +97,12 @@ public interface OrderComponentService {
|
||||
List<Long> getChildComponentIdsOnTopId(Long id);
|
||||
|
||||
/**
|
||||
* 查询部件归属的父部件的所有子部件id列表
|
||||
* 查询部件归属的父部件和其下所有子部件id列表
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Long> getChildComponentIdsOnMyParent(Long id);
|
||||
List<Long> getChildComponentIdsOnMy(Long id);
|
||||
|
||||
/**
|
||||
* 查询订单下板件+配件详情
|
||||
|
||||
+196
-143
@@ -6,10 +6,10 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.enums.OrderPackageStatusEnum;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
@@ -23,29 +23,28 @@ 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.goods.GoodsDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.goods.OrderGoodsPlateNumAndAreaDO;
|
||||
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;
|
||||
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.order.OrderDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderPlateNumAndAreaDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyPlateNumAndAreaDO;
|
||||
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.orderItem.OrderItemMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemTempMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.ordercomponent.OrderComponentMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||
import com.cf.imes.module.executor.enums.ErrorCodeConstants;
|
||||
import com.cf.imes.module.executor.service.manage.pack.PackService;
|
||||
import com.cf.imes.module.executor.service.order.OrderInfoVersionControlService;
|
||||
import com.cf.imes.module.infra.api.file.FileApi;
|
||||
import jakarta.annotation.Resource;
|
||||
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;
|
||||
@@ -94,9 +93,18 @@ public class OrderComponentServiceImpl implements OrderComponentService {
|
||||
@Resource
|
||||
private OrderBodyMapper orderBodyMapper;
|
||||
|
||||
@Resource
|
||||
private OrderItemTempMapper orderItemTempMapper;
|
||||
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
@Resource
|
||||
private OrderInfoVersionControlService orderInfoVersionControlService;
|
||||
|
||||
@Resource
|
||||
private PackService packService;
|
||||
|
||||
@Override
|
||||
public List<OrderComponentRespVO> getOrderComponentList(OrderDetailComponentListReqVO reqVO) {
|
||||
List<OrderComponentRespVO> resultList = new ArrayList<>();
|
||||
@@ -111,7 +119,7 @@ public class OrderComponentServiceImpl implements OrderComponentService {
|
||||
List<List<Long>> partitions = CollUtil.split(orderDetailComponentIds, 500);
|
||||
for (List<Long> partIds : partitions) {
|
||||
// 根据部件id查询顶级节点
|
||||
List<OrderComponentDO> topComponentList = orderComponentMapper.getTopComponentListIn(partIds);
|
||||
List<OrderComponentDO> topComponentList = orderComponentMapper.getTopComponentListIn(partIds, reqVO.isDeleted());
|
||||
if (CollUtil.isNotEmpty(topComponentList)) {
|
||||
resultDOList.addAll(topComponentList);
|
||||
}
|
||||
@@ -378,6 +386,8 @@ public class OrderComponentServiceImpl implements OrderComponentService {
|
||||
OrderDO orderDO = orderMapper.selectById(orderId);
|
||||
AssertUtils.notEmpty(orderDO, ORDER_NOT_EXISTS);
|
||||
|
||||
Long organId = orderDO.getOrganId();
|
||||
|
||||
OrderComponentDO componentDO = orderComponentMapper.selectById(id);
|
||||
AssertUtils.notEmpty(componentDO, ORDER_COMPONENT_NOT_EXIST);
|
||||
|
||||
@@ -387,55 +397,117 @@ public class OrderComponentServiceImpl implements OrderComponentService {
|
||||
// 整理出所属的下级,整理成id集合
|
||||
Set<Long> deleteIds = getChildrenIds(componentDO, componentOnTop);
|
||||
|
||||
// 板件id Set
|
||||
Set<Long> plateIdSet = new HashSet<>();
|
||||
// 需要重新累计数量的order_goods id
|
||||
Set<Long> deleteGoodsIds = new HashSet<>();
|
||||
// 需要重新累计数量的柜体 id
|
||||
Set<Long> deleteBodyIds = new HashSet<>();
|
||||
// 删除的板件总数量
|
||||
int deleteRowsTotal = 0;
|
||||
// 需要处理的包裹编号
|
||||
Set<Long> packageIdSet = new HashSet<>();
|
||||
|
||||
// 👉 批量更新缓存
|
||||
List<Long> plateBuffer = new ArrayList<>(1000);
|
||||
|
||||
// 分批处理:删除对应的板件
|
||||
List<List<Long>> split = CollUtil.split(deleteIds, 10);
|
||||
for (List<Long> ids : split) {
|
||||
// 5、部件下是否有在排单中的板件,有则终止删除
|
||||
// 部件下是否有在排单中的板件,有则终止删除
|
||||
boolean plateInPlan = orderComponentMapper.selectOrderComponentPlateInPlan(ids);
|
||||
if (plateInPlan) {
|
||||
throw new ServiceException(ORDER_COMPONENT_DELETE_PLATE_IN_PLAN);
|
||||
}
|
||||
|
||||
// 查询明细表数据准备删除
|
||||
List<OrderItemDO> orderItemDOS = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>()
|
||||
.eq(OrderItemDO::getOrderId, orderId)
|
||||
.in(OrderItemDO::getCompId, ids)
|
||||
.ne(OrderItemDO::getPlateId, 0L)
|
||||
.select(OrderItemDO::getPlateId, OrderItemDO::getBodyId, OrderItemDO::getPackageId)
|
||||
);
|
||||
|
||||
// 删除前累计goods_id
|
||||
List<Long> batchDeleteGoodsIds = plateMapper.selectOrderComponentGoodsIds(orderId, ids, false);
|
||||
deleteGoodsIds.addAll(batchDeleteGoodsIds);
|
||||
|
||||
// 删除前累计body_id
|
||||
List<Long> batchDeleteBodyIds = plateMapper.selectOrderComponentBodyIds(orderId, ids, false);
|
||||
deleteBodyIds.addAll(batchDeleteBodyIds);
|
||||
|
||||
// 删除部件下的板件
|
||||
int deletedRows;
|
||||
do {
|
||||
// 调用 Mapper 批量删除
|
||||
deletedRows = plateMapper.updateOrderComponentPlate(orderId, ids, true);
|
||||
// 循环直到没有删除
|
||||
deleteRowsTotal += deletedRows;
|
||||
} while (deletedRows > 0);
|
||||
// 累计必要数据:更新order_plate、累计bodyid和packageid
|
||||
cumulativeNecessaryDeleteData(orderId, organId, orderItemDOS, plateIdSet, plateBuffer, deleteBodyIds, packageIdSet);
|
||||
|
||||
// 删除部件
|
||||
orderComponentMapper.deleteByIds(ids);
|
||||
orderComponentMapper.updateOrderComponentsDeletedStatus(orderId, ids, true);
|
||||
|
||||
// TODO 打包解包
|
||||
}
|
||||
|
||||
if (deleteRowsTotal == 0) {
|
||||
return;
|
||||
// 👉 处理最后不足1000的
|
||||
if (CollUtil.isNotEmpty(plateBuffer)) {
|
||||
plateMapper.updateDeletedPlate(plateBuffer, organId, orderId);
|
||||
}
|
||||
|
||||
// 更新影响的柜体
|
||||
updateOrderBodyPlateNum(deleteBodyIds);
|
||||
// 更新影响的订单商品
|
||||
updateOrderGoodsPlateNumAndArea(deleteGoodsIds);
|
||||
// 更新订单
|
||||
updateOrderPlateNumAndArea(orderDO);
|
||||
// order_item记录临时表
|
||||
orderItemTempMapper.selectInsertOrderItemTemp(orderId, organId, null, deleteIds.stream().toList());
|
||||
|
||||
// order_item删除记录
|
||||
orderItemMapper.delete(new LambdaQueryWrapper<OrderItemDO>()
|
||||
.eq(OrderItemDO::getOrderId, orderId)
|
||||
.in(OrderItemDO::getCompId, deleteIds)
|
||||
);
|
||||
|
||||
// 删除包裹
|
||||
if (CollUtil.isNotEmpty(packageIdSet)) {
|
||||
unpackAndDeletePack(orderId, organId, packageIdSet);
|
||||
}
|
||||
|
||||
// 更新影响的柜体的板件数量和面积
|
||||
if (CollUtil.isNotEmpty(deleteBodyIds)) {
|
||||
orderInfoVersionControlService.updateOrderBodyPlateNum(deleteBodyIds, true);
|
||||
}
|
||||
// 更新影响的订单商品的板件数量和面积
|
||||
if (CollUtil.isNotEmpty(deleteGoodsIds)) {
|
||||
orderInfoVersionControlService.updateOrderGoodsPlateNumAndArea(deleteGoodsIds, true);
|
||||
}
|
||||
// 更新订单的板件数量和面积
|
||||
orderInfoVersionControlService.updateOrderPlateNumAndArea(orderDO, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解包和删除包裹
|
||||
*
|
||||
* @param orderId
|
||||
* @param organId
|
||||
* @param packIds
|
||||
*/
|
||||
private void unpackAndDeletePack(Long orderId, Long organId, Set<Long> packIds) {
|
||||
// 包裹号和订单号的对应关系
|
||||
Map<String, List<Long>> orderIdsByPackageNo = packService.getOrderIdsByPackageNo(packIds);
|
||||
|
||||
Set<String> needDeletePackNoSet = new HashSet<>();
|
||||
|
||||
for (Map.Entry<String, List<Long>> entry : orderIdsByPackageNo.entrySet()) {
|
||||
String packNoKey = entry.getKey();
|
||||
List<Long> orderIds = entry.getValue();
|
||||
|
||||
// 当这个包裹只属于这个订单时,删除这个包裹
|
||||
if (CollUtil.isNotEmpty(orderIds) && orderIds.size() == 1 && ObjectUtil.equals(orderId, orderIds.get(0))) {
|
||||
needDeletePackNoSet.add(packNoKey);
|
||||
}
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(needDeletePackNoSet)) {
|
||||
// 删除订单下对应编号的包裹
|
||||
packService.deletePackageByPackageNo(orderId, needDeletePackNoSet);
|
||||
|
||||
// 重置明细的包裹编号
|
||||
orderItemMapper.deletePackList(orderId, needDeletePackNoSet, organId);
|
||||
|
||||
OrderDO orderDO = orderMapper.selectById(orderId);
|
||||
|
||||
AssertUtils.notEmpty(orderDO, ORDER_NOT_EXISTS);
|
||||
|
||||
orderDO.setPackaged(OrderPackageStatusEnum.UNPACKED.getStatus());
|
||||
|
||||
orderMapper.updateById(orderDO);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -445,6 +517,8 @@ public class OrderComponentServiceImpl implements OrderComponentService {
|
||||
OrderDO orderDO = orderMapper.selectById(orderId);
|
||||
AssertUtils.notEmpty(orderDO, ORDER_NOT_EXISTS);
|
||||
|
||||
Long organId = orderDO.getOrganId();
|
||||
|
||||
OrderComponentDO componentDO = orderComponentMapper.selectByIdIgnoreDeleted(id);
|
||||
AssertUtils.notEmpty(componentDO, ORDER_COMPONENT_NOT_EXIST);
|
||||
AssertUtils.equals(componentDO.getDeleted(), false, ORDER_COMPONENT_NO_NEED_TO_RESTORE);
|
||||
@@ -460,163 +534,146 @@ public class OrderComponentServiceImpl implements OrderComponentService {
|
||||
// 查询top树下层级以下的所有部件
|
||||
List<OrderComponentDO> componentOnTop = orderComponentMapper.getComponentListOnTopLevel(orderId, componentDO.getTopId(), componentDO.getLevel(), true);
|
||||
|
||||
// 板件id Set
|
||||
Set<Long> plateIdSet = new HashSet<>();
|
||||
// 整理出所属的下级,整理成id集合
|
||||
Set<Long> restoreIds = getChildrenIds(componentDO, componentOnTop);
|
||||
|
||||
// 需要重新累计数量的order_goods id
|
||||
Set<Long> restoreGoodsIds = new HashSet<>();
|
||||
// 需要重新累计数量的柜体 id
|
||||
Set<Long> restoreBodyIds = new HashSet<>();
|
||||
// 删除的板件总数量
|
||||
int restoreRowsTotal = 0;
|
||||
|
||||
// 👉 批量更新缓存
|
||||
List<Long> plateBuffer = new ArrayList<>(1000);
|
||||
|
||||
// 分批处理:删除对应的板件
|
||||
List<List<Long>> split = CollUtil.split(restoreIds, 10);
|
||||
for (List<Long> ids : split) {
|
||||
// 5、部件下是否有在排单中的板件,有则终止恢复
|
||||
// 部件下是否有在排单中的板件,有则终止恢复
|
||||
boolean plateInPlan = orderComponentMapper.selectOrderComponentPlateInPlan(ids);
|
||||
if (plateInPlan) {
|
||||
throw new ServiceException(ORDER_COMPONENT_DELETE_PLATE_IN_PLAN);
|
||||
}
|
||||
|
||||
// 查询临时表数据准备恢复
|
||||
List<OrderItemTempDO> orderItemDOS = orderItemTempMapper.selectList(new LambdaQueryWrapper<OrderItemTempDO>()
|
||||
.eq(OrderItemTempDO::getOrderId, orderId)
|
||||
.in(OrderItemTempDO::getCompId, ids)
|
||||
.ne(OrderItemTempDO::getPlateId, 0L)
|
||||
.select(OrderItemTempDO::getPlateId, OrderItemTempDO::getBodyId)
|
||||
);
|
||||
|
||||
// 恢复前累计goods_id
|
||||
List<Long> batchDeleteGoodsIds = plateMapper.selectOrderComponentGoodsIds(orderId, ids, true);
|
||||
restoreGoodsIds.addAll(batchDeleteGoodsIds);
|
||||
|
||||
// 恢复前累计body_id
|
||||
List<Long> batchDeleteBodyIds = plateMapper.selectOrderComponentBodyIds(orderId, ids, true);
|
||||
restoreBodyIds.addAll(batchDeleteBodyIds);
|
||||
|
||||
// 恢复部件下的板件
|
||||
int restoreRows;
|
||||
do {
|
||||
// 批量恢复
|
||||
restoreRows = plateMapper.updateOrderComponentPlate(orderId, ids, false);
|
||||
// 循环直到没有影响
|
||||
restoreRowsTotal += restoreRows;
|
||||
} while (restoreRows > 0);
|
||||
// 累计必要数据:更新order_plate、累计bodyid
|
||||
cumulativeNecessaryRestoreData(orderId, organId, orderItemDOS, plateIdSet, plateBuffer, restoreBodyIds);
|
||||
|
||||
// 恢复部件
|
||||
orderComponentMapper.restoreOrderComponents(orderId, ids);
|
||||
|
||||
// TODO 打包解包
|
||||
orderComponentMapper.updateOrderComponentsDeletedStatus(orderId, ids, false);
|
||||
}
|
||||
|
||||
if (restoreRowsTotal == 0) {
|
||||
return;
|
||||
// 👉 处理最后不足1000的
|
||||
if (CollUtil.isNotEmpty(plateBuffer)) {
|
||||
plateMapper.updateNoDeletedPlate(plateBuffer, organId, orderId);
|
||||
}
|
||||
|
||||
// order_item恢复临时记录
|
||||
orderItemTempMapper.selectInsertOrderItem(orderId, organId, null, restoreIds.stream().toList());
|
||||
|
||||
// order_item_temp删除记录
|
||||
orderItemTempMapper.delete(new LambdaQueryWrapper<OrderItemTempDO>()
|
||||
.eq(OrderItemTempDO::getOrderId, orderId)
|
||||
.in(OrderItemTempDO::getCompId, restoreIds)
|
||||
);
|
||||
|
||||
// 更新影响的柜体
|
||||
updateOrderBodyPlateNum(restoreBodyIds);
|
||||
if (CollUtil.isNotEmpty(restoreBodyIds)) {
|
||||
orderInfoVersionControlService.updateOrderBodyPlateNum(restoreBodyIds, false);
|
||||
}
|
||||
// 更新影响的订单商品
|
||||
updateOrderGoodsPlateNumAndArea(restoreGoodsIds);
|
||||
if (CollUtil.isNotEmpty(restoreGoodsIds)) {
|
||||
orderInfoVersionControlService.updateOrderGoodsPlateNumAndArea(restoreGoodsIds, false);
|
||||
}
|
||||
// 更新订单
|
||||
updateOrderPlateNumAndArea(orderDO);
|
||||
orderInfoVersionControlService.updateOrderPlateNumAndArea(orderDO, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新影响的柜体的 板件数量
|
||||
* 累计必要数据
|
||||
*
|
||||
* @param orderBodyIds
|
||||
* @param orderId
|
||||
* @param organId
|
||||
* @param orderItemDOS 明细列表
|
||||
* @param plateIdSet 影响的板件id
|
||||
* @param plateBuffer 每1000条更新一次的plateid缓存
|
||||
* @param deleteBodyIds 影响的柜体id
|
||||
* @param packageIdSet 影响的包裹id
|
||||
*/
|
||||
private void updateOrderBodyPlateNum(Set<Long> orderBodyIds) {
|
||||
// 查询删除涉及的柜体
|
||||
Map<Long, OrderBodyDO> bodyMap = orderBodyMapper.selectByIds(orderBodyIds)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(OrderBodyDO::getId, Function.identity()));
|
||||
private void cumulativeNecessaryDeleteData(Long orderId, Long organId, List<OrderItemDO> orderItemDOS, Set<Long> plateIdSet, List<Long> plateBuffer, Set<Long> deleteBodyIds, Set<Long> packageIdSet) {
|
||||
for (OrderItemDO item : orderItemDOS) {
|
||||
|
||||
// 统计删除涉及的柜体下的数量和面积、更新到order_body
|
||||
Map<Long, OrderBodyPlateNumAndAreaDO> bodyStatMap = orderBodyMapper.selectPlateNumAndArea(orderBodyIds)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
OrderBodyPlateNumAndAreaDO::getOrderBodyId,
|
||||
Function.identity()
|
||||
));
|
||||
for (Long orderBodyId : orderBodyIds) {
|
||||
Long plateId = item.getPlateId();
|
||||
|
||||
OrderBodyDO orderBodyDO = bodyMap.get(orderBodyId);
|
||||
int version = orderBodyDO.getVersion();
|
||||
OrderBodyPlateNumAndAreaDO stat =
|
||||
bodyStatMap.getOrDefault(orderBodyId,
|
||||
new OrderBodyPlateNumAndAreaDO(orderBodyId, 0, BigDecimal.ZERO));
|
||||
if (plateId != null && plateIdSet.add(plateId)) {
|
||||
plateBuffer.add(plateId);
|
||||
|
||||
int update = orderBodyMapper.update(new LambdaUpdateWrapper<OrderBodyDO>()
|
||||
.eq(OrderBodyDO::getId, orderBodyId)
|
||||
.eq(OrderBodyDO::getVersion, version)
|
||||
.set(OrderBodyDO::getPlateNum, stat.getNum())
|
||||
.set(OrderBodyDO::getVersion, version + 1));
|
||||
// 满1000就更新
|
||||
if (plateBuffer.size() >= 1000) {
|
||||
// 删除小板
|
||||
plateMapper.updateDeletedPlate(plateBuffer, organId, orderId);
|
||||
plateBuffer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (update == 0) {
|
||||
throw new ServiceException(ErrorCodeConstants.BODY_PLATE_UPDATE_CONCURRENCY_ERROR, orderBodyId);
|
||||
|
||||
// 累计柜体id
|
||||
if (item.getBodyId() != null) {
|
||||
deleteBodyIds.add(item.getBodyId());
|
||||
}
|
||||
|
||||
// 累计包裹id
|
||||
if (item.getPackageId() != null) {
|
||||
packageIdSet.add(item.getPackageId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新影响的订单商品的 板件数量和面积
|
||||
* 累计必要数据
|
||||
*
|
||||
* @param orderGoodsIds
|
||||
* @param orderId
|
||||
* @param organId
|
||||
* @param orderItemTempDOS 临时明细
|
||||
* @param plateIdSet 影响的板件id
|
||||
* @param plateBuffer 每1000条更新一次的plateid缓存
|
||||
* @param restoreBodyIds 影响的柜体id
|
||||
*/
|
||||
private void updateOrderGoodsPlateNumAndArea(Set<Long> orderGoodsIds) {
|
||||
// 查询删除涉及的order_goods
|
||||
Map<Long, GoodsDO> goodsMap =
|
||||
goodsMapper.selectByIds(orderGoodsIds)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(GoodsDO::getId, Function.identity()));
|
||||
private void cumulativeNecessaryRestoreData(Long orderId, Long organId, List<OrderItemTempDO> orderItemTempDOS, Set<Long> plateIdSet, List<Long> plateBuffer, Set<Long> restoreBodyIds) {
|
||||
for (OrderItemTempDO item : orderItemTempDOS) {
|
||||
|
||||
// 统计删除涉及的order_goods下的数量和面积、更新到order_goods
|
||||
Map<Long, OrderGoodsPlateNumAndAreaDO> goodStatMap =
|
||||
goodsMapper.selectPlateNumAndArea(orderGoodsIds)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
OrderGoodsPlateNumAndAreaDO::getOrderGoodsId,
|
||||
Function.identity()
|
||||
));
|
||||
Long plateId = item.getPlateId();
|
||||
|
||||
for (Long orderGoodsId : orderGoodsIds) {
|
||||
if (plateId != null && plateIdSet.add(plateId)) {
|
||||
plateBuffer.add(plateId);
|
||||
|
||||
GoodsDO goodsDO = goodsMap.get(orderGoodsId);
|
||||
// 满1000就更新
|
||||
if (plateBuffer.size() >= 1000) {
|
||||
// 删除小板
|
||||
plateMapper.updateNoDeletedPlate(plateBuffer, organId, orderId);
|
||||
plateBuffer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
OrderGoodsPlateNumAndAreaDO stat =
|
||||
goodStatMap.getOrDefault(orderGoodsId,
|
||||
new OrderGoodsPlateNumAndAreaDO(orderGoodsId, 0, BigDecimal.ZERO));
|
||||
|
||||
int version = goodsDO.getVersion();
|
||||
int update = goodsMapper.update(new LambdaUpdateWrapper<GoodsDO>()
|
||||
.eq(GoodsDO::getId, orderGoodsId)
|
||||
.eq(GoodsDO::getVersion, version)
|
||||
.set(GoodsDO::getArea, stat.getArea())
|
||||
.set(GoodsDO::getPlateNum, stat.getNum())
|
||||
.set(GoodsDO::getVersion, version + 1));
|
||||
|
||||
if (update == 0) {
|
||||
throw new ServiceException(ErrorCodeConstants.GOODS_PLATE_UPDATE_CONCURRENCY_ERROR, orderGoodsId);
|
||||
// 累计柜体id
|
||||
if (item.getBodyId() != null) {
|
||||
restoreBodyIds.add(item.getBodyId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOrderPlateNumAndArea(OrderDO orderDO) {
|
||||
Long orderId = orderDO.getId();
|
||||
// 重新计算订单数量
|
||||
// 统计每个orders下的未排单面积,更新到orders中
|
||||
OrderPlateNumAndAreaDO orderPlateNumAndAreaDO = orderMapper.selectPlateNumAndArea(orderId);
|
||||
|
||||
// 当前订单下排单的板件数量
|
||||
Integer num = orderPlateNumAndAreaDO.getNum();
|
||||
|
||||
int version = orderDO.getVersion();
|
||||
LambdaUpdateWrapper<OrderDO> updateWrapper = new LambdaUpdateWrapper<OrderDO>()
|
||||
.eq(OrderDO::getId, orderId)
|
||||
.eq(OrderDO::getVersion, version)
|
||||
.set(OrderDO::getPlannedPlateArea, orderPlateNumAndAreaDO.getArea())
|
||||
.set(OrderDO::getPlannedPlateNum, num)
|
||||
.set(OrderDO::getVersion, version + 1);
|
||||
int update = orderMapper.update(updateWrapper);
|
||||
if (update == 0) {
|
||||
throw new ServiceException(com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_PLATE_UPDATE_CONCURRENCY_ERROR, orderId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 整理出需要删除的部件id列表
|
||||
*
|
||||
@@ -699,14 +756,10 @@ public class OrderComponentServiceImpl implements OrderComponentService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getChildComponentIdsOnMyParent(Long id) {
|
||||
public List<Long> getChildComponentIdsOnMy(Long id) {
|
||||
List<Long> result = new ArrayList<>();
|
||||
OrderComponentDO componentDO = orderComponentMapper.selectById(id);
|
||||
if (ObjectUtil.isNotNull(componentDO)) {
|
||||
OrderComponentDO parentComponentDO = orderComponentMapper.selectById(componentDO.getPid());
|
||||
if (ObjectUtil.isNull(parentComponentDO)) {
|
||||
return result;
|
||||
}
|
||||
// 查询顶级下所有部件
|
||||
List<OrderComponentDO> componentListOnTop = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
|
||||
.eq(OrderComponentDO::getTopId, componentDO.getTopId())
|
||||
@@ -714,7 +767,7 @@ public class OrderComponentServiceImpl implements OrderComponentService {
|
||||
.select(OrderComponentDO::getId, OrderComponentDO::getPid)
|
||||
);
|
||||
|
||||
return getChildrenIds(parentComponentDO, componentListOnTop).stream().toList();
|
||||
return getChildrenIds(componentDO, componentListOnTop).stream().toList();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+1
-1
@@ -585,7 +585,7 @@
|
||||
<foreach collection="orderGoodsIds" item="orderGoodsId" open="(" close=")" separator=",">
|
||||
#{orderGoodsId}
|
||||
</foreach>
|
||||
AND op.deleted = false
|
||||
AND op.deleted = #{delete}
|
||||
GROUP BY op.goods_id
|
||||
</select>
|
||||
|
||||
|
||||
+1
-1
@@ -640,7 +640,7 @@
|
||||
join order_plate op on o.organ_id = op.organ_id and o.id = op.order_id
|
||||
where o.id = #{orderId}
|
||||
and op.plan_id = 0
|
||||
and op.deleted = false
|
||||
and op.deleted = #{delete}
|
||||
and o.deleted = false
|
||||
</select>
|
||||
|
||||
|
||||
+11
-6
@@ -72,18 +72,23 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="selectPlateNumAndArea" resultType="com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyPlateNumAndAreaDO">
|
||||
<select id="selectPlateNumAndArea" resultType="com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyPlateNumDO">
|
||||
SELECT
|
||||
oi.body_id AS order_body_id,
|
||||
COUNT(*) AS num,
|
||||
IFNULL(SUM(op.area),0) AS area
|
||||
FROM order_item oi
|
||||
COUNT(*) AS num
|
||||
<choose>
|
||||
<when test="delete">
|
||||
FROM order_item_temp oi
|
||||
</when>
|
||||
<otherwise>
|
||||
FROM order_item oi
|
||||
</otherwise>
|
||||
</choose>
|
||||
JOIN order_plate op
|
||||
ON op.organ_id = oi.organ_id
|
||||
AND op.order_id = oi.order_id
|
||||
AND op.id = oi.plate_id
|
||||
AND op.plan_id != 0
|
||||
AND op.deleted = false
|
||||
AND op.deleted = #{delete}
|
||||
WHERE oi.body_id IN
|
||||
<foreach collection="orderBodyIds" item="orderBodyId" open="(" close=")" separator=",">
|
||||
#{orderBodyId}
|
||||
|
||||
+33
-33
@@ -95,7 +95,14 @@
|
||||
<select id="selectPartsByOrderId"
|
||||
resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPlatesDetailRespVO">
|
||||
SELECT DISTINCT i.order_id, i.room_id, i.body_id, i.parts_id, p.`name` as part_name, SUM(i.num) AS plate_num, p.unit
|
||||
FROM `order_item` i
|
||||
<choose>
|
||||
<when test="deleted != null and deleted == @com.cf.imes.framework.common.enums.DeletedCodeEnum@DELETED.getStatus()">
|
||||
FROM `order_item_temp` i
|
||||
</when>
|
||||
<otherwise>
|
||||
FROM `order_item` i
|
||||
</otherwise>
|
||||
</choose>
|
||||
RIGHT JOIN `order_parts` p ON i.organ_id = p.organ_id AND i.order_id = p.order_id AND i.parts_id = p.id
|
||||
RIGHT JOIN `order_body` ob ON i.organ_id = ob.organ_id AND i.order_id = ob.order_id AND i.body_id = ob.id
|
||||
WHERE i.organ_id = #{organId} AND i.order_id = #{orderId} AND ob.deleted = #{deleted} AND (i.group_id is null or i.group_id = 0) AND p.category in
|
||||
@@ -129,15 +136,15 @@
|
||||
|
||||
UPDATE order_item
|
||||
|
||||
SET package_id = 0
|
||||
SET package_id = 0, pack_num = 0, heap_num = 0, heap_split_status = ${@com.cf.imes.module.executor.enums.heapsplit.HeapSplitStatusEnum@NO.status}
|
||||
|
||||
WHERE organ_id = #{organId}
|
||||
and order_id = #{orderId}
|
||||
and package_id in
|
||||
<foreach item="packIds" collection="packIds" open="(" separator="," close=")">
|
||||
#{packIds}
|
||||
<foreach item="packId" collection="packIds" open="(" separator="," close=")">
|
||||
#{packId}
|
||||
</foreach>
|
||||
|
||||
and source_id = 0
|
||||
|
||||
</update>
|
||||
|
||||
@@ -259,33 +266,26 @@
|
||||
|
||||
|
||||
|
||||
<select id="selectOrderPlanList" resultType="java.lang.Long">
|
||||
|
||||
|
||||
|
||||
select distinct
|
||||
op.plan_id
|
||||
|
||||
<select id="selectExistOrderPlan" resultType="java.lang.Integer">
|
||||
select 1
|
||||
from order_item oi
|
||||
join order_plate op on oi.organ_id = op.organ_id and oi.order_id = op.order_id and oi.plate_id = op.id
|
||||
|
||||
<where> oi.organ_id = #{organId}
|
||||
and oi.order_id = #{orderId}
|
||||
<if test="bodyId !=null">
|
||||
and oi.body_id = #{bodyId}
|
||||
</if>
|
||||
|
||||
<if test="roomIds !=null">
|
||||
and oi.room_id in
|
||||
<foreach item="roomIds" collection="roomIds" open="(" separator="," close=")">
|
||||
#{roomIds}
|
||||
</foreach>
|
||||
</if>
|
||||
and op.plan_id != 0
|
||||
|
||||
</where>
|
||||
|
||||
|
||||
join order_plate op
|
||||
on oi.organ_id = op.organ_id
|
||||
and oi.order_id = op.order_id
|
||||
and oi.plate_id = op.id
|
||||
where oi.organ_id = #{organId}
|
||||
and oi.order_id = #{orderId}
|
||||
<if test="bodyId != null">
|
||||
and oi.body_id = #{bodyId}
|
||||
</if>
|
||||
<if test="roomIds != null and roomIds.size() > 0">
|
||||
and oi.room_id in
|
||||
<foreach item="roomId" collection="roomIds" open="(" separator="," close=")">
|
||||
#{roomId}
|
||||
</foreach>
|
||||
</if>
|
||||
and op.plan_id != 0
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
|
||||
@@ -794,7 +794,7 @@
|
||||
, MIN(comp_id) AS comp_id
|
||||
</if>
|
||||
FROM order_item
|
||||
WHERE order_id = #{orderId} and plate_id != 0
|
||||
WHERE order_id = #{orderId} and 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=")">
|
||||
@@ -842,7 +842,7 @@
|
||||
, MIN(comp_id) AS comp_id
|
||||
</if>
|
||||
FROM order_item
|
||||
WHERE order_id = #{orderId} and parts_id != 0
|
||||
WHERE order_id = #{orderId} and parts_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=")">
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemTempMapper">
|
||||
<insert id="selectInsertOrderItemTemp">
|
||||
INSERT INTO order_item_temp
|
||||
SELECT *
|
||||
FROM order_item
|
||||
WHERE order_id = #{orderId} and organ_id = #{organId}
|
||||
<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="compIds != null and compIds.size() > 0">
|
||||
AND comp_id IN
|
||||
<foreach item="compId" collection="compIds" open="(" separator="," close=")">
|
||||
#{compId}
|
||||
</foreach>
|
||||
</if>
|
||||
AND source_id = 0
|
||||
</insert>
|
||||
|
||||
<insert id="selectInsertOrderItem">
|
||||
INSERT INTO order_item
|
||||
SELECT *
|
||||
FROM order_item_temp
|
||||
WHERE order_id = #{orderId} and organ_id = #{organId}
|
||||
<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="compIds != null and compIds.size() > 0">
|
||||
AND comp_id IN
|
||||
<foreach item="compId" collection="compIds" open="(" separator="," close=")">
|
||||
#{compId}
|
||||
</foreach>
|
||||
</if>
|
||||
</insert>
|
||||
</mapper>
|
||||
+1
-1
@@ -205,7 +205,7 @@
|
||||
|
||||
|
||||
<select id="selectPartsIdListByBodyId" resultType="java.lang.Long">
|
||||
SELECT parts_id FROM order_item
|
||||
SELECT parts_id FROM order_item_temp
|
||||
WHERE body_id IN
|
||||
<foreach item="bodyId" collection="bodyIds" open="(" separator="," close=")">
|
||||
#{bodyId}
|
||||
|
||||
+4
-3
@@ -30,6 +30,7 @@
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and p.deleted = #{deleted}
|
||||
</select>
|
||||
|
||||
<select id="getComponentListOnTopLevel"
|
||||
@@ -63,15 +64,15 @@
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<update id="restoreOrderComponents">
|
||||
<update id="updateOrderComponentsDeletedStatus">
|
||||
update order_component
|
||||
set deleted = false
|
||||
set deleted = #{delete}
|
||||
where
|
||||
order_id = #{orderId}
|
||||
and id in
|
||||
<foreach item="componentId" collection="componentIds" open="(" close=")" separator=",">
|
||||
#{componentId}
|
||||
</foreach>
|
||||
and deleted = true
|
||||
and deleted != #{delete}
|
||||
</update>
|
||||
</mapper>
|
||||
+24
-19
@@ -188,25 +188,27 @@
|
||||
|
||||
<update id="updateDeletedPlate">
|
||||
UPDATE order_plate
|
||||
SET deleted = true,is_optimized = false
|
||||
WHERE organ_id = #{organId}
|
||||
SET deleted = true, is_optimized = false
|
||||
WHERE organ_id = #{organId}
|
||||
and order_id = #{orderId}
|
||||
and id IN
|
||||
<foreach item="plateId" collection="plateIds" open="(" separator="," close=")">
|
||||
#{plateId}
|
||||
</foreach>
|
||||
and deleted = false
|
||||
</update>
|
||||
|
||||
|
||||
<update id="updateNoDeletedPlate">
|
||||
UPDATE order_plate
|
||||
SET deleted = false,is_optimized = false
|
||||
WHERE organ_id = #{organId}
|
||||
SET deleted = false, is_optimized = false
|
||||
WHERE organ_id = #{organId}
|
||||
and order_id = #{orderId}
|
||||
and id IN
|
||||
<foreach item="plateId" collection="plateIds" open="(" separator="," close=")">
|
||||
#{plateId}
|
||||
</foreach>
|
||||
and deleted = true
|
||||
</update>
|
||||
|
||||
|
||||
@@ -301,8 +303,8 @@
|
||||
WHERE i.organ_id = #{organId}
|
||||
AND i.order_id = #{orderId}
|
||||
AND i.body_id IN
|
||||
<foreach item="roomIdItem" collection="bodyIds" open="(" separator="," close=")">
|
||||
#{roomIdItem}
|
||||
<foreach item="bodyId" collection="bodyIds" open="(" separator="," close=")">
|
||||
#{bodyId}
|
||||
</foreach>
|
||||
AND p.deleted = false
|
||||
|
||||
@@ -314,12 +316,12 @@
|
||||
|
||||
SELECT distinct p.*
|
||||
FROM order_plate p
|
||||
LEFT JOIN order_item i ON p.organ_id = i.organ_id and p.order_id = i.order_id and p.id = i.plate_id
|
||||
LEFT JOIN order_item_temp i ON p.organ_id = i.organ_id and p.order_id = i.order_id and p.id = i.plate_id
|
||||
WHERE i.organ_id = #{organId}
|
||||
AND i.order_id = #{orderId}
|
||||
AND i.body_id IN
|
||||
<foreach item="roomIdItem" collection="bodyIds" open="(" separator="," close=")">
|
||||
#{roomIdItem}
|
||||
<foreach item="bodyId" collection="bodyIds" open="(" separator="," close=")">
|
||||
#{bodyId}
|
||||
</foreach>
|
||||
AND p.deleted = true
|
||||
|
||||
@@ -1156,23 +1158,26 @@
|
||||
</update>
|
||||
|
||||
<select id="selectOrderComponentGoodsIds" resultType="java.lang.Long">
|
||||
SELECT op.goods_id
|
||||
SELECT DISTINCT op.goods_id
|
||||
FROM order_plate op
|
||||
WHERE op.order_id = #{orderId}
|
||||
AND op.deleted = #{deleted}
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM order_item oi
|
||||
WHERE oi.plate_id = op.id
|
||||
<choose>
|
||||
<when test="deleted">
|
||||
JOIN order_item_temp oi
|
||||
</when>
|
||||
<otherwise>
|
||||
JOIN order_item oi
|
||||
</otherwise>
|
||||
</choose>
|
||||
ON oi.plate_id = op.id
|
||||
AND oi.organ_id = op.organ_id
|
||||
AND oi.order_id = op.order_id
|
||||
AND oi.plate_id != 0
|
||||
WHERE op.order_id = #{orderId}
|
||||
AND op.deleted = #{deleted}
|
||||
AND oi.comp_id IN
|
||||
<foreach item="componentId" collection="componentIds" open="(" separator="," close=")">
|
||||
#{componentId}
|
||||
</foreach>
|
||||
AND oi.plate_id != 0
|
||||
)
|
||||
GROUP BY op.goods_id
|
||||
</select>
|
||||
|
||||
<select id="selectOrderComponentBodyIds" resultType="java.lang.Long">
|
||||
|
||||
Reference in New Issue
Block a user