From e042abb746dfe7b59e2c67a2cc669da833f29fbd Mon Sep 17 00:00:00 2001 From: x_z Date: Wed, 22 Jun 2022 09:36:00 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=B8=8B=E8=BD=BD=E5=8F=82=E6=95=B0=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=8B=E8=BD=BD=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=202.=E4=BF=AE=E6=94=B9=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E7=9A=84=E4=B8=8B=E8=BD=BD=E6=96=B9=E6=B3=95?= =?UTF-8?q?=203.=E5=B0=86=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E5=87=8F=E5=B0=91=E4=B8=BA1=E4=B8=AA=EF=BC=8C?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4=E4=B8=BA?= =?UTF-8?q?=E6=AF=8F=E5=A4=A9=E9=9B=B6=E7=82=B9=E9=9B=B6=E4=BA=94=E5=88=86?= =?UTF-8?q?=EF=BC=8C=E4=B8=8B=E8=BD=BD=E5=89=8D=E4=B8=80=E5=A4=A9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/device/UdidlDeviceController.java | 1 + .../glxp/udidl/admin/req/udid/DeviceRequest.java | 3 +++ .../service/dataSync/DeviceSyncService.java | 16 +++++++++++----- .../glxp/udidl/admin/thread/DownloadTask2.java | 7 ++----- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/glxp/udidl/admin/controller/device/UdidlDeviceController.java b/src/main/java/com/glxp/udidl/admin/controller/device/UdidlDeviceController.java index 96e094e..036e4e1 100644 --- a/src/main/java/com/glxp/udidl/admin/controller/device/UdidlDeviceController.java +++ b/src/main/java/com/glxp/udidl/admin/controller/device/UdidlDeviceController.java @@ -102,6 +102,7 @@ public class UdidlDeviceController { if (null == deviceRequest) { return ResultVOUtils.error(500, "下载参数不能为空"); } + deviceRequest.setDataType("manual"); //接口手动下载 deviceSyncService.downloadUdiData(deviceRequest); return ResultVOUtils.success("后台已经开始下载"); } diff --git a/src/main/java/com/glxp/udidl/admin/req/udid/DeviceRequest.java b/src/main/java/com/glxp/udidl/admin/req/udid/DeviceRequest.java index e625eaa..8aafb89 100644 --- a/src/main/java/com/glxp/udidl/admin/req/udid/DeviceRequest.java +++ b/src/main/java/com/glxp/udidl/admin/req/udid/DeviceRequest.java @@ -50,4 +50,7 @@ public class DeviceRequest { @ApiModelProperty(value = "请求分页数,初始请求时,从 1 开始") private String currentPageNumber; + @ApiModelProperty(value = "下载方式: auto:自动 manual:手动") + private String downloadType; + } diff --git a/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceSyncService.java b/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceSyncService.java index 8730796..0d8d6df 100644 --- a/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceSyncService.java +++ b/src/main/java/com/glxp/udidl/admin/service/dataSync/DeviceSyncService.java @@ -313,7 +313,12 @@ public class DeviceSyncService { public void downloadUdi(int days) { for (int i = 1; i <= days; 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库数据"); - redisUtil.set("开始下载时间", DateUtil.getDateTime()); + log.info("本次任务开始下载时间:" + DateUtil.getDateTime()); for (String date : dates) { + log.info("下载:" + date + " 的数据"); deviceRequest.setRangeValue(date); //插入日志 JobLog jobLog = new JobLog(); - jobLog.setDownloadType("manual"); + jobLog.setDownloadType(deviceRequest.getDownloadType()); jobLog.setDownloadDate(DateUtil.parseDate(date)); jobLog.setType("info"); jobLog.setMsg("下载中"); @@ -421,8 +427,8 @@ public class DeviceSyncService { jobLog.setInsertCount(0); jobLogService.update(jobLog); } + log.info(date + " 的数据下载完成"); } - - redisUtil.set("下载结束时间", DateUtil.getDateTime()); + log.info("本次任务下载结束时间:" + DateUtil.getDateTime()); } } diff --git a/src/main/java/com/glxp/udidl/admin/thread/DownloadTask2.java b/src/main/java/com/glxp/udidl/admin/thread/DownloadTask2.java index e38f81f..51c657d 100644 --- a/src/main/java/com/glxp/udidl/admin/thread/DownloadTask2.java +++ b/src/main/java/com/glxp/udidl/admin/thread/DownloadTask2.java @@ -1,15 +1,12 @@ package com.glxp.udidl.admin.thread; 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 org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.SchedulingConfigurer; import org.springframework.scheduling.config.ScheduledTaskRegistrar; -import org.springframework.scheduling.support.CronTrigger; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -27,7 +24,7 @@ public class DownloadTask2 implements SchedulingConfigurer { @Override public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { - scheduledTaskRegistrar.addTriggerTask(() -> process(), + /*scheduledTaskRegistrar.addTriggerTask(() -> process(), triggerContext -> { ScheduledRequest scheduledRequest = new ScheduledRequest(); scheduledRequest.setCronName("downloadUdi2"); @@ -37,7 +34,7 @@ public class DownloadTask2 implements SchedulingConfigurer { logger.error("cron is null"); } return new CronTrigger(cron).nextExecutionTime(triggerContext); - }); + });*/ } private void process() {