记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
bb430898
Commit
bb430898
authored
Jun 13, 2021
by
jiangxiulong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
演出 redis整理
parent
ca69604b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
196 additions
and
249 deletions
+196
-249
KylinRedisConst.java
...com/liquidnet/service/kylin/constant/KylinRedisConst.java
+3
-1
DateUtil.java
...c/main/java/com/liquidnet/commons/lang/util/DateUtil.java
+11
-6
KylinPerformancesController.java
...service/kylin/controller/KylinPerformancesController.java
+6
-28
KylinPerformancesServiceImpl.java
...vice/kylin/service/impl/KylinPerformancesServiceImpl.java
+103
-202
DataUtils.java
...ain/java/com/liquidnet/service/kylin/utils/DataUtils.java
+73
-12
No files found.
liquidnet-bus-api/liquidnet-service-kylin-api/src/main/java/com/liquidnet/service/kylin/constant/KylinRedisConst.java
View file @
bb430898
...
...
@@ -4,7 +4,9 @@ public class KylinRedisConst {
public
static
final
String
FIELDS
=
"kylin:fields:id"
;
public
static
final
String
PERFORMANCES
=
"kylin:performances:id:"
;
public
static
final
String
PERFORMANCES_LIST_CITYNAME
=
"kylin:performances:cityName:"
;
public
static
final
String
PERFORMANCES_LIST_RECOMMEND
=
"kylin:performances:recommend:"
;
public
static
final
String
PERFORMANCES_LIST_ALL
=
"kylin:performances:cityName*"
;
public
static
final
String
PERFORMANCES_LIST_RECOMMEND
=
"kylin:performances:recommend"
;
public
static
final
String
PERFORMANCES_ROADLIST
=
"kylin:performances:roadShowId:"
;
public
static
final
String
PERFORMANCES_RECOMMEND
=
"kylin:performances:recommend:id:"
;
public
static
final
String
PERFORMANCES_INVENTORY
=
"kylin:performances_inventory:ticket:id:"
;
public
static
final
String
SURPLUS_GENERAL
=
"surplusGeneral"
;
...
...
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/DateUtil.java
View file @
bb430898
...
...
@@ -404,8 +404,8 @@ public abstract class DateUtil {
return
yearInterval
*
12
+
monthInterval
;
}
// 获得当天开始时间和结束时间
public
static
HashMap
oneDayStartEnd
(
String
[]
args
)
{
// 获得当天开始时间和结束时间
jiangxiulong
public
static
HashMap
oneDayStartEnd
()
{
HashMap
datas
=
new
HashMap
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
new
Date
());
...
...
@@ -414,18 +414,23 @@ public abstract class DateUtil {
calendar
.
set
(
Calendar
.
SECOND
,
0
);
Date
start
=
calendar
.
getTime
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
startStr
=
sdf
.
format
(
start
);
datas
.
put
(
"start"
,
start
);
datas
.
put
(
"startStr"
,
startStr
);
calendar
.
add
(
Calendar
.
DAY_OF_MONTH
,
1
);
calendar
.
add
(
Calendar
.
SECOND
,
-
1
);
Date
end
=
calendar
.
getTime
();
String
endStr
=
sdf
.
format
(
end
);
datas
.
put
(
"end"
,
end
);
datas
.
put
(
"endStr"
,
endStr
);
return
datas
;
}
// 获取当月第一天
// 获取当月第一天
jiangxiulong
public
static
String
getMonthFirst
()
{
//规定返回日期格式
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
...
...
@@ -440,12 +445,12 @@ public abstract class DateUtil {
return
dayFirst
;
}
// 获取某月第一天
// 获取某月第一天
jiangxiulong
public
static
String
getMonthFirst
(
String
month
)
{
return
month
.
concat
(
"-01"
);
}
// 获取当月最后一天
// 获取当月最后一天
jiangxiulong
public
static
String
getMonthLast
()
{
//获取Calendar
Calendar
calendar
=
Calendar
.
getInstance
();
...
...
@@ -458,7 +463,7 @@ public abstract class DateUtil {
return
dayLast
+
" 23:59:59"
;
}
// 获取某月最后一天
// 获取某月最后一天
jiangxiulong
public
static
String
getMonthLast
(
String
month
)
throws
ParseException
{
// String 转 Date
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
...
...
liquidnet-bus-service/liquidnet-service-kylin/liquidnet-service-kylin-impl/src/main/java/com/liquidnet/service/kylin/controller/KylinPerformancesController.java
View file @
bb430898
...
...
@@ -13,7 +13,6 @@ import io.swagger.annotations.ApiOperation;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.text.ParseException
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -38,49 +37,35 @@ public class KylinPerformancesController {
@GetMapping
(
"localList"
)
@ApiOperation
(
"本地演出列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"
timeStart"
,
value
=
"演出开始时间 2021-01-01"
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"
cityName"
,
value
=
"城市名称"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"int"
,
name
=
"days"
,
value
=
"时间范围 几天 今天1 三天3。。。"
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"title"
,
value
=
"演出名称"
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"cityName"
,
value
=
"城市名称"
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"int"
,
name
=
"type"
,
value
=
"演出类型 101音乐节 102小型演出(livehouse演出) 103巡演 演出类型只有这几个了"
),
// @ApiImplicitParam(type = "query", dataType = "int", name = "type", value = "演出类型 1音乐节 2演唱会 3小型演出 4展览 6舞台剧"),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"Integer"
,
name
=
"isDiscount"
,
value
=
"是否会员优惠 0 1"
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"Integer"
,
name
=
"isAdvance"
,
value
=
"是否优先 0 1"
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"Integer"
,
name
=
"isExclusive"
,
value
=
"是否会员专属 0 1"
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"int"
,
name
=
"page"
,
value
=
"页码"
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"int"
,
name
=
"size"
,
value
=
"每页数量"
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"orderBy"
,
value
=
"排序字段 时间timeStart"
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"sort"
,
value
=
"排序方式[DESC ASC]"
),
})
public
ResponseDto
<
HashMap
<
String
,
Object
>>
localList
(
@RequestParam
(
defaultValue
=
""
)
String
timeStart
,
@RequestParam
(
defaultValue
=
"0"
)
int
days
,
@RequestParam
(
defaultValue
=
""
)
String
title
,
@RequestParam
(
defaultValue
=
""
)
String
cityName
,
@RequestParam
(
defaultValue
=
"0"
)
int
days
,
@RequestParam
(
defaultValue
=
"0"
)
int
type
,
@RequestParam
(
defaultValue
=
""
)
Integer
isDiscount
,
@RequestParam
(
defaultValue
=
""
)
Integer
isAdvance
,
@RequestParam
(
defaultValue
=
""
)
Integer
isExclusive
,
@RequestParam
(
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
defaultValue
=
"10"
)
int
size
,
// 排序
@RequestParam
(
defaultValue
=
""
)
String
orderBy
,
@RequestParam
(
defaultValue
=
""
)
String
sort
)
{
HashMap
<
String
,
Object
>
result
=
kylinPerformancesService
.
localList
(
timeStart
,
days
,
title
,
cityName
,
type
,
days
,
cityName
,
type
,
isDiscount
,
isAdvance
,
isExclusive
,
page
,
size
,
orderBy
,
sort
);
return
ResponseDto
.
success
(
result
);
}
...
...
@@ -100,15 +85,8 @@ public class KylinPerformancesController {
@GetMapping
(
"exclusiveList"
)
@ApiOperation
(
"会员专属演出列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"int"
,
name
=
"page"
,
value
=
"页码"
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"int"
,
name
=
"size"
,
value
=
"每页数量"
)
})
public
ResponseDto
<
List
<
KylinPerformanceVo
>>
exclusiveList
(
@RequestParam
(
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
defaultValue
=
"10"
)
int
size
)
{
List
<
KylinPerformanceVo
>
result
=
kylinPerformancesService
.
exclusiveList
(
page
,
size
);
public
ResponseDto
<
List
<
KylinPerformanceVo
>>
exclusiveList
()
{
List
<
KylinPerformanceVo
>
result
=
kylinPerformancesService
.
exclusiveList
();
return
ResponseDto
.
success
(
result
);
}
...
...
@@ -135,7 +113,7 @@ public class KylinPerformancesController {
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"yearMonth"
,
value
=
"年月 2021-01"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"cityName"
,
value
=
"城市名称"
,
required
=
true
)
})
public
ResponseDto
<
List
>
performanceCalendar
(
@RequestParam
String
yearMonth
,
@RequestParam
String
cityName
)
throws
ParseException
{
public
ResponseDto
<
List
>
performanceCalendar
(
@RequestParam
String
yearMonth
,
@RequestParam
String
cityName
)
{
List
result
=
null
;
result
=
kylinPerformancesService
.
performanceCalendar
(
yearMonth
,
cityName
);
return
ResponseDto
.
success
(
result
);
...
...
liquidnet-bus-service/liquidnet-service-kylin/liquidnet-service-kylin-impl/src/main/java/com/liquidnet/service/kylin/service/impl/KylinPerformancesServiceImpl.java
View file @
bb430898
...
...
@@ -26,6 +26,7 @@ import org.springframework.data.mongodb.core.query.Query;
import
org.springframework.stereotype.Service
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
...
...
@@ -53,144 +54,87 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
private
PerformanceVoTask
task
;
public
HashMap
<
String
,
Object
>
localList
(
String
timeStart
,
int
days
,
String
title
,
String
cityName
,
int
type
,
int
days
,
String
cityName
,
int
type
,
Integer
isDiscount
,
Integer
isAdvance
,
Integer
isExclusive
,
int
page
,
int
size
,
String
orderBy
,
String
sort
)
{
HashMap
<
String
,
Object
>
info
=
new
HashMap
<>(
);
List
<
KylinPerformanceVo
>
performancesList
=
dataUtils
.
getPerformancesListOfcityName
(
cityName
);
// 排序 分页
Sort
sortName
=
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"timeStart"
);
// 默认开票越早的在上面
if
(
sort
.
equals
(
"DESC"
))
{
if
(!
orderBy
.
isEmpty
())
{
sortName
=
Sort
.
by
(
Sort
.
Direction
.
DESC
,
orderBy
);
// 判断搜索 处理新数据
List
<
KylinPerformanceVo
>
performancesListNew
=
new
ArrayList
<>();
for
(
KylinPerformanceVo
info
:
performancesList
)
{
boolean
isShow
=
true
;
if
(
type
>
0
)
{
if
(
info
.
getType
()
!=
type
)
{
isShow
=
false
;
}
}
else
if
(
sort
.
equals
(
"ASC"
))
{
if
(!
orderBy
.
isEmpty
())
{
sortName
=
Sort
.
by
(
Sort
.
Direction
.
ASC
,
orderBy
);
}
if
(
null
!=
isExclusive
)
{
if
(
info
.
getIsExclusive
()
!=
isExclusive
)
{
isShow
=
false
;
}
Pageable
pageable
=
PageRequest
.
of
(
page
-
1
,
size
,
sortName
);
//条件
Document
queryObject
=
new
Document
();
if
(!
title
.
isEmpty
())
{
queryObject
.
put
(
"title"
,
Pattern
.
compile
(
title
,
Pattern
.
CASE_INSENSITIVE
));
}
if
(!
cityName
.
isEmpty
())
{
queryObject
.
put
(
"cityName"
,
Pattern
.
compile
(
cityName
,
Pattern
.
CASE_INSENSITIVE
));
if
(
null
!=
isDiscount
)
{
if
(
info
.
getIsDiscount
()
!=
isDiscount
)
{
isShow
=
false
;
}
if
(
type
>
0
)
{
queryObject
.
put
(
"type"
,
type
);
}
if
(
isExclusive
!=
null
)
{
queryObject
.
put
(
"isExclusive"
,
isExclusive
);
if
(
null
!=
isAdvance
)
{
if
(
info
.
getIsAdvance
()
!=
isAdvance
)
{
isShow
=
false
;
}
if
(
isDiscount
!=
null
)
{
queryObject
.
put
(
"isDiscount"
,
isDiscount
);
}
if
(
isAdvance
!=
null
)
{
queryObject
.
put
(
"isAdvance"
,
isAdvance
);
if
(
isShow
)
{
performancesListNew
.
add
(
info
);
}
Query
query
=
new
BasicQuery
(
queryObject
);
if
(!
timeStart
.
isEmpty
())
{
String
timeStartEnd
=
timeStart
+
" 23:59:59"
;
query
.
addCriteria
(
Criteria
.
where
(
"timeStart"
).
gte
(
timeStart
).
lte
(
timeStartEnd
));
}
if
(
days
>
0
)
{
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
String
nowTimeStr
=
nowTime
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
));
LocalDateTime
OtherTime
=
nowTime
.
plusDays
(
days
);
String
OtherTimeStr
=
OtherTime
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
));
query
.
addCriteria
(
Criteria
.
where
(
"timeStart"
).
gte
(
nowTimeStr
).
lte
(
OtherTimeStr
));
}
// 固定查询条件
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
String
nowTimeStr
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
nowTime
);
query
.
addCriteria
(
Criteria
.
where
(
"timeEnd"
).
gte
(
nowTimeStr
));
// 查询总数
long
count
=
mongoTemplate
.
count
(
query
,
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
());
query
.
with
(
pageable
);
// 要查询的字段
query
.
fields
().
exclude
(
"details"
);
query
.
fields
().
exclude
(
"noticeImage"
);
List
<
KylinPerformanceVo
>
list
=
mongoTemplate
.
find
(
query
,
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
());
// 推荐其他地区演出
List
<
KylinPerformanceVo
>
otherlist
=
null
;
// 推荐
int
is_native
=
1
;
int
recommend
=
list
.
size
();
if
(
count
<
size
&&
!
cityName
.
isEmpty
())
{
/*Document newQueryObject = query.getQueryObject();
queryObject.put("cityName", "上海");
Query queryOther = new BasicQuery(newQueryObject);*/
Query
queryOther
=
new
Query
();
String
regex
=
String
.
format
(
"%s%s%s"
,
"^((?!"
,
cityName
,
").)*$"
);
Pattern
cityNameCompile
=
Pattern
.
compile
(
regex
,
Pattern
.
CASE_INSENSITIVE
);
queryOther
.
addCriteria
(
Criteria
.
where
(
"cityName"
).
regex
(
cityNameCompile
));
queryOther
.
addCriteria
(
Criteria
.
where
(
"timeEnd"
).
gte
(
nowTimeStr
));
long
newSize
=
size
-
count
;
Pageable
newPageable
=
PageRequest
.
of
(
0
,
(
int
)
newSize
,
sortName
);
queryOther
.
with
(
newPageable
);
query
.
fields
().
exclude
(
"details"
);
query
.
fields
().
exclude
(
"noticeImage"
);
otherlist
=
mongoTemplate
.
find
(
queryOther
,
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
());
if
(
otherlist
.
size
()
>
0
)
{
int
recommend
=
performancesListNew
.
size
();
if
(
recommend
<
2
)
{
List
<
KylinPerformanceVo
>
performancesListRecommend
=
dataUtils
.
getPerformancesListIsRecommend
();
if
(
performancesListRecommend
.
size
()
>
0
)
{
is_native
=
0
;
list
.
addAll
(
otherlist
);
performancesListNew
.
addAll
(
performancesListRecommend
);
}
}
// 组合数据
HashMap
<
String
,
Object
>
info
=
new
HashMap
<>();
info
.
put
(
"is_native"
,
is_native
);
// 本地演出少是否推荐了其他演出 0有推荐 1没有
info
.
put
(
"recommend"
,
recommend
);
// 从第几个开始是其他推荐演出
(非后台设置的那个推荐)
info
.
put
(
"total"
,
count
);
info
.
put
(
"list"
,
list
);
info
.
put
(
"recommend"
,
recommend
);
// 从第几个开始是其他推荐演出
后台设置的那个推荐
info
.
put
(
"total"
,
0
);
info
.
put
(
"list"
,
performancesListNew
);
return
info
;
}
public
HashMap
<
String
,
Object
>
noticeList
()
{
// 固定条件
Query
query
=
new
Query
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
String
nowTimeStr
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
nowTime
);
query
.
addCriteria
(
Criteria
.
where
(
"timeEnd"
).
gte
(
nowTimeStr
));
// 所有城市演出
List
<
KylinPerformanceVo
>
performancesList
=
dataUtils
.
getPerformancesListAll
();
// 条件整理
List
<
KylinPerformanceVo
>
toDayList
=
new
ArrayList
<>();
List
<
KylinPerformanceVo
>
threeDaysList
=
new
ArrayList
<>();
// 今天的
LocalDateTime
toDayTime
=
LocalDateTime
.
now
();
String
toDayTimeStr
=
toDayTime
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
));
LocalDateTime
toDayEndTime
=
toDayTime
.
plusDays
(
1
);
String
toDayEndTimeStr
=
toDayEndTime
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
));
query
.
addCriteria
(
Criteria
.
where
(
"timeStart"
).
gte
(
toDayTimeStr
).
lt
(
toDayEndTimeStr
));
query
.
fields
().
exclude
(
"details"
);
query
.
fields
().
exclude
(
"noticeImage"
);
List
<
KylinPerformanceVo
>
toDayList
=
mongoTemplate
.
find
(
query
,
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
());
HashMap
toDayTime
=
DateUtil
.
oneDayStartEnd
();
String
nowTimeTStr
=
(
String
)
toDayTime
.
get
(
"startStr"
);
String
toDayEndTimeStr
=
(
String
)
toDayTime
.
get
(
"endStr"
);
// 三天的
Query
queryT
=
new
Query
();
LocalDateTime
nowTimeT
=
LocalDateTime
.
now
();
String
nowTimeStrT
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
nowTimeT
);
queryT
.
addCriteria
(
Criteria
.
where
(
"timeEnd"
).
gte
(
nowTimeStrT
));
LocalDateTime
threeDaysLater
=
toDayTime
.
plusDays
(
3
);
String
threeDaysLaterStr
=
threeDaysLater
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
));
queryT
.
addCriteria
(
Criteria
.
where
(
"timeStart"
).
gte
(
toDayEndTimeStr
).
lt
(
threeDaysLaterStr
));
queryT
.
fields
().
exclude
(
"details"
);
queryT
.
fields
().
exclude
(
"noticeImage"
);
List
<
KylinPerformanceVo
>
threeDaysList
=
mongoTemplate
.
find
(
queryT
,
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
());
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
((
Date
)
toDayTime
.
get
(
"end"
));
Date
beforeDayEnd
=
DateUtil
.
getBeforeDayEnd
(
cal
,
3
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
threeDaysLaterStr
=
sdf
.
format
(
beforeDayEnd
);
for
(
KylinPerformanceVo
info
:
performancesList
)
{
String
timeStart
=
info
.
getTimeStart
();
if
(-
1
!=
DateUtil
.
compareStrDay
(
timeStart
,
nowTimeTStr
)
&&
-
1
==
DateUtil
.
compareStrDay
(
timeStart
,
toDayEndTimeStr
))
{
toDayList
.
add
(
info
);
}
if
(-
1
!=
DateUtil
.
compareStrDay
(
timeStart
,
toDayEndTimeStr
)
&&
-
1
==
DateUtil
.
compareStrDay
(
timeStart
,
threeDaysLaterStr
))
{
threeDaysList
.
add
(
info
);
}
}
HashMap
<
String
,
Object
>
info
=
new
HashMap
<>();
info
.
put
(
"toDayList"
,
toDayList
);
...
...
@@ -199,54 +143,25 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
}
public
List
<
KylinPerformanceVo
>
recommendList
()
{
// 固定条件
Query
query
=
new
Query
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
String
nowTimeStr
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
nowTime
);
query
.
addCriteria
(
Criteria
.
where
(
"timeEnd"
).
gte
(
nowTimeStr
));
query
.
fields
().
exclude
(
"details"
);
query
.
fields
().
exclude
(
"noticeImage"
);
// 推荐
query
.
addCriteria
(
Criteria
.
where
(
"isRecommend"
).
is
(
1
));
List
<
KylinPerformanceVo
>
recommendList
=
mongoTemplate
.
find
(
query
,
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
());
return
recommendList
;
List
<
KylinPerformanceVo
>
performancesListRecommend
=
dataUtils
.
getPerformancesListIsRecommend
();
return
performancesListRecommend
;
}
public
List
<
KylinPerformanceVo
>
exclusiveList
(
Integer
page
,
Integer
size
)
{
// 固定条件
Query
query
=
new
Query
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
String
nowTimeStr
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
nowTime
);
query
.
addCriteria
(
Criteria
.
where
(
"timeEnd"
).
gte
(
nowTimeStr
));
query
.
fields
().
exclude
(
"details"
);
query
.
fields
().
exclude
(
"noticeImage"
);
Pageable
pageable
=
PageRequest
.
of
(
page
-
1
,
size
);
query
.
with
(
pageable
);
query
.
addCriteria
(
Criteria
.
where
(
"isExclusive"
).
is
(
1
));
List
<
KylinPerformanceVo
>
recommendList
=
mongoTemplate
.
find
(
query
,
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
());
return
recommendList
;
public
List
<
KylinPerformanceVo
>
exclusiveList
()
{
// 所有城市演出
List
<
KylinPerformanceVo
>
performancesList
=
dataUtils
.
getPerformancesListAll
();
List
<
KylinPerformanceVo
>
performancesListNew
=
new
ArrayList
<>();
for
(
KylinPerformanceVo
info
:
performancesList
)
{
if
(
1
==
info
.
getIsExclusive
())
{
performancesListNew
.
add
(
info
);
}
}
return
performancesListNew
;
}
public
KylinPerformanceVo
detail
(
String
performancesId
,
double
latitudeFrom
,
double
longitudeFrom
)
{
KylinPerformanceVo
performancesInfo
=
dataUtils
.
getPerformanceVo
(
performancesId
);
String
roadShowId
=
performancesInfo
.
getRoadShowId
();
List
<
KylinPerformanceVo
>
roadList
=
new
ArrayList
();
if
(
Integer
.
parseInt
(
roadShowId
)
>
0
)
{
roadList
=
mongoTemplate
.
find
(
Query
.
query
(
Criteria
.
where
(
"roadShowId"
).
is
(
roadShowId
)),
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
()
);
}
// 处理状态 购买 未开始 结束可更改 下架 售馨不可更改
if
(
performancesInfo
.
getAppStatus
()
==
6
||
performancesInfo
.
getAppStatus
()
==
9
||
performancesInfo
.
getAppStatus
()
==
10
)
{
...
...
@@ -271,13 +186,8 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
if
(
longitudeFrom
!=
CommonConst
.
DFT_DOUBLE_VAL
)
{
String
diffDistance
=
DistanceUtil
.
getDistance
(
longitudeFrom
,
latitudeFrom
,
Double
.
parseDouble
(
performancesInfo
.
getLongitude
()),
Double
.
parseDouble
(
performancesInfo
.
getLatitude
()));
performancesInfo
.
setDiffDistance
(
diffDistance
);
for
(
KylinPerformanceVo
road
:
roadList
)
{
String
diffDistanceRoad
=
DistanceUtil
.
getDistance
(
longitudeFrom
,
latitudeFrom
,
Double
.
parseDouble
(
performancesInfo
.
getLongitude
()),
Double
.
parseDouble
(
performancesInfo
.
getLatitude
()));
road
.
setDiffDistance
(
diffDistanceRoad
);
}
}
performancesInfo
.
setRoadList
(
roadList
);
return
performancesInfo
;
}
...
...
@@ -291,11 +201,6 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
query
.
addCriteria
(
Criteria
.
where
(
"isAgent"
).
is
(
isAgent
));
}
List
<
KylinTicketVo
>
ticketList
=
partner
.
getTicketList
();
// mongoTemplate.find(
// query,
// KylinTicketVo.class,
// KylinTicketVo.class.getSimpleName()
// );
for
(
KylinTicketVo
ticket
:
ticketList
)
{
// 处理状态 购买 未开始 结束可更改 下架 售馨不可更改
...
...
@@ -347,42 +252,36 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
}
public
List
<
KylinPerformanceVo
>
performanceList
(
String
...
performancesIds
)
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"performancesId"
).
in
(
performancesIds
));
query
.
fields
().
exclude
(
"details"
);
query
.
fields
().
exclude
(
"noticeImage"
);
List
<
KylinPerformanceVo
>
list
=
mongoTemplate
.
find
(
query
,
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
());
return
list
;
List
<
KylinPerformanceVo
>
performanceList
=
new
ArrayList
<>();
for
(
String
id
:
performancesIds
)
{
KylinPerformanceVo
info
=
dataUtils
.
getPerformanceVo
(
id
);
performanceList
.
add
(
info
);
}
public
List
performanceCalendar
(
String
yearMonth
,
String
cityName
)
throws
ParseException
{
Document
queryObject
=
new
Document
();
if
(!
cityName
.
isEmpty
())
{
queryObject
.
put
(
"cityName"
,
Pattern
.
compile
(
cityName
,
Pattern
.
CASE_INSENSITIVE
));
return
performanceList
;
}
Query
query
=
new
BasicQuery
(
queryObject
);
public
List
performanceCalendar
(
String
yearMonth
,
String
cityName
)
{
List
<
KylinPerformanceVo
>
performancesList
=
dataUtils
.
getPerformancesListOfcityName
(
cityName
);
// 处理成正常格式
yearMonth
=
yearMonth
.
concat
(
"-01 00:00:00"
);
// 获取此月开始结束时间
String
monthStart
=
DateUtil
.
getMonthFirst
(
yearMonth
);
String
monthEnd
=
DateUtil
.
getMonthLast
(
yearMonth
)
;
query
.
addCriteria
(
Criteria
.
where
(
"timeStart"
).
gte
(
monthStart
).
lte
(
monthEnd
)
);
query
.
fields
().
include
(
"timeStart"
);
String
monthEnd
=
""
;
try
{
monthEnd
=
DateUtil
.
getMonthLast
(
yearMonth
);
}
catch
(
Exception
e
)
{
List
<
KylinPerformanceVo
>
list
=
mongoTemplate
.
find
(
query
,
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
());
}
List
date
=
new
ArrayList
();
for
(
KylinPerformanceVo
v
:
list
)
{
String
timeStart
=
v
.
getTimeStart
();
for
(
KylinPerformanceVo
info
:
performancesList
)
{
String
timeStart
=
info
.
getTimeStart
();
if
(-
1
!=
DateUtil
.
compareStrDay
(
timeStart
,
monthStart
)
&&
1
!=
DateUtil
.
compareStrDay
(
timeStart
,
monthEnd
))
{
String
[]
timeStartArr
=
timeStart
.
split
(
" "
);
date
.
add
(
timeStartArr
[
0
]);
}
}
// 去重
List
newList
=
(
List
)
date
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
...
...
@@ -390,18 +289,19 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
}
public
List
calendarPerformances
(
String
yearMonthDay
,
String
cityName
)
{
Document
queryObject
=
new
Document
();
queryObject
.
put
(
"cityName"
,
Pattern
.
compile
(
cityName
,
Pattern
.
CASE_INSENSITIVE
));
Query
query
=
new
BasicQuery
(
queryObject
);
List
<
KylinPerformanceVo
>
performancesList
=
dataUtils
.
getPerformancesListOfcityName
(
cityName
);
String
yearMonthDayEnd
=
yearMonthDay
.
concat
(
" 23:59:59"
);
query
.
addCriteria
(
Criteria
.
where
(
"timeStart"
).
gte
(
yearMonthDay
).
lte
(
yearMonthDayEnd
));
query
.
fields
().
exclude
(
"details"
);
query
.
fields
().
exclude
(
"noticeImage"
);
List
<
KylinPerformanceVo
>
list
=
mongoTemplate
.
find
(
query
,
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
());
List
<
KylinPerformanceVo
>
performancesListNew
=
new
ArrayList
();
for
(
KylinPerformanceVo
info
:
performancesList
)
{
String
timeStart
=
info
.
getTimeStart
();
if
(-
1
!=
DateUtil
.
compareStrDay
(
timeStart
,
yearMonthDay
)
&&
1
!=
DateUtil
.
compareStrDay
(
timeStart
,
yearMonthDayEnd
))
{
performancesListNew
.
add
(
info
);
}
}
return
list
;
return
performancesListNew
;
}
public
HashMap
performancesSearch
(
String
title
,
int
page
,
int
size
)
{
...
...
@@ -413,6 +313,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
query
.
fields
().
exclude
(
"details"
);
query
.
fields
().
exclude
(
"noticeImage"
);
query
.
fields
().
exclude
(
"ticketTimeList"
);
Sort
sortName
=
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"timeStart"
);
Pageable
pageable
=
PageRequest
.
of
(
page
-
1
,
size
,
sortName
);
...
...
liquidnet-bus-service/liquidnet-service-kylin/liquidnet-service-kylin-impl/src/main/java/com/liquidnet/service/kylin/utils/DataUtils.java
View file @
bb430898
...
...
@@ -17,12 +17,12 @@ import org.springframework.data.domain.Sort;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.*
;
import
java.util.regex.Pattern
;
@Component
public
class
DataUtils
{
...
...
@@ -35,6 +35,10 @@ public class DataUtils {
private
RedisUtil
redisUtil
;
@Autowired
private
MongoVoUtils
mongoVoUtils
;
@Autowired
private
DataUtils
dataUtils
;
@Autowired
private
RedisTemplate
redisTemplate
;
/**
* 根据 购票须知 id 获取 购票须知文案
...
...
@@ -141,7 +145,12 @@ public class DataUtils {
if
(
redisUtil
.
hasKey
(
KylinRedisConst
.
PERFORMANCES
+
performanceId
))
{
}
else
{
KylinPerformanceVo
performanceData
=
mongoTemplate
.
findOne
(
Query
.
query
(
Criteria
.
where
(
"performancesId"
).
is
(
performanceId
)),
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
());
List
<
KylinPerformanceVo
>
roadList
=
new
ArrayList
();
if
(
Integer
.
parseInt
(
performanceData
.
getRoadShowId
())
>
0
)
{
roadList
=
dataUtils
.
getRoadList
(
performanceData
.
getRoadShowId
());
}
redisUtil
.
set
(
KylinRedisConst
.
PERFORMANCES
+
performanceId
,
performanceData
);
performanceData
.
setRoadList
(
roadList
);
// 不一起存到演出详情
}
return
(
KylinPerformanceVo
)
redisUtil
.
get
(
KylinRedisConst
.
PERFORMANCES
+
performanceId
);
}
...
...
@@ -369,14 +378,14 @@ public class DataUtils {
int
count
=
0
;
for
(
int
i
=
0
;
i
<
allTicketId
.
get
(
useTime
).
size
();
i
++)
{
String
item
=
allTicketId
.
get
(
useTime
).
get
(
i
);
if
(
allTicketId
.
get
(
useTime
).
size
()==
1
)
{
if
(
allTicketId
.
get
(
useTime
).
size
()
==
1
)
{
redisUtil
.
incr
(
performanceIdKey
,
buyCount
);
break
;
}
if
(
i
==
0
)
{
count
=
(
int
)
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
);
}
else
{
if
(
count
!=
(
int
)
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
))
{
if
(
count
!=
(
int
)
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
))
{
redisUtil
.
incr
(
performanceIdKey
,
buyCount
);
break
;
}
...
...
@@ -391,14 +400,14 @@ public class DataUtils {
int
count
=
0
;
for
(
int
i
=
0
;
i
<
allTicketId
.
get
(
useTime
).
size
();
i
++)
{
String
item
=
allTicketId
.
get
(
useTime
).
get
(
i
);
if
(
allTicketId
.
get
(
useTime
).
size
()==
1
)
{
if
(
allTicketId
.
get
(
useTime
).
size
()
==
1
)
{
redisUtil
.
decr
(
performanceIdKey
,
Math
.
abs
(
buyCount
));
break
;
}
if
(
i
==
0
)
{
count
=
(
int
)
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
);
}
else
{
if
(
count
!=
(
int
)
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
))
{
if
(
count
!=
(
int
)
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
))
{
redisUtil
.
decr
(
performanceIdKey
,
Math
.
abs
(
buyCount
));
break
;
}
...
...
@@ -471,13 +480,19 @@ public class DataUtils {
* @param cityName
*/
public
List
<
KylinPerformanceVo
>
getPerformancesListOfcityName
(
String
cityName
)
{
String
redisKey
=
KylinRedisConst
.
PERFORMANCES
.
concat
(
cityName
);
String
redisKey
=
KylinRedisConst
.
PERFORMANCES
_LIST_CITYNAME
.
concat
(
cityName
);
if
(!
redisUtil
.
hasKey
(
redisKey
))
{
// 固定查询条件
Query
query
=
new
Query
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
String
nowTimeStr
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
nowTime
);
query
.
addCriteria
(
Criteria
.
where
(
"timeEnd"
).
gte
(
nowTimeStr
));
// 其他条件
Pattern
cityNameCompile
=
Pattern
.
compile
(
"^.*"
+
cityName
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
query
.
addCriteria
(
Criteria
.
where
(
"cityName"
).
regex
(
cityNameCompile
));
// 排序
Sort
sortName
=
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"timeStart"
);
query
.
with
(
sortName
);
// 不要查询的字段
query
.
fields
().
exclude
(
"details"
);
query
.
fields
().
exclude
(
"noticeImage"
);
...
...
@@ -488,6 +503,15 @@ public class DataUtils {
return
(
List
<
KylinPerformanceVo
>)
redisUtil
.
get
(
redisKey
);
}
/**
* 删除演出列表redis
*
* @param cityName
*/
public
void
delPerformancesListOfcityName
(
String
cityName
)
{
redisUtil
.
del
(
KylinRedisConst
.
ORDER_ENTITIES
.
concat
(
cityName
));
}
/**
* 获取推荐演出列表redis
*/
...
...
@@ -499,6 +523,9 @@ public class DataUtils {
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
String
nowTimeStr
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
nowTime
);
query
.
addCriteria
(
Criteria
.
where
(
"timeEnd"
).
gte
(
nowTimeStr
));
// 排序
Sort
sortName
=
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"timeStart"
);
query
.
with
(
sortName
);
// 不要查询的字段
query
.
fields
().
exclude
(
"details"
);
query
.
fields
().
exclude
(
"noticeImage"
);
...
...
@@ -513,11 +540,45 @@ public class DataUtils {
/**
* 删除演出列表redis
*
* @param cityName
*/
public
void
delPerformancesListOfcityName
(
String
cityName
)
{
redisUtil
.
del
(
KylinRedisConst
.
ORDER_ENTITIES
.
concat
(
cityName
));
public
void
delPerformancesListIsRecommend
()
{
redisUtil
.
del
(
KylinRedisConst
.
PERFORMANCES_LIST_RECOMMEND
);
}
/**
* 获取所有城市演出列表redis
*/
public
List
<
KylinPerformanceVo
>
getPerformancesListAll
()
{
List
<
KylinPerformanceVo
>
list
=
new
ArrayList
<>();
Set
<
String
>
keys
=
redisTemplate
.
keys
(
KylinRedisConst
.
PERFORMANCES_LIST_ALL
);
for
(
String
key
:
keys
)
{
List
<
KylinPerformanceVo
>
OneCityList
=
(
List
<
KylinPerformanceVo
>)
redisUtil
.
get
(
key
);
list
.
addAll
(
OneCityList
);
}
return
list
;
}
/**
* 获取巡演列表redis
*/
public
List
<
KylinPerformanceVo
>
getRoadList
(
String
roadShowId
)
{
String
redisKey
=
KylinRedisConst
.
PERFORMANCES_ROADLIST
.
concat
(
roadShowId
);
if
(!
redisUtil
.
hasKey
(
redisKey
))
{
List
<
KylinPerformanceVo
>
roadList
=
mongoTemplate
.
find
(
Query
.
query
(
Criteria
.
where
(
"roadShowId"
).
is
(
roadShowId
)),
KylinPerformanceVo
.
class
,
KylinPerformanceVo
.
class
.
getSimpleName
()
);
redisUtil
.
set
(
redisKey
,
roadList
);
}
return
(
List
<
KylinPerformanceVo
>)
redisUtil
.
get
(
redisKey
);
}
/**
* 删除巡演列表redis
*/
public
void
delRoadList
(
String
roadShowId
)
{
redisUtil
.
del
(
KylinRedisConst
.
PERFORMANCES_ROADLIST
.
concat
(
roadShowId
));
}
}
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