From f7d508d33fa45d760ec3e08772bd6a6dcbe29bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=99=93=E8=BF=AA?= <2596750866@qq.com> Date: Wed, 9 Oct 2024 17:21:00 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E4=BB=93=E5=BA=93=E7=AE=A1=E7=90=86?= =?UTF-8?q?=20=E5=87=BA=E5=BA=93=E5=8D=95=20=E6=96=B0=E5=A2=9E=E5=A7=94?= =?UTF-8?q?=E5=A4=96=E5=8D=95=E5=87=BA=E5=BA=93=E9=A1=B5=E9=9D=A2=E5=92=8C?= =?UTF-8?q?=E5=A7=94=E5=A4=96=E5=8D=95=E5=87=BA=E5=BA=93=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=EF=BC=9B=20=E4=BF=AE=E6=94=B9=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E5=8D=95=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E8=A1=A5=E5=85=A8=E6=8C=89=E9=92=AE=EF=BC=9B=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=87=BA=E5=BA=93=E5=8D=95=E5=87=BA=E5=BA=93controlle?= =?UTF-8?q?r=E3=80=81service=E6=96=B9=E6=B3=95=EF=BC=8C=E8=A1=A5=E5=85=A8?= =?UTF-8?q?=E5=87=BA=E5=BA=93=E7=B1=BB=E5=9E=8B=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=9F=A5=E8=AF=A2=E3=80=81=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E7=9B=B8=E5=85=B3=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WarehouseOutOrderController.java | 49 ++- .../impl/WarehouseOutOrderServiceImpl.java | 381 +++++++++++++++++- .../outsourceOutWarehouse.html | 210 ++++++++++ .../outsourceOutWarehouseDetail.html | 197 +++++++++ .../warehouseOutOrder/warehouseOutOrder.html | 21 + 5 files changed, 825 insertions(+), 33 deletions(-) create mode 100644 ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/outsourceOutWarehouse.html create mode 100644 ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/outsourceOutWarehouseDetail.html diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseOutOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseOutOrderController.java index 1fd99ff6..567f38b4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseOutOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseOutOrderController.java @@ -247,6 +247,40 @@ public class WarehouseOutOrderController extends BaseController } + /** + * 委外单-出库 + */ + @GetMapping("/outsourceOutWarehouse/{outOrderId}") + public String outsourceOutWarehouse(@PathVariable("outOrderId") Long outOrderId, ModelMap mmap) + { + WarehouseOutOrder warehouseOutOrder = warehouseOutOrderService.selectWarehouseOutOrderById(outOrderId); + mmap.put("warehouseOutOrder", warehouseOutOrder); + return prefix + "/outsourceOutWarehouse"; + } + + /** + * 修改保存委外单-出库 + */ + @RequiresPermissions("warehouse:warehouseOutOrder:outsourceOutWarehouse") + @Log(title = "仓库出库单", businessType = BusinessType.UPDATE) + @PostMapping("/outsourceOutWarehouse") + @ResponseBody + public AjaxResult outsourceOutWarehouseSave(@RequestBody WarehouseOutOrder warehouseOutOrder) + { + return toAjax(warehouseOutOrderService.updateOutsourceOutWarehouse(warehouseOutOrder)); + } + + + /** + * 委外单-出库详情 + */ + @GetMapping("/outsourceOutWarehouseDetail/{outOrderId}") + public String outsourceOutWarehouseDetail(@PathVariable("outOrderId") Long outOrderId, ModelMap mmap) + { + WarehouseOutOrder warehouseOutOrder = warehouseOutOrderService.selectWarehouseOutOrderById(outOrderId); + mmap.put("warehouseOutOrder", warehouseOutOrder); + return prefix + "/outsourceOutWarehouseDetail"; + } /** * 生产单-出库 */ @@ -282,19 +316,6 @@ public class WarehouseOutOrderController extends BaseController return prefix + "/makeOutWarehouseDetail"; } - /** - * 修改保存生产单-出库详情 - */ - @RequiresPermissions("warehouse:warehouseOutOrder:makeOutWarehouseDetail") - @Log(title = "仓库出库单", businessType = BusinessType.UPDATE) - @PostMapping("/makeOutWarehouseDetail") - @ResponseBody - public AjaxResult makeOutWarehouseDetailSave(@RequestBody WarehouseOutOrder warehouseOutOrder) - { - return toAjax(warehouseOutOrderService.generalUpdateWarehouseOutOrder(warehouseOutOrder)); - } - - /** * 生产单-出库 */ @@ -340,7 +361,7 @@ public class WarehouseOutOrderController extends BaseController @ResponseBody public AjaxResult requisitioningOutWarehouseSave(@RequestBody WarehouseOutOrder warehouseOutOrder) { - return toAjax(warehouseOutOrderService.updatePrepareMaterial(warehouseOutOrder)); + return toAjax(warehouseOutOrderService.updateRequisitionOutWarehouse(warehouseOutOrder)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java index 496927f8..f87a45a1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.warehouse.service.impl; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -8,25 +9,25 @@ import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.erp.domain.ErpDevelopModifyorder; import com.ruoyi.erp.domain.ErpDevelopModifyorderPicking; import com.ruoyi.erp.domain.ErpDevelopModifyorderPickingDetail; import com.ruoyi.erp.domain.vo.ErpDevelopModifyorderPickingVo; -import com.ruoyi.erp.mapper.ErpDevelopModifyorderDetailMapper; import com.ruoyi.erp.mapper.ErpDevelopModifyorderPickingDetailMapper; import com.ruoyi.erp.mapper.ErpDevelopModifyorderPickingMapper; +import com.ruoyi.quality.domain.QualityRefundsExchanges; +import com.ruoyi.quality.mapper.QualityRefundsExchangesMapper; import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.Vo.BaseEmpRequisiteOrderVO; +import com.ruoyi.system.domain.Vo.OutsourceRequisitionVO; import com.ruoyi.system.mapper.*; -import com.ruoyi.warehouse.domain.WarehouseOutOrderDetail; -import com.ruoyi.warehouse.domain.WarehouseStorageOrder; -import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; +import com.ruoyi.warehouse.domain.*; +import com.ruoyi.warehouse.mapper.WarehouseInventoryInquiryDetailMapper; +import com.ruoyi.warehouse.mapper.WarehouseInventoryInquiryMapper; import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper; -import com.ruoyi.warehouse.domain.WarehouseOutOrder; import com.ruoyi.warehouse.service.IWarehouseOutOrderService; import com.ruoyi.common.core.text.Convert; import org.springframework.transaction.annotation.Transactional; @@ -79,6 +80,20 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService @Autowired private ErpDevelopModifyorderPickingMapper modifyorderPickingMapper; + @Autowired + private WarehouseInventoryInquiryMapper inventoryInquiryMapper; + + @Autowired + private WarehouseInventoryInquiryDetailMapper inventoryInquiryDetailMapper; + + @Autowired + private OutsourceRequisitionMapper requisitionMapper; + + @Autowired + private BaseEmpRequisiteOrderMapper empRequisiteOrderMapper; + + @Autowired + private QualityRefundsExchangesMapper refundsExchangesMapper; /** * 查询仓库出库单 @@ -237,7 +252,7 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService String loginName = ShiroUtils.getLoginName(); warehouseOutOrder.setUpdateBy(loginName); - warehouseOutOrder.setUpdateTime(new Date()); + warehouseOutOrder.setUpdateTime(DateUtils.getNowDate()); //设置为已出库 warehouseOutOrder.setWarehouseOutStatus("7"); @@ -273,6 +288,24 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService int updateWarehouseOutOrderDetailResult = outOrderDetailMapper.updateWarehouseOutOrderDetail(warehouseOutOrderDetail); if (updateWarehouseOutOrderDetailResult <= 0){ throw new BusinessException("更新出库单详情数据失败"); + }else { +// 更新库存查询记录,新增库存历史 + String materialNo = warehouseOutOrderDetail.getMaterialNo(); + WarehouseInventoryInquiry inventoryInquiry = inventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(materialNo); + if(inventoryInquiry == null){ + throw new BusinessException("更新库存查询数据失败!该物料不存在库存查询数据"); + }else{ + int inquiryUpdateResult = updateWarehouseInventoryInquiry(warehouseOutOrderDetail,inventoryInquiry); + if (inquiryUpdateResult <= 0){ + throw new BusinessException("更新库存查询数据失败"); + } + WarehouseInventoryInquiryDetail inquiryDetail = createWarehouseInventoryInquiryDetail(warehouseOutOrderDetail); + inquiryDetail.setInventoryHistoricalType("8");//销售出库 + int insertInquiryResult = inventoryInquiryDetailMapper.insertWarehouseInventoryInquiryDetail(inquiryDetail); + if (insertInquiryResult <= 0){ + throw new BusinessException("新增库存历史数据失败"); + } + } } } //更新销售出货通知列表 @@ -296,7 +329,48 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService return updateWarehouseOutOrderResult; } +// 更新物料对应库存查询记录 + public int updateWarehouseInventoryInquiry(WarehouseOutOrderDetail outOrderDetail,WarehouseInventoryInquiry inventoryInquiry){ +// 更新可用库存数 + BigDecimal stockNum = inventoryInquiry.getAvailableStockNum(); + if((stockNum.compareTo(BigDecimal.ZERO) <= 0)){ + throw new BusinessException("出库失败!该物料无可用库存数"); + } + int outNum = outOrderDetail.getActualOutOrderSum(); + stockNum = stockNum.subtract(BigDecimal.valueOf(outNum)); + inventoryInquiry.setAvailableStockNum(stockNum); +// 更新使用数 + BigDecimal useNum = inventoryInquiry.getUseNum(); + useNum = useNum.add(BigDecimal.valueOf(outNum)); + inventoryInquiry.setUseNum(useNum); + + inventoryInquiry.setUpdateBy(ShiroUtils.getLoginName()); + inventoryInquiry.setUpdateTime(DateUtils.getNowDate()); + int inquiryUpdateResult = inventoryInquiryMapper.updateWarehouseInventoryInquiry(inventoryInquiry); + + return inquiryUpdateResult; + } +// 根据出库单详情生成库存历史记录 + public WarehouseInventoryInquiryDetail createWarehouseInventoryInquiryDetail(WarehouseOutOrderDetail outOrderDetail){ + WarehouseInventoryInquiryDetail inquiryDetail = new WarehouseInventoryInquiryDetail(); + inquiryDetail.setMaterialNo(outOrderDetail.getMaterialNo()); + inquiryDetail.setMaterialName(outOrderDetail.getMaterialName()); + inquiryDetail.setMaterialBrand(outOrderDetail.getMaterialBrand()); + inquiryDetail.setMaterialPhotourl(outOrderDetail.getMaterialPhotourl()); + inquiryDetail.setMaterialDescribe(outOrderDetail.getMaterialDescribe()); + inquiryDetail.setMaterialUnit(outOrderDetail.getMaterialUnit()); + inquiryDetail.setMaterialType(outOrderDetail.getMaterialType()); + inquiryDetail.setInventoryIncreaseDecrease("0"); + int decreaseNum = outOrderDetail.getActualOutOrderSum(); + BigDecimal useNum = BigDecimal.valueOf(decreaseNum); + inquiryDetail.setUseNum(useNum); + inquiryDetail.setAvailableStockNum(useNum); + inquiryDetail.setInventoryHistoricalTime(DateUtils.getNowDate()); + inquiryDetail.setCreateBy(ShiroUtils.getLoginName()); + inquiryDetail.setCreateTime(DateUtils.getNowDate()); + return inquiryDetail; + } /** * 修改保存退换货-出库 */ @@ -308,16 +382,67 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService List warehouseOutOrderDetailList = warehouseOutOrder.getWarehouseOutOrderDetailList(); if (StringUtils.isEmpty(warehouseOutOrderDetailList)){ - log.warn("退换货-出库,物料列表信息为空:{}",warehouseOutOrder); + throw new BusinessException("出库失败,出库单物料详情为空!"); } int updateRows = 0; for (WarehouseOutOrderDetail warehouseOutOrderDetail : warehouseOutOrderDetailList) { warehouseOutOrderDetail.setUpdateBy(loginName); - warehouseOutOrderDetail.setUpdateTime(new Date()); + warehouseOutOrderDetail.setUpdateTime(DateUtils.getNowDate()); + //设置已出库数 + warehouseOutOrderDetail.setHasOutOrderSum(warehouseOutOrderDetail.getActualOutOrderSum()); + //设置仓库员 + warehouseOutOrderDetail.setWarehouseName(loginName); //更新数据库记录 updateRows += outOrderDetailMapper.updateWarehouseOutOrderDetail(warehouseOutOrderDetail); + if (updateRows <= 0) { + throw new BusinessException("更新出库单详情数据失败"); + } + } + warehouseOutOrder.setUpdateBy(loginName); + warehouseOutOrder.setUpdateTime(DateUtils.getNowDate()); + //表明已出库 + warehouseOutOrder.setWarehouseOutStatus("7"); + //设置出库时间 + warehouseOutOrder.setOutOrderTime(DateUtils.getNowDate()); + //设置仓库员 + warehouseOutOrder.setWarehouseName(loginName); + //计算出库单主表的出库数 + Integer outOrderSum = 0; + + // 检查outOrderSum是否含有null值 + boolean hasOutOrderSumNull = warehouseOutOrderDetailList.stream() + .anyMatch(item -> item.getActualOutOrderSum() == null); + + if (hasOutOrderSumNull) { + throw new BusinessException("存在实际出库数为空,请检查!"); + } + + // 检查库存是否超出 + boolean hasOutOrderSumOver = warehouseOutOrderDetailList.stream() + .anyMatch(item -> item.getActualOutOrderSum() > item.getApplyOutOrderSum()); + + if (hasOutOrderSumOver) { + throw new BusinessException("存在实际出库数大于申请出库数,请检查!"); } - return updateRows; + // 计算各个字段的总和 + outOrderSum = warehouseOutOrderDetailList.stream() + .mapToInt(WarehouseOutOrderDetail::getActualOutOrderSum) + .sum(); + //设置出库单主表的出库数 + warehouseOutOrder.setOutOrderSum(outOrderSum); + + QualityRefundsExchanges tempExchanges = new QualityRefundsExchanges(); + tempExchanges.setOutStorageCode(warehouseOutOrder.getOutOrderCode()); + List tempExchangesList = refundsExchangesMapper.selectQualityRefundsExchangesList(tempExchanges); + QualityRefundsExchanges refundsExchanges = tempExchangesList.get(0); + refundsExchanges.setQualityWarehouseStatus("4"); + refundsExchanges.setUpdateBy(ShiroUtils.getLoginName()); + refundsExchanges.setUpdateTime(DateUtils.getNowDate()); + int updateRefundResult = refundsExchangesMapper.updateQualityRefundsExchanges(refundsExchanges); + if(updateRefundResult<=0){ + throw new BusinessException("更新关联退换货订单仓库状态失败!"); + } + return warehouseOutOrderMapper.updateWarehouseOutOrder(warehouseOutOrder); } /* @@ -522,18 +647,37 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService warehouseOutOrderDetail.setWarehouseName(loginName); //更新数据库记录 updateRows += outOrderDetailMapper.updateWarehouseOutOrderDetail(warehouseOutOrderDetail); - } - if (updateRows <= 0){ - throw new BusinessException("更新出库单详情数据失败"); - } + if (updateRows <= 0){ + throw new BusinessException("更新出库单详情数据失败"); + }else { +// 更新库存查询记录,新增库存历史 + String materialNo = warehouseOutOrderDetail.getMaterialNo(); + WarehouseInventoryInquiry inventoryInquiry = inventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(materialNo); + if(inventoryInquiry == null){ + throw new BusinessException("更新库存查询数据失败!该物料不存在库存数据"); + }else{ + int inquiryUpdateResult = updateWarehouseInventoryInquiry(warehouseOutOrderDetail,inventoryInquiry); + if (inquiryUpdateResult <= 0){ + throw new BusinessException("更新库存查询数据失败"); + } + WarehouseInventoryInquiryDetail inquiryDetail = createWarehouseInventoryInquiryDetail(warehouseOutOrderDetail); + inquiryDetail.setInventoryHistoricalType("4");//生产出库 + int insertInquiryResult = inventoryInquiryDetailMapper.insertWarehouseInventoryInquiryDetail(inquiryDetail); + if (insertInquiryResult <= 0){ + throw new BusinessException("新增库存历史数据失败"); + } + } + } + + } } warehouseOutOrder.setUpdateBy(loginName); - warehouseOutOrder.setUpdateTime(new Date()); + warehouseOutOrder.setUpdateTime(DateUtils.getNowDate()); //表明已出库 warehouseOutOrder.setWarehouseOutStatus("7"); //设置出库时间 - warehouseOutOrder.setOutOrderTime(new Date()); + warehouseOutOrder.setOutOrderTime(DateUtils.getNowDate()); //设置仓库员 warehouseOutOrder.setWarehouseName(loginName); @@ -853,8 +997,8 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService // log.warn("关联订单号为空:{}",relatedCode); // } - //出库状态为 待仓库准备物料 - warehouseOutOrder.setWarehouseOutStatus("0"); + //出库状态为 待出库 + warehouseOutOrder.setWarehouseOutStatus("4"); //订单类型设置为 请购订单 warehouseOutOrder.setWarehouseOrderType("2"); //出库类型设置为 员工领料 @@ -875,7 +1019,203 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService return warehouseOutOrderMapper.insertWarehouseOutOrder(warehouseOutOrder); } - //新增出库单明细 +// 委外单-出库 + @Transactional(rollbackFor = Exception.class) + @Override + public int updateOutsourceOutWarehouse(WarehouseOutOrder warehouseOutOrder) { + String loginName = ShiroUtils.getLoginName(); + // 参数校验 + if (warehouseOutOrder == null) { + throw new BusinessException("更新出库单信息失败:缺少必要参数"); + } + + List warehouseOutOrderDetailList = warehouseOutOrder.getWarehouseOutOrderDetailList(); + + if (CollectionUtils.isEmpty(warehouseOutOrderDetailList)){ + log.warn("保存委外单出库,物料列表信息为空:{}",warehouseOutOrder); + throw new BusinessException("出库单详情数据为空"); + }else { + int updateRows = 0; + for (WarehouseOutOrderDetail warehouseOutOrderDetail : warehouseOutOrderDetailList) { + warehouseOutOrderDetail.setUpdateBy(loginName); + warehouseOutOrderDetail.setUpdateTime(DateUtils.getNowDate()); + warehouseOutOrderDetail.setRemark(warehouseOutOrder.getRemark()); + //设置已出库数 + warehouseOutOrderDetail.setHasOutOrderSum(warehouseOutOrderDetail.getActualOutOrderSum()); + //设置仓库员 + warehouseOutOrderDetail.setWarehouseName(loginName); + //更新数据库记录 + updateRows += outOrderDetailMapper.updateWarehouseOutOrderDetail(warehouseOutOrderDetail); + if (updateRows <= 0){ + throw new BusinessException("更新出库单详情数据失败"); + }else { +// 更新库存查询记录,新增库存历史 + String materialNo = warehouseOutOrderDetail.getMaterialNo(); + WarehouseInventoryInquiry inventoryInquiry = inventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(materialNo); + if(inventoryInquiry == null){ + throw new BusinessException("更新库存查询数据失败!该物料不存在库存数据"); + }else{ + int inquiryUpdateResult = updateWarehouseInventoryInquiry(warehouseOutOrderDetail,inventoryInquiry); + if (inquiryUpdateResult <= 0){ + throw new BusinessException("更新库存查询数据失败"); + } + WarehouseInventoryInquiryDetail inquiryDetail = createWarehouseInventoryInquiryDetail(warehouseOutOrderDetail); + inquiryDetail.setInventoryHistoricalType("5");//委外领料 + int insertInquiryResult = inventoryInquiryDetailMapper.insertWarehouseInventoryInquiryDetail(inquiryDetail); + if (insertInquiryResult <= 0){ + throw new BusinessException("新增库存历史数据失败"); + } + } + } + } + } + warehouseOutOrder.setUpdateBy(loginName); + warehouseOutOrder.setUpdateTime(DateUtils.getNowDate()); + //表明已出库 + warehouseOutOrder.setWarehouseOutStatus("7"); + //设置出库时间 + warehouseOutOrder.setOutOrderTime(DateUtils.getNowDate()); + //设置仓库员 + warehouseOutOrder.setWarehouseName(loginName); + //计算出库单主表的出库数 + Integer outOrderSum = 0; + + // 检查outOrderSum是否含有null值 + boolean hasOutOrderSumNull = warehouseOutOrderDetailList.stream() + .anyMatch(item -> item.getActualOutOrderSum() == null); + + if (hasOutOrderSumNull) { + throw new BusinessException("存在实际出库数为空,请检查!"); + } + + // 检查outOrderSum是否含有null值 + boolean hasOutOrderSumOver = warehouseOutOrderDetailList.stream() + .anyMatch(item -> item.getActualOutOrderSum() > item.getApplyOutOrderSum()); + + if (hasOutOrderSumOver) { + throw new BusinessException("存在实际出库数大于申请出库数,请检查!"); + } + // 计算各个字段的总和 + outOrderSum = warehouseOutOrderDetailList.stream() + .mapToInt(WarehouseOutOrderDetail::getActualOutOrderSum) + .sum(); + //设置出库单主表的出库数 + warehouseOutOrder.setOutOrderSum(outOrderSum); + + // 更新委外领料单 + OutsourceRequisitionVO temp = new OutsourceRequisitionVO(); + temp.setOutsourceRequisitionNo(warehouseOutOrder.getRelatedOrderCode()); + List outRequisitions = requisitionMapper.selectOutsourceRequisitionList(temp); + OutsourceRequisitionVO requisitionVO = outRequisitions.get(0); + requisitionVO.setRequisitionStatus("2"); + requisitionVO.setUpdateTime(DateUtils.getNowDate()); + requisitionVO.setUpdateBy(ShiroUtils.getLoginName()); + int updateResult = requisitionMapper.updateOutsourceRequisition(requisitionVO); + if(updateResult<=0){ + throw new BusinessException("更新委外领料单失败!"); + } + + return warehouseOutOrderMapper.updateWarehouseOutOrder(warehouseOutOrder); + } + + // 请购单-出库 + @Transactional(rollbackFor = Exception.class) + @Override + public int updateRequisitionOutWarehouse(WarehouseOutOrder warehouseOutOrder) { + String loginName = ShiroUtils.getLoginName(); + // 参数校验 + if (warehouseOutOrder == null) { + throw new BusinessException("更新出库单信息失败:缺少必要参数"); + } + + List warehouseOutOrderDetailList = warehouseOutOrder.getWarehouseOutOrderDetailList(); + + if (CollectionUtils.isEmpty(warehouseOutOrderDetailList)){ + log.warn("保存请购单出库,物料列表信息为空:{}",warehouseOutOrder); + throw new BusinessException("出库单详情数据为空"); + }else { + int updateRows = 0; + for (WarehouseOutOrderDetail warehouseOutOrderDetail : warehouseOutOrderDetailList) { + warehouseOutOrderDetail.setUpdateBy(loginName); + warehouseOutOrderDetail.setUpdateTime(DateUtils.getNowDate()); + warehouseOutOrderDetail.setRemark(warehouseOutOrder.getRemark()); + //设置已出库数 + warehouseOutOrderDetail.setHasOutOrderSum(warehouseOutOrderDetail.getActualOutOrderSum()); + //设置仓库员 + warehouseOutOrderDetail.setWarehouseName(loginName); + //更新数据库记录 + updateRows += outOrderDetailMapper.updateWarehouseOutOrderDetail(warehouseOutOrderDetail); + if (updateRows <= 0){ + throw new BusinessException("更新出库单详情数据失败"); + }else { +// 更新库存查询记录,新增库存历史 + String materialNo = warehouseOutOrderDetail.getMaterialNo(); + WarehouseInventoryInquiry inventoryInquiry = inventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(materialNo); + if(inventoryInquiry == null){ + throw new BusinessException("更新库存查询数据失败!该物料不存在库存数据"); + }else{ + int inquiryUpdateResult = updateWarehouseInventoryInquiry(warehouseOutOrderDetail,inventoryInquiry); + if (inquiryUpdateResult <= 0){ + throw new BusinessException("更新库存查询数据失败"); + } + WarehouseInventoryInquiryDetail inquiryDetail = createWarehouseInventoryInquiryDetail(warehouseOutOrderDetail); + inquiryDetail.setInventoryHistoricalType("6");//员工领料 + int insertInquiryResult = inventoryInquiryDetailMapper.insertWarehouseInventoryInquiryDetail(inquiryDetail); + if (insertInquiryResult <= 0){ + throw new BusinessException("新增库存历史数据失败"); + } + } + } + } + } + warehouseOutOrder.setUpdateBy(loginName); + warehouseOutOrder.setUpdateTime(DateUtils.getNowDate()); + //表明已出库 + warehouseOutOrder.setWarehouseOutStatus("7"); + //设置出库时间 + warehouseOutOrder.setOutOrderTime(DateUtils.getNowDate()); + //设置仓库员 + warehouseOutOrder.setWarehouseName(loginName); + //计算出库单主表的出库数 + Integer outOrderSum = 0; + + // 检查outOrderSum是否含有null值 + boolean hasOutOrderSumNull = warehouseOutOrderDetailList.stream() + .anyMatch(item -> item.getActualOutOrderSum() == null); + + if (hasOutOrderSumNull) { + throw new BusinessException("存在实际出库数为空,请检查!"); + } + + // 检查outOrderSum是否含有null值 + boolean hasOutOrderSumOver = warehouseOutOrderDetailList.stream() + .anyMatch(item -> item.getActualOutOrderSum() > item.getApplyOutOrderSum()); + + if (hasOutOrderSumOver) { + throw new BusinessException("存在实际出库数大于申请出库数,请检查!"); + } + // 计算各个字段的总和 + outOrderSum = warehouseOutOrderDetailList.stream() + .mapToInt(WarehouseOutOrderDetail::getActualOutOrderSum) + .sum(); + //设置出库单主表的出库数 + warehouseOutOrder.setOutOrderSum(outOrderSum); + + // 更新员工领料单 + BaseEmpRequisiteOrderVO temp = new BaseEmpRequisiteOrderVO(); + temp.setRequisitieCode(warehouseOutOrder.getRelatedOrderCode()); + List empRequisiteOrderVOS = empRequisiteOrderMapper.selectBaseEmpRequisiteOrderList(temp); + BaseEmpRequisiteOrderVO requisitionVO = empRequisiteOrderVOS.get(0); + requisitionVO.setRequisitieStatus("2"); + requisitionVO.setUpdateTime(DateUtils.getNowDate()); + requisitionVO.setUpdateBy(ShiroUtils.getLoginName()); + int updateResult = empRequisiteOrderMapper.updateBaseEmpRequisiteOrder(requisitionVO); + if(updateResult<=0){ + throw new BusinessException("更新员工领料单失败!"); + } + return warehouseOutOrderMapper.updateWarehouseOutOrder(warehouseOutOrder); + } + //新增出库单明细(员工领料) private void CreateOutOrderDetailByRequisiteOrderChildList(BaseEmpRequisiteOrderVO baseEmpRequisiteOrderVO, String outOrderCode) { List childList = baseEmpRequisiteOrderVO.getBaseEmpRequisiteOrderChildList(); String requisiteCode = baseEmpRequisiteOrderVO.getRequisitieCode(); @@ -894,6 +1234,9 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService warehouseOutOrderDetail.setMaterialProcessMethod(child.getProcessMethod()); warehouseOutOrderDetail.setEnterpriseSum(Math.toIntExact(child.getMaterialNum())); warehouseOutOrderDetail.setMakeNum(Math.toIntExact(child.getMaterialNum())); + warehouseOutOrderDetail.setApplyOutOrderSum(Math.toIntExact(child.getMaterialNum())); + warehouseOutOrderDetail.setWarehouseOrderType("2"); + warehouseOutOrderDetail.setWarehouseOutType("2"); warehouseOutOrderDetail.setCreateTime(DateUtils.getNowDate()); warehouseOutOrderDetail.setCreateBy(child.getCreateBy()); int insertOutOrderDetailResult = outOrderDetailMapper.insertWarehouseOutOrderDetail(warehouseOutOrderDetail); diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/outsourceOutWarehouse.html b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/outsourceOutWarehouse.html new file mode 100644 index 00000000..1bf6965e --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/outsourceOutWarehouse.html @@ -0,0 +1,210 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/outsourceOutWarehouseDetail.html b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/outsourceOutWarehouseDetail.html new file mode 100644 index 00000000..d4309d25 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/outsourceOutWarehouseDetail.html @@ -0,0 +1,197 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/warehouseOutOrder.html b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/warehouseOutOrder.html index c463ef0e..fc3a1428 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/warehouseOutOrder.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/warehouseOutOrder.html @@ -71,6 +71,7 @@ var prepareMaterialFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:prepareMaterial')}]]; var salesOutWarehouseFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:salesOutWarehouse')}]]; var makeOutWarehouseFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:makeOutWarehouse')}]]; + var outsourceOutWarehouseFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:outsourceOutWarehouse')}]]; var requisitioningOutWarehouseFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:requisitioningOutWarehouse')}]]; var refundsExchangesOutWarehouseFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:refundsExchangesOutWarehouse')}]]; var developModifyOutWarehouseFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:developModifyOutWarehouse')}]]; @@ -78,6 +79,7 @@ var prepareMaterialDetailFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:prepareMaterialDetail')}]]; var salesOutWarehouseDetailFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:salesOutWarehouseDetail')}]]; var makeOutWarehouseDetailFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:makeOutWarehouseDetail')}]]; + var outsourceOutWarehouseDetailFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:outsoruceOutWarehouseDetail')}]]; var requisitioningOutWarehouseDetailFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:requisitioningOutWarehouseDetail')}]]; var refundsExchangesOutWarehouseDetailFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:refundsExchangesOutWarehouseDetail')}]]; var developModifyOutWarehouseDetailFlag = [[${@permission.hasPermi('warehouse:warehouseOutOrder:developModifyOutWarehouseDetail')}]]; @@ -237,6 +239,14 @@ actions.push('详情 '); } + /*委外单-出库*/ + if (row.warehouseOutStatus == 4 && row.warehouseOrderType == 3 && row.warehouseOutType == 3){ + actions.push('出库 '); + } + /*生产单-出库 详情*/ + if (row.warehouseOrderType == 3 && row.warehouseOutType == 3){ + actions.push('详情 '); + } return actions.join(''); } @@ -282,6 +292,17 @@ $.modal.open("出库详情",url); } + /*生产单-出库*/ + function outsourceOutWarehouse(outOrderId){ + var url = ctx + 'warehouse/warehouseOutOrder/outsourceOutWarehouse/' + outOrderId; + $.modal.open("出库",url); + } + + /*生产单-出库详情*/ + function outsourceOutWarehouseDetail(outOrderId){ + var url = ctx + 'warehouse/warehouseOutOrder/outsourceOutWarehouseDetail/' + outOrderId; + $.modal.open("出库详情",url); + } /*开发修改单-出库*/ function developModifyOutWarehouse(outOrderId){ var url = ctx + 'warehouse/warehouseOutOrder/developModifyOutWarehouse/' + outOrderId;