Commit 13d1f3bc authored by tangwei's avatar tangwei

单体模式下,不初始化锁

parent 75904892
...@@ -39,7 +39,6 @@ public class RedissonConfig { ...@@ -39,7 +39,6 @@ public class RedissonConfig {
} }
Config config = new Config(); Config config = new Config();
ClusterServersConfig clusterServersConfig = config.useClusterServers() ClusterServersConfig clusterServersConfig = config.useClusterServers()
.setScanInterval(2000) // 集群状态扫描间隔时间,单位是毫秒 .setScanInterval(2000) // 集群状态扫描间隔时间,单位是毫秒
.addNodeAddress(clusterNodes.toArray(new String[clusterNodes.size()])); .addNodeAddress(clusterNodes.toArray(new String[clusterNodes.size()]));
...@@ -56,19 +55,19 @@ public class RedissonConfig { ...@@ -56,19 +55,19 @@ public class RedissonConfig {
* 单机模式 redisson 客户端 * 单机模式 redisson 客户端
*/ */
@Bean // @Bean
@ConditionalOnProperty(name = "spring.redis.mode", havingValue = "single") // @ConditionalOnProperty(name = "spring.redis.mode", havingValue = "single")
RedissonClient redissonSingle() { // RedissonClient redissonSingle() {
Config config = new Config(); // Config config = new Config();
String node = redisConfigProperties.getRedissonUrl(); // String node = redisConfigProperties.getRedissonUrl();
node = node.startsWith("redis://") ? node : "redis://" + node; // node = node.startsWith("redis://") ? node : "redis://" + node;
SingleServerConfig serverConfig = config.useSingleServer() // SingleServerConfig serverConfig = config.useSingleServer()
.setAddress(node); // .setAddress(node);
if (StringUtils.isNotBlank(redisConfigProperties.getPassword())) { // if (StringUtils.isNotBlank(redisConfigProperties.getPassword())) {
serverConfig.setPassword(redisConfigProperties.getPassword()); // serverConfig.setPassword(redisConfigProperties.getPassword());
} // }
return Redisson.create(config); // return Redisson.create(config);
} // }
} }
\ No newline at end of file
...@@ -6,6 +6,7 @@ import com.yeejoin.equipmanage.common.utils.DateUtils; ...@@ -6,6 +6,7 @@ import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.service.IAnalysisReportLogService; import com.yeejoin.equipmanage.service.IAnalysisReportLogService;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired; 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.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -25,43 +26,61 @@ public class AnalysisReportSchedulerJob { ...@@ -25,43 +26,61 @@ public class AnalysisReportSchedulerJob {
@Autowired @Autowired
private IAnalysisReportLogService iAnalysisReportLogService; private IAnalysisReportLogService iAnalysisReportLogService;
@Autowired @Autowired(required = false)
org.redisson.api.RedissonClient redisson; org.redisson.api.RedissonClient redisson;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Value("${spring.redis.mode}")
private String cluster;
/** /**
* 每天凌晨0点-日报生成 * 每天凌晨0点-日报生成
*/ */
@Scheduled(cron = "0 0 0 * * ?") @Scheduled(cron = "0 0 0 * * ?")
public void dayReport() throws ParseException { 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 beginDate = DateUtils.dateAdd(new Date(), -1, false);
Date endDate = DateUtils.dateAdd(new Date(), -1, false); Date endDate = DateUtils.dateAdd(new Date(), -1, false);
iAnalysisReportLogService.generateReport(AnalysisReportEnum.DAY_REPORT, beginDate, endDate); 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 { ...@@ -69,30 +88,40 @@ public class AnalysisReportSchedulerJob {
*/ */
@Scheduled(cron = "0 0 0 ? * 1") @Scheduled(cron = "0 0 0 ? * 1")
public void weekReport() throws ParseException { public void weekReport() throws ParseException {
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time=format.format(new Date()); if(cluster.equals("cluster")) {
String jobName = "weekReport" + time;
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
//为了便于区分key,增加后缀_redisson String time = format.format(new Date());
RLock lock = redisson.getLock(jobName); String jobName = "weekReport" + time;
try {
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock.tryLock(10, TimeUnit.SECONDS); //为了便于区分key,增加后缀_redisson
//为了防止重复 RLock lock = redisson.getLock(jobName);
if (!redisUtils.hasKey(jobName + "_weekReport_key")) { try {
redisUtils.set(jobName + "_weekReport_key", "1");//增加标识 //拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
Date yestDay = DateUtils.dateAdd(new Date(), -1, false); lock.tryLock(10, TimeUnit.SECONDS);
Date beginDate = DateUtils.getFirstDayOfWeek(yestDay); //为了防止重复
Date endDate = DateUtils.getLastDayOfWeek(yestDay); if (!redisUtils.hasKey(jobName + "_weekReport_key")) {
iAnalysisReportLogService.generateReport(AnalysisReportEnum.WEEK_REPORT, beginDate, endDate); 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) { }else{
e.printStackTrace(); Date yestDay = DateUtils.dateAdd(new Date(), -1, false);
} finally { Date beginDate = DateUtils.getFirstDayOfWeek(yestDay);
lock.unlock(); //释放锁 Date endDate = DateUtils.getLastDayOfWeek(yestDay);
} iAnalysisReportLogService.generateReport(AnalysisReportEnum.WEEK_REPORT, beginDate, endDate);
}
} }
/** /**
...@@ -100,28 +129,35 @@ public class AnalysisReportSchedulerJob { ...@@ -100,28 +129,35 @@ public class AnalysisReportSchedulerJob {
*/ */
@Scheduled(cron="0 0 0 1 * ?") @Scheduled(cron="0 0 0 1 * ?")
public void monthReport() throws ParseException { public void monthReport() throws ParseException {
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); if(cluster.equals("cluster")) {
String time=format.format(new Date()); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String jobName = "monthReport" + time; String time = format.format(new Date());
String jobName = "monthReport" + time;
//为了便于区分key,增加后缀_redisson
RLock lock = redisson.getLock(jobName); //为了便于区分key,增加后缀_redisson
try { RLock lock = redisson.getLock(jobName);
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30 try {
lock.tryLock(10, TimeUnit.SECONDS); //拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
//为了防止重复 lock.tryLock(10, TimeUnit.SECONDS);
if (!redisUtils.hasKey(jobName + "_monthReport_key")) { //为了防止重复
redisUtils.set(jobName + "_monthReport_key", "1");//增加标识 if (!redisUtils.hasKey(jobName + "_monthReport_key")) {
Date yestDay = DateUtils.dateAdd(new Date(), -1, false); redisUtils.set(jobName + "_monthReport_key", "1");//增加标识
Date beginDate = DateUtils.getFirstDayOfMonth(yestDay); Date yestDay = DateUtils.dateAdd(new Date(), -1, false);
Date endDate = DateUtils.getLastDayOfMonth(yestDay); Date beginDate = DateUtils.getFirstDayOfMonth(yestDay);
iAnalysisReportLogService.generateMonthReport(AnalysisReportEnum.MONTH_REPORT, beginDate, endDate); Date endDate = DateUtils.getLastDayOfMonth(yestDay);
iAnalysisReportLogService.generateMonthReport(AnalysisReportEnum.MONTH_REPORT, beginDate, endDate);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
lock.unlock(); //释放锁
} }
} catch (Exception e) { }else{
e.printStackTrace(); Date yestDay = DateUtils.dateAdd(new Date(), -1, false);
} finally { Date beginDate = DateUtils.getFirstDayOfMonth(yestDay);
lock.unlock(); //释放锁 Date endDate = DateUtils.getLastDayOfMonth(yestDay);
} iAnalysisReportLogService.generateMonthReport(AnalysisReportEnum.MONTH_REPORT, beginDate, endDate);
}
} }
} }
...@@ -13,6 +13,7 @@ import java.util.List; ...@@ -13,6 +13,7 @@ import java.util.List;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -49,8 +50,11 @@ public class View3dController extends AbstractBaseController { ...@@ -49,8 +50,11 @@ public class View3dController extends AbstractBaseController {
private IRiskSourceService riskSourceService; private IRiskSourceService riskSourceService;
@Autowired @Autowired
private IView3dService view3dService; private IView3dService view3dService;
@Autowired
@Autowired(required = false)
org.redisson.api.RedissonClient redisson; org.redisson.api.RedissonClient redisson;
@Value("${spring.redis.mode}")
private String cluster;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
...@@ -228,7 +232,7 @@ public class View3dController extends AbstractBaseController { ...@@ -228,7 +232,7 @@ public class View3dController extends AbstractBaseController {
@Scheduled(cron = "${param.safetyIndexChange.cron}") @Scheduled(cron = "${param.safetyIndexChange.cron}")
public CommonResponse safetyIndexLog(){ public CommonResponse safetyIndexLog(){
if("cluster".equals(cluster)){
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time=format.format(new Date()); String time=format.format(new Date());
String jobName = "fas-2" + time; String jobName = "fas-2" + time;
...@@ -252,6 +256,12 @@ public class View3dController extends AbstractBaseController { ...@@ -252,6 +256,12 @@ public class View3dController extends AbstractBaseController {
} finally { } finally {
lock.unlock(); //释放锁 lock.unlock(); //释放锁
} }
}else{
view3dService.safetyIndexLogGenJob(null);
}
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
......
...@@ -12,6 +12,7 @@ import org.redisson.api.RedissonClient; ...@@ -12,6 +12,7 @@ import org.redisson.api.RedissonClient;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -25,15 +26,17 @@ public class FireScheduled { ...@@ -25,15 +26,17 @@ public class FireScheduled {
@Autowired @Autowired
IContingencyInstance iContingencyInstance; IContingencyInstance iContingencyInstance;
@Autowired @Autowired(required = false)
RedissonClient redisson; RedissonClient redisson;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Value("${spring.redis.mode}")
private String cluster;
@Scheduled(cron = "*/2 * * * * ?") @Scheduled(cron = "*/2 * * * * ?")
public void runFireQueue() throws Exception { public void runFireQueue() throws Exception {
if("cluster".equals(cluster)){
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time=format.format(new Date()); String time=format.format(new Date());
...@@ -80,6 +83,31 @@ public class FireScheduled { ...@@ -80,6 +83,31 @@ public class FireScheduled {
lock.unlock(); //释放锁 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() { public static LinkedList<Map<String, String>> getFireQueue() {
return fireQueue; return fireQueue;
......
...@@ -6,6 +6,7 @@ import com.yeejoin.amos.knowledgebase.face.service.DocAuditService; ...@@ -6,6 +6,7 @@ import com.yeejoin.amos.knowledgebase.face.service.DocAuditService;
import com.yeejoin.amos.knowledgebase.face.service.InteractionCountService; import com.yeejoin.amos.knowledgebase.face.service.InteractionCountService;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -37,8 +38,12 @@ public class QuoteCountFlushTiming { ...@@ -37,8 +38,12 @@ public class QuoteCountFlushTiming {
@Autowired @Autowired
private ConfigLoader configLoader; private ConfigLoader configLoader;
@Autowired @Autowired(required = false)
org.redisson.api.RedissonClient redisson; org.redisson.api.RedissonClient redisson;
@Value("${spring.redis.mode}")
private String cluster;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
...@@ -55,6 +60,7 @@ public class QuoteCountFlushTiming { ...@@ -55,6 +60,7 @@ public class QuoteCountFlushTiming {
@Transactional(rollbackFor = {Exception.class, BaseException.class}) @Transactional(rollbackFor = {Exception.class, BaseException.class})
public void flushTagQuoteCount() { public void flushTagQuoteCount() {
if("cluster".equals(cluster)){
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time=format.format(new Date()); String time=format.format(new Date());
String jobName = "knowledgeBase-1" +time; String jobName = "knowledgeBase-1" +time;
...@@ -85,40 +91,57 @@ public class QuoteCountFlushTiming { ...@@ -85,40 +91,57 @@ public class QuoteCountFlushTiming {
} finally { } finally {
lock.unlock(); //释放锁 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) @Scheduled(fixedRate = 3 * 1000)
@Transactional(rollbackFor = {Exception.class, BaseException.class}) @Transactional(rollbackFor = {Exception.class, BaseException.class})
public void pushDocs2Rule() { public void pushDocs2Rule() {
if("cluster".equals(cluster)) {
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time=format.format(new Date()); String time = format.format(new Date());
String jobName = "knowledgeBase-2" + time; String jobName = "knowledgeBase-2" + time;
RLock lock = redisson.getLock(jobName); RLock lock = redisson.getLock(jobName);
try { try {
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30 //拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock.tryLock(10, TimeUnit.SECONDS); lock.tryLock(10, TimeUnit.SECONDS);
System.out.println("获取锁成功============"); System.out.println("获取锁成功============");
//为了防止重复 //为了防止重复
if (!redisUtils.hasKey(jobName + "_redisson_key")) { if (!redisUtils.hasKey(jobName + "_redisson_key")) {
redisUtils.set(jobName + "_redisson_key", "1");// redisUtils.set(jobName + "_redisson_key", "1");//
if (needPush2Rule.get()) { if (needPush2Rule.get()) {
needPush2Rule.set(false); needPush2Rule.set(false);
docAuditService.pushDocs2RuleByMQ(); docAuditService.pushDocs2RuleByMQ();
System.out.println("定时-同步规则-完成"); 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(); //释放锁
} }
} }
} }
...@@ -77,8 +77,13 @@ public class JobService implements IJobService { ...@@ -77,8 +77,13 @@ public class JobService implements IJobService {
private String patrolTopic; private String patrolTopic;
@Autowired @Autowired(required = false)
org.redisson.api.RedissonClient redisson; org.redisson.api.RedissonClient redisson;
@Value("${spring.redis.mode}")
private String cluster;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
...@@ -304,6 +309,9 @@ public class JobService implements IJobService { ...@@ -304,6 +309,9 @@ public class JobService implements IJobService {
@Transactional @Transactional
public void taskJobPerform(long taskId, String jobType, String jobName) { public void taskJobPerform(long taskId, String jobType, String jobName) {
if("cluster".equals(cluster)){
//为了便于区分key,增加后缀_redisson //为了便于区分key,增加后缀_redisson
RLock lock = redisson.getLock(jobName); RLock lock = redisson.getLock(jobName);
try { try {
...@@ -349,7 +357,38 @@ public class JobService implements IJobService { ...@@ -349,7 +357,38 @@ public class JobService implements IJobService {
} finally { } finally {
lock.unlock(); //释放锁 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 @Override
...@@ -407,13 +446,29 @@ public class JobService implements IJobService { ...@@ -407,13 +446,29 @@ public class JobService implements IJobService {
@Override @Override
public void msgJobPerform(long msgId, String jobType, String jobName) { public void msgJobPerform(long msgId, String jobType, String jobName) {
if("cluster".equals(cluster)) {
//为了便于区分key,增加后缀_redisson //为了便于区分key,增加后缀_redisson
RLock lock = redisson.getLock(jobName); RLock lock = redisson.getLock(jobName);
try { try {
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30 //拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock.tryLock(10, TimeUnit.SECONDS); 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")) { if (!redisUtils.hasKey(jobName + "_redisson_key")) {
redisUtils.set(jobName + "_redisson_key", "1");//增加标识 redisUtils.set(jobName + "_redisson_key", "1");//增加标识
...@@ -424,10 +479,6 @@ public class JobService implements IJobService { ...@@ -424,10 +479,6 @@ public class JobService implements IJobService {
} }
removeJob(jobName); removeJob(jobName);
} }
} catch (Exception e) {
e.printStackTrace();
} finally {
lock.unlock(); //释放锁
} }
} }
} }
...@@ -4,6 +4,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; ...@@ -4,6 +4,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.maintenance.business.service.intfc.IPlanTaskService; import com.yeejoin.amos.maintenance.business.service.intfc.IPlanTaskService;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired; 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.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -20,8 +21,11 @@ import java.util.concurrent.TimeUnit; ...@@ -20,8 +21,11 @@ import java.util.concurrent.TimeUnit;
@EnableScheduling @EnableScheduling
public class PlanTaskJob { public class PlanTaskJob {
@Autowired @Autowired(required = false)
org.redisson.api.RedissonClient redisson; org.redisson.api.RedissonClient redisson;
@Value("${spring.redis.mode}")
private String cluster;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
...@@ -34,7 +38,7 @@ public class PlanTaskJob { ...@@ -34,7 +38,7 @@ public class PlanTaskJob {
@Scheduled(cron = "${jobs.cron}") @Scheduled(cron = "${jobs.cron}")
public void scheduleJob() { public void scheduleJob() {
if("cluster".equals(cluster)){
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time=format.format(new Date()); String time=format.format(new Date());
String jobName = "maintenance-1" + time; String jobName = "maintenance-1" + time;
...@@ -55,7 +59,11 @@ public class PlanTaskJob { ...@@ -55,7 +59,11 @@ public class PlanTaskJob {
} finally { } finally {
lock.unlock(); //释放锁 lock.unlock(); //释放锁
} }
}else{
planTaskService.taskExecution(null);
}
} }
...@@ -65,28 +73,30 @@ public class PlanTaskJob { ...@@ -65,28 +73,30 @@ public class PlanTaskJob {
*/ */
@Scheduled(cron = "${jobs.cron}") @Scheduled(cron = "${jobs.cron}")
public void taskMessage() { public void taskMessage() {
if("cluster".equals(cluster)) {
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time=format.format(new Date()); String time = format.format(new Date());
String jobName = "maintenance-2" + time; String jobName = "maintenance-2" + time;
RLock lock = redisson.getLock(jobName); RLock lock = redisson.getLock(jobName);
try { try {
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30 //拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
lock.tryLock(10, TimeUnit.SECONDS); lock.tryLock(10, TimeUnit.SECONDS);
System.out.println("获取锁成功============"); System.out.println("获取锁成功============");
//为了防止重复 //为了防止重复
if (!redisUtils.hasKey(jobName + "_redisson_key")) { if (!redisUtils.hasKey(jobName + "_redisson_key")) {
redisUtils.set(jobName + "_redisson_key", "1");// redisUtils.set(jobName + "_redisson_key", "1");//
planTaskService.taskMessage(null); planTaskService.taskMessage(null);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
lock.unlock(); //释放锁
} }
} catch (Exception e) { }else{
e.printStackTrace(); planTaskService.taskMessage(null);
} finally {
lock.unlock(); //释放锁
} }
} }
} }
...@@ -30,6 +30,7 @@ import org.redisson.api.RLock; ...@@ -30,6 +30,7 @@ import org.redisson.api.RLock;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -71,9 +72,12 @@ public class PlanTaskController extends AbstractBaseController { ...@@ -71,9 +72,12 @@ public class PlanTaskController extends AbstractBaseController {
/* @Autowired /* @Autowired
private IUserService userService;*/ private IUserService userService;*/
@Autowired @Autowired(required = false)
org.redisson.api.RedissonClient redisson; org.redisson.api.RedissonClient redisson;
@Value("${spring.redis.mode}")
private String cluster;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
...@@ -418,7 +422,7 @@ public class PlanTaskController extends AbstractBaseController { ...@@ -418,7 +422,7 @@ public class PlanTaskController extends AbstractBaseController {
@RequestMapping(value = "/queryOmission", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @RequestMapping(value = "/queryOmission", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public CommonResponse pushCarData() { public CommonResponse pushCarData() {
if("cluster".equals(cluster)){
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time=format.format(new Date()); String time=format.format(new Date());
String jobName = "pushCarData" +time; String jobName = "pushCarData" +time;
...@@ -446,6 +450,11 @@ public class PlanTaskController extends AbstractBaseController { ...@@ -446,6 +450,11 @@ public class PlanTaskController extends AbstractBaseController {
}finally { }finally {
lock.unlock(); //释放锁 lock.unlock(); //释放锁
} }
}else{
RequestAttributes reqs = RequestContextHolder.getRequestAttributes();
RequestContextHolder.setRequestAttributes(reqs, true);
planTaskService.taskExecution(null);
}
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
...@@ -454,26 +463,32 @@ public class PlanTaskController extends AbstractBaseController { ...@@ -454,26 +463,32 @@ public class PlanTaskController extends AbstractBaseController {
*/ */
@Scheduled(cron = "${jobs.cron}") @Scheduled(cron = "${jobs.cron}")
public void taskMessage() { public void taskMessage() {
String jobName = "taskMessage" + System.currentTimeMillis();
//为了便于区分key,增加后缀_redisson if("cluster".equals(cluster)) {
RLock lock = redisson.getLock(jobName); String jobName = "taskMessage" + System.currentTimeMillis();
try { //为了便于区分key,增加后缀_redisson
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30 RLock lock = redisson.getLock(jobName);
lock.tryLock(10, TimeUnit.SECONDS); try {
//为了防止重复 //拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
if (!redisUtils.hasKey(jobName + "_taskMessage_key")) { lock.tryLock(10, TimeUnit.SECONDS);
redisUtils.set(jobName + "_taskMessage_key", "1");//增加标识 //为了防止重复
RequestAttributes reqs = RequestContextHolder.getRequestAttributes(); if (!redisUtils.hasKey(jobName + "_taskMessage_key")) {
RequestContextHolder.setRequestAttributes(reqs, true); redisUtils.set(jobName + "_taskMessage_key", "1");//增加标识
planTaskService.taskMessage(null); RequestAttributes reqs = RequestContextHolder.getRequestAttributes();
RequestContextHolder.setRequestAttributes(reqs, true);
planTaskService.taskMessage(null);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
lock.unlock(); //释放锁
} }
} catch (Exception e) { }else{
e.printStackTrace(); RequestAttributes reqs = RequestContextHolder.getRequestAttributes();
} finally { RequestContextHolder.setRequestAttributes(reqs, true);
lock.unlock(); //释放锁 planTaskService.taskMessage(null);
} }
} }
/** /**
......
...@@ -96,8 +96,11 @@ public class JobService implements IJobService { ...@@ -96,8 +96,11 @@ public class JobService implements IJobService {
@Autowired @Autowired
JcsFeignClient jcsFeignClient; JcsFeignClient jcsFeignClient;
@Autowired @Autowired(required = false)
org.redisson.api.RedissonClient redisson; org.redisson.api.RedissonClient redisson;
@Value("${spring.redis.mode}")
private String cluster;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
...@@ -658,6 +661,8 @@ public class JobService implements IJobService { ...@@ -658,6 +661,8 @@ public class JobService implements IJobService {
@Override @Override
@Transactional @Transactional
public void taskJobPerform(long taskId, String jobType, String jobName) { public void taskJobPerform(long taskId, String jobType, String jobName) {
if("cluster".equals(cluster)){
// TODO Auto-generated method stub // TODO Auto-generated method stub
//为了便于区分key,增加后缀_redisson //为了便于区分key,增加后缀_redisson
RLock lock = redisson.getLock(jobName); RLock lock = redisson.getLock(jobName);
...@@ -707,6 +712,40 @@ public class JobService implements IJobService { ...@@ -707,6 +712,40 @@ public class JobService implements IJobService {
} finally { } finally {
lock.unlock(); //释放锁 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 { ...@@ -765,38 +804,58 @@ public class JobService implements IJobService {
@Override @Override
@Transactional @Transactional
public void planTaskJobPerform(long planTaskId, String jobType, String jobName) { 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)) { if("cluster".equals(cluster)) {
PlanTask planTask = iPlanTaskDao.findById(planTaskId).get(); RLock lock = redisson.getLock(jobName);
if (XJConstant.STATUS_MONITOR_START.equals(jobType)) { try {
if (PlanTaskFinishStatusEnum.NOTSTARTED.getValue() == planTask.getFinishStatus()) { //拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
planTask.setFinishStatus(PlanTaskFinishStatusEnum.UNDERWAY.getValue()); lock.tryLock(10, TimeUnit.SECONDS);
iPlanTaskDao.save(planTask); System.out.println("获取锁成功============");
} if (!redisUtils.hasKey(jobName + "_redisson_key")) {
} else if (XJConstant.STATUS_MONITOR_END.equals(jobType)) { redisUtils.set(jobName + "_redisson_key", "1");//增加标识
if (PlanTaskFinishStatusEnum.UNDERWAY.getValue() == planTask.getFinishStatus()) {
updatePlanTaskStatus(planTask, PlanTaskFinishStatusEnum.OVERTIME.getValue()); 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 { } catch (Exception e) {
Toke toke= remoteSecurityService.getServerToken(); e.printStackTrace();
messageService.pushPlanTaskMessage(toke.getToke(), toke.getProduct(), toke.getAppKey(),planTask, jobType); } finally {
lock.unlock(); //释放锁
} }
} }else{
removeJob(jobName); 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) { removeJob(jobName);
e.printStackTrace();
} finally {
lock.unlock(); //释放锁
} }
} }
@Override @Override
...@@ -806,27 +865,35 @@ public class JobService implements IJobService { ...@@ -806,27 +865,35 @@ public class JobService implements IJobService {
@Override @Override
public void msgJobPerform(long msgId, String jobType, String jobName) { public void msgJobPerform(long msgId, String jobType, String jobName) {
RLock lock = redisson.getLock(jobName); if("cluster".equals(cluster)) {
try { RLock lock = redisson.getLock(jobName);
//拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30 try {
lock.tryLock(10, TimeUnit.SECONDS); //拿锁失败10停止尝试, 任务执行超时默认续30s 每个10秒续到30
//为了防止重复 lock.tryLock(10, TimeUnit.SECONDS);
if(!redisUtils.hasKey(jobName+"_redisson_key")){ //为了防止重复
redisUtils.set(jobName+"_redisson_key","1");//增加标识 if (!redisUtils.hasKey(jobName + "_redisson_key")) {
redisUtils.set(jobName + "_redisson_key", "1");//增加标识
if (iMsgDao.existsById(msgId)) {
Msg msg = iMsgDao.findById(msgId).get(); if (iMsgDao.existsById(msgId)) {
Toke toke= remoteSecurityService.getServerToken(); Msg msg = iMsgDao.findById(msgId).get();
messageService.pushMsgAndSave(toke.getToke(), toke.getProduct(), toke.getAppKey(),msg); Toke toke = remoteSecurityService.getServerToken();
} messageService.pushMsgAndSave(toke.getToke(), toke.getProduct(), toke.getAppKey(), msg);
removeJob(jobName); }
removeJob(jobName);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
lock.unlock(); //释放锁
} }
} catch (Exception e) { }else{
e.printStackTrace(); if (iMsgDao.existsById(msgId)) {
} finally { Msg msg = iMsgDao.findById(msgId).get();
lock.unlock(); //释放锁 Toke toke = remoteSecurityService.getServerToken();
messageService.pushMsgAndSave(toke.getToke(), toke.getProduct(), toke.getAppKey(), msg);
}
removeJob(jobName);
} }
} }
} }
...@@ -3,6 +3,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; ...@@ -3,6 +3,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.patrol.business.service.intfc.ILatentDangerService; import com.yeejoin.amos.patrol.business.service.intfc.ILatentDangerService;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
...@@ -21,9 +22,12 @@ public class LatentDanerScheduled { ...@@ -21,9 +22,12 @@ public class LatentDanerScheduled {
@Autowired @Autowired
private ILatentDangerService iLatentDangerService; private ILatentDangerService iLatentDangerService;
@Autowired @Autowired(required = false)
org.redisson.api.RedissonClient redisson; org.redisson.api.RedissonClient redisson;
@Value("${spring.redis.mode}")
private String cluster;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
...@@ -34,6 +38,7 @@ public class LatentDanerScheduled { ...@@ -34,6 +38,7 @@ public class LatentDanerScheduled {
@Scheduled(cron = "0 0/1 * * * ?") @Scheduled(cron = "0 0/1 * * * ?")
public void updateDangerStateOfOvertime() { public void updateDangerStateOfOvertime() {
if("cluster".equals(cluster)){
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time=format.format(new Date()); String time=format.format(new Date());
String jobName = "updateDangerStateOfOvertime" +time; String jobName = "updateDangerStateOfOvertime" +time;
...@@ -55,7 +60,9 @@ public class LatentDanerScheduled { ...@@ -55,7 +60,9 @@ public class LatentDanerScheduled {
} finally { } finally {
lock.unlock(); //释放锁 lock.unlock(); //释放锁
} }
}else{
iLatentDangerService.updateDangerStateOfOvertime();
}
......
...@@ -4,6 +4,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; ...@@ -4,6 +4,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanTaskService; import com.yeejoin.amos.supervision.business.service.intfc.IPlanTaskService;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired; 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.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -20,8 +21,11 @@ import java.util.concurrent.TimeUnit; ...@@ -20,8 +21,11 @@ import java.util.concurrent.TimeUnit;
@EnableScheduling @EnableScheduling
public class PlanTaskJob { public class PlanTaskJob {
@Autowired @Autowired(required = false)
org.redisson.api.RedissonClient redisson; org.redisson.api.RedissonClient redisson;
@Value("${spring.redis.mode}")
private String cluster;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
...@@ -34,7 +38,7 @@ public class PlanTaskJob { ...@@ -34,7 +38,7 @@ public class PlanTaskJob {
@Scheduled(cron = "${jobs.cron}") @Scheduled(cron = "${jobs.cron}")
public void scheduleJob() { public void scheduleJob() {
if("cluster".equals(cluster)){
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String time=format.format(new Date()); String time=format.format(new Date());
String jobName = "supervision-1" +time; String jobName = "supervision-1" +time;
...@@ -56,5 +60,8 @@ public class PlanTaskJob { ...@@ -56,5 +60,8 @@ public class PlanTaskJob {
lock.unlock(); //释放锁 lock.unlock(); //释放锁
} }
}else{
planTaskService.taskExecution(null);
}
} }
} }
...@@ -186,12 +186,11 @@ spring.redis.database=1 ...@@ -186,12 +186,11 @@ spring.redis.database=1
spring.redis.timeout=10000 spring.redis.timeout=10000
spring.redis.password=yeejoin@2020 spring.redis.password=yeejoin@2020
spring.redis.expire.time=300 spring.redis.expire.time=300
#单机集群判断 cluster集群 single单机 #单机集群判断 cluster
spring.redis.mode=single spring.redis.mode=single
#redis 单机配置 #redis 单机配置
spring.redis.host=172.16.10.211 spring.redis.host=172.16.10.211
spring.redis.port=6379 spring.redis.port=6379
spring.redis.redissonUrl=172.16.10.211:6379
......
...@@ -175,7 +175,6 @@ spring.redis.mode=single ...@@ -175,7 +175,6 @@ spring.redis.mode=single
#redis 单机配置 #redis 单机配置
spring.redis.host=172.16.11.20 spring.redis.host=172.16.11.20
spring.redis.port=6379 spring.redis.port=6379
spring.redis.redissonUrl=172.16.11.20:6379
spring.data.elasticsearch.repositories.enabled=true spring.data.elasticsearch.repositories.enabled=true
......
...@@ -81,7 +81,6 @@ spring.redis.mode=single ...@@ -81,7 +81,6 @@ spring.redis.mode=single
#redis 单机配置 #redis 单机配置
spring.redis.host=172.16.11.20 spring.redis.host=172.16.11.20
spring.redis.port=6379 spring.redis.port=6379
spring.redis.redissonUrl=172.16.11.20:6379
#注册中心地址 #注册中心地址
eureka.client.service-url.defaultZone =http://172.16.10.72:10001/eureka/ eureka.client.service-url.defaultZone =http://172.16.10.72:10001/eureka/
......
...@@ -146,7 +146,6 @@ spring.redis.mode=single ...@@ -146,7 +146,6 @@ spring.redis.mode=single
#redis 单机配置 #redis 单机配置
spring.redis.host=172.16.11.20 spring.redis.host=172.16.11.20
spring.redis.port=6379 spring.redis.port=6379
spring.redis.redissonUrl=172.16.11.20:6379
......
...@@ -124,7 +124,6 @@ spring.redis.mode=single ...@@ -124,7 +124,6 @@ spring.redis.mode=single
#redis 单机配置 #redis 单机配置
spring.redis.host=172.16.11.20 spring.redis.host=172.16.11.20
spring.redis.port=6379 spring.redis.port=6379
spring.redis.redissonUrl=172.16.11.20:6379
......
...@@ -151,7 +151,6 @@ spring.redis.mode=single ...@@ -151,7 +151,6 @@ spring.redis.mode=single
#redis 单机配置 #redis 单机配置
spring.redis.host=172.16.11.20 spring.redis.host=172.16.11.20
spring.redis.port=6379 spring.redis.port=6379
spring.redis.redissonUrl=172.16.11.20:6379
......
...@@ -129,7 +129,6 @@ spring.redis.mode=single ...@@ -129,7 +129,6 @@ spring.redis.mode=single
#redis 单机配置 #redis 单机配置
spring.redis.host=172.16.10.211 spring.redis.host=172.16.10.211
spring.redis.port=6379 spring.redis.port=6379
spring.redis.redissonUrl=172.16.10.211:6379
......
...@@ -85,7 +85,6 @@ spring.redis.jedis.pool.min-idle=1 ...@@ -85,7 +85,6 @@ spring.redis.jedis.pool.min-idle=1
#redis 单机配置 #redis 单机配置
spring.redis.host=172.16.11.20 spring.redis.host=172.16.11.20
spring.redis.port=6379 spring.redis.port=6379
spring.redis.redissonUrl=172.16.11.20:6379
spring.data.elasticsearch.repositories.enabled=true spring.data.elasticsearch.repositories.enabled=true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment