Commit 5925ec10 authored by lanbaoming's avatar lanbaoming

2024-05-01 报表修改

parent aeee811d
package cn.iocoder.yudao.framework.apollo.core.event.export;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/*
lanbm 2024-05-01 add
销售分析报表导出excel
*/
@Data
public class ReportCustomerAnalysisExcelExportEvent {
/**
* 操作用户
*/
private Long userId;
/**
* 端口
*/
private Integer userType;
/**
* 请求参数
*/
private String requestParams;
/**
* 国际化语言值,默认0中文, 具体取值I18nMessage.getLang()
*/
private Integer lang = 0;
/**
* 文件名称
*/
private String fileName;
/**
* 文件路径
*/
private String path;
/**
* 下载地址
*/
private String url;
/**
* 执行结果
*/
private String result;
@ApiModelProperty(value = "文件ID")
private Long fileId;
}
package cn.iocoder.yudao.framework.apollo.core.event.export;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/*
客户分析报表导出 lanbm 2024-05-01 add
*/
@Data
public class ReportSalesAnalysisExcelExportEvent {
/**
* 操作用户
*/
private Long userId;
/**
* 端口
*/
private Integer userType;
/**
* 请求参数
*/
private String requestParams;
/**
* 国际化语言值,默认0中文, 具体取值I18nMessage.getLang()
*/
private Integer lang = 0;
/**
* 文件名称
*/
private String fileName;
/**
* 文件路径
*/
private String path;
/**
* 下载地址
*/
private String url;
/**
* 执行结果
*/
private String result;
@ApiModelProperty(value = "文件ID")
private Long fileId;
}
......@@ -33,5 +33,12 @@
<artifactId>yudao-module-system-impl</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-infra-impl</artifactId>
<version>1.6.1-snapshot</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
......@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.framework.redis.helper.RedisHelper;
......@@ -17,7 +18,11 @@ import cn.iocoder.yudao.module.delivery.service.CustomerAnalysisService2;
import cn.iocoder.yudao.module.delivery.service.EcwReportPermissionService;
import cn.iocoder.yudao.module.delivery.service.view_order_businesstimeService;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.file.FileMakeApi;
import cn.iocoder.yudao.module.system.api.file.dto.FileMakeReqDTO;
import cn.iocoder.yudao.module.system.enums.download.DownloadTypeEnum;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.core.JsonProcessingException;
......@@ -78,123 +83,8 @@ public class CustomerAnalysisControl {
@Autowired
private DictDataApi dictDataApi;
/*
计算百分比
lanbm 2024-04-10 add
*/
private String getPercentage(BigDecimal part, BigDecimal total) {
BigDecimal percentage = part.divide(total, 5,
BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
// 输出百分比
String sR = format(percentage) + "%";
return sR;
}
/*
格式化BigDecimal为字符串,保留两位小数
lanbm 2024-04-10 add
*/
private String format(BigDecimal value) {
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(2);
numberFormat.setMaximumFractionDigits(2);
return numberFormat.format(value.doubleValue());
}
private String getCurDate() {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String currentDate = sdf.format(date);
return currentDate;
}
private int getCurYear() {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
return year;
}
/*
获取数据查询条件
*/
private CustomerAnalysisReq getDataWhere(CustomerAnalysisReq query) {
if (query.getSearchDataType1() != null &&
query.getSearchDataType2() != null &&
query.getSearchDataType3() != null) {
}
return query;
}
/*
对查询逻辑做处理 lanbm 2024-04-16 add
*/
private CustomerAnalysisReq getReq(CustomerAnalysisReq Req) {
//计算月份差
long lc = monthDiff(Req.getSdate(), Req.getEdate());
if (lc == 0) {
lc = 1;
}
Req.setNMonth(Integer.parseInt(String.valueOf(lc)));
int y = getCurYear();
if (Req.getSdate() == null) {
Req.setCurYear(String.valueOf(y));
Req.setSdate(String.valueOf(y) + "-01-01");
if (Req.getDuibiYear() == null) {
Req.setDuibiYear(String.valueOf(y - 1));
} else {
Req.setSduibidate(Req.getDuibiYear() + "-01-01");
}
} else {
//2024-03-01
String sT = Req.getSdate();
String s = sT.substring(4, 10);
if (Req.getDuibiYear() == null) {
int nTemp = Integer.parseInt(sT.substring(0, 4)) - 1;
Req.setSduibidate(String.valueOf(nTemp) + s);
} else {
Req.setSduibidate(Req.getDuibiYear() + s);
}
Req.setCurYear(sT.substring(0, 4));
}
if (Req.getEdate() == null) {
Req.setEdate(getCurDate());
String s = Req.getEdate().substring(5, 7);
int ld = getLastDay(Integer.parseInt(Req.getDuibiYear()), Integer.parseInt(s));
Req.setEduibidate(Req.getDuibiYear() + "-" + s + "-" + String.valueOf(ld));
} else {
String sE = Req.getEdate();
String sY = sE.substring(0, 4);
//int ld = getLastDay(Integer.parseInt(sY), Integer.parseInt(s));
//2024-03-01
String s1 = sE.substring(4, 10);
if (Req.getDuibiYear() == null) {
int nTemp = Integer.parseInt(sY) - 1;
Req.setEduibidate(String.valueOf(nTemp) + s1);
} else {
Req.setEduibidate(Req.getDuibiYear() + s1);
}
}
return Req;
}
/*
获取某年某月的最后一天 lanbm 2024-04-16 add
*/
private int getLastDay(int year, int month) {
YearMonth yearMonth = YearMonth.of(year, month);
int lastDay = yearMonth.lengthOfMonth();
return lastDay;
}
@Resource
private FileMakeApi fileMakeApi;
/*
......@@ -219,7 +109,8 @@ public class CustomerAnalysisControl {
LambdaQueryWrapper<EcwReportPermission> lambdaQueryWrapper =
new LambdaQueryWrapper();
lambdaQueryWrapper.eq(EcwReportPermission::getUserId, loginUserId);
List<EcwReportPermission> objList = ecwReportPermissionService.list(lambdaQueryWrapper);
List<EcwReportPermission> objList =
ecwReportPermissionService.list(lambdaQueryWrapper);
if (objList == null || objList.size() == 0) {
ErrorCode eCode = new ErrorCode(2024041504,
"当前用户未分配报表权限,请联系系统管理员处理。");
......@@ -230,564 +121,45 @@ public class CustomerAnalysisControl {
CustomerAnalysisReq query = JSON.parseObject(JSON.toJSONString(map),
CustomerAnalysisReq.class);
query = getReq(query);
query = getDataWhere(query);
System.out.println("处理后的查询条件:" + query);
PageResult<CustomerAnalysisResp> pageResult = GetDataResult(query);
return success(pageResult);
}
private PageResult<CustomerAnalysisResp> GetDataResult(CustomerAnalysisReq query)
throws JsonProcessingException {
//把model转 JSON字符串 lanbm
//String jsonStr = JsonUtils.toJsonString(query);
//JsonUtils.SaveLog(jsonStr);
System.out.println("客户分析查询条件为:" + query);
List<DictDataRespDTO> dicCustomer_type =
dictDataApi.getDictDatas("customer_type");
Map<String, String> mapDic = new HashMap<>();
for (DictDataRespDTO d : dicCustomer_type
) {
mapDic.put(d.getValue(), d.getLabel());
}
PageResult<CustomerAnalysisResp> pageResult =
customerAnalysisService.getListPage(query);
String sTemp = "";
int nPm = query.getStart() + 1;
for (CustomerAnalysisResp r : pageResult.getList()) {
r.setPx(nPm);
nPm++;
//客户类型转换
String sType = r.getType();
if (sType == null) {
r.setCustomerrole("");
} else {
r.setCustomerrole(mapDic.get(sType));
}
if (r.getAllsumvolume() == null ||
r.getAllsumvolume().compareTo(BigDecimal.ZERO) == 0) {
r.setAllsumvolume(new BigDecimal(0));
//计算月均
r = calMonthAvg(query, r, true);
//计算总值
r = calAll(r, true);
//计算海运数据
r = cal1(query, r, true);
//计算空运数据
r = cal3(query, r, true);
//计算重货数据
r = calZH(r, true);
//计算泡货数据
r = calPH(r, true);
//计算控货数据
r = calKH(r, true);
} else {
//计算月均
r = calMonthAvg(query, r, false);
//计算总值
r = calAll(r, false);
//计算海运数据
r = cal1(query, r, false);
//计算空运数据
r = cal3(query, r, false);
//重货
r = calZH(r, false);
//计算泡货占比
r = calPH(r, false);
//计算控货占比
r = calKH(r, false);
}
r = calPick(r, false);
}
return pageResult;
}
private CustomerAnalysisResp calMonthAvg(CustomerAnalysisReq query,
CustomerAnalysisResp r, boolean bZzNull) {
String sTemp = "";
if (bZzNull == true) {
r.setAllsumvolume(new BigDecimal(0));
r.setMonthAvg("0");
} else {
r.setMonthAvg(r.getAllsumvolume().divide(
new BigDecimal(query.getNMonth()), 2,
BigDecimal.ROUND_HALF_UP).toString());
}
//计算同比
if (r.getAllsumvolumeTb() == null ||
r.getAllsumvolumeTb().compareTo(BigDecimal.ZERO) == 0) {
r.setMonthAvgTbShow("同期值为0");
} else {
sTemp = getPercentage(
(r.getAllsumvolume().subtract(r.getAllsumvolumeTb())),
r.getAllsumvolumeTb());
r.setMonthAvgTbShow(sTemp);
}
return r;
}
/*
总值计算
*/
private CustomerAnalysisResp calAll(CustomerAnalysisResp r, boolean bZzNull) {
String sTemp = "";
if (bZzNull == true) {
r.setAllsumvolume(new BigDecimal(0));
}
if (r.getAllsumvolumeTb() == null ||
r.getAllsumvolumeTb().compareTo(BigDecimal.ZERO) == 0) {
r.setAllsumvolumeTbShow("同期V值为0");
} else {
//(本期-同期)/同期
sTemp = getPercentage(
(r.getAllsumvolume().subtract(r.getAllsumvolumeTb())),
r.getAllsumvolumeTb());
r.setAllsumvolumeTbShow(sTemp);
}
return r;
}
/*
计算提货数据
*/
private CustomerAnalysisResp calPick(CustomerAnalysisResp r, boolean bZzNull) {
if (r.getChargequantity() == 0) {
r.setThL("总箱数为0");
} else {
r.setThL(getIntPercentage(r.getPickquantity(), r.getChargequantity()));
}
return r;
}
/*
处理海运数据
*/
private CustomerAnalysisResp cal1(CustomerAnalysisReq query,
CustomerAnalysisResp r, boolean bZzNull) {
String sTemp = "";
if (bZzNull == true) {
r.setAllsumvolume(new BigDecimal(0));
}
if (r.getSumvolume1() == null ||
r.getSumvolume1().compareTo(BigDecimal.ZERO) == 0) {
//海运V值
r.setSumvolumeV1(new BigDecimal(0));
//海运体积数
r.setSumvolume1(new BigDecimal(0));
if (bZzNull == true) {
r.setSeaZb("总值为0");
//海运月均
r.setSeaMonthAvg("总值为0");
} else {
//海运占比
r.setSeaZb("0");
//海运月均
r.setSeaMonthAvg("0");
}
} else {
//设置海运V值
r.setSumvolumeV1(r.getSumvolume1());
if (bZzNull == true) {
r.setSeaZb("总值为0");
} else {
r.setSeaZb(getPercentage(r.getSumvolumeV1(), r.getAllsumvolume()));
}
//月均V值 是体积
r.setSeaMonthAvg(r.getSumvolume1().divide(new BigDecimal(query.getNMonth()), 2,
BigDecimal.ROUND_HALF_UP).toString());
}
if (r.getSumvolumeTb1() == null ||
r.getSumvolumeTb1().compareTo(BigDecimal.ZERO) == 0) {
r.setSumvolumeTbV1(new BigDecimal(0));
r.setSumvolumeTbShow1("同期为0");
} else {
r.setSumvolumeTbV1(new BigDecimal(1).multiply(r.getSumvolumeTb1()));
sTemp = getPercentage(
(r.getSumvolumeV1().subtract(r.getSumvolumeTbV1())),
r.getSumvolumeTbV1());
r.setSumvolumeTbShow1(sTemp);
}
return r;
}
/*
处理空运数据
*/
private CustomerAnalysisResp cal3(CustomerAnalysisReq query,
CustomerAnalysisResp r, boolean bZzNull) {
String sTemp = "";
if (bZzNull == true) {
r.setAllsumvolume(new BigDecimal(0));
}
//当期值
if (r.getSumweight3() == null ||
r.getSumweight3().compareTo(BigDecimal.ZERO) == 0) {
r.setSumweightV3(new BigDecimal(0));
r.setSumweight3(new BigDecimal(0));
if (bZzNull == true) {
r.setAirZb("总值为0");
r.setAirMothAvg("总值为0");
} else {
r.setAirZb("0");
r.setAirMothAvg("0");
}
} else {
r.setSumweightV3(r.getSumweight3().divide(new BigDecimal(100)));
if (bZzNull == true) {
r.setAirZb("总值为0");
} else {
r.setAirZb(getPercentage(r.getSumweightV3(), r.getAllsumvolume()));
}
//月均是 重量
r.setAirMothAvg(r.getSumweight3().divide(new BigDecimal(query.getNMonth()), 2,
BigDecimal.ROUND_HALF_UP).toString());
}
//同期值
if (r.getSumweightTb3() == null ||
r.getSumweightTb3().compareTo(BigDecimal.ZERO) == 0) {
r.setSumweightTb3(new BigDecimal(0));
r.setSumweightTbV3(new BigDecimal(0));
r.setSumweightTbShow3("同期值为0");
} else {
r.setSumweightTbV3(r.getSumweightTb3().divide(new BigDecimal(100)));
sTemp = getPercentage(
(r.getSumweightV3().subtract(r.getSumweightTbV3())),
r.getSumweightTbV3());
r.setSumweightTbShow3(sTemp);
}
return r;
}
/*
计算重货数据
*/
private CustomerAnalysisResp calZH(CustomerAnalysisResp r, boolean bZzNull) {
if (bZzNull == true) {
//总值为0的情况
r.setAllsumvolume(new BigDecimal(0));
}
//重货 占比
if (r.getWeightSumV() == null ||
r.getWeightSumV().compareTo(BigDecimal.ZERO) == 0) {
r.setWeightSumV(new BigDecimal(0));
if (bZzNull == true) {
r.setWeithtSumZb("总值为0");
} else {
r.setWeithtSumZb("0");
}
} else {
r.setWeithtSumZb(getPercentage(r.getWeightSumV(), r.getAllsumvolume()));
}
return r;
}
/*
计算泡货数据
*/
private CustomerAnalysisResp calPH(CustomerAnalysisResp r, boolean bZzNull) {
if (bZzNull == true) {
//泡货 占比
r.setAllsumvolume(new BigDecimal(0));
}
if (r.getPhSumV() == null ||
r.getPhSumV().compareTo(BigDecimal.ZERO) == 0) {
r.setPhSumV(new BigDecimal(0));
if (bZzNull == true) {
r.setPhSumZb("总值为0");
} else {
r.setPhSumZb("0");
}
} else {
r.setPhSumZb(getPercentage(r.getPhSumV(), r.getAllsumvolume()));
}
return r;
}
/*
计算控货数据
*/
private CustomerAnalysisResp calKH(CustomerAnalysisResp r, boolean bZzNull) {
if (bZzNull == true) {
//控货 占比
r.setAllsumvolume(new BigDecimal(0));
}
if (r.getKhSumV() == null ||
r.getKhSumV().compareTo(BigDecimal.ZERO) == 0) {
r.setKhSumV(new BigDecimal(0));
if (bZzNull == true) {
r.setKhSumZb("总值为0");
} else {
r.setKhSumZb("0");
}
} else {
r.setKhSumZb(getPercentage(r.getKhSumV(),
r.getAllsumvolume()));
}
return r;
}
private String getIntPercentage(int number, int divisor) {
// 计算百分比
double percentage = number / (double) divisor;
// 格式化输出百分比
String formatted = String.format("%.2f%%", percentage);
return formatted;
}
private int monthDiff(String dateString1, String dateString2) {
// 将字符串转换为 LocalDate 对象
LocalDate date1 = LocalDate.parse(dateString1);
LocalDate date2 = LocalDate.parse(dateString2);
// 获软时间1的年份和月份
int year1 = date1.getYear();
int month1 = date1.getMonthValue();
// 获取时间2的年份和月份
int year2 = date2.getYear();
int month2 = date2.getMonthValue();
// 计算时间1的总月数
int totalMonths1 = year1 * 12 + month1;
// 计算时间2的总月数
int totalMonths2 = year2 * 12 + month2;
// 计算总月数差
int monthsDiff = totalMonths2 - totalMonths1;
return monthsDiff;
}
private List<CustomerAnalysisResp> GetPageResult(
List<CustomerAnalysisResp> list, int pageNum, int pageSize) {
/*
// 正序
Collections.sort(list, (a, b) -> {
return a.排序字段 - b.排序字段;
});
// 倒序
Collections.sort(list, (a, b) -> {
return b.排序字段 - a.排序字段;
});*/
// 总数
int total = list.size();
// 分页数据
List<CustomerAnalysisResp> subList =
list.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
return subList;
customerAnalysisService.GetDataResult(query);
return success(pageResult);
}
@GetMapping("/exportExcel")
@ApiOperation("导出客户分析数据")
@OperateLog(type = EXPORT)
public void export(HttpServletResponse response, @Valid CustomerAnalysisReq query) throws IOException {
query = getReq(query);
query = getDataWhere(query);
query = customerAnalysisService.getReq(query);
query = customerAnalysisService.getDataWhere(query);
System.out.println("处理后的查询条件:" + query);
PageResult<CustomerAnalysisResp> pageResult = GetDataResult(query);
List<CustomerAnalysisResp> list = pageResult.getList();
/*
FileMakeReqDTO reqDTO = new FileMakeReqDTO();
reqDTO.setType(DownloadTypeEnum.REPORT_CSSTOMER_ANALYSIS.getType());
reqDTO.setName("客户分析报表");
reqDTO.setFileSuffix("xlsx");
reqDTO.setTemporaryFile(true);
reqDTO.setUserType(2);
reqDTO.setLang(I18nMessage.getLang());
reqDTO.setRequestParams(JSONObject.toJSONString(query));
fileMakeApi.sendFileMake(reqDTO);
return CommonResult.success(true);
*/
List<CustomerAnalysisResp> list =
customerAnalysisService.GetDataListResult(query);
List<CustomerAnalysisExcelResp> listExel =
CustomerAnalysis.INSTANCE.convertList(list);
// 导出 Excel
ExcelUtils.write(response, "客户分析报表.xls", "客户分析报表",
CustomerAnalysisExcelResp.class, listExel);
}
@PostMapping("/getListPageWithRedis")
public CommonResult<PageResult<CustomerAnalysisResp>>
getListPageWithRedis(@RequestBody Map map) throws JsonProcessingException {
//ecw_customer 的部门字段都为空 department 都为空,所以要关联客户经理所在的部门来查询
//ecw_order_item order_item_type 订单类型:1 普货 2 重货 3 泡货
//ecw_order order_type 订单类型:1 普货 2 重货 3 泡货
// is_cargo_control 是否控货 1 控货,0不控货
//同比增长速度=(本期发展水平-同期发展水平)/同期发展水平×100%
//客户角色数据字典
//客户表和数据字典表中的编码方式不一样,做关联查询有异常,为了不改变表的编码方式,在后台做转换
//获取当前用户ID
//先判断用户有什么报表权限
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
LambdaQueryWrapper<EcwReportPermission> lambdaQueryWrapper =
new LambdaQueryWrapper();
lambdaQueryWrapper.eq(EcwReportPermission::getUserId, loginUserId);
List<EcwReportPermission> objList = ecwReportPermissionService.list(lambdaQueryWrapper);
if (objList == null || objList.size() == 0) {
ErrorCode eCode = new ErrorCode(2024041504,
"当前用户未分配报表权限,请联系系统管理员处理。");
return error(eCode);
}
System.out.println(map);
CustomerAnalysisReq query = JSON.parseObject(JSON.toJSONString(map),
CustomerAnalysisReq.class);
query = getReq(query);
query = getDataWhere(query);
System.out.println("处理后的查询条件:" + query);
//把model转 JSON字符串 lanbm
//String jsonStr = JsonUtils.toJsonString(query);
//JsonUtils.SaveLog(jsonStr);
System.out.println("客户分析查询条件为:" + query);
List<DictDataRespDTO> dicCustomer_type =
dictDataApi.getDictDatas("customer_type");
Map<String, String> mapDic = new HashMap<>();
for (DictDataRespDTO d : dicCustomer_type
) {
mapDic.put(d.getValue(), d.getLabel());
}
ObjectMapper objectMapper = new ObjectMapper();
String sList = redisHelper.get("view_order_businesstime");
if (sList == null || sList.length() == 0) {
listBData = vieworderbusinesstimeService.getOrderBusinessData();
String json = objectMapper.writeValueAsString(listBData);
redisHelper.set("view_order_businesstime", json);
} else {
if (listBData == null) {
listBData = JSON.parseArray(sList, view_order_businesstime.class);
}
}
String sList2 = redisHelper.get("CustomerAnalysisResp");
if (sList2 == null || sList2.length() == 0) {
objListResult = customerAnalysisService2.getList(query);
String json = objectMapper.writeValueAsString(objListResult);
redisHelper.set("CustomerAnalysisResp", json);
} else {
objListResult = JSON.parseArray(sList2,
CustomerAnalysisResp.class);
}
if (query.getCountry() != null && query.getCountry().length() > 0) {
int cC = Integer.parseInt(query.getCountry());
objListResult =
objListResult.stream().filter(c -> c.getCountryID() == cC).collect(Collectors.toList());
}
String sTemp = "";
int nPm = 1;
for (CustomerAnalysisResp r : objListResult) {
r.setPx(nPm);
nPm++;
//客户类型转换
String sType = r.getType();
if (sType == null) {
r.setCustomerrole("");
} else {
r.setCustomerrole(mapDic.get(sType));
}
String sID = r.getId();
List<view_order_businesstime> lAll =
listBData.stream().filter(c -> c.getCustomerid() == sID).
collect(Collectors.toList());
BigDecimal sumV =
lAll.stream().map(view_order_businesstime::getVz).
reduce(BigDecimal.ZERO, BigDecimal::add);
r.setAllsumvolume(sumV);
if (r.getAllsumvolume() == null ||
r.getAllsumvolume().compareTo(BigDecimal.ZERO) == 0) {
r.setAllsumvolume(new BigDecimal(0));
//计算月均
r = calMonthAvg(query, r, true);
//计算总值
r = calAll(r, true);
//计算海运数据
r = cal1(query, r, true);
//计算空运数据
r = cal3(query, r, true);
//计算重货数据
r = calZH(r, true);
//计算泡货数据
r = calPH(r, true);
//计算控货数据
r = calKH(r, true);
} else {
//计算月均
r = calMonthAvg(query, r, false);
//计算总值
r = calAll(r, false);
//计算海运数据
r = cal1(query, r, false);
//计算空运数据
r = cal3(query, r, false);
//重货
r = calZH(r, false);
//计算泡货占比
r = calPH(r, false);
//计算控货占比
r = calKH(r, false);
}
r = calPick(r, false);
}
IPage<CustomerAnalysisResp> mpPage = MyBatisUtils.buildPage(query);
long total = objListResult.size();
System.out.println("符合条件的客户总数:" + String.valueOf(total));
List<CustomerAnalysisResp> list = GetPageResult(objListResult, query.getPageNo(), query.getPageSize());
PageResult<CustomerAnalysisResp> pageResult = new PageResult<>(list, total, mpPage.getSize(),
query.getPageNo(), (total + mpPage.getSize() - 1) / mpPage.getSize());
return success(pageResult);
}
}
......@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisReq;
......@@ -13,10 +14,15 @@ import cn.iocoder.yudao.module.delivery.entity.SalesAnalysisReq;
import cn.iocoder.yudao.module.delivery.entity.SalesAnalysisResp;
import cn.iocoder.yudao.module.delivery.service.SalesAnalysisService;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.file.FileMakeApi;
import cn.iocoder.yudao.module.system.api.file.dto.FileMakeReqDTO;
import cn.iocoder.yudao.module.system.enums.download.DownloadTypeEnum;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
......@@ -46,6 +52,9 @@ public class SalesAnalysisControl {
@Autowired
private DictDataApi dictDataApi;
@Resource
private FileMakeApi fileMakeApi;
/*
根据原始信息计算逻辑展示信息 lanbm 2024-04-29 add
*/
......@@ -164,13 +173,26 @@ public class SalesAnalysisControl {
@GetMapping("/exportExcel")
@ApiOperation("导出销售分析数据")
@OperateLog(type = EXPORT)
public void export(HttpServletResponse response,
public CommonResult<Boolean> export(HttpServletResponse response,
@Valid SalesAnalysisReq Req)
throws IOException {
System.out.println("订单分析查询数据导出查询条件:" + Req);
FileMakeReqDTO reqDTO = new FileMakeReqDTO();
reqDTO.setType(DownloadTypeEnum.REPORT_SALES_ANALYSIS.getType());
reqDTO.setName("销售分析数据");
reqDTO.setFileSuffix("xlsx");
reqDTO.setTemporaryFile(true);
reqDTO.setUserType(2);
reqDTO.setLang(I18nMessage.getLang());
reqDTO.setRequestParams(JSONObject.toJSONString(Req));
fileMakeApi.sendFileMake(reqDTO);
return CommonResult.success(true);
/*
List<SalesAnalysisExcelResp> list = salesAnalysisService.getList(Req);
ExcelUtils.write(response, "销售分析数据.xls", "销售分析数据",
SalesAnalysisExcelResp.class, list);
SalesAnalysisExcelResp.class, list);*/
}
}
......@@ -5,6 +5,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import java.math.BigDecimal;
/*
客户分析报表
逻辑数据大部分集中在表 ecw_customer
......@@ -29,10 +31,6 @@ public class CustomerAnalysisReq extends PageParam {
private String name;
private String searchtype;
/*
是否新客户
*/
private int isnew;
/*
客户国家
......@@ -71,6 +69,11 @@ public class CustomerAnalysisReq extends PageParam {
*/
private int first;
/*
业绩类型
*/
private int cusYjType;
/*
客户角色
*/
......@@ -81,17 +84,29 @@ public class CustomerAnalysisReq extends PageParam {
数据筛选类型
*/
private String searchDataType1;
private BigDecimal searchData1;//总V值查询
private String searchDataType2;
private BigDecimal searchData2;//海运拼柜
private String searchDataType3;
private BigDecimal searchData3; //专线空运
/*
客户时间筛选条件
客户创建时间
*/
private String searchDataType4;
private String sdate4;
private String edate4;
/*
首次成交时间
*/
private String sdate5;
private String edate5;
/*
时间筛选类型
首次成交日期,客户创建日期
......
......@@ -87,7 +87,6 @@ public class CustomerAnalysisResp {
*/
private String sumvolumeTbShow1;
/*
专线空运
*/
......@@ -120,22 +119,25 @@ public class CustomerAnalysisResp {
海运月均方数
*/
private String seaMonthAvg;
private BigDecimal seaMonthAvgZ;
/*
海运月均方数同比
*/
private String seaMonthAvgTb;
private BigDecimal seaMonthAvgTbZ;
/*
空运月均重量
*/
private String airMothAvg;
private BigDecimal airMothAvgZ;//数值
/*
空运月均同比
*/
private String airMothAvgTb;
private String airMothAvgTb;//显示字符串
private BigDecimal airMothAvgTbZ;//数值
/*
重货总V值
*/
......
package cn.iocoder.yudao.module.delivery.listener;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.event.export.ReportCustomerAnalysisExcelExportEvent;
import cn.iocoder.yudao.framework.apollo.core.event.export.ReportSalesAnalysisExcelExportEvent;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
import cn.iocoder.yudao.module.delivery.convert.CustomerAnalysis;
import cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisExcelResp;
import cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisReq;
import cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisResp;
import cn.iocoder.yudao.module.delivery.service.CustomerAnalysisService;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.infra.service.file.FileService;
import cn.iocoder.yudao.module.system.framework.ue.UeProperties;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileInputStream;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import static cn.iocoder.yudao.framework.excel.constant.ExportConstant.DATA_FORMAT;
@Component("CustomerAnalysisExcelExportListener")
@AllArgsConstructor
@Slf4j
public class CustomerAnalysisExcelExportListener {
private UeProperties ueProperties;
private FileService fileService;
@Autowired
private CustomerAnalysisService customerAnalysisService;
/**
* 客户分析导出监听 lanbm 2024-05-01 add
*
* @param event 编号记录
*/
@EventListener(ReportCustomerAnalysisExcelExportEvent.class)
public void CustomerAnalysisExcelExportPushEvent(
ReportCustomerAnalysisExcelExportEvent event) {
if (StringUtils.isNotBlank(event.getRequestParams())) {
try {
System.out.println("开始数据导出");
DateTimeFormatter formatter =
DateTimeFormatter.ofPattern(DATA_FORMAT);
String nowTime = formatter.format(LocalDateTime.now());
String dir = ueProperties.getTempDir().
concat("/CustomerAnalysis/excel/");
File fileDir = new File(dir);
if (!fileDir.exists()) {
fileDir.mkdirs();
}
CustomerAnalysisReq query =
JSONObject.parseObject(event.getRequestParams(),
CustomerAnalysisReq.class);
String fileName =
event.getUserId().toString().
concat(StrUtil.DASHED).concat(
event.getUserType().toString()).
concat(StrUtil.DASHED).
concat(nowTime).
concat("客户分析报表.xlsx");
List<CustomerAnalysisResp> list =
customerAnalysisService.getList(query);
List<CustomerAnalysisExcelResp> listExel =
CustomerAnalysis.INSTANCE.convertList(list);
String path = ExcelUtils.write(dir, fileName,
"客户分析报表",
CustomerAnalysisExcelResp.class,
listExel);
// 获取到临时文件
File file = new File(path);
// 创建FileInputStream对象
FileInputStream fileInputStream = new FileInputStream(file);
// 读取文件内容
byte[] fileBytes = new byte[(int) file.length()];
fileInputStream.read(fileBytes);
// 关闭文件流
fileInputStream.close();
// 将文件上传到资源服务器
FileDO fileDO = fileService.createFile(dir, fileName, fileBytes);
event.setPath(fileDO.getPath());
event.setFileName(fileDO.getPath());
event.setUrl(fileDO.getUrl());
event.setFileId(fileDO.getId());
} catch (Exception e) {
e.printStackTrace();
event.setResult(e.getMessage());
}
} else {
event.setResult("param fail");
}
}
}
package cn.iocoder.yudao.module.delivery.listener;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.event.export.ReportSalesAnalysisExcelExportEvent;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
import cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisReq;
import cn.iocoder.yudao.module.delivery.entity.SalesAnalysisExcelResp;
import cn.iocoder.yudao.module.delivery.entity.SalesAnalysisReq;
import cn.iocoder.yudao.module.delivery.entity.SalesAnalysisResp;
import cn.iocoder.yudao.module.delivery.service.SalesAnalysisService;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.infra.service.file.FileService;
import cn.iocoder.yudao.module.system.framework.ue.UeProperties;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileInputStream;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import static cn.iocoder.yudao.framework.excel.constant.ExportConstant.DATA_FORMAT;
@Component("SalesAnalysisExcelExportListener")
@AllArgsConstructor
@Slf4j
public class SalesAnalysisExcelExportListener {
private UeProperties ueProperties;
private FileService fileService;
@Autowired
private SalesAnalysisService salesAnalysisService;
/**
* 销售分析导出监听 lanbm 2024-05-01 add
* 参考网址
*https://www.cnblogs.com/h-java/p/9951547.html
* @param event 编号记录
*/
@EventListener(ReportSalesAnalysisExcelExportEvent.class)
public void SalesAnalysisExcelExportPushEvent(
ReportSalesAnalysisExcelExportEvent event) {
if (StringUtils.isNotBlank(event.getRequestParams())) {
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATA_FORMAT);
String nowTime = formatter.format(LocalDateTime.now());
String dir = ueProperties.getTempDir().concat("/SalesAnalysis/excel/");
File fileDir = new File(dir);
if (!fileDir.exists()) {
fileDir.mkdirs();
}
String fileName =
event.getUserId().toString().
concat(StrUtil.DASHED).
concat(event.getUserType().toString()).
concat(StrUtil.DASHED).
concat(nowTime).
concat("销售分析数据.xlsx");
SalesAnalysisReq query =
JSONObject.parseObject(event.getRequestParams(),
SalesAnalysisReq.class);
List<SalesAnalysisExcelResp> list =
salesAnalysisService.getList(query);
String path = ExcelUtils.write(dir, fileName,
"销售分析数据", SalesAnalysisExcelResp.class, list);
// 获取到临时文件
File file = new File(path);
// 创建FileInputStream对象
FileInputStream fileInputStream = new FileInputStream(file);
// 读取文件内容
byte[] fileBytes = new byte[(int) file.length()];
fileInputStream.read(fileBytes);
// 关闭文件流
fileInputStream.close();
// 将文件上传到资源服务器
FileDO fileDO = fileService.createFile(dir, fileName, fileBytes);
event.setPath(fileDO.getPath());
event.setFileName(fileDO.getPath());
event.setUrl(fileDO.getUrl());
event.setFileId(fileDO.getId());
} catch (Exception e) {
e.printStackTrace();
event.setResult(e.getMessage());
}
} else {
event.setResult("param fail");
}
}
}
......@@ -33,6 +33,6 @@ public interface CustomerAnalysisMapper {
*/
Long GetCount(CustomerAnalysisReq req);
List<CustomerAnalysisExcelResp>getList(CustomerAnalysisReq req);
List<CustomerAnalysisResp>getList(CustomerAnalysisReq req);
}
......@@ -17,7 +17,17 @@ public interface CustomerAnalysisService {
throws JsonProcessingException;
List<CustomerAnalysisExcelResp>getList(CustomerAnalysisReq req);
List<CustomerAnalysisResp> getList(CustomerAnalysisReq req);
PageResult<CustomerAnalysisResp> GetDataResult(CustomerAnalysisReq query)
throws JsonProcessingException;
List<CustomerAnalysisResp> GetDataListResult(CustomerAnalysisReq query)
throws JsonProcessingException;
CustomerAnalysisReq getReq(CustomerAnalysisReq Req);
CustomerAnalysisReq getDataWhere(CustomerAnalysisReq query);
}
......@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.delivery.service.Impl;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
......@@ -13,6 +14,7 @@ import cn.iocoder.yudao.module.delivery.entity.CustomerReportReq;
import cn.iocoder.yudao.module.delivery.mapper.CustomerAnalysisMapper;
import cn.iocoder.yudao.module.delivery.service.CustomerAnalysisService;
import cn.iocoder.yudao.module.delivery.service.CustomerReportService;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -22,7 +24,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.*;
import java.util.stream.Collectors;
/*
......@@ -35,10 +42,13 @@ public class CustomerAnalysisImpl implements CustomerAnalysisService {
@Autowired
private CustomerAnalysisMapper customerAnalysisMapper;
@Autowired
private DictDataApi dictDataApi;
@Resource
private RedisHelper redisHelper;
public List<CustomerAnalysisExcelResp> getList(CustomerAnalysisReq req) {
public List<CustomerAnalysisResp> getList(CustomerAnalysisReq req) {
return customerAnalysisMapper.getList(req);
}
......@@ -98,6 +108,631 @@ public class CustomerAnalysisImpl implements CustomerAnalysisService {
}
/*
计算百分比
lanbm 2024-04-10 add
*/
private String getPercentage(BigDecimal part, BigDecimal total) {
BigDecimal percentage = part.divide(total, 5,
BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
// 输出百分比
String sR = format(percentage) + "%";
return sR;
}
/*
格式化BigDecimal为字符串,保留两位小数
lanbm 2024-04-10 add
*/
private String format(BigDecimal value) {
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(2);
numberFormat.setMaximumFractionDigits(2);
return numberFormat.format(value.doubleValue());
}
private String getCurDate() {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String currentDate = sdf.format(date);
return currentDate;
}
private int getCurYear() {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
return year;
}
/*
获取数据查询条件
*/
public CustomerAnalysisReq getDataWhere(CustomerAnalysisReq query) {
if (query.getSearchDataType1() != null &&
query.getSearchDataType2() != null &&
query.getSearchDataType3() != null) {
}
return query;
}
/*
对查询逻辑做处理 lanbm 2024-04-16 add
*/
public CustomerAnalysisReq getReq(CustomerAnalysisReq Req) {
//计算月份差
long lc = monthDiff(Req.getSdate(), Req.getEdate());
if (lc == 0) {
lc = 1;
}
Req.setNMonth(Integer.parseInt(String.valueOf(lc)));
int y = getCurYear();
if (Req.getSdate() == null) {
Req.setCurYear(String.valueOf(y));
Req.setSdate(String.valueOf(y) + "-01-01");
if (Req.getDuibiYear() == null) {
Req.setDuibiYear(String.valueOf(y - 1));
} else {
Req.setSduibidate(Req.getDuibiYear() + "-01-01");
}
} else {
//2024-03-01
String sT = Req.getSdate();
String s = sT.substring(4, 10);
if (Req.getDuibiYear() == null) {
int nTemp = Integer.parseInt(sT.substring(0, 4)) - 1;
Req.setSduibidate(String.valueOf(nTemp) + s);
} else {
Req.setSduibidate(Req.getDuibiYear() + s);
}
Req.setCurYear(sT.substring(0, 4));
}
if (Req.getEdate() == null) {
Req.setEdate(getCurDate());
String s = Req.getEdate().substring(5, 7);
int ld = getLastDay(Integer.parseInt(Req.getDuibiYear()), Integer.parseInt(s));
Req.setEduibidate(Req.getDuibiYear() + "-" + s + "-" + String.valueOf(ld));
} else {
String sE = Req.getEdate();
String sY = sE.substring(0, 4);
//int ld = getLastDay(Integer.parseInt(sY), Integer.parseInt(s));
//2024-03-01
String s1 = sE.substring(4, 10);
if (Req.getDuibiYear() == null) {
int nTemp = Integer.parseInt(sY) - 1;
Req.setEduibidate(String.valueOf(nTemp) + s1);
} else {
Req.setEduibidate(Req.getDuibiYear() + s1);
}
}
/*
if (Req.getSearchData3() != null) {
Req.setSearchData3(Req.getSearchData3().divide(new BigDecimal(100)));
}*/
return Req;
}
/*
获取某年某月的最后一天 lanbm 2024-04-16 add
*/
private int getLastDay(int year, int month) {
YearMonth yearMonth = YearMonth.of(year, month);
int lastDay = yearMonth.lengthOfMonth();
return lastDay;
}
public PageResult<CustomerAnalysisResp> GetDataResult(CustomerAnalysisReq query)
throws JsonProcessingException {
query = getReq(query);
query = getDataWhere(query);
System.out.println("处理后的查询条件:" + query);
//把model转 JSON字符串 lanbm
//String jsonStr = JsonUtils.toJsonString(query);
//JsonUtils.SaveLog(jsonStr);
List<DictDataRespDTO> dicCustomer_type =
dictDataApi.getDictDatas("customer_type");
Map<String, String> mapDic = new HashMap<>();
for (DictDataRespDTO d : dicCustomer_type
) {
mapDic.put(d.getValue(), d.getLabel());
}
PageResult<CustomerAnalysisResp> pageResult = getListPage(query);
String sTemp = "";
int nPm = query.getStart() + 1;
for (CustomerAnalysisResp r : pageResult.getList()) {
r.setPx(nPm);
nPm++;
//客户类型转换
String sType = r.getType();
if (sType == null) {
r.setCustomerrole("");
} else {
r.setCustomerrole(mapDic.get(sType));
}
if (r.getAllsumvolume() == null ||
r.getAllsumvolume().compareTo(BigDecimal.ZERO) == 0) {
r.setAllsumvolume(new BigDecimal(0));
//计算月均
r = calMonthAvg(query, r, true);
//计算总值
r = calAll(r, true);
//计算海运数据
r = cal1(query, r, true);
//计算空运数据
r = cal3(query, r, true);
//计算重货数据
r = calZH(r, true);
//计算泡货数据
r = calPH(r, true);
//计算控货数据
r = calKH(r, true);
} else {
//计算月均
r = calMonthAvg(query, r, false);
//计算总值
r = calAll(r, false);
//计算海运数据
r = cal1(query, r, false);
//计算空运数据
r = cal3(query, r, false);
//重货
r = calZH(r, false);
//计算泡货占比
r = calPH(r, false);
//计算控货占比
r = calKH(r, false);
}
r = calPick(r, false);
}
return pageResult;
}
public List<CustomerAnalysisResp> GetDataListResult(CustomerAnalysisReq query)
throws JsonProcessingException {
query = getReq(query);
query = getDataWhere(query);
System.out.println("处理后的查询条件:" + query);
//把model转 JSON字符串 lanbm
//String jsonStr = JsonUtils.toJsonString(query);
//JsonUtils.SaveLog(jsonStr);
List<DictDataRespDTO> dicCustomer_type =
dictDataApi.getDictDatas("customer_type");
Map<String, String> mapDic = new HashMap<>();
for (DictDataRespDTO d : dicCustomer_type
) {
mapDic.put(d.getValue(), d.getLabel());
}
List<CustomerAnalysisResp> list = getList(query);
String sTemp = "";
int nPm = query.getStart() + 1;
for (CustomerAnalysisResp r : list) {
r.setPx(nPm);
nPm++;
//客户类型转换
String sType = r.getType();
if (sType == null) {
r.setCustomerrole("");
} else {
r.setCustomerrole(mapDic.get(sType));
}
if (r.getAllsumvolume() == null ||
r.getAllsumvolume().compareTo(BigDecimal.ZERO) == 0) {
r.setAllsumvolume(new BigDecimal(0));
//计算月均
r = calMonthAvg(query, r, true);
//计算总值
r = calAll(r, true);
//计算海运数据
r = cal1(query, r, true);
//计算空运数据
r = cal3(query, r, true);
//计算重货数据
r = calZH(r, true);
//计算泡货数据
r = calPH(r, true);
//计算控货数据
r = calKH(r, true);
} else {
//计算月均
r = calMonthAvg(query, r, false);
//计算总值
r = calAll(r, false);
//计算海运数据
r = cal1(query, r, false);
//计算空运数据
r = cal3(query, r, false);
//重货
r = calZH(r, false);
//计算泡货占比
r = calPH(r, false);
//计算控货占比
r = calKH(r, false);
}
r = calPick(r, false);
}
return list;
}
private CustomerAnalysisResp calMonthAvg(CustomerAnalysisReq query,
CustomerAnalysisResp r, boolean bZzNull) {
String sTemp = "";
if (bZzNull == true) {
r.setAllsumvolume(new BigDecimal(0));
r.setMonthAvg("0");
} else {
r.setMonthAvg(r.getAllsumvolume().divide(
new BigDecimal(query.getNMonth()), 2,
BigDecimal.ROUND_HALF_UP).toString());
}
//计算同比
if (r.getAllsumvolumeTb() == null ||
r.getAllsumvolumeTb().compareTo(BigDecimal.ZERO) == 0) {
r.setMonthAvgTbShow("同期值为0");
} else {
sTemp = getPercentage(
(r.getAllsumvolume().subtract(r.getAllsumvolumeTb())),
r.getAllsumvolumeTb());
r.setMonthAvgTbShow(sTemp);
}
return r;
}
/*
总值计算
*/
private CustomerAnalysisResp calAll(CustomerAnalysisResp r, boolean bZzNull) {
String sTemp = "";
if (bZzNull == true) {
r.setAllsumvolume(new BigDecimal(0));
}
if (r.getAllsumvolumeTb() == null ||
r.getAllsumvolumeTb().compareTo(BigDecimal.ZERO) == 0) {
r.setAllsumvolumeTbShow("同期V值为0");
} else {
//(本期-同期)/同期
sTemp = getPercentage(
(r.getAllsumvolume().subtract(r.getAllsumvolumeTb())),
r.getAllsumvolumeTb());
r.setAllsumvolumeTbShow(sTemp);
}
return r;
}
/*
计算提货数据
*/
private CustomerAnalysisResp calPick(CustomerAnalysisResp r, boolean bZzNull) {
if (r.getChargequantity() == 0) {
r.setThL("总箱数为0");
} else {
r.setThL(getIntPercentage(r.getPickquantity(), r.getChargequantity()));
}
return r;
}
/*
处理海运数据
*/
private CustomerAnalysisResp cal1(CustomerAnalysisReq query,
CustomerAnalysisResp r, boolean bZzNull) {
String sTemp = "";
if (bZzNull == true) {
r.setAllsumvolume(new BigDecimal(0));
}
if (r.getSumvolume1() == null ||
r.getSumvolume1().compareTo(BigDecimal.ZERO) == 0) {
//海运V值
r.setSumvolumeV1(new BigDecimal(0));
//海运体积数
r.setSumvolume1(new BigDecimal(0));
r.setSeaMonthAvgZ(new BigDecimal(0));
if (bZzNull == true) {
r.setSeaZb("总值为0");
//海运月均
r.setSeaMonthAvg("总值为0");
} else {
//海运占比
r.setSeaZb("0");
//海运月均
r.setSeaMonthAvg("0");
}
} else {
//设置海运V值
r.setSumvolumeV1(r.getSumvolume1());
if (bZzNull == true) {
r.setSeaZb("总值为0");
} else {
r.setSeaZb(getPercentage(r.getSumvolumeV1(), r.getAllsumvolume()));
}
//月均V值 是体积
r.setSeaMonthAvgZ(r.getSumvolume1().divide(new BigDecimal(query.getNMonth()), 2,
BigDecimal.ROUND_HALF_UP));
r.setSeaMonthAvg(r.getSeaMonthAvgZ().toString());
}
if (r.getSumvolumeTb1() == null ||
r.getSumvolumeTb1().compareTo(BigDecimal.ZERO) == 0) {
r.setSumvolumeTbV1(new BigDecimal(0));
r.setSumvolumeTbShow1("同期为0");
r.setSeaMonthAvgTbZ(new BigDecimal(0));
} else {
r.setSumvolumeTbV1(new BigDecimal(1).multiply(r.getSumvolumeTb1()));
sTemp = getPercentage(
(r.getSumvolumeV1().subtract(r.getSumvolumeTbV1())),
r.getSumvolumeTbV1());
r.setSumvolumeTbShow1(sTemp);
r.setSeaMonthAvgTbZ(r.getSumvolumeTb1().divide(new BigDecimal(query.getNMonth()), 2,
BigDecimal.ROUND_HALF_UP));
}
//计算海运月均同比
if (r.getSeaMonthAvgTbZ() == null ||
r.getSeaMonthAvgTbZ().compareTo(BigDecimal.ZERO) == 0) {
r.setSeaMonthAvgTb("同期为0");
} else {
sTemp = getPercentage(
(r.getSeaMonthAvgZ().subtract(r.getSeaMonthAvgTbZ())),
r.getSeaMonthAvgTbZ());
r.setSeaMonthAvgTb(sTemp);
}
return r;
}
/*
处理空运数据
*/
private CustomerAnalysisResp cal3(CustomerAnalysisReq query,
CustomerAnalysisResp r, boolean bZzNull) {
String sTemp = "";
if (bZzNull == true) {
r.setAllsumvolume(new BigDecimal(0));
}
//当期值
if (r.getSumweightV3() == null ||
r.getSumweightV3().compareTo(BigDecimal.ZERO) == 0) {
r.setSumweightV3(new BigDecimal(0));
r.setSumweight3(new BigDecimal(0));
r.setAirMothAvgZ(new BigDecimal(0));
if (bZzNull == true) {
r.setAirZb("总值为0");
r.setAirMothAvg("总值为0");
} else {
r.setAirZb("0");
r.setAirMothAvg("0");
}
} else {
//SQL语句算出的是V值,要把V值转换位KG数
r.setSumweight3(r.getSumweightV3().multiply(new BigDecimal(100)));
if (bZzNull == true) {
r.setAirZb("总值为0");
} else {
//空运占比
r.setAirZb(getPercentage(r.getSumweightV3(), r.getAllsumvolume()));
}
//月均是 重量
r.setAirMothAvgZ(r.getSumweight3().divide(new BigDecimal(query.getNMonth()), 2,
BigDecimal.ROUND_HALF_UP));
r.setAirMothAvg(r.getAirMothAvgZ().toString());
}
//同期值
if (r.getSumweightTbV3() == null ||
r.getSumweightTbV3().compareTo(BigDecimal.ZERO) == 0) {
r.setSumweightTb3(new BigDecimal(0));
r.setSumweightTbV3(new BigDecimal(0));
r.setSumweightTbShow3("同期值为0");
r.setAirMothAvgTbZ(new BigDecimal(0));
} else {
//SQL语句算出的是V值,要把V值转换位KG数
r.setSumweightTb3(r.getSumweightTbV3().multiply(new BigDecimal(100)));
sTemp = getPercentage(
(r.getSumweightV3().subtract(r.getSumweightTbV3())),
r.getSumweightTbV3());
r.setSumweightTbShow3(sTemp);
r.setAirMothAvgTbZ(r.getSumweightTb3().divide(new BigDecimal(query.getNMonth()), 2,
BigDecimal.ROUND_HALF_UP));
}
//计算空运月均同比
if (r.getAirMothAvgTbZ() == null ||
r.getAirMothAvgTbZ().compareTo(BigDecimal.ZERO) == 0) {
r.setAirMothAvgTb("同期为0");
} else {
sTemp = getPercentage(
(r.getAirMothAvgZ().subtract(r.getAirMothAvgTbZ())),
r.getAirMothAvgTbZ());
r.setAirMothAvgTb(sTemp);
}
return r;
}
/*
计算重货数据
*/
private CustomerAnalysisResp calZH(CustomerAnalysisResp r, boolean bZzNull) {
if (bZzNull == true) {
//总值为0的情况
r.setAllsumvolume(new BigDecimal(0));
}
//重货 占比
if (r.getWeightSumV() == null ||
r.getWeightSumV().compareTo(BigDecimal.ZERO) == 0) {
r.setWeightSumV(new BigDecimal(0));
if (bZzNull == true) {
r.setWeithtSumZb("总值为0");
} else {
r.setWeithtSumZb("0");
}
} else {
r.setWeithtSumZb(getPercentage(r.getWeightSumV(), r.getAllsumvolume()));
}
return r;
}
/*
计算泡货数据
*/
private CustomerAnalysisResp calPH(CustomerAnalysisResp r, boolean bZzNull) {
if (bZzNull == true) {
//泡货 占比
r.setAllsumvolume(new BigDecimal(0));
}
if (r.getPhSumV() == null ||
r.getPhSumV().compareTo(BigDecimal.ZERO) == 0) {
r.setPhSumV(new BigDecimal(0));
if (bZzNull == true) {
r.setPhSumZb("总值为0");
} else {
r.setPhSumZb("0");
}
} else {
r.setPhSumZb(getPercentage(r.getPhSumV(), r.getAllsumvolume()));
}
return r;
}
/*
计算控货数据
*/
private CustomerAnalysisResp calKH(CustomerAnalysisResp r, boolean bZzNull) {
if (bZzNull == true) {
//控货 占比
r.setAllsumvolume(new BigDecimal(0));
}
if (r.getKhSumV() == null ||
r.getKhSumV().compareTo(BigDecimal.ZERO) == 0) {
r.setKhSumV(new BigDecimal(0));
if (bZzNull == true) {
r.setKhSumZb("总值为0");
} else {
r.setKhSumZb("0");
}
} else {
r.setKhSumZb(getPercentage(r.getKhSumV(),
r.getAllsumvolume()));
}
return r;
}
private String getIntPercentage(int number, int divisor) {
// 计算百分比
double percentage = number / (double) divisor;
// 格式化输出百分比
String formatted = String.format("%.2f%%", percentage);
return formatted;
}
private int monthDiff(String dateString1, String dateString2) {
// 将字符串转换为 LocalDate 对象
LocalDate date1 = LocalDate.parse(dateString1);
LocalDate date2 = LocalDate.parse(dateString2);
// 获软时间1的年份和月份
int year1 = date1.getYear();
int month1 = date1.getMonthValue();
// 获取时间2的年份和月份
int year2 = date2.getYear();
int month2 = date2.getMonthValue();
// 计算时间1的总月数
int totalMonths1 = year1 * 12 + month1;
// 计算时间2的总月数
int totalMonths2 = year2 * 12 + month2;
// 计算总月数差
int monthsDiff = totalMonths2 - totalMonths1;
return monthsDiff;
}
private List<CustomerAnalysisResp> GetPageResult2(
List<CustomerAnalysisResp> list, int pageNum, int pageSize) {
/*
// 正序
Collections.sort(list, (a, b) -> {
return a.排序字段 - b.排序字段;
});
// 倒序
Collections.sort(list, (a, b) -> {
return b.排序字段 - a.排序字段;
});*/
// 总数
int total = list.size();
// 分页数据
List<CustomerAnalysisResp> subList =
list.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
return subList;
}
/*
lanbm 2024-04-26 add
*/
......
package cn.iocoder.yudao.module.delivery.task;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/*
lanbm 2024-04-30 测试定时任务
*/
@Component
@TenantJob
@Slf4j
public class ReportTask implements JobHandler {
@Override
public String execute(String param) throws Exception {
int var1 = 30;
int var2 = 3;
int var3 = 6;
if (StringUtils.isNotBlank(param)){
String[] vars = param.split(StrUtil.COMMA);
if (vars.length > 0){
var1 = Integer.parseInt(vars[0]);
}
if (vars.length > 1){
var2 = Integer.parseInt(vars[1]);
}
if (vars.length > 2){
var3 = Integer.parseInt(vars[2]);
}
}
System.out.println("定时任务参数:" + param);
return "";
}
}
......@@ -16,15 +16,15 @@
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and business_time BETWEEN
'${sduibidate}' AND '${eduibidate}') as allsumvolumeTb,
<!--海运-->
(select round(sum(charge_volume),2) from view_order_businesstime where customer_id = c.id and transport_id=1 and
business_time BETWEEN '${sdate}' AND '${edate}') AS sumvolume1,
(select round(sum(charge_volume),2) from view_order_businesstime where customer_id = c.id and transport_id=1 and
business_time BETWEEN '${sduibidate}' AND '${eduibidate}') as sumvolumeTb1,
(select round(sum(charge_volume),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and transport_id=1) AS sumvolume1,
(select round(sum(charge_volume),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sduibidate}' AND '${eduibidate}' and transport_id=1) as sumvolumeTb1,
<!--空运-->
(select round(sum(charge_weight),2) from view_order_businesstime where customer_id = c.id and transport_id=3 and
business_time BETWEEN '${sdate}' AND '${edate}') AS sumweight3,
(select round(sum(charge_weight),2) from view_order_businesstime where customer_id = c.id and transport_id=3 and
business_time BETWEEN '${sduibidate}' AND '${eduibidate}') as sumweightTb3,
(select round(sum(charge_weight)/100,2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and transport_id=3) AS sumweightV3,
(select round(sum(charge_weight)/100,2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sduibidate}' AND '${eduibidate}' and transport_id=3) as sumweightTbV3,
'4' as monthAvg,
'5' as monthAvgTb,
'6' as seaMonthAvg,
......@@ -32,16 +32,16 @@
'8' as airMothAvg,
'9' as airMothAvgTb,
<!--重货 计算占比,不计算同步-->
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and order_type=2 and
business_time BETWEEN '${sdate}' AND '${edate}') as weightSumV,
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and order_type=2) as weightSumV,
<!--泡货 计算占比,不计算同步-->
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and order_type=3 and
business_time BETWEEN '${sdate}' AND '${edate}') as phSumV,
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and order_type=3) as phSumV,
<!--控货 计算占比,不计算同步-->
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and is_cargo_control=1 and
business_time BETWEEN '${sdate}' AND '${edate}') as khSumV,
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and is_cargo_control=1) as khSumV,
(CASE WHEN c.is_new = 1 THEN '是' ELSE '否' END) as isFirst,
(if(c.is_new = 1,c.update_time,''))as firstDate,
(if(c.is_new = 1,c.update_time,'')) as firstDate,
<!--提货率 已提货箱数除总入库总箱数-->
(select sum(charge_quantity) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}') as chargequantity,
......@@ -64,39 +64,73 @@
<sql id="WherePage2">
<where>
<if test="searchDataType4!=null and searchDataType4!=''">
<if test="sdate4!=null and sdate4!=''
and edate4!=null and edate4!=''">
<if test="sdate5!=null and sdate5!=''">
<!--首次成交时间-->
<if test="edate5!=null and edate5!=''">
and firstDate BETWEEN #{sdate5} AND #{edate5}
</if>
</if>
<if test="searchDataType1!=null and searchDataType1!=''">
<if test="searchData1!=null and searchData1!=''">
<!--总值查询-->
<choose>
<when test="searchDataType4 =='1'.toString()">
and firstDate BETWEEN #{sdate4} AND #{edate4}
<when test="searchDataType1 =='1'.toString()">
<!--大于等于的写法-->
and allsumvolume <![CDATA[ >= ]]> #{searchData1}
</when>
<when test="searchDataType1 =='2'.toString()">
and allsumvolume= #{searchData1}
</when>
<when test="searchDataType1 =='3'.toString()">
<!--小于等于的写法-->
and allsumvolume <![CDATA[ <= ]]> #{searchData1}
</when>
</choose>
</if>
</if>
<if test="searchDataType1!=null and searchDataType1!=''
and searchDataType2!=null and searchDataType2!=''
and searchDataType3!=null and searchDataType3!=''">
<choose>
<when test="searchDataType2 =='1'.toString()">
<!--大于等于的写法-->
and ${searchDataType1} <![CDATA[ >= ]]> #{searchDataType3}
</when>
<when test="searchDataType2 =='2'.toString()">
and ${searchDataType1} = #{searchDataType3}
</when>
<when test="searchDataType2 =='3'.toString()">
<!--小于等于的写法-->
and ${searchDataType1} <![CDATA[ <= ]]> #{searchDataType3}
</when>
</choose>
<if test="searchDataType2!=null and searchDataType2!=''">
<if test="searchData2!=null and searchData2!=''">
<!--海运拼柜-->
<choose>
<when test="searchDataType2 =='1'.toString()">
<!--大于等于的写法-->
and sumvolume1 <![CDATA[ >= ]]> #{searchData2}
</when>
<when test="searchDataType2 =='2'.toString()">
and sumvolume1 = #{searchData2}
</when>
<when test="searchDataType2 =='3'.toString()">
<!--小于等于的写法-->
and sumvolume1 <![CDATA[ <= ]]> #{searchData2}
</when>
</choose>
</if>
</if>
<if test="searchDataType3!=null and searchDataType3!=''">
<if test="searchData3!=null and searchData3!=''">
<!--专线空运-->
<choose>
<when test="searchDataType3 =='1'.toString()">
<!--大于等于的写法-->
and sumweightV3 <![CDATA[ >= ]]> #{searchData3}
</when>
<when test="searchDataType3 =='2'.toString()">
and sumweightV3 = #{searchData3}
</when>
<when test="searchDataType3 =='3'.toString()">
<!--小于等于的写法-->
and sumweightV3 <![CDATA[ <= ]]> #{searchData3}
</when>
</choose>
</if>
</if>
</where>
</sql>
<sql id="WherePage">
<where>
and c.deleted = 0
and c.deleted = 0 and c.STATUS=3
<if test="name!=null and name!=''">
<choose>
<when test="searchtype =='in'.toString()">
......@@ -118,8 +152,13 @@
</otherwise>
</choose>
</if>
<if test="isnew!=null and isnew!=''">
and is_new= #{isnew}
<if test="first!=null and first!=''">
<!--是否首次成交-->
and c.is_new= #{first}
</if>
<if test="cusYjType!=null and cusYjType!=''">
<!--业绩类型-->
and c.is_new= #{cusYjType}
</if>
<if test="source!=null and source!=''">
and source= #{source}
......@@ -138,14 +177,10 @@
<if test="deptid!=null and deptid!=''">
and u_d.dept_id= #{deptid}
</if>
<if test="searchDataType4!=null and searchDataType4!=''">
<if test="sdate4!=null and sdate4!=''
and edate4!=null and edate4!=''">
<choose>
<when test="searchDataType4 =='0'">
and c.create_time BETWEEN #{sdate4} AND #{edate4}
</when>
</choose>
<if test="sdate4!=null and sdate4!=''">
<!--客户创建时间-->
<if test="edate4!=null and edate4!=''">
and c.create_time BETWEEN #{sdate4} AND #{edate4}
</if>
</if>
</where>
......@@ -161,8 +196,13 @@
<include refid="WherePage"/>-->
WITH dataTJ as(
SELECT c.id,
(if(c.is_new = 1,c.update_time,'')) as firstDate,
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and business_time BETWEEN
'${sdate}' AND '${edate}') AS allsumvolume
'${sdate}' AND '${edate}') AS allsumvolume,
(select round(sum(charge_volume),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and transport_id=1) AS sumvolume1,
(select round(sum(charge_weight),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and transport_id=3) AS sumweightV3
from ecw_customer c left join (
SELECT d.NAME as deptName,u.dept_id,u.id as userid FROM
system_user u LEFT JOIN system_dept d ON u.dept_id = d.id
......@@ -176,8 +216,9 @@
<select id="getList"
parameterType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisReq"
resultType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisExcelResp">
WITH dataExcel as( SELECT number,name,c.id,(
resultType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisResp">
with dataTJ AS(
SELECT number,name,c.id,(
SELECT nickname from system_user where id=c.customer_service
) as salesman,c.customer_service as salesmanid,
(SELECT label from system_dict_data
......@@ -188,15 +229,15 @@
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and business_time BETWEEN
'${sduibidate}' AND '${eduibidate}') as allsumvolumeTb,
<!--海运-->
(select round(sum(charge_volume),2) from view_order_businesstime where customer_id = c.id and transport_id=1 and
business_time BETWEEN '${sdate}' AND '${edate}') AS sumvolume1,
(select round(sum(charge_volume),2) from view_order_businesstime where customer_id = c.id and transport_id=1 and
business_time BETWEEN '${sduibidate}' AND '${eduibidate}') as sumvolumeTb1,
(select round(sum(charge_volume),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and transport_id=1) AS sumvolume1,
(select round(sum(charge_volume),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sduibidate}' AND '${eduibidate}' and transport_id=1) as sumvolumeTb1,
<!--空运-->
(select round(sum(charge_weight),2) from view_order_businesstime where customer_id = c.id and transport_id=3 and
business_time BETWEEN '${sdate}' AND '${edate}') AS sumweight3,
(select round(sum(charge_weight),2) from view_order_businesstime where customer_id = c.id and transport_id=3 and
business_time BETWEEN '${sduibidate}' AND '${eduibidate}') as sumweightTb3,
(select round(sum(charge_weight)/100,2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and transport_id=3) AS sumweightV3,
(select round(sum(charge_weight)/100,2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sduibidate}' AND '${eduibidate}' and transport_id=3) as sumweightTbV3,
'4' as monthAvg,
'5' as monthAvgTb,
'6' as seaMonthAvg,
......@@ -204,16 +245,16 @@
'8' as airMothAvg,
'9' as airMothAvgTb,
<!--重货 计算占比,不计算同步-->
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and order_type=2 and
business_time BETWEEN '${sdate}' AND '${edate}') as weightSumV,
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and order_type=2) as weightSumV,
<!--泡货 计算占比,不计算同步-->
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and order_type=3 and
business_time BETWEEN '${sdate}' AND '${edate}') as phSumV,
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and order_type=3) as phSumV,
<!--控货 计算占比,不计算同步-->
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and is_cargo_control=1 and
business_time BETWEEN '${sdate}' AND '${edate}') as khSumV,
(select round(sum(vz),2) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}' and is_cargo_control=1) as khSumV,
(CASE WHEN c.is_new = 1 THEN '是' ELSE '否' END) as isFirst,
(if(c.is_new = 1,c.update_time,''))as firstDate,
(if(c.is_new = 1,c.update_time,'')) as firstDate,
<!--提货率 已提货箱数除总入库总箱数-->
(select sum(charge_quantity) from view_order_businesstime where customer_id = c.id and
business_time BETWEEN '${sdate}' AND '${edate}') as chargequantity,
......@@ -221,17 +262,16 @@
business_time BETWEEN '${sdate}' AND '${edate}') as pickquantity,
(CASE WHEN c.is_new = 1 THEN '新客户' ELSE '旧客户' END ) as cusYjType,
(SELECT name_zh from ecw_country where deleted=0 and id=c.country) as country,
c.type,
c.create_time as createtime
c.type, c.create_time as createtime
from ecw_customer c left join (
SELECT d.NAME as deptName,u.dept_id,u.id as userid FROM
system_user u LEFT JOIN system_dept d ON u.dept_id = d.id
) AS u_d ON c.customer_service = u_d.userid
<include refid="WherePage"/>)
select * from dataExcel
<include refid="WherePage"/>
)
select * from dataTJ
<include refid="WherePage2"/>
order by allsumvolume desc limit #{start},#{size}
order by allsumvolume desc,number desc
</select>
......
......@@ -164,6 +164,16 @@ public enum DownloadTypeEnum implements IntArrayValuable {
*/
ACHIEVEMENT_DETAIL_EXCEL_EXPORT(30),
/*
客户分析报表导出 lanbm 2024-05-01 add
*/
REPORT_CSSTOMER_ANALYSIS(31),
/*
销售分析报表导出 lanbm 2024-05-01 add
*/
REPORT_SALES_ANALYSIS(32),
// ....自己补充
;
......
......@@ -347,6 +347,14 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D
case ACHIEVEMENT_DETAIL_EXCEL_EXPORT:
achievementDetailExcelExportPushEvent(downloadLog);
break;
case REPORT_CSSTOMER_ANALYSIS:
//客户分析报表 lanbm 2024-05-01 add
REPORT_CSSTOMER_ANALYSIS_Event(downloadLog);
break;
case REPORT_SALES_ANALYSIS:
//销售分析报表 lanbm 2024-05-01 add
REPORT_SALES_ANALYSIS_Event(downloadLog);
break;
default:
downloadLog.setResult("unknown type");
break;
......@@ -801,4 +809,42 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D
downloadLog.setFileId(event.getFileId());
}
/*
lanbm 2024-05-01 add
客户分析
*/
private void REPORT_CSSTOMER_ANALYSIS_Event(DownloadLogDO downloadLog) {
ReportCustomerAnalysisExcelExportEvent event =
new ReportCustomerAnalysisExcelExportEvent();
event.setUserId(downloadLog.getUserId());
event.setUserType(downloadLog.getUserType());
event.setLang(downloadLog.getLang());
event.setRequestParams(downloadLog.getRequestParams());
applicationContext.publishEvent(event);
downloadLog.setFileName(event.getFileName());
downloadLog.setPath(event.getPath());
downloadLog.setDownloadUrl(event.getUrl());
downloadLog.setResult(event.getResult());
downloadLog.setFileId(event.getFileId());
}
/*
销售分析报表 lanbm 2024-05-01 add
*/
private void REPORT_SALES_ANALYSIS_Event(DownloadLogDO downloadLog) {
ReportSalesAnalysisExcelExportEvent event =
new ReportSalesAnalysisExcelExportEvent();
event.setUserId(downloadLog.getUserId());
event.setUserType(downloadLog.getUserType());
event.setLang(downloadLog.getLang());
event.setRequestParams(downloadLog.getRequestParams());
applicationContext.publishEvent(event);
downloadLog.setFileName(event.getFileName());
downloadLog.setPath(event.getPath());
downloadLog.setDownloadUrl(event.getUrl());
downloadLog.setResult(event.getResult());
downloadLog.setFileId(event.getFileId());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment