WebTest.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package com.mokamrp;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.mokamrp.privates.PrivateServerStart;
  4. import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobilePool;
  5. import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileTaskTimeList;
  6. import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTaskSchedule;
  7. import com.mokamrp.privates.service.CoralApiService;
  8. import com.mokamrp.privates.service.CorpService;
  9. import com.mokamrp.privates.service.pangu.FosterwxMobilePoolService;
  10. import com.mokamrp.privates.service.pangu.FosterwxMobileService;
  11. import com.mokamrp.privates.service.pangu.FosterwxMobileTaskTimeListService;
  12. import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
  13. import com.mokamrp.privates.task.pangu.SyncCreateCashTask;
  14. import com.mokamrp.privates.task.pangu.SyncFosterwxMobilePool;
  15. import com.mokamrp.privates.task.pangu.SyncMobilePoolFans;
  16. import lombok.extern.slf4j.Slf4j;
  17. import org.junit.Test;
  18. import org.junit.runner.RunWith;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.boot.test.context.SpringBootTest;
  21. import org.springframework.test.context.junit4.SpringRunner;
  22. import java.time.LocalDateTime;
  23. @Slf4j
  24. @SpringBootTest(classes = PrivateServerStart.class)
  25. @RunWith(SpringRunner.class)
  26. public class WebTest {
  27. @Autowired
  28. private FosterwxMobileService fosterwxMobileService;
  29. @Autowired
  30. private CorpService corpService;
  31. @Autowired
  32. private FosterwxMobilePoolService fosterwxMobilePoolService;
  33. @Autowired
  34. private SyncFosterwxMobilePool syncFosterwxMobilePool;
  35. @Autowired
  36. private FosterwxMobileTaskTimeListService fosterwxMobileTaskTimeListService;
  37. @Autowired
  38. private FosterwxTaskScheduleService fosterwxTaskScheduleService;
  39. @Autowired
  40. private SyncMobilePoolFans syncMobilePoolFans;
  41. @Autowired
  42. private SyncCreateCashTask syncCreateCashTask;
  43. @Autowired
  44. private CoralApiService coralApiService;
  45. @Test
  46. public void test1() {
  47. // 清洗数据
  48. fosterwxMobileService.list().forEach(fosterwxMobile -> {
  49. // if (corpService.count(new LambdaQueryWrapper<Corp>().eq(Corp::getName, fosterwxMobile.getWorkWxCorp())) > 1) {
  50. // log.warn("{}名字有两个主体", fosterwxMobile.getWorkWxCorp());
  51. // }
  52. // Corp corp = corpService.getOne(new LambdaQueryWrapper<Corp>().eq(Corp::getName, fosterwxMobile.getWorkWxCorp()).last("Limit 1"));
  53. // if (null != corp) {
  54. // fosterwxMobile.setWorkWxCorpId(corp.getId());
  55. // fosterwxMobile.setWxAppid(corp.getWxCorpid());
  56. // fosterwxMobileService.updateById(fosterwxMobile);
  57. // } else {
  58. // fosterwxMobile.setWorkWxCorpId(0);
  59. // fosterwxMobile.setWxAppid(null);
  60. // fosterwxMobileService.updateById(fosterwxMobile);
  61. // }
  62. fosterwxMobilePoolService.update(new FosterwxMobilePool() {{
  63. setWxAppid(fosterwxMobile.getWxAppid());
  64. }}, new LambdaQueryWrapper<FosterwxMobilePool>().eq(FosterwxMobilePool::getPoolIndex, fosterwxMobile.getMobileUnioCode()));
  65. });
  66. }
  67. @Test
  68. public void test2() {
  69. // syncFosterwxMobilePool.execute();
  70. syncMobilePoolFans.syncTotalFans();
  71. syncMobilePoolFans.syncDayFans();
  72. }
  73. /**
  74. * 清洗任务开始时间到新的数据表中
  75. */
  76. @Test
  77. public void test3() {
  78. fosterwxMobileService.list().forEach(fosterwxMobile -> {
  79. if (null != fosterwxMobile.getTaskStartAt()) {
  80. FosterwxMobileTaskTimeList fosterwxMobileTaskTimeList = new FosterwxMobileTaskTimeList();
  81. fosterwxMobileTaskTimeList.setStationId(fosterwxMobile.getStationId());
  82. fosterwxMobileTaskTimeList.setMobileCode(fosterwxMobile.getMobileCode());
  83. fosterwxMobileTaskTimeList.setMobileUnioCode(fosterwxMobile.getMobileUnioCode());
  84. FosterwxTaskSchedule fosterwxTaskSchedule = fosterwxTaskScheduleService.getOne(new LambdaQueryWrapper<FosterwxTaskSchedule>().eq(FosterwxTaskSchedule::getStationId, fosterwxMobile.getStationId()).eq(FosterwxTaskSchedule::getMobileCode, fosterwxMobile.getMobileCode()).last("limit 1"));
  85. if (null != fosterwxTaskSchedule)
  86. fosterwxMobileTaskTimeList.setTemplateId(fosterwxTaskSchedule.getTemplateId());
  87. fosterwxMobileTaskTimeList.setTaskStartAt(fosterwxMobile.getTaskStartAt());
  88. fosterwxMobileTaskTimeList.setTaskEndAt(null);
  89. fosterwxMobileTaskTimeList.setCreateAt(LocalDateTime.now());
  90. fosterwxMobileTaskTimeList.setUpdateAt(LocalDateTime.now());
  91. fosterwxMobileTaskTimeListService.save(fosterwxMobileTaskTimeList);
  92. }
  93. });
  94. }
  95. @Test
  96. public void test4() {
  97. syncCreateCashTask.syncCreateCashTask();
  98. }
  99. }