|
@ -3,25 +3,27 @@ package com.ruoyi.purchase.service.impl; |
|
|
import com.ruoyi.common.core.domain.entity.SysUser; |
|
|
import com.ruoyi.common.core.domain.entity.SysUser; |
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
|
|
|
import com.ruoyi.common.exception.BusinessException; |
|
|
import com.ruoyi.common.service.ICommonService; |
|
|
import com.ruoyi.common.service.ICommonService; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
|
|
|
import com.ruoyi.financial.domain.FinancialAccountsPayable; |
|
|
import com.ruoyi.financial.service.IFinancialAccountsPayableService; |
|
|
import com.ruoyi.financial.service.IFinancialAccountsPayableService; |
|
|
import com.ruoyi.financial.service.impl.FinancialAccountsPayableServiceImpl; |
|
|
|
|
|
import com.ruoyi.process.general.service.IProcessService; |
|
|
import com.ruoyi.process.general.service.IProcessService; |
|
|
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; |
|
|
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; |
|
|
import com.ruoyi.purchase.domain.PurchaseOrder; |
|
|
import com.ruoyi.purchase.domain.PurchaseOrder; |
|
|
import com.ruoyi.purchase.domain.PurchaseOrderChild; |
|
|
import com.ruoyi.purchase.domain.PurchaseOrderChild; |
|
|
import com.ruoyi.purchase.domain.PurchaseOrderVo; |
|
|
|
|
|
import com.ruoyi.purchase.domain.PurchasePlan; |
|
|
import com.ruoyi.purchase.domain.PurchasePlan; |
|
|
import com.ruoyi.purchase.mapper.PurchaseOrderChildMapper; |
|
|
import com.ruoyi.purchase.mapper.PurchaseOrderChildMapper; |
|
|
import com.ruoyi.purchase.mapper.PurchaseOrderMapper; |
|
|
import com.ruoyi.purchase.mapper.PurchaseOrderMapper; |
|
|
import com.ruoyi.purchase.mapper.PurchasePlanMapper; |
|
|
import com.ruoyi.purchase.mapper.PurchasePlanMapper; |
|
|
import com.ruoyi.purchase.service.IPurchaseOrderService; |
|
|
import com.ruoyi.purchase.service.IPurchaseOrderService; |
|
|
|
|
|
import com.ruoyi.system.domain.SysSupplier; |
|
|
import com.ruoyi.system.mapper.SysUserMapper; |
|
|
import com.ruoyi.system.mapper.SysUserMapper; |
|
|
import com.ruoyi.system.service.ISysAttachFileService; |
|
|
import com.ruoyi.system.service.ISysAttachFileService; |
|
|
import com.ruoyi.system.service.ISysAttachService; |
|
|
import com.ruoyi.system.service.ISysAttachService; |
|
|
import com.ruoyi.system.service.ISysRoleService; |
|
|
import com.ruoyi.system.service.ISysRoleService; |
|
|
|
|
|
import com.ruoyi.system.service.ISysSupplierService; |
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrder; |
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrder; |
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; |
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; |
|
|
import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper; |
|
|
import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper; |
|
@ -35,12 +37,10 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.HashMap; |
|
|
import java.util.*; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.github.pagehelper.page.PageMethod.startPage; |
|
|
import static com.github.pagehelper.page.PageMethod.startPage; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -97,6 +97,9 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private IFinancialAccountsPayableService financialAccountsPayableService; |
|
|
private IFinancialAccountsPayableService financialAccountsPayableService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ISysSupplierService sysSupplierService; |
|
|
/** |
|
|
/** |
|
|
* 查询采购订单 |
|
|
* 查询采购订单 |
|
|
* |
|
|
* |
|
@ -437,7 +440,70 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
@Override |
|
|
|
|
|
public Integer addPurchaseOrderPayable(PurchaseOrder purchaseOrder) { |
|
|
|
|
|
//根据供应商划分物料信息,合计物料不含税单价 ,含税单价,含税总价,不含税总价,实际采购数量
|
|
|
|
|
|
// 获取采购订单的子项列表
|
|
|
|
|
|
List<PurchaseOrderChild> children = purchaseOrder.getPurchaseOrderChildList(); |
|
|
|
|
|
BigDecimal apySupplierNoRmbPrice = new BigDecimal(0); |
|
|
|
|
|
BigDecimal apySupplierTaxRmbPrice = new BigDecimal(0); |
|
|
|
|
|
// 分组供应商的子订单,分组统计各供应商应付单供应商
|
|
|
|
|
|
List<PurchaseOrderChild> supplierGroup = (List<PurchaseOrderChild>) 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<PurchaseOrderChild> 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<SysSupplier> 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) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public ProcessInstance submitApply(PurchaseOrder purchaseOrder) { |
|
|
public ProcessInstance submitApply(PurchaseOrder purchaseOrder) { |
|
|
SysUser user = ShiroUtils.getSysUser(); |
|
|
SysUser user = ShiroUtils.getSysUser(); |
|
|