Browse Source

1、实时监控以及多路控制器采集bug修复。

dev
mh 3 weeks ago
parent
commit
dadfdafa87
  1. 11
      user-service/src/main/java/com/mh/user/controller/NowDataController.java
  2. 4
      user-service/src/main/java/com/mh/user/controller/NowPublicDataController.java
  3. 2
      user-service/src/main/java/com/mh/user/job/DealDataJob.java
  4. 8
      user-service/src/main/java/com/mh/user/mapper/NowDataMapper.java
  5. 2
      user-service/src/main/java/com/mh/user/serialport/SendAndReceiveByCom.java
  6. 17
      user-service/src/main/java/com/mh/user/service/NowDataService.java
  7. 17
      user-service/src/main/java/com/mh/user/service/impl/NowDataServiceImpl.java
  8. 12
      user-service/src/main/java/com/mh/user/service/impl/NowPublicDataServiceImpl.java
  9. 2
      user-service/src/main/java/com/mh/user/strategy/HeatPumpStrategy.java
  10. 14
      user-service/src/main/java/com/mh/user/strategy/WaterLevelSwitchStrategy.java

11
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("查询当前监控状态出错!");
}
}

4
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("查询公共信息出错!");
}
}

2
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;
}

8
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<String, Object> selectTopOneState(@Param("buildingId") String buildingId);
@Select("<script>" +
"select Convert(decimal(18,1),max(CAST(water_temp as FLOAT))) from now_data where building_id=#{buildingId} " +
"<if test='temp != null'>" +
" and water_temp >= #{temp} " +
"</if>" +
"</script>")
String selectMaxTemp(@Param("buildingId") String buildingId, @Param("temp") Integer temp);
}

2
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;

17
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<String, Object> selectTopOneState(String buildingId);
void updateNowPublicData(NowPublicDataEntity publicData);
}

17
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<String, Object> selectTopOneState(String buildingId) {
return nowDataMapper.selectTopOneState(buildingId);
}
@Override
public void updateNowPublicData(NowPublicDataEntity publicData) {
nowPublicDataMapper.updateNowPublicData(publicData);
}
}

12
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<String, Object> 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);
}
//判断历史表是否有记录

2
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 + " ---------------");

14
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<String, Object> 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);
}
}
}

Loading…
Cancel
Save