Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
项目统一框架
amos-boot-biz
Commits
13d1f3bc
Commit
13d1f3bc
authored
Oct 13, 2022
by
tangwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
单体模式下,不初始化锁
parent
75904892
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
579 additions
and
272 deletions
+579
-272
RedissonConfig.java
...java/com/yeejoin/amos/boot/biz/config/RedissonConfig.java
+14
-14
AnalysisReportSchedulerJob.java
...eejoin/equipmanage/quartz/AnalysisReportSchedulerJob.java
+96
-60
View3dController.java
...eejoin/amos/fas/business/controller/View3dController.java
+12
-2
FireScheduled.java
...om/yeejoin/amos/fas/business/scheduled/FireScheduled.java
+30
-2
QuoteCountFlushTiming.java
...n/amos/knowledgebase/face/util/QuoteCountFlushTiming.java
+50
-27
JobService.java
.../java/com/yeejoin/amos/maintenance/quartz/JobService.java
+64
-13
PlanTaskJob.java
...n/java/com/yeejoin/amos/maintenance/task/PlanTaskJob.java
+31
-21
PlanTaskController.java
...n/amos/patrol/business/controller/PlanTaskController.java
+34
-19
JobService.java
.../main/java/com/yeejoin/amos/patrol/quartz/JobService.java
+114
-47
LatentDanerScheduled.java
...om/yeejoin/amos/patrol/schedule/LatentDanerScheduled.java
+9
-2
JobService.java
.../java/com/yeejoin/amos/supervision/quartz/JobService.java
+115
-54
PlanTaskJob.java
...n/java/com/yeejoin/amos/supervision/task/PlanTaskJob.java
+9
-2
application-single.properties
...em-equip/src/main/resources/application-single.properties
+1
-2
application-single.properties
...stem-jcs/src/main/resources/application-single.properties
+0
-1
application-single.properties
...edgebase/src/main/resources/application-single.properties
+0
-1
application-single.properties
...ntdanger/src/main/resources/application-single.properties
+0
-1
application-single.properties
...ntenance/src/main/resources/application-single.properties
+0
-1
application-single.properties
...m-patrol/src/main/resources/application-single.properties
+0
-1
application-single.properties
...ervision/src/main/resources/application-single.properties
+0
-1
application-single.properties
...ls-video/src/main/resources/application-single.properties
+0
-1
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/config/RedissonConfig.java
View file @
13d1f3bc
...
...
@@ -39,7 +39,6 @@ public class RedissonConfig {
}
Config
config
=
new
Config
();
ClusterServersConfig
clusterServersConfig
=
config
.
useClusterServers
()
.
setScanInterval
(
2000
)
// 集群状态扫描间隔时间,单位是毫秒
.
addNodeAddress
(
clusterNodes
.
toArray
(
new
String
[
clusterNodes
.
size
()]));
...
...
@@ -56,19 +55,19 @@ public class RedissonConfig {
* 单机模式 redisson 客户端
*/
@Bean
@ConditionalOnProperty
(
name
=
"spring.redis.mode"
,
havingValue
=
"single"
)
RedissonClient
redissonSingle
()
{
Config
config
=
new
Config
();
String
node
=
redisConfigProperties
.
getRedissonUrl
();
node
=
node
.
startsWith
(
"redis://"
)
?
node
:
"redis://"
+
node
;
SingleServerConfig
serverConfig
=
config
.
useSingleServer
()
.
setAddress
(
node
);
if
(
StringUtils
.
isNotBlank
(
redisConfigProperties
.
getPassword
()))
{
serverConfig
.
setPassword
(
redisConfigProperties
.
getPassword
());
}
return
Redisson
.
create
(
config
);
}
//
@Bean
//
@ConditionalOnProperty(name = "spring.redis.mode", havingValue = "single")
//
RedissonClient redissonSingle() {
//
Config config = new Config();
//
String node = redisConfigProperties.getRedissonUrl();
//
node = node.startsWith("redis://") ? node : "redis://" + node;
//
SingleServerConfig serverConfig = config.useSingleServer()
//
.setAddress(node);
//
if (StringUtils.isNotBlank(redisConfigProperties.getPassword())) {
//
serverConfig.setPassword(redisConfigProperties.getPassword());
//
}
//
return Redisson.create(config);
//
}
}
\ No newline at end of file
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/quartz/AnalysisReportSchedulerJob.java
View file @
13d1f3bc
...
...
@@ -6,6 +6,7 @@ import com.yeejoin.equipmanage.common.utils.DateUtils;
import
com.yeejoin.equipmanage.service.IAnalysisReportLogService
;
import
org.redisson.api.RLock
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -25,43 +26,61 @@ public class AnalysisReportSchedulerJob {
@Autowired
private
IAnalysisReportLogService
iAnalysisReportLogService
;
@Autowired
@Autowired
(
required
=
false
)
org
.
redisson
.
api
.
RedissonClient
redisson
;
@Autowired
private
RedisUtils
redisUtils
;
@Value
(
"${spring.redis.mode}"
)
private
String
cluster
;
/**
* 每天凌晨0点-日报生成
*/
@Scheduled
(
cron
=
"0 0 0 * * ?"
)
public
void
dayReport
()
throws
ParseException
{
if
(
cluster
.
equals
(
"cluster"
)){
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"dayReport"
+
time
;
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_dayReport_key"
))
{
redisUtils
.
set
(
jobName
+
"_dayReport_key"
,
"1"
);
//增加标识
Date
beginDate
=
DateUtils
.
dateAdd
(
new
Date
(),
-
1
,
false
);
Date
endDate
=
DateUtils
.
dateAdd
(
new
Date
(),
-
1
,
false
);
iAnalysisReportLogService
.
generateReport
(
AnalysisReportEnum
.
DAY_REPORT
,
beginDate
,
endDate
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
try
{
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"dayReport"
+
time
;
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_dayReport_key"
))
{
redisUtils
.
set
(
jobName
+
"_dayReport_key"
,
"1"
);
//增加标识
Date
beginDate
=
DateUtils
.
dateAdd
(
new
Date
(),
-
1
,
false
);
Date
endDate
=
DateUtils
.
dateAdd
(
new
Date
(),
-
1
,
false
);
iAnalysisReportLogService
.
generateReport
(
AnalysisReportEnum
.
DAY_REPORT
,
beginDate
,
endDate
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
/**
...
...
@@ -69,30 +88,40 @@ public class AnalysisReportSchedulerJob {
*/
@Scheduled
(
cron
=
"0 0 0 ? * 1"
)
public
void
weekReport
()
throws
ParseException
{
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"weekReport"
+
time
;
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_weekReport_key"
))
{
redisUtils
.
set
(
jobName
+
"_weekReport_key"
,
"1"
);
//增加标识
Date
yestDay
=
DateUtils
.
dateAdd
(
new
Date
(),
-
1
,
false
);
Date
beginDate
=
DateUtils
.
getFirstDayOfWeek
(
yestDay
);
Date
endDate
=
DateUtils
.
getLastDayOfWeek
(
yestDay
);
iAnalysisReportLogService
.
generateReport
(
AnalysisReportEnum
.
WEEK_REPORT
,
beginDate
,
endDate
);
if
(
cluster
.
equals
(
"cluster"
))
{
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"weekReport"
+
time
;
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_weekReport_key"
))
{
redisUtils
.
set
(
jobName
+
"_weekReport_key"
,
"1"
);
//增加标识
Date
yestDay
=
DateUtils
.
dateAdd
(
new
Date
(),
-
1
,
false
);
Date
beginDate
=
DateUtils
.
getFirstDayOfWeek
(
yestDay
);
Date
endDate
=
DateUtils
.
getLastDayOfWeek
(
yestDay
);
iAnalysisReportLogService
.
generateReport
(
AnalysisReportEnum
.
WEEK_REPORT
,
beginDate
,
endDate
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
Date
yestDay
=
DateUtils
.
dateAdd
(
new
Date
(),
-
1
,
false
);
Date
beginDate
=
DateUtils
.
getFirstDayOfWeek
(
yestDay
);
Date
endDate
=
DateUtils
.
getLastDayOfWeek
(
yestDay
);
iAnalysisReportLogService
.
generateReport
(
AnalysisReportEnum
.
WEEK_REPORT
,
beginDate
,
endDate
);
}
}
/**
...
...
@@ -100,28 +129,35 @@ public class AnalysisReportSchedulerJob {
*/
@Scheduled
(
cron
=
"0 0 0 1 * ?"
)
public
void
monthReport
()
throws
ParseException
{
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"monthReport"
+
time
;
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_monthReport_key"
))
{
redisUtils
.
set
(
jobName
+
"_monthReport_key"
,
"1"
);
//增加标识
Date
yestDay
=
DateUtils
.
dateAdd
(
new
Date
(),
-
1
,
false
);
Date
beginDate
=
DateUtils
.
getFirstDayOfMonth
(
yestDay
);
Date
endDate
=
DateUtils
.
getLastDayOfMonth
(
yestDay
);
iAnalysisReportLogService
.
generateMonthReport
(
AnalysisReportEnum
.
MONTH_REPORT
,
beginDate
,
endDate
);
if
(
cluster
.
equals
(
"cluster"
))
{
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"monthReport"
+
time
;
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_monthReport_key"
))
{
redisUtils
.
set
(
jobName
+
"_monthReport_key"
,
"1"
);
//增加标识
Date
yestDay
=
DateUtils
.
dateAdd
(
new
Date
(),
-
1
,
false
);
Date
beginDate
=
DateUtils
.
getFirstDayOfMonth
(
yestDay
);
Date
endDate
=
DateUtils
.
getLastDayOfMonth
(
yestDay
);
iAnalysisReportLogService
.
generateMonthReport
(
AnalysisReportEnum
.
MONTH_REPORT
,
beginDate
,
endDate
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
Date
yestDay
=
DateUtils
.
dateAdd
(
new
Date
(),
-
1
,
false
);
Date
beginDate
=
DateUtils
.
getFirstDayOfMonth
(
yestDay
);
Date
endDate
=
DateUtils
.
getLastDayOfMonth
(
yestDay
);
iAnalysisReportLogService
.
generateMonthReport
(
AnalysisReportEnum
.
MONTH_REPORT
,
beginDate
,
endDate
);
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-fas-biz/src/main/java/com/yeejoin/amos/fas/business/controller/View3dController.java
View file @
13d1f3bc
...
...
@@ -13,6 +13,7 @@ import java.util.List;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
org.redisson.api.RLock
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
@@ -49,8 +50,11 @@ public class View3dController extends AbstractBaseController {
private
IRiskSourceService
riskSourceService
;
@Autowired
private
IView3dService
view3dService
;
@Autowired
@Autowired
(
required
=
false
)
org
.
redisson
.
api
.
RedissonClient
redisson
;
@Value
(
"${spring.redis.mode}"
)
private
String
cluster
;
@Autowired
private
RedisUtils
redisUtils
;
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
...
...
@@ -228,7 +232,7 @@ public class View3dController extends AbstractBaseController {
@Scheduled
(
cron
=
"${param.safetyIndexChange.cron}"
)
public
CommonResponse
safetyIndexLog
(){
if
(
"cluster"
.
equals
(
cluster
)){
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"fas-2"
+
time
;
...
...
@@ -252,6 +256,12 @@ public class View3dController extends AbstractBaseController {
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
view3dService
.
safetyIndexLogGenJob
(
null
);
}
return
CommonResponseUtil
.
success
();
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-fas-biz/src/main/java/com/yeejoin/amos/fas/business/scheduled/FireScheduled.java
View file @
13d1f3bc
...
...
@@ -12,6 +12,7 @@ import org.redisson.api.RedissonClient;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -25,15 +26,17 @@ public class FireScheduled {
@Autowired
IContingencyInstance
iContingencyInstance
;
@Autowired
@Autowired
(
required
=
false
)
RedissonClient
redisson
;
@Autowired
private
RedisUtils
redisUtils
;
@Value
(
"${spring.redis.mode}"
)
private
String
cluster
;
@Scheduled
(
cron
=
"*/2 * * * * ?"
)
public
void
runFireQueue
()
throws
Exception
{
if
(
"cluster"
.
equals
(
cluster
)){
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
...
...
@@ -80,6 +83,31 @@ public class FireScheduled {
lock
.
unlock
();
//释放锁
}
}
else
{
if
(
fireQueue
.
size
()
==
0
)
return
;
Map
<
String
,
String
>
map
=
fireQueue
.
getFirst
();
String
batchNo
=
map
.
get
(
"batchNo"
);
String
stepCode
=
map
.
get
(
"stepCode"
);
String
buttonCode
=
map
.
get
(
"buttonCode"
);
String
confirm
=
map
.
get
(
"confirm"
);
String
contingencyPlanId
=
map
.
get
(
"contingencyPlanId"
);
String
stepState
=
map
.
get
(
"stepState"
);
// String token = map.get("token");
// String product = map.get("product");
log
.
info
(
"fireQueue-size:"
+
fireQueue
.
size
());
log
.
info
(
"stepCode:"
+
map
.
get
(
"stepCode"
));
log
.
info
(
"buttonCode:"
+
map
.
get
(
"buttonCode"
));
log
.
info
(
"confirm:"
+
map
.
get
(
"confirm"
));
log
.
info
(
"stepState:"
+
map
.
get
(
"stepState"
));
// RequestContext.setToken(token);
// RequestContext.setProduct(product);
iContingencyInstance
.
setButtonExecuted
(
batchNo
,
contingencyPlanId
,
buttonCode
,
confirm
);
iContingencyInstance
.
fire
(
batchNo
,
stepCode
,
contingencyPlanId
,
buttonCode
,
confirm
,
stepState
);
}
}
public
static
LinkedList
<
Map
<
String
,
String
>>
getFireQueue
()
{
return
fireQueue
;
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-knowledgebase-biz/src/main/java/com/yeejoin/amos/knowledgebase/face/util/QuoteCountFlushTiming.java
View file @
13d1f3bc
...
...
@@ -6,6 +6,7 @@ import com.yeejoin.amos.knowledgebase.face.service.DocAuditService;
import
com.yeejoin.amos.knowledgebase.face.service.InteractionCountService
;
import
org.redisson.api.RLock
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -37,8 +38,12 @@ public class QuoteCountFlushTiming {
@Autowired
private
ConfigLoader
configLoader
;
@Autowired
@Autowired
(
required
=
false
)
org
.
redisson
.
api
.
RedissonClient
redisson
;
@Value
(
"${spring.redis.mode}"
)
private
String
cluster
;
@Autowired
private
RedisUtils
redisUtils
;
...
...
@@ -55,6 +60,7 @@ public class QuoteCountFlushTiming {
@Transactional
(
rollbackFor
=
{
Exception
.
class
,
BaseException
.
class
})
public
void
flushTagQuoteCount
()
{
if
(
"cluster"
.
equals
(
cluster
)){
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"knowledgeBase-1"
+
time
;
...
...
@@ -85,40 +91,57 @@ public class QuoteCountFlushTiming {
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
if
(
needFlush
.
get
())
{
needFlush
.
set
(
false
);
interactionCountService
.
deleteAllTagQuote
();
List
<
KnowledgeInteractionCount
>
allTagQuoteRecords
=
interactionCountService
.
getAllTagQuoteRecords
();
if
(!
allTagQuoteRecords
.
isEmpty
())
{
allTagQuoteRecords
.
forEach
(
e
->
e
.
setAgencyCode
(
configLoader
.
getAgencyCode
()));
boolean
finished
=
interactionCountService
.
saveBatch
(
allTagQuoteRecords
);
System
.
out
.
println
(
"定时-刷新标签引用数-"
+
(
finished
?
"完成"
:
"失败"
));
}
}
}
}
@Scheduled
(
fixedRate
=
3
*
1000
)
@Transactional
(
rollbackFor
=
{
Exception
.
class
,
BaseException
.
class
})
public
void
pushDocs2Rule
()
{
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"knowledgeBase-2"
+
time
;
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
System
.
out
.
println
(
"获取锁成功============"
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_redisson_key"
))
{
redisUtils
.
set
(
jobName
+
"_redisson_key"
,
"1"
);
//
if
(
needPush2Rule
.
get
())
{
needPush2Rule
.
set
(
false
);
docAuditService
.
pushDocs2RuleByMQ
();
System
.
out
.
println
(
"定时-同步规则-完成"
);
}
if
(
"cluster"
.
equals
(
cluster
))
{
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"knowledgeBase-2"
+
time
;
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
System
.
out
.
println
(
"获取锁成功============"
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_redisson_key"
))
{
redisUtils
.
set
(
jobName
+
"_redisson_key"
,
"1"
);
//
if
(
needPush2Rule
.
get
())
{
needPush2Rule
.
set
(
false
);
docAuditService
.
pushDocs2RuleByMQ
();
System
.
out
.
println
(
"定时-同步规则-完成"
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
if
(
needPush2Rule
.
get
())
{
needPush2Rule
.
set
(
false
);
docAuditService
.
pushDocs2RuleByMQ
();
System
.
out
.
println
(
"定时-同步规则-完成"
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/quartz/JobService.java
View file @
13d1f3bc
...
...
@@ -77,8 +77,13 @@ public class JobService implements IJobService {
private
String
patrolTopic
;
@Autowired
@Autowired
(
required
=
false
)
org
.
redisson
.
api
.
RedissonClient
redisson
;
@Value
(
"${spring.redis.mode}"
)
private
String
cluster
;
@Autowired
private
RedisUtils
redisUtils
;
...
...
@@ -304,6 +309,9 @@ public class JobService implements IJobService {
@Transactional
public
void
taskJobPerform
(
long
taskId
,
String
jobType
,
String
jobName
)
{
if
(
"cluster"
.
equals
(
cluster
)){
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
...
...
@@ -349,7 +357,38 @@ public class JobService implements IJobService {
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
if
(
iTaskDao
.
existsById
(
taskId
))
{
Task
task
=
iTaskDao
.
findById
(
taskId
).
get
();
Toke
toke
=
remoteSecurityService
.
getServerToken
();
if
(
XJConstant
.
STATUS_MONITOR_END
.
equals
(
jobType
))
{
if
(
TaskStatusEnum
.
UNDERWAY
.
getValue
()
==
task
.
getStatus
())
{
task
.
setStatus
(
TaskStatusEnum
.
OVERTIME
.
getValue
());
iTaskDao
.
saveAndFlush
(
task
);
TaskFeedback
taskFeedback
=
new
TaskFeedback
();
taskFeedback
.
setUserId
(
task
.
getExecutorId
());
taskFeedback
.
setMessage
(
"该任务在规定时间内未完成,请核实信息!任务名称: "
+
task
.
getTitle
()
+
" 要求完成时间: "
+
DateUtil
.
getDateFormat
(
task
.
getFinishTime
(),
"yyyy-MM-dd HH:mm:ss"
)
+
" 发起人:"
+
task
.
getPublisherName
()
+
" 执行人:"
+
task
.
getExecutor
());
taskFeedback
.
setCreateDate
(
new
Date
());
taskFeedback
.
setUserName
(
task
.
getExecutor
());
taskFeedback
.
setFeedbackTime
(
new
Date
());
taskFeedback
.
setOrgCode
(
task
.
getOrgCode
());
taskFeedback
.
setTaskId
(
task
.
getId
());
taskFeedback
.
setMessageType
(
TaskStatusEnum
.
OVERTIME
.
getName
());
taskFeedback
=
taskFeedbackDao
.
save
(
taskFeedback
);
try
{
asyncTask
.
pushTaskDetailInfoTo3D
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
taskId
);
// 超时任务向3D推送
}
catch
(
InterruptedException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
}
}
else
{
messageService
.
pushTaskMessage
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
task
);
}
}
removeJob
(
jobName
);
}
}
@Override
...
...
@@ -407,13 +446,29 @@ public class JobService implements IJobService {
@Override
public
void
msgJobPerform
(
long
msgId
,
String
jobType
,
String
jobName
)
{
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(
"cluster"
.
equals
(
cluster
))
{
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_redisson_key"
))
{
redisUtils
.
set
(
jobName
+
"_redisson_key"
,
"1"
);
//增加标识
if
(
iMsgDao
.
existsById
(
msgId
))
{
Msg
msg
=
iMsgDao
.
findById
(
msgId
).
get
();
Toke
toke
=
remoteSecurityService
.
getServerToken
();
messageService
.
pushMsg
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
msg
);
}
removeJob
(
jobName
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
if
(!
redisUtils
.
hasKey
(
jobName
+
"_redisson_key"
))
{
redisUtils
.
set
(
jobName
+
"_redisson_key"
,
"1"
);
//增加标识
...
...
@@ -424,10 +479,6 @@ public class JobService implements IJobService {
}
removeJob
(
jobName
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-maintenance-biz/src/main/java/com/yeejoin/amos/maintenance/task/PlanTaskJob.java
View file @
13d1f3bc
...
...
@@ -4,6 +4,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import
com.yeejoin.amos.maintenance.business.service.intfc.IPlanTaskService
;
import
org.redisson.api.RLock
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -20,8 +21,11 @@ import java.util.concurrent.TimeUnit;
@EnableScheduling
public
class
PlanTaskJob
{
@Autowired
@Autowired
(
required
=
false
)
org
.
redisson
.
api
.
RedissonClient
redisson
;
@Value
(
"${spring.redis.mode}"
)
private
String
cluster
;
@Autowired
private
RedisUtils
redisUtils
;
...
...
@@ -34,7 +38,7 @@ public class PlanTaskJob {
@Scheduled
(
cron
=
"${jobs.cron}"
)
public
void
scheduleJob
()
{
if
(
"cluster"
.
equals
(
cluster
)){
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"maintenance-1"
+
time
;
...
...
@@ -55,7 +59,11 @@ public class PlanTaskJob {
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
planTaskService
.
taskExecution
(
null
);
}
}
...
...
@@ -65,28 +73,30 @@ public class PlanTaskJob {
*/
@Scheduled
(
cron
=
"${jobs.cron}"
)
public
void
taskMessage
()
{
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"maintenance-2"
+
time
;
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
System
.
out
.
println
(
"获取锁成功============"
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_redisson_key"
))
{
redisUtils
.
set
(
jobName
+
"_redisson_key"
,
"1"
);
//
planTaskService
.
taskMessage
(
null
);
if
(
"cluster"
.
equals
(
cluster
))
{
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"maintenance-2"
+
time
;
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
System
.
out
.
println
(
"获取锁成功============"
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_redisson_key"
))
{
redisUtils
.
set
(
jobName
+
"_redisson_key"
,
"1"
);
//
planTaskService
.
taskMessage
(
null
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
else
{
planTaskService
.
taskMessage
(
null
);
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/controller/PlanTaskController.java
View file @
13d1f3bc
...
...
@@ -30,6 +30,7 @@ import org.redisson.api.RLock;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.util.ObjectUtils
;
...
...
@@ -71,9 +72,12 @@ public class PlanTaskController extends AbstractBaseController {
/* @Autowired
private IUserService userService;*/
@Autowired
@Autowired
(
required
=
false
)
org
.
redisson
.
api
.
RedissonClient
redisson
;
@Value
(
"${spring.redis.mode}"
)
private
String
cluster
;
@Autowired
private
RedisUtils
redisUtils
;
...
...
@@ -418,7 +422,7 @@ public class PlanTaskController extends AbstractBaseController {
@RequestMapping
(
value
=
"/queryOmission"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
CommonResponse
pushCarData
()
{
if
(
"cluster"
.
equals
(
cluster
)){
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"pushCarData"
+
time
;
...
...
@@ -446,6 +450,11 @@ public class PlanTaskController extends AbstractBaseController {
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
RequestAttributes
reqs
=
RequestContextHolder
.
getRequestAttributes
();
RequestContextHolder
.
setRequestAttributes
(
reqs
,
true
);
planTaskService
.
taskExecution
(
null
);
}
return
CommonResponseUtil
.
success
();
}
...
...
@@ -454,26 +463,32 @@ public class PlanTaskController extends AbstractBaseController {
*/
@Scheduled
(
cron
=
"${jobs.cron}"
)
public
void
taskMessage
()
{
String
jobName
=
"taskMessage"
+
System
.
currentTimeMillis
();
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_taskMessage_key"
))
{
redisUtils
.
set
(
jobName
+
"_taskMessage_key"
,
"1"
);
//增加标识
RequestAttributes
reqs
=
RequestContextHolder
.
getRequestAttributes
();
RequestContextHolder
.
setRequestAttributes
(
reqs
,
true
);
planTaskService
.
taskMessage
(
null
);
if
(
"cluster"
.
equals
(
cluster
))
{
String
jobName
=
"taskMessage"
+
System
.
currentTimeMillis
();
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_taskMessage_key"
))
{
redisUtils
.
set
(
jobName
+
"_taskMessage_key"
,
"1"
);
//增加标识
RequestAttributes
reqs
=
RequestContextHolder
.
getRequestAttributes
();
RequestContextHolder
.
setRequestAttributes
(
reqs
,
true
);
planTaskService
.
taskMessage
(
null
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
else
{
RequestAttributes
reqs
=
RequestContextHolder
.
getRequestAttributes
();
RequestContextHolder
.
setRequestAttributes
(
reqs
,
true
);
planTaskService
.
taskMessage
(
null
);
}
}
/**
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/quartz/JobService.java
View file @
13d1f3bc
...
...
@@ -96,8 +96,11 @@ public class JobService implements IJobService {
@Autowired
JcsFeignClient
jcsFeignClient
;
@Autowired
@Autowired
(
required
=
false
)
org
.
redisson
.
api
.
RedissonClient
redisson
;
@Value
(
"${spring.redis.mode}"
)
private
String
cluster
;
@Autowired
private
RedisUtils
redisUtils
;
...
...
@@ -658,6 +661,8 @@ public class JobService implements IJobService {
@Override
@Transactional
public
void
taskJobPerform
(
long
taskId
,
String
jobType
,
String
jobName
)
{
if
(
"cluster"
.
equals
(
cluster
)){
// TODO Auto-generated method stub
//为了便于区分key,增加后缀_redisson
RLock
lock
=
redisson
.
getLock
(
jobName
);
...
...
@@ -707,6 +712,40 @@ public class JobService implements IJobService {
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
if
(
iTaskDao
.
existsById
(
taskId
))
{
Task
task
=
iTaskDao
.
findById
(
taskId
).
get
();
Toke
toke
=
remoteSecurityService
.
getServerToken
();
if
(
XJConstant
.
STATUS_MONITOR_END
.
equals
(
jobType
))
{
if
(
TaskStatusEnum
.
UNDERWAY
.
getValue
()
==
task
.
getStatus
())
{
task
.
setStatus
(
TaskStatusEnum
.
OVERTIME
.
getValue
());
iTaskDao
.
saveAndFlush
(
task
);
TaskFeedback
taskFeedback
=
new
TaskFeedback
();
taskFeedback
.
setUserId
(
task
.
getExecutorId
());
taskFeedback
.
setMessage
(
"该任务在规定时间内未完成,请核实信息!任务名称: "
+
task
.
getTitle
()
+
" 要求完成时间: "
+
DateUtil
.
getDateFormat
(
task
.
getFinishTime
(),
"yyyy-MM-dd HH:mm:ss"
)
+
" 发起人:"
+
task
.
getPublisherName
()
+
" 执行人:"
+
task
.
getExecutor
());
taskFeedback
.
setCreateDate
(
new
Date
());
taskFeedback
.
setUserName
(
task
.
getExecutor
());
taskFeedback
.
setFeedbackTime
(
new
Date
());
taskFeedback
.
setOrgCode
(
task
.
getOrgCode
());
taskFeedback
.
setTaskId
(
task
.
getId
());
taskFeedback
.
setMessageType
(
TaskStatusEnum
.
OVERTIME
.
getName
());
taskFeedback
=
taskFeedbackDao
.
save
(
taskFeedback
);
try
{
asyncTask
.
pushTaskDetailInfoTo3D
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
taskId
);
// 超时任务向3D推送
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
log
.
error
(
e
.
getMessage
(),
e
);
e
.
printStackTrace
();
}
}
}
else
{
messageService
.
pushTaskMessage
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
task
);
}
}
removeJob
(
jobName
);
}
}
...
...
@@ -765,38 +804,58 @@ public class JobService implements IJobService {
@Override
@Transactional
public
void
planTaskJobPerform
(
long
planTaskId
,
String
jobType
,
String
jobName
)
{
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
System
.
out
.
println
(
"获取锁成功============"
);
if
(!
redisUtils
.
hasKey
(
jobName
+
"_redisson_key"
)){
redisUtils
.
set
(
jobName
+
"_redisson_key"
,
"1"
);
//增加标识
if
(
iPlanTaskDao
.
existsById
(
planTaskId
))
{
PlanTask
planTask
=
iPlanTaskDao
.
findById
(
planTaskId
).
get
();
if
(
XJConstant
.
STATUS_MONITOR_START
.
equals
(
jobType
))
{
if
(
PlanTaskFinishStatusEnum
.
NOTSTARTED
.
getValue
()
==
planTask
.
getFinishStatus
())
{
planTask
.
setFinishStatus
(
PlanTaskFinishStatusEnum
.
UNDERWAY
.
getValue
());
iPlanTaskDao
.
save
(
planTask
);
}
}
else
if
(
XJConstant
.
STATUS_MONITOR_END
.
equals
(
jobType
))
{
if
(
PlanTaskFinishStatusEnum
.
UNDERWAY
.
getValue
()
==
planTask
.
getFinishStatus
())
{
updatePlanTaskStatus
(
planTask
,
PlanTaskFinishStatusEnum
.
OVERTIME
.
getValue
());
if
(
"cluster"
.
equals
(
cluster
))
{
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
System
.
out
.
println
(
"获取锁成功============"
);
if
(!
redisUtils
.
hasKey
(
jobName
+
"_redisson_key"
))
{
redisUtils
.
set
(
jobName
+
"_redisson_key"
,
"1"
);
//增加标识
if
(
iPlanTaskDao
.
existsById
(
planTaskId
))
{
PlanTask
planTask
=
iPlanTaskDao
.
findById
(
planTaskId
).
get
();
if
(
XJConstant
.
STATUS_MONITOR_START
.
equals
(
jobType
))
{
if
(
PlanTaskFinishStatusEnum
.
NOTSTARTED
.
getValue
()
==
planTask
.
getFinishStatus
())
{
planTask
.
setFinishStatus
(
PlanTaskFinishStatusEnum
.
UNDERWAY
.
getValue
());
iPlanTaskDao
.
save
(
planTask
);
}
}
else
if
(
XJConstant
.
STATUS_MONITOR_END
.
equals
(
jobType
))
{
if
(
PlanTaskFinishStatusEnum
.
UNDERWAY
.
getValue
()
==
planTask
.
getFinishStatus
())
{
updatePlanTaskStatus
(
planTask
,
PlanTaskFinishStatusEnum
.
OVERTIME
.
getValue
());
}
}
else
{
Toke
toke
=
remoteSecurityService
.
getServerToken
();
messageService
.
pushPlanTaskMessage
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
planTask
,
jobType
);
}
}
removeJob
(
jobName
);
}
}
else
{
Toke
toke
=
remoteSecurityService
.
getServerToken
();
messageService
.
pushPlanTaskMessage
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
planTask
,
jobType
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
removeJob
(
jobName
);
}
else
{
if
(
iPlanTaskDao
.
existsById
(
planTaskId
))
{
PlanTask
planTask
=
iPlanTaskDao
.
findById
(
planTaskId
).
get
();
if
(
XJConstant
.
STATUS_MONITOR_START
.
equals
(
jobType
))
{
if
(
PlanTaskFinishStatusEnum
.
NOTSTARTED
.
getValue
()
==
planTask
.
getFinishStatus
())
{
planTask
.
setFinishStatus
(
PlanTaskFinishStatusEnum
.
UNDERWAY
.
getValue
());
iPlanTaskDao
.
save
(
planTask
);
}
}
else
if
(
XJConstant
.
STATUS_MONITOR_END
.
equals
(
jobType
))
{
if
(
PlanTaskFinishStatusEnum
.
UNDERWAY
.
getValue
()
==
planTask
.
getFinishStatus
())
{
updatePlanTaskStatus
(
planTask
,
PlanTaskFinishStatusEnum
.
OVERTIME
.
getValue
());
}
}
else
{
Toke
toke
=
remoteSecurityService
.
getServerToken
();
messageService
.
pushPlanTaskMessage
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
planTask
,
jobType
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
removeJob
(
jobName
);
}
}
@Override
...
...
@@ -806,27 +865,35 @@ public class JobService implements IJobService {
@Override
public
void
msgJobPerform
(
long
msgId
,
String
jobType
,
String
jobName
)
{
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_redisson_key"
)){
redisUtils
.
set
(
jobName
+
"_redisson_key"
,
"1"
);
//增加标识
if
(
iMsgDao
.
existsById
(
msgId
))
{
Msg
msg
=
iMsgDao
.
findById
(
msgId
).
get
();
Toke
toke
=
remoteSecurityService
.
getServerToken
();
messageService
.
pushMsgAndSave
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
msg
);
}
removeJob
(
jobName
);
if
(
"cluster"
.
equals
(
cluster
))
{
RLock
lock
=
redisson
.
getLock
(
jobName
);
try
{
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
);
//为了防止重复
if
(!
redisUtils
.
hasKey
(
jobName
+
"_redisson_key"
))
{
redisUtils
.
set
(
jobName
+
"_redisson_key"
,
"1"
);
//增加标识
if
(
iMsgDao
.
existsById
(
msgId
))
{
Msg
msg
=
iMsgDao
.
findById
(
msgId
).
get
();
Toke
toke
=
remoteSecurityService
.
getServerToken
();
messageService
.
pushMsgAndSave
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
msg
);
}
removeJob
(
jobName
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
lock
.
unlock
();
//释放锁
}
else
{
if
(
iMsgDao
.
existsById
(
msgId
))
{
Msg
msg
=
iMsgDao
.
findById
(
msgId
).
get
();
Toke
toke
=
remoteSecurityService
.
getServerToken
();
messageService
.
pushMsgAndSave
(
toke
.
getToke
(),
toke
.
getProduct
(),
toke
.
getAppKey
(),
msg
);
}
removeJob
(
jobName
);
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/schedule/LatentDanerScheduled.java
View file @
13d1f3bc
...
...
@@ -3,6 +3,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import
com.yeejoin.amos.patrol.business.service.intfc.ILatentDangerService
;
import
org.redisson.api.RLock
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
...
...
@@ -21,9 +22,12 @@ public class LatentDanerScheduled {
@Autowired
private
ILatentDangerService
iLatentDangerService
;
@Autowired
@Autowired
(
required
=
false
)
org
.
redisson
.
api
.
RedissonClient
redisson
;
@Value
(
"${spring.redis.mode}"
)
private
String
cluster
;
@Autowired
private
RedisUtils
redisUtils
;
...
...
@@ -34,6 +38,7 @@ public class LatentDanerScheduled {
@Scheduled
(
cron
=
"0 0/1 * * * ?"
)
public
void
updateDangerStateOfOvertime
()
{
if
(
"cluster"
.
equals
(
cluster
)){
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"updateDangerStateOfOvertime"
+
time
;
...
...
@@ -55,7 +60,9 @@ public class LatentDanerScheduled {
}
finally
{
lock
.
unlock
();
//释放锁
}
}
else
{
iLatentDangerService
.
updateDangerStateOfOvertime
();
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-supervision-biz/src/main/java/com/yeejoin/amos/supervision/quartz/JobService.java
View file @
13d1f3bc
This diff is collapsed.
Click to expand it.
amos-boot-module/amos-boot-module-biz/amos-boot-module-supervision-biz/src/main/java/com/yeejoin/amos/supervision/task/PlanTaskJob.java
View file @
13d1f3bc
...
...
@@ -4,6 +4,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import
com.yeejoin.amos.supervision.business.service.intfc.IPlanTaskService
;
import
org.redisson.api.RLock
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -20,8 +21,11 @@ import java.util.concurrent.TimeUnit;
@EnableScheduling
public
class
PlanTaskJob
{
@Autowired
@Autowired
(
required
=
false
)
org
.
redisson
.
api
.
RedissonClient
redisson
;
@Value
(
"${spring.redis.mode}"
)
private
String
cluster
;
@Autowired
private
RedisUtils
redisUtils
;
...
...
@@ -34,7 +38,7 @@ public class PlanTaskJob {
@Scheduled
(
cron
=
"${jobs.cron}"
)
public
void
scheduleJob
()
{
if
(
"cluster"
.
equals
(
cluster
)){
DateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
String
time
=
format
.
format
(
new
Date
());
String
jobName
=
"supervision-1"
+
time
;
...
...
@@ -56,5 +60,8 @@ public class PlanTaskJob {
lock
.
unlock
();
//释放锁
}
}
else
{
planTaskService
.
taskExecution
(
null
);
}
}
}
amos-boot-system-equip/src/main/resources/application-single.properties
View file @
13d1f3bc
...
...
@@ -186,12 +186,11 @@ spring.redis.database=1
spring.redis.timeout
=
10000
spring.redis.password
=
yeejoin@2020
spring.redis.expire.time
=
300
#单机集群判断 cluster
集群 single单机
#单机集群判断 cluster
spring.redis.mode
=
single
#redis 单机配置
spring.redis.host
=
172.16.10.211
spring.redis.port
=
6379
spring.redis.redissonUrl
=
172.16.10.211:6379
...
...
amos-boot-system-jcs/src/main/resources/application-single.properties
View file @
13d1f3bc
...
...
@@ -175,7 +175,6 @@ spring.redis.mode=single
#redis 单机配置
spring.redis.host
=
172.16.11.20
spring.redis.port
=
6379
spring.redis.redissonUrl
=
172.16.11.20:6379
spring.data.elasticsearch.repositories.enabled
=
true
...
...
amos-boot-system-knowledgebase/src/main/resources/application-single.properties
View file @
13d1f3bc
...
...
@@ -81,7 +81,6 @@ spring.redis.mode=single
#redis 单机配置
spring.redis.host
=
172.16.11.20
spring.redis.port
=
6379
spring.redis.redissonUrl
=
172.16.11.20:6379
#注册中心地址
eureka.client.service-url.defaultZone
=
http://172.16.10.72:10001/eureka/
...
...
amos-boot-system-latentdanger/src/main/resources/application-single.properties
View file @
13d1f3bc
...
...
@@ -146,7 +146,6 @@ spring.redis.mode=single
#redis 单机配置
spring.redis.host
=
172.16.11.20
spring.redis.port
=
6379
spring.redis.redissonUrl
=
172.16.11.20:6379
...
...
amos-boot-system-maintenance/src/main/resources/application-single.properties
View file @
13d1f3bc
...
...
@@ -124,7 +124,6 @@ spring.redis.mode=single
#redis 单机配置
spring.redis.host
=
172.16.11.20
spring.redis.port
=
6379
spring.redis.redissonUrl
=
172.16.11.20:6379
...
...
amos-boot-system-patrol/src/main/resources/application-single.properties
View file @
13d1f3bc
...
...
@@ -151,7 +151,6 @@ spring.redis.mode=single
#redis 单机配置
spring.redis.host
=
172.16.11.20
spring.redis.port
=
6379
spring.redis.redissonUrl
=
172.16.11.20:6379
...
...
amos-boot-system-supervision/src/main/resources/application-single.properties
View file @
13d1f3bc
...
...
@@ -129,7 +129,6 @@ spring.redis.mode=single
#redis 单机配置
spring.redis.host
=
172.16.10.211
spring.redis.port
=
6379
spring.redis.redissonUrl
=
172.16.10.211:6379
...
...
amos-boot-utils/amos-boot-utils-video/src/main/resources/application-single.properties
View file @
13d1f3bc
...
...
@@ -85,7 +85,6 @@ spring.redis.jedis.pool.min-idle=1
#redis 单机配置
spring.redis.host
=
172.16.11.20
spring.redis.port
=
6379
spring.redis.redissonUrl
=
172.16.11.20:6379
spring.data.elasticsearch.repositories.enabled
=
true
...
...
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