Commit 9a53cf49 by 杨林龙

开发试驾数据 修改编码格式

1 parent 1b1a0670
...@@ -3,12 +3,12 @@ package cn.com.glsx.admin.modules.controller; ...@@ -3,12 +3,12 @@ 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 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.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 com.glsx.plat.office.excel.EasyExcelUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -20,8 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -20,8 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
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.net.URLEncoder;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -35,7 +33,7 @@ import java.util.Map; ...@@ -35,7 +33,7 @@ import java.util.Map;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping(value = "/effectiveTestDriveReport") @RequestMapping(value = "/effectivetestdrivereport")
@Api(value = "试驾报表管理", tags = {"试驾报表管理"}) @Api(value = "试驾报表管理", tags = {"试驾报表管理"})
public class EffectiveTestDriveReportController { public class EffectiveTestDriveReportController {
...@@ -68,24 +66,20 @@ public class EffectiveTestDriveReportController { ...@@ -68,24 +66,20 @@ public class EffectiveTestDriveReportController {
return R.error(); return R.error();
} }
@GetMapping(value = "/exportReport") @GetMapping(value = "/exportreport")
@SysLog("导出试驾车辆数据") @SysLog("导出试驾车辆数据")
@ApiOperation(value = "试驾报表导出") @ApiOperation(value = "试驾报表导出")
public void exportGqWindReport(EffectiveTestDriveDTO reportRequest) throws IOException { public void exportGqWindReport(EffectiveTestDriveDTO reportRequest) throws Exception {
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);
// 封装数据 // 封装数据
List<EffectiveTestDriveReportExcel> testDriveReportExcels = effectiveTestDriveReportService.exportEffectiveTestDriveReport(reportRequest, testDrivePageList); List<EffectiveTestDriveReportExcel> testDriveReportExcels = effectiveTestDriveReportService.exportEffectiveTestDriveReport(reportRequest, testDrivePageList);
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); // 调用公用方法导出 excel表格
EasyExcel.write(response.getOutputStream(), EffectiveTestDriveReportExcel.class).autoCloseStream(true).sheet("有效试驾次数统计(按日)表").doWrite(testDriveReportExcels); EasyExcelUtils.writeExcel((HttpServletResponse) response.getOutputStream(), testDriveReportExcels, fileName, "有效试驾次数统计(按日)表", EffectiveTestDriveReportExcel.class);
} }
@GetMapping(value = "/getYearWithData") @GetMapping(value = "/getyearwithdata")
@SysLog("获取下拉选接口") @SysLog("获取下拉选接口")
@ApiOperation(value = "获取有试驾数据的年份") @ApiOperation(value = "获取有试驾数据的年份")
public R getYearWithData() { public R getYearWithData() {
......
...@@ -29,33 +29,33 @@ ...@@ -29,33 +29,33 @@
parameterType="cn.com.glsx.admin.modules.model.EffectiveTestDriveDTO" parameterType="cn.com.glsx.admin.modules.model.EffectiveTestDriveDTO"
resultMap="PageBaseMap"> resultMap="PageBaseMap">
SELECT SELECT
du.username shopCode, tu.username shopCode,
du.userRemark shopName, tu.userRemark shopName,
defs.sn, tefs.sn,
defs.standno, tefs.standno,
dvts.vehicle_type_name vehicleTypeName tvts.vehicle_type_name vehicleTypeName
from d_electric_fence_sns defs from t_electric_fence_sns tefs
inner join d_electric_fence def on def.id = defs.fenceId inner join t_electric_fence tef on tef.id = tefs.fenceId
left join d_user du on du.d_LoginUserId = def.loginUserId left join t_user tu on tu.d_LoginUserId = tef.loginUserId
left join d_vehicle dv on dv.standno = defs.standno left join t_vehicle tv on tv.standno = tefs.standno
left join d_vehicle_type_standno dvts on dvts.standno = dv.standno left join t_vehicle_type_standno tvts on tvts.standno = tv.standno
left join d_class dc on dv.classId = dc.classid left join t_class tc on tv.classId = tc.classid
where defs.fenceId = def.id where tefs.fenceId = tef.id
and def.bizFenceType = 1 and tef.bizFenceType = 1
<if test="shopCode!=null and shopCode!=''"> <if test="shopCode!=null and shopCode!=''">
and du.username like '%${shopCode}%' and tu.username like '%${shopCode}%'
</if> </if>
<if test="shopName!=null and shopName!=''"> <if test="shopName!=null and shopName!=''">
and du.userRemark like '%${shopName}%' and tu.userRemark like '%${shopName}%'
</if> </if>
<if test="guangBenClassId != null and guangBenClassId != '' "> <if test="guangBenClassId != null and guangBenClassId != '' ">
and dc.vehicleGroupId = #{guangBenClassId,jdbcType=INTEGER} and tc.vehicleGroupId = #{guangBenClassId,jdbcType=INTEGER}
</if> </if>
and dvts.vehicle_type_name IN and tvts.vehicle_type_name IN
<foreach collection="splitList" item="vehicleTypeName" index="index" open="(" close=")" separator=","> <foreach collection="splitList" item="vehicleTypeName" index="index" open="(" close=")" separator=",">
#{vehicleTypeName} #{vehicleTypeName}
</foreach> </foreach>
order by def.id order by tef.id
</select> </select>
<select id="getEffectiveTestDriveData" <select id="getEffectiveTestDriveData"
...@@ -63,52 +63,52 @@ ...@@ -63,52 +63,52 @@
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
(select du.username shopCode, du.userRemark shopName, dvts.vehicle_type_name vehicleTypeName, (select tu.username shopCode, tu.userRemark shopName, tvts.vehicle_type_name vehicleTypeName,
defdd.sn, tefdd.sn,
dv.standno, DATE_FORMAT(defdd.journey_time,'%Y-%m-%d') statDate, sum(case when defdd.percent >= 80 then 1 else 0 tv.standno, DATE_FORMAT(tefdd.journey_time,'%Y-%m-%d') statDate, sum(case when tefdd.percent >= 80 then 1 else 0
end) cnt end) cnt
from d_electric_fence_drive defdd from t_electric_fence_drive defdd
left join d_electric_fence def on def.id = defdd.fence_id left join t_electric_fence def on tef.id = tefdd.fence_id
left join d_track_info dti on dti.sn = defdd.sn left join t_track_info dti on tti.sn = tefdd.sn
left join d_vehicle dv on dv.vehicleId = dti.vehicleId left join t_vehicle dv on tv.vehicleId = tti.vehicleId
left join d_vehicle_type_standno dvts on dvts.standno = dv.standno left join t_vehicle_type_standno tvts on tvts.standno = tv.standno
left join d_user du on du.d_LoginUserId = def.loginUserId left join t_user du on tu.d_LoginUserId = tef.loginUserId
<where> <where>
<choose> <choose>
<when test="year != null and year != '' and month != null and month != '' "> <when test="year != null and year != '' and month != null and month != '' ">
left(defdd.journey_time,7) = CONCAT(#{year,jdbcType=VARCHAR},'-',#{month,jdbcType=VARCHAR}) left(tefdd.journey_time,7) = CONCAT(#{year,jdbcType=VARCHAR},'-',#{month,jdbcType=VARCHAR})
</when> </when>
<otherwise> <otherwise>
<if test="year != null and year != '' "> <if test="year != null and year != '' ">
left(defdd.journey_time,4) = #{year,jdbcType=VARCHAR} left(tefdd.journey_time,4) = #{year,jdbcType=VARCHAR}
</if> </if>
<if test="month != null and month != '' "> <if test="month != null and month != '' ">
right(left(journey_time,7),2) = #{month,jdbcType=VARCHAR} right(left(tefdd.journey_time,7),2) = #{month,jdbcType=VARCHAR}
</if> </if>
</otherwise> </otherwise>
</choose> </choose>
<if test="shopCode !=null and shopCode != ''"> <if test="shopCode !=null and shopCode != ''">
and du.username like '%${shopCode}%' and tu.username like '%${shopCode}%'
</if> </if>
<if test="shopName !=null and shopName != ''"> <if test="shopName !=null and shopName != ''">
and du.userRemark like '%${shopName}%' and tu.userRemark like '%${shopName}%'
</if> </if>
<if test="sn !=null and sn != ''"> <if test="sn !=null and sn != ''">
and defdd.sn = #{sn,jdbcType=VARCHAR} and tefdd.sn = #{sn,jdbcType=VARCHAR}
</if> </if>
and dvts.vehicle_type_name IN and tvts.vehicle_type_name IN
<foreach collection="splitList" item="vehicleTypeName" index="index" open="(" close=")" separator=","> <foreach collection="splitList" item="vehicleTypeName" index="index" open="(" close=")" separator=",">
#{vehicleTypeName} #{vehicleTypeName}
</foreach> </foreach>
</where> </where>
GROUP BY defdd.sn,defdd.fence_id,statDate order by du.username) tall GROUP BY tall.shopCode, tall.sn, GROUP BY tefdd.sn,tefdd.fence_id,statDate order by tu.username) tall GROUP BY tall.shopCode, tall.sn,
tall.statDate ORDER BY tall.shopCode tall.statDate ORDER BY tall.shopCode
</select> </select>
<select id="getYearWithData" resultType="java.lang.String"> <select id="getYearWithData" resultType="java.lang.String">
select distinct left(journey_time,4) from d_electric_fence_drive select distinct left(journey_time,4) from t_electric_fence_drive
</select> </select>
</mapper> </mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!