From 0f3e7c31d657c1ee97d4bf48a6fdab9f86e00fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=99=93=E8=BF=AA?= <2596750866@qq.com> Date: Fri, 15 Nov 2024 14:52:53 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E7=94=9F=E4=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=20=E7=94=9F=E4=BA=A7=E8=AE=A2=E5=8D=95=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E5=85=A5=E5=BA=93=E5=8D=95=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=94=AE=E5=90=8E?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8=E5=AD=97=E6=AE=B5=EF=BC=9B?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E7=94=9F=E4=BA=A7=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=EF=BC=8C=E6=96=B0=E5=A2=9E=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E7=8A=B6=E6=80=81=E5=AD=97=E6=AE=B5=E5=92=8C?= =?UTF-8?q?=E7=94=9F=E4=BA=A7bom=E5=88=97=E8=A1=A8=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=9B=20=E4=BF=AE=E6=94=B9=E8=AE=BE=E5=A4=87=E5=B1=A5?= =?UTF-8?q?=E5=8E=86=E8=AF=A6=E6=83=85=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=93=81=E8=B4=A8=E7=8A=B6=E6=80=81=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=9B=20=E4=BF=AE=E6=94=B9=E7=94=9F=E4=BA=A7=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=83=A8=E9=97=A8=E4=B8=BB=E7=AE=A1=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?service=E6=96=B9=E6=B3=95=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=87=87=E8=B4=AD=E9=83=A8=E9=97=A8=E9=A2=86=E5=AF=BC?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=EF=BC=8C=E8=AE=BE=E7=BD=AE=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E7=8A=B6=E6=80=81=E4=B8=BA=E5=B7=B2=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=EF=BC=9B=20=E6=96=B0=E5=A2=9E=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=B7=B3=E8=BD=AC=E9=87=87=E8=B4=AD=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E3=80=81=E4=B8=8B=E8=BD=BD=E4=B8=8A=E4=BC=A0=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E3=80=81=E5=AF=BC=E5=85=A5=E5=B7=A5=E5=BA=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=88=97=E8=A1=A8=E3=80=81=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=88=97=E8=A1=A8=E3=80=81=E6=9F=A5=E6=89=BE=E5=B7=B2?= =?UTF-8?q?=E5=8A=A0=E7=9A=84=E8=AE=BE=E5=A4=87=E5=B1=A5=E5=8E=86=E3=80=81?= =?UTF-8?q?=E6=9F=A5=E6=89=BE=E6=9C=AA=E6=8F=90=E4=BA=A4/=E4=B8=8D?= =?UTF-8?q?=E5=90=88=E6=A0=BC=E8=AE=BE=E5=A4=87=E5=B1=A5=E5=8E=86controlle?= =?UTF-8?q?r=E6=8E=A5=E5=8F=A3=EF=BC=9B=20=E4=BF=AE=E6=94=B9=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=94=9F=E4=BA=A7=E8=AE=A2=E5=8D=95=E3=80=81=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E5=AE=A1=E6=A0=B8=E3=80=81=E9=87=87=E8=B4=AD=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8service=E6=96=B9=E6=B3=95=EF=BC=9B=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=94=9F=E4=BA=A7=E8=AE=A2=E5=8D=95mapper=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=97=E6=AE=B5=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/domain/ErpInboundOrderDetail.java | 13 + .../controller/SysMakeOrderController.java | 140 +++++++- .../com/ruoyi/system/domain/SysMakeOrder.java | 24 ++ .../ruoyi/system/dto/SysEquipDetailDto.java | 1 + .../system/service/ISysMakeOrderService.java | 10 +- .../service/impl/SysMakeOrderServiceImpl.java | 313 ++++++++++++++---- .../impl/SysMakeorderDeptServiceImpl.java | 8 + .../mapper/system/SysMakeOrderMapper.xml | 9 +- 8 files changed, 433 insertions(+), 85 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpInboundOrderDetail.java b/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpInboundOrderDetail.java index c6bcb7f8..32cdf6ce 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpInboundOrderDetail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpInboundOrderDetail.java @@ -1,6 +1,9 @@ package com.ruoyi.erp.domain; import java.math.BigDecimal; +import java.util.List; + +import com.ruoyi.aftersales.domain.AfterSalesShippingDevice; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; @@ -57,6 +60,8 @@ public class ErpInboundOrderDetail extends BaseEntity private String salesOrderMaterialNo; + private List salesShippingDeviceList; + public void setId(Long id) { this.id = id; @@ -164,6 +169,14 @@ public class ErpInboundOrderDetail extends BaseEntity this.salesOrderMaterialNo = salesOrderMaterialNo; } + public List getSalesShippingDeviceList() { + return salesShippingDeviceList; + } + + public void setSalesShippingDeviceList(List salesShippingDeviceList) { + this.salesShippingDeviceList = salesShippingDeviceList; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) 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 67fbcd6a..1a848b3d 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 @@ -14,6 +14,7 @@ import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.erp.domain.ErpBomImportVo; import com.ruoyi.erp.domain.ErpInboundOrder; import com.ruoyi.erp.service.IErpMaterialService; import com.ruoyi.financial.domain.FinancialReceivables; @@ -24,19 +25,21 @@ import com.ruoyi.system.dto.SysEquipMaterialDto; import com.ruoyi.system.dto.SysMakeorderDeptDto; import com.ruoyi.system.dto.SysMakeorderMaterialDto; import com.ruoyi.system.mapper.OutsourceMaterialMapper; -import com.ruoyi.system.service.ISysMakeOrderService; -import com.ruoyi.system.service.ISysMakeorderDeptService; -import com.ruoyi.system.service.ISysSalesOrderChildService; -import com.ruoyi.system.service.ISysSalesOrderService; +import com.ruoyi.system.service.*; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; +import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; /** * 生产订单Controller @@ -68,6 +71,9 @@ public class SysMakeOrderController extends BaseController @Autowired private OutsourceMaterialMapper outsourceMaterialMapper; + @Autowired + private IProcessIssueRecordService processIssueRecordService; + @GetMapping("/test") public AjaxResult test(){ sysMakeOrderService.generateMakeOrderBySalesOrderCode("XS20240411007"); @@ -140,6 +146,25 @@ public class SysMakeOrderController extends BaseController return prefix + "/gcsh"; } + /** + * 跳转采购审核页面 + */ + @GetMapping("/cgsh/{id}") + public String cgsh(@PathVariable("id") Long id, ModelMap mmap) + { + SysMakeOrder sysMakeOrder = sysMakeOrderService.selectSysMakeOrderById(id); + SysSalesOrder sysSalesOrder = salesOrderService.selectSysSalesOrderBySalesOrderCode(sysMakeOrder.getSaleNo()); + if(StringUtils.isNotNull(sysSalesOrder)){ + sysMakeOrder.setOrderType(sysSalesOrder.getSalesOrderType()); + sysMakeOrder.setSalesman(sysSalesOrder.getBusinessMembers()); + sysMakeOrder.setCustomerName(sysSalesOrder.getEnterpriseName()); + sysMakeOrder.setCustomerId(sysSalesOrder.getEnterpriseCode()); + sysMakeOrder.setCustomerOderCode(sysSalesOrder.getSalesOrderNumber()); + } + mmap.put("sysMakeOrder", sysMakeOrder); + return prefix + "/cgsh"; + } + /** * 跳转添加领料页面 */ @@ -192,8 +217,6 @@ public class SysMakeOrderController extends BaseController /** * 保存添加委外计划 */ -// @RequiresPermissions("system:makeorder:edit") -// @Log(title = "生产订单", businessType = BusinessType.UPDATE) @PostMapping("/addOutsourcePlan") @ResponseBody public AjaxResult addOutsourcePlan(@RequestBody OutsourcePlan outsourcePlan) @@ -252,7 +275,63 @@ public class SysMakeOrderController extends BaseController return toAjax(sysMakeOrderService.addProduceInboundSave(erpInboundOrder)); } + /** + * 下载导入模板 + */ + @GetMapping("/importTemplate") + @ResponseBody + public AjaxResult importTemplate() + { + ExcelUtil util = new ExcelUtil(ProcessIssueRecord.class); + return util.importTemplateExcel("工序问题记录模板"); + } + /* + * 导入工序问题列表*/ + @Transactional(rollbackFor = Exception.class) + @PostMapping("/importProcessIssueRecord") + @ResponseBody + public AjaxResult handleFileUpload(@RequestParam("file") MultipartFile file, + @RequestParam(value = "serialNo",required = true) String serialNo, + @RequestParam(value = "materialNo") String materialNo, + @RequestParam(value = "makeNo") String makeNo){ + // 处理文件上传 + try { + // 验证文件类型 + if (!file.getContentType().equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) { + return AjaxResult.error("无效的文件类型,请上传Excel文件。"); + } + ExcelUtil excelUtil = new ExcelUtil(ProcessIssueRecord.class); + List processIssueRecords = excelUtil.importExcel(file.getInputStream()); + String msg = processIssueRecordService.importProcessIssueRecord(serialNo,materialNo,makeNo,processIssueRecords); + return AjaxResult.success(msg); + } catch (Exception e) { + return AjaxResult.error("文件上传失败: " + e.getMessage()); + } + } + /* + * 显示工序问题列表*/ + @GetMapping("/showRecords/{serialNo}") + public String showRecords(@PathVariable("serialNo") String serialNo, ModelMap mmap) + { + ProcessIssueRecord tempRecord = new ProcessIssueRecord(); + tempRecord.setSerialNo(serialNo); + List processIssueRecordList = processIssueRecordService.selectProcessIssueRecordList(tempRecord); + mmap.put("processIssueRecordList", processIssueRecordList); + return prefix + "/showRecords"; + } + + @PostMapping("/removeRecords") + @ResponseBody + public AjaxResult removeRecords(@RequestParam(value = "serialNo",required = true) String serialNo, + @RequestParam(value = "materialNo") String materialNo, + @RequestParam(value = "makeNo") String makeNo){ + ProcessIssueRecord processIssueRecord = new ProcessIssueRecord(); + processIssueRecord.setMakeNo(makeNo); + processIssueRecord.setMaterialNo(materialNo); + processIssueRecord.setSerialNo(serialNo); + return toAjax(processIssueRecordService.removeProcessIssueRecord(processIssueRecord)); + } /** @@ -282,16 +361,15 @@ public class SysMakeOrderController extends BaseController @PostMapping("/addEquipmentResumeSave") public AjaxResult addEquipmentResumeSave(@RequestBody SysEquipMaterialDto equipMaterialDto) { - - return toAjax(sysMakeOrderService.addEquipmentResumeSave(equipMaterialDto)); + return AjaxResult.success(sysMakeOrderService.addEquipmentResumeSave(equipMaterialDto)); } /** * 查找已经添加的设备履历 */ - @PostMapping("/getEquipMaterialDetails") - @ResponseBody - public TableDataInfo getEquipMaterialDetails(SysEquipMaterialDto equipMaterialDto){ +// @PostMapping("/getEquipMaterialDetails") +// @ResponseBody + public List getEquipMaterialDetails(SysEquipMaterialDto equipMaterialDto){ startPage(); String makeNo = equipMaterialDto.getMakeNo(); String salesOrderCode = equipMaterialDto.getQuoteId(); @@ -300,9 +378,38 @@ public class SysMakeOrderController extends BaseController afterSalesShippingDevice.setSalesOrderCode(salesOrderCode); afterSalesShippingDevice.setMaterialNo(equipMaterialDto.getMaterialCode()); List equipDetailDtos = salesShippingDeviceService.selectAfterSalesShippingDeviceByNoAndCode(afterSalesShippingDevice); - return getDataTable(equipDetailDtos); + return equipDetailDtos; } + /** + * 查找未提交/品质不合格设备履历 + */ + @PostMapping("/getUnqualifyEquipMaterialDetails") + @ResponseBody + public TableDataInfo getUnqualifyEquipMaterialDetails(SysEquipMaterialDto equipMaterialDto){ + startPage(); + List equipDetailDtos = getEquipMaterialDetails(equipMaterialDto); + List filteredEquipDetailDtos = equipDetailDtos.stream() + .filter(dto -> dto.getQualityStatus().equals("0") || dto.getQualityStatus().equals("3")) + .collect(Collectors.toList()); + + return getDataTable(filteredEquipDetailDtos); + } + + /** + * 查找已经添加的设备履历 + */ + @PostMapping("/getQualifyEquipMaterialDetails") + @ResponseBody + public TableDataInfo getQualifyEquipMaterialDetails(SysEquipMaterialDto equipMaterialDto){ + startPage(); + List equipDetailDtos = getEquipMaterialDetails(equipMaterialDto); + List filteredEquipDetailDtos = equipDetailDtos.stream() + .filter(dto -> dto.getQualityStatus().equals("1") || dto.getQualityStatus().equals("2")) + .collect(Collectors.toList()); + + return getDataTable(filteredEquipDetailDtos); + } /** * 部门评审 @@ -347,11 +454,18 @@ public class SysMakeOrderController extends BaseController @RequiresPermissions("system:makeorder:engineer") @PostMapping("/gcReview") @ResponseBody - public AjaxResult gcReview(SysMakeOrder sysMakeOrder){ + public AjaxResult gcReview(@RequestBody SysMakeOrder sysMakeOrder){ sysMakeOrderService.gcReview(sysMakeOrder); return AjaxResult.success("工程审核成功!"); } + @RequiresPermissions("system:makeorder:purchase") + @PostMapping("/cgReview") + @ResponseBody + public AjaxResult cgReview(@RequestBody SysMakeOrder sysMakeOrder){ + sysMakeOrderService.cgReview(sysMakeOrder); + return AjaxResult.success("采购审核成功!"); + } /** * 查询生产订单列表 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeOrder.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeOrder.java index 45639239..24cc69ef 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeOrder.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeOrder.java @@ -6,6 +6,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import java.math.BigDecimal; +import java.util.List; /** * 生产订单对象 sys_makeorder @@ -36,6 +37,11 @@ public class SysMakeOrder extends BaseEntity @Excel(name = "使用状态") private String useStatus; + + /*采购确认状态(0待确认,1已确认)*/ + private String purchaseStatus; + + /** 生产订单号 */ @Excel(name = "生产订单号") private String makeNo; @@ -94,6 +100,8 @@ public class SysMakeOrder extends BaseEntity /** 部门主管确认状态 */ private String deptLeaderConfirmStatus; + private List sysMakeorderBomList; + public void setId(Long id) { this.id = id; @@ -281,6 +289,22 @@ public class SysMakeOrder extends BaseEntity this.deptLeaderConfirmStatus = deptLeaderConfirmStatus; } + public String getPurchaseStatus() { + return purchaseStatus; + } + + public void setPurchaseStatus(String purchaseStatus) { + this.purchaseStatus = purchaseStatus; + } + + public List getSysMakeorderBomList() { + return sysMakeorderBomList; + } + + public void setSysMakeorderBomList(List sysMakeorderBomList) { + this.sysMakeorderBomList = sysMakeorderBomList; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/dto/SysEquipDetailDto.java b/ruoyi-admin/src/main/java/com/ruoyi/system/dto/SysEquipDetailDto.java index e3301af4..d2fc57ca 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/dto/SysEquipDetailDto.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/dto/SysEquipDetailDto.java @@ -37,5 +37,6 @@ public class SysEquipDetailDto implements Serializable { /** 是否添加工序问题记录(0代表是 1代表否) */ private String addProcessIssueRecordFlag; + private String qualityStatus; } 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 03feeb0d..d8e891aa 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,8 +1,10 @@ package com.ruoyi.system.service; +import com.ruoyi.aftersales.domain.AfterSalesShippingDevice; import com.ruoyi.erp.domain.ErpInboundOrder; import com.ruoyi.system.domain.OutsourcePlan; import com.ruoyi.system.domain.SysMakeOrder; +import com.ruoyi.system.domain.SysMakeorderBom; import com.ruoyi.system.dto.SysEquipMaterialDto; import com.ruoyi.system.dto.SysMakeorderMaterialDto; import com.ruoyi.warehouse.domain.WarehouseStorageOrder; @@ -104,6 +106,12 @@ public interface ISysMakeOrderService */ void gcReview(SysMakeOrder sysMakeOrder); + /** + * 采购审核 + * @param sysMakeOrder + */ + void cgReview(SysMakeOrder sysMakeOrder); + List selectMaterialList(SysMakeOrder sysMakeOrder); /* @@ -119,7 +127,7 @@ public interface ISysMakeOrderService /** * 添加保存设备履历 */ - int addEquipmentResumeSave(SysEquipMaterialDto equipMaterialDto); + List addEquipmentResumeSave(SysEquipMaterialDto equipMaterialDto); /** * 添加保存创建生产入库和设备履历设置 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 b2b519e6..fa372669 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 @@ -12,6 +12,8 @@ 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.domain.ErpMaterial; +import com.ruoyi.erp.mapper.ErpMaterialMapper; import com.ruoyi.erp.service.IErpBomService; import com.ruoyi.purchase.service.IPurchasePlanService; import com.ruoyi.quality.domain.QualityOrder; @@ -37,6 +39,7 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.util.*; +import java.util.stream.Collectors; /** * 生产订单Service业务层处理 @@ -98,6 +101,12 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService @Autowired private SysMakeorderBomMapper makeorderBomMapper; + + @Autowired + private ProcessIssueRecordMapper processIssueRecordMapper; + + @Autowired + private ErpMaterialMapper erpMaterialMapper; /** * 查询生产订单 * @@ -242,7 +251,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService // 是 makeOrder.setUseStatus("1"); makeOrder.setSaleNo(salesOrderCode); - makeOrder.setMakeStatus("0"); + makeOrder.setPurchaseStatus("0"); makeOrder.setSalesman(sysSalesOrderVo.getBusinessMembers()); makeOrder.setSaleNo(sysSalesOrderVo.getSalesOrderCode()); makeOrder.setOrderType(sysSalesOrderVo.getSalesOrderType()); @@ -253,68 +262,197 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService makeOrder.setMaterial(String.valueOf(sysSalesOrderVo.getMaterialSum())); String makeNo = redisCache.generateBillNo("PO"); makeOrder.setMakeNo(makeNo); - makeOrder.setCreateTime(sysSalesOrderVo.getApplyTime()); - insertSysMakeOrder(makeOrder); // 生成部门待预审数据 List salesOrderChildList = salesOrderChildService.selectSysSalesOrderChildByQuoteId(salesOrderCode); if(CollectionUtil.isNotEmpty(salesOrderChildList)){ - salesOrderChildList.forEach(t->{ - String materialCode = t.getMaterialCode(); - makeorderDeptService.generateYsDataByMakeNoAndMaterialNo(makeNo,materialCode,salesOrderType); - }); - } - - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void gcReview(SysMakeOrder sysMakeOrder) { - String makeNo = sysMakeOrder.getMakeNo(); - // 定义一个列表用于收集新插入的SysMakeorderBom - List insertedSysMakeorderBoms = new ArrayList<>(); - // 待生产 - sysMakeOrder.setMakeStatus("3"); - updateByMakeNo(sysMakeOrder); - // 根据销售订单物料生成BOM - String saleNo = sysMakeOrder.getSaleNo(); - List salesOrderChildList = salesOrderChildService.selectSysSalesOrderChildByQuoteId(saleNo); - if(CollectionUtil.isNotEmpty(salesOrderChildList)){ + // 根据销售订单物料生成生产订单BOM Long sortNo = 0L; - for (int i = 0; i < salesOrderChildList.size(); i++) { - SysSalesOrderChild sysSalesOrderChild = salesOrderChildList.get(i); + for (SysSalesOrderChild sysSalesOrderChild:salesOrderChildList) { String materialCode = sysSalesOrderChild.getMaterialCode(); - // 0阶 + // 0阶保存(后续采购审核可能会修改0阶) ErpBom erpBom = erpBomService.selectErpBomByOneMaterialNo(materialCode); + if (erpBom != null){ + SysMakeorderBom makeorderBom = new SysMakeorderBom(); + BeanUtils.copyProperties(erpBom,makeorderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark"); + makeorderBom.setMakeNo(makeNo); + makeorderBom.setSalesOrderCode(salesOrderCode); + makeorderBom.setLossRate(erpBom.getLossRate()); + makeorderBom.setUseNum(erpBom.getUseNum()); + makeorderBom.setLevel(0L); + sortNo ++; + makeorderBom.setSortNo(sortNo); + makeorderBom.setOrderNum(sysSalesOrderChild.getMaterialNum()); + makeorderBom.setDeliveryTime(sysSalesOrderChild.getDeliveryTime()); + makeorderBom.setCreateBy(ShiroUtils.getLoginName()); + makeorderBom.setCreateTime(DateUtils.getNowDate()); + makeorderBomService.insertSysMakeorderBom(makeorderBom); Long id = erpBom.getId(); - // 查询1阶及以下 - ErpBom oneLevelBom = new ErpBom(); - oneLevelBom.setParentId(id); - List subBomList = erpBomService.selectOtherOrderErpBomAllLevelList(oneLevelBom); - for (int j = 0; j < subBomList.size(); j++) { - ErpBom subBom = subBomList.get(j); - SysMakeorderBom orderBom = new SysMakeorderBom(); - BeanUtils.copyProperties(subBom,orderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark"); - orderBom.setMakeNo(makeNo); - orderBom.setSalesOrderCode(saleNo); - orderBom.setSalesOrderMaterialNo(materialCode); - orderBom.setLossRate(subBom.getLossRate()); - orderBom.setUseNum(subBom.getUseNum()); - //如果sys_makeorder_bom数据表里面没有入库部门.这里给他加入 - //orderBom.setWarehouseDept(subBom.getWarehouseDept()); - sortNo++; - orderBom.setSortNo(sortNo); - makeorderBomService.insertSysMakeorderBom(orderBom); - insertedSysMakeorderBoms.add(orderBom); + //采购类型无下阶物料, 只有料号为5/6/7/8/9开头时才有bom,其他为原料/辅料 + if(!erpBom.getProcessMethod().equals("0") && materialCode!=null && ((materialCode.startsWith("5"))||(materialCode.startsWith("6")) + ||(materialCode.startsWith("7"))||(materialCode.startsWith("8"))||(materialCode.startsWith("9")))){ + // 查询1阶及以下 + ErpBom oneLevelBom = new ErpBom(); + oneLevelBom.setParentId(id); + + List subBomList = erpBomService.selectPurchaseLimitedErpBomAllLevelList(oneLevelBom); + for (int j = 0; j < subBomList.size(); j++) { + ErpBom subBom = subBomList.get(j); + SysMakeorderBom orderBom = new SysMakeorderBom(); + BeanUtils.copyProperties(subBom,orderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark"); + orderBom.setMakeNo(makeNo); + orderBom.setSalesOrderCode(salesOrderCode); + orderBom.setSalesOrderMaterialNo(materialCode); + orderBom.setLossRate(subBom.getLossRate()); + orderBom.setUseNum(subBom.getUseNum()); + //如果sys_makeorder_bom数据表里面没有入库部门.这里给他加入 + //orderBom.setWarehouseDept(subBom.getWarehouseDept()); + sortNo++; + orderBom.setSortNo(sortNo); + makeorderBom.setCreateBy(ShiroUtils.getLoginName()); + makeorderBom.setCreateTime(DateUtils.getNowDate()); + makeorderBomService.insertSysMakeorderBom(orderBom); + } } }else { - throw new BusinessException("料号为"+materialCode+"的Bom信息不全,请补充!"); + sortNo ++; + SysMakeorderBom sysMakeorderBom = generateMakeorderBom(sortNo,sysSalesOrderChild); + sysMakeorderBom.setMakeNo(makeNo); + sysMakeorderBom.setSalesOrderCode(salesOrderCode); + int result = makeorderBomMapper.insertSysMakeorderBom(sysMakeorderBom); + if(result<=0){ + throw new BusinessException("新增生产bom" + materialCode +"失败"); + } } + makeorderDeptService.generateYsDataByMakeNoAndMaterialNo(makeNo,materialCode,salesOrderType); + } + } + makeOrder.setCreateTime(sysSalesOrderVo.getApplyTime()); + insertSysMakeOrder(makeOrder); + } + //根据销售订单子表生成生产bom0阶 + public SysMakeorderBom generateMakeorderBom(Long sortNo,SysSalesOrderChild sysSalesOrderChild){ + SysMakeorderBom makeorderBom = new SysMakeorderBom(); + makeorderBom.setMaterialNo(sysSalesOrderChild.getMaterialCode()); + makeorderBom.setMaterialName(sysSalesOrderChild.getMaterialName()); + makeorderBom.setMaterialType(sysSalesOrderChild.getMaterialType()); + makeorderBom.setMaterialModel(sysSalesOrderChild.getMaterialModel()); + makeorderBom.setUnit(sysSalesOrderChild.getUnit()); + makeorderBom.setBrand(sysSalesOrderChild.getBrand()); + makeorderBom.setDescribe(sysSalesOrderChild.getDescribe()); + makeorderBom.setProcessMethod(sysSalesOrderChild.getProcessMethod()); + makeorderBom.setLevel(0L); + + makeorderBom.setSortNo(sortNo); + makeorderBom.setOrderNum(sysSalesOrderChild.getMaterialNum()); + makeorderBom.setDeliveryTime(sysSalesOrderChild.getDeliveryTime()); + makeorderBom.setCreateBy(ShiroUtils.getLoginName()); + makeorderBom.setCreateTime(DateUtils.getNowDate()); + return makeorderBom; + } + @Override + @Transactional(rollbackFor = Exception.class) + public void gcReview(SysMakeOrder sysMakeOrder) { + String makeNo = sysMakeOrder.getMakeNo(); + String salesOrderCode = sysMakeOrder.getSaleNo(); + List makeorderBoms = sysMakeOrder.getSysMakeorderBomList(); + /* + * 获取前端返回生产bom列表0阶料号合集(只返回有修改的bom)*/ + Set uniqueMaterialNos = new HashSet<>(); + for (SysMakeorderBom bom : makeorderBoms) { + uniqueMaterialNos.add(bom.getSalesOrderMaterialNo()); + } + /* + * 获取该生产订单关联销售订单中的0阶物料(存在bom)*/ + /*SysSalesOrderChild tempChild = new SysSalesOrderChild(); + tempChild.setQuoteId(salesOrderCode); + List salesOrderChildList = salesOrderChildService.selectSysSalesOrderChildListWithBom(tempChild); +*/ + /* + * 获取该生产订单关联销售订单中的0阶物料(存在bom)*/ + SysMakeorderBom tempMakeorderBom = new SysMakeorderBom(); + tempMakeorderBom.setMakeNo(makeNo); + tempMakeorderBom.setSalesOrderCode(salesOrderCode); + tempMakeorderBom.setLevel(0L); + List tempBomList = makeorderBomService.selectSysMakeorderBomList(tempMakeorderBom); + /* + * 比对获取前端未修改过的bom料号,后续查找生产bom表看其子阶是否为空,另外要去除加工类型为采购的数据*/ + List filteredList = tempBomList.stream() + .filter(child -> !uniqueMaterialNos.contains(child.getMaterialNo())) + .filter(child -> child.getMaterialNo().startsWith("5")||child.getMaterialNo().startsWith("6") + ||child.getMaterialNo().startsWith("7")||child.getMaterialNo().startsWith("8") + ||child.getMaterialNo().startsWith("9")) + .filter(child -> !child.getProcessMethod().equals("0")) + .map(SysMakeorderBom::getMaterialNo) + .collect(Collectors.toList()); + /* + * 判断bom是否为空*/ + if(StringUtils.isNotEmpty(filteredList)){ + for (String code:filteredList) { + SysMakeorderBom tempMakeBom = new SysMakeorderBom(); + tempMakeBom.setMakeNo(makeNo); + tempMakeBom.setSalesOrderCode(salesOrderCode); + tempMakeBom.setSalesOrderMaterialNo(code); + List makeorderBomList = makeorderBomService.selectSysMakeorderBomList(tempMakeBom); + if(StringUtils.isEmpty(makeorderBomList)){ + throw new BusinessException(code + "BOM不能为空"); + } } } + /* + * 删除返回0阶料号的原有bom*/ + for (String materialNo:uniqueMaterialNos) { + SysMakeorderBom tempBom = new SysMakeorderBom(); + tempBom.setMakeNo(makeNo); + tempBom.setSalesOrderCode(salesOrderCode); + tempBom.setSalesOrderMaterialNo(materialNo); + makeorderBomMapper.deleteSysMakeorderBomByNos(tempBom); + } + Long sortNo = 0L; + for (SysMakeorderBom makeBom:makeorderBoms) { + sortNo ++; + makeBom.setSortNo(sortNo); + int insertResult = makeorderBomMapper.insertSysMakeorderBom(makeBom); + if(insertResult<=0){ + throw new BusinessException("bom"+makeBom.getSalesOrderMaterialNo()+"层级添加失败!"); + } + } + // 待采购审核 + sysMakeOrder.setMakeStatus("7"); + updateByMakeNo(sysMakeOrder); // todo 加工方式“采购”的物料生成采购计划 - purchasePlanService.generatePurchasePlanByMakeOrder(insertedSysMakeorderBoms); +// purchasePlanService.generatePurchasePlanByMakeOrder(insertedSysMakeorderBoms); + } + + /* + * 采购审核,修改加工方式委外或采购为采购,若修改则删除下阶物料 + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public void cgReview(SysMakeOrder sysMakeOrder) { + List makeorderBomList = sysMakeOrder.getSysMakeorderBomList(); + if(StringUtils.isNotEmpty(makeorderBomList)){ + for (SysMakeorderBom makeBom:makeorderBomList) { + if(makeBom.getProcessMethod().equals("0")){ + SysMakeorderBom tempBom = new SysMakeorderBom(); + tempBom.setMakeNo(sysMakeOrder.getMakeNo()); + tempBom.setSalesOrderCode(sysMakeOrder.getSaleNo()); + tempBom.setSalesOrderMaterialNo(makeBom.getMaterialNo()); + makeorderBomMapper.deleteSysMakeorderBomByNos(tempBom); + } + makeBom.setUpdateBy(ShiroUtils.getLoginName()); + makeBom.setUpdateTime(DateUtils.getNowDate()); + makeorderBomMapper.updateSysMakeorderBom(makeBom); + } + } +// sysMakeOrder.setMakeStatus("3");//生产状态-待生产 +// sysMakeOrder.setEceiptStatus("0");//入库状态-待采购 + + //测试用状态(跳过采购) + sysMakeOrder.setMakeStatus("4");//生产状态-待生产 + sysMakeOrder.setEceiptStatus("7");//入库状态-待采购 + updateSysMakeOrder(sysMakeOrder); } @Override @@ -322,7 +460,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService return sysMakeOrderMapper.selectMaterialList(sysMakeOrder); } - /* + /* * 品质管理制程检验工序关联生产单号 * */ @Override @@ -380,7 +518,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService */ @Transactional(rollbackFor = Exception.class) @Override - public int addEquipmentResumeSave(SysEquipMaterialDto equipMaterialDto) { + public List addEquipmentResumeSave(SysEquipMaterialDto equipMaterialDto) { if (CollectionUtils.isEmpty(equipMaterialDto.getSysEquipDetailDtos())) { log.warn("设备履历详情数据为空"); throw new BusinessException("设备履历详情数据为空"); @@ -388,6 +526,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService int result = 0; + List shippingDevice = new ArrayList<>(); for (SysEquipDetailDto sysEquipDetailDto : equipMaterialDto.getSysEquipDetailDtos()) { AfterSalesShippingDevice afterSalesShippingDevice = new AfterSalesShippingDevice(); @@ -402,24 +541,43 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService afterSalesShippingDevice.setMaterialDescribe(equipMaterialDto.getDescribe()); afterSalesShippingDevice.setDeviceModelCode(sysEquipDetailDto.getEquipmentModel()); afterSalesShippingDevice.setDeviceRunningNumber(sysEquipDetailDto.getSerialNo()); + afterSalesShippingDevice.setStartMakeTime(sysEquipDetailDto.getStartMakeTime()); + afterSalesShippingDevice.setEndMakeTime(sysEquipDetailDto.getEndMakeTime()); + afterSalesShippingDevice.setAddProcessIssueRecordFlag(sysEquipDetailDto.getAddProcessIssueRecordFlag()); + if (StringUtils.isEmpty(sysEquipDetailDto.getEquipmentId())) { // 如果设备ID为空,说明是新记录,需要插入 afterSalesShippingDevice.setShippingDeviceId(redisCache.generateBillNo("CHSB")); afterSalesShippingDevice.setCreateBy(ShiroUtils.getLoginName()); - afterSalesShippingDevice.setCreateTime(new Date()); + afterSalesShippingDevice.setCreateTime(DateUtils.getNowDate()); + afterSalesShippingDevice.setQualityStatus("0");//待申请 result += afterSalesShippingDeviceMapper.insertAfterSalesShippingDevice(afterSalesShippingDevice); } else { // 设备ID不为空,假设需要更新逻辑(根据业务需求确定是否需要此分支) afterSalesShippingDevice.setShippingDeviceId(sysEquipDetailDto.getEquipmentId()); // 确保ID设置正确 afterSalesShippingDevice.setUpdateBy(ShiroUtils.getLoginName()); - afterSalesShippingDevice.setUpdateTime(new Date()); + afterSalesShippingDevice.setUpdateTime(DateUtils.getNowDate()); + afterSalesShippingDevice.setQualityStatus("0");//待申请 // 注意:这里假设了updateAfterSalesShippingDevice方法是存在的且逻辑正确,根据实际情况调整 result += afterSalesShippingDeviceMapper.updateAfterSalesShippingDevice(afterSalesShippingDevice); } - } - return result; + if(result<=0){ + throw new BusinessException("新增设备履历失败"); + } + shippingDevice.add(afterSalesShippingDevice); + ProcessIssueRecord tempRecord = new ProcessIssueRecord(); + tempRecord.setSerialNo(afterSalesShippingDevice.getDeviceRunningNumber()); + List processIssueRecords = processIssueRecordMapper.selectProcessIssueRecordList(tempRecord); + if(StringUtils.isNotEmpty(processIssueRecords)){ + for (ProcessIssueRecord processRecord:processIssueRecords) { + processRecord.setShippingDeviceId(afterSalesShippingDevice.getShippingDeviceId()); + processIssueRecordMapper.updateProcessIssueRecord(processRecord); + } + } + } + return shippingDevice; } @@ -432,23 +590,40 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService String loginName = ShiroUtils.getLoginName(); erpInboundOrder.setCreateBy(loginName); erpInboundOrder.setCreateTime(DateUtils.getNowDate()); - String qualityOrderCode = redisCache.generateBillNo("PZ"); - QualityOrder qualityOrder = createQualityOrder(qualityOrderCode, erpInboundOrder, loginName); - //更新生产订单的本次完成数 + List inboundDetails = erpInboundOrder.getInboundDetails(); + if(StringUtils.isEmpty(inboundDetails)){ + throw new BusinessException("入库单物料为空!"); + } + int result = 0; long finishNum = erpInboundOrder.getInboundDetails().stream().mapToLong(ErpInboundOrderDetail::getCurrentNum).sum(); - SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderByMakeNo(erpInboundOrder.getMakeNo()); - sysMakeOrder.setFinishNum(finishNum); - int updateSysMakeOrderResult = sysMakeOrderMapper.updateSysMakeOrder(sysMakeOrder); - if (updateSysMakeOrderResult <= 0){ - throw new BusinessException("更新生产订单失败"); + if(finishNum == 0){ + throw new BusinessException("本次完成数不能全为0"); + } + for (ErpInboundOrderDetail inboundDetail:inboundDetails) { + String qualityOrderCode = redisCache.generateBillNo("PZ"); + QualityOrder qualityOrder = createQualityOrder(qualityOrderCode, erpInboundOrder, loginName); + + result += qualityOrderMapper.insertQualityOrder(qualityOrder); + List deviceList = inboundDetail.getSalesShippingDeviceList(); + if(StringUtils.isNotEmpty(deviceList)){ + for (AfterSalesShippingDevice device:deviceList) { + device.setQualityStatus("1");//待品质 + afterSalesShippingDeviceMapper.updateAfterSalesShippingDevice(device); + } + } } - Map materialInfoMap = fetchMaterialInfoMap(erpInboundOrder); - - addQualityOrderDetails(qualityOrder, erpInboundOrder, materialInfoMap); - addQualityOrderReports(qualityOrder, erpInboundOrder, materialInfoMap); + //品质报告单审核通过后再更新已完成数 +// SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderByMakeNo(erpInboundOrder.getMakeNo()); +// long hasFinished = sysMakeOrder.getFinishNum(); +// finishNum += hasFinished; +// sysMakeOrder.setFinishNum(finishNum); +// int updateSysMakeOrderResult = sysMakeOrderMapper.updateSysMakeOrder(sysMakeOrder); +// if (updateSysMakeOrderResult <= 0){ +// throw new BusinessException("更新生产订单失败"); +// } - return qualityOrderMapper.insertQualityOrder(qualityOrder); + return result; } private QualityOrder createQualityOrder(String code, ErpInboundOrder erpInboundOrder, String loginName) { @@ -458,7 +633,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService qualityOrder.setQualityStatus("0"); qualityOrder.setQualityStorageStatus("4"); qualityOrder.setQualityOrderType("1"); - qualityOrder.setCreateTime(new Date()); + qualityOrder.setCreateTime(DateUtils.getNowDate()); qualityOrder.setCreateBy(loginName); return qualityOrder; } @@ -502,7 +677,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService qualityOrderDetail.setMakeTotal(salesOrderChild.getMaterialNum()); qualityOrderDetail.setMakeCompletionNum(Math.toIntExact(detail.getCurrentNum())); qualityOrderDetail.setCreateBy(ShiroUtils.getLoginName()); - qualityOrderDetail.setCreateTime(new Date()); + qualityOrderDetail.setCreateTime(DateUtils.getNowDate()); return qualityOrderDetail; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderDeptServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderDeptServiceImpl.java index 81710fe8..ec08805b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderDeptServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderDeptServiceImpl.java @@ -239,6 +239,14 @@ public class SysMakeorderDeptServiceImpl implements ISysMakeorderDeptService makeOrder.setMakeStatus("2"); makeOrderService.updateByMakeNo(makeOrder); } + // 采购部门领导确认完,采购确认状态更新为已确认 + if ("PUD".equals(deptNumber)) { + SysMakeOrder makeOrder = new SysMakeOrder(); + makeOrder.setMakeNo(makeNo); + // 待采购审核 + makeOrder.setPurchaseStatus("1"); + makeOrderService.updateByMakeNo(makeOrder); + } } @Override diff --git a/ruoyi-admin/src/main/resources/mapper/system/SysMakeOrderMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/SysMakeOrderMapper.xml index eae62152..34651cb9 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/SysMakeOrderMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/SysMakeOrderMapper.xml @@ -31,20 +31,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + select a.id, a.make_status, a.eceipt_status, a.quality_status, a.use_status, a.makeNo, a.saleNo, a.Salesman, a.customerId, a.customerName, a.customerOderCode, a.material , a.materialSum, a.finishNum, a.eceiptNum, a.noRate, a.rate - , a.create_by, a.create_time, a.update_by, a.update_time, a.remark, a.del_flag + , a.create_by, a.create_time, a.update_by, a.update_time, a.remark, a.del_flag,a.purchase_status from sys_makeorder a