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
54816dbc
Commit
54816dbc
authored
Aug 13, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改租車訂單地址,修改车辆预定时添加订单号
parent
5bbf3acc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
26 deletions
+45
-26
VehicleBiz.java
...c/main/java/com/xxfc/platform/vehicle/biz/VehicleBiz.java
+45
-26
No files found.
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleBiz.java
View file @
54816dbc
...
...
@@ -208,7 +208,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public
RestResponse
add
(
List
<
AddOrUpdateVehicleVo
>
addOrUpdateVehicleVoList
)
throws
Exception
{
if
(
addOrUpdateVehicleVoList
.
size
()>
MAX_BATCH_SIZE_VEHICLE
){
throw
new
CustomIllegalParam
Exception
(
"添加的车辆数量过多!"
);
throw
new
Base
Exception
(
"添加的车辆数量过多!"
);
}
for
(
AddOrUpdateVehicleVo
addOrUpdateVehicleVo:
addOrUpdateVehicleVoList
)
{
...
...
@@ -217,7 +217,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
BeanUtilsBean
.
getInstance
().
copyProperties
(
vehicle
,
addOrUpdateVehicleVo
);
if
(
addOrUpdateVehicleVo
.
getParkBranchCompanyId
()==
null
)
{
throw
new
CustomIllegalParam
Exception
(
"停靠公司不能为空"
);
throw
new
Base
Exception
(
"停靠公司不能为空"
);
}
vehicle
.
setId
(
UUID
.
randomUUID
().
toString
());
...
...
@@ -251,7 +251,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
// }
if
(
addOrUpdateVehicleVo
.
getNumberPlate
()
==
null
){
throw
new
CustomIllegalParam
Exception
(
"车牌不能为空"
);
throw
new
Base
Exception
(
"车牌不能为空"
);
}
List
<
Vehicle
>
vehicles
=
mapper
.
lockByCode
(
addOrUpdateVehicleVo
);
return
vehicles
;
...
...
@@ -265,14 +265,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
@Transactional
public
RestResponse
update
(
List
<
AddOrUpdateVehicleVo
>
addOrUpdateVehicleVoList
)
throws
Exception
{
if
(
addOrUpdateVehicleVoList
.
size
()>
MAX_BATCH_SIZE_VEHICLE
){
throw
new
CustomIllegalParam
Exception
(
"exceed max batch size"
);
throw
new
Base
Exception
(
"exceed max batch size"
);
}
for
(
AddOrUpdateVehicleVo
addOrUpdateVehicleVo:
addOrUpdateVehicleVoList
){
Vehicle
vehicle
=
new
Vehicle
();
BeanUtilsBean
.
getInstance
().
copyProperties
(
vehicle
,
addOrUpdateVehicleVo
);
if
(
addOrUpdateVehicleVo
.
getParkBranchCompanyId
()==
null
)
{
throw
new
CustomIllegalParam
Exception
(
"Stop at branch office cannot be empty"
);
throw
new
Base
Exception
(
"Stop at branch office cannot be empty"
);
}
//悲观锁,检查是否已存在车牌或编码
...
...
@@ -305,7 +305,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
*/
public
RestResponse
discard
(
List
<
String
>
idList
){
if
(
idList
.
size
()>
MAX_BATCH_SIZE_VEHICLE
){
throw
new
CustomIllegalParam
Exception
(
"exceed max batch size"
);
throw
new
Base
Exception
(
"exceed max batch size"
);
}
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
params
.
put
(
"idList"
,
idList
);
...
...
@@ -337,7 +337,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod
(
yearMonthAndDate
,
startDay
,
endDay
);
if
(
yearMonthAndDate
.
size
()>
3
){
//连续的日期最多夸3个月
throw
new
CustomIllegalParam
Exception
(
" you can only within 2 month"
);
throw
new
Base
Exception
(
" you can only within 2 month"
);
}
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry:
yearMonthAndDate
.
entrySet
()){
Boolean
rsEach
=
applyVehicle4EmployeePerMonth
(
bookVehicleVo
.
getVehicleId
(),
entry
.
getValue
(),
entry
.
getKey
());
...
...
@@ -419,7 +419,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod
(
yearMonthAndDate
,
startDay
,
endDay
);
if
(
yearMonthAndDate
.
size
()>
3
){
//连续的日期最多夸3个月
throw
new
CustomIllegalParam
Exception
(
" 只可以预约两个月内的车辆"
);
throw
new
Base
Exception
(
" 只可以预约两个月内的车辆"
);
}
//检查车辆是否可以预定
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry:
yearMonthAndDate
.
entrySet
()){
...
...
@@ -503,7 +503,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod
(
yearMonthAndDate
,
startDay
,
endDay
);
if
(
yearMonthAndDate
.
size
()>
3
){
//连续的日期最多夸3个月
throw
new
CustomIllegalParam
Exception
(
" 只可以预约两个月内的车辆"
);
throw
new
Base
Exception
(
" 只可以预约两个月内的车辆"
);
}
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry:
yearMonthAndDate
.
entrySet
()){
Boolean
rsEach
=
applyVehicle4EmployeePerMonth
(
bookVehicleVo
.
getVehicleId
(),
entry
.
getValue
(),
entry
.
getKey
());
...
...
@@ -599,10 +599,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
VehicleBookRecord
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
bookRecordId
);
//申请记录验证
if
(
vehicleBookRecord
==
null
){
throw
new
CustomIllegalParam
Exception
(
" invalid book record"
);
throw
new
Base
Exception
(
" invalid book record"
);
}
if
(
!
VehicleBookRecordStatus
.
APPLY
.
getCode
().
equals
(
vehicleBookRecord
.
getStatus
())){
return
RestResponse
.
code
(
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getCode
());
if
(
VehicleBookRecordStatus
.
APPROVE
.
getCode
().
equals
(
vehicleBookRecord
.
getStatus
())){
throw
new
BaseException
(
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getDesc
(),
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getCode
());
}
//转换为相应预定参数
BookVehicleVO
bookVehicleVo
=
new
BookVehicleVO
();
...
...
@@ -655,7 +655,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
VehicleBookRecord
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
bookRecordId
);
//申请记录验证
if
(
vehicleBookRecord
==
null
){
throw
new
CustomIllegalParam
Exception
(
" invalid book record"
);
throw
new
Base
Exception
(
" invalid book record"
);
}
//已通过审核的可以取消预定
if
(!
VehicleBookRecordStatus
.
APPROVE
.
getCode
().
equals
(
vehicleBookRecord
.
getStatus
())){
...
...
@@ -743,7 +743,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod
(
yearMonthAndDate
,
startDay
,
endDay
);
if
(
yearMonthAndDate
.
size
()>
3
){
//连续的日期最多夸3个月
throw
new
CustomIllegalParam
Exception
(
" 只可以预约两个月内的车辆"
);
throw
new
Base
Exception
(
" 只可以预约两个月内的车辆"
);
}
Boolean
rs
=
Boolean
.
TRUE
;
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry:
yearMonthAndDate
.
entrySet
()){
...
...
@@ -781,7 +781,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
params
.
put
(
"yearMonth"
,
yearMonth
);
//加入更新条件
if
(
CollectionUtils
.
isEmpty
(
bookedDates
)){
throw
new
CustomIllegalParam
Exception
(
" there are no day to book"
);
throw
new
Base
Exception
(
" there are no day to book"
);
}
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
yearMonthAndDate
.
put
(
vehicleBookInfo
.
getYearMonth
(),
bookedDates
);
...
...
@@ -822,7 +822,26 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
for
(
DateTime
curDate
=
startDay
;
curDate
.
compareTo
(
endDay
)<=
0
;
curDate
=
curDate
.
plusDays
(
1
)){
String
curDateStr
=
curDate
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
if
(
curDateStr
.
compareTo
(
DateTime
.
now
().
toString
(
DEFAULT_DATE_TIME_FORMATTER
))<
0
){
throw
new
CustomIllegalParamException
(
"只可以取消当前时间之后的车辆"
);
throw
new
BaseException
(
"只可以取消当前时间之后的车辆"
);
}
String
curYearMonth
=
curDate
.
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
if
(!
yearMonthAndDate
.
containsKey
(
curYearMonth
)){
yearMonthAndDate
.
put
(
curYearMonth
,
Lists
.
newArrayList
());
}
List
<
String
>
curBookedDateList
=
yearMonthAndDate
.
get
(
curYearMonth
);
curBookedDateList
.
add
(
curDateStr
);
}
if
(
yearMonthAndDate
.
size
()>
3
){
//连续的日期最多夸3个月
throw
new
BaseException
(
" 只可以预约两个月内的车辆"
);
}
}
private
void
uinbookDateList4DatePeriod
(
Map
<
String
,
List
<
String
>>
yearMonthAndDate
,
DateTime
startDay
,
DateTime
endDay
){
for
(
DateTime
curDate
=
startDay
;
curDate
.
compareTo
(
endDay
)<=
0
;
curDate
=
curDate
.
plusDays
(
1
)){
String
curDateStr
=
curDate
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
if
(
curDateStr
.
compareTo
(
DateTime
.
now
().
toString
(
DEFAULT_DATE_TIME_FORMATTER
))<
0
){
throw
new
BaseException
(
"只可以取消当前时间之后的车辆"
);
}
String
curYearMonth
=
curDate
.
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
if
(!
yearMonthAndDate
.
containsKey
(
curYearMonth
)){
...
...
@@ -833,7 +852,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
if
(
yearMonthAndDate
.
size
()>
3
){
//连续的日期最多夸3个月
throw
new
CustomIllegalParam
Exception
(
" 只可以预约两个月内的车辆"
);
throw
new
Base
Exception
(
" 只可以预约两个月内的车辆"
);
}
}
...
...
@@ -849,10 +868,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
DateTime
startDay
=
DateTime
.
parse
(
bookVehicleVo
.
getUnbookStartDate
(),
DEFAULT_DATE_TIME_FORMATTER
);
DateTime
endDay
=
DateTime
.
parse
(
bookVehicleVo
.
getUnbookEndDate
(),
DEFAULT_DATE_TIME_FORMATTER
);
//转换日期范围为列表,并检查是否合法
fill
DateList4DatePeriod
(
yearMonthAndDate
,
startDay
,
endDay
);
uinbook
DateList4DatePeriod
(
yearMonthAndDate
,
startDay
,
endDay
);
if
(
yearMonthAndDate
.
size
()>
3
){
//连续的日期最多夸3个月
throw
new
CustomIllegalParam
Exception
(
" 只可以预约两个月内的车辆"
);
throw
new
Base
Exception
(
" 只可以预约两个月内的车辆"
);
}
Boolean
rs
=
Boolean
.
TRUE
;
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry:
yearMonthAndDate
.
entrySet
()){
...
...
@@ -873,7 +892,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
params
.
put
(
"yearMonth"
,
yearMonth
);
//加入更新条件
if
(
CollectionUtils
.
isEmpty
(
unbookDates
)){
throw
new
CustomIllegalParam
Exception
(
" 车辆不可预定"
);
throw
new
Base
Exception
(
" 车辆不可预定"
);
}
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
yearMonthAndDate
.
put
(
yearMonth
,
unbookDates
);
...
...
@@ -900,7 +919,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public
void
fillBookedDateSearchParam
(
Map
<
String
,
Object
>
params
,
Map
<
String
,
List
<
String
>>
yearMonthAndDate
,
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
){
if
(
MapUtils
.
isEmpty
(
yearMonthAndDate
)&&
MapUtils
.
isEmpty
(
yearMonthAndDateNotBooked
)){
//没有预定信息查询条件
throw
new
CustomIllegalParam
Exception
(
"没有预订信息!"
);
throw
new
Base
Exception
(
"没有预订信息!"
);
}
Map
<
String
,
Map
<
String
,
Integer
>>
yearMonthAndParam
=
new
HashMap
<>();
...
...
@@ -945,7 +964,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
for
(
String
dateStr:
entry
.
getValue
())
{
//已预定作为条件,该位与1作与运算必定为1
if
(
bookedYearMonth
.
contains
(
dateStr
)){
throw
new
CustomIllegalParam
Exception
(
"同一天既作为未预定查询条件又作为已预定查询条件"
);
throw
new
Base
Exception
(
"同一天既作为未预定查询条件又作为已预定查询条件"
);
}
DateTime
dateTime
=
DateTime
.
parse
(
dateStr
,
DEFAULT_DATE_TIME_FORMATTER
);
//仅对应位为1的整形值
...
...
@@ -1034,10 +1053,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
=
new
HashMap
<>();
//未预定年月 - 未预定日期列表
classifyByYearMonth
(
notBookedDates
,
yearMonthAndDateNotBooked
,
allYearMonth
);
if
(
allYearMonth
.
size
()>
0
&&
params
.
get
(
"subordinateBranch"
)
==
null
){
throw
new
CustomIllegalParam
Exception
(
" <subordinateBranch> must included in params while using <bookedInfo> param. "
);
throw
new
Base
Exception
(
" <subordinateBranch> must included in params while using <bookedInfo> param. "
);
}
if
(
allYearMonth
.
size
()>
MAX_MONTH_COUNT_BOOKED_INFO_QUERY
){
throw
new
CustomIllegalParam
Exception
(
" only 3 month can be included <bookedInfo> param."
);
throw
new
Base
Exception
(
" only 3 month can be included <bookedInfo> param."
);
}
//加入预定信息查询条件
fillBookedDateSearchParam
(
params
,
yearMonthAndDate
,
yearMonthAndDateNotBooked
);
...
...
@@ -1133,7 +1152,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
=
new
HashMap
<>();
//需比较未预定的年月 - 未预定日期列表 "2019-08-29"...."2019-09-04",
classifyByYearMonth
(
notBookedDates
,
yearMonthAndDateNotBooked
,
allYearMonth
);
if
(
allYearMonth
.
size
()>
MAX_MONTH_COUNT_BOOKED_INFO_QUERY
){
throw
new
CustomIllegalParam
Exception
(
" only 3 month can be included <bookedInfo> param."
);
throw
new
Base
Exception
(
" only 3 month can be included <bookedInfo> param."
);
}
//加入预定信息查询条件
...
...
@@ -1159,7 +1178,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
=
new
HashMap
<>();
//未预定年月 - 未预定日期列表
classifyByYearMonth
(
notBookedDates
,
yearMonthAndDateNotBooked
,
allYearMonth
);
if
(
allYearMonth
.
size
()>
MAX_MONTH_COUNT_BOOKED_INFO_QUERY
){
throw
new
CustomIllegalParam
Exception
(
" only 3 month can be included <bookedInfo> param."
);
throw
new
Base
Exception
(
" only 3 month can be included <bookedInfo> param."
);
}
//加入预定信息查询条件
fillBookedDateSearchParam
(
params
,
yearMonthAndDate
,
yearMonthAndDateNotBooked
);
...
...
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