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