Commit 51c5b9e7 authored by suhuiguang's avatar suhuiguang

1.分布式定时任务锁

parent 2d187912
...@@ -21,6 +21,14 @@ ...@@ -21,6 +21,14 @@
<artifactId>amos-boot-module-common-api</artifactId> <artifactId>amos-boot-module-common-api</artifactId>
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
</dependency> </dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-redis-spring</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.yeejoin.amos; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos;
import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils; import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils;
import com.yeejoin.amos.boot.module.elevator.biz.service.impl.StartPlatformTokenService; import com.yeejoin.amos.boot.module.elevator.biz.service.impl.StartPlatformTokenService;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -40,6 +41,7 @@ import java.net.UnknownHostException; ...@@ -40,6 +41,7 @@ import java.net.UnknownHostException;
@EnableAsync @EnableAsync
@EnableSwagger2WebMvc @EnableSwagger2WebMvc
@EnableEurekaClient @EnableEurekaClient
@EnableSchedulerLock(defaultLockAtMostFor = "10m")
//@EnableScheduling //@EnableScheduling
@MapperScan({"org.typroject.tyboot.demo.face.orm.dao*", "org.typroject.tyboot.face.*.orm.dao*", @MapperScan({"org.typroject.tyboot.demo.face.orm.dao*", "org.typroject.tyboot.face.*.orm.dao*",
"org.typroject.tyboot.core.auth.face.orm.dao*", "org.typroject.tyboot.component.*.face.orm.dao*", "org.typroject.tyboot.core.auth.face.orm.dao*", "org.typroject.tyboot.component.*.face.orm.dao*",
......
package com.yeejoin.amos.boot.module.elevator.biz.config;
import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.redis.spring.RedisLockProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
/**
* @author Administrator
*/
@Configuration
public class ShedLockConfig {
@Bean
public LockProvider lockProvider(RedisConnectionFactory connectionFactory) {
return new RedisLockProvider(connectionFactory);
}
}
...@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.module.elevator.api.entity.VoiceRecordLog; ...@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.module.elevator.api.entity.VoiceRecordLog;
import com.yeejoin.amos.boot.module.elevator.api.mapper.VoiceRecordLogMapper; import com.yeejoin.amos.boot.module.elevator.api.mapper.VoiceRecordLogMapper;
import com.yeejoin.amos.boot.module.elevator.api.service.ICtiService; import com.yeejoin.amos.boot.module.elevator.api.service.ICtiService;
import com.yeejoin.amos.boot.module.elevator.api.service.IVoiceRecordLogService; import com.yeejoin.amos.boot.module.elevator.api.service.IVoiceRecordLogService;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
...@@ -72,6 +73,7 @@ public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,Voi ...@@ -72,6 +73,7 @@ public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,Voi
private TzsAuthServiceImpl tzsAuthServiceImpl; private TzsAuthServiceImpl tzsAuthServiceImpl;
@Scheduled(fixedDelay=ONE_Minute) @Scheduled(fixedDelay=ONE_Minute)
@SchedulerLock(name="voiceRecordLogTask",lockAtMostFor = "PT1H")
public void fixedDelayJob(){ public void fixedDelayJob(){
// 设置token // 设置token
tzsAuthServiceImpl.setRequestContext(); tzsAuthServiceImpl.setRequestContext();
...@@ -93,7 +95,7 @@ public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,Voi ...@@ -93,7 +95,7 @@ public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,Voi
this.updateById(l); this.updateById(l);
continue; continue;
} }
if(ctiInfos == null || ctiInfos.size() == 0) { if(ctiInfos == null || ctiInfos.isEmpty()) {
this.updateById(l); this.updateById(l);
continue; continue;
} }
...@@ -160,7 +162,7 @@ public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,Voi ...@@ -160,7 +162,7 @@ public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,Voi
} }
l.setIsDeal(true); l.setIsDeal(true);
this.updateById(l); this.updateById(l);
}; }
} }
System.out.println("执行通话记录任务"); System.out.println("执行通话记录任务");
......
...@@ -22,6 +22,14 @@ ...@@ -22,6 +22,14 @@
<artifactId>amos-boot-module-common-api</artifactId> <artifactId>amos-boot-module-common-api</artifactId>
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
</dependency> </dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-redis-spring</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.yeejoin.amos; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos;
import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils; import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils;
import com.yeejoin.amos.boot.module.cylinder.biz.listener.FillingRecordSyncListener; import com.yeejoin.amos.boot.module.cylinder.biz.listener.FillingRecordSyncListener;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -44,6 +45,7 @@ import java.net.UnknownHostException; ...@@ -44,6 +45,7 @@ import java.net.UnknownHostException;
@EnableSwagger2WebMvc @EnableSwagger2WebMvc
@EnableEurekaClient @EnableEurekaClient
@EnableScheduling @EnableScheduling
@EnableSchedulerLock(defaultLockAtMostFor = "10m")
@MapperScan({ "org.typroject.tyboot.demo.face.orm.dao*", "org.typroject.tyboot.face.*.orm.dao*", @MapperScan({ "org.typroject.tyboot.demo.face.orm.dao*", "org.typroject.tyboot.face.*.orm.dao*",
"org.typroject.tyboot.core.auth.face.orm.dao*", "org.typroject.tyboot.component.*.face.orm.dao*", "org.typroject.tyboot.core.auth.face.orm.dao*", "org.typroject.tyboot.component.*.face.orm.dao*",
"com.yeejoin.amos.boot.module.**.api.mapper", "com.yeejoin.amos.boot.biz.common.dao.mapper" }) "com.yeejoin.amos.boot.module.**.api.mapper", "com.yeejoin.amos.boot.biz.common.dao.mapper" })
......
package com.yeejoin.amos.boot.module.cylinder.biz.config;
import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.redis.spring.RedisLockProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
/**
* @author Administrator
*/
@Configuration
public class ShedLockConfig {
@Bean
public LockProvider lockProvider(RedisConnectionFactory connectionFactory) {
return new RedisLockProvider(connectionFactory);
}
}
...@@ -57,7 +57,7 @@ public class ESAlertCalledService { ...@@ -57,7 +57,7 @@ public class ESAlertCalledService {
public void init() throws Exception public void init() throws Exception
{ {
//初始化ES,重建索引 //初始化ES,重建索引
initEs(); // initEs();
} }
/** /**
......
package com.yeejoin.amos.boot.module.cylinder.flc.biz.quartz; package com.yeejoin.amos.boot.module.cylinder.flc.biz.quartz;
import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.ScheduleService; import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.ScheduleService;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
...@@ -20,6 +21,7 @@ public class CylinderSchedulerJob { ...@@ -20,6 +21,7 @@ public class CylinderSchedulerJob {
* 每天9点-日报生成 * 每天9点-日报生成
*/ */
@Scheduled(cron = "${cylinder-early-warning-cron:0 0 9 * * ?}") @Scheduled(cron = "${cylinder-early-warning-cron:0 0 9 * * ?}")
@SchedulerLock(name="calEarlyWarningLevelTask",lockAtMostFor = "PT6H")
public void dayReport() { public void dayReport() {
scheduleService.calEarlyWarningLevel(); scheduleService.calEarlyWarningLevel();
} }
......
...@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderTableDto; ...@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderTableDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.*; import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.*;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderDateInfoMapper; import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderDateInfoMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderUnitMapper; import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderUnitMapper;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -160,10 +161,15 @@ public class CylinderDateInfoServiceImpl extends BaseService<CylinderDateInfoDto ...@@ -160,10 +161,15 @@ public class CylinderDateInfoServiceImpl extends BaseService<CylinderDateInfoDto
return page; return page;
} }
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 /**
* 每天凌晨两点执行
*/
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="fixedDelayJobCylinderDataTask",lockAtMostFor = "PT6H")
public void fixedDelayJob() { public void fixedDelayJob() {
// 每天更新或者添加昨天的数据 // 每天更新或者添加昨天的数据
Date date = new Date();//取时间 //取时间
Date date = new Date();
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(date); calendar.setTime(date);
calendar.add(Calendar.DATE, -1); calendar.add(Calendar.DATE, -1);
......
...@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderFillingRecordDt ...@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderFillingRecordDt
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderFillingRecord; import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderFillingRecord;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderFillingRecordMapper; import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderFillingRecordMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderFillingRecordService; import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderFillingRecordService;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope; import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.auth.UsernamePasswordCredentials;
...@@ -127,6 +128,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -127,6 +128,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Scheduled(cron = "${tzs.cylinder.fill.cron}") @Scheduled(cron = "${tzs.cylinder.fill.cron}")
@SchedulerLock(name="cylinderFillingRecord2ESTask",lockAtMostFor = "PT6H")
public void setTimeSaveCylinderInfoToES(){ public void setTimeSaveCylinderInfoToES(){
Page<ESCylinderFillingRecordDto> cylinderFillingRecordPage = new Page<>(); Page<ESCylinderFillingRecordDto> cylinderFillingRecordPage = new Page<>();
Page<ESCylinderFillingRecordDto> cyinderInfoList = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage); Page<ESCylinderFillingRecordDto> cyinderInfoList = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage);
......
...@@ -24,6 +24,7 @@ import com.yeejoin.amos.component.rule.RuleTrigger; ...@@ -24,6 +24,7 @@ import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel; import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope; import org.apache.http.auth.AuthScope;
...@@ -214,8 +215,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -214,8 +215,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
/** /**
* 按单位统计 * 按单位统计
*/ */
@Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synFillingUnloadDataTask",lockAtMostFor = "PT6H")
public void synFillingUnloadData() { public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>()); cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
countByRegion(regionModel -> { countByRegion(regionModel -> {
...@@ -240,8 +243,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -240,8 +243,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
/** /**
* 按区域统计 * 按区域统计
*/ */
@Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synAreaDataTask",lockAtMostFor = "PT60M")
public void synAreaData() { public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>()); cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
countByRegion(regionModel -> { countByRegion(regionModel -> {
...@@ -275,6 +280,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -275,6 +280,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "* * 2 * * ?") @Scheduled(cron = "* * 2 * * ?")
@SchedulerLock(name="addIntegrityDataTask",lockAtMostFor = "PT60M")
public void addIntegrityData() { public void addIntegrityData() {
System.out.println("====================数据完整性开始============================"); System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>()); cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
...@@ -337,8 +343,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -337,8 +343,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
/** /**
* 企业总量按区域统计 * 企业总量按区域统计
*/ */
@Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="cylinderUnitInfoTask",lockAtMostFor = "PT60M")
public void getCylinderUnitInfo() { public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>()); cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> { countByRegion(regionModel -> {
...@@ -371,8 +379,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -371,8 +379,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
/** /**
* 气瓶总量按区域统计 * 气瓶总量按区域统计
*/ */
@Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="cylinderInfoTask",lockAtMostFor = "PT6H")
public void getCylinderInfo() { public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>()); cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> { countByRegion(regionModel -> {
...@@ -404,8 +414,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -404,8 +414,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
/** /**
* 按单位统计 * 按单位统计
*/ */
@Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synUnitCylinderInfoDataTask",lockAtMostFor = "PT6H")
public void synUnitCylinderInfoData() { public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>()); cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
countByUnit(cylinderUnit -> { countByUnit(cylinderUnit -> {
...@@ -437,8 +449,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -437,8 +449,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
/** /**
* 充装量按单位和月统计 * 充装量按单位和月统计
*/ */
@Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synUnitCylinderFillingDataTask",lockAtMostFor = "PT6H")
public void synUnitCylinderFillingData() { public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>()); cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> { countByUnit(cylinderUnit -> {
...@@ -480,8 +494,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -480,8 +494,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
/** /**
* 按单位统计 * 按单位统计
*/ */
@Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synUnitCylinderTagsDataTask",lockAtMostFor = "PT6H")
public void synUnitCylinderTagsData() { public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>()); cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
countByUnit(cylinderUnit -> { countByUnit(cylinderUnit -> {
...@@ -511,8 +527,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -511,8 +527,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
/** /**
* 按单位统计 * 按单位统计
*/ */
@Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synUnitIntegrityDataTask",lockAtMostFor = "PT6H")
public void synUnitIntegrityData() { public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>()); cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> { countByUnit(cylinderUnit -> {
...@@ -570,8 +588,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -570,8 +588,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
/** /**
* 充装详情按单位统计 * 充装详情按单位统计
*/ */
@Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synUnitFillingCheckDataTask",lockAtMostFor = "PT6H")
public void synUnitFillingCheckData() { public void synUnitFillingCheckData() {
// cylinderFillingCheckDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingCheckDataUnit>()); // cylinderFillingCheckDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingCheckDataUnit>());
countByUnit(cylinderUnit -> { countByUnit(cylinderUnit -> {
...@@ -669,8 +689,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -669,8 +689,10 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
/** /**
* 充装量、卸液量按单位统计 * 充装量、卸液量按单位统计
*/ */
@Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synFillingUnloadUnitDataTask",lockAtMostFor = "PT6H")
public void synFillingUnloadUnitData() { public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>()); cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
countByUnit(cylinderUnit -> { countByUnit(cylinderUnit -> {
...@@ -693,6 +715,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -693,6 +715,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
} }
@Scheduled(cron = "${tzs.cylinder.info.cron}") @Scheduled(cron = "${tzs.cylinder.info.cron}")
@SchedulerLock(name="cylinderInfoToESTask",lockAtMostFor = "PT6H")
public void setTimeSaveCylinderInfoToES(){ public void setTimeSaveCylinderInfoToES(){
Page<CylinderInfoDto> cylinderInfoPage = new Page<>(); Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
Page<CylinderInfoDto> cyinderInfoList = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage); Page<CylinderInfoDto> cyinderInfoList = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
......
...@@ -57,7 +57,7 @@ public class ESAlertCalledService { ...@@ -57,7 +57,7 @@ public class ESAlertCalledService {
public void init() throws Exception public void init() throws Exception
{ {
//初始化ES,重建索引 //初始化ES,重建索引
initEs(); // initEs();
} }
/** /**
......
...@@ -21,6 +21,14 @@ ...@@ -21,6 +21,14 @@
<artifactId>amos-boot-module-common-api</artifactId> <artifactId>amos-boot-module-common-api</artifactId>
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
</dependency> </dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-redis-spring</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -16,6 +16,7 @@ import com.yeejoin.amos.boot.module.tcm.flc.biz.service.impl.UnitInfoServiceImpl ...@@ -16,6 +16,7 @@ import com.yeejoin.amos.boot.module.tcm.flc.biz.service.impl.UnitInfoServiceImpl
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.RoleModel; import com.yeejoin.amos.feign.privilege.model.RoleModel;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -58,7 +59,7 @@ import java.util.List; ...@@ -58,7 +59,7 @@ import java.util.List;
@EnableAsync @EnableAsync
@EnableSwagger2WebMvc @EnableSwagger2WebMvc
@EnableEurekaClient @EnableEurekaClient
//@EnableScheduling @EnableSchedulerLock(defaultLockAtMostFor = "10m")
@MapperScan({"org.typroject.tyboot.demo.face.orm.dao*", "org.typroject.tyboot.face.*.orm.dao*", @MapperScan({"org.typroject.tyboot.demo.face.orm.dao*", "org.typroject.tyboot.face.*.orm.dao*",
"org.typroject.tyboot.core.auth.face.orm.dao*", "org.typroject.tyboot.component.*.face.orm.dao*", "org.typroject.tyboot.core.auth.face.orm.dao*", "org.typroject.tyboot.component.*.face.orm.dao*",
"com.yeejoin.amos.boot.module.**.api.mapper", "com.yeejoin.amos.boot.biz.common.dao.mapper"}) "com.yeejoin.amos.boot.module.**.api.mapper", "com.yeejoin.amos.boot.biz.common.dao.mapper"})
......
package com.yeejoin.amos.boot.module.tcm.biz.config;
import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.redis.spring.RedisLockProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
/**
* @author Administrator
*/
@Configuration
public class ShedLockConfig {
@Bean
public LockProvider lockProvider(RedisConnectionFactory connectionFactory) {
return new RedisLockProvider(connectionFactory);
}
}
...@@ -67,7 +67,7 @@ public class PlatformUserTopicMessage extends EmqxListener { ...@@ -67,7 +67,7 @@ public class PlatformUserTopicMessage extends EmqxListener {
try { try {
if (StringUtils.isNotEmpty(path)) { if (StringUtils.isNotEmpty(path)) {
if (path.contains("company") && !"company".equals(dataResult.get("level"))) { if (path.contains("company") && !"company".equals(dataResult.get("level"))) {
equipmentCategoryService.creatTree(); // equipmentCategoryService.creatTree();
} else if (path.contains("agencyuser")) { } else if (path.contains("agencyuser")) {
regUnitInfoService.updateAdminInfo(dataResult); regUnitInfoService.updateAdminInfo(dataResult);
} }
......
...@@ -57,7 +57,7 @@ public class ESAlertCalledService { ...@@ -57,7 +57,7 @@ public class ESAlertCalledService {
public void init() throws Exception public void init() throws Exception
{ {
//初始化ES,重建索引 //初始化ES,重建索引
initEs(); // initEs();
} }
/** /**
......
...@@ -41,6 +41,7 @@ import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; ...@@ -41,6 +41,7 @@ import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel; import com.yeejoin.amos.feign.privilege.model.RoleModel;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
...@@ -237,6 +238,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -237,6 +238,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
return model; return model;
} }
@SchedulerLock(name="asyncSetQrCodeTask",lockAtMostFor = "PT30M")
@Scheduled(cron = "${async.set.qr-code.cron:0 0/1 * * * ?}") @Scheduled(cron = "${async.set.qr-code.cron:0 0/1 * * * ?}")
public void asyncSetQrCode() { public void asyncSetQrCode() {
// 给所有新注册的企业创建二维码,每次处理1000个,不排序 // 给所有新注册的企业创建二维码,每次处理1000个,不排序
......
...@@ -68,13 +68,10 @@ public class PlatformUserTopicMessage extends EmqxListener { ...@@ -68,13 +68,10 @@ public class PlatformUserTopicMessage extends EmqxListener {
if (StringUtils.isNotEmpty(path)) { if (StringUtils.isNotEmpty(path)) {
if (path.contains("company") && !"company".equals(dataResult.get("level"))) { if (path.contains("company") && !"company".equals(dataResult.get("level"))) {
equipmentCategoryService.creatTree(); equipmentCategoryService.creatTree();
} else if (path.contains("agencyuser")) {
regUnitInfoService.updateAdminInfo(dataResult);
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.info("平台同步消息失败:{}", e.getMessage()); log.info("平台同步消息失败:{}", e.getMessage());
e.printStackTrace();
} }
log.info("平台推送消息同步完成"); log.info("平台推送消息同步完成");
} }
......
...@@ -57,7 +57,7 @@ public class ESAlertCalledService { ...@@ -57,7 +57,7 @@ public class ESAlertCalledService {
public void init() throws Exception public void init() throws Exception
{ {
//初始化ES,重建索引 //初始化ES,重建索引
initEs(); // initEs();
} }
/** /**
......
...@@ -67,7 +67,16 @@ ...@@ -67,7 +67,16 @@
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
<version>4.44.0</version>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-redis-spring</artifactId>
<version>4.44.0</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
</project> </project>
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