feat(ems): 为监测点添加能源名称字段并优化查询性能

- 在 EmsBaseMonitorInfo 类中添加 energyName 字段
- 更新 EmsBaseMonitorInfoMapper.xml 以包含能源名称查询
- 优化查询语句,使用别名区分表,提高可读性和性能
- 调整缓存刷新间隔为 60 秒,提升数据新鲜度
boardTest
zch 3 months ago
parent 8c4d541123
commit 0f3cbb05c1

@ -86,6 +86,8 @@ public class EmsBaseMonitorInfo extends BaseEntity
@Excel(name = "表具层级")
private Long monitorHierarchy;
private String energyName;
private List<EmsBaseMonitorInfo> children = new ArrayList<EmsBaseMonitorInfo>();
private String parentName;
@ -300,6 +302,14 @@ public class EmsBaseMonitorInfo extends BaseEntity
return monitorHierarchy;
}
public String getEnergyName() {
return energyName;
}
public void setEnergyName(String energyName) {
this.energyName = energyName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -7,10 +7,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 启用二级缓存 -->
<cache
eviction="LRU"
flushInterval="3600000"
flushInterval="60000"
size="1000"
readOnly="true"/>
<resultMap type="EmsBaseMonitorInfo" id="EmsBaseMonitorInfoResult">
<result property="objId" column="obj_id" />
<result property="parentId" column="parent_id" />
@ -35,49 +35,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="publicShareType" column="public_share_type" />
<result property="monitorHierarchy" column="monitor_hierarchy" />
<result property="energyName" column="energy_name" />
</resultMap>
<sql id="selectEmsBaseMonitorInfoVo">
select obj_id, parent_id, monitor_code, monitor_name, monitor_addr, monitor_type, monitor_status, collect_device_id, ancestors, grade, meter_type_id, correct_value, pt, ct, is_ammeter, is_key_monitor, is_circuit, create_by, create_time, update_by, update_time, public_share_type, monitor_hierarchy from ems_base_monitor_info
select ebmi.obj_id, ebmi.parent_id, ebmi.monitor_code, ebmi.monitor_name, ebmi.monitor_addr,
ebmi.monitor_type, ebmi.monitor_status, ebmi.collect_device_id, ebmi.ancestors, ebmi.grade, ebmi.meter_type_id, ebmi.correct_value, ebmi.pt,
ebmi.ct, ebmi.is_ammeter, ebmi.is_key_monitor, ebmi.is_circuit, ebmi.create_by, ebmi.create_time, ebmi.update_by, ebmi.update_time, ebmi.public_share_type,
ebmi.monitor_hierarchy,
ebet.energy_name
from ems_base_monitor_info ebmi
left join ems_base_energy_type ebet on ebet.energy_type_id = ebmi.monitor_type
</sql>
<select id="selectEmsBaseMonitorInfoList" parameterType="EmsBaseMonitorInfo" resultMap="EmsBaseMonitorInfoResult">
<include refid="selectEmsBaseMonitorInfoVo"/>
<where>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="monitorCode != null and monitorCode != ''"> and monitor_code = #{monitorCode}</if>
<if test="monitorName != null and monitorName != ''"> and monitor_name like concat('%', #{monitorName}, '%')</if>
<if test="parentId != null "> and ebmi.parent_id = #{parentId}</if>
<if test="monitorCode != null and monitorCode != ''"> and ebmi.monitor_code = #{monitorCode}</if>
<if test="monitorName != null and monitorName != ''"> and ebmi.monitor_name like concat('%', #{monitorName}, '%')</if>
<if test="monitorTypeList != null and monitorTypeList.size > 0">
and monitor_type IN
and ebmi.monitor_type IN
<foreach item="monitorId" collection="monitorTypeList" open="(" separator="," close=")">
#{monitorId}
</foreach>
</if>
<if test="monitorAddr != null and monitorAddr != ''"> and monitor_addr = #{monitorAddr}</if>
<if test="monitorType != null "> and monitor_type = #{monitorType}</if>
<if test="monitorStatus != null "> and monitor_status = #{monitorStatus}</if>
<if test="collectDeviceId != null and collectDeviceId != ''"> and collect_device_id = #{collectDeviceId}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="grade != null "> and grade = #{grade}</if>
<if test="meterTypeId != null and meterTypeId != ''"> and meter_type_id = #{meterTypeId}</if>
<if test="correctValue != null "> and correct_value = #{correctValue}</if>
<if test="pt != null "> and pt = #{pt}</if>
<if test="ct != null "> and ct = #{ct}</if>
<if test="isAmmeter != null and isAmmeter != ''"> and is_ammeter = #{isAmmeter}</if>
<if test="isKeyMonitor != null "> and is_key_monitor = #{isKeyMonitor}</if>
<if test="isCircuit != null "> and is_circuit = #{isCircuit}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by = #{updateBy}</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="publicShareType != null "> and public_share_type = #{publicShareType}</if>
<if test="monitorHierarchy != null "> and monitor_hierarchy = #{monitorHierarchy}</if>
<if test="monitorAddr != null and monitorAddr != ''"> and ebmi.monitor_addr = #{monitorAddr}</if>
<if test="monitorType != null "> and ebmi.monitor_type = #{monitorType}</if>
<if test="monitorStatus != null "> and ebmi.monitor_status = #{monitorStatus}</if>
<if test="collectDeviceId != null and collectDeviceId != ''"> and ebmi.collect_device_id = #{collectDeviceId}</if>
<if test="ancestors != null and ancestors != ''"> and ebmi.ancestors = #{ancestors}</if>
<if test="grade != null "> and ebmi.grade = #{grade}</if>
<if test="meterTypeId != null and meterTypeId != ''"> and ebmi.meter_type_id = #{meterTypeId}</if>
<if test="correctValue != null "> and ebmi.correct_value = #{correctValue}</if>
<if test="pt != null "> and ebmi.pt = #{pt}</if>
<if test="ct != null "> and ebmi.ct = #{ct}</if>
<if test="isAmmeter != null and isAmmeter != ''"> and ebmi.is_ammeter = #{isAmmeter}</if>
<if test="isKeyMonitor != null "> and ebmi.is_key_monitor = #{isKeyMonitor}</if>
<if test="isCircuit != null "> and ebmi.is_circuit = #{isCircuit}</if>
<if test="createBy != null and createBy != ''"> and ebmi.create_by = #{createBy}</if>
<if test="createTime != null "> and ebmi.create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and ebmi.update_by = #{updateBy}</if>
<if test="updateTime != null "> and ebmi.update_time = #{updateTime}</if>
<if test="publicShareType != null "> and ebmi.public_share_type = #{publicShareType}</if>
<if test="monitorHierarchy != null "> and ebmi.monitor_hierarchy = #{monitorHierarchy}</if>
</where>
</select>
<select id="selectEmsBaseMonitorInfoByObjId" parameterType="Long" resultMap="EmsBaseMonitorInfoResult">
<include refid="selectEmsBaseMonitorInfoVo"/>
where obj_id = #{objId}
where ebmi.obj_id = #{objId}
</select>
<select id="selectEmsBaseMonitorTypeByMonitorCode" parameterType="String">
@ -182,7 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 根据设备编码列表查询设备信息 -->
<select id="selectMonitorInfoByCodes" resultMap="EmsBaseMonitorInfoResult">
<include refid="selectEmsBaseMonitorInfoVo"/>
WHERE monitor_code IN
WHERE ebmi.monitor_code IN
<foreach collection="monitorCodes" item="monitorCode" open="(" separator="," close=")">
#{monitorCode}
</foreach>

Loading…
Cancel
Save