Showing
2 changed files
with
38 additions
and
0 deletions
@@ -48,6 +48,9 @@ import org.thingsboard.server.common.data.id.EntityId; | @@ -48,6 +48,9 @@ import org.thingsboard.server.common.data.id.EntityId; | ||
48 | import org.thingsboard.server.common.data.id.EntityIdFactory; | 48 | import org.thingsboard.server.common.data.id.EntityIdFactory; |
49 | import org.thingsboard.server.common.data.page.PageData; | 49 | import org.thingsboard.server.common.data.page.PageData; |
50 | import org.thingsboard.server.common.data.page.TimePageLink; | 50 | import org.thingsboard.server.common.data.page.TimePageLink; |
51 | +import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | ||
52 | +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | ||
53 | +import org.thingsboard.server.common.data.yunteng.dto.BatchAckAlarmDTO; | ||
51 | import org.thingsboard.server.dao.yunteng.service.TkDeviceService; | 54 | import org.thingsboard.server.dao.yunteng.service.TkDeviceService; |
52 | import org.thingsboard.server.queue.util.TbCoreComponent; | 55 | import org.thingsboard.server.queue.util.TbCoreComponent; |
53 | import org.thingsboard.server.service.security.permission.Operation; | 56 | import org.thingsboard.server.service.security.permission.Operation; |
@@ -193,6 +196,29 @@ public class AlarmController extends BaseController { | @@ -193,6 +196,29 @@ public class AlarmController extends BaseController { | ||
193 | @RequestMapping(value = "/alarm/{alarmId}/ack", method = RequestMethod.POST) | 196 | @RequestMapping(value = "/alarm/{alarmId}/ack", method = RequestMethod.POST) |
194 | @ResponseStatus(value = HttpStatus.OK) | 197 | @ResponseStatus(value = HttpStatus.OK) |
195 | public void ackAlarm(@ApiParam(value = ALARM_ID_PARAM_DESCRIPTION) @PathVariable(ALARM_ID) String strAlarmId) throws ThingsboardException { | 198 | public void ackAlarm(@ApiParam(value = ALARM_ID_PARAM_DESCRIPTION) @PathVariable(ALARM_ID) String strAlarmId) throws ThingsboardException { |
199 | + //thingsKit function | ||
200 | + processAlarm(strAlarmId); | ||
201 | + } | ||
202 | + | ||
203 | + @ApiOperation(value = "批量处理确认") | ||
204 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") | ||
205 | + @RequestMapping(value = "/alarm/batch/ack", method = RequestMethod.POST) | ||
206 | + @ResponseStatus(value = HttpStatus.OK) | ||
207 | + public void batchAckAlarm(@ApiParam(value = ALARM_ID_PARAM_DESCRIPTION) @RequestBody BatchAckAlarmDTO alarmDTO) throws ThingsboardException { | ||
208 | + List<String> strAlarmIds = alarmDTO.getAlarmIds(); | ||
209 | + if(null == strAlarmIds || strAlarmIds.isEmpty()){ | ||
210 | + throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | ||
211 | + } | ||
212 | + for (String strAlarmId:strAlarmIds){ | ||
213 | + if(StringUtils.isEmpty(strAlarmId)){ | ||
214 | + throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | ||
215 | + } | ||
216 | + //thingsKit function | ||
217 | + processAlarm(strAlarmId); | ||
218 | + } | ||
219 | + } | ||
220 | + //thingsKit function | ||
221 | + private void processAlarm(String strAlarmId) throws ThingsboardException { | ||
196 | checkParameter(ALARM_ID, strAlarmId); | 222 | checkParameter(ALARM_ID, strAlarmId); |
197 | try { | 223 | try { |
198 | AlarmId alarmId = new AlarmId(toUUID(strAlarmId)); | 224 | AlarmId alarmId = new AlarmId(toUUID(strAlarmId)); |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/BatchAckAlarmDTO.java
0 → 100644
1 | +package org.thingsboard.server.common.data.yunteng.dto; | ||
2 | + | ||
3 | +import io.swagger.annotations.ApiModelProperty; | ||
4 | +import lombok.Data; | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | + | ||
8 | +@Data | ||
9 | +public class BatchAckAlarmDTO { | ||
10 | + @ApiModelProperty(value = "批量删除告警IDS") | ||
11 | + private List<String> alarmIds; | ||
12 | +} |