10 changed files with 202 additions and 9 deletions
@ -0,0 +1,37 @@ |
|||||
|
package com.epmet.feign; |
||||
|
|
||||
|
import com.epmet.commons.tools.constant.ServiceConstant; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.feign.impl.GovIssueFeignClientFallBack; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
|
||||
|
/** |
||||
|
* @Description 议题定时任务 |
||||
|
* @Author wangc |
||||
|
* @Date 2020/5/23 13:42 |
||||
|
*/ |
||||
|
@FeignClient(name = ServiceConstant.GOV_ISSUE_SERVER, fallback = GovIssueFeignClientFallBack.class) |
||||
|
public interface GovIssueFeignClient { |
||||
|
|
||||
|
/** |
||||
|
* @Description 定时任务 每天生成生成昨日的议题表决日统计数 |
||||
|
* @param |
||||
|
* @return |
||||
|
* @author wangc |
||||
|
* @date 2020.05.20 15:39 |
||||
|
**/ |
||||
|
@PostMapping(value = "gov/issue/issuevotestatisticaldaily/dailystatisticalvotejob") |
||||
|
Result dailyStatisticalVoteJob(); |
||||
|
|
||||
|
/** |
||||
|
* @Description 将所有表决中的投票数从缓存同步到数据库,要进行数据对比,若数据一致无需更新 |
||||
|
* @param |
||||
|
* @return |
||||
|
* @author wangc |
||||
|
* @date 2020.05.21 09:07 |
||||
|
**/ |
||||
|
@PostMapping(value = "gov/issue/issuevotestatistical/syncvotingcacheanddb") |
||||
|
Result syncVotingCacheAndDb(); |
||||
|
|
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package com.epmet.feign.impl; |
||||
|
|
||||
|
import com.epmet.commons.tools.constant.ServiceConstant; |
||||
|
import com.epmet.commons.tools.utils.ModuleUtils; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.feign.GovIssueFeignClient; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @Description |
||||
|
* @ClassName GovIssueFeignClientFallBack |
||||
|
* @Auth wangc |
||||
|
* @Date 2020-05-25 09:02 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class GovIssueFeignClientFallBack implements GovIssueFeignClient { |
||||
|
@Override |
||||
|
public Result dailyStatisticalVoteJob() { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "dailyStatisticalVoteJob"); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result syncVotingCacheAndDb() { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "syncVotingCacheAndDb"); |
||||
|
} |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
|
||||
|
/** |
||||
|
* @Description 同步缓存与数据库定时任务 -> 议题表决统计 |
||||
|
* @Author wangc |
||||
|
* @Date 2020/5/20 17:39 |
||||
|
*/ |
||||
|
public interface SyncVotingCacheAndDbService { |
||||
|
|
||||
|
Result syncVotingCacheAndDb(); |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.feign.GovIssueFeignClient; |
||||
|
import com.epmet.service.IssueVotingDailyStatisticalTaskService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
/** |
||||
|
* @Description |
||||
|
* @ClassName IssueVotingDailyStatisticalTaskServiceImpl |
||||
|
* @Auth wangc |
||||
|
* @Date 2020-05-25 09:24 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class IssueVotingDailyStatisticalTaskServiceImpl implements IssueVotingDailyStatisticalTaskService { |
||||
|
@Autowired |
||||
|
private GovIssueFeignClient govIssueFeignClient; |
||||
|
|
||||
|
@Override |
||||
|
public Result issueVotingDailyStatistical() { |
||||
|
return govIssueFeignClient.dailyStatisticalVoteJob(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.feign.GovIssueFeignClient; |
||||
|
import com.epmet.service.SyncVotingCacheAndDbService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
/** |
||||
|
* @Description |
||||
|
* @ClassName SyncVotingCacheAndDbServiceImpl |
||||
|
* @Auth wangc |
||||
|
* @Date 2020-05-25 09:45 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class SyncVotingCacheAndDbServiceImpl implements SyncVotingCacheAndDbService { |
||||
|
@Autowired |
||||
|
private GovIssueFeignClient govIssueFeignClient; |
||||
|
|
||||
|
@Override |
||||
|
public Result syncVotingCacheAndDb() { |
||||
|
return govIssueFeignClient.syncVotingCacheAndDb(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
package com.epmet.task; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.service.IssueVotingDailyStatisticalTaskService; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @Description |
||||
|
* @ClassName dailyStatisticalVoteTask |
||||
|
* @Auth wangc |
||||
|
* @Date 2020-05-25 09:22 |
||||
|
*/ |
||||
|
@Component("dailyStatisticalVoteTask") |
||||
|
public class DailyStatisticalVoteTask implements ITask{ |
||||
|
private Logger logger = LoggerFactory.getLogger(getClass()); |
||||
|
|
||||
|
@Autowired |
||||
|
private IssueVotingDailyStatisticalTaskService issueVotingDailyStatisticalTaskService; |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public void run(String params) { |
||||
|
logger.debug("dailyStatisticalVoteTask定时任务正在执行,参数为:{}", params); |
||||
|
Result result=issueVotingDailyStatisticalTaskService.issueVotingDailyStatistical(); |
||||
|
if(result.success()){ |
||||
|
logger.debug("dailyStatisticalVoteTask定时任务正在执行定时任务执行成功"); |
||||
|
}else{ |
||||
|
logger.debug("dailyStatisticalVoteTask定时任务正在执行定时任务执行失败:"+result.getMsg()); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package com.epmet.task; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.service.SyncVotingCacheAndDbService; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @Description |
||||
|
* @ClassName SyncVotingCacheAndDbTask |
||||
|
* @Auth wangc |
||||
|
* @Date 2020-05-25 09:47 |
||||
|
*/ |
||||
|
@Component("syncVotingCacheAndDbTask") |
||||
|
public class SyncVotingCacheAndDbTask implements ITask { |
||||
|
private Logger logger = LoggerFactory.getLogger(getClass()); |
||||
|
|
||||
|
@Autowired |
||||
|
private SyncVotingCacheAndDbService syncVotingCacheAndDbService; |
||||
|
|
||||
|
@Override |
||||
|
public void run(String params) { |
||||
|
logger.debug("syncVotingCacheAndDbTask定时任务正在执行,参数为:{}", params); |
||||
|
Result result = syncVotingCacheAndDbService.syncVotingCacheAndDb(); |
||||
|
if(result.success()){ |
||||
|
logger.debug("syncVotingCacheAndDbTask定时任务正在执行定时任务执行成功"); |
||||
|
}else{ |
||||
|
logger.debug("syncVotingCacheAndDbTask定时任务正在执行定时任务执行失败:"+result.getMsg()); |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue