辅控sql语句优化
This commit is contained in:
parent
310b1cc5c6
commit
38ced6e356
@ -16,8 +16,6 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public interface DeviceSignalMapper extends BaseMapper<DeviceSignal> {
|
public interface DeviceSignalMapper extends BaseMapper<DeviceSignal> {
|
||||||
|
|
||||||
List<DeviceSignal> selectDeviceSignalYx(String slave_ip, String address);
|
DeviceSignal selectOneDeviceSignal(String slaveIp, String type, String address);
|
||||||
List<DeviceSignal> selectDeviceSignalYc(String slave_ip, String address);
|
Map<String,Object> selectDeviceSignalMap(String slaveIp, String type, String address);
|
||||||
List<Map<String,Object>> selectDeviceSignal_Map(String slave_ip, String type, String address);
|
|
||||||
List<Map<String,Object>> selectDeviceSignal_Map2(String type,String address);
|
|
||||||
}
|
}
|
||||||
|
@ -71,16 +71,16 @@ public class DeviceAlarmRecordServiceImpl extends ServiceImpl<DeviceAlarmRecordM
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void doAlaramRecord(String from, String type, String slaveIp, String address, String value) {
|
public void doAlaramRecord(String from, String type, String slaveIp, String address, String value) {
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
String sinnalType = type;
|
||||||
if ("IEC104".equals(from)) {
|
if ("IEC104".equals(from)) {
|
||||||
list = deviceSignalMapper.selectDeviceSignal_Map(slaveIp, "yc", address);
|
sinnalType = "yc";
|
||||||
} else if ("IEC61850".equals(from)) {
|
} else if ("IEC61850".equals(from)) {
|
||||||
list = deviceSignalMapper.selectDeviceSignal_Map2(type, address);
|
slaveIp = null;
|
||||||
}
|
}
|
||||||
if (list.size() == 0) {
|
Map<String, Object> map = deviceSignalMapper.selectDeviceSignalMap(slaveIp, sinnalType, address);
|
||||||
|
if (map == null || ObjUtil.isEmpty(map)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Map<String, Object> map = list.get(0);
|
|
||||||
//如果是yx 遥信 (设备自身报警记录)
|
//如果是yx 遥信 (设备自身报警记录)
|
||||||
if ("yx".equals(type)) {
|
if ("yx".equals(type)) {
|
||||||
//如果信号类型是1 设备告警
|
//如果信号类型是1 设备告警
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.yfd.platform.modules.auxcontrol.service.impl;
|
package com.yfd.platform.modules.auxcontrol.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.yfd.platform.modules.auxcontrol.domain.DeviceSignal;
|
import com.yfd.platform.modules.auxcontrol.domain.DeviceSignal;
|
||||||
import com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper;
|
import com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper;
|
||||||
@ -37,19 +38,9 @@ public class DeviceSignalServiceImpl extends ServiceImpl<DeviceSignalMapper, Dev
|
|||||||
@Override
|
@Override
|
||||||
public boolean updateDeviceSignalValue(String slaveIp, String address, String type, String value,
|
public boolean updateDeviceSignalValue(String slaveIp, String address, String type, String value,
|
||||||
String dateString) throws ParseException {
|
String dateString) throws ParseException {
|
||||||
List<DeviceSignal> list = null;
|
|
||||||
|
|
||||||
if ("yx".equals(type)) {
|
|
||||||
// 遥信
|
|
||||||
list = deviceSignalMapper.selectDeviceSignalYx(slaveIp, address);
|
|
||||||
} else if ("yc".equals(type)) {
|
|
||||||
// 遥测
|
|
||||||
list = deviceSignalMapper.selectDeviceSignalYc(slaveIp, address);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list != null && !list.isEmpty()) {
|
|
||||||
DeviceSignal deviceSignal = list.get(0);
|
|
||||||
|
|
||||||
|
DeviceSignal deviceSignal = deviceSignalMapper.selectOneDeviceSignal(slaveIp, type, address);
|
||||||
|
if (deviceSignal != null && ObjectUtil.isNotEmpty(deviceSignal)) {
|
||||||
try {
|
try {
|
||||||
if ("yx".equals(type)) {
|
if ("yx".equals(type)) {
|
||||||
// 遥信
|
// 遥信
|
||||||
@ -64,7 +55,6 @@ public class DeviceSignalServiceImpl extends ServiceImpl<DeviceSignalMapper, Dev
|
|||||||
}
|
}
|
||||||
|
|
||||||
deviceSignal.setLastmodifier("系统更新");
|
deviceSignal.setLastmodifier("系统更新");
|
||||||
|
|
||||||
// 设置最后修改时间
|
// 设置最后修改时间
|
||||||
Date parsedDate;
|
Date parsedDate;
|
||||||
if (StrUtil.isEmpty(dateString) || "null".equals(dateString)) {
|
if (StrUtil.isEmpty(dateString) || "null".equals(dateString)) {
|
||||||
|
@ -40,14 +40,13 @@ public class DeviceWorkDataServiceImpl extends ServiceImpl<DeviceWorkDataMapper,
|
|||||||
@Override
|
@Override
|
||||||
public void insertData(String from, String slaveIp, String address, String value, String dateTimeString) {
|
public void insertData(String from, String slaveIp, String address, String value, String dateTimeString) {
|
||||||
DeviceWorkData workdata = new DeviceWorkData();
|
DeviceWorkData workdata = new DeviceWorkData();
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
if ("IEC61850".equals(from)) {
|
||||||
if ("IEC104".equals(from)) {
|
slaveIp = null;
|
||||||
list = deviceSignalMapper.selectDeviceSignal_Map(slaveIp, "yc", address);
|
}
|
||||||
} else if ("IEC61850".equals(from)) {
|
Map<String, Object> map = deviceSignalMapper.selectDeviceSignalMap(slaveIp, "yc", address);
|
||||||
list = deviceSignalMapper.selectDeviceSignal_Map2("yc", address);
|
if (map == null || ObjUtil.isEmpty(map)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (list.size() > 0) {
|
|
||||||
Map<String, Object> map = list.get(0);
|
|
||||||
workdata.setId(IdUtil.fastSimpleUUID());
|
workdata.setId(IdUtil.fastSimpleUUID());
|
||||||
workdata.setSystemcode(map.get("systemcode").toString());
|
workdata.setSystemcode(map.get("systemcode").toString());
|
||||||
workdata.setStationId(map.get("station_id").toString());
|
workdata.setStationId(map.get("station_id").toString());
|
||||||
@ -67,6 +66,5 @@ public class DeviceWorkDataServiceImpl extends ServiceImpl<DeviceWorkDataMapper,
|
|||||||
this.saveOrUpdate(workdata);
|
this.saveOrUpdate(workdata);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,34 +3,7 @@
|
|||||||
<mapper namespace="com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper">
|
<mapper namespace="com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper">
|
||||||
|
|
||||||
<!-- 查询辅控设备信号表-->
|
<!-- 查询辅控设备信号表-->
|
||||||
<select id="selectDeviceSignalYx" resultType="com.yfd.platform.modules.auxcontrol.domain.DeviceSignal">
|
<select id="selectDeviceSignalMap" resultType="java.util.Map">
|
||||||
SELECT
|
|
||||||
b.*
|
|
||||||
FROM
|
|
||||||
fk_meter_device a
|
|
||||||
JOIN fk_device_signal b ON ( a.device_id = b.device_id )
|
|
||||||
JOIN fk_gateway_device c ON ( a.netdevice_ip = c.ip_addr )
|
|
||||||
WHERE
|
|
||||||
c.ip_addr = #{slave_ip}
|
|
||||||
|
|
||||||
AND b.yx_addr = #{address}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectDeviceSignalYc" resultType="com.yfd.platform.modules.auxcontrol.domain.DeviceSignal">
|
|
||||||
SELECT
|
|
||||||
b.*
|
|
||||||
FROM
|
|
||||||
fk_meter_device a
|
|
||||||
JOIN fk_device_signal b ON ( a.device_id = b.device_id )
|
|
||||||
JOIN fk_gateway_device c ON ( a.netdevice_ip = c.ip_addr )
|
|
||||||
WHERE
|
|
||||||
c.ip_addr = #{slave_ip}
|
|
||||||
|
|
||||||
AND b.yc_addr = #{address}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!-- 查询辅控设备信号表-->
|
|
||||||
<select id="selectDeviceSignal_Map" resultType="java.util.Map">
|
|
||||||
SELECT
|
SELECT
|
||||||
a.station_id,
|
a.station_id,
|
||||||
a.systemcode,
|
a.systemcode,
|
||||||
@ -38,10 +11,13 @@
|
|||||||
b.*
|
b.*
|
||||||
FROM
|
FROM
|
||||||
fk_meter_device a
|
fk_meter_device a
|
||||||
JOIN fk_device_signal b ON ( a.device_id = b.device_id )
|
JOIN fk_device_signal b ON ( a.device_id = b.meter_device_id )
|
||||||
JOIN fk_gateway_device c ON ( a.netdevice_ip = c.ip_addr )
|
JOIN fk_gateway_device c ON ( a.netdevice_ip = c.ip_addr )
|
||||||
WHERE
|
WHERE
|
||||||
c.ip_addr = #{slave_ip}
|
1 =1
|
||||||
|
<if test="slaveIp != null and slaveIp != ''">
|
||||||
|
and c.ip_addr = #{slaveIp}
|
||||||
|
</if>
|
||||||
<if test="type=='yx'">
|
<if test="type=='yx'">
|
||||||
and b.yx_addr = #{address}
|
and b.yx_addr = #{address}
|
||||||
</if>
|
</if>
|
||||||
@ -52,22 +28,24 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询辅控设备信号表-->
|
<!-- 查询辅控设备信号表-->
|
||||||
<select id="selectDeviceSignal_Map2" resultType="java.util.Map">
|
<select id="selectOneDeviceSignal" resultType="com.yfd.platform.modules.auxcontrol.domain.DeviceSignal">
|
||||||
SELECT
|
SELECT
|
||||||
a.station_id,
|
|
||||||
a.systemcode,
|
|
||||||
a.device_name,
|
|
||||||
b.*
|
b.*
|
||||||
FROM
|
FROM
|
||||||
fk_meter_device a
|
fk_meter_device a
|
||||||
JOIN fk_device_signal b ON ( a.device_id = b.device_id )
|
JOIN fk_device_signal b ON ( a.device_id = b.meter_device_id )
|
||||||
|
JOIN fk_gateway_device c ON ( a.netdevice_ip = c.ip_addr )
|
||||||
WHERE
|
WHERE
|
||||||
1 =1
|
<if test="slaveIp != null and slaveIp != ''">
|
||||||
|
c.ip_addr = #{slaveIp}
|
||||||
|
</if>
|
||||||
<if test="type=='yx'">
|
<if test="type=='yx'">
|
||||||
and b.yx_addr = #{address}
|
and b.yx_addr = #{address}
|
||||||
</if>
|
</if>
|
||||||
<if test="type=='yc'">
|
<if test="type=='yc'">
|
||||||
and b.yc_addr = #{address}
|
and b.yc_addr = #{address}
|
||||||
</if>
|
</if>
|
||||||
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user