Commit 94e1cf7f84c46d865acca4a177263ec92ff292b6

Authored by xp.Huang
1 parent 2dfe716f

feat: 告警增加批量清除处理

@@ -200,7 +200,7 @@ public class AlarmController extends BaseController { @@ -200,7 +200,7 @@ public class AlarmController extends BaseController {
200 processAlarm(strAlarmId); 200 processAlarm(strAlarmId);
201 } 201 }
202 202
203 - @ApiOperation(value = "批量处理确认") 203 + @ApiOperation(value = "批量处理")
204 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") 204 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
205 @RequestMapping(value = "/alarm/batch/ack", method = RequestMethod.POST) 205 @RequestMapping(value = "/alarm/batch/ack", method = RequestMethod.POST)
206 @ResponseStatus(value = HttpStatus.OK) 206 @ResponseStatus(value = HttpStatus.OK)
@@ -243,6 +243,30 @@ public class AlarmController extends BaseController { @@ -243,6 +243,30 @@ public class AlarmController extends BaseController {
243 @RequestMapping(value = "/alarm/{alarmId}/clear", method = RequestMethod.POST) 243 @RequestMapping(value = "/alarm/{alarmId}/clear", method = RequestMethod.POST)
244 @ResponseStatus(value = HttpStatus.OK) 244 @ResponseStatus(value = HttpStatus.OK)
245 public void clearAlarm(@ApiParam(value = ALARM_ID_PARAM_DESCRIPTION) @PathVariable(ALARM_ID) String strAlarmId) throws ThingsboardException { 245 public void clearAlarm(@ApiParam(value = ALARM_ID_PARAM_DESCRIPTION) @PathVariable(ALARM_ID) String strAlarmId) throws ThingsboardException {
  246 + //Thingskit function
  247 + processClear(strAlarmId);
  248 + }
  249 +
  250 + @ApiOperation(value = "批量清除")
  251 + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
  252 + @RequestMapping(value = "/alarm/batch/clear", method = RequestMethod.POST)
  253 + @ResponseStatus(value = HttpStatus.OK)
  254 + public void batchClearAlarm(@ApiParam(value = ALARM_ID_PARAM_DESCRIPTION) @RequestBody BatchAckAlarmDTO batchAckAlarmDTO) throws ThingsboardException {
  255 + List<String> strAlarmIds = batchAckAlarmDTO.getAlarmIds();
  256 + if(null == strAlarmIds || strAlarmIds.isEmpty()){
  257 + throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  258 + }
  259 + for (String strAlarmId:strAlarmIds){
  260 + if(StringUtils.isEmpty(strAlarmId)){
  261 + throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  262 + }
  263 + //thingsKit function
  264 + processClear(strAlarmId);
  265 + }
  266 + }
  267 +
  268 + //Thingskit function
  269 + private void processClear(String strAlarmId) throws ThingsboardException {
246 checkParameter(ALARM_ID, strAlarmId); 270 checkParameter(ALARM_ID, strAlarmId);
247 try { 271 try {
248 AlarmId alarmId = new AlarmId(toUUID(strAlarmId)); 272 AlarmId alarmId = new AlarmId(toUUID(strAlarmId));