|
@@ -3,7 +3,9 @@ package com.jiayue.ipfcst.upload.job;
|
|
|
|
|
|
import com.jiayue.ipfcst.common.data.util.CommonDataUtil;
|
|
|
import com.jiayue.ipfcst.upload.constants.CacheConstant;
|
|
|
+import com.jiayue.ipfcst.upload.service.restart.RestartUploadService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -19,6 +21,8 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
@EnableScheduling
|
|
|
public class ReadLocalFileJob {
|
|
|
+ @Autowired
|
|
|
+ RestartUploadService restartUploadService;
|
|
|
|
|
|
@Scheduled(fixedDelay = 10000)
|
|
|
public void execute() throws Exception {
|
|
@@ -27,50 +31,59 @@ public class ReadLocalFileJob {
|
|
|
// 获取文件创建时间
|
|
|
if (CommonDataUtil.imageFileExist("ElectricField")) {
|
|
|
// 判断场站镜像是否改变
|
|
|
- long ct = CommonDataUtil.getImageFileCreateTime("ElectricField");
|
|
|
+ long ct = CommonDataUtil.getFileModifyTime("ElectricField");
|
|
|
if (CacheConstant.imageFileTimeMap.get("ElectricField").longValue() != ct) {
|
|
|
// 重启程序
|
|
|
+ restartUploadService.restart();
|
|
|
}
|
|
|
}
|
|
|
if (CommonDataUtil.imageFileExist("UploadObject")) {
|
|
|
// 判断场站镜像是否改变
|
|
|
- long ct = CommonDataUtil.getImageFileCreateTime("UploadObject");
|
|
|
+ long ct = CommonDataUtil.getFileModifyTime("UploadObject");
|
|
|
if (CacheConstant.imageFileTimeMap.get("UploadObject").longValue() != ct) {
|
|
|
// 重启程序
|
|
|
+ restartUploadService.restart();
|
|
|
}
|
|
|
}
|
|
|
if (CommonDataUtil.imageFileExist("UploadFileChannel")) {
|
|
|
// 判断场站镜像是否改变
|
|
|
- long ct = CommonDataUtil.getImageFileCreateTime("UploadFileChannel");
|
|
|
+ long ct = CommonDataUtil.getFileModifyTime("UploadFileChannel");
|
|
|
if (CacheConstant.imageFileTimeMap.get("UploadFileChannel").longValue() != ct) {
|
|
|
// 重启程序
|
|
|
+ restartUploadService.restart();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (CommonDataUtil.imageFileExist("UploadFileCode") && CacheConstant.imageFileTimeMap.get("UploadFileCode")!=null) {
|
|
|
- long ct = CommonDataUtil.getImageFileCreateTime("UploadFileCode");
|
|
|
+ long ct = CommonDataUtil.getFileModifyTime("UploadFileCode");
|
|
|
if (CacheConstant.imageFileTimeMap.get("UploadFileCode").longValue() != ct) {
|
|
|
// 重启程序
|
|
|
+ restartUploadService.restart();
|
|
|
}
|
|
|
}
|
|
|
else if (!CommonDataUtil.imageFileExist("UploadFileCode") && CacheConstant.imageFileTimeMap.get("UploadFileCode")!=null){
|
|
|
// 缓存有,镜像无,重启程序
|
|
|
+ restartUploadService.restart();
|
|
|
}
|
|
|
else if (CommonDataUtil.imageFileExist("UploadFileCode") && CacheConstant.imageFileTimeMap.get("UploadFileCode")==null){
|
|
|
// 缓存无,镜像有,重启程序
|
|
|
+ restartUploadService.restart();
|
|
|
}
|
|
|
|
|
|
if (CommonDataUtil.imageFileExist("UploadURL") && CacheConstant.imageFileTimeMap.get("UploadURL")!=null) {
|
|
|
- long ct = CommonDataUtil.getImageFileCreateTime("UploadURL");
|
|
|
+ long ct = CommonDataUtil.getFileModifyTime("UploadURL");
|
|
|
if (CacheConstant.imageFileTimeMap.get("UploadURL").longValue() != ct) {
|
|
|
// 重启程序
|
|
|
+ restartUploadService.restart();
|
|
|
}
|
|
|
}
|
|
|
else if (!CommonDataUtil.imageFileExist("UploadURL") && CacheConstant.imageFileTimeMap.get("UploadURL")!=null){
|
|
|
// 缓存有,镜像无,重启程序
|
|
|
+ restartUploadService.restart();
|
|
|
}
|
|
|
else if (CommonDataUtil.imageFileExist("UploadURL") && CacheConstant.imageFileTimeMap.get("UploadURL")==null){
|
|
|
// 缓存无,镜像有,重启程序
|
|
|
+ restartUploadService.restart();
|
|
|
}
|
|
|
log.info("读取镜像文件结束");
|
|
|
}
|