优化部分之前代码逻辑

This commit is contained in:
weitang 2025-05-23 17:38:54 +08:00
parent a4be773f45
commit ffb629c51a
6 changed files with 35 additions and 27 deletions

View File

@ -54,6 +54,8 @@ public class AlarmThresholdController {
Map<String, Object> m = new HashMap<>(BeanUtil.beanToMap(alarmThreshold));
Map<String, String> thresholdInterval = alarmThresholdService.getThresholdInterval(id);
m.putAll(thresholdInterval);
// Map<String, String> thresholdInterval1=alarmThresholdService.getAlgorithmModelById(id);
return ResponseResult.successData(m);
}

View File

@ -99,33 +99,17 @@ public class LinkageSignalController {
@ApiOperation("根据联动信号Id查询绑定的巡视信息")
public ResponseResult getSubstationDeviceListById(String id) {
LinkageSignal linkageSignal = linkageSignalService.getById(id);
String deviceIdList = linkageSignal.getDeviceIdList();
//String videoPos = linkageSignal.getVideoPos();
List<Map<String, Object>> mapList = new ArrayList<>();
if (StrUtil.isNotBlank(deviceIdList)) {
String[] split = deviceIdList.split(",");
for (String s : split) {
Map<String, Object> map = new HashMap<>();
SubstationDevice substationDevice = substationDeviceService.getById(s);
if (substationDevice == null) {
continue;
}
map.put("deviceId", substationDevice.getDeviceId());
map.put("deviceName", substationDevice.getDeviceName());
map.put("stationName", substationDevice.getStationName());
map.put("stationCode", substationDevice.getStationCode());
map.put("areaName", substationDevice.getAreaName());
map.put("bayName", substationDevice.getBayName());
map.put("areaId", substationDevice.getAreaId());
map.put("bayId", substationDevice.getBayId());
mapList.add(map);
}
} /*else if (StrUtil.isNotBlank(videoPos)) {
List<Map> list = JSONUtil.toList(videoPos, Map.class);
for (Map map : list) {
mapList.add(map);
}
}*/
String deviceIdListStr = linkageSignal.getDeviceIdList();
List<String> deviceIdList = StrUtil.split(deviceIdListStr, ",");
if (deviceIdList.size() <= 0) {
return ResponseResult.successData(new ArrayList<>());
}
LambdaQueryWrapper<SubstationDevice> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(SubstationDevice::getDeviceId, deviceIdList).select(SubstationDevice::getDeviceId,
SubstationDevice::getDeviceName, SubstationDevice::getStationName, SubstationDevice::getStationCode,
SubstationDevice::getAreaName, SubstationDevice::getAreaId, SubstationDevice::getBayId,
SubstationDevice::getBayName);
List<Map<String, Object>> mapList = substationDeviceService.listMaps(queryWrapper);
return ResponseResult.successData(mapList);
}

View File

@ -16,4 +16,6 @@ import java.util.Map;
public interface AlarmThresholdMapper extends BaseMapper<AlarmThreshold> {
Map<String, String> getThresholdInterval(String deviceId);
Map<String, String> getAlgorithmModelById(String id);
}

View File

@ -16,4 +16,6 @@ import java.util.Map;
public interface IAlarmThresholdService extends IService<AlarmThreshold> {
Map<String, String> getThresholdInterval(String deviceId);
Map<String, String> getAlgorithmModelById(String id);
}

View File

@ -26,4 +26,9 @@ public class AlarmThresholdServiceImpl extends ServiceImpl<AlarmThresholdMapper,
public Map<String, String> getThresholdInterval(String deviceId) {
return alarmThresholdMapper.getThresholdInterval(deviceId);
}
@Override
public Map<String, String> getAlgorithmModelById(String id) {
return alarmThresholdMapper.getAlgorithmModelById(id);
}
}

View File

@ -16,4 +16,17 @@
iis_alarm_threshold
WHERE device_id = #{deviceId}
</select>
<select id="getAlgorithmModelById" resultType="java.util.Map">
SELECT
device_id deviceId,
MAX(CASE WHEN (alarm_level = '1' AND decide_rule ='6') THEN base_line_value ELSE NULL END) AS commonLower,
MAX(CASE WHEN (alarm_level = '1' AND decide_rule ='7') THEN base_line_value ELSE NULL END) AS commonUpper,
MAX(CASE WHEN (alarm_level = '2' AND decide_rule ='6') THEN base_line_value ELSE NULL END) AS seriousLower,
MAX(CASE WHEN (alarm_level = '2' AND decide_rule ='7') THEN base_line_value ELSE NULL END) AS seriousUpper,
MAX(CASE WHEN (alarm_level = '3' AND decide_rule ='6') THEN base_line_value ELSE NULL END) AS dangerLower,
MAX(CASE WHEN (alarm_level = '3' AND decide_rule ='7') THEN base_line_value ELSE NULL END) AS dangerUpper
FROM
iis_alarm_threshold
WHERE device_id = #{deviceId}
</select>
</mapper>