Commit 48ee2a99e86232911e1e48a9fe9b6e46156f7d81
Merge branch '20220419' into 'master'
20220419 See merge request huang/thingsboard3.3.2!81
Showing
10 changed files
with
132 additions
and
20 deletions
... | ... | @@ -10,7 +10,7 @@ import javax.validation.constraints.NotEmpty; |
10 | 10 | @EqualsAndHashCode(callSuper = true) |
11 | 11 | public class YtVideoDTO extends TenantDTO { |
12 | 12 | @ApiModelProperty(value = "摄像头附加信息,json格式", required = false) |
13 | - private String deviceInfo; | |
13 | + private String additionalJson; | |
14 | 14 | |
15 | 15 | @ApiModelProperty(value = "封面图", required = false) |
16 | 16 | private String avatar; | ... | ... |
... | ... | @@ -19,7 +19,7 @@ public class YtVideoEntity extends TenantBaseEntity { |
19 | 19 | |
20 | 20 | private static final long serialVersionUID = 1498859811403607497L; |
21 | 21 | private String name; |
22 | - private String deviceInfo; | |
22 | + private String additionalJson; | |
23 | 23 | private String avatar; |
24 | 24 | private String videoUrl; |
25 | 25 | private String brand; | ... | ... |
... | ... | @@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | 4 | import lombok.RequiredArgsConstructor; |
5 | 5 | import org.apache.commons.lang3.StringUtils; |
6 | 6 | import org.springframework.beans.BeanUtils; |
7 | +import org.springframework.cache.CacheManager; | |
7 | 8 | import org.springframework.stereotype.Service; |
9 | +import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; | |
8 | 10 | import org.thingsboard.server.common.data.yunteng.dto.SysAreaDTO; |
9 | 11 | import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; |
10 | 12 | import org.thingsboard.server.dao.yunteng.entities.SysArea; |
... | ... | @@ -23,23 +25,32 @@ import java.util.List; |
23 | 25 | public class SysAreaServiceImpl implements SysAreaService { |
24 | 26 | |
25 | 27 | private final SysAreaMapper sysAreaMapper; |
28 | + private final CacheManager cacheManager; | |
26 | 29 | |
27 | 30 | @Override |
28 | 31 | public List<SysAreaDTO> list(SysAreaDTO sysAreaDTO) { |
29 | - return ReflectUtils.sourceToTarget( | |
30 | - sysAreaMapper.selectList( | |
31 | - new LambdaQueryWrapper<SysArea>() | |
32 | - .eq(sysAreaDTO.getLevel() != null, SysArea::getLevel, sysAreaDTO.getLevel()) | |
33 | - .eq( | |
34 | - sysAreaDTO.getParentId() != null, | |
35 | - SysArea::getParentId, | |
36 | - sysAreaDTO.getParentId()) | |
37 | - .eq(sysAreaDTO.getCode() != null, SysArea::getCode, sysAreaDTO.getCode()) | |
38 | - .like( | |
39 | - StringUtils.isNotEmpty(sysAreaDTO.getName()), | |
40 | - SysArea::getName, | |
41 | - sysAreaDTO.getName())), | |
42 | - SysAreaDTO.class); | |
32 | + cacheManager.getCache(FastIotConstants.CacheKey.area).get(sysAreaDTO.getParentId()); | |
33 | + List<SysAreaDTO> result = cacheManager.getCache(FastIotConstants.CacheKey.area).get(sysAreaDTO.getParentId(),List.class); | |
34 | + if(result == null || result.isEmpty()){ | |
35 | + result = ReflectUtils.sourceToTarget( | |
36 | + sysAreaMapper.selectList( | |
37 | + new LambdaQueryWrapper<SysArea>() | |
38 | + .eq(sysAreaDTO.getLevel() != null, SysArea::getLevel, sysAreaDTO.getLevel()) | |
39 | + .eq( | |
40 | + sysAreaDTO.getParentId() != null, | |
41 | + SysArea::getParentId, | |
42 | + sysAreaDTO.getParentId()) | |
43 | + .eq(sysAreaDTO.getCode() != null, SysArea::getCode, sysAreaDTO.getCode()) | |
44 | + .like( | |
45 | + StringUtils.isNotEmpty(sysAreaDTO.getName()), | |
46 | + SysArea::getName, | |
47 | + sysAreaDTO.getName())), | |
48 | + SysAreaDTO.class); | |
49 | + cacheManager.getCache(FastIotConstants.CacheKey.area).put(sysAreaDTO.getParentId(),result); | |
50 | + } | |
51 | + | |
52 | + | |
53 | + return result; | |
43 | 54 | } |
44 | 55 | |
45 | 56 | @Override | ... | ... |
... | ... | @@ -49,8 +49,8 @@ public class YtVideoServiceImpl extends AbstractBaseService<YtVideoMapper, YtVid |
49 | 49 | .in(organizationIds!=null&& !organizationIds.isEmpty(),YtVideoEntity::getOrganizationId,organizationIds) |
50 | 50 | .eq(status!=null,YtVideoEntity::getStatus,status) |
51 | 51 | .like(StringUtils.isNotEmpty(name),YtVideoEntity::getName,name); |
52 | - IPage<YtVideoEntity> page = | |
53 | - baseMapper.selectPage(pageInfrom, pageFilter); | |
52 | + IPage<YtVideoDTO> page = | |
53 | + baseMapper.getVideoPage(pageInfrom, tenantId,name,status,organizationIds); | |
54 | 54 | return getPageData(page, YtVideoDTO.class); |
55 | 55 | } |
56 | 56 | ... | ... |
... | ... | @@ -5,9 +5,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
5 | 5 | import org.apache.ibatis.annotations.Mapper; |
6 | 6 | import org.apache.ibatis.annotations.Param; |
7 | 7 | import org.thingsboard.server.common.data.yunteng.dto.AlarmProfileDTO; |
8 | +import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO; | |
9 | +import org.thingsboard.server.common.data.yunteng.dto.YtVideoDTO; | |
8 | 10 | import org.thingsboard.server.dao.yunteng.entities.AlarmProfile; |
9 | 11 | import org.thingsboard.server.dao.yunteng.entities.YtVideoEntity; |
10 | 12 | |
13 | +import java.util.List; | |
11 | 14 | import java.util.Map; |
12 | 15 | |
13 | 16 | /** |
... | ... | @@ -15,4 +18,14 @@ import java.util.Map; |
15 | 18 | */ |
16 | 19 | @Mapper |
17 | 20 | public interface YtVideoMapper extends BaseMapper<YtVideoEntity> { |
21 | + /** | |
22 | + * | |
23 | + * @param page | |
24 | + * @param tenantId | |
25 | + * @param name | |
26 | + * @param status | |
27 | + * @param organizationId | |
28 | + * @return | |
29 | + */ | |
30 | + IPage<YtVideoDTO> getVideoPage(IPage<?> page, @Param("tenantId") String tenantId, @Param("name") String name, @Param("status") Boolean status, @Param("organization") List<String> organizationId); | |
18 | 31 | } | ... | ... |
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | <result property="endTs" column="end_ts"/> |
19 | 19 | <result property="ackTs" column="ack_ts"/> |
20 | 20 | <result property="clearTs" column="clear_ts"/> |
21 | - <result property="details" column="details" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/> | |
21 | + <result property="details" column="additional_info" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/> | |
22 | 22 | <result property="propagate" column="propagate"/> |
23 | 23 | </resultMap> |
24 | 24 | ... | ... |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
3 | + | |
4 | +<mapper namespace="org.thingsboard.server.dao.yunteng.mapper.YtVideoMapper"> | |
5 | + <resultMap type="org.thingsboard.server.common.data.yunteng.dto.YtVideoDTO" id="videoMap"> | |
6 | + <result property="id" column="id"/> | |
7 | + <result property="name" column="name"/> | |
8 | + <result property="avatar" column="avatar"/> | |
9 | + <result property="videoUrl" column="video_url"/> | |
10 | + <result property="brand" column="brand"/> | |
11 | + <result property="deviceType" column="device_type" /> | |
12 | + <result property="sn" column="sn"/> | |
13 | + <result property="tenantId" column="tenant_id"/> | |
14 | + <result property="createTime" column="create_time"/> | |
15 | + <result property="updateTime" column="update_time"/> | |
16 | + <result property="creator" column="creator"/> | |
17 | + <result property="updater" column="updater"/> | |
18 | + <result property="description" column="description"/> | |
19 | + <result property="status" column="status"/> | |
20 | + <result property="additionalJson" column="additional_json"/> | |
21 | + <result property="organizationId" column="organization_id"/> | |
22 | + <result property="organizationName" column="organization_name"/> | |
23 | + </resultMap> | |
24 | + | |
25 | + | |
26 | + | |
27 | + <sql id="basicColumns"> | |
28 | + base.id,base.sn,base.name,base.avatar,base.video_url,base.description,base.status,base.additional_json,base.device_type,base.organization_id | |
29 | + ,base.tenant_id,base.create_time,base.update_time,base.creator, base.updater | |
30 | + </sql> | |
31 | + | |
32 | + <sql id="detailColumns"> | |
33 | + <include refid="basicColumns"/> | |
34 | + ,org.name AS organization_name | |
35 | + </sql> | |
36 | + <select id="getVideoPage" resultMap="videoMap"> | |
37 | + SELECT | |
38 | + <include refid="detailColumns"/> | |
39 | + FROM iotfs_device_camera base | |
40 | + LEFT JOIN iotfs_organization org ON org.id = base.organization_id | |
41 | + <where> | |
42 | + <if test="tenantId !=null and tenantId !=''"> | |
43 | + AND base.tenant_id = #{tenantId} | |
44 | + </if> | |
45 | + <if test="name !=null and name !=''"> | |
46 | + AND base.name LIKE concat('%',#{name}::TEXT,'%') | |
47 | + </if> | |
48 | + <if test="status !=null"> | |
49 | + AND base.status = #{status} | |
50 | + </if> | |
51 | + <if test="organization !=null"> | |
52 | + AND base.organization_id IN | |
53 | + <foreach collection="organization" item="organizationId" open="(" separator="," close=")"> | |
54 | + #{organizationId} | |
55 | + </foreach> | |
56 | + </if> | |
57 | + </where> | |
58 | + </select> | |
59 | + | |
60 | + | |
61 | + <select id="selectDetail" resultMap="videoMap"> | |
62 | + SELECT | |
63 | + <include refid="detailColumns"/>,d.customer_id::TEXT AS customer_id | |
64 | + FROM iotfs_device_camera base | |
65 | + LEFT JOIN iotfs_organization org ON org.id = base.organization_id | |
66 | + <where> | |
67 | + <if test="tenantId !=null and tenantId !=''"> | |
68 | + AND base.tenant_id = #{tenantId} | |
69 | + </if> | |
70 | + <if test="id !=null and id !=''"> | |
71 | + AND base.id = #{id} | |
72 | + </if> | |
73 | + | |
74 | + </where> | |
75 | + </select> | |
76 | + | |
77 | + | |
78 | + | |
79 | + | |
80 | +</mapper> | ... | ... |
... | ... | @@ -284,7 +284,7 @@ class ReactState { |
284 | 284 | for (String id : devices) { |
285 | 285 | TbMsg newMsg = ctx.newMsg(lastMsgQueueName != null ? lastMsgQueueName : ServiceQueue.MAIN |
286 | 286 | , msg.getType() |
287 | - , msg.getOriginator() | |
287 | + , new DeviceId(UUID.fromString(id)) | |
288 | 288 | , msg != null ? msg.getCustomerId() : null |
289 | 289 | , metaData |
290 | 290 | , JacksonUtil.toString(context)); | ... | ... |