|
@@ -1,6 +1,5 @@
|
|
|
package com.sooka.sponest.data.utils;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.ruoyi.common.core.utils.DateUtils;
|
|
|
import com.ruoyi.common.core.utils.SpringUtils;
|
|
|
import com.ruoyi.common.core.utils.file.FilePrefixUtils;
|
|
@@ -8,8 +7,6 @@ import com.ruoyi.common.redis.service.RedisService;
|
|
|
import com.ruoyi.system.api.RemoteConfigService;
|
|
|
import com.ruoyi.system.api.RemoteFileService;
|
|
|
import com.ruoyi.system.api.domain.SysFile;
|
|
|
-import com.sooka.sponest.data.system.attach.domain.CenterdataTAttach;
|
|
|
-import com.sooka.sponest.data.system.attach.mapper.CenterdataTAttachMapper;
|
|
|
import com.sooka.sponest.data.system.attach.service.ICenterdataTAttachService;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
import org.apache.commons.fileupload.FileItem;
|
|
@@ -21,8 +18,6 @@ import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
@@ -39,6 +34,7 @@ import java.util.Map;
|
|
|
//@RestController
|
|
|
//@RequestMapping("/testattach")
|
|
|
public class ScheduleAtachUtil {
|
|
|
+
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
@Autowired
|
|
@@ -46,40 +42,47 @@ public class ScheduleAtachUtil {
|
|
|
@Resource
|
|
|
private RedisService redisService;
|
|
|
|
|
|
-
|
|
|
+ // 文件前缀
|
|
|
+ public static final String FILE_PREFIX_LOCAL = "fileUrl";
|
|
|
+ public static final String FILE_PREFIX_APP = "appUrl";
|
|
|
+ public static final String FILE_PREFIX_HIK1 = "HIK_1";
|
|
|
+ public static final String FILE_PREFIX_HIK2 = "HIK_2";
|
|
|
+ public static final String FILE_PREFIX_DH1 = "DH_1";
|
|
|
+ public static final String FILE_PREFIX_DH2 = "DH_2";
|
|
|
+ public static final String FILE_DOWNLOAD = "downloadUrl";
|
|
|
|
|
|
@GetMapping("/attach")
|
|
|
public void runAtach() throws Exception {
|
|
|
logger.info("执行定时任务大华图片本地上传开始=>{}", DateUtils.dateTimeNow());
|
|
|
- Map<String, String> paramMap = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigMap(Arrays.asList(EventConstants.FILE_PREFIX_LOCAL, EventConstants.FILE_PREFIX_HIK1, EventConstants.FILE_PREFIX_HIK2, EventConstants.FILE_PREFIX_DH1, EventConstants.FILE_PREFIX_DH2)).getData();
|
|
|
+ Map<String, String> paramMap = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigMap(Arrays.asList(FILE_PREFIX_LOCAL, FILE_PREFIX_HIK1, FILE_PREFIX_HIK2, FILE_PREFIX_DH1, FILE_PREFIX_DH2)).getData();
|
|
|
//paramMap.put("token", redisService.getCacheObject("DH_TOKEN"));// 大华token
|
|
|
List<Map<String, Object>> list = centerdataTAttachService.selectFailUpattah();
|
|
|
int i = 0;
|
|
|
for (Map map : list) {
|
|
|
paramMap.put("czlx", "AI");
|
|
|
paramMap.put("busId", MapUtils.getString(map, "busId"));
|
|
|
- logger.info("event_name-------------->"+MapUtils.getString(map, "event_name"));
|
|
|
- logger.info("create_time-------------->"+MapUtils.getString(map, "create_time"));
|
|
|
+ logger.info("event_name-------------->" + MapUtils.getString(map, "event_name"));
|
|
|
+ logger.info("create_time-------------->" + MapUtils.getString(map, "create_time"));
|
|
|
logger.info("==================>大华图片远程接口之前" + MapUtils.getString(map, "busId") + "当前序号" + i);
|
|
|
centerdataTAttachService.updateEventAttach(paramMap);
|
|
|
logger.info("延时1分钟");
|
|
|
i++;
|
|
|
-
|
|
|
}
|
|
|
logger.info("执行定时任务大华图片本地上传结束=====>{}", DateUtils.dateTimeNow());
|
|
|
}
|
|
|
+
|
|
|
//每周的周日晚上8点开始运行
|
|
|
@Scheduled(cron = "* * 20 ? * 1")
|
|
|
@GetMapping("/urlToMultipartFile")
|
|
|
- public void urlToMultipartFile() throws Exception{
|
|
|
+ public void urlToMultipartFile() throws Exception {
|
|
|
logger.info("执行定时任务大华图片本地上传开始=>{}", DateUtils.dateTimeNow());
|
|
|
- Map<String, String> paramMap = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigMap(Arrays.asList(EventConstants.FILE_PREFIX_LOCAL, EventConstants.FILE_PREFIX_HIK1, EventConstants.FILE_PREFIX_HIK2, EventConstants.FILE_PREFIX_DH1, EventConstants.FILE_PREFIX_DH2)).getData();
|
|
|
+ Map<String, String> paramMap = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigMap(Arrays.asList(FILE_PREFIX_LOCAL, FILE_PREFIX_HIK1, FILE_PREFIX_HIK2, FILE_PREFIX_DH1, FILE_PREFIX_DH2)).getData();
|
|
|
List<Map<String, Object>> attaches = centerdataTAttachService.selectFailUpattah();
|
|
|
logger.info("此次需要更新的图片的总数==================>" + attaches.size());
|
|
|
int i = 0;
|
|
|
for (Map<String, Object> item : attaches) {
|
|
|
- logger.info("event_name-------------->"+MapUtils.getString(item, "event_name"));
|
|
|
- logger.info("create_time-------------->"+MapUtils.getString(item, "create_time"));
|
|
|
+ logger.info("event_name-------------->" + MapUtils.getString(item, "event_name"));
|
|
|
+ logger.info("create_time-------------->" + MapUtils.getString(item, "create_time"));
|
|
|
logger.info("busId==================>" + MapUtils.getString(item, "busId") + "当前序号" + i);
|
|
|
paramMap.put("token", redisService.getCacheObject("DH_TOKEN"));// 大华token
|
|
|
File file = null;
|
|
@@ -127,9 +130,8 @@ public class ScheduleAtachUtil {
|
|
|
centerdataTAttachService.updateEventAttachSchedule(item, sysFile);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
public static File inputStreamToFile(InputStream ins, String name) {
|
|
|
File file = new File(System.getProperty("java.io.tmpdir") + File.separator + name);
|
|
|
int len = 8192;
|
|
@@ -153,6 +155,7 @@ public class ScheduleAtachUtil {
|
|
|
}
|
|
|
return file;
|
|
|
}
|
|
|
+
|
|
|
public static MultipartFile fileToMultipartFile(File file) {
|
|
|
DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(16, null);
|
|
|
FileItem item = diskFileItemFactory.createItem(file.getName(), "text/plain", true, file.getName());
|
|
@@ -179,5 +182,4 @@ public class ScheduleAtachUtil {
|
|
|
}
|
|
|
return new CommonsMultipartFile(item);
|
|
|
}
|
|
|
-
|
|
|
}
|