|
@@ -53,10 +53,7 @@ import com.fjhx.sale.entity.pack.po.PackDetailProduct;
|
|
import com.fjhx.sale.entity.pack.vo.PackDetailProductVo;
|
|
import com.fjhx.sale.entity.pack.vo.PackDetailProductVo;
|
|
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseDto;
|
|
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseDto;
|
|
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseSelectDto;
|
|
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseSelectDto;
|
|
-import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
|
|
|
|
-import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProduct;
|
|
|
|
-import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProductMountings;
|
|
|
|
-import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProject;
|
|
|
|
|
|
+import com.fjhx.sale.entity.purchase.po.*;
|
|
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseDocumentaryVo;
|
|
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseDocumentaryVo;
|
|
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseProductVo;
|
|
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseProductVo;
|
|
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo;
|
|
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo;
|
|
@@ -66,10 +63,7 @@ import com.fjhx.sale.mapper.purchase.EhsdPurchaseProductMapper;
|
|
import com.fjhx.sale.service.contract.ContractService;
|
|
import com.fjhx.sale.service.contract.ContractService;
|
|
import com.fjhx.sale.service.pack.PackDetailProductService;
|
|
import com.fjhx.sale.service.pack.PackDetailProductService;
|
|
import com.fjhx.sale.service.pack.PackDetailService;
|
|
import com.fjhx.sale.service.pack.PackDetailService;
|
|
-import com.fjhx.sale.service.purchase.EhsdPurchaseProductMountingsService;
|
|
|
|
-import com.fjhx.sale.service.purchase.EhsdPurchaseProductService;
|
|
|
|
-import com.fjhx.sale.service.purchase.EhsdPurchaseProjectService;
|
|
|
|
-import com.fjhx.sale.service.purchase.EhsdPurchaseService;
|
|
|
|
|
|
+import com.fjhx.sale.service.purchase.*;
|
|
import com.fjhx.supply.entity.supplier.po.SupplierInfo;
|
|
import com.fjhx.supply.entity.supplier.po.SupplierInfo;
|
|
import com.fjhx.supply.entity.supplier.po.SupplierPrice;
|
|
import com.fjhx.supply.entity.supplier.po.SupplierPrice;
|
|
import com.fjhx.supply.entity.supplier.vo.SupplierPriceVo;
|
|
import com.fjhx.supply.entity.supplier.vo.SupplierPriceVo;
|
|
@@ -77,7 +71,6 @@ import com.fjhx.supply.service.supplier.SupplierInfoService;
|
|
import com.fjhx.supply.service.supplier.SupplierPriceService;
|
|
import com.fjhx.supply.service.supplier.SupplierPriceService;
|
|
import com.fjhx.tenant.utils.DeptUstil;
|
|
import com.fjhx.tenant.utils.DeptUstil;
|
|
import com.fjhx.wms.entity.stock.po.StockWait;
|
|
import com.fjhx.wms.entity.stock.po.StockWait;
|
|
-import com.fjhx.wms.service.stock.StockWaitDetailsService;
|
|
|
|
import com.fjhx.wms.service.stock.StockWaitService;
|
|
import com.fjhx.wms.service.stock.StockWaitService;
|
|
import com.ruoyi.common.core.domain.BasePo;
|
|
import com.ruoyi.common.core.domain.BasePo;
|
|
import com.ruoyi.common.core.domain.BaseSelectDto;
|
|
import com.ruoyi.common.core.domain.BaseSelectDto;
|
|
@@ -155,7 +148,7 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
|
|
@Autowired
|
|
@Autowired
|
|
private EhsdPurchaseProductMapper ehsdPurchaseProductMapper;
|
|
private EhsdPurchaseProductMapper ehsdPurchaseProductMapper;
|
|
@Autowired
|
|
@Autowired
|
|
- private StockWaitDetailsService stockWaitDetailsService;
|
|
|
|
|
|
+ private PurchaseBackService purchaseBackService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 分页
|
|
* 分页
|
|
@@ -182,8 +175,8 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
|
|
}
|
|
}
|
|
|
|
|
|
//权限过滤:采购
|
|
//权限过滤:采购
|
|
- wrapper.in("t1", EhsdPurchase::getCompanyId, SecurityUtils.getCompanyIds());
|
|
|
|
- wrapper.eq("t1", EhsdPurchase::getCompanyId, dto.getCompanyId());
|
|
|
|
|
|
+ wrapper.in("t1", EhsdPurchase::getCompanyId, SecurityUtils.getCompanyIds());
|
|
|
|
+ wrapper.eq("t1", EhsdPurchase::getCompanyId, dto.getCompanyId());
|
|
|
|
|
|
|
|
|
|
wrapper.orderByDesc("t1", EhsdPurchase::getCreateTime);
|
|
wrapper.orderByDesc("t1", EhsdPurchase::getCreateTime);
|
|
@@ -199,15 +192,33 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
|
|
// 赋值流程id
|
|
// 赋值流程id
|
|
flowExampleService.setFlowId(records, EhsdPurchaseVo::setFlowId);
|
|
flowExampleService.setFlowId(records, EhsdPurchaseVo::setFlowId);
|
|
|
|
|
|
- //赋值以付款金额
|
|
|
|
|
|
+ //赋值已付款金额
|
|
List<Long> pids = records.stream().map(EhsdPurchaseVo::getId).collect(Collectors.toList());
|
|
List<Long> pids = records.stream().map(EhsdPurchaseVo::getId).collect(Collectors.toList());
|
|
List<PayDetailVo> payDetailVoList = payDetailService.getSumMoneyByPurchaseIds(pids);
|
|
List<PayDetailVo> payDetailVoList = payDetailService.getSumMoneyByPurchaseIds(pids);
|
|
Map<Long, BigDecimal> payMap = payDetailVoList.stream().collect(Collectors.toMap(PayDetailVo::getPurchaseId, PayDetailVo::getSumMoney));
|
|
Map<Long, BigDecimal> payMap = payDetailVoList.stream().collect(Collectors.toMap(PayDetailVo::getPurchaseId, PayDetailVo::getSumMoney));
|
|
records.forEach(item -> item.setSumPayMoney(payMap.getOrDefault(item.getId(), BigDecimal.ZERO)));
|
|
records.forEach(item -> item.setSumPayMoney(payMap.getOrDefault(item.getId(), BigDecimal.ZERO)));
|
|
|
|
|
|
|
|
+ //赋值采购退货金额
|
|
|
|
+ Map<Long, List<PurchaseBack>> purchaseBackMap = purchaseBackService.mapKGroup(PurchaseBack::getPurchaseId, q -> q
|
|
|
|
+ .in(PurchaseBack::getPurchaseId, pids)
|
|
|
|
+ .in(PurchaseBack::getStatus, FlowStatusEnum1.PASS, FlowStatusEnum1.UPDATE_LOADING)
|
|
|
|
+ );
|
|
|
|
+ for (EhsdPurchaseVo record : records) {
|
|
|
|
+ //赋值退货金额、应付金额
|
|
|
|
+ List<PurchaseBack> purchaseBackList = purchaseBackMap.getOrDefault(record.getId(), new ArrayList<>());
|
|
|
|
+ BigDecimal backAmount = purchaseBackList.stream().map(PurchaseBack::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ record.setBackAmount(backAmount);
|
|
|
|
+ record.setPayableAmount(record.getAmount().subtract(backAmount));
|
|
|
|
+ }
|
|
|
|
+
|
|
//赋值用户名称
|
|
//赋值用户名称
|
|
UserUtil.assignmentNickName(records, EhsdPurchase::getCreateUser, EhsdPurchase::setUserName);
|
|
UserUtil.assignmentNickName(records, EhsdPurchase::getCreateUser, EhsdPurchase::setUserName);
|
|
|
|
|
|
|
|
+ //赋值供应商名称
|
|
|
|
+ supplierInfoService.attributeAssign(records, EhsdPurchase::getSellCorporationId, (item, supply) -> {
|
|
|
|
+ item.setSellCorporationName(supply.getName());
|
|
|
|
+ });
|
|
|
|
+
|
|
//获取生产公司信息
|
|
//获取生产公司信息
|
|
List<Long> companyIds = records.stream().map(EhsdPurchase::getCompanyId).collect(Collectors.toList());
|
|
List<Long> companyIds = records.stream().map(EhsdPurchase::getCompanyId).collect(Collectors.toList());
|
|
Map<Long, String> companyNameMap = DeptUstil.getDeptNameMap(companyIds);
|
|
Map<Long, String> companyNameMap = DeptUstil.getDeptNameMap(companyIds);
|
|
@@ -587,6 +598,13 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
|
|
|
|
|
|
List<EhsdPurchaseVo> ehsdPurchases = BeanUtil.copyToList(list, EhsdPurchaseVo.class);
|
|
List<EhsdPurchaseVo> ehsdPurchases = BeanUtil.copyToList(list, EhsdPurchaseVo.class);
|
|
List<Long> ids = list.stream().distinct().map(EhsdPurchase::getId).collect(Collectors.toList());
|
|
List<Long> ids = list.stream().distinct().map(EhsdPurchase::getId).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ //赋值采购退货金额
|
|
|
|
+ Map<Long, List<PurchaseBack>> purchaseBackMap = purchaseBackService.mapKGroup(PurchaseBack::getPurchaseId, q -> q
|
|
|
|
+ .in(PurchaseBack::getPurchaseId, ids)
|
|
|
|
+ .in(PurchaseBack::getStatus, FlowStatusEnum1.PASS, FlowStatusEnum1.UPDATE_LOADING)
|
|
|
|
+ );
|
|
|
|
+
|
|
List<InvoiceDetailsVo> invoiceDetailsList = invoiceDetailsService.getSumMoneyByPurchaseIds(ids);
|
|
List<InvoiceDetailsVo> invoiceDetailsList = invoiceDetailsService.getSumMoneyByPurchaseIds(ids);
|
|
Map<Long, BigDecimal> invoiceMap = invoiceDetailsList.stream().collect(Collectors.toMap(InvoiceDetailsVo::getPurchaseId, InvoiceDetailsVo::getSumMoney));
|
|
Map<Long, BigDecimal> invoiceMap = invoiceDetailsList.stream().collect(Collectors.toMap(InvoiceDetailsVo::getPurchaseId, InvoiceDetailsVo::getSumMoney));
|
|
List<PayDetailVo> payDetailVoList = payDetailService.getSumMoneyByPurchaseIds(ids);
|
|
List<PayDetailVo> payDetailVoList = payDetailService.getSumMoneyByPurchaseIds(ids);
|
|
@@ -602,6 +620,12 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
|
|
} else {
|
|
} else {
|
|
p.setSumPayMoney(BigDecimal.ZERO);
|
|
p.setSumPayMoney(BigDecimal.ZERO);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //赋值退货金额、应付金额
|
|
|
|
+ List<PurchaseBack> purchaseBackList = purchaseBackMap.getOrDefault(p.getId(), new ArrayList<>());
|
|
|
|
+ BigDecimal backAmount = purchaseBackList.stream().map(PurchaseBack::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ p.setBackAmount(backAmount);
|
|
|
|
+ p.setPayableAmount(p.getAmount().subtract(backAmount));
|
|
}
|
|
}
|
|
|
|
|
|
return ehsdPurchases;
|
|
return ehsdPurchases;
|