diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java index 2377507e1..c9dc11456 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java @@ -1,6 +1,5 @@ package com.cf.imes.module.executor.service.optimizeplan; -import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.text.CharSequenceUtil; @@ -22,6 +21,7 @@ import co.elastic.clients.elasticsearch.sql.TranslateResponse; import co.elastic.clients.json.JsonData; import co.elastic.clients.json.JsonpMappingException; import com.alibaba.fastjson.JSON; +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; @@ -30,6 +30,7 @@ import com.cf.imes.framework.common.enums.OrderStatusEnum; import com.cf.imes.framework.common.enums.PlanStatusEnum; import com.cf.imes.framework.common.enums.PlanTypeEnum; import com.cf.imes.framework.common.exception.ServiceException; +import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil; import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.common.util.Assert.AssertUtils; import com.cf.imes.framework.common.util.object.BeanUtils; @@ -73,6 +74,8 @@ import com.cf.imes.module.system.api.systemconfig.dto.ProcessSchemeDTO; import com.fasterxml.jackson.databind.JsonNode; import lombok.extern.slf4j.Slf4j; import org.springframework.aop.framework.AopContext; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -98,6 +101,7 @@ import static com.cf.imes.module.system.enums.ErrorCodeConstants.*; */ @Service @Slf4j +@RefreshScope public class OptimizePlanServiceImpl implements OptimizePlanService { @Resource @@ -151,6 +155,9 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { @Resource private PlateGoodMapper plateGoodMapper; + @Value("${chenfeng.plan.create.plate-threshold:20000}") + private int planCreatePlateThreshold; + private static final String FIELD_ORDER_ID = "orderId"; private static final String FIELD_PLATE_ID = "plateId"; private static final String FIELD_PLAN_ID = "planId"; @@ -773,6 +780,16 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { AssertUtils.notEmpty(orderDOS,THIS_ORDER_PLATE_DATA_ERROR); + // 查询未排单的小板数量 + Long unplanPlateNum = plateMapper.selectCount(new LambdaQueryWrapper() + .in(PlateDO::getOrderId, orderIds) + .in(PlateDO::getGoodsId, orderGoodsIds) + .eq(PlateDO::getPlanId, 0) + .eq(PlateDO::getDeleted, false)); + if (planCreatePlateThreshold < unplanPlateNum) { + throw ServiceExceptionUtil.exception(ORDER_PLAN_CREATE_PLATE_NUM_REACH_THRESHOLD_ERROR, planCreatePlateThreshold); + } + List plateDetailRespVOS = plateMapper.selectNoPlanPlate(orderIds, orderGoodsIds, getUserOrganId()); AssertUtils.notEmpty(plateDetailRespVOS,ORDER_PLATE_ERROR); diff --git a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java index 48e2fa3c8..a78031e2f 100644 --- a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java +++ b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java @@ -342,6 +342,7 @@ public class ErrorCodeConstants { public static final ErrorCode PLAN_IS_OPERATOR = new ErrorCode(1_002_041_052, "当前排单正在被用户:{} 操作,无法继续操作"); public static final ErrorCode PLAN_IS_OPERATOR_NOT = new ErrorCode(1_002_041_053, "排单:{} ,正在被用户:{} 操作,无法继续操作"); public static final ErrorCode ORDER_PLAN_DATA_ERROR = new ErrorCode(1_002_041_054, "生产单/排单数据有误,请查看对应的数据"); + public static final ErrorCode ORDER_PLAN_CREATE_PLATE_NUM_REACH_THRESHOLD_ERROR = new ErrorCode(1_002_041_055, "达到排单板件上限{}片,请减少选择板件数量后创建排单");