1.下载参数增加下载类型字段

2.修改定时任务调用的下载方法
3.将定时任务数量减少为1个,下载开始时间为每天零点零五分,下载前一天数据
master
x_z 3 years ago
parent c9e8869907
commit e042abb746

@ -102,6 +102,7 @@ public class UdidlDeviceController {
if (null == deviceRequest) { if (null == deviceRequest) {
return ResultVOUtils.error(500, "下载参数不能为空"); return ResultVOUtils.error(500, "下载参数不能为空");
} }
deviceRequest.setDataType("manual"); //接口手动下载
deviceSyncService.downloadUdiData(deviceRequest); deviceSyncService.downloadUdiData(deviceRequest);
return ResultVOUtils.success("后台已经开始下载"); return ResultVOUtils.success("后台已经开始下载");
} }

@ -50,4 +50,7 @@ public class DeviceRequest {
@ApiModelProperty(value = "请求分页数,初始请求时,从 1 开始") @ApiModelProperty(value = "请求分页数,初始请求时,从 1 开始")
private String currentPageNumber; private String currentPageNumber;
@ApiModelProperty(value = "下载方式: auto自动 manual手动")
private String downloadType;
} }

@ -313,7 +313,12 @@ public class DeviceSyncService {
public void downloadUdi(int days) { public void downloadUdi(int days) {
for (int i = 1; i <= days; i++) { for (int i = 1; i <= days; i++) {
String day = DateUtil.getLastDay(-i); String day = DateUtil.getLastDay(-i);
downloadUdi(day, "auto"); DeviceRequest deviceRequest = new DeviceRequest();
deviceRequest.setRequestType("1"); //按天请求
deviceRequest.setRangeValue(day);
deviceRequest.setDownloadType("auto"); //下载方式
deviceRequest.setDataType("3"); //全量下载
downloadUdiData(deviceRequest);
} }
} }
@ -375,13 +380,14 @@ public class DeviceSyncService {
} }
log.info("开始下载国家UDI库数据"); log.info("开始下载国家UDI库数据");
redisUtil.set("开始下载时间", DateUtil.getDateTime()); log.info("本次任务开始下载时间:" + DateUtil.getDateTime());
for (String date : dates) { for (String date : dates) {
log.info("下载:" + date + " 的数据");
deviceRequest.setRangeValue(date); deviceRequest.setRangeValue(date);
//插入日志 //插入日志
JobLog jobLog = new JobLog(); JobLog jobLog = new JobLog();
jobLog.setDownloadType("manual"); jobLog.setDownloadType(deviceRequest.getDownloadType());
jobLog.setDownloadDate(DateUtil.parseDate(date)); jobLog.setDownloadDate(DateUtil.parseDate(date));
jobLog.setType("info"); jobLog.setType("info");
jobLog.setMsg("下载中"); jobLog.setMsg("下载中");
@ -421,8 +427,8 @@ public class DeviceSyncService {
jobLog.setInsertCount(0); jobLog.setInsertCount(0);
jobLogService.update(jobLog); jobLogService.update(jobLog);
} }
log.info(date + " 的数据下载完成");
} }
log.info("本次任务下载结束时间:" + DateUtil.getDateTime());
redisUtil.set("下载结束时间", DateUtil.getDateTime());
} }
} }

@ -1,15 +1,12 @@
package com.glxp.udidl.admin.thread; package com.glxp.udidl.admin.thread;
import com.glxp.udidl.admin.dao.info.ScheduledMapper; import com.glxp.udidl.admin.dao.info.ScheduledMapper;
import com.glxp.udidl.admin.entity.info.ScheduledEntity;
import com.glxp.udidl.admin.req.info.ScheduledRequest;
import com.glxp.udidl.admin.service.dataSync.DeviceSyncService; import com.glxp.udidl.admin.service.dataSync.DeviceSyncService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer; import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar; import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -27,7 +24,7 @@ public class DownloadTask2 implements SchedulingConfigurer {
@Override @Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
scheduledTaskRegistrar.addTriggerTask(() -> process(), /*scheduledTaskRegistrar.addTriggerTask(() -> process(),
triggerContext -> { triggerContext -> {
ScheduledRequest scheduledRequest = new ScheduledRequest(); ScheduledRequest scheduledRequest = new ScheduledRequest();
scheduledRequest.setCronName("downloadUdi2"); scheduledRequest.setCronName("downloadUdi2");
@ -37,7 +34,7 @@ public class DownloadTask2 implements SchedulingConfigurer {
logger.error("cron is null"); logger.error("cron is null");
} }
return new CronTrigger(cron).nextExecutionTime(triggerContext); return new CronTrigger(cron).nextExecutionTime(triggerContext);
}); });*/
} }
private void process() { private void process() {

Loading…
Cancel
Save