fix:优化逻辑

优化辅控系统信号相关逻辑
This commit is contained in:
weitang 2025-06-11 15:42:10 +08:00
parent c045ddc7bd
commit 094ee4012b
4 changed files with 77 additions and 17 deletions

View File

@ -101,9 +101,12 @@ public class IEC61850Service {
* type 类型ykyt * type 类型ykyt
* value * value
*/ */
public boolean sendCommand(String systemcode, String signalid, String type, String value) throws IOException, public boolean sendCommand(String systemcode, String signalid, String type, String deviceType, String value) throws IOException,
ServiceError { ServiceError {
// value = getControlValue(deviceType, value);
// if (StrUtil.isBlank(value)) {
// return false;
// }
DeviceSignal deviceSignal = deviceSignalService.getById(signalid); DeviceSignal deviceSignal = deviceSignalService.getById(signalid);
//辅控系统下属网关机状态监控 //辅控系统下属网关机状态监控
if (StrUtil.isNotEmpty(systemcode) && "10".equals(systemcode)) { if (StrUtil.isNotEmpty(systemcode) && "10".equals(systemcode)) {
@ -180,5 +183,26 @@ public class IEC61850Service {
return false; return false;
} }
/**
* 获取控制值
*
* @param type 类型
* @param value
* @return
*/
public String getControlValue(String type, String value) {
if ("7".equals(type)) {
return value.equals("1") ? "false" : "true";
}
if ("14".equals(type)) {
return value.equals("1") ? "false" : "true";
}
if ("20".equals(type)) {
return value.equals("1") ? "false" : "true";
}
return null;
}
} }

View File

@ -61,17 +61,14 @@ public class IECController {
***********************************/ ***********************************/
@GetMapping("/sendCommand") @GetMapping("/sendCommand")
@ApiOperation("发送遥控遥调命令") @ApiOperation("发送遥控遥调命令")
public ResponseResult sendCommand(String systemcode, String signalid, String type, String value) throws Exception { public ResponseResult sendCommand(String systemcode, String signalId, String type,String deviceType, String value) throws Exception {
if (StrUtil.isBlank(signalid)) { if (StrUtil.isBlank(signalId)) {
return ResponseResult.error("信号ID不能为空"); return ResponseResult.error("信号ID不能为空");
} }
DeviceSignal deviceSignal = deviceSignalService.getById(signalid); DeviceSignal deviceSignal = deviceSignalService.getById(signalId);
if (ObjUtil.isNotEmpty(deviceSignal)) { if (ObjUtil.isNotEmpty(deviceSignal)) {
LambdaQueryWrapper<MeterDevice> queryWrapper = new LambdaQueryWrapper<>();
//型号对应的监控设备id
queryWrapper.eq(MeterDevice::getDeviceId, deviceSignal.getMeterDeviceId());
//查找信号对应监控设备 //查找信号对应监控设备
MeterDevice meterDevice = meterDeviceService.getOne(queryWrapper); MeterDevice meterDevice = meterDeviceService.getById(deviceSignal.getMeterDeviceId());
LambdaQueryWrapper<GatewayDevice> queryWrapper2 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GatewayDevice> queryWrapper2 = new LambdaQueryWrapper<>();
//IP地址 //IP地址
queryWrapper2.eq(GatewayDevice::getIpAddr, meterDevice.getNetdeviceIp()); queryWrapper2.eq(GatewayDevice::getIpAddr, meterDevice.getNetdeviceIp());
@ -81,9 +78,9 @@ public class IECController {
return ResponseResult.error("组件未关联信号!"); return ResponseResult.error("组件未关联信号!");
} }
if ("IEC104".equals(netDevice.getProtocol())) { if ("IEC104".equals(netDevice.getProtocol())) {
iec104Service.sendCommand(systemcode, signalid, type, value); iec104Service.sendCommand(systemcode, signalId, type, value);
} else if ("IEC61850".equals(netDevice.getProtocol())) { } else if ("IEC61850".equals(netDevice.getProtocol())) {
iec61850Service.sendCommand(systemcode, signalid, type, value); iec61850Service.sendCommand(systemcode, signalId, type,deviceType, value);
} }
return ResponseResult.success(); return ResponseResult.success();
} else { } else {

View File

@ -130,7 +130,9 @@
</select> </select>
<select id="queryYxData" resultType="java.util.Map"> <select id="queryYxData" resultType="java.util.Map">
SELECT SELECT
md.systemcode,
md.device_type, md.device_type,
ds.signal_id,
ds.signal_name, ds.signal_name,
ds.signal_code, ds.signal_code,
ds.yx_addr, ds.yx_addr,
@ -142,13 +144,15 @@
WHERE WHERE
ds.yx_addr IS NOT NULL ds.yx_addr IS NOT NULL
AND ds.yx_addr != '' AND ds.yx_addr != ''
AND md.status != '00'
AND md.device_type IN ('07','14','20')
<if test="stationId != null and stationId != ''"> <if test="stationId != null and stationId != ''">
AND md.station_id = #{stationId} AND md.station_id = #{stationId}
</if> </if>
<if test="areaId != null and areaId != ''"> <if test="areaId != null and areaId != ''">
AND md.region = #{areaId} AND md.region = #{areaId}
</if> </if>
<if test="type != null and type != ''"> <if test="type != null and type != '' and type !='all'">
AND md.device_type = #{type} AND md.device_type = #{type}
</if> </if>
ORDER BY ORDER BY
@ -156,6 +160,7 @@
ds.signal_code ds.signal_code
</select> </select>
<select id="countDeviceTypeStatus" resultType="java.util.Map"> <select id="countDeviceTypeStatus" resultType="java.util.Map">
SELECT SELECT
IFNULL(md.device_type, 'all') AS device_type, IFNULL(md.device_type, 'all') AS device_type,
@ -167,13 +172,15 @@
WHERE WHERE
ds.yx_addr IS NOT NULL ds.yx_addr IS NOT NULL
AND ds.yx_addr != '' AND ds.yx_addr != ''
AND md.status != '00'
AND md.device_type IN ('07','14','20')
<if test="stationId != null and stationId != ''"> <if test="stationId != null and stationId != ''">
AND md.station_id = #{stationId} AND md.station_id = #{stationId}
</if> </if>
<if test="areaId != null and areaId != ''"> <if test="areaId != null and areaId != ''">
AND md.region = #{areaId} AND md.region = #{areaId}
</if> </if>
<if test="type != null and type != ''"> <if test="type != null and type != '' and type !='all'">
AND md.device_type = #{type} AND md.device_type = #{type}
</if> </if>
GROUP BY GROUP BY
@ -181,4 +188,36 @@
ORDER BY ORDER BY
md.device_type; md.device_type;
</select> </select>
<!-- <select id="countDeviceTypeStatus" resultType="java.util.Map">-->
<!-- SELECT-->
<!-- IFNULL( dict.itemcode, 'all' ) AS device_type,-->
<!-- COUNT( md.device_id ) AS total,-->
<!-- SUM( CASE WHEN md.STATUS = '01' THEN 1 ELSE 0 END ) AS online_count-->
<!-- FROM-->
<!-- sys_dictionary_items dict-->
<!-- LEFT JOIN (-->
<!-- fk_device_signal ds-->
<!-- INNER JOIN fk_meter_device md ON ds.meter_device_id = md.device_id-->
<!-- AND md.STATUS != '00' -->
<!-- AND ds.yx_addr IS NOT NULL-->
<!-- <if test="stationId != null and stationId != ''">-->
<!-- AND md.station_id = #{stationId}-->
<!-- </if>-->
<!-- <if test="areaId != null and areaId != ''">-->
<!-- AND md.region = #{areaId}-->
<!-- </if>-->
<!-- <if test="type != null and type != '' and type !='all'">-->
<!-- AND md.device_type = #{type}-->
<!-- </if>-->
<!-- AND ds.yx_addr != ''-->
<!-- ) ON dict.itemcode = md.device_type-->
<!-- WHERE-->
<!-- dict.dictid = '8f9b538c754fe32c2d000c773a3198ae'-->
<!-- AND dict.itemcode IN ( '07', '14', '20' )-->
<!-- GROUP BY-->
<!-- dict.itemcode WITH ROLLUP-->
<!-- ORDER BY-->
<!-- dict.itemcode;-->
<!-- </select>-->
</mapper> </mapper>