fix:系统数量限制,物料入库数量限制
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package com.zt.plat.module.qms.core.constant;
|
package com.zt.plat.module.qms.core.constant;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class CommonConstant {
|
public class CommonConstant {
|
||||||
|
|
||||||
|
|
||||||
@@ -75,4 +77,16 @@ public class CommonConstant {
|
|||||||
//================数据库常量======================
|
//================数据库常量======================
|
||||||
public static final String SQL_WHERE = "where";
|
public static final String SQL_WHERE = "where";
|
||||||
|
|
||||||
|
//================数量限制========================
|
||||||
|
/**
|
||||||
|
* 单次最大生成数量(防止系统资源耗尽)
|
||||||
|
*/
|
||||||
|
public static final BigDecimal MAX_GENERATE_QUANTITY = new BigDecimal("10000");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单次最大响应数量(防止响应数据过大)
|
||||||
|
*/
|
||||||
|
public static final BigDecimal MAX_RESPONSE_QUANTITY = new BigDecimal("1000");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ package com.zt.plat.module.qms.resource.material.constant;
|
|||||||
* 物料常量
|
* 物料常量
|
||||||
*/
|
*/
|
||||||
public class MaterialConstants {
|
public class MaterialConstants {
|
||||||
// 字典 类型
|
// 字典
|
||||||
public static final String DICT_MATERIAL_FLOW_TYPE = "jy_material_lifecycle_bsn_type";
|
public static final String DICT_MATERIAL_FLOW_TYPE = "jy_material_lifecycle_bsn_type";
|
||||||
|
public static final String DICT_MATERIAL_INBOUND_QUANTITY_LIMIT = "materialInboundQuantityLimit";
|
||||||
|
|
||||||
// 序列号
|
// 序列号
|
||||||
public static final String SEQUENCE_INF_KEY = "QMS_MATERIAL_INF_NO";
|
public static final String SEQUENCE_INF_KEY = "QMS_MATERIAL_INF_NO";
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
package com.zt.plat.module.qms.resource.material.service;
|
package com.zt.plat.module.qms.resource.material.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.zt.plat.framework.common.exception.ServiceException;
|
import com.zt.plat.framework.common.exception.ServiceException;
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
import com.zt.plat.framework.security.core.LoginUser;
|
import com.zt.plat.framework.security.core.LoginUser;
|
||||||
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
|
import com.zt.plat.module.qms.common.dic.controller.vo.DictionaryBusinessRespVO;
|
||||||
|
import com.zt.plat.module.qms.common.dic.service.DictionaryBusinessService;
|
||||||
import com.zt.plat.module.qms.core.code.SequenceUtil;
|
import com.zt.plat.module.qms.core.code.SequenceUtil;
|
||||||
|
import com.zt.plat.module.qms.core.constant.CommonConstant;
|
||||||
import com.zt.plat.module.qms.core.constant.DataTypeConstant;
|
import com.zt.plat.module.qms.core.constant.DataTypeConstant;
|
||||||
import com.zt.plat.module.qms.resource.material.constant.MaterialConstants;
|
import com.zt.plat.module.qms.resource.material.constant.MaterialConstants;
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailRespVO;
|
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundDetailRespVO;
|
||||||
@@ -55,6 +60,8 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb
|
|||||||
private MaterialInfomationService materialInfomationService;
|
private MaterialInfomationService materialInfomationService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MaterialInventoryInboundDetailService materialInventoryInboundDetailService;
|
private MaterialInventoryInboundDetailService materialInventoryInboundDetailService;
|
||||||
|
@Autowired
|
||||||
|
private DictionaryBusinessService dictionaryBusinessService;
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -63,6 +70,19 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb
|
|||||||
Long gongduanId = createReqVO.getGongduanId();
|
Long gongduanId = createReqVO.getGongduanId();
|
||||||
BigDecimal reqQuantity = createReqVO.getQuantity();
|
BigDecimal reqQuantity = createReqVO.getQuantity();
|
||||||
if (reqQuantity.compareTo(BigDecimal.ZERO) <= 0) throw new ServiceException(1_032_160_000, "入库数量不能小于等于0");
|
if (reqQuantity.compareTo(BigDecimal.ZERO) <= 0) throw new ServiceException(1_032_160_000, "入库数量不能小于等于0");
|
||||||
|
CommonResult<DictionaryBusinessRespVO> inboundQuantityLimitResult = dictionaryBusinessService.getDataByDataKey(MaterialConstants.DICT_MATERIAL_INBOUND_QUANTITY_LIMIT);
|
||||||
|
DictionaryBusinessRespVO inboundQuantityLimit = inboundQuantityLimitResult.getData();
|
||||||
|
if (reqQuantity.compareTo(CommonConstant.MAX_GENERATE_QUANTITY) > 0
|
||||||
|
|| reqQuantity.compareTo(CommonConstant.MAX_RESPONSE_QUANTITY) > 0)
|
||||||
|
throw new ServiceException(1_032_160_000,
|
||||||
|
String.format("入库数量不能超过系统限制数量:%s", Math.min(CommonConstant.MAX_GENERATE_QUANTITY.doubleValue(), CommonConstant.MAX_RESPONSE_QUANTITY.doubleValue())));
|
||||||
|
if (inboundQuantityLimit != null) {
|
||||||
|
BigDecimal inbQtyLimit = new BigDecimal(inboundQuantityLimit.getValue());
|
||||||
|
if (reqQuantity.compareTo(inbQtyLimit) > 0) {
|
||||||
|
throw new ServiceException(1_032_160_000,
|
||||||
|
String.format("入库数量超出配置限制:%s,当前请求数量:%s", inbQtyLimit, reqQuantity));
|
||||||
|
}
|
||||||
|
}
|
||||||
MaterialBatchDO gongDO = materialBatchService.getMaterialBatch(gongduanId);
|
MaterialBatchDO gongDO = materialBatchService.getMaterialBatch(gongduanId);
|
||||||
if (gongDO == null) throw exception(MATERIAL_BATCH_GONG_NOT_EXISTS);
|
if (gongDO == null) throw exception(MATERIAL_BATCH_GONG_NOT_EXISTS);
|
||||||
// 1.检查工段是否已经验收
|
// 1.检查工段是否已经验收
|
||||||
@@ -70,7 +90,6 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb
|
|||||||
throw new ServiceException(1_032_160_000, "工段未验收,不能入库");
|
throw new ServiceException(1_032_160_000, "工段未验收,不能入库");
|
||||||
|
|
||||||
// 2.入库数量不大于批次工段数量
|
// 2.入库数量不大于批次工段数量
|
||||||
if (reqQuantity.compareTo(gongDO.getInboundQuantity()) > 0) throw new ServiceException(1_032_160_000, "入库数量不能大于批次工段数量");
|
|
||||||
// TODO 这儿应该调整为去物料实例统计出此工段的入库数量
|
// TODO 这儿应该调整为去物料实例统计出此工段的入库数量
|
||||||
List<MaterialInventoryInboundDO> inboundDOS = materialInventoryInboundMapper.selectList(Wrappers.lambdaQuery(MaterialInventoryInboundDO.class)
|
List<MaterialInventoryInboundDO> inboundDOS = materialInventoryInboundMapper.selectList(Wrappers.lambdaQuery(MaterialInventoryInboundDO.class)
|
||||||
.eq(MaterialInventoryInboundDO::getGongduanId, gongduanId));
|
.eq(MaterialInventoryInboundDO::getGongduanId, gongduanId));
|
||||||
@@ -79,7 +98,10 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb
|
|||||||
for (MaterialInventoryInboundDO inboundDO : inboundDOS) {
|
for (MaterialInventoryInboundDO inboundDO : inboundDOS) {
|
||||||
totalQuantity = totalQuantity.add(inboundDO.getQuantity());
|
totalQuantity = totalQuantity.add(inboundDO.getQuantity());
|
||||||
}
|
}
|
||||||
if (totalQuantity.compareTo(gongDO.getInboundQuantity()) > 0) throw new ServiceException(1_032_160_000, "入库数量不能大于批次工段数量");
|
if (totalQuantity.compareTo(gongDO.getInboundQuantity()) > 0)
|
||||||
|
throw new ServiceException(1_032_160_000, "入库数量不能大于批次工段未入库数量");
|
||||||
|
} else if (reqQuantity.compareTo(gongDO.getInboundQuantity()) > 0) {
|
||||||
|
throw new ServiceException(1_032_160_000, "入库数量不能大于批次工段数量");
|
||||||
}
|
}
|
||||||
// 3.保存入库记录
|
// 3.保存入库记录
|
||||||
MaterialInventoryInboundDO inbound = saveInbound(createReqVO, gongDO);
|
MaterialInventoryInboundDO inbound = saveInbound(createReqVO, gongDO);
|
||||||
|
|||||||
Reference in New Issue
Block a user