Commit 4e72dbcd by 杨林龙

开发不在店试驾统计任务

1 parent 54783cd5
package cn.com.glsx.schedulerjob.task.modules.service;
import cn.com.glsx.stdinterface.api.ElectricInStoreClient;
import com.alibaba.fastjson.JSON;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author liuyf
* @date 2021年01月26日 下午2:37:40
*/
@Slf4j
@Service
public class InStoreSchedulerJobService {
@Autowired
private ElectricInStoreClient electricInStoreClient;
public void calculateInStoreDateEveryDay() {
log.info("开始统计并插入非工作设备的无在店统计数据===");
R statisticsR = electricInStoreClient.calculateInStoreDateEveryDay();
log.info("统计的返回结果===" + JSON.toJSONString(statisticsR));
}
}
package cn.com.glsx.schedulerjob.task.taskscheduler;
import cn.com.glsx.schedulerjob.task.modules.service.InStoreSchedulerJobService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob;
import com.glsx.plat.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@Slf4j
@Component
@ElasticSimpleJob(jobName = "InStoreSchedulerJob", cron = "0 15 4 * * ?")
public class InStoreSchedulerJob implements SimpleJob {
@Autowired
private InStoreSchedulerJobService inStoreSchedulerJobService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("Thread ID: {}, 作业分片总数: {}, " +
"当前分片项: {}.当前参数: {}," +
"作业名称: {}.作业自定义参数: {}",
Thread.currentThread().getId(),
shardingContext.getShardingTotalCount(),
shardingContext.getShardingItem(),
shardingContext.getShardingParameter(),
shardingContext.getJobName(),
shardingContext.getJobParameter()
);
String normalDate = DateUtils.formatNormal(new Date());
log.info("---------------{}-开始----------------", normalDate);
inStoreSchedulerJobService.calculateInStoreDateEveryDay();
log.info("---------------{}-结束--------------", normalDate);
}
}
package cn.com.glsx.schedulerjob.task.modules.service;
import cn.com.glsx.Application;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.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;
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class InStoreSchedulerJobServiceTest {
@Autowired
InStoreSchedulerJobService inStoreSchedulerJobService;
@Test
void calculateInStoreDateEveryDay() {
System.out.println("inStoreSchedulerJobService start===");
inStoreSchedulerJobService.calculateInStoreDateEveryDay();
System.out.println("inStoreSchedulerJobService end===");
}
}
\ No newline at end of file
......@@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class MySimpleJobServiceTest {
@Autowired
MySimpleJobService mySimpleJobService;
private MySimpleJobService mySimpleJobService;
@Autowired
private StatisticsDriveClient statisticsDriveClient;
......@@ -47,4 +47,9 @@ class MySimpleJobServiceTest {
System.out.println("statisticsDriveR = " + JSON.toJSONString(statisticsDriveR));
}
@Test
public void test04() {
System.out.println("开始调用 ==== " + JSON.toJSONString(statisticsDriveClient));
mySimpleJobService.statisticsDriveDataEveryDay();
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!