Commit 97591d73 by xmh

1. 修复录像文件大小小于1mb时显示不正确的bug

2. 完善 任务随机执行 的逻辑:只有在调用启动任务接口时才会执行,其他时候一律不执行
1 parent b9b5d5af
...@@ -50,7 +50,7 @@ public class VideoService { ...@@ -50,7 +50,7 @@ public class VideoService {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void uploadVideo(List<MultipartFile> files, List<String> tags) { public void uploadVideo(List<MultipartFile> files, List<String> tags) {
DecimalFormat decimalFormat = new DecimalFormat(".00"); DecimalFormat decimalFormat = new DecimalFormat("0.00");
for (MultipartFile file : files) { for (MultipartFile file : files) {
String originalFilename = file.getOriginalFilename(); String originalFilename = file.getOriginalFilename();
String basePath = vionConfig.getImage().getPath() + File.separator + "uploadVideo" + File.separator; String basePath = vionConfig.getImage().getPath() + File.separator + "uploadVideo" + File.separator;
...@@ -103,7 +103,7 @@ public class VideoService { ...@@ -103,7 +103,7 @@ public class VideoService {
*/ */
@LocalCache(value = "video_overView", duration = 20, timeunit = TimeUnit.SECONDS) @LocalCache(value = "video_overView", duration = 20, timeunit = TimeUnit.SECONDS)
public JSONObject overview() { public JSONObject overview() {
DecimalFormat decimalFormat = new DecimalFormat(".00"); DecimalFormat decimalFormat = new DecimalFormat("0.00");
ChannelExample channelExample = new ChannelExample(); ChannelExample channelExample = new ChannelExample();
channelExample.createCriteria().andTypeEqualTo(ChannelType.FILE.value); channelExample.createCriteria().andTypeEqualTo(ChannelType.FILE.value);
channelExample.createColumns().hasExpandColumn(); channelExample.createColumns().hasExpandColumn();
......
...@@ -2,14 +2,15 @@ package com.viontech.fanxing.task.model.runtime; ...@@ -2,14 +2,15 @@ package com.viontech.fanxing.task.model.runtime;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.model.Task;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutablePair;
import java.util.concurrent.TimeUnit;
/** /**
* . * 随机执行,只有在调用 启动任务 接口的时候调用一次
* *
* @author 谢明辉 * @author 谢明辉
* @date 2021/10/27 * @date 2021/10/27
...@@ -20,6 +21,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair; ...@@ -20,6 +21,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
@Setter @Setter
public class RandomRuntimeConfig implements RuntimeConfig { public class RandomRuntimeConfig implements RuntimeConfig {
/** 运行多长时间,单位分钟 */
private Long runningTime; private Long runningTime;
public RandomRuntimeConfig(String runtimeConf) { public RandomRuntimeConfig(String runtimeConf) {
...@@ -31,6 +33,8 @@ public class RandomRuntimeConfig implements RuntimeConfig { ...@@ -31,6 +33,8 @@ public class RandomRuntimeConfig implements RuntimeConfig {
@Override @Override
public ImmutablePair<Long, Long> getNextTimeOfExecutionAndTerminal() { public ImmutablePair<Long, Long> getNextTimeOfExecutionAndTerminal() {
// todo // todo
long running = TimeUnit.MINUTES.toMillis(runningTime);
return ImmutablePair.nullPair(); return ImmutablePair.nullPair();
} }
} }
...@@ -39,6 +39,10 @@ public class TaskInitRunner implements CommandLineRunner { ...@@ -39,6 +39,10 @@ public class TaskInitRunner implements CommandLineRunner {
List<Task> tasks = taskMapper.selectByExampleWithBLOBs(new TaskExample()); List<Task> tasks = taskMapper.selectByExampleWithBLOBs(new TaskExample());
for (Task task : tasks) { for (Task task : tasks) {
// 随机任务只有 启动接口 可以启动,暂停状态说明运行完了
if (task.getRuntimeType().equals(3) && task.getStatus() == TaskStatus.PAUSE.val) {
continue;
}
// scene和storage不为空,不处于未部署状态 // scene和storage不为空,不处于未部署状态
if (StringUtils.isNotBlank(task.getScene()) && task.getStoreConfigId() != null && !TaskStatus.AWAIT.valEqual(task.getStatus())) { if (StringUtils.isNotBlank(task.getScene()) && task.getStoreConfigId() != null && !TaskStatus.AWAIT.valEqual(task.getStatus())) {
try { try {
......
...@@ -78,10 +78,10 @@ public class TaskRunner { ...@@ -78,10 +78,10 @@ public class TaskRunner {
continue; continue;
} }
} }
if (temp.getAvailableResources() > resourceNeed) { if (temp.getAvailableResources() >= resourceNeed) {
devLock = vaServerService.getVaServerRedisRepository().getDevLock(devId); devLock = vaServerService.getVaServerRedisRepository().getDevLock(devId);
temp = vaServerMap.get(devId); temp = vaServerMap.get(devId);
if (temp.getAvailableResources() > resourceNeed) { if (temp.getAvailableResources() >= resourceNeed) {
server = temp; server = temp;
break; break;
} else { } else {
...@@ -137,7 +137,10 @@ public class TaskRunner { ...@@ -137,7 +137,10 @@ public class TaskRunner {
boolean success = vaServerService.terminateTask(taskUnid); boolean success = vaServerService.terminateTask(taskUnid);
if (success) { if (success) {
taskService.updateStatus(taskData.getTask().getId(), TaskStatus.PAUSE.val); taskService.updateStatus(taskData.getTask().getId(), TaskStatus.PAUSE.val);
boolean b = taskDataService.distributeTask(taskData); // 随机任务不进行部署
if (taskData.getTask().getRuntimeType() != TaskStatus.PAUSE.val) {
boolean b = taskDataService.distributeTask(taskData);
}
} }
set.remove(taskUnid); set.remove(taskUnid);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!