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
a54d4d50
Commit
a54d4d50
authored
Aug 29, 2019
by
hanfeng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'base-modify' of
http://113.105.137.151:22280/youjj/cloud-platform
into dev-hf
parents
143b6202
728931ba
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
918 additions
and
524 deletions
+918
-524
RandomUtil.java
...a/com/github/wxiaoqi/security/common/util/RandomUtil.java
+6
-6
CampsiteShopBiz.java
.../java/com/xxfc/platform/campsite/biz/CampsiteShopBiz.java
+1
-1
TourFeign.java
...src/main/java/com/xxfc/platform/tour/feign/TourFeign.java
+21
-0
TourGoodBiz.java
...src/main/java/com/xxfc/platform/tour/biz/TourGoodBiz.java
+1
-1
TourTagBiz.java
.../src/main/java/com/xxfc/platform/tour/biz/TourTagBiz.java
+10
-0
TourGwController.java
...in/java/com/xxfc/platform/tour/rest/TourGwController.java
+68
-0
RandomListDto.java
...c/main/java/com/xxfc/platform/uccn/dto/RandomListDto.java
+23
-0
TypeEnum.java
...api/src/main/java/com/xxfc/platform/uccn/vo/TypeEnum.java
+43
-0
pom.xml
xx-uccn/xx-uccn-server/pom.xml
+7
-0
RandomListBiz.java
...c/main/java/com/xxfc/platform/uccn/biz/RandomListBiz.java
+54
-0
SummitActivityBiz.java
...in/java/com/xxfc/platform/uccn/biz/SummitActivityBiz.java
+36
-1
ArticleController.java
...n/java/com/xxfc/platform/uccn/rest/ArticleController.java
+1
-1
GwTourController.java
...in/java/com/xxfc/platform/uccn/rest/GwTourController.java
+51
-0
RandomListController.java
...ava/com/xxfc/platform/uccn/rest/RandomListController.java
+25
-0
SummitActivityController.java
...com/xxfc/platform/uccn/rest/SummitActivityController.java
+38
-26
VehicleModelController.java
...a/com/xxfc/platform/uccn/rest/VehicleModelController.java
+8
-4
VehicleFeign.java
...in/java/com/xxfc/platform/vehicle/feign/VehicleFeign.java
+2
-1
BranchCompanyBiz.java
.../java/com/xxfc/platform/vehicle/biz/BranchCompanyBiz.java
+25
-26
VehicleActiveService.java
...a/com/xxfc/platform/vehicle/biz/VehicleActiveService.java
+52
-38
VehicleBiz.java
...c/main/java/com/xxfc/platform/vehicle/biz/VehicleBiz.java
+377
-351
VehicleBookHourInfoBiz.java
...com/xxfc/platform/vehicle/biz/VehicleBookHourInfoBiz.java
+20
-19
VehicleBookInfoBiz.java
...ava/com/xxfc/platform/vehicle/biz/VehicleBookInfoBiz.java
+24
-23
VehicleBookRecordBiz.java
...a/com/xxfc/platform/vehicle/biz/VehicleBookRecordBiz.java
+11
-10
VehicleDepartureService.java
...om/xxfc/platform/vehicle/biz/VehicleDepartureService.java
+7
-8
VehicleModelBiz.java
...n/java/com/xxfc/platform/vehicle/biz/VehicleModelBiz.java
+1
-1
VehicleJobHandler.java
...m/xxfc/platform/vehicle/jobhandler/VehicleJobHandler.java
+3
-5
VehicleModelController.java
...om/xxfc/platform/vehicle/rest/VehicleModelController.java
+2
-1
VehicleBookRecordMapper.xml
...ver/src/main/resources/mapper/VehicleBookRecordMapper.xml
+1
-1
No files found.
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/RandomUtil.java
View file @
a54d4d50
...
@@ -40,8 +40,8 @@ public class RandomUtil
...
@@ -40,8 +40,8 @@ public class RandomUtil
* @param n
* @param n
* @param set
* @param set
*/
*/
public
static
void
randomSet
(
int
max
,
int
n
,
Set
<
Integer
>
set
)
{
public
static
void
randomSet
(
int
max
,
int
n
,
Set
<
Integer
>
set
,
int
total
)
{
if
(
n
>
(
max
+
1
)
||
max
<
0
)
{
if
(
n
>
(
max
)
||
max
<
0
)
{
return
;
return
;
}
}
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
...
@@ -50,8 +50,8 @@ public class RandomUtil
...
@@ -50,8 +50,8 @@ public class RandomUtil
}
}
int
setSize
=
set
.
size
();
int
setSize
=
set
.
size
();
// 如果存入的数小于指定生成的个数,则调用递归再生成剩余个数的随机数,如此循环,直到达到指定大小
// 如果存入的数小于指定生成的个数,则调用递归再生成剩余个数的随机数,如此循环,直到达到指定大小
if
(
setSize
<
n
)
{
if
(
setSize
<
total
)
{
randomSet
(
max
,
n
-
setSize
,
set
);
// 递归
randomSet
(
max
,
total
-
setSize
,
set
,
total
);
// 递归
}
}
}
}
...
@@ -63,9 +63,9 @@ public class RandomUtil
...
@@ -63,9 +63,9 @@ public class RandomUtil
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
int
max
=
20
;
int
max
=
20
;
int
n
=
5
;
int
n
=
20
;
Set
<
Integer
>
set
=
new
HashSet
<>();
Set
<
Integer
>
set
=
new
HashSet
<>();
randomSet
(
max
,
n
,
set
);
randomSet
(
max
,
n
,
set
,
n
);
for
(
Integer
a
:
set
)
{
for
(
Integer
a
:
set
)
{
System
.
out
.
println
(
a
);
System
.
out
.
println
(
a
);
}
}
...
...
xx-campsite/xx-campsite-server/src/main/java/com/xxfc/platform/campsite/biz/CampsiteShopBiz.java
View file @
a54d4d50
...
@@ -347,7 +347,7 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> {
...
@@ -347,7 +347,7 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> {
return
ObjectRestResponse
.
succ
(
list
);
return
ObjectRestResponse
.
succ
(
list
);
}
}
Set
<
Integer
>
set
=
new
HashSet
<>();
Set
<
Integer
>
set
=
new
HashSet
<>();
RandomUtil
.
randomSet
(
list
.
size
(),
number
,
set
);
RandomUtil
.
randomSet
(
list
.
size
(),
number
,
set
,
number
);
for
(
Integer
i
:
set
)
{
for
(
Integer
i
:
set
)
{
resultList
.
add
(
list
.
get
(
i
));
resultList
.
add
(
list
.
get
(
i
));
}
}
...
...
xx-tour/xx-tour-api/src/main/java/com/xxfc/platform/tour/feign/TourFeign.java
View file @
a54d4d50
...
@@ -7,6 +7,7 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
...
@@ -7,6 +7,7 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
import
com.xxfc.platform.tour.dto.TourSpePriceDTO
;
import
com.xxfc.platform.tour.dto.TourSpePriceDTO
;
import
com.xxfc.platform.tour.entity.TourGood
;
import
com.xxfc.platform.tour.entity.TourGood
;
import
com.xxfc.platform.tour.entity.TourGoodVerification
;
import
com.xxfc.platform.tour.entity.TourGoodVerification
;
import
com.xxfc.platform.tour.entity.TourTag
;
import
com.xxfc.platform.tour.entity.TourUser
;
import
com.xxfc.platform.tour.entity.TourUser
;
import
com.xxfc.platform.tour.vo.TourGoodOrderFindVo
;
import
com.xxfc.platform.tour.vo.TourGoodOrderFindVo
;
import
com.xxfc.platform.tour.vo.TourGoodOrderVo
;
import
com.xxfc.platform.tour.vo.TourGoodOrderVo
;
...
@@ -107,4 +108,24 @@ public interface TourFeign {
...
@@ -107,4 +108,24 @@ public interface TourFeign {
@GetMapping
(
value
=
"/tourGood/app/unauth/findRandomVehicle"
)
@GetMapping
(
value
=
"/tourGood/app/unauth/findRandomVehicle"
)
public
ObjectRestResponse
findRandomVehicle
(
@RequestParam
(
value
=
"number"
)
Integer
number
);
public
ObjectRestResponse
findRandomVehicle
(
@RequestParam
(
value
=
"number"
)
Integer
number
);
//查询旅游路线列表
@RequestMapping
(
value
=
"/gw/app/unauth/getGoodList"
,
method
=
RequestMethod
.
GET
)
ObjectRestResponse
getGoodList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
value
=
"tagId"
,
required
=
false
)
Integer
tagId
);
//获取公司详情
@GetMapping
(
"/gw/app/unauth/detail/{id}"
)
ObjectRestResponse
getOne
(
@PathVariable
Integer
id
);
//首页旅游列表
@GetMapping
(
value
=
"/gw/app/shopList"
)
List
<
GoodDataVO
>
goodListAll
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"4"
)
Integer
limit
);
//旅游标签列表
@GetMapping
(
value
=
"/gw/tagList"
)
List
<
TourTag
>
tagList
(
@RequestParam
(
value
=
"isHot"
,
defaultValue
=
"0"
)
Integer
isHot
);
}
}
xx-tour/xx-tour-server/src/main/java/com/xxfc/platform/tour/biz/TourGoodBiz.java
View file @
a54d4d50
...
@@ -338,7 +338,7 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
...
@@ -338,7 +338,7 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
return
ObjectRestResponse
.
succ
(
list
);
return
ObjectRestResponse
.
succ
(
list
);
}
}
Set
<
Integer
>
set
=
new
HashSet
<>();
Set
<
Integer
>
set
=
new
HashSet
<>();
RandomUtil
.
randomSet
(
list
.
size
(),
number
,
set
);
RandomUtil
.
randomSet
(
list
.
size
(),
number
,
set
,
number
);
for
(
Integer
i
:
set
)
{
for
(
Integer
i
:
set
)
{
resultList
.
add
(
list
.
get
(
i
));
resultList
.
add
(
list
.
get
(
i
));
}
}
...
...
xx-tour/xx-tour-server/src/main/java/com/xxfc/platform/tour/biz/TourTagBiz.java
View file @
a54d4d50
...
@@ -49,6 +49,16 @@ public class TourTagBiz extends BaseBiz<TourTagMapper,TourTag> {
...
@@ -49,6 +49,16 @@ public class TourTagBiz extends BaseBiz<TourTagMapper,TourTag> {
return
mapper
.
findHotListTag
(
tag
);
return
mapper
.
findHotListTag
(
tag
);
}
}
public
List
<
TourTag
>
getTagList
(
Integer
isHot
)
{
TourTag
tag
=
new
TourTag
();
tag
.
setIsDel
(
0
);
if
(
isHot
!=
null
&&
isHot
==
1
){
tag
.
setIsHot
(
1
);
return
mapper
.
findHotListTag
(
tag
);
}
return
mapper
.
findAllByIsDel
(
tag
);
}
public
PageDataVO
<
TourTag
>
findPage
(
Map
map
)
{
public
PageDataVO
<
TourTag
>
findPage
(
Map
map
)
{
...
...
xx-tour/xx-tour-server/src/main/java/com/xxfc/platform/tour/rest/TourGwController.java
0 → 100644
View file @
a54d4d50
package
com
.
xxfc
.
platform
.
tour
.
rest
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.rest.BaseController
;
import
com.github.wxiaoqi.security.common.vo.GoodDataVO
;
import
com.xxfc.platform.tour.biz.TourGoodBiz
;
import
com.xxfc.platform.tour.biz.TourGoodDetailBiz
;
import
com.xxfc.platform.tour.biz.TourTagBiz
;
import
com.xxfc.platform.tour.entity.TourGood
;
import
com.xxfc.platform.tour.entity.TourTag
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
@RestController
@RequestMapping
(
"gw"
)
@IgnoreClientToken
@IgnoreUserToken
public
class
TourGwController
extends
BaseController
<
TourGoodBiz
,
TourGood
>
{
@Autowired
TourGoodDetailBiz
goodDetailBiz
;
@Autowired
TourTagBiz
tourTagBiz
;
/**
* 查询旅游路线列表
*
* @param page
* @param limit
* @param tagId
* @return
*/
@ApiOperation
(
"查询旅游路线列表"
)
@RequestMapping
(
value
=
"/app/unauth/getGoodList"
,
method
=
RequestMethod
.
GET
)
public
ObjectRestResponse
getGoodList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
value
=
"tagId"
,
required
=
false
)
Integer
tagId
)
{
return
baseBiz
.
getGoodList
(
page
,
limit
,
""
,
null
,
null
,
tagId
,
null
);
}
@GetMapping
(
"/app/unauth/detail/{id}"
)
public
ObjectRestResponse
getOne
(
@PathVariable
Integer
id
)
{
return
goodDetailBiz
.
getGoodDetaileById
(
id
);
}
@ApiOperation
(
"首页旅游列表"
)
@GetMapping
(
value
=
"/shopList"
)
public
List
<
GoodDataVO
>
goodListAll
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"4"
)
Integer
limit
)
{
return
baseBiz
.
getAllByHome
(
page
,
limit
);
}
@ApiOperation
(
"旅游标签列表"
)
@GetMapping
(
value
=
"/tagList"
)
public
List
<
TourTag
>
tagList
(
@RequestParam
(
value
=
"isHot"
,
defaultValue
=
"0"
)
Integer
isHot
)
{
return
tourTagBiz
.
getTagList
(
isHot
);
}
}
\ No newline at end of file
xx-uccn/xx-uccn-api/src/main/java/com/xxfc/platform/uccn/dto/RandomListDto.java
0 → 100644
View file @
a54d4d50
package
com
.
xxfc
.
platform
.
uccn
.
dto
;
import
lombok.Data
;
@Data
public
class
RandomListDto
{
/**
* 列表类型 TypeEnum
*/
private
Integer
type
;
/**
* 随机数量
*/
private
Integer
number
;
/**
* 活动位置,1:欣欣官网 2:滴房车官网 0:无限制,
*/
private
Integer
location
;
}
xx-uccn/xx-uccn-api/src/main/java/com/xxfc/platform/uccn/vo/TypeEnum.java
0 → 100644
View file @
a54d4d50
package
com
.
xxfc
.
platform
.
uccn
.
vo
;
import
lombok.Data
;
public
enum
TypeEnum
{
VEHICLE
(
1
,
"车型"
),
TOUR
(
2
,
"旅游"
),
CAMPSITE
(
3
,
"营地"
),
ACTIVITY
(
4
,
"活动"
);
private
Integer
code
;
private
String
msg
;
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
TypeEnum
(
Integer
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
static
TypeEnum
getByValue
(
Integer
value
){
for
(
TypeEnum
typeEnum
:
values
()){
if
(
typeEnum
.
getCode
()
==
value
)
{
return
typeEnum
;
}
}
return
null
;
}
}
xx-uccn/xx-uccn-server/pom.xml
View file @
a54d4d50
...
@@ -33,6 +33,12 @@
...
@@ -33,6 +33,12 @@
<version>
2.0-SNAPSHOT
</version>
<version>
2.0-SNAPSHOT
</version>
<scope>
compile
</scope>
<scope>
compile
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
com.xxfc.platform
</groupId>
<artifactId>
xx-tour-api
</artifactId>
<version>
2.0-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<dependency>
<groupId>
com.xxfc.platform
</groupId>
<groupId>
com.xxfc.platform
</groupId>
<artifactId>
xx-campsite-api
</artifactId>
<artifactId>
xx-campsite-api
</artifactId>
...
@@ -41,6 +47,7 @@
...
@@ -41,6 +47,7 @@
</dependency>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<finalName>
xx-uccn
</finalName>
<plugins>
<plugins>
<!-- 此插件用来生成通用mapper的代码 -->
<!-- 此插件用来生成通用mapper的代码 -->
<plugin>
<plugin>
...
...
xx-uccn/xx-uccn-server/src/main/java/com/xxfc/platform/uccn/biz/RandomListBiz.java
0 → 100644
View file @
a54d4d50
package
com
.
xxfc
.
platform
.
uccn
.
biz
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.campsite.feign.CampsiteFeign
;
import
com.xxfc.platform.tour.feign.TourFeign
;
import
com.xxfc.platform.uccn.vo.TypeEnum
;
import
com.xxfc.platform.vehicle.feign.VehicleFeign
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* 获取随机数量的车型、旅游、营地、活动
*/
@Service
@Slf4j
public
class
RandomListBiz
{
@Autowired
VehicleFeign
vehicleFeign
;
@Autowired
TourFeign
tourFeign
;
@Autowired
CampsiteFeign
campsiteFeign
;
@Autowired
SummitActivityBiz
summitActivityBiz
;
/**
* @param type 类型
* @param number 随机数,默认是2
* @return
*/
public
ObjectRestResponse
getRandomList
(
Integer
type
,
Integer
number
,
Integer
location
)
{
if
(
type
!=
null
)
{
number
=
number
==
null
?
2
:
number
;
switch
(
TypeEnum
.
getByValue
(
type
))
{
case
VEHICLE:
return
vehicleFeign
.
findRandomVehicle
(
number
);
case
TOUR:
return
tourFeign
.
findRandomVehicle
(
number
);
case
CAMPSITE:
return
campsiteFeign
.
findRandomVehicle
(
number
);
case
ACTIVITY:
return
ObjectRestResponse
.
succ
(
summitActivityBiz
.
getHostWithSummitActivity
(
number
,
location
));
}
}
return
ObjectRestResponse
.
succ
();
}
}
xx-uccn/xx-uccn-server/src/main/java/com/xxfc/platform/uccn/biz/SummitActivityBiz.java
View file @
a54d4d50
...
@@ -168,6 +168,7 @@ public class SummitActivityBiz extends BaseBiz<SummitActivityMapper, SummitActiv
...
@@ -168,6 +168,7 @@ public class SummitActivityBiz extends BaseBiz<SummitActivityMapper, SummitActiv
public
List
<
SummitActivityVo
>
getHostWithSummitActivity
(
Integer
num
,
Integer
location
)
{
public
List
<
SummitActivityVo
>
getHostWithSummitActivity
(
Integer
num
,
Integer
location
)
{
List
<
SummitActivityVo
>
summitActivityVos
=
new
ArrayList
<>();
List
<
SummitActivityVo
>
summitActivityVos
=
new
ArrayList
<>();
Example
example
=
new
Example
(
SummitActivity
.
class
);
Example
example
=
new
Example
(
SummitActivity
.
class
);
example
.
setOrderByClause
(
"crt_time DESC"
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
Example
.
Criteria
criteria
=
example
.
createCriteria
();
//未删除
//未删除
criteria
.
andEqualTo
(
"isDel"
,
0
);
criteria
.
andEqualTo
(
"isDel"
,
0
);
...
@@ -193,7 +194,7 @@ public class SummitActivityBiz extends BaseBiz<SummitActivityMapper, SummitActiv
...
@@ -193,7 +194,7 @@ public class SummitActivityBiz extends BaseBiz<SummitActivityMapper, SummitActiv
}
}
}
else
{
}
else
{
Set
<
Integer
>
resultSet
=
new
HashSet
<>();
Set
<
Integer
>
resultSet
=
new
HashSet
<>();
RandomUtil
.
randomSet
(
summitActivities
.
size
(),
num
,
resultSet
);
RandomUtil
.
randomSet
(
summitActivities
.
size
(),
num
,
resultSet
,
num
);
for
(
Integer
i
:
resultSet
)
{
for
(
Integer
i
:
resultSet
)
{
summitActivityVo
=
new
SummitActivityVo
();
summitActivityVo
=
new
SummitActivityVo
();
SummitActivity
summitActivity
=
summitActivities
.
get
(
i
);
SummitActivity
summitActivity
=
summitActivities
.
get
(
i
);
...
@@ -206,4 +207,38 @@ public class SummitActivityBiz extends BaseBiz<SummitActivityMapper, SummitActiv
...
@@ -206,4 +207,38 @@ public class SummitActivityBiz extends BaseBiz<SummitActivityMapper, SummitActiv
}
}
return
summitActivityVos
;
return
summitActivityVos
;
}
}
public
PageDataVO
<
SummitActivityVo
>
findSummitActivityWithPage
(
Integer
page
,
Integer
limit
,
Integer
location
)
{
PageDataVO
<
SummitActivityVo
>
dataVO
=
new
PageDataVO
<>();
Example
example
=
new
Example
(
SummitActivity
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
//未删除
criteria
.
andEqualTo
(
"isDel"
,
0
);
//已发布
criteria
.
andEqualTo
(
"isPublish"
,
1
);
//活动未下架
criteria
.
andEqualTo
(
"isShow"
,
1
);
//位置
criteria
.
andIn
(
"location"
,
Arrays
.
asList
(
location
,
0
));
PageDataVO
<
SummitActivity
>
summitActivityPageDataVO
=
PageDataVO
.
pageInfo
(
page
,
limit
,
()
->
mapper
.
selectByExample
(
example
));
List
<
SummitActivity
>
summitActivities
=
summitActivityPageDataVO
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
summitActivities
)){
return
dataVO
;
}
List
<
SummitActivityVo
>
summitActivityVos
=
new
ArrayList
<>();
SummitActivityVo
summitActivityVo
;
for
(
SummitActivity
summitActivity
:
summitActivities
)
{
summitActivityVo
=
new
SummitActivityVo
();
BeanUtils
.
copyProperties
(
summitActivity
,
summitActivityVo
);
summitActivityVos
.
add
(
summitActivityVo
);
}
dataVO
.
setData
(
summitActivityVos
);
dataVO
.
setPageNum
(
summitActivityPageDataVO
.
getPageNum
());
dataVO
.
setPageSize
(
summitActivityPageDataVO
.
getPageSize
());
dataVO
.
setTotalCount
(
summitActivityPageDataVO
.
getTotalCount
());
dataVO
.
setTotalPage
(
summitActivityPageDataVO
.
getTotalPage
());
return
dataVO
;
}
}
}
\ No newline at end of file
xx-uccn/xx-uccn-server/src/main/java/com/xxfc/platform/uccn/rest/ArticleController.java
View file @
a54d4d50
...
@@ -25,7 +25,7 @@ public class ArticleController extends BaseController<ArticleBiz, Article> {
...
@@ -25,7 +25,7 @@ public class ArticleController extends BaseController<ArticleBiz, Article> {
public
ObjectRestResponse
getArticleList
(
public
ObjectRestResponse
getArticleList
(
@RequestParam
(
name
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
name
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
name
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
name
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
name
=
"type"
,
defaultValue
=
"
0
"
)
Integer
type
)
{
@RequestParam
(
name
=
"type"
,
defaultValue
=
"
1
"
)
Integer
type
)
{
return
ObjectRestResponse
.
succ
(
baseBiz
.
getArticleList
(
page
,
limit
,
type
));
return
ObjectRestResponse
.
succ
(
baseBiz
.
getArticleList
(
page
,
limit
,
type
));
}
}
...
...
xx-uccn/xx-uccn-server/src/main/java/com/xxfc/platform/uccn/rest/GwTourController.java
0 → 100644
View file @
a54d4d50
package
com
.
xxfc
.
platform
.
uccn
.
rest
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.rest.CommonBaseController
;
import
com.xxfc.platform.tour.feign.TourFeign
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
@RestController
@RequestMapping
(
"app/unauth/tour"
)
@Slf4j
@IgnoreClientToken
public
class
GwTourController
extends
CommonBaseController
{
@Autowired
TourFeign
tourFeign
;
@ApiOperation
(
"查询旅游路线列表"
)
@RequestMapping
(
value
=
"/getGoodList"
,
method
=
RequestMethod
.
GET
)
@IgnoreUserToken
public
ObjectRestResponse
getGoodList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
value
=
"tagId"
,
required
=
false
)
Integer
tagId
)
{
return
tourFeign
.
getGoodList
(
page
,
limit
,
tagId
);
}
@GetMapping
(
"/detail/{id}"
)
@IgnoreUserToken
public
ObjectRestResponse
getOne
(
@PathVariable
Integer
id
)
{
return
tourFeign
.
getOne
(
id
);
}
@ApiOperation
(
"首页旅游列表"
)
@GetMapping
(
value
=
"/shopList"
)
@IgnoreUserToken
public
ObjectRestResponse
goodListAll
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"4"
)
Integer
limit
)
{
return
ObjectRestResponse
.
succ
(
tourFeign
.
goodListAll
(
page
,
limit
));
}
@GetMapping
(
"/tagList"
)
@IgnoreUserToken
public
ObjectRestResponse
getTagList
(
@RequestParam
(
value
=
"isHot"
,
defaultValue
=
"0"
)
Integer
isHot
)
{
return
ObjectRestResponse
.
succ
(
tourFeign
.
tagList
(
isHot
));
}
}
xx-uccn/xx-uccn-server/src/main/java/com/xxfc/platform/uccn/rest/RandomListController.java
0 → 100644
View file @
a54d4d50
package
com
.
xxfc
.
platform
.
uccn
.
rest
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.uccn.biz.RandomListBiz
;
import
com.xxfc.platform.uccn.dto.RandomListDto
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/random/list"
)
public
class
RandomListController
{
@Autowired
RandomListBiz
randomListBiz
;
@GetMapping
(
"/app/unauth/get"
)
public
ObjectRestResponse
getRandomList
(
RandomListDto
randomListDto
)
{
if
(
randomListDto
==
null
)
{
return
ObjectRestResponse
.
paramIsEmpty
();
}
return
randomListBiz
.
getRandomList
(
randomListDto
.
getType
(),
randomListDto
.
getNumber
(),
randomListDto
.
getLocation
());
}
}
xx-uccn/xx-uccn-server/src/main/java/com/xxfc/platform/uccn/rest/SummitActivityController.java
View file @
a54d4d50
package
com
.
xxfc
.
platform
.
uccn
.
rest
;
package
com
.
xxfc
.
platform
.
uccn
.
rest
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.xxfc.platform.uccn.biz.SummitActivityBiz
;
import
com.xxfc.platform.uccn.biz.SummitActivityBiz
;
import
com.xxfc.platform.uccn.vo.SummitActivityDetailVo
;
import
com.xxfc.platform.uccn.vo.SummitActivityDetailVo
;
import
com.xxfc.platform.uccn.vo.SummitActivityVo
;
import
com.xxfc.platform.uccn.vo.SummitActivityVo
;
...
@@ -15,37 +16,48 @@ import java.util.List;
...
@@ -15,37 +16,48 @@ import java.util.List;
/**
/**
* @author libin
* @author libin
* @version 1.0
* @version 1.0
* @description
* @description
* @data 2019/8/26 15:36
* @data 2019/8/26 15:36
*/
*/
@RestController
@RestController
@RequestMapping
(
"/summitActivity/app/unauth"
)
@RequestMapping
(
"/summitActivity/app/unauth"
)
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
@Api
(
"峰会"
)
@Api
(
"峰会"
)
public
class
SummitActivityController
{
public
class
SummitActivityController
{
private
final
SummitActivityBiz
summitActivityBiz
;
private
final
SummitActivityBiz
summitActivityBiz
;
@ApiOperation
(
"官网首页展示"
)
@ApiOperation
(
"官网首页展示"
)
@GetMapping
(
"/home"
)
@GetMapping
(
"/home"
)
public
ObjectRestResponse
<
List
<
SummitActivityVo
>>
findSummitActivityForHomePage
(
@RequestParam
(
defaultValue
=
"5"
,
required
=
false
)
Integer
limit
,
@RequestParam
(
value
=
"location"
,
defaultValue
=
"1"
,
required
=
false
)
Integer
location
){
public
ObjectRestResponse
<
List
<
SummitActivityVo
>>
findSummitActivityForHomePage
(
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"5"
,
required
=
false
)
Integer
limit
,
@RequestParam
(
value
=
"location"
,
defaultValue
=
"1"
,
required
=
false
)
Integer
location
)
{
List
<
SummitActivityVo
>
summitActivityVos
=
summitActivityBiz
.
findSummitActivityForHomePage
(
limit
,
location
);
return
ObjectRestResponse
.
succ
(
summitActivityVos
);
List
<
SummitActivityVo
>
summitActivityVos
=
summitActivityBiz
.
findSummitActivityForHomePage
(
limit
,
location
);
}
return
ObjectRestResponse
.
succ
(
summitActivityVos
);
}
@ApiOperation
(
"峰会活动详情"
)
@GetMapping
(
"/{id}"
)
@ApiOperation
(
"峰会活动详情"
)
public
ObjectRestResponse
<
SummitActivityDetailVo
>
findSummitActivityDetailById
(
@PathVariable
(
value
=
"id"
)
Integer
id
){
@GetMapping
(
"/{id}"
)
SummitActivityDetailVo
summitActivityDetailVo
=
summitActivityBiz
.
findSummitActivityDetailById
(
id
);
public
ObjectRestResponse
<
SummitActivityDetailVo
>
findSummitActivityDetailById
(
@PathVariable
(
value
=
"id"
)
Integer
id
)
{
return
ObjectRestResponse
.
succ
(
summitActivityDetailVo
);
SummitActivityDetailVo
summitActivityDetailVo
=
summitActivityBiz
.
findSummitActivityDetailById
(
id
);
}
return
ObjectRestResponse
.
succ
(
summitActivityDetailVo
);
}
@ApiOperation
(
"热门推荐获取"
)
@GetMapping
(
"/hot"
)
@ApiOperation
(
"热门推荐获取"
)
public
ObjectRestResponse
<
List
<
SummitActivityVo
>>
findHotWithSummitActivity
(
@RequestParam
(
value
=
"num"
,
required
=
false
,
defaultValue
=
"2"
)
Integer
num
,
@RequestParam
(
value
=
"location"
,
defaultValue
=
"1"
,
required
=
false
)
Integer
location
){
@GetMapping
(
"/hot"
)
List
<
SummitActivityVo
>
summitActivityVos
=
summitActivityBiz
.
getHostWithSummitActivity
(
num
,
location
);
public
ObjectRestResponse
<
List
<
SummitActivityVo
>>
findHotWithSummitActivity
(
@RequestParam
(
value
=
"num"
,
required
=
false
,
defaultValue
=
"2"
)
Integer
num
,
return
ObjectRestResponse
.
succ
(
summitActivityVos
);
@RequestParam
(
value
=
"location"
,
defaultValue
=
"1"
,
required
=
false
)
Integer
location
)
{
}
List
<
SummitActivityVo
>
summitActivityVos
=
summitActivityBiz
.
getHostWithSummitActivity
(
num
,
location
);
return
ObjectRestResponse
.
succ
(
summitActivityVos
);
}
@ApiOperation
(
"官网活动列表"
)
@GetMapping
(
"/list"
)
public
ObjectRestResponse
<
PageDataVO
<
SummitActivityVo
>>
findSummitActivityWithPage
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
,
required
=
false
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"6"
,
required
=
false
)
Integer
limit
,
@RequestParam
(
value
=
"location"
,
defaultValue
=
"0"
,
required
=
false
)
Integer
location
)
{
PageDataVO
<
SummitActivityVo
>
pageDataVO
=
summitActivityBiz
.
findSummitActivityWithPage
(
page
,
limit
,
location
);
return
ObjectRestResponse
.
succ
(
pageDataVO
);
}
}
}
\ No newline at end of file
xx-uccn/xx-uccn-server/src/main/java/com/xxfc/platform/uccn/rest/VehicleModelController.java
View file @
a54d4d50
...
@@ -5,11 +5,13 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
...
@@ -5,11 +5,13 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.rest.CommonBaseController
;
import
com.github.wxiaoqi.security.common.rest.CommonBaseController
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.xxfc.platform.vehicle.entity.VehicleModel
;
import
com.xxfc.platform.vehicle.entity.VehicleModel
;
import
com.xxfc.platform.vehicle.feign.VehicleFeign
;
import
com.xxfc.platform.vehicle.feign.VehicleFeign
;
import
com.xxfc.platform.vehicle.pojo.VModelDetailVO
;
import
com.xxfc.platform.vehicle.pojo.VModelDetailVO
;
import
com.xxfc.platform.vehicle.pojo.VehicleModelQueryCondition
;
import
com.xxfc.platform.vehicle.pojo.VehicleModelQueryCondition
;
import
com.xxfc.platform.vehicle.pojo.VehicleModelVo
;
import
com.xxfc.platform.vehicle.pojo.VehicleModelVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -20,9 +22,10 @@ import org.springframework.web.bind.annotation.*;
...
@@ -20,9 +22,10 @@ import org.springframework.web.bind.annotation.*;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
@RestController
@RestController
@RequestMapping
(
"/vehicleModel"
)
@RequestMapping
(
"/vehicleModel
/app/unauth
"
)
@Slf4j
@Slf4j
@IgnoreClientToken
@IgnoreClientToken
@Api
(
tags
=
"房车车型"
,
value
=
"房车车型"
)
public
class
VehicleModelController
extends
CommonBaseController
{
public
class
VehicleModelController
extends
CommonBaseController
{
@Autowired
@Autowired
...
@@ -50,9 +53,10 @@ public class VehicleModelController extends CommonBaseController {
...
@@ -50,9 +53,10 @@ public class VehicleModelController extends CommonBaseController {
* @return
* @return
*/
*/
@ApiOperation
(
"车型列表"
)
@ApiOperation
(
"车型列表"
)
@
PostMapping
(
value
=
"/app/unauth
/findVehicleModelPage"
)
@
GetMapping
(
value
=
"
/findVehicleModelPage"
)
@IgnoreUserToken
@IgnoreUserToken
public
ObjectRestResponse
<
VehicleModelVo
>
findVehicleModelPageUnauthfind
(
@RequestBody
VehicleModelQueryCondition
vmqc
)
{
public
ObjectRestResponse
<
PageDataVO
<
VehicleModelVo
>>
findVehicleModelPageUnauthfind
(
VehicleModelQueryCondition
vmqc
)
{
return
vehicleFeign
.
findVehicleModelPageUnauthfind
(
vmqc
);
ObjectRestResponse
<
PageDataVO
<
VehicleModelVo
>>
objectRestResponse
=
vehicleFeign
.
findVehicleModelPageUnauthfind
(
vmqc
);
return
objectRestResponse
;
}
}
}
}
xx-vehicle/xx-vehicle-api/src/main/java/com/xxfc/platform/vehicle/feign/VehicleFeign.java
View file @
a54d4d50
...
@@ -2,6 +2,7 @@ package com.xxfc.platform.vehicle.feign;
...
@@ -2,6 +2,7 @@ package com.xxfc.platform.vehicle.feign;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.vo.GoodDataVO
;
import
com.github.wxiaoqi.security.common.vo.GoodDataVO
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.xxfc.platform.vehicle.common.RestResponse
;
import
com.xxfc.platform.vehicle.common.RestResponse
;
import
com.xxfc.platform.vehicle.entity.*
;
import
com.xxfc.platform.vehicle.entity.*
;
import
com.xxfc.platform.vehicle.pojo.*
;
import
com.xxfc.platform.vehicle.pojo.*
;
...
@@ -133,5 +134,5 @@ public interface VehicleFeign {
...
@@ -133,5 +134,5 @@ public interface VehicleFeign {
ObjectRestResponse
<
VModelDetailVO
>
detailByParam
(
@RequestParam
(
"vehicleModel"
)
Map
<
String
,
Object
>
vehicleModel
);
ObjectRestResponse
<
VModelDetailVO
>
detailByParam
(
@RequestParam
(
"vehicleModel"
)
Map
<
String
,
Object
>
vehicleModel
);
@PostMapping
(
"/vehicleModel/app/unauth/findVehicleModelPage"
)
@PostMapping
(
"/vehicleModel/app/unauth/findVehicleModelPage"
)
public
ObjectRestResponse
<
VehicleModelVo
>
findVehicleModelPageUnauthfind
(
@RequestBody
VehicleModelQueryCondition
vmqc
);
public
ObjectRestResponse
<
PageDataVO
<
VehicleModelVo
>
>
findVehicleModelPageUnauthfind
(
@RequestBody
VehicleModelQueryCondition
vmqc
);
}
}
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/BranchCompanyBiz.java
View file @
a54d4d50
...
@@ -85,7 +85,6 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
...
@@ -85,7 +85,6 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
private
VehicleBiz
vehicleBiz
;
private
VehicleBiz
vehicleBiz
;
/**
/**
* 按主键获取公司
* 按主键获取公司
*
*
...
@@ -120,7 +119,7 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
...
@@ -120,7 +119,7 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
* @param id
* @param id
* @return
* @return
*/
*/
@Cache
(
key
=
RedisKey
.
BRANCH_COMPANY_CACHE
+
"{1}"
)
@Cache
(
key
=
RedisKey
.
BRANCH_COMPANY_CACHE
+
"{1}"
)
public
CompanyDetail
getDetailById
(
Integer
id
)
{
public
CompanyDetail
getDetailById
(
Integer
id
)
{
BranchCompany
branchCompany
=
this
.
getById
(
id
);
BranchCompany
branchCompany
=
this
.
getById
(
id
);
CompanyDetail
detail
=
null
;
CompanyDetail
detail
=
null
;
...
@@ -161,35 +160,35 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
...
@@ -161,35 +160,35 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
}
}
public
PageDataVO
<
BranchCompany
>
getAll
(
Integer
page
,
Integer
limit
,
Integer
addrProvince
,
Integer
addrCity
,
public
PageDataVO
<
BranchCompany
>
getAll
(
Integer
page
,
Integer
limit
,
Integer
addrProvince
,
Integer
addrCity
,
Integer
addrTown
,
Integer
zoneId
,
UserDTO
userDTO
)
{
Integer
addrTown
,
Integer
zoneId
,
UserDTO
userDTO
)
{
Example
example
=
new
Example
(
BranchCompany
.
class
);
Example
example
=
new
Example
(
BranchCompany
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
Example
.
Criteria
criteria
=
example
.
createCriteria
();
String
provinceIds
=
""
;
String
provinceIds
=
""
;
if
(
Objects
.
nonNull
(
zoneId
)){
if
(
Objects
.
nonNull
(
zoneId
))
{
Area
area
=
areaBiz
.
selectById
(
zoneId
);
Area
area
=
areaBiz
.
selectById
(
zoneId
);
provinceIds
=
area
.
getProvinceIds
();
provinceIds
=
area
.
getProvinceIds
();
}
}
if
(
StringUtils
.
isNotEmpty
(
provinceIds
)){
if
(
StringUtils
.
isNotEmpty
(
provinceIds
))
{
List
<
String
>
provinceIdList
=
Arrays
.
asList
(
provinceIds
.
split
(
","
));
List
<
String
>
provinceIdList
=
Arrays
.
asList
(
provinceIds
.
split
(
","
));
if
(
Objects
.
nonNull
(
addrProvince
)){
if
(
Objects
.
nonNull
(
addrProvince
))
{
if
(
provinceIdList
.
contains
(
String
.
valueOf
(
addrProvince
))){
if
(
provinceIdList
.
contains
(
String
.
valueOf
(
addrProvince
)))
{
criteria
.
andEqualTo
(
"addrProvince"
,
addrProvince
);
criteria
.
andEqualTo
(
"addrProvince"
,
addrProvince
);
}
else
{
}
else
{
return
new
PageDataVO
<
BranchCompany
>();
return
new
PageDataVO
<
BranchCompany
>();
}
}
}
else
{
}
else
{
criteria
.
andIn
(
"addrProvince"
,
provinceIdList
);
criteria
.
andIn
(
"addrProvince"
,
provinceIdList
);
}
}
}
else
{
}
else
{
if
(
addrProvince
!=
null
)
{
if
(
addrProvince
!=
null
)
{
criteria
.
andEqualTo
(
"addrProvince"
,
addrProvince
);
criteria
.
andEqualTo
(
"addrProvince"
,
addrProvince
);
}
}
}
}
if
(
addrCity
!=
null
)
{
if
(
addrCity
!=
null
)
{
criteria
.
andEqualTo
(
"addrCity"
,
addrCity
);
criteria
.
andEqualTo
(
"addrCity"
,
addrCity
);
}
}
if
(
addrTown
!=
null
)
{
if
(
addrTown
!=
null
)
{
criteria
.
andEqualTo
(
"addrTown"
,
addrTown
);
criteria
.
andEqualTo
(
"addrTown"
,
addrTown
);
}
}
if
(
userDTO
!=
null
&&
DATA_ALL_FALSE
.
equals
(
userDTO
.
getDataAll
()))
{
if
(
userDTO
!=
null
&&
DATA_ALL_FALSE
.
equals
(
userDTO
.
getDataAll
()))
{
if
(
StringUtils
.
isNotBlank
(
userDTO
.
getDataZone
()))
{
if
(
StringUtils
.
isNotBlank
(
userDTO
.
getDataZone
()))
{
...
@@ -361,15 +360,15 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
...
@@ -361,15 +360,15 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
}
}
public
Map
<
Integer
,
BranComanyLeaderVo
>
findCompanyLeaderMapByIds
(
List
<
Integer
>
companyIds
)
{
public
Map
<
Integer
,
BranComanyLeaderVo
>
findCompanyLeaderMapByIds
(
List
<
Integer
>
companyIds
)
{
Map
<
Integer
,
BranComanyLeaderVo
>
companyIdAndLeaderMap
=
new
HashMap
<>(
companyIds
.
size
());
Map
<
Integer
,
BranComanyLeaderVo
>
companyIdAndLeaderMap
=
new
HashMap
<>(
companyIds
.
size
());
List
<
BranchCompany
>
branchCompanies
=
mapper
.
selectByIdList
(
companyIds
);
List
<
BranchCompany
>
branchCompanies
=
mapper
.
selectByIdList
(
companyIds
);
if
(
CollectionUtils
.
isEmpty
(
branchCompanies
)){
if
(
CollectionUtils
.
isEmpty
(
branchCompanies
))
{
return
companyIdAndLeaderMap
;
return
companyIdAndLeaderMap
;
}
}
return
branchCompanies
.
stream
().
collect
(
Collectors
.
toMap
(
BranchCompany:
:
getId
,
branchCompany
->
{
return
branchCompanies
.
stream
().
collect
(
Collectors
.
toMap
(
BranchCompany:
:
getId
,
branchCompany
->
{
BranComanyLeaderVo
branComanyLeaderVo
=
new
BranComanyLeaderVo
();
BranComanyLeaderVo
branComanyLeaderVo
=
new
BranComanyLeaderVo
();
BeanUtils
.
copyProperties
(
branchCompany
,
branComanyLeaderVo
);
BeanUtils
.
copyProperties
(
branchCompany
,
branComanyLeaderVo
);
return
branComanyLeaderVo
;
return
branComanyLeaderVo
;
}));
}));
}
}
...
@@ -377,14 +376,14 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
...
@@ -377,14 +376,14 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
PageDataVO
<
BranchCompanyListVO
>
pageDataVO
=
new
PageDataVO
<>();
PageDataVO
<
BranchCompanyListVO
>
pageDataVO
=
new
PageDataVO
<>();
PageDataVO
<
BranchCompanyListDTO
>
dataVO
=
PageDataVO
.
pageInfo
(
branchCompanyFindDTO
.
getPage
(),
branchCompanyFindDTO
.
getLimit
(),
()
->
mapper
.
findBranchCompanys
(
branchCompanyFindDTO
.
getAddrProvince
(),
branchCompanyFindDTO
.
getAddrCity
()));
PageDataVO
<
BranchCompanyListDTO
>
dataVO
=
PageDataVO
.
pageInfo
(
branchCompanyFindDTO
.
getPage
(),
branchCompanyFindDTO
.
getLimit
(),
()
->
mapper
.
findBranchCompanys
(
branchCompanyFindDTO
.
getAddrProvince
(),
branchCompanyFindDTO
.
getAddrCity
()));
List
<
BranchCompanyListDTO
>
data
=
dataVO
.
getData
();
List
<
BranchCompanyListDTO
>
data
=
dataVO
.
getData
();
if
(
CollectionUtils
.
isEmpty
(
data
)){
if
(
CollectionUtils
.
isEmpty
(
data
))
{
return
pageDataVO
;
return
pageDataVO
;
}
}
List
<
BranchCompanyListVO
>
branchCompanyListVOS
=
new
ArrayList
<>();
List
<
BranchCompanyListVO
>
branchCompanyListVOS
=
new
ArrayList
<>();
BranchCompanyListVO
branchCompanyListVO
;
BranchCompanyListVO
branchCompanyListVO
;
for
(
BranchCompanyListDTO
companyListDTO
:
data
)
{
for
(
BranchCompanyListDTO
companyListDTO
:
data
)
{
branchCompanyListVO
=
new
BranchCompanyListVO
();
branchCompanyListVO
=
new
BranchCompanyListVO
();
BeanUtils
.
copyProperties
(
companyListDTO
,
branchCompanyListVO
);
BeanUtils
.
copyProperties
(
companyListDTO
,
branchCompanyListVO
);
branchCompanyListVOS
.
add
(
branchCompanyListVO
);
branchCompanyListVOS
.
add
(
branchCompanyListVO
);
}
}
pageDataVO
.
setData
(
branchCompanyListVOS
);
pageDataVO
.
setData
(
branchCompanyListVOS
);
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleActiveService.java
View file @
a54d4d50
...
@@ -9,6 +9,7 @@ import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
...
@@ -9,6 +9,7 @@ import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import
com.xxfc.platform.vehicle.entity.*
;
import
com.xxfc.platform.vehicle.entity.*
;
import
com.xxfc.platform.vehicle.mapper.*
;
import
com.xxfc.platform.vehicle.mapper.*
;
import
com.xxfc.platform.vehicle.pojo.*
;
import
com.xxfc.platform.vehicle.pojo.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.joda.time.DateTime
;
import
org.joda.time.DateTime
;
import
org.joda.time.format.DateTimeFormat
;
import
org.joda.time.format.DateTimeFormat
;
...
@@ -20,12 +21,10 @@ import org.springframework.stereotype.Service;
...
@@ -20,12 +21,10 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
java.util.Date
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
@Service
@Slf4j
public
class
VehicleActiveService
{
public
class
VehicleActiveService
{
@Autowired
@Autowired
...
@@ -66,7 +65,7 @@ public class VehicleActiveService {
...
@@ -66,7 +65,7 @@ public class VehicleActiveService {
throw
new
BaseException
(
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getDesc
(),
throw
new
BaseException
(
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getDesc
(),
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getCode
());
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getCode
());
}
}
if
(
StringUtils
.
isBlank
(
departureVo
.
getCheckMan
())
||
StringUtils
.
isBlank
(
departureVo
.
getCheckManTel
()))
{
if
(
StringUtils
.
isBlank
(
departureVo
.
getCheckMan
())
||
StringUtils
.
isBlank
(
departureVo
.
getCheckManTel
()))
{
throw
new
BaseException
(
ResCode
.
CHECKUSER_AND_PHONE_NOT_NULL
.
getDesc
(),
throw
new
BaseException
(
ResCode
.
CHECKUSER_AND_PHONE_NOT_NULL
.
getDesc
(),
ResCode
.
CHECKUSER_AND_PHONE_NOT_NULL
.
getCode
());
ResCode
.
CHECKUSER_AND_PHONE_NOT_NULL
.
getCode
());
}
}
...
@@ -76,13 +75,13 @@ public class VehicleActiveService {
...
@@ -76,13 +75,13 @@ public class VehicleActiveService {
}
}
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
checkDateInvalide
(
departureVo
);
checkDateInvalide
(
departureVo
);
Integer
MileageLift
=
vehicle
.
getMileageLastUpdate
();
Integer
MileageLift
=
vehicle
.
getMileageLastUpdate
();
Integer
MileageLift1
=
departureVo
.
getMileage
();
Integer
MileageLift1
=
departureVo
.
getMileage
();
if
(
MileageLift1
==
null
)
{
if
(
MileageLift1
==
null
)
{
throw
new
BaseException
(
ResCode
.
VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED
.
getDesc
(),
throw
new
BaseException
(
ResCode
.
VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED
.
getDesc
(),
ResCode
.
VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED
.
getCode
());
ResCode
.
VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED
.
getCode
());
}
}
if
(
MileageLift
==
null
||
MileageLift1
>=
MileageLift
)
{
if
(
MileageLift
==
null
||
MileageLift1
>=
MileageLift
)
{
// 写入车辆公里数,预计目的地
// 写入车辆公里数,预计目的地
vehicle
.
setMileageLastUpdate
(
MileageLift1
);
vehicle
.
setMileageLastUpdate
(
MileageLift1
);
vehicle
.
setExpectDestinationBranchCompanyId
(
departureVo
.
getExpectArrivalBranchCompanyId
());
vehicle
.
setExpectDestinationBranchCompanyId
(
departureVo
.
getExpectArrivalBranchCompanyId
());
...
@@ -98,19 +97,19 @@ public class VehicleActiveService {
...
@@ -98,19 +97,19 @@ public class VehicleActiveService {
}
}
//修改预约记录状态
//修改预约记录状态
VehicleBookRecord
vehicleBookRecord
=
null
;
VehicleBookRecord
vehicleBookRecord
=
null
;
if
(
departureVo
.
getBookRecordId
()
!=
null
)
{
if
(
departureVo
.
getBookRecordId
()
!=
null
)
{
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
departureVo
.
getBookRecordId
());
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
departureVo
.
getBookRecordId
());
updateBookRecordStatus
(
vehicleBookRecord
,
1
);
updateBookRecordStatus
(
vehicleBookRecord
,
1
);
}
}
VehicleDepartureLogVo
vehicleDepartureLogVo
=
vehicleDepartureLogMapper
.
selectByBookRecordId
(
departureVo
.
getBookRecordId
());
VehicleDepartureLogVo
vehicleDepartureLogVo
=
vehicleDepartureLogMapper
.
selectByBookRecordId
(
departureVo
.
getBookRecordId
());
if
(
vehicleDepartureLogVo
!=
null
)
{
if
(
vehicleDepartureLogVo
!=
null
)
{
BeanUtil
.
copyProperties
(
departureVo
,
vehicleDepartureLogVo
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
).
setIgnoreError
(
true
));
BeanUtil
.
copyProperties
(
departureVo
,
vehicleDepartureLogVo
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
).
setIgnoreError
(
true
));
VehicleDepartureLog
departureLog
=
vehicleDepartureLogVo
.
getVehicleDeparture
(
vehicleDepartureLogVo
);
VehicleDepartureLog
departureLog
=
vehicleDepartureLogVo
.
getVehicleDeparture
(
vehicleDepartureLogVo
);
departureLog
.
setDepartureTime
(
new
Date
());
departureLog
.
setDepartureTime
(
new
Date
());
departureLog
.
setUpdateTime
(
new
Date
());
departureLog
.
setUpdateTime
(
new
Date
());
departureLog
.
setState
(
VehicleDepartureState
.
DEPARTURE
.
getCode
());
departureLog
.
setState
(
VehicleDepartureState
.
DEPARTURE
.
getCode
());
departureLog
.
setDepartureRemark
(
departureVo
.
getRemark
());
departureLog
.
setDepartureRemark
(
departureVo
.
getRemark
());
if
(
vehicleBookRecord
!=
null
)
{
if
(
vehicleBookRecord
!=
null
)
{
departureLog
.
setDepartureBranchCompanyId
(
vehicleBookRecord
.
getLiftCompany
());
departureLog
.
setDepartureBranchCompanyId
(
vehicleBookRecord
.
getLiftCompany
());
departureLog
.
setUse
(
BookType
.
getByCode
(
vehicleBookRecord
.
getBookType
()));
departureLog
.
setUse
(
BookType
.
getByCode
(
vehicleBookRecord
.
getBookType
()));
departureLog
.
setUser
(
vehicleBookRecord
.
getVehicleUsername
());
departureLog
.
setUser
(
vehicleBookRecord
.
getVehicleUsername
());
...
@@ -127,7 +126,7 @@ public class VehicleActiveService {
...
@@ -127,7 +126,7 @@ public class VehicleActiveService {
departureLog
.
setState
(
VehicleDepartureState
.
DEPARTURE
.
getCode
());
departureLog
.
setState
(
VehicleDepartureState
.
DEPARTURE
.
getCode
());
departureLog
.
setBookRecordId
(
departureVo
.
getBookRecordId
());
departureLog
.
setBookRecordId
(
departureVo
.
getBookRecordId
());
departureLog
.
setDepartureRemark
(
departureVo
.
getRemark
());
departureLog
.
setDepartureRemark
(
departureVo
.
getRemark
());
if
(
vehicleBookRecord
!=
null
)
{
if
(
vehicleBookRecord
!=
null
)
{
departureLog
.
setDepartureBranchCompanyId
(
vehicleBookRecord
.
getLiftCompany
());
departureLog
.
setDepartureBranchCompanyId
(
vehicleBookRecord
.
getLiftCompany
());
departureLog
.
setUse
(
BookType
.
getByCode
(
vehicleBookRecord
.
getBookType
()));
departureLog
.
setUse
(
BookType
.
getByCode
(
vehicleBookRecord
.
getBookType
()));
departureLog
.
setUser
(
vehicleBookRecord
.
getVehicleUsername
());
departureLog
.
setUser
(
vehicleBookRecord
.
getVehicleUsername
());
...
@@ -144,7 +143,7 @@ public class VehicleActiveService {
...
@@ -144,7 +143,7 @@ public class VehicleActiveService {
activeLog
.
setStartTime
(
new
Date
());
activeLog
.
setStartTime
(
new
Date
());
activeLog
.
setCreateTime
(
new
Date
());
activeLog
.
setCreateTime
(
new
Date
());
vehicleActiveLogMapper
.
insert
(
activeLog
);
vehicleActiveLogMapper
.
insert
(
activeLog
);
}
else
{
}
else
{
throw
new
BaseException
(
ResCode
.
VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED
.
getDesc
(),
throw
new
BaseException
(
ResCode
.
VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED
.
getDesc
(),
ResCode
.
VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED
.
getCode
());
ResCode
.
VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED
.
getCode
());
}
}
...
@@ -171,14 +170,20 @@ public class VehicleActiveService {
...
@@ -171,14 +170,20 @@ public class VehicleActiveService {
break
;
break
;
}
}
List
<
VehicleBookRecordVo
>
vehicleBookRecordVos
=
vehicleBookRecordBiz
.
selectByVehicleId
(
vehicleId
);
List
<
VehicleBookRecordVo
>
vehicleBookRecordVos
=
vehicleBookRecordBiz
.
selectByVehicleId
(
vehicleId
);
if
(
vehicleBookRecordVos
!=
null
&&
vehicleBookRecordVos
.
size
()
>
0
&&
vehicleBookRecordVos
.
get
(
0
).
getVehicleDepartureLogVo
()
!=
null
&&
vehicleBookRecordVos
.
get
(
0
).
getVehicleDepartureLogVo
().
getState
()
!=
1
)
{
if
(
vehicleBookRecordVos
!=
null
&&
vehicleBookRecordVos
.
size
()
>
0
)
{
stringBuilder
.
append
(
"中,使用人:"
);
Iterator
<
VehicleBookRecordVo
>
iterator
=
vehicleBookRecordVos
.
iterator
();
stringBuilder
.
append
(
vehicleBookRecordVos
.
get
(
0
).
getVehicleUsername
());
while
(
iterator
.
hasNext
())
{
stringBuilder
.
append
(
" 使用人电话:"
);
VehicleBookRecordVo
vehicleBookRecordVo
=
iterator
.
next
();
stringBuilder
.
append
(
vehicleBookRecordVos
.
get
(
0
).
getVehicleUserPhone
());
if
(
vehicleBookRecordVo
.
getVehicleDepartureLogVo
()
!=
null
&&
vehicleBookRecordVo
.
getVehicleDepartureLogVo
().
getState
()
!=
1
)
{
//已经出车
}
else
{
stringBuilder
.
append
(
"中,使用人:"
);
stringBuilder
.
append
(
"请联系管理员修改车辆状态为正常状态"
);
stringBuilder
.
append
(
vehicleBookRecordVo
.
getVehicleUsername
());
stringBuilder
.
append
(
" 使用人电话:"
);
stringBuilder
.
append
(
vehicleBookRecordVo
.
getVehicleUserPhone
());
return
stringBuilder
.
toString
();
}
}
}
}
stringBuilder
.
append
(
", 请联系管理员修改车辆状态为正常状态"
);
return
stringBuilder
.
toString
();
return
stringBuilder
.
toString
();
}
}
...
@@ -189,7 +194,7 @@ public class VehicleActiveService {
...
@@ -189,7 +194,7 @@ public class VehicleActiveService {
throw
new
BaseException
(
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getDesc
(),
throw
new
BaseException
(
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getDesc
(),
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getCode
());
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getCode
());
}
}
if
(
StringUtils
.
isBlank
(
arrivalVo
.
getRecycleMan
())
||
StringUtils
.
isBlank
(
arrivalVo
.
getRecycleManTel
()))
{
if
(
StringUtils
.
isBlank
(
arrivalVo
.
getRecycleMan
())
||
StringUtils
.
isBlank
(
arrivalVo
.
getRecycleManTel
()))
{
throw
new
BaseException
(
ResCode
.
CHECKUSER_AND_PHONE_NOT_NULL
.
getDesc
(),
throw
new
BaseException
(
ResCode
.
CHECKUSER_AND_PHONE_NOT_NULL
.
getDesc
(),
ResCode
.
CHECKUSER_AND_PHONE_NOT_NULL
.
getCode
());
ResCode
.
CHECKUSER_AND_PHONE_NOT_NULL
.
getCode
());
}
}
...
@@ -205,14 +210,14 @@ public class VehicleActiveService {
...
@@ -205,14 +210,14 @@ public class VehicleActiveService {
}
}
if
(
Mileagerest
!=
null
&&
Mileagerest1
>=
Mileagerest
)
{
if
(
Mileagerest
!=
null
&&
Mileagerest1
>=
Mileagerest
)
{
VehicleBookRecord
vehicleBookRecord
=
null
;
VehicleBookRecord
vehicleBookRecord
=
null
;
if
(
arrivalVo
.
getBookRecordId
()
!=
null
)
{
if
(
arrivalVo
.
getBookRecordId
()
!=
null
)
{
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
arrivalVo
.
getBookRecordId
());
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
arrivalVo
.
getBookRecordId
());
updateBookRecordStatus
(
vehicleBookRecord
,
2
);
updateBookRecordStatus
(
vehicleBookRecord
,
2
);
}
}
// 写入车辆公里数,还车分公司id
// 写入车辆公里数,还车分公司id
vehicle
.
setMileageLastUpdate
(
Mileagerest1
);
vehicle
.
setMileageLastUpdate
(
Mileagerest1
);
if
(
vehicleBookRecord
!=
null
)
{
if
(
vehicleBookRecord
!=
null
)
{
vehicle
.
setParkBranchCompanyId
(
vehicleBookRecord
.
getRetCompany
());
vehicle
.
setParkBranchCompanyId
(
vehicleBookRecord
.
getRetCompany
());
}
}
vehicle
.
setExpectDestinationBranchCompanyId
(
0
);
vehicle
.
setExpectDestinationBranchCompanyId
(
0
);
...
@@ -236,7 +241,7 @@ public class VehicleActiveService {
...
@@ -236,7 +241,7 @@ public class VehicleActiveService {
DateTime
arrivalDate
=
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
());
DateTime
arrivalDate
=
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
());
DateTime
actualArrivalDate
=
new
DateTime
(
new
Date
());
DateTime
actualArrivalDate
=
new
DateTime
(
new
Date
());
//提前还车处理
//提前还车处理
if
(
actualArrivalDate
.
compareTo
(
arrivalDate
)
<
0
)
{
//实际还车时间小于预计还车时间,需要释放后面的时间
if
(
actualArrivalDate
.
compareTo
(
arrivalDate
)
<
0
)
{
//实际还车时间小于预计还车时间,需要释放后面的时间
BookVehicleVO
bookVehicleVo
=
new
BookVehicleVO
();
BookVehicleVO
bookVehicleVo
=
new
BookVehicleVO
();
BeanUtils
.
copyProperties
(
vehicleBookRecord
,
bookVehicleVo
);
BeanUtils
.
copyProperties
(
vehicleBookRecord
,
bookVehicleVo
);
bookVehicleVo
.
setNotCheckTimeLegal
(
Boolean
.
TRUE
);
bookVehicleVo
.
setNotCheckTimeLegal
(
Boolean
.
TRUE
);
...
@@ -246,10 +251,10 @@ public class VehicleActiveService {
...
@@ -246,10 +251,10 @@ public class VehicleActiveService {
bookVehicleVo
.
setUnbookEndDate
(
arrivalDate
.
toString
(
DATE_TIME_FORMATTER
));
bookVehicleVo
.
setUnbookEndDate
(
arrivalDate
.
toString
(
DATE_TIME_FORMATTER
));
try
{
try
{
Boolean
hasSuc
=
vehicleBiz
.
unbookVehicle
(
bookVehicleVo
);
Boolean
hasSuc
=
vehicleBiz
.
unbookVehicle
(
bookVehicleVo
);
if
(!
hasSuc
)
{
if
(!
hasSuc
)
{
throw
new
BaseException
(
ResCode
.
VEHICLE_UNBOOK_FAIL
.
getDesc
(),
ResCode
.
VEHICLE_UNBOOK_FAIL
.
getCode
());
throw
new
BaseException
(
ResCode
.
VEHICLE_UNBOOK_FAIL
.
getDesc
(),
ResCode
.
VEHICLE_UNBOOK_FAIL
.
getCode
());
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
...
@@ -264,7 +269,7 @@ public class VehicleActiveService {
...
@@ -264,7 +269,7 @@ public class VehicleActiveService {
departureLog
.
setIllegalAmount
(
arrivalVo
.
getIllegalAmount
());
departureLog
.
setIllegalAmount
(
arrivalVo
.
getIllegalAmount
());
departureLog
.
setArrivalPic
(
arrivalVo
.
getArrivalPic
());
departureLog
.
setArrivalPic
(
arrivalVo
.
getArrivalPic
());
departureLog
.
setArrivalRemark
(
arrivalVo
.
getRemark
());
departureLog
.
setArrivalRemark
(
arrivalVo
.
getRemark
());
if
(
vehicleBookRecord
!=
null
)
{
if
(
vehicleBookRecord
!=
null
)
{
departureLog
.
setArrivalBranchCompanyId
(
vehicleBookRecord
.
getRetCompany
());
departureLog
.
setArrivalBranchCompanyId
(
vehicleBookRecord
.
getRetCompany
());
}
}
vehicleDepartureLogMapper
.
updateByPrimaryKeySelective
(
departureLog
);
vehicleDepartureLogMapper
.
updateByPrimaryKeySelective
(
departureLog
);
...
@@ -302,15 +307,24 @@ public class VehicleActiveService {
...
@@ -302,15 +307,24 @@ public class VehicleActiveService {
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
public
void
checkDateInvalide
(
VehicleDepartureVo
arrivalVo
)
{
public
void
checkDateInvalide
(
VehicleDepartureVo
arrivalVo
)
{
if
(
arrivalVo
.
getBookRecordId
()
!=
null
)
{
if
(
arrivalVo
.
getBookRecordId
()
!=
null
)
{
VehicleBookRecord
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
arrivalVo
.
getBookRecordId
());
VehicleBookRecord
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
arrivalVo
.
getBookRecordId
());
if
(
vehicleBookRecord
!=
null
)
{
if
(
vehicleBookRecord
!=
null
)
{
DateTime
startDate
=
new
DateTime
(
vehicleBookRecord
.
getBookStartDate
());
DateTime
startDate
=
new
DateTime
(
vehicleBookRecord
.
getBookStartDate
());
DateTime
endDate
=
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
());
DateTime
endDate
=
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
());
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"vehicleId"
,
vehicleBookRecord
.
getVehicleId
());
param
.
put
(
"vehicleId"
,
vehicleBookRecord
.
getVehicleId
());
param
.
put
(
"bookedEndDate"
,
vehicleBookRecord
.
getBookStartDate
());
param
.
put
(
"bookedEndDate"
,
vehicleBookRecord
.
getBookStartDate
());
List
<
VehicleBookRecordVo
>
list
=
vehicleBookRecordBiz
.
selectByVehicleIdAndTime
(
param
);
List
<
VehicleBookRecordVo
>
list
=
vehicleBookRecordBiz
.
selectByVehicleIdAndTime
(
param
);
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
Iterator
<
VehicleBookRecordVo
>
iterator
=
list
.
iterator
();
while
(
iterator
.
hasNext
())
{
VehicleBookRecordVo
vehicleBookRecordVo
=
iterator
.
next
();
if
(
vehicleBookRecordVo
.
getVehicleDepartureLogVo
()
==
null
&&
vehicleBookRecordVo
.
getBookEndDate
().
getTime
()
-
new
Date
().
getTime
()
<
0
)
{
iterator
.
remove
();
}
}
}
if
(!(
startDate
.
minusDays
(
1
).
compareTo
(
DateTime
.
now
())
<=
0
&&
DateTime
.
now
().
compareTo
(
endDate
)
<=
0
&&
vehicleBookRecord
.
getStatus
()
==
VehicleBookRecordStatus
.
APPROVE
.
getCode
()
&&
(
list
==
null
||
list
.
size
()
<=
0
)))
{
if
(!(
startDate
.
minusDays
(
1
).
compareTo
(
DateTime
.
now
())
<=
0
&&
DateTime
.
now
().
compareTo
(
endDate
)
<=
0
&&
vehicleBookRecord
.
getStatus
()
==
VehicleBookRecordStatus
.
APPROVE
.
getCode
()
&&
(
list
==
null
||
list
.
size
()
<=
0
)))
{
throw
new
BaseException
(
ResCode
.
VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED
.
getDesc
(),
throw
new
BaseException
(
ResCode
.
VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED
.
getDesc
(),
ResCode
.
VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED
.
getCode
());
ResCode
.
VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED
.
getCode
());
...
@@ -322,8 +336,8 @@ public class VehicleActiveService {
...
@@ -322,8 +336,8 @@ public class VehicleActiveService {
public
void
updateBookRecordStatus
(
VehicleBookRecord
vehicleBookRecord
,
Integer
type
)
{
public
void
updateBookRecordStatus
(
VehicleBookRecord
vehicleBookRecord
,
Integer
type
)
{
if
(
vehicleBookRecord
!=
null
)
{
if
(
vehicleBookRecord
!=
null
)
{
if
(
type
==
1
)
{
if
(
type
==
1
)
{
vehicleBookRecord
.
setActualStartDate
(
new
Date
());
vehicleBookRecord
.
setActualStartDate
(
new
Date
());
}
else
{
}
else
{
vehicleBookRecord
.
setActualEndDate
(
new
Date
());
vehicleBookRecord
.
setActualEndDate
(
new
Date
());
...
@@ -354,9 +368,9 @@ public class VehicleActiveService {
...
@@ -354,9 +368,9 @@ public class VehicleActiveService {
throw
new
BaseException
(
ResCode
.
VEHICLE_UPKEEP_VEHICLE_DISABLE
.
getDesc
(),
throw
new
BaseException
(
ResCode
.
VEHICLE_UPKEEP_VEHICLE_DISABLE
.
getDesc
(),
ResCode
.
VEHICLE_UPKEEP_VEHICLE_DISABLE
.
getCode
());
ResCode
.
VEHICLE_UPKEEP_VEHICLE_DISABLE
.
getCode
());
}
}
Integer
lastMileage
=
vehicleUpkeepVo
.
getMileage
();
Integer
lastMileage
=
vehicleUpkeepVo
.
getMileage
();
int
result
=
vehicleMapper
.
upMileageByIdAndStatus
(
vehicleUpkeepVo
.
getVehicleId
(),
VehicleStatus
.
UPKEEP
.
getCode
(),
int
result
=
vehicleMapper
.
upMileageByIdAndStatus
(
vehicleUpkeepVo
.
getVehicleId
(),
VehicleStatus
.
UPKEEP
.
getCode
(),
VehicleStatus
.
NORMAL
.
getCode
(),
lastMileage
);
VehicleStatus
.
NORMAL
.
getCode
(),
lastMileage
);
if
(
result
==
0
)
{
if
(
result
==
0
)
{
// 车辆状态异常
// 车辆状态异常
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
...
@@ -407,9 +421,9 @@ public class VehicleActiveService {
...
@@ -407,9 +421,9 @@ public class VehicleActiveService {
throw
new
BaseException
(
ResCode
.
VEHICLE_UPKEEP_VEHICLE_UNUPKEEP
.
getDesc
(),
throw
new
BaseException
(
ResCode
.
VEHICLE_UPKEEP_VEHICLE_UNUPKEEP
.
getDesc
(),
ResCode
.
VEHICLE_UPKEEP_VEHICLE_UNUPKEEP
.
getCode
());
ResCode
.
VEHICLE_UPKEEP_VEHICLE_UNUPKEEP
.
getCode
());
}
}
Integer
mileageLastUpdate
=
vehicle
.
getMileageLastUpdate
()==
null
?
0
:
vehicle
.
getMileageLastUpdate
();
Integer
mileageLastUpdate
=
vehicle
.
getMileageLastUpdate
()
==
null
?
0
:
vehicle
.
getMileageLastUpdate
();
Integer
maintenance_mileage
=
Mileage
+
mileageLastUpdate
;
Integer
maintenance_mileage
=
Mileage
+
mileageLastUpdate
;
int
result
=
vehicleMapper
.
updateMileageStatusByIdAndStatus
(
vehicleId
,
VehicleStatus
.
NORMAL
.
getCode
(),
VehicleStatus
.
UPKEEP
.
getCode
(),
maintenance_mileage
);
int
result
=
vehicleMapper
.
updateMileageStatusByIdAndStatus
(
vehicleId
,
VehicleStatus
.
NORMAL
.
getCode
(),
VehicleStatus
.
UPKEEP
.
getCode
(),
maintenance_mileage
);
if
(
result
==
0
)
{
if
(
result
==
0
)
{
throw
new
BaseException
(
ResCode
.
VEHICLE_UPKEEP_VEHICLE_UNUPKEEP
.
getDesc
(),
throw
new
BaseException
(
ResCode
.
VEHICLE_UPKEEP_VEHICLE_UNUPKEEP
.
getDesc
(),
ResCode
.
VEHICLE_UPKEEP_VEHICLE_UNUPKEEP
.
getCode
());
ResCode
.
VEHICLE_UPKEEP_VEHICLE_UNUPKEEP
.
getCode
());
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleBiz.java
View file @
a54d4d50
...
@@ -99,9 +99,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -99,9 +99,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
}
@Value
(
"${vehicle.baseUploadPath}"
)
@Value
(
"${vehicle.baseUploadPath}"
)
private
String
baseUploadPath
;
private
String
baseUploadPath
;
@Value
(
"${vehicle.fristMileage}"
)
@Value
(
"${vehicle.fristMileage}"
)
private
Integer
fristMileage
;
private
Integer
fristMileage
;
/**
/**
* 每批次最大更、插入车辆最大条目数
* 每批次最大更、插入车辆最大条目数
...
@@ -110,17 +110,18 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -110,17 +110,18 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 写入上传文件,返回相对路径
* 写入上传文件,返回相对路径
*
* @param file
* @param file
* @return
* @return
*/
*/
public
RestResponse
<
String
>
uploadDrivingLicense
(
MultipartFile
file
)
throws
Exception
{
public
RestResponse
<
String
>
uploadDrivingLicense
(
MultipartFile
file
)
throws
Exception
{
//创建本日存放目录
//创建本日存放目录
DateTime
now
=
DateTime
.
now
();
DateTime
now
=
DateTime
.
now
();
String
dirPathToday
=
File
.
separator
+
now
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
String
dirPathToday
=
File
.
separator
+
now
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
String
redisNoKey
=
RedisKey
.
UPLOAD_FILE_NO_PREFIX
+
now
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
String
redisNoKey
=
RedisKey
.
UPLOAD_FILE_NO_PREFIX
+
now
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
Long
no
=
customRedisTemplate
.
opsForValue
().
increment
(
redisNoKey
);
Long
no
=
customRedisTemplate
.
opsForValue
().
increment
(
redisNoKey
);
if
(
no
.
equals
(
1
l
))
{
if
(
no
.
equals
(
1
l
))
{
customRedisTemplate
.
expire
(
redisNoKey
,
1
,
TimeUnit
.
DAYS
);
customRedisTemplate
.
expire
(
redisNoKey
,
1
,
TimeUnit
.
DAYS
);
}
}
String
fileName
=
file
.
getOriginalFilename
();
String
fileName
=
file
.
getOriginalFilename
();
String
realFileRelPath
=
dirPathToday
+
File
.
separator
+
no
+
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
));
String
realFileRelPath
=
dirPathToday
+
File
.
separator
+
no
+
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
));
...
@@ -133,11 +134,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -133,11 +134,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 下载行驶证图片
* 下载行驶证图片
*
* @param realFileRelPath
* @param realFileRelPath
* @return
* @return
* @throws Exception
* @throws Exception
*/
*/
public
ResponseEntity
<
byte
[]>
downloadDrivingLicense
(
String
realFileRelPath
)
throws
Exception
{
public
ResponseEntity
<
byte
[]>
downloadDrivingLicense
(
String
realFileRelPath
)
throws
Exception
{
String
filePath
=
baseUploadPath
+
realFileRelPath
;
String
filePath
=
baseUploadPath
+
realFileRelPath
;
File
file
=
new
File
(
filePath
);
//新建一个文件
File
file
=
new
File
(
filePath
);
//新建一个文件
...
@@ -145,37 +147,39 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -145,37 +147,39 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
String
downloadFileName
=
new
String
(
file
.
getName
());
//设置编码
String
downloadFileName
=
new
String
(
file
.
getName
());
//设置编码
headers
.
setContentDispositionFormData
(
"attachment"
,
downloadFileName
);
headers
.
setContentDispositionFormData
(
"attachment"
,
downloadFileName
);
headers
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM
);
headers
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM
);
return
new
ResponseEntity
<
byte
[]>(
FileUtils
.
readFileToByteArray
(
file
),
headers
,
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<
byte
[]>(
FileUtils
.
readFileToByteArray
(
file
),
headers
,
HttpStatus
.
CREATED
);
}
}
// @Cache(key = "vehical")
// @Cache(key = "vehical")
public
Vehicle
get
(
String
id
){
public
Vehicle
get
(
String
id
)
{
Vehicle
vehicle
=
mapper
.
selectByPrimaryKey
(
id
);
Vehicle
vehicle
=
mapper
.
selectByPrimaryKey
(
id
);
return
vehicle
;
return
vehicle
;
}
}
/**
/**
* 获取相关预订记录
* 获取相关预订记录
*
* @param vehicle
* @param vehicle
* @param yearMonth
* @param yearMonth
* @return
* @return
*/
*/
public
VehicleBookInfo
getByVehicleIdAndYearMonth
(
String
vehicle
,
String
yearMonth
)
{
public
VehicleBookInfo
getByVehicleIdAndYearMonth
(
String
vehicle
,
String
yearMonth
)
{
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
params
.
put
(
"vehicle"
,
vehicle
);
params
.
put
(
"vehicle"
,
vehicle
);
params
.
put
(
"yearMonth"
,
yearMonth
);
params
.
put
(
"yearMonth"
,
yearMonth
);
List
<
VehicleBookInfo
>
vehicleBookInfoList
=
vehicleBookInfoMapper
.
getByVehicleIdAndYearMonth
(
params
);
List
<
VehicleBookInfo
>
vehicleBookInfoList
=
vehicleBookInfoMapper
.
getByVehicleIdAndYearMonth
(
params
);
return
CollectionUtils
.
isEmpty
(
vehicleBookInfoList
)
?
null
:
vehicleBookInfoList
.
get
(
0
);
return
CollectionUtils
.
isEmpty
(
vehicleBookInfoList
)
?
null
:
vehicleBookInfoList
.
get
(
0
);
}
}
/**
/**
* 获取相关预订记录
* 获取相关预订记录
*
* @param vehicle
* @param vehicle
* @return
* @return
*/
*/
public
List
<
VehicleBookInfo
>
getByVehicleIdAndYearMonth
(
String
vehicle
){
public
List
<
VehicleBookInfo
>
getByVehicleIdAndYearMonth
(
String
vehicle
)
{
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
params
.
put
(
"vehicle"
,
vehicle
);
params
.
put
(
"vehicle"
,
vehicle
);
params
.
put
(
"yearMonths"
,
params
.
put
(
"yearMonths"
,
Lists
.
newArrayList
(
Lists
.
newArrayList
(
DateTime
.
now
().
toString
(
YEARMONTH_DATE_TIME_FORMATTER
),
DateTime
.
now
().
toString
(
YEARMONTH_DATE_TIME_FORMATTER
),
...
@@ -190,7 +194,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -190,7 +194,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 检查常量是否合法
* 检查常量是否合法
*/
*/
private
void
checkIfConstantValid
(
AddOrUpdateVehicleVo
addOrUpdateVehicleVo
){
private
void
checkIfConstantValid
(
AddOrUpdateVehicleVo
addOrUpdateVehicleVo
)
{
//检查常量是否合法
//检查常量是否合法
if
(
addOrUpdateVehicleVo
.
getUseType
()
!=
null
&&
addOrUpdateVehicleVo
.
getUseType
()
>
0
)
{
if
(
addOrUpdateVehicleVo
.
getUseType
()
!=
null
&&
addOrUpdateVehicleVo
.
getUseType
()
>
0
)
{
constantBiz
.
checkIfExists
(
ConstantType
.
VEHICLE_USE
.
getCode
(),
addOrUpdateVehicleVo
.
getUseType
());
constantBiz
.
checkIfExists
(
ConstantType
.
VEHICLE_USE
.
getCode
(),
addOrUpdateVehicleVo
.
getUseType
());
...
@@ -202,30 +206,31 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -202,30 +206,31 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 增加车辆
* 增加车辆
*
* @param addOrUpdateVehicleVoList
* @param addOrUpdateVehicleVoList
*/
*/
@Transactional
@Transactional
public
RestResponse
add
(
List
<
AddOrUpdateVehicleVo
>
addOrUpdateVehicleVoList
)
throws
Exception
{
public
RestResponse
add
(
List
<
AddOrUpdateVehicleVo
>
addOrUpdateVehicleVoList
)
throws
Exception
{
if
(
addOrUpdateVehicleVoList
.
size
()>
MAX_BATCH_SIZE_VEHICLE
)
{
if
(
addOrUpdateVehicleVoList
.
size
()
>
MAX_BATCH_SIZE_VEHICLE
)
{
throw
new
BaseException
(
ResultCode
.
ADD_VEHICLE_MORE
);
throw
new
BaseException
(
ResultCode
.
ADD_VEHICLE_MORE
);
}
}
for
(
AddOrUpdateVehicleVo
addOrUpdateVehicleVo:
addOrUpdateVehicleVoList
)
{
for
(
AddOrUpdateVehicleVo
addOrUpdateVehicleVo
:
addOrUpdateVehicleVoList
)
{
Vehicle
vehicle
=
new
Vehicle
();
Vehicle
vehicle
=
new
Vehicle
();
BeanUtilsBean
.
getInstance
().
copyProperties
(
vehicle
,
addOrUpdateVehicleVo
);
BeanUtilsBean
.
getInstance
().
copyProperties
(
vehicle
,
addOrUpdateVehicleVo
);
if
(
addOrUpdateVehicleVo
.
getParkBranchCompanyId
()
==
null
)
{
if
(
addOrUpdateVehicleVo
.
getParkBranchCompanyId
()
==
null
)
{
throw
new
BaseException
(
ResultCode
.
RET_COMPANY_CAN_NOT_BE_NULL
);
throw
new
BaseException
(
ResultCode
.
RET_COMPANY_CAN_NOT_BE_NULL
);
}
}
vehicle
.
setId
(
UUID
.
randomUUID
().
toString
());
vehicle
.
setId
(
UUID
.
randomUUID
().
toString
());
// 检查车牌或者编码是否已存在,已存在则返回失败
// 检查车牌或者编码是否已存在,已存在则返回失败
List
<
Vehicle
>
exitsVehicles
=
lockByCode
(
addOrUpdateVehicleVo
);
List
<
Vehicle
>
exitsVehicles
=
lockByCode
(
addOrUpdateVehicleVo
);
if
(
CollectionUtils
.
isNotEmpty
(
exitsVehicles
))
{
if
(
CollectionUtils
.
isNotEmpty
(
exitsVehicles
))
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_INFO_SAME_NUM_PLATE_EXISTS
.
getCode
(),
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_INFO_SAME_NUM_PLATE_EXISTS
.
getCode
(),
ResCode
.
VEHICLE_INFO_SAME_NUM_PLATE_EXISTS
.
getDesc
());
ResCode
.
VEHICLE_INFO_SAME_NUM_PLATE_EXISTS
.
getDesc
());
// if(addOrUpdateVehicleVo.getCode()!= null &&
// if(addOrUpdateVehicleVo.getCode()!= null &&
// addOrUpdateVehicleVo.getCode().equals(exitsVehicles.get(0).getCode())){
// addOrUpdateVehicleVo.getCode().equals(exitsVehicles.get(0).getCode())){
...
@@ -242,15 +247,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -242,15 +247,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 此方法必须置于事务中以使锁生效
* 此方法必须置于事务中以使锁生效
* 符合查询条件记录的修改活且相关记录的锁获取操作将被锁定
* 符合查询条件记录的修改活且相关记录的锁获取操作将被锁定
*
* @param addOrUpdateVehicleVo
* @param addOrUpdateVehicleVo
* @return 锁定成功返回
* @return 锁定成功返回
*/
*/
private
List
<
Vehicle
>
lockByCode
(
AddOrUpdateVehicleVo
addOrUpdateVehicleVo
)
throws
CustomIllegalParamException
{
private
List
<
Vehicle
>
lockByCode
(
AddOrUpdateVehicleVo
addOrUpdateVehicleVo
)
throws
CustomIllegalParamException
{
// if(addOrUpdateVehicleVo.getCode() == null){
// if(addOrUpdateVehicleVo.getCode() == null){
// return null;
// return null;
// }
// }
if
(
addOrUpdateVehicleVo
.
getNumberPlate
()
==
null
)
{
if
(
addOrUpdateVehicleVo
.
getNumberPlate
()
==
null
)
{
throw
new
BaseException
(
ResultCode
.
NUMBER_PLAT_CAN_NOT_BE_NULL
);
throw
new
BaseException
(
ResultCode
.
NUMBER_PLAT_CAN_NOT_BE_NULL
);
}
}
List
<
Vehicle
>
vehicles
=
mapper
.
lockByCode
(
addOrUpdateVehicleVo
);
List
<
Vehicle
>
vehicles
=
mapper
.
lockByCode
(
addOrUpdateVehicleVo
);
...
@@ -259,27 +265,28 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -259,27 +265,28 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 修改汽车信息
* 修改汽车信息
*
* @param addOrUpdateVehicleVoList
* @param addOrUpdateVehicleVoList
* @return
* @return
*/
*/
@Transactional
@Transactional
public
RestResponse
update
(
List
<
AddOrUpdateVehicleVo
>
addOrUpdateVehicleVoList
)
throws
Exception
{
public
RestResponse
update
(
List
<
AddOrUpdateVehicleVo
>
addOrUpdateVehicleVoList
)
throws
Exception
{
if
(
addOrUpdateVehicleVoList
.
size
()>
MAX_BATCH_SIZE_VEHICLE
)
{
if
(
addOrUpdateVehicleVoList
.
size
()
>
MAX_BATCH_SIZE_VEHICLE
)
{
throw
new
BaseException
(
ResultCode
.
ADD_VEHICLE_MORE
);
throw
new
BaseException
(
ResultCode
.
ADD_VEHICLE_MORE
);
}
}
for
(
AddOrUpdateVehicleVo
addOrUpdateVehicleVo:
addOrUpdateVehicleVoList
)
{
for
(
AddOrUpdateVehicleVo
addOrUpdateVehicleVo
:
addOrUpdateVehicleVoList
)
{
Vehicle
vehicle
=
new
Vehicle
();
Vehicle
vehicle
=
new
Vehicle
();
BeanUtilsBean
.
getInstance
().
copyProperties
(
vehicle
,
addOrUpdateVehicleVo
);
BeanUtilsBean
.
getInstance
().
copyProperties
(
vehicle
,
addOrUpdateVehicleVo
);
if
(
addOrUpdateVehicleVo
.
getParkBranchCompanyId
()
==
null
)
{
if
(
addOrUpdateVehicleVo
.
getParkBranchCompanyId
()
==
null
)
{
throw
new
BaseException
(
ResultCode
.
RET_COMPANY_CAN_NOT_BE_NULL
);
throw
new
BaseException
(
ResultCode
.
RET_COMPANY_CAN_NOT_BE_NULL
);
}
}
//悲观锁,检查是否已存在车牌或编码
//悲观锁,检查是否已存在车牌或编码
List
<
Vehicle
>
exitsVehicles
=
lockByCode
(
addOrUpdateVehicleVo
);
List
<
Vehicle
>
exitsVehicles
=
lockByCode
(
addOrUpdateVehicleVo
);
if
(
CollectionUtils
.
isNotEmpty
(
exitsVehicles
))
{
if
(
CollectionUtils
.
isNotEmpty
(
exitsVehicles
))
{
for
(
Vehicle
exitsVehicle:
exitsVehicles
)
{
for
(
Vehicle
exitsVehicle
:
exitsVehicles
)
{
if
(
exitsVehicle
.
getId
().
equals
(
addOrUpdateVehicleVo
.
getId
()))
{
if
(
exitsVehicle
.
getId
().
equals
(
addOrUpdateVehicleVo
.
getId
()))
{
continue
;
continue
;
}
}
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_INFO_SAME_NUM_PLATE_EXISTS
.
getCode
(),
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_INFO_SAME_NUM_PLATE_EXISTS
.
getCode
(),
...
@@ -300,15 +307,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -300,15 +307,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 废弃车辆(状态设置为废弃)
* 废弃车辆(状态设置为废弃)
*
* @param idList
* @param idList
* @return
* @return
*/
*/
public
RestResponse
discard
(
List
<
String
>
idList
){
public
RestResponse
discard
(
List
<
String
>
idList
)
{
if
(
idList
.
size
()>
MAX_BATCH_SIZE_VEHICLE
)
{
if
(
idList
.
size
()
>
MAX_BATCH_SIZE_VEHICLE
)
{
throw
new
BaseException
(
ResultCode
.
ADD_VEHICLE_MORE
);
throw
new
BaseException
(
ResultCode
.
ADD_VEHICLE_MORE
);
}
}
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
params
.
put
(
"idList"
,
idList
);
params
.
put
(
"idList"
,
idList
);
params
.
put
(
"status"
,
VehicleStatus
.
DISCARD
.
getCode
());
params
.
put
(
"status"
,
VehicleStatus
.
DISCARD
.
getCode
());
mapper
.
updateStatusById
(
params
);
mapper
.
updateStatusById
(
params
);
return
RestResponse
.
suc
();
return
RestResponse
.
suc
();
...
@@ -405,6 +413,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -405,6 +413,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 不需要审核
* 不需要审核
*
* @param userId
* @param userId
* @param bookVehicleVo
* @param bookVehicleVo
* @param userName
* @param userName
...
@@ -412,11 +421,11 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -412,11 +421,11 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
* @throws Exception
* @throws Exception
*/
*/
@Transactional
@Transactional
public
VehicleBookRecord
applyVehicle
(
Integer
userId
,
BookVehicleVO
bookVehicleVo
,
String
userName
)
throws
Exception
{
public
VehicleBookRecord
applyVehicle
(
Integer
userId
,
BookVehicleVO
bookVehicleVo
,
String
userName
)
throws
Exception
{
log
.
info
(
"预定车辆参数:userId = {}, bookVehicleVo = {},username = {}"
,
userId
,
bookVehicleVo
,
userName
);
log
.
info
(
"预定车辆参数:userId = {}, bookVehicleVo = {},username = {}"
,
userId
,
bookVehicleVo
,
userName
);
//检查车辆信息是否合法
//检查车辆信息是否合法
Vehicle
vehicle
=
mapper
.
selectByPrimaryKey
(
bookVehicleVo
.
getVehicleId
());
Vehicle
vehicle
=
mapper
.
selectByPrimaryKey
(
bookVehicleVo
.
getVehicleId
());
if
(
vehicle
==
null
)
{
if
(
vehicle
==
null
)
{
throw
new
BaseException
(
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getDesc
(),
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getCode
());
throw
new
BaseException
(
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getDesc
(),
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_UNEXIST
.
getCode
());
}
}
if
(
vehicle
.
getStatus
().
equals
(
VehicleStatus
.
DISCARD
.
getCode
()))
{
if
(
vehicle
.
getStatus
().
equals
(
VehicleStatus
.
DISCARD
.
getCode
()))
{
...
@@ -427,16 +436,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -427,16 +436,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
throw
new
BaseException
(
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_DELETE
.
getDesc
(),
throw
new
BaseException
(
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_DELETE
.
getDesc
(),
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_DELETE
.
getCode
());
ResCode
.
VEHICLE_DEPARTURE_VEHICLE_DELETE
.
getCode
());
}
}
if
(
StringUtils
.
isBlank
(
bookVehicleVo
.
getBookStartDate
())
||
StringUtils
.
isBlank
(
bookVehicleVo
.
getBookEndDate
()))
{
if
(
StringUtils
.
isBlank
(
bookVehicleVo
.
getBookStartDate
())
||
StringUtils
.
isBlank
(
bookVehicleVo
.
getBookEndDate
()))
{
throw
new
BaseException
(
ResultCode
.
DATE_TIME_IS_NULL
);
throw
new
BaseException
(
ResultCode
.
DATE_TIME_IS_NULL
);
}
}
//提取日期和相应的预定目标日期
//提取日期和相应的预定目标日期
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
Maps
.
newHashMap
();
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
Maps
.
newHashMap
();
DateTime
startDay
=
DateTime
.
parse
(
bookVehicleVo
.
getBookStartDate
(),
DATE_TIME_FORMATTER
);
DateTime
startDay
=
DateTime
.
parse
(
bookVehicleVo
.
getBookStartDate
(),
DATE_TIME_FORMATTER
);
DateTime
endDay
=
DateTime
.
parse
(
bookVehicleVo
.
getBookEndDate
(),
DATE_TIME_FORMATTER
);
DateTime
endDay
=
DateTime
.
parse
(
bookVehicleVo
.
getBookEndDate
(),
DATE_TIME_FORMATTER
);
//转换日期范围为列表,并检查是否合法
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod
(
yearMonthAndDate
,
DateTime
.
parse
(
startDay
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
DEFAULT_DATE_TIME_FORMATTER
),
DateTime
.
parse
(
endDay
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
DEFAULT_DATE_TIME_FORMATTER
));
fillDateList4DatePeriod
(
yearMonthAndDate
,
DateTime
.
parse
(
startDay
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
DEFAULT_DATE_TIME_FORMATTER
),
DateTime
.
parse
(
endDay
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
DEFAULT_DATE_TIME_FORMATTER
));
if
(
yearMonthAndDate
.
size
()>
3
)
{
//连续的日期最多夸3个月
if
(
yearMonthAndDate
.
size
()
>
3
)
{
//连续的日期最多夸3个月
throw
new
BaseException
(
ResultCode
.
ONLY_BOOK_TWO_MONTH
);
throw
new
BaseException
(
ResultCode
.
ONLY_BOOK_TWO_MONTH
);
}
}
...
@@ -444,9 +453,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -444,9 +453,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map
<
String
,
Integer
>
map
=
new
HashMap
<>();
Map
<
String
,
Integer
>
map
=
new
HashMap
<>();
//加入预定申请记录
//加入预定申请记录
VehicleBookRecord
vehicleBookRecord
=
null
;
VehicleBookRecord
vehicleBookRecord
=
null
;
if
(
bookVehicleVo
.
getVehicleBookRecordId
()
==
null
)
{
if
(
bookVehicleVo
.
getVehicleBookRecordId
()
==
null
)
{
//检验时间是否可以预定
//检验时间是否可以预定
map
=
vehicleBookHourInfoBiz
.
getPredictableHours
(
bookVehicleVo
.
getBookStartDate
(),
bookVehicleVo
.
getBookEndDate
(),
bookVehicleVo
.
getNotCheckTimeLegal
());
map
=
vehicleBookHourInfoBiz
.
getPredictableHours
(
bookVehicleVo
.
getBookStartDate
(),
bookVehicleVo
.
getBookEndDate
(),
bookVehicleVo
.
getNotCheckTimeLegal
());
vehicleBookRecord
=
new
VehicleBookRecord
();
vehicleBookRecord
=
new
VehicleBookRecord
();
BeanUtil
.
copyProperties
(
bookVehicleVo
,
vehicleBookRecord
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
).
setIgnoreError
(
true
));
BeanUtil
.
copyProperties
(
bookVehicleVo
,
vehicleBookRecord
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
).
setIgnoreError
(
true
));
vehicleBookRecord
.
setBookStartDate
(
startDay
.
toDate
());
vehicleBookRecord
.
setBookStartDate
(
startDay
.
toDate
());
...
@@ -458,35 +467,35 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -458,35 +467,35 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
vehicleBookRecordBiz
.
save
(
vehicleBookRecord
);
vehicleBookRecordBiz
.
save
(
vehicleBookRecord
);
}
else
{
}
else
{
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
bookVehicleVo
.
getVehicleBookRecordId
());
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
bookVehicleVo
.
getVehicleBookRecordId
());
if
(
vehicleBookRecord
==
null
)
{
if
(
vehicleBookRecord
==
null
)
{
throw
new
BaseException
(
ResCode
.
VEHICLE_BOOKED_RECORD_NOT_EXIST
.
getDesc
(),
ResCode
.
VEHICLE_BOOKED_RECORD_NOT_EXIST
.
getCode
());
throw
new
BaseException
(
ResCode
.
VEHICLE_BOOKED_RECORD_NOT_EXIST
.
getDesc
(),
ResCode
.
VEHICLE_BOOKED_RECORD_NOT_EXIST
.
getCode
());
}
else
{
}
else
{
//先取消预定,然后再修改
//先取消预定,然后再修改
//先取消之前预定时间,然后再修改
//先取消之前预定时间,然后再修改
bookVehicleVo
.
setUnbookStartDate
(
new
DateTime
(
vehicleBookRecord
.
getBookStartDate
()).
toString
(
DATE_TIME_FORMATTER
));
bookVehicleVo
.
setUnbookStartDate
(
new
DateTime
(
vehicleBookRecord
.
getBookStartDate
()).
toString
(
DATE_TIME_FORMATTER
));
bookVehicleVo
.
setUnbookEndDate
(
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
()).
toString
(
DATE_TIME_FORMATTER
));
bookVehicleVo
.
setUnbookEndDate
(
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
()).
toString
(
DATE_TIME_FORMATTER
));
unbookVehicle
(
bookVehicleVo
);
unbookVehicle
(
bookVehicleVo
);
//检验时间是否可以预定
//检验时间是否可以预定
map
=
vehicleBookHourInfoBiz
.
getPredictableHours
(
bookVehicleVo
.
getBookStartDate
(),
bookVehicleVo
.
getBookEndDate
(),
bookVehicleVo
.
getNotCheckTimeLegal
());
map
=
vehicleBookHourInfoBiz
.
getPredictableHours
(
bookVehicleVo
.
getBookStartDate
(),
bookVehicleVo
.
getBookEndDate
(),
bookVehicleVo
.
getNotCheckTimeLegal
());
vehicleBookRecord
.
setBookStartDate
(
startDay
.
toDate
());
vehicleBookRecord
.
setBookStartDate
(
startDay
.
toDate
());
vehicleBookRecord
.
setBookEndDate
(
endDay
.
toDate
());
vehicleBookRecord
.
setBookEndDate
(
endDay
.
toDate
());
vehicleBookRecordBiz
.
updateSelectiveByIdRe
(
vehicleBookRecord
);
vehicleBookRecordBiz
.
updateSelectiveByIdRe
(
vehicleBookRecord
);
}
}
}
}
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
yearMonthAndDate
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
yearMonthAndDate
.
entrySet
())
{
Boolean
rsEach
=
applyVehicle4EmployeePerMonth
(
bookVehicleVo
.
getVehicleId
(),
entry
.
getValue
(),
entry
.
getKey
(),
map
);
Boolean
rsEach
=
applyVehicle4EmployeePerMonth
(
bookVehicleVo
.
getVehicleId
(),
entry
.
getValue
(),
entry
.
getKey
(),
map
);
if
(
Boolean
.
FALSE
.
equals
(
rsEach
))
{
if
(
Boolean
.
FALSE
.
equals
(
rsEach
))
{
throw
new
BaseException
(
ResultCode
.
VEHICLE_IS_BOOKED
);
throw
new
BaseException
(
ResultCode
.
VEHICLE_IS_BOOKED
);
}
}
}
}
//添加预定日期记录
//添加预定日期记录
Boolean
hasSuc
=
bookedVehicle
(
bookVehicleVo
);
Boolean
hasSuc
=
bookedVehicle
(
bookVehicleVo
);
if
(!
hasSuc
)
{
if
(!
hasSuc
)
{
throw
new
BaseException
(
ResultCode
.
BOOKED_FAILED_CODE
);
throw
new
BaseException
(
ResultCode
.
BOOKED_FAILED_CODE
);
}
}
// //添加预定时间记录
// //添加预定时间记录
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
map
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
map
.
entrySet
())
{
VehicleBookHourInfoDto
vehicleBookHourInfoDto
=
new
VehicleBookHourInfoDto
();
VehicleBookHourInfoDto
vehicleBookHourInfoDto
=
new
VehicleBookHourInfoDto
();
vehicleBookHourInfoDto
.
setVehicleId
(
bookVehicleVo
.
getVehicleId
());
vehicleBookHourInfoDto
.
setVehicleId
(
bookVehicleVo
.
getVehicleId
());
vehicleBookHourInfoDto
.
setYearMonthDay
(
entry
.
getKey
());
vehicleBookHourInfoDto
.
setYearMonthDay
(
entry
.
getKey
());
...
@@ -495,13 +504,13 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -495,13 +504,13 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
}
//添加随车物品
//添加随车物品
List
<
Map
<
String
,
Object
>>
params
=
Lists
.
newArrayList
();
List
<
Map
<
String
,
Object
>>
params
=
Lists
.
newArrayList
();
if
(
MapUtils
.
isNotEmpty
(
bookVehicleVo
.
getSelectedAccItem
()))
{
if
(
MapUtils
.
isNotEmpty
(
bookVehicleVo
.
getSelectedAccItem
()))
{
for
(
Map
.
Entry
<
Integer
,
Integer
>
idAndAmount
:
bookVehicleVo
.
getSelectedAccItem
().
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
Integer
>
idAndAmount
:
bookVehicleVo
.
getSelectedAccItem
().
entrySet
())
{
Map
<
String
,
Object
>
row
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
row
=
Maps
.
newHashMap
();
row
.
put
(
"id"
,
idAndAmount
.
getKey
());
row
.
put
(
"id"
,
idAndAmount
.
getKey
());
row
.
put
(
"amount"
,
idAndAmount
.
getValue
());
row
.
put
(
"amount"
,
idAndAmount
.
getValue
());
row
.
put
(
"bookRecordId"
,
vehicleBookRecord
.
getId
());
row
.
put
(
"bookRecordId"
,
vehicleBookRecord
.
getId
());
params
.
add
(
row
);
params
.
add
(
row
);
}
}
bookRecordAccItemMapper
.
batchAdd
(
params
);
bookRecordAccItemMapper
.
batchAdd
(
params
);
...
@@ -512,21 +521,21 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -512,21 +521,21 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
@Transactional
@Transactional
public
Boolean
applyVehicle4EmployeePerMonth
(
String
vehicleId
,
List
<
String
>
bookedDates
,
String
yearMonth
,
Map
<
String
,
Integer
>
hourInfo
){
public
Boolean
applyVehicle4EmployeePerMonth
(
String
vehicleId
,
List
<
String
>
bookedDates
,
String
yearMonth
,
Map
<
String
,
Integer
>
hourInfo
)
{
//检查车辆是否有空档
//检查车辆是否有空档
//获得当月预定记录
//获得当月预定记录
VehicleBookInfo
vehicleBookInfo
=
getByVehicleIdAndYearMonth
(
vehicleId
,
yearMonth
);
VehicleBookInfo
vehicleBookInfo
=
getByVehicleIdAndYearMonth
(
vehicleId
,
yearMonth
);
//位操作确定目标日期是否可预订
//位操作确定目标日期是否可预订
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
yearMonthAndDate
.
put
(
yearMonth
,
bookedDates
);
yearMonthAndDate
.
put
(
yearMonth
,
bookedDates
);
fillBookedDateSearchParam
(
params
,
null
,
yearMonthAndDate
);
//转换为查询对应日期未预定的条件
fillBookedDateSearchParam
(
params
,
null
,
yearMonthAndDate
);
//转换为查询对应日期未预定的条件
Map
<
String
,
Map
<
String
,
Integer
>>
yearMonthAndParam
=
(
Map
<
String
,
Map
<
String
,
Integer
>>)
params
.
get
(
"yearMonthAndParam"
);
Map
<
String
,
Map
<
String
,
Integer
>>
yearMonthAndParam
=
(
Map
<
String
,
Map
<
String
,
Integer
>>)
params
.
get
(
"yearMonthAndParam"
);
Map
<
String
,
Integer
>
andOpratorParam
=
yearMonthAndParam
.
get
(
yearMonth
);
Map
<
String
,
Integer
>
andOpratorParam
=
yearMonthAndParam
.
get
(
yearMonth
);
Integer
andOperationFactor
=
andOpratorParam
.
get
(
"andOperationFactor"
);
Integer
andOperationFactor
=
andOpratorParam
.
get
(
"andOperationFactor"
);
Integer
andOperationRs
=
andOpratorParam
.
get
(
"andOperationRs"
);
Integer
andOperationRs
=
andOpratorParam
.
get
(
"andOperationRs"
);
if
(
vehicleBookInfo
!=
null
&&
vehicleBookInfo
.
getBookedDate
()
!=
null
&&
if
(
vehicleBookInfo
!=
null
&&
vehicleBookInfo
.
getBookedDate
()
!=
null
&&
((
vehicleBookInfo
.
getBookedDate
()
&
andOperationFactor
)
!=
0
)){
//已经被预定
((
vehicleBookInfo
.
getBookedDate
()
&
andOperationFactor
)
!=
0
))
{
//已经被预定
//当天已经被预定检查小时是否也被预定
//当天已经被预定检查小时是否也被预定
return
filterHourInfoBooked
(
vehicleId
,
hourInfo
);
return
filterHourInfoBooked
(
vehicleId
,
hourInfo
);
}
}
...
@@ -535,16 +544,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -535,16 +544,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public
boolean
filterHourInfoBooked
(
String
vehicleId
,
Map
<
String
,
Integer
>
hourInfo
)
{
public
boolean
filterHourInfoBooked
(
String
vehicleId
,
Map
<
String
,
Integer
>
hourInfo
)
{
if
(
MapUtils
.
isEmpty
(
hourInfo
))
{
if
(
MapUtils
.
isEmpty
(
hourInfo
))
{
return
false
;
return
false
;
}
}
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
hourInfo
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
hourInfo
.
entrySet
())
{
if
(
entry
.
getValue
()
==
0
)
{
//0点 查询是否有已经预约的记录
if
(
entry
.
getValue
()
==
0
)
{
//0点 查询是否有已经预约的记录
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"vehicleId"
,
vehicleId
);
param
.
put
(
"vehicleId"
,
vehicleId
);
param
.
put
(
"bookedEndDate"
,
DateTime
.
parse
(
entry
.
getKey
()
+
" 00:00:00"
,
DATE_TIME_FORMATTER
));
param
.
put
(
"bookedEndDate"
,
DateTime
.
parse
(
entry
.
getKey
()
+
" 00:00:00"
,
DATE_TIME_FORMATTER
));
List
<
VehicleBookRecordVo
>
vehicleBookRecordVos
=
vehicleBookRecordBiz
.
selectZeroHourRecord
(
param
);
List
<
VehicleBookRecordVo
>
vehicleBookRecordVos
=
vehicleBookRecordBiz
.
selectZeroHourRecord
(
param
);
if
(
vehicleBookRecordVos
!=
null
&&
vehicleBookRecordVos
.
size
()
>
0
)
{
if
(
vehicleBookRecordVos
!=
null
&&
vehicleBookRecordVos
.
size
()
>
0
)
{
return
false
;
return
false
;
}
}
}
}
...
@@ -552,8 +561,8 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -552,8 +561,8 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
vehicleBookHourInfoDto
.
setYearMonthDay
(
entry
.
getKey
());
vehicleBookHourInfoDto
.
setYearMonthDay
(
entry
.
getKey
());
vehicleBookHourInfoDto
.
setVehicleId
(
vehicleId
);
vehicleBookHourInfoDto
.
setVehicleId
(
vehicleId
);
List
<
VehicleBookHourInfo
>
vehicleBookHourInfos
=
vehicleBookHourInfoBiz
.
selectByVehicleAndDate
(
vehicleBookHourInfoDto
);
List
<
VehicleBookHourInfo
>
vehicleBookHourInfos
=
vehicleBookHourInfoBiz
.
selectByVehicleAndDate
(
vehicleBookHourInfoDto
);
if
(
vehicleBookHourInfos
!=
null
&&
vehicleBookHourInfos
.
size
()
>
0
)
{
if
(
vehicleBookHourInfos
!=
null
&&
vehicleBookHourInfos
.
size
()
>
0
)
{
if
((
vehicleBookHourInfos
.
get
(
0
).
getBookedHour
()
&
entry
.
getValue
())
!=
0
)
{
// 已经被预定
if
((
vehicleBookHourInfos
.
get
(
0
).
getBookedHour
()
&
entry
.
getValue
())
!=
0
)
{
// 已经被预定
log
.
info
(
entry
.
getKey
()
+
"预定的时间段已经被预约!"
);
log
.
info
(
entry
.
getKey
()
+
"预定的时间段已经被预约!"
);
return
Boolean
.
FALSE
;
return
Boolean
.
FALSE
;
}
}
...
@@ -564,48 +573,49 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -564,48 +573,49 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 批准预定车辆预定
* 批准预定车辆预定
*
* @param operatorId
* @param operatorId
* @param bookRecordId
* @param bookRecordId
* @return
* @return
*/
*/
@Transactional
@Transactional
public
RestResponse
<
Integer
>
reviewVehicleBooking
(
Integer
operatorId
,
Long
bookRecordId
,
Integer
rsStatus
,
String
userName
,
String
rejectRemark
,
Boolean
notCheckTimeLegal
)
throws
Exception
{
public
RestResponse
<
Integer
>
reviewVehicleBooking
(
Integer
operatorId
,
Long
bookRecordId
,
Integer
rsStatus
,
String
userName
,
String
rejectRemark
,
Boolean
notCheckTimeLegal
)
throws
Exception
{
try
{
try
{
//获取相关申请记录
//获取相关申请记录
VehicleBookRecord
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
bookRecordId
);
VehicleBookRecord
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
bookRecordId
);
//申请记录验证
//申请记录验证
if
(
vehicleBookRecord
==
null
)
{
if
(
vehicleBookRecord
==
null
)
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_BOOK_RECORD_IS_NOT_EXIST
.
getCode
(),
ResCode
.
VEHICLE_BOOK_RECORD_IS_NOT_EXIST
.
getDesc
());
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_BOOK_RECORD_IS_NOT_EXIST
.
getCode
(),
ResCode
.
VEHICLE_BOOK_RECORD_IS_NOT_EXIST
.
getDesc
());
}
}
if
(
VehicleBookRecordStatus
.
APPROVE
.
getCode
().
equals
(
vehicleBookRecord
.
getStatus
()))
{
if
(
VehicleBookRecordStatus
.
APPROVE
.
getCode
().
equals
(
vehicleBookRecord
.
getStatus
()))
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getCode
(),
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getDesc
());
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getCode
(),
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getDesc
());
}
}
//转换为相应预定参数
//转换为相应预定参数
BookVehicleVO
bookVehicleVo
=
new
BookVehicleVO
();
BookVehicleVO
bookVehicleVo
=
new
BookVehicleVO
();
BeanUtils
.
copyProperties
(
bookVehicleVo
,
vehicleBookRecord
);
BeanUtils
.
copyProperties
(
bookVehicleVo
,
vehicleBookRecord
);
bookVehicleVo
.
setBookStartDate
(
new
DateTime
(
vehicleBookRecord
.
getBookStartDate
()).
toString
(
DATE_TIME_FORMATTER
));
bookVehicleVo
.
setBookStartDate
(
new
DateTime
(
vehicleBookRecord
.
getBookStartDate
()).
toString
(
DATE_TIME_FORMATTER
));
bookVehicleVo
.
setBookEndDate
(
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
()).
toString
(
DATE_TIME_FORMATTER
));
bookVehicleVo
.
setBookEndDate
(
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
()).
toString
(
DATE_TIME_FORMATTER
));
//成功后修改预定记录状态
//成功后修改预定记录状态
Map
<
String
,
Object
>
updateParam
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
updateParam
=
Maps
.
newHashMap
();
updateParam
.
put
(
"id"
,
bookRecordId
);
updateParam
.
put
(
"id"
,
bookRecordId
);
updateParam
.
put
(
"status"
,
rsStatus
);
updateParam
.
put
(
"status"
,
rsStatus
);
updateParam
.
put
(
"reviewerApply"
,
operatorId
);
updateParam
.
put
(
"reviewerApply"
,
operatorId
);
updateParam
.
put
(
"reviewerNameApply"
,
userName
);
updateParam
.
put
(
"reviewerNameApply"
,
userName
);
updateParam
.
put
(
"statusCondition"
,
VehicleBookRecordStatus
.
APPLY
.
getCode
());
updateParam
.
put
(
"statusCondition"
,
VehicleBookRecordStatus
.
APPLY
.
getCode
());
if
(
StringUtils
.
isNotBlank
(
rejectRemark
))
{
if
(
StringUtils
.
isNotBlank
(
rejectRemark
))
{
updateParam
.
put
(
"rejectRemark"
,
rejectRemark
);
updateParam
.
put
(
"rejectRemark"
,
rejectRemark
);
}
}
Integer
effected
=
vehicleBookRecordBiz
.
changeRecordStatus
(
updateParam
);
Integer
effected
=
vehicleBookRecordBiz
.
changeRecordStatus
(
updateParam
);
if
(
effected
==
0
)
{
//修改失败,手动回滚
if
(
effected
==
0
)
{
//修改失败,手动回滚
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
//手动回滚
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
//手动回滚
return
RestResponse
.
code
(
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getCode
());
return
RestResponse
.
code
(
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getCode
());
}
else
if
(
VehicleBookRecordStatus
.
REJECTED
.
getCode
().
equals
(
rsStatus
))
{
}
else
if
(
VehicleBookRecordStatus
.
REJECTED
.
getCode
().
equals
(
rsStatus
))
{
//拒绝,则释放bookinfo
//拒绝,则释放bookinfo
bookVehicleVo
.
setUnbookStartDate
(
bookVehicleVo
.
getBookStartDate
());
bookVehicleVo
.
setUnbookStartDate
(
bookVehicleVo
.
getBookStartDate
());
bookVehicleVo
.
setUnbookEndDate
(
bookVehicleVo
.
getBookEndDate
());
bookVehicleVo
.
setUnbookEndDate
(
bookVehicleVo
.
getBookEndDate
());
Boolean
hasSuc
=
unbookVehicle
(
bookVehicleVo
);
Boolean
hasSuc
=
unbookVehicle
(
bookVehicleVo
);
if
(
hasSuc
)
{
if
(
hasSuc
)
{
return
RestResponse
.
suc
();
return
RestResponse
.
suc
();
}
}
}
}
...
@@ -618,23 +628,24 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -618,23 +628,24 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 取消预定
* 取消预定
*
* @return
* @return
*/
*/
@Transactional
@Transactional
public
RestResponse
unbookVehicle4Employee
(
Integer
operatorId
,
Long
bookRecordId
,
String
userName
,
String
rejectRemark
,
Boolean
notCheckTimeLegal
)
throws
Exception
{
public
RestResponse
unbookVehicle4Employee
(
Integer
operatorId
,
Long
bookRecordId
,
String
userName
,
String
rejectRemark
,
Boolean
notCheckTimeLegal
)
throws
Exception
{
//获取相关申请记录
//获取相关申请记录
VehicleBookRecord
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
bookRecordId
);
VehicleBookRecord
vehicleBookRecord
=
vehicleBookRecordBiz
.
selectById
(
bookRecordId
);
//申请记录验证
//申请记录验证
if
(
vehicleBookRecord
==
null
)
{
if
(
vehicleBookRecord
==
null
)
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_BOOK_RECORD_IS_NOT_EXIST
.
getCode
(),
ResCode
.
VEHICLE_BOOK_RECORD_IS_NOT_EXIST
.
getDesc
());
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_BOOK_RECORD_IS_NOT_EXIST
.
getCode
(),
ResCode
.
VEHICLE_BOOK_RECORD_IS_NOT_EXIST
.
getDesc
());
}
}
//已通过审核的可以取消预定
//已通过审核的可以取消预定
if
(!
VehicleBookRecordStatus
.
APPROVE
.
getCode
().
equals
(
vehicleBookRecord
.
getStatus
()))
{
if
(!
VehicleBookRecordStatus
.
APPROVE
.
getCode
().
equals
(
vehicleBookRecord
.
getStatus
()))
{
return
RestResponse
.
code
(
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getCode
());
return
RestResponse
.
code
(
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getCode
());
}
}
//转换为相应取消预定参数
//转换为相应取消预定参数
BookVehicleVO
bookVehicleVo
=
new
BookVehicleVO
();
BookVehicleVO
bookVehicleVo
=
new
BookVehicleVO
();
BeanUtils
.
copyProperties
(
bookVehicleVo
,
vehicleBookRecord
);
BeanUtils
.
copyProperties
(
bookVehicleVo
,
vehicleBookRecord
);
bookVehicleVo
.
setNotCheckTimeLegal
(
notCheckTimeLegal
);
bookVehicleVo
.
setNotCheckTimeLegal
(
notCheckTimeLegal
);
bookVehicleVo
.
setBookStartDate
(
null
);
bookVehicleVo
.
setBookStartDate
(
null
);
bookVehicleVo
.
setBookEndDate
(
null
);
bookVehicleVo
.
setBookEndDate
(
null
);
...
@@ -642,21 +653,21 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -642,21 +653,21 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
bookVehicleVo
.
setUnbookEndDate
(
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
()).
toString
(
DATE_TIME_FORMATTER
));
bookVehicleVo
.
setUnbookEndDate
(
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
()).
toString
(
DATE_TIME_FORMATTER
));
//取消预定
//取消预定
Boolean
hasSuc
=
unbookVehicle
(
bookVehicleVo
);
Boolean
hasSuc
=
unbookVehicle
(
bookVehicleVo
);
if
(!
hasSuc
)
{
if
(!
hasSuc
)
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_UNBOOK_FAIL
.
getCode
(),
ResCode
.
VEHICLE_UNBOOK_FAIL
.
getDesc
());
return
RestResponse
.
codeAndMessage
(
ResCode
.
VEHICLE_UNBOOK_FAIL
.
getCode
(),
ResCode
.
VEHICLE_UNBOOK_FAIL
.
getDesc
());
}
}
//修改预定状态,写入取消人
//修改预定状态,写入取消人
Map
<
String
,
Object
>
updateParam
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
updateParam
=
Maps
.
newHashMap
();
updateParam
.
put
(
"id"
,
bookRecordId
);
updateParam
.
put
(
"id"
,
bookRecordId
);
updateParam
.
put
(
"status"
,
VehicleBookRecordStatus
.
CANCEL_APPLY
.
getCode
());
updateParam
.
put
(
"status"
,
VehicleBookRecordStatus
.
CANCEL_APPLY
.
getCode
());
updateParam
.
put
(
"reviewerCancel"
,
operatorId
);
updateParam
.
put
(
"reviewerCancel"
,
operatorId
);
updateParam
.
put
(
"reviewerNameCancel"
,
userName
);
updateParam
.
put
(
"reviewerNameCancel"
,
userName
);
updateParam
.
put
(
"statusCondition"
,
VehicleBookRecordStatus
.
APPROVE
.
getCode
());
updateParam
.
put
(
"statusCondition"
,
VehicleBookRecordStatus
.
APPROVE
.
getCode
());
if
(
StringUtils
.
isNotBlank
(
rejectRemark
))
{
if
(
StringUtils
.
isNotBlank
(
rejectRemark
))
{
updateParam
.
put
(
"rejectRemark"
,
rejectRemark
);
updateParam
.
put
(
"rejectRemark"
,
rejectRemark
);
}
}
Integer
effected
=
vehicleBookRecordBiz
.
changeRecordStatus
(
updateParam
);
Integer
effected
=
vehicleBookRecordBiz
.
changeRecordStatus
(
updateParam
);
if
(
effected
==
0
)
{
//修改失败,手动回滚
if
(
effected
==
0
)
{
//修改失败,手动回滚
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
//手动回滚
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
//手动回滚
return
RestResponse
.
code
(
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getCode
());
return
RestResponse
.
code
(
ResCode
.
VEHICLE_BOOKED_RECORD_ALREADY_CHANGED
.
getCode
());
}
}
...
@@ -675,54 +686,56 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -675,54 +686,56 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 获取预定车辆相关与操作参数
* 获取预定车辆相关与操作参数
*
* @return
* @return
*/
*/
private
Integer
getBitOpratorFactor4Booked
(
List
<
String
>
dates
){
private
Integer
getBitOpratorFactor4Booked
(
List
<
String
>
dates
)
{
Integer
andOperationFactor
=
0
;
Integer
andOperationFactor
=
0
;
for
(
String
dateStr
:
dates
)
{
//已预定作为条件,该位与1作与运算必定为1
for
(
String
dateStr
:
dates
)
{
//已预定作为条件,该位与1作与运算必定为1
DateTime
dateTime
=
DateTime
.
parse
(
dateStr
,
DEFAULT_DATE_TIME_FORMATTER
);
DateTime
dateTime
=
DateTime
.
parse
(
dateStr
,
DEFAULT_DATE_TIME_FORMATTER
);
//仅对应位为1的整形值
//仅对应位为1的整形值
andOperationFactor
|=
1
<<(
dateTime
.
dayOfMonth
().
get
()-
1
);
andOperationFactor
|=
1
<<
(
dateTime
.
dayOfMonth
().
get
()
-
1
);
}
}
return
andOperationFactor
;
return
andOperationFactor
;
}
}
/**
/**
* 获取预定车辆相关与操作参数
* 获取预定车辆相关与操作参数
*
* @return
* @return
*/
*/
private
Integer
getBitOpratorFactor4UnBooked
(
List
<
String
>
dates
){
private
Integer
getBitOpratorFactor4UnBooked
(
List
<
String
>
dates
)
{
Integer
andOperationFactor
=
Integer
.
MAX_VALUE
;
Integer
andOperationFactor
=
Integer
.
MAX_VALUE
;
for
(
String
dateStr
:
dates
)
{
//已预定作为条件,该位与1作与运算必定为1
for
(
String
dateStr
:
dates
)
{
//已预定作为条件,该位与1作与运算必定为1
DateTime
dateTime
=
DateTime
.
parse
(
dateStr
,
DEFAULT_DATE_TIME_FORMATTER
);
DateTime
dateTime
=
DateTime
.
parse
(
dateStr
,
DEFAULT_DATE_TIME_FORMATTER
);
//仅对应位为1的整形值
//仅对应位为1的整形值
andOperationFactor
^=
1
<<(
dateTime
.
dayOfMonth
().
get
()-
1
);
andOperationFactor
^=
1
<<
(
dateTime
.
dayOfMonth
().
get
()
-
1
);
}
}
return
andOperationFactor
;
return
andOperationFactor
;
}
}
/**
/**
* 根据预定日期逐条修改预定记录
* 根据预定日期逐条修改预定记录
*
* @param bookVehicleVo
* @param bookVehicleVo
* @return
* @return
*/
*/
@Transactional
@Transactional
public
Boolean
bookedVehicle
(
BookVehicleVO
bookVehicleVo
)
throws
Exception
{
public
Boolean
bookedVehicle
(
BookVehicleVO
bookVehicleVo
)
throws
Exception
{
//提取日期和相应的预定目标日期
//提取日期和相应的预定目标日期
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
Maps
.
newHashMap
();
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
Maps
.
newHashMap
();
DateTime
startDay
=
DateTime
.
parse
(
bookVehicleVo
.
getBookStartDate
(),
DATE_TIME_FORMATTER
);
DateTime
startDay
=
DateTime
.
parse
(
bookVehicleVo
.
getBookStartDate
(),
DATE_TIME_FORMATTER
);
DateTime
endDay
=
DateTime
.
parse
(
bookVehicleVo
.
getBookEndDate
(),
DATE_TIME_FORMATTER
);
DateTime
endDay
=
DateTime
.
parse
(
bookVehicleVo
.
getBookEndDate
(),
DATE_TIME_FORMATTER
);
//转换日期范围为列表,并检查是否合法
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod
(
yearMonthAndDate
,
startDay
,
endDay
);
fillDateList4DatePeriod
(
yearMonthAndDate
,
startDay
,
endDay
);
if
(
yearMonthAndDate
.
size
()>
3
)
{
//连续的日期最多夸3个月
if
(
yearMonthAndDate
.
size
()
>
3
)
{
//连续的日期最多夸3个月
throw
new
BaseException
(
ResultCode
.
ONLY_BOOK_TWO_MONTH
);
throw
new
BaseException
(
ResultCode
.
ONLY_BOOK_TWO_MONTH
);
}
}
Boolean
rs
=
Boolean
.
TRUE
;
Boolean
rs
=
Boolean
.
TRUE
;
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry:
yearMonthAndDate
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
yearMonthAndDate
.
entrySet
())
{
Boolean
rsEach
=
bookedVehiclePerMonth
(
bookVehicleVo
.
getVehicleId
(),
entry
.
getValue
(),
entry
.
getKey
());
Boolean
rsEach
=
bookedVehiclePerMonth
(
bookVehicleVo
.
getVehicleId
(),
entry
.
getValue
(),
entry
.
getKey
());
if
(
Boolean
.
FALSE
.
equals
(
rsEach
))
{
if
(
Boolean
.
FALSE
.
equals
(
rsEach
))
{
rs
=
Boolean
.
FALSE
;
rs
=
Boolean
.
FALSE
;
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
//手动回滚
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
//手动回滚
}
}
...
@@ -732,13 +745,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -732,13 +745,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 不存在插入、存在更新,利用唯一索引确保相同车辆以及年月序列化提交事务
* 不存在插入、存在更新,利用唯一索引确保相同车辆以及年月序列化提交事务
*
* @param vehicleId
* @param vehicleId
* @param bookedDates
* @param bookedDates
* @param yearMonth
* @param yearMonth
* @return 是否更新或插入成功
* @return 是否更新或插入成功
*/
*/
@Transactional
@Transactional
public
Boolean
bookedVehiclePerMonth
(
String
vehicleId
,
List
<
String
>
bookedDates
,
String
yearMonth
)
throws
Exception
{
public
Boolean
bookedVehiclePerMonth
(
String
vehicleId
,
List
<
String
>
bookedDates
,
String
yearMonth
)
throws
Exception
{
VehicleBookInfo
vehicleBookInfo
=
new
VehicleBookInfo
();
VehicleBookInfo
vehicleBookInfo
=
new
VehicleBookInfo
();
vehicleBookInfo
.
setVehicle
(
vehicleId
);
vehicleBookInfo
.
setVehicle
(
vehicleId
);
vehicleBookInfo
.
setYearMonth
(
yearMonth
);
vehicleBookInfo
.
setYearMonth
(
yearMonth
);
...
@@ -746,47 +760,48 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -746,47 +760,48 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
checkIfVehicleExists
(
vehicleId
);
checkIfVehicleExists
(
vehicleId
);
Integer
orRsOperationFactor
=
getBitOpratorFactor4Booked
(
bookedDates
);
//预定的相关或运算因子,当前月份没有预定记录时同时也是结果
Integer
orRsOperationFactor
=
getBitOpratorFactor4Booked
(
bookedDates
);
//预定的相关或运算因子,当前月份没有预定记录时同时也是结果
vehicleBookInfo
.
setBookedDate
(
orRsOperationFactor
);
vehicleBookInfo
.
setBookedDate
(
orRsOperationFactor
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"vehicle"
,
vehicleId
);
map
.
put
(
"vehicle"
,
vehicleId
);
map
.
put
(
"yearMonth"
,
yearMonth
);
map
.
put
(
"yearMonth"
,
yearMonth
);
List
<
VehicleBookInfo
>
vehicleBookInfos
=
vehicleBookInfoMapper
.
getByVehicleIdAndYearMonth
(
map
);
List
<
VehicleBookInfo
>
vehicleBookInfos
=
vehicleBookInfoMapper
.
getByVehicleIdAndYearMonth
(
map
);
if
(
vehicleBookInfos
!=
null
&&
vehicleBookInfos
.
size
()
>
0
)
{
if
(
vehicleBookInfos
!=
null
&&
vehicleBookInfos
.
size
()
>
0
)
{
if
((
vehicleBookInfos
.
get
(
0
).
getBookedDate
()
&
orRsOperationFactor
)
==
orRsOperationFactor
)
{
if
((
vehicleBookInfos
.
get
(
0
).
getBookedDate
()
&
orRsOperationFactor
)
==
orRsOperationFactor
)
{
return
Boolean
.
TRUE
;
return
Boolean
.
TRUE
;
}
}
}
}
Integer
effected
=
vehicleBookInfoMapper
.
insertIgnore
(
vehicleBookInfo
);
Integer
effected
=
vehicleBookInfoMapper
.
insertIgnore
(
vehicleBookInfo
);
if
(
effected
==
0
)
{
//已存在则需要更新
if
(
effected
==
0
)
{
//已存在则需要更新
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
params
.
put
(
"vehicleId"
,
vehicleBookInfo
.
getVehicle
());
params
.
put
(
"vehicleId"
,
vehicleBookInfo
.
getVehicle
());
params
.
put
(
"yearMonth"
,
yearMonth
);
params
.
put
(
"yearMonth"
,
yearMonth
);
//加入更新条件
//加入更新条件
if
(
CollectionUtils
.
isEmpty
(
bookedDates
))
{
if
(
CollectionUtils
.
isEmpty
(
bookedDates
))
{
throw
new
BaseException
(
ResultCode
.
BOOKED_DATE_IS_EMPTY
);
throw
new
BaseException
(
ResultCode
.
BOOKED_DATE_IS_EMPTY
);
}
}
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
yearMonthAndDate
.
put
(
vehicleBookInfo
.
getYearMonth
(),
bookedDates
);
yearMonthAndDate
.
put
(
vehicleBookInfo
.
getYearMonth
(),
bookedDates
);
//转换为查询对应日期未预定的条件
//转换为查询对应日期未预定的条件
fillBookedDateSearchParam
(
params
,
null
,
yearMonthAndDate
);
fillBookedDateSearchParam
(
params
,
null
,
yearMonthAndDate
);
//提取相关参数组装更细条件
//提取相关参数组装更细条件
Map
<
String
,
Map
<
String
,
Integer
>>
yearMonthAndParam
=
(
Map
<
String
,
Map
<
String
,
Integer
>>)
params
.
get
(
"yearMonthAndParam"
);
Map
<
String
,
Map
<
String
,
Integer
>>
yearMonthAndParam
=
(
Map
<
String
,
Map
<
String
,
Integer
>>)
params
.
get
(
"yearMonthAndParam"
);
Map
<
String
,
Integer
>
andOpratorParam
=
yearMonthAndParam
.
get
(
vehicleBookInfo
.
getYearMonth
());
Map
<
String
,
Integer
>
andOpratorParam
=
yearMonthAndParam
.
get
(
vehicleBookInfo
.
getYearMonth
());
params
.
putAll
(
andOpratorParam
);
params
.
putAll
(
andOpratorParam
);
params
.
put
(
"orRsOperationFactor"
,
params
.
put
(
"orRsOperationFactor"
,
orRsOperationFactor
);
orRsOperationFactor
);
effected
=
vehicleBookInfoMapper
.
updateBookedInfo
(
params
);
effected
=
vehicleBookInfoMapper
.
updateBookedInfo
(
params
);
}
}
return
effected
>
0
?
Boolean
.
TRUE
:
Boolean
.
FALSE
;
return
effected
>
0
?
Boolean
.
TRUE
:
Boolean
.
FALSE
;
}
}
/**
/**
* 检查车辆是否存在
* 检查车辆是否存在
*
* @param id
* @param id
*/
*/
public
boolean
checkIfVehicleExists
(
String
id
){
public
boolean
checkIfVehicleExists
(
String
id
)
{
Vehicle
vehicle
=
mapper
.
selectByPrimaryKey
(
id
);
Vehicle
vehicle
=
mapper
.
selectByPrimaryKey
(
id
);
if
(
vehicle
==
null
)
{
if
(
vehicle
==
null
)
{
return
false
;
return
false
;
}
}
if
(
vehicle
.
getStatus
().
equals
(
VehicleStatus
.
DISCARD
.
getCode
()))
{
if
(
vehicle
.
getStatus
().
equals
(
VehicleStatus
.
DISCARD
.
getCode
()))
{
...
@@ -817,84 +832,86 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -817,84 +832,86 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
}
List
<
VehicleBookRecordVo
>
vehicleBookRecordVos
=
vehicleBookRecordBiz
.
selectByVehicleId
(
vehicleId
);
List
<
VehicleBookRecordVo
>
vehicleBookRecordVos
=
vehicleBookRecordBiz
.
selectByVehicleId
(
vehicleId
);
vehicleBookRecordBiz
.
removeStatus2
(
vehicleBookRecordVos
);
vehicleBookRecordBiz
.
removeStatus2
(
vehicleBookRecordVos
);
if
(
vehicleBookRecordVos
!=
null
&&
vehicleBookRecordVos
.
size
()
>
0
&&
vehicleBookRecordVos
.
get
(
0
).
getBookEndDate
()
!=
null
&&
vehicleBookRecordVos
.
get
(
0
).
getBookEndDate
().
after
(
new
Date
()))
{
if
(
vehicleBookRecordVos
!=
null
&&
vehicleBookRecordVos
.
size
()
>
0
&&
vehicleBookRecordVos
.
get
(
0
).
getBookEndDate
()
!=
null
&&
vehicleBookRecordVos
.
get
(
0
).
getBookEndDate
().
after
(
new
Date
()))
{
stringBuilder
.
append
(
"中,使用人:"
);
stringBuilder
.
append
(
"中,使用人:"
);
stringBuilder
.
append
(
vehicleBookRecordVos
.
get
(
0
).
getVehicleUsername
());
stringBuilder
.
append
(
vehicleBookRecordVos
.
get
(
0
).
getVehicleUsername
());
stringBuilder
.
append
(
" 使用人电话:"
);
stringBuilder
.
append
(
" 使用人电话:"
);
stringBuilder
.
append
(
vehicleBookRecordVos
.
get
(
0
).
getVehicleUserPhone
());
stringBuilder
.
append
(
vehicleBookRecordVos
.
get
(
0
).
getVehicleUserPhone
());
}
else
{
}
else
{
stringBuilder
.
append
(
"请联系管理员修改车辆状态为正常状态"
);
stringBuilder
.
append
(
"
,
请联系管理员修改车辆状态为正常状态"
);
}
}
return
stringBuilder
.
toString
();
return
stringBuilder
.
toString
();
}
}
/**
/**
* 把日期范围转换为列表,并检查操作范围是否合法
* 把日期范围转换为列表,并检查操作范围是否合法
*
* @param yearMonthAndDate
* @param yearMonthAndDate
* @param startDay
* @param startDay
* @param endDay
* @param endDay
*/
*/
private
void
fillDateList4DatePeriod
(
Map
<
String
,
List
<
String
>>
yearMonthAndDate
,
DateTime
startDay
,
DateTime
endDay
)
{
private
void
fillDateList4DatePeriod
(
Map
<
String
,
List
<
String
>>
yearMonthAndDate
,
DateTime
startDay
,
DateTime
endDay
)
{
for
(
DateTime
curDate
=
startDay
;
curDate
.
compareTo
(
endDay
)
<=
0
;
curDate
=
curDate
.
plusDays
(
1
))
{
for
(
DateTime
curDate
=
startDay
;
curDate
.
compareTo
(
endDay
)
<=
0
;
curDate
=
curDate
.
plusDays
(
1
))
{
String
curDateStr
=
curDate
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
String
curDateStr
=
curDate
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
if
(
curDateStr
.
compareTo
(
DateTime
.
now
().
toString
(
DEFAULT_DATE_TIME_FORMATTER
))<
0
)
{
if
(
curDateStr
.
compareTo
(
DateTime
.
now
().
toString
(
DEFAULT_DATE_TIME_FORMATTER
))
<
0
)
{
throw
new
BaseException
(
ResultCode
.
ONLY_BOOK_FROM_TODAY
);
throw
new
BaseException
(
ResultCode
.
ONLY_BOOK_FROM_TODAY
);
}
}
String
curYearMonth
=
curDate
.
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
String
curYearMonth
=
curDate
.
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
if
(!
yearMonthAndDate
.
containsKey
(
curYearMonth
))
{
if
(!
yearMonthAndDate
.
containsKey
(
curYearMonth
))
{
yearMonthAndDate
.
put
(
curYearMonth
,
Lists
.
newArrayList
());
yearMonthAndDate
.
put
(
curYearMonth
,
Lists
.
newArrayList
());
}
}
List
<
String
>
curBookedDateList
=
yearMonthAndDate
.
get
(
curYearMonth
);
List
<
String
>
curBookedDateList
=
yearMonthAndDate
.
get
(
curYearMonth
);
curBookedDateList
.
add
(
curDateStr
);
curBookedDateList
.
add
(
curDateStr
);
}
}
if
(
yearMonthAndDate
.
size
()>
3
)
{
//连续的日期最多夸3个月
if
(
yearMonthAndDate
.
size
()
>
3
)
{
//连续的日期最多夸3个月
throw
new
BaseException
(
" 只可以预约两个月内的车辆"
);
throw
new
BaseException
(
" 只可以预约两个月内的车辆"
);
}
}
}
}
private
void
unbookDateList4DatePeriod
(
Map
<
String
,
List
<
String
>>
yearMonthAndDate
,
DateTime
startDay
,
DateTime
endDay
)
{
private
void
unbookDateList4DatePeriod
(
Map
<
String
,
List
<
String
>>
yearMonthAndDate
,
DateTime
startDay
,
DateTime
endDay
)
{
for
(
DateTime
curDate
=
startDay
;
curDate
.
compareTo
(
endDay
)
<=
0
;
curDate
=
curDate
.
plusDays
(
1
))
{
for
(
DateTime
curDate
=
startDay
;
curDate
.
compareTo
(
endDay
)
<=
0
;
curDate
=
curDate
.
plusDays
(
1
))
{
String
curDateStr
=
curDate
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
String
curDateStr
=
curDate
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
// if(curDateStr.compareTo(DateTime.now().toString(DEFAULT_DATE_TIME_FORMATTER))<0){
// if(curDateStr.compareTo(DateTime.now().toString(DEFAULT_DATE_TIME_FORMATTER))<0){
// throw new BaseException("只可以取消当前时间之后的车辆");
// throw new BaseException("只可以取消当前时间之后的车辆");
// }
// }
String
curYearMonth
=
curDate
.
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
String
curYearMonth
=
curDate
.
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
if
(!
yearMonthAndDate
.
containsKey
(
curYearMonth
))
{
if
(!
yearMonthAndDate
.
containsKey
(
curYearMonth
))
{
yearMonthAndDate
.
put
(
curYearMonth
,
Lists
.
newArrayList
());
yearMonthAndDate
.
put
(
curYearMonth
,
Lists
.
newArrayList
());
}
}
List
<
String
>
curBookedDateList
=
yearMonthAndDate
.
get
(
curYearMonth
);
List
<
String
>
curBookedDateList
=
yearMonthAndDate
.
get
(
curYearMonth
);
curBookedDateList
.
add
(
curDateStr
);
curBookedDateList
.
add
(
curDateStr
);
}
}
if
(
yearMonthAndDate
.
size
()>
3
)
{
//连续的日期最多夸3个月
if
(
yearMonthAndDate
.
size
()
>
3
)
{
//连续的日期最多夸3个月
throw
new
BaseException
(
ResultCode
.
ONLY_BOOK_TWO_MONTH
);
throw
new
BaseException
(
ResultCode
.
ONLY_BOOK_TWO_MONTH
);
}
}
}
}
/**
/**
* 取消预定(释放bookinfo)
* 取消预定(释放bookinfo)
*
* @return
* @return
*/
*/
@Transactional
@Transactional
public
Boolean
unbookVehicle
(
BookVehicleVO
bookVehicleVo
)
throws
Exception
{
public
Boolean
unbookVehicle
(
BookVehicleVO
bookVehicleVo
)
throws
Exception
{
//提取日期参数,改为每月一份
//提取日期参数,改为每月一份
//提取日期和相应的预定目标日期
//提取日期和相应的预定目标日期
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
Maps
.
newHashMap
();
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
Maps
.
newHashMap
();
DateTime
startDay
=
DateTime
.
parse
(
bookVehicleVo
.
getUnbookStartDate
(),
DATE_TIME_FORMATTER
);
DateTime
startDay
=
DateTime
.
parse
(
bookVehicleVo
.
getUnbookStartDate
(),
DATE_TIME_FORMATTER
);
DateTime
endDay
=
DateTime
.
parse
(
bookVehicleVo
.
getUnbookEndDate
(),
DATE_TIME_FORMATTER
);
DateTime
endDay
=
DateTime
.
parse
(
bookVehicleVo
.
getUnbookEndDate
(),
DATE_TIME_FORMATTER
);
//转换日期范围为列表,并检查是否合法
//转换日期范围为列表,并检查是否合法
unbookDateList4DatePeriod
(
yearMonthAndDate
,
DateTime
.
parse
(
startDay
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
DEFAULT_DATE_TIME_FORMATTER
),
DateTime
.
parse
(
endDay
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
DEFAULT_DATE_TIME_FORMATTER
));
unbookDateList4DatePeriod
(
yearMonthAndDate
,
DateTime
.
parse
(
startDay
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
DEFAULT_DATE_TIME_FORMATTER
),
DateTime
.
parse
(
endDay
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
DEFAULT_DATE_TIME_FORMATTER
));
//原设计为 读取 bookVehicleVo.getNotCheckTimeLegal(), 现在取消/拒绝 true
//原设计为 读取 bookVehicleVo.getNotCheckTimeLegal(), 现在取消/拒绝 true
Map
<
String
,
Integer
>
map
=
vehicleBookHourInfoBiz
.
getPredictableHours
(
bookVehicleVo
.
getUnbookStartDate
(),
bookVehicleVo
.
getUnbookEndDate
(),
Boolean
.
TRUE
);
Map
<
String
,
Integer
>
map
=
vehicleBookHourInfoBiz
.
getPredictableHours
(
bookVehicleVo
.
getUnbookStartDate
(),
bookVehicleVo
.
getUnbookEndDate
(),
Boolean
.
TRUE
);
if
(
yearMonthAndDate
.
size
()
>
3
)
{
//连续的日期最多夸3个月
if
(
yearMonthAndDate
.
size
()
>
3
)
{
//连续的日期最多夸3个月
throw
new
BaseException
(
ResultCode
.
ONLY_UNBOOK_TWO_MONTH
);
throw
new
BaseException
(
ResultCode
.
ONLY_UNBOOK_TWO_MONTH
);
}
}
Boolean
rs
=
Boolean
.
TRUE
;
Boolean
rs
=
Boolean
.
TRUE
;
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
yearMonthAndDate
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
yearMonthAndDate
.
entrySet
())
{
Boolean
rsEach
=
unbookVehiclePerMonth
(
bookVehicleVo
.
getVehicleId
(),
entry
.
getValue
(),
entry
.
getKey
(),
map
);
Boolean
rsEach
=
unbookVehiclePerMonth
(
bookVehicleVo
.
getVehicleId
(),
entry
.
getValue
(),
entry
.
getKey
(),
map
);
if
(
Boolean
.
FALSE
.
equals
(
rsEach
))
{
if
(
Boolean
.
FALSE
.
equals
(
rsEach
))
{
rs
=
Boolean
.
FALSE
;
rs
=
Boolean
.
FALSE
;
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
//手动回滚
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
//手动回滚
}
}
...
@@ -904,56 +921,56 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -904,56 +921,56 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
@Transactional
@Transactional
public
Boolean
unbookVehiclePerMonth
(
String
vehicleId
,
List
<
String
>
unbookDates
,
String
yearMonth
,
Map
<
String
,
Integer
>
hourInfo
){
public
Boolean
unbookVehiclePerMonth
(
String
vehicleId
,
List
<
String
>
unbookDates
,
String
yearMonth
,
Map
<
String
,
Integer
>
hourInfo
)
{
checkIfVehicleExists
(
vehicleId
);
checkIfVehicleExists
(
vehicleId
);
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
params
.
put
(
"vehicleId"
,
vehicleId
);
params
.
put
(
"vehicleId"
,
vehicleId
);
params
.
put
(
"yearMonth"
,
yearMonth
);
params
.
put
(
"yearMonth"
,
yearMonth
);
//加入更新条件
//加入更新条件
if
(
CollectionUtils
.
isEmpty
(
unbookDates
))
{
if
(
CollectionUtils
.
isEmpty
(
unbookDates
))
{
throw
new
BaseException
(
ResultCode
.
VEHICLE_CAN_NOT_UNBOOK
);
throw
new
BaseException
(
ResultCode
.
VEHICLE_CAN_NOT_UNBOOK
);
}
}
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
yearMonthAndDate
.
put
(
yearMonth
,
unbookDates
);
yearMonthAndDate
.
put
(
yearMonth
,
unbookDates
);
//转换为查询对应日期未预定的条件
//转换为查询对应日期未预定的条件
fillBookedDateSearchParam
(
params
,
yearMonthAndDate
,
null
);
fillBookedDateSearchParam
(
params
,
yearMonthAndDate
,
null
);
//提取相关参数组装更细条件
//提取相关参数组装更细条件
Map
<
String
,
Map
<
String
,
Integer
>>
yearMonthAndParam
=
(
Map
<
String
,
Map
<
String
,
Integer
>>)
params
.
get
(
"yearMonthAndParam"
);
Map
<
String
,
Map
<
String
,
Integer
>>
yearMonthAndParam
=
(
Map
<
String
,
Map
<
String
,
Integer
>>)
params
.
get
(
"yearMonthAndParam"
);
Map
<
String
,
Integer
>
andOpratorParam
=
yearMonthAndParam
.
get
(
yearMonth
);
Map
<
String
,
Integer
>
andOpratorParam
=
yearMonthAndParam
.
get
(
yearMonth
);
params
.
putAll
(
andOpratorParam
);
params
.
putAll
(
andOpratorParam
);
Integer
andRsOperationFactor
=
getBitOpratorFactor4UnBooked
(
unbookDates
);
//预定的相关或运算因子,当前月份没有预定记录时同时也是结果
Integer
andRsOperationFactor
=
getBitOpratorFactor4UnBooked
(
unbookDates
);
//预定的相关或运算因子,当前月份没有预定记录时同时也是结果
params
.
put
(
"andRsOperationFactor"
,
params
.
put
(
"andRsOperationFactor"
,
andRsOperationFactor
);
andRsOperationFactor
);
return
unbookHourInfo
(
vehicleId
,
hourInfo
,
params
);
return
unbookHourInfo
(
vehicleId
,
hourInfo
,
params
);
}
}
public
boolean
unbookHourInfo
(
String
vehicleId
,
Map
<
String
,
Integer
>
hourInfo
,
Map
<
String
,
Object
>
params
)
{
public
boolean
unbookHourInfo
(
String
vehicleId
,
Map
<
String
,
Integer
>
hourInfo
,
Map
<
String
,
Object
>
params
)
{
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
hourInfo
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
hourInfo
.
entrySet
())
{
VehicleBookHourInfoDto
vehicleBookHourInfoDto
=
new
VehicleBookHourInfoDto
();
VehicleBookHourInfoDto
vehicleBookHourInfoDto
=
new
VehicleBookHourInfoDto
();
vehicleBookHourInfoDto
.
setYearMonthDay
(
entry
.
getKey
());
vehicleBookHourInfoDto
.
setYearMonthDay
(
entry
.
getKey
());
vehicleBookHourInfoDto
.
setVehicleId
(
vehicleId
);
vehicleBookHourInfoDto
.
setVehicleId
(
vehicleId
);
List
<
VehicleBookHourInfo
>
vehicleBookHourInfos
=
vehicleBookHourInfoBiz
.
selectByVehicleAndDate
(
vehicleBookHourInfoDto
);
List
<
VehicleBookHourInfo
>
vehicleBookHourInfos
=
vehicleBookHourInfoBiz
.
selectByVehicleAndDate
(
vehicleBookHourInfoDto
);
if
(
vehicleBookHourInfos
!=
null
&&
vehicleBookHourInfos
.
size
()
>
0
)
{
if
(
vehicleBookHourInfos
!=
null
&&
vehicleBookHourInfos
.
size
()
>
0
)
{
if
((
vehicleBookHourInfos
.
get
(
0
).
getBookedHour
()
&
~
entry
.
getValue
())
==
0
)
{
//时间取与运算为0说明当天全部取消预定
if
((
vehicleBookHourInfos
.
get
(
0
).
getBookedHour
()
&
~
entry
.
getValue
())
==
0
)
{
//时间取与运算为0说明当天全部取消预定
DateTime
dateTime
=
DateTime
.
parse
(
entry
.
getKey
(),
DEFAULT_DATE_TIME_FORMATTER
);
DateTime
dateTime
=
DateTime
.
parse
(
entry
.
getKey
(),
DEFAULT_DATE_TIME_FORMATTER
);
Integer
andOperationFactor
=
0
;
Integer
andOperationFactor
=
0
;
andOperationFactor
|=
1
<<
(
dateTime
.
dayOfMonth
().
get
()
-
1
);
andOperationFactor
|=
1
<<
(
dateTime
.
dayOfMonth
().
get
()
-
1
);
VehicleBookInfo
vehicleBookInfo
=
getByVehicleIdAndYearMonth
(
vehicleId
,
dateTime
.
toString
(
YEARMONTH_DATE_TIME_FORMATTER
));
VehicleBookInfo
vehicleBookInfo
=
getByVehicleIdAndYearMonth
(
vehicleId
,
dateTime
.
toString
(
YEARMONTH_DATE_TIME_FORMATTER
));
if
(
vehicleBookInfo
!=
null
)
{
if
(
vehicleBookInfo
!=
null
)
{
vehicleBookInfo
.
setBookedDate
(
vehicleBookInfo
.
getBookedDate
()
&
~
andOperationFactor
);
vehicleBookInfo
.
setBookedDate
(
vehicleBookInfo
.
getBookedDate
()
&
~
andOperationFactor
);
int
effected
=
vehicleBookInfoBiz
.
update
(
vehicleBookInfo
);
int
effected
=
vehicleBookInfoBiz
.
update
(
vehicleBookInfo
);
if
(
effected
<
1
)
{
if
(
effected
<
1
)
{
return
Boolean
.
FALSE
;
return
Boolean
.
FALSE
;
}
}
}
}
}
}
vehicleBookHourInfos
.
get
(
0
).
setBookedHour
((
vehicleBookHourInfos
.
get
(
0
).
getBookedHour
()
&
~
entry
.
getValue
()));
vehicleBookHourInfos
.
get
(
0
).
setBookedHour
((
vehicleBookHourInfos
.
get
(
0
).
getBookedHour
()
&
~
entry
.
getValue
()));
int
effect
=
vehicleBookHourInfoBiz
.
updateByIdRe
(
vehicleBookHourInfos
.
get
(
0
));
int
effect
=
vehicleBookHourInfoBiz
.
updateByIdRe
(
vehicleBookHourInfos
.
get
(
0
));
if
(
effect
<
1
)
{
if
(
effect
<
1
)
{
return
Boolean
.
FALSE
;
return
Boolean
.
FALSE
;
}
else
{
}
else
{
continue
;
continue
;
}
}
}
else
{
}
else
{
return
Boolean
.
FALSE
;
return
Boolean
.
FALSE
;
}
}
...
@@ -963,77 +980,78 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -963,77 +980,78 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 获取某月份相应预定日期查询条件
* 获取某月份相应预定日期查询条件
* @param yearMonthAndDate 年月 - 预定日期条件字符串(yyyy-MM-dd)
*
* @param yearMonthAndDate 年月 - 预定日期条件字符串(yyyy-MM-dd)
* @param yearMonthAndDateNotBooked 年月 - 未预定日期条件字符串
* @param yearMonthAndDateNotBooked 年月 - 未预定日期条件字符串
* @return
* @return
*/
*/
public
void
fillBookedDateSearchParam
(
Map
<
String
,
Object
>
params
,
public
void
fillBookedDateSearchParam
(
Map
<
String
,
Object
>
params
,
Map
<
String
,
List
<
String
>>
yearMonthAndDate
,
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
)
{
Map
<
String
,
List
<
String
>>
yearMonthAndDate
,
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
)
{
if
(
MapUtils
.
isEmpty
(
yearMonthAndDate
)&&
MapUtils
.
isEmpty
(
yearMonthAndDateNotBooked
))
{
//没有预定信息查询条件
if
(
MapUtils
.
isEmpty
(
yearMonthAndDate
)
&&
MapUtils
.
isEmpty
(
yearMonthAndDateNotBooked
))
{
//没有预定信息查询条件
throw
new
BaseException
(
ResultCode
.
BOOKED_DATE_IS_EMPTY
);
throw
new
BaseException
(
ResultCode
.
BOOKED_DATE_IS_EMPTY
);
}
}
Map
<
String
,
Map
<
String
,
Integer
>>
yearMonthAndParam
=
new
HashMap
<>();
Map
<
String
,
Map
<
String
,
Integer
>>
yearMonthAndParam
=
new
HashMap
<>();
Set
<
String
>
bookedYearMonth
=
new
HashSet
<>();
//记录未预定查询条件,供检查是否是否存在同一天既是已预定,又是没有预定
Set
<
String
>
bookedYearMonth
=
new
HashSet
<>();
//记录未预定查询条件,供检查是否是否存在同一天既是已预定,又是没有预定
if
(
MapUtils
.
isNotEmpty
(
yearMonthAndDate
))
{
if
(
MapUtils
.
isNotEmpty
(
yearMonthAndDate
))
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry:
yearMonthAndDate
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
yearMonthAndDate
.
entrySet
())
{
String
curYearMonth
=
entry
.
getKey
();
String
curYearMonth
=
entry
.
getKey
();
if
(
CollectionUtils
.
isEmpty
(
entry
.
getValue
()))
{
if
(
CollectionUtils
.
isEmpty
(
entry
.
getValue
()))
{
continue
;
continue
;
}
}
Integer
andOperationFactor
=
0
;
//查找条件中作与运算的参数
Integer
andOperationFactor
=
0
;
//查找条件中作与运算的参数
Integer
andOperationRs
=
0
;
//与运算结果
Integer
andOperationRs
=
0
;
//与运算结果
for
(
String
dateStr
:
entry
.
getValue
())
{
//已预定作为条件,该位与1作与运算必定为1
for
(
String
dateStr
:
entry
.
getValue
())
{
//已预定作为条件,该位与1作与运算必定为1
DateTime
dateTime
=
DateTime
.
parse
(
dateStr
,
DEFAULT_DATE_TIME_FORMATTER
);
DateTime
dateTime
=
DateTime
.
parse
(
dateStr
,
DEFAULT_DATE_TIME_FORMATTER
);
bookedYearMonth
.
add
(
dateStr
);
bookedYearMonth
.
add
(
dateStr
);
//仅对应位为1的整形值
//仅对应位为1的整形值
andOperationFactor
|=
1
<<(
dateTime
.
dayOfMonth
().
get
()-
1
);
andOperationFactor
|=
1
<<
(
dateTime
.
dayOfMonth
().
get
()
-
1
);
andOperationRs
|=
1
<<(
dateTime
.
dayOfMonth
().
get
()-
1
);
andOperationRs
|=
1
<<
(
dateTime
.
dayOfMonth
().
get
()
-
1
);
}
}
Map
<
String
,
Integer
>
andOperationParam
=
Maps
.
newHashMap
();
Map
<
String
,
Integer
>
andOperationParam
=
Maps
.
newHashMap
();
andOperationParam
.
put
(
"andOperationFactor"
,
andOperationFactor
);
andOperationParam
.
put
(
"andOperationFactor"
,
andOperationFactor
);
andOperationParam
.
put
(
"andOperationRs"
,
andOperationRs
);
andOperationParam
.
put
(
"andOperationRs"
,
andOperationRs
);
yearMonthAndParam
.
put
(
curYearMonth
,
andOperationParam
);
yearMonthAndParam
.
put
(
curYearMonth
,
andOperationParam
);
}
}
}
}
if
(
MapUtils
.
isNotEmpty
(
yearMonthAndDateNotBooked
))
{
if
(
MapUtils
.
isNotEmpty
(
yearMonthAndDateNotBooked
))
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry:
yearMonthAndDateNotBooked
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
yearMonthAndDateNotBooked
.
entrySet
())
{
String
curYearMonth
=
entry
.
getKey
();
String
curYearMonth
=
entry
.
getKey
();
if
(
CollectionUtils
.
isEmpty
(
entry
.
getValue
()))
{
if
(
CollectionUtils
.
isEmpty
(
entry
.
getValue
()))
{
continue
;
continue
;
}
}
Map
<
String
,
Integer
>
andOperationParam
=
Maps
.
newHashMap
();
Map
<
String
,
Integer
>
andOperationParam
=
Maps
.
newHashMap
();
andOperationParam
.
put
(
"andOperationFactor"
,
0
);
andOperationParam
.
put
(
"andOperationFactor"
,
0
);
andOperationParam
.
put
(
"andOperationRs"
,
0
);
andOperationParam
.
put
(
"andOperationRs"
,
0
);
Integer
andOperationFactor
=
0
;
//查找条件中作与运算的参数
Integer
andOperationFactor
=
0
;
//查找条件中作与运算的参数
if
(
yearMonthAndParam
.
containsKey
(
curYearMonth
))
{
if
(
yearMonthAndParam
.
containsKey
(
curYearMonth
))
{
andOperationParam
=
yearMonthAndParam
.
get
(
curYearMonth
);
andOperationParam
=
yearMonthAndParam
.
get
(
curYearMonth
);
andOperationFactor
=
andOperationParam
.
get
(
"andOperationFactor"
);
andOperationFactor
=
andOperationParam
.
get
(
"andOperationFactor"
);
}
else
{
}
else
{
yearMonthAndParam
.
put
(
curYearMonth
,
andOperationParam
);
yearMonthAndParam
.
put
(
curYearMonth
,
andOperationParam
);
}
}
for
(
String
dateStr
:
entry
.
getValue
())
{
//已预定作为条件,该位与1作与运算必定为1
for
(
String
dateStr
:
entry
.
getValue
())
{
//已预定作为条件,该位与1作与运算必定为1
if
(
bookedYearMonth
.
contains
(
dateStr
))
{
if
(
bookedYearMonth
.
contains
(
dateStr
))
{
log
.
info
(
"当天不可预定,日期为:dateStr = {}"
,
dateStr
);
log
.
info
(
"当天不可预定,日期为:dateStr = {}"
,
dateStr
);
throw
new
BaseException
(
ResultCode
.
TODAY_CAN_NOT_BOOK
);
throw
new
BaseException
(
ResultCode
.
TODAY_CAN_NOT_BOOK
);
}
}
DateTime
dateTime
=
DateTime
.
parse
(
dateStr
,
DEFAULT_DATE_TIME_FORMATTER
);
DateTime
dateTime
=
DateTime
.
parse
(
dateStr
,
DEFAULT_DATE_TIME_FORMATTER
);
//仅对应位为1的整形值
//仅对应位为1的整形值
andOperationFactor
|=
1
<<(
dateTime
.
dayOfMonth
().
get
()-
1
);
andOperationFactor
|=
1
<<
(
dateTime
.
dayOfMonth
().
get
()
-
1
);
}
}
andOperationParam
.
put
(
"andOperationFactor"
,
andOperationFactor
);
andOperationParam
.
put
(
"andOperationFactor"
,
andOperationFactor
);
// if(!bookedYearMonth.contains(curYearMonth)){//仅以未预定日期条件查询时,不存在预定记录即为没有预定
// if(!bookedYearMonth.contains(curYearMonth)){//仅以未预定日期条件查询时,不存在预定记录即为没有预定
// andOperationParam.put("notBookedOnly",1);
// andOperationParam.put("notBookedOnly",1);
// }
// }
}
}
}
}
if
(
MapUtils
.
isNotEmpty
(
yearMonthAndParam
))
{
if
(
MapUtils
.
isNotEmpty
(
yearMonthAndParam
))
{
params
.
put
(
"yearMonthAndParam"
,
yearMonthAndParam
);
params
.
put
(
"yearMonthAndParam"
,
yearMonthAndParam
);
String
bitStr
=
""
;
String
bitStr
=
""
;
for
(
String
key
:
yearMonthAndParam
.
keySet
())
{
for
(
String
key
:
yearMonthAndParam
.
keySet
())
{
bitStr
+=
"1"
;
bitStr
+=
"1"
;
}
}
params
.
put
(
"yearMonthAndParamBitStr"
,
bitStr
);
params
.
put
(
"yearMonthAndParamBitStr"
,
bitStr
);
}
}
...
@@ -1042,15 +1060,15 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1042,15 +1060,15 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 根据月份分类到map中
* 根据月份分类到map中
*/
*/
private
void
classifyByYearMonth
(
List
<
String
>
target
,
Map
<
String
,
List
<
String
>>
yearMonthAndDate
,
Set
<
String
>
allYearMonth
)
{
private
void
classifyByYearMonth
(
List
<
String
>
target
,
Map
<
String
,
List
<
String
>>
yearMonthAndDate
,
Set
<
String
>
allYearMonth
)
{
if
(
CollectionUtils
.
isNotEmpty
(
target
))
{
//已预约
if
(
CollectionUtils
.
isNotEmpty
(
target
))
{
//已预约
for
(
String
dateStr
:
target
)
{
for
(
String
dateStr
:
target
)
{
String
curYearMonth
=
DateTime
.
parse
(
dateStr
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
String
curYearMonth
=
DateTime
.
parse
(
dateStr
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
allYearMonth
.
add
(
curYearMonth
);
allYearMonth
.
add
(
curYearMonth
);
List
<
String
>
dateStrList
=
yearMonthAndDate
.
get
(
curYearMonth
);
List
<
String
>
dateStrList
=
yearMonthAndDate
.
get
(
curYearMonth
);
if
(
dateStrList
==
null
)
{
if
(
dateStrList
==
null
)
{
dateStrList
=
Lists
.
newArrayList
();
dateStrList
=
Lists
.
newArrayList
();
yearMonthAndDate
.
put
(
curYearMonth
,
dateStrList
);
yearMonthAndDate
.
put
(
curYearMonth
,
dateStrList
);
}
}
dateStrList
.
add
(
dateStr
);
dateStrList
.
add
(
dateStr
);
}
}
...
@@ -1059,15 +1077,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1059,15 +1077,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 把日期范围转换成列表
* 把日期范围转换成列表
*
* @param startDate
* @param startDate
* @param endDate
* @param endDate
* @return
* @return
*/
*/
private
List
<
String
>
convertDatePeriod2List
(
String
startDate
,
String
endDate
)
{
private
List
<
String
>
convertDatePeriod2List
(
String
startDate
,
String
endDate
)
{
DateTime
startDay
=
DateTime
.
parse
(
startDate
,
DEFAULT_DATE_TIME_FORMATTER
);
DateTime
startDay
=
DateTime
.
parse
(
startDate
,
DEFAULT_DATE_TIME_FORMATTER
);
DateTime
endDay
=
DateTime
.
parse
(
endDate
,
DEFAULT_DATE_TIME_FORMATTER
);
DateTime
endDay
=
DateTime
.
parse
(
endDate
,
DEFAULT_DATE_TIME_FORMATTER
);
List
<
String
>
rs
=
Lists
.
newArrayList
();
List
<
String
>
rs
=
Lists
.
newArrayList
();
for
(
DateTime
curDate
=
startDay
;
curDate
.
compareTo
(
endDay
)<=
0
;
curDate
=
curDate
.
plusDays
(
1
))
{
for
(
DateTime
curDate
=
startDay
;
curDate
.
compareTo
(
endDay
)
<=
0
;
curDate
=
curDate
.
plusDays
(
1
))
{
String
curDateStr
=
curDate
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
String
curDateStr
=
curDate
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
rs
.
add
(
curDateStr
);
rs
.
add
(
curDateStr
);
}
}
...
@@ -1076,13 +1095,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1076,13 +1095,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 根据前端预定日期查询条件转换为实际查询条件
* 根据前端预定日期查询条件转换为实际查询条件
*
* @param params
* @param params
* @return
* @return
*/
*/
public
void
adjustBookedInfoParam
(
Map
<
String
,
Object
>
params
,
VehiclePageQueryVo
vehiclePageQueryVo
)
{
public
void
adjustBookedInfoParam
(
Map
<
String
,
Object
>
params
,
VehiclePageQueryVo
vehiclePageQueryVo
)
{
//加入每月预定信息查询条件
//加入每月预定信息查询条件
List
<
String
>
bookedDates
=
Lists
.
newArrayList
();
List
<
String
>
bookedDates
=
Lists
.
newArrayList
();
if
(
StringUtils
.
isNotBlank
(
vehiclePageQueryVo
.
getBookedStartDate
())
&&
if
(
StringUtils
.
isNotBlank
(
vehiclePageQueryVo
.
getBookedStartDate
())
&&
StringUtils
.
isNotBlank
(
vehiclePageQueryVo
.
getBookedEndDate
()))
{
StringUtils
.
isNotBlank
(
vehiclePageQueryVo
.
getBookedEndDate
()))
{
bookedDates
=
convertDatePeriod2List
(
vehiclePageQueryVo
.
getBookedStartDate
(),
bookedDates
=
convertDatePeriod2List
(
vehiclePageQueryVo
.
getBookedStartDate
(),
vehiclePageQueryVo
.
getBookedEndDate
());
vehiclePageQueryVo
.
getBookedEndDate
());
...
@@ -1091,7 +1111,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1091,7 +1111,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
params
.
remove
(
"bookEndDate"
);
params
.
remove
(
"bookEndDate"
);
List
<
String
>
notBookedDates
=
Lists
.
newArrayList
();
List
<
String
>
notBookedDates
=
Lists
.
newArrayList
();
if
(
StringUtils
.
isNotBlank
(
vehiclePageQueryVo
.
getNotBookedStartDate
())
&&
if
(
StringUtils
.
isNotBlank
(
vehiclePageQueryVo
.
getNotBookedStartDate
())
&&
StringUtils
.
isNotBlank
(
vehiclePageQueryVo
.
getNotBookedEndDate
()))
{
StringUtils
.
isNotBlank
(
vehiclePageQueryVo
.
getNotBookedEndDate
()))
{
notBookedDates
=
convertDatePeriod2List
(
vehiclePageQueryVo
.
getNotBookedStartDate
(),
notBookedDates
=
convertDatePeriod2List
(
vehiclePageQueryVo
.
getNotBookedStartDate
(),
vehiclePageQueryVo
.
getNotBookedEndDate
());
vehiclePageQueryVo
.
getNotBookedEndDate
());
...
@@ -1100,68 +1120,71 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1100,68 +1120,71 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
params
.
remove
(
"norBookedEndDate"
);
params
.
remove
(
"norBookedEndDate"
);
//若传入预定信息查询条件,则查询对应月份预定信息查询条件(不超过3个月)
//若传入预定信息查询条件,则查询对应月份预定信息查询条件(不超过3个月)
if
(
CollectionUtils
.
isEmpty
(
bookedDates
)
&&
CollectionUtils
.
isEmpty
(
notBookedDates
))
{
if
(
CollectionUtils
.
isEmpty
(
bookedDates
)
&&
CollectionUtils
.
isEmpty
(
notBookedDates
))
{
return
;
return
;
}
}
//筛选出查询条件所在月份
//筛选出查询条件所在月份
Set
<
String
>
allYearMonth
=
new
HashSet
<>();
//记录所有年月
Set
<
String
>
allYearMonth
=
new
HashSet
<>();
//记录所有年月
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
//预定年月 - 预定日期列表
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
//预定年月 - 预定日期列表
classifyByYearMonth
(
bookedDates
,
yearMonthAndDate
,
allYearMonth
);
classifyByYearMonth
(
bookedDates
,
yearMonthAndDate
,
allYearMonth
);
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
=
new
HashMap
<>();
//未预定年月 - 未预定日期列表
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
=
new
HashMap
<>();
//未预定年月 - 未预定日期列表
classifyByYearMonth
(
notBookedDates
,
yearMonthAndDateNotBooked
,
allYearMonth
);
classifyByYearMonth
(
notBookedDates
,
yearMonthAndDateNotBooked
,
allYearMonth
);
if
(
allYearMonth
.
size
()>
0
&&
params
.
get
(
"subordinateBranch"
)
==
null
)
{
if
(
allYearMonth
.
size
()
>
0
&&
params
.
get
(
"subordinateBranch"
)
==
null
)
{
throw
new
BaseException
(
" <subordinateBranch> must included in params while using <bookedInfo> param. "
);
throw
new
BaseException
(
" <subordinateBranch> must included in params while using <bookedInfo> param. "
);
}
}
if
(
allYearMonth
.
size
()>
MAX_MONTH_COUNT_BOOKED_INFO_QUERY
)
{
if
(
allYearMonth
.
size
()
>
MAX_MONTH_COUNT_BOOKED_INFO_QUERY
)
{
throw
new
BaseException
(
" only 3 month can be included <bookedInfo> param."
);
throw
new
BaseException
(
" only 3 month can be included <bookedInfo> param."
);
}
}
//加入预定信息查询条件
//加入预定信息查询条件
fillBookedDateSearchParam
(
params
,
yearMonthAndDate
,
yearMonthAndDateNotBooked
);
fillBookedDateSearchParam
(
params
,
yearMonthAndDate
,
yearMonthAndDateNotBooked
);
}
}
/**
/**
* 按页查询
* 按页查询
*
* @param vehiclePageQueryVo
* @param vehiclePageQueryVo
* @return
* @return
* @throws Exception
* @throws Exception
*/
*/
public
PageDataVO
<
ResultVehicleVo
>
getByPage
(
VehiclePageQueryVo
vehiclePageQueryVo
)
throws
Exception
{
public
PageDataVO
<
ResultVehicleVo
>
getByPage
(
VehiclePageQueryVo
vehiclePageQueryVo
)
throws
Exception
{
Map
<
String
,
Object
>
params
=
PropertyUtils
.
describe
(
vehiclePageQueryVo
);
Map
<
String
,
Object
>
params
=
PropertyUtils
.
describe
(
vehiclePageQueryVo
);
Integer
pageSize
=
(
Integer
)
params
.
get
(
"limit"
);
Integer
pageSize
=
(
Integer
)
params
.
get
(
"limit"
);
params
.
remove
(
"pageSize"
);
params
.
remove
(
"pageSize"
);
Integer
pageNo
=
(
Integer
)
params
.
get
(
"page"
);
Integer
pageNo
=
(
Integer
)
params
.
get
(
"page"
);
params
.
remove
(
"pageNo"
);
params
.
remove
(
"pageNo"
);
//处理预定日期相关参数
//处理预定日期相关参数
adjustBookedInfoParam
(
params
,
vehiclePageQueryVo
);
adjustBookedInfoParam
(
params
,
vehiclePageQueryVo
);
params
.
get
(
"yearMonthAndParam"
);
params
.
get
(
"yearMonthAndParam"
);
if
(
vehiclePageQueryVo
.
getModelId
()
==
null
)
{
if
(
vehiclePageQueryVo
.
getModelId
()
==
null
)
{
params
.
remove
(
"modelId"
);
params
.
remove
(
"modelId"
);
}
}
PageHelper
.
startPage
(
pageNo
,
pageSize
);
PageHelper
.
startPage
(
pageNo
,
pageSize
);
List
<
ResultVehicleVo
>
vehicles
=
mapper
.
getByPage
(
params
);
List
<
ResultVehicleVo
>
vehicles
=
mapper
.
getByPage
(
params
);
PageInfo
<
ResultVehicleVo
>
vehiclePageInfo
=
new
PageInfo
<>(
vehicles
);
PageInfo
<
ResultVehicleVo
>
vehiclePageInfo
=
new
PageInfo
<>(
vehicles
);
return
PageDataVO
.
pageInfo
(
vehiclePageInfo
);
return
PageDataVO
.
pageInfo
(
vehiclePageInfo
);
}
}
/**
/**
* 按页查询(非所有数据,过滤分公司信息)
* 按页查询(非所有数据,过滤分公司信息)
*
* @param vehiclePageQueryVo
* @param vehiclePageQueryVo
* @return
* @return
* @throws Exception
* @throws Exception
*/
*/
public
PageDataVO
<
ResultVehicleVo
>
getByPageNotAllData
(
VehiclePageQueryVo
vehiclePageQueryVo
,
List
<
Integer
>
companyList
)
throws
Exception
{
public
PageDataVO
<
ResultVehicleVo
>
getByPageNotAllData
(
VehiclePageQueryVo
vehiclePageQueryVo
,
List
<
Integer
>
companyList
)
throws
Exception
{
Map
<
String
,
Object
>
params
=
PropertyUtils
.
describe
(
vehiclePageQueryVo
);
Map
<
String
,
Object
>
params
=
PropertyUtils
.
describe
(
vehiclePageQueryVo
);
Integer
pageSize
=
(
Integer
)
params
.
get
(
"limit"
);
Integer
pageSize
=
(
Integer
)
params
.
get
(
"limit"
);
params
.
remove
(
"pageSize"
);
params
.
remove
(
"pageSize"
);
Integer
pageNo
=
(
Integer
)
params
.
get
(
"page"
);
Integer
pageNo
=
(
Integer
)
params
.
get
(
"page"
);
params
.
remove
(
"pageNo"
);
params
.
remove
(
"pageNo"
);
//处理预定日期相关参数
//处理预定日期相关参数
adjustBookedInfoParam
(
params
,
vehiclePageQueryVo
);
adjustBookedInfoParam
(
params
,
vehiclePageQueryVo
);
if
(
companyList
!=
null
&&
companyList
.
size
()
>
0
)
{
if
(
companyList
!=
null
&&
companyList
.
size
()
>
0
)
{
params
.
put
(
"companyList"
,
companyList
);
params
.
put
(
"companyList"
,
companyList
);
}
else
{
}
else
{
params
.
put
(
"companyList"
,
Arrays
.
asList
(-
1
));
params
.
put
(
"companyList"
,
Arrays
.
asList
(-
1
));
}
}
PageHelper
.
startPage
(
pageNo
,
pageSize
);
PageHelper
.
startPage
(
pageNo
,
pageSize
);
List
<
ResultVehicleVo
>
vehicles
=
mapper
.
getByPageNotAllData
(
params
);
List
<
ResultVehicleVo
>
vehicles
=
mapper
.
getByPageNotAllData
(
params
);
PageInfo
<
ResultVehicleVo
>
vehiclePageInfo
=
new
PageInfo
<>(
vehicles
);
PageInfo
<
ResultVehicleVo
>
vehiclePageInfo
=
new
PageInfo
<>(
vehicles
);
return
PageDataVO
.
pageInfo
(
vehiclePageInfo
);
return
PageDataVO
.
pageInfo
(
vehiclePageInfo
);
...
@@ -1169,9 +1192,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1169,9 +1192,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public
List
<
Integer
>
dataCompany
(
String
dataZone
,
String
dataCompany
)
{
public
List
<
Integer
>
dataCompany
(
String
dataZone
,
String
dataCompany
)
{
List
<
BranchCompany
>
zoneCompanys
=
branchCompanyBiz
.
dataCompany
(
dataZone
);
List
<
BranchCompany
>
zoneCompanys
=
branchCompanyBiz
.
dataCompany
(
dataZone
);
//((VehicleBiz)AopContext.currentProxy()).dataCompany(dataZone);
//((VehicleBiz)AopContext.currentProxy()).dataCompany(dataZone);
List
<
Integer
>
zoneCompanyIds
=
zoneCompanys
.
parallelStream
().
map
(
BranchCompany:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
Integer
>
zoneCompanyIds
=
zoneCompanys
.
parallelStream
().
map
(
BranchCompany:
:
getId
).
collect
(
Collectors
.
toList
());
if
(
StringUtils
.
isNotBlank
(
dataCompany
))
{
if
(
StringUtils
.
isNotBlank
(
dataCompany
))
{
List
<
Integer
>
dataCompanyIds
=
Arrays
.
asList
(
dataCompany
.
split
(
","
)).
parallelStream
().
map
(
s
->
Integer
.
valueOf
(
s
)).
collect
(
Collectors
.
toList
());
List
<
Integer
>
dataCompanyIds
=
Arrays
.
asList
(
dataCompany
.
split
(
","
)).
parallelStream
().
map
(
s
->
Integer
.
valueOf
(
s
)).
collect
(
Collectors
.
toList
());
zoneCompanyIds
.
addAll
(
dataCompanyIds
);
zoneCompanyIds
.
addAll
(
dataCompanyIds
);
}
}
...
@@ -1179,15 +1202,15 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1179,15 +1202,15 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return
zoneCompanyIds
.
parallelStream
().
distinct
().
collect
(
Collectors
.
toList
());
return
zoneCompanyIds
.
parallelStream
().
distinct
().
collect
(
Collectors
.
toList
());
}
}
public
PageDataVO
<
UsableVehicleModelVO
>
searchUsableModel
(
UsableVeicleDTO
dto
){
public
PageDataVO
<
UsableVehicleModelVO
>
searchUsableModel
(
UsableVeicleDTO
dto
)
{
Map
<
String
,
Object
>
params
=
BeanUtil
.
beanToMap
(
dto
);
Map
<
String
,
Object
>
params
=
BeanUtil
.
beanToMap
(
dto
);
if
(
StrUtil
.
isNotBlank
(
dto
.
getStartDate
())
&&
StrUtil
.
isNotBlank
(
dto
.
getEndDate
()))
{
if
(
StrUtil
.
isNotBlank
(
dto
.
getStartDate
())
&&
StrUtil
.
isNotBlank
(
dto
.
getEndDate
()))
{
initBookSearchParam
(
dto
,
params
);
initBookSearchParam
(
dto
,
params
);
}
}
return
PageDataVO
.
pageInfo
(
dto
.
getPage
(),
dto
.
getLimit
(),
()
->
mapper
.
searchUsableModel
(
params
));
return
PageDataVO
.
pageInfo
(
dto
.
getPage
(),
dto
.
getLimit
(),
()
->
mapper
.
searchUsableModel
(
params
));
}
}
public
PageDataVO
<
UsableVehicleModelVO
>
hotModel
(
HotVeicleDTO
dto
){
public
PageDataVO
<
UsableVehicleModelVO
>
hotModel
(
HotVeicleDTO
dto
)
{
dto
.
setHotSign
(
1
);
dto
.
setHotSign
(
1
);
Map
<
String
,
Object
>
params
=
BeanUtil
.
beanToMap
(
dto
);
Map
<
String
,
Object
>
params
=
BeanUtil
.
beanToMap
(
dto
);
return
PageDataVO
.
pageInfo
(
dto
.
getPage
(),
dto
.
getLimit
(),
()
->
mapper
.
searchUsableModel
(
params
));
return
PageDataVO
.
pageInfo
(
dto
.
getPage
(),
dto
.
getLimit
(),
()
->
mapper
.
searchUsableModel
(
params
));
...
@@ -1195,7 +1218,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1195,7 +1218,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
private
void
initBookSearchParam
(
UsableVeicleDTO
dto
,
Map
<
String
,
Object
>
params
)
{
private
void
initBookSearchParam
(
UsableVeicleDTO
dto
,
Map
<
String
,
Object
>
params
)
{
List
<
String
>
notBookedDates
=
Lists
.
newArrayList
();
List
<
String
>
notBookedDates
=
Lists
.
newArrayList
();
if
(
StringUtils
.
isNotBlank
(
dto
.
getStartDate
())
&&
if
(
StringUtils
.
isNotBlank
(
dto
.
getStartDate
())
&&
StringUtils
.
isNotBlank
(
dto
.
getEndDate
()))
{
StringUtils
.
isNotBlank
(
dto
.
getEndDate
()))
{
// notBookedDates = convertDatePeriod2List(dto.getStartDate(),
// notBookedDates = convertDatePeriod2List(dto.getStartDate(),
// dto.getEndDate());
// dto.getEndDate());
...
@@ -1204,27 +1227,27 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1204,27 +1227,27 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
}
//若传入预定信息查询条件,则查询对应月份预定信息查询条件(不超过3个月)
//若传入预定信息查询条件,则查询对应月份预定信息查询条件(不超过3个月)
if
(
CollectionUtils
.
isEmpty
(
notBookedDates
))
{
if
(
CollectionUtils
.
isEmpty
(
notBookedDates
))
{
throw
new
BaseException
(
ResultCode
.
NOTEXIST_CODE
);
throw
new
BaseException
(
ResultCode
.
NOTEXIST_CODE
);
}
}
//筛选出查询条件所在月份 如 想预定 8月29 ~ 9月 4日
//筛选出查询条件所在月份 如 想预定 8月29 ~ 9月 4日
Set
<
String
>
allYearMonth
=
new
HashSet
<>();
//记录所有年月 "2019-08","2019-09"
Set
<
String
>
allYearMonth
=
new
HashSet
<>();
//记录所有年月 "2019-08","2019-09"
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
//需比较已预定的年月 - 预定日期列表 为空(拒绝 预约记录时用到)
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
//需比较已预定的年月 - 预定日期列表 为空(拒绝 预约记录时用到)
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
=
new
HashMap
<>();
//需比较未预定的年月 - 未预定日期列表 "2019-08-29"...."2019-09-04",
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
=
new
HashMap
<>();
//需比较未预定的年月 - 未预定日期列表 "2019-08-29"...."2019-09-04",
classifyByYearMonth
(
notBookedDates
,
yearMonthAndDateNotBooked
,
allYearMonth
);
classifyByYearMonth
(
notBookedDates
,
yearMonthAndDateNotBooked
,
allYearMonth
);
if
(
allYearMonth
.
size
()>
MAX_MONTH_COUNT_BOOKED_INFO_QUERY
)
{
if
(
allYearMonth
.
size
()
>
MAX_MONTH_COUNT_BOOKED_INFO_QUERY
)
{
throw
new
BaseException
(
" only 3 month can be included <bookedInfo> param."
);
throw
new
BaseException
(
" only 3 month can be included <bookedInfo> param."
);
}
}
//加入预定信息查询条件
//加入预定信息查询条件
fillBookedDateSearchParam
(
params
,
yearMonthAndDate
,
yearMonthAndDateNotBooked
);
fillBookedDateSearchParam
(
params
,
yearMonthAndDate
,
yearMonthAndDateNotBooked
);
}
}
public
PageDataVO
<
Vehicle
>
searchUsableVehicle
(
RentVehicleBookDTO
dto
)
{
public
PageDataVO
<
Vehicle
>
searchUsableVehicle
(
RentVehicleBookDTO
dto
)
{
Map
<
String
,
Object
>
params
=
BeanUtil
.
beanToMap
(
dto
);
Map
<
String
,
Object
>
params
=
BeanUtil
.
beanToMap
(
dto
);
List
<
String
>
notBookedDates
=
Lists
.
newArrayList
();
List
<
String
>
notBookedDates
=
Lists
.
newArrayList
();
if
(
StringUtils
.
isNotBlank
(
dto
.
getBookEndDate
())
&&
if
(
StringUtils
.
isNotBlank
(
dto
.
getBookEndDate
())
&&
StringUtils
.
isNotBlank
(
dto
.
getBookEndDate
()))
{
StringUtils
.
isNotBlank
(
dto
.
getBookEndDate
()))
{
// notBookedDates = convertDatePeriod2List(dto.getBookStartDate(),
// notBookedDates = convertDatePeriod2List(dto.getBookStartDate(),
// dto.getBookEndDate());
// dto.getBookEndDate());
...
@@ -1233,19 +1256,19 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1233,19 +1256,19 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
}
//若传入预定信息查询条件,则查询对应月份预定信息查询条件(不超过3个月)
//若传入预定信息查询条件,则查询对应月份预定信息查询条件(不超过3个月)
if
(
CollectionUtils
.
isEmpty
(
notBookedDates
))
{
if
(
CollectionUtils
.
isEmpty
(
notBookedDates
))
{
//return;
//return;
}
}
//筛选出查询条件所在月份
//筛选出查询条件所在月份
Set
<
String
>
allYearMonth
=
new
HashSet
<>();
//记录所有年月
Set
<
String
>
allYearMonth
=
new
HashSet
<>();
//记录所有年月
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
//预定年月 - 预定日期列表
Map
<
String
,
List
<
String
>>
yearMonthAndDate
=
new
HashMap
<>();
//预定年月 - 预定日期列表
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
=
new
HashMap
<>();
//未预定年月 - 未预定日期列表
Map
<
String
,
List
<
String
>>
yearMonthAndDateNotBooked
=
new
HashMap
<>();
//未预定年月 - 未预定日期列表
classifyByYearMonth
(
notBookedDates
,
yearMonthAndDateNotBooked
,
allYearMonth
);
classifyByYearMonth
(
notBookedDates
,
yearMonthAndDateNotBooked
,
allYearMonth
);
if
(
allYearMonth
.
size
()>
MAX_MONTH_COUNT_BOOKED_INFO_QUERY
)
{
if
(
allYearMonth
.
size
()
>
MAX_MONTH_COUNT_BOOKED_INFO_QUERY
)
{
throw
new
BaseException
(
" only 3 month can be included <bookedInfo> param."
);
throw
new
BaseException
(
" only 3 month can be included <bookedInfo> param."
);
}
}
//加入预定信息查询条件
//加入预定信息查询条件
fillBookedDateSearchParam
(
params
,
yearMonthAndDate
,
yearMonthAndDateNotBooked
);
fillBookedDateSearchParam
(
params
,
yearMonthAndDate
,
yearMonthAndDateNotBooked
);
PageHelper
.
startPage
(
dto
.
getPage
(),
dto
.
getLimit
());
PageHelper
.
startPage
(
dto
.
getPage
(),
dto
.
getLimit
());
List
<
Vehicle
>
lists
=
mapper
.
searchUsableVehicle
(
params
);
List
<
Vehicle
>
lists
=
mapper
.
searchUsableVehicle
(
params
);
...
@@ -1255,38 +1278,40 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1255,38 +1278,40 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 保存
* 保存
*
* @param vehicle
* @param vehicle
* @return
* @return
*/
*/
@Transactional
@Transactional
public
ObjectRestResponse
save
(
Vehicle
vehicle
){
public
ObjectRestResponse
save
(
Vehicle
vehicle
)
{
if
(
vehicle
==
null
)
{
if
(
vehicle
==
null
)
{
ObjectRestResponse
.
paramIsEmpty
();
ObjectRestResponse
.
paramIsEmpty
();
}
}
String
id
=
vehicle
.
getId
();
String
id
=
vehicle
.
getId
();
if
(
StringUtils
.
isBlank
(
id
))
{
if
(
StringUtils
.
isBlank
(
id
))
{
insertSelective
(
vehicle
);
insertSelective
(
vehicle
);
insertSelective
(
vehicle
);
insertSelective
(
vehicle
);
}
else
{
}
else
{
updateSelectiveById
(
vehicle
);
updateSelectiveById
(
vehicle
);
}
}
return
ObjectRestResponse
.
succ
();
return
ObjectRestResponse
.
succ
();
}
}
/**
/**
* 查找
* 查找
*
* @param vehicleVo
* @param vehicleVo
* @param page
* @param page
* @param limit
* @param limit
* @return
* @return
*/
*/
public
ObjectRestResponse
findListByVehicle
(
VehicleVo
vehicleVo
,
Integer
page
,
Integer
limit
){
public
ObjectRestResponse
findListByVehicle
(
VehicleVo
vehicleVo
,
Integer
page
,
Integer
limit
)
{
Vehicle
vehicle
=
new
Vehicle
();
Vehicle
vehicle
=
new
Vehicle
();
// vehicleVo复制一份到vehicle
// vehicleVo复制一份到vehicle
try
{
try
{
BeanUtilsBean
.
getInstance
().
copyProperties
(
vehicle
,
vehicleVo
);
BeanUtilsBean
.
getInstance
().
copyProperties
(
vehicle
,
vehicleVo
);
}
catch
(
IllegalAccessException
e
)
{
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
InvocationTargetException
e
)
{
}
catch
(
InvocationTargetException
e
)
{
...
@@ -1297,33 +1322,33 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1297,33 +1322,33 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
WeekendSqls
<
Vehicle
>
sqls
=
WeekendSqls
.<
Vehicle
>
custom
();
WeekendSqls
<
Vehicle
>
sqls
=
WeekendSqls
.<
Vehicle
>
custom
();
//车辆状态
//车辆状态
if
(
vehicle
.
getStatus
()!=
null
||
vehicle
.
getStatus
()!=
0
)
{
if
(
vehicle
.
getStatus
()
!=
null
||
vehicle
.
getStatus
()
!=
0
)
{
sqls
.
andEqualTo
(
Vehicle:
:
getStatus
,
vehicle
.
getStatus
());
sqls
.
andEqualTo
(
Vehicle:
:
getStatus
,
vehicle
.
getStatus
());
}
}
//车牌号
//车牌号
if
(
StringUtils
.
isBlank
(
vehicle
.
getNumberPlate
()))
{
if
(
StringUtils
.
isBlank
(
vehicle
.
getNumberPlate
()))
{
sqls
.
andEqualTo
(
Vehicle:
:
getNumberPlate
,
vehicle
.
getNumberPlate
());
sqls
.
andEqualTo
(
Vehicle:
:
getNumberPlate
,
vehicle
.
getNumberPlate
());
Function
<
Vehicle
,
Integer
>
getStatus
=
Vehicle:
:
getStatus
;
Function
<
Vehicle
,
Integer
>
getStatus
=
Vehicle:
:
getStatus
;
}
}
//公司
//公司
if
(
vehicle
.
getSubordinateBranch
()==
null
||
vehicle
.
getSubordinateBranch
()==
0
)
{
if
(
vehicle
.
getSubordinateBranch
()
==
null
||
vehicle
.
getSubordinateBranch
()
==
0
)
{
sqls
.
andEqualTo
(
Vehicle:
:
getSubordinateBranch
,
vehicle
.
getSubordinateBranch
());
sqls
.
andEqualTo
(
Vehicle:
:
getSubordinateBranch
,
vehicle
.
getSubordinateBranch
());
}
}
//大区
//大区
if
(
vehicleVo
.
getZoneId
()==
null
||
vehicleVo
.
getZoneId
()==
0
)
{
if
(
vehicleVo
.
getZoneId
()
==
null
||
vehicleVo
.
getZoneId
()
==
0
)
{
//获取大区内的公司id
//获取大区内的公司id
Example
example
=
Example
.
builder
(
BranchCompany
.
class
).
where
(
WeekendSqls
.<
BranchCompany
>
custom
()
Example
example
=
Example
.
builder
(
BranchCompany
.
class
).
where
(
WeekendSqls
.<
BranchCompany
>
custom
()
.
andEqualTo
(
BranchCompany:
:
getZoneId
,
vehicleVo
.
getZoneId
())).
build
();
.
andEqualTo
(
BranchCompany:
:
getZoneId
,
vehicleVo
.
getZoneId
())).
build
();
List
<
BranchCompany
>
branchCompanies
=
branchCompanyBiz
.
selectByExample
(
example
);
List
<
BranchCompany
>
branchCompanies
=
branchCompanyBiz
.
selectByExample
(
example
);
ArrayList
<
Integer
>
bIds
=
new
ArrayList
<>();
ArrayList
<
Integer
>
bIds
=
new
ArrayList
<>();
for
(
BranchCompany
branchCompany
:
branchCompanies
)
{
for
(
BranchCompany
branchCompany
:
branchCompanies
)
{
bIds
.
add
(
branchCompany
.
getId
());
bIds
.
add
(
branchCompany
.
getId
());
}
}
sqls
.
andIn
(
Vehicle:
:
getSubordinateBranch
,
bIds
);
sqls
.
andIn
(
Vehicle:
:
getSubordinateBranch
,
bIds
);
}
}
sqls
.
andEqualTo
(
Vehicle:
:
getStatus
,
0
);
sqls
.
andEqualTo
(
Vehicle:
:
getStatus
,
0
);
Example
exa
=
Example
.
builder
(
Vehicle
.
class
).
where
(
sqls
).
build
();
Example
exa
=
Example
.
builder
(
Vehicle
.
class
).
where
(
sqls
).
build
();
PageDataVO
<
Object
>
objectPageDataVO
=
PageDataVO
.
pageInfo
(
page
,
limit
,
()
->
selectByExample
(
exa
));
PageDataVO
<
Object
>
objectPageDataVO
=
PageDataVO
.
pageInfo
(
page
,
limit
,
()
->
selectByExample
(
exa
));
return
ObjectRestResponse
.
succ
(
objectPageDataVO
);
return
ObjectRestResponse
.
succ
(
objectPageDataVO
);
...
@@ -1331,17 +1356,18 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1331,17 +1356,18 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
/**
/**
* 查询条
* 查询条
*
* @param id
* @param id
* @return
* @return
*/
*/
public
ObjectRestResponse
getOneById
(
Integer
id
){
public
ObjectRestResponse
getOneById
(
Integer
id
)
{
return
ObjectRestResponse
.
succ
(
selectByExample
(
return
ObjectRestResponse
.
succ
(
selectByExample
(
Example
.
builder
(
Vehicle
.
class
)
Example
.
builder
(
Vehicle
.
class
)
.
where
(
WeekendSqls
.<
Vehicle
>
custom
()
.
where
(
WeekendSqls
.<
Vehicle
>
custom
()
.
andEqualTo
(
Vehicle:
:
getId
,
id
)
.
andEqualTo
(
Vehicle:
:
getId
,
id
)
.
andEqualTo
(
Vehicle:
:
getStatus
,
0
))
.
andEqualTo
(
Vehicle:
:
getStatus
,
0
))
.
build
()));
.
build
()));
}
}
...
@@ -1356,21 +1382,21 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1356,21 +1382,21 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
}
public
ObjectRestResponse
<
PageDataVO
<
VehicleAndModelInfoVo
>>
getVehicle
(
VehiclePlanDto
vehiclePlanDto
)
{
public
ObjectRestResponse
<
PageDataVO
<
VehicleAndModelInfoVo
>>
getVehicle
(
VehiclePlanDto
vehiclePlanDto
)
{
Integer
page
=
vehiclePlanDto
.
getPage
()
==
null
?
1
:
vehiclePlanDto
.
getPage
();
Integer
page
=
vehiclePlanDto
.
getPage
()
==
null
?
1
:
vehiclePlanDto
.
getPage
();
Integer
limit
=
vehiclePlanDto
.
getLimit
()
==
null
?
10
:
vehiclePlanDto
.
getLimit
();
Integer
limit
=
vehiclePlanDto
.
getLimit
()
==
null
?
10
:
vehiclePlanDto
.
getLimit
();
vehiclePlanDto
.
setPage
(
page
);
vehiclePlanDto
.
setPage
(
page
);
vehiclePlanDto
.
setLimit
(
limit
);
vehiclePlanDto
.
setLimit
(
limit
);
UserDTO
userDTO
=
getAdminUserInfo
();
UserDTO
userDTO
=
getAdminUserInfo
();
if
(
userDTO
==
null
)
{
if
(
userDTO
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
RSTOKEN_EXPIRED_CODE
,
"token失效"
);
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
RSTOKEN_EXPIRED_CODE
,
"token失效"
);
}
}
List
<
Integer
>
companyList
=
Lists
.
newArrayList
();
List
<
Integer
>
companyList
=
Lists
.
newArrayList
();
List
<
BranchCompany
>
branchCompany
=
branchCompanyBiz
.
getListByUser
(
userDTO
);
List
<
BranchCompany
>
branchCompany
=
branchCompanyBiz
.
getListByUser
(
userDTO
);
companyList
=
branchCompany
.
stream
().
map
(
BranchCompany:
:
getId
).
collect
(
Collectors
.
toList
());
companyList
=
branchCompany
.
stream
().
map
(
BranchCompany:
:
getId
).
collect
(
Collectors
.
toList
());
if
(
vehiclePlanDto
.
getParkBranchCompanyId
()
!=
null
)
{
if
(
vehiclePlanDto
.
getParkBranchCompanyId
()
!=
null
)
{
if
(
companyList
.
size
()
>
0
)
{
if
(
companyList
.
size
()
>
0
)
{
if
(
companyList
.
contains
(
vehiclePlanDto
.
getParkBranchCompanyId
()))
{
if
(
companyList
.
contains
(
vehiclePlanDto
.
getParkBranchCompanyId
()))
{
companyList
.
clear
();
companyList
.
clear
();
companyList
.
add
(
vehiclePlanDto
.
getParkBranchCompanyId
());
companyList
.
add
(
vehiclePlanDto
.
getParkBranchCompanyId
());
}
else
{
}
else
{
...
@@ -1388,27 +1414,27 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1388,27 +1414,27 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
}
//删除车辆信息
//删除车辆信息
public
RestResponse
delVehicleById
(
String
id
)
{
public
RestResponse
delVehicleById
(
String
id
)
{
Vehicle
vehicle
=
new
Vehicle
();
Vehicle
vehicle
=
new
Vehicle
();
vehicle
.
setId
(
id
);
vehicle
.
setId
(
id
);
vehicle
.
setIsDel
(
1
);
vehicle
.
setIsDel
(
1
);
updateSelectiveById
(
vehicle
);
updateSelectiveById
(
vehicle
);
return
RestResponse
.
suc
();
return
RestResponse
.
suc
();
}
}
public
List
<
String
>
getHourList
(
String
result
)
{
public
List
<
String
>
getHourList
(
String
result
)
{
StringBuffer
stringBuffer
=
new
StringBuffer
();
StringBuffer
stringBuffer
=
new
StringBuffer
();
if
(
result
.
length
()
<
24
)
{
//如果不足24位补0
if
(
result
.
length
()
<
24
)
{
//如果不足24位补0
for
(
int
i
=
0
;
i
<
24
-
result
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
24
-
result
.
length
();
i
++)
{
stringBuffer
.
append
(
"0"
);
stringBuffer
.
append
(
"0"
);
}
}
log
.
info
(
stringBuffer
.
toString
());
log
.
info
(
stringBuffer
.
toString
());
}
}
stringBuffer
.
append
(
result
);
stringBuffer
.
append
(
result
);
List
<
String
>
list
=
new
ArrayList
<>(
24
);
List
<
String
>
list
=
new
ArrayList
<>(
24
);
for
(
int
i
=
0
;
i
<
stringBuffer
.
toString
().
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
stringBuffer
.
toString
().
length
();
i
++)
{
if
(
"1"
.
equals
(
stringBuffer
.
toString
().
charAt
(
i
)+
""
))
{
if
(
"1"
.
equals
(
stringBuffer
.
toString
().
charAt
(
i
)
+
""
))
{
list
.
add
(
i
,
"1"
);
list
.
add
(
i
,
"1"
);
}
else
{
}
else
{
list
.
add
(
i
,
"0"
);
list
.
add
(
i
,
"0"
);
...
@@ -1418,6 +1444,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -1418,6 +1444,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
}
public
List
<
String
>
findExistVehicleIds
()
{
public
List
<
String
>
findExistVehicleIds
()
{
return
mapper
.
findExistVehicleIds
();
return
mapper
.
findExistVehicleIds
();
}
}
}
}
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleBookHourInfoBiz.java
View file @
a54d4d50
...
@@ -41,19 +41,19 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
...
@@ -41,19 +41,19 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
public
static
final
DateTimeFormatter
DEFAULT_DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd HH:mm:ss"
);
public
static
final
DateTimeFormatter
DEFAULT_DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd HH:mm:ss"
);
public
static
final
DateTimeFormatter
DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd"
);
public
static
final
DateTimeFormatter
DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd"
);
public
Map
<
String
,
Integer
>
getPredictableHours
(
String
bookStartDate
,
String
bookEndDate
,
Boolean
notCheckTimeLegal
)
{
public
Map
<
String
,
Integer
>
getPredictableHours
(
String
bookStartDate
,
String
bookEndDate
,
Boolean
notCheckTimeLegal
)
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Date
startDate
=
null
;
Date
startDate
=
null
;
Date
endDate
=
null
;
Date
endDate
=
null
;
try
{
try
{
startDate
=
simpleDateFormat
.
parse
(
bookStartDate
);
startDate
=
simpleDateFormat
.
parse
(
bookStartDate
);
endDate
=
simpleDateFormat
.
parse
(
bookEndDate
);
endDate
=
simpleDateFormat
.
parse
(
bookEndDate
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
//判定时间是否合法
//判定时间是否合法
if
(!
Boolean
.
TRUE
.
equals
(
notCheckTimeLegal
))
{
if
(!
Boolean
.
TRUE
.
equals
(
notCheckTimeLegal
))
{
if
(
bookStartDate
.
compareTo
(
DateTime
.
now
().
toString
(
DEFAULT_DATE_TIME_FORMATTER
))
<
0
)
{
if
(
bookStartDate
.
compareTo
(
DateTime
.
now
().
toString
(
DEFAULT_DATE_TIME_FORMATTER
))
<
0
)
{
throw
new
BaseException
(
ResultCode
.
ONLY_BOOK_FROM_TODAY
);
throw
new
BaseException
(
ResultCode
.
ONLY_BOOK_FROM_TODAY
);
}
}
...
@@ -78,17 +78,17 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
...
@@ -78,17 +78,17 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
}
}
DateTime
startDay
=
DateTime
.
parse
(
DateTime
.
parse
(
bookStartDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
),
DATE_TIME_FORMATTER
);
DateTime
startDay
=
DateTime
.
parse
(
DateTime
.
parse
(
bookStartDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
),
DATE_TIME_FORMATTER
);
DateTime
endDay
=
DateTime
.
parse
(
DateTime
.
parse
(
bookEndDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
),
DATE_TIME_FORMATTER
);
DateTime
endDay
=
DateTime
.
parse
(
DateTime
.
parse
(
bookEndDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
),
DATE_TIME_FORMATTER
);
if
(
startPredictableHour
==
0
)
{
//如果是0点就直接预订全天
if
(
startPredictableHour
==
0
)
{
//如果是0点就直接预订全天
startPredictableHour
=
16777215
;
startPredictableHour
=
16777215
;
}
}
if
(
DateTime
.
parse
(
bookStartDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
).
equals
(
DateTime
.
parse
(
bookEndDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
)))
{
//同一天预定
if
(
DateTime
.
parse
(
bookStartDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
).
equals
(
DateTime
.
parse
(
bookEndDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
)))
{
//同一天预定
//如果开始时间是0点开始
//如果开始时间是0点开始
predictableHours
.
put
(
DateTime
.
parse
(
bookStartDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
),
startPredictableHour
&
endPredictableHour
);
predictableHours
.
put
(
DateTime
.
parse
(
bookStartDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
),
startPredictableHour
&
endPredictableHour
);
}
else
{
//非同一天开始
}
else
{
//非同一天开始
predictableHours
.
put
(
DateTime
.
parse
(
bookStartDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
),
startPredictableHour
);
predictableHours
.
put
(
DateTime
.
parse
(
bookStartDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
),
startPredictableHour
);
predictableHours
.
put
(
DateTime
.
parse
(
bookEndDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
),
endPredictableHour
);
predictableHours
.
put
(
DateTime
.
parse
(
bookEndDate
,
DEFAULT_DATE_TIME_FORMATTER
).
toString
(
DATE_TIME_FORMATTER
),
endPredictableHour
);
}
}
if
(
endDay
.
getMillis
()
-
startDay
.
getMillis
()
>
24
*
3600
*
1000
)
{
//
if
(
endDay
.
getMillis
()
-
startDay
.
getMillis
()
>
24
*
3600
*
1000
)
{
//
for
(
DateTime
curDate
=
startDay
.
plusDays
(
1
);
curDate
.
compareTo
(
endDay
)
<
0
;
curDate
=
curDate
.
plusDays
(
1
))
{
for
(
DateTime
curDate
=
startDay
.
plusDays
(
1
);
curDate
.
compareTo
(
endDay
)
<
0
;
curDate
=
curDate
.
plusDays
(
1
))
{
String
curDateStr
=
curDate
.
toString
(
DATE_TIME_FORMATTER
);
String
curDateStr
=
curDate
.
toString
(
DATE_TIME_FORMATTER
);
//全天预定
//全天预定
...
@@ -115,14 +115,14 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
...
@@ -115,14 +115,14 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
@Transactional
@Transactional
@CacheClear
(
key
=
"vehicle.hourInfo"
)
@CacheClear
(
key
=
"vehicle.hourInfo"
)
public
ObjectRestResponse
save
(
VehicleBookHourInfoDto
vehicleBookHourInfoDto
)
{
public
ObjectRestResponse
save
(
VehicleBookHourInfoDto
vehicleBookHourInfoDto
)
{
if
(
vehicleBookHourInfoDto
==
null
)
{
if
(
vehicleBookHourInfoDto
==
null
)
{
return
ObjectRestResponse
.
paramIsEmpty
();
return
ObjectRestResponse
.
paramIsEmpty
();
}
}
List
<
VehicleBookHourInfo
>
vehicleBookHourInfos
=
mapper
.
selectByVehicleAndDate
(
vehicleBookHourInfoDto
);
List
<
VehicleBookHourInfo
>
vehicleBookHourInfos
=
mapper
.
selectByVehicleAndDate
(
vehicleBookHourInfoDto
);
//有数据直接更新
//有数据直接更新
if
(
vehicleBookHourInfos
.
size
()
>=
1
)
{
if
(
vehicleBookHourInfos
.
size
()
>=
1
)
{
for
(
VehicleBookHourInfo
vehicleBookHourInfo
:
vehicleBookHourInfos
)
{
for
(
VehicleBookHourInfo
vehicleBookHourInfo
:
vehicleBookHourInfos
)
{
if
(
vehicleBookHourInfo
.
getBookedHour
().
equals
(
vehicleBookHourInfoDto
.
getBookedHour
()))
{
if
(
vehicleBookHourInfo
.
getBookedHour
().
equals
(
vehicleBookHourInfoDto
.
getBookedHour
()))
{
return
ObjectRestResponse
.
createFailedResult
(
ResCode
.
VEHICLE_IS_BOOKED_TODAY
.
getCode
(),
ResCode
.
VEHICLE_IS_BOOKED_TODAY
.
getDesc
());
return
ObjectRestResponse
.
createFailedResult
(
ResCode
.
VEHICLE_IS_BOOKED_TODAY
.
getCode
(),
ResCode
.
VEHICLE_IS_BOOKED_TODAY
.
getDesc
());
}
else
{
}
else
{
vehicleBookHourInfo
.
setBookedHour
(
vehicleBookHourInfo
.
getBookedHour
()
|
vehicleBookHourInfoDto
.
getBookedHour
());
vehicleBookHourInfo
.
setBookedHour
(
vehicleBookHourInfo
.
getBookedHour
()
|
vehicleBookHourInfoDto
.
getBookedHour
());
...
@@ -138,6 +138,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
...
@@ -138,6 +138,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
/**
/**
* 删除预定车辆小时记录信息
* 删除预定车辆小时记录信息
*
* @param vehicleId 车辆Id
* @param vehicleId 车辆Id
* @param dateList 日期列表
* @param dateList 日期列表
* @return
* @return
...
@@ -145,7 +146,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
...
@@ -145,7 +146,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
@Transactional
@Transactional
@CacheClear
(
key
=
"vehicle.hourInfo"
)
@CacheClear
(
key
=
"vehicle.hourInfo"
)
public
ObjectRestResponse
delete
(
String
vehicleId
,
List
<
String
>
dateList
)
{
public
ObjectRestResponse
delete
(
String
vehicleId
,
List
<
String
>
dateList
)
{
if
(
StringUtils
.
isBlank
(
vehicleId
)
||
dateList
.
size
()
<=
0
)
{
if
(
StringUtils
.
isBlank
(
vehicleId
)
||
dateList
.
size
()
<=
0
)
{
return
ObjectRestResponse
.
paramIsEmpty
();
return
ObjectRestResponse
.
paramIsEmpty
();
}
}
Map
<
String
,
Object
>
param
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
param
=
Maps
.
newHashMap
();
...
@@ -156,15 +157,15 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
...
@@ -156,15 +157,15 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
return
ObjectRestResponse
.
succ
();
return
ObjectRestResponse
.
succ
();
}
}
public
ObjectRestResponse
checkBookHourInfo
()
{
public
ObjectRestResponse
checkBookHourInfo
()
{
List
<
VehicleBookHourInfoDto
>
vehicleBookHourInfos
=
new
ArrayList
<>();
List
<
VehicleBookHourInfoDto
>
vehicleBookHourInfos
=
new
ArrayList
<>();
List
<
VehicleBookRecord
>
list
=
vehicleBookRecordBiz
.
selectListAll
();
List
<
VehicleBookRecord
>
list
=
vehicleBookRecordBiz
.
selectListAll
();
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
for
(
VehicleBookRecord
vehicleBookRecord
:
list
)
{
for
(
VehicleBookRecord
vehicleBookRecord
:
list
)
{
VehicleDepartureLogVo
vehicleDepartureLog
=
vehicleDepartureService
.
getByRecordId
(
vehicleBookRecord
.
getId
());
VehicleDepartureLogVo
vehicleDepartureLog
=
vehicleDepartureService
.
getByRecordId
(
vehicleBookRecord
.
getId
());
if
((
vehicleDepartureLog
==
null
||
vehicleDepartureLog
.
getState
()
!=
1
)
&&
(
vehicleBookRecord
.
getStatus
()
==
2
||
vehicleBookRecord
.
getStatus
()
==
1
))
{
//未出车或未还车
if
((
vehicleDepartureLog
==
null
||
vehicleDepartureLog
.
getState
()
!=
1
)
&&
(
vehicleBookRecord
.
getStatus
()
==
2
||
vehicleBookRecord
.
getStatus
()
==
1
))
{
//未出车或未还车
Map
<
String
,
Integer
>
map
=
getPredictableHours
(
new
DateTime
(
vehicleBookRecord
.
getBookStartDate
()).
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
()).
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
Boolean
.
TRUE
);
Map
<
String
,
Integer
>
map
=
getPredictableHours
(
new
DateTime
(
vehicleBookRecord
.
getBookStartDate
()).
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
new
DateTime
(
vehicleBookRecord
.
getBookEndDate
()).
toString
(
DEFAULT_DATE_TIME_FORMATTER
),
Boolean
.
TRUE
);
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
map
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
map
.
entrySet
())
{
VehicleBookHourInfoDto
vehicleBookHourInfoDto
=
new
VehicleBookHourInfoDto
();
VehicleBookHourInfoDto
vehicleBookHourInfoDto
=
new
VehicleBookHourInfoDto
();
vehicleBookHourInfoDto
.
setVehicleId
(
vehicleBookRecord
.
getVehicleId
());
vehicleBookHourInfoDto
.
setVehicleId
(
vehicleBookRecord
.
getVehicleId
());
vehicleBookHourInfoDto
.
setYearMonthDay
(
entry
.
getKey
());
vehicleBookHourInfoDto
.
setYearMonthDay
(
entry
.
getKey
());
...
@@ -204,10 +205,10 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
...
@@ -204,10 +205,10 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
VehicleBookHourInfoBiz
vehicleBookHourInfoBiz
=
new
VehicleBookHourInfoBiz
();
VehicleBookHourInfoBiz
vehicleBookHourInfoBiz
=
new
VehicleBookHourInfoBiz
();
Map
<
String
,
Integer
>
map
=
vehicleBookHourInfoBiz
.
getPredictableHours
(
"2019-08-26 10:00:00"
,
"2019-08-27 10:00:00"
,
Boolean
.
TRUE
);
Map
<
String
,
Integer
>
map
=
vehicleBookHourInfoBiz
.
getPredictableHours
(
"2019-08-26 10:00:00"
,
"2019-08-27 10:00:00"
,
Boolean
.
TRUE
);
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
map
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
map
.
entrySet
())
{
System
.
out
.
println
(
entry
.
getKey
());
System
.
out
.
println
(
entry
.
getKey
());
System
.
out
.
println
(
entry
.
getValue
());
System
.
out
.
println
(
entry
.
getValue
());
}
}
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleBookInfoBiz.java
View file @
a54d4d50
...
@@ -29,7 +29,7 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
...
@@ -29,7 +29,7 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
public
static
final
DateTimeFormatter
YEARMONTH_DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM"
);
public
static
final
DateTimeFormatter
YEARMONTH_DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM"
);
public
static
final
Integer
DEL_BATCH_SIZE
=
1000
;
public
static
final
Integer
DEL_BATCH_SIZE
=
1000
;
public
static
final
Integer
COPY_BATCH_SIZE
=
100
;
public
static
final
Integer
COPY_BATCH_SIZE
=
100
;
public
static
final
int
MONTH_INTERVAL
=
2
;
public
static
final
int
MONTH_INTERVAL
=
2
;
@Autowired
@Autowired
private
RedisTemplate
customRedisTemplate
;
private
RedisTemplate
customRedisTemplate
;
...
@@ -40,14 +40,14 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
...
@@ -40,14 +40,14 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
*/
*/
@Scheduled
(
cron
=
"0 0 0 1 * ?"
)
//每月1号0点触发
@Scheduled
(
cron
=
"0 0 0 1 * ?"
)
//每月1号0点触发
@Transactional
@Transactional
public
void
transfer2HistoryTb
(){
public
void
transfer2HistoryTb
()
{
//获取表格名称
//获取表格名称
String
tbName
=
getTbNameNow
();
String
tbName
=
getTbNameNow
();
DateTime
now
=
DateTime
.
now
();
//当前获取的时间为标准
DateTime
now
=
DateTime
.
now
();
//当前获取的时间为标准
log
.
info
(
"开始预定信息迁移至历史表的定时任务。"
);
log
.
info
(
"开始预定信息迁移至历史表的定时任务。"
);
//每月初将上月数据复制到历史表
//每月初将上月数据复制到历史表
Boolean
needRun
=
copyDataLastMoth
(
now
,
tbName
);
Boolean
needRun
=
copyDataLastMoth
(
now
,
tbName
);
if
(
needRun
)
{
if
(
needRun
)
{
//每月初将上上月数据从当前信息表中删除
//每月初将上上月数据从当前信息表中删除
delDataTheMonthBeforeLast
(
now
,
tbName
);
delDataTheMonthBeforeLast
(
now
,
tbName
);
}
}
...
@@ -57,14 +57,14 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
...
@@ -57,14 +57,14 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
* 获取上月数据,并复制到历史表
* 获取上月数据,并复制到历史表
*/
*/
@Transactional
@Transactional
public
Boolean
copyDataLastMoth
(
DateTime
now
,
String
tbName
)
{
public
Boolean
copyDataLastMoth
(
DateTime
now
,
String
tbName
)
{
String
lastMonthStr
=
now
.
plusMonths
(-
1
).
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
String
lastMonthStr
=
now
.
plusMonths
(-
1
).
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
String
redisKey
=
RedisKey
.
DEL_BOOK_INFO_LOCK_PREFIX
+
lastMonthStr
;
String
redisKey
=
RedisKey
.
DEL_BOOK_INFO_LOCK_PREFIX
+
lastMonthStr
;
Boolean
hasSuc
=
customRedisTemplate
.
opsForValue
().
setIfAbsent
(
redisKey
,
String
.
valueOf
(
DateTime
.
now
().
getMillis
()));
Boolean
hasSuc
=
customRedisTemplate
.
opsForValue
().
setIfAbsent
(
redisKey
,
String
.
valueOf
(
DateTime
.
now
().
getMillis
()));
if
(
hasSuc
)
{
//设置1天后过期
if
(
hasSuc
)
{
//设置1天后过期
customRedisTemplate
.
expire
(
redisKey
,
1
,
TimeUnit
.
DAYS
);
customRedisTemplate
.
expire
(
redisKey
,
1
,
TimeUnit
.
DAYS
);
}
else
{
}
else
{
log
.
info
(
"[预定信息迁移]乐观锁获取失败,该线程不执行任务。"
);
log
.
info
(
"[预定信息迁移]乐观锁获取失败,该线程不执行任务。"
);
return
Boolean
.
FALSE
;
return
Boolean
.
FALSE
;
}
}
...
@@ -78,9 +78,9 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
...
@@ -78,9 +78,9 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
params
.
put
(
"pageStart"
,
(
curPageNo
-
1
)
*
COPY_BATCH_SIZE
);
params
.
put
(
"pageStart"
,
(
curPageNo
-
1
)
*
COPY_BATCH_SIZE
);
params
.
put
(
"pageSize"
,
COPY_BATCH_SIZE
);
params
.
put
(
"pageSize"
,
COPY_BATCH_SIZE
);
vehicleBookInfoList
=
mapper
.
getByPage4YearMonth
(
params
);
vehicleBookInfoList
=
mapper
.
getByPage4YearMonth
(
params
);
if
(
CollectionUtils
.
isNotEmpty
(
vehicleBookInfoList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
vehicleBookInfoList
))
{
//插入数据到历史表
//插入数据到历史表
for
(
VehicleBookInfo
vehicleBookInfo
:
vehicleBookInfoList
)
{
for
(
VehicleBookInfo
vehicleBookInfo
:
vehicleBookInfoList
)
{
Map
<
String
,
Object
>
insertHisParams
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
insertHisParams
=
Maps
.
newHashMap
();
insertHisParams
.
put
(
"tbName"
,
tbName
);
insertHisParams
.
put
(
"tbName"
,
tbName
);
insertHisParams
.
put
(
"id"
,
vehicleBookInfo
.
getId
());
insertHisParams
.
put
(
"id"
,
vehicleBookInfo
.
getId
());
...
@@ -91,17 +91,18 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
...
@@ -91,17 +91,18 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
}
}
}
}
curPageNo
++;
curPageNo
++;
log
.
info
(
"【复制上月预定信息至历史表中】,当前复制页【"
+
curPageNo
+
"】,页大小【"
+
COPY_BATCH_SIZE
+
"】"
);
log
.
info
(
"【复制上月预定信息至历史表中】,当前复制页【"
+
curPageNo
+
"】,页大小【"
+
COPY_BATCH_SIZE
+
"】"
);
}
while
(
CollectionUtils
.
isNotEmpty
(
vehicleBookInfoList
));
}
while
(
CollectionUtils
.
isNotEmpty
(
vehicleBookInfoList
));
log
.
info
(
"复制上月预定信息至历史表中完成,总页数【"
+(
curPageNo
-
1
)+
"】"
);
log
.
info
(
"复制上月预定信息至历史表中完成,总页数【"
+
(
curPageNo
-
1
)
+
"】"
);
;
return
Boolean
.
TRUE
;
;
return
Boolean
.
TRUE
;
}
}
/**
/**
* 删除上上月数据
* 删除上上月数据
*/
*/
@Transactional
@Transactional
public
void
delDataTheMonthBeforeLast
(
DateTime
now
,
String
tbName
)
{
public
void
delDataTheMonthBeforeLast
(
DateTime
now
,
String
tbName
)
{
String
theMonthBeforeLastStr
=
now
.
plusMonths
(-
2
).
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
String
theMonthBeforeLastStr
=
now
.
plusMonths
(-
2
).
toString
(
YEARMONTH_DATE_TIME_FORMATTER
);
Integer
effected
=
0
;
Integer
effected
=
0
;
Integer
total
=
0
;
Integer
total
=
0
;
...
@@ -110,21 +111,21 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
...
@@ -110,21 +111,21 @@ public class VehicleBookInfoBiz extends BaseBiz<VehicleBookInfoMapper, VehicleBo
params
.
put
(
"batchSize"
,
DEL_BATCH_SIZE
);
params
.
put
(
"batchSize"
,
DEL_BATCH_SIZE
);
do
{
do
{
effected
=
mapper
.
del4YearMoth
(
params
);
effected
=
mapper
.
del4YearMoth
(
params
);
total
+=
effected
;
total
+=
effected
;
log
.
info
(
"开始删除预定信息数据,删除总数【"
+
total
+
"】"
);
log
.
info
(
"开始删除预定信息数据,删除总数【"
+
total
+
"】"
);
}
while
(
effected
!=
0
);
}
while
(
effected
!=
0
);
log
.
info
(
"删除预定信息数据完成"
);
log
.
info
(
"删除预定信息数据完成"
);
}
}
private
String
getTbNameNow
(){
private
String
getTbNameNow
()
{
return
TB_NAME_PREFIX
+
DateTime
.
now
().
toString
(
YEAR_DATE_TIME_FORMATTER
);
return
TB_NAME_PREFIX
+
DateTime
.
now
().
toString
(
YEAR_DATE_TIME_FORMATTER
);
}
}
/**
/**
* 创建当年相关表格
* 创建当年相关表格
*/
*/
private
void
createTbIfNotExists
(
String
tbName
){
private
void
createTbIfNotExists
(
String
tbName
)
{
mapper
.
createTbIfNotExists
(
tbName
);
mapper
.
createTbIfNotExists
(
tbName
);
}
}
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleBookRecordBiz.java
View file @
a54d4d50
...
@@ -201,7 +201,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
...
@@ -201,7 +201,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
PageDataVO
<
VehicleBookRecordVo
>
vehicleBookRecordVoPageDataVO
=
PageDataVO
.
pageInfo
(
vehicleBookRecordVoPageInfo
);
PageDataVO
<
VehicleBookRecordVo
>
vehicleBookRecordVoPageDataVO
=
PageDataVO
.
pageInfo
(
vehicleBookRecordVoPageInfo
);
vehicleBookRecordVoPageDataVO
.
setPageNum
(
pageNo
);
vehicleBookRecordVoPageDataVO
.
setPageNum
(
pageNo
);
vehicleBookRecordVoPageDataVO
.
setPageSize
(
pageSize
);
vehicleBookRecordVoPageDataVO
.
setPageSize
(
pageSize
);
vehicleBookRecordVoPageDataVO
.
setTotalCount
((
long
)
vehicleBookRecordVoPageInfo
.
getList
().
size
());
vehicleBookRecordVoPageDataVO
.
setTotalCount
((
long
)
vehicleBookRecordVoPageInfo
.
getList
().
size
());
vehicleBookRecordVoPageDataVO
.
setTotalPage
((
vehicleBookRecordVoPageInfo
.
getList
().
size
()
+
pageSize
-
1
)
/
pageSize
);
vehicleBookRecordVoPageDataVO
.
setTotalPage
((
vehicleBookRecordVoPageInfo
.
getList
().
size
()
+
pageSize
-
1
)
/
pageSize
);
vehicleBookRecordVoPageDataVO
.
setData
(
getData
(
vehicleBookRecordVoPageInfo
.
getList
(),
pageNo
,
pageSize
));
vehicleBookRecordVoPageDataVO
.
setData
(
getData
(
vehicleBookRecordVoPageInfo
.
getList
(),
pageNo
,
pageSize
));
return
RestResponse
.
suc
(
vehicleBookRecordVoPageDataVO
);
return
RestResponse
.
suc
(
vehicleBookRecordVoPageDataVO
);
...
@@ -212,7 +212,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
...
@@ -212,7 +212,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
}
public
void
removeStatus2
(
List
<
VehicleBookRecordVo
>
list
)
{
public
void
removeStatus2
(
List
<
VehicleBookRecordVo
>
list
)
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
Iterator
<
VehicleBookRecordVo
>
iterator
=
list
.
iterator
();
Iterator
<
VehicleBookRecordVo
>
iterator
=
list
.
iterator
();
while
(
iterator
.
hasNext
())
{
while
(
iterator
.
hasNext
())
{
if
(
iterator
.
next
().
getVehicleDepartureLogVo
()
!=
null
)
{
if
(
iterator
.
next
().
getVehicleDepartureLogVo
()
!=
null
)
{
...
@@ -360,29 +360,30 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
...
@@ -360,29 +360,30 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
/**
/**
* 检验数据库预定记录日期是否和时间,日期表中的二进制数据一致
* 检验数据库预定记录日期是否和时间,日期表中的二进制数据一致
*
* @return
* @return
*/
*/
public
ObjectRestResponse
checkDateInvalide
(){
public
ObjectRestResponse
checkDateInvalide
()
{
List
<
VehicleBookRecord
>
list
=
mapper
.
selectAll
();
List
<
VehicleBookRecord
>
list
=
mapper
.
selectAll
();
List
<
VehicleBookRecord
>
unRightList
=
new
ArrayList
<>();
List
<
VehicleBookRecord
>
unRightList
=
new
ArrayList
<>();
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
for
(
VehicleBookRecord
vehicleBookRecord
:
list
)
{
for
(
VehicleBookRecord
vehicleBookRecord
:
list
)
{
log
.
info
(
"vehicleBookRecord = {}"
,
vehicleBookRecord
);
log
.
info
(
"vehicleBookRecord = {}"
,
vehicleBookRecord
);
Map
<
String
,
Integer
>
map
=
vehicleBookHourInfoBiz
.
getPredictableHours
(
DateUtil
.
dateToStr
(
vehicleBookRecord
.
getBookStartDate
(),
"yyyy-MM-dd HH:mm:ss"
),
DateUtil
.
dateToStr
(
vehicleBookRecord
.
getBookStartDate
(),
"yyyy-MM-dd HH:mm:ss"
),
Boolean
.
TRUE
);
Map
<
String
,
Integer
>
map
=
vehicleBookHourInfoBiz
.
getPredictableHours
(
DateUtil
.
dateToStr
(
vehicleBookRecord
.
getBookStartDate
(),
"yyyy-MM-dd HH:mm:ss"
),
DateUtil
.
dateToStr
(
vehicleBookRecord
.
getBookStartDate
(),
"yyyy-MM-dd HH:mm:ss"
),
Boolean
.
TRUE
);
log
.
info
(
"转换为时间二进制:map = {}"
,
map
);
log
.
info
(
"转换为时间二进制:map = {}"
,
map
);
//检验数据有效性
//检验数据有效性
if
(
vehicleBookRecord
.
getStatus
()
==
2
)
{
if
(
vehicleBookRecord
.
getStatus
()
==
2
)
{
VehicleDepartureLogVo
vehicleDepartureLog
=
vehicleDepartureService
.
getByRecordId
(
vehicleBookRecord
.
getId
());
VehicleDepartureLogVo
vehicleDepartureLog
=
vehicleDepartureService
.
getByRecordId
(
vehicleBookRecord
.
getId
());
if
(
vehicleDepartureLog
==
null
||
vehicleDepartureLog
.
getState
()
!=
1
)
{
//未出车或未还车
if
(
vehicleDepartureLog
==
null
||
vehicleDepartureLog
.
getState
()
!=
1
)
{
//未出车或未还车
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
map
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
map
.
entrySet
())
{
VehicleBookHourInfoDto
vehicleBookHourInfoDto
=
new
VehicleBookHourInfoDto
();
VehicleBookHourInfoDto
vehicleBookHourInfoDto
=
new
VehicleBookHourInfoDto
();
vehicleBookHourInfoDto
.
setVehicleId
(
vehicleBookRecord
.
getVehicleId
());
vehicleBookHourInfoDto
.
setVehicleId
(
vehicleBookRecord
.
getVehicleId
());
vehicleBookHourInfoDto
.
setYearMonthDay
(
entry
.
getKey
());
vehicleBookHourInfoDto
.
setYearMonthDay
(
entry
.
getKey
());
List
<
VehicleBookHourInfo
>
vehicleBookHourInfos
=
vehicleBookHourInfoBiz
.
selectByVehicleAndDate
(
vehicleBookHourInfoDto
);
List
<
VehicleBookHourInfo
>
vehicleBookHourInfos
=
vehicleBookHourInfoBiz
.
selectByVehicleAndDate
(
vehicleBookHourInfoDto
);
log
.
info
(
"预定时间信息:vehicleBookHourInfos = {}"
,
vehicleBookHourInfos
);
log
.
info
(
"预定时间信息:vehicleBookHourInfos = {}"
,
vehicleBookHourInfos
);
if
(
vehicleBookHourInfos
!=
null
&&
vehicleBookHourInfos
.
size
()
>
0
)
{
if
(
vehicleBookHourInfos
!=
null
&&
vehicleBookHourInfos
.
size
()
>
0
)
{
//检验数据是否存在
//检验数据是否存在
if
((
vehicleBookHourInfos
.
get
(
0
).
getBookedHour
()
&
entry
.
getValue
())
==
entry
.
getValue
())
{
if
((
vehicleBookHourInfos
.
get
(
0
).
getBookedHour
()
&
entry
.
getValue
())
==
entry
.
getValue
())
{
log
.
info
(
"时间正确,已经存在"
);
log
.
info
(
"时间正确,已经存在"
);
}
else
{
}
else
{
log
.
info
(
"时间不正确"
);
log
.
info
(
"时间不正确"
);
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleDepartureService.java
View file @
a54d4d50
...
@@ -86,7 +86,7 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
...
@@ -86,7 +86,7 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
}
else
{
}
else
{
vehicleDepartureLog
.
setUpdateTime
(
new
Date
());
vehicleDepartureLog
.
setUpdateTime
(
new
Date
());
VehicleDepartureLog
oldValue
=
mapper
.
selectByPrimaryKey
(
vehicleDepartureLog
);
VehicleDepartureLog
oldValue
=
mapper
.
selectByPrimaryKey
(
vehicleDepartureLog
);
if
(
oldValue
!=
null
)
{
if
(
oldValue
!=
null
)
{
log
.
info
(
"更新出行记录: vehicleDepartureLog = {}"
,
oldValue
);
log
.
info
(
"更新出行记录: vehicleDepartureLog = {}"
,
oldValue
);
BeanUtil
.
copyProperties
(
vehicleDepartureLog
,
oldValue
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
).
setIgnoreError
(
true
));
BeanUtil
.
copyProperties
(
vehicleDepartureLog
,
oldValue
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
).
setIgnoreError
(
true
));
oldValue
.
setUpdateTime
(
new
Date
());
oldValue
.
setUpdateTime
(
new
Date
());
...
@@ -104,7 +104,6 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
...
@@ -104,7 +104,6 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
}
}
public
ObjectRestResponse
findOne
(
Integer
vid
)
throws
Exception
{
public
ObjectRestResponse
findOne
(
Integer
vid
)
throws
Exception
{
Example
exm
=
Example
.
builder
(
VehicleDepartureLog
.
class
)
Example
exm
=
Example
.
builder
(
VehicleDepartureLog
.
class
)
.
where
(
WeekendSqls
.<
VehicleDepartureLog
>
custom
()
.
where
(
WeekendSqls
.<
VehicleDepartureLog
>
custom
()
...
@@ -116,7 +115,7 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
...
@@ -116,7 +115,7 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
List
<
VehicleDepartureLog
>
vehicleDepartureLogs
=
mapper
.
selectByExample
(
exm
);
List
<
VehicleDepartureLog
>
vehicleDepartureLogs
=
mapper
.
selectByExample
(
exm
);
if
(
vehicleDepartureLogs
.
size
()
==
1
)
{
if
(
vehicleDepartureLogs
.
size
()
==
1
)
{
VehicleDepartureLog
vehicleDepartureLog
=
vehicleDepartureLogs
.
get
(
0
);
VehicleDepartureLog
vehicleDepartureLog
=
vehicleDepartureLogs
.
get
(
0
);
if
(
vehicleDepartureLog
!=
null
)
{
if
(
vehicleDepartureLog
!=
null
)
{
return
ObjectRestResponse
.
succ
(
vehicleDepartureLog
);
return
ObjectRestResponse
.
succ
(
vehicleDepartureLog
);
}
}
}
}
...
@@ -124,11 +123,11 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
...
@@ -124,11 +123,11 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
}
}
@Transactional
@Transactional
public
ObjectRestResponse
collect
(
VehicleDepartureLog
vdl
){
public
ObjectRestResponse
collect
(
VehicleDepartureLog
vdl
)
{
vdl
.
setArrivalTime
(
new
Date
());
vdl
.
setArrivalTime
(
new
Date
());
vdl
.
setState
(
1
);
vdl
.
setState
(
1
);
updateSelectiveById
(
vdl
);
updateSelectiveById
(
vdl
);
return
ObjectRestResponse
.
succ
();
return
ObjectRestResponse
.
succ
();
}
}
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleModelBiz.java
View file @
a54d4d50
...
@@ -87,7 +87,7 @@ public class VehicleModelBiz extends BaseBiz<VehicleModelMapper, VehicleModel> {
...
@@ -87,7 +87,7 @@ public class VehicleModelBiz extends BaseBiz<VehicleModelMapper, VehicleModel> {
return
ObjectRestResponse
.
succ
(
list
);
return
ObjectRestResponse
.
succ
(
list
);
}
}
Set
<
Integer
>
set
=
new
HashSet
<>();
Set
<
Integer
>
set
=
new
HashSet
<>();
RandomUtil
.
randomSet
(
list
.
size
(),
number
,
set
);
RandomUtil
.
randomSet
(
list
.
size
(),
number
,
set
,
number
);
for
(
Integer
i
:
set
)
{
for
(
Integer
i
:
set
)
{
resultList
.
add
(
list
.
get
(
i
));
resultList
.
add
(
list
.
get
(
i
));
}
}
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/jobhandler/VehicleJobHandler.java
View file @
a54d4d50
...
@@ -46,12 +46,10 @@ public class VehicleJobHandler extends IJobHandler {
...
@@ -46,12 +46,10 @@ public class VehicleJobHandler extends IJobHandler {
List
<
String
>
existVehicleIds
=
vehicleBiz
.
findExistVehicleIds
();
List
<
String
>
existVehicleIds
=
vehicleBiz
.
findExistVehicleIds
();
Dictionary
dictionary
=
thirdFeign
.
findDictionaryByTypeAndCode
(
DIC_VEHICLE_TYPE
,
DIC_VEHICLE_CODE
);
Dictionary
dictionary
=
thirdFeign
.
findDictionaryByTypeAndCode
(
DIC_VEHICLE_TYPE
,
DIC_VEHICLE_CODE
);
LocalDate
date
=
LocalDate
.
now
();
LocalDate
date
=
LocalDate
.
now
();
date
=
date
.
plusMonths
(
Integer
.
valueOf
(
dictionary
.
getDetail
()));
int
year
=
date
.
getYear
();
int
year
=
date
.
getYear
();
int
nowMonth
=
date
.
getMonthValue
();
int
month
=
date
.
getMonthValue
();
int
betweenMonth
=
Integer
.
valueOf
(
dictionary
.
getDetail
()).
intValue
();
String
yearAndMonth
=
String
.
format
(
"%d-%02d"
,
year
,
month
);
int
month
=
nowMonth
+
betweenMonth
>
12
?
(
betweenMonth
+
nowMonth
)
-
12
:
nowMonth
+
betweenMonth
;
year
=
month
>
nowMonth
?
year
:
year
+
1
;
String
yearAndMonth
=
String
.
format
(
"%d-%s"
,
year
,
month
>=
10
?
month:
"0"
+
month
);
XxlJobLogger
.
log
(
"----查询到的车型ids:【{}】"
,
existVehicleIds
);
XxlJobLogger
.
log
(
"----查询到的车型ids:【{}】"
,
existVehicleIds
);
if
(
CollectionUtils
.
isNotEmpty
(
existVehicleIds
))
{
if
(
CollectionUtils
.
isNotEmpty
(
existVehicleIds
))
{
List
<
VehicleBookInfo
>
bookInfos
=
existVehicleIds
.
stream
().
map
(
vehicleId
->
{
List
<
VehicleBookInfo
>
bookInfos
=
existVehicleIds
.
stream
().
map
(
vehicleId
->
{
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/rest/VehicleModelController.java
View file @
a54d4d50
...
@@ -11,6 +11,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
...
@@ -11,6 +11,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import
com.github.wxiaoqi.security.common.rest.BaseController
;
import
com.github.wxiaoqi.security.common.rest.BaseController
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.github.wxiaoqi.security.common.vo.GoodDataVO
;
import
com.github.wxiaoqi.security.common.vo.GoodDataVO
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.xxfc.platform.vehicle.biz.VehicleCataBiz
;
import
com.xxfc.platform.vehicle.biz.VehicleCataBiz
;
import
com.xxfc.platform.vehicle.biz.VehicleModelBiz
;
import
com.xxfc.platform.vehicle.biz.VehicleModelBiz
;
import
com.xxfc.platform.vehicle.biz.VehiclePlatCataBiz
;
import
com.xxfc.platform.vehicle.biz.VehiclePlatCataBiz
;
...
@@ -133,7 +134,7 @@ public class VehicleModelController extends BaseController<VehicleModelBiz, Vehi
...
@@ -133,7 +134,7 @@ public class VehicleModelController extends BaseController<VehicleModelBiz, Vehi
@ApiOperation
(
"车型列表"
)
@ApiOperation
(
"车型列表"
)
@PostMapping
(
value
=
"/app/unauth/findVehicleModelPage"
)
@PostMapping
(
value
=
"/app/unauth/findVehicleModelPage"
)
@IgnoreUserToken
@IgnoreUserToken
public
ObjectRestResponse
<
VehicleModelVo
>
findVehicleModelPageUnauthfind
(
public
ObjectRestResponse
<
PageDataVO
<
VehicleModelVo
>
>
findVehicleModelPageUnauthfind
(
@RequestBody
@ApiParam
(
"查询条件"
)
VehicleModelQueryCondition
vmqc
,
HttpServletRequest
request
)
{
@RequestBody
@ApiParam
(
"查询条件"
)
VehicleModelQueryCondition
vmqc
,
HttpServletRequest
request
)
{
if
(
vmqc
.
getIsDel
()
==
null
)
{
if
(
vmqc
.
getIsDel
()
==
null
)
{
vmqc
.
setIsDel
(
0
);
vmqc
.
setIsDel
(
0
);
...
...
xx-vehicle/xx-vehicle-server/src/main/resources/mapper/VehicleBookRecordMapper.xml
View file @
a54d4d50
...
@@ -380,7 +380,7 @@
...
@@ -380,7 +380,7 @@
</select>
</select>
<select
id=
"selectByVehicleId"
parameterType=
"java.lang.String"
<select
id=
"selectByVehicleId"
parameterType=
"java.lang.String"
result
Type=
"com.xxfc.platform.vehicle.pojo.VehicleBookRecordVo
"
>
result
Map=
"searchBookRecord
"
>
SELECT v1.*,bc2.name retCompanyName from vehicle_book_record v1
SELECT v1.*,bc2.name retCompanyName from vehicle_book_record v1
LEFT JOIN branch_company bc2 on v1.ret_company = bc2.id
LEFT JOIN branch_company bc2 on v1.ret_company = bc2.id
where v1.vehicle_id = #{vehicleId} and v1.status BETWEEN 1 and 2
where v1.vehicle_id = #{vehicleId} and v1.status BETWEEN 1 and 2
...
...
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