Browse Source

设备类型改category判定

jwy_category
review512jwy@163.com 4 weeks ago
parent
commit
a44d99aac3
  1. 43
      dongjian-dashboard-back-common/src/main/java/com/dongjian/dashboard/back/common/Constants.java
  2. 2
      dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_cn.yml
  3. 2
      dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_en.yml
  4. 2
      dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp.yml
  5. 24
      dongjian-dashboard-back-dao/src/main/java/com/dongjian/dashboard/back/dao/auto/DeviceInfoMapper.java
  6. 149
      dongjian-dashboard-back-dao/src/main/resources/mappers/auto/DeviceInfoMapper.xml
  7. 1
      dongjian-dashboard-back-dao/src/main/resources/mappers/ex/DeviceGroupMapperExt.xml
  8. 21
      dongjian-dashboard-back-dao/src/main/resources/mappers/ex/DeviceInfoMapperExt.xml
  9. 7
      dongjian-dashboard-back-dao/src/main/resources/mappers/ex/DeviceRawdataRealtimeMapperExt.xml
  10. 11
      dongjian-dashboard-back-dao/src/main/resources/mappers/ex/FavoritedDeviceMapperExt.xml
  11. 6
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/data/DataSearchParam.java
  12. 6
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/device/DeviceSearchParams.java
  13. 6
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/device/FavoritedDeviceSearchParams.java
  14. 3
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/easyexcel/ExportDeviceAccumulateDataDTO.java
  15. 3
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/easyexcel/ExportDeviceBaStatusDataDTO.java
  16. 4
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/easyexcel/ExportDeviceMeasureDataDTO.java
  17. 68
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/model/DeviceInfo.java
  18. 70
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/model/DeviceInfoExample.java
  19. 12
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/data/BaseData.java
  20. 6
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/data/DeviceAccumulateData.java
  21. 3
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/data/DeviceBaStatusData.java
  22. 6
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/data/DeviceMeasureData.java
  23. 2
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/device/DeviceVO.java
  24. 6
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/device/FavoritedDeviceVO.java
  25. 59
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/common/CommonOpt.java
  26. 25
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceDataAccumulateServiceImpl.java
  27. 2
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceDataAlarmServiceImpl.java
  28. 38
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceDataBaStatusServiceImpl.java
  29. 29
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceDataMeasureServiceImpl.java
  30. 15
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceGroupServiceImpl.java
  31. 2
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceServiceImpl.java
  32. 18
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java
  33. 5
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/MonitoringPointCategoryGroupServiceImpl.java
  34. 2
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/OverviewServiceImpl.java
  35. 2
      pom.xml

43
dongjian-dashboard-back-common/src/main/java/com/dongjian/dashboard/back/common/Constants.java

@ -32,28 +32,51 @@ public class Constants {
public static final int CATEGORY_MEASURE = 3;//计测 public static final int CATEGORY_MEASURE = 3;//计测
public static final int CATEGORY_STATUS= 4;//状态 public static final int CATEGORY_STATUS= 4;//状态
// // 所有设备类型ID的总集合
// public static final List<Integer> ALL_DEVICE_TYPE_IDS = new ArrayList<>();
//
// // 定义分类与设备类型的映射
// public static final Map<Integer, List<Integer>> CATEGORY_DEVICE_TYPE_MAP = new HashMap<>();
//
// //温湿度
// public static final List<Integer> DEVICE_TYPE_TEMPERATURE_HUMIDITY = Arrays.asList(8888882,9999992);
//
// static {
// CATEGORY_DEVICE_TYPE_MAP.put(CATEGORY_ALARM, new ArrayList<>(Arrays.asList(46, 110)));
//
// CATEGORY_DEVICE_TYPE_MAP.put(CATEGORY_MEASURE, new ArrayList<>(Arrays.asList(47, 111, 121)));
// CATEGORY_DEVICE_TYPE_MAP.get(CATEGORY_MEASURE).addAll(DEVICE_TYPE_TEMPERATURE_HUMIDITY);
//
// CATEGORY_DEVICE_TYPE_MAP.put(CATEGORY_ACCUMULATE, new ArrayList<>(Arrays.asList(48, 112, 122)));
//
// CATEGORY_DEVICE_TYPE_MAP.put(CATEGORY_STATUS, new ArrayList<>(Arrays.asList(86, 113, 123)));
//
// // 收集所有的设备类型ID
// for (List<Integer> ids : CATEGORY_DEVICE_TYPE_MAP.values()) {
// ALL_DEVICE_TYPE_IDS.addAll(ids);
// }
// }
// 所有设备类型ID的总集合 // 所有设备类型ID的总集合
public static final List<Integer> ALL_DEVICE_TYPE_IDS = new ArrayList<>(); public static final List<Long> ALL_CATEGORY_IDS = new ArrayList<>();
// 定义分类与设备类型的映射 // 定义分类与设备类型的映射
public static final Map<Integer, List<Integer>> CATEGORY_DEVICE_TYPE_MAP = new HashMap<>(); public static final Map<Integer, List<Long>> CATEGORY_MAP = new HashMap<>();
//温湿度 //温湿度
public static final List<Integer> DEVICE_TYPE_TEMPERATURE_HUMIDITY = Arrays.asList(8888882,9999992); public static final List<Long> DEVICE_TYPE_TEMPERATURE_HUMIDITY = Arrays.asList(8888882L,9999992L);
static { static {
CATEGORY_DEVICE_TYPE_MAP.put(CATEGORY_ALARM, new ArrayList<>(Arrays.asList(46, 110))); CATEGORY_MAP.put(CATEGORY_ALARM, new ArrayList<>(List.of(1001L)));
CATEGORY_DEVICE_TYPE_MAP.put(CATEGORY_MEASURE, new ArrayList<>(Arrays.asList(47, 111, 121))); CATEGORY_MAP.put(CATEGORY_MEASURE, new ArrayList<>(List.of(1003L)));
CATEGORY_DEVICE_TYPE_MAP.get(CATEGORY_MEASURE).addAll(DEVICE_TYPE_TEMPERATURE_HUMIDITY);
CATEGORY_DEVICE_TYPE_MAP.put(CATEGORY_ACCUMULATE, new ArrayList<>(Arrays.asList(48, 112, 122))); CATEGORY_MAP.put(CATEGORY_ACCUMULATE, new ArrayList<>(List.of(1002L)));
CATEGORY_DEVICE_TYPE_MAP.put(CATEGORY_STATUS, new ArrayList<>(Arrays.asList(86, 113, 123))); CATEGORY_MAP.put(CATEGORY_STATUS, new ArrayList<>(List.of(1004L)));
// 收集所有的设备类型ID // 收集所有的设备类型ID
for (List<Integer> ids : CATEGORY_DEVICE_TYPE_MAP.values()) { for (List<Long> ids : CATEGORY_MAP.values()) {
ALL_DEVICE_TYPE_IDS.addAll(ids); ALL_CATEGORY_IDS.addAll(ids);
} }
} }

2
dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_cn.yml

@ -58,7 +58,7 @@ msgcn:
consecutiveLoginFail: 登录失败次数过多,请等待{0}分{1}秒后再登录 consecutiveLoginFail: 登录失败次数过多,请等待{0}分{1}秒后再登录
loginFailCount: 已登录失败{0}次,剩余尝试登录次数:{1} loginFailCount: 已登录失败{0}次,剩余尝试登录次数:{1}
deviceGroupNameHasExisted: 此设备组名称已存在 deviceGroupNameHasExisted: 此设备组名称已存在
groupTypeNotMatch: 设备类型与分组类型不匹配 invalidDeviceCategory: 无效的设备类别
monitoringPointCategoryNameHasExisted: 此监控点分类名称已存在 monitoringPointCategoryNameHasExisted: 此监控点分类名称已存在
monitoringPointCategoryGroupNameHasExisted: 此监控点分组名称已存在 monitoringPointCategoryGroupNameHasExisted: 此监控点分组名称已存在
alertLevel_1: 正常 alertLevel_1: 正常

2
dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_en.yml

@ -58,7 +58,7 @@ msgen:
consecutiveLoginFail: Too many failed login attempts. Please wait {0} minute(s) and {1} second(s) before trying again. consecutiveLoginFail: Too many failed login attempts. Please wait {0} minute(s) and {1} second(s) before trying again.
loginFailCount: Login failed {0} times. Remaining login attempts:{1}. loginFailCount: Login failed {0} times. Remaining login attempts:{1}.
deviceGroupNameHasExisted: Device group name already exists. deviceGroupNameHasExisted: Device group name already exists.
groupTypeNotMatch: Device type does not match the group type invalidDeviceCategory: Invalid device category
monitoringPointCategoryNameHasExisted: This monitoring point category name already exists monitoringPointCategoryNameHasExisted: This monitoring point category name already exists
monitoringPointCategoryGroupNameHasExisted: The monitoring point group name already exists monitoringPointCategoryGroupNameHasExisted: The monitoring point group name already exists
alertLevel_1: Normal alertLevel_1: Normal

2
dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp.yml

@ -58,7 +58,7 @@ msgjp:
consecutiveLoginFail: ログインの失敗が多すぎます。{0}分{1}秒待ってから再度ログインしてください。 consecutiveLoginFail: ログインの失敗が多すぎます。{0}分{1}秒待ってから再度ログインしてください。
loginFailCount: ログインに{0}回失敗しました。残りの試行回数:{1}回。 loginFailCount: ログインに{0}回失敗しました。残りの試行回数:{1}回。
deviceGroupNameHasExisted: デバイスグループ名は既に存在しています。 deviceGroupNameHasExisted: デバイスグループ名は既に存在しています。
groupTypeNotMatch: デバイスタイプがグループタイプと一致しません invalidDeviceCategory: サポートされていないデバイスタイプ。
monitoringPointCategoryNameHasExisted: この監視ポイントカテゴリ名は既に存在します monitoringPointCategoryNameHasExisted: この監視ポイントカテゴリ名は既に存在します
monitoringPointCategoryGroupNameHasExisted: この監視ポイントグループ名は既に存在します monitoringPointCategoryGroupNameHasExisted: この監視ポイントグループ名は既に存在します
alertLevel_1: 通常 alertLevel_1: 通常

24
dongjian-dashboard-back-dao/src/main/java/com/dongjian/dashboard/back/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
dongjian-dashboard-back-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.dongjian.dashboard.back.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.dongjian.dashboard.back.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.dongjian.dashboard.back.model.DeviceInfoExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.dongjian.dashboard.back.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.dongjian.dashboard.back.model.DeviceInfo"> <insert id="insertSelective" parameterType="com.dongjian.dashboard.back.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.dongjian.dashboard.back.model.DeviceInfoExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.dongjian.dashboard.back.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.dongjian.dashboard.back.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.dongjian.dashboard.back.model.DeviceInfo"> <update id="updateByPrimaryKey" parameterType="com.dongjian.dashboard.back.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>

1
dongjian-dashboard-back-dao/src/main/resources/mappers/ex/DeviceGroupMapperExt.xml

@ -63,6 +63,7 @@
device_info.device_id, device_info.device_id,
device_info.device_sn, device_info.device_sn,
device_info.type_id, device_info.type_id,
type.device_category_id categoryId,
type.name as typeName, type.name as typeName,
basic_building.building_id, basic_building.building_id,
basic_building.name as buildingName, basic_building.name as buildingName,

21
dongjian-dashboard-back-dao/src/main/resources/mappers/ex/DeviceInfoMapperExt.xml

@ -10,7 +10,7 @@
device_info.device_id, device_info.device_id,
device_info.device_name, device_info.device_name,
device_info.device_sn, device_info.device_sn,
device_info.type_id, type.device_category_id categoryId,
device_info.retain_alert, device_info.retain_alert,
device_info.monitoring_point_name, device_info.monitoring_point_name,
basic_asset_class_big.id monitoringPointCategoryId, basic_asset_class_big.id monitoringPointCategoryId,
@ -19,7 +19,8 @@
data_provider.thumbnail_base64 as dataProviderThumbnailBase64, data_provider.thumbnail_base64 as dataProviderThumbnailBase64,
device_info.gateway_info_id, device_info.gateway_info_id,
data_provider_gateway_info.name as gatewayInfoName, data_provider_gateway_info.name as gatewayInfoName,
type.unit device_info.unit,
device_info.data_mapping
</sql> </sql>
<sql id="deviceDataFromAndJoin"> <sql id="deviceDataFromAndJoin">
@ -50,10 +51,10 @@
#{deviceId} #{deviceId}
</foreach> </foreach>
</if> </if>
and device_info.flag = 0 and basic_monitoring_asset.flag != 1 and basic_space.flag != 1 and basic_floor.flag != 1 and basic_building.flag != 1 and device_info.flag = 0 and device_info.device_id LIKE '%\_85' and basic_monitoring_asset.flag != 1 and basic_space.flag != 1 and basic_floor.flag != 1 and basic_building.flag != 1
and device_info.type_id in and type.device_category_id in
<foreach collection="typeIdList" item="typeId" open="(" separator="," close=")"> <foreach collection="categoryIdList" item="categoryId" open="(" separator="," close=")">
#{typeId} #{categoryId}
</foreach> </foreach>
</sql> </sql>
@ -365,7 +366,7 @@
device_info.device_name, device_info.device_name,
device_info.device_id, device_info.device_id,
device_info.device_sn, device_info.device_sn,
device_info.type_id, type.device_category_id categoryId,
device_info.flag, device_info.flag,
type.name as typeName, type.name as typeName,
basic_building.building_id, basic_building.building_id,
@ -421,9 +422,9 @@
</foreach> </foreach>
</if> </if>
and device_info.flag = 0 and basic_monitoring_asset.flag != 1 and basic_space.flag != 1 and basic_floor.flag != 1 and basic_building.flag != 1 and device_info.flag = 0 and basic_monitoring_asset.flag != 1 and basic_space.flag != 1 and basic_floor.flag != 1 and basic_building.flag != 1
and device_info.type_id in and type.device_category_id in
<foreach collection="typeIdList" item="typeId" open="(" separator="," close=")"> <foreach collection="categoryIdList" item="categoryId" open="(" separator="," close=")">
#{typeId} #{categoryId}
</foreach> </foreach>
</where> </where>
<include refid="deviceOrder"/> <include refid="deviceOrder"/>

7
dongjian-dashboard-back-dao/src/main/resources/mappers/ex/DeviceRawdataRealtimeMapperExt.xml

@ -17,12 +17,13 @@
INNER JOIN device_info dinfo ON dinfo.device_id = drr.device_id INNER JOIN device_info dinfo ON dinfo.device_id = drr.device_id
INNER JOIN basic_monitoring_asset on dinfo.asset_id = basic_monitoring_asset.equipment_id INNER JOIN basic_monitoring_asset on dinfo.asset_id = basic_monitoring_asset.equipment_id
INNER JOIN basic_asset_class_big on basic_asset_class_big.id = basic_monitoring_asset.class_big_id INNER JOIN basic_asset_class_big on basic_asset_class_big.id = basic_monitoring_asset.class_big_id
LEFT JOIN type ty ON dinfo.type_id = ty.id
WHERE WHERE
bbuilding.company_id = #{companyId} AND bbuilding.flag = 0 AND dinfo.flag = 0 AND basic_monitoring_asset.flag = 0 AND basic_asset_class_big.flag = 0 bbuilding.company_id = #{companyId} AND bbuilding.flag = 0 AND dinfo.flag = 0 AND basic_monitoring_asset.flag = 0 AND basic_asset_class_big.flag = 0
AND drr.status = 'alert' AND drr.status = 'alert'
AND dinfo.type_id in AND ty.device_category_id in
<foreach collection="typeIdList" item="typeId" open="(" separator="," close=")"> <foreach collection="categoryIdList" item="categoryId" open="(" separator="," close=")">
#{typeId} #{categoryId}
</foreach> </foreach>
</select> </select>

11
dongjian-dashboard-back-dao/src/main/resources/mappers/ex/FavoritedDeviceMapperExt.xml

@ -6,7 +6,7 @@
SELECT SELECT
fd.device_id, fd.device_id,
fd.create_at, fd.create_at,
dinfo.type_id, ty.device_category_id categoryId,
dinfo.id, dinfo.id,
dinfo.retain_alert dinfo.retain_alert
FROM FROM
@ -16,15 +16,16 @@
left join basic_space on basic_monitoring_asset.space_id = basic_space.space_id left join basic_space on basic_monitoring_asset.space_id = basic_space.space_id
left join basic_floor on basic_space.floor_id = basic_floor.floor_id left join basic_floor on basic_space.floor_id = basic_floor.floor_id
left join basic_building on basic_floor.building_id = basic_building.building_id left join basic_building on basic_floor.building_id = basic_building.building_id
left join type ty on ty.id = dinfo.type_id
WHERE WHERE
dinfo.flag != 1 AND basic_monitoring_asset.flag != 1 dinfo.flag != 1 AND basic_monitoring_asset.flag != 1
AND basic_space.flag != 1 AND basic_floor.flag != 1 AND basic_building.flag != 1 AND basic_space.flag != 1 AND basic_floor.flag != 1 AND basic_building.flag != 1
AND basic_building.building_id = #{buildingId} AND basic_building.building_id = #{buildingId}
AND dinfo.company_id IN <foreach collection="companyIdList" item="item" open="(" separator="," close=")">#{item}</foreach> AND dinfo.company_id IN <foreach collection="companyIdList" item="item" open="(" separator="," close=")">#{item}</foreach>
<if test="typeIdList != null and typeIdList.size() > 0"> <if test="categoryIdList != null and categoryIdList.size() > 0">
and dinfo.type_id in and ty.device_category_id in
<foreach collection="typeIdList" item="typeId" open="(" separator="," close=")"> <foreach collection="categoryIdList" item="categoryId" open="(" separator="," close=")">
#{typeId} #{categoryId}
</foreach> </foreach>
</if> </if>
order by fd.create_at, fd.device_id desc order by fd.create_at, fd.device_id desc

6
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/data/DataSearchParam.java

@ -20,8 +20,10 @@ public class DataSearchParam extends BaseSearchParams {
@Schema(description = "设备分组ID",example = "122") @Schema(description = "设备分组ID",example = "122")
private Long deviceGroupId; private Long deviceGroupId;
@Schema(description = "设备类型",example = "[]", hidden = true) // @Schema(description = "设备类型",example = "[]", hidden = true)
private List<Integer> typeIdList; // private List<Integer> typeIdList;
@Schema(description = "设备类别类型",example = "[]", hidden = true)
private List<Long> categoryIdList;
@Schema(description = "设备ID",example = "[]", hidden = true) @Schema(description = "设备ID",example = "[]", hidden = true)
private List<String> deviceIdList; private List<String> deviceIdList;

6
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/device/DeviceSearchParams.java

@ -14,8 +14,10 @@ public class DeviceSearchParams extends BaseSearchParams {
@Schema(description = "building ID") @Schema(description = "building ID")
private Long buildingId; private Long buildingId;
@Schema(description = "device type",example = "[]", hidden = true) // @Schema(description = "device type",example = "[]", hidden = true)
private List<Integer> typeIdList; // private List<Integer> typeIdList;
@Schema(description = "设备类别类型",example = "[]", hidden = true)
private List<Long> categoryIdList;
@Schema(description = "Monitoring point name", example = "Device-Monitoring") @Schema(description = "Monitoring point name", example = "Device-Monitoring")
private String monitoringPointName; private String monitoringPointName;

6
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/device/FavoritedDeviceSearchParams.java

@ -17,7 +17,9 @@ public class FavoritedDeviceSearchParams extends BaseSearchParams {
@Schema(description = "1-警报设备,2-积算设备,3-计测设备,4-运行状态设备",example = "1") @Schema(description = "1-警报设备,2-积算设备,3-计测设备,4-运行状态设备",example = "1")
private Integer classId; private Integer classId;
@Schema(description = "设备类型",example = "[]", hidden = true) // @Schema(description = "设备类型",example = "[]", hidden = true)
private List<Integer> typeIdList; // private List<Integer> typeIdList;
@Schema(description = "设备类别类型",example = "[]", hidden = true)
private List<Long> categoryIdList;
} }

3
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/easyexcel/ExportDeviceAccumulateDataDTO.java

@ -25,6 +25,9 @@ public class ExportDeviceAccumulateDataDTO {
@ExcelProperty({"数据提供方名称", "Data Provider Name", "データソース"}) @ExcelProperty({"数据提供方名称", "Data Provider Name", "データソース"})
private String dataProviderName; private String dataProviderName;
@ExcelProperty({"设备状态", "Device Status", "デバイス状態"})
private String status111;
@ExcelProperty({"累积值", "Cumulative Value", "計測値"}) @ExcelProperty({"累积值", "Cumulative Value", "計測値"})
private String cumulativeValue; private String cumulativeValue;

3
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/easyexcel/ExportDeviceBaStatusDataDTO.java

@ -25,6 +25,9 @@ public class ExportDeviceBaStatusDataDTO {
@ExcelProperty({"数据提供方名称", "Data Provider Name", "データソース"}) @ExcelProperty({"数据提供方名称", "Data Provider Name", "データソース"})
private String dataProviderName; private String dataProviderName;
@ExcelProperty({"设备状态", "Device Status", "デバイス状態"})
private String status111;
@ExcelProperty(value = {"运行状态", "Running status", "状態"}, converter = RunningStatusConverter.class) @ExcelProperty(value = {"运行状态", "Running status", "状態"}, converter = RunningStatusConverter.class)
private Integer runningStatus; private Integer runningStatus;

4
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/easyexcel/ExportDeviceMeasureDataDTO.java

@ -1,6 +1,7 @@
package com.dongjian.dashboard.back.easyexcel; package com.dongjian.dashboard.back.easyexcel;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@Data @Data
@ -24,6 +25,9 @@ public class ExportDeviceMeasureDataDTO {
@ExcelProperty({"数据提供方名称", "Data Provider Name", "データソース"}) @ExcelProperty({"数据提供方名称", "Data Provider Name", "データソース"})
private String dataProviderName; private String dataProviderName;
@ExcelProperty({"设备状态", "Device Status", "デバイス状態"})
private String status111;
@ExcelProperty({"测量值", "Measurement value", "計測値"}) @ExcelProperty({"测量值", "Measurement value", "計測値"})
private String measurementValue; private String measurementValue;

68
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/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
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/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;
}
} }
/** /**

12
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/data/BaseData.java

@ -36,8 +36,10 @@ public class BaseData {
@Schema(description = "data provider icon", example = "") @Schema(description = "data provider icon", example = "")
private String dataProviderThumbnailBase64; private String dataProviderThumbnailBase64;
@Schema(description = "device type", example = "86") // @Schema(description = "device type", example = "86")
private Integer typeId; // private Integer typeId;
@Schema(description = "category id", example = "86")
private Long categoryId;
@Schema(description = "1-警报设备,2-积算设备,3-计测设备,4-运行状态设备",example = "1") @Schema(description = "1-警报设备,2-积算设备,3-计测设备,4-运行状态设备",example = "1")
private Integer classId; private Integer classId;
@ -48,4 +50,10 @@ public class BaseData {
@Schema(description = "dashboard自动恢复告警时是否保留告警:0-不保留,1-保留", example = "1") @Schema(description = "dashboard自动恢复告警时是否保留告警:0-不保留,1-保留", example = "1")
private Integer retainAlert; private Integer retainAlert;
@Schema(description = "unit", example = "cm")
private String unit;
@Schema(description = "data mapping", example = "{\"default\":{\"1\":\"漏水\",\"2\":\"漏电\",\"3\":\"起火\"}")
private String dataMapping;
} }

6
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/data/DeviceAccumulateData.java

@ -17,10 +17,10 @@ public class DeviceAccumulateData extends BaseData{
@Schema(description = "Last Year's Value", example = "11") @Schema(description = "Last Year's Value", example = "11")
private String lastYearValue; private String lastYearValue;
@Schema(description = "unit", example = "cm")
private String unit;
@Schema(description = "raw data", example = "", hidden = true) @Schema(description = "raw data", example = "", hidden = true)
private String rawData; private String rawData;
@Schema(description = "device status", example = "障害")
private String status111;
} }

3
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/data/DeviceBaStatusData.java

@ -23,4 +23,7 @@ public class DeviceBaStatusData extends BaseData{
@Schema(description = "continuous running time", example = "0h 11m 45s") @Schema(description = "continuous running time", example = "0h 11m 45s")
private String continuousRunningTimeStr; private String continuousRunningTimeStr;
@Schema(description = "device status", example = "障害")
private String status111;
} }

6
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/data/DeviceMeasureData.java

@ -17,10 +17,10 @@ public class DeviceMeasureData extends BaseData{
@Schema(description = "Minimum value", example = "11") @Schema(description = "Minimum value", example = "11")
private String minValue; private String minValue;
@Schema(description = "unit", example = "cm")
private String unit;
@Schema(description = "raw data", example = "", hidden = true) @Schema(description = "raw data", example = "", hidden = true)
private String rawData; private String rawData;
@Schema(description = "device status", example = "障害")
private String status111;
} }

2
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/device/DeviceVO.java

@ -69,4 +69,6 @@ public class DeviceVO {
@Schema(description = "gateway info", example = "33") @Schema(description = "gateway info", example = "33")
private String gatewayInfoName; private String gatewayInfoName;
private Long categoryId;
} }

6
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/device/FavoritedDeviceVO.java

@ -16,8 +16,10 @@ public class FavoritedDeviceVO {
@Schema(description = "Favorite time", example = "1760010000223") @Schema(description = "Favorite time", example = "1760010000223")
private Long createAt; private Long createAt;
@Schema(description = "type id", example = "46") // @Schema(description = "type id", example = "46")
private Integer typeId; // private Integer typeId;
@Schema(description = "category id", example = "1001")
private Long categoryId;
@Schema(description = "dashboard自动恢复告警时是否保留告警:0-不保留,1-保留", example = "1") @Schema(description = "dashboard自动恢复告警时是否保留告警:0-不保留,1-保留", example = "1")
private Integer retainAlert; private Integer retainAlert;

59
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/common/CommonOpt.java

@ -7,6 +7,7 @@ import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -15,8 +16,11 @@ import com.dongjian.dashboard.back.common.Constants;
import com.dongjian.dashboard.back.common.response.ResponseCode; import com.dongjian.dashboard.back.common.response.ResponseCode;
import com.dongjian.dashboard.back.common.response.SimpleDataResponse; import com.dongjian.dashboard.back.common.response.SimpleDataResponse;
import com.dongjian.dashboard.back.dao.ex.BasicUserMapperExt; import com.dongjian.dashboard.back.dao.ex.BasicUserMapperExt;
import com.dongjian.dashboard.back.dao.ex.DeviceRawdataRealtimeMapperExt;
import com.dongjian.dashboard.back.dao.ex.UserBuildingRelationMapperExt; import com.dongjian.dashboard.back.dao.ex.UserBuildingRelationMapperExt;
import com.dongjian.dashboard.back.dto.device.LineDataSearchParams; import com.dongjian.dashboard.back.dto.device.LineDataSearchParams;
import com.dongjian.dashboard.back.model.DeviceRawdataRealtime;
import com.dongjian.dashboard.back.model.DeviceRawdataRealtimeExample;
import com.dongjian.dashboard.back.util.DESUtil; import com.dongjian.dashboard.back.util.DESUtil;
import com.dongjian.dashboard.back.vo.building.BindedBuildingVO; import com.dongjian.dashboard.back.vo.building.BindedBuildingVO;
import com.dongjian.dashboard.back.vo.company.AuroraInfo; import com.dongjian.dashboard.back.vo.company.AuroraInfo;
@ -44,6 +48,9 @@ public class CommonOpt {
private static Logger logger = LoggerFactory.getLogger(CommonOpt.class); private static Logger logger = LoggerFactory.getLogger(CommonOpt.class);
private static final String SUFFIX_85 = "_85";
private static final String SUFFIX_111 = "_111";
@Value("${spring.datasource.url}") @Value("${spring.datasource.url}")
private String dbUrl; private String dbUrl;
@ -53,6 +60,8 @@ public class CommonOpt {
private BasicUserMapperExt basicUserMapperExt; private BasicUserMapperExt basicUserMapperExt;
@Autowired @Autowired
private UserBuildingRelationMapperExt userBuildingRelationMapperExt; private UserBuildingRelationMapperExt userBuildingRelationMapperExt;
@Autowired
private DeviceRawdataRealtimeMapperExt deviceRawdataRealtimeMapperExt;
/** /**
@ -140,8 +149,8 @@ public class CommonOpt {
return dbUrl.replaceAll(regex, "$1" + auroraHost + "$3"); return dbUrl.replaceAll(regex, "$1" + auroraHost + "$3");
} }
public String extractValue(ObjectMapper mapper, Integer typeId, String rawData) { public String extractValue(ObjectMapper mapper, Long categoryId, String rawData) {
if (Constants.DEVICE_TYPE_TEMPERATURE_HUMIDITY.contains(typeId)){ if (Constants.DEVICE_TYPE_TEMPERATURE_HUMIDITY.contains(categoryId)){
List<String> values = extractAllValues(mapper, rawData); List<String> values = extractAllValues(mapper, rawData);
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
for (int i = 0; i < values.size(); i++){ for (int i = 0; i < values.size(); i++){
@ -456,4 +465,50 @@ public class CommonOpt {
} }
} }
public Map<String, String> buildDeviceId85To111Map(List<String> deviceIds) {
return deviceIds.stream()
.filter(id -> id.endsWith(SUFFIX_85))
.collect(Collectors.toMap(
Function.identity(),
id -> id.substring(0, id.length() - SUFFIX_85.length()) + SUFFIX_111,
(a, b) -> b
));
}
public Map<String, DeviceRawdataRealtime> queryRealtime111Map(List<String> deviceIdList111) {
if (CollectionUtils.isEmpty(deviceIdList111)) {
return Collections.emptyMap();
}
DeviceRawdataRealtimeExample example = new DeviceRawdataRealtimeExample();
example.createCriteria().andDeviceIdIn(deviceIdList111);
return deviceRawdataRealtimeMapperExt
.selectByExampleWithBLOBs(example)
.stream()
.collect(Collectors.toMap(
DeviceRawdataRealtime::getDeviceId,
Function.identity(),
(a, b) -> b
));
}
public String mapStatus111(ObjectMapper mapper,
String dataMapping,
DeviceRawdataRealtime realtime111) {
if (StringUtils.isBlank(dataMapping) || realtime111 == null) {
return null;
}
try {
String statusValue = extractFirstValue(mapper, realtime111.getRawData());
JsonNode root = mapper.readTree(dataMapping);
return root.path("default").path(statusValue).asText(null);
} catch (Exception e) {
logger.error("dataMapping parse error, mapping={}", dataMapping, e);
return null;
}
}
} }

25
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceDataAccumulateServiceImpl.java

@ -15,15 +15,19 @@ import com.dongjian.dashboard.back.common.response.PageInfo;
import com.dongjian.dashboard.back.common.response.SimpleDataResponse; import com.dongjian.dashboard.back.common.response.SimpleDataResponse;
import com.dongjian.dashboard.back.dao.aurora.DashboardRecordAccumulateMapperExt; import com.dongjian.dashboard.back.dao.aurora.DashboardRecordAccumulateMapperExt;
import com.dongjian.dashboard.back.dao.ex.DeviceInfoMapperExt; import com.dongjian.dashboard.back.dao.ex.DeviceInfoMapperExt;
import com.dongjian.dashboard.back.dao.ex.DeviceRawdataRealtimeMapperExt;
import com.dongjian.dashboard.back.dao.ex.FavoritedDeviceMapperExt; import com.dongjian.dashboard.back.dao.ex.FavoritedDeviceMapperExt;
import com.dongjian.dashboard.back.dto.data.AccumulateDataSearchParam; import com.dongjian.dashboard.back.dto.data.AccumulateDataSearchParam;
import com.dongjian.dashboard.back.dto.device.LineDataSearchParams; import com.dongjian.dashboard.back.dto.device.LineDataSearchParams;
import com.dongjian.dashboard.back.model.DeviceRawdataRealtime;
import com.dongjian.dashboard.back.model.DeviceRawdataRealtimeExample;
import com.dongjian.dashboard.back.service.DeviceDataAccumulateService; import com.dongjian.dashboard.back.service.DeviceDataAccumulateService;
import com.dongjian.dashboard.back.service.common.CommonOpt; import com.dongjian.dashboard.back.service.common.CommonOpt;
import com.dongjian.dashboard.back.util.DateUtil; import com.dongjian.dashboard.back.util.DateUtil;
import com.dongjian.dashboard.back.vo.data.DeviceAccumulateData; import com.dongjian.dashboard.back.vo.data.DeviceAccumulateData;
import com.dongjian.dashboard.back.vo.device.DeviceIncrement; import com.dongjian.dashboard.back.vo.device.DeviceIncrement;
import com.dongjian.dashboard.back.vo.device.LineData; import com.dongjian.dashboard.back.vo.device.LineData;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
@ -38,12 +42,16 @@ public class DeviceDataAccumulateServiceImpl implements DeviceDataAccumulateServ
private static final Logger logger = LoggerFactory.getLogger(DeviceDataAccumulateServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(DeviceDataAccumulateServiceImpl.class);
private static final ObjectMapper objectMapper = new ObjectMapper();
@Autowired @Autowired
private DeviceInfoMapperExt deviceInfoMapperExt; private DeviceInfoMapperExt deviceInfoMapperExt;
@Autowired @Autowired
private FavoritedDeviceMapperExt favoritedDeviceMapperExt; private FavoritedDeviceMapperExt favoritedDeviceMapperExt;
@Autowired @Autowired
private DashboardRecordAccumulateMapperExt dashboardRecordAccumulateMapperExt; private DashboardRecordAccumulateMapperExt dashboardRecordAccumulateMapperExt;
@Autowired
private DeviceRawdataRealtimeMapperExt deviceRawdataRealtimeMapperExt;
@Autowired @Autowired
private MsgLanguageChange msgLanguageChange; private MsgLanguageChange msgLanguageChange;
@Autowired @Autowired
@ -80,7 +88,7 @@ public class DeviceDataAccumulateServiceImpl implements DeviceDataAccumulateServ
} }
} }
pageSearchParam.setTypeIdList(Constants.CATEGORY_DEVICE_TYPE_MAP.get(Constants.CATEGORY_ACCUMULATE)); pageSearchParam.setCategoryIdList(Constants.CATEGORY_MAP.get(Constants.CATEGORY_ACCUMULATE));
if (null != pageSearchParam.getDeviceGroupId()){ if (null != pageSearchParam.getDeviceGroupId()){
resultList = deviceInfoMapperExt.getDevice4AccumulateDataByGroup(pageSearchParam); resultList = deviceInfoMapperExt.getDevice4AccumulateDataByGroup(pageSearchParam);
} else { } else {
@ -93,7 +101,14 @@ public class DeviceDataAccumulateServiceImpl implements DeviceDataAccumulateServ
List<String> deviceIds = resultList.stream() List<String> deviceIds = resultList.stream()
.map(DeviceAccumulateData::getDeviceId) .map(DeviceAccumulateData::getDeviceId)
.collect(Collectors.toList()); .toList();
// 查询 111状态 数据
Map<String, String> deviceId85To111Map = commonOpt.buildDeviceId85To111Map(deviceIds);
List<String> deviceIdList_111 = deviceId85To111Map.values()
.stream()
.toList();
Map<String, DeviceRawdataRealtime> realtime111Map = commonOpt.queryRealtime111Map(deviceIdList_111);
LocalDateTime now = LocalDateTime.now(ZoneId.of("Asia/Tokyo")); LocalDateTime now = LocalDateTime.now(ZoneId.of("Asia/Tokyo"));
LocalDate today = now.toLocalDate(); LocalDate today = now.toLocalDate();
@ -110,8 +125,6 @@ public class DeviceDataAccumulateServiceImpl implements DeviceDataAccumulateServ
Map<String, DeviceIncrement> lastYearMap = dashboardRecordAccumulateMapperExt.selectLastYearIncrement(deviceIds, lastYear.getYear(), lastYear.getMonthValue(), lastYear.getDayOfMonth(), targetSeconds) Map<String, DeviceIncrement> lastYearMap = dashboardRecordAccumulateMapperExt.selectLastYearIncrement(deviceIds, lastYear.getYear(), lastYear.getMonthValue(), lastYear.getDayOfMonth(), targetSeconds)
.stream().collect(Collectors.toMap(DeviceIncrement::getDeviceId, Function.identity())); .stream().collect(Collectors.toMap(DeviceIncrement::getDeviceId, Function.identity()));
ObjectMapper mapper = new ObjectMapper();
resultList.forEach(data -> { resultList.forEach(data -> {
String deviceId = data.getDeviceId(); String deviceId = data.getDeviceId();
@ -120,6 +133,10 @@ public class DeviceDataAccumulateServiceImpl implements DeviceDataAccumulateServ
data.setYesterdayValue(getIncrement(yesterdayMap.get(deviceId), DeviceIncrement::getYesterdayIncrement)); data.setYesterdayValue(getIncrement(yesterdayMap.get(deviceId), DeviceIncrement::getYesterdayIncrement));
data.setLastYearValue(getIncrement(lastYearMap.get(deviceId), DeviceIncrement::getLastYearIncrement)); data.setLastYearValue(getIncrement(lastYearMap.get(deviceId), DeviceIncrement::getLastYearIncrement));
//处理111状态映射
DeviceRawdataRealtime realtime111 = realtime111Map.get(deviceId85To111Map.get(deviceId));
data.setStatus111(commonOpt.mapStatus111(objectMapper, data.getDataMapping(), realtime111));
// favorited 判断 // favorited 判断
data.setCollected(favoritedDeviceIds.contains(deviceId) ? 1 : 0); data.setCollected(favoritedDeviceIds.contains(deviceId) ? 1 : 0);
}); });

2
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceDataAlarmServiceImpl.java

@ -88,7 +88,7 @@ public class DeviceDataAlarmServiceImpl implements DeviceDataAlarmService {
} }
} }
pageSearchParam.setTypeIdList(Constants.CATEGORY_DEVICE_TYPE_MAP.get(Constants.CATEGORY_ALARM)); pageSearchParam.setCategoryIdList(Constants.CATEGORY_MAP.get(Constants.CATEGORY_ALARM));
if (null != pageSearchParam.getDeviceGroupId()){ if (null != pageSearchParam.getDeviceGroupId()){
resultList = deviceInfoMapperExt.getDevice4AlarmDataByGroup(pageSearchParam); resultList = deviceInfoMapperExt.getDevice4AlarmDataByGroup(pageSearchParam);
} else { } else {

38
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceDataBaStatusServiceImpl.java

@ -4,12 +4,18 @@ import com.dongjian.dashboard.back.common.Constants;
import com.dongjian.dashboard.back.common.language.msg.MsgLanguageChange; import com.dongjian.dashboard.back.common.language.msg.MsgLanguageChange;
import com.dongjian.dashboard.back.common.response.PageInfo; import com.dongjian.dashboard.back.common.response.PageInfo;
import com.dongjian.dashboard.back.dao.ex.DeviceInfoMapperExt; import com.dongjian.dashboard.back.dao.ex.DeviceInfoMapperExt;
import com.dongjian.dashboard.back.dao.ex.DeviceRawdataRealtimeMapperExt;
import com.dongjian.dashboard.back.dao.ex.FavoritedDeviceMapperExt; import com.dongjian.dashboard.back.dao.ex.FavoritedDeviceMapperExt;
import com.dongjian.dashboard.back.dto.data.BaStatusDataSearchParam; import com.dongjian.dashboard.back.dto.data.BaStatusDataSearchParam;
import com.dongjian.dashboard.back.easyexcel.SecondsToHMSConverter; import com.dongjian.dashboard.back.easyexcel.SecondsToHMSConverter;
import com.dongjian.dashboard.back.model.DeviceRawdataRealtime;
import com.dongjian.dashboard.back.model.DeviceRawdataRealtimeExample;
import com.dongjian.dashboard.back.service.DeviceDataBaStatusService; import com.dongjian.dashboard.back.service.DeviceDataBaStatusService;
import com.dongjian.dashboard.back.service.common.CommonOpt; import com.dongjian.dashboard.back.service.common.CommonOpt;
import com.dongjian.dashboard.back.vo.data.DeviceAccumulateData;
import com.dongjian.dashboard.back.vo.data.DeviceBaStatusData; import com.dongjian.dashboard.back.vo.data.DeviceBaStatusData;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -22,6 +28,8 @@ import org.springframework.stereotype.Service;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service @Service
public class DeviceDataBaStatusServiceImpl implements DeviceDataBaStatusService { public class DeviceDataBaStatusServiceImpl implements DeviceDataBaStatusService {
@ -31,10 +39,14 @@ public class DeviceDataBaStatusServiceImpl implements DeviceDataBaStatusService
@Value("${spring.datasource.url}") @Value("${spring.datasource.url}")
private String dbUrl; private String dbUrl;
private static final ObjectMapper objectMapper = new ObjectMapper();
@Autowired @Autowired
private DeviceInfoMapperExt deviceInfoMapperExt; private DeviceInfoMapperExt deviceInfoMapperExt;
@Autowired @Autowired
private FavoritedDeviceMapperExt favoritedDeviceMapperExt; private FavoritedDeviceMapperExt favoritedDeviceMapperExt;
@Autowired
private DeviceRawdataRealtimeMapperExt deviceRawdataRealtimeMapperExt;
@Autowired @Autowired
private MsgLanguageChange msgLanguageChange; private MsgLanguageChange msgLanguageChange;
@Autowired @Autowired
@ -72,7 +84,7 @@ public class DeviceDataBaStatusServiceImpl implements DeviceDataBaStatusService
} }
} }
pageSearchParam.setTypeIdList(Constants.CATEGORY_DEVICE_TYPE_MAP.get(Constants.CATEGORY_STATUS)); pageSearchParam.setCategoryIdList(Constants.CATEGORY_MAP.get(Constants.CATEGORY_STATUS));
if (null != pageSearchParam.getDeviceGroupId()){ if (null != pageSearchParam.getDeviceGroupId()){
resultList = deviceInfoMapperExt.getDevice4BaStatusDataByGroup(pageSearchParam); resultList = deviceInfoMapperExt.getDevice4BaStatusDataByGroup(pageSearchParam);
} else { } else {
@ -80,16 +92,30 @@ public class DeviceDataBaStatusServiceImpl implements DeviceDataBaStatusService
} }
if (CollectionUtils.isNotEmpty(resultList)) { if (CollectionUtils.isNotEmpty(resultList)) {
List<String> deviceIds = resultList.stream()
.map(DeviceBaStatusData::getDeviceId)
.toList();
// 查询 111状态 数据
Map<String, String> deviceId85To111Map = commonOpt.buildDeviceId85To111Map(deviceIds);
List<String> deviceIdList_111 = deviceId85To111Map.values()
.stream()
.toList();
Map<String, DeviceRawdataRealtime> realtime111Map = commonOpt.queryRealtime111Map(deviceIdList_111);
// 查询 favorited_device 表中所有设备的 device_id // 查询 favorited_device 表中所有设备的 device_id
List<String> favoritedDeviceIds = favoritedDeviceMapperExt.getFavoritedDeviceIds(); List<String> favoritedDeviceIds = favoritedDeviceMapperExt.getFavoritedDeviceIds();
for (DeviceBaStatusData data : resultList){ for (DeviceBaStatusData data : resultList){
String deviceId = data.getDeviceId();
data.setContinuousRunningTimeStr(SecondsToHMSConverter.covertSeconds(data.getContinuousRunningTime())); data.setContinuousRunningTimeStr(SecondsToHMSConverter.covertSeconds(data.getContinuousRunningTime()));
//处理111状态映射
DeviceRawdataRealtime realtime111 = realtime111Map.get(deviceId85To111Map.get(deviceId));
data.setStatus111(commonOpt.mapStatus111(objectMapper, data.getDataMapping(), realtime111));
// 判断设备是否在 favorited_device 表中 // 判断设备是否在 favorited_device 表中
if (favoritedDeviceIds.contains(data.getDeviceId())) { data.setCollected(favoritedDeviceIds.contains(deviceId) ? 1 : 0);
data.setCollected(1);
} else {
data.setCollected(0);
}
} }
} }

29
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceDataMeasureServiceImpl.java

@ -7,14 +7,18 @@ import com.dongjian.dashboard.back.common.response.PageInfo;
import com.dongjian.dashboard.back.common.response.SimpleDataResponse; import com.dongjian.dashboard.back.common.response.SimpleDataResponse;
import com.dongjian.dashboard.back.dao.aurora.DashboardRealtimeMeasureMapperExt; import com.dongjian.dashboard.back.dao.aurora.DashboardRealtimeMeasureMapperExt;
import com.dongjian.dashboard.back.dao.ex.DeviceInfoMapperExt; import com.dongjian.dashboard.back.dao.ex.DeviceInfoMapperExt;
import com.dongjian.dashboard.back.dao.ex.DeviceRawdataRealtimeMapperExt;
import com.dongjian.dashboard.back.dao.ex.FavoritedDeviceMapperExt; import com.dongjian.dashboard.back.dao.ex.FavoritedDeviceMapperExt;
import com.dongjian.dashboard.back.dto.data.MeasureDataSearchParam; import com.dongjian.dashboard.back.dto.data.MeasureDataSearchParam;
import com.dongjian.dashboard.back.dto.device.LineDataSearchParams; import com.dongjian.dashboard.back.dto.device.LineDataSearchParams;
import com.dongjian.dashboard.back.model.DashboardRealtimeMeasure; import com.dongjian.dashboard.back.model.DashboardRealtimeMeasure;
import com.dongjian.dashboard.back.model.DeviceRawdataRealtime;
import com.dongjian.dashboard.back.model.DeviceRawdataRealtimeExample;
import com.dongjian.dashboard.back.service.DeviceDataMeasureService; import com.dongjian.dashboard.back.service.DeviceDataMeasureService;
import com.dongjian.dashboard.back.service.common.CommonOpt; import com.dongjian.dashboard.back.service.common.CommonOpt;
import com.dongjian.dashboard.back.vo.data.DeviceMeasureData; import com.dongjian.dashboard.back.vo.data.DeviceMeasureData;
import com.dongjian.dashboard.back.vo.device.LineData; import com.dongjian.dashboard.back.vo.device.LineData;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
@ -41,12 +45,16 @@ public class DeviceDataMeasureServiceImpl implements DeviceDataMeasureService {
@Value("${spring.datasource.url}") @Value("${spring.datasource.url}")
private String dbUrl; private String dbUrl;
private static final ObjectMapper objectMapper = new ObjectMapper();
@Autowired @Autowired
private DeviceInfoMapperExt deviceInfoMapperExt; private DeviceInfoMapperExt deviceInfoMapperExt;
@Autowired @Autowired
private FavoritedDeviceMapperExt favoritedDeviceMapperExt; private FavoritedDeviceMapperExt favoritedDeviceMapperExt;
@Autowired @Autowired
private DashboardRealtimeMeasureMapperExt dashboardRealtimeMeasureMapperExt; private DashboardRealtimeMeasureMapperExt dashboardRealtimeMeasureMapperExt;
@Autowired
private DeviceRawdataRealtimeMapperExt deviceRawdataRealtimeMapperExt;
@Autowired @Autowired
private MsgLanguageChange msgLanguageChange; private MsgLanguageChange msgLanguageChange;
@Autowired @Autowired
@ -84,7 +92,7 @@ public class DeviceDataMeasureServiceImpl implements DeviceDataMeasureService {
} }
} }
pageSearchParam.setTypeIdList(Constants.CATEGORY_DEVICE_TYPE_MAP.get(Constants.CATEGORY_MEASURE)); pageSearchParam.setCategoryIdList(Constants.CATEGORY_MAP.get(Constants.CATEGORY_MEASURE));
if (null != pageSearchParam.getDeviceGroupId()){ if (null != pageSearchParam.getDeviceGroupId()){
resultList = deviceInfoMapperExt.getDevice4MeasureDataByGroup(pageSearchParam); resultList = deviceInfoMapperExt.getDevice4MeasureDataByGroup(pageSearchParam);
} else { } else {
@ -99,6 +107,13 @@ public class DeviceDataMeasureServiceImpl implements DeviceDataMeasureService {
.map(DeviceMeasureData::getDeviceId) .map(DeviceMeasureData::getDeviceId)
.filter(Objects::nonNull).toList(); .filter(Objects::nonNull).toList();
// 查询 111状态 数据
Map<String, String> deviceId85To111Map = commonOpt.buildDeviceId85To111Map(deviceIds);
List<String> deviceIdList_111 = deviceId85To111Map.values()
.stream()
.toList();
Map<String, DeviceRawdataRealtime> realtime111Map = commonOpt.queryRealtime111Map(deviceIdList_111);
ZoneId tokyoZone = ZoneId.of("Asia/Tokyo"); ZoneId tokyoZone = ZoneId.of("Asia/Tokyo");
LocalDate tokyoToday = LocalDate.now(tokyoZone); LocalDate tokyoToday = LocalDate.now(tokyoZone);
int year = tokyoToday.getYear(); int year = tokyoToday.getYear();
@ -108,18 +123,14 @@ public class DeviceDataMeasureServiceImpl implements DeviceDataMeasureService {
// 查询 dashboard_realtime_measure 数据 // 查询 dashboard_realtime_measure 数据
List<DashboardRealtimeMeasure> realtimeList = List<DashboardRealtimeMeasure> realtimeList =
dashboardRealtimeMeasureMapperExt.selectRealtimeMeasureByDevices(deviceIds); dashboardRealtimeMeasureMapperExt.selectRealtimeMeasureByDevices(deviceIds);
// 转 map:device_id -> 数据对象
Map<String, List<DashboardRealtimeMeasure>> realtimeMap = realtimeList.stream() Map<String, List<DashboardRealtimeMeasure>> realtimeMap = realtimeList.stream()
.collect(Collectors.groupingBy(DashboardRealtimeMeasure::getDeviceId)); .collect(Collectors.groupingBy(DashboardRealtimeMeasure::getDeviceId));
ObjectMapper mapper = new ObjectMapper();
for (DeviceMeasureData data : resultList) { for (DeviceMeasureData data : resultList) {
String deviceId = data.getDeviceId(); String deviceId = data.getDeviceId();
// 默认 measurementValue 从 rawData 提取 // 默认 measurementValue 从 rawData 提取
data.setMeasurementValue(commonOpt.extractValue(mapper, data.getTypeId(), data.getRawData())); data.setMeasurementValue(commonOpt.extractValue(objectMapper, data.getCategoryId(), data.getRawData()));
// 如果在实时表中存在记录,则更新 measurementValue/max/min // 如果在实时表中存在记录,则更新 measurementValue/max/min
List<DashboardRealtimeMeasure> realtime = realtimeMap.get(deviceId); List<DashboardRealtimeMeasure> realtime = realtimeMap.get(deviceId);
@ -127,7 +138,7 @@ public class DeviceDataMeasureServiceImpl implements DeviceDataMeasureService {
List<DashboardRealtimeMeasure> sortedRealtime = realtime;// 默认值为原始数据 List<DashboardRealtimeMeasure> sortedRealtime = realtime;// 默认值为原始数据
if (Constants.DEVICE_TYPE_TEMPERATURE_HUMIDITY.contains(data.getTypeId())){ if (Constants.DEVICE_TYPE_TEMPERATURE_HUMIDITY.contains(data.getCategoryId())){
// 根据 attrCode 排序,temperature 排在前,humidity 排在后 // 根据 attrCode 排序,temperature 排在前,humidity 排在后
sortedRealtime = realtime.stream() sortedRealtime = realtime.stream()
.sorted(Comparator.comparing(measure -> .sorted(Comparator.comparing(measure ->
@ -164,6 +175,10 @@ public class DeviceDataMeasureServiceImpl implements DeviceDataMeasureService {
data.setMinValue(minValues); data.setMinValue(minValues);
} }
//处理111状态映射
DeviceRawdataRealtime realtime111 = realtime111Map.get(deviceId85To111Map.get(deviceId));
data.setStatus111(commonOpt.mapStatus111(objectMapper, data.getDataMapping(), realtime111));
// 收藏状态 // 收藏状态
data.setCollected(favoritedDeviceIds.contains(deviceId) ? 1 : 0); data.setCollected(favoritedDeviceIds.contains(deviceId) ? 1 : 0);
} }

15
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceGroupServiceImpl.java

@ -265,9 +265,8 @@ public class DeviceGroupServiceImpl implements DeviceGroupService {
} }
} }
public static boolean isNotTypeMatch(int groupType, int deviceTypeId) { public static boolean isNotTypeMatch(Long categoryId) {
List<Integer> allowedTypes = Constants.CATEGORY_DEVICE_TYPE_MAP.get(groupType); return !Constants.ALL_CATEGORY_IDS.contains(categoryId);
return allowedTypes == null || !allowedTypes.contains(deviceTypeId);
} }
@Override @Override
@ -281,10 +280,8 @@ public class DeviceGroupServiceImpl implements DeviceGroupService {
return new SimpleDataResponse(ResponseCode.MSG_ERROR, "Device group not set"); return new SimpleDataResponse(ResponseCode.MSG_ERROR, "Device group not set");
} }
// Integer groupType = deviceGroup.getGroupType();
Integer groupType = null;
Long groupBuildingId = deviceGroup.getBuildingId(); Long groupBuildingId = deviceGroup.getBuildingId();
if (groupType == null || groupBuildingId == null) { if (groupBuildingId == null) {
return new SimpleDataResponse(ResponseCode.MSG_ERROR, "Invalid device group info"); return new SimpleDataResponse(ResponseCode.MSG_ERROR, "Invalid device group info");
} }
@ -299,9 +296,9 @@ public class DeviceGroupServiceImpl implements DeviceGroupService {
} }
// **类型不匹配** // **类型不匹配**
Integer deviceTypeId = deviceVO.getTypeId(); Long categoryId = deviceVO.getCategoryId();
if (deviceTypeId == null || isNotTypeMatch(groupType, deviceTypeId)) { if (categoryId == null || isNotTypeMatch(categoryId)) {
return new SimpleDataResponse(ResponseCode.MSG_ERROR, msgLanguageChange.getParameterMapByCode(languageType, "groupTypeNotMatch")); return new SimpleDataResponse(ResponseCode.MSG_ERROR, msgLanguageChange.getParameterMapByCode(languageType, "invalidDeviceCategory"));
} }
// **building 不一致** // **building 不一致**

2
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/DeviceServiceImpl.java

@ -46,7 +46,7 @@ public class DeviceServiceImpl implements DeviceService {
} else { } else {
pageSearchParam.setCompanyIdList(commonOpt.filterCompanyIds(companyId, pageSearchParam.getCompanyIds())); pageSearchParam.setCompanyIdList(commonOpt.filterCompanyIds(companyId, pageSearchParam.getCompanyIds()));
} }
pageSearchParam.setTypeIdList(Constants.ALL_DEVICE_TYPE_IDS); pageSearchParam.setCategoryIdList(Constants.ALL_CATEGORY_IDS);
PageHelper.startPage(pageSearchParam.getPageNum() == null ? 1 : pageSearchParam.getPageNum(), pageSearchParam.getPageSize() == null ? 20 : pageSearchParam.getPageSize()); PageHelper.startPage(pageSearchParam.getPageNum() == null ? 1 : pageSearchParam.getPageNum(), pageSearchParam.getPageSize() == null ? 20 : pageSearchParam.getPageSize());

18
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java

@ -63,7 +63,7 @@ public class FavoritedDeviceServiceImpl implements FavoritedDeviceService {
pageSearchParam.setCompanyIdList(commonOpt.filterCompanyIds(companyId, pageSearchParam.getCompanyIds())); pageSearchParam.setCompanyIdList(commonOpt.filterCompanyIds(companyId, pageSearchParam.getCompanyIds()));
} }
if (null != pageSearchParam.getClassId()){ if (null != pageSearchParam.getClassId()){
pageSearchParam.setTypeIdList(Constants.CATEGORY_DEVICE_TYPE_MAP.get(pageSearchParam.getClassId())); pageSearchParam.setCategoryIdList(Constants.CATEGORY_MAP.get(pageSearchParam.getClassId()));
} }
List<FavoritedDeviceVO> favoritedDeviceVOList = favoritedDeviceMapperExt.getListPage(pageSearchParam); List<FavoritedDeviceVO> favoritedDeviceVOList = favoritedDeviceMapperExt.getListPage(pageSearchParam);
@ -79,12 +79,12 @@ public class FavoritedDeviceServiceImpl implements FavoritedDeviceService {
List<String> statusDeviceIds = new ArrayList<>(); List<String> statusDeviceIds = new ArrayList<>();
for (FavoritedDeviceVO vo : favoritedDeviceVOList) { for (FavoritedDeviceVO vo : favoritedDeviceVOList) {
Integer typeId = vo.getTypeId(); Long categoryId = vo.getCategoryId();
if (Constants.CATEGORY_DEVICE_TYPE_MAP.get(Constants.CATEGORY_ACCUMULATE).contains(typeId)) { if (Constants.CATEGORY_MAP.get(Constants.CATEGORY_ACCUMULATE).contains(categoryId)) {
accumulateDeviceIds.add(vo.getDeviceId()); accumulateDeviceIds.add(vo.getDeviceId());
} else if (Constants.CATEGORY_DEVICE_TYPE_MAP.get(Constants.CATEGORY_MEASURE).contains(typeId)) { } else if (Constants.CATEGORY_MAP.get(Constants.CATEGORY_MEASURE).contains(categoryId)) {
measureDeviceIds.add(vo.getDeviceId()); measureDeviceIds.add(vo.getDeviceId());
} else if (Constants.CATEGORY_DEVICE_TYPE_MAP.get(Constants.CATEGORY_STATUS).contains(typeId)) { } else if (Constants.CATEGORY_MAP.get(Constants.CATEGORY_STATUS).contains(categoryId)) {
statusDeviceIds.add(vo.getDeviceId()); statusDeviceIds.add(vo.getDeviceId());
} }
} }
@ -96,15 +96,15 @@ public class FavoritedDeviceServiceImpl implements FavoritedDeviceService {
// 按收藏顺序生成结果 // 按收藏顺序生成结果
for (FavoritedDeviceVO vo : favoritedDeviceVOList) { for (FavoritedDeviceVO vo : favoritedDeviceVOList) {
Integer typeId = vo.getTypeId(); Long categoryId = vo.getCategoryId();
String deviceId = vo.getDeviceId(); String deviceId = vo.getDeviceId();
Object data = null; Object data = null;
if (Constants.CATEGORY_DEVICE_TYPE_MAP.get(Constants.CATEGORY_ACCUMULATE).contains(typeId)) { if (Constants.CATEGORY_MAP.get(Constants.CATEGORY_ACCUMULATE).contains(categoryId)) {
data = accumulateDataMap.get(deviceId); data = accumulateDataMap.get(deviceId);
} else if (Constants.CATEGORY_DEVICE_TYPE_MAP.get(Constants.CATEGORY_MEASURE).contains(typeId)) { } else if (Constants.CATEGORY_MAP.get(Constants.CATEGORY_MEASURE).contains(categoryId)) {
data = measureDataMap.get(deviceId); data = measureDataMap.get(deviceId);
} else if (Constants.CATEGORY_DEVICE_TYPE_MAP.get(Constants.CATEGORY_STATUS).contains(typeId)) { } else if (Constants.CATEGORY_MAP.get(Constants.CATEGORY_STATUS).contains(categoryId)) {
data = statusDataMap.get(deviceId); data = statusDataMap.get(deviceId);
} }

5
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/MonitoringPointCategoryGroupServiceImpl.java

@ -256,11 +256,6 @@ public class MonitoringPointCategoryGroupServiceImpl implements MonitoringPointC
} }
} }
public static boolean isNotTypeMatch(int groupType, int deviceTypeId) {
List<Integer> allowedTypes = Constants.CATEGORY_DEVICE_TYPE_MAP.get(groupType);
return allowedTypes == null || !allowedTypes.contains(deviceTypeId);
}
@Override @Override
@Transactional @Transactional
public SimpleDataResponse bindCategoryForGroup(BindCategoryForGroupParams bindDeviceForGroupParams, Long userId, Long companyId, Integer languageType) { public SimpleDataResponse bindCategoryForGroup(BindCategoryForGroupParams bindDeviceForGroupParams, Long userId, Long companyId, Integer languageType) {

2
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/OverviewServiceImpl.java

@ -60,7 +60,7 @@ public class OverviewServiceImpl implements OverviewService {
if (CollectionUtils.isNotEmpty(buildingInfoList)){ if (CollectionUtils.isNotEmpty(buildingInfoList)){
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("companyId", companyId); paramMap.put("companyId", companyId);
paramMap.put("typeIdList", Constants.CATEGORY_DEVICE_TYPE_MAP.get(Constants.CATEGORY_ALARM)); paramMap.put("categoryIdList", Constants.CATEGORY_MAP.get(Constants.CATEGORY_ALARM));
List<OverviewInfo> alarmInfoList = deviceRawdataRealtimeMapperExt.getOverviewInfo(paramMap); List<OverviewInfo> alarmInfoList = deviceRawdataRealtimeMapperExt.getOverviewInfo(paramMap);
List<OverviewVO> overviewVOList = convert(alarmInfoList, utcOffset); List<OverviewVO> overviewVOList = convert(alarmInfoList, utcOffset);

2
pom.xml

@ -227,7 +227,7 @@
<dependency> <dependency>
<groupId>io.netty</groupId> <groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId> <artifactId>netty-bom</artifactId>
<version>4.1.128.Final</version> <version>4.2.9.Final</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>

Loading…
Cancel
Save