mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 21:32:07 +08:00
1、贴皮新增待删除的中间状态;2、贴皮优化数据源order-source新增逻辑:只返回未优化的板件还有待删除的贴皮编号列表;
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
package com.cf.imes.module.executor.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 板件贴皮加工状态枚举。
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum VeneerPlateProcessStatusEnum {
|
||||
|
||||
NOT_OPTIMIZED(0, "未优化"),
|
||||
OPTIMIZED(1, "已优化"),
|
||||
CUTTING(2, "开料中"),
|
||||
CUT(3, "已开料");
|
||||
|
||||
/** 状态值。 */
|
||||
private final Integer status;
|
||||
|
||||
/** 状态说明。 */
|
||||
private final String description;
|
||||
}
|
||||
+3
@@ -29,4 +29,7 @@ public class VeneerOrderSource {
|
||||
|
||||
@Schema(description = "贴皮板件造型列表")
|
||||
private List<VeneerOrderModelRespVO> plateModels;
|
||||
|
||||
@Schema(description = "待删除贴皮编号列表")
|
||||
private List<String> pendingDeleteVeneerNos;
|
||||
}
|
||||
|
||||
+10
@@ -113,4 +113,14 @@ public class OrderPlateVeneerDO extends BaseDO {
|
||||
*/
|
||||
private Long planId;
|
||||
|
||||
/**
|
||||
* 加工状态:0-未优化,1-已优化,2-开料中,3-已开料。
|
||||
*/
|
||||
private Integer processStatus;
|
||||
|
||||
/**
|
||||
* 是否待删除。
|
||||
*/
|
||||
private Boolean pendingDelete;
|
||||
|
||||
}
|
||||
|
||||
+8
@@ -31,4 +31,12 @@ public interface VeneerOptimizePlanMapper extends BaseMapperX<OrderVeneerPlanDO>
|
||||
* @return 贴皮及来源板件原始列表
|
||||
*/
|
||||
List<VeneerOptimizePlateRespVO> selectPlateList(@Param("planId") Long planId);
|
||||
|
||||
/**
|
||||
* 查询排单内已标记待删除的贴皮编号。
|
||||
*
|
||||
* @param planId 贴皮排单ID
|
||||
* @return 待删除贴皮编号列表
|
||||
*/
|
||||
List<String> selectPendingDeleteVeneerNos(@Param("planId") Long planId);
|
||||
}
|
||||
|
||||
+12
@@ -95,6 +95,18 @@ public interface VeneerPlanMapper extends BaseMapperX<OrderVeneerPlanDO> {
|
||||
int resetPlanVeneer(@Param("ids") List<Long> ids,
|
||||
@Param("planId") Long planId);
|
||||
|
||||
/**
|
||||
* 将排单内尚未开料的贴皮批量标记为待删除。
|
||||
*
|
||||
* @param ids 板件贴皮记录ID列表
|
||||
* @param planId 贴皮排单ID
|
||||
* @param allowedStatuses 允许标记待删除的加工状态
|
||||
* @return 更新行数
|
||||
*/
|
||||
int markPlanVeneerPendingDelete(@Param("ids") List<Long> ids,
|
||||
@Param("planId") Long planId,
|
||||
@Param("allowedStatuses") List<Integer> allowedStatuses);
|
||||
|
||||
/**
|
||||
* 根据排单当前关联贴皮重新统计数量和面积。
|
||||
*
|
||||
|
||||
+3
@@ -37,6 +37,7 @@ import com.cf.imes.module.executor.dal.mysql.veneer.OrderPlateVeneerBatchMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.veneer.VeneerDecomposeMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.veneer.VeneerMapper;
|
||||
import com.cf.imes.module.executor.enums.VeneerPlateSurfaceEnum;
|
||||
import com.cf.imes.module.executor.enums.VeneerPlateProcessStatusEnum;
|
||||
import com.cf.imes.module.executor.enums.VeneerSideEnum;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -571,6 +572,8 @@ public class VeneerDecomposeServiceImpl implements VeneerDecomposeService {
|
||||
.outerMargin(actualOuterMargin)
|
||||
.veneerArea(veneerArea)
|
||||
.planId(0L)
|
||||
.processStatus(VeneerPlateProcessStatusEnum.NOT_OPTIMIZED.getStatus())
|
||||
.pendingDelete(false)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
+11
-10
@@ -36,7 +36,6 @@ import static com.cf.imes.module.executor.enums.ErrorCodeConstants.VENEER_OPTIMI
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.VENEER_OPTIMIZE_PLAN_LOCKED;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.VENEER_OPTIMIZE_PLAN_NOT_EXIST;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.VENEER_OPTIMIZE_PLATE_EMPTY;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.VENEER_OPTIMIZE_PLATE_MODEL_EMPTY;
|
||||
|
||||
/**
|
||||
* 贴皮排单优化 Service 实现。
|
||||
@@ -81,15 +80,20 @@ public class VeneerOptimizePlanServiceImpl implements VeneerOptimizePlanService
|
||||
lockReq.setVal(val);
|
||||
acquirePlanLock(lockReq);
|
||||
|
||||
// 一次查询贴皮与来源板件,随后合并多加工组造成的重复记录。
|
||||
// 待删除贴皮仅向优化端下发短号,不重复传输此前已经发送的完整板件数据。
|
||||
List<String> pendingDeleteVeneerNos =
|
||||
veneerOptimizePlanMapper.selectPendingDeleteVeneerNos(planId);
|
||||
|
||||
// 只加载本次尚未优化且未标记待删除的贴皮,并合并多加工组造成的重复记录。
|
||||
List<VeneerOptimizePlateRespVO> plates = mergePlateDetails(
|
||||
veneerOptimizePlanMapper.selectPlateList(planId));
|
||||
if (CollUtil.isEmpty(plates)) {
|
||||
if (CollUtil.isEmpty(plates) && CollUtil.isEmpty(pendingDeleteVeneerNos)) {
|
||||
throw new ServiceException(VENEER_OPTIMIZE_PLATE_EMPTY);
|
||||
}
|
||||
|
||||
List<VeneerOptimizeGoodsRespVO> goods = veneerOptimizePlanMapper.selectGoodsList(planId);
|
||||
if (CollUtil.isEmpty(goods)) {
|
||||
List<VeneerOptimizeGoodsRespVO> goods = CollUtil.isEmpty(plates)
|
||||
? List.of() : veneerOptimizePlanMapper.selectGoodsList(planId);
|
||||
if (CollUtil.isNotEmpty(plates) && CollUtil.isEmpty(goods)) {
|
||||
throw new ServiceException(VENEER_OPTIMIZE_GOODS_EMPTY);
|
||||
}
|
||||
|
||||
@@ -100,7 +104,7 @@ public class VeneerOptimizePlanServiceImpl implements VeneerOptimizePlanService
|
||||
for (List<Long> batch : CollUtil.split(orderIds, ORDER_QUERY_BATCH_SIZE)) {
|
||||
orders.addAll(orderMapper.selectBatchIds(batch));
|
||||
}
|
||||
if (CollUtil.isEmpty(orders)) {
|
||||
if (CollUtil.isNotEmpty(plates) && CollUtil.isEmpty(orders)) {
|
||||
throw new ServiceException(VENEER_OPTIMIZE_ORDERS_EMPTY);
|
||||
}
|
||||
|
||||
@@ -116,15 +120,12 @@ public class VeneerOptimizePlanServiceImpl implements VeneerOptimizePlanService
|
||||
model.setVeneerNo(plate.getVeneerNo());
|
||||
models.add(model);
|
||||
}
|
||||
if (CollUtil.isEmpty(models)) {
|
||||
throw new ServiceException(VENEER_OPTIMIZE_PLATE_MODEL_EMPTY);
|
||||
}
|
||||
|
||||
return VeneerOrderSource.builder()
|
||||
.orderList(orders)
|
||||
.goodsList(goods)
|
||||
.plateList(plates)
|
||||
.plateModels(models)
|
||||
.pendingDeleteVeneerNos(pendingDeleteVeneerNos)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
+29
-2
@@ -42,6 +42,7 @@ import com.cf.imes.module.executor.dal.mysql.veneer.OrderVeneerPlanBatchMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.veneer.OrderVeneerGoodsMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.veneer.VeneerPlanMapper;
|
||||
import com.cf.imes.module.executor.enums.VeneerPlanStatusEnum;
|
||||
import com.cf.imes.module.executor.enums.VeneerPlateProcessStatusEnum;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -97,6 +98,11 @@ public class VeneerPlanServiceImpl implements VeneerPlanService {
|
||||
*/
|
||||
private static final int PLAN_BATCH_SIZE = 1000;
|
||||
|
||||
/** 允许标记待删除的贴皮加工状态:未优化、已优化。 */
|
||||
private static final List<Integer> PENDING_DELETE_ALLOWED_STATUSES = List.of(
|
||||
VeneerPlateProcessStatusEnum.NOT_OPTIMIZED.getStatus(),
|
||||
VeneerPlateProcessStatusEnum.OPTIMIZED.getStatus());
|
||||
|
||||
/**
|
||||
* 贴皮排单批量插入数量。
|
||||
*/
|
||||
@@ -381,11 +387,31 @@ public class VeneerPlanServiceImpl implements VeneerPlanService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removePlanPlate(VeneerPlanRemovePlateReqVO req) {
|
||||
Long planId = req == null ? null : req.getPlanId();
|
||||
OrderVeneerPlanDO plan = validatePlanStatuses(planId, PLAN_EDITABLE_STATUSES);
|
||||
validatePlanStatuses(planId, PLAN_EDITABLE_STATUSES);
|
||||
List<Long> veneerIds = normalizePlanVeneerIds(
|
||||
req == null ? null : req.getVeneerIds());
|
||||
|
||||
// 仅允许移除当前排单中的有效贴皮,并保留归属范围用于后续重新统计。
|
||||
// 当前仅记录删除意图,不解除排单关系,也不提前扣减排单数量、面积和订单范围。
|
||||
for (List<Long> idBatch : CollUtil.split(veneerIds, PLAN_BATCH_SIZE)) {
|
||||
int updated = veneerPlanMapper.markPlanVeneerPendingDelete(
|
||||
idBatch, planId, PENDING_DELETE_ALLOWED_STATUSES);
|
||||
if (updated != idBatch.size()) {
|
||||
throw new ServiceException(VENEER_PLAN_PLATE_STATUS_CHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 真正从排单中移除贴皮并重新统计排单及订单范围。
|
||||
*
|
||||
* <p>当前待删除接口不调用本方法;后续保存优化结果时,根据优化端确认删除的
|
||||
* 贴皮编号解析出记录ID后复用。</p>
|
||||
*
|
||||
* @param plan 当前贴皮排单
|
||||
* @param veneerIds 已由优化端确认删除的贴皮记录ID
|
||||
*/
|
||||
private void executeRemovePlanPlate(OrderVeneerPlanDO plan, List<Long> veneerIds) {
|
||||
Long planId = plan.getId();
|
||||
List<OrderPlateVeneerDO> veneers = new ArrayList<>();
|
||||
for (List<Long> idBatch : CollUtil.split(veneerIds, PLAN_BATCH_SIZE)) {
|
||||
veneers.addAll(veneerPlanMapper.selectPlannedVeneerList(idBatch, planId));
|
||||
@@ -394,6 +420,7 @@ public class VeneerPlanServiceImpl implements VeneerPlanService {
|
||||
throw new ServiceException(VENEER_PLAN_PLATE_STATUS_CHANGED);
|
||||
}
|
||||
|
||||
// 解除排单关系并重置待删除、优化和开料状态;更新数量不一致时整次保存回滚。
|
||||
for (List<Long> idBatch : CollUtil.split(veneerIds, PLAN_BATCH_SIZE)) {
|
||||
int updated = veneerPlanMapper.resetPlanVeneer(idBatch, planId);
|
||||
if (updated != idBatch.size()) {
|
||||
|
||||
+13
@@ -31,6 +31,8 @@
|
||||
AND ovg.deleted = false
|
||||
WHERE opv.deleted = false
|
||||
AND opv.plan_id = #{planId}
|
||||
AND opv.process_status = 0
|
||||
AND opv.pending_delete = false
|
||||
ORDER BY ovg.goods_id
|
||||
</select>
|
||||
|
||||
@@ -119,6 +121,17 @@
|
||||
AND opg.id = oi.group_id
|
||||
WHERE opv.deleted = false
|
||||
AND opv.plan_id = #{planId}
|
||||
AND opv.process_status = 0
|
||||
AND opv.pending_delete = false
|
||||
ORDER BY opv.id, oi.group_id
|
||||
</select>
|
||||
|
||||
<select id="selectPendingDeleteVeneerNos" resultType="java.lang.String">
|
||||
SELECT opv.veneer_no
|
||||
FROM order_plate_veneer opv
|
||||
WHERE opv.deleted = false
|
||||
AND opv.plan_id = #{planId}
|
||||
AND opv.pending_delete = true
|
||||
ORDER BY opv.id
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
+19
@@ -109,6 +109,8 @@
|
||||
<update id="resetPlanVeneer">
|
||||
UPDATE order_plate_veneer
|
||||
SET plan_id = 0,
|
||||
process_status = 0,
|
||||
pending_delete = false,
|
||||
update_time = CURRENT_TIMESTAMP
|
||||
WHERE deleted = false
|
||||
AND plan_id = #{planId}
|
||||
@@ -118,6 +120,23 @@
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="markPlanVeneerPendingDelete">
|
||||
UPDATE order_plate_veneer
|
||||
SET pending_delete = true,
|
||||
update_time = CURRENT_TIMESTAMP
|
||||
WHERE deleted = false
|
||||
AND pending_delete = false
|
||||
AND plan_id = #{planId}
|
||||
AND process_status IN
|
||||
<foreach collection="allowedStatuses" item="status" open="(" close=")" separator=",">
|
||||
#{status}
|
||||
</foreach>
|
||||
AND id IN
|
||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="selectPlanStatistics"
|
||||
resultType="com.cf.imes.module.executor.dal.dataobject.veneer.VeneerPlanStatisticsDO">
|
||||
SELECT COUNT(*) AS veneerNum,
|
||||
|
||||
Reference in New Issue
Block a user