From d9cb6adf3ac459140d3adc6d4cf8c396405cc6fa Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Mon, 8 Jul 2024 19:10:06 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E7=94=9F=E4=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=20=E5=93=81=E8=B4=A8=E7=AE=A1=E7=90=86=20=E5=93=81=E8=B4=A8?= =?UTF-8?q?=E5=8D=95=E8=AF=A6=E6=83=85=E8=A1=A8=E6=96=B0=E5=A2=9E=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E5=AE=8C=E6=88=90=E6=95=B0=E5=AD=97=E6=AE=B5=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=9F=E4=BA=A7=E5=85=A5=E5=BA=93=E7=9A=84?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E5=85=A5=E5=BA=93=E8=BD=AC=E6=88=90=E5=93=81?= =?UTF-8?q?=E8=B4=A8=E5=8D=95=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=9F=E4=BA=A7=E5=85=A5=E5=BA=93=E8=BD=AC?= =?UTF-8?q?=E6=88=90=E5=93=81=E8=B4=A8=E5=8D=95=E8=AF=A6=E6=83=85=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E6=8E=A5=E5=8F=A3=20=E6=96=B0=E5=A2=9E=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E5=85=A5=E5=BA=93=E8=BD=AC=E6=88=90=E5=93=81=E8=B4=A8?= =?UTF-8?q?=E5=8D=95=E6=8A=A5=E5=91=8A=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../quality/domain/QualityOrderDetail.java | 13 ++ .../controller/SysMakeOrderController.java | 16 +++ .../system/service/ISysMakeOrderService.java | 5 + .../service/impl/SysMakeOrderServiceImpl.java | 127 +++++++++++++++++- .../quality/QualityOrderDetailMapper.xml | 5 + .../system/makeorder/addProduceInbound.html | 12 +- 6 files changed, 169 insertions(+), 9 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java index 1f0ab2c8..a5cffbe7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java @@ -118,6 +118,9 @@ public class QualityOrderDetail extends BaseEntity @Excel(name = "生产订单数") private Integer makeTotal; + /** 生产完成数 */ + private Integer makeCompletionNum; + /** 实际到货数量 */ @Excel(name = "实际到货数量") private Integer actualArriveNum; @@ -362,6 +365,15 @@ public class QualityOrderDetail extends BaseEntity this.makeTotal = makeTotal; } + + public Integer getMakeCompletionNum() { + return makeCompletionNum; + } + + public void setMakeCompletionNum(Integer makeCompletionNum) { + this.makeCompletionNum = makeCompletionNum; + } + public Integer getActualArriveNum() { return actualArriveNum; } @@ -460,6 +472,7 @@ public class QualityOrderDetail extends BaseEntity .append("qualityQualifiedNum", getQualityQualifiedNum()) .append("qualityUnqualifiedNum", getQualityUnqualifiedNum()) .append("makeInNum",getMakeInNum()) + .append("makeCompletionNum",getMakeCompletionNum()) .append("makeInUnitPrice",getMakeInUnitPrice()) .append("remark", getRemark()) .append("createBy", getCreateBy()) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeOrderController.java index 77aeba35..e227446b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeOrderController.java @@ -13,6 +13,7 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.erp.domain.ErpInboundOrder; import com.ruoyi.erp.service.IErpMaterialService; import com.ruoyi.financial.domain.FinancialReceivables; import com.ruoyi.financial.domain.FinancialReceivablesRecords; @@ -198,6 +199,21 @@ public class SysMakeOrderController extends BaseController return prefix + "/addProduceInbound"; } + + /** + * 添加修改 创建生产入库和设备履历设置 + * */ + @ResponseBody + @PostMapping("/addProduceInboundSave") + public AjaxResult addProduceInboundSave(@RequestBody ErpInboundOrder erpInboundOrder) + { + + return toAjax(sysMakeOrderService.addProduceInboundSave(erpInboundOrder)); + } + + + + /** * 跳转添加设备履历 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysMakeOrderService.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysMakeOrderService.java index 4adfdb1f..e48f18ac 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysMakeOrderService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysMakeOrderService.java @@ -1,5 +1,6 @@ package com.ruoyi.system.service; +import com.ruoyi.erp.domain.ErpInboundOrder; import com.ruoyi.system.domain.SysMakeOrder; import com.ruoyi.system.dto.SysEquipMaterialDto; import com.ruoyi.system.dto.SysMakeorderMaterialDto; @@ -119,4 +120,8 @@ public interface ISysMakeOrderService */ int addEquipmentResumeSave(SysEquipMaterialDto equipMaterialDto); + /** + * 添加保存创建生产入库和设备履历设置 + */ + int addProduceInboundSave(ErpInboundOrder erpInboundOrder); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java index edd751f8..f78b04fc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java @@ -10,8 +10,16 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.erp.domain.ErpBom; +import com.ruoyi.erp.domain.ErpInboundOrder; +import com.ruoyi.erp.domain.ErpInboundOrderDetail; import com.ruoyi.erp.service.IErpBomService; import com.ruoyi.purchase.service.IPurchasePlanService; +import com.ruoyi.quality.domain.QualityOrder; +import com.ruoyi.quality.domain.QualityOrderDetail; +import com.ruoyi.quality.domain.QualityOrderReport; +import com.ruoyi.quality.mapper.QualityOrderDetailMapper; +import com.ruoyi.quality.mapper.QualityOrderMapper; +import com.ruoyi.quality.mapper.QualityOrderReportMapper; import com.ruoyi.system.domain.SysMakeOrder; import com.ruoyi.system.domain.SysMakeorderBom; import com.ruoyi.system.domain.SysSalesOrderChild; @@ -20,6 +28,7 @@ import com.ruoyi.system.dto.SysEquipDetailDto; import com.ruoyi.system.dto.SysEquipMaterialDto; import com.ruoyi.system.dto.SysMakeorderMaterialDto; import com.ruoyi.system.mapper.SysMakeOrderMapper; +import com.ruoyi.system.mapper.SysSalesOrderChildMapper; import com.ruoyi.system.service.*; import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; @@ -31,9 +40,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; /** * 生产订单Service业务层处理 @@ -57,6 +64,9 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService @Autowired private ISysSalesOrderService salesOrderService; + @Autowired + private SysSalesOrderChildMapper salesOrderChildMapper; + @Autowired private ISysSalesOrderChildService salesOrderChildService; @@ -72,6 +82,14 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService @Autowired private AfterSalesShippingDeviceMapper afterSalesShippingDeviceMapper; + @Autowired + private QualityOrderMapper qualityOrderMapper; + + @Autowired + private QualityOrderDetailMapper orderDetailMapper; + + @Autowired + private QualityOrderReportMapper orderReportMapper; /** * 查询生产订单 @@ -408,4 +426,107 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService return result; } + + + /** + * 添加保存创建生产入库和设备履历设置 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int addProduceInboundSave(ErpInboundOrder erpInboundOrder) { + String loginName = ShiroUtils.getLoginName(); + erpInboundOrder.setCreateBy(loginName); + erpInboundOrder.setCreateTime(DateUtils.getNowDate()); + String qualityOrderCode = redisCache.generateBillNo("PZ"); + QualityOrder qualityOrder = createQualityOrder(qualityOrderCode, erpInboundOrder, loginName); + + Map materialInfoMap = fetchMaterialInfoMap(erpInboundOrder); + + addQualityOrderDetails(qualityOrder, erpInboundOrder, materialInfoMap); + addQualityOrderReports(qualityOrder, erpInboundOrder, materialInfoMap); + + return qualityOrderMapper.insertQualityOrder(qualityOrder); + } + + private QualityOrder createQualityOrder(String code, ErpInboundOrder erpInboundOrder, String loginName) { + QualityOrder qualityOrder = new QualityOrder(); + qualityOrder.setQualityOrderCode(code); + qualityOrder.setRelatedOrderCode(erpInboundOrder.getMakeNo()); + qualityOrder.setQualityStatus("0"); + qualityOrder.setQualityStorageStatus("4"); + qualityOrder.setQualityOrderType("1"); + qualityOrder.setCreateTime(new Date()); + qualityOrder.setCreateBy(loginName); + return qualityOrder; + } + + //先查询所有必要的信息并将其存储在一个Map中,提高查询效率 + private Map fetchMaterialInfoMap(ErpInboundOrder erpInboundOrder) { + List inboundDetails = erpInboundOrder.getInboundDetails(); + Map materialInfoMap = new HashMap<>(); + for (ErpInboundOrderDetail detail : inboundDetails) { + SysSalesOrderChild sysSalesOrderChild = new SysSalesOrderChild(); + sysSalesOrderChild.setMaterialCode(detail.getMaterialNo()); + sysSalesOrderChild.setQuoteId(erpInboundOrder.getSaleNo()); + SysSalesOrderChild child = salesOrderChildMapper.selectSalesOrderChildByCodeAndNo(sysSalesOrderChild); + materialInfoMap.put(detail.getMaterialNo(), child); + } + return materialInfoMap; + } + + private void addQualityOrderDetails(QualityOrder qualityOrder, ErpInboundOrder erpInboundOrder, Map materialInfoMap) { + for (ErpInboundOrderDetail detail : erpInboundOrder.getInboundDetails()) { + SysSalesOrderChild salesOrderChild = materialInfoMap.get(detail.getMaterialNo()); + QualityOrderDetail qualityOrderDetail = createQualityOrderDetail(qualityOrder, detail, salesOrderChild); + int result = orderDetailMapper.insertQualityOrderDetail(qualityOrderDetail); + if (result <= 0) { + throw new BusinessException("新增品质单详情失败"); + } + } + } + + private QualityOrderDetail createQualityOrderDetail(QualityOrder qualityOrder, ErpInboundOrderDetail detail, SysSalesOrderChild salesOrderChild) { + QualityOrderDetail qualityOrderDetail = new QualityOrderDetail(); + qualityOrderDetail.setQualityOrderCode(qualityOrder.getQualityOrderCode()); + qualityOrderDetail.setMaterialNo(detail.getMaterialNo()); + qualityOrderDetail.setMaterialName(salesOrderChild.getMaterialName()); + qualityOrderDetail.setMaterialType(salesOrderChild.getMaterialType()); + qualityOrderDetail.setMaterialBrand(salesOrderChild.getBrand()); + qualityOrderDetail.setMaterialDescribe(salesOrderChild.getDescribe()); + qualityOrderDetail.setMaterialUnit(salesOrderChild.getUnit()); + qualityOrderDetail.setMaterialProcessMethod(salesOrderChild.getProcessMethod()); + qualityOrderDetail.setMaterialDeptType("0"); + qualityOrderDetail.setMakeTotal(salesOrderChild.getMaterialNum()); + qualityOrderDetail.setMakeCompletionNum(Math.toIntExact(detail.getCurrentNum())); + qualityOrderDetail.setCreateBy(ShiroUtils.getLoginName()); + qualityOrderDetail.setCreateTime(new Date()); + return qualityOrderDetail; + } + + //添加品质单报告数据 + private void addQualityOrderReports(QualityOrder qualityOrder, ErpInboundOrder erpInboundOrder, Map materialInfoMap) { + + for (ErpInboundOrderDetail detail : erpInboundOrder.getInboundDetails()) { + SysSalesOrderChild salesOrderChild = materialInfoMap.get(detail.getMaterialNo()); + QualityOrderReport qualityOrderReport = createQualityOrderReport(qualityOrder, detail, salesOrderChild); + int result = orderReportMapper.insertQualityOrderReport(qualityOrderReport); + if (result <= 0) { + throw new BusinessException("新增品质单报告失败"); + } + } + } + + + private QualityOrderReport createQualityOrderReport(QualityOrder qualityOrder, ErpInboundOrderDetail detail, SysSalesOrderChild salesOrderChild) { + QualityOrderReport qualityOrderReport = new QualityOrderReport(); + + qualityOrderReport.setQualityOrderCode(qualityOrder.getQualityOrderCode()); + qualityOrderReport.setMaterialNo(detail.getMaterialNo()); + qualityOrderReport.setMaterialName(salesOrderChild.getMaterialName()); + qualityOrderReport.setMakeTotal(salesOrderChild.getMaterialNum()); + qualityOrderReport.setCreateBy(ShiroUtils.getLoginName()); + qualityOrderReport.setCreateTime(new Date()); + return qualityOrderReport; + } + } diff --git a/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml b/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml index e1aaf38f..9fbacb72 100644 --- a/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml @@ -30,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -70,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" material_process_method, material_dept_type, make_total, + make_completion_num, actual_arrive_num, this_arrived_num, quality_hasqualified_num, @@ -154,6 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" material_process_method, material_dept_type, make_total, + make_completion_num, actual_arrive_num, this_arrived_num, quality_hasqualified_num, @@ -192,6 +195,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{materialProcessMethod}, #{materialDeptType}, #{makeTotal}, + #{makeCompletionNum}, #{actualArriveNum}, #{thisArrivedNum}, #{qualityHasqualifiedNum}, @@ -234,6 +238,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" material_process_method = #{materialProcessMethod}, material_dept_type = #{materialDeptType}, make_total = #{makeTotal}, + make_completion_num = #{makeCompletionNum}, actual_arrive_num = #{actualArriveNum}, this_arrived_num = #{thisArrivedNum}, quality_hasqualified_num = #{qualityHasqualifiedNum}, diff --git a/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html b/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html index 5dc2f1c6..c6c12058 100644 --- a/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html +++ b/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html @@ -104,10 +104,10 @@ field: 'materialCode', align: 'center', title: '料号', - formatter: function (value,row,index){ - var curIndex = index; - return ''; - } + // formatter: function (value,row,index){ + // var curIndex = index; + // return ''; + // } }, { field: 'materialName', @@ -393,7 +393,7 @@ var materialDataList = table.map(function(item) { // 根据实际字段名调整 return { - "materialCode":item.materialCode, + "materialNo":item.materialCode, "materialName": item.materialName, "unit": item.unit, "brand": item.brand, @@ -409,7 +409,7 @@ }); // 合并表单数据和表格数据 - const combinedData = Object.assign({}, makeorderData, { sysEquipDetailDtos: materialDataList }); + const combinedData = Object.assign({}, makeorderData, { inboundDetails: materialDataList }); console.log(combinedData) // 使用 JSON.stringify() 序列化数据