Showing
1 changed file
with
7 additions
and
0 deletions
@@ -18,6 +18,7 @@ package org.thingsboard.server.controller; | @@ -18,6 +18,7 @@ package org.thingsboard.server.controller; | ||
18 | import io.swagger.annotations.Api; | 18 | import io.swagger.annotations.Api; |
19 | import io.swagger.annotations.ApiOperation; | 19 | import io.swagger.annotations.ApiOperation; |
20 | import io.swagger.annotations.ApiParam; | 20 | import io.swagger.annotations.ApiParam; |
21 | +import lombok.AllArgsConstructor; | ||
21 | import org.apache.commons.lang3.StringUtils; | 22 | import org.apache.commons.lang3.StringUtils; |
22 | import org.springframework.http.HttpStatus; | 23 | import org.springframework.http.HttpStatus; |
23 | import org.springframework.http.MediaType; | 24 | import org.springframework.http.MediaType; |
@@ -47,6 +48,7 @@ import org.thingsboard.server.common.data.id.EntityId; | @@ -47,6 +48,7 @@ import org.thingsboard.server.common.data.id.EntityId; | ||
47 | import org.thingsboard.server.common.data.id.EntityIdFactory; | 48 | import org.thingsboard.server.common.data.id.EntityIdFactory; |
48 | import org.thingsboard.server.common.data.page.PageData; | 49 | import org.thingsboard.server.common.data.page.PageData; |
49 | import org.thingsboard.server.common.data.page.TimePageLink; | 50 | import org.thingsboard.server.common.data.page.TimePageLink; |
51 | +import org.thingsboard.server.dao.yunteng.service.YtDeviceService; | ||
50 | import org.thingsboard.server.queue.util.TbCoreComponent; | 52 | import org.thingsboard.server.queue.util.TbCoreComponent; |
51 | import org.thingsboard.server.service.security.permission.Operation; | 53 | import org.thingsboard.server.service.security.permission.Operation; |
52 | import org.thingsboard.server.service.security.permission.Resource; | 54 | import org.thingsboard.server.service.security.permission.Resource; |
@@ -73,6 +75,7 @@ import static org.thingsboard.server.controller.ControllerConstants.UUID_WIKI_LI | @@ -73,6 +75,7 @@ import static org.thingsboard.server.controller.ControllerConstants.UUID_WIKI_LI | ||
73 | @TbCoreComponent | 75 | @TbCoreComponent |
74 | @RequestMapping("/api") | 76 | @RequestMapping("/api") |
75 | @Api(tags = {"告警"}) | 77 | @Api(tags = {"告警"}) |
78 | +@AllArgsConstructor | ||
76 | public class AlarmController extends BaseController { | 79 | public class AlarmController extends BaseController { |
77 | 80 | ||
78 | public static final String ALARM_ID = "alarmId"; | 81 | public static final String ALARM_ID = "alarmId"; |
@@ -88,6 +91,8 @@ public class AlarmController extends BaseController { | @@ -88,6 +91,8 @@ public class AlarmController extends BaseController { | ||
88 | private static final String ALARM_QUERY_FETCH_ORIGINATOR_DESCRIPTION = "A boolean value to specify if the alarm originator name will be " + | 91 | private static final String ALARM_QUERY_FETCH_ORIGINATOR_DESCRIPTION = "A boolean value to specify if the alarm originator name will be " + |
89 | "filled in the AlarmInfo object field: 'originatorName' or will returns as null."; | 92 | "filled in the AlarmInfo object field: 'originatorName' or will returns as null."; |
90 | 93 | ||
94 | + private final YtDeviceService ytDeviceService; | ||
95 | + | ||
91 | @ApiOperation(value = "Get Alarm (getAlarmById)", | 96 | @ApiOperation(value = "Get Alarm (getAlarmById)", |
92 | notes = "Fetch the Alarm object based on the provided Alarm Id. " + ALARM_SECURITY_CHECK, produces = MediaType.APPLICATION_JSON_VALUE) | 97 | notes = "Fetch the Alarm object based on the provided Alarm Id. " + ALARM_SECURITY_CHECK, produces = MediaType.APPLICATION_JSON_VALUE) |
93 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") | 98 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
@@ -218,6 +223,8 @@ public class AlarmController extends BaseController { | @@ -218,6 +223,8 @@ public class AlarmController extends BaseController { | ||
218 | Alarm alarm = checkAlarmId(alarmId, Operation.WRITE); | 223 | Alarm alarm = checkAlarmId(alarmId, Operation.WRITE); |
219 | long clearTs = System.currentTimeMillis(); | 224 | long clearTs = System.currentTimeMillis(); |
220 | alarmService.clearAlarm(getCurrentUser().getTenantId(), alarmId, null, clearTs).get(); | 225 | alarmService.clearAlarm(getCurrentUser().getTenantId(), alarmId, null, clearTs).get(); |
226 | + //Thingskit function | ||
227 | + ytDeviceService.freshAlarmStatus(alarm.getOriginator(), 0); | ||
221 | alarm.setClearTs(clearTs); | 228 | alarm.setClearTs(clearTs); |
222 | alarm.setStatus(alarm.getStatus().isAck() ? AlarmStatus.CLEARED_ACK : AlarmStatus.CLEARED_UNACK); | 229 | alarm.setStatus(alarm.getStatus().isAck() ? AlarmStatus.CLEARED_ACK : AlarmStatus.CLEARED_UNACK); |
223 | logEntityAction(alarm.getOriginator(), alarm, getCurrentUser().getCustomerId(), ActionType.ALARM_CLEAR, null); | 230 | logEntityAction(alarm.getOriginator(), alarm, getCurrentUser().getCustomerId(), ActionType.ALARM_CLEAR, null); |