diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrder.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrder.java index 1f2e4166..755250f3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrder.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrder.java @@ -59,6 +59,9 @@ public class QualityOrder extends BaseEntity @Excel(name = "品质不合格数") private Integer qualityUnqualifiedNum; + /** 入库数 */ + private Integer storageNum; + /** 委内加工费总价 */ private BigDecimal makeInTotalPrice; @@ -224,6 +227,14 @@ public class QualityOrder extends BaseEntity this.qualityOrderDetailList = qualityOrderDetailList; } + public Integer getStorageNum() { + return storageNum; + } + + public void setStorageNum(Integer storageNum) { + this.storageNum = storageNum; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -248,6 +259,7 @@ public class QualityOrder extends BaseEntity .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) + .append("storageNum",getStorageNum()) .toString(); } } 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 871d0a8a..4a0941fa 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 @@ -139,7 +139,7 @@ public class WarehouseStorageOrderController extends BaseController @ResponseBody public AjaxResult temporaryPurchaseWarehouseSave(@RequestBody WarehouseStorageOrder warehouseStorageOrder) { - return toAjax(warehouseStorageOrderService.updateWarehouseStorageOrder(warehouseStorageOrder)); + return toAjax(warehouseStorageOrderService.updateTemporaryPurchaseWarehouse(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 506ecf85..5f78b31d 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 @@ -118,4 +118,9 @@ public interface IWarehouseStorageOrderService * 修改保存入库-生产订单(委内入库) * */ int updateStorageMakeIn(WarehouseStorageOrder warehouseStorageOrder); + + /** + * 修改保存暂收-采购单(仓库入库) + */ + int updateTemporaryPurchaseWarehouse(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 e2352fc5..26aeb414 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 @@ -523,6 +523,58 @@ public class WarehouseStorageOrderServiceImpl implements IWarehouseStorageOrderS } + /** + * 修改保存暂收-采购单(仓库入库) + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int updateTemporaryPurchaseWarehouse(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; + + } + /** * 修改保存暂收-采购单(采购入库) 子表数据 * */ diff --git a/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderMapper.xml b/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderMapper.xml index b69ad95c..33ec0f68 100644 --- a/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderMapper.xml @@ -15,6 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -98,8 +99,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" qo.create_time, qo.update_by, qo.update_time, - qo.make_in_total_price + qo.make_in_total_price, + wso.storage_num from quality_order qo + left join warehouse_storage_order wso on wso.related_order_code = qo.related_order_code + and qo.quality_order_code = #{qualityOrderCode} and qo.in_storage_code = #{inStorageCode} diff --git a/ruoyi-admin/src/main/resources/templates/erp/inboundOrder/inboundOrder.html b/ruoyi-admin/src/main/resources/templates/erp/inboundOrder/inboundOrder.html index c272a366..0124655d 100644 --- a/ruoyi-admin/src/main/resources/templates/erp/inboundOrder/inboundOrder.html +++ b/ruoyi-admin/src/main/resources/templates/erp/inboundOrder/inboundOrder.html @@ -165,7 +165,7 @@ { title: '入库数', - field: 'storage_num', + field: 'storageNum', }, // {