diff --git a/psdc-business/src/main/java/com/psdc/entity/res/PsdcThermometerDataRes.java b/psdc-business/src/main/java/com/psdc/entity/res/PsdcThermometerDataRes.java index a29a5e5..80b7a2d 100644 --- a/psdc-business/src/main/java/com/psdc/entity/res/PsdcThermometerDataRes.java +++ b/psdc-business/src/main/java/com/psdc/entity/res/PsdcThermometerDataRes.java @@ -32,6 +32,8 @@ public class PsdcThermometerDataRes { private Double thermometerValueOut ; /** 数据更新时间 */ private String upDateTime ; + /** 设备安装位置 */ + private String installAddress; /** 当天历史温度集合 */ private List tempTodayList ; diff --git a/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerHtdataMapper.java b/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerHtdataMapper.java index 7737a2f..93f829f 100644 --- a/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerHtdataMapper.java +++ b/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerHtdataMapper.java @@ -38,6 +38,10 @@ public interface PsdcThermometerHtdataMapper{ @Param(value = "beginTime") String begin_time, @Param(value = "endTime") String end_time); + List selTodayThermometer2(@Param(value = "installAddress") String installAddress, + @Param(value = "beginTime") String begin_time, + @Param(value = "endTime") String end_time); + /** * 统计总行数 diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java index 6702874..695bf93 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java @@ -122,36 +122,61 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS String te = sdf.format(date) + " 23:59:59"; // 今天结束检索时间 List ary = new ArrayList<>(); List dataResList = psdcThermometerRtdataMapper.selWenDu(SecurityUtils.getUserId(), modelId, sdf3.format(date)); - for (PsdcThermometerDataRes dec : dataResList ){ - Map map3 = new HashMap(); - List htdata = psdcThermometerHtdataMapper.selTodayThermometer(dec.getDeviceId(), tb, te); - - List listTemp = new ArrayList(); // 今天历史温度集合 - List 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 listTempIn = new ArrayList(); // 今天室内历史温度集合 + List listTempOut = new ArrayList(); // 今天室外历史温度集合 + List timesIn = new ArrayList(); // 今天室内历史温度时间轴 + List timesOut = new ArrayList(); // 今天室外历史温度时间轴 + + List tempInList = psdcThermometerHtdataMapper.selTodayThermometer2("室内", tb, te); + houseInTemp = getaDouble(houseInTemp, countIn, listTempIn, timesIn, tempInList); + List tempOutList = psdcThermometerHtdataMapper.selTodayThermometer2("室外", tb, te); + houseOutTemp = getaDouble(houseOutTemp, countOut, listTempOut, timesOut, tempOutList); + + Map mapIn = new HashMap(); + mapIn.put("houseInTemp", houseInTemp); + mapIn.put("listTempIn", listTempIn); + mapIn.put("timesIn", timesIn); + ary.add(mapIn); + Map 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 listTemp, List times, List 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; + } + /** * 查询电磁锅炉进水、出水温度 * diff --git a/psdc-business/src/main/resources/mapper/business/PsdcThermometerHtdataMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcThermometerHtdataMapper.xml index b3a203d..9f788af 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcThermometerHtdataMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcThermometerHtdataMapper.xml @@ -35,6 +35,26 @@ + + +