diff --git a/src/main/java/com/glxp/api/constant/RedissonCacheKey.java b/src/main/java/com/glxp/api/constant/RedissonCacheKey.java index 0716ba7f..8d889c4d 100644 --- a/src/main/java/com/glxp/api/constant/RedissonCacheKey.java +++ b/src/main/java/com/glxp/api/constant/RedissonCacheKey.java @@ -38,4 +38,9 @@ public interface RedissonCacheKey { * web添加单据 */ String WEB_ADD_CODE = "web_add_code"; + + /** + * 复制单据 + */ + String COPY_ORDER = "copy_order"; } diff --git a/src/main/java/com/glxp/api/controller/inout/IoOrderController.java b/src/main/java/com/glxp/api/controller/inout/IoOrderController.java index 26757b90..508f9764 100644 --- a/src/main/java/com/glxp/api/controller/inout/IoOrderController.java +++ b/src/main/java/com/glxp/api/controller/inout/IoOrderController.java @@ -3,7 +3,12 @@ package com.glxp.api.controller.inout; import cn.hutool.core.bean.BeanUtil; import com.glxp.api.annotation.CusRedissonAnnotation; import com.glxp.api.constant.*; +import com.glxp.api.entity.inv.InvPreInProductDetailEntity; +import com.glxp.api.res.inv.InvPlaceDetailResponse; import com.glxp.api.service.inout.impl.IoCodeService; +import com.glxp.api.service.inv.InvPreProductDetailService; +import com.glxp.api.service.inv.InvPreinProductDetailService; +import com.glxp.api.service.inv.impl.InvProductDetailService; import com.glxp.api.service.system.SystemParamConfigService; import org.springframework.beans.BeanUtils; import cn.hutool.core.collection.CollUtil; @@ -87,6 +92,12 @@ public class IoOrderController extends BaseController { CustomerService customerService; @Resource private SystemParamConfigService systemParamConfigService; + @Resource + InvPreProductDetailService invPreProductDetailService; + @Resource + InvPreinProductDetailService invPreinProductDetailService; + @Resource + InvProductDetailService invProductDetailService; /** * 查询单据列表 @@ -1012,8 +1023,8 @@ public class IoOrderController extends BaseController { @Resource InvWarehouseService invWarehouseService; - @RepeatSubmit() @AuthRuleAnnotation("") + @CusRedissonAnnotation(cacheName = RedissonCacheKey.COPY_ORDER, key = {"#addOrderChangeRequest.orderId"}, timeOutMsg = "系统正在处理,请勿重复提交") @PostMapping("/udiwms/stock/order/change") public BaseResponse stockOrderChange(@RequestBody AddOrderChangeRequest addOrderChangeRequest) { @@ -1058,21 +1069,46 @@ public class IoOrderController extends BaseController { List products = addOrderChangeRequest.getProducts(); List orderDetailBizEntities = orderDetailBizService.findByOrderId(originOrder.getBillNo()); // 计算出两个集合之间产品批次号组成的差异 - List IoStatDayEntityList = orderDetailBizEntities.stream() + List insertBizList = orderDetailBizEntities.stream() .filter(comment -> products.stream() .anyMatch(p -> Objects.equals(p.getBatchNo(), comment.getBatchNo()) // 使用 Objects.equals 来进行非空判断 && Objects.equals(p.getRelId(), comment.getBindRlFk()))) .collect(Collectors.toList()); //生成业务单 - if (CollUtil.isNotEmpty(IoStatDayEntityList)) { - for (IoOrderDetailBizEntity orderDetailBizEntity : IoStatDayEntityList) { + if (CollUtil.isNotEmpty(insertBizList)) { + for (IoOrderDetailBizEntity orderDetailBizEntity : insertBizList) { orderDetailBizEntity.setOrderIdFk(newOrder.getBillNo()); orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId()); - orderDetailBizService.insert(orderDetailBizEntity); + + + if (bussinessTypeEntity.isScanPreIn()) { //校验预验收库存 + + if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_NULL) { + BaseResponse invRes = checkPreInInv(orderDetailBizEntity); + if (invRes != null) { + return invRes; + } + } + } else if (bussinessTypeEntity.isAdvancePreIn()) { //校验寄售库存 + if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_NULL) { + BaseResponse invRes = checkPreInv(orderDetailBizEntity); + if (invRes != null) { + return invRes; + } + } + } else { + if (bussinessTypeEntity.isVailInv() && bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { + BaseResponse invRes = checkInv(orderDetailBizEntity, newOrder); + if (invRes != null) { + return invRes; + } + } + + } } + orderDetailBizService.batchInsertBizs(insertBizList); } - originCodes.forEach( code -> { //复制选中的产品 @@ -1228,4 +1264,51 @@ public class IoOrderController extends BaseController { return bizEntity.getCoName() + "数量不匹配!"; } + + public BaseResponse checkInv(IoOrderDetailBizEntity bizEntity, IoOrderEntity orderEntity) { + + int count = 0; + count = invProductDetailService.vailStockCount(bizEntity.getBindRlFk(), bizEntity.getBatchNo(), bizEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), null); + if (count <= 0) { + if (count == -1) { + return ResultVOUtils.error(500, "该产品未入库"); + } else + return ResultVOUtils.error(500, "当前库存不足"); + } + return null; + } + + /** + * 校验寄售库存 + */ + public BaseResponse checkPreInv(IoOrderDetailBizEntity bizEntity) { + + InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_ADVANCE); + int count = 0; + count = invPreProductDetailService.vailStockCount(bizEntity.getBindRlFk(), bizEntity.getBatchNo(), bizEntity.getSupId(), null, invWarehouseEntity.getCode(), null); + if (count <= 0) { + if (count == -1) { + return ResultVOUtils.error(500, "该产品未入库"); + } else + return ResultVOUtils.error(500, "寄售库存数量不足!"); + } + return null; + } + + // 校验预验收库存 + public BaseResponse checkPreInInv(IoOrderDetailBizEntity bizEntity) { + + InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_PREIN); + int count = 0; + count = invPreinProductDetailService.vailStockCount(bizEntity.getBindRlFk(), bizEntity.getBatchNo(), bizEntity.getSupId(), null, invWarehouseEntity.getCode(), null); + if (count <= 0) { + if (count == -1) { + return ResultVOUtils.error(500, "该产品未入库"); + } else + return ResultVOUtils.error(500, "预验收库存数量不足!"); + } + return null; + } + + } diff --git a/src/main/java/com/glxp/api/controller/purchase/PurApplyController.java b/src/main/java/com/glxp/api/controller/purchase/PurApplyController.java index e7d38bb9..1a3aff47 100644 --- a/src/main/java/com/glxp/api/controller/purchase/PurApplyController.java +++ b/src/main/java/com/glxp/api/controller/purchase/PurApplyController.java @@ -146,10 +146,10 @@ public class PurApplyController { if (purApplyRequest.getStatus() == null) { purApplyRequest.setStatus(10); //查询未审核和已审核状态 } - if (purApplyRequest.getIsInvCode() != null && purApplyRequest.getIsInvCode()) { - AuthAdmin authAdmin = customerService.getUserBean(); - purApplyRequest.setTargetInvCode(authAdmin.getLocInvCode() + ""); //查询自己仓库 - } +// if (purApplyRequest.getIsInvCode() != null && purApplyRequest.getIsInvCode()) { +// AuthAdmin authAdmin = customerService.getUserBean(); +// purApplyRequest.setTargetInvCode(authAdmin.getLocInvCode() + ""); //查询自己仓库 +// } List purApplyEntities = purApplyService.queryPageList(purApplyRequest); PageInfo pageInfo; pageInfo = new PageInfo<>(purApplyEntities); diff --git a/src/main/java/com/glxp/api/service/inout/IoOrderDetailBizService.java b/src/main/java/com/glxp/api/service/inout/IoOrderDetailBizService.java index d1773548..e168fc88 100644 --- a/src/main/java/com/glxp/api/service/inout/IoOrderDetailBizService.java +++ b/src/main/java/com/glxp/api/service/inout/IoOrderDetailBizService.java @@ -33,6 +33,7 @@ public interface IoOrderDetailBizService { boolean isExit(Long relId, String bacthNo, Long ignoreId, String orderId); IoOrderDetailBizEntity findByUnique(String orderId, Long relId, String bacthNo, String productDate, String expireDate); + IoOrderDetailBizEntity findByUnique(String orderId, Long relId, String bacthNo); @@ -58,4 +59,7 @@ public interface IoOrderDetailBizService { List getInvoicResultDetail(FilterOrderDetailCodeRequest orderDetailBizRequest); + Boolean batchInsertBizs(List bizEntities); + + } diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoOrderDetailBizServiceImpl.java b/src/main/java/com/glxp/api/service/inout/impl/IoOrderDetailBizServiceImpl.java index 016f1c2b..a819046f 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoOrderDetailBizServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoOrderDetailBizServiceImpl.java @@ -149,6 +149,11 @@ public class IoOrderDetailBizServiceImpl implements IoOrderDetailBizService { return ioOrderDetailBizDao.getfilterOrderList(OrderDetailCodeRequest); } + @Override + public Boolean batchInsertBizs(List bizEntities) { + return ioOrderDetailBizDao.insertBatch(bizEntities); + } + @Override public IoOrderDetailBizEntity selectByBatchNoAndBindRlFk(String batchNo, String bindRlFk) { QueryWrapper ew = new QueryWrapper<>(); diff --git a/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml b/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml index a17f08a4..e024f123 100644 --- a/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml +++ b/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml @@ -470,6 +470,9 @@ GROUP BY basic_udirel.id + + GROUP BY basic_udirel.id,company_product_relevance.unitFk + diff --git a/src/main/resources/mybatis/mapper/inout/IoOrderDao.xml b/src/main/resources/mybatis/mapper/inout/IoOrderDao.xml index 2b28d7db..2504ca28 100644 --- a/src/main/resources/mybatis/mapper/inout/IoOrderDao.xml +++ b/src/main/resources/mybatis/mapper/inout/IoOrderDao.xml @@ -445,7 +445,7 @@ - AND billNo like concat('%', #{billNo}, '%') + AND io.billNo like concat('%', #{billNo}, '%') AND invCode = #{invCode}