PlanAccountJob.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package com.tzld.piaoquan.longarticle.job;
  2. import com.tzld.piaoquan.longarticle.dao.mapper.crawler.ArticleUseGroupMapper;
  3. import com.tzld.piaoquan.longarticle.model.po.crawler.ArticleUseGroup;
  4. import com.tzld.piaoquan.longarticle.model.po.crawler.ArticleUseGroupExample;
  5. import com.tzld.piaoquan.longarticle.service.local.CoreService;
  6. import com.tzld.piaoquan.longarticle.service.local.CoverService;
  7. import com.tzld.piaoquan.longarticle.utils.DateUtil;
  8. import com.tzld.piaoquan.longarticle.utils.LarkRobotUtil;
  9. import com.xxl.job.core.biz.model.ReturnT;
  10. import com.xxl.job.core.handler.annotation.XxlJob;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.data.redis.core.RedisTemplate;
  14. import org.springframework.stereotype.Component;
  15. @Slf4j
  16. @Component
  17. public class PlanAccountJob {
  18. @Autowired
  19. private CoreService coreService;
  20. @Autowired
  21. private CoverService coverService;
  22. @Autowired
  23. private ArticleUseGroupMapper articleUseGroupMapper;
  24. @XxlJob("initAccountSpecialSettingsJob")
  25. public ReturnT<String> initAccountSpecialSettings(String param) {
  26. try {
  27. coreService.initAccountSpecialSettings();
  28. } catch (Exception e) {
  29. LarkRobotUtil.sendMessage("例外设置异常,请及时查看,@薛一鸣");
  30. log.error("initAccountSpecialSettings error", e);
  31. }
  32. return ReturnT.SUCCESS;
  33. }
  34. @XxlJob("initPlanAccountJob")
  35. public ReturnT<String> initPlanAccount(String param) {
  36. try {
  37. coreService.initPlanAccount();
  38. } catch (Exception e) {
  39. LarkRobotUtil.sendMessage("长文系统初始化异常,请及时查看,@薛一鸣");
  40. log.error("initPlanAccountJob error", e);
  41. }
  42. return ReturnT.SUCCESS;
  43. }
  44. @XxlJob("matchPlanAccountJob")
  45. public ReturnT<String> matchPlanAccount(String param) {
  46. try {
  47. coreService.matchContent();
  48. } catch (Exception e) {
  49. LarkRobotUtil.sendMessage("长文系统匹配异常,请及时查看,@薛一鸣");
  50. log.error("matchPlanAccountJob error", e);
  51. }
  52. return ReturnT.SUCCESS;
  53. }
  54. @XxlJob("corePlanAccountJob")
  55. public ReturnT<String> corePlanAccount(String param) {
  56. try {
  57. coreService.core();
  58. } catch (Exception e) {
  59. LarkRobotUtil.sendMessage("长文系统核心流程异常,请及时查看,@薛一鸣");
  60. log.error("corePlanAccountJob error", e);
  61. }
  62. return ReturnT.SUCCESS;
  63. }
  64. @XxlJob("getPushStatusJob")
  65. public ReturnT<String> getPushStatus(String param) {
  66. try {
  67. coreService.getPushStatus();
  68. } catch (Exception e) {
  69. LarkRobotUtil.sendMessage("长文系统获取结果异常,请及时查看,@薛一鸣");
  70. log.error("getPushStatusJob error", e);
  71. }
  72. return ReturnT.SUCCESS;
  73. }
  74. @XxlJob("getEffectiveVideoJob")
  75. public ReturnT<String> getEffectiveVideo(String param) {
  76. try {
  77. coverService.getEffectiveVideo();
  78. } catch (Exception e) {
  79. LarkRobotUtil.sendMessage("长文系统查询可用视频失败");
  80. log.error("getEffectiveVideo error", e);
  81. }
  82. return ReturnT.SUCCESS;
  83. }
  84. @XxlJob("updateRemainingCountJob")
  85. public ReturnT<String> updateRemainingCount(String param) {
  86. try {
  87. int dayOfMonth = DateUtil.getDayOfMonth();
  88. if (dayOfMonth == 1) {
  89. ArticleUseGroup articleUseGroup = new ArticleUseGroup();
  90. articleUseGroup.setRemainingCount(4);
  91. ArticleUseGroupExample example = new ArticleUseGroupExample();
  92. example.createCriteria().andIdGreaterThan(0L);
  93. articleUseGroupMapper.updateByExampleSelective(articleUseGroup, example);
  94. }
  95. } catch (Exception e) {
  96. log.error("updateRemainingCount error", e);
  97. }
  98. return ReturnT.SUCCESS;
  99. }
  100. }