1
This commit is contained in:
parent
e267a2121a
commit
232f13be3e
@ -1,5 +1,7 @@
|
|||||||
package com.ruoyi.busi.service.impl;
|
package com.ruoyi.busi.service.impl;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -10,6 +12,7 @@ import com.ruoyi.busi.domain.BusiChatMain;
|
|||||||
import com.ruoyi.busi.domain.BusiInquiryItem;
|
import com.ruoyi.busi.domain.BusiInquiryItem;
|
||||||
import com.ruoyi.busi.mapper.BusiChatMainMapper;
|
import com.ruoyi.busi.mapper.BusiChatMainMapper;
|
||||||
import com.ruoyi.busi.mapper.BusiInquiryItemMapper;
|
import com.ruoyi.busi.mapper.BusiInquiryItemMapper;
|
||||||
|
import com.ruoyi.busi.utils.CommonUtils;
|
||||||
import com.ruoyi.busi.vo.ChartDataVO;
|
import com.ruoyi.busi.vo.ChartDataVO;
|
||||||
import com.ruoyi.busi.vo.IndexInquiryVO;
|
import com.ruoyi.busi.vo.IndexInquiryVO;
|
||||||
import com.ruoyi.busi.vo.ThirdSoftVO;
|
import com.ruoyi.busi.vo.ThirdSoftVO;
|
||||||
@ -273,17 +276,66 @@ public class BusiThirdItemServiceImpl extends ServiceImpl<BusiThirdItemMapper,Bu
|
|||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> inquiryChart(String tenantId, String startDate, String endDate) {
|
public Map<String, Object> inquiryChart(String tenantId, String startDate, String endDate) {
|
||||||
|
Map<String,Object> rtnMap = new HashMap<>();
|
||||||
//开始日期
|
//开始日期
|
||||||
String startDateStr = startDate+StrConstants.START_DATE;
|
String startDateStr = startDate+StrConstants.START_DATE;
|
||||||
//截止日期
|
//截止日期
|
||||||
String endDateStr = startDate+StrConstants.END_DATE;
|
String endDateStr = endDate+StrConstants.END_DATE;
|
||||||
//先查出这段时间所有三方询盘数据
|
//先查出这段时间所有三方询盘数据
|
||||||
List<BusiThirdItem> thirdItemList = busiThirdItemMapper.selectLineChart(tenantId,startDateStr,endDateStr);
|
List<BusiThirdItem> thirdItemList = busiThirdItemMapper.selectLineChart(tenantId,startDateStr,endDateStr);
|
||||||
//这段时间所有在线询盘数据
|
//这段时间所有在线询盘数据
|
||||||
List<BusiInquiryItem> inquiryItemList = inquiryItemMapper.selectLineChart(tenantId, startDateStr, endDateStr);
|
List<BusiInquiryItem> inquiryItemList = inquiryItemMapper.selectLineChart(tenantId, startDateStr, endDateStr);
|
||||||
//这段时间所有在线聊天的数据
|
//这段时间所有在线聊天的数据
|
||||||
List<BusiChatMain> chatMainList = chatMainMapper.selectLineChart(tenantId, startDateStr, endDateStr);
|
List<BusiChatMain> chatMainList = chatMainMapper.selectLineChart(tenantId, startDateStr, endDateStr);
|
||||||
|
//所有月份
|
||||||
return null;
|
List<String> yearMonthList = CommonUtils.getAllYearMonth(startDate, endDate);
|
||||||
|
List<Integer> allNumList = new ArrayList<>();
|
||||||
|
List<Integer> emailNumList = new ArrayList<>();
|
||||||
|
List<Integer> whatsAppNumList = new ArrayList<>();
|
||||||
|
List<Integer> teamsNumList = new ArrayList<>();
|
||||||
|
List<Integer> chatNumList = new ArrayList<>();
|
||||||
|
List<Integer> inquiryNumList = new ArrayList<>();
|
||||||
|
//遍历每个月份
|
||||||
|
yearMonthList.forEach(item->{
|
||||||
|
//本月总数
|
||||||
|
Integer allNum = 0;
|
||||||
|
Integer emailNum = 0;
|
||||||
|
Integer whatsAppNum = 0;
|
||||||
|
Integer teamsNum = 0;
|
||||||
|
//先过滤三方询盘的
|
||||||
|
List<BusiThirdItem> thirdFilterList = thirdItemList.stream().filter(thirdItem -> DateUtil.formatDate(thirdItem.getCreateTime()).contains(item)).collect(Collectors.toList());
|
||||||
|
for (BusiThirdItem filter:thirdFilterList){
|
||||||
|
if(DictConstants.THIRD_SOFT_EMAIL.equals(filter.getThirdSoft())){
|
||||||
|
//email
|
||||||
|
emailNum++;
|
||||||
|
}else if(DictConstants.THIRD_SOFT_TEAMS.equals(filter.getThirdSoft())){
|
||||||
|
//teams
|
||||||
|
teamsNum++;
|
||||||
|
}else if(DictConstants.THIRD_SOFT_WHATSAPP.equals(filter.getThirdSoft())){
|
||||||
|
//whatsApp
|
||||||
|
whatsAppNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//在线聊天数
|
||||||
|
Integer chatNum = (int) chatMainList.stream().filter(thirdItem -> DateUtil.formatDate(thirdItem.getCreateTime()).contains(item)).count();
|
||||||
|
//在线询盘数
|
||||||
|
Integer inquiryNum = (int) inquiryItemList.stream().filter(thirdItem -> DateUtil.formatDate(thirdItem.getCreateTime()).contains(item)).count();
|
||||||
|
allNum=emailNum+teamsNum+whatsAppNum+chatNum+inquiryNum;
|
||||||
|
allNumList.add(allNum);
|
||||||
|
emailNumList.add(emailNum);
|
||||||
|
whatsAppNumList.add(whatsAppNum);
|
||||||
|
teamsNumList.add(teamsNum);
|
||||||
|
chatNumList.add(chatNum);
|
||||||
|
inquiryNumList.add(inquiryNum);
|
||||||
|
});
|
||||||
|
rtnMap.put("month",yearMonthList);
|
||||||
|
rtnMap.put("allNum",allNumList);
|
||||||
|
rtnMap.put("emailNum",emailNumList);
|
||||||
|
rtnMap.put("whatsAppNum",whatsAppNumList);
|
||||||
|
rtnMap.put("teamsNum",teamsNumList);
|
||||||
|
rtnMap.put("chatNum",chatNumList);
|
||||||
|
rtnMap.put("inquiryNum",inquiryNumList);
|
||||||
|
return rtnMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
/**
|
/**
|
||||||
@ -76,4 +78,28 @@ public class CommonUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取给定的一个时间范围内的所有月份
|
||||||
|
* @author vinjor-M
|
||||||
|
* @date 15:24 2025/7/17
|
||||||
|
* @param startDate 开始日期
|
||||||
|
* @param endDate 结束日期
|
||||||
|
* @return java.util.List<java.lang.String>
|
||||||
|
**/
|
||||||
|
public static List<String> getAllYearMonth(String startDate,String endDate){
|
||||||
|
//定期起始日期
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
LocalDate startDateObj = LocalDate.parse(startDate,formatter);
|
||||||
|
LocalDate endDateObj = LocalDate.parse(endDate,formatter);
|
||||||
|
//获取所有年月
|
||||||
|
List<String> yearMonthList = new ArrayList<>();
|
||||||
|
// 从起始日期开始,遍历到结束日期
|
||||||
|
while (!startDateObj.isAfter(endDateObj)) {
|
||||||
|
// 只要startDate不晚于endDate 获取年-月格式
|
||||||
|
yearMonthList.add(startDateObj.getYear() + "-" + String.format("%02d", startDateObj.getMonthValue()));
|
||||||
|
// 增加一个月
|
||||||
|
startDateObj = startDateObj.plusMonths(1);
|
||||||
|
}
|
||||||
|
return yearMonthList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,14 +57,14 @@ export default {
|
|||||||
this.chart = null
|
this.chart = null
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initChart() {
|
initChart(dataObj) {
|
||||||
this.chart = echarts.init(this.$el, 'macarons')
|
this.chart = echarts.init(this.$el, 'macarons')
|
||||||
this.setOptions(this.chartData)
|
this.setOptions(dataObj)
|
||||||
},
|
},
|
||||||
setOptions({ expectedData, actualData } = {}) {
|
setOptions(dataObj) {
|
||||||
this.chart.setOption({
|
this.chart.setOption({
|
||||||
xAxis: {
|
xAxis: {
|
||||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
data: dataObj.month,
|
||||||
boundaryGap: false,
|
boundaryGap: false,
|
||||||
axisTick: {
|
axisTick: {
|
||||||
show: false
|
show: false
|
||||||
@ -90,44 +90,56 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
data: ['expected', 'actual']
|
data: ['总数', 'teams','whatsApp','email','在线询盘','在线聊天']
|
||||||
},
|
},
|
||||||
series: [{
|
series: [{
|
||||||
name: 'expected', itemStyle: {
|
name: '总数',
|
||||||
normal: {
|
|
||||||
color: '#FF005A',
|
|
||||||
lineStyle: {
|
|
||||||
color: '#FF005A',
|
|
||||||
width: 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
smooth: true,
|
smooth: true,
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data: expectedData,
|
data: dataObj.allNum,
|
||||||
animationDuration: 2800,
|
animationDuration: 2800,
|
||||||
animationEasing: 'cubicInOut'
|
animationEasing: 'cubicInOut'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'actual',
|
name: 'teams',
|
||||||
smooth: true,
|
smooth: true,
|
||||||
type: 'line',
|
type: 'line',
|
||||||
itemStyle: {
|
data: dataObj.teamsNum,
|
||||||
normal: {
|
|
||||||
color: '#3888fa',
|
|
||||||
lineStyle: {
|
|
||||||
color: '#3888fa',
|
|
||||||
width: 2
|
|
||||||
},
|
|
||||||
areaStyle: {
|
|
||||||
color: '#f3f8ff'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data: actualData,
|
|
||||||
animationDuration: 2800,
|
animationDuration: 2800,
|
||||||
animationEasing: 'quadraticOut'
|
animationEasing: 'quadraticOut'
|
||||||
}]
|
},
|
||||||
|
{
|
||||||
|
name: 'whatsApp',
|
||||||
|
smooth: true,
|
||||||
|
type: 'line',
|
||||||
|
data: dataObj.whatsAppNum,
|
||||||
|
animationDuration: 2800,
|
||||||
|
animationEasing: 'quadraticOut'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'email',
|
||||||
|
smooth: true,
|
||||||
|
type: 'line',
|
||||||
|
data: dataObj.emailNum,
|
||||||
|
animationDuration: 2800,
|
||||||
|
animationEasing: 'quadraticOut'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '在线询盘',
|
||||||
|
smooth: true,
|
||||||
|
type: 'line',
|
||||||
|
data: dataObj.inquiryNum,
|
||||||
|
animationDuration: 2800,
|
||||||
|
animationEasing: 'quadraticOut'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '在线聊天',
|
||||||
|
smooth: true,
|
||||||
|
type: 'line',
|
||||||
|
data: dataObj.chatNum,
|
||||||
|
animationDuration: 2800,
|
||||||
|
animationEasing: 'quadraticOut'
|
||||||
|
}]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ export default {
|
|||||||
endDate: '',
|
endDate: '',
|
||||||
tenantId: null
|
tenantId: null
|
||||||
},
|
},
|
||||||
lineChartData: lineChartData.newVisitis,
|
lineChartData: {},
|
||||||
pickerOptions: {
|
pickerOptions: {
|
||||||
shortcuts: [{
|
shortcuts: [{
|
||||||
text: '本月',
|
text: '本月',
|
||||||
@ -117,9 +117,8 @@ export default {
|
|||||||
*/
|
*/
|
||||||
getList(){
|
getList(){
|
||||||
inquiryChart(this.queryParams).then(response => {
|
inquiryChart(this.queryParams).then(response => {
|
||||||
this.rtnMap = response.data
|
this.lineChartData = response.data
|
||||||
this.$refs.barChart.initChart(this.rtnMap.nationalData)
|
this.$refs.lineChart.initChart(this.lineChartData)
|
||||||
this.$refs.pieChart.initChart(this.rtnMap.equipmentData)
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user