change(record): 修改查询蒸汽实时数据功能

- 新增了按设备查询最新记录的功能
- 优化了查询逻辑,支持按监控编码分组查询
- 调整了实时数据页面服务层的查询方法,没有选择设备就显示每个设备的最新一条记录
master
zch 7 months ago
parent 8ce842a919
commit 1337bec423

@ -59,14 +59,6 @@ public interface EmsRecordSteamInstantMapper {
*/
public int deleteEmsRecordSteamInstantByObjIds(Long[] objIds);
/**
*
*
* @param emsRecordSteamInstant
* @return
*/
public List<EmsRecordSteamInstant> selectEmsRecordLatestSteamInstantList(EmsRecordSteamInstant emsRecordSteamInstant);
/**
*
@ -76,4 +68,22 @@ public interface EmsRecordSteamInstantMapper {
*/
public List<EmsRecordSteamInstant> selectEmsRecordSteamInstantListByTime(EmsRecordSteamInstant emsRecordSteamInstant);
/**
*
*
* @param emsRecordSteamInstant
* @return
*/
public List<EmsRecordSteamInstant> selectEmsRecordLatestSteamInstantList(EmsRecordSteamInstant emsRecordSteamInstant);
/**
* MonitorCode
*
* @param emsRecordSteamInstant
* @return
*/
public List<EmsRecordSteamInstant> selectEmsRecordLatestSteamInstantListByMonitorCode(EmsRecordSteamInstant emsRecordSteamInstant);
}

@ -1,6 +1,7 @@
package com.os.ems.record.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -90,16 +91,36 @@ public class EmsRecordSteamInstantServiceImpl implements IEmsRecordSteamInstantS
/**
*
*
*
* @param emsRecordSteamInstant
* @return
*/
@Override
public List<EmsRecordSteamInstant> selectEmsRecordLatestSteamInstantList(EmsRecordSteamInstant emsRecordSteamInstant){
/* return emsRecordSteamInstantMapper.selectEmsRecordLatestSteamInstantList(emsRecordSteamInstant);*/
//只返回第一条数据,subList从索引0开始只截取1条
return emsRecordSteamInstantMapper.selectEmsRecordLatestSteamInstantList(emsRecordSteamInstant).subList(0,1);
//获取监控编码
String monitorCode = emsRecordSteamInstant.getMonitorCode();
//初始化返回列表
List<EmsRecordSteamInstant> emsRecordSteamInstants = new ArrayList<>();
//判断监控编码是否为空
if (monitorCode == null){
//没有选择设备monitorCode为空的时候分组查询全部设备的最新一条记录
List<EmsRecordSteamInstant> allEmsRecordSteamInstants = emsRecordSteamInstantMapper
.selectEmsRecordLatestSteamInstantList(emsRecordSteamInstant);
//遍历查询结果
for (EmsRecordSteamInstant recordSteamInstantallEmsRecordSteamInstants : allEmsRecordSteamInstants){
//如果有设备名称就添加到返回集合中
if (recordSteamInstantallEmsRecordSteamInstants.getMonitorName() != null){
emsRecordSteamInstants.add(recordSteamInstantallEmsRecordSteamInstants);
}
}
}else {
//选择了设备monitorCode不为空的时候根据monitorCode查询指定设备的最新一条记录
emsRecordSteamInstants = emsRecordSteamInstantMapper
.selectEmsRecordLatestSteamInstantListByMonitorCode(emsRecordSteamInstant).subList(0, 1);
}
//返回查询结果
return emsRecordSteamInstants;
}

@ -66,30 +66,7 @@
where ersi.obj_id = #{objId}
</select>
<select id="selectEmsRecordLatestSteamInstantList"
parameterType="EmsRecordSteamInstant"
resultMap="EmsRecordSteamInstantResult">
<include refid="selectEmsRecordSteamInstantVo"/>
<where>
<if test="objId != null">and ersi.obj_id = #{objId}</if>
<if test="monitorCode != null and monitorCode != ''">and ersi.monitor_code = #{monitorCode}</if>
<if test="params.beginCollectTime != null and params.beginCollectTime != '' and params.endCollectTime != null and params.endCollectTime != ''">
and ersi.collect_time between #{params.beginCollectTime} and #{params.endCollectTime}
</if>
<if test="fluxFlow != null ">and ersi.flux_flow = #{fluxFlow}</if>
<if test="steamFlow != null ">and ersi.steam_flow = #{steamFlow}</if>
<if test="heatInstantValue != null ">and ersi.heat_instant_value = #{heatInstantValue}</if>
<if test="heatTotalValue != null ">and ersi.heat_total_value = #{heatTotalValue}</if>
<if test="temperature != null ">and ersi.temperature = #{temperature}</if>
<if test="press != null ">and ersi.press = #{press}</if>
<if test="density != null ">and ersi.density = #{density}</if>
<if test="differencePress != null ">and ersi.difference_press = #{differencePress}</if>
<if test="params.beginRecordTime != null and params.beginRecordTime != '' and params.endRecordTime != null and params.endRecordTime != ''">
and ersi.record_time between #{params.beginRecordTime} and #{params.endRecordTime}
</if>
</where>
order by ersi.obj_id desc
</select>
<insert id="insertEmsRecordSteamInstant" parameterType="EmsRecordSteamInstant" useGeneratedKeys="true"
keyProperty="objId">
@ -176,4 +153,92 @@
</where>
order by ersi.record_time desc
</select>
</mapper>
<select id="selectEmsRecordLatestSteamInstantListByMonitorCode"
parameterType="EmsRecordSteamInstant"
resultMap="EmsRecordSteamInstantResult">
<include refid="selectEmsRecordSteamInstantVo"/>
<where>
<if test="objId != null">and ersi.obj_id = #{objId}</if>
<if test="monitorCode != null and monitorCode != ''">and ersi.monitor_code = #{monitorCode}</if>
<if test="params.beginCollectTime != null and params.beginCollectTime != '' and params.endCollectTime != null and params.endCollectTime != ''">
and ersi.collect_time between #{params.beginCollectTime} and #{params.endCollectTime}
</if>
<if test="fluxFlow != null ">and ersi.flux_flow = #{fluxFlow}</if>
<if test="steamFlow != null ">and ersi.steam_flow = #{steamFlow}</if>
<if test="heatInstantValue != null ">and ersi.heat_instant_value = #{heatInstantValue}</if>
<if test="heatTotalValue != null ">and ersi.heat_total_value = #{heatTotalValue}</if>
<if test="temperature != null ">and ersi.temperature = #{temperature}</if>
<if test="press != null ">and ersi.press = #{press}</if>
<if test="density != null ">and ersi.density = #{density}</if>
<if test="differencePress != null ">and ersi.difference_press = #{differencePress}</if>
<if test="params.beginRecordTime != null and params.beginRecordTime != '' and params.endRecordTime != null and params.endRecordTime != ''">
and ersi.record_time between #{params.beginRecordTime} and #{params.endRecordTime}
</if>
</where>
order by ersi.obj_id desc
</select>
<!--
&lt;!&ndash; 查询每个设备的最新一条记录 &ndash;&gt;
<select id="selectEmsRecordLatestSteamInstantList" parameterType="EmsRecordSteamInstant" resultMap="EmsRecordSteamInstantResult">
SELECT
ersi.obj_id,
ersi.monitor_code,
ebmi.monitor_name,
ersi.collect_time,
ersi.flux_flow,
ersi.steam_flow,
ersi.heat_instant_value,
ersi.heat_total_value,
ersi.temperature,
ersi.press,
ersi.density,
ersi.difference_press,
ersi.record_time
FROM
ems_record_steam_instant ersi
LEFT JOIN
ems_base_monitor_info ebmi ON ersi.monitor_code = ebmi.monitor_code
WHERE
ersi.obj_id = (
SELECT MAX(obj_id)
FROM ems_record_steam_instant
WHERE monitor_code = ersi.monitor_code
)
ORDER BY ersi.monitor_code ASC
</select>
-->
<!-- 查询每个设备的最新一条记录 -->
<select id="selectEmsRecordLatestSteamInstantList" parameterType="EmsRecordSteamInstant" resultMap="EmsRecordSteamInstantResult">
SELECT
ersi.obj_id,
ersi.monitor_code,
ebmi.monitor_name,
ersi.collect_time,
ersi.flux_flow,
ersi.steam_flow,
ersi.heat_instant_value,
ersi.heat_total_value,
ersi.temperature,
ersi.press,
ersi.density,
ersi.difference_press,
ersi.record_time
FROM
ems_record_steam_instant ersi
LEFT JOIN ems_base_monitor_info ebmi ON ersi.monitor_code = ebmi.monitor_code
INNER JOIN (
SELECT monitor_code, MAX(obj_id) AS max_obj_id
FROM ems_record_steam_instant
GROUP BY monitor_code
) ersi_max ON ersi.monitor_code = ersi_max.monitor_code AND ersi.obj_id = ersi_max.max_obj_id
ORDER BY ersi.monitor_code ASC;
</select>
</mapper>

Loading…
Cancel
Save