Commit dbac7e70 by 刘宇峰
2 parents ccd7ef5a d1683b69
......@@ -33,6 +33,11 @@
<artifactId>rest-admin-mybatis</artifactId>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-office</artifactId>
</dependency>
<!--kafka-->
<dependency>
<groupId>org.apache.kafka</groupId>
......@@ -78,27 +83,6 @@
<artifactId>rest-admin-swagger2</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.glsx.poi</groupId>
<artifactId>glsx-poi-jar</artifactId>
<version>2.0.0-SNAPSHOT</version>
<exclusions>
<!-- 拉取版本不对???-->
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
......
......@@ -21,12 +21,12 @@ public class WebConfig implements WebMvcConfigurer {
//1.加入的顺序就是拦截器执行的顺序,
//2.按顺序执行所有拦截器的preHandle
//3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle
registry.addInterceptor(authInterceptor).addPathPatterns("/**")
.excludePathPatterns("/")
.excludePathPatterns("swagger-ui.html")
.excludePathPatterns("/actuator/**")
.excludePathPatterns("/api/**")
.excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
// registry.addInterceptor(authInterceptor).addPathPatterns("/**")
// .excludePathPatterns("/")
// .excludePathPatterns("swagger-ui.html")
// .excludePathPatterns("/actuator/**")
// .excludePathPatterns("/api/**")
// .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
}
@Override
......
......@@ -3,27 +3,29 @@ 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.utils.FileIOUtil;
import com.alibaba.excel.EasyExcel;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 项目名:oms-tiger-shield
......@@ -31,63 +33,61 @@ import java.util.List;
* 作者: Yanglinlong
* 日期: 2021/5/6 10:46
*/
@Slf4j
@RestController
@RequestMapping(value = "/report/effectiveTestDriveReport")
@RequestMapping(value = "/effectiveTestDriveReport")
@Api(value = "试驾报表管理", tags = {"试驾报表管理"})
public class EffectiveTestDriveReportController {
protected final Logger logger = LoggerFactory.getLogger(EffectiveTestDriveReportController.class);
@Autowired
private EffectiveTestDriveReportService effectiveTestDriveReportService;
@GetMapping("/listEffectiveTestDriveReportPage")
@ResponseBody
public R listGqWindReportPage(EffectiveTestDriveDTO reportRequest, Page page) {
try {
PageHelper.startPage(page.getPageNum(), page.getPageSize(), true);
@Autowired
private HttpServletResponse response;
@GetMapping("/list")
@SysLog("查询试驾数据")
@ApiOperation(value = "试驾报表查询")
public R listGqWindReportPage(EffectiveTestDriveDTO reportRequest, PageInfo page) {
PageHelper.startPage(page.getPageNum(), page.getPageSize(), true);
// 优先查询试驾 d_electric_fence_drive 表获取分页页数
List<EffectiveTestDriveReportExcel> testDrivePageList = effectiveTestDriveReportService.getTestDrivePageList(reportRequest);
// 优先查询试驾 d_electric_fence_drive 表获取分页页数
List<EffectiveTestDriveReportExcel> testDrivePageList = effectiveTestDriveReportService.getTestDrivePageList(reportRequest);
// 获取报表详细数据
List<EffectiveTestDriveReportExcel> reportList = effectiveTestDriveReportService.listEffectiveTestDriveReportPage(reportRequest, testDrivePageList);
// 获取报表详细数据
List<EffectiveTestDriveReportExcel> reportList = effectiveTestDriveReportService.listEffectiveTestDriveReportPage(reportRequest, testDrivePageList);
if (CollectionUtils.isNotEmpty(reportList) && CollectionUtils.isNotEmpty(testDrivePageList)) {
long total = ((Page<EffectiveTestDriveReportExcel>) testDrivePageList).getTotal();
return R.ok();
}
return R.ok();
} catch (Exception e) {
e.printStackTrace();
return R.error(e.getMessage());
if (CollectionUtils.isNotEmpty(testDrivePageList) && CollectionUtils.isNotEmpty(reportList)) {
long total = ((Page<EffectiveTestDriveReportExcel>) testDrivePageList).getTotal();
Map data = new HashMap(3);
data.put("list", reportList);
data.put("totalPages", total);
data.put("totalElements", total);
return R.ok().data(data);
}
return R.error();
}
@RequestMapping(value = "/exportEffectiveTestDriveReport")
@GetMapping(value = "/exportReport")
@SysLog("导出试驾车辆数据")
public void exportGqWindReport(EffectiveTestDriveDTO reportRequest, HttpServletResponse response) {
try {
String fileName = "有效试驾次数统计(按日" + DateFormatUtils.format(new Date(), "yyyy-MM-dd") + ")表";
// 优先查询试驾 d_electric_fence_drive 表获取分页页数
List<EffectiveTestDriveReportExcel> testDrivePageList = effectiveTestDriveReportService.getTestDrivePageList(reportRequest);
// 封装数据
InputStream inputStream = effectiveTestDriveReportService.exportEffectiveTestDriveReport(reportRequest, testDrivePageList);
FileIOUtil.download(inputStream, FileIOUtil.MimeType.EXCEL2007, fileName, response);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("exportEffectiveTestDriveReport wrong message:" + e.getMessage());
} finally {
try {
IOUtils.closeQuietly(response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
return;
@ApiOperation(value = "试驾报表导出")
public void exportGqWindReport(EffectiveTestDriveDTO reportRequest) throws IOException {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
String fileName = "有效试驾次数统计(按日" + DateFormatUtils.format(new Date(), "yyyy-MM-dd") + ")表";
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
// 优先查询试驾 d_electric_fence_drive 表获取分页页数
List<EffectiveTestDriveReportExcel> testDrivePageList = effectiveTestDriveReportService.getTestDrivePageList(reportRequest);
// 封装数据
List<EffectiveTestDriveReportExcel> testDriveReportExcels = effectiveTestDriveReportService.exportEffectiveTestDriveReport(reportRequest, testDrivePageList);
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), EffectiveTestDriveReportExcel.class).sheet("有效试驾次数统计(按日)表").doWrite(testDriveReportExcels);
}
@GetMapping(value = "/getYearWithData")
@ResponseBody
@SysLog("获取下拉选接口")
@ApiOperation(value = "获取有试驾数据的年份")
public R getYearWithData() {
List<String> yearList = effectiveTestDriveReportService.getYearWithData();
return R.ok().data(yearList);
......
......@@ -26,7 +26,7 @@
</resultMap>
<select id="getTestDrivePageList"
parameterType="com.glsx.oms.basic.biz.businessmanage.reportmanager.model.request.EffectiveTestDriveRequestModel"
parameterType="cn.com.glsx.admin.modules.model.EffectiveTestDriveDTO"
resultMap="PageBaseMap">
SELECT
du.username shopCode,
......@@ -59,7 +59,7 @@
</select>
<select id="getEffectiveTestDriveData"
parameterType="com.glsx.oms.basic.biz.businessmanage.reportmanager.model.request.EffectiveTestDriveRequestModel"
parameterType="cn.com.glsx.admin.modules.model.EffectiveTestDriveDTO"
resultMap="BaseResultMap">
SELECT tall.shopCode, tall.shopName, tall.vehicleTypeName, tall.sn, tall.standno, left(tall.statDate,7)
statDate, tall.cnt, day(tall.statDate) dayCount , sum(cnt) cnttotal FROM
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!