diff --git a/user-service/src/main/java/com/mh/user/controller/DeviceInstallController.java b/user-service/src/main/java/com/mh/user/controller/DeviceInstallController.java index 1e2784e..43ff65a 100644 --- a/user-service/src/main/java/com/mh/user/controller/DeviceInstallController.java +++ b/user-service/src/main/java/com/mh/user/controller/DeviceInstallController.java @@ -7,10 +7,7 @@ import com.mh.user.annotation.SysLogger; import com.mh.user.entity.BuildingEntity; import com.mh.user.entity.DeviceInstallEntity; import com.mh.user.model.DeviceModel; -import com.mh.user.service.BuildingService; -import com.mh.user.service.DealDataService; -import com.mh.user.service.DeviceInstallService; -import com.mh.user.service.SummaryService; +import com.mh.user.service.*; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; @@ -34,6 +31,10 @@ public class DeviceInstallController { @Autowired BuildingService buildingService; + @Autowired + private NowDataService nowDataService; + + private final DealDataService dealDataService; public DeviceInstallController(DealDataService dealDataService) @@ -54,6 +55,21 @@ public class DeviceInstallController { public HttpResult updateDevice(@RequestBody DeviceInstallEntity deviceInstallEntity) { // 根据id查询对应的deviceInstall DeviceInstallEntity oldEntity = deviceInstallService.selectDeviceById(deviceInstallEntity.getId()); + + // 更新对应的实时记录内容 + if (oldEntity.getDeviceType().equals("热泵")) { + String oldPumpId = oldEntity.getDeviceAddr(); + String oldPumpName = oldEntity.getDeviceName(); + String oldBuildingId = oldEntity.getBuildingId(); + + String pumpId = deviceInstallEntity.getDeviceAddr(); + String pumpName = deviceInstallEntity.getDeviceName(); + String buildingId = deviceInstallEntity.getBuildingId(); + String buildingName = deviceInstallEntity.getBuildingName(); + + nowDataService.updatePumpName(oldPumpId, oldPumpName, oldBuildingId, pumpId, pumpName, buildingId, buildingName); + } + // 删除全部的device_code_param值 deviceInstallService.deleteParamCode(oldEntity); // 设置校验位 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 6fe2d0d..0f0c74b 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 @@ -499,4 +499,21 @@ public interface NowDataMapper { "" + "") String selectMaxTemp(@Param("buildingId") String buildingId, @Param("temp") Integer temp); + + @Update("update now_data set " + + " pump_name=#{pumpName}, " + + " pump_id = #{pumpId}, " + + " building_id = #{buildingId}" + + " where pump_id=#{oldPumpId} and pump_name=#{oldPumpName} and building_id=#{oldBuildingId} ") + void updatePumpName(@Param("oldPumpId") String oldPumpId, + @Param("oldPumpName") String oldPumpName, + @Param("oldBuildingId") String oldBuildingId, + @Param("pumpId") String pumpId, + @Param("pumpName") String pumpName, + @Param("buildingId") String buildingId, + @Param("buildingName") String buildingName); + + @Delete("delete from now_data where pump_id=#{pumpId} and building_id=#{buildingId}") + void deleteNowDataByDeviceAddr(@Param("pumpId") String pumpId, + @Param("buildingId") String buildingId); } 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 a7a92fd..d14d1ac 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 @@ -145,5 +145,7 @@ public interface NowDataService { Map selectTopOneState(String buildingId); void updateNowPublicData(NowPublicDataEntity publicData); + + void updatePumpName(String oldPumpId, String oldPumpName, String oldBuildingId, String pumpId, String pumpName, String buildingId, String buildingName); } diff --git a/user-service/src/main/java/com/mh/user/service/impl/DeviceInstallServiceImpl.java b/user-service/src/main/java/com/mh/user/service/impl/DeviceInstallServiceImpl.java index cb26396..d1b8592 100644 --- a/user-service/src/main/java/com/mh/user/service/impl/DeviceInstallServiceImpl.java +++ b/user-service/src/main/java/com/mh/user/service/impl/DeviceInstallServiceImpl.java @@ -6,6 +6,7 @@ import com.mh.user.entity.DeviceInstallTempEntity; import com.mh.user.entity.UploadDeviceInstallEntity; import com.mh.user.mapper.DeviceCodeParamMapper; import com.mh.user.mapper.DeviceInstallMapper; +import com.mh.user.mapper.NowDataMapper; import com.mh.user.model.DeviceModel; import com.mh.user.service.BuildingService; import com.mh.user.service.DeviceInstallService; @@ -34,6 +35,8 @@ public class DeviceInstallServiceImpl implements DeviceInstallService { @Autowired private DeviceCodeParamMapper deviceCodeParamMapper; + @Autowired + private NowDataMapper nowDataMapper; @Override public int saveDevice(DeviceInstallEntity deviceInstallEntity) { @@ -275,7 +278,7 @@ public class DeviceInstallServiceImpl implements DeviceInstallService { @Override public int deleteDevice(List records) { for(DeviceInstallEntity record:records) { - deviceInstallMapper.deleteDevice(record.getId().toString()); +// deviceInstallMapper.deleteDevice(record.getId().toString()); } return 0; } @@ -286,6 +289,10 @@ public class DeviceInstallServiceImpl implements DeviceInstallService { DeviceInstallEntity oldEntity = deviceInstallMapper.selectDeviceById(Long.valueOf(id)); // 删除全部的device_code_param值 this.deleteParamCode(oldEntity); + if (oldEntity.getDeviceType().equals("热泵")) { + // 删除now_data表数据 + nowDataMapper.deleteNowDataByDeviceAddr(oldEntity.getDeviceAddr(), oldEntity.getBuildingId()); + } return deviceInstallMapper.deleteDevice(id); } 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 43f7a87..c771642 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 @@ -567,4 +567,9 @@ public class NowDataServiceImpl implements NowDataService { public void updateNowPublicData(NowPublicDataEntity publicData) { nowPublicDataMapper.updateNowPublicData(publicData); } + + @Override + public void updatePumpName(String oldPumpId, String oldPumpName, String oldBuildingId, String pumpId, String pumpName, String buildingId, String buildingName) { + nowDataMapper.updatePumpName(oldPumpId, oldPumpName, oldBuildingId, pumpId, pumpName, buildingId, buildingName); + } }