Commit 9a53cf49 by 杨林龙

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

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