...
|
...
|
@@ -39,13 +39,10 @@ import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum; |
39
|
39
|
import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum;
|
40
|
40
|
import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
|
41
|
41
|
import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
|
42
|
|
-import org.thingsboard.server.controller.AlarmController;
|
43
|
42
|
import org.thingsboard.server.controller.BaseController;
|
44
|
|
-import org.thingsboard.server.dao.yunteng.entities.TkUserCollectEntity;
|
45
|
43
|
import org.thingsboard.server.dao.yunteng.service.TkAlarmInfoService;
|
46
|
44
|
import org.thingsboard.server.dao.yunteng.service.TkDeviceProfileService;
|
47
|
45
|
import org.thingsboard.server.dao.yunteng.service.TkDeviceService;
|
48
|
|
-import org.thingsboard.server.dao.yunteng.service.TkUserCollectService;
|
49
|
46
|
import org.thingsboard.server.service.gateway_device.GatewayNotificationsService;
|
50
|
47
|
import org.thingsboard.server.service.security.permission.Operation;
|
51
|
48
|
import org.thingsboard.server.service.security.permission.Resource;
|
...
|
...
|
@@ -68,7 +65,6 @@ public class TkDeviceController extends BaseController { |
68
|
65
|
private final TkDeviceProfileService ytDeviceProfileService;
|
69
|
66
|
private final GatewayNotificationsService gatewayNotificationsService;
|
70
|
67
|
private final TkAlarmInfoService tkAlarmInfoService ;
|
71
|
|
- private final AlarmController alarmController;
|
72
|
68
|
|
73
|
69
|
|
74
|
70
|
|
...
|
...
|
@@ -337,13 +333,22 @@ public class TkDeviceController extends BaseController { |
337
|
333
|
}
|
338
|
334
|
|
339
|
335
|
private void deleteAlarm(String id) throws ThingsboardException {
|
|
336
|
+ //根据设备的tbId查询当前设备的所有告警
|
340
|
337
|
List<String> alarmIds = tkAlarmInfoService.getByTbDeviceId(getTenantId().toString(),id);
|
341
|
338
|
if(alarmIds.isEmpty()){
|
342
|
339
|
return;
|
343
|
340
|
}
|
344
|
341
|
alarmIds.forEach(strAlarmId -> {
|
|
342
|
+ //此处参考AlarmController中的deleteAlarm方法
|
345
|
343
|
try {
|
346
|
|
- alarmController.deleteAlarm(strAlarmId);
|
|
344
|
+ AlarmId alarmId = new AlarmId(toUUID(strAlarmId));
|
|
345
|
+ Alarm alarm = checkAlarmId(alarmId, Operation.WRITE);
|
|
346
|
+ List<EdgeId> relatedEdgeIds = findRelatedEdgeIds(getTenantId(), alarm.getOriginator());
|
|
347
|
+ logEntityAction(alarm.getOriginator(), alarm,
|
|
348
|
+ getCurrentUser().getCustomerId(),
|
|
349
|
+ ActionType.ALARM_DELETE, null);
|
|
350
|
+ sendAlarmDeleteNotificationMsg(getTenantId(), alarmId, relatedEdgeIds, alarm);
|
|
351
|
+ alarmService.deleteAlarm(getTenantId(), alarmId);
|
347
|
352
|
} catch (ThingsboardException e) {
|
348
|
353
|
e.printStackTrace();
|
349
|
354
|
}
|
...
|
...
|
|