From ad9f5c11aa48c604b5440a76bdfe15062efd3e9e Mon Sep 17 00:00:00 2001 From: zhangsiqi <2825463979@qq.com> Date: Sat, 6 Jul 2024 19:12:46 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E6=B7=BB=E5=8A=A0=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=89=A9=E6=96=99=E5=88=97=E8=A1=A8=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E9=87=87=E8=B4=AD=E7=89=A9=E6=96=99=E8=BD=AC=E8=B4=A2?= =?UTF-8?q?=E5=8A=A1=E5=BA=94=E4=BB=98=E8=B4=A6=E6=AC=BE=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E6=95=B0=E6=8D=AE=E8=BD=AC=E6=8D=A2=E4=B8=BA=E4=BB=A5?= =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E4=B8=BA=E5=88=86=E7=BB=84=EF=BC=8C?= =?UTF-8?q?=E5=90=88=E8=AE=A1=E5=AF=B9=E6=AF=8F=E4=B8=AA=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E7=9A=84=E5=BA=94=E4=BB=98=E8=B4=A6=E6=AC=BE=EF=BC=8C?= =?UTF-8?q?=E7=94=9F=E6=88=90=E4=B8=8D=E5=90=8C=E7=9A=84=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E7=9B=B8=E5=85=B3=E5=BA=94=E4=BB=98=E8=B4=A6=E6=AC=BE?= =?UTF-8?q?=E3=80=82=E9=9C=80=E6=9F=A5=E8=AF=A2=E4=BE=9B=E5=BA=94=E5=95=86?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E8=B5=84=E6=96=99=EF=BC=8C=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E8=B5=84=E6=96=99=E8=8E=B7=E5=8F=96=E6=9C=89=E5=BC=80=E6=88=B7?= =?UTF-8?q?=E9=93=B6=E8=A1=8C=EF=BC=8C=E4=BB=98=E6=AC=BE=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PurchaseOrderController.java | 2 + .../service/IPurchaseOrderChildService.java | 3 + .../service/IPurchaseOrderService.java | 2 + .../impl/PurchaseOrderServiceImpl.java | 78 +++++++++++++++++-- .../service/impl/PurchasePlanServiceImpl.java | 1 - 5 files changed, 79 insertions(+), 7 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java index 9ca339f5..467a16d8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java @@ -169,6 +169,8 @@ public class PurchaseOrderController extends BaseController purchaseOrder.setUseStatus("0"); purchaseOrder.setDelFlag("0"); purchaseOrderService.insertPurchaseOrder(purchaseOrder); + + purchaseOrderService.addPurchaseOrderPayable(purchaseOrder); // 数据校验,确保前端传入数据格式正确 // 执行主表插入操作 return AjaxResult.success(); // 假设toAjax方法处理成功逻辑 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderChildService.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderChildService.java index 1f52b49f..4bf8c6b7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderChildService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderChildService.java @@ -1,6 +1,8 @@ package com.ruoyi.purchase.service; import java.util.List; + +import com.ruoyi.purchase.domain.PurchaseOrder; import com.ruoyi.purchase.domain.PurchaseOrderChild; /** @@ -78,4 +80,5 @@ public interface IPurchaseOrderChildService List selectPurchaseOrderChildByOrderCodeTotal(String purchaseOrderCode); List selectPurchaseOrderStorageByPurchaseOrderCode(String purchaseOrderCode); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java index bed37a35..b25d1d47 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java @@ -73,6 +73,8 @@ public interface IPurchaseOrderService int addPurchaseOrderStorage(WarehouseStorageOrder warehouseStorageOrder); + Integer addPurchaseOrderPayable(PurchaseOrder purchaseOrder); + @Transactional(rollbackFor = Exception.class) ProcessInstance submitApply(PurchaseOrder purchaseOrder); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java index 913cde60..c2c3205c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java @@ -3,25 +3,27 @@ package com.ruoyi.purchase.service.impl; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.service.ICommonService; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.financial.domain.FinancialAccountsPayable; import com.ruoyi.financial.service.IFinancialAccountsPayableService; -import com.ruoyi.financial.service.impl.FinancialAccountsPayableServiceImpl; import com.ruoyi.process.general.service.IProcessService; import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; import com.ruoyi.purchase.domain.PurchaseOrder; import com.ruoyi.purchase.domain.PurchaseOrderChild; -import com.ruoyi.purchase.domain.PurchaseOrderVo; import com.ruoyi.purchase.domain.PurchasePlan; import com.ruoyi.purchase.mapper.PurchaseOrderChildMapper; import com.ruoyi.purchase.mapper.PurchaseOrderMapper; import com.ruoyi.purchase.mapper.PurchasePlanMapper; import com.ruoyi.purchase.service.IPurchaseOrderService; +import com.ruoyi.system.domain.SysSupplier; import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.service.ISysAttachFileService; import com.ruoyi.system.service.ISysAttachService; import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.system.service.ISysSupplierService; import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper; @@ -35,12 +37,10 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; + import static com.github.pagehelper.page.PageMethod.startPage; /** @@ -97,6 +97,9 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService @Autowired private IFinancialAccountsPayableService financialAccountsPayableService; + + @Autowired + private ISysSupplierService sysSupplierService; /** * 查询采购订单 * @@ -437,7 +440,70 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService return result; } + @Transactional(rollbackFor = Exception.class) @Override + public Integer addPurchaseOrderPayable(PurchaseOrder purchaseOrder) { + //根据供应商划分物料信息,合计物料不含税单价 ,含税单价,含税总价,不含税总价,实际采购数量 + // 获取采购订单的子项列表 + List children = purchaseOrder.getPurchaseOrderChildList(); + BigDecimal apySupplierNoRmbPrice = new BigDecimal(0); + BigDecimal apySupplierTaxRmbPrice = new BigDecimal(0); + // 分组供应商的子订单,分组统计各供应商应付单供应商 + List supplierGroup = (List) children.stream() + // 分组依据为supplierCode + .collect(Collectors.groupingBy(PurchaseOrderChild::getSupplierCode)) + // 把每个分组转为流,然后取第一个元素 + .values().stream() + .map(groupSupplier -> groupSupplier.stream().findFirst().orElse(null)) + // 过滤掉null值,以防万一某些分组是空的 + .filter(Objects::nonNull) + .collect(Collectors.toList()); + //根据物料中提出的供应商列表核对, 遍历每个相关的子订单,合计数据量 + for (PurchaseOrderChild purchaseOrderChild : supplierGroup) { + List purchaseOrderChildList = purchaseOrder.getPurchaseOrderChildList(); + FinancialAccountsPayable financialAccountsPayable = new FinancialAccountsPayable(); + financialAccountsPayable.setAccountsPayableCode(redisCache.generateBillNo("YF")); + financialAccountsPayable.setRelevanceCode(purchaseOrder.getPurchaseOrderCode()); + for (PurchaseOrderChild purchaseOrderChild1 : purchaseOrderChildList) { + BigDecimal supplierNoRmbPrice = purchaseOrderChild1.getMaterialRealNoRmbSum(); + BigDecimal supplierRmbTaxPrice = purchaseOrderChild1.getMaterialRealRmbSum(); + //供应商应付账款 不含税金额 + apySupplierNoRmbPrice = supplierNoRmbPrice.add(supplierNoRmbPrice); + //供应商应付账款 含税金额 + apySupplierTaxRmbPrice = apySupplierTaxRmbPrice.add(supplierRmbTaxPrice); + //每当当前供应商完成一次循环,生成一条供应商应付账款 + + SysSupplier sysSupplier = new SysSupplier(); + sysSupplier.setSupplierCode(purchaseOrderChild1.getSupplierCode()); + + List sysSupplierList = sysSupplierService.selectSysSupplierList(sysSupplier); + financialAccountsPayable.setSupplierCode(purchaseOrderChild.getSupplierCode()); + financialAccountsPayable.setSupplierName(purchaseOrderChild.getSupplierName()); + int supplierListSize = sysSupplierList.size(); + if(supplierListSize == 0){ + continue; + }else{ + SysSupplier sysSupplier1 = sysSupplierList.get(0); + //获取供应商相关的信息 + financialAccountsPayable.setOpenBank(sysSupplier1.getDepositBank()); + financialAccountsPayable.setOpenAccount(sysSupplier1.getBankAccount()); + financialAccountsPayable.setPaymentCondition(sysSupplier1.getPaymentTerms()); + } + } + financialAccountsPayable.setCreateBy(ShiroUtils.getLoginName()); + financialAccountsPayable.setCreateTime(DateUtils.getNowDate()); + financialAccountsPayable.setPurchaseBuyer(purchaseOrder.getPurchaseBuyer()); + //不含税金额 + financialAccountsPayable.setPriceExcludingTax(apySupplierNoRmbPrice); + //含税金额 + financialAccountsPayable.setPriceIncludesTax(apySupplierTaxRmbPrice); + financialAccountsPayable.setStorageStatus("0"); + financialAccountsPayable.setAccountsPayableStatus("0"); + financialAccountsPayableService.insertFinancialAccountsPayable(financialAccountsPayable); + } + //根据供应商编分组,合计供应商总共合计了多少数,采购物采购,采购物料料 + return 1; // 返回成功标识 + } @Transactional(rollbackFor = Exception.class) public ProcessInstance submitApply(PurchaseOrder purchaseOrder) { SysUser user = ShiroUtils.getSysUser(); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java index 6a0b4fb7..50483190 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java @@ -182,7 +182,6 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService //统计物料种类的数量 Integer materialAmount = filterUniqueBoms.size(); - // 仅查询一次,因为所有SysMakeorderBom都关联同一生产单号 SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderByMakeNo(insertedSysMakeorderBoms.get(0).getMakeNo());