mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
创建排单批量操作优化
This commit is contained in:
+10
@@ -16,6 +16,16 @@ import java.math.BigDecimal;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class OrderPlanPlateNumAndAreaRespVO {
|
public class OrderPlanPlateNumAndAreaRespVO {
|
||||||
|
/**
|
||||||
|
* 排单ID
|
||||||
|
*/
|
||||||
|
private Long planId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单ID
|
||||||
|
*/
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 已排板件数量
|
* 已排板件数量
|
||||||
*/
|
*/
|
||||||
|
|||||||
+8
@@ -208,6 +208,14 @@ public interface GoodsMapper extends BaseMapperX<GoodsDO> {
|
|||||||
*/
|
*/
|
||||||
OrderPlanPlateNumAndAreaRespVO selectPlannedPlateNumAndArea(@Param("orderGoodsId") Long orderGoodsId);
|
OrderPlanPlateNumAndAreaRespVO selectPlannedPlateNumAndArea(@Param("orderGoodsId") Long orderGoodsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量统计已排单板件数量和面积
|
||||||
|
*
|
||||||
|
* @param orderGoodsIds 商品id列表
|
||||||
|
* @return 每个商品的已排板件数量和面积
|
||||||
|
*/
|
||||||
|
List<OrderGoodsPlateNumAndAreaDO> selectPlannedPlateNumAndAreaGroup(@Param("orderGoodsIds") Collection<Long> orderGoodsIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单材质下的板件数量和面积
|
* 查询订单材质下的板件数量和面积
|
||||||
*
|
*
|
||||||
|
|||||||
+8
@@ -398,6 +398,14 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
|||||||
*/
|
*/
|
||||||
OrderPlanPlateNumAndAreaRespVO selectPlannedPlateNumAndArea(@Param("orderId") Long orderId);
|
OrderPlanPlateNumAndAreaRespVO selectPlannedPlateNumAndArea(@Param("orderId") Long orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量统计已排单板件数量和面积
|
||||||
|
*
|
||||||
|
* @param orderIds 订单id列表
|
||||||
|
* @return 每个订单的已排板件数量和面积
|
||||||
|
*/
|
||||||
|
List<OrderPlanPlateNumAndAreaRespVO> selectPlannedPlateNumAndAreaGroup(@Param("orderIds") Collection<Long> orderIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单下板件数量和面积
|
* 查询订单下板件数量和面积
|
||||||
*
|
*
|
||||||
|
|||||||
+7
@@ -114,4 +114,11 @@ public interface PlanItemMapper extends BaseMapperX<PlanItemDO> {
|
|||||||
*/
|
*/
|
||||||
OrderPlanPlateNumAndAreaRespVO selectPlanPlateNumAndArea(@Param("planId") Long planId);
|
OrderPlanPlateNumAndAreaRespVO selectPlanPlateNumAndArea(@Param("planId") Long planId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量统计排单板件数量和面积
|
||||||
|
*
|
||||||
|
* @param planIds 排单id列表
|
||||||
|
* @return 每个排单的板件数量和面积
|
||||||
|
*/
|
||||||
|
List<OrderPlanPlateNumAndAreaRespVO> selectPlanPlateNumAndAreaGroup(@Param("planIds") List<Long> planIds);
|
||||||
}
|
}
|
||||||
+102
-91
@@ -32,6 +32,7 @@ import com.cf.imes.module.executor.controller.admin.plate.vo.OrderPlateIds;
|
|||||||
import com.cf.imes.module.executor.controller.admin.plate.vo.OrderViewPlatePageRespVO;
|
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.GoodsDO;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.goods.OptimizeBoardModelDO;
|
import com.cf.imes.module.executor.dal.dataobject.goods.OptimizeBoardModelDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.goods.OrderGoodsPlateNumAndAreaDO;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.goods.PlanActualGoodsModelDO;
|
import com.cf.imes.module.executor.dal.dataobject.goods.PlanActualGoodsModelDO;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
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.orderBody.OrderBodyDO;
|
||||||
@@ -191,16 +192,19 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
}
|
}
|
||||||
// 计算排单的数量和面积
|
// 计算排单的数量和面积
|
||||||
if (CollUtil.isNotEmpty(planDOS)) {
|
if (CollUtil.isNotEmpty(planDOS)) {
|
||||||
|
List<Long> planIdList = planDOS.stream().map(PlanDO::getId).toList();
|
||||||
|
Map<Long, OrderPlanPlateNumAndAreaRespVO> planPlateNumAndAreaMap = planItemMapper.selectPlanPlateNumAndAreaGroup(planIdList)
|
||||||
|
.stream().collect(Collectors.toMap(OrderPlanPlateNumAndAreaRespVO::getPlanId, Function.identity()));
|
||||||
for (PlanDO planDO : planDOS) {
|
for (PlanDO planDO : planDOS) {
|
||||||
OrderPlanPlateNumAndAreaRespVO orderPlanPlateNumAndAreaRespVO = planItemMapper.selectPlanPlateNumAndArea(planDO.getId());
|
OrderPlanPlateNumAndAreaRespVO vo = planPlateNumAndAreaMap.get(planDO.getId());
|
||||||
if (ObjectUtil.isNotNull(orderPlanPlateNumAndAreaRespVO)) {
|
if (vo != null) {
|
||||||
planDO.setPlateNum(orderPlanPlateNumAndAreaRespVO.getNum());
|
planDO.setPlateNum(vo.getNum());
|
||||||
planDO.setPlateArea(orderPlanPlateNumAndAreaRespVO.getArea());
|
planDO.setPlateArea(vo.getArea());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 增加排单
|
||||||
|
planMapper.insertBatch(planDOS);
|
||||||
}
|
}
|
||||||
// 增加排单
|
|
||||||
planMapper.insertBatch(planDOS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1649,6 +1653,7 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
LoginUser loginUser) {
|
LoginUser loginUser) {
|
||||||
|
|
||||||
Set<Long> orderIdSet = new HashSet<>();
|
Set<Long> orderIdSet = new HashSet<>();
|
||||||
|
Set<Long> allGoodsIds = new HashSet<>();
|
||||||
|
|
||||||
long sort = System.currentTimeMillis();
|
long sort = System.currentTimeMillis();
|
||||||
|
|
||||||
@@ -1657,30 +1662,32 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
// 查找和大板分类ID相同的小板的数据
|
// 查找和大板分类ID相同的小板的数据
|
||||||
List<SavePlanPlateList.PlateItemList> plateList = plateItemList.stream().filter(p -> f.getIds().contains(p.getId())).toList();
|
List<SavePlanPlateList.PlateItemList> plateList = plateItemList.stream().filter(p -> f.getIds().contains(p.getId())).toList();
|
||||||
|
|
||||||
// 累计排单板件数量
|
// 排单ID
|
||||||
Integer planPlateNum = plateList.size();
|
Long planId = (Long) identifierGenerator.nextId(null);
|
||||||
|
|
||||||
Set<Long> planOrderIdSet = new HashSet<>();
|
// 更新小板排单id
|
||||||
Map<Long, List<Long>> goodsPlateIdMap = new HashMap<>();
|
List<Long> plateIds = plateList.stream().map(SavePlanPlateList.PlateItemList::getPlateId).toList();
|
||||||
for (SavePlanPlateList.PlateItemList savePlanPlate : plateList) {
|
if (CollUtil.isNotEmpty(plateIds)) {
|
||||||
Long orderId = savePlanPlate.getOrderId();
|
List<List<Long>> batchPlateIdList = batchProcess(plateIds);
|
||||||
// 累计排单下的订单号
|
for (List<Long> batchIds : batchPlateIdList) {
|
||||||
planOrderIdSet.add(orderId);
|
int updatePlateNum = plateMapper.update(new LambdaUpdateWrapper<PlateDO>()
|
||||||
// 累计发生改变的订单号
|
.in(PlateDO::getId, batchIds)
|
||||||
orderIdSet.add(orderId);
|
.eq(PlateDO::getPlanId, 0)
|
||||||
|
.set(PlateDO::getPlanId, planId));
|
||||||
// 累计商品id下的订单号
|
if (updatePlateNum != batchIds.size()) {
|
||||||
List<Long> goodsPlateIdList = goodsPlateIdMap.get(savePlanPlate.getId());
|
throw new ServiceException(CREAT_PLAN_PLATE_PART_PLANNED);
|
||||||
if (CollUtil.isEmpty(goodsPlateIdList)) {
|
}
|
||||||
goodsPlateIdList = new ArrayList<>();
|
|
||||||
goodsPlateIdList.add(savePlanPlate.getPlateId());
|
|
||||||
goodsPlateIdMap.put(savePlanPlate.getId(), goodsPlateIdList);
|
|
||||||
} else {
|
|
||||||
goodsPlateIdList.add(savePlanPlate.getPlateId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Long planId = (Long) identifierGenerator.nextId(null);
|
// 累计排单下的订单号 & 累计发生改变的订单号
|
||||||
|
Set<Long> planOrderIdSet = plateList.stream()
|
||||||
|
.map(SavePlanPlateList.PlateItemList::getOrderId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
orderIdSet.addAll(planOrderIdSet);
|
||||||
|
|
||||||
|
// 累计涉及的商品id
|
||||||
|
allGoodsIds.addAll(plateList.stream().map(SavePlanPlateList.PlateItemList::getId).toList());
|
||||||
|
|
||||||
// 大板商品id
|
// 大板商品id
|
||||||
String goodsId = f.getPlanActualGoodsModelDO().getGoodsId();
|
String goodsId = f.getPlanActualGoodsModelDO().getGoodsId();
|
||||||
@@ -1698,14 +1705,13 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
.operator(loginUser.getNickname())
|
.operator(loginUser.getNickname())
|
||||||
.planTime(LocalDateTime.now())
|
.planTime(LocalDateTime.now())
|
||||||
.goodsId(goodsId)
|
.goodsId(goodsId)
|
||||||
.plateNum(planPlateNum)
|
.plateNum(plateList.size())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 更新板件排单id & 统计更新order_goods的数量和面积
|
|
||||||
computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap);
|
|
||||||
planDOS.add(planDO);
|
planDOS.add(planDO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// 统计更新order_goods的数量和面积
|
||||||
|
computePlatePlanAndComputeOrderGoodsInfo(allGoodsIds);
|
||||||
// 统计更新orders的小板数量和面积
|
// 统计更新orders的小板数量和面积
|
||||||
computeOrderInfo(orderIdSet);
|
computeOrderInfo(orderIdSet);
|
||||||
}
|
}
|
||||||
@@ -1724,6 +1730,7 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
long sort = System.currentTimeMillis();
|
long sort = System.currentTimeMillis();
|
||||||
|
|
||||||
Set<Long> orderIdSet = new HashSet<>();
|
Set<Long> orderIdSet = new HashSet<>();
|
||||||
|
Set<Long> allGoodsIds = new HashSet<>();
|
||||||
|
|
||||||
// 进行数据处理:value 里为 大板的分类ID
|
// 进行数据处理:value 里为 大板的分类ID
|
||||||
for (Map.Entry<String, List<Long>> entry : grouped.entrySet()) {
|
for (Map.Entry<String, List<Long>> entry : grouped.entrySet()) {
|
||||||
@@ -1732,30 +1739,32 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
// 查找和大板分类ID相同的小板的数据
|
// 查找和大板分类ID相同的小板的数据
|
||||||
List<SavePlanPlateList.PlateItemList> plateList = plateItemList.stream().filter(p -> value.contains(p.getId())).toList();
|
List<SavePlanPlateList.PlateItemList> plateList = plateItemList.stream().filter(p -> value.contains(p.getId())).toList();
|
||||||
|
|
||||||
// 累计排单板件数
|
// 排单ID
|
||||||
Integer planPlateNum = plateList.size();
|
Long planId = (Long) identifierGenerator.nextId(null);
|
||||||
|
|
||||||
Set<Long> planOrderIdSet = new HashSet<>();
|
// 直接小板排单id
|
||||||
Map<Long, List<Long>> goodsPlateIdMap = new HashMap<>();
|
List<Long> plateIds = plateList.stream().map(SavePlanPlateList.PlateItemList::getPlateId).toList();
|
||||||
for (SavePlanPlateList.PlateItemList savePlanPlate : plateList) {
|
if (CollUtil.isNotEmpty(plateIds)) {
|
||||||
Long orderId = savePlanPlate.getOrderId();
|
List<List<Long>> batchPlateIdList = batchProcess(plateIds);
|
||||||
// 累计排单下的订单号
|
for (List<Long> batchIds : batchPlateIdList) {
|
||||||
planOrderIdSet.add(orderId);
|
int updatePlateNum = plateMapper.update(new LambdaUpdateWrapper<PlateDO>()
|
||||||
// 累计发生改变的订单号
|
.in(PlateDO::getId, batchIds)
|
||||||
orderIdSet.add(orderId);
|
.eq(PlateDO::getPlanId, 0)
|
||||||
|
.set(PlateDO::getPlanId, planId));
|
||||||
// 累计商品id下的订单号
|
if (updatePlateNum != batchIds.size()) {
|
||||||
List<Long> goodsPlateIdList = goodsPlateIdMap.get(savePlanPlate.getId());
|
throw new ServiceException(CREAT_PLAN_PLATE_PART_PLANNED);
|
||||||
if(CollUtil.isEmpty(goodsPlateIdList)) {
|
}
|
||||||
goodsPlateIdList = new ArrayList<>();
|
|
||||||
goodsPlateIdList.add(savePlanPlate.getPlateId());
|
|
||||||
goodsPlateIdMap.put(savePlanPlate.getId(), goodsPlateIdList);
|
|
||||||
} else {
|
|
||||||
goodsPlateIdList.add(savePlanPlate.getPlateId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Long planId = (Long) identifierGenerator.nextId(null);
|
// 累计排单下的订单号 & 累计发生改变的订单号
|
||||||
|
Set<Long> planOrderIdSet = plateList.stream()
|
||||||
|
.map(SavePlanPlateList.PlateItemList::getOrderId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
orderIdSet.addAll(planOrderIdSet);
|
||||||
|
|
||||||
|
// 累计涉及的商品id
|
||||||
|
allGoodsIds.addAll(plateList.stream().map(SavePlanPlateList.PlateItemList::getId).toList());
|
||||||
|
|
||||||
// 创建排单
|
// 创建排单
|
||||||
PlanDO planDO = PlanDO.builder()
|
PlanDO planDO = PlanDO.builder()
|
||||||
@@ -1769,53 +1778,41 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
.status(PlanStatusEnum.NOCUTTING.getStatus())
|
.status(PlanStatusEnum.NOCUTTING.getStatus())
|
||||||
.operator(loginUser.getNickname())
|
.operator(loginUser.getNickname())
|
||||||
.planTime(LocalDateTime.now())
|
.planTime(LocalDateTime.now())
|
||||||
.plateNum(planPlateNum)
|
.plateNum(plateList.size())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 更新板件排单id & 统计更新order_goods的数量和面积
|
|
||||||
computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap);
|
|
||||||
planDOS.add(planDO);
|
planDOS.add(planDO);
|
||||||
}
|
}
|
||||||
|
// 统计更新order_goods的数量和面积
|
||||||
|
computePlatePlanAndComputeOrderGoodsInfo(allGoodsIds);
|
||||||
// 统计更新orders的小板数量和面积
|
// 统计更新orders的小板数量和面积
|
||||||
computeOrderInfo(orderIdSet);
|
computeOrderInfo(orderIdSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新板件排单id & 统计更新order_goods的小板数量和面积
|
* 统计更新order_goods的小板数量和面积
|
||||||
*
|
*
|
||||||
* @param planId
|
* @param allGoodsIds
|
||||||
* @param goodsPlateIdMap
|
|
||||||
*/
|
*/
|
||||||
public void computePlatePlanAndComputeOrderGoodsInfo(Long planId, Map<Long, List<Long>> goodsPlateIdMap) {
|
public void computePlatePlanAndComputeOrderGoodsInfo(Set<Long> allGoodsIds) {
|
||||||
for (Map.Entry<Long, List<Long>> entry : goodsPlateIdMap.entrySet()) {
|
if (CollUtil.isNotEmpty(allGoodsIds)) {
|
||||||
Long orderGoodsId = entry.getKey();
|
List<GoodsDO> goodsDOList = goodsMapper.selectByIds(new ArrayList<>(allGoodsIds));
|
||||||
// 查询version
|
Map<Long, OrderGoodsPlateNumAndAreaDO> statsMap = goodsMapper.selectPlannedPlateNumAndAreaGroup(allGoodsIds)
|
||||||
GoodsDO goodsDO = goodsMapper.selectById(orderGoodsId);
|
.stream().collect(Collectors.toMap(OrderGoodsPlateNumAndAreaDO::getOrderGoodsId, Function.identity()));
|
||||||
List<Long> groupedPlateIdList = entry.getValue();
|
for (GoodsDO goodsDO : goodsDOList) {
|
||||||
// 排单id更新到小板信息中
|
OrderGoodsPlateNumAndAreaDO stats = statsMap.getOrDefault(goodsDO.getId(),
|
||||||
List<List<Long>> batchPlanPlateIdList = batchProcess(groupedPlateIdList);
|
OrderGoodsPlateNumAndAreaDO.builder().num(0).area(BigDecimal.ZERO).build());
|
||||||
for (List<Long> plateIdList : batchPlanPlateIdList) {
|
int version = goodsDO.getVersion();
|
||||||
int updatePlateNum = plateMapper.update(new LambdaUpdateWrapper<PlateDO>()
|
int update = goodsMapper.update(new LambdaUpdateWrapper<GoodsDO>()
|
||||||
.in(PlateDO::getId, plateIdList)
|
.eq(GoodsDO::getId, goodsDO.getId())
|
||||||
.eq(PlateDO::getPlanId, 0)
|
.eq(GoodsDO::getVersion, version)
|
||||||
.set(PlateDO::getPlanId, planId));
|
.set(GoodsDO::getPlannedPlateArea, stats.getArea())
|
||||||
if (updatePlateNum != plateIdList.size()) {
|
.set(GoodsDO::getPlannedPlateNum, stats.getNum())
|
||||||
throw new ServiceException(CREAT_PLAN_PLATE_PART_PLANNED);
|
.set(GoodsDO::getVersion, version + 1));
|
||||||
|
if (update == 0) {
|
||||||
|
throw new ServiceException(ErrorCodeConstants.CREATE_PLAN_GOODS_UPDATE_CONCURRENCY_ERROR, goodsDO.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int version = goodsDO.getVersion();
|
|
||||||
// 统计每个order_goods下的未排单面积,更新到order_goods中
|
|
||||||
OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId);
|
|
||||||
int update = goodsMapper.update(new LambdaUpdateWrapper<GoodsDO>()
|
|
||||||
.eq(GoodsDO::getId, orderGoodsId)
|
|
||||||
.eq(GoodsDO::getVersion, version)
|
|
||||||
.set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfo.getArea())
|
|
||||||
.set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfo.getNum())
|
|
||||||
.set(GoodsDO::getVersion, version + 1));
|
|
||||||
if (update == 0) {
|
|
||||||
throw new ServiceException(ErrorCodeConstants.CREATE_PLAN_GOODS_UPDATE_CONCURRENCY_ERROR, orderGoodsId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1825,21 +1822,34 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
* @param orderIdSet
|
* @param orderIdSet
|
||||||
*/
|
*/
|
||||||
public void computeOrderInfo(Set<Long> orderIdSet) {
|
public void computeOrderInfo(Set<Long> orderIdSet) {
|
||||||
|
if (CollUtil.isEmpty(orderIdSet)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量查询订单信息(获取version和status)
|
||||||
|
Map<Long, OrderDO> orderMap = orderMapper.selectByIds(new ArrayList<>(orderIdSet)).stream()
|
||||||
|
.collect(Collectors.toMap(OrderDO::getId, Function.identity()));
|
||||||
|
|
||||||
|
// 批量统计已排板件数量和面积
|
||||||
|
Map<Long, OrderPlanPlateNumAndAreaRespVO> statsMap = orderMapper.selectPlannedPlateNumAndAreaGroup(orderIdSet).stream()
|
||||||
|
.collect(Collectors.toMap(OrderPlanPlateNumAndAreaRespVO::getOrderId, Function.identity()));
|
||||||
|
|
||||||
|
// 循环更新每个订单(需要version乐观锁校验 + 条件状态更新)
|
||||||
for (Long orderId : orderIdSet) {
|
for (Long orderId : orderIdSet) {
|
||||||
// 统计每个orders下的未排单面积,更新到orders中
|
OrderDO orderDO = orderMap.get(orderId);
|
||||||
OrderDO orderDO = orderMapper.selectById(orderId);
|
OrderPlanPlateNumAndAreaRespVO stats = statsMap.getOrDefault(orderId,
|
||||||
OrderPlanPlateNumAndAreaRespVO orderPlateNumAndAreaPlanInfo = orderMapper.selectPlannedPlateNumAndArea(orderId);
|
OrderPlanPlateNumAndAreaRespVO.builder().num(0).area(BigDecimal.ZERO).build());
|
||||||
|
|
||||||
// 当前订单下排单的板件数量
|
|
||||||
Integer num = orderPlateNumAndAreaPlanInfo.getNum();
|
|
||||||
|
|
||||||
|
Integer num = stats.getNum();
|
||||||
int version = orderDO.getVersion();
|
int version = orderDO.getVersion();
|
||||||
|
|
||||||
LambdaUpdateWrapper<OrderDO> updateWrapper = new LambdaUpdateWrapper<OrderDO>()
|
LambdaUpdateWrapper<OrderDO> updateWrapper = new LambdaUpdateWrapper<OrderDO>()
|
||||||
.eq(OrderDO::getId, orderId)
|
.eq(OrderDO::getId, orderId)
|
||||||
.eq(OrderDO::getVersion, version)
|
.eq(OrderDO::getVersion, version)
|
||||||
.set(OrderDO::getPlannedPlateArea, orderPlateNumAndAreaPlanInfo.getArea())
|
.set(OrderDO::getPlannedPlateArea, stats.getArea())
|
||||||
.set(OrderDO::getPlannedPlateNum, num)
|
.set(OrderDO::getPlannedPlateNum, num)
|
||||||
.set(OrderDO::getVersion, version + 1);
|
.set(OrderDO::getVersion, version + 1);
|
||||||
|
|
||||||
Integer orderDOStatus = orderDO.getStatus();
|
Integer orderDOStatus = orderDO.getStatus();
|
||||||
// 更新订单排单状态
|
// 更新订单排单状态
|
||||||
if (ObjectUtil.equals(orderDOStatus, OrderStatusEnum.NEW_ORDER.getStatus())) {
|
if (ObjectUtil.equals(orderDOStatus, OrderStatusEnum.NEW_ORDER.getStatus())) {
|
||||||
@@ -1854,6 +1864,7 @@ public class PlanServiceImpl implements PlanService {
|
|||||||
updateWrapper.set(OrderDO::getStatus, OrderStatusEnum.NEW_ORDER.getStatus());
|
updateWrapper.set(OrderDO::getStatus, OrderStatusEnum.NEW_ORDER.getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int update = orderMapper.update(updateWrapper);
|
int update = orderMapper.update(updateWrapper);
|
||||||
if (update == 0) {
|
if (update == 0) {
|
||||||
throw new ServiceException(ErrorCodeConstants.CREATE_PLAN_ORDER_UPDATE_CONCURRENCY_ERROR, orderId);
|
throw new ServiceException(ErrorCodeConstants.CREATE_PLAN_ORDER_UPDATE_CONCURRENCY_ERROR, orderId);
|
||||||
|
|||||||
+2
-2
@@ -646,12 +646,12 @@ public class PlateServiceImpl implements PlateService {
|
|||||||
.build());
|
.build());
|
||||||
|
|
||||||
// 累加订单板数和面积
|
// 累加订单板数和面积
|
||||||
orderPlanPlateNumAndAreaRespVOMap.putIfAbsent(orderId, new OrderPlanPlateNumAndAreaRespVO(0, BigDecimal.ZERO));
|
orderPlanPlateNumAndAreaRespVOMap.putIfAbsent(orderId, new OrderPlanPlateNumAndAreaRespVO().setNum(0).setArea(BigDecimal.ZERO));
|
||||||
OrderPlanPlateNumAndAreaRespVO orderPlanPlateNumAndAreaRespVO = orderPlanPlateNumAndAreaRespVOMap.get(orderId);
|
OrderPlanPlateNumAndAreaRespVO orderPlanPlateNumAndAreaRespVO = orderPlanPlateNumAndAreaRespVOMap.get(orderId);
|
||||||
orderPlanPlateNumAndAreaRespVO.setArea(orderPlanPlateNumAndAreaRespVO.getArea().add(area)).setNum(orderPlanPlateNumAndAreaRespVO.getNum() + 1);
|
orderPlanPlateNumAndAreaRespVO.setArea(orderPlanPlateNumAndAreaRespVO.getArea().add(area)).setNum(orderPlanPlateNumAndAreaRespVO.getNum() + 1);
|
||||||
|
|
||||||
// 累加订单材质板数和面积
|
// 累加订单材质板数和面积
|
||||||
orderGoodsPlanPlateNumAndAreaRespVOMap.putIfAbsent(orderId, new OrderPlanPlateNumAndAreaRespVO(0, BigDecimal.ZERO));
|
orderGoodsPlanPlateNumAndAreaRespVOMap.putIfAbsent(orderId, new OrderPlanPlateNumAndAreaRespVO().setNum(0).setArea(BigDecimal.ZERO));
|
||||||
OrderPlanPlateNumAndAreaRespVO orderGoodsPlanPlateNumAndAreaRespVO = orderGoodsPlanPlateNumAndAreaRespVOMap.get(orderId);
|
OrderPlanPlateNumAndAreaRespVO orderGoodsPlanPlateNumAndAreaRespVO = orderGoodsPlanPlateNumAndAreaRespVOMap.get(orderId);
|
||||||
orderGoodsPlanPlateNumAndAreaRespVO.setArea(orderGoodsPlanPlateNumAndAreaRespVO.getArea().add(area)).setNum(orderGoodsPlanPlateNumAndAreaRespVO.getNum() + 1);
|
orderGoodsPlanPlateNumAndAreaRespVO.setArea(orderGoodsPlanPlateNumAndAreaRespVO.getArea().add(area)).setNum(orderGoodsPlanPlateNumAndAreaRespVO.getNum() + 1);
|
||||||
});
|
});
|
||||||
|
|||||||
+14
@@ -575,6 +575,20 @@
|
|||||||
and og.deleted = false
|
and og.deleted = false
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectPlannedPlateNumAndAreaGroup" resultType="com.cf.imes.module.executor.dal.dataobject.goods.OrderGoodsPlateNumAndAreaDO">
|
||||||
|
select op.goods_id as orderGoodsId, count(op.id) as num, IFNULL(sum(op.area), 0) as area
|
||||||
|
from order_goods og
|
||||||
|
join order_plate op on og.organ_id = op.organ_id and og.order_id = op.order_id and og.id = op.goods_id
|
||||||
|
where og.id in
|
||||||
|
<foreach collection="orderGoodsIds" item="orderGoodsId" open="(" separator="," close=")">
|
||||||
|
#{orderGoodsId}
|
||||||
|
</foreach>
|
||||||
|
and op.plan_id != 0
|
||||||
|
and op.deleted = false
|
||||||
|
and og.deleted = false
|
||||||
|
group by op.goods_id
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectPlateNumAndArea" resultType="com.cf.imes.module.executor.dal.dataobject.goods.OrderGoodsPlateNumAndAreaDO">
|
<select id="selectPlateNumAndArea" resultType="com.cf.imes.module.executor.dal.dataobject.goods.OrderGoodsPlateNumAndAreaDO">
|
||||||
SELECT
|
SELECT
|
||||||
op.goods_id as order_goods_id,
|
op.goods_id as order_goods_id,
|
||||||
|
|||||||
+14
@@ -1000,6 +1000,20 @@
|
|||||||
and o.deleted = false
|
and o.deleted = false
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectPlannedPlateNumAndAreaGroup" resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPlanPlateNumAndAreaRespVO">
|
||||||
|
select o.id as orderId, count(op.id) as num, IFNULL(sum(op.area), 0) as area
|
||||||
|
from orders o
|
||||||
|
join order_plate op on o.organ_id = op.organ_id and o.id = op.order_id
|
||||||
|
where o.id in
|
||||||
|
<foreach collection="orderIds" item="orderId" open="(" separator="," close=")">
|
||||||
|
#{orderId}
|
||||||
|
</foreach>
|
||||||
|
and op.plan_id != 0
|
||||||
|
and op.deleted = false
|
||||||
|
and o.deleted = false
|
||||||
|
group by o.id
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectPlateNumAndArea" resultType="com.cf.imes.module.executor.dal.dataobject.order.OrderPlateNumAndAreaDO">
|
<select id="selectPlateNumAndArea" resultType="com.cf.imes.module.executor.dal.dataobject.order.OrderPlateNumAndAreaDO">
|
||||||
select count(op.id) as num, IFNULL(sum(op.area), 0) as area
|
select count(op.id) as num, IFNULL(sum(op.area), 0) as area
|
||||||
from orders o
|
from orders o
|
||||||
|
|||||||
+11
@@ -604,4 +604,15 @@
|
|||||||
and op.deleted = false
|
and op.deleted = false
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectPlanPlateNumAndAreaGroup" resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPlanPlateNumAndAreaRespVO">
|
||||||
|
select op.plan_id as planId, count(op.id) as num, IFNULL(sum(op.area), 0) as area
|
||||||
|
from order_plate op
|
||||||
|
where op.plan_id in
|
||||||
|
<foreach collection="planIds" item="planId" open="(" separator="," close=")">
|
||||||
|
#{planId}
|
||||||
|
</foreach>
|
||||||
|
and op.deleted = false
|
||||||
|
group by op.plan_id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user