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 405ce916
authored
Nov 22, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化不在店统计逻辑,将不在店每天统计数据落库
1 parent
708d7b85
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
12 deletions
src/main/java/cn/com/glsx/admin/modules/entity/ElectricInStoreDrive.java
src/main/java/cn/com/glsx/admin/modules/service/ElectricInStoreDriveService.java
src/main/resources/mapper/ElectricInStoreDriveMapper.xml
src/test/java/cn/com/glsx/admin/modules/service/ElectricInStoreDriveServiceTest.java
src/main/java/cn/com/glsx/admin/modules/entity/ElectricInStoreDrive.java
View file @
405ce91
...
@@ -82,5 +82,11 @@ public class ElectricInStoreDrive implements Serializable {
...
@@ -82,5 +82,11 @@ public class ElectricInStoreDrive implements Serializable {
@Transient
@Transient
private
Integer
instoreCnt
;
private
Integer
instoreCnt
;
/**
* 每天在店数据的年月信息
*/
@Transient
private
String
statDate
;
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/admin/modules/service/ElectricInStoreDriveService.java
View file @
405ce91
...
@@ -4,7 +4,6 @@ import cn.com.glsx.admin.modules.entity.ElectricInStoreDrive;
...
@@ -4,7 +4,6 @@ import cn.com.glsx.admin.modules.entity.ElectricInStoreDrive;
import
cn.com.glsx.admin.modules.mapper.ElectricInStoreDriveMapper
;
import
cn.com.glsx.admin.modules.mapper.ElectricInStoreDriveMapper
;
import
cn.com.glsx.admin.modules.model.export.ElectricInStoreExport
;
import
cn.com.glsx.admin.modules.model.export.ElectricInStoreExport
;
import
cn.com.glsx.admin.modules.model.param.ElectricInStoreSearch
;
import
cn.com.glsx.admin.modules.model.param.ElectricInStoreSearch
;
import
cn.hutool.core.date.DateUtil
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -73,7 +72,7 @@ public class ElectricInStoreDriveService {
...
@@ -73,7 +72,7 @@ public class ElectricInStoreDriveService {
// 组合每一天的数据
// 组合每一天的数据
for
(
ElectricInStoreDrive
inStoreDrive
:
inStoreDataList
)
{
for
(
ElectricInStoreDrive
inStoreDrive
:
inStoreDataList
)
{
// 设置报表统计时间
// 设置报表统计时间
electricInStoreExport
.
setStatDate
(
DateUtil
.
format
(
inStoreDrive
.
getGpsTime
(),
"yyyy-MM"
));
electricInStoreExport
.
setStatDate
(
inStoreDrive
.
getStatDate
(
));
summation
=
summation
+
inStoreDrive
.
getInstoreCnt
();
summation
=
summation
+
inStoreDrive
.
getInstoreCnt
();
switch
(
inStoreDrive
.
getDayOfMonth
())
{
switch
(
inStoreDrive
.
getDayOfMonth
())
{
case
1
:
case
1
:
...
...
src/main/resources/mapper/ElectricInStoreDriveMapper.xml
View file @
405ce91
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
<resultMap
id=
"InStoreDataMap"
type=
"cn.com.glsx.admin.modules.entity.ElectricInStoreDrive"
>
<resultMap
id=
"InStoreDataMap"
type=
"cn.com.glsx.admin.modules.entity.ElectricInStoreDrive"
>
<result
property=
"instoreCnt"
column=
"instoreCnt"
jdbcType=
"INTEGER"
/>
<result
property=
"instoreCnt"
column=
"instoreCnt"
jdbcType=
"INTEGER"
/>
<result
property=
"
gpsTime"
column=
"gps_time"
jdbcType=
"TIMESTAMP
"
/>
<result
property=
"
statDate"
column=
"statDate"
jdbcType=
"VARCHAR
"
/>
<result
property=
"dayOfMonth"
column=
"dayOfMonth"
jdbcType=
"INTEGER"
/>
<result
property=
"dayOfMonth"
column=
"dayOfMonth"
jdbcType=
"INTEGER"
/>
</resultMap>
</resultMap>
...
@@ -61,19 +61,33 @@
...
@@ -61,19 +61,33 @@
order by tu.account
order by tu.account
</select>
</select>
<!-- <select id="getInStoreDataList" resultMap="InStoreDataMap">-->
<!-- select-->
<!-- case when sum(case when teid.gps_state = 2 then 1 else 0 end) = count(1) then 1 else 0 end as instoreCnt,-->
<!-- teid.gps_time ,-->
<!-- day(teid.gps_time) as dayOfMonth-->
<!-- from t_electric_instore_drive teid-->
<!-- left join t_vehicle_device tvd on tvd.id = teid.vd_id-->
<!-- <where>-->
<!-- <if test="year != null and year != '' and month != null and month != '' ">-->
<!-- left(teid.gps_time,7) = CONCAT(#{year},'-',#{month})-->
<!-- </if>-->
<!-- and tvd.vehicle_id = #{vehicleId}-->
<!-- </where>-->
<!-- group by left(teid.gps_time,10)-->
<!-- </select>-->
<select
id=
"getInStoreDataList"
resultMap=
"InStoreDataMap"
>
<select
id=
"getInStoreDataList"
resultMap=
"InStoreDataMap"
>
select
select tsid.instore_num as instoreCnt,
case when sum(case when teid.gps_state = 2 then 1 else 0 end) = count(1) then 1 else 0 end as instoreCnt,
left(tsid.instore_time, 7) as statDate,
teid.gps_time ,
day(str_to_date(tsid.instore_time, '%Y-%m-%d')) as dayOfMonth
day(teid.gps_time) as dayOfMonth
from t_statistics_instore_drive tsid
from t_electric_instore_drive teid
left join t_vehicle_device tvd on tvd.id = tsid.vd_id
left join t_vehicle_device tvd on tvd.id = teid.vd_id
<where>
<where>
<if
test=
"year != null and year != '' and month != null and month != '' "
>
<if
test=
"year != null and year != '' and month != null and month != '' "
>
left(t
eid.gps
_time,7) = CONCAT(#{year},'-',#{month})
left(t
sid.instore
_time,7) = CONCAT(#{year},'-',#{month})
</if>
</if>
and tvd.vehicle_id = #{vehicleId}
and tvd.vehicle_id = #{vehicleId}
</where>
</where>
group by left(teid.gps_time,10)
</select>
</select>
</mapper>
</mapper>
src/test/java/cn/com/glsx/admin/modules/service/ElectricInStoreDriveServiceTest.java
View file @
405ce91
...
@@ -300,7 +300,7 @@ public class ElectricInStoreDriveServiceTest {
...
@@ -300,7 +300,7 @@ public class ElectricInStoreDriveServiceTest {
@Test
@Test
public
void
test03
()
{
public
void
test03
()
{
ElectricInStoreSearch
search
=
new
ElectricInStoreSearch
();
ElectricInStoreSearch
search
=
new
ElectricInStoreSearch
();
search
.
setVehicleId
(
5498
L
);
search
.
setVehicleId
(
39
L
);
List
<
ElectricInStoreDrive
>
inStoreDataList
=
inStoreDriveMapper
.
getInStoreDataList
(
search
);
List
<
ElectricInStoreDrive
>
inStoreDataList
=
inStoreDriveMapper
.
getInStoreDataList
(
search
);
System
.
out
.
println
(
"inStoreDataList = "
+
JSON
.
toJSONString
(
inStoreDataList
));
System
.
out
.
println
(
"inStoreDataList = "
+
JSON
.
toJSONString
(
inStoreDataList
));
}
}
...
...
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