Commit b76774c7 by 杨林龙

优化报表查询

1 parent 95067eeb
package cn.com.glsx.admin.modules.model.export;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
......@@ -10,6 +11,11 @@ import lombok.Data;
*/
@Data
public class ElectricInStoreExport {
/**
* 车辆Id
*/
@ExcelIgnore
private Long vehicleId;
@ExcelProperty(value = "特约店代码", index = 0)
private String shopCode;
......
......@@ -19,6 +19,10 @@ public class TrialDriveReportExport {
@ExcelIgnore
private Integer dayCount;
// 车辆Id
@ExcelIgnore
private Long vehicleId;
@ExcelProperty(value = "特约店代码", index = 0)
private String shopCode;
......
......@@ -26,7 +26,7 @@ public class ElectricInStoreSearch extends Page {
private String keywords;
/**
* 设备号
* 车辆id
*/
private String sn;
private Long vehicleId;
}
......@@ -29,20 +29,18 @@
<select id="getAllTestDrive" parameterType="cn.com.glsx.admin.modules.model.param.ElectricInStoreSearch"
resultType="cn.com.glsx.admin.modules.model.export.ElectricInStoreExport">
SELECT distinct
SELECT
tu.account shopCode,
tu.username shopName,
tefs.sn,
tefs.vin,
tv.vin,
tv.id as vehicleId,
tv.model_name modelName
from t_vehicle tv
inner join t_electric_fence_sns tefs on tv.vin = tefs.vin
inner join t_electric_fence tef on tef.id = tefs.fence_id
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_user tu on tu.id = tef.created_by
where tef.biz_fence_type = 12
and tu.del_flag = 0
and tvd.trial_type = 1
FROM t_vehicle tv
inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id
LEFT JOIN t_user tu ON tu.id = ttdv.created_by
WHERE tu.del_flag = 0
AND tv.del_flag = 0
AND ttdv.del_flag = 0
<if test="keywords != null and keywords!='' ">
and (
tu.account like '%${keywords}%'
......@@ -55,6 +53,7 @@
<select id="getInStoreDataListBySn" resultMap="BaseResultMap">
select teid.position_state , teid.gps_state , teid.gps_time , day(teid.gps_time) as dayOfMonth
from t_electric_instore_drive teid
left join t_vehicle_device tvd on tvd.sn = teid.sn
<where>
<choose>
<when test="year != null and year != '' and month != null and month != '' ">
......@@ -69,7 +68,10 @@
</if>
</otherwise>
</choose>
and teid.sn = #{sn}
and tvd.vehicle_id = #{vehicleId}
and tvd.bind_status = 1
and tvd.trial_type = 1
and tvd.del_flag = 0
</where>
</select>
</mapper>
......@@ -19,26 +19,25 @@
<result column="shopName" jdbcType="VARCHAR" property="shopName"/>
<result column="sn" jdbcType="VARCHAR" property="sn"/>
<result column="vin" jdbcType="VARCHAR" property="vin"/>
<result column="vehicleId" jdbcType="INTEGER" property="vehicleId"/>
<result column="vehicleTypeName" jdbcType="VARCHAR" property="vehicleTypeName"/>
</resultMap>
<select id="getTestDrivePageList"
parameterType="cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch"
resultMap="PageBaseMap">
SELECT distinct
SELECT
tu.account shopCode,
tu.username shopName,
tefs.sn,
tefs.vin,
tv.vin,
tv.id as vehicleId,
case when tv.type_id is null then tv.model_name else concat(tv.sub_brand_name, '/', series_name) end vehicleTypeName
from t_vehicle tv
inner join t_electric_fence_sns tefs on tv.vin = tefs.vin
inner join t_electric_fence tef on tef.id = tefs.fence_id
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_user tu on tu.id = tef.created_by
where tef.del_flag = 0
and tef.biz_fence_type = 12
and tvd.trial_type = 1
FROM t_vehicle tv
inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id
LEFT JOIN t_user tu ON tu.id = ttdv.created_by
WHERE tu.del_flag = 0
AND tv.del_flag = 0
AND ttdv.del_flag = 0
<if test="keywords != null and keywords!='' ">
and (
tu.account like '%${keywords}%'
......@@ -54,6 +53,7 @@
left(tsfd.drive_time,7) as statDate,
day(str_to_date(tsfd.drive_time, '%Y-%m-%d')) as dayCount
from t_statistics_fence_drive tsfd
left join t_vehicle_device tvd on tvd.sn = tsfd.sn
<where>
<choose>
<when test="year != null and year != '' and month != null and month != '' ">
......@@ -68,7 +68,10 @@
</if>
</otherwise>
</choose>
and tsfd.sn = #{sn}
and tvd.vehicle_id = #{vehicleId}
and tvd.bind_status = 1
and tvd.trial_type = 1
and tvd.del_flag = 0
</where>
</select>
......
......@@ -165,6 +165,7 @@
left join t_user tu on tv.created_by = tu.id and tu.del_flag = 0
left join t_trial_drive_shop ttds on tu.id = ttds.created_by and ttds.del_flag = 0
where tv.del_flag = 0
and ttdv.del_flag = 0
<include refid="search_sql_condition"/>
group by tv.id
order by tv.created_date desc
......@@ -182,10 +183,12 @@
tu.username shopName, tu.account shopCode,
group_concat(tvd.sn) sns
from t_vehicle tv
inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id
left join t_vehicle_device tvd on tv.id = tvd.vehicle_id and tvd.bind_status = 1 and tvd.del_flag = 0 and tvd.trial_type = 1
left join t_user tu on tv.created_by = tu.id and tu.del_flag = 0
left join t_trial_drive_shop ttds on tu.id = ttds.created_by and ttds.del_flag = 0
where tv.del_flag = 0
and ttdv.del_flag = 0
<include refid="search_sql_condition"/>
group by tv.id
order by tv.created_date desc
......
......@@ -102,7 +102,7 @@ public class ElectricInStoreDriveServiceTest {
// 如果sn不为null 则封装每天具体数据
if (electricInStoreExport.getSn() != null) {
search.setSn(electricInStoreExport.getSn());
search.setVehicleId(electricInStoreExport.getVehicleId());
List<ElectricInStoreDrive> inStoreDataList = inStoreDriveMapper.getInStoreDataListBySn(search);
Integer num1 = 0;
Integer num2 = 0;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!