From 9b00e3d2493fc4ae6f1281304e9668b43fefeb54 Mon Sep 17 00:00:00 2001 From: anthonyywj2 <353682448@qq.com> Date: Wed, 29 Jun 2022 15:04:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=B0=E6=8D=AE=E5=BB=B6?= =?UTF-8?q?=E6=97=B6=E5=90=8C=E6=AD=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/glxp/api/admin/constant/Constant.java | 2 ++ .../info/SyncDataSetController.java | 20 +++++++++++++++++-- .../admin/res/info/SyncDataSetResponse.java | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/api/admin/constant/Constant.java b/api-admin/src/main/java/com/glxp/api/admin/constant/Constant.java index f375074a..8ffeedf5 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/constant/Constant.java +++ b/api-admin/src/main/java/com/glxp/api/admin/constant/Constant.java @@ -19,4 +19,6 @@ public class Constant { public static String SPTM_TO_DI = "sptm_to_di"; + + public static String DELAY_SYNC_TIME = "DELAY_SYNC_TIME"; } diff --git a/api-admin/src/main/java/com/glxp/api/admin/controller/info/SyncDataSetController.java b/api-admin/src/main/java/com/glxp/api/admin/controller/info/SyncDataSetController.java index 88743d85..aafd2fef 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/controller/info/SyncDataSetController.java +++ b/api-admin/src/main/java/com/glxp/api/admin/controller/info/SyncDataSetController.java @@ -3,11 +3,13 @@ package com.glxp.api.admin.controller.info; import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSON; import com.glxp.api.admin.annotation.AuthRuleAnnotation; +import com.glxp.api.admin.constant.Constant; import com.glxp.api.admin.entity.info.SyncDataBustypeEntity; import com.glxp.api.admin.entity.info.SyncDataSetEntity; import com.glxp.api.admin.res.info.SyncDataSetResponse; import com.glxp.api.admin.service.info.SyncDataBustypeService; import com.glxp.api.admin.service.info.SyncDataSetService; +import com.glxp.api.admin.util.RedisUtil; import com.glxp.api.common.enums.ResultEnum; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; @@ -29,12 +31,22 @@ public class SyncDataSetController { private SyncDataSetService syncDataSetService; @Resource private SyncDataBustypeService syncDataBustypeService; + @Resource + private RedisUtil redisUtil; @AuthRuleAnnotation("system/param/syncData/config") @GetMapping("/system/param/syncData/config") public BaseResponse list() { - return ResultVOUtils.success(syncDataSetService.selectSet()); + + Integer delaySyncTime = (Integer) redisUtil.get(Constant.DELAY_SYNC_TIME); + if (delaySyncTime != null) { + long time = redisUtil.getExpire(Constant.DELAY_SYNC_TIME); + delaySyncTime = Math.toIntExact(time) / 60; + } + SyncDataSetResponse syncDataSetResponse = syncDataSetService.selectSet(); + syncDataSetResponse.setDelaySyncTime(delaySyncTime); + return ResultVOUtils.success(syncDataSetResponse); } @AuthRuleAnnotation("system/param/syncData/save") @@ -49,10 +61,14 @@ public class SyncDataSetController { syncDataBustypeService.inserts(busTypes); syncDataSetEntity.setBusTypes(null); boolean b = syncDataSetService.insert(syncDataSetEntity); + if (syncDataSetResponse.getDelaySyncTime() != null && + syncDataSetResponse.getDelaySyncTime() > 0) { + redisUtil.set(Constant.DELAY_SYNC_TIME, syncDataSetResponse.getDelaySyncTime(), (syncDataSetResponse.getDelaySyncTime() + 1) * 60); + redisUtil.set("SPS_SYNC_GEN_DATA", System.currentTimeMillis() + syncDataSetResponse.getDelaySyncTime() * 60 * 1000); + } if (!b) { return ResultVOUtils.error(ResultEnum.NOT_NETWORK); } return ResultVOUtils.success(); } - } diff --git a/api-admin/src/main/java/com/glxp/api/admin/res/info/SyncDataSetResponse.java b/api-admin/src/main/java/com/glxp/api/admin/res/info/SyncDataSetResponse.java index 2c6a146b..ed9f1517 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/res/info/SyncDataSetResponse.java +++ b/api-admin/src/main/java/com/glxp/api/admin/res/info/SyncDataSetResponse.java @@ -35,5 +35,6 @@ public class SyncDataSetResponse { private boolean entrustAction; private Integer orderSyncTime; private Integer orderSyncDlTime; + private Integer delaySyncTime; }