若依微服务2.0.1

修改金瑞铭以下问题:
1、Web新增设备-无法新增已删除的设备编号
2、告警规则设置无生效
3、模型显示问题,将模型某项数据设置为不显示无生效
dev
xins 7 months ago
parent bfa20d43ff
commit be3dacd3df

@ -63,4 +63,8 @@ public interface RemoteTdEngineService {
@PostMapping("/tdengine/getDeviceStatusList") @PostMapping("/tdengine/getDeviceStatusList")
R<List<Map<String, Object>>> getDeviceStatusList(@Validated @RequestBody DeviceStatus queryDeviceStatus, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); R<List<Map<String, Object>>> 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);
} }

@ -102,6 +102,11 @@ public class RemoteTdEngineFallbackFactory implements FallbackFactory<RemoteTdEn
return R.fail("获取设备状态信息失败:" + throwable.getMessage()); return R.fail("获取设备状态信息失败:" + throwable.getMessage());
} }
@Override
public R<?> dropTable(TdTableDropVo tdTableDropVo, String source) {
return R.fail("drop子表失败:" + throwable.getMessage());
}
}; };
} }
} }

@ -1,6 +1,7 @@
package com.ruoyi.business.domain; package com.ruoyi.business.domain;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.annotation.Excel;
@ -8,59 +9,88 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
/** /**
* hw_device_mode * hw_device_mode
* *
* @author xins * @author xins
* @date 2023-09-04 * @date 2023-09-04
*/ */
public class HwDeviceMode extends BaseEntity public class HwDeviceMode extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 设备模型ID */ /**
* ID
*/
@Excel(name = "设备模型ID") @Excel(name = "设备模型ID")
private Long deviceModeId; private Long deviceModeId;
/** 设备模型名称 */ /**
*
*/
@Excel(name = "设备模型名称") @Excel(name = "设备模型名称")
private String deviceModeName; private String deviceModeName;
/** 租户ID关联hw_tenant的tenant_id */ /**
* IDhw_tenanttenant_id
*/
@Excel(name = "租户ID") @Excel(name = "租户ID")
private Long tenantId; private Long tenantId;
/** 所属场景关联hw_scene表的scene_id字段 */ /**
* hw_scenescene_id
*/
@Excel(name = "所属场景") @Excel(name = "所属场景")
private Long sceneId; private Long sceneId;
/** 语言code,关联表hw_language的language_code字段 */ /**
* code,hw_languagelanguage_code
*/
@Excel(name = "语言") @Excel(name = "语言")
private String languageCode; private String languageCode;
/** 定位标识10 */ /**
* 10
*/
@Excel(name = "定位标识", readConverterExp = "1=是,0=否") @Excel(name = "定位标识", readConverterExp = "1=是,0=否")
private String gpsFlag; private String gpsFlag;
/** 设备模型状态1启用9删除 */ /**
* 19
*/
@Excel(name = "设备模型状态", readConverterExp = "1=启用,9=删除") @Excel(name = "设备模型状态", readConverterExp = "1=启用,9=删除")
private String deviceModeStatus; private String deviceModeStatus;
/** 是否通用物模型1、是0 */ /**
* 10
*/
@Excel(name = "通用标识", readConverterExp = "1=是,0=否") @Excel(name = "通用标识", readConverterExp = "1=是,0=否")
private String commonFlag; private String commonFlag;
/** 模型分类(在平台字典数据表中定义) */ /**
*
*/
@Excel(name = "模型类型")
private String modeType;
/**
*
*/
@Excel(name = "模型分类") @Excel(name = "模型分类")
private Long modeClassfication; private String modeClassfication;
/** 设备模型图片地址 */ /**
*
*/
@Excel(name = "设备模型图片地址") @Excel(name = "设备模型图片地址")
private String deviceModePic; private String deviceModePic;
/** 预留字段,数据校验级别 */ /**
*
*/
// @Excel(name = "预留字段,数据校验级别") // @Excel(name = "预留字段,数据校验级别")
private String dataVerifyLevel; private String dataVerifyLevel;
/** 预留字段 */ /**
*
*/
// @Excel(name = "预留字段") // @Excel(name = "预留字段")
private String deviceModeField; private String deviceModeField;
@ -68,125 +98,120 @@ public class HwDeviceMode extends BaseEntity
private String sceneName; private String sceneName;
/** 设备模型功能信息 */ /**
*
*/
private List<HwDeviceModeFunction> hwDeviceModeFunctionList; private List<HwDeviceModeFunction> hwDeviceModeFunctionList;
public void setDeviceModeId(Long deviceModeId) public void setDeviceModeId(Long deviceModeId) {
{
this.deviceModeId = deviceModeId; this.deviceModeId = deviceModeId;
} }
public Long getDeviceModeId() public Long getDeviceModeId() {
{
return deviceModeId; return deviceModeId;
} }
public void setDeviceModeName(String deviceModeName)
{ public void setDeviceModeName(String deviceModeName) {
this.deviceModeName = deviceModeName; this.deviceModeName = deviceModeName;
} }
public String getDeviceModeName() public String getDeviceModeName() {
{
return deviceModeName; return deviceModeName;
} }
public void setTenantId(Long tenantId)
{ public void setTenantId(Long tenantId) {
this.tenantId = tenantId; this.tenantId = tenantId;
} }
public Long getTenantId() public Long getTenantId() {
{
return tenantId; return tenantId;
} }
public void setSceneId(Long sceneId)
{ public void setSceneId(Long sceneId) {
this.sceneId = sceneId; this.sceneId = sceneId;
} }
public Long getSceneId() public Long getSceneId() {
{
return sceneId; return sceneId;
} }
public void setLanguageCode(String languageCode)
{ public void setLanguageCode(String languageCode) {
this.languageCode = languageCode; this.languageCode = languageCode;
} }
public String getLanguageCode() public String getLanguageCode() {
{
return languageCode; return languageCode;
} }
public void setGpsFlag(String gpsFlag)
{ public void setGpsFlag(String gpsFlag) {
this.gpsFlag = gpsFlag; this.gpsFlag = gpsFlag;
} }
public String getGpsFlag() public String getGpsFlag() {
{
return gpsFlag; return gpsFlag;
} }
public void setDeviceModeStatus(String deviceModeStatus)
{ public void setDeviceModeStatus(String deviceModeStatus) {
this.deviceModeStatus = deviceModeStatus; this.deviceModeStatus = deviceModeStatus;
} }
public String getDeviceModeStatus() public String getDeviceModeStatus() {
{
return deviceModeStatus; return deviceModeStatus;
} }
public void setCommonFlag(String commonFlag)
{ public void setCommonFlag(String commonFlag) {
this.commonFlag = commonFlag; this.commonFlag = commonFlag;
} }
public String getCommonFlag() public String getCommonFlag() {
{
return commonFlag; 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; this.modeClassfication = modeClassfication;
} }
public Long getModeClassfication() public String getModeClassfication() {
{
return modeClassfication; return modeClassfication;
} }
public void setDeviceModePic(String deviceModePic)
{ public void setDeviceModePic(String deviceModePic) {
this.deviceModePic = deviceModePic; this.deviceModePic = deviceModePic;
} }
public String getDeviceModePic() public String getDeviceModePic() {
{
return deviceModePic; return deviceModePic;
} }
public void setDataVerifyLevel(String dataVerifyLevel)
{ public void setDataVerifyLevel(String dataVerifyLevel) {
this.dataVerifyLevel = dataVerifyLevel; this.dataVerifyLevel = dataVerifyLevel;
} }
public String getDataVerifyLevel() public String getDataVerifyLevel() {
{
return dataVerifyLevel; return dataVerifyLevel;
} }
public void setDeviceModeField(String deviceModeField)
{ public void setDeviceModeField(String deviceModeField) {
this.deviceModeField = deviceModeField; this.deviceModeField = deviceModeField;
} }
public String getDeviceModeField() public String getDeviceModeField() {
{
return deviceModeField; return deviceModeField;
} }
public List<HwDeviceModeFunction> getHwDeviceModeFunctionList() public List<HwDeviceModeFunction> getHwDeviceModeFunctionList() {
{
return hwDeviceModeFunctionList; return hwDeviceModeFunctionList;
} }
public void setHwDeviceModeFunctionList(List<HwDeviceModeFunction> hwDeviceModeFunctionList) public void setHwDeviceModeFunctionList(List<HwDeviceModeFunction> hwDeviceModeFunctionList) {
{
this.hwDeviceModeFunctionList = hwDeviceModeFunctionList; this.hwDeviceModeFunctionList = hwDeviceModeFunctionList;
} }
@ -208,25 +233,26 @@ public class HwDeviceMode extends BaseEntity
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("deviceModeId", getDeviceModeId()) .append("deviceModeId", getDeviceModeId())
.append("deviceModeName", getDeviceModeName()) .append("deviceModeName", getDeviceModeName())
.append("tenantId", getTenantId()) .append("tenantId", getTenantId())
.append("sceneId", getSceneId()) .append("sceneId", getSceneId())
.append("languageCode", getLanguageCode()) .append("languageCode", getLanguageCode())
.append("gpsFlag", getGpsFlag()) .append("gpsFlag", getGpsFlag())
.append("deviceModeStatus", getDeviceModeStatus()) .append("deviceModeStatus", getDeviceModeStatus())
.append("commonFlag", getCommonFlag()) .append("commonFlag", getCommonFlag())
.append("modeClassfication", getModeClassfication()) .append("modeType", getModeType())
.append("deviceModePic", getDeviceModePic()) .append("modeClassfication", getModeClassfication())
.append("dataVerifyLevel", getDataVerifyLevel()) .append("deviceModePic", getDeviceModePic())
.append("remark", getRemark()) .append("dataVerifyLevel", getDataVerifyLevel())
.append("createBy", getCreateBy()) .append("remark", getRemark())
.append("createTime", getCreateTime()) .append("createBy", getCreateBy())
.append("updateBy", getUpdateBy()) .append("createTime", getCreateTime())
.append("updateTime", getUpdateTime()) .append("updateBy", getUpdateBy())
.append("deviceModeField", getDeviceModeField()) .append("updateTime", getUpdateTime())
.append("hwDeviceModeFunctionList", getHwDeviceModeFunctionList()) .append("deviceModeField", getDeviceModeField())
.toString(); .append("hwDeviceModeFunctionList", getHwDeviceModeFunctionList())
.toString();
} }
} }

@ -85,12 +85,26 @@ public class HwTenant extends BaseEntity {
// @Excel(name = "租户等级,预留字段") // @Excel(name = "租户等级,预留字段")
private Long tenantGrade; private Long tenantGrade;
/**
*
*/
@Excel(name = "租户看板标题")
private String tenantBoardTopic;
/**
*
*/
@Excel(name = "租户看板图片")
private String tenantBoardPic;
/** /**
* *
*/ */
// @Excel(name = "预留字段") // @Excel(name = "预留字段")
private String tenantField; private String tenantField;
public void setTenantId(Long tenantId) { public void setTenantId(Long tenantId) {
this.tenantId = tenantId; this.tenantId = tenantId;
} }
@ -187,6 +201,22 @@ public class HwTenant extends BaseEntity {
return tenantGrade; 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) { public void setTenantField(String tenantField) {
this.tenantField = tenantField; this.tenantField = tenantField;
} }

@ -107,12 +107,12 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
hwDeviceModeFunctionList.forEach(d -> { hwDeviceModeFunctionList.forEach(d -> {
if (TdEngineConstants.ABNDON_FUNCTION_IDENTIFIERS.contains(d.getFunctionIdentifier().toLowerCase())) { if (TdEngineConstants.ABNDON_FUNCTION_IDENTIFIERS.contains(d.getFunctionIdentifier().toLowerCase())) {
throw new ServiceException("标识符不能等于:" + d.getFunctionIdentifier()); throw new ServiceException("标识符不能:" + d.getFunctionIdentifier());
} }
if (StringUtils.isEmpty(d.getCoordinate()) && if (StringUtils.isEmpty(d.getCoordinate()) &&
(d.getFunctionIdentifier().equalsIgnoreCase(keyLongitude) (d.getFunctionIdentifier().equalsIgnoreCase(keyLongitude)
|| d.getFunctionIdentifier().equalsIgnoreCase(keyLatitude))) { || d.getFunctionIdentifier().equalsIgnoreCase(keyLatitude))) {
throw new ServiceException("非定位设备模型标识符不能等于:" + keyLongitude + "或" + keyLatitude); throw new ServiceException("非定位设备模型标识符不能:" + keyLongitude + "或" + keyLatitude);
} }
}); });

@ -151,7 +151,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
* @author xins * @author xins
* @date 2023-09-19 10:06 * @date 2023-09-19 10:06
*/ */
private void updateMqttAuth(HwDevice hwDevice) { public void updateMqttAuth(HwDevice hwDevice) {
try { try {
HwScene scene = hwSceneMapper.selectHwSceneBySceneId(hwDevice.getSceneId()); HwScene scene = hwSceneMapper.selectHwSceneBySceneId(hwDevice.getSceneId());
String modeAccount = scene.getModeAccount(); String modeAccount = scene.getModeAccount();
@ -193,7 +193,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
* @author xins * @author xins
* @date 2023-09-19 10:07 * @date 2023-09-19 10:07
*/ */
private void createTdTable(HwDevice hwDevice) { public void createTdTable(HwDevice hwDevice) {
TdTableVo tdTableVo = new TdTableVo(); TdTableVo tdTableVo = new TdTableVo();
String databaseName = TdEngineConstants.getDatabaseName(); String databaseName = TdEngineConstants.getDatabaseName();
String superTableName = TdEngineConstants.getSuperTableName(hwDevice.getDeviceModeId()); 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 tdTableVo = new TdTableVo();
tdTableVo.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME); tdTableVo.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME);
tdTableVo.setSuperTableName(TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME); tdTableVo.setSuperTableName(TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME);
@ -375,9 +375,22 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
* @return * @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public int deleteHwDeviceByDeviceId(Long deviceId) { 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<HwDeviceModeFunction> modeFunctions = new ArrayList<>(); List<HwDeviceModeFunction> modeFunctions = new ArrayList<>();
deviceModeFunctions.forEach(mf -> { 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(); TdField field = new TdField();
String functionIdentifierTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(mf.getFunctionIdentifier()); String functionIdentifierTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(mf.getFunctionIdentifier());
String functionIdentifier = functionIdentifierTransfer == null ? mf.getFunctionIdentifier() : functionIdentifierTransfer; String functionIdentifier = functionIdentifierTransfer == null ? mf.getFunctionIdentifier() : functionIdentifierTransfer;
@ -863,7 +878,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
* @author xins * @author xins
* @date 2023-09-19 10:55 * @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 deviceType = hwDevice.getDeviceType();
String databaseName = TdEngineConstants.getDatabaseName(); String databaseName = TdEngineConstants.getDatabaseName();
String tableName = TdEngineConstants.getDeviceDataTableName(hwDevice.getDeviceId()); String tableName = TdEngineConstants.getDeviceDataTableName(hwDevice.getDeviceId());

@ -134,30 +134,34 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService {
List<ElectronicFenceVo> electronicFenceVos = new ArrayList<>(); List<ElectronicFenceVo> electronicFenceVos = new ArrayList<>();
HwElectronicFence queryElectronicFence = new HwElectronicFence(); HwElectronicFence queryElectronicFence = new HwElectronicFence();
queryElectronicFence.setSceneId(sceneId); queryElectronicFence.setSceneId(sceneId);
//先获取所有的电子围栏数据
List<HwElectronicFence> electronicFenceList = hwElectronicFenceMapper.selectHwElectronicFenceList(queryElectronicFence); List<HwElectronicFence> electronicFenceList = hwElectronicFenceMapper.selectHwElectronicFenceList(queryElectronicFence);
electronicFenceList.forEach(electronicFence -> { electronicFenceList.forEach(electronicFence -> {
HwFenceArea queryFenceArea = new HwFenceArea(); HwFenceArea queryFenceArea = new HwFenceArea();
queryFenceArea.setElectronicFenceId(electronicFence.getElectronicFenceId()); queryFenceArea.setElectronicFenceId(electronicFence.getElectronicFenceId());
List<HwFenceArea> fenceAreas = hwFenceAreaMapper.selectHwFenceAreaList(queryFenceArea); List<HwFenceArea> fenceAreas = hwFenceAreaMapper.selectHwFenceAreaList(queryFenceArea);
//获取每个电子围栏的区域坐标数据,返回给前端画区域
for (HwFenceArea fenceArea : fenceAreas) { for (HwFenceArea fenceArea : fenceAreas) {
ElectronicFenceVo e = new ElectronicFenceVo(); ElectronicFenceVo e = new ElectronicFenceVo();
String fenceType = electronicFence.getFenceType(); String fenceType = electronicFence.getFenceType();
String areaShapeFlag = fenceArea.getAreaShapeFlag(); String areaShapeFlag = fenceArea.getAreaShapeFlag();
String areaRange = fenceArea.getAreaRange(); String areaRange = fenceArea.getAreaRange();
Integer deviceCount = 0; Integer deviceCount = 0;
//根据类型为设备的获取设备数量
if (fenceType.equals(HwDictConstants.FENCE_TYPE_DEVICE) if (fenceType.equals(HwDictConstants.FENCE_TYPE_DEVICE)
|| fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) { || fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) {
deviceCount = hwElectronicFenceMapper.selectDeviceCount(electronicFence.getElectronicFenceId()); deviceCount = hwElectronicFenceMapper.selectDeviceCount(electronicFence.getElectronicFenceId());
} }
//根据类型为监控单元的获取设备数量
if (fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) { if (fenceType.equals(HwDictConstants.FENCE_TYPE_MONITOR_UNIT)) {
deviceCount = hwElectronicFenceMapper.selectDeviceCountByMonitorUnit(electronicFence.getElectronicFenceId()); 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()); 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("_"); String[] areaRangeArr = areaRange.split("_");
List<ElectronicFenceVo.AreaPoint> points = new ArrayList<ElectronicFenceVo.AreaPoint>(); List<ElectronicFenceVo.AreaPoint> points = new ArrayList<ElectronicFenceVo.AreaPoint>();
for (String areaR : areaRangeArr) { for (String areaR : areaRangeArr) {
@ -169,7 +173,7 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService {
} }
e.setAreaPoints(points); 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(","); String[] areaRangeArr = areaRange.split(",");
ElectronicFenceVo.AreaPoint p = new ElectronicFenceVo.AreaPoint(); ElectronicFenceVo.AreaPoint p = new ElectronicFenceVo.AreaPoint();
p.setLongitude(Double.valueOf(areaRangeArr[0])); p.setLongitude(Double.valueOf(areaRangeArr[0]));
@ -179,6 +183,7 @@ public class HwElectronicFenceServiceImpl implements IHwElectronicFenceService {
e.setRadius(Double.valueOf(areaRangeArr[2])); e.setRadius(Double.valueOf(areaRangeArr[2]));
} }
//根据电子围栏设置的区域获取报警信息,然后获取异常设备数量
AlarmInfoVo alarmInfoVo = hwAlarmInfoMapper.selectAlarmCountByFenceArea(fenceArea.getFenceAreaId()); AlarmInfoVo alarmInfoVo = hwAlarmInfoMapper.selectAlarmCountByFenceArea(fenceArea.getFenceAreaId());
e.setAbnormalCount(alarmInfoVo.getAlarmCount()); e.setAbnormalCount(alarmInfoVo.getAlarmCount());
e.setAreaShapeFlag(areaShapeFlag); e.setAreaShapeFlag(areaShapeFlag);

@ -15,6 +15,7 @@ import com.ruoyi.tdengine.api.domain.TdField;
import com.ruoyi.tdengine.api.domain.TdHistorySelectDto; import com.ruoyi.tdengine.api.domain.TdHistorySelectDto;
import com.ruoyi.tdengine.api.domain.TdReturnDataVo; import com.ruoyi.tdengine.api.domain.TdReturnDataVo;
import com.ruoyi.tdengine.api.domain.TdSuperTableSelectVo; import com.ruoyi.tdengine.api.domain.TdSuperTableSelectVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -52,11 +53,12 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService {
JSONObject returnObj = new JSONObject(); JSONObject returnObj = new JSONObject();
Long deviceModeId = deviceLatestDataVo.getDeviceModeId(); Long deviceModeId = deviceLatestDataVo.getDeviceModeId();
HwDeviceModeFunction queryModeFunction = new HwDeviceModeFunction(); HwDeviceModeFunction queryModeFunction = new HwDeviceModeFunction();
queryModeFunction.setDeviceModeId(deviceModeId); queryModeFunction.setDeviceModeId(deviceModeId);//索引,先查出数据再过滤
queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE); // queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE);
List<HwDeviceModeFunction> deviceModeFunctions = deviceModeFunctionMapper.selectHwDeviceModeFunctionList(queryModeFunction); List<HwDeviceModeFunction> deviceModeFunctions = deviceModeFunctionMapper.selectHwDeviceModeFunctionList(queryModeFunction);
Map<String, String> functionIndentifierName = deviceModeFunctions.stream().collect( Map<String, String> functionIndentifierName = deviceModeFunctions.stream()
Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier, HwDeviceModeFunction::getFunctionName)); .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); functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP);
Map<String, String> functionIndentifierNameMap = new HashMap<>(); Map<String, String> functionIndentifierNameMap = new HashMap<>();
@ -80,11 +82,10 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService {
tdSuperTableSelectVo.setDeviceName(deviceLatestDataVo.getDeviceName()); tdSuperTableSelectVo.setDeviceName(deviceLatestDataVo.getDeviceName());
tdSuperTableSelectVo.setStartTime(deviceLatestDataVo.getStartTime()); tdSuperTableSelectVo.setStartTime(deviceLatestDataVo.getStartTime());
tdSuperTableSelectVo.setEndTime(deviceLatestDataVo.getEndTime()); tdSuperTableSelectVo.setEndTime(deviceLatestDataVo.getEndTime());
tdSuperTableSelectVo.setOffset(deviceLatestDataVo.getOffset()*deviceLatestDataVo.getLimit()); tdSuperTableSelectVo.setOffset(deviceLatestDataVo.getOffset() * deviceLatestDataVo.getLimit());
tdSuperTableSelectVo.setLimit(deviceLatestDataVo.getLimit()); tdSuperTableSelectVo.setLimit(deviceLatestDataVo.getLimit());
List<TdField> schemaFieldValues = new ArrayList<TdField>(); List<TdField> schemaFieldValues = new ArrayList<TdField>();
List<HwDeviceModeFunction> modeFunctions = new ArrayList<>();
deviceModeFunctions.forEach(mf -> { deviceModeFunctions.forEach(mf -> {
TdField field = new TdField(); TdField field = new TdField();
@ -101,16 +102,23 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService {
List<DeviceDataColumnVo> deviceDataColumnVos = new ArrayList<DeviceDataColumnVo>(); List<DeviceDataColumnVo> deviceDataColumnVos = new ArrayList<DeviceDataColumnVo>();
if (latestDataMaps != null && latestDataMaps.size() > 0) { // Map<String, Object> latestDataMap = latestDataMaps.get(0);
Map<String, Object> latestDataMap = latestDataMaps.get(0); for (Map.Entry<String, String> entry : functionIndentifierNameMap.entrySet()) {
for (Map.Entry<String, Object> entry : latestDataMap.entrySet()) { DeviceDataColumnVo deviceDataColumnVo = new DeviceDataColumnVo();
DeviceDataColumnVo deviceDataColumnVo = new DeviceDataColumnVo(); String columnKey = entry.getKey();
String columnKey = entry.getKey(); if (!columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICEID)
if (!columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICEID) && !columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICEMODEID)
&& !columnKey.equalsIgnoreCase(TdEngineConstants.ST_TAG_DEVICEMODEID)) { && functionIndentifierNameMap.get(columnKey) != null) {
deviceDataColumnVo.setColumnKey(columnKey); deviceDataColumnVo.setColumnKey(columnKey);
deviceDataColumnVo.setColumnName(functionIndentifierNameMap.get(columnKey) == null deviceDataColumnVo.setColumnName(functionIndentifierNameMap.get(columnKey) == null
? columnKey : functionIndentifierNameMap.get(columnKey)); ? 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); deviceDataColumnVos.add(deviceDataColumnVo);
} }
} }
@ -157,33 +165,35 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService {
* @date 2023-09-25 15:40 * @date 2023-09-25 15:40
*/ */
@Override @Override
public List<DeviceDataColumnVo> getDeviceDataColumns(Long deviceModeId, List<Map<String, Object>> latestDataMaps) { public List<DeviceDataColumnVo> getDeviceDataColumns(Long deviceModeId) {
HwDeviceModeFunction queryModeFunction = new HwDeviceModeFunction(); HwDeviceModeFunction queryModeFunction = new HwDeviceModeFunction();
queryModeFunction.setDeviceModeId(deviceModeId); queryModeFunction.setDeviceModeId(deviceModeId);//devicemodeid是索引先根据索引查出再过滤
queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE); // queryModeFunction.setFunctionMode(HwDictConstants.FUNCTION_MODE_ATTRIBUTE);
List<HwDeviceModeFunction> deviceModeFunctions = deviceModeFunctionMapper.selectHwDeviceModeFunctionList(queryModeFunction); List<HwDeviceModeFunction> deviceModeFunctions = deviceModeFunctionMapper.selectHwDeviceModeFunctionList(queryModeFunction);
Map<String, String> functionIndentifierName = deviceModeFunctions.stream().collect( //key是functionidentifier用来获取具体值使用value是functionname用来显示使用
Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier, HwDeviceModeFunction::getFunctionName)); Map<String, String> functionIndentifierNameMap = deviceModeFunctions.stream().
functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP); filter(deviceModeFunction -> deviceModeFunction.getFunctionMode().equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE) && !deviceModeFunction.getDisplayFlag().equals(HwDictConstants.DEVICE_MODE_FUNCTION_DISPLAY_FLAG_NO))
functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP); .collect(Collectors.toMap(HwDeviceModeFunction::getFunctionIdentifier, HwDeviceModeFunction::getFunctionName));
functionIndentifierNameMap.put(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME, TdEngineConstants.DEFAULT_FIRST_FIELD_NAME_DISPLAY);
Map<String, String> functionIndentifierNameMap = new HashMap<>(); // functionIndentifierName.putAll(TdEngineConstants.DEVICE_DATA_COLUMN_MAP);
functionIndentifierName.forEach((key, val) ->
Map<String, String> functionIndentifierNameTransferMap = new HashMap<>();
functionIndentifierNameMap.forEach((key, val) ->
{ {
String keyTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key) == null ? String keyTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key) == null ?
key : TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key); key : TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key);
functionIndentifierNameMap.put(keyTransfer, val); functionIndentifierNameTransferMap.put(keyTransfer, val);
}); });
List<DeviceDataColumnVo> deviceDataColumnVos = new ArrayList<DeviceDataColumnVo>(); List<DeviceDataColumnVo> deviceDataColumnVos = new ArrayList<>();
if (latestDataMaps != null && latestDataMaps.size() > 0) { if (functionIndentifierNameTransferMap != null) {
Map<String, Object> latestDataMap = latestDataMaps.get(0); DeviceDataColumnVo deviceDataColumnVo = null;
for (Map.Entry<String, Object> entry : latestDataMap.entrySet()) { for (Map.Entry<String, String> entry : functionIndentifierNameTransferMap.entrySet()) {
DeviceDataColumnVo deviceDataColumnVo = new DeviceDataColumnVo(); deviceDataColumnVo = new DeviceDataColumnVo();
String columnKey = entry.getKey(); String columnKey = entry.getKey();
deviceDataColumnVo.setColumnKey(columnKey); deviceDataColumnVo.setColumnKey(columnKey);
deviceDataColumnVo.setColumnName(functionIndentifierNameMap.get(columnKey) == null deviceDataColumnVo.setColumnName(StringUtils.isEmpty(functionIndentifierNameTransferMap.get(columnKey))
? columnKey : functionIndentifierNameMap.get(columnKey)); ? columnKey : functionIndentifierNameTransferMap.get(columnKey));
deviceDataColumnVos.add(deviceDataColumnVo); deviceDataColumnVos.add(deviceDataColumnVo);
} }
} }

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.HwDeviceMapper"> <mapper namespace="com.ruoyi.business.mapper.HwDeviceMapper">
<resultMap type="HwDevice" id="HwDeviceResult"> <resultMap type="HwDevice" id="HwDeviceResult">
<result property="deviceId" column="device_id" /> <result property="deviceId" column="device_id" />
<result property="deviceCode" column="device_code" /> <result property="deviceCode" column="device_code" />
@ -113,12 +113,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.tenantDataScope} ${params.tenantDataScope}
</where> </where>
</select> </select>
<select id="selectHwDeviceByDeviceId" parameterType="Long" resultMap="HwDeviceResult"> <select id="selectHwDeviceByDeviceId" parameterType="Long" resultMap="HwDeviceResult">
<include refid="selectHwDeviceVo"/> <include refid="selectHwDeviceVo"/>
where device_id = #{deviceId} where device_id = #{deviceId}
</select> </select>
<insert id="insertHwDevice" parameterType="HwDevice" useGeneratedKeys="true" keyProperty="deviceId"> <insert id="insertHwDevice" parameterType="HwDevice" useGeneratedKeys="true" keyProperty="deviceId">
insert into hw_device insert into hw_device
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -220,11 +220,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<delete id="deleteHwDeviceByDeviceId" parameterType="Long"> <delete id="deleteHwDeviceByDeviceId" parameterType="Long">
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> </delete>
<delete id="deleteHwDeviceByDeviceIds" parameterType="String"> <delete id="deleteHwDeviceByDeviceIds" parameterType="String">
delete from hw_device where device_id in delete from hw_device where device_id in
<foreach item="deviceId" collection="array" open="(" separator="," close=")"> <foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId} #{deviceId}
</foreach> </foreach>
@ -359,4 +359,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.tenantDataScope} ${params.tenantDataScope}
</select> </select>
</mapper> </mapper>

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.HwDeviceModeMapper"> <mapper namespace="com.ruoyi.business.mapper.HwDeviceModeMapper">
<resultMap type="HwDeviceMode" id="HwDeviceModeResult"> <resultMap type="HwDeviceMode" id="HwDeviceModeResult">
<result property="deviceModeId" column="device_mode_id" /> <result property="deviceModeId" column="device_mode_id" />
<result property="deviceModeName" column="device_mode_name" /> <result property="deviceModeName" column="device_mode_name" />
@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="deviceModeStatus" column="device_mode_status" /> <result property="deviceModeStatus" column="device_mode_status" />
<result property="commonFlag" column="common_flag" /> <result property="commonFlag" column="common_flag" />
<result property="modeClassfication" column="mode_classfication" /> <result property="modeClassfication" column="mode_classfication" />
<result property="modeType" column="mode_type" />
<result property="deviceModePic" column="device_mode_pic" /> <result property="deviceModePic" column="device_mode_pic" />
<result property="dataVerifyLevel" column="data_verify_level" /> <result property="dataVerifyLevel" column="data_verify_level" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
@ -69,7 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectHwDeviceModeVo"> <sql id="selectHwDeviceModeVo">
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
</sql> </sql>
<sql id="selectHwDeviceModeParameterVo"> <sql id="selectHwDeviceModeParameterVo">
@ -78,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectHwDeviceModeList" parameterType="HwDeviceMode" resultMap="HwDeviceModeResult"> <select id="selectHwDeviceModeList" parameterType="HwDeviceMode" resultMap="HwDeviceModeResult">
<include refid="selectHwDeviceModeVo"/> <include refid="selectHwDeviceModeVo"/>
<where> <where>
<if test="deviceModeName != null and deviceModeName != ''"> and device_mode_name like concat('%', #{deviceModeName}, '%')</if> <if test="deviceModeName != null and deviceModeName != ''"> and device_mode_name like concat('%', #{deviceModeName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if> <if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if> <if test="sceneId != null "> and scene_id = #{sceneId}</if>
@ -86,7 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="gpsFlag != null and gpsFlag != ''"> and gps_flag = #{gpsFlag}</if> <if test="gpsFlag != null and gpsFlag != ''"> and gps_flag = #{gpsFlag}</if>
<if test="deviceModeStatus != null and deviceModeStatus != ''"> and device_mode_status = #{deviceModeStatus}</if> <if test="deviceModeStatus != null and deviceModeStatus != ''"> and device_mode_status = #{deviceModeStatus}</if>
<if test="commonFlag != null and commonFlag != ''"> and common_flag = #{commonFlag}</if> <if test="commonFlag != null and commonFlag != ''"> and common_flag = #{commonFlag}</if>
<if test="modeClassfication != null "> and mode_classfication = #{modeClassfication}</if> <if test="modeClassfication != null and modeClassfication != ''"> and mode_classfication = #{modeClassfication}</if>
<if test="modeType != null and modeType != ''"> and mode_type = #{modeType}</if>
<if test="deviceModePic != null and deviceModePic != ''"> and device_mode_pic = #{deviceModePic}</if> <if test="deviceModePic != null and deviceModePic != ''"> and device_mode_pic = #{deviceModePic}</if>
<if test="dataVerifyLevel != null and dataVerifyLevel != ''"> and data_verify_level = #{dataVerifyLevel}</if> <if test="dataVerifyLevel != null and dataVerifyLevel != ''"> and data_verify_level = #{dataVerifyLevel}</if>
<if test="deviceModeField != null and deviceModeField != ''"> and device_mode_field = #{deviceModeField}</if> <if test="deviceModeField != null and deviceModeField != ''"> and device_mode_field = #{deviceModeField}</if>
@ -95,7 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
order by device_mode_id desc order by device_mode_id desc
</select> </select>
<select id="selectHwDeviceModeByDeviceModeId" parameterType="Long" resultMap="HwDeviceModeHwDeviceModeFunctionResult"> <select id="selectHwDeviceModeByDeviceModeId" parameterType="Long" resultMap="HwDeviceModeHwDeviceModeFunctionResult">
select a.device_mode_id, a.device_mode_name, a.tenant_id, a.scene_id, a.language_code, a.gps_flag, a.device_mode_status, a.common_flag, a.mode_classfication, a.device_mode_pic, a.data_verify_level, a.remark, a.create_by, a.create_time, a.update_by, a.update_time, a.device_mode_field, select a.device_mode_id, a.device_mode_name, a.tenant_id, a.scene_id, a.language_code, a.gps_flag, a.device_mode_status, a.common_flag, a.mode_classfication, a.device_mode_pic, a.data_verify_level, a.remark, a.create_by, a.create_time, a.update_by, a.update_time, a.device_mode_field,
b.mode_function_id as sub_mode_function_id, b.device_mode_id as sub_device_mode_id, b.function_mode as sub_function_mode, b.coordinate as sub_coordinate, b.function_name as sub_function_name, b.function_identifier as sub_function_identifier, b.function_type as sub_function_type, b.data_type as sub_data_type, b.data_definition as sub_data_definition, b.function_formula as sub_function_formula, b.property_unit as sub_property_unit, b.display_flag as sub_display_flag, b.rw_flag as sub_rw_flag, b.invoke_method as sub_invoke_method, b.event_type as sub_event_type, b.remark as sub_remark, b.acquisition_formula as sub_acquisition_formula, b.order_flag as sub_order_flag, b.device_register as sub_device_register, b.property_step as sub_property_step, b.property_field as sub_property_field b.mode_function_id as sub_mode_function_id, b.device_mode_id as sub_device_mode_id, b.function_mode as sub_function_mode, b.coordinate as sub_coordinate, b.function_name as sub_function_name, b.function_identifier as sub_function_identifier, b.function_type as sub_function_type, b.data_type as sub_data_type, b.data_definition as sub_data_definition, b.function_formula as sub_function_formula, b.property_unit as sub_property_unit, b.display_flag as sub_display_flag, b.rw_flag as sub_rw_flag, b.invoke_method as sub_invoke_method, b.event_type as sub_event_type, b.remark as sub_remark, b.acquisition_formula as sub_acquisition_formula, b.order_flag as sub_order_flag, b.device_register as sub_device_register, b.property_step as sub_property_step, b.property_field as sub_property_field
@ -103,7 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join hw_device_mode_function b on b.device_mode_id = a.device_mode_id left join hw_device_mode_function b on b.device_mode_id = a.device_mode_id
where a.device_mode_id = #{deviceModeId} where a.device_mode_id = #{deviceModeId}
</select> </select>
<insert id="insertHwDeviceMode" parameterType="HwDeviceMode" useGeneratedKeys="true" keyProperty="deviceModeId"> <insert id="insertHwDeviceMode" parameterType="HwDeviceMode" useGeneratedKeys="true" keyProperty="deviceModeId">
insert into hw_device_mode insert into hw_device_mode
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -114,7 +116,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="gpsFlag != null and gpsFlag != ''">gps_flag,</if> <if test="gpsFlag != null and gpsFlag != ''">gps_flag,</if>
<if test="deviceModeStatus != null and deviceModeStatus != ''">device_mode_status,</if> <if test="deviceModeStatus != null and deviceModeStatus != ''">device_mode_status,</if>
<if test="commonFlag != null and commonFlag != ''">common_flag,</if> <if test="commonFlag != null and commonFlag != ''">common_flag,</if>
<if test="modeClassfication != null">mode_classfication,</if> <if test="modeType != null and modeType != ''">mode_type,</if>
<if test="modeClassfication != null and modeClassfication != ''">mode_classfication,</if>
<if test="deviceModePic != null">device_mode_pic,</if> <if test="deviceModePic != null">device_mode_pic,</if>
<if test="dataVerifyLevel != null">data_verify_level,</if> <if test="dataVerifyLevel != null">data_verify_level,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
@ -132,7 +135,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="gpsFlag != null and gpsFlag != ''">#{gpsFlag},</if> <if test="gpsFlag != null and gpsFlag != ''">#{gpsFlag},</if>
<if test="deviceModeStatus != null and deviceModeStatus != ''">#{deviceModeStatus},</if> <if test="deviceModeStatus != null and deviceModeStatus != ''">#{deviceModeStatus},</if>
<if test="commonFlag != null and commonFlag != ''">#{commonFlag},</if> <if test="commonFlag != null and commonFlag != ''">#{commonFlag},</if>
<if test="modeClassfication != null">#{modeClassfication},</if> <if test="modeType != null and modeType != ''">#{modeType},</if>
<if test="modeClassfication != null and modeClassfication != ''">#{modeClassfication},</if>
<if test="deviceModePic != null">#{deviceModePic},</if> <if test="deviceModePic != null">#{deviceModePic},</if>
<if test="dataVerifyLevel != null">#{dataVerifyLevel},</if> <if test="dataVerifyLevel != null">#{dataVerifyLevel},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
@ -154,7 +158,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="gpsFlag != null and gpsFlag != ''">gps_flag = #{gpsFlag},</if> <if test="gpsFlag != null and gpsFlag != ''">gps_flag = #{gpsFlag},</if>
<if test="deviceModeStatus != null and deviceModeStatus != ''">device_mode_status = #{deviceModeStatus},</if> <if test="deviceModeStatus != null and deviceModeStatus != ''">device_mode_status = #{deviceModeStatus},</if>
<if test="commonFlag != null and commonFlag != ''">common_flag = #{commonFlag},</if> <if test="commonFlag != null and commonFlag != ''">common_flag = #{commonFlag},</if>
<if test="modeClassfication != null">mode_classfication = #{modeClassfication},</if> <if test="modeType != null and modeType != ''">mode_type = #{modeType},</if>
<if test="modeClassfication != null and modeClassfication != ''">mode_classfication = #{modeClassfication},</if>
<if test="deviceModePic != null">device_mode_pic = #{deviceModePic},</if> <if test="deviceModePic != null">device_mode_pic = #{deviceModePic},</if>
<if test="dataVerifyLevel != null">data_verify_level = #{dataVerifyLevel},</if> <if test="dataVerifyLevel != null">data_verify_level = #{dataVerifyLevel},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
@ -172,14 +177,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="deleteHwDeviceModeByDeviceModeIds" parameterType="String"> <delete id="deleteHwDeviceModeByDeviceModeIds" parameterType="String">
delete from hw_device_mode where device_mode_id in delete from hw_device_mode where device_mode_id in
<foreach item="deviceModeId" collection="array" open="(" separator="," close=")"> <foreach item="deviceModeId" collection="array" open="(" separator="," close=")">
#{deviceModeId} #{deviceModeId}
</foreach> </foreach>
</delete> </delete>
<delete id="deleteHwDeviceModeFunctionByDeviceModeIds" parameterType="String"> <delete id="deleteHwDeviceModeFunctionByDeviceModeIds" parameterType="String">
delete from hw_device_mode_function where device_mode_id in delete from hw_device_mode_function where device_mode_id in
<foreach item="deviceModeId" collection="array" open="(" separator="," close=")"> <foreach item="deviceModeId" collection="array" open="(" separator="," close=")">
#{deviceModeId} #{deviceModeId}
</foreach> </foreach>
@ -307,7 +312,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="gpsFlag != null and gpsFlag != ''"> and hdm.gps_flag = #{gpsFlag}</if> <if test="gpsFlag != null and gpsFlag != ''"> and hdm.gps_flag = #{gpsFlag}</if>
<if test="deviceModeStatus != null and deviceModeStatus != ''"> and hdm.device_mode_status = #{deviceModeStatus}</if> <if test="deviceModeStatus != null and deviceModeStatus != ''"> and hdm.device_mode_status = #{deviceModeStatus}</if>
<if test="commonFlag != null and commonFlag != ''"> and hdm.common_flag = #{commonFlag}</if> <if test="commonFlag != null and commonFlag != ''"> and hdm.common_flag = #{commonFlag}</if>
<if test="modeClassfication != null "> and hdm.mode_classfication = #{modeClassfication}</if> <if test="modeClassfication != null and modeClassfication != ''"> and hdm.mode_classfication = #{modeClassfication}</if>
<if test="deviceModePic != null and deviceModePic != ''"> and hdm.device_mode_pic = #{deviceModePic}</if> <if test="deviceModePic != null and deviceModePic != ''"> and hdm.device_mode_pic = #{deviceModePic}</if>
<if test="dataVerifyLevel != null and dataVerifyLevel != ''"> and hdm.data_verify_level = #{dataVerifyLevel}</if> <if test="dataVerifyLevel != null and dataVerifyLevel != ''"> and hdm.data_verify_level = #{dataVerifyLevel}</if>
<if test="deviceModeField != null and deviceModeField != ''"> and hdm.device_mode_field = #{deviceModeField}</if> <if test="deviceModeField != null and deviceModeField != ''"> and hdm.device_mode_field = #{deviceModeField}</if>
@ -318,4 +323,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
</mapper> </mapper>

@ -21,12 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="tenantGrade" column="tenant_grade" /> <result property="updateTime" column="update_time" />
<result property="tenantBoardTopic" column="tenant_board_topic" />
<result property="tenantBoardPic" column="tenant_board_pic" />
<result property="tenantField" column="tenant_field" /> <result property="tenantField" column="tenant_field" />
</resultMap> </resultMap>
<sql id="selectHwTenantVo"> <sql id="selectHwTenantVo">
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
</sql> </sql>
<select id="selectHwTenantList" parameterType="HwTenant" resultMap="HwTenantResult"> <select id="selectHwTenantList" parameterType="HwTenant" resultMap="HwTenantResult">
@ -73,6 +75,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="tenanBoardTopic != null and tenantBoardTopic != ''">tenant_board_topic,</if>
<if test="tenantBoardPic != null and tenantBoardPic != ''">tenant_board_pic,</if>
<if test="tenantGrade != null">tenant_grade,</if> <if test="tenantGrade != null">tenant_grade,</if>
<if test="tenantField != null">tenant_field,</if> <if test="tenantField != null">tenant_field,</if>
</trim> </trim>
@ -92,6 +96,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="tenanBoardTopic != null and tenanBoardTopic != ''">#{tenanBoardTopic},</if>
<if test="tenantBoardPic != null and tenantBoardPic != ''">#{tenantBoardPic},</if>
<if test="tenantGrade != null">#{tenantGrade},</if> <if test="tenantGrade != null">#{tenantGrade},</if>
<if test="tenantField != null">#{tenantField},</if> <if test="tenantField != null">#{tenantField},</if>
</trim> </trim>
@ -115,6 +121,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="tenanBoardTopic != null and tenanBoardTopic != ''">tenant_board_topic = #{tenanBoardTopic},</if>
<if test="tenantBoardPic != null and tenantBoardPic != ''">tenant_board_pic = #{tenantBoardPic},</if>
<if test="tenantGrade != null">tenant_grade = #{tenantGrade},</if> <if test="tenantGrade != null">tenant_grade = #{tenantGrade},</if>
<if test="tenantField != null">tenant_field = #{tenantField},</if> <if test="tenantField != null">tenant_field = #{tenantField},</if>
</trim> </trim>

@ -134,14 +134,14 @@ public class DataProcessServiceImpl extends CommanHandleService implements IData
Object latitude = null; Object latitude = null;
for (Map.Entry<String, Object> entry : dataValueJson.entrySet()) { for (Map.Entry<String, Object> entry : dataValueJson.entrySet()) {
String key = entry.getKey(); String originalKey = entry.getKey();//原来的key
Object value = entry.getValue(); Object value = entry.getValue();
/** /**
* keykeyvaluevalue1 * keykeyvaluevalue1
*/ */
key = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key) == null ? key String key = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(originalKey) == null ? originalKey
: TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(key); : TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(originalKey);
if (key.equalsIgnoreCase(TdEngineConstants.PAYLOAD_DEVICE_DATA_TYPE_TYPE)) { if (key.equalsIgnoreCase(TdEngineConstants.PAYLOAD_DEVICE_DATA_TYPE_TYPE)) {
continue; continue;
@ -193,7 +193,10 @@ public class DataProcessServiceImpl extends CommanHandleService implements IData
} else if (key.equalsIgnoreCase(HwDictConstants.DEFAULT_FUNCTION_LATITUDE_IDENTIFIER)) { } else if (key.equalsIgnoreCase(HwDictConstants.DEFAULT_FUNCTION_LATITUDE_IDENTIFIER)) {
latitude = value; latitude = value;
} else { } else {
alarmSchemaFields.add(tdField); TdField alarmTdField = new TdField();
alarmTdField.setFieldName(originalKey);
alarmTdField.setFieldValue(value);
alarmSchemaFields.add(alarmTdField);
} }
} }
} }

@ -481,4 +481,33 @@ public class TdEngineController {
} }
} }
/**
* @return R<?>
* @param: tableDto
* @description
* @author xins
* @date 2023-08-28 16:17
*/
@InnerAuth
@PostMapping("/dropTable")
public R<?> dropTable(@Validated @RequestBody TdTableDropVo tdTableDropVo) {
try {
String databaseName = tdTableDropVo.getDatabaseName();
String tableName = tdTableDropVo.getTableName();
this.tdEngineService.dropTable(databaseName, tableName);
log.info("successfully droped table " + tableName);
return R.ok("successfully droped table " + tableName);
} catch (Exception e) {
String message = e.getCause().getMessage();
try {
message = message.substring(message.lastIndexOf("invalid operation"));
} catch (Exception ex) {
log.error(ex.getMessage());
}
log.error(message);
return R.fail(message);
}
}
} }

@ -153,6 +153,16 @@ public interface TdEngineMapper {
int getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto); int getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto);
/**
* drop
*
* @param databaseName
* @param tableName
*/
void dropTable(@Param("databaseName") String databaseName,
@Param("tableName") String tableName);
// /** // /**
// * 检查表是否存在 // * 检查表是否存在
// * @param dataBaseName // * @param dataBaseName

@ -133,7 +133,14 @@ public interface ITdEngineService {
*/ */
public int getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto); public int getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto);
/**
* @param: databaseName
* @param: tableName
* @description drop
* @author xins
* @date 2024-04-20 11:08
*/
public void dropTable(String databaseName, String tableName) throws Exception;
// void initSTableFrame(String msg) throws Exception; // void initSTableFrame(String msg) throws Exception;
// List<Map<String, Object>> getRealtimeData(SelectVisualDto selectVisualDto); // List<Map<String, Object>> getRealtimeData(SelectVisualDto selectVisualDto);

@ -240,6 +240,23 @@ public class TdEngineServiceImpl implements ITdEngineService {
int count = this.tdEngineMapper.getCountOfHistoryData(tdHistorySelectDto); int count = this.tdEngineMapper.getCountOfHistoryData(tdHistorySelectDto);
return count; return count;
} }
/**
* @param: databaseName
* @param: tableName
* @description drop
* @author xins
* @date 2024-04-20 11:08
*/
@Override
public void dropTable(String databaseName, String tableName) throws Exception {
this.tdEngineMapper.dropTable(databaseName, tableName);
}
// //
// /** // /**
// * 检查数据库表是否存在 // * 检查数据库表是否存在

@ -311,7 +311,9 @@
</select> </select>
<update id="dropTable">
drop table #{databaseName}.#{tableName}
</update>
<!-- <!--
<select id="checkTableExists" resultType="java.lang.Integer"> <select id="checkTableExists" resultType="java.lang.Integer">

Loading…
Cancel
Save