From 755c7cddcfeccfcc07f196d72f86d0d0d17f8c74 Mon Sep 17 00:00:00 2001 From: chenhc <2369838784@qq.com> Date: Thu, 3 Apr 2025 14:47:00 +0800 Subject: [PATCH] feat: inv --- .../controller/inv/InvProductController.java | 18 +- .../api/entity/inv/InvProductBatchEntity.java | 56 +++++- .../glxp/api/entity/inv/InvProductEntity.java | 101 ++-------- .../api/service/inout/IoAddInoutService.java | 45 ++--- .../api/service/inout/IoGenInvService.java | 53 +++--- .../inout/impl/IoOrderServiceImpl.java | 174 ++++++++++-------- .../inv/impl/InvProductBatchService.java | 103 +++++++++-- .../service/inv/impl/InvProductService.java | 28 ++- .../inv/impl/InvRemindMsgServiceImpl.java | 93 +++++----- .../java/com/glxp/api/task/VailInvTask.java | 10 +- src/main/resources/application-dev.yml | 4 +- .../mapper/dev/DeviceMAOrderDetailDao.xml | 2 +- .../mapper/dev/InvMAOrderDetailDao.xml | 2 +- .../mapper/inv/InvCountOrderDetailMapper.xml | 2 +- .../mybatis/mapper/inv/InvProductNewDao.xml | 10 +- .../mybatis/mapper/inv/InvRemindSetDao.xml | 2 +- .../mybatis/mapper/inv/invProductDao.xml | 18 +- src/main/resources/schemas/schema_v2.4.sql | 19 +- 18 files changed, 413 insertions(+), 327 deletions(-) diff --git a/src/main/java/com/glxp/api/controller/inv/InvProductController.java b/src/main/java/com/glxp/api/controller/inv/InvProductController.java index 0fb1967fc..75354553c 100644 --- a/src/main/java/com/glxp/api/controller/inv/InvProductController.java +++ b/src/main/java/com/glxp/api/controller/inv/InvProductController.java @@ -230,15 +230,15 @@ public class InvProductController extends BaseController { String id = deleteRequest.getId(); InvProductEntity invProductEntity = invProductService.findById(id); if (null != invProductEntity) { - FilterInvProductDetailRequest detailRequest = new FilterInvProductDetailRequest(); - detailRequest.setSupId(invProductEntity.getSupId()); - detailRequest.setRelId(String.valueOf(invProductEntity.getRelIdFk())); - detailRequest.setInvCode(invProductEntity.getInvCode()); - if (StrUtil.isBlank(invProductEntity.getBatchNo())) { - detailRequest.setBatchNo("empty"); - } else { - detailRequest.setBatchNo(invProductEntity.getBatchNo()); - } +// FilterInvProductDetailRequest detailRequest = new FilterInvProductDetailRequest(); +// detailRequest.setSupId(invProductEntity.getSupId()); +// detailRequest.setRelId(String.valueOf(invProductEntity.getRelIdFk())); +// detailRequest.setInvCode(invProductEntity.getInvCode()); +// if (StrUtil.isBlank(invProductEntity.getBatchNo())) { +// detailRequest.setBatchNo("empty"); +// } else { +// detailRequest.setBatchNo(invProductEntity.getBatchNo()); +// } invProductService.deleteById(id); return ResultVOUtils.success("删除成功"); } else { diff --git a/src/main/java/com/glxp/api/entity/inv/InvProductBatchEntity.java b/src/main/java/com/glxp/api/entity/inv/InvProductBatchEntity.java index 1559fce22..3b8c39e7a 100644 --- a/src/main/java/com/glxp/api/entity/inv/InvProductBatchEntity.java +++ b/src/main/java/com/glxp/api/entity/inv/InvProductBatchEntity.java @@ -76,9 +76,9 @@ public class InvProductBatchEntity implements Serializable { /** * 生产日期 */ - @TableField(value = "produceDate") + @TableField(value = "productionDate") @ApiModelProperty(value = "生产日期") - private String produceDate; + private String productionDate; /** @@ -88,13 +88,20 @@ public class InvProductBatchEntity implements Serializable { @ApiModelProperty(value = "失效日期") private String expireDate; + /** + * 出库数量 + */ + @TableField(value = "outCount") + @ApiModelProperty(value = "出库数量") + private Integer outCount; + /** * 入库数量 */ - @TableField(value = "invCount") + @TableField(value = "inCount") @ApiModelProperty(value = "入库数量") - private Integer invCount; + private Integer inCount; /** * 剩余数量 @@ -107,9 +114,9 @@ public class InvProductBatchEntity implements Serializable { /** * 供应商ID */ - @TableField(value = "supId") + @TableField(value = "customerId") @ApiModelProperty(value = "供应商ID") - private String supId; + private String customerId; /** * 部门编码 @@ -146,5 +153,42 @@ public class InvProductBatchEntity implements Serializable { private Integer status; + /** + * 现存量 + */ + @TableField(value = "nowStock") + private Integer nowStock; + /** + * 冻结量 + */ + @TableField(value = "frozenCount") + private Integer frozenCount; + /** + * 预计入库量 + */ + @TableField(value = "planInCount") + private Integer planInCount; + /** + * 预计出库量 + */ + @TableField(value = "planOutCount") + private Integer planOutCount; + /** + * 在途库存 + */ + @TableField(value = "onWayCount") + private Integer onWayCount; + /** + * 可用库存 + */ + @TableField(value = "availableStock") + private Integer availableStock; + + /** + * 货位编码 + */ + private String invSpaceCode; + + private static final long serialVersionUID = 1L; } diff --git a/src/main/java/com/glxp/api/entity/inv/InvProductEntity.java b/src/main/java/com/glxp/api/entity/inv/InvProductEntity.java index 5c62d05ba..434200cd7 100644 --- a/src/main/java/com/glxp/api/entity/inv/InvProductEntity.java +++ b/src/main/java/com/glxp/api/entity/inv/InvProductEntity.java @@ -12,8 +12,10 @@ import java.util.Date; @Data @TableName(value = "inv_product") public class InvProductEntity { + @TableId(value = "id", type = IdType.AUTO) - private Integer id; + private Long id; + /** * 耗材字典ID @@ -22,58 +24,25 @@ public class InvProductEntity { private Long relIdFk; /** - * 最小销售标识 + * 供应商 */ - @TableField(value = "nameCode") - private String nameCode; + @TableField(value = "supId") + private String supId; - /** - * 批次号 - */ - @TableField(value = "batchNo") - private String batchNo; /** - * 生产日期 + * 实际数量 */ - @TableField(value = "productionDate") - private String productionDate; + @TableField(value = "reCount") + private Integer reCount; - /** - * 失效日期 - */ - @TableField(value = "expireDate") - private String expireDate; - /** - * 入库数量 - */ @TableField(value = "inCount") private Integer inCount; - /** - * 出库数量 - */ - @TableField(value = "outCount") - private int outCount; - - /** - * 实际数量 - */ - @TableField(value = "reCount") - private int reCount; - - /** - * 客户ID - */ - @TableField(value = "customerId") - private String customerId; - /** - * 供应商ID - */ - @TableField(value = "supId") - private String supId; + @TableField(value = "outCount") + private Integer outCount; /** * 部门编码 @@ -93,12 +62,6 @@ public class InvProductEntity { @TableField(value = "invSpaceCode") private String invSpaceCode; - /** - * 创建时间 - */ - @TableField(value = "createTime") - private Date createTime; - /** * 更新时间 @@ -106,47 +69,5 @@ public class InvProductEntity { @TableField(value = "updateTime") private Date updateTime; - /** - * 现存量 - */ - @TableField(value = "nowStock") - private Integer nowStock; - /** - * 冻结量 - */ - @TableField(value = "frozenCount") - private Integer frozenCount; - /** - * 预计入库量 - */ - @TableField(value = "planInCount") - private Integer planInCount; - /** - * 预计出库量 - */ - @TableField(value = "planOutCount") - private Integer planOutCount; - /** - * 在途库存 - */ - @TableField(value = "onWayCount") - private Integer onWayCount; - /** - * 可用库存 - */ - @TableField(value = "availableStock") - private Integer availableStock; - - - /** - * 价格 - */ - @TableField(value = "price") - private BigDecimal price; - - - @TableField(value = "inBatchNo") - private String inBatchNo; - } diff --git a/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java b/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java index 7b49a32b3..1ee4737f7 100644 --- a/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java +++ b/src/main/java/com/glxp/api/service/inout/IoAddInoutService.java @@ -15,6 +15,7 @@ import com.glxp.api.dao.inout.IoOrderDetailCodeDao; import com.glxp.api.entity.auth.InvWarehouseEntity; import com.glxp.api.entity.basic.*; import com.glxp.api.entity.inout.*; +import com.glxp.api.entity.inv.InvProductBatchEntity; import com.glxp.api.entity.inv.InvProductEntity; import com.glxp.api.entity.system.SystemParamConfigEntity; import com.glxp.api.req.basic.FilterCompanyProductRelevanceRequest; @@ -25,6 +26,7 @@ import com.glxp.api.service.basic.*; 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.InvProductBatchService; import com.glxp.api.service.inv.impl.InvProductService; import com.glxp.api.service.inv.impl.InvProductServiceNew; import com.glxp.api.service.system.SystemParamConfigService; @@ -33,6 +35,7 @@ import com.glxp.api.util.udi.FilterUdiUtils; import com.glxp.api.vo.basic.InvProductNewVo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; @@ -82,6 +85,8 @@ public class IoAddInoutService { InvProductService invProductService; @Resource IoCheckInvService checkInvService; + @Autowired + private InvProductBatchService invProductBatchService; //新增扫码单据处理 public BaseResponse dealProcess(IoOrderEntity orderEntity) { @@ -346,56 +351,30 @@ public class IoAddInoutService { //校验库存 for (IoOrderDetailBizEntity bizEntity : bizEntities) { - if (StrUtil.isNotEmpty(bizEntity.getBatchNo())) { - List invProductEntities = invProductService.selectByRelId(bizEntity.getBindRlFk(), bizEntity.getSupId(), null, orderEntity.getInvCode()); - if (CollUtil.isNotEmpty(invProductEntities)) { + List invProductBatchEntities = invProductBatchService.selectByRelId(bizEntity.getBindRlFk(), bizEntity.getSupId(), null, orderEntity.getInvCode(),bizEntity.getBatchNo(),null); + if (CollUtil.isNotEmpty(invProductBatchEntities)) { int count = 0; - for (InvProductEntity invProductEntity : invProductEntities) { - if (invProductEntity.getReCount() + count > IntUtil.value(bizEntity.getCount())) { + for (InvProductBatchEntity invProductBatchEntity : invProductBatchEntities) { + if (invProductBatchEntity.getReCount() + count > IntUtil.value(bizEntity.getCount())) { IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity(); BeanUtils.copyProperties(bizEntity, orderDetailBizEntity); orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId()); + orderDetailBizEntity.setBatchNo(invProductBatchEntity.getBatchNo()); newBizList.add(orderDetailBizEntity); break; } else { - count = invProductEntity.getReCount(); + count = invProductBatchEntity.getReCount(); IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity(); BeanUtils.copyProperties(bizEntity, orderDetailBizEntity); orderDetailBizEntity.setCount(count); orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId()); + orderDetailBizEntity.setBatchNo(invProductBatchEntity.getBatchNo()); newBizList.add(orderDetailBizEntity); } } } else { newBizList.add(bizEntity); } - } else if (StrUtil.isEmpty(bizEntity.getBatchNo())) { - List invProductEntities = invProductService.selectByRelId(bizEntity.getBindRlFk(), bizEntity.getSupId(), null, orderEntity.getInvCode()); - if (CollUtil.isNotEmpty(invProductEntities)) { - int count = 0; - for (InvProductEntity invProductEntity : invProductEntities) { - if (invProductEntity.getReCount() + count > IntUtil.value(bizEntity.getCount())) { - IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity(); - BeanUtils.copyProperties(bizEntity, orderDetailBizEntity); - orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId()); - orderDetailBizEntity.setBatchNo(invProductEntity.getBatchNo()); - newBizList.add(orderDetailBizEntity); - break; - } else { - count = invProductEntity.getReCount(); - IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity(); - BeanUtils.copyProperties(bizEntity, orderDetailBizEntity); - orderDetailBizEntity.setCount(count); - orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId()); - orderDetailBizEntity.setBatchNo(invProductEntity.getBatchNo()); - newBizList.add(orderDetailBizEntity); - } - } - } else { - newBizList.add(bizEntity); - } - } - } orderDetailBizService.deleteByOrderId(orderEntity.getBillNo()); orderDetailBizService.batchInsertBizs(newBizList); diff --git a/src/main/java/com/glxp/api/service/inout/IoGenInvService.java b/src/main/java/com/glxp/api/service/inout/IoGenInvService.java index e4eeb0a79..9fc69c857 100644 --- a/src/main/java/com/glxp/api/service/inout/IoGenInvService.java +++ b/src/main/java/com/glxp/api/service/inout/IoGenInvService.java @@ -77,44 +77,41 @@ public class IoGenInvService { //生成库存产品表 for (IoOrderDetailResultEntity orderDetailResultEntity : orderDetailResultEntities) { - InvProductEntity invProductEntity = invProductService.selectByUnique(orderDetailResultEntity.getBindRlFk(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getPrice()); - if (invProductEntity == null) { - invProductEntity = new InvProductEntity(); - invProductEntity.setRelIdFk(orderDetailResultEntity.getBindRlFk()); - invProductEntity.setNameCode(orderDetailResultEntity.getNameCode()); - invProductEntity.setBatchNo(orderDetailResultEntity.getBatchNo()); - invProductEntity.setProductionDate(orderDetailResultEntity.getProductDate()); - invProductEntity.setExpireDate(orderDetailResultEntity.getExpireDate()); - invProductEntity.setInCount(0); - invProductEntity.setOutCount(0); - invProductEntity.setSupId(orderDetailResultEntity.getSupId()); - invProductEntity.setDeptCode(orderEntity.getDeptCode()); - invProductEntity.setInvCode(orderEntity.getInvCode()); - invProductEntity.setCreateTime(new Date()); - invProductEntity.setUpdateTime(new Date()); - invProductEntity.setPrice(orderDetailResultEntity.getPrice()); + InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(orderDetailResultEntity.getBindRlFk(), + orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getPrice()); + if (invProductBatchEntity == null) { + invProductBatchEntity = new InvProductBatchEntity(); + invProductBatchEntity.setRelIdFk(String.valueOf(orderDetailResultEntity.getBindRlFk())); + invProductBatchEntity.setNameCode(orderDetailResultEntity.getNameCode()); + invProductBatchEntity.setBatchNo(orderDetailResultEntity.getBatchNo()); + invProductBatchEntity.setProductionDate(orderDetailResultEntity.getProductDate()); + invProductBatchEntity.setExpireDate(orderDetailResultEntity.getExpireDate()); + invProductBatchEntity.setOutCount(0); + invProductBatchEntity.setInCount(0); + invProductBatchEntity.setReCount(0); + invProductBatchEntity.setCustomerId(orderDetailResultEntity.getSupId()); + invProductBatchEntity.setDeptCode(orderEntity.getDeptCode()); + invProductBatchEntity.setInvCode(orderEntity.getInvCode()); + invProductBatchEntity.setCreateTime(new Date()); + invProductBatchEntity.setUpdateTime(new Date()); + invProductBatchEntity.setPrice(orderDetailResultEntity.getPrice()); //添加产品表入院批次号 - invProductEntity.setInBatchNo(orderEntity.getBillNo().substring(orderEntity.getBillNo().length() - 12)); - invProductService.insert(invProductEntity); + invProductBatchEntity.setInBatchNo(orderEntity.getBillNo().substring(orderEntity.getBillNo().length() - 12)); } if (orderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { - invProductEntity.setOutCount(invProductEntity.getOutCount() + orderDetailResultEntity.getCount()); + invProductBatchEntity.setOutCount(invProductBatchEntity.getOutCount() + orderDetailResultEntity.getReCount()); } else if (orderEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { - invProductEntity.setInCount(invProductEntity.getInCount() + orderDetailResultEntity.getCount()); + invProductBatchEntity.setInCount(invProductBatchEntity.getInCount() + orderDetailResultEntity.getReCount()); } - invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount()); - invProductEntity.setUpdateTime(new Date()); - invProductService.update(invProductEntity); + invProductBatchEntity.setReCount(invProductBatchEntity.getInCount() - invProductBatchEntity.getOutCount()); + invProductBatchEntity.setUpdateTime(new Date()); - InvProductBatchEntity batchEntity = new InvProductBatchEntity(); - BeanUtils.copyProperties(invProductEntity, batchEntity); - batchEntity.setId(null); - batchEntities.add(batchEntity); + batchEntities.add(invProductBatchEntity); } if (CollUtil.isNotEmpty(batchEntities)) { - invProductBatchService.saveBatch(batchEntities); + invProductBatchService.saveBatchEvent(batchEntities,bussinessTypeEntity.getMainAction()); } BasicBusTypePreEntity basicBusTypePreEntity = basicBusTypePreService.findByOriginAction(orderEntity.getAction()); diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java b/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java index 8c819b6f8..3427c2d66 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java @@ -46,6 +46,7 @@ import com.glxp.api.service.inv.InvPreProductDetailService; import com.glxp.api.service.inv.InvPreProductService; import com.glxp.api.service.inv.InvPreinProductDetailService; import com.glxp.api.service.inv.InvPreinProductService; +import com.glxp.api.service.inv.impl.InvProductBatchService; import com.glxp.api.service.inv.impl.InvProductService; import com.glxp.api.service.inv.impl.InvProductServiceNew; import com.glxp.api.service.system.SyncUploadDataBustypeService; @@ -59,6 +60,7 @@ import com.glxp.api.vo.basic.InvProductNewVo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -112,6 +114,8 @@ public class IoOrderServiceImpl implements IoOrderService { private HttpOkClient httpOkClient; @Resource private BasicCorpDao basicCorpDao; + @Autowired + private InvProductBatchService invProductBatchService; @Override public List selectAll() { @@ -289,23 +293,25 @@ public class IoOrderServiceImpl implements IoOrderService { //删除普通库存 List invProductDetailEntities = invProductServiceNew.selectByOrderIdFk(billNo); if (CollUtil.isNotEmpty(invProductDetailEntities)) { + List batchEntities = new ArrayList<>(); for (InvProductNewVo invProductDetailEntity : invProductDetailEntities) { //更新库存 - InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelIdFk(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice()); - if (invProductEntity != null) { + InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(invProductDetailEntity.getRelIdFk(), + invProductDetailEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getPrice()); + if (invProductBatchEntity != null) { if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) { - int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount(); - invProductEntity.setInCount(count); + int count = invProductBatchEntity.getInCount() - invProductDetailEntity.getReCount(); + invProductBatchEntity.setInCount(count); } else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) { - int count = invProductEntity.getOutCount() - invProductDetailEntity.getReCount(); - invProductEntity.setOutCount(count); + int count = invProductBatchEntity.getOutCount() - invProductDetailEntity.getReCount(); + invProductBatchEntity.setOutCount(count); } - //计算实际数量 - invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount()); - invProductService.update(invProductEntity); + invProductBatchEntity.setReCount(invProductBatchEntity.getInCount() - invProductBatchEntity.getOutCount()); + batchEntities.add(invProductBatchEntity); } } + invProductBatchService.saveBatchEvent(batchEntities,basicBussinessTypeEntity.getMainAction()); } } } @@ -449,21 +455,28 @@ public class IoOrderServiceImpl implements IoOrderService { InvProductNewVo invProductDetailEntity = invProductServiceNew.selectByCode(codeEntity.getOrderId(), codeEntity.getCode(), codeEntity.getPrice()); if (invProductDetailEntity != null) { + + List batchEntities = new ArrayList<>(); + //更新产品表 - InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelIdFk(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), - invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice()); - if (invProductEntity != null) { + InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(invProductDetailEntity.getRelIdFk(), + invProductDetailEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getPrice()); + if (invProductBatchEntity != null) { if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) { - int inCount = invProductEntity.getInCount() - remainScanCount; - invProductEntity.setInCount(inCount); + int count = invProductBatchEntity.getInCount() - remainScanCount; + invProductBatchEntity.setInCount(count); } else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) { - int outCount = invProductEntity.getOutCount() - remainScanCount; - invProductEntity.setOutCount(outCount); + int count = invProductBatchEntity.getOutCount() - remainScanCount; + invProductBatchEntity.setOutCount(count); } - invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount()); + //计算实际数量 + invProductBatchEntity.setReCount(invProductBatchEntity.getInCount() - invProductBatchEntity.getOutCount()); + batchEntities.add(invProductBatchEntity); } - invProductService.update(invProductEntity); + + invProductBatchService.saveBatchEvent(batchEntities,basicBussinessTypeEntity.getMainAction()); } + } @@ -556,20 +569,25 @@ public class IoOrderServiceImpl implements IoOrderService { } else { List invProductDetailEntities = invProductServiceNew.selectByOrderIdFk(billNo); if (CollUtil.isNotEmpty(invProductDetailEntities)) { + List batchEntities = new ArrayList<>(); for (InvProductNewVo invProductDetailEntity : invProductDetailEntities) { - InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelIdFk(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), - invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice()); - - if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) { - int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount(); - invProductEntity.setInCount(count); - } else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) { - int count = invProductEntity.getOutCount() - invProductDetailEntity.getReCount(); - invProductEntity.setOutCount(count); + //更新库存 + InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(invProductDetailEntity.getRelIdFk(), + invProductDetailEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getPrice()); + if (invProductBatchEntity != null) { + if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) { + int count = invProductBatchEntity.getInCount() - invProductDetailEntity.getReCount(); + invProductBatchEntity.setInCount(count); + } else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) { + int count = invProductBatchEntity.getOutCount() - invProductDetailEntity.getReCount(); + invProductBatchEntity.setOutCount(count); + } + //计算实际数量 + invProductBatchEntity.setReCount(invProductBatchEntity.getInCount() - invProductBatchEntity.getOutCount()); + batchEntities.add(invProductBatchEntity); } - invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount()); - invProductService.update(invProductEntity); } + invProductBatchService.saveBatchEvent(batchEntities,bussinessTypeEntity.getMainAction()); } } @@ -1040,7 +1058,7 @@ public class IoOrderServiceImpl implements IoOrderService { } @Override - public IoOrderResponse findByWorkPlaceCode(String workPlaceCode,String getWorkPlaceQueueCode,Long userId,String action,Integer fifoSplitTag) { + public IoOrderResponse findByWorkPlaceCode(String workPlaceCode, String getWorkPlaceQueueCode, Long userId, String action, Integer fifoSplitTag) { //根据用户和状态查找处理中的订单查询单据表 FilterOrderRequest filterOrderRequest = new FilterOrderRequest(); filterOrderRequest.setWorkPlaceCode(workPlaceCode); @@ -1050,11 +1068,11 @@ public class IoOrderServiceImpl implements IoOrderService { filterOrderRequest.setFifoSplitTag(fifoSplitTag); List ioOrderResponses = orderDao.filterList(filterOrderRequest); - if (ioOrderResponses.size() > 0){ + if (ioOrderResponses.size() > 0) { IoOrderResponse ioOrderResponse = ioOrderResponses.get(0); return ioOrderResponse; } - return null; + return null; } @@ -1119,59 +1137,65 @@ public class IoOrderServiceImpl implements IoOrderService { return orderDao.getfilterOrderList(filterOrderRequest); } - public Boolean setInvProductEntityList(List ioOrderDetailResultEntityList, IoOrderEntity ioOrderEntity) { + public Boolean setInvProductEntityList(List ioOrderDetailResultEntityList, IoOrderEntity orderEntity) { + - for (IoOrderDetailResultEntity ioOrderDetailResultEntity : ioOrderDetailResultEntityList) { + for (IoOrderDetailResultEntity orderDetailResultEntity : ioOrderDetailResultEntityList) { //查询该产品是不是存在 - InvProductEntity invProductEntity = invProductService.selectByUnique(ioOrderDetailResultEntity.getBindRlFk(), ioOrderDetailResultEntity.getBatchNo(), - ioOrderDetailResultEntity.getSupId(), ioOrderEntity.getDeptCode(), ioOrderEntity.getInvCode(), ioOrderDetailResultEntity.getPrice()); - if (invProductEntity == null) { - //没有该产品就填充数据 - invProductEntity = new InvProductEntity(); - invProductEntity.setRelIdFk(ioOrderDetailResultEntity.getBindRlFk()); - invProductEntity.setNameCode(ioOrderDetailResultEntity.getNameCode()); - invProductEntity.setBatchNo(ioOrderDetailResultEntity.getBatchNo()); - invProductEntity.setProductionDate(ioOrderDetailResultEntity.getProductDate()); - invProductEntity.setExpireDate(ioOrderDetailResultEntity.getExpireDate()); - invProductEntity.setInCount(0); - invProductEntity.setOutCount(0); - invProductEntity.setSupId(ioOrderDetailResultEntity.getSupId()); - invProductEntity.setDeptCode(ioOrderEntity.getDeptCode()); - invProductEntity.setInvCode(ioOrderEntity.getInvCode()); - invProductEntity.setPrice(ioOrderDetailResultEntity.getPrice()); - invProductEntity.setCreateTime(new Date()); - invProductEntity.setUpdateTime(new Date()); - invProductEntity.setNowStock(0); //现存量 - invProductEntity.setFrozenCount(0); //冻结量 - invProductEntity.setPlanInCount(0);//预计入库量 - invProductEntity.setPlanOutCount(0);//预计出库量 - invProductEntity.setOnWayCount(0);//在途库存 - invProductEntity.setAvailableStock(0);//可用库存 + InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(orderDetailResultEntity.getBindRlFk(), + orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getPrice()); + if (invProductBatchEntity == null) { + invProductBatchEntity = new InvProductBatchEntity(); + invProductBatchEntity.setRelIdFk(String.valueOf(orderDetailResultEntity.getBindRlFk())); + invProductBatchEntity.setNameCode(orderDetailResultEntity.getNameCode()); + invProductBatchEntity.setBatchNo(orderDetailResultEntity.getBatchNo()); + invProductBatchEntity.setProductionDate(orderDetailResultEntity.getProductDate()); + invProductBatchEntity.setExpireDate(orderDetailResultEntity.getExpireDate()); + invProductBatchEntity.setOutCount(0); + invProductBatchEntity.setInCount(0); + invProductBatchEntity.setReCount(0); + invProductBatchEntity.setCustomerId(orderDetailResultEntity.getSupId()); + invProductBatchEntity.setDeptCode(orderEntity.getDeptCode()); + invProductBatchEntity.setInvCode(orderEntity.getInvCode()); + invProductBatchEntity.setCreateTime(new Date()); + invProductBatchEntity.setUpdateTime(new Date()); + invProductBatchEntity.setNowStock(0); //现存量 + invProductBatchEntity.setFrozenCount(0); //冻结量 + invProductBatchEntity.setPlanInCount(0);//预计入库量 + invProductBatchEntity.setPlanOutCount(0);//预计出库量 + invProductBatchEntity.setOnWayCount(0);//在途库存 + invProductBatchEntity.setAvailableStock(0);//可用库存 + invProductBatchEntity.setPrice(orderDetailResultEntity.getPrice()); + //添加产品表入院批次号 + invProductBatchEntity.setInBatchNo(orderEntity.getBillNo().substring(orderEntity.getBillNo().length() - 12)); } - if (ioOrderEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { - //出库 - if (ioOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) { - invProductEntity.setPlanOutCount((invProductEntity.getPlanOutCount() != null ? invProductEntity.getPlanOutCount() : 0) + ioOrderDetailResultEntity.getReCount());//预计出库量 - invProductEntity.setFrozenCount((invProductEntity.getFrozenCount() != null ? invProductEntity.getFrozenCount() : 0) + ioOrderDetailResultEntity.getReCount());//预计出库量 - } else if (ioOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) { - invProductEntity.setPlanOutCount((invProductEntity.getPlanOutCount() != null ? invProductEntity.getPlanOutCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量 - invProductEntity.setFrozenCount((invProductEntity.getFrozenCount() != null ? invProductEntity.getFrozenCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量 + + + if (orderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { + if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) { + invProductBatchEntity.setPlanOutCount((invProductBatchEntity.getPlanOutCount() != null ? invProductBatchEntity.getPlanOutCount() : 0) + orderDetailResultEntity.getReCount());//预计出库量 + invProductBatchEntity.setFrozenCount((invProductBatchEntity.getFrozenCount() != null ? invProductBatchEntity.getFrozenCount() : 0) + orderDetailResultEntity.getReCount());//预计出库量 + } else if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) { + invProductBatchEntity.setPlanOutCount((invProductBatchEntity.getPlanOutCount() != null ? invProductBatchEntity.getPlanOutCount() : 0) - orderDetailResultEntity.getReCount());//预计出库量 + invProductBatchEntity.setFrozenCount((invProductBatchEntity.getFrozenCount() != null ? invProductBatchEntity.getFrozenCount() : 0) - orderDetailResultEntity.getReCount());//预计出库量 } - } else if (ioOrderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { + + } else if (orderEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { //入库 - if (ioOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) { - invProductEntity.setPlanInCount((invProductEntity.getInCount() != null ? invProductEntity.getInCount() : 0) + ioOrderDetailResultEntity.getReCount());//预计出库量 - } else if (ioOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) { - invProductEntity.setPlanInCount((invProductEntity.getInCount() != null ? invProductEntity.getInCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量 + if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) { + invProductBatchEntity.setPlanInCount((invProductBatchEntity.getInCount() != null ? invProductBatchEntity.getInCount() : 0) + orderDetailResultEntity.getReCount());//预计出库量 + } else if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) { + invProductBatchEntity.setPlanInCount((invProductBatchEntity.getInCount() != null ? invProductBatchEntity.getInCount() : 0) - orderDetailResultEntity.getReCount());//预计出库量 } } + + //判断有没有id走插入或者更新方法 - if (invProductEntity.getId() == null) { - invProductService.insert(invProductEntity); + if (invProductBatchEntity.getId() == null) { + invProductBatchService.save(invProductBatchEntity); } else { - invProductService.update(invProductEntity); + invProductBatchService.updateById(invProductBatchEntity); } - } return true; } diff --git a/src/main/java/com/glxp/api/service/inv/impl/InvProductBatchService.java b/src/main/java/com/glxp/api/service/inv/impl/InvProductBatchService.java index e4be38db3..6be0c2d04 100644 --- a/src/main/java/com/glxp/api/service/inv/impl/InvProductBatchService.java +++ b/src/main/java/com/glxp/api/service/inv/impl/InvProductBatchService.java @@ -1,9 +1,14 @@ package com.glxp.api.service.inv.impl; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.glxp.api.constant.ConstantType; import com.glxp.api.dao.inv.InvProductBatchDao; import com.glxp.api.dao.inv.InvProductRecordMapper; +import com.glxp.api.entity.basic.BasicBussinessTypeEntity; +import com.glxp.api.entity.inv.InvProductEntity; import com.glxp.api.entity.inv.InvProductRecord; import com.glxp.api.entity.inv.InventoryBatchAllocation; import com.glxp.api.entity.inout.IoOrderDetailResultEntity; @@ -16,9 +21,13 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Date; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; @Service @@ -27,13 +36,15 @@ public class InvProductBatchService extends ServiceImpl selectBatchesByFIFO(Long productId, Long warehouseId, Integer requiredQuantity) { // 1. 按入库时间正序查询可用批次 - List availableBatches = inventoryBatchMapper.selectList(new LambdaQueryWrapper() + List availableBatches = invProductBatchDao.selectList(new LambdaQueryWrapper() .eq(InvProductBatchEntity::getRelIdFk, productId) .eq(InvProductBatchEntity::getInvCode, warehouseId) .gt(InvProductBatchEntity::getReCount, 0) // 修正:数量大于0的批次 @@ -114,14 +125,11 @@ public class InvProductBatchService extends ServiceImpl items, IoOrderEntity orderDO) { LocalDateTime now = LocalDateTime.now(); for (IoOrderDetailResultEntity item : items) { - List batches = inventoryBatchMapper.selectList( + List batches = invProductBatchDao.selectList( new LambdaQueryWrapper() .eq(InvProductBatchEntity::getRelIdFk, item.getBindRlFk()) .eq(InvProductBatchEntity::getInvCode, orderDO.getWarehouseId()) @@ -223,4 +231,73 @@ public class InvProductBatchService extends ServiceImpl selectByRelId(Long relId, String supId, String deptCode, String invCode, String batchNo, BigDecimal price) { + return invProductBatchDao.selectList(new QueryWrapper() + .eq("relIdFk", relId) + .eq("supId", supId) + .eq(StrUtil.isNotEmpty(deptCode), "deptCode", deptCode) + .eq(StrUtil.isNotEmpty(batchNo), "batch", batchNo) + .eq(price != null, "price", price) + .eq("invCode", invCode).gt("reCount", 0) + .orderByAsc("inBatchNo") + ); + } + + public InvProductBatchEntity selectByUnique(Long relId, String supId, String deptCode, String invCode, String batchNo, BigDecimal price) { + InvProductBatchEntity invProductBatchEntity = invProductBatchDao.selectOne(new QueryWrapper() + .eq("relIdFk", relId) + .eq("supId", supId) + .eq(StrUtil.isNotEmpty(deptCode), "deptCode", deptCode) + .eq(StrUtil.isNotEmpty(batchNo), "batchNo", batchNo) + .eq(price != null, "price", price) + .eq("invCode", invCode).gt("reCount", 0).or().gt("planInCount", 0).or().gt("planOutCount", 0) + .orderByAsc("inBatchNo").last("limit 1")); + return invProductBatchEntity; + } + + public boolean saveBatchEvent(List batchEntities,String mainAction) { + + List invProductSaveOrUpdateBatch = new ArrayList<>(); + + for (int i = 0; i < batchEntities.size(); i++) { + InvProductBatchEntity invProductBatchEntity = batchEntities.get(i); + //检查是否有生成主表 + InvProductEntity invProductEntity = invProductService.selectByUnique(invProductBatchEntity.getRelIdFk(), invProductBatchEntity.getCustomerId(), invProductBatchEntity.getDeptCode(), invProductBatchEntity.getInvCode(), null); + if (invProductEntity == null) { + invProductEntity = new InvProductEntity(); + invProductEntity.setRelIdFk(Long.valueOf(invProductBatchEntity.getRelIdFk())); + invProductEntity.setInCount(0); + invProductEntity.setOutCount(0); + invProductEntity.setReCount(0); + invProductEntity.setSupId(invProductBatchEntity.getCustomerId()); + invProductEntity.setDeptCode(invProductBatchEntity.getDeptCode()); + invProductEntity.setInvCode(invProductBatchEntity.getInvCode()); + } + + if (ConstantType.TYPE_PUT.equals(mainAction)) { + invProductEntity.setInCount(invProductEntity.getInCount() + invProductBatchEntity.getInCount()); + invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount()); + + } else if (ConstantType.TYPE_OUT.equals(mainAction)) { + invProductEntity.setOutCount(invProductEntity.getOutCount() + invProductBatchEntity.getOutCount()); + invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount()); + } + + invProductBatchEntity.setStatus(invProductBatchEntity.getReCount() > 0 ? 1 : 0); + + invProductEntity.setUpdateTime(new Date()); + invProductSaveOrUpdateBatch.add(invProductEntity); + } + invProductService.saveOrUpdateBatch(invProductSaveOrUpdateBatch); + return saveOrUpdateBatch(batchEntities); + } + + public List selectInvProductInfo(String invCode, String invSpaceCode, String relId) { + return invProductBatchDao.selectList(new QueryWrapper() + .eq("relIdFk", relId) + .eq(StrUtil.isNotEmpty(invSpaceCode), "invSpaceCode", invSpaceCode) + .eq(StrUtil.isNotEmpty(invCode), "invCode", invCode) + .orderByAsc("inBatchNo") + ); + } } diff --git a/src/main/java/com/glxp/api/service/inv/impl/InvProductService.java b/src/main/java/com/glxp/api/service/inv/impl/InvProductService.java index f92c1dba2..9d7ea7a71 100644 --- a/src/main/java/com/glxp/api/service/inv/impl/InvProductService.java +++ b/src/main/java/com/glxp/api/service/inv/impl/InvProductService.java @@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import com.glxp.api.dao.inv.InvProductDao; import com.glxp.api.dao.inv.InvProductNewDao; +import com.glxp.api.entity.basic.BasicBussinessTypeEntity; import com.glxp.api.entity.inv.InvProductEntity; +import com.glxp.api.exception.JsonException; import com.glxp.api.req.inv.FilterInvProductRequest; import com.glxp.api.res.inv.InvProductResponse; import org.springframework.stereotype.Service; @@ -38,13 +40,14 @@ public class InvProductService extends ServiceImpl().eq("relIdFk", relId) - .eq(StrUtil.isNotBlank(batchNo), "batchNo", batchNo).isNull(StrUtil.isEmpty(batchNo), "batchNo") - .eq("supId", supId) + public InvProductEntity selectByUnique(String relIdFk, String supId, String deptCode, String invCode, String invSpaceCode) { + return invProductDao.selectOne(new QueryWrapper() + .eq(StrUtil.isNotBlank(relIdFk),"relIdFk", relIdFk) + .eq(StrUtil.isNotBlank(supId),"supId", supId) .eq(StrUtil.isNotBlank(deptCode),"deptCode", deptCode) - .eq("invCode", invCode) - .eq(price != null, "price", price).isNull(price == null, "price").last("limit 1") + .eq(StrUtil.isNotBlank(invCode),"invCode", invCode) + .eq(StrUtil.isNotBlank(invSpaceCode),"invSpaceCode", invSpaceCode) + .last("limit 1") ); } @@ -189,6 +192,19 @@ public class InvProductService extends ServiceImpl filterList(FilterInvRemindMsgRequest filterInvRemindMsgRequest) { @@ -71,38 +78,38 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService { public void createRemindMsg(InvRemindSetEntity invRemindSetEntity) { log.info("库存预警设置:{}", invRemindSetEntity.toString()); //查询库存数量 - List invProductList = invProductDao.selectInvProductInfo(invRemindSetEntity.getInvCode(), invRemindSetEntity.getInvSpaceCode(), invRemindSetEntity.getRelId()); - if (CollUtil.isNotEmpty(invProductList)) { - List invDataList = new CopyOnWriteArrayList<>(invProductList); + List invProductBatchEntityList = invProductBatchService.selectInvProductInfo(invRemindSetEntity.getInvCode(), invRemindSetEntity.getInvSpaceCode(), invRemindSetEntity.getRelId()); + if (CollUtil.isNotEmpty(invProductBatchEntityList)) { + CopyOnWriteArrayList invDataList = new CopyOnWriteArrayList<>(invProductBatchEntityList); - invDataList.parallelStream().forEach(invProductEntity -> { + invDataList.parallelStream().forEach(invProductBatchEntity -> { //查询产品在耗材字典中设置的预警参数 - UdiRelevanceEntity udiRelevanceEntity = udiRelevanceDao.selectRemindParams(invProductEntity.getRelIdFk()); + UdiRelevanceEntity udiRelevanceEntity = udiRelevanceDao.selectRemindParams(Long.valueOf(invProductBatchEntity.getRelIdFk())); if (null == udiRelevanceEntity) { log.info("此库存产品在耗材字典中不存在,无法生成库存数量及近效期相关预警信息"); } else { //初始化查询预警消息参数 FilterInvRemindMsgRequest invRemindMsgRequest = new FilterInvRemindMsgRequest(); - invRemindMsgRequest.setRelId(invProductEntity.getRelIdFk().toString()); - invRemindMsgRequest.setBatchNo(invProductEntity.getBatchNo()); - invRemindMsgRequest.setDeptCode(invProductEntity.getDeptCode()); - invRemindMsgRequest.setInvCode(invProductEntity.getInvCode()); - invRemindMsgRequest.setInvSpaceCode(invProductEntity.getInvSpaceCode()); - invRemindMsgRequest.setSupId(invProductEntity.getSupId()); + invRemindMsgRequest.setRelId(invProductBatchEntity.getRelIdFk().toString()); + invRemindMsgRequest.setBatchNo(invProductBatchEntity.getBatchNo()); + invRemindMsgRequest.setDeptCode(invProductBatchEntity.getDeptCode()); + invRemindMsgRequest.setInvCode(invProductBatchEntity.getInvCode()); + invRemindMsgRequest.setInvSpaceCode(invProductBatchEntity.getInvSpaceCode()); + invRemindMsgRequest.setSupId(invProductBatchEntity.getCustomerId()); //根据预警设置,添加类型参数 if (invRemindSetEntity.getLowStock() && null != invRemindSetEntity.getLowStockNum()) { //开启低库存预警 invRemindMsgRequest.setType("1"); //库存不足预警 - InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); + InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductBatchEntity); //判断是否需要生成/刷新库存预警 - if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invRemindSetEntity.getLowStockNum() > invProductEntity.getReCount()) { + if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invRemindSetEntity.getLowStockNum() > invProductBatchEntity.getReCount()) { //设置预警消息 - msgEntity.setMsg(StrUtil.format("库存数量已不足:{},当前库存数量:{} ", invRemindSetEntity.getLowStockNum(), invProductEntity.getReCount())); + msgEntity.setMsg(StrUtil.format("库存数量已不足:{},当前库存数量:{} ", invRemindSetEntity.getLowStockNum(), invProductBatchEntity.getReCount())); saveMsg(msgEntity); } } else { - String logInfo = invRemindSetEntity.getLowStock() ? "产品 " + invProductEntity.getRelIdFk() + " 未设置低库存预警数量" : "产品 " + invProductEntity.getRelIdFk() + " 未开启低库存预警"; + String logInfo = invRemindSetEntity.getLowStock() ? "产品 " + invProductBatchEntity.getRelIdFk() + " 未设置低库存预警数量" : "产品 " + invProductBatchEntity.getRelIdFk() + " 未开启低库存预警"; log.info(logInfo); } @@ -110,11 +117,11 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService { if (invRemindSetEntity.getLackStock()) { //开启负库存预警 invRemindMsgRequest.setType("2");//库存负数预警 - InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); + InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductBatchEntity); //判断是否需要生成/刷新库存预警 - if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invProductEntity.getReCount() < 0) { + if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invProductBatchEntity.getReCount() < 0) { //设置预警消息 - msgEntity.setMsg(StrUtil.format("库存数量为负,当前库存数量:{}", invProductEntity.getReCount())); + msgEntity.setMsg(StrUtil.format("库存数量为负,当前库存数量:{}", invProductBatchEntity.getReCount())); saveMsg(msgEntity); } } @@ -122,26 +129,26 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService { if (invRemindSetEntity.getOverStock() && null != invRemindSetEntity.getOverStockNum()) { //开启库存积压预警 invRemindMsgRequest.setType("3"); //库存积压预警 - InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); + InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductBatchEntity); //判断是否需要生成/刷新库存预警 - if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invProductEntity.getReCount() > invRemindSetEntity.getOverStockNum()) { + if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invProductBatchEntity.getReCount() > invRemindSetEntity.getOverStockNum()) { //设置预警消息 - msgEntity.setMsg(StrUtil.format("库存积压,当前库存数量:{}", invProductEntity.getReCount())); + msgEntity.setMsg(StrUtil.format("库存积压,当前库存数量:{}", invProductBatchEntity.getReCount())); saveMsg(msgEntity); } } else { - String logInfo = invRemindSetEntity.getOverStock() ? "产品 " + invProductEntity.getRelIdFk() + " 未设置库存积压预警数量" : "产品 " + invProductEntity.getRelIdFk() + " 未开启库存积压预警"; + String logInfo = invRemindSetEntity.getOverStock() ? "产品 " + invProductBatchEntity.getRelIdFk() + " 未设置库存积压预警数量" : "产品 " + invProductBatchEntity.getRelIdFk() + " 未开启库存积压预警"; log.info(logInfo); } if (invRemindSetEntity.getExpireDate()) { //开启产品过期预警 invRemindMsgRequest.setType("4"); //库存过期预警 - InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); + InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductBatchEntity); //判断是否需要生成/刷新库存预警 - if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && StrUtil.isNotBlank(invProductEntity.getExpireDate()) && MsDateUtil.compareExpire(invProductEntity.getExpireDate(), null)) { + if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && StrUtil.isNotBlank(invProductBatchEntity.getExpireDate()) && MsDateUtil.compareExpire(invProductBatchEntity.getExpireDate(), null)) { //设置预警消息 - msgEntity.setMsg(StrUtil.format("产品已过期,产品失效日期:{}", invProductEntity.getExpireDate())); + msgEntity.setMsg(StrUtil.format("产品已过期,产品失效日期:{}", invProductBatchEntity.getExpireDate())); saveMsg(msgEntity); } } @@ -149,20 +156,20 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService { if (invRemindSetEntity.getRecentDate() && null != invRemindSetEntity.getRecentDateTime()) { //开启库存近效期预警 invRemindMsgRequest.setType("5"); //库存近效期预警 - InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); + InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductBatchEntity); //判断是否需要生成/刷新库存预警 - if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && StrUtil.isNotBlank(invProductEntity.getExpireDate())) { + if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && StrUtil.isNotBlank(invProductBatchEntity.getExpireDate())) { //当前时间 - 近效期预警时间 > 产品失效日期,则进行预警 DateTime dateTime = cn.hutool.core.date.DateUtil.offsetHour(new Date(), invRemindSetEntity.getRecentDateTime()); - if (Long.parseLong(dateTime.toString("yyMMdd")) > Long.parseLong(invProductEntity.getExpireDate())) { + if (Long.parseLong(dateTime.toString("yyMMdd")) > Long.parseLong(invProductBatchEntity.getExpireDate())) { //设置预警消息 - msgEntity.setMsg(StrUtil.format("库存即将过期,产品失效日期:{}", invProductEntity.getExpireDate())); + msgEntity.setMsg(StrUtil.format("库存即将过期,产品失效日期:{}", invProductBatchEntity.getExpireDate())); saveMsg(msgEntity); } } } else { - String logInfo = invRemindSetEntity.getRecentDate() ? "产品 " + invProductEntity.getRelIdFk() + " 未设置近效期预警时间" : "产品 " + invProductEntity.getRelIdFk() + " 未开启近效期预警"; + String logInfo = invRemindSetEntity.getRecentDate() ? "产品 " + invProductBatchEntity.getRelIdFk() + " 未设置近效期预警时间" : "产品 " + invProductBatchEntity.getRelIdFk() + " 未开启近效期预警"; log.info(logInfo); } } @@ -220,20 +227,20 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService { * 查询或生成预警消息预警 * * @param invRemindMsgRequest 预警消息查询参数 - * @param invProductEntity 库存产品信息 + * @param invProductBatchEntity 库存产品信息 * @return */ - private InvRemindMsgEntity getInvRemindMsgEntity(FilterInvRemindMsgRequest invRemindMsgRequest, InvProductEntity invProductEntity) { + private InvRemindMsgEntity getInvRemindMsgEntity(FilterInvRemindMsgRequest invRemindMsgRequest, InvProductBatchEntity invProductBatchEntity) { InvRemindMsgEntity msgEntity = invRemindMsgDao.selectRemindMsg(invRemindMsgRequest); if (null == msgEntity) { //数据库不存在对应的预警消息,生成新的预警消息 msgEntity = new InvRemindMsgEntity(); - msgEntity.setRelId(invProductEntity.getRelIdFk().toString()); //耗材字典产品ID - msgEntity.setBatchNo(invProductEntity.getBatchNo()); //批次号 - msgEntity.setSupId(invProductEntity.getSupId()); //供应商ID - msgEntity.setDeptCode(invProductEntity.getDeptCode()); //部门编码 - msgEntity.setInvCode(invProductEntity.getInvCode()); //仓库编码 - msgEntity.setInvSpaceCode(invProductEntity.getInvSpaceCode()); //货位号 + msgEntity.setRelId(invProductBatchEntity.getRelIdFk().toString()); //耗材字典产品ID + msgEntity.setBatchNo(invProductBatchEntity.getBatchNo()); //批次号 + msgEntity.setSupId(invProductBatchEntity.getCustomerId()); //供应商ID + msgEntity.setDeptCode(invProductBatchEntity.getDeptCode()); //部门编码 + msgEntity.setInvCode(invProductBatchEntity.getInvCode()); //仓库编码 + msgEntity.setInvSpaceCode(invProductBatchEntity.getInvSpaceCode()); //货位号 msgEntity.setType(Integer.valueOf(invRemindMsgRequest.getType())); //预警类型 Date date = new Date(); @@ -241,11 +248,11 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService { } //更新预警消息的产品日期,数量等信息 - msgEntity.setProductionDate(invProductEntity.getProductionDate()); - msgEntity.setExpireDate(invProductEntity.getExpireDate()); - msgEntity.setInCount(invProductEntity.getInCount()); - msgEntity.setOutCount(invProductEntity.getOutCount()); - msgEntity.setReCount(invProductEntity.getReCount()); + msgEntity.setProductionDate(invProductBatchEntity.getProductionDate()); + msgEntity.setExpireDate(invProductBatchEntity.getExpireDate()); + msgEntity.setInCount(invProductBatchEntity.getInCount()); + msgEntity.setOutCount(invProductBatchEntity.getOutCount()); + msgEntity.setReCount(invProductBatchEntity.getReCount()); return msgEntity; } diff --git a/src/main/java/com/glxp/api/task/VailInvTask.java b/src/main/java/com/glxp/api/task/VailInvTask.java index 52ba06a00..2dcb13c8b 100644 --- a/src/main/java/com/glxp/api/task/VailInvTask.java +++ b/src/main/java/com/glxp/api/task/VailInvTask.java @@ -4,6 +4,7 @@ import com.glxp.api.common.res.BaseResponse; import com.glxp.api.dao.schedule.ScheduledDao; import com.glxp.api.entity.inv.InvPreProductEntity; import com.glxp.api.entity.inv.InvPreinProductEntity; +import com.glxp.api.entity.inv.InvProductBatchEntity; import com.glxp.api.entity.inv.InvProductEntity; import com.glxp.api.entity.system.ScheduledEntity; import com.glxp.api.http.sync.SpGetHttpClient; @@ -12,6 +13,7 @@ import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.res.inv.InvProductResponse; import com.glxp.api.service.inv.InvPreProductService; import com.glxp.api.service.inv.InvPreinProductService; +import com.glxp.api.service.inv.impl.InvProductBatchService; import com.glxp.api.service.inv.impl.InvProductService; import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.SchedulingConfigurer; @@ -70,6 +72,8 @@ public class VailInvTask implements SchedulingConfigurer { @Resource InvProductService invProductService; @Resource + InvProductBatchService invProductBatchService; + @Resource InvPreinProductService invPreinProductService; @Resource InvPreProductService invPreProductService; @@ -83,9 +87,9 @@ public class VailInvTask implements SchedulingConfigurer { if (baseResponse.getCode() == 20000) { List list = baseResponse.getData().getList(); list.forEach(invProductResponse -> { - InvProductEntity invProductEntity = invProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(), - invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode(), invProductResponse.getPrice()); - if (invProductEntity.getInCount() != invProductResponse.getInCount() || invProductEntity.getOutCount() != invProductResponse.getOutCount()) { + InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), + invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode(), invProductResponse.getBatchNo(), invProductResponse.getPrice()); + if (invProductBatchEntity.getInCount() != invProductResponse.getInCount() || invProductBatchEntity.getOutCount() != invProductResponse.getOutCount()) { buffer.append(invProductResponse.getCpmctymc() + "," + invProductResponse.getNameCode() + "," + invProductResponse.getBatchNo() + "," diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 1cbd17a16..407c3d9d9 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -4,9 +4,9 @@ server: spring: datasource: driver-class-name: com.p6spy.engine.spy.P6SpyDriver - jdbc-url: jdbc:p6spy:mysql://192.168.0.206:3306/udiwms81?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true + jdbc-url: jdbc:p6spy:mysql://192.168.0.66:3306/udi_wms_cl?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true username: root - password: Glxp@6066 + password: 123456 hikari: connection-timeout: 60000 maximum-pool-size: 20 diff --git a/src/main/resources/mybatis/mapper/dev/DeviceMAOrderDetailDao.xml b/src/main/resources/mybatis/mapper/dev/DeviceMAOrderDetailDao.xml index 5f5e3de67..3d6d4f97a 100644 --- a/src/main/resources/mybatis/mapper/dev/DeviceMAOrderDetailDao.xml +++ b/src/main/resources/mybatis/mapper/dev/DeviceMAOrderDetailDao.xml @@ -9,7 +9,7 @@ ip.expireDate, bp.zczbhhzbapzbh, bp.ylqxzcrbarmc - from inv_product ip + from inv_product_batch ip left join basic_udirel bu on bu.id = ip.relIdFk left join basic_products bp on bu.uuid = bp.uuid where ip.relIdFk = #{relId} diff --git a/src/main/resources/mybatis/mapper/dev/InvMAOrderDetailDao.xml b/src/main/resources/mybatis/mapper/dev/InvMAOrderDetailDao.xml index 2910eaf8a..db710ca44 100644 --- a/src/main/resources/mybatis/mapper/dev/InvMAOrderDetailDao.xml +++ b/src/main/resources/mybatis/mapper/dev/InvMAOrderDetailDao.xml @@ -26,7 +26,7 @@ LEFT JOIN basic_products ON basic_products.uuid = basic_udirel.uuid left join inv_product_detail ipd on ipd.relId = mad.relId and ipd.invCode = ma.invCode and ipd.invSpaceCode = ma.invSpaceCode - left join inv_product ip on ipd.relId = ip.relIdFk and ip.batchNo = ipd.batchNo + left join inv_product_batch ip on ipd.relId = ip.relIdFk and ip.batchNo = ipd.batchNo AND mad.orderIdFk = #{orderIdFk} diff --git a/src/main/resources/mybatis/mapper/inv/InvCountOrderDetailMapper.xml b/src/main/resources/mybatis/mapper/inv/InvCountOrderDetailMapper.xml index 117d0d2b6..2f12e00a9 100644 --- a/src/main/resources/mybatis/mapper/inv/InvCountOrderDetailMapper.xml +++ b/src/main/resources/mybatis/mapper/inv/InvCountOrderDetailMapper.xml @@ -48,7 +48,7 @@ select od.*, bps.cpmctymc productName, bps.ggxh, bps.ylqxzcrbarmc, bps.zczbhhzbapzbh from inv_count_order_detail od left join inv_count_order ico on od.orderIdFk = ico.orderId - left join inv_product ip on od.productId = ip.relIdFk + left join inv_product_batch ip on od.productId = ip.relIdFk left join basic_products bps on od.nameCode = bps.nameCode where od.orderIdFk = #{orderIdFk} group by od.id diff --git a/src/main/resources/mybatis/mapper/inv/InvProductNewDao.xml b/src/main/resources/mybatis/mapper/inv/InvProductNewDao.xml index b4d2c8d9c..1cf461869 100644 --- a/src/main/resources/mybatis/mapper/inv/InvProductNewDao.xml +++ b/src/main/resources/mybatis/mapper/inv/InvProductNewDao.xml @@ -43,7 +43,7 @@ bp.majorStatus, bp.physicType, bp.medicareType - from inv_product ipp + from inv_product_batch ipp inner join basic_udirel on ipp.relIdFk = basic_udirel.id inner join basic_products bp on basic_udirel.uuid = bp.uuid left join basic_corp on ipp.supId = basic_corp.erpId @@ -212,7 +212,7 @@ ad.name deptName, aw.name invName, sp.name invSpaceName - from inv_product pd + from inv_product_batch pd left join basic_udirel bu on pd.relIdFk = bu.id left join basic_products bp on bp.uuid = bu.uuid left join auth_dept ad on pd.deptCode = ad.code @@ -257,7 +257,7 @@ inCount, outCount, reCount - from inv_product pd + from inv_product_batch pd left join basic_udirel bu on pd.relIdFk = bu.id left join basic_products bp on bp.uuid = bu.uuid left join auth_dept ad on pd.deptCode = ad.code @@ -320,7 +320,7 @@ @@ -344,7 +344,7 @@ bp.manufactory, corp.name AS supName FROM - inv_product t1 + inv_product_batch t1 LEFT JOIN basic_udirel bu ON bu.id = t1.relIdFk LEFT JOIN basic_products bp ON bp.uuid = bu.uuid LEFT JOIN auth_dept dept ON dept.code = t1.deptCode diff --git a/src/main/resources/mybatis/mapper/inv/InvRemindSetDao.xml b/src/main/resources/mybatis/mapper/inv/InvRemindSetDao.xml index 8ca228cc9..258430d95 100644 --- a/src/main/resources/mybatis/mapper/inv/InvRemindSetDao.xml +++ b/src/main/resources/mybatis/mapper/inv/InvRemindSetDao.xml @@ -62,7 +62,7 @@ bp.ggxh, bp.cpmctymc AS productName FROM - inv_product ip + inv_product_batch ip LEFT JOIN basic_udirel bu ON ip.relIdFk = bu.id LEFT JOIN basic_products bp ON bu.uuid = bp.uuid LEFT JOIN inv_product_detail ipd diff --git a/src/main/resources/mybatis/mapper/inv/invProductDao.xml b/src/main/resources/mybatis/mapper/inv/invProductDao.xml index e3fdbf539..fb547802a 100644 --- a/src/main/resources/mybatis/mapper/inv/invProductDao.xml +++ b/src/main/resources/mybatis/mapper/inv/invProductDao.xml @@ -52,7 +52,7 @@ bp.basicPrductRemak8, bp.packUnit, ip.price - from inv_product ip + from inv_product_batch ip INNER JOIN basic_products bp ON ip.relIdFk = (SELECT id FROM basic_udirel WHERE uuid = bp.uuid limit 1) LEFT JOIN basic_corp ON ip.supId = basic_corp.erpId LEFT JOIN auth_dept ON auth_dept.CODE = ip.deptCode @@ -172,7 +172,7 @@ sum(ip.inCount) inCount, sum(ip.outCount) outCount, sum(ip.reCount) reCount - from inv_product ip + from inv_product_batch ip inner join basic_udirel bu on ip.relIdFk = bu.id inner join basic_products bp on bu.uuid = bp.uuid left join basic_corp bc on ip.supId = bc.erpId @@ -265,7 +265,7 @@ select ip.relIdFk, bp.cpmctymc, bp.ggxh, bp.ylqxzcrbarmc, bp.zczbhhzbapzbh - from inv_product ip + from inv_product_batch ip left join inv_product_detail ipd on ip.relIdFk = ipd.relId and ip.invCode = ipd.invCode and ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty') left join basic_udirel bu on bu.id = ip.relIdFk @@ -402,7 +402,7 @@ ip.deptCode, ip.price, ip.invCode - from inv_product ip + from inv_product_batch ip inner join basic_udirel on ip.relIdFk = basic_udirel.id inner join basic_products bp on basic_udirel.uuid = bp.uuid left join basic_corp on ip.supId = basic_corp.erpId @@ -492,7 +492,7 @@ ip.deptCode, ip.price, ip.invCode - from inv_product ip + from inv_product_batch ip inner join basic_udirel on ip.relIdFk = basic_udirel.id inner join basic_products bp on basic_udirel.uuid = bp.uuid left join basic_corp on ip.supId = basic_corp.erpId @@ -591,7 +591,7 @@