From d13ce18996f03e646d131139a12a6a4d7da3248b 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:50:13 +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=BA=93=E5=AD=98=E6=8A=A5=E6=8D=9F=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=8A=A5=E6=8D=9Fservice=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=BA=93=E5=AD=98=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=92=8C=E5=BA=93=E5=AD=98=E5=8E=86=E5=8F=B2=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=EF=BC=9B=20=E4=BF=AE=E6=94=B9=E8=AF=B7=E8=B4=AD=E5=8D=95?= =?UTF-8?q?=E5=87=BA=E5=BA=93=E9=A1=B5=E9=9D=A2=EF=BC=8C=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=87=BA=E5=BA=93=E6=93=8D=E4=BD=9C=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...houseInventoryReportDamageServiceImpl.java | 56 ++++++++++++++++++- .../WarehouseInventoryReportDamageMapper.xml | 14 +++-- .../inventoryReportDamage.html | 4 +- .../requisitioningOutWarehouse.html | 33 ++++++++--- .../requisitioningOutWarehouseDetail.html | 11 ++++ 5 files changed, 102 insertions(+), 16 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryReportDamageServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryReportDamageServiceImpl.java index 24fa7f13..be4cc761 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryReportDamageServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryReportDamageServiceImpl.java @@ -14,14 +14,16 @@ import com.ruoyi.common.utils.StringUtils; import com.ruoyi.erp.domain.ErpMaterialVo; import com.ruoyi.system.domain.SysMakeorderBom; import com.ruoyi.system.mapper.SysMakeorderBomMapper; +import com.ruoyi.warehouse.controller.WarehouseInventoryReportDamageController; +import com.ruoyi.warehouse.domain.*; import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO; -import com.ruoyi.warehouse.domain.WarehouseInventoryReportDamageChild; +import com.ruoyi.warehouse.mapper.WarehouseInventoryInquiryDetailMapper; +import com.ruoyi.warehouse.mapper.WarehouseInventoryInquiryMapper; import com.ruoyi.warehouse.mapper.WarehouseInventoryReportDamageChildMapper; import com.ruoyi.warehouse.service.IWarehouseInventoryReportDamageChildService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.warehouse.mapper.WarehouseInventoryReportDamageMapper; -import com.ruoyi.warehouse.domain.WarehouseInventoryReportDamage; import com.ruoyi.warehouse.service.IWarehouseInventoryReportDamageService; import com.ruoyi.common.core.text.Convert; import org.springframework.transaction.annotation.Transactional; @@ -46,6 +48,12 @@ public class WarehouseInventoryReportDamageServiceImpl implements IWarehouseInve @Autowired private SysMakeorderBomMapper sysMakeorderBomMapper; + + @Autowired + private WarehouseInventoryInquiryMapper inventoryInquiryMapper; + + @Autowired + private WarehouseInventoryInquiryDetailMapper inventoryInquiryDetailMapper; /** * 查询仓库库存报损 * @@ -116,6 +124,10 @@ public class WarehouseInventoryReportDamageServiceImpl implements IWarehouseInve warehouseInventoryReportDamageChild.setApplyDeptId(String.valueOf(ShiroUtils.getSysUser().getDeptId())); warehouseInventoryReportDamageChild.setApplyDept(ShiroUtils.getSysUser().getDept().getDeptName()); warehouseInventoryReportDamageChildService.insertWarehouseInventoryReportDamageChild(warehouseInventoryReportDamageChild); + int inquiryUpdateResult = updateWarehouseInventoryInquiry(warehouseInventoryReportDamageChild); + if(inquiryUpdateResult<=0){ + throw new BusinessException("更新库存查询失败!"); + } } }else{ //子表数据为空,则抛出异常 @@ -125,6 +137,46 @@ public class WarehouseInventoryReportDamageServiceImpl implements IWarehouseInve return warehouseInventoryReportDamageMapper.insertWarehouseInventoryReportDamage(warehouseInventoryReportDamage); } + public int updateWarehouseInventoryInquiry(WarehouseInventoryReportDamageChild damageChild){ + WarehouseInventoryInquiry inventoryInquiry = inventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(damageChild.getMaterialNo()); + if(inventoryInquiry == null){ + throw new BusinessException("新增库存报损失败,该物料无库存数据"); + } + WarehouseInventoryInquiryDetail inquiryDetail = createWarehouseInventoryInquiryDetail(damageChild); + inquiryDetail.setInventoryHistoricalType("9"); + int detailInsertResult = inventoryInquiryDetailMapper.insertWarehouseInventoryInquiryDetail(inquiryDetail); + if(detailInsertResult<=0){ + throw new BusinessException("新增库存历史失败!"); + } + BigDecimal reportDamageNum = inventoryInquiry.getReportDamageNum(); + reportDamageNum = reportDamageNum.add(damageChild.getActualScrapQuantity()); + inventoryInquiry.setReportDamageNum(reportDamageNum); + BigDecimal availableNum = inventoryInquiry.getAvailableStockNum(); + availableNum = availableNum.subtract(damageChild.getActualScrapQuantity()); + inventoryInquiry.setAvailableStockNum(availableNum); + inventoryInquiry.setUpdateBy(ShiroUtils.getLoginName()); + inventoryInquiry.setUpdateTime(DateUtils.getNowDate()); + return inventoryInquiryMapper.updateWarehouseInventoryInquiry(inventoryInquiry); + } + + // 根据报损单详情生成库存历史记录 + public WarehouseInventoryInquiryDetail createWarehouseInventoryInquiryDetail(WarehouseInventoryReportDamageChild damageChild){ + WarehouseInventoryInquiryDetail inquiryDetail = new WarehouseInventoryInquiryDetail(); + inquiryDetail.setMaterialNo(damageChild.getMaterialNo()); + inquiryDetail.setMaterialName(damageChild.getMaterialName()); + inquiryDetail.setMaterialBrand(damageChild.getMaterialBrand()); + inquiryDetail.setMaterialPhotourl(damageChild.getMaterialPhotourl()); + inquiryDetail.setMaterialDescribe(damageChild.getMaterialDescribe()); + inquiryDetail.setMaterialUnit(damageChild.getMaterialUnit()); + inquiryDetail.setMaterialType(damageChild.getMaterialType()); + inquiryDetail.setInventoryIncreaseDecrease("0"); + BigDecimal decreaseNum = damageChild.getActualScrapQuantity(); + inquiryDetail.setAvailableStockNum(decreaseNum); + inquiryDetail.setInventoryHistoricalTime(DateUtils.getNowDate()); + inquiryDetail.setCreateBy(ShiroUtils.getLoginName()); + inquiryDetail.setCreateTime(DateUtils.getNowDate()); + return inquiryDetail; + } /** * 修改仓库库存报损 * diff --git a/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryReportDamageMapper.xml b/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryReportDamageMapper.xml index 4d70b37e..e4b7dbfd 100644 --- a/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryReportDamageMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryReportDamageMapper.xml @@ -33,13 +33,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryReportDamage/inventoryReportDamage.html b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryReportDamage/inventoryReportDamage.html index 92691985..c73d88c7 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryReportDamage/inventoryReportDamage.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryReportDamage/inventoryReportDamage.html @@ -143,11 +143,11 @@ let tipMsg = "确定导出当前所有数据吗?"; if ($.common.isNotEmpty(ids)) { - tipMsg = `确定导出当前勾选的 ${ids.length} 条数据吗?`; + tipMsg = `确定导出 ${ids} 数据吗?`; dataParam.push({ "name": "ids", "value": ids }); } - $.modal.loading("正在导出数据,请稍后..."); $.modal.confirm(tipMsg, function () { + $.modal.loading("正在导出数据,请稍后..."); $.post( prefix + "/export", dataParam, function (result) { if (result.code === web_status.SUCCESS) { window.location.href = ctx + "common/download?fileName="+ encodeURI(result.msg) + "&delete=" + true; diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/requisitioningOutWarehouse.html b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/requisitioningOutWarehouse.html index 44025a0a..f6a48934 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/requisitioningOutWarehouse.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/requisitioningOutWarehouse.html @@ -58,6 +58,8 @@ var warehouseOutOrder = [[${warehouseOutOrder}]]; + var processMethodDatas = [[${@dict.getType('processMethod')}]]; + var materialTypeDatas = [[${@category.getChildByCode('materialType')}]]; var prefix = ctx + "warehouse/warehouseOutOrder"; $("#form-makeOutWarehouse-edit").validate({ @@ -82,7 +84,8 @@ "outOrderCode":item.outOrderCode, "materialNo": item.materialNo, // 假设id对应materialId "prepareOutOrderSum":item.prepareOutOrderSum, - "actualOutOrderSum":item.actualOutOrderSum + "actualOutOrderSum":item.actualOutOrderSum, + "applyOutOrderSum": item.applyOutOrderSum // ...其他字段 }; }); @@ -91,10 +94,8 @@ warehouseOutOrderDetailList: materialDataList, }); // 合并表单数据和表格数据 - console.log(combinedData) - // 使用 JSON.stringify() 序列化数据 + const jsonData = JSON.stringify(combinedData); - // 发送 AJAX 请求到后端接口 $.operate.saveJson(prefix + "/requisitioningOutWarehouse", jsonData); } @@ -109,9 +110,7 @@ showToggle: false, showColumns: false, pagination: false, // 设置不分页 - columns: [{ - checkbox: true - }, + columns: [ { title: '出库单详情ID', field: 'outOrderDetailId', @@ -130,6 +129,9 @@ { title: '图片', field: 'materialPhotourl', + formatter: function(value, row, index) { + return $.table.imageView(value); + } }, { title: '物料名称', @@ -138,6 +140,9 @@ { title: '物料类型', field: 'materialType', + formatter: function(value, row, index) { + return $.table.selectCategoryLabel(materialTypeDatas, value); + } }, { title: '描述', @@ -154,6 +159,9 @@ { title: '加工方式', field: 'materialProcessMethod', + formatter: function(value, row, index) { + return $.table.selectDictLabel(processMethodDatas, value); + } }, { title: '订单数量', @@ -170,7 +178,16 @@ { title: '实际出库数', field: 'actualOutOrderSum', - editable:true + editable: { + type: 'text', + mode:'inline', + validate: function (v,row) { + if (!v) return '数量不能为空'; + if (isNaN(v)) return '数量必须是数字'; + var actualOutOrderSum = parseInt(v); + if (actualOutOrderSum <= 0) return '数量必须是正整数'; + } + } } ] }; diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/requisitioningOutWarehouseDetail.html b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/requisitioningOutWarehouseDetail.html index bbcfb116..c5e9b1f4 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/requisitioningOutWarehouseDetail.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/requisitioningOutWarehouseDetail.html @@ -58,6 +58,8 @@ var warehouseOutOrder = [[${warehouseOutOrder}]]; + var processMethodDatas = [[${@dict.getType('processMethod')}]]; + var materialTypeDatas = [[${@category.getChildByCode('materialType')}]]; var prefix = ctx + "warehouse/warehouseOutOrder"; $("#form-makeOutWarehouse-edit").validate({ @@ -130,6 +132,9 @@ { title: '图片', field: 'materialPhotourl', + formatter: function(value, row, index) { + return $.table.imageView(value); + } }, { title: '物料名称', @@ -138,6 +143,9 @@ { title: '物料类型', field: 'materialType', + formatter: function(value, row, index) { + return $.table.selectCategoryLabel(materialTypeDatas, value); + } }, { title: '描述', @@ -154,6 +162,9 @@ { title: '加工方式', field: 'materialProcessMethod', + formatter: function(value, row, index) { + return $.table.selectDictLabel(processMethodDatas, value); + } }, { title: '订单数量',