Commit 6fc4a7ce authored by liuzeheng's avatar liuzeheng

Merge remote-tracking branch 'origin/dev' into dev

parents 9f702dca 27accc20
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>
......@@ -189,8 +189,12 @@ public class CustomerReportControl {
List<String> l = new ArrayList<>();
int nT=1;
for (CustomerReportResp cr : lis) {
l.add(cr.getName());
//top 加客户编号,客户名称
l.add("Top "+String.valueOf(nT)+"_" +cr.getNumber()+"_"+cr.getName());
//l.add("Top "+String.valueOf(nT));
nT++;
cr.setDuibiYear(Req.getDuibiYear());
}
......
......@@ -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,14 +52,69 @@ public class SalesAnalysisControl {
@Autowired
private DictDataApi dictDataApi;
@Resource
private FileMakeApi fileMakeApi;
/*
根据原始信息计算逻辑展示信息 lanbm 2024-04-29 add
*/
private SalesAnalysisResp calBis(SalesAnalysisResp r) {
String sTemp = "";
//付款方
if (r.getDrawee().equals("1")) {
if (r.getCfResourceType().equals("1")) {
r.setShowResourceType("开发客户");
} else if (r.getCfResourceType().equals("2")) {
r.setShowResourceType("公司客户");
}
if (r.getCfYeJiType().equals("0")) {
r.setShowYeJiType("老客户");
} else if (r.getCfYeJiType().equals("1")) {
r.setShowYeJiType("新客户");
}
sTemp = "发货方";
} else if (r.getDrawee().equals("2")) {
if (r.getShResourceType().equals("1")) {
r.setShowResourceType("开发客户");
} else if (r.getShResourceType().equals("2")) {
r.setShowResourceType("公司客户");
}
if (r.getShYeJitype().equals("0")) {
r.setShowYeJiType("老客户");
} else if (r.getShYeJitype().equals("1")) {
r.setShowYeJiType("新客户");
}
sTemp = "收货方";
} else if (r.getDrawee().equals("3")) {
if (r.getCfResourceType().equals("1")) {
r.setShowResourceType("开发客户");
} else if (r.getCfResourceType().equals("2")) {
r.setShowResourceType("公司客户");
}
if (r.getCfYeJiType().equals("0")) {
r.setShowYeJiType("老客户");
} else if (r.getCfYeJiType().equals("1")) {
r.setShowYeJiType("新客户");
}
sTemp = "自定义";
}
r.setDraweeName(sTemp);
return r;
}
/*
客户分析列表 lanbm 2024-04-02 add
*/
@GetMapping("/getListPage")
public CommonResult<PageResult<SalesAnalysisResp>> getListPage(@Valid SalesAnalysisReq query) {
public CommonResult<PageResult<SalesAnalysisResp>>
getListPage(@Valid SalesAnalysisReq query) {
System.out.println("订单分析查询条件:" + query);
/*
SalesAnalysisReq query = JSON.parseObject(JSON.toJSONString(map),
SalesAnalysisReq.class);
......@@ -73,6 +134,7 @@ public class SalesAnalysisControl {
salesAnalysisService.getListPage(query);
int nPm = query.getStart() + 1;
String sTemp = "";
for (SalesAnalysisResp r : pageResult.getList()
) {
r.setPx(nPm);
......@@ -81,14 +143,27 @@ public class SalesAnalysisControl {
//订单状态
r.setStatusName(map_order_status.get(r.getStatus()));
if (r.getTransportId() == "1")
r.setTransportIdName("海运拼柜");
else if (r.getTransportId() == "3")
r.setTransportIdName("专线空运");
String sType = "";
if (r.getOrdertype() == 2) {
//是重货,非泡货
sType = "是/否";
} else if (r.getOrdertype() == 3) {
sType = "否/是";
} else if (r.getOrdertype() == 1) {
sType = "普货";
}
r.setOrdertypeShow(sType);
//业务数据逻辑运算
r = calBis(r);
if (r.getUseweightunit() == null) r.setUseweightunit("无");
if (r.getUsevolumeunit() == null) r.setUsevolumeunit("无");
r.setZpUnitShow(r.getUseweightunit() + "/" + r.getUsevolumeunit());
}
return success(pageResult);
}
......@@ -98,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);*/
}
}
package cn.iocoder.yudao.module.delivery.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.delivery.entity.SalesReportReq;
import cn.iocoder.yudao.module.delivery.entity.SalesReportResp;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.delivery.entity.*;
import cn.iocoder.yudao.module.delivery.entity.bar.CustomerReportBar;
import cn.iocoder.yudao.module.delivery.entity.bar.series;
import cn.iocoder.yudao.module.delivery.entity.bar.yAxis;
import cn.iocoder.yudao.module.delivery.service.SalesReportService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
......@@ -43,7 +47,7 @@ public class SalesReportControl {
*/
@PostMapping("/FirstCustomerCount")
public CommonResult<Integer> FirstCustomerCount(@RequestBody SalesReportReq Req) {
int nR=salesReportService.FirstCustomerCount(Req);
int nR = salesReportService.FirstCustomerCount(Req);
return success(nR);
}
......@@ -53,8 +57,8 @@ public class SalesReportControl {
*/
@PostMapping("/SalesReportCount")
public CommonResult<SalesReportResp> SalesReportCount(@RequestBody SalesReportReq Req) {
String s="";
SalesReportResp re=salesReportService.SalesReportCount(Req);
String s = "";
SalesReportResp re = salesReportService.SalesReportCount(Req);
return success(re);
}
......@@ -64,11 +68,87 @@ public class SalesReportControl {
*/
@PostMapping("/SalesReportList")
public CommonResult<Integer> SalesReportList(@RequestBody SalesReportReq Req) {
int nR=salesReportService.FirstCustomerCount(Req);
int nR = salesReportService.FirstCustomerCount(Req);
return success(nR);
}
/*
获取销售分析图表数据
*/
@GetMapping("/getEChartData")
public CommonResult<CustomerReportBar>
getEChartData(@Valid SalesAnalysisReq query) {
CustomerReportBar customerReportBar = new CustomerReportBar();
yAxis y = new yAxis();
y.setType("category");
y.setInverse(true);
List<String> l = new ArrayList<>();
l.add("1");
l.add("2");
l.add("3");
l.add("4");
l.add("5");
y.setData(l);
customerReportBar.setObjyAxis(y);
List<series> sl = new ArrayList<>();
//总V值
series s1 = new series();
s1.setName("2024");
s1.setType("bar");
s1.setBarGap("60%");
s1.setBarCategoryGap("60%");
List<String> s1L = new ArrayList<>();
s1L.add("12");
s1L.add("4");
s1L.add("7");
s1L.add("10");
s1L.add("20");
s1.setData(s1L);
sl.add(s1);
//海运
series s2 = new series();
s2.setName("2023");
s2.setType("bar");
s2.setBarGap("60%");
s2.setBarCategoryGap("60%");
List<String> s2L = new ArrayList<>();
s2L.add("10");
s2L.add("13");
s2L.add("6");
s2L.add("8");
s2L.add("9");
s2.setData(s2L);
sl.add(s2);
//空运
series s3 = new series();
s3.setName("2022");
s3.setType("bar");
s3.setBarGap("60%");
s3.setBarCategoryGap("60%");
List<String> s3L = new ArrayList<>();
s3L.add("10");
s3L.add("13");
s3L.add("19");
s3L.add("8");
s3L.add("19");
s3.setData(s3L);
sl.add(s3);
customerReportBar.setObSseries(sl);
// customerReportBar.setResultList(lis);
return success(customerReportBar);
}
}
......@@ -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值
*/
......
......@@ -13,7 +13,6 @@ import lombok.ToString;
@ToString(callSuper = true)
public class SalesAnalysisReq extends PageParam {
private int start;
private int size;
......@@ -23,6 +22,7 @@ public class SalesAnalysisReq extends PageParam {
*/
private int transportId;
/*
订单编号查询类型
*/
......@@ -33,11 +33,30 @@ public class SalesAnalysisReq extends PageParam {
private String orderNo;
/*
提单的查询类别
*/
private String SearchType2;
/*
提单编号
*/
private String tidanNo;
/*
发货人编号
*/
private String SearchType3;
private String fhNumber;
/*
收货人编号
*/
private String SearchType4;
private String shNumber;
/*
销售经理
*/
......@@ -53,8 +72,93 @@ public class SalesAnalysisReq extends PageParam {
*/
private String marks;
/*
订单状态
*/
private String status;
/*
始发仓
*/
private String startWarehouseId;
/*
目的国
*/
private String muDiGuo;
/*
目的城市
*/
private String muDiShi;
/*
目的仓
*/
private String dstwarehouseid;
/*
是否控货
*/
private int isCargoControl;
/*
渠道
*/
private String shippingChannelId;
/*
付款方
付款人:1 发货人 2 收货人 3 自定义
*/
private String drawee;
/*
重泡货类型
*/
private String zpType;
/*
资源类型
*/
private String ResourceType;
/*
业绩类型
*/
private String YeJiType;
/*
时间筛选类型
*/
private String dateSearch1;
/*
开始时间
*/
private String sdate1;
/*
结束时间
*/
private String edate2;
/*
数据类型筛选
*/
private String dataSearch1;
/*
比较符号设置
*/
private String dataSearch2;
/*
数据值
*/
private String dataSearch3;
}
......@@ -21,6 +21,10 @@ public class SalesAnalysisResp {
*/
private int px;
/*
订单ID
*/
private String orderId;
/*
订单编号
......@@ -53,6 +57,32 @@ public class SalesAnalysisResp {
*/
private String orderConsigneeCusId;
/*
发货人编号
*/
private String fhNumber;
private long cfCustomerId;
/*
收货人编号
*/
private String shNumber;
private long shCustomerId;
/*
资源类型 lanbm 2024-04-29 add
*/
private String cfResourceType;//发货人资源类型
private String shResourceType;//收货人资源类型
private String showResourceType;//显示资源类型,根据付款方来做逻辑判断
/*
业绩类型 新客户,老客户 lanbm 2024-04-29 add
*/
private String cfYeJiType;//收货人业绩类型
private String shYeJitype;//发货人业绩类型
private String showYeJiType;
/*
客户经理
*/
......@@ -79,10 +109,12 @@ public class SalesAnalysisResp {
/*
目的国
*/
private String muDiGuo;
/*
目的城市
*/
private String muDiShi;
/*
目的仓
......@@ -103,7 +135,16 @@ public class SalesAnalysisResp {
/*
入仓箱数
*/
private String sumquantity;
private int sumquantity;
/*
提货箱数
*/
private int picknum;
/*
根据入库箱数和提货箱数计算出的提货率
*/
private String showThl;
/*
入仓体积
......@@ -121,9 +162,49 @@ public class SalesAnalysisResp {
*/
private String iscargocontrol;
/*
订单类型:1 普货 2 重货 3 泡货
*/
private int ordertype;
private String ordertypeShow;
/*
创建时间
*/
private String createtime;
/*
业绩产生时间
*/
private String businesstime;
/*
付款方
付款人:1 发货人 2 收货人 3 自定义
*/
private String drawee;
/*
付款方显示字段
*/
private String draweeName;
/*
计算使用的重货标准基数
*/
private String useweightunit;
/*
计算使用的泡货标准基数
*/
private String usevolumeunit;
private String zpUnitShow;
/*
首次入仓时间
*/
private String firstInTime;
}
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);
}
......@@ -10,4 +10,6 @@ public interface SalesAnalysisService {
PageResult<SalesAnalysisResp> getListPage(SalesAnalysisReq page);
List<SalesAnalysisExcelResp> getList(SalesAnalysisReq req);
}
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 "";
}
}
......@@ -22,7 +22,7 @@
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"/>
ORDER BY allsumvolume desc
limit 0,30
limit 0,10
</select>
<sql id="WherePage">
<where>
......
......@@ -4,45 +4,172 @@
<select id="getListPage"
parameterType="cn.iocoder.yudao.module.delivery.entity.SalesAnalysisReq"
resultType="cn.iocoder.yudao.module.delivery.entity.SalesAnalysisResp">
select order_no as orderNo, tidan_no as tidanNo,
c.status,salesman_id as salesmanid,transport_id,marks,
w.start_warehouse_name as startwarehousename,
select c.order_id as orderId, order_no as orderNo, tidan_no as tidanNo,
c.status,salesman_id as salesmanid,
(SELECT nickname from system_user where id=c.salesman_id) as salesmanidName,
c.transport_id as transportId,c.drawee,
if(c.transport_id=1,'海运拼柜','专线空运') as transportIdName,
order_type as ordertype,use_weight_unit as useweightunit,
use_volume_unit as usevolumeunit,
c.marks,w.start_warehouse_name as startwarehousename,
w.dst_warehouse_name as dstwarehousename,w.muDiGuo,w.muDiShi,
c.channel_id as channelid,channel.name_zh as channelidName,
c.create_time as createtime,sum_quantity as sumquantity,
sum_volume as sumvolume,sum_weight as sumweight,
is_cargo_control as iscargocontrol
if(is_cargo_control=0,'否','是') as iscargocontrol,
( if( c.transport_id = 1 , c.load_time, c.rucang_time) ) AS businesstime,
cf.number as fhNumber,sh.number as shNumber,
cf.id as cfCustomerId,sh.id as shCustomerId,
cf.resource_type as cfresourceType,sh.resource_type as shResource_type,
cf.is_new as cfYeJiType,sh.is_new as shYeJitype,
(SELECT sum(ecw_order_pickup.pick_num) FROM ecw_order_pickup
WHERE ( ecw_order_pickup.order_id = c.order_no)) AS picknum,
(select in_time from ecw_order_warehouse_in where
order_id=c.order_id ORDER BY in_time asc LIMIT 1) as firstInTime
from ecw_order c
left join (SELECT ewl.id AS line_id,
ew_start.id AS start_warehouse_id,
ew_dest.id AS dst_warehouse_id,ew_start.title_zh AS start_title_zh,
ew_dest.title_zh AS dst_warehouse_name,
r_dest.title_zh as muDiGuo,r_sdest.title_zh as muDiShi,
r_dest.title_zh as muDiGuo, r_dest.id as muDiGuoID,
r_sdest.title_zh as muDiShi,r_sdest.id as muDiShiID,
ew_start.title_zh AS start_warehouse_name FROM ecw_warehouse_line ewl
LEFT JOIN ecw_warehouse ew_start ON
ewl.start_warehouse_id = ew_start.id
LEFT JOIN ecw_warehouse ew_start ON ewl.start_warehouse_id = ew_start.id
LEFT JOIN ecw_warehouse ew_dest ON ewl.dest_warehouse_id = ew_dest.id
left join ecw_region r_dest on ew_dest.guojia=r_dest.id
LEFT JOIN ecw_region r_sdest on ew_dest.shi=r_sdest.id
) w ON w.line_id = c.line_id
left join ecw_channel channel on channel.channel_id =c.channel_id
left join ecw_channel channel on channel.channel_id =c.channel_id and channel.deleted=0
<!--订单发货人信息-->
left join ecw_order_consignor nor on nor.order_id = c.order_id and nor.deleted=0
left join ecw_customer cf on cf.id=nor.customer_id and cf.deleted=0
<!--订单收货人信息-->
left join ecw_order_consignee nee on nee.order_id = c.order_id and nee.deleted=0
left join ecw_customer sh on sh.id=nee.customer_id and sh.deleted=0
<include refid="WherePage"/>
ORDER BY c.create_time desc limit #{start}, #{size}
ORDER BY c.create_time asc limit #{start}, #{size}
</select>
<sql id="WherePage">
<where>
and c.deleted = 0
<if test="orderNo!=null and orderNo!=''">
<!--订单编号-->
and c.order_no= #{orderNo}
</if>
<if test="tidanNo!=null and tidanNo!=''">
<!--提单编号-->
and c.tidan_no= #{tidanNo}
</if>
<if test="fhNumber!=null and fhNumber!=''">
<!--发货人编号-->
and cf.number= #{fhNumber}
</if>
<if test="shNumber!=null and shNumber!=''">
<!--收货人编号-->
and sh.number= #{shNumber}
</if>
<if test="marks!=null and marks!=''">
<!--唛头-->
and c.marks= #{marks}
</if>
<if test="salesmanId!=null and salesmanId!=''">
<!--客户经理-->
and c.salesman_id= #{salesmanId}
</if>
<if test="status!=null and status!=''">
<!--订单状态-->
and c.status= #{status}
</if>
<if test="transportId!=null and transportId!=''">
<!--运输方式查询条件-->
and c.transport_id= #{transportId}
</if>
<if test="orderNo!=null and orderNo!=''">
<!--订单编号-->
and c.order_no= #{orderNo}
<if test="startWarehouseId!=null and startWarehouseId!=''">
<!--始发仓-->
and w.start_warehouse_id= #{startWarehouseId}
</if>
<if test="muDiGuo!=null and muDiGuo!=''">
<!--目的国-->
and w.muDiGuoID= #{muDiGuo}
</if>
<if test="muDiShi!=null and muDiShi!=''">
<!--目的城市-->
and w.muDiShiID= #{muDiShi}
</if>
<if test="dstwarehouseid!=null and dstwarehouseid!=''">
<!--目的仓-->
and w.dst_warehouse_id= #{dstwarehouseid}
</if>
<if test="isCargoControl!=null and isCargoControl!=''">
<!--是否控货-->
and c.is_cargo_control= #{isCargoControl}
</if>
<if test="zpType!=null and zpType!=''">
<!--重泡货类型-->
and c.order_type= #{zpType}
</if>
<if test="drawee!=null and drawee!=''">
<!--付款方-->
and c.drawee= #{drawee}
</if>
<if test="shippingChannelId!=null and shippingChannelId!=''">
<!--渠道-->
and c.channel_id= #{shippingChannelId}
</if>
<if test="ResourceType!=null and ResourceType!=''">
<!--资源类型-->
and c.channel_id= #{ResourceType}
</if>
<if test="YeJiType!=null and YeJiType!=''">
<!--业绩类型-->
and c.channel_id= #{YeJiType}
</if>
<if test="dateSearch1!=null and dateSearch1!=''
and sdate1!=null and sdate1!=''
and edate2!=null and edate2!=''">
<!--订单创建时间-->
and c.create_time BETWEEN #{sdate1} AND #{edate2}
</if>
<if test="dataSearch3!=null and dataSearch3!=''">
<if test="dataSearch1!=null and dataSearch1!=''">
<if test="dataSearch2=null and dataSearch2!=''">
<!--数据筛选-->
<choose>
<when test="dataSearch1 =='1'.toString()">
<!--入仓箱数-->
</when>
<when test="dataSearch1 =='2'.toString()">
<!--入仓体积-->
</when>
<when test="dataSearch1 =='3'.toString()">
<!--入仓重量-->
</when>
<when test="dataSearch1 =='3'.toString()">
<!--重/泡标准-->
</when>
<when test="dataSearch1 =='3'.toString()">
<!--提货率-->
</when>
</choose>
</if>
</if>
</if>
</where>
</sql>
......
......@@ -445,6 +445,7 @@ public class MakeBillOfLadingServiceImpl extends AbstractService<MakeBillOfLadin
paramMap.put("seaFreight", item.getOneSeaFreight() + currencyMap.get(item.getSeaFreightCurrency()) + "/m³");
if (item.getOneClearanceFreight().compareTo(BigDecimal.ZERO) == 0) {
//paramMap.put("clearanceFreight", "");
//lanbm 2024-04-29 修改为0的显示
paramMap.put("clearanceFreight", "0" + currencyMap.get(item.getClearanceFreightCurrency()) + "/m³");
} else {
paramMap.put("clearanceFreight", item.getOneClearanceFreight() + currencyMap.get(item.getClearanceFreightCurrency()) + "/m³");
......
......@@ -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