Commit b76774c7 by 杨林龙

优化报表查询

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