林颖晨 2 years ago
commit 2d5f60f6d0
  1. 2
      psdc-business/src/main/java/com/psdc/entity/res/PsdcThermometerDataRes.java
  2. 4
      psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerHtdataMapper.java
  3. 67
      psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java
  4. 20
      psdc-business/src/main/resources/mapper/business/PsdcThermometerHtdataMapper.xml
  5. 3
      psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml

@ -32,6 +32,8 @@ public class PsdcThermometerDataRes {
private Double thermometerValueOut ;
/** 数据更新时间 */
private String upDateTime ;
/** 设备安装位置 */
private String installAddress;
/** 当天历史温度集合 */
private List<Double> tempTodayList ;

@ -38,6 +38,10 @@ public interface PsdcThermometerHtdataMapper{
@Param(value = "beginTime") String begin_time,
@Param(value = "endTime") String end_time);
List<PsdcThermometerHtdata> selTodayThermometer2(@Param(value = "installAddress") String installAddress,
@Param(value = "beginTime") String begin_time,
@Param(value = "endTime") String end_time);
/**
* 统计总行数

@ -122,36 +122,61 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
String te = sdf.format(date) + " 23:59:59"; // 今天结束检索时间
List<Map> ary = new ArrayList<>();
List<PsdcThermometerDataRes> dataResList = psdcThermometerRtdataMapper.selWenDu(SecurityUtils.getUserId(), modelId, sdf3.format(date));
for (PsdcThermometerDataRes dec : dataResList ){
Map<String, Object> map3 = new HashMap();
List<PsdcThermometerHtdata> htdata = psdcThermometerHtdataMapper.selTodayThermometer(dec.getDeviceId(), tb, te);
List<Double> listTemp = new ArrayList(); // 今天历史温度集合
List<String> times = new ArrayList(); // 时间轴
// 循环遍历今天历史数据对象集合
for (PsdcThermometerHtdata h : htdata) {
if (null != h.getThermometerValue()) {
listTemp.add(h.getThermometerValue());
Double houseInTemp = 0.0; // 实验室内平均温度
int countIn = 0;
Double houseOutTemp = 0.0; // 实验室外平均温度
int countOut = 0;
if (dataResList.size() > 0 && null != dataResList) {
for (PsdcThermometerDataRes dsc : dataResList) {
if (dsc.getInstallAddress().contains("室内")) {
houseInTemp = houseInTemp + dsc.getThermometerValue();
countIn = countIn + 1;
}
if (dsc.getInstallAddress().contains("室外")) {
houseOutTemp = houseOutTemp + dsc.getThermometerValue();
countOut = countOut + 1;
}
String t = h.getUpdateTime().split(" ")[1].substring(0, 5);
times.add(t);
}
map3.put("deviceId", dec.getDeviceId());
map3.put("deviceName", dec.getDeviceName());
map3.put("deviceTemp", dec.getThermometerValue());
map3.put("temps", listTemp);
map3.put("times", times);
ary.add(map3);
}
List<Double> listTempIn = new ArrayList(); // 今天室内历史温度集合
List<Double> listTempOut = new ArrayList(); // 今天室外历史温度集合
List<String> timesIn = new ArrayList(); // 今天室内历史温度时间轴
List<String> timesOut = new ArrayList(); // 今天室外历史温度时间轴
List<PsdcThermometerHtdata> tempInList = psdcThermometerHtdataMapper.selTodayThermometer2("室内", tb, te);
houseInTemp = getaDouble(houseInTemp, countIn, listTempIn, timesIn, tempInList);
List<PsdcThermometerHtdata> tempOutList = psdcThermometerHtdataMapper.selTodayThermometer2("室外", tb, te);
houseOutTemp = getaDouble(houseOutTemp, countOut, listTempOut, timesOut, tempOutList);
Map<String, Object> mapIn = new HashMap();
mapIn.put("houseInTemp", houseInTemp);
mapIn.put("listTempIn", listTempIn);
mapIn.put("timesIn", timesIn);
ary.add(mapIn);
Map<String, Object> mapOut = new HashMap();
mapOut.put("houseOutTemp", houseOutTemp);
mapOut.put("listTempOut", listTempOut);
mapOut.put("timesOut", timesOut);
ary.add(mapOut);
return ary;
}
private Double getaDouble(Double houseTemp, int count, List<Double> listTemp, List<String> times, List<PsdcThermometerHtdata> tempList) {
if (tempList.size() == 0) {
count = 1;
}
for (PsdcThermometerHtdata scr1 : tempList) {
Double evIn = scr1.getThermometerValue() / count;
listTemp.add(evIn);
times.add(scr1.getUpdateTime());
}
houseTemp = houseTemp / count;
return houseTemp;
}
/**
* 查询电磁锅炉进水出水温度
*

@ -35,6 +35,26 @@
</select>
<select id="selTodayThermometer2" resultMap="PsdcThermometerHtdataMap">
Select thermometer_htdata_id, SUM(thermometer_value) As thermometer_value, pth.update_time
From psdc_thermometer_htdata pth
LEFT JOIN psdc_device pd On pd.device_id = pth.device_id
<where>
<if test="installAddress != null and installAddress != ''">
pd.device_address LIKE concat('%', #{installAddress}, '%')
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
And date_format(pth.update_time,'%Y-%m-%d %H:%i:%S') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%S')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
And date_format(pth.update_time,'%Y-%m-%d %H:%i:%S') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%S')
</if>
</where>
GROUP BY PTH.update_time
ORDER BY pth.update_time
</select>
<!--分页查询指定行数据-->
<select id="queryAllByLimit" resultMap="PsdcThermometerHtdataMap">
Select

@ -15,6 +15,7 @@
<result property="deviceName" column="device_name" />
<result property="deviceRunStatus" column="device_runstatus" />
<result property="upDateTime" column="upDateTime" />
<result property="installAddress" column="device_address" />
<result property="thermometerValue" column="thermometer_value" />
<result property="thermometerValueIn" column="thermometer_value_in" />
<result property="thermometerValueOut" column="thermometer_value_out" />
@ -36,7 +37,7 @@
</select>
<select id="selWenDu" resultMap="PsdcThermometerRtdataMap2">
Select pd.device_id, pd.device_name, ptr.thermometer_value, DATE_FORMAT(ptr.update_time,'%Y-%m-%d %H') As upDateTime
Select pd.device_id, pd.device_name, IFNULL(ptr.thermometer_value, 0.0) As thermometer_value, pd.device_address, DATE_FORMAT(ptr.update_time,'%Y-%m-%d %H') As upDateTime
From psdc_device pd
LEFT join psdc_thermometer_rtdata ptr on pd.device_id = ptr.device_id
And DATE_FORMAT(ptr.update_time,'%Y-%m-%d %H') = #{today}

Loading…
Cancel
Save