Browse Source

设备增加单位和数据映射

master
review512jwy@163.com 4 weeks ago
parent
commit
ad67d048b0
  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. 3
      data-center-business-common/src/main/resources/config/language/msg/msg_jp.yml
  4. 4
      data-center-business-controller/src/main/resources/db/migration/V61__device_adapt_category.sql
  5. BIN
      data-center-business-controller/src/main/resources/template/deviceInfo_zh.xlsx
  6. BIN
      data-center-business-controller/src/main/resources/template/en/deviceInfo_en.xlsx
  7. BIN
      data-center-business-controller/src/main/resources/template/jp/deviceInfo_jp.xlsx
  8. 24
      data-center-business-dao/src/main/java/com/techsor/datacenter/business/dao/auto/DeviceInfoMapper.java
  9. 149
      data-center-business-dao/src/main/resources/mappers/auto/DeviceInfoMapper.xml
  10. 7
      data-center-business-dao/src/main/resources/mappers/ex/DeviceInfoMapperExt.xml
  11. 6
      data-center-business-model/src/main/java/com/techsor/datacenter/business/dto/device/DeviceAddParams.java
  12. 6
      data-center-business-model/src/main/java/com/techsor/datacenter/business/dto/device/DeviceUpdateParams.java
  13. 6
      data-center-business-model/src/main/java/com/techsor/datacenter/business/importexcel/deviceinfo/DeviceInfoExcel.java
  14. 6
      data-center-business-model/src/main/java/com/techsor/datacenter/business/importexcel/deviceinfo/DeviceInfoExcelCn.java
  15. 6
      data-center-business-model/src/main/java/com/techsor/datacenter/business/importexcel/deviceinfo/DeviceInfoExcelEn.java
  16. 6
      data-center-business-model/src/main/java/com/techsor/datacenter/business/importexcel/deviceinfo/DeviceInfoExcelJp.java
  17. 68
      data-center-business-model/src/main/java/com/techsor/datacenter/business/model/DeviceInfo.java
  18. 70
      data-center-business-model/src/main/java/com/techsor/datacenter/business/model/DeviceInfoExample.java
  19. 6
      data-center-business-model/src/main/java/com/techsor/datacenter/business/vo/device/DeviceVO.java
  20. 29
      data-center-business-service/src/main/java/com/techsor/datacenter/business/service/impl/DeviceServiceImpl.java
  21. 14
      data-center-business-util/src/main/java/com/techsor/datacenter/business/util/CommonUtil.java

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

@ -199,3 +199,4 @@ msgcn:
levelReferencedByChildren: 已被下级层级绑定,请先解绑后再删除 levelReferencedByChildren: 已被下级层级绑定,请先解绑后再删除
levelRoleNameExist: 层级角色已存在 levelRoleNameExist: 层级角色已存在
roleHasBinded: 角色已绑定用户,请先解绑再删除 roleHasBinded: 角色已绑定用户,请先解绑再删除
dataMappingFormatError: 数据映射格式错误

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

@ -198,4 +198,5 @@ msgen:
invalidParentLevel: Invalid parent level invalidParentLevel: Invalid parent level
levelReferencedByChildren: It is bound by child levels. Please unbind them before deleting. levelReferencedByChildren: It is bound by child levels. Please unbind them before deleting.
levelRoleNameExist: The role already exists. levelRoleNameExist: The role already exists.
roleHasBinded: The role is assigned to users. Please unbind them before deleting. roleHasBinded: The role is assigned to users. Please unbind them before deleting.
dataMappingFormatError: Invalid data mapping format

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

@ -198,4 +198,5 @@ msgjp:
invalidParentLevel: 無効な上位階層です invalidParentLevel: 無効な上位階層です
levelReferencedByChildren: 下位階層に紐づいています。削除する前に紐付けを解除してください。 levelReferencedByChildren: 下位階層に紐づいています。削除する前に紐付けを解除してください。
levelRoleNameExist: 役割名が既に登録済み levelRoleNameExist: 役割名が既に登録済み
roleHasBinded: 役割はユーザーにバインドされている ので、削除する前にバインドを解除してください roleHasBinded: 役割はユーザーにバインドされている ので、削除する前にバインドを解除してください
dataMappingFormatError: データマッピング形式が不正です

4
data-center-business-controller/src/main/resources/db/migration/V61__device_adapt_category.sql

@ -0,0 +1,4 @@
ALTER TABLE device_info ADD (
`unit` varchar(45) DEFAULT NULL,
`data_mapping` json DEFAULT NULL COMMENT '数据映射关系,格式为:{"default":{"1":"漏水","2":"漏电","3":"起火"},"status":{"1":"开门","2":"关门"}},默认只有default一个字段,预留多字段设计'
);

BIN
data-center-business-controller/src/main/resources/template/deviceInfo_zh.xlsx

Binary file not shown.

BIN
data-center-business-controller/src/main/resources/template/en/deviceInfo_en.xlsx

Binary file not shown.

BIN
data-center-business-controller/src/main/resources/template/jp/deviceInfo_jp.xlsx

Binary file not shown.

24
data-center-business-dao/src/main/java/com/techsor/datacenter/business/dao/auto/DeviceInfoMapper.java

@ -46,6 +46,14 @@ public interface DeviceInfoMapper {
*/ */
int insertSelective(DeviceInfo record); int insertSelective(DeviceInfo record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table device_info
*
* @mbg.generated
*/
List<DeviceInfo> selectByExampleWithBLOBs(DeviceInfoExample example);
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table device_info * This method corresponds to the database table device_info
@ -70,6 +78,14 @@ public interface DeviceInfoMapper {
*/ */
int updateByExampleSelective(@Param("record") DeviceInfo record, @Param("example") DeviceInfoExample example); int updateByExampleSelective(@Param("record") DeviceInfo record, @Param("example") DeviceInfoExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table device_info
*
* @mbg.generated
*/
int updateByExampleWithBLOBs(@Param("record") DeviceInfo record, @Param("example") DeviceInfoExample example);
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table device_info * This method corresponds to the database table device_info
@ -86,6 +102,14 @@ public interface DeviceInfoMapper {
*/ */
int updateByPrimaryKeySelective(DeviceInfo record); int updateByPrimaryKeySelective(DeviceInfo record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table device_info
*
* @mbg.generated
*/
int updateByPrimaryKeyWithBLOBs(DeviceInfo record);
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table device_info * This method corresponds to the database table device_info

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

@ -30,6 +30,14 @@
<result column="gateway_info_id" jdbcType="BIGINT" property="gatewayInfoId" /> <result column="gateway_info_id" jdbcType="BIGINT" property="gatewayInfoId" />
<result column="alarm_level" jdbcType="INTEGER" property="alarmLevel" /> <result column="alarm_level" jdbcType="INTEGER" property="alarmLevel" />
<result column="retain_alert" jdbcType="INTEGER" property="retainAlert" /> <result column="retain_alert" jdbcType="INTEGER" property="retainAlert" />
<result column="unit" jdbcType="VARCHAR" property="unit" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.techsor.datacenter.business.model.DeviceInfo">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<result column="data_mapping" jdbcType="LONGVARCHAR" property="dataMapping" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<!-- <!--
@ -105,8 +113,36 @@
id, device_id, device_sn, type_id, wsclient_id, space_id, device_name, remark, building_id, 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, 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, project_id, floor_id, monitoring_point_name, monitoring_point_category_id, data_provider_id,
gateway_info_id, alarm_level, retain_alert gateway_info_id, alarm_level, retain_alert, unit
</sql> </sql>
<sql id="Blob_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
data_mapping
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.techsor.datacenter.business.model.DeviceInfoExample" resultMap="ResultMapWithBLOBs">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
'true' as QUERYID,
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from device_info
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.techsor.datacenter.business.model.DeviceInfoExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.techsor.datacenter.business.model.DeviceInfoExample" resultMap="BaseResultMap">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
@ -126,13 +162,15 @@
order by ${orderByClause} order by ${orderByClause}
</if> </if>
</select> </select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
--> -->
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from device_info from device_info
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</select> </select>
@ -169,8 +207,8 @@
created_timestamp, updated_by, updated_timestamp, created_timestamp, updated_by, updated_timestamp,
project_id, floor_id, monitoring_point_name, project_id, floor_id, monitoring_point_name,
monitoring_point_category_id, data_provider_id, monitoring_point_category_id, data_provider_id,
gateway_info_id, alarm_level, retain_alert gateway_info_id, alarm_level, retain_alert,
) unit, data_mapping)
values (#{deviceId,jdbcType=VARCHAR}, #{deviceSn,jdbcType=VARCHAR}, #{typeId,jdbcType=INTEGER}, values (#{deviceId,jdbcType=VARCHAR}, #{deviceSn,jdbcType=VARCHAR}, #{typeId,jdbcType=INTEGER},
#{wsclientId,jdbcType=INTEGER}, #{spaceId,jdbcType=BIGINT}, #{deviceName,jdbcType=VARCHAR}, #{wsclientId,jdbcType=INTEGER}, #{spaceId,jdbcType=BIGINT}, #{deviceName,jdbcType=VARCHAR},
#{remark,jdbcType=VARCHAR}, #{buildingId,jdbcType=BIGINT}, #{assetId,jdbcType=BIGINT}, #{remark,jdbcType=VARCHAR}, #{buildingId,jdbcType=BIGINT}, #{assetId,jdbcType=BIGINT},
@ -178,8 +216,8 @@
#{createdTimestamp,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT}, #{updatedTimestamp,jdbcType=BIGINT}, #{createdTimestamp,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT}, #{updatedTimestamp,jdbcType=BIGINT},
#{projectId,jdbcType=BIGINT}, #{floorId,jdbcType=BIGINT}, #{monitoringPointName,jdbcType=VARCHAR}, #{projectId,jdbcType=BIGINT}, #{floorId,jdbcType=BIGINT}, #{monitoringPointName,jdbcType=VARCHAR},
#{monitoringPointCategoryId,jdbcType=BIGINT}, #{dataProviderId,jdbcType=BIGINT}, #{monitoringPointCategoryId,jdbcType=BIGINT}, #{dataProviderId,jdbcType=BIGINT},
#{gatewayInfoId,jdbcType=BIGINT}, #{alarmLevel,jdbcType=INTEGER}, #{retainAlert,jdbcType=INTEGER} #{gatewayInfoId,jdbcType=BIGINT}, #{alarmLevel,jdbcType=INTEGER}, #{retainAlert,jdbcType=INTEGER},
) #{unit,jdbcType=VARCHAR}, #{dataMapping,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="com.techsor.datacenter.business.model.DeviceInfo"> <insert id="insertSelective" parameterType="com.techsor.datacenter.business.model.DeviceInfo">
<!-- <!--
@ -260,6 +298,12 @@
<if test="retainAlert != null"> <if test="retainAlert != null">
retain_alert, retain_alert,
</if> </if>
<if test="unit != null">
unit,
</if>
<if test="dataMapping != null">
data_mapping,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null"> <if test="deviceId != null">
@ -331,6 +375,12 @@
<if test="retainAlert != null"> <if test="retainAlert != null">
#{retainAlert,jdbcType=INTEGER}, #{retainAlert,jdbcType=INTEGER},
</if> </if>
<if test="unit != null">
#{unit,jdbcType=VARCHAR},
</if>
<if test="dataMapping != null">
#{dataMapping,jdbcType=LONGVARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.techsor.datacenter.business.model.DeviceInfoExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.techsor.datacenter.business.model.DeviceInfoExample" resultType="java.lang.Long">
@ -422,11 +472,53 @@
<if test="record.retainAlert != null"> <if test="record.retainAlert != null">
retain_alert = #{record.retainAlert,jdbcType=INTEGER}, retain_alert = #{record.retainAlert,jdbcType=INTEGER},
</if> </if>
<if test="record.unit != null">
unit = #{record.unit,jdbcType=VARCHAR},
</if>
<if test="record.dataMapping != null">
data_mapping = #{record.dataMapping,jdbcType=LONGVARCHAR},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</update> </update>
<update id="updateByExampleWithBLOBs" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update device_info
set id = #{record.id,jdbcType=INTEGER},
device_id = #{record.deviceId,jdbcType=VARCHAR},
device_sn = #{record.deviceSn,jdbcType=VARCHAR},
type_id = #{record.typeId,jdbcType=INTEGER},
wsclient_id = #{record.wsclientId,jdbcType=INTEGER},
space_id = #{record.spaceId,jdbcType=BIGINT},
device_name = #{record.deviceName,jdbcType=VARCHAR},
remark = #{record.remark,jdbcType=VARCHAR},
building_id = #{record.buildingId,jdbcType=BIGINT},
asset_id = #{record.assetId,jdbcType=BIGINT},
flag = #{record.flag,jdbcType=INTEGER},
company_id = #{record.companyId,jdbcType=BIGINT},
created_by = #{record.createdBy,jdbcType=BIGINT},
created_timestamp = #{record.createdTimestamp,jdbcType=TIMESTAMP},
updated_by = #{record.updatedBy,jdbcType=BIGINT},
updated_timestamp = #{record.updatedTimestamp,jdbcType=BIGINT},
project_id = #{record.projectId,jdbcType=BIGINT},
floor_id = #{record.floorId,jdbcType=BIGINT},
monitoring_point_name = #{record.monitoringPointName,jdbcType=VARCHAR},
monitoring_point_category_id = #{record.monitoringPointCategoryId,jdbcType=BIGINT},
data_provider_id = #{record.dataProviderId,jdbcType=BIGINT},
gateway_info_id = #{record.gatewayInfoId,jdbcType=BIGINT},
alarm_level = #{record.alarmLevel,jdbcType=INTEGER},
retain_alert = #{record.retainAlert,jdbcType=INTEGER},
unit = #{record.unit,jdbcType=VARCHAR},
data_mapping = #{record.dataMapping,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
@ -456,7 +548,8 @@
data_provider_id = #{record.dataProviderId,jdbcType=BIGINT}, data_provider_id = #{record.dataProviderId,jdbcType=BIGINT},
gateway_info_id = #{record.gatewayInfoId,jdbcType=BIGINT}, gateway_info_id = #{record.gatewayInfoId,jdbcType=BIGINT},
alarm_level = #{record.alarmLevel,jdbcType=INTEGER}, alarm_level = #{record.alarmLevel,jdbcType=INTEGER},
retain_alert = #{record.retainAlert,jdbcType=INTEGER} retain_alert = #{record.retainAlert,jdbcType=INTEGER},
unit = #{record.unit,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -537,9 +630,48 @@
<if test="retainAlert != null"> <if test="retainAlert != null">
retain_alert = #{retainAlert,jdbcType=INTEGER}, retain_alert = #{retainAlert,jdbcType=INTEGER},
</if> </if>
<if test="unit != null">
unit = #{unit,jdbcType=VARCHAR},
</if>
<if test="dataMapping != null">
data_mapping = #{dataMapping,jdbcType=LONGVARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.techsor.datacenter.business.model.DeviceInfo">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update device_info
set device_id = #{deviceId,jdbcType=VARCHAR},
device_sn = #{deviceSn,jdbcType=VARCHAR},
type_id = #{typeId,jdbcType=INTEGER},
wsclient_id = #{wsclientId,jdbcType=INTEGER},
space_id = #{spaceId,jdbcType=BIGINT},
device_name = #{deviceName,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
building_id = #{buildingId,jdbcType=BIGINT},
asset_id = #{assetId,jdbcType=BIGINT},
flag = #{flag,jdbcType=INTEGER},
company_id = #{companyId,jdbcType=BIGINT},
created_by = #{createdBy,jdbcType=BIGINT},
created_timestamp = #{createdTimestamp,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=BIGINT},
updated_timestamp = #{updatedTimestamp,jdbcType=BIGINT},
project_id = #{projectId,jdbcType=BIGINT},
floor_id = #{floorId,jdbcType=BIGINT},
monitoring_point_name = #{monitoringPointName,jdbcType=VARCHAR},
monitoring_point_category_id = #{monitoringPointCategoryId,jdbcType=BIGINT},
data_provider_id = #{dataProviderId,jdbcType=BIGINT},
gateway_info_id = #{gatewayInfoId,jdbcType=BIGINT},
alarm_level = #{alarmLevel,jdbcType=INTEGER},
retain_alert = #{retainAlert,jdbcType=INTEGER},
unit = #{unit,jdbcType=VARCHAR},
data_mapping = #{dataMapping,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.techsor.datacenter.business.model.DeviceInfo"> <update id="updateByPrimaryKey" parameterType="com.techsor.datacenter.business.model.DeviceInfo">
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
@ -568,7 +700,8 @@
data_provider_id = #{dataProviderId,jdbcType=BIGINT}, data_provider_id = #{dataProviderId,jdbcType=BIGINT},
gateway_info_id = #{gatewayInfoId,jdbcType=BIGINT}, gateway_info_id = #{gatewayInfoId,jdbcType=BIGINT},
alarm_level = #{alarmLevel,jdbcType=INTEGER}, alarm_level = #{alarmLevel,jdbcType=INTEGER},
retain_alert = #{retainAlert,jdbcType=INTEGER} retain_alert = #{retainAlert,jdbcType=INTEGER},
unit = #{unit,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
</mapper> </mapper>

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

@ -7,7 +7,7 @@
device_name, remark, building_id, asset_id, flag, company_id, device_name, remark, building_id, asset_id, flag, company_id,
created_by, created_timestamp, updated_by, updated_timestamp, created_by, created_timestamp, updated_by, updated_timestamp,
project_id, floor_id, monitoring_point_name, data_provider_id, project_id, floor_id, monitoring_point_name, data_provider_id,
gateway_info_id, alarm_level) gateway_info_id, alarm_level, unit, data_mapping)
VALUES VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
( (
@ -31,7 +31,9 @@
#{item.monitoringPointName,jdbcType=VARCHAR}, #{item.monitoringPointName,jdbcType=VARCHAR},
#{item.dataProviderId,jdbcType=BIGINT}, #{item.dataProviderId,jdbcType=BIGINT},
#{item.gatewayInfoId,jdbcType=BIGINT}, #{item.gatewayInfoId,jdbcType=BIGINT},
#{item.alarmLevel,jdbcType=INTEGER} #{item.alarmLevel,jdbcType=INTEGER},
#{item.unit,jdbcType=VARCHAR},
#{item.dataMapping,jdbcType=LONGVARCHAR}
) )
</foreach> </foreach>
</insert> </insert>
@ -50,6 +52,7 @@
type.device_category_id,device_info.monitoring_point_name,device_info.monitoring_point_category_id,mpc.name monitoringPointCategoryName, type.device_category_id,device_info.monitoring_point_name,device_info.monitoring_point_category_id,mpc.name monitoringPointCategoryName,
device_info.data_provider_id, data_provider.name dataProviderName, device_info.retain_alert, 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.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
from from
device_info device_info

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

@ -61,5 +61,11 @@ public class DeviceAddParams {
@Schema(description ="设备组ID",example = "2") @Schema(description ="设备组ID",example = "2")
private Long deviceGroupId; private Long deviceGroupId;
@Schema(description = "unit", example = "km")
private String unit;
@Schema(description = "data mapping", example = "{\"default\":{\"1\":\"漏水\",\"2\":\"漏电\",\"3\":\"起火\"}")
private String dataMapping;
} }

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

@ -62,4 +62,10 @@ public class DeviceUpdateParams {
@Schema(description ="设备组ID",example = "2") @Schema(description ="设备组ID",example = "2")
private Long deviceGroupId; private Long deviceGroupId;
@Schema(description = "unit", example = "km")
private String unit;
@Schema(description = "data mapping", example = "{\"default\":{\"1\":\"漏水\",\"2\":\"漏电\",\"3\":\"起火\"}")
private String dataMapping;
} }

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

@ -72,5 +72,11 @@ public class DeviceInfoExcel {
@ExcelProperty(value ="设备组") @ExcelProperty(value ="设备组")
private String deviceGroup; private String deviceGroup;
@ExcelProperty(value ="单位")
private String unit;
@ExcelProperty(value ="数据映射")
private String dataMapping;
} }

6
data-center-business-model/src/main/java/com/techsor/datacenter/business/importexcel/deviceinfo/DeviceInfoExcelCn.java

@ -98,4 +98,10 @@ public class DeviceInfoExcelCn {
@ExcelProperty(value ="设备组") @ExcelProperty(value ="设备组")
private String deviceGroup; private String deviceGroup;
@ExcelProperty(value ="单位")
private String unit;
@ExcelProperty(value ="数据映射")
private String dataMapping;
} }

6
data-center-business-model/src/main/java/com/techsor/datacenter/business/importexcel/deviceinfo/DeviceInfoExcelEn.java

@ -68,4 +68,10 @@ public class DeviceInfoExcelEn {
@ExcelProperty(value ="Device Group") @ExcelProperty(value ="Device Group")
private String deviceGroup; private String deviceGroup;
@ExcelProperty(value ="Unit")
private String unit;
@ExcelProperty(value ="Data Mapping")
private String dataMapping;
} }

6
data-center-business-model/src/main/java/com/techsor/datacenter/business/importexcel/deviceinfo/DeviceInfoExcelJp.java

@ -70,4 +70,10 @@ public class DeviceInfoExcelJp {
@ExcelProperty(value ="デバイスグループ") @ExcelProperty(value ="デバイスグループ")
private String deviceGroup; private String deviceGroup;
@ExcelProperty(value ="単位")
private String unit;
@ExcelProperty(value ="データマッピング")
private String dataMapping;
} }

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

@ -220,6 +220,24 @@ public class DeviceInfo implements Serializable {
*/ */
private Integer retainAlert; private Integer retainAlert;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column device_info.unit
*
* @mbg.generated
*/
private String unit;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column device_info.data_mapping
*
* @mbg.generated
*/
private String dataMapping;
/** /**
* This field was generated by MyBatis Generator. * This field was generated by MyBatis Generator.
* This field corresponds to the database table device_info * This field corresponds to the database table device_info
@ -804,6 +822,54 @@ public class DeviceInfo implements Serializable {
this.retainAlert = retainAlert; this.retainAlert = retainAlert;
} }
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column device_info.unit
*
* @return the value of device_info.unit
*
* @mbg.generated
*/
public String getUnit() {
return unit;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column device_info.unit
*
* @param unit the value for device_info.unit
*
* @mbg.generated
*/
public void setUnit(String unit) {
this.unit = unit == null ? null : unit.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column device_info.data_mapping
*
* @return the value of device_info.data_mapping
*
* @mbg.generated
*/
public String getDataMapping() {
return dataMapping;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column device_info.data_mapping
*
* @param dataMapping the value for device_info.data_mapping
*
* @mbg.generated
*/
public void setDataMapping(String dataMapping) {
this.dataMapping = dataMapping == null ? null : dataMapping.trim();
}
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table device_info * This method corresponds to the database table device_info
@ -840,6 +906,8 @@ public class DeviceInfo implements Serializable {
sb.append(", gatewayInfoId=").append(gatewayInfoId); sb.append(", gatewayInfoId=").append(gatewayInfoId);
sb.append(", alarmLevel=").append(alarmLevel); sb.append(", alarmLevel=").append(alarmLevel);
sb.append(", retainAlert=").append(retainAlert); sb.append(", retainAlert=").append(retainAlert);
sb.append(", unit=").append(unit);
sb.append(", dataMapping=").append(dataMapping);
sb.append(", serialVersionUID=").append(serialVersionUID); sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();

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

@ -1684,6 +1684,76 @@ public class DeviceInfoExample {
addCriterion("retain_alert not between", value1, value2, "retainAlert"); addCriterion("retain_alert not between", value1, value2, "retainAlert");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andUnitIsNull() {
addCriterion("unit is null");
return (Criteria) this;
}
public Criteria andUnitIsNotNull() {
addCriterion("unit is not null");
return (Criteria) this;
}
public Criteria andUnitEqualTo(String value) {
addCriterion("unit =", value, "unit");
return (Criteria) this;
}
public Criteria andUnitNotEqualTo(String value) {
addCriterion("unit <>", value, "unit");
return (Criteria) this;
}
public Criteria andUnitGreaterThan(String value) {
addCriterion("unit >", value, "unit");
return (Criteria) this;
}
public Criteria andUnitGreaterThanOrEqualTo(String value) {
addCriterion("unit >=", value, "unit");
return (Criteria) this;
}
public Criteria andUnitLessThan(String value) {
addCriterion("unit <", value, "unit");
return (Criteria) this;
}
public Criteria andUnitLessThanOrEqualTo(String value) {
addCriterion("unit <=", value, "unit");
return (Criteria) this;
}
public Criteria andUnitLike(String value) {
addCriterion("unit like", value, "unit");
return (Criteria) this;
}
public Criteria andUnitNotLike(String value) {
addCriterion("unit not like", value, "unit");
return (Criteria) this;
}
public Criteria andUnitIn(List<String> values) {
addCriterion("unit in", values, "unit");
return (Criteria) this;
}
public Criteria andUnitNotIn(List<String> values) {
addCriterion("unit not in", values, "unit");
return (Criteria) this;
}
public Criteria andUnitBetween(String value1, String value2) {
addCriterion("unit between", value1, value2, "unit");
return (Criteria) this;
}
public Criteria andUnitNotBetween(String value1, String value2) {
addCriterion("unit not between", value1, value2, "unit");
return (Criteria) this;
}
} }
/** /**

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

@ -126,4 +126,10 @@ public class DeviceVO {
@Schema(description ="设备组组名",example = "组2") @Schema(description ="设备组组名",example = "组2")
private String deviceGroupName; private String deviceGroupName;
@Schema(description = "unit", example = "km")
private String unit;
@Schema(description = "data mapping", example = "{\"default\":{\"1\":\"漏水\",\"2\":\"漏电\",\"3\":\"起火\"}")
private String dataMapping;
} }

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

@ -225,6 +225,9 @@ public class DeviceServiceImpl implements IDeviceService {
@Override @Override
public SimpleDataResponse addDeviceInfos(DeviceAddParams deviceAddParams, Long userId, Long companyId, Integer languageType) { public SimpleDataResponse addDeviceInfos(DeviceAddParams deviceAddParams, Long userId, Long companyId, Integer languageType) {
try { try {
if (StringUtils.isNotBlank(deviceAddParams.getDataMapping()) && !CommonUtil.isJson(deviceAddParams.getDataMapping())){
return new SimpleDataResponse(ResponseCode.MSG_ERROR, msgLanguageChange.getParameterMapByCode(languageType, "dataMappingFormatError"));
}
/** Some validation operations **/ /** Some validation operations **/
try { try {
List<Long> selfAndSubCompanyList = commonOpt.getSelfAndSubCompanyId(companyId); List<Long> selfAndSubCompanyList = commonOpt.getSelfAndSubCompanyId(companyId);
@ -238,7 +241,6 @@ public class DeviceServiceImpl implements IDeviceService {
} catch (MsgCodeException e) { } catch (MsgCodeException e) {
return new SimpleDataResponse(ResponseCode.MSG_ERROR, e.getMessage()); return new SimpleDataResponse(ResponseCode.MSG_ERROR, e.getMessage());
} }
// Check if device ID is globally unique // Check if device ID is globally unique
DeviceInfoExample deviceInfoCountExample = new DeviceInfoExample(); DeviceInfoExample deviceInfoCountExample = new DeviceInfoExample();
deviceInfoCountExample.createCriteria().andFlagNotEqualTo(1).andDeviceIdEqualTo(deviceAddParams.getDeviceId()); deviceInfoCountExample.createCriteria().andFlagNotEqualTo(1).andDeviceIdEqualTo(deviceAddParams.getDeviceId());
@ -307,6 +309,9 @@ public class DeviceServiceImpl implements IDeviceService {
if (ObjectUtils.isEmpty(deviceUpdateParams.getId())) { if (ObjectUtils.isEmpty(deviceUpdateParams.getId())) {
return new SimpleDataResponse(ResponseCode.MSG_ERROR, "id is null"); return new SimpleDataResponse(ResponseCode.MSG_ERROR, "id is null");
} }
if (StringUtils.isNotBlank(deviceUpdateParams.getDataMapping()) && !CommonUtil.isJson(deviceUpdateParams.getDataMapping())){
return new SimpleDataResponse(ResponseCode.MSG_ERROR, msgLanguageChange.getParameterMapByCode(languageType, "dataMappingFormatError"));
}
/** Some validation operations **/ /** Some validation operations **/
try { try {
List<Long> selfAndSubCompanyList = commonOpt.getSelfAndSubCompanyId(companyId); List<Long> selfAndSubCompanyList = commonOpt.getSelfAndSubCompanyId(companyId);
@ -339,6 +344,12 @@ public class DeviceServiceImpl implements IDeviceService {
if (Objects.nonNull(deviceUpdateParams.getTypeId())) { if (Objects.nonNull(deviceUpdateParams.getTypeId())) {
deviceInfo.setTypeId(deviceUpdateParams.getTypeId().intValue()); deviceInfo.setTypeId(deviceUpdateParams.getTypeId().intValue());
} }
if (StringUtils.isBlank(deviceUpdateParams.getUnit())) {
deviceInfo.setUnit("");
}
if (StringUtils.isBlank(deviceUpdateParams.getDataMapping())) {
deviceInfo.setDataMapping("");
}
this.deviceInfoMapperExt.updateByPrimaryKeySelective(deviceInfo); this.deviceInfoMapperExt.updateByPrimaryKeySelective(deviceInfo);
DeviceGroupRelationExample example = new DeviceGroupRelationExample(); DeviceGroupRelationExample example = new DeviceGroupRelationExample();
@ -883,6 +894,10 @@ public class DeviceServiceImpl implements IDeviceService {
errorList.add(msgLanguageChange.getParameterMapByCode(languageType, "targetCodeNotExist")); errorList.add(msgLanguageChange.getParameterMapByCode(languageType, "targetCodeNotExist"));
} }
if (StringUtils.isNotBlank(deviceInfoExcel.getDataMapping()) && !CommonUtil.isJson(deviceInfoExcel.getDataMapping())){
errorList.add(msgLanguageChange.getParameterMapByCode(languageType, "dataMappingFormatError"));
}
// Error messages handling // Error messages handling
if (!errorList.isEmpty()) { if (!errorList.isEmpty()) {
StringBuffer stringBuffer=new StringBuffer(); StringBuffer stringBuffer=new StringBuffer();
@ -932,6 +947,16 @@ public class DeviceServiceImpl implements IDeviceService {
if (StringUtils.isNotBlank(deviceInfoExcel.getDataProvider())) { if (StringUtils.isNotBlank(deviceInfoExcel.getDataProvider())) {
deviceInfo.setDataProviderId(dataProviderMapping.get(deviceInfoExcel.getDataProvider()).getId()); deviceInfo.setDataProviderId(dataProviderMapping.get(deviceInfoExcel.getDataProvider()).getId());
} }
if (StringUtils.isBlank(deviceInfoExcel.getUnit())){
deviceInfo.setUnit("");
} else {
deviceInfo.setUnit(deviceInfoExcel.getUnit());
}
if (StringUtils.isBlank(deviceInfoExcel.getDataMapping())){
deviceInfo.setDataMapping("");
} else {
deviceInfo.setDataMapping(deviceInfoExcel.getDataMapping());
}
// if (StringUtils.isNotBlank(deviceInfoExcel.getMonitoringPointCategory())) { // if (StringUtils.isNotBlank(deviceInfoExcel.getMonitoringPointCategory())) {
// deviceInfo.setMonitoringPointCategoryId(monitoringPointCategoryMapping.get(deviceInfoExcel.getMonitoringPointCategory()).getId()); // deviceInfo.setMonitoringPointCategoryId(monitoringPointCategoryMapping.get(deviceInfoExcel.getMonitoringPointCategory()).getId());
// } // }
@ -952,6 +977,8 @@ public class DeviceServiceImpl implements IDeviceService {
deviceInfo.setFlag(0); deviceInfo.setFlag(0);
deviceInfo.setUpdatedTimestamp(System.currentTimeMillis()); deviceInfo.setUpdatedTimestamp(System.currentTimeMillis());
deviceInfo.setWsclientId(wsClientIdId); deviceInfo.setWsclientId(wsClientIdId);
deviceInfo.setUnit(deviceInfoExcel.getUnit());
deviceInfo.setDataMapping(deviceInfoExcel.getDataMapping());
if (StringUtils.isNotBlank(deviceInfoExcel.getMonitoringPointName())) { if (StringUtils.isNotBlank(deviceInfoExcel.getMonitoringPointName())) {
deviceInfo.setMonitoringPointName(deviceInfoExcel.getMonitoringPointName()); deviceInfo.setMonitoringPointName(deviceInfoExcel.getMonitoringPointName());
} }

14
data-center-business-util/src/main/java/com/techsor/datacenter/business/util/CommonUtil.java

@ -27,6 +27,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class CommonUtil { public class CommonUtil {
private static final ObjectMapper objectMapper = new ObjectMapper();
private static final String decimalsRegex = "[.](.*)"; private static final String decimalsRegex = "[.](.*)";
private static final String hexStringRegex = "^[A-Fa-f0-9]+$"; private static final String hexStringRegex = "^[A-Fa-f0-9]+$";
@ -822,5 +824,17 @@ public class CommonUtil {
} }
} }
public static boolean isJson(String str) {
if (str == null || str.trim().isEmpty()) {
return false;
}
try {
objectMapper.readTree(str);
return true;
} catch (Exception e) {
return false;
}
}
} }

Loading…
Cancel
Save