Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
map-parent
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
常超
map-parent
Commits
ac305945
Commit
ac305945
authored
Nov 22, 2022
by
宋珺琪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日程提醒(湖南)
parent
90977a79
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
+92
-0
service/publicapi/src/main/java/com/founder/publicapi/PublicapiApplication.java
+2
-0
service/publicapi/src/main/java/com/founder/publicapi/controller/SkypDesktop/SkypDesktopController.java
+90
-0
No files found.
service/publicapi/src/main/java/com/founder/publicapi/PublicapiApplication.java
View file @
ac305945
...
@@ -9,9 +9,11 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
...
@@ -9,9 +9,11 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
@EnableScheduling
@SpringBootApplication
@SpringBootApplication
@ComponentScan
(
basePackages
=
{
"com.founder"
})
@ComponentScan
(
basePackages
=
{
"com.founder"
})
@MapperScan
(
basePackages
=
{
"com.founder.publicapi.mapper"
})
@MapperScan
(
basePackages
=
{
"com.founder.publicapi.mapper"
})
...
...
service/publicapi/src/main/java/com/founder/publicapi/controller/SkypDesktop/SkypDesktopController.java
View file @
ac305945
...
@@ -12,13 +12,16 @@ import com.founder.publicapi.mapper.mysqlMapper.SkMenuMapper;
...
@@ -12,13 +12,16 @@ import com.founder.publicapi.mapper.mysqlMapper.SkMenuMapper;
import
com.founder.publicapi.mapper.mysqlMapper.SkScheduleMapper
;
import
com.founder.publicapi.mapper.mysqlMapper.SkScheduleMapper
;
import
com.founder.servicebase.logs.OperLog
;
import
com.founder.servicebase.logs.OperLog
;
import
com.founder.servicebase.logs.OperationType
;
import
com.founder.servicebase.logs.OperationType
;
import
com.founder.servicebase.meassage.WebSocketServer
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -305,4 +308,91 @@ public class SkypDesktopController {
...
@@ -305,4 +308,91 @@ public class SkypDesktopController {
return
formatter
.
format
(
date
);
return
formatter
.
format
(
date
);
}
}
/**
* 启动后一分钟启动,之后每一个小时开始一次
* 每天八点到十点 每半个小时 0 0/30 8-22 * * ?
* 每天的8点开始,2小时执行一次:0 0 8/2 * * ?
* 每个整点执行一次:0 0 0/1 * * ?
*/
@Scheduled
(
initialDelay
=
60000
,
fixedDelay
=
1800000
)
public
void
timing
()
throws
ParseException
{
System
.
out
.
println
(
"-----------------------日程定时任务启动"
);
for
(
String
s
:
WebSocketServer
.
map
.
keySet
())
{
//获取所有正常的日程
QueryWrapper
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"state"
,
"2"
);
wrapper
.
eq
(
"isDeleted"
,
"0"
);
wrapper
.
eq
(
"zjhm"
,
s
);
List
<
SkSchedule
>
list
=
skScheduleMapper
.
selectList
(
wrapper
);
startTask
(
list
);
}
}
public
void
startTask
(
List
<
SkSchedule
>
list
)
throws
ParseException
{
if
(
list
!=
null
&&
list
.
size
()>
0
){
for
(
SkSchedule
skSchedule
:
list
)
{
//日程时间
String
time
=
skSchedule
.
getTime
();
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Date
Jzsj
=
simpleDateFormat
.
parse
(
time
);
//当前时间
Date
date
=
new
Date
();
//开始时间 在当前时间的基础上减一个小时
Calendar
rightNow
=
Calendar
.
getInstance
();
rightNow
.
setTime
(
date
);
//rightNow.add(Calendar.DATE, -1);
rightNow
.
add
(
Calendar
.
HOUR
,
-
1
);
Date
kssj
=
rightNow
.
getTime
();
System
.
out
.
println
(
kssj
);
//判断日程是否在当前时间的前一个小时内
Boolean
flag
=
belongCalendar
(
Jzsj
,
kssj
,
date
);
String
userId
=
skSchedule
.
getZjhm
();
if
(
flag
){
System
.
out
.
println
(
"++++++++++++++++++++++日程定时1111"
);
WebSocketServer
.
SendMessage
(
WebSocketServer
.
map
.
get
(
userId
),
":你的("
+
skSchedule
.
getBz
()+
")日程到了,请尽快处理"
);
System
.
out
.
println
(
"++++++++++++++++++++++日程定时结束"
);
}
//当前时间
Date
date1
=
new
Date
();
//开始时间 在当前时间的基础上减一个小时
Calendar
rightNow1
=
Calendar
.
getInstance
();
rightNow1
.
setTime
(
date1
);
//rightNow.add(Calendar.DATE, -1);
rightNow1
.
add
(
Calendar
.
HOUR
,
1
);
Date
kssj1
=
rightNow1
.
getTime
();
// 判断日程是否在当前时间的后一个小时内
Boolean
flag1
=
belongCalendar
(
Jzsj
,
date
,
kssj1
);
if
(
flag1
){
System
.
out
.
println
(
"++++++++++++++++++++++日程定时1111"
);
WebSocketServer
.
SendMessage
(
WebSocketServer
.
map
.
get
(
userId
),
":你的("
+
skSchedule
.
getBz
()+
")日程快到了,请尽快处理"
);
System
.
out
.
println
(
"++++++++++++++++++++++日程定时结束"
);
}
}
}
}
/**
* Description: 判断一个时间是否在一个时间段内 </br>
*
* @param nowTime 当前时间 </br>
* @param beginTime 开始时间 </br>
* @param endTime 结束时间 </br>
*/
private
boolean
belongCalendar
(
Date
nowTime
,
Date
beginTime
,
Date
endTime
)
{
Calendar
date
=
Calendar
.
getInstance
();
date
.
setTime
(
nowTime
);
Calendar
begin
=
Calendar
.
getInstance
();
begin
.
setTime
(
beginTime
);
Calendar
end
=
Calendar
.
getInstance
();
end
.
setTime
(
endTime
);
return
date
.
after
(
begin
)
&&
date
.
before
(
end
);
}
}
}
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