Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
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
徐少华
midjourney-proxy
Commits
058d0e1a
Commit
058d0e1a
authored
Jun 19, 2019
by
高鹏
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mymaster' into 'master'
C1000805_微信群群发支持计划式多次发送,增加时间判断2 See merge request rays/pcloud-book!17
parents
39e255c3
f41dc6cf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
PushCheck.java
...k/src/main/java/com/pcloud/book/push/check/PushCheck.java
+52
-0
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/push/check/PushCheck.java
View file @
058d0e1a
...
...
@@ -12,6 +12,7 @@ import com.pcloud.common.utils.ListUtils;
import
com.pcloud.common.utils.string.StringUtil
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -46,6 +47,7 @@ public class PushCheck {
if
(
push
.
getStartTime
()
!=
null
&&
push
.
getEndTime
()
!=
null
&&
push
.
getStartTime
().
getTime
()
-
push
.
getEndTime
().
getTime
()
>
0
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"开始时间必须在结束时间之前!"
);
}
checkHasDayToSend
(
push
);
if
(
ListUtils
.
isEmpty
(
push
.
getPushGroups
()))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"发送群不能为空!"
);
}
...
...
@@ -99,6 +101,56 @@ public class PushCheck {
}
/**
* 校验时间有效性
*/
private
void
checkHasDayToSend
(
Push
push
)
{
if
(
push
.
getStartTime
()
!=
null
&&
push
.
getEndTime
()
!=
null
)
{
if
(
PushTypeEnum
.
DAY
.
value
.
equals
(
push
.
getPushType
()))
{
Date
endTime
=
push
.
getEndTime
();
Date
now
=
new
Date
();
String
pushTime
=
push
.
getPushTime
();
if
(
DateUtils
.
getDayStart
(
endTime
).
getTime
()
==
DateUtils
.
getDayStart
(
now
).
getTime
())
{
if
(
DateUtils
.
getDateFromString
(
pushTime
,
"HH:mm:ss"
).
getTime
()
<
DateUtils
.
getDateFromString
(
DateUtils
.
getStrFormTime
(
"HH:mm:ss"
,
new
Date
()),
"HH:mm:ss"
).
getTime
())
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"时间填写错误,没有有效的群发时间,请重新选取!"
);
}
}
}
if
(
PushTypeEnum
.
WEEK
.
value
.
equals
(
push
.
getPushType
())
&&
push
.
getWeekDay
()
!=
null
&&
push
.
getEndTime
()
!=
null
)
{
Date
endDay
=
push
.
getEndTime
();
Integer
weekDay
=
push
.
getWeekDay
();
String
pushTime
=
push
.
getPushTime
();
if
(
weekDay
==
7
)
{
weekDay
=
1
;
}
else
{
weekDay
=
weekDay
+
1
;
}
List
<
String
>
list
=
new
ArrayList
<>();
for
(
Date
i
=
new
Date
();
!
i
.
after
(
endDay
);
i
=
DateUtils
.
addDay
(
i
,
1
))
{
if
(
weekDay
==
DateUtils
.
getWeekIndex
(
i
))
{
list
.
add
(
DateUtils
.
formatDate
(
i
,
"yyyy-MM-dd"
));
}
}
if
(
ListUtils
.
isEmpty
(
list
))
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"时间填写错误,没有有效的群发时间,请重新选取!"
);
}
if
(
list
.
size
()
==
1
)
{
String
s
=
list
.
get
(
0
);
Date
date1
=
DateUtils
.
getDateFromString
(
s
,
"yyyy-MM-dd"
);
date1
=
DateUtils
.
addHour
(
date1
,
new
Integer
(
pushTime
.
substring
(
0
,
2
)));
date1
=
DateUtils
.
addMinute
(
date1
,
new
Integer
(
pushTime
.
substring
(
3
,
5
)));
date1
=
DateUtils
.
addMinute
(
date1
,
new
Integer
(
pushTime
.
substring
(
6
,
8
)));
Long
sl
=
date1
.
getTime
();
Long
sll
=
new
Date
().
getTime
();
if
(
sl
<
sll
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"时间填写错误,没有有效的群发时间,请重新选取!"
);
}
}
}
}
}
/**
* 校验时间
*
* @param push
...
...
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