diff --git a/2024数据库脚本.sql b/2024数据库脚本.sql index 62f3db4..e60e2ef 100644 --- a/2024数据库脚本.sql +++ b/2024数据库脚本.sql @@ -188,4 +188,12 @@ EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间', @le EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'状态', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'knowledge_data', @level2type=N'Column', @level2name=N'status'; EXEC sp_addextendedproperty @name=N'MS_Description', @value=N'备注', @level0type=N'Schema', @level0name=N'dbo', @level1type=N'Table', @level1name=N'knowledge_data', @level2type=N'Column', @level2name=N'remark'; -create index knowledge_data_create_time on history_data_pre (create_time); \ No newline at end of file +create index knowledge_data_create_time on history_data_pre (create_time); + +-- 2024-07-01 水位变换添加 +ALTER TABLE chws_gsh.dbo.waterLevel ADD level14 varchar(50) NULL; +EXEC chws_gsh.sys.sp_addextendedproperty 'MS_Description', N'14点水位', 'schema', N'dbo', 'table', N'waterLevel', 'column', N'level14'; + +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'; + diff --git a/user-service/src/main/java/com/mh/user/controller/BuildingController.java b/user-service/src/main/java/com/mh/user/controller/BuildingController.java index 815fe28..f90b5bf 100644 --- a/user-service/src/main/java/com/mh/user/controller/BuildingController.java +++ b/user-service/src/main/java/com/mh/user/controller/BuildingController.java @@ -176,6 +176,9 @@ public class BuildingController { rolName = "水箱高度"; break; case 8 : + rolName = "水箱高度(低区)"; + break; + case 9 : rolName = "热泵个数"; break; } @@ -190,13 +193,14 @@ public class BuildingController { // 创建实体类 BuildingEntity uploadEntity = new BuildingEntity(); uploadEntity.setBuildingName(deviceList.get(0));//楼栋名称 - uploadEntity.setLevelsCount(Integer.parseInt(deviceList.get(1))); //楼层数 - uploadEntity.setBeginLevel(Integer.parseInt(deviceList.get(2))); //起始楼层 - uploadEntity.setHouseCount(Integer.parseInt(deviceList.get(3))); //每层宿舍数 - uploadEntity.setBedCount(Integer.parseInt(deviceList.get(4))); //床位数 - uploadEntity.setCheckInCount(Integer.parseInt(deviceList.get(5))); //实际入住数 - uploadEntity.setTankHeight(Double.parseDouble(deviceList.get(6))); //实际入住数 - uploadEntity.setPumpCount(Integer.parseInt(deviceList.get(7))); //实际入住数 + uploadEntity.setLevelsCount(Integer.parseInt(deviceList.get(1))); //楼层数 + uploadEntity.setBeginLevel(Integer.parseInt(deviceList.get(2))); //起始楼层 + uploadEntity.setHouseCount(Integer.parseInt(deviceList.get(3))); //每层宿舍数 + uploadEntity.setBedCount(Integer.parseInt(deviceList.get(4))); //床位数 + uploadEntity.setCheckInCount(Integer.parseInt(deviceList.get(5))); //实际入住数 + uploadEntity.setTankHeight(Double.parseDouble(deviceList.get(6))); //默认(高区)水箱高度 + uploadEntity.setLowTankHeight(Double.parseDouble(deviceList.get(7))); //低区水箱高度 + uploadEntity.setPumpCount(Integer.parseInt(deviceList.get(8))); //热泵个数 deviceList.clear(); diff --git a/user-service/src/main/java/com/mh/user/entity/BuildingEntity.java b/user-service/src/main/java/com/mh/user/entity/BuildingEntity.java index 550b35d..92e84bd 100644 --- a/user-service/src/main/java/com/mh/user/entity/BuildingEntity.java +++ b/user-service/src/main/java/com/mh/user/entity/BuildingEntity.java @@ -16,6 +16,7 @@ public class BuildingEntity { private String areaId; private String remarks; private Double tankHeight; + private Double lowTankHeight; private int pumpCount; } diff --git a/user-service/src/main/java/com/mh/user/entity/WaterLevelEntity.java b/user-service/src/main/java/com/mh/user/entity/WaterLevelEntity.java index 7488a20..6be325f 100644 --- a/user-service/src/main/java/com/mh/user/entity/WaterLevelEntity.java +++ b/user-service/src/main/java/com/mh/user/entity/WaterLevelEntity.java @@ -16,6 +16,7 @@ public class WaterLevelEntity { private String level08; private String level11; private String level13; + private String level14; private String level15; private String level16; private String level17; diff --git a/user-service/src/main/java/com/mh/user/entity/WaterTempEntity.java b/user-service/src/main/java/com/mh/user/entity/WaterTempEntity.java index c790bf3..175651e 100644 --- a/user-service/src/main/java/com/mh/user/entity/WaterTempEntity.java +++ b/user-service/src/main/java/com/mh/user/entity/WaterTempEntity.java @@ -25,7 +25,7 @@ public class WaterTempEntity { private String temp11; // private String temp12; private String temp13; -// private String temp14; + private String temp14; private String temp15; private String temp16; private String temp17; 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 0997ddd..ebd096f 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 @@ -50,7 +50,7 @@ public class DealDataJob { /** * 定时处理汇总数据:每15分钟处理一次,十分钟(0 0/10 * * * ?) */ - @Scheduled(cron = "0 0/15 * * * ?") +// @Scheduled(cron = "0 0/15 * * * ?") public void ProEnergy() { try { SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); @@ -148,7 +148,7 @@ public class DealDataJob { /** * 定时处理数据:每十五分钟处理一次 */ - @Scheduled(cron = "0 0/15 * * * ?") +// @Scheduled(cron = "0 0/15 * * * ?") public void dealData() { try { StopWatch stopWatch = new StopWatch(); diff --git a/user-service/src/main/java/com/mh/user/mapper/BuildingMapper.java b/user-service/src/main/java/com/mh/user/mapper/BuildingMapper.java index c7d4006..1e24611 100644 --- a/user-service/src/main/java/com/mh/user/mapper/BuildingMapper.java +++ b/user-service/src/main/java/com/mh/user/mapper/BuildingMapper.java @@ -15,8 +15,8 @@ public interface BuildingMapper { * 保存楼栋信息 * @param buildingEntity */ - @Insert("insert into building(building_name,levels_count,begin_level,house_count,bed_count,check_in_count,area_id,remarks,tankHeight,pump_count) values (" + - "#{buildingName},#{levelsCount},#{beginLevel},#{houseCount},#{bedCount},#{checkInCount},#{areaId},#{remarks},#{tankHeight}, #{pumpCount})") + @Insert("insert into building(building_name,levels_count,begin_level,house_count,bed_count,check_in_count,area_id,remarks,tankHeight,pump_count,low_tank_height) values (" + + "#{buildingName},#{levelsCount},#{beginLevel},#{houseCount},#{bedCount},#{checkInCount},#{areaId},#{remarks},#{tankHeight}, #{pumpCount}, #{lowTabkHeight})") int saveBuilding(BuildingEntity buildingEntity); /** @@ -35,6 +35,7 @@ public interface BuildingMapper { " , area_id = #{areaId} " + " , remarks = #{remarks} " + " , tankHeight = #{tankHeight} " + + " , low_tank_height = #{lowTankHeight} " + " , pump_count = #{pumpCount} " + " where id = #{id} " + "") @@ -57,7 +58,9 @@ public interface BuildingMapper { @Result(property="checkInCount",column="check_in_count"), @Result(property="areaId",column="area_id"), @Result(property="pumpCount",column="pump_count"), - @Result(property="remarks",column="remarks") + @Result(property="remarks",column="remarks"), + @Result(property="tankHeight",column="tankHeight"), + @Result(property="lowTankHeight",column="low_tank_height") }) @SelectProvider(type = BuildingProvider.class,method = "queryBuilding") @@ -116,4 +119,7 @@ public interface BuildingMapper { @Select("select building_name from building where id = #{buildingId} ") String selectBuildingNameById(@Param("buildingId") String buildingId); + + @Select("select low_tank_height from building where id=#{id}" ) + Double queryLowTankHeight(@Param("id") String buildingId); } diff --git a/user-service/src/main/java/com/mh/user/mapper/provider/NowDataProvider.java b/user-service/src/main/java/com/mh/user/mapper/provider/NowDataProvider.java index 7ddc73f..71a6523 100644 --- a/user-service/src/main/java/com/mh/user/mapper/provider/NowDataProvider.java +++ b/user-service/src/main/java/com/mh/user/mapper/provider/NowDataProvider.java @@ -176,7 +176,9 @@ public class NowDataProvider { "convert(decimal(8,1),AVG(convert(float,t1.temp02)))as temp02," + "convert(decimal(8,1),AVG(convert(float,t1.temp06)))as temp06," + "convert(decimal(8,1),AVG(convert(float,t1.temp08)))as temp08,convert(decimal(8,1),AVG(convert(float,t1.temp11)))as temp11," + - "convert(decimal(8,1),AVG(convert(float,t1.temp13)))as temp13,convert(decimal(8,1),AVG(convert(float,t1.temp15)))as temp15," + + "convert(decimal(8,1),AVG(convert(float,t1.temp13)))as temp13," + + "convert(decimal(8,1),AVG(convert(float,t1.temp14)))as temp14," + + "convert(decimal(8,1),AVG(convert(float,t1.temp15)))as temp15," + "convert(decimal(8,1),AVG(convert(float,t1.temp16)))as temp16,convert(decimal(8,1),AVG(convert(float,t1.temp17)))as temp17," + "convert(decimal(8,1),AVG(convert(float,t1.temp18)))as temp18,convert(decimal(8,1),AVG(convert(float,t1.temp19)))as temp19," + "convert(decimal(8,1),AVG(convert(float,t1.temp20)))as temp20,convert(decimal(8,1),AVG(convert(float,t1.temp21)))as temp21," + @@ -200,7 +202,9 @@ public class NowDataProvider { "select t1.cur_date,t1.building_id,t2.building_name,t2.sort,convert(decimal(8,1),AVG(convert(float,t1.temp00)))as temp00," + "convert(decimal(8,1),AVG(convert(float,t1.temp02)))as temp02,convert(decimal(8,1),AVG(convert(float,t1.temp06)))as temp06," + "convert(decimal(8,1),AVG(convert(float,t1.temp08)))as temp08,convert(decimal(8,1),AVG(convert(float,t1.temp11)))as temp11," + - "convert(decimal(8,1),AVG(convert(float,t1.temp13)))as temp13,convert(decimal(8,1),AVG(convert(float,t1.temp15)))as temp15," + + "convert(decimal(8,1),AVG(convert(float,t1.temp13)))as temp13," + + "convert(decimal(8,1),AVG(convert(float,t1.temp14)))as temp14," + + "convert(decimal(8,1),AVG(convert(float,t1.temp15)))as temp15," + "convert(decimal(8,1),AVG(convert(float,t1.temp16)))as temp16,convert(decimal(8,1),AVG(convert(float,t1.temp17)))as temp17," + "convert(decimal(8,1),AVG(convert(float,t1.temp18)))as temp18,convert(decimal(8,1),AVG(convert(float,t1.temp19)))as temp19," + "convert(decimal(8,1),AVG(convert(float,t1.temp20)))as temp20,convert(decimal(8,1),AVG(convert(float,t1.temp21)))as temp21," + diff --git a/user-service/src/main/java/com/mh/user/service/BuildingService.java b/user-service/src/main/java/com/mh/user/service/BuildingService.java index f2a3a97..6a750cb 100644 --- a/user-service/src/main/java/com/mh/user/service/BuildingService.java +++ b/user-service/src/main/java/com/mh/user/service/BuildingService.java @@ -72,4 +72,6 @@ public interface BuildingService { int selectPumpCount(String buildingId); String selectBuildingNameById(String buildingId); + + Double queryLowTankHeight(String buildingId); } diff --git a/user-service/src/main/java/com/mh/user/service/impl/BuildingServiceImpl.java b/user-service/src/main/java/com/mh/user/service/impl/BuildingServiceImpl.java index 38080b3..99f3b10 100644 --- a/user-service/src/main/java/com/mh/user/service/impl/BuildingServiceImpl.java +++ b/user-service/src/main/java/com/mh/user/service/impl/BuildingServiceImpl.java @@ -93,4 +93,9 @@ public class BuildingServiceImpl implements BuildingService { public String selectBuildingNameById(String buildingId) { return buildingMapper.selectBuildingNameById(buildingId); } + + @Override + public Double queryLowTankHeight(String buildingId) { + return buildingMapper.queryLowTankHeight(buildingId); + } } diff --git a/user-service/src/main/java/com/mh/user/strategy/PressureTransStrategy.java b/user-service/src/main/java/com/mh/user/strategy/PressureTransStrategy.java index dcf97c5..ef7eb74 100644 --- a/user-service/src/main/java/com/mh/user/strategy/PressureTransStrategy.java +++ b/user-service/src/main/java/com/mh/user/strategy/PressureTransStrategy.java @@ -1,7 +1,9 @@ package com.mh.user.strategy; +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.service.*; import com.mh.user.utils.ExchangeStringUtil; import com.mh.user.utils.SpringBeanUtil; @@ -84,10 +86,23 @@ public class PressureTransStrategy implements DeviceStrategy { data = ExchangeStringUtil.hexToDec(checkStr.substring(6, 10));//十六进制转整形 wtHeight = Double.parseDouble(data) / 100 * 0.102; //通过压力求水高 } - Double tankHeight = buildingService.queryTankHeight(buildingId);//水箱高,从数据库获取 + Double tankHeight; + // 默认是高区域 + tankHeight = buildingService.queryTankHeight(buildingId);//水箱高,从数据库获取 if (tankHeight == null) { tankHeight = 2.0; } + // 查询当前压变有低区 + DeviceInstallEntity deviceInstallEntity = deviceInstallService.selectDevice(addr, "压变", buildingId); + if (null != deviceInstallEntity + && !StringUtils.isBlank(deviceInstallEntity.getDeviceName())) { + if (deviceInstallEntity.getDeviceName().contains("低")) { + tankHeight = buildingService.queryLowTankHeight(buildingId);//水箱高,从数据库获取 + if (tankHeight == null) { + tankHeight = 2.0; + } + } + } Double wtLevel = wtHeight / tankHeight * 100; //水箱水位 log.info("------水箱水高:" + wtLevel + "------"); if (wtLevel <= 0) {