From 1514065484f4f3c5c1cc7d542e5600c82c1cf145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=98=8E=E6=A2=81?= <2429105222@qq.com> Date: Fri, 11 Aug 2023 16:39:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E5=AD=98=E4=BB=A3=E7=A0=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../glxp/api/entity/inv/InvProductEntity.java | 31 ++++++++ .../service/inout/IoCheckInoutService.java | 5 +- .../api/service/inout/IoOrderService.java | 3 + .../inout/impl/IoOrderServiceImpl.java | 73 +++++++++++++++++++ .../service/inv/InvPreinProductService.java | 2 + .../api/service/inv/InvProductService.java | 2 + .../inv/impl/InvPreinProductServiceImpl.java | 7 ++ .../inv/impl/InvProductServiceImpl.java | 6 ++ 8 files changed, 128 insertions(+), 1 deletion(-) 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 75c99f7ac..f1cfb4375 100644 --- a/src/main/java/com/glxp/api/entity/inv/InvProductEntity.java +++ b/src/main/java/com/glxp/api/entity/inv/InvProductEntity.java @@ -105,5 +105,36 @@ 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; + } diff --git a/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java b/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java index 079d0d683..6149a18cb 100644 --- a/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java +++ b/src/main/java/com/glxp/api/service/inout/IoCheckInoutService.java @@ -426,6 +426,8 @@ public class IoCheckInoutService { orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST); orderEntity.setUpdateTime(new Date()); orderService.update(orderEntity); + //生成预存的库存 + orderService.updateOrderInventory(orderEntity.getBillNo(),orderEntity.getStatus()); genLostCode(orderEntity.getBillNo()); checkThird(orderEntity); } @@ -540,7 +542,7 @@ public class IoCheckInoutService { orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST); orderEntity.setUpdateTime(new Date()); orderService.update(orderEntity); - + orderService.updateOrderInventory(orderEntity.getBillNo(),orderEntity.getStatus()); //生成缺失码 genLostCode(orderEntity.getBillNo()); @@ -1051,6 +1053,7 @@ public class IoCheckInoutService { genInvService.genPreInv(orderEntity.getBillNo()); } else { genInvService.genNorInv(orderEntity.getBillNo()); + orderService.updateOrderInventory(orderEntity.getBillNo(),orderEntity.getStatus()); } } else { //不入库存,直接进行单据流转 diff --git a/src/main/java/com/glxp/api/service/inout/IoOrderService.java b/src/main/java/com/glxp/api/service/inout/IoOrderService.java index 90ceb2977..2c29c59a0 100644 --- a/src/main/java/com/glxp/api/service/inout/IoOrderService.java +++ b/src/main/java/com/glxp/api/service/inout/IoOrderService.java @@ -149,4 +149,7 @@ public interface IoOrderService { List selectOrderIdList(@Param("data") String data); + void updateOrderInventory(String billNo,Integer status); + + } 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 5cebaac78..e12d8bb59 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 @@ -22,6 +22,7 @@ import com.glxp.api.dao.basic.BasicCorpDao; import com.glxp.api.dao.inout.IoOrderDao; import com.glxp.api.dao.thrsys.ThrSystemBusApiDao; import com.glxp.api.dao.thrsys.ThrSystemDao; +import com.glxp.api.entity.auth.InvWarehouseEntity; import com.glxp.api.entity.basic.BasicBussinessTypeEntity; import com.glxp.api.entity.basic.BasicCorpEntity; import com.glxp.api.entity.inout.*; @@ -969,6 +970,24 @@ public class IoOrderServiceImpl implements IoOrderService { return orderDao.selectOrderIdList(data); } + @Override + public void updateOrderInventory(String billNo, Integer status) { + //查询单据表 + QueryWrapper ew = new QueryWrapper<>(); + ew.eq("billNo", billNo); + IoOrderEntity ioOrderEntity = orderDao.selectVoOne(ew); + //查询单据result表 + List ioOrderDetailResultEntityList = ioOrderDetailResultService.findByOrderId(billNo); + //查询产库信息 + InvWarehouseEntity invWarehouseEntity = invWarehouseDao.filterGroupInvSubAndcode(ioOrderEntity.getInvCode()); + if (ioOrderEntity != null && invWarehouseEntity != null) { + //判断是哪个类型的库存 + if (invWarehouseEntity.getAdvanceType() == ConstantStatus.ACTION_TYPE_NORMAL) { + setInvProductEntityList(ioOrderDetailResultEntityList, ioOrderEntity.getMainAction(), status); + } + } + } + /** * 查询此单据关联的所有单据 * @@ -1072,4 +1091,58 @@ public class IoOrderServiceImpl implements IoOrderService { return orderDao.getfilterOrderList(filterOrderRequest); } + public Boolean setInvProductEntityList(List ioOrderDetailResultEntityList, String mainAction, Integer status) { + + for (IoOrderDetailResultEntity ioOrderDetailResultEntity : ioOrderDetailResultEntityList) { + //查询该产品是不是存在 + InvProductEntity invProductEntity = invProductService.selectByUnique(ioOrderDetailResultEntity.getBindRlFk(), ioOrderDetailResultEntity.getBatchNo(), ioOrderDetailResultEntity.getSupId()); + 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(ioOrderDetailResultEntity.getDeptCode()); + 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);//可用库存 + } + if (mainAction.equals(ConstantType.TYPE_PUT)) { + //出库 + if (status == 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 (status == ConstantStatus.ORDER_STATUS_AUDITED) { + invProductEntity.setPlanOutCount((invProductEntity.getPlanOutCount() != null ? invProductEntity.getPlanOutCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量 + invProductEntity.setFrozenCount((invProductEntity.getFrozenCount() != null ? invProductEntity.getFrozenCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量 + } + } else if (mainAction.equals(ConstantType.TYPE_OUT)) { + //入库 + if (status == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) { + invProductEntity.setPlanInCount((invProductEntity.getInCount() != null ? invProductEntity.getInCount() : 0) + ioOrderDetailResultEntity.getReCount());//预计出库量 + } else if (status == ConstantStatus.ORDER_STATUS_AUDITED) { + invProductEntity.setPlanInCount((invProductEntity.getInCount() != null ? invProductEntity.getInCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量 + } + } + //判断有没有id走插入或者更新方法 + if (invProductEntity.getId() == null) { + invProductService.insert(invProductEntity); + } else { + invProductService.update(invProductEntity); + } + + } + return true; + } + } diff --git a/src/main/java/com/glxp/api/service/inv/InvPreinProductService.java b/src/main/java/com/glxp/api/service/inv/InvPreinProductService.java index 9f3121129..4f460fcec 100644 --- a/src/main/java/com/glxp/api/service/inv/InvPreinProductService.java +++ b/src/main/java/com/glxp/api/service/inv/InvPreinProductService.java @@ -18,6 +18,8 @@ public interface InvPreinProductService { InvPreinProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode); + InvPreinProductEntity selectByUnique(Long relId, String batchNo, String supId); + boolean deleteById(Integer id); /** diff --git a/src/main/java/com/glxp/api/service/inv/InvProductService.java b/src/main/java/com/glxp/api/service/inv/InvProductService.java index 7e2b64c0b..fb2120985 100644 --- a/src/main/java/com/glxp/api/service/inv/InvProductService.java +++ b/src/main/java/com/glxp/api/service/inv/InvProductService.java @@ -17,6 +17,8 @@ public interface InvProductService { InvProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode); + InvProductEntity selectByUnique(Long relId, String batchNo, String supId); + /** * 库存查询 * diff --git a/src/main/java/com/glxp/api/service/inv/impl/InvPreinProductServiceImpl.java b/src/main/java/com/glxp/api/service/inv/impl/InvPreinProductServiceImpl.java index b19b7c4bf..5ebfa831f 100644 --- a/src/main/java/com/glxp/api/service/inv/impl/InvPreinProductServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inv/impl/InvPreinProductServiceImpl.java @@ -41,6 +41,13 @@ public class InvPreinProductServiceImpl implements InvPreinProductService { } + @Override + public InvPreinProductEntity selectByUnique(Long relId, String batchNo, String supId) { + return invPreinProductDao.selectOne(new QueryWrapper().eq("relIdFk", relId).eq(StrUtil.isNotEmpty(batchNo), "batchNo", batchNo) + .isNull(StrUtil.isEmpty(batchNo), "batchNo").eq("supId", supId)); + + } + @Override public boolean deleteById(Integer id) { return invPreinProductDao.deleteById(id) == 1 ? true : false; diff --git a/src/main/java/com/glxp/api/service/inv/impl/InvProductServiceImpl.java b/src/main/java/com/glxp/api/service/inv/impl/InvProductServiceImpl.java index 7d5629767..111ef36a7 100644 --- a/src/main/java/com/glxp/api/service/inv/impl/InvProductServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inv/impl/InvProductServiceImpl.java @@ -47,6 +47,12 @@ public class InvProductServiceImpl implements InvProductService { .isNull(StrUtil.isEmpty(batchNo), "batchNo").eq("supId", supId).eq("deptCode", deptCode).eq("invCode", invCode)); } + @Override + public InvProductEntity selectByUnique(Long relId, String batchNo, String supId) { + return invProductDao.selectOne(new QueryWrapper().eq("relIdFk", relId).eq(StrUtil.isNotEmpty(batchNo), "batchNo", batchNo) + .isNull(StrUtil.isEmpty(batchNo), "batchNo").eq("supId", supId)); + } + @Override public List filterList(FilterInvProductRequest filterInvProductRequest) { if (null == filterInvProductRequest) {