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
629cae07
Commit
629cae07
authored
Oct 23, 2019
by
libin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'holiday-price' into dev
parents
83694faa
ad229709
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
32 deletions
+66
-32
VehicleModelHolidayPriceSaveDTO.java
...orm/vehicle/pojo/dto/VehicleModelHolidayPriceSaveDTO.java
+2
-1
VehicleModelHolidayPriceVo.java
.../platform/vehicle/pojo/vo/VehicleModelHolidayPriceVo.java
+3
-1
VehicleModelCalendarPriceBiz.java
...fc/platform/vehicle/biz/VehicleModelCalendarPriceBiz.java
+17
-22
VehicleModelHolidayPriceBiz.java
...xfc/platform/vehicle/biz/VehicleModelHolidayPriceBiz.java
+22
-8
DateUtils.java
...c/main/java/com/xxfc/platform/vehicle/util/DateUtils.java
+22
-0
No files found.
xx-vehicle/xx-vehicle-api/src/main/java/com/xxfc/platform/vehicle/pojo/dto/VehicleModelHolidayPriceSaveDTO.java
View file @
629cae07
...
...
@@ -28,7 +28,8 @@ public class VehicleModelHolidayPriceSaveDTO implements Serializable {
/**
* 节假日日期
*/
private
List
<
Date
>
date
;
private
Date
startDate
;
private
Date
endDate
;
/**
* 节假日名称
*/
...
...
xx-vehicle/xx-vehicle-api/src/main/java/com/xxfc/platform/vehicle/pojo/vo/VehicleModelHolidayPriceVo.java
View file @
629cae07
...
...
@@ -24,7 +24,9 @@ public class VehicleModelHolidayPriceVo implements Serializable {
/**
* 节假日日期
*/
private
Date
festivalDay
;
// private Date festivalDay;
private
Date
startDate
;
private
Date
endDate
;
/**
* 节假日
*/
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleModelCalendarPriceBiz.java
View file @
629cae07
...
...
@@ -11,6 +11,7 @@ import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceSaveDTO;
import
com.xxfc.platform.vehicle.pojo.dto.VehicleModelDTO
;
import
com.xxfc.platform.vehicle.pojo.dto.VehicleModelHolidayPriceDTO
;
import
com.xxfc.platform.vehicle.pojo.vo.VehicleModelDayPriceVo
;
import
com.xxfc.platform.vehicle.util.DateUtils
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
...
...
@@ -67,7 +68,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
List
<
Date
>
dateList
=
vehicleModelCalendarPrices
.
stream
().
peek
(
x
->
{
VehicleModelCalendarPrice
calendarPrice
=
new
VehicleModelCalendarPrice
();
BeanUtils
.
copyProperties
(
x
,
calendarPrice
);
Date
date
=
localDateToDate
(
LocalDate
.
parse
(
x
.
getDate
()));
Date
date
=
DateUtils
.
localDateToDate
(
LocalDate
.
parse
(
x
.
getDate
()));
calendarPrice
.
setVehicleModelDay
(
date
);
calendarPrice
.
setCrtTime
(
new
Date
());
calendarPrice
.
setCrtUserId
(
userId
);
...
...
@@ -153,10 +154,10 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
List
<
VehicleModelCalendarPriceSaveDTO
>
vehicleModelCalendarPriceSaveDTOS
=
new
ArrayList
<>();
Example
example
=
new
Example
(
VehicleModelCalendarPrice
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
LocalDate
startLocalDate
=
dateToLocalDate
(
currentDate
).
withDayOfMonth
(
1
);
Date
startDate
=
localDateToDate
(
startLocalDate
);
LocalDate
startLocalDate
=
DateUtils
.
dateToLocalDate
(
currentDate
).
withDayOfMonth
(
1
);
Date
startDate
=
DateUtils
.
localDateToDate
(
startLocalDate
);
LocalDate
endLocalDate
=
startLocalDate
.
with
(
TemporalAdjusters
.
lastDayOfMonth
());
Date
endDate
=
localDateToDate
(
endLocalDate
);
Date
endDate
=
DateUtils
.
localDateToDate
(
endLocalDate
);
criteria
.
andBetween
(
"vehicleModelDay"
,
startDate
,
endDate
);
criteria
.
andEqualTo
(
"isDel"
,
0
);
List
<
VehicleModelCalendarPrice
>
vehicleModelCalendarPriceList
=
mapper
.
selectByExample
(
example
);
...
...
@@ -201,8 +202,8 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
* @return
*/
public
List
<
VehicleModelCalendarPriceDTO
>
listVehicleModelCalendarPriceByDateAndVehicleModelIdAndUserId
(
Date
startDate
,
Date
endDate
,
Integer
vehicleModelId
,
Integer
userId
)
{
LocalDate
startLocalDate
=
startDate
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
(
);
LocalDate
endLocalDate
=
endDate
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
(
);
LocalDate
startLocalDate
=
DateUtils
.
dateToLocalDate
(
startDate
);
LocalDate
endLocalDate
=
DateUtils
.
dateToLocalDate
(
endDate
);
//处理后延伸的开始时间
AtomicReference
<
Date
>
startReference
=
new
AtomicReference
<>(
startDate
);
...
...
@@ -211,7 +212,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
transformStartDateAndEndDate
(
startReference
,
endReference
);
List
<
VehicleModelCalendarPriceDTO
>
vehicleModelCalendarPrice
=
findVehicleModelCalendarPrice
(
startReference
.
get
(),
endReference
.
get
(),
vehicleModelId
,
userId
);
for
(
VehicleModelCalendarPriceDTO
vehicleModelCalendarPriceDTO
:
vehicleModelCalendarPrice
)
{
LocalDate
current_date
=
dateToLocalDate
(
vehicleModelCalendarPriceDTO
.
getDate
());
LocalDate
current_date
=
DateUtils
.
dateToLocalDate
(
vehicleModelCalendarPriceDTO
.
getDate
());
boolean
isSelect
=
(
current_date
.
isAfter
(
startLocalDate
)
&&
current_date
.
isBefore
(
endLocalDate
))
||
current_date
.
isEqual
(
startLocalDate
)
||
current_date
.
isEqual
(
endLocalDate
);
vehicleModelCalendarPriceDTO
.
setIsSelect
(
isSelect
?
true
:
false
);
}
...
...
@@ -252,8 +253,8 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
memberLevel
=
baseUserMember
==
null
?
memberLevel
:
baseUserMember
.
getMemberLevel
();
}
VehicleModelCalendarPriceDTO
vehicleModelCalendarPriceDTO
;
LocalDate
final_startLocalDate
=
dateToLocalDate
(
startDate
);
LocalDate
final_endLocalDate
=
dateToLocalDate
(
endDate
);
LocalDate
final_startLocalDate
=
DateUtils
.
dateToLocalDate
(
startDate
);
LocalDate
final_endLocalDate
=
DateUtils
.
dateToLocalDate
(
endDate
);
while
(
final_startLocalDate
.
isBefore
(
final_endLocalDate
)
||
final_startLocalDate
.
isEqual
(
final_endLocalDate
))
{
vehicleModelCalendarPriceDTO
=
new
VehicleModelCalendarPriceDTO
();
//价格重置
...
...
@@ -264,7 +265,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
Integer
free_days
=
DEFAULT_FREE_DAYS
;
//节假日对应的价格和免费天数
Map
<
String
,
Object
>
price_freeDays_map
=
null
;
Date
current_date
=
localDateToDate
(
final_startLocalDate
);
Date
current_date
=
DateUtils
.
localDateToDate
(
final_startLocalDate
);
vehicleModelCalendarPriceDTO
.
setDate
(
current_date
);
if
(
calendarPriceMap
!=
null
&&
!
calendarPriceMap
.
isEmpty
())
{
VehicleModelCalendarPrice
vehicleModelCalendarPrice
=
calendarPriceMap
.
get
(
current_date
);
...
...
@@ -372,13 +373,13 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
LocalDate
now
=
LocalDate
.
now
();
LocalDate
endLocalDate
=
now
.
with
(
TemporalAdjusters
.
lastDayOfMonth
());
LocalDate
startLocalDate
=
now
.
withDayOfMonth
(
1
);
startDate
=
localDateToDate
(
startLocalDate
);
endDate
=
localDateToDate
(
endLocalDate
);
startDate
=
DateUtils
.
localDateToDate
(
startLocalDate
);
endDate
=
DateUtils
.
localDateToDate
(
endLocalDate
);
}
else
{
int
days
=
0
;
/****************************************开始时间处理******************************************************/
LocalDate
startLocalDate
=
dateToLocalDate
(
startDate
);
LocalDate
startLocalDate
=
DateUtils
.
dateToLocalDate
(
startDate
);
int
start_week
=
startLocalDate
.
getDayOfWeek
().
getValue
();
if
(
START_OF_WEEK
<
start_week
&&
start_week
<
END_OF_WEEK
)
{
days
=
start_week
-
START_OF_WEEK
;
...
...
@@ -391,7 +392,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
/****************************************结束时间处理******************************************************/
days
=
0
;
LocalDate
endLocalDate
=
dateToLocalDate
(
endDate
);
LocalDate
endLocalDate
=
DateUtils
.
dateToLocalDate
(
endDate
);
int
end_week
=
endLocalDate
.
getDayOfWeek
().
getValue
();
if
(
START_OF_WEEK
<
end_week
&&
end_week
<
END_OF_WEEK
)
{
...
...
@@ -403,20 +404,14 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
}
LocalDate
end_endLocalDate
=
endLocalDate
.
plusDays
(
days
);
/****************************************时间转换******************************************************/
startDate
=
localDateToDate
(
start_startLocalDate
);
endDate
=
localDateToDate
(
end_endLocalDate
);
startDate
=
DateUtils
.
localDateToDate
(
start_startLocalDate
);
endDate
=
DateUtils
.
localDateToDate
(
end_endLocalDate
);
}
startDatee
.
set
(
startDate
);
endDatee
.
set
(
endDate
);
}
private
static
LocalDate
dateToLocalDate
(
Date
date
){
return
LocalDate
.
from
(
date
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
());
}
private
static
Date
localDateToDate
(
LocalDate
localDate
){
return
Date
.
from
(
localDate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
}
public
static
void
main
(
String
[]
args
)
{
AtomicReference
<
Date
>
start
=
new
AtomicReference
<>(
Date
.
from
(
LocalDate
.
parse
(
"2019-10-03"
).
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
()));
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleModelHolidayPriceBiz.java
View file @
629cae07
...
...
@@ -9,6 +9,7 @@ import com.xxfc.platform.vehicle.pojo.dto.VehicleModelHolidayPriceDTO;
import
com.xxfc.platform.vehicle.pojo.dto.VehicleModelHolidayPriceFindDTO
;
import
com.xxfc.platform.vehicle.pojo.dto.VehicleModelHolidayPriceSaveDTO
;
import
com.xxfc.platform.vehicle.pojo.vo.VehicleModelHolidayPriceVo
;
import
com.xxfc.platform.vehicle.util.DateUtils
;
import
lombok.RequiredArgsConstructor
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -23,7 +24,9 @@ import java.time.LocalDate;
import
java.time.ZoneId
;
import
java.time.temporal.TemporalAdjusters
;
import
java.util.*
;
import
java.util.function.Supplier
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* @author libin
...
...
@@ -48,13 +51,16 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
List
<
VehicleModelHolidayPrice
>
vehicleModelHolidayPriceList
=
new
ArrayList
<>();
VehicleModelHolidayPrice
vehicleModelHolidayPrice
;
List
<
Date
>
dates
=
vehicleModelHolidayPriceSaveDTO
.
getDate
();
for
(
Date
date
:
dates
)
{
Date
startDate
=
vehicleModelHolidayPriceSaveDTO
.
getStartDate
();
LocalDate
startLocaldate
=
DateUtils
.
dateToLocalDate
(
startDate
);
LocalDate
endLocaldate
=
DateUtils
.
dateToLocalDate
(
vehicleModelHolidayPriceSaveDTO
.
getEndDate
());
while
(
startLocaldate
.
isBefore
(
endLocaldate
)
||
startLocaldate
.
isEqual
(
endLocaldate
)){
vehicleModelHolidayPrice
=
new
VehicleModelHolidayPrice
();
BeanUtils
.
copyProperties
(
vehicleModelHolidayPriceSaveDTO
,
vehicleModelHolidayPrice
);
date
=
Date
.
from
(
date
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
().
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
Date
date
=
DateUtils
.
localDateToDate
(
startLocaldate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toLocalDate
());
vehicleModelHolidayPrice
.
setFestivalDay
(
date
);
vehicleModelHolidayPriceList
.
add
(
vehicleModelHolidayPrice
);
startLocaldate
.
plusDays
(
1
);
}
//编辑
if
(
Objects
.
nonNull
(
vehicleModelHolidayPriceSaveDTO
.
getId
()))
{
...
...
@@ -121,11 +127,17 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
}
List
<
Integer
>
festivalIds
=
holidayPrices
.
stream
().
map
(
VehicleModelHolidayPrice:
:
getFestivalId
).
collect
(
Collectors
.
toList
());
Map
<
Integer
,
Festival
>
festivalMap
=
festivalBiz
.
findFestivalsByIds
(
festivalIds
);
Map
<
Integer
,
List
<
VehicleModelHolidayPrice
>>
listMap
=
holidayPrices
.
stream
().
collect
(
Collectors
.
groupingBy
(
VehicleModelHolidayPrice:
:
getFestivalId
,
Collectors
.
toList
()));
VehicleModelHolidayPriceVo
vehicleModelHolidayPriceVo
;
for
(
VehicleModelHolidayPrice
holidayPrice
:
holidayPrices
)
{
for
(
Integer
festivalId
:
festivalIds
)
{
vehicleModelHolidayPriceVo
=
new
VehicleModelHolidayPriceVo
();
BeanUtils
.
copyProperties
(
holidayPrice
,
vehicleModelHolidayPriceVo
);
vehicleModelHolidayPriceVo
.
setFestival
(
festivalMap
==
null
?
""
:
festivalMap
.
get
(
holidayPrice
.
getFestivalId
()).
getName
());
BeanUtils
.
copyProperties
(
listMap
.
get
(
festivalId
).
get
(
0
),
vehicleModelHolidayPriceVo
);
vehicleModelHolidayPriceVo
.
setFestival
(
festivalMap
==
null
?
""
:
festivalMap
.
get
(
festivalId
).
getName
());
Date
startDate
=
listMap
.
get
(
festivalId
).
stream
().
map
(
VehicleModelHolidayPrice:
:
getFestivalDay
).
min
(
Date:
:
compareTo
).
get
();
Date
endDate
=
listMap
.
get
(
festivalId
).
stream
().
map
(
VehicleModelHolidayPrice:
:
getFestivalDay
).
max
(
Date:
:
compareTo
).
get
();
vehicleModelHolidayPriceVo
.
setStartDate
(
startDate
);
vehicleModelHolidayPriceVo
.
setEndDate
(
endDate
);
vehicleModelHolidayPriceVos
.
add
(
vehicleModelHolidayPriceVo
);
}
return
vehicleModelHolidayPriceVos
;
...
...
@@ -172,10 +184,12 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
if
(
CollectionUtils
.
isEmpty
(
vehicleModelHolidayPrices
))
{
throw
new
BaseException
(
"数据不存在"
);
}
List
<
Date
>
dates
=
vehicleModelHolidayPrices
.
stream
().
map
(
VehicleModelHolidayPrice:
:
getFestivalDay
).
collect
(
Collectors
.
toList
());
Date
startDate
=
vehicleModelHolidayPrices
.
stream
().
map
(
VehicleModelHolidayPrice:
:
getFestivalDay
).
min
(
Date:
:
compareTo
).
get
();
Date
endDate
=
vehicleModelHolidayPrices
.
stream
().
map
(
VehicleModelHolidayPrice:
:
getFestivalDay
).
max
(
Date:
:
compareTo
).
get
();
VehicleModelHolidayPrice
vehicleModelHolidayPrice
=
vehicleModelHolidayPrices
.
get
(
0
);
BeanUtils
.
copyProperties
(
vehicleModelHolidayPrice
,
modelHolidayPriceSaveDTO
);
modelHolidayPriceSaveDTO
.
setDate
(
dates
);
modelHolidayPriceSaveDTO
.
setStartDate
(
startDate
);
modelHolidayPriceSaveDTO
.
setEndDate
(
endDate
);
return
modelHolidayPriceSaveDTO
;
}
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/util/DateUtils.java
0 → 100644
View file @
629cae07
package
com
.
xxfc
.
platform
.
vehicle
.
util
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.util.Date
;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/10/23 10:52
*/
public
class
DateUtils
{
public
static
LocalDate
dateToLocalDate
(
Date
date
)
{
return
LocalDate
.
from
(
date
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
());
}
public
static
Date
localDateToDate
(
LocalDate
localDate
)
{
return
Date
.
from
(
localDate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
}
}
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