From dc6501aa5c59f60341807805f089237ac90f380c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=99=93=E8=BF=AA?= <2596750866@qq.com> Date: Tue, 27 Aug 2024 09:21:18 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E5=93=81=E8=B4=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=20=E5=93=81=E8=B4=A8=E5=8D=95=20=E6=96=B0=E5=A2=9E=E5=93=81?= =?UTF-8?q?=E8=B4=A8=E5=8D=95service=E6=A0=B9=E6=8D=AE=E5=93=81=E8=B4=A8?= =?UTF-8?q?=E5=8D=95=E7=94=9F=E6=88=90=E9=80=80=E6=8D=A2=E8=B4=A7=E5=8D=95?= =?UTF-8?q?=E3=80=81=E6=A0=B9=E6=8D=AE=E5=93=81=E8=B4=A8=E5=8D=95=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=80=80=E6=8D=A2=E8=B4=A7=E5=85=A5=E5=BA=93=E5=8D=95?= =?UTF-8?q?=E3=80=81=E6=A0=B9=E6=8D=AE=E5=93=81=E8=B4=A8=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E7=94=9F=E6=88=90=E9=80=80=E6=8D=A2=E8=B4=A7=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E3=80=81=E6=A0=B9=E6=8D=AE=E5=93=81=E8=B4=A8=E5=8D=95?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E7=94=9F=E6=88=90=E9=80=80=E6=8D=A2=E8=B4=A7?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=E8=AF=A6=E6=83=85=E3=80=81=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=93=81=E8=B4=A8=E5=8D=95=E8=AF=A6=E6=83=85=E5=92=8C?= =?UTF-8?q?=E5=93=81=E8=B4=A8=E6=8A=A5=E5=91=8A=E7=94=9F=E6=88=90=E9=80=80?= =?UTF-8?q?=E6=8D=A2=E8=B4=A7=E6=8A=A5=E5=91=8A=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/QualityOrderServiceImpl.java | 223 +++++++++++++++++- 1 file changed, 214 insertions(+), 9 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java index 8f24fe9f..c712d14b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java @@ -11,20 +11,18 @@ import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.erp.domain.ErpDevelopModifyorder; import com.ruoyi.erp.mapper.ErpDevelopModifyorderMapper; -import com.ruoyi.quality.domain.QualityOrderDetail; -import com.ruoyi.quality.domain.QualityOrderReport; -import com.ruoyi.quality.domain.QualityOrderReportUnqualified; -import com.ruoyi.quality.mapper.QualityOrderDetailMapper; -import com.ruoyi.quality.mapper.QualityOrderReportMapper; -import com.ruoyi.quality.mapper.QualityOrderReportUnqualifiedMapper; +import com.ruoyi.quality.domain.*; +import com.ruoyi.quality.mapper.*; +import com.ruoyi.quality.service.IQualityOrderReportService; import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; +import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper; +import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper; +import com.ruoyi.warehouse.mapper.WarehouseStorageOrderMapper; import com.ruoyi.warehouse.service.IWarehouseStorageOrderService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.ruoyi.quality.mapper.QualityOrderMapper; -import com.ruoyi.quality.domain.QualityOrder; import com.ruoyi.quality.service.IQualityOrderService; import com.ruoyi.common.core.text.Convert; import org.springframework.transaction.annotation.Transactional; @@ -50,6 +48,27 @@ public class QualityOrderServiceImpl implements IQualityOrderService @Autowired private QualityOrderReportMapper orderReportMapper; + @Autowired + private IQualityOrderReportService qualityOrderReportService; + + @Autowired + private QualityRefundsExchangesMapper exchangesMapper; + + @Autowired + private QualityRefundsExchangesDetailMapper exchangesDetailMapper; + + @Autowired + private QualityRefundsExchangesOrderMapper exchangesOrderMapper; + + @Autowired + private QualityRefundsExchangesUnqualifiedMapper exchangesUnqualifiedMapper; + + @Autowired + private WarehouseStorageOrderDetailMapper warehouseStorageDetailMapper; + + @Autowired + private WarehouseStorageOrderMapper warehouseStorageOrderMapper; + @Autowired private QualityOrderReportUnqualifiedMapper orderReportUnqualifiedMapper; @@ -225,7 +244,7 @@ public class QualityOrderServiceImpl implements IQualityOrderService erpDevelopModifyorder.setPurchaseStorageStatus("6"); developModifyorderMapper.updateErpDevelopModifyorder(erpDevelopModifyorder); } - + generateBeforeRefundsExchanges(qualityOrder); int updateResult = qualityOrderMapper.updateQualityOrder(qualityOrder); if (updateResult <= 0){ log.warn("更新品质单失败,未影响任何行"); @@ -233,6 +252,192 @@ public class QualityOrderServiceImpl implements IQualityOrderService return updateResult; } +// 根据品质单生成退换货单 + @Transactional(rollbackFor = Exception.class) + public int generateBeforeRefundsExchanges(QualityOrder qualityOrder){ + QualityRefundsExchanges refundsExchanges = new QualityRefundsExchanges(); + refundsExchanges.setRefundsExchangesCode(redisCache.generateBillNo("THH")); + refundsExchanges.setRelatedOrderCode(qualityOrder.getQualityOrderCode()); + refundsExchanges.setMaterialTotal(qualityOrder.getQualityOrderDetailList().size()); + refundsExchanges.setNumTotal(qualityOrder.getQualityUnqualifiedNum()); + refundsExchanges.setRefundsExchangesStatus("0"); + refundsExchanges.setQualityWarehouseStatus("0"); + refundsExchanges.setQualityPurchaseStatus("0"); + refundsExchanges.setQualityDeliveryStatus("0"); + refundsExchanges.setWarehouseStorageType(qualityOrder.getQualityStorageStatus()); + refundsExchanges.setQualityReturnNode("0"); + refundsExchanges.setDeliveryInspectionTime(qualityOrder.getDeliveryInspectionTime()); + +// 根据品质单生成退换货入库单 + WarehouseStorageOrder warehouseStorageOrder = generateWarehouseStorageOrder(refundsExchanges.getRefundsExchangesCode(),qualityOrder); + int warehouseResult = warehouseStorageOrderMapper.insertWarehouseStorageOrder(warehouseStorageOrder); + if (warehouseResult <= 0){ + log.warn("插入入库单失败,未影响任何行"); + } + List qualityOrderDetailList = orderDetailMapper.selectQualityOrderDetailListByCode(qualityOrder.getQualityOrderCode()); + + if (CollectionUtils.isEmpty(qualityOrderDetailList)){ + throw new BusinessException("品质单详情数据为空"); + } + for (QualityOrderDetail detail: qualityOrderDetailList) { +// 根据品质单详情生成退换货详情 + QualityRefundsExchangesDetail exchangesDetail = generateRefundsExchangesDetail(refundsExchanges.getRefundsExchangesCode(),detail); + int exchangesDetailResult = exchangesDetailMapper.insertQualityRefundsExchangesDetail(exchangesDetail); + if (exchangesDetailResult <= 0){ + log.warn("插入退换货详情失败,未影响任何行"); + } +// 根据品质单详情生成退换货入库单详情 + WarehouseStorageOrderDetail warehouseStorageOrderDetail = generateWarehouseStorageOrderDetail(warehouseStorageOrder.getWarehouseStorageCode(), refundsExchanges.getRefundsExchangesCode(),detail); + int warehouseDetailResult = warehouseStorageDetailMapper.insertWarehouseStorageOrderDetail(warehouseStorageOrderDetail); + if (warehouseDetailResult <= 0){ + log.warn("插入入库单详情失败,未影响任何行"); + } + +// 根据品质报告单生成退换货品质报告单 + QualityOrderReport qualityReport = qualityOrderReportService.selectQualityOrderReportByNoAndCode(detail.getMaterialNo(), detail.getSupplierCode(), detail.getQualityOrderCode()); + QualityRefundsExchangesOrder exchangesOrder = generateQualityRefundsExchangesOrder(refundsExchanges.getRefundsExchangesCode(),qualityReport,detail); + int exchangesOrderResult = exchangesOrderMapper.insertQualityRefundsExchangesOrder(exchangesOrder); + if (exchangesOrderResult <= 0){ + log.warn("插入退换货详情报告失败,未影响任何行"); + } + + QualityOrderReportUnqualified unqualified = new QualityOrderReportUnqualified(); + unqualified.setQualityOrderReportId(qualityReport.getQualityOrderReportId()); + List reportUnqualifiedList = orderReportUnqualifiedMapper.selectOrderReportUnqualifiedByOrderReportId(unqualified); + if (CollectionUtils.isEmpty(reportUnqualifiedList)){ + throw new BusinessException("品质单报告不合格分类数据为空"); + } +// 根据品质报告不合格分类列表生成退换货不合格 + for (QualityOrderReportUnqualified unqualifiedReport:reportUnqualifiedList) { + QualityRefundsExchangesUnqualified exchangesUnqualified = new QualityRefundsExchangesUnqualified(); + exchangesUnqualified.setRefundsExchangesCode(refundsExchanges.getRefundsExchangesCode()); + exchangesUnqualified.setMaterialNo(detail.getMaterialNo()); + exchangesUnqualified.setMaterialName(detail.getMaterialName()); + exchangesUnqualified.setProcessBadClassification(unqualifiedReport.getProcessBadClassification()); + exchangesUnqualified.setProcessBadGrade(unqualifiedReport.getProcessBadGrade()); + exchangesUnqualified.setProcessBadNum(unqualifiedReport.getProcessBadNum()); + exchangesUnqualified.setUnqualifiedReportUrl(unqualifiedReport.getUnqualifiedReportUrl()); + exchangesUnqualified.setInspectionTime(detail.getDeliveryInspectionTime()); + exchangesUnqualified.setCreateBy(ShiroUtils.getLoginName()); + exchangesUnqualified.setCreateTime(DateUtils.getNowDate()); + int exchangeUnqualifiedResult = exchangesUnqualifiedMapper.insertQualityRefundsExchangesUnqualified(exchangesUnqualified); + if (exchangeUnqualifiedResult <= 0){ + log.warn("插入入库单详情失败,未影响任何行"); + } + } + + } + refundsExchanges.setInStorageCode(warehouseStorageOrder.getWarehouseStorageCode()); + refundsExchanges.setCreateBy(ShiroUtils.getLoginName()); + refundsExchanges.setCreateTime(DateUtils.getNowDate()); + return exchangesMapper.insertQualityRefundsExchanges(refundsExchanges); + } +// 根据品质单生成退换货入库单 + public WarehouseStorageOrder generateWarehouseStorageOrder(String refundsExchangesCode, QualityOrder qualityOrder){ + WarehouseStorageOrder warehouseStorageOrder = new WarehouseStorageOrder(); + warehouseStorageOrder.setWarehouseStorageCode(redisCache.generateBillNo("RK")); + warehouseStorageOrder.setRelatedOrderCode(refundsExchangesCode); + warehouseStorageOrder.setWarehouseStorageStatus("2"); + warehouseStorageOrder.setWarehouseQualityStatus(qualityOrder.getQualityStatus()); + warehouseStorageOrder.setWarehouseStorageType("3"); + warehouseStorageOrder.setWarehouseOrderType("2"); + warehouseStorageOrder.setWarehouseDeptType("1"); + warehouseStorageOrder.setActualArrivedNum(qualityOrder.getThisArrivedNum()); + warehouseStorageOrder.setQualityQualifiedNum(qualityOrder.getQualityQualifiedNum()); + warehouseStorageOrder.setQualityUnqualifiedNum(qualityOrder.getQualityUnqualifiedNum()); + warehouseStorageOrder.setStorageNum(qualityOrder.getStorageNum()); + warehouseStorageOrder.setQualityTime(qualityOrder.getDeliveryInspectionTime()); + warehouseStorageOrder.setCreateBy(ShiroUtils.getLoginName()); + warehouseStorageOrder.setCreateTime(DateUtils.getNowDate()); + return warehouseStorageOrder; + } + +// 根据品质单详情生成退换货详情 + public QualityRefundsExchangesDetail generateRefundsExchangesDetail(String refundsExchangesCode,QualityOrderDetail detail){ + QualityRefundsExchangesDetail exchangesDetail = new QualityRefundsExchangesDetail(); + exchangesDetail.setRefundsExchangesCode(refundsExchangesCode); + exchangesDetail.setRefundsExchangesStatus("0"); + exchangesDetail.setQualityWarehouseStatus("0"); + exchangesDetail.setQualityPurchaseStatus("0"); + exchangesDetail.setQualityDeliveryStatus("0"); + exchangesDetail.setRelatedOrderCode(detail.getQualityOrderCode()); + exchangesDetail.setInStorageCode("11"); + exchangesDetail.setQualityWarehouseStatus(detail.getQualityStorageStatus()); + exchangesDetail.setDeliveryInspectionTime(detail.getDeliveryInspectionTime()); + exchangesDetail.setQualityReturnNode("0"); + exchangesDetail.setMaterialNo(detail.getMaterialNo()); + exchangesDetail.setMaterialName(detail.getMaterialName()); + exchangesDetail.setMaterialType(detail.getMaterialType()); + exchangesDetail.setMaterialBrand(detail.getMaterialBrand()); + exchangesDetail.setMaterialPhotourl(detail.getMaterialPhotourl()); + exchangesDetail.setMaterialBrand(detail.getMaterialBrand()); + exchangesDetail.setMaterialProcessMethod(detail.getMaterialProcessMethod()); + exchangesDetail.setMaterialUnit(detail.getMaterialUnit()); + exchangesDetail.setRefundsExchangesNum(detail.getQualityUnqualifiedNum()); + exchangesDetail.setQualityUnqualifiedNum(detail.getQualityUnqualifiedNum()); + exchangesDetail.setSupplierCode(detail.getSupplierCode()); + exchangesDetail.setSupplierName(detail.getSupplierName()); + exchangesDetail.setSupplierAddress(detail.getSupplierAddress()); + exchangesDetail.setCustomerContact(detail.getCustomerContact()); + exchangesDetail.setContactNumber(detail.getContactNumber()); + exchangesDetail.setCreateBy(ShiroUtils.getLoginName()); + exchangesDetail.setCreateTime(DateUtils.getNowDate()); + return exchangesDetail; + } + +// 根据品质单详情生成退换货入库单详情 + public WarehouseStorageOrderDetail generateWarehouseStorageOrderDetail(String warehouseStorageCode,String refundsExchangesCode,QualityOrderDetail detail){ + WarehouseStorageOrderDetail storageOrderDetail = new WarehouseStorageOrderDetail(); + storageOrderDetail.setWarehouseStorageCode(warehouseStorageCode); + storageOrderDetail.setRelatedOrderCode(refundsExchangesCode); + storageOrderDetail.setWarehouseStorageStatus("2"); + storageOrderDetail.setWarehouseQualityStatus(detail.getQualityStatus()); + storageOrderDetail.setWarehouseStorageType("3"); + storageOrderDetail.setWarehouseOrderType("2"); + storageOrderDetail.setWarehouseDeptType("1"); + storageOrderDetail.setSupplierCode(detail.getSupplierCode()); + storageOrderDetail.setSupplierName(detail.getSupplierName()); + storageOrderDetail.setSupplierAddress(detail.getSupplierAddress()); + storageOrderDetail.setCustomerContact(detail.getCustomerContact()); + storageOrderDetail.setContactNumber(detail.getContactNumber()); + storageOrderDetail.setMaterialNo(detail.getMaterialNo()); + storageOrderDetail.setMaterialName(detail.getMaterialName()); + storageOrderDetail.setMaterialType(detail.getMaterialType()); + storageOrderDetail.setMaterialBrand(detail.getMaterialBrand()); + storageOrderDetail.setMaterialPhotourl(detail.getMaterialPhotourl()); + storageOrderDetail.setMaterialBrand(detail.getMaterialBrand()); + storageOrderDetail.setMaterialProcessMethod(detail.getMaterialProcessMethod()); + storageOrderDetail.setMaterialUnit(detail.getMaterialUnit()); + storageOrderDetail.setMakeTotal(detail.getMakeTotal()); + storageOrderDetail.setActualArriveNum(detail.getActualArriveNum()); + storageOrderDetail.setQualityQualifiedNum(detail.getQualityQualifiedNum()); + storageOrderDetail.setQualityHasQualifiedNum(detail.getQualityHasqualifiedNum()); + storageOrderDetail.setRefundsExchangesNum(detail.getQualityUnqualifiedNum()); + storageOrderDetail.setDeliveryInspectionTime(detail.getDeliveryInspectionTime()); + storageOrderDetail.setCreateBy(ShiroUtils.getLoginName()); + storageOrderDetail.setCreateTime(DateUtils.getNowDate()); + return storageOrderDetail; + } + +// 根据品质单详情和品质报告生成退换货报告 + public QualityRefundsExchangesOrder generateQualityRefundsExchangesOrder(String refundsExchangesCode,QualityOrderReport qualityReport,QualityOrderDetail detail){ + QualityRefundsExchangesOrder exchangesOrder = new QualityRefundsExchangesOrder(); + exchangesOrder.setRefundsExchangesCode(refundsExchangesCode); + exchangesOrder.setSupplierCode(detail.getSupplierCode()); + exchangesOrder.setSupplierName(detail.getSupplierName()); + exchangesOrder.setMaterialNo(detail.getMaterialNo()); + exchangesOrder.setMaterialName(detail.getMaterialName()); + exchangesOrder.setMakeTotal(detail.getMakeTotal()); + exchangesOrder.setQualityHasqualifiedNum(detail.getQualityHasqualifiedNum()); + exchangesOrder.setOkAcceptedNum(qualityReport.getOkAcceptedNum()); + exchangesOrder.setOkReportUrl(qualityReport.getOkReportUrl()); + exchangesOrder.setSpecialConcessionsNum(qualityReport.getSpecialConcessionsNum()); + exchangesOrder.setSpecialReportUrl(qualityReport.getSpecialReportUrl()); + exchangesOrder.setCheckoutCompletionTime(qualityReport.getCheckoutCompletionTime()); + exchangesOrder.setCreateBy(ShiroUtils.getLoginName()); + exchangesOrder.setCreateTime(DateUtils.getNowDate()); + return exchangesOrder; + } /** * 删除品质管理品质单对象 *