Commit 26a30d20 by 刘宇峰

试驾报表

1 parent 7a938a17
......@@ -31,12 +31,14 @@ public class ElectricFenceController {
@Autowired
private ElectricFenceService electricFenceService;
@ApiOperation(value = "围栏列表查询")
@GetMapping("/search")
public R search(ElectricFenceSearch search) {
PageInfo<ElectricFenceDTO> pageInfo = electricFenceService.search(search);
return R.ok().putPageData(pageInfo);
}
@ApiOperation(value = "围栏列表导出")
@GetMapping(value = "/export")
public void export(HttpServletResponse response, ElectricFenceSearch search) throws Exception {
List<ElectricFenceExport> list = electricFenceService.export(search);
......
package cn.com.glsx.admin.modules.controller;
import cn.com.glsx.admin.modules.model.EffectiveTestDriveDTO;
import cn.com.glsx.admin.modules.model.excel.EffectiveTestDriveReportExcel;
import cn.com.glsx.admin.modules.service.EffectiveTestDriveReportService;
import cn.com.glsx.admin.modules.model.export.TrialDriveReportExport;
import cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch;
import cn.com.glsx.admin.modules.service.TrialDriveReportService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.annotation.SysLog;
import com.glsx.plat.core.web.R;
import com.glsx.plat.office.excel.EasyExcelUtils;
......@@ -33,30 +32,30 @@ import java.util.Map;
*/
@Slf4j
@RestController
@RequestMapping(value = "/effectivetestdrivereport")
@RequestMapping(value = "/trialdrivereport")
@Api(value = "试驾报表管理", tags = {"试驾报表管理"})
public class EffectiveTestDriveReportController {
public class TrialDriveReportController {
@Autowired
private EffectiveTestDriveReportService effectiveTestDriveReportService;
private TrialDriveReportService trialDriveReportService;
@Autowired
private HttpServletResponse response;
@GetMapping("/list")
@GetMapping("/search")
@SysLog("查询试驾数据")
@ApiOperation(value = "试驾报表查询")
public R listGqWindReportPage(EffectiveTestDriveDTO reportRequest, PageInfo page) {
PageHelper.startPage(page.getPageNum(), page.getPageSize(), true);
public R search(TrialDriveReportSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize(), true);
// 优先查询试驾 d_electric_fence_drive 表获取分页页数
List<EffectiveTestDriveReportExcel> testDrivePageList = effectiveTestDriveReportService.getTestDrivePageList(reportRequest);
List<TrialDriveReportExport> testDrivePageList = trialDriveReportService.search(search);
// 获取报表详细数据
List<EffectiveTestDriveReportExcel> reportList = effectiveTestDriveReportService.listEffectiveTestDriveReportPage(reportRequest, testDrivePageList);
List<TrialDriveReportExport> reportList = trialDriveReportService.listEffectiveTestDriveReportPage(search, testDrivePageList);
if (CollectionUtils.isNotEmpty(testDrivePageList) && CollectionUtils.isNotEmpty(reportList)) {
long total = ((Page<EffectiveTestDriveReportExcel>) testDrivePageList).getTotal();
long total = ((Page<TrialDriveReportExport>) testDrivePageList).getTotal();
Map data = new HashMap(3);
data.put("list", reportList);
data.put("totalPages", total);
......@@ -66,24 +65,24 @@ public class EffectiveTestDriveReportController {
return R.error();
}
@GetMapping(value = "/exportreport")
@GetMapping(value = "/export")
@SysLog("导出试驾车辆数据")
@ApiOperation(value = "试驾报表导出")
public void exportGqWindReport(EffectiveTestDriveDTO reportRequest) throws Exception {
public void exportGqWindReport(TrialDriveReportSearch search) throws Exception {
String fileName = "有效试驾次数统计(按日" + DateFormatUtils.format(new Date(), "yyyy-MM-dd") + ")表";
// 优先查询试驾 d_electric_fence_drive 表获取分页页数
List<EffectiveTestDriveReportExcel> testDrivePageList = effectiveTestDriveReportService.getTestDrivePageList(reportRequest);
List<TrialDriveReportExport> testDrivePageList = trialDriveReportService.search(search);
// 封装数据
List<EffectiveTestDriveReportExcel> testDriveReportExcels = effectiveTestDriveReportService.exportEffectiveTestDriveReport(reportRequest, testDrivePageList);
List<TrialDriveReportExport> testDriveReportExcels = trialDriveReportService.exportEffectiveTestDriveReport(search, testDrivePageList);
// 调用公用方法导出 excel表格
EasyExcelUtils.writeExcel((HttpServletResponse) response.getOutputStream(), testDriveReportExcels, fileName, "有效试驾次数统计(按日)表", EffectiveTestDriveReportExcel.class);
EasyExcelUtils.writeExcel((HttpServletResponse) response.getOutputStream(), testDriveReportExcels, fileName, "有效试驾次数统计(按日)表", TrialDriveReportExport.class);
}
@GetMapping(value = "/getyearwithdata")
@GetMapping(value = "/years")
@SysLog("获取下拉选接口")
@ApiOperation(value = "获取有试驾数据的年份")
public R getYearWithData() {
List<String> yearList = effectiveTestDriveReportService.getYearWithData();
List<String> yearList = trialDriveReportService.getYearWithData();
return R.ok().data(yearList);
}
}
......@@ -31,12 +31,14 @@ public class TrialDriveShopController {
@Autowired
private TrialDriveShopService trialDriveShopService;
@ApiOperation(value = "特约店列表查询")
@GetMapping("/search")
public R search(TrialDriveShopSearch search) {
PageInfo<TrialDriveShopDTO> pageInfo = trialDriveShopService.search(search);
return R.ok().putPageData(pageInfo);
}
@ApiOperation(value = "特约店列表导出")
@GetMapping(value = "/export")
public void export(HttpServletResponse response, TrialDriveShopSearch search) throws Exception {
List<TrialDriveShopExport> list = trialDriveShopService.export(search);
......
package cn.com.glsx.admin.modules.mapper;
import cn.com.glsx.admin.modules.entity.ElectricFenceDrive;
import cn.com.glsx.admin.modules.model.EffectiveTestDriveDTO;
import cn.com.glsx.admin.modules.model.excel.EffectiveTestDriveReportExcel;
import cn.com.glsx.admin.modules.model.export.TrialDriveReportExport;
import cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
......@@ -12,11 +12,11 @@ import java.util.List;
* 试驾数据Mapper层
*/
@Mapper
public interface EffectiveTestDriveReportMapper extends CommonBaseMapper<ElectricFenceDrive> {
public interface TrialDriveReportMapper extends CommonBaseMapper<ElectricFenceDrive> {
List<EffectiveTestDriveReportExcel> getTestDrivePageList(EffectiveTestDriveDTO reportRequest);
List<TrialDriveReportExport> getTestDrivePageList(TrialDriveReportSearch search);
List<EffectiveTestDriveReportExcel> getEffectiveTestDriveData(EffectiveTestDriveDTO reportRequest);
List<TrialDriveReportExport> getEffectiveTestDriveData(TrialDriveReportSearch search);
List<String> getYearWithData();
}
......@@ -15,11 +15,4 @@ public class ElectricFenceSnsDTO extends ElectricFenceSnsModel {
*/
private String lat;
/**
* 解析地址
*/
private String address;
private String gpsTime;
}
......@@ -23,4 +23,14 @@ public class ElectricFenceSnsModel {
*/
private String userTel;
/**
* gps上点时间
*/
private String gpsTime;
/**
* 解析位置
*/
private String address;
}
package cn.com.glsx.admin.modules.model.excel;
package cn.com.glsx.admin.modules.model.export;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
......@@ -10,7 +10,7 @@ import lombok.Data;
* @Date 2021/1/19
*/
@Data
public class EffectiveTestDriveReportExcel {
public class TrialDriveReportExport {
// 围栏Id
@ExcelIgnore
private Integer fenceId;
......
......@@ -19,9 +19,9 @@ public class ElectricFenceBO {
private Long id;
/**
* 栅栏名称
* 围栏名称
*/
@NotBlank(message = "栅栏名称不能为空")
@NotBlank(message = "围栏名称不能为空")
private String fenceName;
/**
* 围栏编号
......@@ -31,15 +31,12 @@ public class ElectricFenceBO {
* 业务围栏类型 0警情围栏,1试驾围栏
*/
private Integer bizFenceType;
/**
* 定位信息类型 1gps,2基站
*/
private Integer locationType;
/**
* 围栏形状类型 1.圆形(默认) 2.矩形 3.多边形 4.行政区域
*/
private Integer shapeType;
/**
* 半径(米)
*/
......
package cn.com.glsx.admin.modules.model.param;
import cn.hutool.db.Page;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
public class TrialDriveReportSearch extends Page {
/**
* 勾选的id
*/
private List<String> idList;
/**
* 限制展示的车辆
*/
private List<String> splitList;
/**
* 广本分组ID
*/
private Integer guangBenClassId;
/**
* sn 号
*/
private String sn;
/**
* 查询年份
*/
private String year;
/**
* 查询月份
*/
private String month;
/**
* 特约店代码
*/
private String shopCode;
/**
* 特约店名称
*/
private String shopName;
}
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.modules.mapper.EffectiveTestDriveReportMapper;
import cn.com.glsx.admin.modules.model.EffectiveTestDriveDTO;
import cn.com.glsx.admin.modules.model.excel.EffectiveTestDriveReportExcel;
import cn.com.glsx.admin.modules.mapper.TrialDriveReportMapper;
import cn.com.glsx.admin.modules.model.export.TrialDriveReportExport;
import cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch;
import cn.com.glsx.admin.modules.utils.DateUtil;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.context.utils.PropertiesUtils;
......@@ -11,7 +11,6 @@ import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.*;
/**
......@@ -21,76 +20,76 @@ import java.util.*;
*/
@Slf4j
@Service
public class EffectiveTestDriveReportService {
public class TrialDriveReportService {
@Autowired
private EffectiveTestDriveReportMapper effectiveTestDriveReportMapper;
private TrialDriveReportMapper trialDriveReportMapper;
public List<EffectiveTestDriveReportExcel> getTestDrivePageList(EffectiveTestDriveDTO reportRequest) {
public List<TrialDriveReportExport> search(TrialDriveReportSearch search) {
String needToShowVehicleTypeList = PropertiesUtils.getProperty("glsx.effectivetestdrive.needtoshow");
Integer guangBenClassId = Integer.parseInt(PropertiesUtils.getProperty("glsx.effectivetestdrive.guangBenClassId"));
String[] splitArr = needToShowVehicleTypeList.split(",");
List<String> splitList = Arrays.asList(splitArr);
reportRequest.setSplitList(splitList);
reportRequest.setGuangBenClassId(guangBenClassId);
return effectiveTestDriveReportMapper.getTestDrivePageList(reportRequest);
search.setSplitList(splitList);
search.setGuangBenClassId(guangBenClassId);
return trialDriveReportMapper.getTestDrivePageList(search);
}
public List<EffectiveTestDriveReportExcel> listEffectiveTestDriveReportPage(EffectiveTestDriveDTO reportRequest, List<EffectiveTestDriveReportExcel> testDrivePageList) {
String month = reportRequest.getMonth();
public List<TrialDriveReportExport> listEffectiveTestDriveReportPage(TrialDriveReportSearch search, List<TrialDriveReportExport> testDrivePageList) {
String month = search.getMonth();
if (StringUtils.isNotEmpty(month) && StringUtils.isNotBlank(month) && Integer.parseInt(month) < 10) {
month = ("0").concat(month);
reportRequest.setMonth(month);
search.setMonth(month);
}
HashMap<String, EffectiveTestDriveReportExcel> excelHashMap = new HashMap<>();
HashMap<String, TrialDriveReportExport> excelHashMap = new HashMap<>();
// 需要展示的车型
String needToShowVehicleTypeList = PropertiesUtils.getProperty("glsx.effectivetestdrive.needtoshow");
String[] splitArr = needToShowVehicleTypeList.split(",");
List<String> splitList = Arrays.asList(splitArr);
for (EffectiveTestDriveReportExcel testDrivePage : testDrivePageList) {
reportRequest.setSplitList(splitList);
reportRequest.setSn(testDrivePage.getSn());
List<EffectiveTestDriveReportExcel> testDriveDataOneList = effectiveTestDriveReportMapper.getEffectiveTestDriveData(reportRequest);
excelHashMap = makeDriveData(testDriveDataOneList, testDrivePageList, reportRequest.getYear(), reportRequest.getMonth());
for (TrialDriveReportExport testDrivePage : testDrivePageList) {
search.setSplitList(splitList);
search.setSn(testDrivePage.getSn());
List<TrialDriveReportExport> testDriveDataOneList = trialDriveReportMapper.getEffectiveTestDriveData(search);
excelHashMap = makeDriveData(testDriveDataOneList, testDrivePageList, search.getYear(), search.getMonth());
}
testDrivePageList = new ArrayList<>(excelHashMap.values());
// 将数据集合按照店代码排序
testDrivePageList.sort(new Comparator<EffectiveTestDriveReportExcel>() {
testDrivePageList.sort(new Comparator<TrialDriveReportExport>() {
@Override
public int compare(EffectiveTestDriveReportExcel o1, EffectiveTestDriveReportExcel o2) {
public int compare(TrialDriveReportExport o1, TrialDriveReportExport o2) {
return o1.getShopCode().compareToIgnoreCase(o2.getShopCode());
}
});
return testDrivePageList;
}
public List<EffectiveTestDriveReportExcel> exportEffectiveTestDriveReport(EffectiveTestDriveDTO reportRequest, List<EffectiveTestDriveReportExcel> testDrivePageList) throws IOException {
public List<TrialDriveReportExport> exportEffectiveTestDriveReport(TrialDriveReportSearch search, List<TrialDriveReportExport> testDrivePageList) {
//获取查询的月参数
String month = reportRequest.getMonth();
String month = search.getMonth();
if (StringUtils.isNotEmpty(month) && StringUtils.isNotBlank(month) && Integer.parseInt(month) < 10) {
month = ("0").concat(month);
reportRequest.setMonth(month);
search.setMonth(month);
}
HashMap<String, EffectiveTestDriveReportExcel> excelHashMap = new HashMap<>();
HashMap<String, TrialDriveReportExport> excelHashMap = new HashMap<>();
// 需要展示的车型
String needToShowVehicleTypeList = PropertiesUtils.getProperty("glsx.effectivetestdrive.needtoshow");
String[] splitArr = needToShowVehicleTypeList.split(",");
List<String> splitList = Arrays.asList(splitArr);
for (EffectiveTestDriveReportExcel testDrivePage : testDrivePageList) {
reportRequest.setSplitList(splitList);
reportRequest.setSn(testDrivePage.getSn());
List<EffectiveTestDriveReportExcel> testDriveDataOneList = effectiveTestDriveReportMapper.getEffectiveTestDriveData(reportRequest);
excelHashMap = makeDriveData(testDriveDataOneList, testDrivePageList, reportRequest.getYear(), reportRequest.getMonth());
for (TrialDriveReportExport testDrivePage : testDrivePageList) {
search.setSplitList(splitList);
search.setSn(testDrivePage.getSn());
List<TrialDriveReportExport> testDriveDataOneList = trialDriveReportMapper.getEffectiveTestDriveData(search);
excelHashMap = makeDriveData(testDriveDataOneList, testDrivePageList, search.getYear(), search.getMonth());
}
List<EffectiveTestDriveReportExcel> effectiveTestDriveList = new ArrayList<>(excelHashMap.values());
List<TrialDriveReportExport> effectiveTestDriveList = new ArrayList<>(excelHashMap.values());
if (CollectionUtils.isEmpty(effectiveTestDriveList)) {
return null;
}
// 将数据集合按照店代码排序
testDrivePageList.sort(new Comparator<EffectiveTestDriveReportExcel>() {
testDrivePageList.sort(new Comparator<TrialDriveReportExport>() {
@Override
public int compare(EffectiveTestDriveReportExcel o1, EffectiveTestDriveReportExcel o2) {
public int compare(TrialDriveReportExport o1, TrialDriveReportExport o2) {
return o1.getShopCode().compareToIgnoreCase(o2.getShopCode());
}
});
......@@ -100,7 +99,7 @@ public class EffectiveTestDriveReportService {
public List<String> getYearWithData() {
// 获取有数据的年份
return effectiveTestDriveReportMapper.getYearWithData();
return trialDriveReportMapper.getYearWithData();
}
/**
......@@ -112,7 +111,7 @@ public class EffectiveTestDriveReportService {
* @param month
* @return
*/
private HashMap<String, EffectiveTestDriveReportExcel> makeDriveData(List<EffectiveTestDriveReportExcel> testDriveDataOneList, List<EffectiveTestDriveReportExcel> testDrivePageList, String year, String month) {
private HashMap<String, TrialDriveReportExport> makeDriveData(List<TrialDriveReportExport> testDriveDataOneList, List<TrialDriveReportExport> testDrivePageList, String year, String month) {
//获取查询的年月参数
String yearAndMonth = null;
if (StringUtils.isNotEmpty(year) && StringUtils.isNotBlank(year) && StringUtils.isNotEmpty(month) && StringUtils.isNotBlank(month)) {
......@@ -127,18 +126,18 @@ public class EffectiveTestDriveReportService {
}
HashMap<String, EffectiveTestDriveReportExcel> excelHashMap = new HashMap<>();
HashMap<String, TrialDriveReportExport> excelHashMap = new HashMap<>();
HashMap<String, Integer> sumHashMap = new HashMap<>();
// 试驾表格需要展示的车辆类型
try {
// 初始化map中的每个对象
for (EffectiveTestDriveReportExcel drivePageExcel : testDrivePageList) {
for (TrialDriveReportExport drivePageExcel : testDrivePageList) {
excelHashMap.put(drivePageExcel.getShopCode() + drivePageExcel.getSn(), drivePageExcel);
sumHashMap.put(drivePageExcel.getShopCode() + drivePageExcel.getSn(), 0);
}
// 填充每一个有试驾车辆的数据
for (EffectiveTestDriveReportExcel driveDataOne : testDriveDataOneList) {
EffectiveTestDriveReportExcel driveReportData = new EffectiveTestDriveReportExcel();
for (TrialDriveReportExport driveDataOne : testDriveDataOneList) {
TrialDriveReportExport driveReportData = new TrialDriveReportExport();
int summation = 0;
switch (driveDataOne.getDayCount()) {
case 1:
......@@ -361,7 +360,7 @@ public class EffectiveTestDriveReportService {
default:
driveReportData.setDayNum1(0);
}
EffectiveTestDriveReportExcel testDriveReportExcel = excelHashMap.get(driveDataOne.getShopCode() + driveDataOne.getSn());
TrialDriveReportExport testDriveReportExcel = excelHashMap.get(driveDataOne.getShopCode() + driveDataOne.getSn());
// 设置总计数量
testDriveReportExcel.setSummation(sumHashMap.get(driveDataOne.getShopCode() + driveDataOne.getSn()));
// 填充行程时间
......@@ -371,7 +370,7 @@ public class EffectiveTestDriveReportService {
}
// 将没有数据的部分用 O 替代
for (EffectiveTestDriveReportExcel drivePageExcel : testDrivePageList) {
for (TrialDriveReportExport drivePageExcel : testDrivePageList) {
// 获取当天的最大天数
int maxDayNum = 31;
if (StringUtils.isNotEmpty(year) && StringUtils.isNotBlank(year) && StringUtils.isNotEmpty(month) && StringUtils.isNotBlank(month)) {
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.admin.modules.mapper.EffectiveTestDriveReportMapper">
<mapper namespace="TrialDriveReportMapper">
<resultMap id="BaseResultMap"
type="cn.com.glsx.admin.modules.model.excel.EffectiveTestDriveReportExcel">
type="cn.com.glsx.admin.modules.model.export.TrialDriveReportExport">
<result column="shopCode" jdbcType="VARCHAR" property="shopCode"/>
<result column="shopName" jdbcType="VARCHAR" property="shopName"/>
<result column="vehicleTypeName" jdbcType="VARCHAR" property="vehicleTypeName"/>
......@@ -15,7 +15,7 @@
</resultMap>
<resultMap id="PageBaseMap"
type="cn.com.glsx.admin.modules.model.excel.EffectiveTestDriveReportExcel">
type="cn.com.glsx.admin.modules.model.export.TrialDriveReportExport">
<result column="fenceId" jdbcType="INTEGER" property="fenceId"/>
<result column="electricFenceName" jdbcType="VARCHAR" property="electricFenceName"/>
<result column="shopCode" jdbcType="VARCHAR" property="shopCode"/>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!