提交系统逻辑

This commit is contained in:
weitang 2025-05-17 14:50:03 +08:00
parent 5302d8208b
commit bc05013751
14 changed files with 213 additions and 114 deletions

View File

@ -1120,7 +1120,7 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
alarmLog.setAlarmType(ObjUtil.isNotEmpty(map.get("alarmtype")) ? map.get("alarmtype").toString() : ""); alarmLog.setAlarmType(ObjUtil.isNotEmpty(map.get("alarmtype")) ? map.get("alarmtype").toString() : "");
//'字典表<1>: = 超温报警<2>: = 温升报警<3>: = 三相温差报警<4>: = 三相对比报警<5>: = 声音异常<6>: = 外观异常<7>: = 仪表越限报警<8>: = 仪表超量程报警<9>: = //'字典表<1>: = 超温报警<2>: = 温升报警<3>: = 三相温差报警<4>: = 三相对比报警<5>: = 声音异常<6>: = 外观异常<7>: = 仪表越限报警<8>: = 仪表超量程报警<9>: =
// 仪表三相对比<10>: = 变位报警', // 仪表三相对比<10>: = 变位报警',
alarmLog.setAlarmLevel(ObjUtil.isNotEmpty(map.get("alarmlevel")) ? map.get("alarmlevel").toString() : "4");// alarmLog.setAlarmLevel(ObjUtil.isNotEmpty(map.get("alarmlevel")) ? map.get("alarmlevel").toString() : "3");//
// '1:预警2:一般3:严重4;危急', 待判断细分 // '1:预警2:一般3:严重4;危急', 待判断细分
alarmLog.setRecognitionType(taskResult.getRecognitionType());//'1:表计读取2:位置状态识别3:设备外观查看4:红外测温5:声音检测6 alarmLog.setRecognitionType(taskResult.getRecognitionType());//'1:表计读取2:位置状态识别3:设备外观查看4:红外测温5:声音检测6
// :闪烁检测11:局放超声波检测12:局放地电压检测13:局放特高频检测101:环境温度检测102:环境湿度检测103:氧气浓度检测104SF6浓度检测', // :闪烁检测11:局放超声波检测12:局放地电压检测13:局放特高频检测101:环境温度检测102:环境湿度检测103:氧气浓度检测104SF6浓度检测',

View File

@ -1,14 +1,17 @@
package com.yfd.platform.modules.algorithm.service.impl; package com.yfd.platform.modules.algorithm.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yfd.platform.modules.algorithm.domain.AlgorithmClassComponent;
import com.yfd.platform.modules.algorithm.mapper.AlgorithmClassComponentMapper;
import com.yfd.platform.modules.algorithm.service.IAlgorithmClassComponentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.bcel.generic.LADD; import com.yfd.platform.modules.algorithm.domain.AlgorithmClassComponent;
import com.yfd.platform.modules.algorithm.domain.AlgorithmDevice;
import com.yfd.platform.modules.algorithm.mapper.AlgorithmClassComponentMapper;
import com.yfd.platform.modules.algorithm.mapper.AlgorithmDeviceMapper;
import com.yfd.platform.modules.algorithm.service.IAlgorithmClassComponentService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
/** /**
@ -23,6 +26,9 @@ import java.util.List;
public class AlgorithmClassComponentServiceImpl extends ServiceImpl<AlgorithmClassComponentMapper, public class AlgorithmClassComponentServiceImpl extends ServiceImpl<AlgorithmClassComponentMapper,
AlgorithmClassComponent> implements IAlgorithmClassComponentService { AlgorithmClassComponent> implements IAlgorithmClassComponentService {
@Resource
private AlgorithmDeviceMapper algorithmDeviceMapper;
/********************************** /**********************************
* 用途说明: 算法关联主设备部件 * 用途说明: 算法关联主设备部件
* 参数说明 algorithmId 算法分类id * 参数说明 algorithmId 算法分类id
@ -45,6 +51,16 @@ public class AlgorithmClassComponentServiceImpl extends ServiceImpl<AlgorithmCla
***********************************/ ***********************************/
@Override @Override
public boolean deleteAlgorithmClassComponent(String id) { public boolean deleteAlgorithmClassComponent(String id) {
AlgorithmClassComponent algorithmClassComponent = this.getById(id);
String algorithmId = algorithmClassComponent.getAlgorithmId();
String componentId = algorithmClassComponent.getComponentId();
if (StrUtil.isNotBlank(algorithmId) && StrUtil.isNotBlank(componentId)) {
LambdaQueryWrapper<AlgorithmDevice> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlgorithmDevice::getAlgorithmId, algorithmId).eq(AlgorithmDevice::getComponentId,
componentId);
algorithmDeviceMapper.delete(queryWrapper);
}
return this.removeById(id); return this.removeById(id);
} }

View File

@ -69,9 +69,12 @@ public class AlgorithmClassServiceImpl extends ServiceImpl<AlgorithmClassMapper,
public boolean deleteAlgorithmClass(String id) { public boolean deleteAlgorithmClass(String id) {
LambdaQueryWrapper<AlgorithmParams> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AlgorithmParams> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlgorithmParams::getAlgorithmId, id); queryWrapper.eq(AlgorithmParams::getAlgorithmId, id);
boolean remove = algorithmParamsService.remove(queryWrapper); boolean removeDevice =
algorithmDeviceService.remove(new LambdaQueryWrapper<AlgorithmDevice>().eq(AlgorithmDevice::getAlgorithmId, id));
algorithmClassComponentMapper.delete(new LambdaQueryWrapper<AlgorithmClassComponent>().eq(AlgorithmClassComponent::getAlgorithmId, id));
boolean removeParams = algorithmParamsService.remove(queryWrapper);
boolean b = this.removeById(id); boolean b = this.removeById(id);
if (remove && b) { if (removeDevice && b && removeParams) {
return true; return true;
} }
throw new RuntimeException("删除错误"); throw new RuntimeException("删除错误");

View File

@ -1,14 +1,19 @@
package com.yfd.platform.modules.algorithm.service.impl; package com.yfd.platform.modules.algorithm.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass; import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
import com.yfd.platform.modules.algorithm.domain.AlgorithmClassComponent;
import com.yfd.platform.modules.algorithm.domain.AlgorithmDevice;
import com.yfd.platform.modules.algorithm.domain.AlgorithmParams; import com.yfd.platform.modules.algorithm.domain.AlgorithmParams;
import com.yfd.platform.modules.algorithm.mapper.AlgorithmClassMapper; import com.yfd.platform.modules.algorithm.mapper.AlgorithmClassMapper;
import com.yfd.platform.modules.algorithm.mapper.AlgorithmDeviceMapper;
import com.yfd.platform.modules.algorithm.mapper.AlgorithmParamsMapper; import com.yfd.platform.modules.algorithm.mapper.AlgorithmParamsMapper;
import com.yfd.platform.modules.algorithm.service.IAlgorithmParamsService; import com.yfd.platform.modules.algorithm.service.IAlgorithmParamsService;
import com.yfd.platform.utils.HttpRESTfulUtils; import com.yfd.platform.utils.HttpRESTfulUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap; import java.util.HashMap;
@ -24,12 +29,16 @@ import java.util.Map;
* @since 2025-05-13 * @since 2025-05-13
*/ */
@Service @Service
@Transactional
public class AlgorithmParamsServiceImpl extends ServiceImpl<AlgorithmParamsMapper, AlgorithmParams> implements IAlgorithmParamsService { public class AlgorithmParamsServiceImpl extends ServiceImpl<AlgorithmParamsMapper, AlgorithmParams> implements IAlgorithmParamsService {
@Resource @Resource
private AlgorithmParamsMapper algorithmParamsMapper; private AlgorithmParamsMapper algorithmParamsMapper;
@Resource @Resource
private AlgorithmClassMapper algorithmClassMapper; private AlgorithmClassMapper algorithmClassMapper;
@Resource
private AlgorithmDeviceMapper algorithmDeviceMapper;
@Resource @Resource
private HttpRESTfulUtils httpRESTfulUtils; private HttpRESTfulUtils httpRESTfulUtils;
@ -53,8 +62,12 @@ public class AlgorithmParamsServiceImpl extends ServiceImpl<AlgorithmParamsMappe
return this.saveOrUpdateBatch(algorithmParamsList); return this.saveOrUpdateBatch(algorithmParamsList);
} }
@Transactional(rollbackFor = Exception.class)
@Override @Override
public boolean deleteAlgorithmParams(String id) { public boolean deleteAlgorithmParams(String id) {
LambdaQueryWrapper<AlgorithmDevice> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlgorithmDevice::getParamId, id);
algorithmDeviceMapper.delete(queryWrapper);
return this.removeById(id); return this.removeById(id);
} }

View File

@ -109,6 +109,7 @@ public class SubstationPatroldeviceController {
String ids = jsonObject.getStr("ids"); String ids = jsonObject.getStr("ids");
String manufacturer = jsonObject.getStr("manufacturer"); String manufacturer = jsonObject.getStr("manufacturer");
String flag = jsonObject.getStr("flag"); String flag = jsonObject.getStr("flag");
String online = jsonObject.getStr("online");
SysUser userInfo = userService.getUserInfo(); SysUser userInfo = userService.getUserInfo();
Integer usertype = userInfo.getUsertype(); Integer usertype = userInfo.getUsertype();
LambdaQueryWrapper<SubstationPatroldevice> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SubstationPatroldevice> queryWrapper = new LambdaQueryWrapper<>();
@ -136,6 +137,9 @@ public class SubstationPatroldeviceController {
if (StrUtil.isNotBlank(patrolDeviceName)) { if (StrUtil.isNotBlank(patrolDeviceName)) {
queryWrapper.like(SubstationPatroldevice::getPatroldeviceName, patrolDeviceName); queryWrapper.like(SubstationPatroldevice::getPatroldeviceName, patrolDeviceName);
} }
if (StrUtil.isNotBlank(online)) {
queryWrapper.eq(SubstationPatroldevice::getOnline, online);
}
// 模糊查询(设备型号) // 模糊查询(设备型号)
if (StrUtil.isNotBlank(deviceModel)) { if (StrUtil.isNotBlank(deviceModel)) {
queryWrapper.like(SubstationPatroldevice::getDeviceModel, deviceModel); queryWrapper.like(SubstationPatroldevice::getDeviceModel, deviceModel);

View File

@ -2,6 +2,7 @@ package com.yfd.platform.modules.basedata.service.impl;
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.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.modules.auxcontrol.domain.DeviceSignal; import com.yfd.platform.modules.auxcontrol.domain.DeviceSignal;
import com.yfd.platform.modules.auxcontrol.service.IDeviceSignalService; import com.yfd.platform.modules.auxcontrol.service.IDeviceSignalService;
@ -150,11 +151,21 @@ public class SubstationMaindeviceServiceImpl extends ServiceImpl<SubstationMaind
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean deleteMainDevice(String id) { public boolean deleteMainDevice(String id) {
Integer integer =
substationComponentMapper.selectCount(new LambdaQueryWrapper<SubstationComponent>().eq(SubstationComponent::getMainDeviceId, id));
if (integer > 0) {
throw new RuntimeException("当前主设备已经绑定部件无法删除");
}
SubstationMaindevice substationMaindevice = this.getById(id); SubstationMaindevice substationMaindevice = this.getById(id);
// 如果是启用状态不允许删除 // 如果是启用状态不允许删除
if ("1".equals(substationMaindevice.getDatastatus())) { if ("1".equals(substationMaindevice.getDatastatus())) {
return false; return false;
} }
// LambdaQueryWrapper<SubstationComponent> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.eq(SubstationComponent::getMainDeviceId, id);
// substationComponentMapper.delete(queryWrapper);
boolean ok = this.removeById(id); boolean ok = this.removeById(id);
String bayId = substationMaindevice.getBayId(); String bayId = substationMaindevice.getBayId();
List<SubstationMaindevice> list = List<SubstationMaindevice> list =
@ -164,14 +175,6 @@ public class SubstationMaindeviceServiceImpl extends ServiceImpl<SubstationMaind
substationMaindevice1.setCustom1(i + 1); substationMaindevice1.setCustom1(i + 1);
this.updateById(substationMaindevice1); this.updateById(substationMaindevice1);
} }
if (ok) {
List<SubstationComponent> substationComponents =
substationComponentMapper.selectList(new LambdaQueryWrapper<SubstationComponent>().eq(SubstationComponent::getMainDeviceId, id));
for (SubstationComponent substationComponent : substationComponents) {
String componentId = substationComponent.getComponentId();
substationComponentMapper.deleteById(componentId);
}
}
return ok; return ok;
} }

View File

@ -591,6 +591,7 @@ public class SubstationPatroldeviceServiceImpl extends ServiceImpl<SubstationPat
if (StrUtil.isNotBlank(manufacturer)) { if (StrUtil.isNotBlank(manufacturer)) {
queryWrapper.like(SubstationPatroldevice::getManufacturer, manufacturer); queryWrapper.like(SubstationPatroldevice::getManufacturer, manufacturer);
} }
queryWrapper.orderByAsc(SubstationPatroldevice::getPatroldeviceCode);
List<SubstationPatroldevice> list = this.list(queryWrapper); List<SubstationPatroldevice> list = this.list(queryWrapper);
List<Map<String, Object>> mapList = new ArrayList<>(); List<Map<String, Object>> mapList = new ArrayList<>();
Map<String, Object> patrolEquipmentType = sysDictionaryItemsService.getDeviceMapByType( Map<String, Object> patrolEquipmentType = sysDictionaryItemsService.getDeviceMapByType(

View File

@ -406,7 +406,13 @@ public class SubstationServiceImpl extends ServiceImpl<SubstationMapper, Substat
@Override @Override
public boolean deleteSubstation(String stationId) { public boolean deleteSubstation(String stationId) {
Substation substation = substationMapper.selectById(stationId); Substation substation = substationMapper.selectById(stationId);
String stationCode = substation.getStationCode(); Integer integer =
substationAreaMapper.selectCount(new LambdaQueryWrapper<SubstationArea>().eq(SubstationArea::getStationCode, substation.getStationCode()));
if (integer > 0) {
throw new RuntimeException("当前变电站已经绑定区域无法删除");
}
int i = substationMapper.deleteById(stationId); int i = substationMapper.deleteById(stationId);
if (i <= 0) { if (i <= 0) {
return false; return false;
@ -417,13 +423,14 @@ public class SubstationServiceImpl extends ServiceImpl<SubstationMapper, Substat
substation1.setCustom1(i1 + 1); substation1.setCustom1(i1 + 1);
this.updateById(substation1); this.updateById(substation1);
} }
List<SubstationArea> substationAreas = // String stationCode = substation.getStationCode();
substationAreaMapper.selectList(new LambdaQueryWrapper<SubstationArea>().eq(SubstationArea::getStationCode, // List<SubstationArea> substationAreas =
stationCode)); // substationAreaMapper.selectList(new LambdaQueryWrapper<SubstationArea>().eq(SubstationArea::getStationCode,
for (SubstationArea substationArea : substationAreas) { // stationCode));
String areaId = substationArea.getAreaId(); // for (SubstationArea substationArea : substationAreas) {
this.deleteSubstationArea(areaId); // String areaId = substationArea.getAreaId();
} // this.deleteSubstationArea(areaId);
// }
return true; return true;
} }
@ -435,6 +442,12 @@ public class SubstationServiceImpl extends ServiceImpl<SubstationMapper, Substat
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public boolean deleteSubstationArea(String areaId) { public boolean deleteSubstationArea(String areaId) {
Integer integer =
substationBayMapper.selectCount(new LambdaQueryWrapper<SubstationBay>().eq(SubstationBay::getAreaId, areaId));
if (integer > 0) {
throw new RuntimeException("当前区域已经绑定间隔无法删除");
}
int i = substationAreaMapper.deleteById(areaId); int i = substationAreaMapper.deleteById(areaId);
if (i <= 0) { if (i <= 0) {
return false; return false;
@ -446,13 +459,17 @@ public class SubstationServiceImpl extends ServiceImpl<SubstationMapper, Substat
substationArea.setCustom1(i1 + 1); substationArea.setCustom1(i1 + 1);
substationAreaMapper.updateById(substationArea); substationAreaMapper.updateById(substationArea);
} }
List<SubstationBay> substationBays =
substationBayMapper.selectList(new LambdaQueryWrapper<SubstationBay>().eq(SubstationBay::getAreaId, // LambdaQueryWrapper<SubstationBay> queryWrapper = new LambdaQueryWrapper<>();
areaId)); // queryWrapper.eq(SubstationBay::getAreaId, areaId);
for (SubstationBay substationBay : substationBays) { // substationBayMapper.delete(queryWrapper);
String bayId = substationBay.getBayId(); // List<SubstationBay> substationBays =
this.deleteSubstationBay(bayId); // substationBayMapper.selectList(new LambdaQueryWrapper<SubstationBay>().orderByAsc(SubstationBay::getCustom1));
} // for (int i1 = 0; i1 < substationBays.size(); i1++) {
// SubstationBay substationBay = substationBays.get(i1);
// substationBay.setCustom1(i1 + 1);
// substationBayMapper.updateById(substationBay);
// }
return true; return true;
} }
@ -463,6 +480,11 @@ public class SubstationServiceImpl extends ServiceImpl<SubstationMapper, Substat
***********************************/ ***********************************/
@Override @Override
public boolean deleteSubstationBay(String bayId) { public boolean deleteSubstationBay(String bayId) {
Integer integer =
substationMaindeviceMapper.selectCount(new LambdaQueryWrapper<SubstationMaindevice>().eq(SubstationMaindevice::getBayId, bayId));
if (integer > 0) {
throw new RuntimeException("当前间隔已经绑定主设备无法删除");
}
int i = substationBayMapper.deleteById(bayId); int i = substationBayMapper.deleteById(bayId);
List<SubstationBay> substationBays = List<SubstationBay> substationBays =
substationBayMapper.selectList(new LambdaQueryWrapper<SubstationBay>().orderByAsc(SubstationBay::getCustom1)); substationBayMapper.selectList(new LambdaQueryWrapper<SubstationBay>().orderByAsc(SubstationBay::getCustom1));

View File

@ -154,7 +154,7 @@ public class AlarmLog implements Serializable {
private String defectType; private String defectType;
/** /**
* 1:预警2:一般3:严重4;危急 *1:一般2:严重3;危急
*/ */
private String alarmLevel; private String alarmLevel;

View File

@ -280,7 +280,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
resImagePath = result.getStr("resImagePath"); resImagePath = result.getStr("resImagePath");
} }
Map<String, Object> judgeresult = judgeAbnormal(result.getStr("type"), result.getStr("value"), Map<String, Object> judgeresult = judgeAbnormal(result.getStr("type"), result.getStr("value"),
result.getStr("conf"), substationDevice.getDeviceId(), ""); desc, substationDevice.getDeviceId(), "");
// || "yjsk".equals(result.getStr("type")) // || "yjsk".equals(result.getStr("type"))
log.info("=======================发送结果=======================" + result.getStr("type")); log.info("=======================发送结果=======================" + result.getStr("type"));
if (!("meter".equals(type) || "infrared".equals(type) || "sound".equals(type) || StrUtil.isBlank(type) || "yjsk".equals(result.getStr("type")) || "isolator".equals(result.getStr("type")))) { if (!("meter".equals(type) || "infrared".equals(type) || "sound".equals(type) || StrUtil.isBlank(type) || "yjsk".equals(result.getStr("type")) || "isolator".equals(result.getStr("type")))) {
@ -454,6 +454,9 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
typeList.add(type); typeList.add(type);
taskResult.setValueType(result.getStr("type")); taskResult.setValueType(result.getStr("type"));
String value = result.getStr("value"); String value = result.getStr("value");
if ("infrared".equals(type) && StrUtil.isNotBlank(value)) {
value = StrUtil.split(value, ",").get(0);
}
String desc = result.getStr("desc"); String desc = result.getStr("desc");
String conf = result.getStr("conf"); String conf = result.getStr("conf");
if (ObjectUtil.isNotEmpty(conf)) { if (ObjectUtil.isNotEmpty(conf)) {
@ -479,10 +482,12 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
taskResult.setDefectFilePath(taskResult.getFilePath()); taskResult.setDefectFilePath(taskResult.getFilePath());
} }
String valueType = taskResult.getValueType(); String valueType = taskResult.getValueType();
Map<String, Object> judgeresult = judgeAbnormal(result.getStr("type"), result.getStr("value"), Map<String, Object> judgeresult = judgeAbnormal(result.getStr("type"), value,
result.getStr("conf"), taskResult.getDeviceId(), taskResult.getResultId()); result.getStr("desc"), taskResult.getDeviceId(), taskResult.getResultId());
log.info("=======================发送结果=======================" + result.getStr("type")); log.info("=======================发送结果=======================" + result.getStr("type"));
if (!("meter".equals(type) || "infrared".equals(type) || "sound".equals(type) || StrUtil.isBlank(type) || "yjsk".equals(result.getStr("type")) || "isolator".equals(result.getStr("type")))) { if (!("meter".equals(type) || "fhz".equals(result.getStr("type")) || "infrared".equals(type) ||
"sound".equals(type) || StrUtil.isBlank(type) || "yjsk".equals(result.getStr("type")) ||
"isolator".equals(result.getStr("type")))) {
// 图像缺陷分析类型 // 图像缺陷分析类型
List<Map<String, Object>> pictureDefectAnalysisTypeList = sysDictionaryItemsService.getDeviceByType( List<Map<String, Object>> pictureDefectAnalysisTypeList = sysDictionaryItemsService.getDeviceByType(
"PictureDefectAnalysisType"); "PictureDefectAnalysisType");
@ -728,7 +733,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
alarmLog.setAlarmType(ObjUtil.isNotEmpty(map.get("alarmtype")) ? map.get("alarmtype") : ""); alarmLog.setAlarmType(ObjUtil.isNotEmpty(map.get("alarmtype")) ? map.get("alarmtype") : "");
//'字典表<1>: = 超温报警<2>: = 温升报警<3>: = 三相温差报警<4>: = 三相对比报警<5>: = 声音异常<6>: = 外观异常<7>: = 仪表越限报警<8>: = 仪表超量程报警<9>: = //'字典表<1>: = 超温报警<2>: = 温升报警<3>: = 三相温差报警<4>: = 三相对比报警<5>: = 声音异常<6>: = 外观异常<7>: = 仪表越限报警<8>: = 仪表超量程报警<9>: =
// 仪表三相对比<10>: = 变位报警', // 仪表三相对比<10>: = 变位报警',
alarmLog.setAlarmLevel(ObjUtil.isNotEmpty(map.get("alarmlevel")) ? map.get("alarmlevel") : "4");// alarmLog.setAlarmLevel(ObjUtil.isNotEmpty(map.get("alarmlevel")) ? map.get("alarmlevel") : "3");//
// '1:预警2:一般3:严重4;危急', 待判断细分 // '1:预警2:一般3:严重4;危急', 待判断细分
alarmLog.setRecognitionType(taskResult.getRecognitionType());//'1:表计读取2:位置状态识别3:设备外观查看4:红外测温5:声音检测6 alarmLog.setRecognitionType(taskResult.getRecognitionType());//'1:表计读取2:位置状态识别3:设备外观查看4:红外测温5:声音检测6
// :闪烁检测11:局放超声波检测12:局放地电压检测13:局放特高频检测101:环境温度检测102:环境湿度检测103:氧气浓度检测104SF6浓度检测', // :闪烁检测11:局放超声波检测12:局放地电压检测13:局放特高频检测101:环境温度检测102:环境湿度检测103:氧气浓度检测104SF6浓度检测',
@ -1164,7 +1169,15 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
***********************************/ ***********************************/
@Override @Override
public Map<String, Object> getAlarmLogById(String id) { public Map<String, Object> getAlarmLogById(String id) {
return alarmLogMapper.getAlarmLogById(id); Map<String, Object> alarmLog = alarmLogMapper.getAlarmLogById(id);
if (ObjectUtil.isNotEmpty(alarmLog.get("deviceid"))) {
Map<String, String> thresholdInterval = alarmThresholdService.getThresholdInterval(alarmLog.get("deviceId"
).toString());
alarmLog.putAll(thresholdInterval);
}
return alarmLog;
} }
private String getSlienceType(String type) { private String getSlienceType(String type) {
@ -1450,7 +1463,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
double resultvalue = Double.parseDouble(valueList.get(0)); double resultvalue = Double.parseDouble(valueList.get(0));
// 判断是否是非同源 // 判断是否是非同源
String patroldeviceJson = substationDevice.getPatroldeviceJson(); String patroldeviceJson = substationDevice.getPatroldeviceJson();
if (JSONUtil.isTypeJSONArray(patroldeviceJson)) { if (JSONUtil.isTypeJSONArray(patroldeviceJson) && !"3".equals(alarmThreshold.getAlarmType()) && !"9".equals(alarmThreshold.getAlarmType())) {
JSONArray jsonArray = JSONUtil.parseArray(patroldeviceJson); JSONArray jsonArray = JSONUtil.parseArray(patroldeviceJson);
if (jsonArray.size() > 1) { if (jsonArray.size() > 1) {
// 非同源告警 // 非同源告警
@ -1472,27 +1485,27 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
return result; return result;
} }
} }
if (jsonArray.size() == 1) { // if (jsonArray.size() == 1) {
// 非同源告警 // // 非同源告警
LambdaQueryWrapper<TaskResult> queryWrapper = new LambdaQueryWrapper<>(); // LambdaQueryWrapper<TaskResult> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TaskResult::getDeviceId, deviceid).eq(TaskResult::getTaskTodoId, // queryWrapper.eq(TaskResult::getDeviceId, deviceid).eq(TaskResult::getTaskTodoId,
taskResult.getTaskTodoId()).eq(TaskResult::getFlag, "2").ne(TaskResult::getResultId, // taskResult.getTaskTodoId()).eq(TaskResult::getFlag, "2").ne(TaskResult::getResultId,
resultId); // resultId);
List<TaskResult> taskResultList = taskResultMapper.selectList(queryWrapper); // List<TaskResult> taskResultList = taskResultMapper.selectList(queryWrapper);
// List<String> values = taskResultList.stream().filter(v->StrUtil.isNotBlank // // List<String> values = taskResultList.stream().filter(v->StrUtil.isNotBlank
// (v.getValue())).map(TaskResult::getValue).collect(Collectors.toList()); // // (v.getValue())).map(TaskResult::getValue).collect(Collectors.toList());
Optional<TaskResult> maxDifferenceTaskResult = // Optional<TaskResult> maxDifferenceTaskResult =
taskResultList.stream().filter(t -> StrUtil.isNotBlank(t.getValue())).max(Comparator.comparingDouble(t -> Math.abs(NumberUtil.parseDouble(t.getValue()) - NumberUtil.parseDouble(value)))); // taskResultList.stream().filter(t -> StrUtil.isNotBlank(t.getValue())).max(Comparator.comparingDouble(t -> Math.abs(NumberUtil.parseDouble(t.getValue()) - NumberUtil.parseDouble(value))));
if (maxDifferenceTaskResult.isPresent()) { // if (maxDifferenceTaskResult.isPresent()) {
TaskResult oldResult = maxDifferenceTaskResult.get(); // TaskResult oldResult = maxDifferenceTaskResult.get();
resultvalue = Math.abs(resultvalue - NumberUtil.parseDouble(oldResult.getValue())); // resultvalue = Math.abs(resultvalue - NumberUtil.parseDouble(oldResult.getValue()));
result.put("isSame", "1"); // result.put("isSame", "1");
result.put("oldContent", // result.put("oldContent",
oldResult.getPatroldeviceName() + "设备识别结果为" + oldResult.getValue() + ""); // oldResult.getPatroldeviceName() + "设备识别结果为" + oldResult.getValue() + "");
} else { // } else {
return result; // return result;
} // }
} // }
} }
// 三相温差告警仪表三项对比 // 三相温差告警仪表三项对比
if ("3".equals(alarmThreshold.getAlarmType()) || "9".equals(alarmThreshold.getAlarmType())) { if ("3".equals(alarmThreshold.getAlarmType()) || "9".equals(alarmThreshold.getAlarmType())) {
@ -1509,10 +1522,28 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
} }
List<String> values = List<String> values =
nonCoherentResult.stream().filter(n -> ObjectUtil.isNotEmpty(n.getValue())).map(TaskResult::getValue).collect(Collectors.toList()); nonCoherentResult.stream().filter(n -> ObjectUtil.isNotEmpty(n.getValue())).map(TaskResult::getValue).collect(Collectors.toList());
String max = CollectionUtil.max(values); // 将字符串转换为Double并过滤无效数值
String min = CollectionUtil.min(values); List<Double> numericValues = values.stream()
.map(str -> {
try {
return Double.parseDouble(str);
} catch (NumberFormatException e) {
return null; // 或记录日志并跳过无效值
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (numericValues.isEmpty()) {
// 处理空值情况根据业务需求选择返回0/抛出异常等
resultvalue = 0.0;
}
// 使用数值列表计算最大最小值
double max = Collections.max(numericValues);
double min = Collections.min(numericValues);
// 最大值减去最小值 // 最大值减去最小值
resultvalue = NumberUtil.sub(Double.parseDouble(max), Double.parseDouble(min)); resultvalue = NumberUtil.sub(max, min);
Map<String, String> phaseToValueMap = nonCoherentResult.stream() Map<String, String> phaseToValueMap = nonCoherentResult.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
TaskResult::getPhase, TaskResult::getPhase,
@ -1643,32 +1674,33 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
result.put("alarmtype", alarmThreshold.getAlarmType()); result.put("alarmtype", alarmThreshold.getAlarmType());
result.put("alarmlevel", "4"); result.put("alarmlevel", "4");
result.put("isSame", "1"); result.put("isSame", "1");
}
if (jsonArray.size() == 1) {
// 非同源告警
LambdaQueryWrapper<TaskResult> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TaskResult::getDeviceId, deviceid).eq(TaskResult::getTaskTodoId,
taskResult.getTaskTodoId()).eq(TaskResult::getFlag, "2").ne(TaskResult::getResultId,
resultId);
List<TaskResult> taskResultList = taskResultMapper.selectList(queryWrapper);
Optional<TaskResult> first =
taskResultList.stream().filter(f -> StrUtil.isNotBlank(f.getValue()) && !value.equals(f.getValue())).findFirst();
if (!first.isPresent()) {
return result; return result;
} }
TaskResult oldResult = first.get(); // if (jsonArray.size() == 1) {
result.put("oldContent", // // 非同源告警
oldResult.getPatroldeviceName() + "设备识别结果为" + oldResult.getDesc() + ""); // LambdaQueryWrapper<TaskResult> queryWrapper = new LambdaQueryWrapper<>();
result.put("isNormal", "0"); // queryWrapper.eq(TaskResult::getDeviceId, deviceid).eq(TaskResult::getTaskTodoId,
result.put("alarmtype", alarmThreshold.getAlarmType()); // taskResult.getTaskTodoId()).eq(TaskResult::getFlag, "2").ne(TaskResult::getResultId,
result.put("alarmlevel", "4"); // resultId);
result.put("isSame", "1"); // List<TaskResult> taskResultList = taskResultMapper.selectList(queryWrapper);
} // Optional<TaskResult> first =
return result; // taskResultList.stream().filter(f -> StrUtil.isNotBlank(f.getValue()) && !value.equals(f.getValue())).findFirst();
// if (!first.isPresent()) {
// return result;
// }
// TaskResult oldResult = first.get();
// result.put("oldContent",
// oldResult.getPatroldeviceName() + "设备识别结果为" + oldResult.getDesc() + "");
// result.put("isNormal", "0");
// result.put("alarmtype", alarmThreshold.getAlarmType());
// result.put("alarmlevel", "4");
// result.put("isSame", "1");
// }
} }
if ("1".equals(alarmThreshold.getIsLastContrast())) { if ("1".equals(alarmThreshold.getIsLastContrast())) {
LambdaQueryWrapper<TaskResult> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TaskResult> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TaskResult::getDeviceId, deviceid).isNotNull(TaskResult::getPatroldeviceDate).lt(TaskResult::getPatroldeviceDate, queryWrapper.ne(TaskResult::getResultId,resultId).eq(TaskResult::getDeviceId, deviceid).isNotNull(TaskResult::getPatroldeviceDate).lt(TaskResult::getPatroldeviceDate,
taskResult.getPatroldeviceDate()).orderByDesc(TaskResult::getPatroldeviceDate).last("limit 0," + taskResult.getPatroldeviceDate()).orderByDesc(TaskResult::getPatroldeviceDate).last("limit 0," +
"1"); "1");
List<TaskResult> taskResultList = taskResultMapper.selectList(queryWrapper); List<TaskResult> taskResultList = taskResultMapper.selectList(queryWrapper);
@ -1751,7 +1783,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
alarmLog.setTaskAlarmType("1"); //'1:巡视任务告警2:静默任务告警3巡视设备告警', alarmLog.setTaskAlarmType("1"); //'1:巡视任务告警2:静默任务告警3巡视设备告警',
//alarmLog.setMonitorType("");//非静默监视不填 //alarmLog.setMonitorType("");//非静默监视不填
alarmLog.setAlarmType(ObjUtil.isNotEmpty(map.get("alarmtype")) ? map.get("alarmtype").toString() : "");//'字典表<1>: = 超温报警<2>: = 温升报警<3>: = 三相温差报警<4>: = 三相对比报警<5>: = 声音异常<6>: = 外观异常<7>: = 仪表越限报警<8>: = 仪表超量程报警<9>: = 仪表三相对比<10>: = 变位报警', alarmLog.setAlarmType(ObjUtil.isNotEmpty(map.get("alarmtype")) ? map.get("alarmtype").toString() : "");//'字典表<1>: = 超温报警<2>: = 温升报警<3>: = 三相温差报警<4>: = 三相对比报警<5>: = 声音异常<6>: = 外观异常<7>: = 仪表越限报警<8>: = 仪表超量程报警<9>: = 仪表三相对比<10>: = 变位报警',
alarmLog.setAlarmLevel(ObjUtil.isNotEmpty(map.get("alarmlevel")) ? map.get("alarmlevel").toString() : "4");// '1:预警2:一般3:严重4;危急', 待判断细分 alarmLog.setAlarmLevel(ObjUtil.isNotEmpty(map.get("alarmlevel")) ? map.get("alarmlevel").toString() : "3");// '1:预警2:一般3:严重4;危急', 待判断细分
alarmLog.setRecognitionType(taskResult.getRecognitionType());//'1:表计读取2:位置状态识别3:设备外观查看4:红外测温5:声音检测6:闪烁检测11:局放超声波检测12:局放地电压检测13:局放特高频检测101:环境温度检测102:环境湿度检测103:氧气浓度检测104SF6浓度检测', alarmLog.setRecognitionType(taskResult.getRecognitionType());//'1:表计读取2:位置状态识别3:设备外观查看4:红外测温5:声音检测6:闪烁检测11:局放超声波检测12:局放地电压检测13:局放特高频检测101:环境温度检测102:环境湿度检测103:氧气浓度检测104SF6浓度检测',
alarmLog.setFileType(taskResult.getFileType());//'1:红外图谱2:可见光照片3:音频4:视频5:识别图片存在多个文件文件类型用逗号分隔', alarmLog.setFileType(taskResult.getFileType());//'1:红外图谱2:可见光照片3:音频4:视频5:识别图片存在多个文件文件类型用逗号分隔',
//告警文件目录规范地市名/区域名/变电站名/分类/年月 //告警文件目录规范地市名/区域名/变电站名/分类/年月
@ -2298,7 +2330,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
signalDate.get("signalName").toString()); signalDate.get("signalName").toString());
alarmLog.setContent(alarmMessage); alarmLog.setContent(alarmMessage);
//状态 //状态
alarmLog.setAlarmLevel("4"); alarmLog.setAlarmLevel("3");
alarmLog.setAlarmClass("2"); alarmLog.setAlarmClass("2");
//2-设备报警 //2-设备报警
alarmLog.setRegion(meterDevice.getRegion()); alarmLog.setRegion(meterDevice.getRegion());

View File

@ -498,6 +498,11 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
customParams.put("TempAngleList", jsonArray); customParams.put("TempAngleList", jsonArray);
} }
if (JSONUtil.isTypeJSONObject(map.get("outsideAngle").toString())) {
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(map.get("outsideAngle").toString());
customParams.put("TempAngle", jsonObject);
}
} }
//基准图 //基准图

View File

@ -1,14 +1,11 @@
package com.yfd.platform.utils; package com.yfd.platform.utils;
import cn.hutool.core.io.FileUtil;
public class TestFileDir { public class TestFileDir {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String filename = "d:\\riis\\alarm\\商丘市\\500Kv标准变电站管理区域\\500V变电站\\缺陷\\202505\\20250514_145108_500kV测试间隔_500kV" + double resultvalue = 50;
"测试主设备_声纹点位.wav"; double baseValue = 100;
String filename1 = "d:\\riis\\alarm\\商丘市\\500Kv标准变电站管理区域\\510V变电站\\缺陷\\202505\\20250514_145108_500kV" + double abs = Math.abs((resultvalue - baseValue) / baseValue * 100);
"测试间隔_500kV" + System.out.println(abs);
"测试主设备_声纹点位.wav";
FileUtil.copy(filename, filename1,true);
} }
} }

View File

@ -114,10 +114,12 @@
fds.normal_range, fds.normal_range,
fds.ykyt_type, fds.ykyt_type,
fmd.device_model, fmd.device_model,
fmd.device_code,
fmd.place,
fgd.ip_addr, fgd.ip_addr,
fgd.Protocol, fgd.Protocol,
fgd.frequency, fgd.frequency,
fgd.device_name, fmd.device_name,
fgd.device_type fgd.device_type
FROM FROM
fk_device_signal fds fk_device_signal fds

View File

@ -93,6 +93,7 @@
<select id="getAlarmLogById" resultType="java.util.Map"> <select id="getAlarmLogById" resultType="java.util.Map">
SELECT SELECT
al.*, al.*,
al.device_id deviceid,
tr.patroldevice_code deviceId, tr.patroldevice_code deviceId,
tr.patroldevice_channelcode channelId, tr.patroldevice_channelcode channelId,
tr.patroldevice_pos patroldevicePos tr.patroldevice_pos patroldevicePos