优化逻辑

This commit is contained in:
weitang 2025-05-14 15:14:59 +08:00
parent 7c3abcfa3e
commit 88ee5540d9
7 changed files with 45 additions and 37 deletions

View File

@ -76,6 +76,9 @@ public class AlgorithmClassController {
@PostMapping("/deleteAlgorithmClass") @PostMapping("/deleteAlgorithmClass")
@ApiOperation("删除算法分类") @ApiOperation("删除算法分类")
public ResponseResult deleteAlgorithmClass(String id) { public ResponseResult deleteAlgorithmClass(String id) {
if (StrUtil.isBlank(id)) {
return ResponseResult.error("算法分类id为空");
}
boolean isOK = algorithmClassService.deleteAlgorithmClass(id); boolean isOK = algorithmClassService.deleteAlgorithmClass(id);
if (isOK) { if (isOK) {
return ResponseResult.success(); return ResponseResult.success();

View File

@ -30,7 +30,7 @@ public interface IAlgorithmClassService extends IService<AlgorithmClass> {
boolean updateAlgorithmClass(AlgorithmClass algorithmClass); boolean updateAlgorithmClass(AlgorithmClass algorithmClass);
/********************************** /**********************************
* 用途说明: 新增算法分类 * 用途说明: 删除算法分类
* 参数说明 id 算法分类Id * 参数说明 id 算法分类Id
* 返回值说明: boolean 是否成功 * 返回值说明: boolean 是否成功
***********************************/ ***********************************/

View File

@ -3,6 +3,8 @@ package com.yfd.platform.modules.algorithm.service.impl;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass; import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
import com.yfd.platform.modules.algorithm.domain.AlgorithmParams; import com.yfd.platform.modules.algorithm.domain.AlgorithmParams;
import com.yfd.platform.modules.algorithm.domain.AlgorithmParamsRequest; import com.yfd.platform.modules.algorithm.domain.AlgorithmParamsRequest;
@ -55,13 +57,21 @@ public class AlgorithmClassServiceImpl extends ServiceImpl<AlgorithmClassMapper,
} }
/********************************** /**********************************
* 用途说明: 新增算法分类 * 用途说明: 删除算法分类
* 参数说明 id 算法分类Id * 参数说明 id 算法分类Id
* 返回值说明: boolean 是否成功 * 返回值说明: boolean 是否成功
***********************************/ ***********************************/
@Override @Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteAlgorithmClass(String id) { public boolean deleteAlgorithmClass(String id) {
return this.removeById(id); LambdaQueryWrapper<AlgorithmParams> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlgorithmParams::getAlgorithmId, id);
boolean remove = algorithmParamsService.remove(queryWrapper);
boolean b = this.removeById(id);
if (remove && b) {
return true;
}
throw new RuntimeException("删除错误");
} }
@Override @Override

View File

@ -105,6 +105,7 @@ public class AnalyseCallController {
result.put("code", SystemCode.REFUSE_STATUS_CODE.getCode()); result.put("code", SystemCode.REFUSE_STATUS_CODE.getCode());
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());; log.error(e.getMessage());;
result.put("code", "500"); result.put("code", "500");
} }

View File

@ -471,9 +471,6 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
JSONObject jsonObject = jsonArray.getJSONObject(0); JSONObject jsonObject = jsonArray.getJSONObject(0);
if (jsonObject.size() > 0) { if (jsonObject.size() > 0) {
posArray.addAll(jsonArray); posArray.addAll(jsonArray);
JSONArray areas = jsonObject.getJSONArray("areas");
JSONObject jsonObject1 = areas.getJSONObject(0);
JSONObject jsonObject2 = areas.getJSONObject(1);
} }
} }
@ -573,8 +570,9 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
// 只要存在异常就判定为异常 // 只要存在异常就判定为异常
taskResult.setFlag("2"); taskResult.setFlag("2");
taskResult.setValid("2"); taskResult.setValid("2");
SubstationDevice device = deviceMapper.selectById(taskResult.getDeviceId());
// 根据巡视点位判断是否生成报警 // 根据巡视点位判断是否生成报警
if ("1".equals(taskResult.getIsAlarm())) { if ("1".equals(device.getIsAlarm())) {
log.info("=========================生成报警记录===================="); log.info("=========================生成报警记录====================");
//生成报警记录 //生成报警记录
createTaskAlarmLog(taskResult, map); createTaskAlarmLog(taskResult, map);
@ -1774,12 +1772,17 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
//拷贝识别图到报警目录下 //拷贝识别图到报警目录下
if (ObjUtil.isNotEmpty(taskResult.getDefectFilePath())) { if (ObjUtil.isNotEmpty(taskResult.getDefectFilePath())) {
String fulldefectfilename = URLDecoder.decode(taskResult.getDefectFilePath(), "utf-8"); if (!taskResult.getFilePath().equals(taskResult.getDefectFilePath())) {
String alarmfilename = StrUtil.replace(StrUtil.subAfter(fulldefectfilename, "/", true), "识别", "缺陷告警"); String fulldefectfilename = URLDecoder.decode(taskResult.getDefectFilePath(), "utf-8");
String fullalarmfile = alarmfilepath + alarmfilename; String alarmfilename = StrUtil.replace(StrUtil.subAfter(fulldefectfilename, "/", true), "识别", "缺陷告警");
FileUtil.copy(Config.getSnapFilePath() + fulldefectfilename, Config.getAlarmFilePath() + fullalarmfile, String fullalarmfile = alarmfilepath + alarmfilename;
true); FileUtil.copy(Config.getSnapFilePath() + fulldefectfilename, Config.getAlarmFilePath() + fullalarmfile,
alarmLog.setDefectFilePath(URLEncoder.encode(fullalarmfile, "utf-8"));//标注了识别框和信息 true);
alarmLog.setDefectFilePath(URLEncoder.encode(fullalarmfile, "utf-8"));//标注了识别框和信息
} else {
alarmLog.setDefectFilePath(alarmLog.getFilePath());//标注了识别框和信息
}
} }
alarmLog.setValue(taskResult.getValue());//图形识别结果 alarmLog.setValue(taskResult.getValue());//图形识别结果
alarmLog.setUnit(taskResult.getUnit()); alarmLog.setUnit(taskResult.getUnit());
@ -1831,7 +1834,8 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
unit, taskResult.getDesc()); unit, taskResult.getDesc());
} }
if ("sound".equals(taskResult.getValueType())) { if ("sound".equals(taskResult.getValueType())) {
alarminfo = "声音检测异常,%s本次识别结果为[" + taskResult.getDesc() + "]"; // alarminfo = "声音检测异常,本次识别结果为[" + taskResult.getDesc() + "]";
alarminfo = String.format("声音检测异常,%s本次识别结果为[%s]", taskResult.getDeviceName(), taskResult.getDesc());
} }
String pictureAnalysisTypeList = device.getPictureAnalysisTypeList(); String pictureAnalysisTypeList = device.getPictureAnalysisTypeList();
if (StrUtil.isNotBlank(pictureAnalysisTypeList)) { if (StrUtil.isNotBlank(pictureAnalysisTypeList)) {

View File

@ -402,10 +402,10 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
} }
try { try {
String patroldeviceCode = map.get("patroldeviceCode").toString(); String patroldeviceCode = map.get("patroldeviceCode").toString();
voiceServerService.sendVoiceServerControl(patroldeviceCode, "ON", fullfilename); // voiceServerService.sendVoiceServerControl(patroldeviceCode, "ON", fullfilename);
FileUtil.copy("", config.getSnapFilePath() + fullfilename, true); FileUtil.copy("D:\\riis\\video\\sound.wav", config.getSnapFilePath() + fullfilename, true);
Thread.sleep(duration * 1000); Thread.sleep(duration * 1000);
voiceServerService.sendVoiceServerControl(patroldeviceCode, "OFF", fullfilename); // voiceServerService.sendVoiceServerControl(patroldeviceCode, "OFF", fullfilename);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -416,8 +416,8 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
fullfilename, "2"); fullfilename, "2");
System.out.println("customParams" + JSONUtil.toJsonStr(customParams)); System.out.println("customParams" + JSONUtil.toJsonStr(customParams));
callresult = httpUtil.callPicAnalyse(map.get("resultId").toString(), callresult = httpUtil.callPicAnalyse(map.get("taskTodoId").toString(),
map.get("deviceId").toString(), JSONUtil.toJsonStr(typelist), map.get("resultId").toString(), JSONUtil.toJsonStr(typelist),
JSONUtil.toJsonStr(customParams), encodefilename, analysePort); JSONUtil.toJsonStr(customParams), encodefilename, analysePort);
} else { } else {
@ -664,6 +664,7 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
} catch (Exception e) { } catch (Exception e) {
log.error(String.format("单条任务执行失败,任务名称:%s,时间:%s", jobName, DateUtil.now())); log.error(String.format("单条任务执行失败,任务名称:%s,时间:%s", jobName, DateUtil.now()));
e.printStackTrace();
log.error(e.getMessage());; log.error(e.getMessage());;
try { try {
// 解除摄像头的工作状态 // 解除摄像头的工作状态

View File

@ -1,25 +1,14 @@
package com.yfd.platform.utils; package com.yfd.platform.utils;
import java.util.regex.Matcher; import cn.hutool.core.io.FileUtil;
import java.util.regex.Pattern;
public class TestFileDir { public class TestFileDir {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
System.out.println("user.home = " + System.getProperty("user.home")); String filename = "d:\\riis\\alarm\\商丘市\\500Kv标准变电站管理区域\\500V变电站\\缺陷\\202505\\20250514_145108_500kV测试间隔_500kV" +
// //获取告警触发条件 "测试主设备_声纹点位.wav";
String str = "20<=value<50"; String filename1 = "d:\\riis\\alarm\\商丘市\\500Kv标准变电站管理区域\\510V变电站\\缺陷\\202505\\20250514_145108_500kV" +
// 定义正则表达式 "测试间隔_500kV" +
String regex = "(\\d+)\\s*((?:==?|!=|<=?|>=?))\\s*value\\s*((?:==?|!=|<=?|>=?))\\s*(\\d+)"; "测试主设备_声纹点位.wav";
Pattern pattern = Pattern.compile(regex); FileUtil.copy(filename, filename1,true);
Matcher matcher = pattern.matcher(str);
if (matcher.find()) {
String number1 = matcher.group(1); // 第一个数字
String operator1 = matcher.group(2); // 第一个比较符
String operator2 = matcher.group(3); // 第二个比较符
String number2 = matcher.group(4); // 第二个数字
System.out.printf("%s %s value %s %s%n", number1, operator1, operator2, number2);
}
System.out.println("");
} }
} }