|
@@ -0,0 +1,77 @@
|
|
|
+package com.jiayue.ipfcst.upload.job;
|
|
|
+
|
|
|
+
|
|
|
+import com.jiayue.ipfcst.common.data.util.CommonDataUtil;
|
|
|
+import com.jiayue.ipfcst.upload.constants.CacheConstant;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 读取本地文件定时
|
|
|
+ *
|
|
|
+ * @author xsl
|
|
|
+ * @version 3.0
|
|
|
+ * @since 2020/4/24 14:54
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+@EnableScheduling
|
|
|
+public class ReadLocalFileJob {
|
|
|
+
|
|
|
+ @Scheduled(fixedDelay = 10000)
|
|
|
+ public void execute() throws Exception {
|
|
|
+ log.info("读取镜像文件开始");
|
|
|
+
|
|
|
+ // 获取文件创建时间
|
|
|
+ if (CommonDataUtil.imageFileExist("ElectricField")) {
|
|
|
+ // 判断场站镜像是否改变
|
|
|
+ long ct = CommonDataUtil.getImageFileCreateTime("ElectricField");
|
|
|
+ if (CacheConstant.imageFileTimeMap.get("ElectricField").longValue() != ct) {
|
|
|
+ // 重启程序
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CommonDataUtil.imageFileExist("UploadObject")) {
|
|
|
+ // 判断场站镜像是否改变
|
|
|
+ long ct = CommonDataUtil.getImageFileCreateTime("UploadObject");
|
|
|
+ if (CacheConstant.imageFileTimeMap.get("UploadObject").longValue() != ct) {
|
|
|
+ // 重启程序
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CommonDataUtil.imageFileExist("UploadFileChannel")) {
|
|
|
+ // 判断场站镜像是否改变
|
|
|
+ long ct = CommonDataUtil.getImageFileCreateTime("UploadFileChannel");
|
|
|
+ if (CacheConstant.imageFileTimeMap.get("UploadFileChannel").longValue() != ct) {
|
|
|
+ // 重启程序
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CommonDataUtil.imageFileExist("UploadFileCode") && CacheConstant.imageFileTimeMap.get("UploadFileCode")!=null) {
|
|
|
+ long ct = CommonDataUtil.getImageFileCreateTime("UploadFileCode");
|
|
|
+ if (CacheConstant.imageFileTimeMap.get("UploadFileCode").longValue() != ct) {
|
|
|
+ // 重启程序
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (!CommonDataUtil.imageFileExist("UploadFileCode") && CacheConstant.imageFileTimeMap.get("UploadFileCode")!=null){
|
|
|
+ // 缓存有,镜像无,重启程序
|
|
|
+ }
|
|
|
+ else if (CommonDataUtil.imageFileExist("UploadFileCode") && CacheConstant.imageFileTimeMap.get("UploadFileCode")==null){
|
|
|
+ // 缓存无,镜像有,重启程序
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CommonDataUtil.imageFileExist("UploadURL") && CacheConstant.imageFileTimeMap.get("UploadURL")!=null) {
|
|
|
+ long ct = CommonDataUtil.getImageFileCreateTime("UploadURL");
|
|
|
+ if (CacheConstant.imageFileTimeMap.get("UploadURL").longValue() != ct) {
|
|
|
+ // 重启程序
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (!CommonDataUtil.imageFileExist("UploadURL") && CacheConstant.imageFileTimeMap.get("UploadURL")!=null){
|
|
|
+ // 缓存有,镜像无,重启程序
|
|
|
+ }
|
|
|
+ else if (CommonDataUtil.imageFileExist("UploadURL") && CacheConstant.imageFileTimeMap.get("UploadURL")==null){
|
|
|
+ // 缓存无,镜像有,重启程序
|
|
|
+ }
|
|
|
+ log.info("读取镜像文件结束");
|
|
|
+ }
|
|
|
+}
|