|
@@ -1,9 +1,11 @@
|
|
|
package com.fjhx.sale.service.sale.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fjhx.account.controller.utils.DateUtils;
|
|
|
import com.fjhx.account.entity.account.vo.AccountPaymentVo;
|
|
@@ -11,6 +13,9 @@ import com.fjhx.area.utils.AreaUtil;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.customer.entity.customer.dto.CustomerDto;
|
|
|
import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
|
|
|
+import com.fjhx.customer.entity.customer.po.Customer;
|
|
|
+import com.fjhx.customer.entity.customer.vo.CustomerVo;
|
|
|
+import com.fjhx.customer.service.customer.CustomerService;
|
|
|
import com.fjhx.sale.entity.contract.po.Contract;
|
|
|
import com.fjhx.sale.entity.contract.vo.ContractPdfInfoVo;
|
|
|
import com.fjhx.sale.entity.contract.vo.ContractVo;
|
|
@@ -24,6 +29,9 @@ import com.fjhx.sale.service.quotation.QuotationProductService;
|
|
|
import com.fjhx.sale.service.sale.SaleQuotationService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.sale.util.code.CodeEnum;
|
|
|
+import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
|
|
|
+import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
|
|
|
+import com.fjhx.tenant.service.dict.DictTenantDataService;
|
|
|
import com.obs.services.internal.ServiceException;
|
|
|
import com.ruoyi.common.core.domain.BasePo;
|
|
|
import com.ruoyi.system.utils.UserUtil;
|
|
@@ -60,6 +68,12 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
@Autowired
|
|
|
private ContractService contractService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CustomerService customerService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DictTenantDataService dictTenantDataService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 报价表分页
|
|
@@ -129,7 +143,7 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
}
|
|
|
//查询商品-报价表的数据
|
|
|
SaleQuotation saleQuotation = this.getById(saleQuotationDto.getId());
|
|
|
- if (ObjectUtil.isNotEmpty(saleQuotation)){
|
|
|
+ if (ObjectUtil.isNotEmpty(saleQuotation)) {
|
|
|
throw new ServiceException("报价表的数据不存在");
|
|
|
}
|
|
|
|
|
@@ -159,15 +173,17 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
|
|
|
/**
|
|
|
* 查询这个客户的报价次数
|
|
|
+ *
|
|
|
* @param id (客户ID)
|
|
|
*/
|
|
|
@Override
|
|
|
public Integer getCount(Long id) {
|
|
|
- return baseMapper.getCount(id);
|
|
|
+ return baseMapper.getCount(id);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询指定客户的每月报价总额
|
|
|
+ *
|
|
|
* @param dto
|
|
|
* @return
|
|
|
*/
|
|
@@ -192,19 +208,20 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
*/
|
|
|
@Override
|
|
|
public Map<String, Object> salesStatistics(CustomerDto dto) {
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
//切换数据源
|
|
|
DynamicDataSourceContextHolder.push(SourceConstant.SALE);
|
|
|
//查询这个客户的销售额(合同总金额)及成交合同数量
|
|
|
ContractVo contractVo = contractService.getSalesTotal(dto.getId());
|
|
|
- map.put("contractVo",contractVo);
|
|
|
+ map.put("contractVo", contractVo);
|
|
|
|
|
|
//查询这个客户的报价次数
|
|
|
Integer count = this.getCount(dto.getId());
|
|
|
DynamicDataSourceContextHolder.poll();
|
|
|
- map.put("count",count);
|
|
|
+ map.put("count", count);
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 报价销售走势(客户画像)
|
|
|
*/
|
|
@@ -215,50 +232,50 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
List<String> monthBetweenDate = DateUtils.getMonthBetweenDate(DateUtil.offsetMonth(new Date(), -12), new Date());
|
|
|
|
|
|
//存放报价的数据;
|
|
|
- List<Map<String,Object>> saleQuotationList = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> saleQuotationList = new ArrayList<>();
|
|
|
//存放报价的数据;
|
|
|
- List<Map<String,Object>> contractList = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> contractList = new ArrayList<>();
|
|
|
|
|
|
- dto.setBeginTime(DateUtil.format(DateUtil.offsetMonth(new Date(), -12),"yy-MM"));
|
|
|
- dto.setEndTime(DateUtil.format(new Date(),"yy-MM"));
|
|
|
+ dto.setBeginTime(DateUtil.format(DateUtil.offsetMonth(new Date(), -12), "yy-MM"));
|
|
|
+ dto.setEndTime(DateUtil.format(new Date(), "yy-MM"));
|
|
|
//查询指定客户的每月报价总额
|
|
|
List<SaleQuotationVo> saleQuotationVoList = this.getAmount(dto);
|
|
|
|
|
|
Map<String, List<SaleQuotationVo>> saleQuotationVoMap = saleQuotationVoList.stream()
|
|
|
- .collect(Collectors.groupingBy(item->DateUtil.format(item.getCreateTime(),"yyyy-MM")));
|
|
|
+ .collect(Collectors.groupingBy(item -> DateUtil.format(item.getCreateTime(), "yyyy-MM")));
|
|
|
|
|
|
//查询指定客户的每月合同总额
|
|
|
List<ContractVo> contractVoList = contractService.getAmount(dto);
|
|
|
Map<String, List<ContractVo>> contractVoMap = contractVoList.stream()
|
|
|
- .collect(Collectors.groupingBy(item->DateUtil.format(item.getCreateTime(),"yyyy-MM")));
|
|
|
+ .collect(Collectors.groupingBy(item -> DateUtil.format(item.getCreateTime(), "yyyy-MM")));
|
|
|
|
|
|
//赋值每个月的值
|
|
|
for (String month : monthBetweenDate) {
|
|
|
//存放每月的报价总额
|
|
|
- Map<String,Object> saleQuotationMap = new HashMap<>();
|
|
|
+ Map<String, Object> saleQuotationMap = new HashMap<>();
|
|
|
//每月的金额初始化的值为0
|
|
|
- saleQuotationMap.put("month",month);
|
|
|
- saleQuotationMap.put("saleAmount",new BigDecimal(0));
|
|
|
+ saleQuotationMap.put("month", month);
|
|
|
+ saleQuotationMap.put("saleAmount", new BigDecimal(0));
|
|
|
List<SaleQuotationVo> saleQuotationVos = saleQuotationVoMap.get(month);
|
|
|
//给每月的报价金额赋值
|
|
|
- if (ObjectUtil.isNotEmpty(saleQuotationVos)){
|
|
|
- saleQuotationMap.put("saleAmount",saleQuotationVos.get(0).getAmount());
|
|
|
+ if (ObjectUtil.isNotEmpty(saleQuotationVos)) {
|
|
|
+ saleQuotationMap.put("saleAmount", saleQuotationVos.get(0).getAmount());
|
|
|
}
|
|
|
saleQuotationList.add(saleQuotationMap);
|
|
|
|
|
|
//存放每月的合同总额
|
|
|
- Map<String,Object> contractMap = new HashMap<>();
|
|
|
+ Map<String, Object> contractMap = new HashMap<>();
|
|
|
//每月的金额初始化的值为0
|
|
|
- contractMap.put("month",month);
|
|
|
- contractMap.put("contractAmount",new BigDecimal(0));
|
|
|
+ contractMap.put("month", month);
|
|
|
+ contractMap.put("contractAmount", new BigDecimal(0));
|
|
|
List<ContractVo> contractVoList1 = contractVoMap.get(month);
|
|
|
- if (ObjectUtil.isNotEmpty(contractVoList1)){
|
|
|
- contractMap.put("contractAmount",contractVoList1.get(0).getAmount());
|
|
|
+ if (ObjectUtil.isNotEmpty(contractVoList1)) {
|
|
|
+ contractMap.put("contractAmount", contractVoList1.get(0).getAmount());
|
|
|
}
|
|
|
contractList.add(contractMap);
|
|
|
}
|
|
|
- map.put("contractList",contractList);
|
|
|
- map.put("saleQuotationList",saleQuotationList);
|
|
|
+ map.put("contractList", contractList);
|
|
|
+ map.put("saleQuotationList", saleQuotationList);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -266,7 +283,7 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
* 销售明细(客户画像)
|
|
|
*/
|
|
|
@Override
|
|
|
- public Page<SaleQuotationVo> saleDetail(CustomerSelectDto dto) {
|
|
|
+ public Page<SaleQuotationVo> saleDetail(CustomerSelectDto dto) {
|
|
|
Page<SaleQuotationVo> saleQuotationVoPage = baseMapper.saleDetail(dto.getPage(), dto);
|
|
|
List<SaleQuotationVo> records = saleQuotationVoPage.getRecords();
|
|
|
// 赋值用户名称
|
|
@@ -276,6 +293,286 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 来源统计(客户分析)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> sourceStatistics(CustomerDto dto) {
|
|
|
+ //切换数据源
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.CUSTOMER);
|
|
|
+ //存放来源统计的数据
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+
|
|
|
+ //存放来源存量与增量的数据列表
|
|
|
+ List<Map<String,Object>> stockList = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ //来源存量(在指定时间外的数量)
|
|
|
+ QueryWrapper<Object> query = Wrappers.query();
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCountryId()), "c.country_id", dto.getCountryId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getProvinceId()), "c.province_id", dto.getProvinceId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCityId()), "c.city_id", dto.getCityId());
|
|
|
+ query.groupBy("c.source");
|
|
|
+ query.le("DATE_FORMAT(c.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.ge("DATE_FORMAT(c.create_time,'%Y-%m')", dto.getEndTime());
|
|
|
+ List<CustomerVo> sourceStockList = customerService.sourceStock(query);
|
|
|
+
|
|
|
+ //来源增量(在指定时间内的数量)
|
|
|
+ query.clear();
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCountryId()), "c.country_id", dto.getCountryId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getProvinceId()), "c.province_id", dto.getProvinceId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCityId()), "c.city_id", dto.getCityId());
|
|
|
+ query.groupBy("c.source");
|
|
|
+ query.ge("DATE_FORMAT(c.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.le("DATE_FORMAT(c.create_time,'%Y-%m')", dto.getEndTime());
|
|
|
+ List<CustomerVo> sourceIncrementList = customerService.sourceIncrement(query);
|
|
|
+
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
+
|
|
|
+ //切换数据源
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
|
+ //获取来源的字典数据
|
|
|
+ List<DictTenantDataVo> dictTenantDataVos = getDict("customer_source");
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
+ //获取来源增量总计
|
|
|
+ Integer incrementAmount = sourceIncrementList.stream().map(customerVo -> customerVo.getCount())
|
|
|
+ .collect(Collectors.toList()).stream().reduce(Integer::sum).orElse(0);
|
|
|
+ map.put("incrementAmount", incrementAmount);
|
|
|
+ //获取来源存量总计
|
|
|
+ Integer stockAmount = sourceStockList.stream().map(customerVo -> customerVo.getCount())
|
|
|
+ .collect(Collectors.toList()).stream().reduce(Integer::sum).orElse(0);
|
|
|
+ map.put("stockAmount", stockAmount);
|
|
|
+
|
|
|
+ Map<String, List<CustomerVo>> sourceIncrementMap = sourceIncrementList.stream()
|
|
|
+ .collect(Collectors.groupingBy(CustomerVo::getSource));
|
|
|
+
|
|
|
+ Map<String, List<CustomerVo>> sourceStockMap = sourceStockList.stream().collect(Collectors.groupingBy(Customer::getSource));
|
|
|
+
|
|
|
+ if (dictTenantDataVos.size()==0){
|
|
|
+ throw new ServiceException("数据有误:该租户没有配客户来源字典");
|
|
|
+ }
|
|
|
+
|
|
|
+ //赋值 增量 存量数据
|
|
|
+ for (DictTenantDataVo dictTenantDataVo : dictTenantDataVos) {
|
|
|
+ //存放来源存量与增量的数据
|
|
|
+ Map<String,Object> stockMap = new HashMap<>();
|
|
|
+ //赋值初使值
|
|
|
+ stockMap.put("source",dictTenantDataVo.getDictValue());
|
|
|
+ stockMap.put("stockAmount",0);
|
|
|
+ stockMap.put("incrementAmount",0);
|
|
|
+
|
|
|
+ //赋值增量数据
|
|
|
+ List<CustomerVo> customers = sourceIncrementMap.get(dictTenantDataVo.getDictKey());
|
|
|
+ if (ObjectUtil.isNotEmpty(customers)){
|
|
|
+ stockMap.put("incrementAmount",customers.get(0).getCount());
|
|
|
+ }
|
|
|
+ //赋值存量数据
|
|
|
+ List<CustomerVo> customerVos = sourceStockMap.get(dictTenantDataVo.getDictKey());
|
|
|
+ if (ObjectUtil.isNotEmpty(customerVos)){
|
|
|
+ stockMap.put("stockAmount",customerVos.get(0).getCount());
|
|
|
+ }
|
|
|
+ stockList.add(stockMap);
|
|
|
+ }
|
|
|
+ map.put("stockList", stockList);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 类型统计(客户分析)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> typeStatistics(CustomerDto dto) {
|
|
|
+ if (ObjectUtil.isEmpty(dto.getBeginTime()) && ObjectUtil.isNotEmpty(dto.getEndTime())) {
|
|
|
+ throw new ServiceException("参数缺失:开始时间,结束时间不能为null");
|
|
|
+ }
|
|
|
+ //存放类型统计数据
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+
|
|
|
+ //存放询盘数据 成交单的列表
|
|
|
+ List<Map<String,Object>> saleList = new ArrayList<>();
|
|
|
+
|
|
|
+ QueryWrapper<Object> query = Wrappers.query();
|
|
|
+ query.ge("DATE_FORMAT(sq.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.le("DATE_FORMAT(sq.create_time,'%Y-%m')", dto.getEndTime());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCountryId()), "c.country_id", dto.getCountryId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getProvinceId()), "c.province_id", dto.getProvinceId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCityId()), "c.city_id", dto.getCityId());
|
|
|
+ query.eq("sq.status", 30);
|
|
|
+ //类型询盘统计(报价)
|
|
|
+ List<SaleQuotationVo> saleStatisticsList = baseMapper.saleStatistics(query);
|
|
|
+ Map<String, List<SaleQuotationVo>> saleStatisticsMap = saleStatisticsList.stream().collect(Collectors.groupingBy(SaleQuotationVo::getStatus));
|
|
|
+
|
|
|
+ //查询成交单统计(合同)
|
|
|
+ List<SaleQuotationVo> contractStatisticsList = contractService.contractStatistics(query);
|
|
|
+ Map<String, List<SaleQuotationVo>> contractStatisticsMap = contractStatisticsList.stream()
|
|
|
+ .collect(Collectors.groupingBy(SaleQuotationVo::getStatus));
|
|
|
+
|
|
|
+ //获取询盘总计
|
|
|
+ Integer saleAmount = saleStatisticsList.stream().map(saleQuotationVo -> saleQuotationVo.getCount())
|
|
|
+ .reduce(Integer::sum).orElse(0);
|
|
|
+
|
|
|
+ //获取成交单总计
|
|
|
+ Integer contractAmount = contractStatisticsList.stream().map(saleQuotationVo -> saleQuotationVo.getCount())
|
|
|
+ .reduce(Integer::sum).orElse(0);
|
|
|
+
|
|
|
+ map.put("saleAmount", saleAmount);
|
|
|
+ map.put("contractAmount", contractAmount);
|
|
|
+
|
|
|
+ //获取类型的字典数据
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
|
+ List<DictTenantDataVo> dictTenantDataVoList = getDict("customer_status");
|
|
|
+
|
|
|
+ if (dictTenantDataVoList.size()==0){
|
|
|
+ throw new ServiceException("数据有误:该租户没有配客户类型字典");
|
|
|
+ }
|
|
|
+
|
|
|
+ //赋值询盘 成交单数据
|
|
|
+ for (DictTenantDataVo dictTenantDataVo : dictTenantDataVoList) {
|
|
|
+ //存放询盘数据 成交单的数据
|
|
|
+ Map<String, Object> saleMap = new HashMap<>();
|
|
|
+ //赋值初使值
|
|
|
+ saleMap.put("status",dictTenantDataVo.getDictValue());
|
|
|
+ saleMap.put("contractAmount",0);
|
|
|
+ saleMap.put("saleAmount",0);
|
|
|
+
|
|
|
+ //赋值询盘数据
|
|
|
+ List<SaleQuotationVo> saleQuotationVoList = saleStatisticsMap.get(dictTenantDataVo.getDictKey());
|
|
|
+ if (ObjectUtil.isNotEmpty(saleQuotationVoList)){
|
|
|
+ saleMap.put("saleAmount",saleQuotationVoList.get(0).getCount());
|
|
|
+ }
|
|
|
+
|
|
|
+ //赋值成交单数据
|
|
|
+ List<SaleQuotationVo> saleQuotationList = contractStatisticsMap.get(dictTenantDataVo.getDictKey());
|
|
|
+ if (ObjectUtil.isNotEmpty(saleQuotationList)){
|
|
|
+ saleMap.put("contractAmount",saleQuotationList.get(0).getCount());
|
|
|
+ }
|
|
|
+ saleList.add(saleMap);
|
|
|
+ }
|
|
|
+ map.put("saleList", saleList);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 趋势分析(客户分析)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> trendAnalysis(CustomerDto dto) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ //切换数据源
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.CUSTOMER);
|
|
|
+
|
|
|
+ Date now = new Date();
|
|
|
+ //获取当前月数往前12月的月份数
|
|
|
+ List<String> monthBetweenDate = DateUtils.getMonthBetweenDate(DateUtil.offsetMonth(now, -12), now);
|
|
|
+ dto.setBeginTime(DateUtil.format(DateUtil.offsetMonth(now, -12), "yyyy-MM"));
|
|
|
+ dto.setEndTime(DateUtil.format(now, "yyyy-MM"));
|
|
|
+ //来源存量(在指定时间外的数量)
|
|
|
+ QueryWrapper<Object> query = Wrappers.query();
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCountryId()), "c.country_id", dto.getCountryId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getProvinceId()), "c.province_id", dto.getProvinceId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCityId()), "c.city_id", dto.getCityId());
|
|
|
+ query.groupBy("DATE_FORMAT(c.create_time,'%Y-%m')");
|
|
|
+ query.le("DATE_FORMAT(c.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.ge("DATE_FORMAT(c.create_time,'%Y-%m')", dto.getEndTime());
|
|
|
+// query.select("count(*) count, DATE_FORMAT(c.create_time,'%Y-%m') time");
|
|
|
+ List<CustomerVo> sourceStockList = customerService.sourceStock(query);
|
|
|
+ Map<String, List<CustomerVo>> sourceStockMap = sourceStockList.stream().collect(Collectors.groupingBy(CustomerVo::getTime));
|
|
|
+
|
|
|
+ //来源增量(在指定时间内的数量)
|
|
|
+ query.clear();
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCountryId()), "c.country_id", dto.getCountryId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getProvinceId()), "c.province_id", dto.getProvinceId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCityId()), "c.city_id", dto.getCityId());
|
|
|
+ query.groupBy("DATE_FORMAT(c.create_time,'%Y-%m')");
|
|
|
+ query.ge("DATE_FORMAT(c.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.le("DATE_FORMAT(c.create_time,'%Y-%m')", dto.getEndTime());
|
|
|
+// query.select("count(*) count, DATE_FORMAT(c.create_time,'%Y-%m') time");
|
|
|
+ List<CustomerVo> sourceIncrementList = customerService.sourceIncrement(query);
|
|
|
+ Map<String, List<CustomerVo>> sourceIncrementMap = sourceIncrementList.stream().collect(Collectors.groupingBy(CustomerVo::getTime));
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
+
|
|
|
+ query.clear();
|
|
|
+ query.ge("DATE_FORMAT(sq.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.le("DATE_FORMAT(sq.create_time,'%Y-%m')", dto.getBeginTime());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCountryId()), "c.country_id", dto.getCountryId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getProvinceId()), "c.province_id", dto.getProvinceId());
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(dto.getCityId()), "c.city_id", dto.getCityId());
|
|
|
+ query.eq("sq.status", 30);
|
|
|
+ query.groupBy("DATE_FORMAT(sq.create_time,'%Y-%m')");
|
|
|
+// query.select("count(*), DATE_FORMAT(sq.create_time,'%Y-%m') time");
|
|
|
+ //类型询盘统计(报价)
|
|
|
+ List<SaleQuotationVo> saleStatisticsList = baseMapper.saleStatistics(query);
|
|
|
+ Map<String, List<SaleQuotationVo>> saleStatisticsMap = saleStatisticsList.stream()
|
|
|
+ .collect(Collectors.groupingBy(SaleQuotationVo::getTime));
|
|
|
+
|
|
|
+ //查询成交单统计(合同)
|
|
|
+ List<SaleQuotationVo> contractStatisticsList = contractService.contractStatistics(query);
|
|
|
+ Map<String, List<SaleQuotationVo>> contractStatisticsMap = contractStatisticsList.stream()
|
|
|
+ .collect(Collectors.groupingBy(SaleQuotationVo::getTime));
|
|
|
+
|
|
|
+ //存放来源存量
|
|
|
+ List<Map<String, Object>> sourceStockList1 = new ArrayList<>();
|
|
|
+ //存放来源增量
|
|
|
+ List<Map<String, Object>> sourceIncrementList1 = new ArrayList<>();
|
|
|
+ //存放类型询盘
|
|
|
+ List<Map<String, Object>> saleStatisticList1 = new ArrayList<>();
|
|
|
+ //类型成交单
|
|
|
+ List<Map<String, Object>> contractStatisticsList1 = new ArrayList<>();
|
|
|
+
|
|
|
+ //赋值
|
|
|
+ for (String month : monthBetweenDate) {
|
|
|
+ //存放来源存量
|
|
|
+ Map<String, Object> stockMap = new HashMap<>();
|
|
|
+ //设置默认值
|
|
|
+ stockMap.put("month", month);
|
|
|
+ stockMap.put("count", 0);
|
|
|
+ List<CustomerVo> sourceStocks = sourceStockMap.get(month);
|
|
|
+ if (ObjectUtil.isNotEmpty(sourceStocks)) {
|
|
|
+ stockMap.put("count", sourceStocks.get(0).getCount());
|
|
|
+ }
|
|
|
+ sourceStockList1.add(stockMap);
|
|
|
+
|
|
|
+ //存放来源增量
|
|
|
+ Map<String, Object> incrementMap = new HashMap<>();
|
|
|
+ //设置默认值
|
|
|
+ incrementMap.put("month", month);
|
|
|
+ incrementMap.put("count", 0);
|
|
|
+ List<CustomerVo> sourceIncrements = sourceIncrementMap.get(month);
|
|
|
+ if (ObjectUtil.isNotEmpty(sourceIncrements)) {
|
|
|
+ incrementMap.put("count", sourceIncrements.get(0).getCount());
|
|
|
+ }
|
|
|
+ sourceIncrementList1.add(incrementMap);
|
|
|
+
|
|
|
+ //类型询盘
|
|
|
+ Map<String, Object> saleMap = new HashMap<>();
|
|
|
+ //设置默认值
|
|
|
+ saleMap.put("month", month);
|
|
|
+ saleMap.put("count", 0);
|
|
|
+ List<SaleQuotationVo> saleList = saleStatisticsMap.get(month);
|
|
|
+ if (ObjectUtil.isNotEmpty(saleList)) {
|
|
|
+ saleMap.put("count", saleList.get(0).getCount());
|
|
|
+ }
|
|
|
+ saleStatisticList1.add(saleMap);
|
|
|
+
|
|
|
+ //类型成交单
|
|
|
+ Map<String, Object> contractMap = new HashMap<>();
|
|
|
+ //设置默认值
|
|
|
+ contractMap.put("month", month);
|
|
|
+ contractMap.put("count", 0);
|
|
|
+ List<SaleQuotationVo> contractList = contractStatisticsMap.get(month);
|
|
|
+ if (ObjectUtil.isNotEmpty(contractList)) {
|
|
|
+ contractMap.put("count", contractList.get(0).getCount());
|
|
|
+ }
|
|
|
+ contractStatisticsList1.add(contractMap);
|
|
|
+ }
|
|
|
+ map.put("sourceStockList", sourceStockList1);
|
|
|
+ map.put("sourceIncrementList", sourceIncrementList1);
|
|
|
+ map.put("saleStatisticList", saleStatisticList1);
|
|
|
+ map.put("contractStatisticsList", contractStatisticsList1);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 赋值买卖公司地址
|
|
|
*/
|
|
|
private void setArea(SaleQuotationVo saleQuotationVo) {
|
|
@@ -293,4 +590,13 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
|
|
|
}
|
|
|
|
|
|
|
|
|
+ //根据字典编码获取字典的数据
|
|
|
+ private List<DictTenantDataVo> getDict(String code){
|
|
|
+ DictTenantDataSelectDto dto = new DictTenantDataSelectDto();
|
|
|
+ dto.setDictCode(code);
|
|
|
+ List<DictTenantDataVo> dictTenantDataServiceList = dictTenantDataService.getList(dto);
|
|
|
+ return dictTenantDataServiceList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|