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
ca6d68f0
Commit
ca6d68f0
authored
Nov 22, 2022
by
宋珺琪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
时空日程提醒
parent
d736be2f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
1 deletions
+100
-1
service/publicapi/src/main/java/com/founder/publicapi/PublicapiApplication.java
+2
-1
service/publicapi/src/main/java/com/founder/publicapi/controller/SkypDesktop/SkypDesktopController.java
+98
-0
No files found.
service/publicapi/src/main/java/com/founder/publicapi/PublicapiApplication.java
View file @
ca6d68f0
...
@@ -6,8 +6,9 @@ import org.springframework.boot.SpringApplication;
...
@@ -6,8 +6,9 @@ import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
@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 @
ca6d68f0
package
com
.
founder
.
publicapi
.
controller
.
SkypDesktop
;
package
com
.
founder
.
publicapi
.
controller
.
SkypDesktop
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.founder.commonutils.model.newPublicEntity.ApprovalEntity.TbstApproveOrder
;
import
com.founder.commonutils.model.newPublicEntity.ApprovalEntity.TbstOrderDetail
;
import
com.founder.commonutils.model.newPublicEntity.MapRestResult
;
import
com.founder.commonutils.model.newPublicEntity.MapRestResult
;
import
com.founder.commonutils.model.newPublicEntity.SkypDesktopEntity.SkMenu
;
import
com.founder.commonutils.model.newPublicEntity.SkypDesktopEntity.SkMenu
;
import
com.founder.commonutils.model.newPublicEntity.SkypDesktopEntity.SkSchedule
;
import
com.founder.commonutils.model.newPublicEntity.SkypDesktopEntity.SkSchedule
;
...
@@ -13,14 +15,19 @@ import com.founder.publicapi.mapper.mysqlMapper.SkMenuMapper;
...
@@ -13,14 +15,19 @@ 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.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -36,6 +43,9 @@ public class SkypDesktopController {
...
@@ -36,6 +43,9 @@ public class SkypDesktopController {
@Autowired
@Autowired
SkScheduleMapper
skScheduleMapper
;
SkScheduleMapper
skScheduleMapper
;
@Autowired
WebSocketServer
webSocketServer
;
/**
/**
* 时空桌面菜单新增
* 时空桌面菜单新增
...
@@ -306,4 +316,92 @@ public class SkypDesktopController {
...
@@ -306,4 +316,92 @@ public class SkypDesktopController {
return
formatter
.
format
(
date
);
return
formatter
.
format
(
date
);
}
}
/**
* 启动后10秒启动,之后每一个小时开始一次
*/
@Scheduled
(
initialDelay
=
10000
,
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