Showing
5 changed files
with
47 additions
and
4 deletions
... | ... | @@ -4,6 +4,7 @@ import io.swagger.annotations.Api; |
4 | 4 | import io.swagger.annotations.ApiOperation; |
5 | 5 | import lombok.RequiredArgsConstructor; |
6 | 6 | import org.apache.commons.lang3.StringUtils; |
7 | +import org.springframework.http.ResponseEntity; | |
7 | 8 | import org.springframework.web.bind.annotation.GetMapping; |
8 | 9 | import org.springframework.web.bind.annotation.RequestMapping; |
9 | 10 | import org.springframework.web.bind.annotation.RequestParam; |
... | ... | @@ -14,15 +15,14 @@ import org.thingsboard.server.common.data.alarm.AlarmInfo; |
14 | 15 | import org.thingsboard.server.common.data.alarm.AlarmStatus; |
15 | 16 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
16 | 17 | import org.thingsboard.server.common.data.page.TimePageLink; |
18 | +import org.thingsboard.server.common.data.yunteng.dto.SysDictDTO; | |
17 | 19 | import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum; |
18 | 20 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
19 | 21 | import org.thingsboard.server.controller.BaseController; |
20 | 22 | import org.thingsboard.server.dao.yunteng.entities.YtAlarmEntity; |
21 | 23 | import org.thingsboard.server.dao.yunteng.service.YtAlarmInfoService; |
22 | 24 | |
23 | -import java.util.HashMap; | |
24 | -import java.util.Map; | |
25 | -import java.util.UUID; | |
25 | +import java.util.*; | |
26 | 26 | |
27 | 27 | import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.*; |
28 | 28 | |
... | ... | @@ -70,4 +70,13 @@ public class YtAlarmInfoController extends BaseController { |
70 | 70 | |
71 | 71 | |
72 | 72 | |
73 | + @ApiOperation(value="告警类型") | |
74 | + @GetMapping() | |
75 | + public ResponseEntity<List<SysDictDTO>> alarmType() throws ThingsboardException { | |
76 | + List result = alarmInfoService.alarmType(getCurrentUser().getTenantId()); | |
77 | + return ResponseEntity.ok(result); | |
78 | + } | |
79 | + | |
80 | + | |
81 | + | |
73 | 82 | } | ... | ... |
... | ... | @@ -15,7 +15,9 @@ import org.thingsboard.server.common.data.page.PageData; |
15 | 15 | import org.thingsboard.server.common.data.page.TimePageLink; |
16 | 16 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
17 | 17 | import org.thingsboard.server.common.data.yunteng.dto.OrganizationDTO; |
18 | +import org.thingsboard.server.common.data.yunteng.dto.SysDictDTO; | |
18 | 19 | import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum; |
20 | +import org.thingsboard.server.common.data.yunteng.utils.ReflectUtils; | |
19 | 21 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
20 | 22 | import org.thingsboard.server.dao.yunteng.entities.AlarmContact; |
21 | 23 | import org.thingsboard.server.dao.yunteng.entities.YtAlarmEntity; |
... | ... | @@ -87,4 +89,8 @@ private final OrganizationMapper organizationMapper; |
87 | 89 | } |
88 | 90 | } |
89 | 91 | |
92 | + @Override | |
93 | + public List<SysDictDTO> alarmType(TenantId tenantId) { | |
94 | + return ReflectUtils.sourceToTarget(ytJpaAarmDao.alarmType(tenantId.getId()), SysDictDTO.class); | |
95 | + } | |
90 | 96 | } | ... | ... |
... | ... | @@ -11,6 +11,7 @@ import org.thingsboard.server.common.data.id.TenantId; |
11 | 11 | import org.thingsboard.server.common.data.yunteng.dto.MenuDTO; |
12 | 12 | import org.thingsboard.server.common.data.yunteng.dto.TenantDTO; |
13 | 13 | import org.thingsboard.server.dao.yunteng.entities.Menu; |
14 | +import org.thingsboard.server.dao.yunteng.entities.SysDict; | |
14 | 15 | import org.thingsboard.server.dao.yunteng.entities.YtAlarmEntity; |
15 | 16 | |
16 | 17 | import java.util.Collection; |
... | ... | @@ -32,4 +33,6 @@ public interface YtAlarmMapper extends BaseMapper<YtAlarmEntity> { |
32 | 33 | ,@Param("originatorType") EntityType originatorType |
33 | 34 | ,@Param("organizationId")List<String> organizationId |
34 | 35 | ); |
36 | + | |
37 | + List<SysDict> alarmType(@Param("tenantId") UUID tenantId); | |
35 | 38 | } | ... | ... |
... | ... | @@ -7,9 +7,11 @@ import org.thingsboard.server.common.data.alarm.AlarmStatus; |
7 | 7 | import org.thingsboard.server.common.data.id.TenantId; |
8 | 8 | import org.thingsboard.server.common.data.page.TimePageLink; |
9 | 9 | import org.thingsboard.server.common.data.yunteng.dto.AlarmInfoDTO; |
10 | +import org.thingsboard.server.common.data.yunteng.dto.SysDictDTO; | |
10 | 11 | import org.thingsboard.server.common.data.yunteng.utils.tools.YtPageData; |
11 | 12 | import org.thingsboard.server.dao.yunteng.entities.YtAlarmEntity; |
12 | 13 | |
14 | +import java.util.List; | |
13 | 15 | import java.util.Map; |
14 | 16 | import java.util.UUID; |
15 | 17 | |
... | ... | @@ -33,4 +35,12 @@ public interface YtAlarmInfoService { |
33 | 35 | */ |
34 | 36 | YtPageData<YtAlarmEntity> alarmPage(Map<String, Object> pageMap, TenantId tenantId, String alarmType, Long startTime, Long endTime, AlarmStatus status, String deviceId, EntityType originatorType, String organizationId); |
35 | 37 | |
38 | + | |
39 | + /** | |
40 | + * 设备告警类型 | |
41 | + * @param tenantId | |
42 | + * @return | |
43 | + */ | |
44 | + List<SysDictDTO> alarmType(TenantId tenantId); | |
45 | + | |
36 | 46 | } | ... | ... |
... | ... | @@ -22,6 +22,11 @@ |
22 | 22 | <result property="propagate" column="propagate"/> |
23 | 23 | </resultMap> |
24 | 24 | |
25 | + <resultMap type="org.thingsboard.server.dao.yunteng.entities.SysDict" id="alarmType"> | |
26 | + <result property="dictName" column="dict_name"/> | |
27 | + <result property="dictCode" column="dict_code"/> | |
28 | + </resultMap> | |
29 | + | |
25 | 30 | |
26 | 31 | <select id="alarmPage" resultMap="alarmInfo"> |
27 | 32 | SELECT d.name AS device_name,d.id device_id,m.* |
... | ... | @@ -32,7 +37,7 @@ |
32 | 37 | AND type LIKE CONCAT('%',#{alarmType},'%') |
33 | 38 | </if> |
34 | 39 | <if test="startTime!=null"> |
35 | - AND created_time >= #{tenantId} | |
40 | + AND created_time >= #{startTime} | |
36 | 41 | </if> |
37 | 42 | <if test="endTime!=null"> |
38 | 43 | AND created_time <= #{endTime} |
... | ... | @@ -55,4 +60,14 @@ |
55 | 60 | |
56 | 61 | </where> |
57 | 62 | </select> |
63 | + | |
64 | + | |
65 | + <select id="alarmType" resultMap="alarmType"> | |
66 | + SELECT DISTINCT m.type AS dict_name,m.type AS dict_code | |
67 | + FROM alarm m | |
68 | + <where> | |
69 | + m.tenant_id = #{tenantId} | |
70 | + </where> | |
71 | + </select> | |
72 | + | |
58 | 73 | </mapper> | ... | ... |