数据概览导出+优化

This commit is contained in:
ywh 2024-08-18 17:16:30 +08:00
parent 393987d292
commit d16d0648e7
5 changed files with 118 additions and 21 deletions

View File

@ -2,16 +2,16 @@ package com.ruoyi.business.controller;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar; import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.business.domain.*; import com.ruoyi.business.domain.*;
import com.ruoyi.business.mapper.BusAgentInfoMapper;
import com.ruoyi.business.service.IBusReturnVisitInfoService; import com.ruoyi.business.service.IBusReturnVisitInfoService;
import com.ruoyi.business.service.IBusStoreDayInfoService; import com.ruoyi.business.service.IBusStoreDayInfoService;
import com.ruoyi.business.service.IBusStoreInfoService; import com.ruoyi.business.service.IBusStoreInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -64,10 +64,33 @@ public class BusStoreDayHistoryInfoController extends BaseController
public TableDataInfo list1(String account, String expStartTime, String expEndTime) public TableDataInfo list1(String account, String expStartTime, String expEndTime)
{ {
// startPage(); // startPage();
TableDataInfo list = busStoreDayHistoryInfoService.selectBusStoreDayHistoryInfoList1(account, expStartTime,expEndTime); TableDataInfo list = busStoreDayHistoryInfoService.selectBusStoreDayHistoryInfoList1(true,account, expStartTime,expEndTime);
return list; return list;
} }
@Resource
private BusAgentInfoMapper agentInfoMapper;
@PostMapping("/exportDataOverview")
public void exportDataOverview(HttpServletResponse response,String account, String expStartTime, String expEndTime) throws Exception{
Map<String,Object> sql = new HashMap<>();
if(StringUtils.isNotBlank(account)){
sql.put("account",account);
}
if(StringUtils.isNotBlank(expStartTime)){
sql.put("expStartTime",expStartTime);
}
if(StringUtils.isNotBlank(expEndTime)){
sql.put("expEndTime",expEndTime);
}
// TableDataInfo tdi = busStoreDayHistoryInfoService.selectBusStoreDayHistoryInfoList1(false,account, expStartTime,expEndTime);
// List<BusOverviewInfo> datas = (List<BusOverviewInfo>) tdi.getRows();
List<BusOverviewInfo> datas = agentInfoMapper.selectDaataOverview(sql);
ExcelUtil<BusOverviewInfo> util = new ExcelUtil<>(BusOverviewInfo.class);
util.exportExcel(response, datas, "数据概览统计数据");
}
@PostMapping("/export") @PostMapping("/export")
public void export(Long storeId,String expStartTime,String expEndTime,HttpServletResponse response) throws Exception { public void export(Long storeId,String expStartTime,String expEndTime,HttpServletResponse response) throws Exception {
String startTime = expStartTime; String startTime = expStartTime;

View File

@ -1,7 +1,10 @@
package com.ruoyi.business.mapper; package com.ruoyi.business.mapper;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ruoyi.business.domain.BusAgentInfo; import com.ruoyi.business.domain.BusAgentInfo;
import com.ruoyi.business.domain.BusOverviewInfo;
/** /**
* 代理管理Mapper接口 * 代理管理Mapper接口
@ -27,6 +30,9 @@ public interface BusAgentInfoMapper
*/ */
public List<BusAgentInfo> selectBusAgentInfoList(BusAgentInfo busAgentInfo); public List<BusAgentInfo> selectBusAgentInfoList(BusAgentInfo busAgentInfo);
public List<BusOverviewInfo> selectDaataOverview(Map<String,Object> sql);
/** /**
* 新增代理管理 * 新增代理管理
* *

View File

@ -30,7 +30,7 @@ public interface IBusStoreDayHistoryInfoService
* @return 店铺单日信息集合 * @return 店铺单日信息集合
*/ */
public List<BusStoreExcelInfo> selectBusStoreDayHistoryInfoList(BusStoreExcelInfo busStoreExcelInfo); public List<BusStoreExcelInfo> selectBusStoreDayHistoryInfoList(BusStoreExcelInfo busStoreExcelInfo);
public TableDataInfo selectBusStoreDayHistoryInfoList1(String account, String expStartTime, String expEndTime); public TableDataInfo selectBusStoreDayHistoryInfoList1(boolean isPage,String account, String expStartTime, String expEndTime);
/** /**
* 新增店铺单日信息 * 新增店铺单日信息

View File

@ -77,8 +77,10 @@ public class BusStoreDayHistoryInfoServiceImpl implements IBusStoreDayHistoryInf
} }
@Override @Override
public TableDataInfo selectBusStoreDayHistoryInfoList1(String account, String expStartTime, String expEndTime) { public TableDataInfo selectBusStoreDayHistoryInfoList1(boolean isPage,String account, String expStartTime, String expEndTime) {
PageUtils.startPage(); if(isPage){
PageUtils.startPage();
}
BusAgentInfo agentInfo = new BusAgentInfo(); BusAgentInfo agentInfo = new BusAgentInfo();
agentInfo.setDelStatus("1"); agentInfo.setDelStatus("1");
if (StringUtils.isNotEmpty(account)) { if (StringUtils.isNotEmpty(account)) {
@ -93,23 +95,23 @@ public class BusStoreDayHistoryInfoServiceImpl implements IBusStoreDayHistoryInf
List<BusOverviewInfo> data = new ArrayList<>(); List<BusOverviewInfo> data = new ArrayList<>();
for (BusAgentInfo info : agentInfoList) { for (BusAgentInfo info : agentInfoList) {
BusOverviewInfo overviewInfo = new BusOverviewInfo(); BusOverviewInfo overviewInfo = new BusOverviewInfo();
overviewInfo.setAccount(info.getAgentAccount()); overviewInfo.setAccount(info.getAgentAccount());//账号
BusStoreInfo storeInfo = new BusStoreInfo(); BusStoreInfo storeInfo = new BusStoreInfo();
storeInfo.setBindUser(info.getAgentAccount()); storeInfo.setBindUser(info.getAgentAccount());
List<BusStoreInfo> l = storeInfoMapper.selectBusStoreInfoList(storeInfo); List<BusStoreInfo> l = storeInfoMapper.selectBusStoreInfoList(storeInfo);
overviewInfo.setGrantTotal(l.size()); overviewInfo.setGrantTotal(l.size());//营销源总数
BusStoreInfo storeInfo1 = new BusStoreInfo(); BusStoreInfo storeInfo1 = new BusStoreInfo();
storeInfo1.setGrantStatus("2"); storeInfo1.setGrantStatus("2");
storeInfo1.setBindUser(info.getAgentAccount()); storeInfo1.setBindUser(info.getAgentAccount());
List<BusStoreInfo> li = storeInfoMapper.selectBusStoreInfoList(storeInfo1); List<BusStoreInfo> li = storeInfoMapper.selectBusStoreInfoList(storeInfo1);
overviewInfo.setNoGrantTotal(li.size()); overviewInfo.setNoGrantTotal(li.size());//失效总数
BusStoreInfo storeInfo2 = new BusStoreInfo(); BusStoreInfo storeInfo2 = new BusStoreInfo();
storeInfo2.setGrantStatus("1"); storeInfo2.setGrantStatus("1");
storeInfo2.setBindUser(info.getAgentAccount()); storeInfo2.setBindUser(info.getAgentAccount());
List<BusStoreInfo> lis = storeInfoMapper.selectBusStoreInfoList(storeInfo2); List<BusStoreInfo> lis = storeInfoMapper.selectBusStoreInfoList(storeInfo2);
overviewInfo.setIsGrantTotal(lis.size()); overviewInfo.setIsGrantTotal(lis.size());//在营销总数
List<Long> ids = new ArrayList<>(); List<Long> ids = new ArrayList<>();
for (BusStoreInfo busStoreInfo : l) { for (BusStoreInfo busStoreInfo : l) {
@ -117,13 +119,13 @@ public class BusStoreDayHistoryInfoServiceImpl implements IBusStoreDayHistoryInf
} }
if (ids.size() > 0) { if (ids.size() > 0) {
BusOverviewInfo busOverviewInfo = busStoreDayHistoryInfoMapper.getCount(ids, expStartTime, expEndTime); BusOverviewInfo busOverviewInfo = busStoreDayHistoryInfoMapper.getCount(ids, expStartTime, expEndTime);
overviewInfo.setOrderTotal(busOverviewInfo.getOrderTotal()); overviewInfo.setOrderTotal(busOverviewInfo.getOrderTotal());//订单数量
overviewInfo.setCommentsTotal(busOverviewInfo.getCommentsTotal()); overviewInfo.setCommentsTotal(busOverviewInfo.getCommentsTotal());//好评数量
overviewInfo.setFiveTotal(busOverviewInfo.getFiveTotal()); overviewInfo.setFiveTotal(busOverviewInfo.getFiveTotal());//五星数量
} }
List<BusIntegralRecord> recordList = busStoreDayHistoryInfoMapper.getIntegralCount(info.getAgentAccount(),expStartTime,expEndTime); List<BusIntegralRecord> recordList = busStoreDayHistoryInfoMapper.getIntegralCount(info.getAgentAccount(),expStartTime,expEndTime);
overviewInfo.setMinusTotal(recordList.size()); overviewInfo.setMinusTotal(recordList.size());//消耗数量
if (recordList.size() > 0) { if (recordList.size() > 0) {
List<BusIntegralRecord> recordList1 = new ArrayList<>(); List<BusIntegralRecord> recordList1 = new ArrayList<>();
@ -138,9 +140,9 @@ public class BusStoreDayHistoryInfoServiceImpl implements IBusStoreDayHistoryInf
recordList3.add(record); recordList3.add(record);
} }
} }
overviewInfo.setSmsTotal(recordList1.size()); overviewInfo.setSmsTotal(recordList1.size());//短信数量
overviewInfo.setAiTotal(recordList2.size()); overviewInfo.setAiTotal(recordList2.size());//AI数量
overviewInfo.setOtherTotal(recordList3.size()); overviewInfo.setOtherTotal(recordList3.size());//通过数量
} }
//好评数量/消耗数量 //好评数量/消耗数量
@ -148,10 +150,10 @@ public class BusStoreDayHistoryInfoServiceImpl implements IBusStoreDayHistoryInf
overviewInfo.setRate("0"); overviewInfo.setRate("0");
}else { }else {
BigDecimal b = new BigDecimal(overviewInfo.getCommentsTotal()).divide(new BigDecimal(overviewInfo.getMinusTotal()),2, RoundingMode.HALF_UP); BigDecimal b = new BigDecimal(overviewInfo.getCommentsTotal()).divide(new BigDecimal(overviewInfo.getMinusTotal()),2, RoundingMode.HALF_UP);
overviewInfo.setRate(b.toString()); overviewInfo.setRate(b.toString());//营销比(%)
} }
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
overviewInfo.setTime(sdf.format(new Date())); overviewInfo.setTime(sdf.format(new Date()));//结算时间
data.add(overviewInfo); data.add(overviewInfo);
} }

View File

@ -28,6 +28,72 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, agent_account, agent_name, integral,create_time ,superior_agent_code, superior_agent_account, grant_store_num, operate_store_num, last_use_integral_num, last_positive_reviews_num, ai_duration_balance, last_login_time, last_login_ip, login_num, del_status,ai_real_time_num from bus_agent_info select id, agent_account, agent_name, integral,create_time ,superior_agent_code, superior_agent_account, grant_store_num, operate_store_num, last_use_integral_num, last_positive_reviews_num, ai_duration_balance, last_login_time, last_login_ip, login_num, del_status,ai_real_time_num from bus_agent_info
</sql> </sql>
<select id="selectDaataOverview" parameterType="java.util.Map" resultType="com.ruoyi.business.domain.BusOverviewInfo">
SELECT
Agent_Account as account,
(SELECT count(1) FROM Bus_Store_Info WHERE Bind_User = a.Agent_Account AND self_delivery_status != '3' ) as grantTotal,
(SELECT count(1) FROM bus_store_info WHERE self_delivery_status != '3' AND grant_status = '2' AND bind_user = a.Agent_Account) as noGrantTotal,
(select count(1) from bus_store_info WHERE self_delivery_status != '3' and grant_status = '1' and bind_user = a.Agent_Account) as isGrantTotal,
b.*,
c.*,
(case WHEN (minusTotal != Null) THEN IFNULL(commentsTotal,0) / minusTotal else 0 end) as rate,
#{expEndTime} as time
FROM
(
select * from bus_agent_info
<where>
del_status = 1
<if test="account != null">
and Agent_Account = #{account}
</if>
</where>
) a
left JOIN
(SELECT
count(case WHEN agent_remark = 'sms' then 1 end) as smsTotal,
count(case WHEN agent_remark = '其他' then 1 end) as otherTotal,
count(case WHEN agent_remark = 'AI' then 1 end) as aiTotal,
count(1) as minusTotal,
account as bt
from bus_integral_record
<where>
1=1
<if test="expStartTime != null and expStartTime != '' and expEndTime != null and expEndTime != ''">
and DATE_FORMAT(Integral_update_time,'%Y-%m-%d') between #{expStartTime} and #{expEndTime}
</if>
<if test="expStartTime == null or expStartTime == '' or expEndTime == null or expEndTime == ''">
and DATE_FORMAT(Integral_update_time,'%Y-%m-%d') = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 DAY),'%Y-%m-%d')
</if>
<if test="account != null">and account=#{account}</if>
AND update_type = '消耗账分'
AND agent_remark IS NOT NULL
</where>
GROUP BY account) b
on a.agent_account = b.bt
left join (
select
ifnull(sum(last_order_num),0) as orderTotal,
ifnull(sum(last_positive_reviews_num),0) as commentsTotal,
ifnull(sum(last_five_star_reviews_num),0) as fiveTotal,
Bind_User
from (SELECT * from bus_store_day_history_info
<where>
<if test="expStartTime != null and expStartTime != '' and expEndTime != null and expEndTime != ''">
and DATE_FORMAT(create_time,'%Y-%m-%d') between #{expStartTime} and #{expEndTime}
</if>
<if test="expStartTime == null or expStartTime == '' or expEndTime == null or expEndTime == ''">
and DATE_FORMAT(create_time,'%Y-%m-%d') = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 DAY),'%Y-%m-%d')
</if>
</where>
) k
join (SELECT id,Bind_User FROM Bus_Store_Info WHERE
self_delivery_status != '3' ) m
on k.store_id = m.id
GROUP BY Bind_User
) c
on a.agent_account = c.Bind_User
</select>
<select id="selectBusAgentInfoList" parameterType="BusAgentInfo" resultMap="BusAgentInfoResult"> <select id="selectBusAgentInfoList" parameterType="BusAgentInfo" resultMap="BusAgentInfoResult">
<include refid="selectBusAgentInfoVo"/> <include refid="selectBusAgentInfoVo"/>
<where> <where>