From 1ec94c00e5c312818c9e1e3742ca838e60b7e5e7 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期一, 20 十月 2025 17:15:10 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java | 514 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 486 insertions(+), 28 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java
index 38a2573..98633e0 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpProcurementServiceImpl.java
@@ -7,9 +7,16 @@
import com.ruoyi.common.core.domain.BaseModel;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.dto.AddProcurementDto;
+import com.ruoyi.system.export.PlatformLedgerReportExport;
+import com.ruoyi.system.export.ProcurementReportClinicExport;
+import com.ruoyi.system.export.ProcurementReportPlatformExport;
+import com.ruoyi.system.export.ProcurementReportSupplierExport;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.model.*;
+import com.ruoyi.system.query.ClinicProcurementReportQuery;
+import com.ruoyi.system.query.PerformanceReportQuery;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.TErpProcurementQuery;
import com.ruoyi.system.service.TErpGoodsService;
@@ -32,6 +39,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.net.ssl.SSLContext;
@@ -44,9 +52,13 @@
import java.math.RoundingMode;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -99,6 +111,17 @@
@Resource
private TErpSupplierOutboundGoodsMapper erpSupplierOutboundGoodsMapper;
+ @Resource
+ private TCrmWarehouseMapper crmWarehouseMapper;
+ @Resource
+ private TCrmBranchMapper crmBranchMapper;
+ @Resource
+ private TCrmSalespersonMapper crmSalespersonMapper;
+ @Resource
+ private TCrmChangePointsMapper crmChangePointsMapper;
+ @Resource
+ private TErpProcurementCommissionMapper erpProcurementCommissionMapper;
+
@Override
public PageInfo<TErpProcurementVo> pageList(TErpProcurementQuery query, SysUser user) {
@@ -136,25 +159,25 @@
List<String> ids = list.stream().map(TErpProcurementVo::getId).collect(Collectors.toList());
List<TErpProcurementGoods> tErpProcurementGoods = erpProcurementGoodsMapper.selectList
(new LambdaQueryWrapper<TErpProcurementGoods>().in(TErpProcurementGoods::getProcurementId, ids));
- List<TSysCommission> tSysCommissions = new ArrayList<>();
- if (!tErpProcurementGoods.isEmpty()) {
- List<String> collect = tErpProcurementGoods.stream().map(TErpProcurementGoods::getId).collect(Collectors.toList());
- tSysCommissions = sysCommissionMapper.selectList(new LambdaQueryWrapper<TSysCommission>().in(TSysCommission::getTErpProcurementGoodsId, collect));
- }
+//// List<TSysCommission> tSysCommissions = new ArrayList<>();
+// if (!tErpProcurementGoods.isEmpty()) {
+//// List<String> collect = tErpProcurementGoods.stream().map(TErpProcurementGoods::getId).collect(Collectors.toList());
+//// tSysCommissions = sysCommissionMapper.selectList(new LambdaQueryWrapper<TSysCommission>().in(TSysCommission::getTErpProcurementGoodsId, collect));
+// }
for (TErpProcurementVo tErpProcurementVo : list) {
List<TErpProcurementGoods> collect = tErpProcurementGoods.stream().filter(e -> e.getProcurementId().equals(tErpProcurementVo.getId())).collect(Collectors.toList());
int size = collect.stream().map(TErpProcurementGoods::getGoodsId).collect(Collectors.toSet()).size();
tErpProcurementVo.setTypeNum(size);
BigDecimal reduce = collect.stream().map(TErpProcurementGoods::getTotalPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
tErpProcurementVo.setTotalPrice(reduce);
- if (!collect.isEmpty()) {
- List<String> collect1 = collect.stream().map(TErpProcurementGoods::getId).collect(Collectors.toList());
- List<TSysCommission> collect2 = tSysCommissions.stream().filter(e -> collect1.contains(e.getTErpProcurementGoodsId())).collect(Collectors.toList());
- BigDecimal reduce1 = collect2.stream().filter(e -> e.getType() == 1).map(TSysCommission::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
- BigDecimal reduce2 = collect2.stream().filter(e -> e.getType() == 2).map(TSysCommission::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
- tErpProcurementVo.setPlatformMoney(reduce1);
- tErpProcurementVo.setSupplierMoney(reduce2);
- }
+// if (!collect.isEmpty()) {
+//// List<String> collect1 = collect.stream().map(TErpProcurementGoods::getId).collect(Collectors.toList());
+//// List<TSysCommission> collect2 = tSysCommissions.stream().filter(e -> collect1.contains(e.getTErpProcurementGoodsId())).collect(Collectors.toList());
+//// BigDecimal reduce1 = collect2.stream().filter(e -> e.getType() == 1).map(TSysCommission::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
+//// BigDecimal reduce2 = collect2.stream().filter(e -> e.getType() == 2).map(TSysCommission::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
+//// tErpProcurementVo.setPlatformMoney(reduce1);
+//// tErpProcurementVo.setSupplierMoney(reduce2);
+// }
}
@@ -168,15 +191,15 @@
Integer roleType = user.getRoleType();
- String supplierClinicId = null;
+ List<String> supplierClinicId = null;
if (roleType == 6) {
- // 供应商
- TCrmSupplier crmSupplier = crmSupplierMapper.selectOne(Wrappers.lambdaQuery(TCrmSupplier.class)
- .eq(TCrmSupplier::getUserId, user.getUserId())
+
+ TCrmWarehouse warehouse = crmWarehouseMapper.selectOne(Wrappers.lambdaQuery(TCrmWarehouse.class)
+ .eq(TCrmWarehouse::getUserId, user.getUserId())
.last("LIMIT 1"));
- supplierClinicId = crmSupplier.getId();
-
-
+ // 供应商
+ supplierClinicId = crmSupplierMapper.selectList(Wrappers.lambdaQuery(TCrmSupplier.class)
+ .eq(TCrmSupplier::getWarehouseId, warehouse.getId())).stream().map(TCrmSupplier::getId).collect(Collectors.toList());
String sTime = null;
String eTime = null;
if (query.getTime() != null && !query.getTime().isEmpty()) {
@@ -184,7 +207,11 @@
sTime = split[0] + " 00:00:00";
eTime = split[1] + " 23:59:59";
}
+
PageInfo<TErpProcurementVo> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
+ if(CollectionUtils.isEmpty(supplierClinicId)){
+ return pageInfo;
+ }
List<TErpProcurementVo> list = this.baseMapper.pageListWarehouse(query, pageInfo, user, sTime, eTime, supplierClinicId);
// if (list.isEmpty()) {
// return pageInfo;
@@ -302,7 +329,7 @@
@Override
public PageInfo<TErpGoods> pageGoodsPageList(TErpGoodsQuery query, SysUser user) {
PageInfo<TErpGoods> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
- PageInfo<TErpGoods> p = erpGoodsMapper.selectPage(pageInfo, new LambdaQueryWrapper<TErpGoods>().eq(TErpGoods::getGoodsSource, 1).isNotNull(TErpGoods::getClinicPurchasePrice).orderByDesc(BaseModel::getCreateTime));
+ PageInfo<TErpGoods> p = erpGoodsMapper.selectPage(pageInfo, new LambdaQueryWrapper<TErpGoods>().eq(TErpGoods::getState,1).eq(TErpGoods::getGoodsSource, 1).isNotNull(TErpGoods::getClinicPurchasePrice).orderByDesc(BaseModel::getCreateTime));
List<TErpGoods> list = p.getRecords();
List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList());
@@ -377,7 +404,7 @@
BigDecimal all = BigDecimal.ZERO;
for (AddProcurementDto addProcurementDto : value) {
- BigDecimal multiply = addProcurementDto.getSalesAmount().multiply(BigDecimal.valueOf(addProcurementDto.getPurchaseCount()));
+ BigDecimal multiply = addProcurementDto.getGoodsSalesAmount().multiply(BigDecimal.valueOf(addProcurementDto.getPurchaseCount()));
all = all.add(multiply);
}
tErpProcurement.setPayMoney(all);
@@ -404,7 +431,9 @@
tErpProcurementGoods.setQuasiNumber(goods.getQuasiNumber());
TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(goods.getPackingUnitId());
- tErpProcurementGoods.setUnitName(tErpGoodsUnit.getUnitName());
+ if(tErpGoodsUnit!=null){
+ tErpProcurementGoods.setUnitName(tErpGoodsUnit.getUnitName());
+ }
tErpProcurementGoods.setPurchasePrice(dto.getGoodsSalesAmount());
tErpProcurementGoods.setSalesAmount(dto.getSalesAmount());
tErpProcurementGoods.setTotalPrice(dto.getGoodsSalesAmount().multiply(new BigDecimal(dto.getPurchaseCount())));
@@ -426,7 +455,7 @@
if (tErpProcurement.getMoney().doubleValue() < 0) {
throw new RuntimeException("金额设置错误,请联系平台管理员");
}
- tErpProcurement.sets
+ tErpProcurement.setSupplierMoney(supplierCommissionPrice);
this.save(tErpProcurement);
tErpProcurementGoods1.forEach(e -> e.setProcurementId(tErpProcurement.getId()));
erpProcurementGoodsService.saveBatch(tErpProcurementGoods1);
@@ -438,6 +467,13 @@
public DetailProcurementVO detailProcurement(String clinicSupplierId, SysUser user, String id) {
DetailProcurementVO detailProcurementVO = new DetailProcurementVO();
TErpProcurement tErpProcurement = this.getById(id);
+ if (tErpProcurement.getWarehousingUserId()!=null && !tErpProcurement.getWarehousingUserId().isEmpty()) {
+ SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(tErpProcurement.getWarehousingUserId()));
+ detailProcurementVO.setWarehousingUserName(sysUser.getUserName());
+ }
+ detailProcurementVO.setWarehousingTime(tErpProcurement.getWarehousingTime());
+
+
detailProcurementVO.setStatus(tErpProcurement.getStatus());
detailProcurementVO.setCreateTime(tErpProcurement.getCreateTime());
detailProcurementVO.setSendTime(tErpProcurement.getSendTime());
@@ -460,6 +496,25 @@
detailProcurementNextVO.setTotalPrice(tErpProcurement.getPayMoney());
detailProcurementNextVO.setId(tErpProcurementGoods.getId());
detailProcurementNextVO.setPurchasePrice(tErpProcurementGoods.getPurchasePrice());
+
+ List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getProcurementGoodsId, tErpProcurementGoods.getId()));
+ if(!tErpSupplierOutboundGoods.isEmpty()){
+ ArrayList<DetailProcurementNextThreeVO> detailProcurementNextThreeVOS = new ArrayList<>();
+ List<String> collect = tErpSupplierOutboundGoods.stream().map(TErpSupplierOutboundGoods::getWarehousingBatchId).collect(Collectors.toList());
+ List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectBatchIds(collect);
+ for (TErpSupplierOutboundGoods tErpSupplierOutboundGood : tErpSupplierOutboundGoods) {
+ List<TErpSupplierWarehousingBatch> collect1 = tErpSupplierWarehousingBatches.stream().filter(e -> e.getId().equals(tErpSupplierOutboundGood.getWarehousingBatchId())).collect(Collectors.toList());
+ for (TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch : collect1) {
+ DetailProcurementNextThreeVO detailProcurementNextThreeVO = new DetailProcurementNextThreeVO();
+ detailProcurementNextThreeVO.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
+ detailProcurementNextThreeVO.setProductionDate(tErpSupplierWarehousingBatch.getProductionDate());
+ detailProcurementNextThreeVO.setExpirationDate(tErpSupplierWarehousingBatch.getExpiryDate());
+ detailProcurementNextThreeVO.setNum(tErpSupplierOutboundGood.getOutboundCount());
+ detailProcurementNextThreeVOS.add(detailProcurementNextThreeVO);
+ }
+ }
+ detailProcurementNextVO.setDetailProcurementNextThreeVOS(detailProcurementNextThreeVOS);
+ }
detailProcurementNextVOS.add(detailProcurementNextVO);
}
detailProcurementVO.setList(detailProcurementNextVOS);
@@ -468,11 +523,11 @@
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
- public void detailProcurementSend(String clinicSupplierId, SysUser user, String id) {
+ public void detailProcurementSend(List<String> clinicSupplierId, SysUser user, String id,String logisticsNumber) {
// 查出这个采购的下级商品
List<TErpProcurementGoods> list = erpProcurementGoodsService.list(new QueryWrapper<TErpProcurementGoods>().eq("procurement_id", id));
List<TErpSupplierWarehousing> tErpSupplierWarehousings = erpSupplierWarehousingMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousing>()
- .eq(TErpSupplierWarehousing::getSupplierId, clinicSupplierId).in(TErpSupplierWarehousing::getGoodsId, list.stream().map(TErpProcurementGoods::getGoodsId).collect(Collectors.toList()))
+ .in(TErpSupplierWarehousing::getSupplierId, clinicSupplierId).in(TErpSupplierWarehousing::getGoodsId, list.stream().map(TErpProcurementGoods::getGoodsId).collect(Collectors.toList()))
.orderByAsc(BaseModel::getCreateTime));
if(tErpSupplierWarehousings.isEmpty()){
@@ -516,7 +571,7 @@
if(count>=purchaseCount){
// 添加出库记录
TErpSupplierOutbound tErpSupplierOutbound= new TErpSupplierOutbound();
- tErpSupplierOutbound.setSupplierId(clinicSupplierId);
+ tErpSupplierOutbound.setSupplierId(tErpSupplierWarehousing.getSupplierId());
tErpSupplierOutbound.setWarehouseId(tErpSupplierWarehousing.getWarehouseId());
tErpSupplierOutbound.setOutboundType(7);
//TODO 确定这个是采购价还是销售价格
@@ -530,6 +585,7 @@
tErpSupplierOutboundGoods.setWarehousingBatchId(warehousingBatch.getId());
tErpSupplierOutboundGoods.setOutboundCount(purchaseCount);
tErpSupplierOutboundGoods.setTotalPrice(tErpProcurementGoods.getPurchasePrice().multiply(new BigDecimal(purchaseCount)));
+ tErpSupplierOutboundGoods.setProcurementGoodsId(tErpProcurementGoods.getId());
erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods);
continue outer;
}
@@ -538,7 +594,7 @@
purchaseCount = purchaseCount - count;
// 添加出库记录
TErpSupplierOutbound tErpSupplierOutbound= new TErpSupplierOutbound();
- tErpSupplierOutbound.setSupplierId(clinicSupplierId);
+ tErpSupplierOutbound.setSupplierId(tErpSupplierWarehousing.getSupplierId());
tErpSupplierOutbound.setWarehouseId(tErpSupplierWarehousing.getWarehouseId());
tErpSupplierOutbound.setOutboundType(7);
//TODO 确定这个是采购价还是销售价格
@@ -552,6 +608,7 @@
tErpSupplierOutboundGoods.setWarehousingBatchId(warehousingBatch.getId());
tErpSupplierOutboundGoods.setOutboundCount(purchaseCount);
tErpSupplierOutboundGoods.setTotalPrice(tErpProcurementGoods.getPurchasePrice().multiply(new BigDecimal(purchaseCount)));
+ tErpSupplierOutboundGoods.setProcurementGoodsId(tErpProcurementGoods.getId());
erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods);
}
@@ -564,7 +621,408 @@
}
+ TErpProcurement byId = this.getById(id);
+ byId.setStatus(4);
+ byId.setSendTime(LocalDateTime.now());
+ byId.setLogisticsNumber(logisticsNumber);
+ this.updateById(byId);
}
+ @Override
+ public List<SupplierThirtyProcurementStatisticsVO> supplierThirtyProcurementStatistics(String supplierAndClinicId, String startTime, String endTime,Integer roleType) {
+ return this.baseMapper.supplierThirtyProcurementStatistics(supplierAndClinicId, startTime, endTime, roleType);
+ }
+
+ @Override
+ public List<SupplierThirtyMoneyProcurementStatisticsVO> supplierThirtyMoneyProcurementStatistics(String supplierAndClinicId, String startTime, String endTime,Integer roleType) {
+ return this.baseMapper.supplierThirtyMoneyProcurementStatistics(supplierAndClinicId, startTime, endTime, roleType);
+ }
+
+ @Override
+ public Integer supplierSalesStatisticsTypeCount(String supplierId) {
+ return this.baseMapper.supplierSalesStatisticsTypeCount(supplierId);
+ }
+
+ @Override
+ public Integer supplierSalesStatisticsCount(String supplierId) {
+ return this.baseMapper.supplierSalesStatisticsCount(supplierId);
+ }
+
+ @Override
+ public BigDecimal supplierSalesStatisticsMoney(String supplierId, String startTime, String endTime) {
+ return this.baseMapper.supplierSalesStatisticsMoney(supplierId,startTime, endTime);
+ }
+
+ @Override
+ public List<SupplierSalesStatisticsGoodsTypeVO> supplierSalesStatisticsGoodsType(String supplierId, String startTime, String endTime) {
+ return this.baseMapper.supplierSalesStatisticsGoodsType(supplierId,startTime, endTime);
+ }
+
+ @Override
+ public List<SupplierSalesStatisticsGoodsCountVO> supplierSalesStatisticsGoodsCount(String supplierId, String startTime, String endTime, String goodsName) {
+ return this.baseMapper.supplierSalesStatisticsGoodsCount(supplierId,startTime, endTime,goodsName);
+ }
+
+ @Override
+ public List<SupplierSalesStatisticsGoodsCountVO> supplierSalesStatisticsGoodsCountMonth(String supplierId, String startTime, String endTime, String goodsName) {
+ return this.baseMapper.supplierSalesStatisticsGoodsCountMonth(supplierId,startTime, endTime,goodsName);
+ }
+
+ @Override
+ public List<TErpProcurementGoods> branchAdminStatisticsThree(List<String> clinicIds) {
+ return this.baseMapper.branchAdminStatisticsThree(clinicIds);
+ }
+
+ @Override
+ public PageInfo<ClinicProcurementReportVO> clinicProcurementReport(ClinicProcurementReportQuery query) {
+ PageInfo<ClinicProcurementReportVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
+ List<ClinicProcurementReportVO> list = this.baseMapper.clinicProcurementReport(query, pageInfo);
+ if(CollectionUtils.isEmpty(list)){
+ return pageInfo;
+ }
+ List<String> procurementIds = list.stream().map(TErpProcurement::getId).collect(Collectors.toList());
+ List<TErpProcurementGoods> erpProcurementGoods = erpProcurementGoodsMapper.selectList(new QueryWrapper<TErpProcurementGoods>().lambda().in(TErpProcurementGoods::getProcurementId, procurementIds));
+ for (ClinicProcurementReportVO clinicProcurementReportVO : list) {
+ List<TErpProcurementGoods> procurementGoods = erpProcurementGoods.stream().filter(tErpProcurementGoods -> tErpProcurementGoods.getProcurementId().equals(clinicProcurementReportVO.getId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(procurementGoods)){
+ int sum = procurementGoods.stream().mapToInt(TErpProcurementGoods::getPurchaseCount).sum();
+ clinicProcurementReportVO.setProcurementGoodsNum(sum);
+ }
+ }
+ pageInfo.setRecords(list);
+ return pageInfo;
+ }
+
+ @Override
+ public List<ProcurementReportClinicExport> exportProcurementReportClinic(ClinicProcurementReportQuery query) {
+ List<ProcurementReportClinicExport> list = this.baseMapper.exportProcurementReportClinic(query);
+ if(CollectionUtils.isEmpty(list)){
+ return new ArrayList<>();
+ }
+ List<String> procurementIds = list.stream().map(ProcurementReportClinicExport::getId).collect(Collectors.toList());
+ List<TErpProcurementGoods> erpProcurementGoods = erpProcurementGoodsMapper.selectList(new QueryWrapper<TErpProcurementGoods>().lambda().in(TErpProcurementGoods::getProcurementId, procurementIds));
+ for (ProcurementReportClinicExport procurementReportClinicExport : list) {
+ List<TErpProcurementGoods> procurementGoods = erpProcurementGoods.stream().filter(tErpProcurementGoods -> tErpProcurementGoods.getProcurementId().equals(procurementReportClinicExport.getId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(procurementGoods)){
+ int sum = procurementGoods.stream().mapToInt(TErpProcurementGoods::getPurchaseCount).sum();
+ procurementReportClinicExport.setProcurementGoodsNum(sum);
+ }
+ if(Objects.nonNull(procurementReportClinicExport.getPayTime())){
+ String payTimeStr = new SimpleDateFormat("yyyy-MM-dd").format(DateUtils.localDateTimeToDate(procurementReportClinicExport.getPayTime()));
+ procurementReportClinicExport.setPayTimeStr(payTimeStr);
+ }
+ }
+ return list;
+ }
+
+ @Override
+ public List<ProcurementReportSupplierExport> exportProcurementReportSupplier(ClinicProcurementReportQuery query) {
+ List<ProcurementReportSupplierExport> list = this.baseMapper.exportProcurementReportSupplier(query);
+ if(CollectionUtils.isEmpty(list)){
+ return new ArrayList<>();
+ }
+ for (ProcurementReportSupplierExport procurementReportSupplierExport : list) {
+ if(Objects.nonNull(procurementReportSupplierExport.getPayTime())){
+ String payTimeStr = new SimpleDateFormat("yyyy-MM-dd").format(DateUtils.localDateTimeToDate(procurementReportSupplierExport.getPayTime()));
+ procurementReportSupplierExport.setPayTimeStr(payTimeStr);
+ }
+ }
+ return list;
+ }
+
+ @Override
+ public List<ProcurementReportPlatformExport> exportProcurementReportPlatform(ClinicProcurementReportQuery query) {
+ List<ProcurementReportPlatformExport> list = this.baseMapper.exportProcurementReportPlatform(query);
+ if(CollectionUtils.isEmpty(list)){
+ return new ArrayList<>();
+ }
+ for (ProcurementReportPlatformExport procurementReportPlatformExport : list) {
+ if(Objects.nonNull(procurementReportPlatformExport.getPayTime())){
+ String payTimeStr = new SimpleDateFormat("yyyy-MM-dd").format(DateUtils.localDateTimeToDate(procurementReportPlatformExport.getPayTime()));
+ procurementReportPlatformExport.setPayTimeStr(payTimeStr);
+ }
+ }
+ return list;
+ }
+
+ @Override
+ public PageInfo<ClinicProcurementReportVO> platformLedgerReport(ClinicProcurementReportQuery query) {
+ PageInfo<ClinicProcurementReportVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
+ List<ClinicProcurementReportVO> list = this.baseMapper.platformLedgerReport(query, pageInfo);
+ pageInfo.setRecords(list);
+ return pageInfo;
+ }
+
+ @Override
+ public List<PlatformLedgerReportExport> exportPlatformLedgerReport(ClinicProcurementReportQuery query) {
+ List<PlatformLedgerReportExport> list = this.baseMapper.exportPlatformLedgerReport(query);
+ if(CollectionUtils.isEmpty(list)){
+ return new ArrayList<>();
+ }
+ for (PlatformLedgerReportExport platformLedgerReportExport : list) {
+ if(Objects.nonNull(platformLedgerReportExport.getPayTime())){
+ String payTimeStr = new SimpleDateFormat("yyyy-MM-dd").format(DateUtils.localDateTimeToDate(platformLedgerReportExport.getPayTime()));
+ platformLedgerReportExport.setPayTimeStr(payTimeStr);
+ }
+ }
+ return list;
+ }
+
+ @Override
+ public PageInfo<BranchPerformanceReportVO> branchPerformanceReport(PerformanceReportQuery query) {
+
+ List<String> clinicIds = new ArrayList<>();
+
+ if(StringUtils.isNotBlank(query.getBranchName())){
+ // 查询分公司名称
+ List<TCrmBranch> crmBranches = crmBranchMapper.selectList(Wrappers.lambdaQuery(TCrmBranch.class)
+ .like(TCrmBranch::getBranchName, query.getBranchName()));
+ if(CollectionUtils.isEmpty(crmBranches)){
+ return new PageInfo<>();
+ }
+ List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
+ List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class)
+ .in(TCrmClinic::getBranchId, branchIds));
+ if(CollectionUtils.isEmpty(crmClinics)){
+ return new PageInfo<>();
+ }
+ List<String> ids = crmClinics.stream().map(TCrmClinic::getId).collect(Collectors.toList());
+ clinicIds.addAll(ids);
+ }
+ query.setClinicIds(clinicIds);
+ PageInfo<BranchPerformanceReportVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
+
+ List<BranchPerformanceReportVO> list = this.baseMapper.branchPerformanceReport(query, pageInfo);
+ if(CollectionUtils.isEmpty(list)){
+ return pageInfo;
+ }
+ List<String> procurementIds = list.stream().map(BranchPerformanceReportVO::getId).collect(Collectors.toList());
+
+ // 查询可获得积分
+ List<TCrmChangePoints> crmChangePoints = crmChangePointsMapper.selectList(Wrappers.lambdaQuery(TCrmChangePoints.class)
+ .in(TCrmChangePoints::getProcurementId, procurementIds)
+ .eq(TCrmChangePoints::getUserType, 1)
+ .eq(TCrmChangePoints::getChangeType, 1)
+ .eq(TCrmChangePoints::getChangeReason, 1));
+ // 查询业绩
+ List<TErpProcurementCommission> erpProcurementCommissions = erpProcurementCommissionMapper.selectList(Wrappers.lambdaQuery(TErpProcurementCommission.class)
+ .in(TErpProcurementCommission::getProcurementId, procurementIds)
+ .eq(TErpProcurementCommission::getCommissionType, 1));
+ for (BranchPerformanceReportVO branchPerformanceReportVO : list) {
+ // 查询可获得积分
+ List<TCrmChangePoints> changePoints = crmChangePoints.stream().filter(tCrmChangePoints -> branchPerformanceReportVO.getId().equals(tCrmChangePoints.getProcurementId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(changePoints)){
+ branchPerformanceReportVO.setAvailablePoints(changePoints.stream().mapToInt(TCrmChangePoints::getChangeValue).sum());
+ }
+ // 查询业绩
+ List<TErpProcurementCommission> commissions = erpProcurementCommissions.stream().filter(tErpProcurementCommission -> branchPerformanceReportVO.getId().equals(tErpProcurementCommission.getProcurementId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(commissions)){
+ branchPerformanceReportVO.setPerformance(commissions.stream().map(TErpProcurementCommission::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add));
+ }
+ }
+ pageInfo.setRecords(list);
+ return pageInfo;
+ }
+
+ @Override
+ public PageInfo<SalespersonPerformanceReportVO> salespersonPerformanceReport(PerformanceReportQuery query) {
+ List<String> clinicIds = new ArrayList<>();
+
+ if(StringUtils.isNotBlank(query.getBranchName())){
+ // 查询分公司名称
+ List<TCrmBranch> crmBranches = crmBranchMapper.selectList(Wrappers.lambdaQuery(TCrmBranch.class)
+ .like(TCrmBranch::getBranchName, query.getBranchName()));
+ if(CollectionUtils.isEmpty(crmBranches)){
+ return new PageInfo<>();
+ }
+ List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
+ List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class)
+ .in(TCrmClinic::getBranchId, branchIds));
+ if(CollectionUtils.isEmpty(crmClinics)){
+ return new PageInfo<>();
+ }
+ List<String> ids = crmClinics.stream().map(TCrmClinic::getId).collect(Collectors.toList());
+ clinicIds.addAll(ids);
+ }
+ if(StringUtils.isNotBlank(query.getSalespersonName())){
+ // 查询业务员名称
+ List<TCrmSalesperson> crmSalespeopleList = crmSalespersonMapper.selectList(Wrappers.lambdaQuery(TCrmSalesperson.class)
+ .like(TCrmSalesperson::getSalespersonName, query.getSalespersonName()));
+ if(CollectionUtils.isEmpty(crmSalespeopleList)){
+ return new PageInfo<>();
+ }
+ List<String> salespersonIds = crmSalespeopleList.stream().map(TCrmSalesperson::getId).collect(Collectors.toList());
+ List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class)
+ .in(TCrmClinic::getSalespersonId, salespersonIds));
+ if(CollectionUtils.isEmpty(crmClinics)){
+ return new PageInfo<>();
+ }
+ List<String> ids = crmClinics.stream().map(TCrmClinic::getId).collect(Collectors.toList());
+ clinicIds.addAll(ids);
+ }
+ clinicIds = clinicIds.stream().distinct().collect(Collectors.toList());
+ query.setClinicIds(clinicIds);
+ PageInfo<SalespersonPerformanceReportVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
+ List<SalespersonPerformanceReportVO> list = this.baseMapper.salespersonPerformanceReport(query, pageInfo);
+ if(CollectionUtils.isEmpty(list)){
+ return pageInfo;
+ }
+ List<String> procurementIds = list.stream().map(SalespersonPerformanceReportVO::getId).collect(Collectors.toList());
+
+ // 查询可获得积分
+ List<TCrmChangePoints> crmChangePoints = crmChangePointsMapper.selectList(Wrappers.lambdaQuery(TCrmChangePoints.class)
+ .in(TCrmChangePoints::getProcurementId, procurementIds)
+ .eq(TCrmChangePoints::getUserType, 2)
+ .eq(TCrmChangePoints::getChangeType, 1)
+ .eq(TCrmChangePoints::getChangeReason, 1));
+ // 查询业绩
+ List<TErpProcurementCommission> erpProcurementCommissions = erpProcurementCommissionMapper.selectList(Wrappers.lambdaQuery(TErpProcurementCommission.class)
+ .in(TErpProcurementCommission::getProcurementId, procurementIds)
+ .eq(TErpProcurementCommission::getCommissionType, 2));
+ for (SalespersonPerformanceReportVO salespersonPerformanceReportVO : list) {
+ // 查询可获得积分
+ List<TCrmChangePoints> changePoints = crmChangePoints.stream().filter(tCrmChangePoints -> salespersonPerformanceReportVO.getId().equals(tCrmChangePoints.getProcurementId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(changePoints)){
+ salespersonPerformanceReportVO.setAvailablePoints(changePoints.stream().mapToInt(TCrmChangePoints::getChangeValue).sum());
+ }
+ // 查询业绩
+ List<TErpProcurementCommission> commissions = erpProcurementCommissions.stream().filter(tErpProcurementCommission -> salespersonPerformanceReportVO.getId().equals(tErpProcurementCommission.getProcurementId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(commissions)){
+ salespersonPerformanceReportVO.setPerformance(commissions.stream().map(TErpProcurementCommission::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add));
+ }
+ }
+ pageInfo.setRecords(list);
+ return pageInfo;
+ }
+
+ @Override
+ public List<BranchPerformanceReportVO> exportBranchPerformanceReport(PerformanceReportQuery query) {
+ List<String> clinicIds = new ArrayList<>();
+
+ if(StringUtils.isNotBlank(query.getBranchName())){
+ // 查询分公司名称
+ List<TCrmBranch> crmBranches = crmBranchMapper.selectList(Wrappers.lambdaQuery(TCrmBranch.class)
+ .like(TCrmBranch::getBranchName, query.getBranchName()));
+ if(CollectionUtils.isEmpty(crmBranches)){
+ return new ArrayList<>();
+ }
+ List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
+ List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class)
+ .in(TCrmClinic::getBranchId, branchIds));
+ if(CollectionUtils.isEmpty(crmClinics)){
+ return new ArrayList<>();
+ }
+ List<String> ids = crmClinics.stream().map(TCrmClinic::getId).collect(Collectors.toList());
+ clinicIds.addAll(ids);
+ }
+ query.setClinicIds(clinicIds);
+ List<BranchPerformanceReportVO> list = this.baseMapper.exportBranchPerformanceReport(query);
+ if(CollectionUtils.isEmpty(list)){
+ return new ArrayList<>();
+ }
+ List<String> procurementIds = list.stream().map(BranchPerformanceReportVO::getId).collect(Collectors.toList());
+
+ // 查询可获得积分
+ List<TCrmChangePoints> crmChangePoints = crmChangePointsMapper.selectList(Wrappers.lambdaQuery(TCrmChangePoints.class)
+ .in(TCrmChangePoints::getProcurementId, procurementIds)
+ .eq(TCrmChangePoints::getUserType, 1)
+ .eq(TCrmChangePoints::getChangeType, 1)
+ .eq(TCrmChangePoints::getChangeReason, 1));
+ // 查询业绩
+ List<TErpProcurementCommission> erpProcurementCommissions = erpProcurementCommissionMapper.selectList(Wrappers.lambdaQuery(TErpProcurementCommission.class)
+ .in(TErpProcurementCommission::getProcurementId, procurementIds)
+ .eq(TErpProcurementCommission::getCommissionType, 1));
+ for (BranchPerformanceReportVO branchPerformanceReportVO : list) {
+ // 查询可获得积分
+ List<TCrmChangePoints> changePoints = crmChangePoints.stream().filter(tCrmChangePoints -> branchPerformanceReportVO.getId().equals(tCrmChangePoints.getProcurementId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(changePoints)){
+ branchPerformanceReportVO.setAvailablePoints(changePoints.stream().mapToInt(TCrmChangePoints::getChangeValue).sum());
+ }
+ // 查询业绩
+ List<TErpProcurementCommission> commissions = erpProcurementCommissions.stream().filter(tErpProcurementCommission -> branchPerformanceReportVO.getId().equals(tErpProcurementCommission.getProcurementId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(commissions)){
+ branchPerformanceReportVO.setPerformance(commissions.stream().map(TErpProcurementCommission::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add));
+ }
+ if(Objects.nonNull(branchPerformanceReportVO.getPayTime())){
+ String payTimeStr = new SimpleDateFormat("yyyy-MM-dd").format(DateUtils.localDateTimeToDate(branchPerformanceReportVO.getPayTime()));
+ branchPerformanceReportVO.setPayTimeStr(payTimeStr);
+ }
+ }
+ return list;
+ }
+
+ @Override
+ public List<SalespersonPerformanceReportVO> exportSalespersonPerformanceReport(PerformanceReportQuery query) {
+ List<String> clinicIds = new ArrayList<>();
+
+ if(StringUtils.isNotBlank(query.getBranchName())){
+ // 查询分公司名称
+ List<TCrmBranch> crmBranches = crmBranchMapper.selectList(Wrappers.lambdaQuery(TCrmBranch.class)
+ .like(TCrmBranch::getBranchName, query.getBranchName()));
+ if(CollectionUtils.isEmpty(crmBranches)){
+ return new ArrayList<>();
+ }
+ List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList());
+ List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class)
+ .in(TCrmClinic::getBranchId, branchIds));
+ if(CollectionUtils.isEmpty(crmClinics)){
+ return new ArrayList<>();
+ }
+ List<String> ids = crmClinics.stream().map(TCrmClinic::getId).collect(Collectors.toList());
+ clinicIds.addAll(ids);
+ }
+ if(StringUtils.isNotBlank(query.getSalespersonName())){
+ // 查询业务员名称
+ List<TCrmSalesperson> crmSalespeopleList = crmSalespersonMapper.selectList(Wrappers.lambdaQuery(TCrmSalesperson.class)
+ .like(TCrmSalesperson::getSalespersonName, query.getSalespersonName()));
+ if(CollectionUtils.isEmpty(crmSalespeopleList)){
+ return new ArrayList<>();
+ }
+ List<String> salespersonIds = crmSalespeopleList.stream().map(TCrmSalesperson::getId).collect(Collectors.toList());
+ List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class)
+ .in(TCrmClinic::getSalespersonId, salespersonIds));
+ if(CollectionUtils.isEmpty(crmClinics)){
+ return new ArrayList<>();
+ }
+ List<String> ids = crmClinics.stream().map(TCrmClinic::getId).collect(Collectors.toList());
+ clinicIds.addAll(ids);
+ }
+ clinicIds = clinicIds.stream().distinct().collect(Collectors.toList());
+ query.setClinicIds(clinicIds);
+ List<SalespersonPerformanceReportVO> list = this.baseMapper.exportSalespersonPerformanceReport(query);
+ if(CollectionUtils.isEmpty(list)){
+ return new ArrayList<>();
+ }
+ List<String> procurementIds = list.stream().map(SalespersonPerformanceReportVO::getId).collect(Collectors.toList());
+
+ // 查询可获得积分
+ List<TCrmChangePoints> crmChangePoints = crmChangePointsMapper.selectList(Wrappers.lambdaQuery(TCrmChangePoints.class)
+ .in(TCrmChangePoints::getProcurementId, procurementIds)
+ .eq(TCrmChangePoints::getUserType, 2)
+ .eq(TCrmChangePoints::getChangeType, 1)
+ .eq(TCrmChangePoints::getChangeReason, 1));
+ // 查询业绩
+ List<TErpProcurementCommission> erpProcurementCommissions = erpProcurementCommissionMapper.selectList(Wrappers.lambdaQuery(TErpProcurementCommission.class)
+ .in(TErpProcurementCommission::getProcurementId, procurementIds)
+ .eq(TErpProcurementCommission::getCommissionType, 2));
+ for (SalespersonPerformanceReportVO salespersonPerformanceReportVO : list) {
+ // 查询可获得积分
+ List<TCrmChangePoints> changePoints = crmChangePoints.stream().filter(tCrmChangePoints -> salespersonPerformanceReportVO.getId().equals(tCrmChangePoints.getProcurementId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(changePoints)){
+ salespersonPerformanceReportVO.setAvailablePoints(changePoints.stream().mapToInt(TCrmChangePoints::getChangeValue).sum());
+ }
+ // 查询业绩
+ List<TErpProcurementCommission> commissions = erpProcurementCommissions.stream().filter(tErpProcurementCommission -> salespersonPerformanceReportVO.getId().equals(tErpProcurementCommission.getProcurementId())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(commissions)){
+ salespersonPerformanceReportVO.setPerformance(commissions.stream().map(TErpProcurementCommission::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add));
+ }
+ if(Objects.nonNull(salespersonPerformanceReportVO.getPayTime())){
+ String payTimeStr = new SimpleDateFormat("yyyy-MM-dd").format(DateUtils.localDateTimeToDate(salespersonPerformanceReportVO.getPayTime()));
+ salespersonPerformanceReportVO.setPayTimeStr(payTimeStr);
+ }
+ }
+ return list;
+ }
+
}
--
Gitblit v1.7.1