From 0db07e6d5341f9c0f2546a252c3bfb9532ce7818 Mon Sep 17 00:00:00 2001 From: zcxlsm Date: Mon, 4 Aug 2025 22:04:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor(property):=20=E5=B0=86=20RemoteUnitSer?= =?UTF-8?q?vice=20=E8=B0=83=E6=95=B4=E4=B8=BA=20RemoteBuildingService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../property/api/RemoteBuildingService.java | 13 +++++++ .../property/api/RemoteUnitService.java | 13 ------- ...emoteUnitVo.java => RemoteBuildingVo.java} | 26 ++++--------- .../dubbo/RemoteBuildingServiceImpl.java | 37 ++++++++++++++++++ .../property/dubbo/RemoteUnitServiceImpl.java | 39 ------------------- .../impl/SisElevatorInfoServiceImpl.java | 22 +++++++---- 6 files changed, 71 insertions(+), 79 deletions(-) create mode 100644 ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteBuildingService.java delete mode 100644 ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteUnitService.java rename ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/{RemoteUnitVo.java => RemoteBuildingVo.java} (54%) create mode 100644 ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteBuildingServiceImpl.java delete mode 100644 ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteUnitServiceImpl.java diff --git a/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteBuildingService.java b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteBuildingService.java new file mode 100644 index 00000000..a190cf68 --- /dev/null +++ b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteBuildingService.java @@ -0,0 +1,13 @@ +package org.dromara.property.api; + +import org.dromara.property.api.domain.vo.RemoteBuildingVo; + +/** + * 物业楼层远程服务 + * @author lxj + */ +public interface RemoteBuildingService { + + RemoteBuildingVo queryBuildingById(Long id); + +} diff --git a/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteUnitService.java b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteUnitService.java deleted file mode 100644 index 175b9b0e..00000000 --- a/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteUnitService.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.dromara.property.api; - -import org.dromara.property.api.domain.vo.RemoteUnitVo; - -/** - * 物业楼层远程服务 - * @author lxj - */ -public interface RemoteUnitService { - - RemoteUnitVo queryUnitById(Long id); - -} diff --git a/ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteUnitVo.java b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteBuildingVo.java similarity index 54% rename from ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteUnitVo.java rename to ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteBuildingVo.java index 97b6e0b7..3e4e5137 100644 --- a/ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteUnitVo.java +++ b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteBuildingVo.java @@ -11,7 +11,7 @@ import java.io.Serializable; * @author lxj */ @Data -public class RemoteUnitVo implements Serializable { +public class RemoteBuildingVo implements Serializable { @Serial private static final long serialVersionUID = -11L; @@ -21,31 +21,19 @@ public class RemoteUnitVo implements Serializable { */ private Long id; + /** + * 园区id + */ private Long communityId; /** * 建筑名称 */ - private Long buildingId; + private String buildingName; /** - * 单元名称 + * 总层数 */ - private String unitName; - - /** - * 单元层数 - */ - private Integer floorCount; - - /** - * 单元户数 - */ - private Integer householdCount; - - /** - * 楼梯数量 - */ - private Integer stairCount; + private Long floorCount; } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteBuildingServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteBuildingServiceImpl.java new file mode 100644 index 00000000..391fbe35 --- /dev/null +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteBuildingServiceImpl.java @@ -0,0 +1,37 @@ +package org.dromara.property.dubbo; + +import lombok.RequiredArgsConstructor; +import org.apache.dubbo.config.annotation.DubboService; +import org.dromara.property.api.RemoteBuildingService; +import org.dromara.property.api.domain.vo.RemoteBuildingVo; +import org.dromara.property.domain.vo.TbBuildingVo; +import org.dromara.property.domain.vo.TbUnitVo; +import org.dromara.property.service.ITbBuildingService; +import org.dromara.property.service.ITbUnitService; + +/** + * 对外提供的远程服务调用 + * + * @author lxj + */ +@DubboService +@RequiredArgsConstructor +public class RemoteBuildingServiceImpl implements RemoteBuildingService { + + private final ITbBuildingService iTbBuildingService; + + + @Override + public RemoteBuildingVo queryBuildingById(Long id) { + TbBuildingVo tbBuildingVo = iTbBuildingService.queryById(id); + if(tbBuildingVo == null) { + return null; + } + RemoteBuildingVo remoteBuildingVo = new RemoteBuildingVo(); + remoteBuildingVo.setId(tbBuildingVo.getId()); + remoteBuildingVo.setCommunityId(tbBuildingVo.getCommunityId()); + remoteBuildingVo.setBuildingName(tbBuildingVo.getBuildingName()); + remoteBuildingVo.setFloorCount(tbBuildingVo.getFloorCount()); + return remoteBuildingVo; + } +} diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteUnitServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteUnitServiceImpl.java deleted file mode 100644 index 7016393e..00000000 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteUnitServiceImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.dromara.property.dubbo; - -import lombok.RequiredArgsConstructor; -import org.apache.dubbo.config.annotation.DubboService; -import org.dromara.common.core.utils.MapstructUtils; -import org.dromara.property.api.RemoteUnitService; -import org.dromara.property.api.domain.vo.RemoteUnitVo; -import org.dromara.property.domain.vo.TbUnitVo; -import org.dromara.property.service.ITbUnitService; - -/** - * 对外提供的远程服务调用 - * - * @author lxj - */ -@DubboService -@RequiredArgsConstructor -public class RemoteUnitServiceImpl implements RemoteUnitService { - - private final ITbUnitService tbUnitService; - - - @Override - public RemoteUnitVo queryUnitById(Long id) { - TbUnitVo tbUnitVo = tbUnitService.queryById(id); - if(tbUnitVo == null) { - return null; - } - RemoteUnitVo remoteUnitVo = new RemoteUnitVo(); - remoteUnitVo.setId(tbUnitVo.getId()); - remoteUnitVo.setCommunityId(tbUnitVo.getCommunityId()); - remoteUnitVo.setBuildingId(tbUnitVo.getBuildingId()); - remoteUnitVo.setUnitName(tbUnitVo.getUnitName()); - remoteUnitVo.setFloorCount(tbUnitVo.getFloorCount()); - remoteUnitVo.setHouseholdCount(tbUnitVo.getHouseholdCount()); - remoteUnitVo.setStairCount(tbUnitVo.getStairCount()); - return remoteUnitVo; - } -} diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisElevatorInfoServiceImpl.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisElevatorInfoServiceImpl.java index 2b1bc9b7..0cdf66b6 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisElevatorInfoServiceImpl.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisElevatorInfoServiceImpl.java @@ -13,8 +13,8 @@ import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; -import org.dromara.property.api.RemoteUnitService; -import org.dromara.property.api.domain.vo.RemoteUnitVo; +import org.dromara.property.api.RemoteBuildingService; +import org.dromara.property.api.domain.vo.RemoteBuildingVo; import org.dromara.sis.domain.SisDeviceBindRef; import org.dromara.sis.domain.SisElevatorInfo; import org.dromara.sis.domain.bo.SisElevatorInfoBo; @@ -45,7 +45,7 @@ public class SisElevatorInfoServiceImpl implements ISisElevatorInfoService { private final ISisDeviceBindRefService deviceBindRefService; @DubboReference - private RemoteUnitService remoteUnitService; + private RemoteBuildingService remoteBuildingService; /** * 查询电梯基本信息 @@ -137,17 +137,23 @@ public class SisElevatorInfoServiceImpl implements ISisElevatorInfoService { @Override @Transactional(rollbackFor = Exception.class) public Boolean insertByBo(SisElevatorInfoBo bo) { - // 验证单元是否存在 - RemoteUnitVo remoteUnitVo = remoteUnitService.queryUnitById(bo.getUnitId()); - Assert.notNull(remoteUnitVo, "社区单元信息不存在。"); + // 验证建筑是否存在 + RemoteBuildingVo remoteBuildingVo = remoteBuildingService.queryBuildingById(bo.getBuildingId()); + Assert.notNull(remoteBuildingVo, "建筑信息不存在。"); + + // 数据转换 SisElevatorInfo add = MapstructUtils.convert(bo, SisElevatorInfo.class); Assert.notNull(add, "电梯信息处理失败。"); - add.setCommunityId(remoteUnitVo.getCommunityId()); - add.setBuildingId(remoteUnitVo.getBuildingId()); + + assert add != null; + add.setCommunityId(remoteBuildingVo.getCommunityId()); + add.setBuildingId(remoteBuildingVo.getId()); // 生成电梯编码 String code = ELEVATOR_CONTROL_CODE_PREFIX + IdUtil.getSnowflakeNextIdStr(); add.setElevatorCode(code); boolean flag = baseMapper.insert(add) > 0; + Assert.isTrue(flag, "新增电梯信息失败。"); + if (flag) { bo.setElevatorId(add.getElevatorId()); List ls = new ArrayList<>();