diff --git a/user-service/src/main/java/com/mh/user/controller/NowDataController.java b/user-service/src/main/java/com/mh/user/controller/NowDataController.java index 7543764..433f644 100644 --- a/user-service/src/main/java/com/mh/user/controller/NowDataController.java +++ b/user-service/src/main/java/com/mh/user/controller/NowDataController.java @@ -8,6 +8,8 @@ import com.mh.user.model.DeviceModel; import com.mh.user.model.PumpModel; import com.mh.user.model.WaterLevelModel; import com.mh.user.service.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -23,6 +25,7 @@ import java.util.List; @RequestMapping("monitor") public class NowDataController { + private static final Logger log = LoggerFactory.getLogger(NowDataController.class); @Autowired NowDataService nowDataService; @@ -44,6 +47,7 @@ public class NowDataController { try{ //把热泵的水温保存到公共信息中中的用水温度和回水温度 String avgWaterTemp=nowDataService.selectAve(buildingId); + String maxWaterTemp=nowDataService.selectMaxTemp(buildingId); String buildingName=buildingService.queryBuildingName(buildingId);//获取楼栋名称 SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -56,9 +60,12 @@ public class NowDataController { nowPublicData.setBuildingName(buildingName); if (avgWaterTemp!=null){ nowPublicData.setBackWaterTemp(avgWaterTemp); - nowPublicData.setUseWaterTemp(avgWaterTemp); }else{ nowPublicData.setBackWaterTemp("0"); + } + if (maxWaterTemp!=null){ + nowPublicData.setUseWaterTemp(maxWaterTemp); + }else{ nowPublicData.setUseWaterTemp("0"); } nowPublicDataService.saveNowHistoryPublicData(nowPublicData); @@ -95,7 +102,7 @@ public class NowDataController { list=nowDataService.queryNowData(buildingId); return HttpResult.ok(list); }catch (Exception e){ -// e.printStackTrace(); + log.error("查询当前监控状态出错!",e); return HttpResult.error("查询当前监控状态出错!"); } } diff --git a/user-service/src/main/java/com/mh/user/controller/NowPublicDataController.java b/user-service/src/main/java/com/mh/user/controller/NowPublicDataController.java index f5a259f..5a8d30e 100644 --- a/user-service/src/main/java/com/mh/user/controller/NowPublicDataController.java +++ b/user-service/src/main/java/com/mh/user/controller/NowPublicDataController.java @@ -9,6 +9,7 @@ import com.mh.user.model.TempModel; import com.mh.user.service.BuildingService; import com.mh.user.service.NowDataService; import com.mh.user.service.NowPublicDataService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -20,6 +21,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +@Slf4j @RestController @RequestMapping("monitor_public") public class NowPublicDataController { @@ -39,7 +41,7 @@ public class NowPublicDataController { NowPublicDataEntity nowPublicDataEntity=nowPublicDataService.queryNowPublicData(buildingId); return HttpResult.ok(nowPublicDataEntity); }catch (Exception e){ - //e.printStackTrace(); + log.error("查询公共信息出错!",e); return HttpResult.error("查询公共信息出错!"); } } diff --git a/user-service/src/main/java/com/mh/user/job/DealDataJob.java b/user-service/src/main/java/com/mh/user/job/DealDataJob.java index eaf6852..92d2fff 100644 --- a/user-service/src/main/java/com/mh/user/job/DealDataJob.java +++ b/user-service/src/main/java/com/mh/user/job/DealDataJob.java @@ -111,7 +111,7 @@ public class DealDataJob { } CountDownLatch countDownLatch = new CountDownLatch(Math.min(batchSize, dataComMap.size() - k)); index = k; - for (int j = 0; j < Math.min(batchSize, dataComMap.size() - k); j++) { + for (int j = 0; j < Math.min(batchSize, dataComMap.size() - k); j++) { if (Constant.WEB_FLAG) { break; } diff --git a/user-service/src/main/java/com/mh/user/mapper/NowDataMapper.java b/user-service/src/main/java/com/mh/user/mapper/NowDataMapper.java index 281ef2b..6fe2d0d 100644 --- a/user-service/src/main/java/com/mh/user/mapper/NowDataMapper.java +++ b/user-service/src/main/java/com/mh/user/mapper/NowDataMapper.java @@ -491,4 +491,12 @@ public interface NowDataMapper { "where " + " building_id = #{buildingId} and convert(varchar(10), cur_date, 120) = convert(varchar(10), getdate(), 120) ") Map selectTopOneState(@Param("buildingId") String buildingId); + + @Select("") + String selectMaxTemp(@Param("buildingId") String buildingId, @Param("temp") Integer temp); } diff --git a/user-service/src/main/java/com/mh/user/serialport/SendAndReceiveByCom.java b/user-service/src/main/java/com/mh/user/serialport/SendAndReceiveByCom.java index ebc4fb1..d5a9b6d 100644 --- a/user-service/src/main/java/com/mh/user/serialport/SendAndReceiveByCom.java +++ b/user-service/src/main/java/com/mh/user/serialport/SendAndReceiveByCom.java @@ -59,7 +59,7 @@ public class SendAndReceiveByCom { log.info("有指令下发退出定时采集"); break; } - String comName = deviceManageEntityList.get(i).getDataCom(); + String comName = deviceManageEntityList.get(i).getDataCom().toUpperCase(); if (StringUtils.isBlank(comName)) { log.info("-------------串口:" + comName + "不存在!-------------"); continue; diff --git a/user-service/src/main/java/com/mh/user/service/NowDataService.java b/user-service/src/main/java/com/mh/user/service/NowDataService.java index be37fac..a7a92fd 100644 --- a/user-service/src/main/java/com/mh/user/service/NowDataService.java +++ b/user-service/src/main/java/com/mh/user/service/NowDataService.java @@ -1,15 +1,13 @@ package com.mh.user.service; import com.mh.user.annotation.SysLogger; -import com.mh.user.entity.NowDataEntity; -import com.mh.user.entity.PumpMinutesEntity; -import com.mh.user.entity.WaterLevelEntity; -import com.mh.user.entity.WaterTempEntity; +import com.mh.user.entity.*; import com.mh.user.model.WaterLevelModel; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.util.List; +import java.util.Map; public interface NowDataService { @@ -67,6 +65,13 @@ public interface NowDataService { //从监视表查询热泵温度平均值 String selectAve(String buildingId); + /** + * 查询最高温度 + * @param buildingId + * @return + */ + String selectMaxTemp(String buildingId); + //求单个热泵温度 String selectSingleTemp(String pumpId,String buildingId); @@ -136,5 +141,9 @@ public interface NowDataService { String selectMinPumpId(String buildingId); void updateNowDataByPumpName(String pumpName, String buildingId, String useWater, String backWater, String upWater); + + Map selectTopOneState(String buildingId); + + void updateNowPublicData(NowPublicDataEntity publicData); } diff --git a/user-service/src/main/java/com/mh/user/service/impl/NowDataServiceImpl.java b/user-service/src/main/java/com/mh/user/service/impl/NowDataServiceImpl.java index 7568d9e..43f7a87 100644 --- a/user-service/src/main/java/com/mh/user/service/impl/NowDataServiceImpl.java +++ b/user-service/src/main/java/com/mh/user/service/impl/NowDataServiceImpl.java @@ -18,8 +18,10 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.text.SimpleDateFormat; +import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.Map; import java.util.concurrent.locks.ReentrantLock; @Slf4j @@ -400,6 +402,11 @@ public class NowDataServiceImpl implements NowDataService { return nowDataMapper.selectAve(buildingId, null); } + @Override + public String selectMaxTemp(String buildingId) { + return nowDataMapper.selectMaxTemp(buildingId, null); + } + @Override public String selectSingleTemp(String pumpId,String buildingId) { return nowDataMapper.selectSingleTemp(pumpId,buildingId); @@ -550,4 +557,14 @@ public class NowDataServiceImpl implements NowDataService { public void updateNowDataByPumpName(String pumpName, String buildingId, String useWater, String backWater, String upWater) { nowDataMapper.updateNowDataByPumpName(pumpName, buildingId, useWater, backWater, upWater); } + + @Override + public Map selectTopOneState(String buildingId) { + return nowDataMapper.selectTopOneState(buildingId); + } + + @Override + public void updateNowPublicData(NowPublicDataEntity publicData) { + nowPublicDataMapper.updateNowPublicData(publicData); + } } diff --git a/user-service/src/main/java/com/mh/user/service/impl/NowPublicDataServiceImpl.java b/user-service/src/main/java/com/mh/user/service/impl/NowPublicDataServiceImpl.java index e56a57f..67cc040 100644 --- a/user-service/src/main/java/com/mh/user/service/impl/NowPublicDataServiceImpl.java +++ b/user-service/src/main/java/com/mh/user/service/impl/NowPublicDataServiceImpl.java @@ -46,7 +46,10 @@ public class NowPublicDataServiceImpl implements NowPublicDataService { @Override public NowPublicDataEntity queryNowPublicData(String buildingId) { - return nowPublicDataMapper.queryNowPublicData(buildingId); + NowPublicDataEntity nowPublicDataEntity = nowPublicDataMapper.queryNowPublicData(buildingId); + String maxTemp = nowDataMapper.selectMaxTemp(buildingId, null); + nowPublicDataEntity.setUseWaterTemp(maxTemp); + return nowPublicDataEntity; } @Override @@ -88,13 +91,6 @@ public class NowPublicDataServiceImpl implements NowPublicDataService { if (r1==0){ nowPublicDataMapper.saveNowPublicData(nowPublicDataEntity); } else { - // 判断今天的记录是否存在多个补水,供水,回水状态值 - Map states = nowDataMapper.selectTopOneState(buildingId); - if (states != null && !states.isEmpty()) { - nowPublicDataEntity.setUpWater(String.valueOf(states.get("up_water_state"))); - nowPublicDataEntity.setUseWater(String.valueOf(states.get("use_water_state"))); - nowPublicDataEntity.setBackWater(String.valueOf(states.get("back_water_state"))); - } nowPublicDataMapper.updateNowPublicData(nowPublicDataEntity); } //判断历史表是否有记录 diff --git a/user-service/src/main/java/com/mh/user/strategy/HeatPumpStrategy.java b/user-service/src/main/java/com/mh/user/strategy/HeatPumpStrategy.java index dde9e50..6f030d5 100644 --- a/user-service/src/main/java/com/mh/user/strategy/HeatPumpStrategy.java +++ b/user-service/src/main/java/com/mh/user/strategy/HeatPumpStrategy.java @@ -340,7 +340,9 @@ public class HeatPumpStrategy implements DeviceStrategy { String avgTemp = nowDataService.selectAve(buildingId); NowPublicDataEntity publicData = new NowPublicDataEntity(); publicData.setBuildingId(buildingId); + // 供水温度 publicData.setUseWaterTemp(avgTemp); + // 回水温度 publicData.setBackWaterTemp(avgTemp); String pumpId = nowDataService.selectMinPumpId(buildingId); log.info("---------------addr:" + addr + ",pumpId:" + pumpId + " ---------------"); diff --git a/user-service/src/main/java/com/mh/user/strategy/WaterLevelSwitchStrategy.java b/user-service/src/main/java/com/mh/user/strategy/WaterLevelSwitchStrategy.java index d00884b..5946920 100644 --- a/user-service/src/main/java/com/mh/user/strategy/WaterLevelSwitchStrategy.java +++ b/user-service/src/main/java/com/mh/user/strategy/WaterLevelSwitchStrategy.java @@ -509,15 +509,15 @@ public class WaterLevelSwitchStrategy implements DeviceStrategy { } log.info("-----------------供水/回水状态:" + l8 + "-----------------"); } else { - if (l2.equals("0001")) { //l路,0000表示有输入,0001表示无输入 + if (l2.equals("0001") || l3.equals("0001")) { //2,3路,0000表示有输入,0001表示无输入 publicData.setUseWater("运行"); //供水 publicData.setBackWater("运行");//回水 } else { publicData.setUseWater("不运行"); publicData.setBackWater("不运行"); } - log.info("-----------------供水/回水状态:" + l2 + "-----------------"); - if (l1.equals("0001")) { //2路 //补水 + log.info("-----------------供水/回水状态:" + l2 + "--" + l3 + "-----------------"); + if (l1.equals("0001")) { //1路 //补水 publicData.setUpWater("运行"); } else { publicData.setUpWater("不运行"); @@ -539,6 +539,14 @@ public class WaterLevelSwitchStrategy implements DeviceStrategy { } else { nowDataService.updateNowDataByPumpName(null, buildingId, publicData.getUseWater(), publicData.getBackWater(), publicData.getUpWater()); } + // 判断今天的记录是否存在多个补水,供水,回水状态值 + Map states = nowDataService.selectTopOneState(buildingId); + if (states != null && !states.isEmpty()) { + publicData.setUpWater(String.valueOf(states.get("up_water_state"))); + publicData.setUseWater(String.valueOf(states.get("use_water_state"))); + publicData.setBackWater(String.valueOf(states.get("back_water_state"))); + } + nowDataService.updateNowPublicData(publicData); } } }