From 448f05caae6dc3d985f5897a4a12c5c6296347d0 Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Mon, 1 Jul 2024 08:35:07 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E4=BB=93=E5=BA=93=E7=AE=A1=E7=90=86?= =?UTF-8?q?=20=20=E5=93=81=E8=B4=A8=E7=AE=A1=E7=90=86=20=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E6=9A=82=E6=94=B6=20=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=E4=B8=BB=E8=A1=A8=E5=AE=9E=E9=99=85?= =?UTF-8?q?=E5=88=B0=E8=B4=A7=E6=95=B0=E7=9A=84=E8=AE=A1=E7=AE=97=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=85=A5=E5=BA=93=E5=8D=95=E4=B8=BB?= =?UTF-8?q?=E8=A1=A8=E6=9A=82=E6=94=B6=E5=90=88=E6=A0=BC=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=20=E6=96=B0=E5=A2=9E=20=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=8D=95=E4=B8=BB=E8=A1=A8=E6=9A=82=E6=94=B6=E4=B8=8D=E5=90=88?= =?UTF-8?q?=E6=A0=BC=E6=95=B0=E7=9A=84=E8=AE=A1=E7=AE=97=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20=E5=85=A5=E5=BA=93=E5=8D=95=E4=B8=BB=E8=A1=A8?= =?UTF-8?q?=E6=9A=82=E6=94=B6=E5=90=88=E6=A0=BC=E6=95=B0=E5=92=8C=E5=AE=9E?= =?UTF-8?q?=E9=99=85=E5=88=B0=E8=B4=A7=E6=95=B0=E5=A4=A7=E5=B0=8F=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 入库单子表暂收合格数和实际到货数大小校验 修改采购入库单转品质单后端接口 --- .../service/impl/QualityOrderServiceImpl.java | 8 +- .../WarehouseStorageOrderController.java | 2 +- .../IWarehouseStorageOrderService.java | 5 ++ .../WarehouseStorageOrderServiceImpl.java | 75 +++++++++++++++++++ 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java index 346ccf47..c63bacec 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java @@ -193,10 +193,12 @@ public class QualityOrderServiceImpl implements IQualityOrderService qualityOrder.setQualityStatus("0"); qualityOrder.setQualityOrderType("0"); qualityOrder.setQualityStorageStatus("0"); - qualityOrder.setThisArrivedNum(warehouseStorageOrder.getActualArrivedNum()); + //qualityOrder.setThisArrivedNum(warehouseStorageOrder.getActualArrivedNum()); qualityOrder.setWarehouseCode(warehouseStorageOrder.getWarehouseCode()); qualityOrder.setWarehouseName(warehouseStorageOrder.getWarehouseName()); qualityOrder.setDeliveryInspectionTime(warehouseStorageOrder.getDeliveryInspectionTime()); + qualityOrder.setCreateBy(ShiroUtils.getLoginName()); + qualityOrder.setCreateTime(new Date()); qualityOrderMapper.insertQualityOrder(qualityOrder); @@ -211,6 +213,7 @@ public class QualityOrderServiceImpl implements IQualityOrderService } + //品质单不合格分类表 private void insertQualityOrderUnqualifiedByWarehouseStorageOrder( WarehouseStorageOrderDetail warehouseStorageOrderDetail) { QualityOrderReportUnqualified qualityOrderReportUnqualified = new QualityOrderReportUnqualified(); //插入品质报告不合格数 @@ -224,6 +227,7 @@ public class QualityOrderServiceImpl implements IQualityOrderService } + //品质单报告表 private void insertQualityOrderReportByWarehouseStorageOrder(WarehouseStorageOrderDetail warehouseStorageOrderDetail) { QualityOrderReport qualityOrderReport = new QualityOrderReport(); //插入品质单报告开始品质单 @@ -237,6 +241,7 @@ public class QualityOrderServiceImpl implements IQualityOrderService orderReportMapper.insertQualityOrderReport(qualityOrderReport); } + //品质单详情表 private void insertQualityOrderDetailByWarehouseStorageOrder(WarehouseStorageOrder warehouseStorageOrder, WarehouseStorageOrderDetail warehouseStorageOrderDetail, String qualityOrderCode) { QualityOrderDetail qualityOrderDetail = new QualityOrderDetail(); @@ -253,6 +258,7 @@ public class QualityOrderServiceImpl implements IQualityOrderService qualityOrderDetail.setMaterialDescribe(warehouseStorageOrderDetail.getMaterialDescribe()); qualityOrderDetail.setMaterialName(warehouseStorageOrderDetail.getMaterialName()); qualityOrderDetail.setMaterialProcessMethod(warehouseStorageOrderDetail.getMaterialProcessMethod()); + //To do 缺少入库部门 ,如果后续需要从这里添加 qualityOrderDetail.setMaterialPhotourl(warehouseStorageOrderDetail.getMaterialPhotourl()); qualityOrderDetail.setMaterialUnit(warehouseStorageOrderDetail.getMaterialUnit()); qualityOrderDetail.setMaterialType(warehouseStorageOrderDetail.getMaterialType()); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseStorageOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseStorageOrderController.java index 31ac1158..8f0f9db3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseStorageOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseStorageOrderController.java @@ -198,7 +198,7 @@ public class WarehouseStorageOrderController extends BaseController @ResponseBody public AjaxResult temporaryPurchaseSave(@RequestBody WarehouseStorageOrder warehouseStorageOrder) { - return toAjax(warehouseStorageOrderService.temporaryPurchaseWarehouseStorageOrder(warehouseStorageOrder)); + return toAjax(warehouseStorageOrderService.temporaryPurchaseSave(warehouseStorageOrder)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseStorageOrderService.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseStorageOrderService.java index ed39e981..b5a58bda 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseStorageOrderService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseStorageOrderService.java @@ -93,4 +93,9 @@ public interface IWarehouseStorageOrderService * 入库-采购单(采购入库) * */ int storagePurchaseWarehouseStorageOrder(WarehouseStorageOrder warehouseStorageOrder); + + /** + * 修改保存暂收-采购单(采购入库) + * */ + int temporaryPurchaseSave(WarehouseStorageOrder warehouseStorageOrder); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseStorageOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseStorageOrderServiceImpl.java index 25e950ed..c28f9ac2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseStorageOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseStorageOrderServiceImpl.java @@ -165,6 +165,7 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS warehouseStorageOrder.setUpdateBy(loginName); warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); warehouseStorageOrder.setWarehouseStorageStatus("1"); + warehouseStorageOrder.setWarehouseEmployee(loginName); //设置暂存时间 warehouseStorageOrder.setTemporaryTime(new Date()); updateWarehouseStorageOrderDetails(warehouseStorageOrder); @@ -250,6 +251,80 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS return updateResult; } + /** + * 修改保存暂收-采购单(采购入库) + * */ + @Transactional(rollbackFor = Exception.class) + @Override + public int temporaryPurchaseSave(WarehouseStorageOrder warehouseStorageOrder) { + + String loginName = ShiroUtils.getLoginName(); + warehouseStorageOrder.setUpdateBy(loginName); + warehouseStorageOrder.setUpdateTime(DateUtils.getNowDate()); + //改变状态为已暂收 + warehouseStorageOrder.setWarehouseStorageStatus("1"); + //设置品质状态,为待品质 + warehouseStorageOrder.setWarehouseQualityStatus("0"); + warehouseStorageOrder.setWarehouseEmployee(loginName); + List warehouseStorageOrderDetailList = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); + //入库单主表的实际到货数为子表的合计 + int actualArriveNum = warehouseStorageOrderDetailList.stream().mapToInt(WarehouseStorageOrderDetail::getActualArriveNum).sum(); + //入库单主表的暂收合格数为子表的合计 + int temporaryQualifiedNum = warehouseStorageOrderDetailList.stream().mapToInt(WarehouseStorageOrderDetail::getTemporaryQualifiedNum).sum(); + if (actualArriveNum < temporaryQualifiedNum) { + throw new BusinessException("暂收合格数不能大于实际到货数"); + } + + //插入实际到货数 + warehouseStorageOrder.setActualArrivedNum(actualArriveNum); + //插入暂收合格数 + warehouseStorageOrder.setTemporaryQualifiedNum(temporaryQualifiedNum); + //插入暂收不合格数 + warehouseStorageOrder.setTemporaryUnqualifiedNum(Math.max(0, actualArriveNum - temporaryQualifiedNum)); + //设置暂存时间 + warehouseStorageOrder.setTemporaryTime(new Date()); + int updateDetailResult = updateTemporaryPurchaseDetails(warehouseStorageOrder); + if (updateDetailResult != warehouseStorageOrder.getWarehouseStorageOrderDetailList().size()) { + throw new BusinessException("更新入库单明细记录失败"); + } + int updateResult = warehouseStorageOrderMapper.updateWarehouseStorageOrder(warehouseStorageOrder); + if (updateResult <= 0) { + throw new BusinessException("更新入库单主记录失败"); + } + + try { + qualityOrderService.insertQualityOrderByWarehouseStorageOrder(warehouseStorageOrder, warehouseStorageOrder.getWarehouseStorageOrderDetailList()); + } catch (Exception e) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + log.error("生成品质单时发生错误", e); + throw new BusinessException("生成品质单时发生错误"); + } + + return updateResult; + } + + /** + * 修改保存暂收-采购单(采购入库) 子表数据 + * */ + private int updateTemporaryPurchaseDetails(WarehouseStorageOrder warehouseStorageOrder) { + int updateResultDetails = 0; + List details = warehouseStorageOrder.getWarehouseStorageOrderDetailList(); + if (org.springframework.util.CollectionUtils.isEmpty(details)){ + return 0; + } + for (WarehouseStorageOrderDetail detail : details) { + detail.setWarehouseStorageCode(warehouseStorageOrder.getWarehouseStorageCode()); + Integer actualArriveNum = detail.getActualArriveNum(); + Integer temporaryQualifiedNum = detail.getTemporaryQualifiedNum(); + if (actualArriveNum < temporaryQualifiedNum){ + throw new BusinessException("暂收合格数要小于等于实际到货数"); + } + updateResultDetails += storageOrderDetailMapper.updateWarehouseStorageOrderDetailByObject(detail); + } + return updateResultDetails; + } + + /* * 更新仓库入库单详情的数据 * */