Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
youjj
cloud-platform
Commits
5e34edae
Commit
5e34edae
authored
Nov 25, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充车辆统计数据
parent
2ddebc2d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
28 deletions
+110
-28
BranchCompanyVehicleCountBiz.java
...fc/platform/vehicle/biz/BranchCompanyVehicleCountBiz.java
+66
-27
VehicleBookRecordBiz.java
...a/com/xxfc/platform/vehicle/biz/VehicleBookRecordBiz.java
+1
-0
BranchCompanyVehicleCountMapper.java
...tform/vehicle/mapper/BranchCompanyVehicleCountMapper.java
+1
-1
BranchCompanyVehicleCountMapper.xml
...main/resources/mapper/BranchCompanyVehicleCountMapper.xml
+42
-0
No files found.
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/BranchCompanyVehicleCountBiz.java
View file @
5e34edae
...
...
@@ -6,17 +6,22 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.Query
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.xxfc.platform.order.Utils.OrderDateUtils
;
import
com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount
;
import
com.xxfc.platform.vehicle.mapper.BranchCompanyVehicleCountMapper
;
import
com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo
;
import
com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO
;
import
com.xxfc.platform.vehicle.util.DateUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.joda.time.DateTime
;
import
org.joda.time.format.DateTimeFormat
;
import
org.joda.time.format.DateTimeFormatter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
@Slf4j
...
...
@@ -24,6 +29,10 @@ public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCo
@Autowired
VehicleBiz
vehicleBiz
;
//以时间字符串为key, 以公司ID和数量组成map为value
private
static
Map
<
String
,
Map
<
Integer
,
Integer
>>
mapMap
=
new
HashMap
<>();
public
static
final
DateTimeFormatter
DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd HH:mm:ss"
);
public
static
final
DateTimeFormatter
DEFAULT_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd"
);
public
ObjectRestResponse
add
(
BranchCompanyVehicleCount
branchCompanyVehicleCount
)
{
if
(
branchCompanyVehicleCount
==
null
)
{
...
...
@@ -80,34 +89,64 @@ public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCo
}
public
ObjectRestResponse
<
PageDataVO
<
BranchCompanyVehicleCountVo
>>
getAllCountInfo
(
BranchCompanyVehicleCountDTO
branchCompanyVehicleCountDTO
)
{
if
(
branchCompanyVehicleCountDTO
==
null
)
{
return
ObjectRestResponse
.
paramIsEmpty
();
}
Integer
page
=
branchCompanyVehicleCountDTO
.
getPage
()
==
null
?
1
:
branchCompanyVehicleCountDTO
.
getPage
();
Integer
limit
=
branchCompanyVehicleCountDTO
.
getLimit
()
==
null
?
10
:
branchCompanyVehicleCountDTO
.
getLimit
();
Integer
type
=
branchCompanyVehicleCountDTO
.
getType
()
==
null
?
1
:
branchCompanyVehicleCountDTO
.
getType
();
branchCompanyVehicleCountDTO
.
setPage
(
page
);
branchCompanyVehicleCountDTO
.
setLimit
(
limit
);
Query
query
=
new
Query
(
branchCompanyVehicleCountDTO
);
if
(
type
==
1
)
{
//按天
return
ObjectRestResponse
.
succ
(
countByDay
(
query
));
}
if
(
type
==
2
)
{
//按周
PageDataVO
<
BranchCompanyVehicleCountVo
>
pageDataVO
=
countByWeek
(
query
);
if
(
pageDataVO
!=
null
&&
pageDataVO
.
getData
()
!=
null
&&
pageDataVO
.
getData
().
size
()
>
0
)
{
pageDataVO
.
getData
().
parallelStream
().
forEach
(
result
->
{
String
weekStartDate
=
OrderDateUtils
.
getStartDayOfWeekNo
(
result
.
getCountYear
(),
result
.
getCountWeek
());
String
weekEndDate
=
OrderDateUtils
.
getEndDayOfWeekNo
(
result
.
getCountYear
(),
result
.
getCountWeek
());
result
.
setWeekStartDate
(
weekStartDate
);
result
.
setWeekEndDate
(
weekEndDate
);
});
}
return
ObjectRestResponse
.
succ
(
pageDataVO
);
getAllVehicleNum
();
// if (branchCompanyVehicleCountDTO == null) {
// return ObjectRestResponse.paramIsEmpty();
// }
// Integer page = branchCompanyVehicleCountDTO.getPage() == null ? 1 : branchCompanyVehicleCountDTO.getPage();
// Integer limit = branchCompanyVehicleCountDTO.getLimit() == null ? 10 : branchCompanyVehicleCountDTO.getLimit();
// Integer type = branchCompanyVehicleCountDTO.getType() == null ? 1 : branchCompanyVehicleCountDTO.getType();
// branchCompanyVehicleCountDTO.setPage(page);
// branchCompanyVehicleCountDTO.setLimit(limit);
// Query query = new Query(branchCompanyVehicleCountDTO);
// if (type == 1) {//按天
// return ObjectRestResponse.succ(countByDay(query));
// }
// if (type == 2) {//按周
// PageDataVO<BranchCompanyVehicleCountVo> pageDataVO = countByWeek(query);
// if (pageDataVO != null && pageDataVO.getData() != null && pageDataVO.getData().size() > 0) {
// pageDataVO.getData().parallelStream().forEach(result -> {
// String weekStartDate = OrderDateUtils.getStartDayOfWeekNo(result.getCountYear(), result.getCountWeek());
// String weekEndDate = OrderDateUtils.getEndDayOfWeekNo(result.getCountYear(), result.getCountWeek());
// result.setWeekStartDate(weekStartDate);
// result.setWeekEndDate(weekEndDate);
// });
// }
// return ObjectRestResponse.succ(pageDataVO);
// }
// if (type == 3) {//按月
// return ObjectRestResponse.succ(countByMonth(query));
// }
return
ObjectRestResponse
.
succ
(
new
PageDataVO
<>());
}
//获取所有月份车辆统计数据
public
void
getAllVehicleNum
(
DateTime
dateTime
)
{
DateTime
nowTime
=
DateTime
.
now
().
minusDays
(
1
);
if
(
dateTime
!=
null
)
{
nowTime
=
dateTime
.
minusDays
(
1
);
}
if
(
type
==
3
)
{
//按月
return
ObjectRestResponse
.
succ
(
countByMonth
(
query
));
Long
startTime
=
DateUtils
.
getStartOfDay
(
nowTime
.
toDate
());
Long
endTime
=
DateUtils
.
getEndOfDay
(
nowTime
.
toDate
());
String
timeStr
=
nowTime
.
toString
(
DEFAULT_TIME_FORMATTER
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"startTime"
,
new
DateTime
().
withMillis
(
startTime
).
toString
(
DATE_TIME_FORMATTER
));
map
.
put
(
"endTime"
,
new
DateTime
().
withMillis
(
endTime
).
toString
(
DATE_TIME_FORMATTER
));
List
<
BranchCompanyVehicleCountVo
>
list
=
mapper
.
selectBookRecordByTime
(
map
);
Map
<
Integer
,
Integer
>
companyMap
=
mapMap
.
getOrDefault
(
timeStr
,
new
HashMap
<>());
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
list
.
parallelStream
().
forEach
(
result
->
{
companyMap
.
put
(
result
.
getCompanyId
(),
result
.
getVehicleNum
());
});
mapMap
.
put
(
timeStr
,
companyMap
);
}
return
ObjectRestResponse
.
succ
(
new
PageDataVO
<>()
);
log
.
info
(
"统计车辆数据: Map = {}"
,
mapMap
);
}
public
void
getAllVehicleNum
()
{
DateTime
dateTime
=
DateTime
.
parse
(
"2019-01-01"
);
for
(
DateTime
curDate
=
dateTime
.
plusDays
(
1
);
curDate
.
compareTo
(
DateTime
.
now
())
<
0
;
curDate
=
curDate
.
plusDays
(
1
))
{
getAllVehicleNum
(
curDate
);
}
}
}
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleBookRecordBiz.java
View file @
5e34edae
...
...
@@ -505,6 +505,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
return
selectAllBookRecord
(
map
);
}
/**
* 获取上月数据,并复制到历史表
*/
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/mapper/BranchCompanyVehicleCountMapper.java
View file @
5e34edae
...
...
@@ -14,5 +14,5 @@ public interface BranchCompanyVehicleCountMapper extends Mapper<BranchCompanyVeh
List
<
BranchCompanyVehicleCountVo
>
countByMonth
(
Map
<
String
,
Object
>
param
);
List
<
BranchCompanyVehicleCountVo
>
countByWeek
(
Map
<
String
,
Object
>
param
);
List
<
BranchCompanyVehicleCountVo
>
selectBookRecordByTime
(
Map
<
String
,
Object
>
param
);
}
\ No newline at end of file
xx-vehicle/xx-vehicle-server/src/main/resources/mapper/BranchCompanyVehicleCountMapper.xml
View file @
5e34edae
...
...
@@ -58,4 +58,46 @@
GROUP BY c.company_id,c.count_year,c.count_week
</select>
<select
id=
"selectBookRecordByTime"
parameterType=
"Map"
resultType=
"com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo"
>
SELECT
tmp.lift_company as companyId, count(*) as vehicleNum
FROM
(
SELECT
*
FROM
vehicle_book_record
WHERE
STATUS = 2
AND (
(
book_start_date
>
#{startTime}
AND book_start_date
<
#{endTime}
AND book_end_date
>
#{endTime}
)
OR (
book_start_date
<
#{startTime}
AND book_end_date
>
#{endTime}
)
OR (
book_start_date
<
#{startTime}
AND book_end_date
>
#{startTime}
AND book_end_date
<
#{endTime}
)
OR (
book_start_date
>
#{startTime}
AND book_end_date
<
#{endTime}
)
)
ORDER BY
vehicle_id,
book_start_date
) tmp
GROUP BY
tmp.lift_company
</select>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment