From d33c78ae965c41716358a58479d0064c3e5358dc Mon Sep 17 00:00:00 2001 From: xins Date: Fri, 26 Apr 2024 15:58:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=8B=A5=E4=BE=9D=E5=BE=AE=E6=9C=8D?= =?UTF-8?q?=E5=8A=A12.0.0=20=E6=8F=90=E4=BA=A4=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tdengine/api/domain/TdTableDropVo.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/domain/TdTableDropVo.java diff --git a/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/domain/TdTableDropVo.java b/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/domain/TdTableDropVo.java new file mode 100644 index 0000000..0690a6b --- /dev/null +++ b/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/domain/TdTableDropVo.java @@ -0,0 +1,29 @@ +package com.ruoyi.tdengine.api.domain; + +import com.ruoyi.common.core.hw.validated.tdengine.InsertTdTable; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import java.util.List; + +/** + * @Description: drop子表实体类 + * @ClassName: TdTableDropVo + * @Author : xins + * @Date :2024-04-20 11:09 + * @Version :1.0 + */ +@Data +public class TdTableDropVo { + + //数据库名称 + @NotEmpty(message="databaseName cannot be empty") + private String databaseName; + + + //子表名称 + @NotEmpty(message="tableName cannot be empty") + private String tableName; + + +} From be3dacd3df912412ae2d45b467b556276fe63597 Mon Sep 17 00:00:00 2001 From: xins Date: Fri, 26 Apr 2024 16:13:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=8B=A5=E4=BE=9D=E5=BE=AE=E6=9C=8D?= =?UTF-8?q?=E5=8A=A12.0.1=20=E4=BF=AE=E6=94=B9=E9=87=91=E7=91=9E=E9=93=AD?= =?UTF-8?q?=E4=BB=A5=E4=B8=8B=E9=97=AE=E9=A2=98=EF=BC=9A=201=E3=80=81Web?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E5=A4=87-=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B7=B2=E5=88=A0=E9=99=A4=E7=9A=84=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=BC=96=E5=8F=B7=202=E3=80=81=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E8=A7=84=E5=88=99=E8=AE=BE=E7=BD=AE=E6=97=A0=E7=94=9F=E6=95=88?= =?UTF-8?q?=203=E3=80=81=E6=A8=A1=E5=9E=8B=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E5=B0=86=E6=A8=A1=E5=9E=8B=E6=9F=90=E9=A1=B9?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=AE=BE=E7=BD=AE=E4=B8=BA=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=97=A0=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tdengine/api/RemoteTdEngineService.java | 4 + .../RemoteTdEngineFallbackFactory.java | 5 + .../ruoyi/business/domain/HwDeviceMode.java | 204 ++++++++++-------- .../com/ruoyi/business/domain/HwTenant.java | 30 +++ .../service/impl/HwDeviceModeServiceImpl.java | 4 +- .../service/impl/HwDeviceServiceImpl.java | 27 ++- .../impl/HwElectronicFenceServiceImpl.java | 11 +- .../impl/HwMonitorPlatformServiceImpl.java | 78 ++++--- .../mapper/business/HwDeviceMapper.xml | 12 +- .../mapper/business/HwDeviceModeMapper.xml | 33 +-- .../mapper/business/HwTenantMapper.xml | 12 +- .../service/impl/DataProcessServiceImpl.java | 11 +- .../controller/TdEngineController.java | 29 +++ .../ruoyi/tdengine/mapper/TdEngineMapper.java | 10 + .../tdengine/service/ITdEngineService.java | 9 +- .../service/impl/TdEngineServiceImpl.java | 17 ++ .../mapper/tdengine/TdEngineMapper.xml | 4 +- 17 files changed, 338 insertions(+), 162 deletions(-) diff --git a/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/RemoteTdEngineService.java b/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/RemoteTdEngineService.java index f123653..62038da 100644 --- a/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/RemoteTdEngineService.java +++ b/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/RemoteTdEngineService.java @@ -63,4 +63,8 @@ public interface RemoteTdEngineService { @PostMapping("/tdengine/getDeviceStatusList") R>> getDeviceStatusList(@Validated @RequestBody DeviceStatus queryDeviceStatus, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + + @PostMapping("/tdengine/dropTable") + R dropTable(@Validated @RequestBody TdTableDropVo tdTableDropVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); } diff --git a/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/factory/RemoteTdEngineFallbackFactory.java b/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/factory/RemoteTdEngineFallbackFactory.java index 7e737b2..624cc50 100644 --- a/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/factory/RemoteTdEngineFallbackFactory.java +++ b/ruoyi-api/hw-api-tdengine/src/main/java/com/ruoyi/tdengine/api/factory/RemoteTdEngineFallbackFactory.java @@ -102,6 +102,11 @@ public class RemoteTdEngineFallbackFactory implements FallbackFactory dropTable(TdTableDropVo tdTableDropVo, String source) { + return R.fail("drop子表失败:" + throwable.getMessage()); + } + }; } } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDeviceMode.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDeviceMode.java index d314b23..97675ac 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDeviceMode.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDeviceMode.java @@ -1,6 +1,7 @@ package com.ruoyi.business.domain; import java.util.List; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.core.annotation.Excel; @@ -8,59 +9,88 @@ import com.ruoyi.common.core.web.domain.BaseEntity; /** * 设备模型对象 hw_device_mode - * + * * @author xins * @date 2023-09-04 */ -public class HwDeviceMode extends BaseEntity -{ +public class HwDeviceMode extends BaseEntity { private static final long serialVersionUID = 1L; - /** 设备模型ID */ + /** + * 设备模型ID + */ @Excel(name = "设备模型ID") private Long deviceModeId; - /** 设备模型名称 */ + /** + * 设备模型名称 + */ @Excel(name = "设备模型名称") private String deviceModeName; - /** 租户ID,关联hw_tenant的tenant_id */ + /** + * 租户ID,关联hw_tenant的tenant_id + */ @Excel(name = "租户ID") private Long tenantId; - /** 所属场景,关联hw_scene表的scene_id字段 */ + /** + * 所属场景,关联hw_scene表的scene_id字段 + */ @Excel(name = "所属场景") private Long sceneId; - /** 语言code,关联表hw_language的language_code字段 */ + /** + * 语言code,关联表hw_language的language_code字段 + */ @Excel(name = "语言") private String languageCode; - /** 定位标识(1:是,0:否) */ + /** + * 定位标识(1:是,0:否) + */ @Excel(name = "定位标识", readConverterExp = "1=是,0=否") private String gpsFlag; - /** 设备模型状态(1:启用,9:删除) */ + /** + * 设备模型状态(1:启用,9:删除) + */ @Excel(name = "设备模型状态", readConverterExp = "1=启用,9=删除") private String deviceModeStatus; - /** 是否通用物模型(1、是,0:否) */ + /** + * 是否通用物模型(1、是,0:否) + */ @Excel(name = "通用标识", readConverterExp = "1=是,0=否") private String commonFlag; - /** 模型分类(在平台字典数据表中定义) */ + /** + * 模型类型(在平台字典数据表中定义) + */ + @Excel(name = "模型类型") + private String modeType; + + /** + * 模型分类(在平台字典数据表中定义) + */ @Excel(name = "模型分类") - private Long modeClassfication; + private String modeClassfication; - /** 设备模型图片地址 */ + /** + * 设备模型图片地址 + */ @Excel(name = "设备模型图片地址") private String deviceModePic; - /** 预留字段,数据校验级别 */ + /** + * 预留字段,数据校验级别 + */ // @Excel(name = "预留字段,数据校验级别") private String dataVerifyLevel; - /** 预留字段 */ + /** + * 预留字段 + */ // @Excel(name = "预留字段") private String deviceModeField; @@ -68,125 +98,120 @@ public class HwDeviceMode extends BaseEntity private String sceneName; - /** 设备模型功能信息 */ + /** + * 设备模型功能信息 + */ private List hwDeviceModeFunctionList; - public void setDeviceModeId(Long deviceModeId) - { + public void setDeviceModeId(Long deviceModeId) { this.deviceModeId = deviceModeId; } - public Long getDeviceModeId() - { + public Long getDeviceModeId() { return deviceModeId; } - public void setDeviceModeName(String deviceModeName) - { + + public void setDeviceModeName(String deviceModeName) { this.deviceModeName = deviceModeName; } - public String getDeviceModeName() - { + public String getDeviceModeName() { return deviceModeName; } - public void setTenantId(Long tenantId) - { + + public void setTenantId(Long tenantId) { this.tenantId = tenantId; } - public Long getTenantId() - { + public Long getTenantId() { return tenantId; } - public void setSceneId(Long sceneId) - { + + public void setSceneId(Long sceneId) { this.sceneId = sceneId; } - public Long getSceneId() - { + public Long getSceneId() { return sceneId; } - public void setLanguageCode(String languageCode) - { + + public void setLanguageCode(String languageCode) { this.languageCode = languageCode; } - public String getLanguageCode() - { + public String getLanguageCode() { return languageCode; } - public void setGpsFlag(String gpsFlag) - { + + public void setGpsFlag(String gpsFlag) { this.gpsFlag = gpsFlag; } - public String getGpsFlag() - { + public String getGpsFlag() { return gpsFlag; } - public void setDeviceModeStatus(String deviceModeStatus) - { + + public void setDeviceModeStatus(String deviceModeStatus) { this.deviceModeStatus = deviceModeStatus; } - public String getDeviceModeStatus() - { + public String getDeviceModeStatus() { return deviceModeStatus; } - public void setCommonFlag(String commonFlag) - { + + public void setCommonFlag(String commonFlag) { this.commonFlag = commonFlag; } - public String getCommonFlag() - { + public String getCommonFlag() { return commonFlag; } - public void setModeClassfication(Long modeClassfication) - { + + public String getModeType() { + return modeType; + } + + public void setModeType(String modeType) { + this.modeType = modeType; + } + + public void setModeClassfication(String modeClassfication) { this.modeClassfication = modeClassfication; } - public Long getModeClassfication() - { + public String getModeClassfication() { return modeClassfication; } - public void setDeviceModePic(String deviceModePic) - { + + public void setDeviceModePic(String deviceModePic) { this.deviceModePic = deviceModePic; } - public String getDeviceModePic() - { + public String getDeviceModePic() { return deviceModePic; } - public void setDataVerifyLevel(String dataVerifyLevel) - { + + public void setDataVerifyLevel(String dataVerifyLevel) { this.dataVerifyLevel = dataVerifyLevel; } - public String getDataVerifyLevel() - { + public String getDataVerifyLevel() { return dataVerifyLevel; } - public void setDeviceModeField(String deviceModeField) - { + + public void setDeviceModeField(String deviceModeField) { this.deviceModeField = deviceModeField; } - public String getDeviceModeField() - { + public String getDeviceModeField() { return deviceModeField; } - public List getHwDeviceModeFunctionList() - { + public List getHwDeviceModeFunctionList() { return hwDeviceModeFunctionList; } - public void setHwDeviceModeFunctionList(List hwDeviceModeFunctionList) - { + public void setHwDeviceModeFunctionList(List hwDeviceModeFunctionList) { this.hwDeviceModeFunctionList = hwDeviceModeFunctionList; } @@ -208,25 +233,26 @@ public class HwDeviceMode extends BaseEntity @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("deviceModeId", getDeviceModeId()) - .append("deviceModeName", getDeviceModeName()) - .append("tenantId", getTenantId()) - .append("sceneId", getSceneId()) - .append("languageCode", getLanguageCode()) - .append("gpsFlag", getGpsFlag()) - .append("deviceModeStatus", getDeviceModeStatus()) - .append("commonFlag", getCommonFlag()) - .append("modeClassfication", getModeClassfication()) - .append("deviceModePic", getDeviceModePic()) - .append("dataVerifyLevel", getDataVerifyLevel()) - .append("remark", getRemark()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("deviceModeField", getDeviceModeField()) - .append("hwDeviceModeFunctionList", getHwDeviceModeFunctionList()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("deviceModeId", getDeviceModeId()) + .append("deviceModeName", getDeviceModeName()) + .append("tenantId", getTenantId()) + .append("sceneId", getSceneId()) + .append("languageCode", getLanguageCode()) + .append("gpsFlag", getGpsFlag()) + .append("deviceModeStatus", getDeviceModeStatus()) + .append("commonFlag", getCommonFlag()) + .append("modeType", getModeType()) + .append("modeClassfication", getModeClassfication()) + .append("deviceModePic", getDeviceModePic()) + .append("dataVerifyLevel", getDataVerifyLevel()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("deviceModeField", getDeviceModeField()) + .append("hwDeviceModeFunctionList", getHwDeviceModeFunctionList()) + .toString(); } } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwTenant.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwTenant.java index 9beff84..f5d22e3 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwTenant.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwTenant.java @@ -85,12 +85,26 @@ public class HwTenant extends BaseEntity { // @Excel(name = "租户等级,预留字段") private Long tenantGrade; + /** + * 租户看板标题 + */ + @Excel(name = "租户看板标题") + private String tenantBoardTopic; + + /** + * 租户名称 + */ + @Excel(name = "租户看板图片") + private String tenantBoardPic; + + /** * 预留字段 */ // @Excel(name = "预留字段") private String tenantField; + public void setTenantId(Long tenantId) { this.tenantId = tenantId; } @@ -187,6 +201,22 @@ public class HwTenant extends BaseEntity { return tenantGrade; } + public String getTenantBoardTopic() { + return tenantBoardTopic; + } + + public void setTenantBoardTopic(String tenantBoardTopic) { + this.tenantBoardTopic = tenantBoardTopic; + } + + public String getTenantBoardPic() { + return tenantBoardPic; + } + + public void setTenantBoardPic(String tenantBoardPic) { + this.tenantBoardPic = tenantBoardPic; + } + public void setTenantField(String tenantField) { this.tenantField = tenantField; } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java index e25b422..13a6ca6 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java @@ -107,12 +107,12 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService { hwDeviceModeFunctionList.forEach(d -> { if (TdEngineConstants.ABNDON_FUNCTION_IDENTIFIERS.contains(d.getFunctionIdentifier().toLowerCase())) { - throw new ServiceException("标识符不能等于:" + d.getFunctionIdentifier()); + throw new ServiceException("标识符不能是:" + d.getFunctionIdentifier()); } if (StringUtils.isEmpty(d.getCoordinate()) && (d.getFunctionIdentifier().equalsIgnoreCase(keyLongitude) || d.getFunctionIdentifier().equalsIgnoreCase(keyLatitude))) { - throw new ServiceException("非定位设备模型标识符不能等于:" + keyLongitude + "或" + keyLatitude); + throw new ServiceException("非定位设备模型标识符不能是:" + keyLongitude + "或" + keyLatitude); } }); diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java index 9fab36e..35bea9f 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java @@ -151,7 +151,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { * @author xins * @date 2023-09-19 10:06 */ - private void updateMqttAuth(HwDevice hwDevice) { + public void updateMqttAuth(HwDevice hwDevice) { try { HwScene scene = hwSceneMapper.selectHwSceneBySceneId(hwDevice.getSceneId()); String modeAccount = scene.getModeAccount(); @@ -193,7 +193,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { * @author xins * @date 2023-09-19 10:07 */ - private void createTdTable(HwDevice hwDevice) { + public void createTdTable(HwDevice hwDevice) { TdTableVo tdTableVo = new TdTableVo(); String databaseName = TdEngineConstants.getDatabaseName(); String superTableName = TdEngineConstants.getSuperTableName(hwDevice.getDeviceModeId()); @@ -212,7 +212,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { } } - private void createTdDeviceStatusTable(HwDevice hwDevice) { + public void createTdDeviceStatusTable(HwDevice hwDevice) { TdTableVo tdTableVo = new TdTableVo(); tdTableVo.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME); tdTableVo.setSuperTableName(TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME); @@ -375,9 +375,22 @@ public class HwDeviceServiceImpl implements IHwDeviceService { * @return 结果 */ @Override + @Transactional(rollbackFor = Exception.class) public int deleteHwDeviceByDeviceId(Long deviceId) { + //逻辑删除,修改状态为9,修改设备编号为null, + // 可以不drop子表,drop了也不会省出空间,而且子表的名称是用主键ID作为后缀的,不影响后续表的新建 +// String databaseName = TdEngineConstants.getDatabaseName(); +// String tableName = TdEngineConstants.getDeviceDataTableName(deviceId); +// TdTableDropVo tdTableDropVo = new TdTableDropVo(); +// tdTableDropVo.setDatabaseName(databaseName); +// tdTableDropVo.setTableName(tableName); + int rows = hwDeviceMapper.deleteHwDeviceByDeviceId(deviceId); +// R tdReturnMsg = this.remoteTdEngineService.dropTable(tdTableDropVo,SecurityConstants.INNER); +// if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务 +// throw new RuntimeException(tdReturnMsg.getMsg()); +// } - return hwDeviceMapper.deleteHwDeviceByDeviceId(deviceId); + return rows; } @@ -409,7 +422,9 @@ public class HwDeviceServiceImpl implements IHwDeviceService { List modeFunctions = new ArrayList<>(); deviceModeFunctions.forEach(mf -> { - if (mf.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) { + //是属性的,并且是可显示的 + if (mf.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE) + && !mf.getDisplayFlag().equals(HwDictConstants.DEVICE_MODE_FUNCTION_DISPLAY_FLAG_NO)) { TdField field = new TdField(); String functionIdentifierTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(mf.getFunctionIdentifier()); String functionIdentifier = functionIdentifierTransfer == null ? mf.getFunctionIdentifier() : functionIdentifierTransfer; @@ -863,7 +878,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { * @author xins * @date 2023-09-19 10:55 */ - private void updateTdEngine(HwDevice hwDevice, HwDevice dbDevice) { + public void updateTdEngine(HwDevice hwDevice, HwDevice dbDevice) { String deviceType = hwDevice.getDeviceType(); String databaseName = TdEngineConstants.getDatabaseName(); String tableName = TdEngineConstants.getDeviceDataTableName(hwDevice.getDeviceId()); diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java index c32db98..f6a373b 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwElectronicFenceServiceImpl.java @@ -134,30 +134,34 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService { List electronicFenceVos = new ArrayList<>(); HwElectronicFence queryElectronicFence = new HwElectronicFence(); queryElectronicFence.setSceneId(sceneId); + //先获取所有的电子围栏数据 List electronicFenceList = hwElectronicFenceMapper.selectHwElectronicFenceList(queryElectronicFence); electronicFenceList.forEach(electronicFence -> { HwFenceArea queryFenceArea = new HwFenceArea(); queryFenceArea.setElectronicFenceId(electronicFence.getElectronicFenceId()); List fenceAreas = hwFenceAreaMapper.selectHwFenceAreaList(queryFenceArea); + //获取每个电子围栏的区域坐标数据,返回给前端画区域 for (HwFenceArea fenceArea : fenceAreas) { ElectronicFenceVo e = new ElectronicFenceVo(); String fenceType = electronicFence.getFenceType(); String areaShapeFlag = fenceArea.getAreaShapeFlag(); String areaRange = fenceArea.getAreaRange(); Integer deviceCount = 0; + //根据类型为设备的获取设备数量 if (fenceType.equals(HwDictConstants.FENCE_TYPE_DEVICE) || fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) { deviceCount = hwElectronicFenceMapper.selectDeviceCount(electronicFence.getElectronicFenceId()); } + //根据类型为监控单元的获取设备数量 if (fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) { deviceCount = hwElectronicFenceMapper.selectDeviceCountByMonitorUnit(electronicFence.getElectronicFenceId()); - } else if (fenceType.equals(HwDictConstants.FENCE_TYPE_SCENE)) { + } else if (fenceType.equals(HwDictConstants.FENCE_TYPE_SCENE)) {//根据类型为场景的获取设备数量 deviceCount = hwElectronicFenceMapper.selectDeviceCountByScene(electronicFence.getSceneId()); } - if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_POLYGN)) { + if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_POLYGN)) {//多边形 String[] areaRangeArr = areaRange.split("_"); List points = new ArrayList(); for (String areaR : areaRangeArr) { @@ -169,7 +173,7 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService { } e.setAreaPoints(points); - } else if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA)) { + } else if (areaShapeFlag.equals(HwDictConstants.AREA_SHAPE_FLAG_CIRCULA)) {//圆形 String[] areaRangeArr = areaRange.split(","); ElectronicFenceVo.AreaPoint p = new ElectronicFenceVo.AreaPoint(); p.setLongitude(Double.valueOf(areaRangeArr[0])); @@ -179,6 +183,7 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService { e.setRadius(Double.valueOf(areaRangeArr[2])); } + //根据电子围栏设置的区域获取报警信息,然后获取异常设备数量 AlarmInfoVo alarmInfoVo = hwAlarmInfoMapper.selectAlarmCountByFenceArea(fenceArea.getFenceAreaId()); e.setAbnormalCount(alarmInfoVo.getAlarmCount()); e.setAreaShapeFlag(areaShapeFlag); diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorPlatformServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorPlatformServiceImpl.java index 7369464..c6c2c8c 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorPlatformServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorPlatformServiceImpl.java @@ -15,6 +15,7 @@ import com.ruoyi.tdengine.api.domain.TdField; import com.ruoyi.tdengine.api.domain.TdHistorySelectDto; import com.ruoyi.tdengine.api.domain.TdReturnDataVo; import com.ruoyi.tdengine.api.domain.TdSuperTableSelectVo; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -52,11 +53,12 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService { JSONObject returnObj = new JSONObject(); Long deviceModeId = deviceLatestDataVo.getDeviceModeId(); HwDeviceModeFunction queryModeFunction = new HwDeviceModeFunction(); - queryModeFunction.setDeviceModeId(deviceModeId); - queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE); + queryModeFunction.setDeviceModeId(deviceModeId);//索引,先查出数据再过滤 +// queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE); List deviceModeFunctions = deviceModeFunctionMapper.selectHwDeviceModeFunctionList(queryModeFunction); - Map functionIndentifierName = deviceModeFunctions.stream().collect( - Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier, HwDeviceModeFunction::getFunctionName)); + Map functionIndentifierName = deviceModeFunctions.stream() + .filter(deviceModeFunction -> deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE) && !deviceModeFunction.getDisplayFlag().equals(HwDictConstants.DEVICE_MODE_FUNCTION_DISPLAY_FLAG_NO)) + .collect(Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier, HwDeviceModeFunction::getFunctionName)); functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP); Map functionIndentifierNameMap = new HashMap<>(); @@ -80,11 +82,10 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService { tdSuperTableSelectVo.setDeviceName(deviceLatestDataVo.getDeviceName()); tdSuperTableSelectVo.setStartTime(deviceLatestDataVo.getStartTime()); tdSuperTableSelectVo.setEndTime(deviceLatestDataVo.getEndTime()); - tdSuperTableSelectVo.setOffset(deviceLatestDataVo.getOffset()*deviceLatestDataVo.getLimit()); + tdSuperTableSelectVo.setOffset(deviceLatestDataVo.getOffset() * deviceLatestDataVo.getLimit()); tdSuperTableSelectVo.setLimit(deviceLatestDataVo.getLimit()); List schemaFieldValues = new ArrayList(); - List modeFunctions = new ArrayList<>(); deviceModeFunctions.forEach(mf -> { TdField field = new TdField(); @@ -101,16 +102,23 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService { List deviceDataColumnVos = new ArrayList(); - if (latestDataMaps != null && latestDataMaps.size() > 0) { - Map latestDataMap = latestDataMaps.get(0); - for (Map.Entry entry : latestDataMap.entrySet()) { - DeviceDataColumnVo deviceDataColumnVo = new DeviceDataColumnVo(); - String columnKey = entry.getKey(); - if (!columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICEID) - && !columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICEMODEID)) { - deviceDataColumnVo.setColumnKey(columnKey); - deviceDataColumnVo.setColumnName(functionIndentifierNameMap.get(columnKey) == null - ? columnKey : functionIndentifierNameMap.get(columnKey)); +// Map latestDataMap = latestDataMaps.get(0); + for (Map.Entry entry : functionIndentifierNameMap.entrySet()) { + DeviceDataColumnVo deviceDataColumnVo = new DeviceDataColumnVo(); + String columnKey = entry.getKey(); + if (!columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICEID) + && !columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICEMODEID) + && functionIndentifierNameMap.get(columnKey) != null) { + deviceDataColumnVo.setColumnKey(columnKey); + deviceDataColumnVo.setColumnName(functionIndentifierNameMap.get(columnKey) == null + ? columnKey : functionIndentifierNameMap.get(columnKey)); + if (columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICECODE)) { + deviceDataColumnVos.add(0, deviceDataColumnVo); + } else if (columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICENAME)) { + deviceDataColumnVos.add(1, deviceDataColumnVo); + } else if (columnKey.equalsIgnoreCase(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME)) { + deviceDataColumnVos.add(2, deviceDataColumnVo); + } else { deviceDataColumnVos.add(deviceDataColumnVo); } } @@ -157,33 +165,35 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService { * @date 2023-09-25 15:40 */ @Override - public List getDeviceDataColumns(Long deviceModeId, List> latestDataMaps) { + public List getDeviceDataColumns(Long deviceModeId) { HwDeviceModeFunction queryModeFunction = new HwDeviceModeFunction(); - queryModeFunction.setDeviceModeId(deviceModeId); - queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE); + queryModeFunction.setDeviceModeId(deviceModeId);//devicemodeid是索引,先根据索引查出再过滤 +// queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE); List deviceModeFunctions = deviceModeFunctionMapper.selectHwDeviceModeFunctionList(queryModeFunction); - Map functionIndentifierName = deviceModeFunctions.stream().collect( - Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier, HwDeviceModeFunction::getFunctionName)); - functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP); - functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP); - - Map functionIndentifierNameMap = new HashMap<>(); - functionIndentifierName.forEach((key, val) -> + //key是functionidentifier,用来获取具体值使用;value是functionname,用来显示使用 + Map functionIndentifierNameMap = deviceModeFunctions.stream(). + filter(deviceModeFunction -> deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE) && !deviceModeFunction.getDisplayFlag().equals(HwDictConstants.DEVICE_MODE_FUNCTION_DISPLAY_FLAG_NO)) + .collect(Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier, HwDeviceModeFunction::getFunctionName)); + functionIndentifierNameMap.put(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME, TdEngineConstants.DEFAULT_FIRST_FIELD_NAME_DISPLAY); +// functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP); + + Map functionIndentifierNameTransferMap = new HashMap<>(); + functionIndentifierNameMap.forEach((key, val) -> { String keyTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key) == null ? key : TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key); - functionIndentifierNameMap.put(keyTransfer, val); + functionIndentifierNameTransferMap.put(keyTransfer, val); }); - List deviceDataColumnVos = new ArrayList(); - if (latestDataMaps != null && latestDataMaps.size() > 0) { - Map latestDataMap = latestDataMaps.get(0); - for (Map.Entry entry : latestDataMap.entrySet()) { - DeviceDataColumnVo deviceDataColumnVo = new DeviceDataColumnVo(); + List deviceDataColumnVos = new ArrayList<>(); + if (functionIndentifierNameTransferMap != null) { + DeviceDataColumnVo deviceDataColumnVo = null; + for (Map.Entry entry : functionIndentifierNameTransferMap.entrySet()) { + deviceDataColumnVo = new DeviceDataColumnVo(); String columnKey = entry.getKey(); deviceDataColumnVo.setColumnKey(columnKey); - deviceDataColumnVo.setColumnName(functionIndentifierNameMap.get(columnKey) == null - ? columnKey : functionIndentifierNameMap.get(columnKey)); + deviceDataColumnVo.setColumnName(StringUtils.isEmpty(functionIndentifierNameTransferMap.get(columnKey)) + ? columnKey : functionIndentifierNameTransferMap.get(columnKey)); deviceDataColumnVos.add(deviceDataColumnVo); } } diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml index 03ada52..c981a02 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -113,12 +113,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ${params.tenantDataScope} - + - + insert into hw_device @@ -220,11 +220,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update hw_device set device_status = '9' where device_id = #{deviceId} + update hw_device set device_status = '9',device_code=null where device_id = #{deviceId} - delete from hw_device where device_id in + delete from hw_device where device_id in #{deviceId} @@ -359,4 +359,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ${params.tenantDataScope} - \ No newline at end of file + diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml index e10c1ab..d128d86 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwDeviceModeMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -69,7 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select device_mode_id, device_mode_name, tenant_id, scene_id, language_code, gps_flag, device_mode_status, common_flag, mode_classfication, device_mode_pic, data_verify_level, remark, create_by, create_time, update_by, update_time, device_mode_field from hw_device_mode hdm + select device_mode_id, device_mode_name, tenant_id, scene_id, language_code, gps_flag, device_mode_status, common_flag, mode_classfication,mode_type, device_mode_pic, data_verify_level, remark, create_by, create_time, update_by, update_time, device_mode_field from hw_device_mode hdm @@ -78,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - + insert into hw_device_mode @@ -114,7 +116,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" gps_flag, device_mode_status, common_flag, - mode_classfication, + mode_type, + mode_classfication, device_mode_pic, data_verify_level, remark, @@ -132,7 +135,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{gpsFlag}, #{deviceModeStatus}, #{commonFlag}, - #{modeClassfication}, + #{modeType}, + #{modeClassfication}, #{deviceModePic}, #{dataVerifyLevel}, #{remark}, @@ -154,7 +158,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" gps_flag = #{gpsFlag}, device_mode_status = #{deviceModeStatus}, common_flag = #{commonFlag}, - mode_classfication = #{modeClassfication}, + mode_type = #{modeType}, + mode_classfication = #{modeClassfication}, device_mode_pic = #{deviceModePic}, data_verify_level = #{dataVerifyLevel}, remark = #{remark}, @@ -172,14 +177,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from hw_device_mode where device_mode_id in + delete from hw_device_mode where device_mode_id in #{deviceModeId} - + - delete from hw_device_mode_function where device_mode_id in + delete from hw_device_mode_function where device_mode_id in #{deviceModeId} @@ -307,7 +312,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and hdm.gps_flag = #{gpsFlag} and hdm.device_mode_status = #{deviceModeStatus} and hdm.common_flag = #{commonFlag} - and hdm.mode_classfication = #{modeClassfication} + and hdm.mode_classfication = #{modeClassfication} and hdm.device_mode_pic = #{deviceModePic} and hdm.data_verify_level = #{dataVerifyLevel} and hdm.device_mode_field = #{deviceModeField} @@ -318,4 +323,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - \ No newline at end of file + diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwTenantMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwTenantMapper.xml index 26f8d25..32d8e76 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwTenantMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwTenantMapper.xml @@ -21,12 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + + - select tenant_id, tenant_type, tenant_name, tenant_industry, contact_name, contact_phone, email, area_id, contact_address, remark, tenant_status, is_register, create_by, create_time, update_by, update_time, tenant_grade, tenant_field from hw_tenant ht + select tenant_id, tenant_type, tenant_name, tenant_industry, contact_name, contact_phone, email, area_id, contact_address, remark, tenant_status, is_register, create_by, create_time, update_by, update_time,tenant_board_topic, tenant_board_pic,tenant_grade, tenant_field from hw_tenant ht - + + drop table #{databaseName}.#{tableName} +