Commit 2bb49cca by 刘宇峰

V1.3.0需求开发-试驾详情

1 parent b1787957
package cn.com.glsx.admin.modules.controller; package cn.com.glsx.admin.modules.controller;
import cn.com.glsx.admin.modules.model.TrialDriveReportDetailDTO;
import cn.com.glsx.admin.modules.model.export.ElectricFenceExport;
import cn.com.glsx.admin.modules.model.export.TrialDriveReportDetailExport;
import cn.com.glsx.admin.modules.model.export.TrialDriveReportExport; import cn.com.glsx.admin.modules.model.export.TrialDriveReportExport;
import cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch; import cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch;
import cn.com.glsx.admin.modules.service.TrialDriveReportService; import cn.com.glsx.admin.modules.service.TrialDriveReportService;
...@@ -7,6 +10,7 @@ import com.github.pagehelper.Page; ...@@ -7,6 +10,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.glsx.plat.common.annotation.SysLog; import com.glsx.plat.common.annotation.SysLog;
import com.glsx.plat.common.enums.OperateType; import com.glsx.plat.common.enums.OperateType;
import com.glsx.plat.common.utils.DateUtils;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import com.glsx.plat.office.excel.EasyExcelUtils; import com.glsx.plat.office.excel.EasyExcelUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -72,16 +76,20 @@ public class TrialDriveReportController { ...@@ -72,16 +76,20 @@ public class TrialDriveReportController {
return R.ok().data(yearList); return R.ok().data(yearList);
} }
@GetMapping("/details") @GetMapping("/detailsearch")
@SysLog(module = "有效试驾(日报)", value = "查询有效试驾(日报)", action = OperateType.QUERY, saveLog = false) @SysLog(module = "有效试驾(日报)-试驾详情", value = "查询有效试驾(日报)-试驾详情", action = OperateType.QUERY, saveLog = false)
@ApiOperation(value = "有效试驾(日报)") @ApiOperation(value = "有效试驾(日报)-试驾详情")
public R details(TrialDriveReportSearch search) { public R detailSearch(TrialDriveReportSearch search) {
Page<Object> page = PageHelper.startPage(search.getPageNumber(), search.getPageSize(), true); Page<TrialDriveReportDetailDTO> page = PageHelper.startPage(search.getPageNumber(), search.getPageSize(), true);
List<TrialDriveReportDetailDTO> list = trialDriveReportService.detailSearch(search);
// 优先查询试驾 d_electric_fence_drive 表获取分页页数 return R.ok().putPageData(list, page.getTotal());
List<TrialDriveReportExport> testDrivePageList = trialDriveReportService.search(search); }
return R.ok().putPageData(testDrivePageList, page.getTotal()); @ApiOperation(value = "有效试驾(日报)-试驾详情导出")
@GetMapping(value = "/detailExport")
public void export(HttpServletResponse response, TrialDriveReportSearch search) throws Exception {
List<TrialDriveReportDetailExport> list = trialDriveReportService.detailExport(search);
EasyExcelUtils.writeExcel(response, list, "试驾详情_" + DateUtils.formatSerial(new Date()), "Sheet1", ElectricFenceExport.class);
} }
} }
package cn.com.glsx.admin.modules.mapper; package cn.com.glsx.admin.modules.mapper;
import cn.com.glsx.admin.modules.entity.ElectricFenceDrive; import cn.com.glsx.admin.modules.entity.ElectricFenceDrive;
import cn.com.glsx.admin.modules.model.TrialDriveReportDetailDTO;
import cn.com.glsx.admin.modules.model.export.TrialDriveReportDetailExport;
import cn.com.glsx.admin.modules.model.export.TrialDriveReportExport; import cn.com.glsx.admin.modules.model.export.TrialDriveReportExport;
import cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch; import cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch;
import com.glsx.plat.common.annotation.DataPerm; import com.glsx.plat.common.annotation.DataPerm;
...@@ -21,4 +23,9 @@ public interface TrialDriveReportMapper extends CommonBaseMapper<ElectricFenceDr ...@@ -21,4 +23,9 @@ public interface TrialDriveReportMapper extends CommonBaseMapper<ElectricFenceDr
List<TrialDriveReportExport> getTestDriveData(TrialDriveReportSearch search); List<TrialDriveReportExport> getTestDriveData(TrialDriveReportSearch search);
List<String> getYearWithData(); List<String> getYearWithData();
List<TrialDriveReportDetailDTO> detailSearch(TrialDriveReportSearch search);
List<TrialDriveReportDetailExport> detailExport(TrialDriveReportSearch search);
} }
package cn.com.glsx.admin.modules.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class TrialDriveReportDetailDTO {
private Long vdId;
private String account;
private String username;
private String licensePlate;
private String vin;
private String sn;
private String seriesName;
private String typeName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date journeyBeginTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date journeyEndTime;
private Integer totalMileage;
private Integer percent;
private Boolean valid;
private String reason;
}
package cn.com.glsx.admin.modules.model.export;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class TrialDriveReportDetailExport {
@ExcelIgnore
private Long vdId;
@ExcelProperty(value = "特约店账号", index = 0)
private String account;
@ExcelProperty(value = "特约店名称", index = 1)
private String username;
@ExcelProperty(value = "车牌号", index = 2)
private String licensePlate;
@ExcelProperty(value = "车架号", index = 3)
private String vin;
@ExcelProperty(value = "设备号", index = 4)
private String sn;
@ExcelProperty(value = "车系", index = 5)
private String seriesName;
@ExcelProperty(value = "车型", index = 6)
private String typeName;
@ExcelProperty(value = "开始时间", index = 7)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date journeyBeginTime;
@ExcelProperty(value = "结束时间", index = 8)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date journeyEndTime;
@ExcelIgnore
private Integer totalMileage;
@ExcelIgnore
private Integer percent;
@ExcelProperty(value = "是否有效", index = 9)
private String valid;
@ExcelProperty(value = "无效原因", index = 10)
private String reason;
}
...@@ -30,7 +30,12 @@ public class TrialDriveReportSearch extends Page { ...@@ -30,7 +30,12 @@ public class TrialDriveReportSearch extends Page {
*/ */
private String keywords; private String keywords;
private String sn;
private String sDate; private String sDate;
private String eDate; private String eDate;
/**
* 是否有效试驾:1有效,2无效
*/
private Integer validDriveType;
} }
package cn.com.glsx.admin.modules.service; package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.modules.mapper.TrialDriveReportMapper; import cn.com.glsx.admin.modules.mapper.TrialDriveReportMapper;
import cn.com.glsx.admin.modules.model.TrialDriveReportDetailDTO;
import cn.com.glsx.admin.modules.model.export.TrialDriveReportDetailExport;
import cn.com.glsx.admin.modules.model.export.TrialDriveReportExport; import cn.com.glsx.admin.modules.model.export.TrialDriveReportExport;
import cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch; import cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch;
import cn.com.glsx.admin.modules.utils.DateUtil; import cn.com.glsx.admin.modules.utils.DateUtil;
...@@ -239,4 +241,35 @@ public class TrialDriveReportService { ...@@ -239,4 +241,35 @@ public class TrialDriveReportService {
private Integer replaceDayCount(Integer dayCount) { private Integer replaceDayCount(Integer dayCount) {
return dayCount == null ? 0 : dayCount; return dayCount == null ? 0 : dayCount;
} }
private String replaceStatDate(String statDate, String yearAndMonth) {
if (StringUtils.isNotEmpty(statDate)) {
return statDate;
}
if (StringUtils.isNotEmpty(yearAndMonth)) {
return yearAndMonth;
}
return DateUtil.getYearAndMonthYesterday();
}
public List<TrialDriveReportDetailDTO> detailSearch(TrialDriveReportSearch search) {
List<TrialDriveReportDetailDTO> list = trialDriveReportMapper.detailSearch(search);
list.forEach(tdrd -> {
boolean valid = tdrd.getPercent() >= 50;
tdrd.setValid(valid);
tdrd.setReason(valid ? "" : "试驾线路重合度低于标准值");
});
return list;
}
public List<TrialDriveReportDetailExport> detailExport(TrialDriveReportSearch search) {
List<TrialDriveReportDetailExport> list = trialDriveReportMapper.detailExport(search);
list.forEach(tdrd -> {
boolean valid = tdrd.getPercent() >= 50;
tdrd.setValid(valid ? "是" : "否");
tdrd.setReason(valid ? "" : "试驾线路重合度低于标准值");
});
return list;
}
} }
...@@ -80,5 +80,93 @@ ...@@ -80,5 +80,93 @@
select distinct left (journey_time, 4) select distinct left (journey_time, 4)
from t_electric_fence_drive from t_electric_fence_drive
</select> </select>
<select id="detailSearch" resultType="cn.com.glsx.admin.modules.model.TrialDriveReportDetailDTO">
select tefd.vd_id vdId,
tu.account,
tu.username,
tv.license_plate licensePlate,
tv.vin,
tefd.sn,
concat(tv.sub_brand_name, '/', tv.series_name, '/') seriesName,
tv.type_name typeName,
journey_time journeyBeginTime,
journey_end_time journeyEndTime,
total_mileage totalMileage,
percent
from t_electric_fence_drive tefd
left join t_vehicle_device tvd on tvd.id = tefd.vd_id
left join t_vehicle tv on tv.id = tvd.vehicle_id
left join t_user tu on tu.id = tv.created_by
where tv.del_flag = 0
and tvd.del_flag = 0
<if test="keywords != null and keywords!='' ">
and (
tu.account like '%${keywords}%'
or tu.username like '%${keywords}%'
or tv.vin like '%${keywords}%'
or tefd.sn like '%${keywords}%'
)
</if>
<choose>
<when test="validDriveType == 1">
and tefd.percent &gt;= 50
</when>
<when test="validDriveType == 2">
and tefd.percent &lt; 50
</when>
</choose>
<if test="vin != null and vin !=''">
and tv.vin = #{vin}
</if>
<if test="sDate != null and sDate != '' and eDate != null and eDate != ''">
and DATE_FORMAT(journey_time, '%Y-%m-%d') &gt;= #{sDate}
and DATE_FORMAT(journey_time, '%Y-%m-%d') &lt;= #{eDate}
</if>
</select>
<select id="detailExport" resultType="cn.com.glsx.admin.modules.model.export.TrialDriveReportDetailExport">
select tefd.vd_id vdId,
tu.account,
tu.username,
tv.license_plate licensePlate,
tv.vin,
tefd.sn,
concat(tv.sub_brand_name, '/', tv.series_name, '/') seriesName,
tv.type_name typeName,
journey_time journeyBeginTime,
journey_end_time journeyEndTime,
total_mileage totalMileage,
percent
from t_electric_fence_drive tefd
left join t_vehicle_device tvd on tvd.id = tefd.vd_id
left join t_vehicle tv on tv.id = tvd.vehicle_id
left join t_user tu on tu.id = tv.created_by
where tv.del_flag = 0
and tvd.del_flag = 0
<if test="keywords != null and keywords!='' ">
and (
tu.account like '%${keywords}%'
or tu.username like '%${keywords}%'
or tv.vin like '%${keywords}%'
or tefd.sn like '%${keywords}%'
)
</if>
<choose>
<when test="validDriveType == 1">
and tefd.percent &gt;= 50
</when>
<when test="validDriveType == 2">
and tefd.percent &lt; 50
</when>
</choose>
<if test="vin != null and vin !=''">
and tv.vin = #{vin}
</if>
<if test="sDate != null and sDate != '' and eDate != null and eDate != ''">
and DATE_FORMAT(journey_time, '%Y-%m-%d') &gt;= #{sDate}
and DATE_FORMAT(journey_time, '%Y-%m-%d') &lt;= #{eDate}
</if>
</select>
</mapper> </mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!