Browse Source

1、监控页面实时运行状态;

dev
mh 1 month ago
parent
commit
89728921ba
  1. 43
      user-service/src/main/java/com/mh/user/mapper/NowDataMapper.java
  2. 11
      user-service/src/main/java/com/mh/user/service/impl/NowPublicDataServiceImpl.java
  3. 8
      user-service/src/main/java/com/mh/user/strategy/WaterLevelSwitchStrategy.java

43
user-service/src/main/java/com/mh/user/mapper/NowDataMapper.java

@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;
import java.util.List;
import java.util.Map;
@Mapper
@ -448,4 +449,46 @@ public interface NowDataMapper {
@Param("useWater") String useWater,
@Param("backWater") String backWater,
@Param("upWater") String upWater);
/**
* 查询对应的钱
* @return
*/
@Select("SELECT " +
" TOP 1 " +
" CASE " +
" WHEN EXISTS ( " +
" SELECT " +
" 1 " +
" FROM " +
" now_data " +
" WHERE " +
" up_water_state = '运行') THEN '运行' " +
" ELSE '不运行' " +
" END AS up_water_state, " +
" CASE " +
" WHEN EXISTS ( " +
" SELECT " +
" 1 " +
" FROM " +
" now_data " +
" WHERE " +
" use_water_state = '运行') THEN '运行' " +
" ELSE '不运行' " +
" END AS use_water_state, " +
" CASE " +
" WHEN EXISTS ( " +
" SELECT " +
" 1 " +
" FROM " +
" now_data " +
" WHERE " +
" back_water_state = '运行') THEN '运行' " +
" ELSE '不运行' " +
" END AS back_water_state " +
"FROM " +
" now_data " +
"where " +
" building_id = #{buildingId} and convert(varchar(10), cur_date, 120) = convert(varchar(10), getdate(), 120) ")
Map<String, Object> selectTopOneState(@Param("buildingId") String buildingId);
}

11
user-service/src/main/java/com/mh/user/service/impl/NowPublicDataServiceImpl.java

@ -3,6 +3,7 @@ package com.mh.user.service.impl;
import com.mh.user.entity.NowPublicDataEntity;
import com.mh.user.mapper.BuildingMapper;
import com.mh.user.mapper.DeviceInstallMapper;
import com.mh.user.mapper.NowDataMapper;
import com.mh.user.mapper.NowPublicDataMapper;
import com.mh.user.model.TempModel;
import com.mh.user.service.NowPublicDataService;
@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
@ -29,6 +31,8 @@ public class NowPublicDataServiceImpl implements NowPublicDataService {
BuildingMapper buildingMapper;
private final SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
private NowDataMapper nowDataMapper;
@Override
public void saveNowPublicData(NowPublicDataEntity nowPublicDataEntity) {
@ -84,6 +88,13 @@ 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);
}
//判断历史表是否有记录

8
user-service/src/main/java/com/mh/user/strategy/WaterLevelSwitchStrategy.java

@ -509,20 +509,20 @@ public class WaterLevelSwitchStrategy implements DeviceStrategy {
}
log.info("-----------------供水/回水状态:" + l8 + "-----------------");
} else {
if (l1.equals("0001")) { //l路,0000表示有输入,0001表示无输入
if (l2.equals("0001")) { //l路,0000表示有输入,0001表示无输入
publicData.setUseWater("运行"); //供水
publicData.setBackWater("运行");//回水
} else {
publicData.setUseWater("不运行");
publicData.setBackWater("不运行");
}
log.info("-----------------供水/回水状态:" + l1 + "-----------------");
if (l2.equals("0001")) { //2路 //补水
log.info("-----------------供水/回水状态:" + l2 + "-----------------");
if (l1.equals("0001")) { //2路 //补水
publicData.setUpWater("运行");
} else {
publicData.setUpWater("不运行");
}
log.info("-----------------补水状态:" + l2 + "-----------------");
log.info("-----------------补水状态:" + l1 + "-----------------");
}
nowPublicDataService.saveNowHistoryPublicData(publicData);
log.info("地址:{},供回补水状态保存数据库成功!楼栋ID:{},名称:{}" ,addr, buildingId, buildingName);

Loading…
Cancel
Save