Browse Source

设备管理中,新增、编辑、查询都增加了gateway关联

zhc
zhczyx@163.com 2 weeks ago
parent
commit
5b26606574
  1. 1
      data-center-business-common/src/main/resources/config/language/msg/msg_cn.yml
  2. 3
      data-center-business-common/src/main/resources/config/language/msg/msg_en.yml
  3. 1
      data-center-business-common/src/main/resources/config/language/msg/msg_jp.yml
  4. 2
      data-center-business-controller/src/main/resources/db/migration/V65__device_update.sql
  5. 49
      data-center-business-dao/src/main/resources/mappers/auto/DeviceInfoMapper.xml
  6. 7
      data-center-business-dao/src/main/resources/mappers/ex/DeviceInfoMapperExt.xml
  7. 3
      data-center-business-model/src/main/java/com/techsor/datacenter/business/dto/device/DeviceAddParams.java
  8. 3
      data-center-business-model/src/main/java/com/techsor/datacenter/business/dto/device/DeviceUpdateParams.java
  9. 3
      data-center-business-model/src/main/java/com/techsor/datacenter/business/importexcel/deviceinfo/DeviceInfoExcel.java
  10. 34
      data-center-business-model/src/main/java/com/techsor/datacenter/business/model/DeviceInfo.java
  11. 60
      data-center-business-model/src/main/java/com/techsor/datacenter/business/model/DeviceInfoExample.java
  12. 2
      data-center-business-model/src/main/java/com/techsor/datacenter/business/vo/device/DeviceVO.java
  13. 28
      data-center-business-service/src/main/java/com/techsor/datacenter/business/service/impl/DeviceServiceImpl.java

1
data-center-business-common/src/main/resources/config/language/msg/msg_cn.yml

@ -18,6 +18,7 @@ msgcn:
buildingNameDoesNotExist: 楼宇名称不存在
floorNameHasExisted: 楼层名称已存在
floorNameDoesNotExist: 楼层名称不存在
gatewayClientDoesNotExist: 网关不存在
buildingNotFound: 不存在该楼宇
fbNotSameCompany: 需与楼宇归属于同一企业
spaceNameHasExisted: 房间名称已存在

3
data-center-business-common/src/main/resources/config/language/msg/msg_en.yml

@ -26,7 +26,8 @@ msgen:
assetNameHasExisted: Asset name already exists.
assetSymbolHasExisted: Asset symbol already exists.
assetNameDoesNotExist: Asset name does not exist.
assetSymbolDoesNotExist: 资产记号不存在
gatewayClientDoesNotExist: Gateway client does not exist.
assetSymbolDoesNotExist: Asset symbol does not exist.
spaceNotFound: Room not found.
faNotSameCompany: Must belong to the same company as the room.
bindedDevice: Device is bound.

1
data-center-business-common/src/main/resources/config/language/msg/msg_jp.yml

@ -27,6 +27,7 @@ msgjp:
assetSymbolHasExisted: 記号はすでに存在します
assetNameDoesNotExist: 該当資産名がない
assetSymbolDoesNotExist: 資産記号が存在しません
gatewayClientDoesNotExist: 該当ゲートウェイが存在しません
spaceNotFound: 該当空間がない
faNotSameCompany: 空間と同じ会社に所属してください
bindedDevice: 登録されたデバイスは存在しています

2
data-center-business-controller/src/main/resources/db/migration/V65__device_update.sql

@ -0,0 +1,2 @@
ALTER TABLE `device_info`
ADD COLUMN `gateway_client_id` INT NULL DEFAULT NULL AFTER `asset_id`;

49
data-center-business-dao/src/main/resources/mappers/auto/DeviceInfoMapper.xml

@ -16,6 +16,7 @@
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="building_id" jdbcType="BIGINT" property="buildingId" />
<result column="asset_id" jdbcType="BIGINT" property="assetId" />
<result column="gateway_client_id" jdbcType="INTEGER" property="gatewayClientId" />
<result column="flag" jdbcType="INTEGER" property="flag" />
<result column="company_id" jdbcType="BIGINT" property="companyId" />
<result column="created_by" jdbcType="BIGINT" property="createdBy" />
@ -111,9 +112,9 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, device_id, device_sn, type_id, wsclient_id, space_id, device_name, remark, building_id,
asset_id, flag, company_id, created_by, created_timestamp, updated_by, updated_timestamp,
project_id, floor_id, monitoring_point_name, monitoring_point_category_id, data_provider_id,
gateway_info_id, alarm_level, retain_alert, unit
asset_id, gateway_client_id, flag, company_id, created_by, created_timestamp, updated_by,
updated_timestamp, project_id, floor_id, monitoring_point_name, monitoring_point_category_id,
data_provider_id, gateway_info_id, alarm_level, retain_alert, unit
</sql>
<sql id="Blob_Column_List">
<!--
@ -203,21 +204,23 @@
insert into device_info (device_id, device_sn, type_id,
wsclient_id, space_id, device_name,
remark, building_id, asset_id,
flag, company_id, created_by,
created_timestamp, updated_by, updated_timestamp,
project_id, floor_id, monitoring_point_name,
monitoring_point_category_id, data_provider_id,
gateway_info_id, alarm_level, retain_alert,
unit, data_mapping)
gateway_client_id, flag, company_id,
created_by, created_timestamp, updated_by,
updated_timestamp, project_id, floor_id,
monitoring_point_name, monitoring_point_category_id,
data_provider_id, gateway_info_id, alarm_level,
retain_alert, unit, data_mapping
)
values (#{deviceId,jdbcType=VARCHAR}, #{deviceSn,jdbcType=VARCHAR}, #{typeId,jdbcType=INTEGER},
#{wsclientId,jdbcType=INTEGER}, #{spaceId,jdbcType=BIGINT}, #{deviceName,jdbcType=VARCHAR},
#{remark,jdbcType=VARCHAR}, #{buildingId,jdbcType=BIGINT}, #{assetId,jdbcType=BIGINT},
#{flag,jdbcType=INTEGER}, #{companyId,jdbcType=BIGINT}, #{createdBy,jdbcType=BIGINT},
#{createdTimestamp,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT}, #{updatedTimestamp,jdbcType=BIGINT},
#{projectId,jdbcType=BIGINT}, #{floorId,jdbcType=BIGINT}, #{monitoringPointName,jdbcType=VARCHAR},
#{monitoringPointCategoryId,jdbcType=BIGINT}, #{dataProviderId,jdbcType=BIGINT},
#{gatewayInfoId,jdbcType=BIGINT}, #{alarmLevel,jdbcType=INTEGER}, #{retainAlert,jdbcType=INTEGER},
#{unit,jdbcType=VARCHAR}, #{dataMapping,jdbcType=LONGVARCHAR})
#{gatewayClientId,jdbcType=INTEGER}, #{flag,jdbcType=INTEGER}, #{companyId,jdbcType=BIGINT},
#{createdBy,jdbcType=BIGINT}, #{createdTimestamp,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT},
#{updatedTimestamp,jdbcType=BIGINT}, #{projectId,jdbcType=BIGINT}, #{floorId,jdbcType=BIGINT},
#{monitoringPointName,jdbcType=VARCHAR}, #{monitoringPointCategoryId,jdbcType=BIGINT},
#{dataProviderId,jdbcType=BIGINT}, #{gatewayInfoId,jdbcType=BIGINT}, #{alarmLevel,jdbcType=INTEGER},
#{retainAlert,jdbcType=INTEGER}, #{unit,jdbcType=VARCHAR}, #{dataMapping,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.techsor.datacenter.business.model.DeviceInfo">
<!--
@ -256,6 +259,9 @@
<if test="assetId != null">
asset_id,
</if>
<if test="gatewayClientId != null">
gateway_client_id,
</if>
<if test="flag != null">
flag,
</if>
@ -333,6 +339,9 @@
<if test="assetId != null">
#{assetId,jdbcType=BIGINT},
</if>
<if test="gatewayClientId != null">
#{gatewayClientId,jdbcType=INTEGER},
</if>
<if test="flag != null">
#{flag,jdbcType=INTEGER},
</if>
@ -430,6 +439,9 @@
<if test="record.assetId != null">
asset_id = #{record.assetId,jdbcType=BIGINT},
</if>
<if test="record.gatewayClientId != null">
gateway_client_id = #{record.gatewayClientId,jdbcType=INTEGER},
</if>
<if test="record.flag != null">
flag = #{record.flag,jdbcType=INTEGER},
</if>
@ -499,6 +511,7 @@
remark = #{record.remark,jdbcType=VARCHAR},
building_id = #{record.buildingId,jdbcType=BIGINT},
asset_id = #{record.assetId,jdbcType=BIGINT},
gateway_client_id = #{record.gatewayClientId,jdbcType=INTEGER},
flag = #{record.flag,jdbcType=INTEGER},
company_id = #{record.companyId,jdbcType=BIGINT},
created_by = #{record.createdBy,jdbcType=BIGINT},
@ -535,6 +548,7 @@
remark = #{record.remark,jdbcType=VARCHAR},
building_id = #{record.buildingId,jdbcType=BIGINT},
asset_id = #{record.assetId,jdbcType=BIGINT},
gateway_client_id = #{record.gatewayClientId,jdbcType=INTEGER},
flag = #{record.flag,jdbcType=INTEGER},
company_id = #{record.companyId,jdbcType=BIGINT},
created_by = #{record.createdBy,jdbcType=BIGINT},
@ -588,6 +602,9 @@
<if test="assetId != null">
asset_id = #{assetId,jdbcType=BIGINT},
</if>
<if test="gatewayClientId != null">
gateway_client_id = #{gatewayClientId,jdbcType=INTEGER},
</if>
<if test="flag != null">
flag = #{flag,jdbcType=INTEGER},
</if>
@ -654,6 +671,7 @@
remark = #{remark,jdbcType=VARCHAR},
building_id = #{buildingId,jdbcType=BIGINT},
asset_id = #{assetId,jdbcType=BIGINT},
gateway_client_id = #{gatewayClientId,jdbcType=INTEGER},
flag = #{flag,jdbcType=INTEGER},
company_id = #{companyId,jdbcType=BIGINT},
created_by = #{createdBy,jdbcType=BIGINT},
@ -687,6 +705,7 @@
remark = #{remark,jdbcType=VARCHAR},
building_id = #{buildingId,jdbcType=BIGINT},
asset_id = #{assetId,jdbcType=BIGINT},
gateway_client_id = #{gatewayClientId,jdbcType=INTEGER},
flag = #{flag,jdbcType=INTEGER},
company_id = #{companyId,jdbcType=BIGINT},
created_by = #{createdBy,jdbcType=BIGINT},

7
data-center-business-dao/src/main/resources/mappers/ex/DeviceInfoMapperExt.xml

@ -53,7 +53,8 @@
device_info.data_provider_id, data_provider.name dataProviderName, device_info.retain_alert,
device_info.gateway_info_id, data_provider_gateway_info.name gatewayInfoName, device_info.alarm_level,
device_info.unit,device_info.data_mapping,
dashboard_device_group.id deviceGroupId, dashboard_device_group.name deviceGroupName
dashboard_device_group.id deviceGroupId, dashboard_device_group.name deviceGroupName,
gateway_clients.client_name gatewayClientName
from
device_info
left join basic_project on device_info.project_id = basic_project.id
@ -69,6 +70,7 @@
left join device_alert_config dac on device_info.id=dac.device_config_id and dac.flag = 0
left join dashboard_device_group_relation on dashboard_device_group_relation.device_info_id = device_info.id
left join dashboard_device_group on dashboard_device_group_relation.device_group_id = dashboard_device_group.id
left join gateway_clients on gateway_clients.client_id = device_info.gateway_client_id
<if test="deviceVO.targetIdValue != null ">
left join target_id_check tic on dac.id = tic.alert_config_id
</if>
@ -103,6 +105,9 @@
<if test="deviceVO.floorId != null ">
and basic_floor.floor_id = #{deviceVO.floorId}
</if>
<if test="deviceVO.gatewayClientName != null ">
and gateway_clients.client_name like concat('%', #{deviceVO.gatewayClientName}, '%')
</if>
<if test="deviceVO.targetIdValue != null ">
and tic.target_id_value = #{deviceVO.targetIdValue}
</if>

3
data-center-business-model/src/main/java/com/techsor/datacenter/business/dto/device/DeviceAddParams.java

@ -37,6 +37,9 @@ public class DeviceAddParams {
@Schema(description = "Asset ID", example = "Asset-ID")
private Long assetId;
@Schema(description = "gatewayClientId", example = "1")
private Integer gatewayClientId;
@Schema(description = "Floor ID", example = "Floor-ID")
private Long floorId;

3
data-center-business-model/src/main/java/com/techsor/datacenter/business/dto/device/DeviceUpdateParams.java

@ -38,6 +38,9 @@ public class DeviceUpdateParams {
@Schema(description = "Asset ID", example = "Asset ID")
private Long assetId;
@Schema(description = "gatewayClientId", example = "gatewayClientId")
private Integer gatewayClientId;
@Schema(description = "Floor ID", example = "Floor ID")
private Long floorId;

3
data-center-business-model/src/main/java/com/techsor/datacenter/business/importexcel/deviceinfo/DeviceInfoExcel.java

@ -27,6 +27,9 @@ public class DeviceInfoExcel {
@ExcelProperty(value ="资产记号")
private String assetSymbol;
@ExcelProperty(value ="网关ID")
private String gatewayClientId;
@ExcelProperty(value ="设备ID")
private String deviceId;

34
data-center-business-model/src/main/java/com/techsor/datacenter/business/model/DeviceInfo.java

@ -94,6 +94,15 @@ public class DeviceInfo implements Serializable {
*/
private Long assetId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column device_info.gateway_client_id
*
* @mbg.generated
*/
private Integer gatewayClientId;
/**
*
* This field was generated by MyBatis Generator.
@ -486,6 +495,30 @@ public class DeviceInfo implements Serializable {
this.assetId = assetId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column device_info.gateway_client_id
*
* @return the value of device_info.gateway_client_id
*
* @mbg.generated
*/
public Integer getGatewayClientId() {
return gatewayClientId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column device_info.gateway_client_id
*
* @param gatewayClientId the value for device_info.gateway_client_id
*
* @mbg.generated
*/
public void setGatewayClientId(Integer gatewayClientId) {
this.gatewayClientId = gatewayClientId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column device_info.flag
@ -892,6 +925,7 @@ public class DeviceInfo implements Serializable {
sb.append(", remark=").append(remark);
sb.append(", buildingId=").append(buildingId);
sb.append(", assetId=").append(assetId);
sb.append(", gatewayClientId=").append(gatewayClientId);
sb.append(", flag=").append(flag);
sb.append(", companyId=").append(companyId);
sb.append(", createdBy=").append(createdBy);

60
data-center-business-model/src/main/java/com/techsor/datacenter/business/model/DeviceInfoExample.java

@ -835,6 +835,66 @@ public class DeviceInfoExample {
return (Criteria) this;
}
public Criteria andGatewayClientIdIsNull() {
addCriterion("gateway_client_id is null");
return (Criteria) this;
}
public Criteria andGatewayClientIdIsNotNull() {
addCriterion("gateway_client_id is not null");
return (Criteria) this;
}
public Criteria andGatewayClientIdEqualTo(Integer value) {
addCriterion("gateway_client_id =", value, "gatewayClientId");
return (Criteria) this;
}
public Criteria andGatewayClientIdNotEqualTo(Integer value) {
addCriterion("gateway_client_id <>", value, "gatewayClientId");
return (Criteria) this;
}
public Criteria andGatewayClientIdGreaterThan(Integer value) {
addCriterion("gateway_client_id >", value, "gatewayClientId");
return (Criteria) this;
}
public Criteria andGatewayClientIdGreaterThanOrEqualTo(Integer value) {
addCriterion("gateway_client_id >=", value, "gatewayClientId");
return (Criteria) this;
}
public Criteria andGatewayClientIdLessThan(Integer value) {
addCriterion("gateway_client_id <", value, "gatewayClientId");
return (Criteria) this;
}
public Criteria andGatewayClientIdLessThanOrEqualTo(Integer value) {
addCriterion("gateway_client_id <=", value, "gatewayClientId");
return (Criteria) this;
}
public Criteria andGatewayClientIdIn(List<Integer> values) {
addCriterion("gateway_client_id in", values, "gatewayClientId");
return (Criteria) this;
}
public Criteria andGatewayClientIdNotIn(List<Integer> values) {
addCriterion("gateway_client_id not in", values, "gatewayClientId");
return (Criteria) this;
}
public Criteria andGatewayClientIdBetween(Integer value1, Integer value2) {
addCriterion("gateway_client_id between", value1, value2, "gatewayClientId");
return (Criteria) this;
}
public Criteria andGatewayClientIdNotBetween(Integer value1, Integer value2) {
addCriterion("gateway_client_id not between", value1, value2, "gatewayClientId");
return (Criteria) this;
}
public Criteria andFlagIsNull() {
addCriterion("flag is null");
return (Criteria) this;

2
data-center-business-model/src/main/java/com/techsor/datacenter/business/vo/device/DeviceVO.java

@ -65,6 +65,8 @@ public class DeviceVO {
private String assetSymbol;
private String gatewayClientName;
private Integer flag;
private Long companyId;

28
data-center-business-service/src/main/java/com/techsor/datacenter/business/service/impl/DeviceServiceImpl.java

@ -147,6 +147,9 @@ public class DeviceServiceImpl implements IDeviceService {
@Resource
private NotificationService notificationService;
@Resource
private GatewayClientsMapperExt gatewayClientsMapperExt;
@Resource
private DeviceAlertTemplateMapperExt deviceAlertTemplateMapperExt;
@ -844,6 +847,12 @@ public class DeviceServiceImpl implements IDeviceService {
errorList.add(msgLanguageChange.getParameterMapByCode(languageType, "assetSymbolDoesNotExist"));
}
// Floor Check
boolean gatewayClientExist = checkGatewayClient(deviceInfoExcel.getGatewayClientId(), companyId, deviceInfo);
if (!floorExists) {
errorList.add(msgLanguageChange.getParameterMapByCode(languageType, "floorNameDoesNotExist"));
}
// Device Type Check
boolean deviceExists = checkDeviceType(deviceInfoExcel.getDeviceType(), companyId);
if (!deviceExists) {
@ -2087,6 +2096,25 @@ public class DeviceServiceImpl implements IDeviceService {
}
}
private boolean checkGatewayClient(String gatewayClientName, long companyId, DeviceInfo deviceInfo) {
if (StringUtils.isBlank(gatewayClientName)) {
return true;
} else {
GatewayClientsExample gatewayClientsExample = new GatewayClientsExample();
gatewayClientsExample.createCriteria().andClientNameEqualTo(gatewayClientName).andCompanyIdEqualTo(companyId).andFlagEqualTo(0);
List<GatewayClients> assetList = this.gatewayClientsMapperExt.selectByExample(gatewayClientsExample);
if (CollectionUtils.isEmpty(assetList)) {
return false;
} else {
deviceInfo.setGatewayClientId(assetList.get(assetList.size()-1).getId());
return true;
}
}
}
private boolean checkDeviceType(String deviceType, long companyId) {
if (StringUtils.isBlank(deviceType)) {
return false;

Loading…
Cancel
Save