Commit 4729fda6 by xmh

<fix> 数据删除策略,删除时不删除大于等于今天的数据

<feat> 修改任务时添加多种日志
<fix> 修复 判断任务是否要重新构建 逻辑中可能出现的空指针异常
1 parent 42da1656
......@@ -93,6 +93,10 @@ public class PicKeepRunner {
" from information_schema.partitions\n" +
" where table_name = 'd_behavior'\n" +
" ) as ttt", Date.class);
if (minDate != null && minDate.after(DateUtil.setDayMaxTime(DateUtil.addDays(new Date(), -1)))) {
log.warn("磁盘空间使用达到阈值,但没有可以删除的数据");
return;
}
keep1(minDate);
log.info("磁盘空间使用达到阈值,需要删除:[{}]数据", DateUtil.format(DateUtil.FORMAT_LONG, minDate));
} else {
......
......@@ -85,7 +85,8 @@ public class OpsClientService {
String username = null;
if (requestAttributes != null) {
HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
username = URLDecoder.decode(request.getHeader("username"), "utf8");
username = request.getHeader("username");
username = username == null ? "" : URLDecoder.decode(username, "utf8");
}
LogVo logVo = new LogVo();
logVo.setUsername(username);
......
package com.viontech.fanxing.task.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
......@@ -134,14 +135,7 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic
for (int i = 1; i < sceneNum + 1; i++) {
Scene.Config config = new Scene.Config().setXml(xml);
Scene.PlayUrls playUrls = new Scene.PlayUrls();
Scene scene = new Scene()
.setPosition_num(String.valueOf(i))
.setPosition_name(String.valueOf(i))
.setVchan_refid(channelUnid)
.setScene_unid(UUID.randomUUID().toString())
.setAlgo_type(Integer.parseInt(algType))
.setConfig(config)
.setPlay_urls(playUrls);
Scene scene = new Scene().setPosition_num(String.valueOf(i)).setPosition_name(String.valueOf(i)).setVchan_refid(channelUnid).setScene_unid(UUID.randomUUID().toString()).setAlgo_type(Integer.parseInt(algType)).setConfig(config).setPlay_urls(playUrls);
if (streamPath.contains("http")) {
playUrls.setHttp(streamPath);
} else {
......@@ -178,9 +172,60 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic
boolean rebuild = TaskUtils.INSTANCE.needRebuild(originalTask, task);
taskDataService.updateTask(task, rebuild);
}
try {
compareAndAddLog(task, originalTask);
} catch (Exception e) {
logger.info("添加日志时出错", e);
}
return new TaskVo(task);
}
/**
* 判断 修改参数设置、修改区域设置、修改标定设置、修改时间设置、修改算法类型
*
* @param task
* @param originalTask
*/
private void compareAndAddLog(Task task, Task originalTask) {
if (!task.getRuntimeConf().equals(originalTask.getRuntimeConf())) {
opsClientService.addLog(String.format("[%s][%s]", task.getName(), "修改时间设置"));
}
if (!task.getAlgType().equals(originalTask.getAlgType())) {
opsClientService.addLog(String.format("[%s][%s]", task.getName(), "修改算法类型"));
}
JSONArray scenes = JSON.parseArray(task.getScene());
JSONArray originalScenes = JSON.parseArray(originalTask.getScene());
boolean paramModified = false;
boolean roiModified = false;
boolean calibrationModified = false;
for (int i = 0; i < scenes.size(); i++) {
for (int j = 0; j < originalScenes.size(); j++) {
JSONObject obj1 = scenes.getJSONObject(i);
JSONObject obj2 = originalScenes.getJSONObject(j);
if (obj1.getString("scene_unid").equals(obj2.getString("scene_unid"))) {
if (!obj1.getString("rois").equals(obj2.getString("rois"))) {
roiModified = true;
}
if (!obj1.getString("calibration").equals(obj2.getString("calibration"))) {
calibrationModified = true;
}
if (!obj1.getString("config").equals(obj2.getString("config"))) {
paramModified = true;
}
}
}
}
if (paramModified) {
opsClientService.addLog(String.format("[%s][%s]", task.getName(), "修改算法参数"));
}
if (roiModified) {
opsClientService.addLog(String.format("[%s][%s]", task.getName(), "修改区域设置"));
}
if (calibrationModified) {
opsClientService.addLog(String.format("[%s][%s]", task.getName(), "修改标定设置"));
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void removeTask(Long id) {
......
......@@ -23,6 +23,7 @@ import org.redisson.api.RMap;
import java.time.LocalTime;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
......@@ -51,10 +52,10 @@ public enum TaskUtils {
* @param present 现在的任务信息
*/
public boolean needRebuild(Task original, Task present) {
return (!original.getRuntimeConf().equals(present.getRuntimeConf()))
|| (!original.getStoreConfigId().equals(present.getStoreConfigId()))
|| (!original.getResourceNeed().equals(present.getResourceNeed()))
|| (!original.getVaType().equals(present.getVaType()));
return (!Objects.equals(original.getRuntimeConf(), equals(present.getRuntimeConf())))
|| (!Objects.equals(original.getStoreConfigId(), present.getStoreConfigId()))
|| (!Objects.equals(original.getResourceNeed(), present.getResourceNeed()))
|| (!Objects.equals(original.getVaType(), present.getVaType()));
}
public void checkRuntimeConf(TaskData taskData, VAServerService vaServerService, TaskDataService taskDataService) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!