Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a7dd5071
authored
Aug 30, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化试驾数据查询
1 parent
0326e2b6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
111 deletions
src/main/java/cn/com/glsx/admin/modules/mapper/StatisticsDriveMapper.java
src/main/java/cn/com/glsx/admin/modules/mapper/TrialDriveReportMapper.java
src/main/java/cn/com/glsx/admin/modules/service/TrialDriveReportService.java
src/main/resources/mapper/StatisticsDriveMapper.xml
src/main/resources/mapper/TrialDriveReportMapper.xml
src/test/java/cn/com/glsx/admin/modules/service/TrialDriveReportServiceTest.java
src/main/java/cn/com/glsx/admin/modules/mapper/StatisticsDriveMapper.java
deleted
100644 → 0
View file @
0326e2b
package
cn
.
com
.
glsx
.
admin
.
modules
.
mapper
;
import
cn.com.glsx.admin.modules.entity.StatisticsDrive
;
import
cn.com.glsx.admin.modules.model.export.TrialDriveReportExport
;
import
cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
/**
* @Entity generator.domain.StatisticsFenceDrive
*/
@Mapper
public
interface
StatisticsDriveMapper
extends
CommonBaseMapper
<
StatisticsDrive
>
{
List
<
TrialDriveReportExport
>
getTestDriveData
(
TrialDriveReportSearch
search
);
}
src/main/java/cn/com/glsx/admin/modules/mapper/TrialDriveReportMapper.java
View file @
a7dd507
...
...
@@ -17,7 +17,7 @@ public interface TrialDriveReportMapper extends CommonBaseMapper<ElectricFenceDr
@DataPerm
(
showSql
=
true
)
List
<
TrialDriveReportExport
>
getTestDrivePageList
(
TrialDriveReportSearch
search
);
List
<
TrialDriveReportExport
>
get
Effective
TestDriveData
(
TrialDriveReportSearch
search
);
List
<
TrialDriveReportExport
>
getTestDriveData
(
TrialDriveReportSearch
search
);
List
<
String
>
getYearWithData
();
}
src/main/java/cn/com/glsx/admin/modules/service/TrialDriveReportService.java
View file @
a7dd507
package
cn
.
com
.
glsx
.
admin
.
modules
.
service
;
import
cn.com.glsx.admin.modules.mapper.StatisticsDriveMapper
;
import
cn.com.glsx.admin.modules.mapper.TrialDriveReportMapper
;
import
cn.com.glsx.admin.modules.model.export.TrialDriveReportExport
;
import
cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch
;
...
...
@@ -25,9 +24,6 @@ public class TrialDriveReportService {
@Autowired
private
TrialDriveReportMapper
trialDriveReportMapper
;
@Autowired
private
StatisticsDriveMapper
statisticsDriveMapper
;
public
List
<
TrialDriveReportExport
>
search
(
TrialDriveReportSearch
search
)
{
// 没有年月查询消息时 默认显示当前年月
if
(
StringUtils
.
isNullOrEmpty
(
search
.
getMonth
())
&&
StringUtils
.
isNullOrEmpty
(
search
.
getYear
()))
{
...
...
@@ -43,7 +39,7 @@ public class TrialDriveReportService {
for
(
TrialDriveReportExport
drivePageExcel
:
testDrivePageList
)
{
search
.
setSn
(
drivePageExcel
.
getSn
());
List
<
TrialDriveReportExport
>
testDriveDataOneList
=
statisticsDrive
Mapper
.
getTestDriveData
(
search
);
List
<
TrialDriveReportExport
>
testDriveDataOneList
=
trialDriveReport
Mapper
.
getTestDriveData
(
search
);
//将每一个查询的对象进行填充
makeDriveData
(
testDriveDataOneList
,
drivePageExcel
);
}
...
...
src/main/resources/mapper/StatisticsDriveMapper.xml
deleted
100644 → 0
View file @
0326e2b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.com.glsx.admin.modules.mapper.StatisticsDriveMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.admin.modules.entity.StatisticsDrive"
>
<id
property=
"id"
column=
"id"
jdbcType=
"INTEGER"
/>
<result
property=
"sn"
column=
"sn"
jdbcType=
"VARCHAR"
/>
<result
property=
"driveNum"
column=
"drive_num"
jdbcType=
"INTEGER"
/>
<result
property=
"driveTime"
column=
"drive_time"
jdbcType=
"VARCHAR"
/>
<result
property=
"createdTime"
column=
"created_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"updatedTime"
column=
"updated_time"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id,sn,drive_num,
drive_time,created_time,updated_time
</sql>
<select
id=
"getTestDriveData"
parameterType=
"cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch"
resultType=
"cn.com.glsx.admin.modules.model.export.TrialDriveReportExport"
>
select tsfd.drive_num as cnttotal,
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
<where>
<choose>
<when
test=
"year != null and year != '' and month != null and month != '' "
>
left(tsfd.drive_time,7) = CONCAT(#{year},'-',#{month})
</when>
<otherwise>
<if
test=
"year != null and year != '' "
>
left(tsfd.drive_time,4) = #{year}
</if>
<if
test=
"month != null and month != '' "
>
right(left(tsfd.drive_time,7),2) = #{month}
</if>
</otherwise>
</choose>
<if
test=
"sn != null and sn !=''"
>
and tsfd.sn = #{sn}
</if>
</where>
</select>
</mapper>
src/main/resources/mapper/TrialDriveReportMapper.xml
View file @
a7dd507
...
...
@@ -31,7 +31,8 @@
tu.username shopName,
tefs.sn,
tefs.vin,
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
inner join t_electric_fence_sns tefs on tv.vin = tefs.vin
inner join t_electric_fence tef on tef.id = tefs.fence_id
...
...
@@ -39,7 +40,7 @@
left join t_user tu on tu.id = tef.created_by
where tef.del_flag = 0
and tef.biz_fence_type = 12
and ttdv.del_flag =
0
and ttdv.del_flag = 0
<if
test=
"keywords != null and keywords!='' "
>
and (
tu.account like '%${keywords}%'
...
...
@@ -49,49 +50,31 @@
order by tu.account
</select>
<select
id=
"getEffectiveTestDriveData"
parameterType=
"cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch"
resultMap=
"BaseResultMap"
>
SELECT tall.shopCode, tall.shopName, tall.vehicleTypeName, tall.sn, tall.vin, left(tall.statDate,7)
statDate, tall.cnt, day(tall.statDate) dayCount , sum(cnt) cnttotal FROM (select tu.account shopCode,
tu.username shopName,
case when tv.type_id is null then tv.model_name else concat(tv.sub_brand_name, '/', series_name) end vehicleTypeName,
tefdd.sn,
tv.vin,
DATE_FORMAT(tefdd.journey_time,'%Y-%m-%d') statDate,
sum(case when tefdd.percent >= 80 then 1 else 0 end) cnt
from t_electric_fence_drive tefdd
left join t_electric_fence tef on tef.id = tefdd.fence_id
left join t_vehicle_device tvv on tvv.sn = tefdd.sn and tvv.bind_status = 1 and tvv.del_flag = 0
left join t_vehicle tv on tv.id = tvv.vehicle_id
left join t_user tu on tu.id = tef.created_by
<select
id=
"getTestDriveData"
parameterType=
"cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch"
resultType=
"cn.com.glsx.admin.modules.model.export.TrialDriveReportExport"
>
select tsfd.drive_num as cnttotal,
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
<where>
<choose>
<when
test=
"year != null and year != '' and month != null and month != '' "
>
left(t
efdd.journey_time,7) = CONCAT(#{year,jdbcType=VARCHAR},'-',#{month,jdbcType=VARCHAR
})
left(t
sfd.drive_time,7) = CONCAT(#{year},'-',#{month
})
</when>
<otherwise>
<if
test=
"year != null and year != '' "
>
left(t
efdd.journey_time,4) = #{year,jdbcType=VARCHAR
}
left(t
sfd.drive_time,4) = #{year
}
</if>
<if
test=
"month != null and month != '' "
>
right(left(t
efdd.journey_time,7),2) = #{month,jdbcType=VARCHAR
}
right(left(t
sfd.drive_time,7),2) = #{month
}
</if>
</otherwise>
</choose>
<if
test=
"keywords !=null and keywords != ''"
>
and (
tu.account like '%${keywords}%'
or tu.username like '%${keywords}%'
)
</if>
<if
test=
"sn !=null and sn != ''"
>
and tefdd.sn = #{sn,jdbcType=VARCHAR}
<if
test=
"sn != null and sn !=''"
>
and tsfd.sn = #{sn}
</if>
</where>
GROUP BY tefdd.sn,tefdd.fence_id,statDate order by tu.account) tall GROUP BY tall.shopCode, tall.sn,
tall.statDate ORDER BY tall.shopCode
</select>
<select
id=
"getYearWithData"
resultType=
"java.lang.String"
>
...
...
src/test/java/cn/com/glsx/admin/modules/service/TrialDriveReportServiceTest.java
View file @
a7dd507
package
cn
.
com
.
glsx
.
admin
.
modules
.
service
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.admin.modules.mapper.StatisticsDriveMapper
;
import
cn.com.glsx.admin.modules.model.export.TrialDriveReportExport
;
import
cn.com.glsx.admin.modules.model.param.TrialDriveReportSearch
;
import
cn.com.glsx.usercenter.api.dto.response.Organization
;
...
...
@@ -37,9 +36,6 @@ public class TrialDriveReportServiceTest {
@Autowired
private
UserService
userService
;
@Autowired
private
StatisticsDriveMapper
statisticsDriveMapper
;
@Test
public
void
search
()
{
TrialDriveReportSearch
trialDriveReportSearch
=
new
TrialDriveReportSearch
();
...
...
@@ -91,9 +87,7 @@ public class TrialDriveReportServiceTest {
search
.
setSn
(
"8700922794"
);
search
.
setYear
(
"2021"
);
search
.
setMonth
(
"08"
);
List
<
TrialDriveReportExport
>
testDriveData
=
statisticsDriveMapper
.
getTestDriveData
(
search
);
List
<
TrialDriveReportExport
>
testDriveData
=
trialDriveReportService
.
search
(
search
);
System
.
out
.
println
(
"testDriveData = "
+
JSON
.
toJSONString
(
testDriveData
));
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment