Commit b55f6755 authored by lanbaoming's avatar lanbaoming

2024-04-27 更新报表功能

parent eeb94a6d
...@@ -28,5 +28,10 @@ ...@@ -28,5 +28,10 @@
<artifactId>yudao-module-system-api</artifactId> <artifactId>yudao-module-system-api</artifactId>
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-impl</artifactId>
<version>${revision}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; ...@@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.framework.redis.helper.RedisHelper; import cn.iocoder.yudao.framework.redis.helper.RedisHelper;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.delivery.convert.CustomerAnalysis;
import cn.iocoder.yudao.module.delivery.entity.*; import cn.iocoder.yudao.module.delivery.entity.*;
import cn.iocoder.yudao.module.delivery.entity.orderdata.view_order_businesstime; import cn.iocoder.yudao.module.delivery.entity.orderdata.view_order_businesstime;
import cn.iocoder.yudao.module.delivery.service.CustomerAnalysisService; import cn.iocoder.yudao.module.delivery.service.CustomerAnalysisService;
...@@ -197,7 +198,7 @@ public class CustomerAnalysisControl { ...@@ -197,7 +198,7 @@ public class CustomerAnalysisControl {
/* /*
客户分析列表 lanbm 2024-04-02 add 客户分析列表lanbm 2024-04-02 add
xml动态查询参考网址 xml动态查询参考网址
https://blog.csdn.net/CYK_byte/article/details/128611104 https://blog.csdn.net/CYK_byte/article/details/128611104
*/ */
...@@ -233,6 +234,14 @@ public class CustomerAnalysisControl { ...@@ -233,6 +234,14 @@ public class CustomerAnalysisControl {
query = getDataWhere(query); query = getDataWhere(query);
System.out.println("处理后的查询条件:" + query); System.out.println("处理后的查询条件:" + query);
PageResult<CustomerAnalysisResp> pageResult = GetDataResult(query);
return success(pageResult);
}
private PageResult<CustomerAnalysisResp> GetDataResult(CustomerAnalysisReq query)
throws JsonProcessingException {
//把model转 JSON字符串 lanbm //把model转 JSON字符串 lanbm
//String jsonStr = JsonUtils.toJsonString(query); //String jsonStr = JsonUtils.toJsonString(query);
//JsonUtils.SaveLog(jsonStr); //JsonUtils.SaveLog(jsonStr);
...@@ -249,7 +258,6 @@ public class CustomerAnalysisControl { ...@@ -249,7 +258,6 @@ public class CustomerAnalysisControl {
PageResult<CustomerAnalysisResp> pageResult = PageResult<CustomerAnalysisResp> pageResult =
customerAnalysisService.getListPage(query); customerAnalysisService.getListPage(query);
String sTemp = ""; String sTemp = "";
int nPm = query.getStart() + 1; int nPm = query.getStart() + 1;
for (CustomerAnalysisResp r : pageResult.getList()) { for (CustomerAnalysisResp r : pageResult.getList()) {
...@@ -287,7 +295,6 @@ public class CustomerAnalysisControl { ...@@ -287,7 +295,6 @@ public class CustomerAnalysisControl {
r = calKH(r, true); r = calKH(r, true);
} else { } else {
//计算月均 //计算月均
r = calMonthAvg(query, r, false); r = calMonthAvg(query, r, false);
//计算总值 //计算总值
...@@ -302,27 +309,10 @@ public class CustomerAnalysisControl { ...@@ -302,27 +309,10 @@ public class CustomerAnalysisControl {
r = calPH(r, false); r = calPH(r, false);
//计算控货占比 //计算控货占比
r = calKH(r, false); r = calKH(r, false);
} }
r = calPick(r, false); r = calPick(r, false);
} }
return success(pageResult); return pageResult;
/*
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
System.out.println("当前用户ID:" + loginUserId.toString());
System.out.println(map);
CustomerAnalysisReq Req = JSON.parseObject(JSON.toJSONString(map),
CustomerAnalysisReq.class);
System.out.println(Req);
*/
//客户来源
/*
List<DictDataRespDTO> dicCustomer_source =
dictDataApi.getDictDatas("customer_source");
*/
} }
...@@ -628,14 +618,18 @@ public class CustomerAnalysisControl { ...@@ -628,14 +618,18 @@ public class CustomerAnalysisControl {
@GetMapping("/exportExcel") @GetMapping("/exportExcel")
@ApiOperation("导出客户分析数据") @ApiOperation("导出客户分析数据")
@OperateLog(type = EXPORT) @OperateLog(type = EXPORT)
public void export(HttpServletResponse response, @Valid CustomerAnalysisReq Req) throws IOException { public void export(HttpServletResponse response, @Valid CustomerAnalysisReq query) throws IOException {
Req = getReq(Req); query = getReq(query);
Req = getDataWhere(Req); query = getDataWhere(query);
System.out.println("处理后的查询条件:" + Req); System.out.println("处理后的查询条件:" + query);
List<CustomerAnalysisExcelResp> list = customerAnalysisService.getList(Req);
PageResult<CustomerAnalysisResp> pageResult = GetDataResult(query);
List<CustomerAnalysisResp> list = pageResult.getList();
List<CustomerAnalysisExcelResp> listExel=
CustomerAnalysis.INSTANCE.convertList(list);
// 导出 Excel // 导出 Excel
ExcelUtils.write(response, "客户分析报表.xls", "数据", ExcelUtils.write(response, "客户分析报表.xls", "客户分析报表",
CustomerAnalysisExcelResp.class, list); CustomerAnalysisExcelResp.class, listExel);
} }
...@@ -703,15 +697,14 @@ public class CustomerAnalysisControl { ...@@ -703,15 +697,14 @@ public class CustomerAnalysisControl {
String json = objectMapper.writeValueAsString(objListResult); String json = objectMapper.writeValueAsString(objListResult);
redisHelper.set("CustomerAnalysisResp", json); redisHelper.set("CustomerAnalysisResp", json);
} else { } else {
if (objListResult == null) {
objListResult = JSON.parseArray(sList2, objListResult = JSON.parseArray(sList2,
CustomerAnalysisResp.class); CustomerAnalysisResp.class);
}
} }
if (query.getCountry() != null && query.getCountry().length() > 0) { if (query.getCountry() != null && query.getCountry().length() > 0) {
String cC = query.getCountry(); int cC = Integer.parseInt(query.getCountry());
objListResult= objListResult =
objListResult.stream().filter(c -> c.getCountryID() == cC).collect(Collectors.toList()); objListResult.stream().filter(c -> c.getCountryID() == cC).collect(Collectors.toList());
} }
...@@ -729,6 +722,18 @@ public class CustomerAnalysisControl { ...@@ -729,6 +722,18 @@ public class CustomerAnalysisControl {
r.setCustomerrole(mapDic.get(sType)); 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 || if (r.getAllsumvolume() == null ||
r.getAllsumvolume().compareTo(BigDecimal.ZERO) == 0) { r.getAllsumvolume().compareTo(BigDecimal.ZERO) == 0) {
......
...@@ -186,6 +186,7 @@ public class CustomerReportControl { ...@@ -186,6 +186,7 @@ public class CustomerReportControl {
yAxis y = new yAxis(); yAxis y = new yAxis();
y.setType("category"); y.setType("category");
y.setInverse(true); y.setInverse(true);
List<String> l = new ArrayList<>(); List<String> l = new ArrayList<>();
for (CustomerReportResp cr : lis) { for (CustomerReportResp cr : lis) {
...@@ -210,15 +211,17 @@ public class CustomerReportControl { ...@@ -210,15 +211,17 @@ public class CustomerReportControl {
if (cr.getSumvolume1() == null) cr.setSumvolume1(BigDecimal.valueOf(0)); if (cr.getSumvolume1() == null) cr.setSumvolume1(BigDecimal.valueOf(0));
if (cr.getSumweight3() == null) cr.setSumweight3(BigDecimal.valueOf(0)); if (cr.getSumweight3() == null) cr.setSumweight3(BigDecimal.valueOf(0));
cr.setAllsumvolume(cr.getSumvolume1().add(cr.getSumweight3())); //cr.setAllsumvolume(cr.getSumvolume1().add(cr.getSumweight3()));
if (cr.getAllsumvolume() == null) { if (cr.getAllsumvolume() == null) {
cr.setAllsumvolume(new BigDecimal(0));
s1L.add("0"); s1L.add("0");
} else { } else {
s1L.add(cr.getAllsumvolume().toString()); s1L.add(cr.getAllsumvolume().toString());
} }
if (cr.getAllsumvolumeTb() == null || cr.getAllsumvolumeTb().compareTo(BigDecimal.ZERO) == 0) { if (cr.getAllsumvolumeTb() == null ||
cr.getAllsumvolumeTb().compareTo(BigDecimal.ZERO) == 0) {
cr.setAllsumvolumeTbMsg("同期值为0"); cr.setAllsumvolumeTbMsg("同期值为0");
} }
else else
......
...@@ -176,7 +176,6 @@ public class EcwReportPermissionController { ...@@ -176,7 +176,6 @@ public class EcwReportPermissionController {
*/ */
@GetMapping @GetMapping
public CommonResult queryAll() { public CommonResult queryAll() {
return success(this.ecwReportPermissionService.list()); return success(this.ecwReportPermissionService.list());
} }
......
...@@ -46,7 +46,6 @@ public class EcwVzController { ...@@ -46,7 +46,6 @@ public class EcwVzController {
if (temp == null) { if (temp == null) {
return success(ecwVzService.create(ecwVz)); return success(ecwVzService.create(ecwVz));
} else { } else {
ecwVz.setId(temp.getId()); ecwVz.setId(temp.getId());
ecwVzService.update(ecwVz); ecwVzService.update(ecwVz);
return success(ecwVz.getId()); return success(ecwVz.getId());
......
package cn.iocoder.yudao.module.delivery.controller.admin; package cn.iocoder.yudao.module.delivery.controller.admin;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.delivery.entity.EcwVz; import cn.iocoder.yudao.module.delivery.entity.EcwVz;
import cn.iocoder.yudao.module.delivery.entity.EcwVzPageReq; import cn.iocoder.yudao.module.delivery.entity.EcwVzPageReq;
import cn.iocoder.yudao.module.delivery.entity.deptex.DeptEx; import cn.iocoder.yudao.module.delivery.entity.deptex.DeptEx;
import cn.iocoder.yudao.module.delivery.mapper.DeptExMapper; import cn.iocoder.yudao.module.delivery.mapper.DeptExMapper;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSimpleResp2VO;
import cn.iocoder.yudao.module.system.convert.user.UserConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -15,7 +23,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -15,7 +23,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
...@@ -29,9 +38,61 @@ public class SysDeptExtControl { ...@@ -29,9 +38,61 @@ public class SysDeptExtControl {
@Resource @Resource
private DeptExMapper deptExMapper; private DeptExMapper deptExMapper;
@Resource
private AdminUserService userService;
@Resource
private DeptService deptService;
@GetMapping("/getDeptChild") @GetMapping("/getDeptChild")
@Operation(summary = "根据父机部门获取子部门") @Operation(summary = "根据父机部门获取子部门")
public CommonResult<List<DeptEx>> getDeptChild(@Valid DeptEx Req) { public CommonResult<List<DeptEx>> getDeptChild(@Valid DeptEx Req) {
return success(deptExMapper.getDeptChild(Req)); return success(deptExMapper.getDeptChild(Req));
} }
@GetMapping("/listServiceUser")
@ApiOperation(value = "获取客服岗人员列表", notes = "只包含客服用户,主要用于前端的下拉选项")
public CommonResult<List<UserSimpleResp2VO>> listServiceUser(@Valid DeptEx Req) {
List<AdminUserDO> list =
userService.getUsersByPostIds(Arrays.asList(2L, 19L));
List<UserSimpleResp2VO> resultList =
UserConvert.INSTANCE.convertList05(list);
if (CollectionUtil.isNotEmpty(resultList)) {
List<Long> deptIds =
resultList.stream().map(t -> t.getDeptId()).
filter(Objects::nonNull).distinct().
collect(Collectors.toList());
Map<Long, DeptDO> deptMap = deptService.getDeptMap(deptIds);
if (CollectionUtil.isNotEmpty(deptMap)) {
for (UserSimpleResp2VO userSimpleResp2VO : resultList) {
if (userSimpleResp2VO.getDeptId() != null) {
DeptDO deptDO = deptMap.get(userSimpleResp2VO.getDeptId());
if (deptDO != null) {
userSimpleResp2VO.setDeptName(deptDO.getName());
}
}
}
}
}
List<DeptEx> listDept = deptExMapper.getDeptChild(Req);
List<Long> deptQuanX = new ArrayList<>();
for (DeptEx d : listDept
) {
deptQuanX.add(d.getId());
}
List<UserSimpleResp2VO> list2 = new ArrayList<>();
for (UserSimpleResp2VO u : resultList
) {
if (deptQuanX.contains(u.getDeptId())) {
list2.add(u);
}
}
// 排序后,返回给前端
return success(list2);
}
} }
package cn.iocoder.yudao.module.delivery.convert;
import cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisExcelResp;
import cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisResp;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;
import java.util.List;
/*
model类型转换 lanbm 2024-04-27 add
https://www.cnblogs.com/DDgougou/articles/13365277.html
*/
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface CustomerAnalysis {
/*****转换MapStruct*****/
CustomerAnalysis INSTANCE = Mappers.getMapper(CustomerAnalysis.class);
// @Mapping(target = "salesmanid", ignore = true)
// @Mapping(source = "salesmanid",target ="salesmanid",ignore = true)
CustomerAnalysisExcelResp convert(CustomerAnalysisResp bean);
List<CustomerAnalysisExcelResp> convertList(List<CustomerAnalysisResp> list);
}
...@@ -19,7 +19,6 @@ public class CustomerAnalysisExcelResp { ...@@ -19,7 +19,6 @@ public class CustomerAnalysisExcelResp {
*/ */
@ExcelProperty("客户编号") @ExcelProperty("客户编号")
private String number; private String number;
private String id;
/* /*
客户姓名 客户姓名
...@@ -30,35 +29,21 @@ public class CustomerAnalysisExcelResp { ...@@ -30,35 +29,21 @@ public class CustomerAnalysisExcelResp {
/* /*
客户经理姓名 客户经理姓名
*/ */
@ExcelProperty("客户经理姓名") @ExcelProperty("客户经理")
private String salesman; private String salesman;
/*
客户经理所在的部门
*/
private String deptid;
/* /*
部门名称 客户经理部门名称
*/ */
@ExcelProperty("客户经理部门") @ExcelProperty("部门")
private String deptname; private String deptname;
/*
客户经理ID
customer_service 客户表中的跟进客服
*/
private String salesmanid;
/* /*
总值,海运拼柜,专线空运 总值,海运拼柜,专线空运
*/ */
@ExcelProperty("总V值") @ExcelProperty("总V值")
private BigDecimal allsumvolume; private BigDecimal allsumvolume;
/*
总值同比
*/
private BigDecimal allsumvolumeTb;
/* /*
总V值同比显示信息 总V值同比显示信息
...@@ -69,120 +54,128 @@ public class CustomerAnalysisExcelResp { ...@@ -69,120 +54,128 @@ public class CustomerAnalysisExcelResp {
/* /*
海运拼柜 海运拼柜
*/ */
private BigDecimal sumvolume1; @ExcelProperty("海运拼柜")
private BigDecimal sumvolumeV1; private BigDecimal sumvolumeV1;
private BigDecimal sumvolumeTb1;
private BigDecimal sumvolumeTbV1;
/* /*
海运拼柜占比 海运占比
*/ */
@ExcelProperty("海运占比")
private String seaZb; private String seaZb;
/* /*
海运同比显示 海运同比显示
*/ */
@ExcelProperty("海运同比")
private String sumvolumeTbShow1; private String sumvolumeTbShow1;
/* /*
专线空运 专线空运V值
*/ */
private BigDecimal sumweight3; @ExcelProperty("专线空运")
private BigDecimal sumweightV3; private BigDecimal sumweightV3;
private BigDecimal sumweightTb3;
private BigDecimal sumweightTbV3;
/* /*
空运占比 空运占比
*/ */
@ExcelProperty("空运占比")
private String airZb; private String airZb;
/* /*
空运同显示 空运同显示
*/ */
@ExcelProperty("空运同比")
private String sumweightTbShow3; private String sumweightTbShow3;
/* /*
月均 月均
*/ */
@ExcelProperty("月均")
private String monthAvg; private String monthAvg;
private String monthAvgTb;
/* /*
月均同比 月均同比
*/ */
@ExcelProperty("月均同比")
private String monthAvgTbShow; private String monthAvgTbShow;
/* /*
海运月均方数 海运月均方数
*/ */
@ExcelProperty("海运月均方数")
private String seaMonthAvg; private String seaMonthAvg;
/* /*
海运月均方数同比 海运月均方数同比
*/ */
@ExcelProperty("海运月均同比")
private String seaMonthAvgTb; private String seaMonthAvgTb;
/* /*
空运月均重量 空运月均重量
*/ */
@ExcelProperty("空运月均重量")
private String airMothAvg; private String airMothAvg;
/* /*
空运月均同比 空运月均同比
*/ */
@ExcelProperty("空运月均同比")
private String airMothAvgTb; private String airMothAvgTb;
/* /*
重货总V值 重货总V值
*/ */
@ExcelProperty("重货总V值")
private BigDecimal weightSumV; private BigDecimal weightSumV;
/* /*
重货占比 重货占比
*/ */
@ExcelProperty("重货占比")
private String weithtSumZb; private String weithtSumZb;
/* /*
泡货总V值 泡货总V值
*/ */
@ExcelProperty("泡货总V值")
private BigDecimal phSumV; private BigDecimal phSumV;
/* /*
泡货占比 泡货占比
*/ */
@ExcelProperty("泡货占比")
private String phSumZb; private String phSumZb;
/* /*
控货总V值 控货总V值
*/ */
@ExcelProperty("控货总V值")
private BigDecimal khSumV; private BigDecimal khSumV;
/* /*
控货总占比 控货总占比
*/ */
@ExcelProperty("控货占比")
private String khSumZb; private String khSumZb;
/* /*
是否首次成交 是否首次成交
*/ */
@ExcelProperty("是否首次成交")
private String isFirst; private String isFirst;
/* /*
首次成交时间 首次成交时间
*/ */
@ExcelProperty("首次成交时间")
private String firstDate; private String firstDate;
/*
入库总箱数
*/
private int chargequantity;
/*
提货数
*/
private int pickquantity;
/* /*
提货率 提货率
*/ */
@ExcelProperty("提货率")
private String thL; private String thL;
/* /*
...@@ -192,11 +185,6 @@ public class CustomerAnalysisExcelResp { ...@@ -192,11 +185,6 @@ public class CustomerAnalysisExcelResp {
@ExcelProperty("客户业绩类型") @ExcelProperty("客户业绩类型")
private String cusYjType; private String cusYjType;
/*
客户来源
*/
private String source;
/* /*
客户来源名称 客户来源名称
*/ */
...@@ -210,17 +198,11 @@ public class CustomerAnalysisExcelResp { ...@@ -210,17 +198,11 @@ public class CustomerAnalysisExcelResp {
@ExcelProperty("客户国家") @ExcelProperty("客户国家")
private String country; private String country;
/* /*
客户角色 客户角色
*/ */
private String customerrole;
/*
对应数据字典中的客户类别 type
*/
@ExcelProperty("客户角色") @ExcelProperty("客户角色")
private String type; private String customerrole;
/* /*
客户创建日期 客户创建日期
...@@ -228,5 +210,4 @@ public class CustomerAnalysisExcelResp { ...@@ -228,5 +210,4 @@ public class CustomerAnalysisExcelResp {
@ExcelProperty("客户创建日期") @ExcelProperty("客户创建日期")
private String createtime; private String createtime;
} }
...@@ -209,7 +209,7 @@ public class CustomerAnalysisResp { ...@@ -209,7 +209,7 @@ public class CustomerAnalysisResp {
客户国家 客户国家
*/ */
private String country; private String country;
private String countryID; private int countryID;
/* /*
......
...@@ -22,4 +22,5 @@ public class yAxis { ...@@ -22,4 +22,5 @@ public class yAxis {
是否倒序 是否倒序
*/ */
private boolean inverse; private boolean inverse;
} }
...@@ -12,10 +12,10 @@ import lombok.NoArgsConstructor; ...@@ -12,10 +12,10 @@ import lombok.NoArgsConstructor;
public class DeptEx { public class DeptEx {
//部门扩展功能 model //部门扩展功能 model
private String id; private Long id;
private String name; private String name;
private String parentId; private Long parentId;
} }
...@@ -23,6 +23,11 @@ public interface CustomerAnalysisMapper { ...@@ -23,6 +23,11 @@ public interface CustomerAnalysisMapper {
List<CustomerAnalysisResp> getListPage(CustomerAnalysisReq req); List<CustomerAnalysisResp> getListPage(CustomerAnalysisReq req);
/*
lanbm 2024-04-26 add
*/
List<CustomerAnalysisResp> getListPage_New(CustomerAnalysisReq req);
/* /*
获取查询条件的总数 获取查询条件的总数
*/ */
......
...@@ -10,7 +10,12 @@ import java.util.List; ...@@ -10,7 +10,12 @@ import java.util.List;
public interface CustomerAnalysisService { public interface CustomerAnalysisService {
PageResult<CustomerAnalysisResp> getListPage(CustomerAnalysisReq req) throws JsonProcessingException; PageResult<CustomerAnalysisResp> getListPage(CustomerAnalysisReq req)
throws JsonProcessingException;
PageResult<CustomerAnalysisResp> getListPage_New(CustomerAnalysisReq req)
throws JsonProcessingException;
List<CustomerAnalysisExcelResp>getList(CustomerAnalysisReq req); List<CustomerAnalysisExcelResp>getList(CustomerAnalysisReq req);
......
...@@ -38,8 +38,7 @@ public class CustomerAnalysisImpl implements CustomerAnalysisService { ...@@ -38,8 +38,7 @@ public class CustomerAnalysisImpl implements CustomerAnalysisService {
@Resource @Resource
private RedisHelper redisHelper; private RedisHelper redisHelper;
public List<CustomerAnalysisExcelResp>getList(CustomerAnalysisReq req) public List<CustomerAnalysisExcelResp> getList(CustomerAnalysisReq req) {
{
return customerAnalysisMapper.getList(req); return customerAnalysisMapper.getList(req);
} }
...@@ -49,38 +48,35 @@ public class CustomerAnalysisImpl implements CustomerAnalysisService { ...@@ -49,38 +48,35 @@ public class CustomerAnalysisImpl implements CustomerAnalysisService {
IPage<CustomerAnalysisResp> mpPage = MyBatisUtils.buildPage(req); IPage<CustomerAnalysisResp> mpPage = MyBatisUtils.buildPage(req);
long total = customerAnalysisMapper.GetCount(req); long total = customerAnalysisMapper.GetCount(req);
System.out.println("符合条件的客户总数:"+String.valueOf(total)); System.out.println("符合条件的客户总数:" + String.valueOf(total));
int start = (req.getPageNo() - 1) * req.getPageSize(); int start = (req.getPageNo() - 1) * req.getPageSize();
int size = req.getPageSize(); int size = req.getPageSize();
req.setSize(size); req.setSize(size);
req.setStart(start); req.setStart(start);
/*
List<CustomerAnalysisResp> list=null; List<CustomerAnalysisResp> list = null;
String sList= redisHelper.get("CustomerAnalysisRespList"); String sList = redisHelper.get("CustomerAnalysisRespList");
if(sList==null||sList.length()==0) { if (sList == null || sList.length() == 0) {
list = customerAnalysisMapper.getListPage(req); list = customerAnalysisMapper.getListPage(req);
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
// 将List转换为JSON字符串 // 将List转换为JSON字符串
String json = objectMapper.writeValueAsString(list); String json = objectMapper.writeValueAsString(list);
redisHelper.set("CustomerAnalysisRespList", json); redisHelper.set("CustomerAnalysisRespList", json);
} else {
list = JSON.parseArray(sList, CustomerAnalysisResp.class);
} }
else { */
list= JSON.parseArray(sList,CustomerAnalysisResp.class); List<CustomerAnalysisResp> list = customerAnalysisMapper.getListPage(req);
}
list=GetPageResult(list,req.getPageNo(),req.getPageSize());
return new PageResult<>(list, total, mpPage.getSize(), return new PageResult<>(list, total, mpPage.getSize(),
req.getPageNo(), (total + mpPage.getSize() - 1) / mpPage.getSize()); req.getPageNo(), (total + mpPage.getSize() - 1) / mpPage.getSize());
} }
private List<CustomerAnalysisResp> GetPageResult( private List<CustomerAnalysisResp> GetPageResult(
List<CustomerAnalysisResp> list,int pageNum,int pageSize) List<CustomerAnalysisResp> list, int pageNum, int pageSize) {
{
/* /*
// 正序 // 正序
Collections.sort(list, (a, b) -> { Collections.sort(list, (a, b) -> {
...@@ -99,4 +95,20 @@ public class CustomerAnalysisImpl implements CustomerAnalysisService { ...@@ -99,4 +95,20 @@ public class CustomerAnalysisImpl implements CustomerAnalysisService {
return subList; return subList;
} }
/*
lanbm 2024-04-26 add
*/
public PageResult<CustomerAnalysisResp> getListPage_New(CustomerAnalysisReq req)
throws JsonProcessingException {
List<CustomerAnalysisResp> list = customerAnalysisMapper.getListPage_New(req);
long total=list.size();
list = GetPageResult(list, req.getPageNo(), req.getPageSize());
return new PageResult<>(list, total, req.getPageSize(),
req.getPageNo(),
(total + req.getPageSize() - 1) / req.getPageSize());
}
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<select id="getListPage" <select id="getListPage"
parameterType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisReq" parameterType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisReq"
resultType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisResp"> resultType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisResp">
WITH dataTJ as(
SELECT number,name,c.id,( SELECT number,name,c.id,(
SELECT nickname from system_user where id=c.customer_service SELECT nickname from system_user where id=c.customer_service
) as salesman,c.customer_service as salesmanid, ) as salesman,c.customer_service as salesmanid,
...@@ -48,15 +49,46 @@ ...@@ -48,15 +49,46 @@
business_time BETWEEN '${sdate}' AND '${edate}') as pickquantity, business_time BETWEEN '${sdate}' AND '${edate}') as pickquantity,
(CASE WHEN c.is_new = 1 THEN '新客户' ELSE '旧客户' END ) as cusYjType, (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, (SELECT name_zh from ecw_country where deleted=0 and id=c.country) as country,
c.type, c.type, c.create_time as createtime
c.create_time as createtime
from ecw_customer c left join ( from ecw_customer c left join (
SELECT d.NAME as deptName,u.dept_id,u.id as userid FROM 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 system_user u LEFT JOIN system_dept d ON u.dept_id = d.id
) AS u_d ON c.customer_service = u_d.userid ) AS u_d ON c.customer_service = u_d.userid
<include refid="WherePage"/> <include refid="WherePage"/>
<!-- ORDER BY allsumvolume desc limit #{start}, #{size}--> )
select * from dataTJ
<include refid="WherePage2"/>
order by allsumvolume desc,number desc
limit #{start},#{size}
</select> </select>
<sql id="WherePage2">
<where>
<if test="searchDataType4!=null and searchDataType4!=''">
<if test="sdate4!=null and sdate4!=''
and edate4!=null and edate4!=''">
<choose>
<when test="searchDataType4 =='1'.toString()">
and firstDate BETWEEN #{sdate4} AND #{edate4}
</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} >= #{searchDataType3}
</when>
<when test="searchDataType2 =='2'.toString()">
and ${searchDataType1} = #{searchDataType3}
</when>
</choose>
</if>
</where>
</sql>
<sql id="WherePage"> <sql id="WherePage">
<where> <where>
and c.deleted = 0 and c.deleted = 0
...@@ -105,33 +137,17 @@ ...@@ -105,33 +137,17 @@
<if test="sdate4!=null and sdate4!='' <if test="sdate4!=null and sdate4!=''
and edate4!=null and edate4!=''"> and edate4!=null and edate4!=''">
<choose> <choose>
<when test="searchDataType4 =='1'">
and firstDate BETWEEN #{sdate4} AND #{edate4}
</when>
<when test="searchDataType4 =='0'"> <when test="searchDataType4 =='0'">
and c.create_time BETWEEN #{sdate4} AND #{edate4} and c.create_time BETWEEN #{sdate4} AND #{edate4}
</when> </when>
</choose> </choose>
</if> </if>
</if> </if>
<!--2024-04-22
<if test="searchDataType1!=null and searchDataType1!=''
and searchDataType2!=null and searchDataType2!=''
and searchDataType3!=null and searchDataType3!=''">
<choose>
<when test="searchDataType2 =='1'.toString()">
and #{searchDataType1} >= #{searchDataType3}
</when>
<when test="searchDataType2 =='2'.toString()">
and #{searchDataType1} = #{searchDataType3}
</when>
</choose>
</if>-->
</where> </where>
</sql> </sql>
<select id="GetCount" resultType="java.lang.Long"> <select id="GetCount" resultType="java.lang.Long">
SELECT count(1) SELECT count(*)
from ecw_customer c left join ( from ecw_customer c left join (
SELECT d.NAME as deptName,u.dept_id,u.id as userid FROM 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 system_user u LEFT JOIN system_dept d ON u.dept_id = d.id
...@@ -142,7 +158,7 @@ ...@@ -142,7 +158,7 @@
<select id="getList" <select id="getList"
parameterType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisReq" parameterType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisReq"
resultType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisExcelResp"> resultType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisExcelResp">
SELECT number,name,c.id,( WITH dataExcel as( SELECT number,name,c.id,(
SELECT nickname from system_user where id=c.customer_service SELECT nickname from system_user where id=c.customer_service
) as salesman,c.customer_service as salesmanid, ) as salesman,c.customer_service as salesmanid,
(SELECT label from system_dict_data (SELECT label from system_dict_data
...@@ -192,8 +208,97 @@ ...@@ -192,8 +208,97 @@
SELECT d.NAME as deptName,u.dept_id,u.id as userid FROM 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 system_user u LEFT JOIN system_dept d ON u.dept_id = d.id
) AS u_d ON c.customer_service = u_d.userid ) AS u_d ON c.customer_service = u_d.userid
<include refid="WherePage"/> <include refid="WherePage"/>)
select * from dataExcel
<include refid="WherePage2"/>
order by allsumvolume desc limit #{start},#{size}
</select>
<select id="getListPage_New"
parameterType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisReq"
resultType="cn.iocoder.yudao.module.delivery.entity.CustomerAnalysisResp">
select a.*,
sum(voTb.vz) as allsumvolumeTb,
sum(if(voTb.transport_id = 1, voTb.charge_volume, 0)) as sumvolumeTb1,
sum(if(voTb.transport_id = 3, voTb.charge_weight, 0)) as sumweightTb3
from (
SELECT vc.number,
vc.name,
vc.id,
vc.salesman,
vc.salesmanid,
vc.is_in_open_sea,
vc.sourcename,
vc.source,
vc.deptid,
vc.deptname,
vc.isFirst,
vc.firstDate,
vc.cusYjType,
vc.country,
vc.countryID,
vc.type,
vc.createtime,
sum(vo.vz) as allsumvolume,
sum(if(vo.transport_id = 1, vo.charge_volume, 0)) as sumvolume1,
sum(if(vo.transport_id = 3, vo.charge_weight, 0)) as sumweight3,
sum(if(vo.order_type = 2, vo.vz, 0)) as weightSumV,
sum(if(vo.is_cargo_control = 1, vo.vz, 0)) as khSumV,
sum(if(vo.order_type = 3, vo.vz, 0)) as phSumV,
sum(vo.charge_quantity) as charge_quantity,
sum(vo.pick_num) as pick_num
from view_customer_businesstime vc
left join view_order_businesstime vo on vc.id = vo.customer_id
where vo.business_time BETWEEN '${sdate}' and '${edate}'
GROUP BY vc.id) as a
left join view_order_businesstime voTb on a.id = voTb.customer_id
and voTb.business_time BETWEEN '${sduibidate}' and '${eduibidate}'
<include refid="WherePage_new"/>
GROUP BY a.id
order by a.allsumvolume desc
</select> </select>
<sql id="WherePage_new">
<where>
<if test="isnew!=null and isnew!=''">
</if>
<if test="source!=null and source!=''">
and a.source= #{source}
</if>
<if test="customerrole!=null and customerrole!=''">
and a.type= #{customerrole}
</if>
<if test="country!=null and country!=''">
and a.countryID= #{country}
</if>
<if test="salesmanid!=null and salesmanid!=''">
<!--有具体的客户经理,就不算掉入公海池客户-->
and a.is_in_open_sea=0
and a.salesmanid= #{salesmanid}
</if>
<if test="deptid!=null and deptid!=''">
and a.deptid= #{deptid}
</if>
<if test="searchDataType4!=null and searchDataType4!=''">
<if test="sdate4!=null and sdate4!=''
and edate4!=null and edate4!=''">
<choose>
<when test="searchDataType4 =='1'">
and a.firstDate BETWEEN #{sdate4} AND #{edate4}
</when>
<when test="searchDataType4 =='0'">
and a.createtime BETWEEN #{sdate4} AND #{edate4}
</when>
</choose>
</if>
</if>
</where>
</sql>
</mapper> </mapper>
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
) AS u_d ON c.customer_service = u_d.userid ) AS u_d ON c.customer_service = u_d.userid
<include refid="WherePage"/> <include refid="WherePage"/>
</select> </select>
<sql id="WherePage"> <sql id="WherePage">
<where> <where>
and c.deleted = 0 and c.deleted = 0
......
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
(SELECT round(sum(vz),2) FROM view_order_businesstime WHERE customer_id = c.id AND business_time BETWEEN '${sDate}' AND '${eDate}') AS allsumvolume, (SELECT round(sum(vz),2) FROM view_order_businesstime WHERE customer_id = c.id AND business_time BETWEEN '${sDate}' AND '${eDate}') AS allsumvolume,
(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(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)/(SELECT vz FROM ecw_vz WHERE fuhao ='M3' LIMIT 1),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)/(SELECT vz FROM ecw_vz WHERE fuhao ='M3' LIMIT 1),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_weight),2)*100 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)/(SELECT vz FROM ecw_vz WHERE fuhao ='KG' LIMIT 1 ) 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)*100 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),2)/(SELECT vz FROM ecw_vz WHERE fuhao ='KG' LIMIT 1 ) FROM view_order_businesstime WHERE customer_id = c.id AND transport_id = 3 AND business_time BETWEEN '${sDuiBiDate}' AND '${eDuiBiDate}') as sumweightTb3
from ecw_customer c left join (SELECT d.NAME as deptName,u.dept_id,u.id as userid FROM 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 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"/> <include refid="WherePage"/>
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
<if test="salesmanid!=null and salesmanid!=''"> <if test="salesmanid!=null and salesmanid!=''">
and c.customer_service= #{salesmanid} and c.customer_service= #{salesmanid}
</if> </if>
<if test="deptid!=null and deptid!=''">
and u_d.dept_id= #{deptid}
</if>
</where> </where>
</sql> </sql>
<select id="GetCount" resultType="java.lang.Long"> <select id="GetCount" resultType="java.lang.Long">
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
T1.parent_id, T1.parent_id,
T1.sort T1.sort
FROM system_dept T1 FROM system_dept T1
WHERE T1.id = 123 WHERE T1.id = #{id}
UNION ALL UNION ALL
SELECT T2.id, SELECT T2.id,
T2.name, T2.name,
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
) )
SELECT T.id, SELECT T.id,
T.name, T.name,
T.parent_id T.parent_id as parentId
FROM system_dept T FROM recursion T
ORDER BY sort asc; ORDER BY T.id asc;
</select> </select>
......
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