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、创建排单、新增/删除小板修改排单板件数和面积同步;
This commit is contained in:
+3
@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@@ -95,6 +96,8 @@ public class PlanRespVO {
|
||||
@Schema(description = "总小板片数")
|
||||
private Long plateNum;
|
||||
|
||||
@Schema(description = "总小板面积")
|
||||
private BigDecimal area;
|
||||
|
||||
@Schema(description = "未优化小板片数")
|
||||
private Long unOptimizePlateCount;
|
||||
|
||||
+6
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@@ -122,6 +123,11 @@ public class PlanDO extends BaseDO {
|
||||
*/
|
||||
private Integer plateNum;
|
||||
|
||||
/**
|
||||
* 板件面积
|
||||
*/
|
||||
private BigDecimal area;
|
||||
|
||||
/**
|
||||
* 已排大板数
|
||||
*/
|
||||
|
||||
+47
-12
@@ -1394,6 +1394,8 @@ public class PlanServiceImpl implements PlanService {
|
||||
for (Map.Entry<Long, List<OrderPlateIds>> entry : groupedPlates.entrySet()) {
|
||||
Long orderGoodsId = entry.getKey();
|
||||
List<OrderPlateIds> plates = entry.getValue();
|
||||
Integer plateNum = 0;
|
||||
BigDecimal area = BigDecimal.ZERO;
|
||||
|
||||
// 查询version
|
||||
GoodsDO goodsDO = goodsMapper.selectById(orderGoodsId);
|
||||
@@ -1412,15 +1414,27 @@ public class PlanServiceImpl implements PlanService {
|
||||
int version = goodsDO.getVersion();
|
||||
// 统计每个order_goods下的未排单面积,更新到order_goods中
|
||||
OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId);
|
||||
BigDecimal goodsPlateNumAndAreaPlanInfoArea = goodsPlateNumAndAreaPlanInfo.getArea();
|
||||
Integer goodsPlateNumAndAreaPlanInfoNum = goodsPlateNumAndAreaPlanInfo.getNum();
|
||||
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::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfoArea)
|
||||
.set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfoNum)
|
||||
.set(GoodsDO::getVersion, version + 1));
|
||||
if (update == 0) {
|
||||
throw new ServiceException(ErrorCodeConstants.GOODS_PLATE_UPDATE_CONCURRENCY_ERROR, orderGoodsId);
|
||||
}
|
||||
// 累计板件数量和面积
|
||||
plateNum += goodsPlateNumAndAreaPlanInfoNum;
|
||||
area = area.add(goodsPlateNumAndAreaPlanInfoArea);
|
||||
}
|
||||
if (plateNum != 0) {
|
||||
// 更新排单板件数量和面积
|
||||
planMapper.update(new LambdaUpdateWrapper<PlanDO>()
|
||||
.eq(PlanDO::getId, planId)
|
||||
.set(PlanDO::getPlateNum, plateNum)
|
||||
.set(PlanDO::getArea, area));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1440,6 +1454,8 @@ public class PlanServiceImpl implements PlanService {
|
||||
for (Map.Entry<Long, List<PlateDO>> entry : groupedPlates.entrySet()) {
|
||||
Long planId = entry.getKey();
|
||||
List<PlateDO> plates = entry.getValue();
|
||||
Integer plateNum = 0;
|
||||
BigDecimal area = BigDecimal.ZERO;
|
||||
|
||||
// 根据goodsId分组
|
||||
Map<Long, List<PlateDO>> groupedPlatesByGoodsId = plates.stream().collect(Collectors.groupingBy(PlateDO::getGoodsId));
|
||||
@@ -1466,16 +1482,29 @@ public class PlanServiceImpl implements PlanService {
|
||||
int version = goodsDO.getVersion();
|
||||
// 统计每个order_goods下的未排单面积,更新到order_goods中
|
||||
OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId);
|
||||
BigDecimal goodsPlateNumAndAreaPlanInfoArea = goodsPlateNumAndAreaPlanInfo.getArea();
|
||||
Integer goodsPlateNumAndAreaPlanInfoNum = goodsPlateNumAndAreaPlanInfo.getNum();
|
||||
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::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfoArea)
|
||||
.set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfoNum)
|
||||
.set(GoodsDO::getVersion, version + 1));
|
||||
if (update == 0) {
|
||||
throw new ServiceException(ErrorCodeConstants.GOODS_PLATE_UPDATE_CONCURRENCY_ERROR, orderGoodsId);
|
||||
}
|
||||
// 累计板件数量和面积
|
||||
plateNum += goodsPlateNumAndAreaPlanInfoNum;
|
||||
area = area.add(goodsPlateNumAndAreaPlanInfoArea);
|
||||
}
|
||||
if (plateNum != 0) {
|
||||
// 更新排单板件数量和面积
|
||||
planMapper.update(new LambdaUpdateWrapper<PlanDO>()
|
||||
.eq(PlanDO::getId, planId)
|
||||
.set(PlanDO::getPlateNum, plateNum)
|
||||
.set(PlanDO::getArea, area));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 统计更新orders的小板数量和面积
|
||||
@@ -1899,7 +1928,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
String goodsId = f.getPlanActualGoodsModelDO().getGoodsId();
|
||||
|
||||
// 创建排单
|
||||
planDOS.add(PlanDO.builder()
|
||||
PlanDO planDO = PlanDO.builder()
|
||||
.id(planId)
|
||||
.sort(++sort)
|
||||
.type(PlanTypeEnum.MIXEDORDERPLAN.getType())
|
||||
@@ -1912,10 +1941,11 @@ public class PlanServiceImpl implements PlanService {
|
||||
.planTime(LocalDateTime.now())
|
||||
.goodsId(goodsId)
|
||||
.plateNum(planPlateNum)
|
||||
.build());
|
||||
.build();
|
||||
|
||||
// 更新板件排单id & 统计更新order_goods的数量和面积
|
||||
computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap);
|
||||
planDO.setArea(computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap));
|
||||
planDOS.add(planDO);
|
||||
|
||||
}
|
||||
// 统计更新orders的小板数量和面积
|
||||
@@ -1970,7 +2000,7 @@ public class PlanServiceImpl implements PlanService {
|
||||
Long planId = (Long) identifierGenerator.nextId(null);
|
||||
|
||||
// 创建排单
|
||||
planDOS.add(PlanDO.builder()
|
||||
PlanDO planDO = PlanDO.builder()
|
||||
.id(planId)
|
||||
.sort(++sort)
|
||||
.type(planType)
|
||||
@@ -1982,10 +2012,11 @@ public class PlanServiceImpl implements PlanService {
|
||||
.operator(loginUser.getNickname())
|
||||
.planTime(LocalDateTime.now())
|
||||
.plateNum(planPlateNum)
|
||||
.build());
|
||||
.build();
|
||||
|
||||
// 更新板件排单id & 统计更新order_goods的数量和面积
|
||||
computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap);
|
||||
planDO.setArea(computePlatePlanAndComputeOrderGoodsInfo(planId, goodsPlateIdMap));
|
||||
planDOS.add(planDO);
|
||||
}
|
||||
// 统计更新orders的小板数量和面积
|
||||
computeOrderInfo(orderIdSet);
|
||||
@@ -1997,7 +2028,8 @@ public class PlanServiceImpl implements PlanService {
|
||||
* @param planId
|
||||
* @param goodsPlateIdMap
|
||||
*/
|
||||
public void computePlatePlanAndComputeOrderGoodsInfo(Long planId, Map<Long, List<Long>> goodsPlateIdMap) {
|
||||
public BigDecimal computePlatePlanAndComputeOrderGoodsInfo(Long planId, Map<Long, List<Long>> goodsPlateIdMap) {
|
||||
BigDecimal planArea = BigDecimal.ZERO;
|
||||
for (Map.Entry<Long, List<Long>> entry : goodsPlateIdMap.entrySet()) {
|
||||
Long orderGoodsId = entry.getKey();
|
||||
// 查询version
|
||||
@@ -2018,16 +2050,19 @@ public class PlanServiceImpl implements PlanService {
|
||||
int version = goodsDO.getVersion();
|
||||
// 统计每个order_goods下的未排单面积,更新到order_goods中
|
||||
OrderPlanPlateNumAndAreaRespVO goodsPlateNumAndAreaPlanInfo = goodsMapper.selectPlannedPlateNumAndArea(orderGoodsId);
|
||||
BigDecimal plannedArea = goodsPlateNumAndAreaPlanInfo.getArea();
|
||||
int update = goodsMapper.update(new LambdaUpdateWrapper<GoodsDO>()
|
||||
.eq(GoodsDO::getId, orderGoodsId)
|
||||
.eq(GoodsDO::getVersion, version)
|
||||
.set(GoodsDO::getPlannedPlateArea, goodsPlateNumAndAreaPlanInfo.getArea())
|
||||
.set(GoodsDO::getPlannedPlateArea, plannedArea)
|
||||
.set(GoodsDO::getPlannedPlateNum, goodsPlateNumAndAreaPlanInfo.getNum())
|
||||
.set(GoodsDO::getVersion, version + 1));
|
||||
if (update == 0) {
|
||||
throw new ServiceException(ErrorCodeConstants.CREATE_PLAN_GOODS_UPDATE_CONCURRENCY_ERROR, orderGoodsId);
|
||||
}
|
||||
planArea = planArea.add(plannedArea);
|
||||
}
|
||||
return planArea;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-1
@@ -239,6 +239,7 @@
|
||||
<result property="thickness" column="thickness"/>
|
||||
<result property="brand" column="brand"/>
|
||||
<result property="num" column="num"/>
|
||||
<result property="area" column="area"/>
|
||||
|
||||
<collection property="orderIds" ofType="com.cf.imes.module.executor.controller.admin.plan.bo.OrderIds" resultMap="orderIdsMap"/>
|
||||
|
||||
@@ -299,7 +300,8 @@
|
||||
og.thickness as thickness,
|
||||
og.brand as brand,
|
||||
og.texture as texture,
|
||||
sum(og.plate_num - og.planned_plate_num) as num
|
||||
sum(og.plate_num - og.planned_plate_num) as num,
|
||||
sum(og.area - og.planned_plate_area) as area
|
||||
|
||||
from orders o
|
||||
join order_goods og on o.id = og.order_id and og.organ_id = #{organId}
|
||||
|
||||
Reference in New Issue
Block a user