|
@@ -6,7 +6,6 @@ import com.ruoyi.common.core.utils.SpringUtils;
|
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
|
import com.ruoyi.common.core.utils.uuid.IdUtils;
|
|
|
import com.ruoyi.common.redis.service.RedisService;
|
|
|
-import com.ruoyi.common.security.utils.SecurityUtils;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.domain.CentereventTDownloads;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.domain.CentereventTEventcatalogue;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.mapper.CentereventTEventcatalogueMapper;
|
|
@@ -21,10 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
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.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -57,6 +52,7 @@ public class ScheduleTaskUtil {
|
|
|
|
|
|
static final String DOWN_LOCK = "downlod:lock";
|
|
|
static final String VALUE_LOCK = "valueLock";
|
|
|
+
|
|
|
@Scheduled(cron = "0 10 0 * * ?")
|
|
|
//@GetMapping("/down")
|
|
|
public void runTask() throws Exception {
|
|
@@ -68,59 +64,58 @@ public class ScheduleTaskUtil {
|
|
|
if (StringUtils.isBlank(lock)) {
|
|
|
redis.setCacheObject(DOWN_LOCK, VALUE_LOCK);
|
|
|
List<CentereventTEventcatalogue> eventcatalogues = centereventTEventcatalogueMapper.getbeforedateDownload();
|
|
|
- for (CentereventTEventcatalogue eventcatalogue : eventcatalogues){
|
|
|
- String busIndex = "bus_indx_other";// 其他
|
|
|
- if ("1".equals(eventcatalogue.getEventType())) {
|
|
|
- busIndex = "bus_indx_forest";// 火情
|
|
|
- }
|
|
|
- String uuid = IdUtils.simpleUUID();
|
|
|
- R result = remoteMonitorService.getPlaybackByTime(uuid, busIndex, eventcatalogue.getCreateBy(),
|
|
|
- DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.subtractTime(eventcatalogue.getReportTime(), -2)),
|
|
|
- DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.subtractTime(eventcatalogue.getReportTime(), 1)));
|
|
|
- if (200 == result.getCode()) {
|
|
|
- //成功
|
|
|
- CentereventTFireLog centereventTFireLog = new CentereventTFireLog();
|
|
|
- centereventTFireLog.setId(uuid);
|
|
|
- centereventTFireLog.setEventCode(eventcatalogue.getEventCode());
|
|
|
- centereventTFireLog.setLogContent(SecurityUtils.getLoginUser().getSysUser().getNickName() + "下载该事件视频。");
|
|
|
- centereventTFireLog.setOperation("bus_oper_type_1");
|
|
|
- centereventTFireLog.setOperationType("log_oper_type_1");
|
|
|
- centereventTFireLogService.insertCentereventTFireLog(centereventTFireLog);
|
|
|
- CentereventTDownloads centereventTDownloads=new CentereventTDownloads();
|
|
|
- centereventTDownloads.setId(IdUtils.simpleUUID());
|
|
|
- centereventTDownloads.setEventCode(eventcatalogue.getEventCode());
|
|
|
- centereventTDownloads.setEventName(eventcatalogue.getEventName());
|
|
|
- centereventTDownloads.setLogId(uuid);
|
|
|
- centereventTDownloadsService.insertCentereventTDownloads(centereventTDownloads);
|
|
|
- //TimeUnit.MINUTES.sleep(5);//延时5分钟在调取
|
|
|
- Thread.sleep(300000);
|
|
|
- }else{
|
|
|
- //失败
|
|
|
- CentereventTDownloads centereventTDownloads=new CentereventTDownloads();
|
|
|
- centereventTDownloads.setId(IdUtils.simpleUUID());
|
|
|
- centereventTDownloads.setEventCode(eventcatalogue.getEventCode());
|
|
|
- centereventTDownloads.setEventName(eventcatalogue.getEventName());
|
|
|
- centereventTDownloads.setFlag("0");
|
|
|
- centereventTDownloads.setReason(result.getMsg());//失败原因
|
|
|
- centereventTDownloadsService.insertCentereventTDownloads(centereventTDownloads);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- //视频下载日志表 视频下载成功 定时任务结束回调,检验是否真的成功
|
|
|
- List<CentereventTDownloads> downloadsList= centereventTDownloadsService.validDownloadIs();
|
|
|
- for (CentereventTDownloads down:downloadsList){
|
|
|
- if(StringUtils.isNotEmpty(down.getAttachPath())){
|
|
|
- down.setFlag("1");
|
|
|
- down.setPath(down.getAttachPath());
|
|
|
- }else{
|
|
|
- down.setFlag("0");
|
|
|
- down.setReason("视频在下载过程中失败!");
|
|
|
- }
|
|
|
- centereventTDownloadsService.updateCentereventTDownloads(down);
|
|
|
- }
|
|
|
+ for (CentereventTEventcatalogue eventcatalogue : eventcatalogues) {
|
|
|
+ String busIndex = "bus_indx_other";// 其他
|
|
|
+ if ("1".equals(eventcatalogue.getEventType())) {
|
|
|
+ busIndex = "bus_indx_forest";// 火情
|
|
|
+ }
|
|
|
+ String uuid = IdUtils.simpleUUID();
|
|
|
+ R result = remoteMonitorService.getPlaybackByTime(uuid, busIndex, eventcatalogue.getCreateBy(),
|
|
|
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.subtractTime(eventcatalogue.getReportTime(), -2)),
|
|
|
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.subtractTime(eventcatalogue.getReportTime(), 1)));
|
|
|
+ if (200 == result.getCode()) {
|
|
|
+ //成功
|
|
|
+ CentereventTFireLog centereventTFireLog = new CentereventTFireLog();
|
|
|
+ centereventTFireLog.setId(uuid);
|
|
|
+ centereventTFireLog.setEventCode(eventcatalogue.getEventCode());
|
|
|
+ centereventTFireLog.setLogContent("系统管理员下载该事件视频。");
|
|
|
+ centereventTFireLog.setOperation("bus_oper_type_1");
|
|
|
+ centereventTFireLog.setOperationType("log_oper_type_1");
|
|
|
+ centereventTFireLogService.insertCentereventTFireLog(centereventTFireLog);
|
|
|
+ CentereventTDownloads centereventTDownloads = new CentereventTDownloads();
|
|
|
+ centereventTDownloads.setId(IdUtils.simpleUUID());
|
|
|
+ centereventTDownloads.setEventCode(eventcatalogue.getEventCode());
|
|
|
+ centereventTDownloads.setEventName(eventcatalogue.getEventName());
|
|
|
+ centereventTDownloads.setLogId(uuid);
|
|
|
+ centereventTDownloadsService.insertCentereventTDownloads(centereventTDownloads);
|
|
|
+ //TimeUnit.MINUTES.sleep(5);//延时5分钟在调取
|
|
|
+ Thread.sleep(300000);
|
|
|
+ } else {
|
|
|
+ //失败
|
|
|
+ CentereventTDownloads centereventTDownloads = new CentereventTDownloads();
|
|
|
+ centereventTDownloads.setId(IdUtils.simpleUUID());
|
|
|
+ centereventTDownloads.setEventCode(eventcatalogue.getEventCode());
|
|
|
+ centereventTDownloads.setEventName(eventcatalogue.getEventName());
|
|
|
+ centereventTDownloads.setFlag("0");
|
|
|
+ centereventTDownloads.setReason(result.getMsg());//失败原因
|
|
|
+ centereventTDownloadsService.insertCentereventTDownloads(centereventTDownloads);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //视频下载日志表 视频下载成功 定时任务结束回调,检验是否真的成功
|
|
|
+ List<CentereventTDownloads> downloadsList = centereventTDownloadsService.validDownloadIs();
|
|
|
+ for (CentereventTDownloads down : downloadsList) {
|
|
|
+ if (StringUtils.isNotEmpty(down.getAttachPath())) {
|
|
|
+ down.setFlag("1");
|
|
|
+ down.setPath(down.getAttachPath());
|
|
|
+ } else {
|
|
|
+ down.setFlag("0");
|
|
|
+ down.setReason("视频在下载过程中失败!");
|
|
|
+ }
|
|
|
+ centereventTDownloadsService.updateCentereventTDownloads(down);
|
|
|
+ }
|
|
|
}
|
|
|
//redis.deleteObject(DOWN_LOCK);
|
|
|
- redis.setCacheObject(DOWN_LOCK, (System.currentTimeMillis() -startMill) ,(long) 3600 * 12, TimeUnit.SECONDS);
|
|
|
+ redis.setCacheObject(DOWN_LOCK, (System.currentTimeMillis() - startMill), (long) 3600 * 12, TimeUnit.SECONDS);
|
|
|
logger.info("执行定时任务结束=====>{}", DateUtils.dateTimeNow());
|
|
|
}
|
|
|
}
|