Browse Source

1、添加某栋楼存在高低水位时,可以在监控页面查看到;

2、监控页面添加补水、供水、回水状态;
3、控制页面添加高低水电表读取,补水统一页面设置;
dev
mh 1 month ago
parent
commit
5344d21ea4
  1. 8
      2024数据库脚本.sql
  2. 6
      user-service/src/main/java/com/mh/user/entity/NowDataEntity.java
  3. 16
      user-service/src/main/java/com/mh/user/mapper/NowDataMapper.java
  4. 1
      user-service/src/main/java/com/mh/user/service/NowDataService.java
  5. 5
      user-service/src/main/java/com/mh/user/service/impl/NowDataServiceImpl.java
  6. 24
      user-service/src/main/java/com/mh/user/strategy/WaterLevelSwitchStrategy.java
  7. 9
      user-service/src/test/java/com/mh/user/UserServiceApplicationTests.java
  8. 27
      user-service/src/test/java/com/mh/user/socket/NIOServer.java

8
2024数据库脚本.sql

@ -197,3 +197,11 @@ EXEC chws_gsh.sys.sp_addextendedproperty 'MS_Description', N'14点水位', 'sche
ALTER TABLE chws_gsh.dbo.building ADD low_tank_height numeric(24,2) NULL;
EXEC chws_gsh.sys.sp_addextendedproperty 'MS_Description', N'低区域水箱高度', 'schema', N'dbo', 'table', N'building', 'column', N'low_tank_height';
-- 2024-10-11 添加供水,补水,回水状态
ALTER TABLE now_data ADD up_water_state varchar(50) NULL;
EXEC sp_addextendedproperty 'MS_Description', N'供水状态', 'schema', N'dbo', 'table', N'now_data', 'column', N'up_water_state';
ALTER TABLE now_data ADD use_water_state varchar(50) NULL;
EXEC sp_addextendedproperty 'MS_Description', N'补水状态', 'schema', N'dbo', 'table', N'now_data', 'column', N'use_water_state';
ALTER TABLE now_data ADD back_water_state varchar(50) NULL;
EXEC sp_addextendedproperty 'MS_Description', N'回水状态', 'schema', N'dbo', 'table', N'now_data', 'column', N'back_water_state';

6
user-service/src/main/java/com/mh/user/entity/NowDataEntity.java

@ -23,4 +23,10 @@ public class NowDataEntity {
private String tankName; //水箱名称
private String envTemp; //环境温度
private String upWaterState; // 供水状态
private String useWaterState; // 补水状态
private String backWaterState; // 回水状态
}

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

@ -65,6 +65,9 @@ public interface NowDataMapper {
@Result(property ="tempSet",column ="temp_set"),
@Result(property="waterTemp",column="water_temp"),
@Result(property ="runState",column ="run_state"),
@Result(property ="upWaterState",column ="up_water_state"),
@Result(property ="useWaterState",column ="use_water_state"),
@Result(property ="backWaterState",column ="back_water_state"),
@Result(property ="isFault",column ="is_fault"),
@Result(property ="levelSet",column ="level_set"),
@Result(property ="waterLevel",column ="water_level"),
@ -432,4 +435,17 @@ public interface NowDataMapper {
@Select("select count(1) from now_data where pump_name like '%热泵%' ")
int selectPumpCount(@Param("buildingId") String buildingId);
@Update("<script>" +
"update now_data set use_water_state=#{useWater},back_water_state=#{backWater},up_water_state=#{upWater} " +
" where building_id=#{buildingId} " +
"<if test='pumpName != null and pumpName != \"\"'>" +
" and pump_name like ('%'+#{pumpName}+'%') " +
"</if>" +
"</script>")
void updateNowDataByPumpName(@Param("pumpName") String pumpName,
@Param("buildingId") String buildingId,
@Param("useWater") String useWater,
@Param("backWater") String backWater,
@Param("upWater") String upWater);
}

1
user-service/src/main/java/com/mh/user/service/NowDataService.java

@ -135,5 +135,6 @@ public interface NowDataService {
//通过楼栋编号获取最小热泵id号,规定最小热泵号为单箱
String selectMinPumpId(String buildingId);
void updateNowDataByPumpName(String pumpName, String buildingId, String useWater, String backWater, String upWater);
}

5
user-service/src/main/java/com/mh/user/service/impl/NowDataServiceImpl.java

@ -545,4 +545,9 @@ public class NowDataServiceImpl implements NowDataService {
public String selectMinPumpId(String buildingId) {
return nowDataMapper.selectMinPumpId(buildingId);
}
@Override
public void updateNowDataByPumpName(String pumpName, String buildingId, String useWater, String backWater, String upWater) {
nowDataMapper.updateNowDataByPumpName(pumpName, buildingId, useWater, backWater, upWater);
}
}

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

@ -4,12 +4,10 @@ import com.alibaba.fastjson2.JSON;
import com.mh.common.utils.StringUtils;
import com.mh.user.constants.Constant;
import com.mh.user.entity.DeviceCodeParamEntity;
import com.mh.user.entity.DeviceInstallEntity;
import com.mh.user.entity.NowPublicDataEntity;
import com.mh.user.entity.SysParamEntity;
import com.mh.user.service.BuildingService;
import com.mh.user.service.NowDataService;
import com.mh.user.service.NowPublicDataService;
import com.mh.user.service.SysParamService;
import com.mh.user.service.*;
import com.mh.user.utils.ExchangeStringUtil;
import com.mh.user.utils.SpringBeanUtil;
import lombok.extern.slf4j.Slf4j;
@ -39,6 +37,8 @@ public class WaterLevelSwitchStrategy implements DeviceStrategy {
BuildingService buildingService = context.getBean(BuildingService.class);
DeviceInstallService deviceInstallService = context.getBean(DeviceInstallService.class);
private static class SingletonHolder {
private static final WaterLevelSwitchStrategy INSTANCE = new WaterLevelSwitchStrategy();
}
@ -525,7 +525,21 @@ public class WaterLevelSwitchStrategy implements DeviceStrategy {
log.info("-----------------补水状态:" + l2 + "-----------------");
}
nowPublicDataService.saveNowHistoryPublicData(publicData);
log.info("-----------------状态保存数据库成功!楼栋名称:" + buildingName + "-----------------");
log.info("地址:{},供回补水状态保存数据库成功!楼栋ID:{},名称:{}" ,addr, buildingId, buildingName);
// 更新now_data表中对应的供水、回水、补水状态
DeviceInstallEntity deviceInstallEntity = deviceInstallService.selectDevice(addr, "水位开关", buildingId);
if (deviceInstallEntity != null
&& !StringUtils.isBlank(deviceInstallEntity.getDeviceName())) {
if (deviceInstallEntity.getDeviceName().contains("低")) {
log.info("更新now_data表中低区对应的供水、回水、补水状态,楼栋ID:{},供水状态:{},回水状态:{},补水状态:{}", buildingId, publicData.getUseWater(), publicData.getBackWater(), publicData.getUpWater());
nowDataService.updateNowDataByPumpName("低", buildingId, publicData.getUseWater(), publicData.getBackWater(), publicData.getUpWater());
} else if (deviceInstallEntity.getDeviceName().contains("高")) {
log.info("更新now_data表中高区对应的供水、回水、补水状态,楼栋ID:{},供水状态:{},回水状态:{},补水状态:{}", buildingId, publicData.getUseWater(), publicData.getBackWater(), publicData.getUpWater());
nowDataService.updateNowDataByPumpName("高", buildingId, publicData.getUseWater(), publicData.getBackWater(), publicData.getUpWater());
} else {
nowDataService.updateNowDataByPumpName(null, buildingId, publicData.getUseWater(), publicData.getBackWater(), publicData.getUpWater());
}
}
}
}
return Constant.FAIL;

9
user-service/src/test/java/com/mh/user/UserServiceApplicationTests.java

@ -8,6 +8,7 @@ import com.mh.user.serialport.SerialPortThread;
import com.mh.user.service.DeviceManageService;
import com.mh.user.service.GaugeService;
import com.mh.user.service.HistoryDataPreService;
import com.mh.user.service.NowDataService;
import com.mh.user.strategy.PressureTransStrategy;
import com.mh.user.utils.*;
import org.checkerframework.checker.units.qual.A;
@ -145,4 +146,12 @@ class UserServiceApplicationTests {
System.out.println(energyPre);
}
@Autowired
private NowDataService nowDataService;
@Test
public void testNowData() {
nowDataService.updateNowDataByPumpName(null, "21", "1", "2", "3");
}
}

27
user-service/src/test/java/com/mh/user/socket/NIOServer.java

@ -29,16 +29,27 @@ public class NIOServer {
private static ArrayList<SocketChannel> channels = new ArrayList<>();
public static void main(String[] args) throws IOException {
log.info("test");
NIOServer nioServer = new NIOServer();
// 缓冲测试
// nioServer.BufferTest();
// 通道测试
// nioServer.ChannelTest();
// Selector单线程操作
nioServer.SelectorSingleTest();
// log.info("test");
// NIOServer nioServer = new NIOServer();
// // 缓冲测试
//// nioServer.BufferTest();
// // 通道测试
//// nioServer.ChannelTest();
// // Selector单线程操作
// nioServer.SelectorSingleTest();
StringBuilder dataStr = new StringBuilder();
ArrayList<Object> objects = new ArrayList<>();
test1(dataStr, objects);
System.out.println(dataStr.toString());
System.out.println(objects.get(0));
}
public static String test1(StringBuilder dataStr, ArrayList<Object> objects) {
dataStr.append("12345678911111");
objects.add(dataStr);
return "123456789";
}
// 缓冲区使用
public void BufferTest(){
// // 构建一个堆内字节缓冲区

Loading…
Cancel
Save