|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Double> listTempIn = new ArrayList(); // 今天室内历史温度集合
|
|
|
|
|
List<Double> listTempOut = new ArrayList(); // 今天室外历史温度集合
|
|
|
|
|
List<String> timesIn = new ArrayList(); // 今天室内历史温度时间轴
|
|
|
|
|
List<String> timesOut = new ArrayList(); // 今天室外历史温度时间轴
|
|
|
|
|
|
|
|
|
|
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<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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询电磁锅炉进水、出水温度 |
|
|
|
|
* |
|
|
|
|