package com.mokamrp; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.mokamrp.privates.PrivateServerStart; import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobilePool; import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileTaskTimeList; import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTaskSchedule; import com.mokamrp.privates.service.CoralApiService; import com.mokamrp.privates.service.CorpService; import com.mokamrp.privates.service.pangu.FosterwxMobilePoolService; import com.mokamrp.privates.service.pangu.FosterwxMobileService; import com.mokamrp.privates.service.pangu.FosterwxMobileTaskTimeListService; import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService; import com.mokamrp.privates.task.pangu.SyncCreateCashTask; import com.mokamrp.privates.task.pangu.SyncFosterwxMobilePool; import com.mokamrp.privates.task.pangu.SyncMobilePoolFans; import lombok.extern.slf4j.Slf4j; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.time.LocalDateTime; @Slf4j @SpringBootTest(classes = PrivateServerStart.class) @RunWith(SpringRunner.class) public class WebTest { @Autowired private FosterwxMobileService fosterwxMobileService; @Autowired private CorpService corpService; @Autowired private FosterwxMobilePoolService fosterwxMobilePoolService; @Autowired private SyncFosterwxMobilePool syncFosterwxMobilePool; @Autowired private FosterwxMobileTaskTimeListService fosterwxMobileTaskTimeListService; @Autowired private FosterwxTaskScheduleService fosterwxTaskScheduleService; @Autowired private SyncMobilePoolFans syncMobilePoolFans; @Autowired private SyncCreateCashTask syncCreateCashTask; @Autowired private CoralApiService coralApiService; @Test public void test1() { // 清洗数据 fosterwxMobileService.list().forEach(fosterwxMobile -> { // if (corpService.count(new LambdaQueryWrapper().eq(Corp::getName, fosterwxMobile.getWorkWxCorp())) > 1) { // log.warn("{}名字有两个主体", fosterwxMobile.getWorkWxCorp()); // } // Corp corp = corpService.getOne(new LambdaQueryWrapper().eq(Corp::getName, fosterwxMobile.getWorkWxCorp()).last("Limit 1")); // if (null != corp) { // fosterwxMobile.setWorkWxCorpId(corp.getId()); // fosterwxMobile.setWxAppid(corp.getWxCorpid()); // fosterwxMobileService.updateById(fosterwxMobile); // } else { // fosterwxMobile.setWorkWxCorpId(0); // fosterwxMobile.setWxAppid(null); // fosterwxMobileService.updateById(fosterwxMobile); // } fosterwxMobilePoolService.update(new FosterwxMobilePool() {{ setWxAppid(fosterwxMobile.getWxAppid()); }}, new LambdaQueryWrapper().eq(FosterwxMobilePool::getPoolIndex, fosterwxMobile.getMobileUnioCode())); }); } @Test public void test2() { // syncFosterwxMobilePool.execute(); syncMobilePoolFans.syncTotalFans(); syncMobilePoolFans.syncDayFans(); } /** * 清洗任务开始时间到新的数据表中 */ @Test public void test3() { fosterwxMobileService.list().forEach(fosterwxMobile -> { if (null != fosterwxMobile.getTaskStartAt()) { FosterwxMobileTaskTimeList fosterwxMobileTaskTimeList = new FosterwxMobileTaskTimeList(); fosterwxMobileTaskTimeList.setStationId(fosterwxMobile.getStationId()); fosterwxMobileTaskTimeList.setMobileCode(fosterwxMobile.getMobileCode()); fosterwxMobileTaskTimeList.setMobileUnioCode(fosterwxMobile.getMobileUnioCode()); FosterwxTaskSchedule fosterwxTaskSchedule = fosterwxTaskScheduleService.getOne(new LambdaQueryWrapper().eq(FosterwxTaskSchedule::getStationId, fosterwxMobile.getStationId()).eq(FosterwxTaskSchedule::getMobileCode, fosterwxMobile.getMobileCode()).last("limit 1")); if (null != fosterwxTaskSchedule) fosterwxMobileTaskTimeList.setTemplateId(fosterwxTaskSchedule.getTemplateId()); fosterwxMobileTaskTimeList.setTaskStartAt(fosterwxMobile.getTaskStartAt()); fosterwxMobileTaskTimeList.setTaskEndAt(null); fosterwxMobileTaskTimeList.setCreateAt(LocalDateTime.now()); fosterwxMobileTaskTimeList.setUpdateAt(LocalDateTime.now()); fosterwxMobileTaskTimeListService.save(fosterwxMobileTaskTimeList); } }); } @Test public void test4() { syncCreateCashTask.syncCreateCashTask(); } }