|
@@ -7,6 +7,8 @@ import com.zksy.base.alarm.enums.*;
|
|
|
import com.zksy.base.alarm.mapper.AlarmLogMapper;
|
|
import com.zksy.base.alarm.mapper.AlarmLogMapper;
|
|
|
import com.zksy.base.alarm.mapper.AlarmOperationsMapper;
|
|
import com.zksy.base.alarm.mapper.AlarmOperationsMapper;
|
|
|
import com.zksy.base.enums.AlarmStatusEnum;
|
|
import com.zksy.base.enums.AlarmStatusEnum;
|
|
|
|
|
+import com.zksy.ops.dto.WorkOrderDetailVO;
|
|
|
|
|
+import com.zksy.ops.service.WorkOrderService;
|
|
|
import com.zksy.common.core.domain.entity.SysDictData;
|
|
import com.zksy.common.core.domain.entity.SysDictData;
|
|
|
import com.zksy.common.exception.ServiceException;
|
|
import com.zksy.common.exception.ServiceException;
|
|
|
import com.zksy.ops.enums.WorkOrderStatusEnum;
|
|
import com.zksy.ops.enums.WorkOrderStatusEnum;
|
|
@@ -28,6 +30,7 @@ public class AlarmOperationsService {
|
|
|
private final AlarmReviewScopeService scope;
|
|
private final AlarmReviewScopeService scope;
|
|
|
private final AlarmLogMapper logs;
|
|
private final AlarmLogMapper logs;
|
|
|
private final ISysDictDataService dictDataService;
|
|
private final ISysDictDataService dictDataService;
|
|
|
|
|
+ private final WorkOrderService workOrderService;
|
|
|
|
|
|
|
|
public Page<AlarmVO> page(AlarmQuery query) {
|
|
public Page<AlarmVO> page(AlarmQuery query) {
|
|
|
validate(query);
|
|
validate(query);
|
|
@@ -54,9 +57,14 @@ public class AlarmOperationsService {
|
|
|
return detailInScope(id, query.toAlarmQuery(), scope.resolveMobile(query));
|
|
return detailInScope(id, query.toAlarmQuery(), scope.resolveMobile(query));
|
|
|
}
|
|
}
|
|
|
public List<AlarmLog> mobileLogs(String id, MobileAlarmQuery query) {
|
|
public List<AlarmLog> mobileLogs(String id, MobileAlarmQuery query) {
|
|
|
- mobileDetail(id, query);
|
|
|
|
|
|
|
+ requireMobileAlarm(id, query);
|
|
|
return history(id);
|
|
return history(id);
|
|
|
}
|
|
}
|
|
|
|
|
+ private void requireMobileAlarm(String id, MobileAlarmQuery query) {
|
|
|
|
|
+ if (mapper.selectMobileDetail(id, query.toAlarmQuery(), scope.resolveMobile(query)) == null) {
|
|
|
|
|
+ throw new ServiceException("报警不存在或不属于当前管理范围");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
private Page<AlarmVO> pageInScope(AlarmQuery query, List<Integer> typeIds) {
|
|
private Page<AlarmVO> pageInScope(AlarmQuery query, List<Integer> typeIds) {
|
|
|
validate(query);
|
|
validate(query);
|
|
|
Page<AlarmVO> page = mapper.selectMobilePage(new Page<>(query.getPageNum(), query.getPageSize()), query, typeIds);
|
|
Page<AlarmVO> page = mapper.selectMobilePage(new Page<>(query.getPageNum(), query.getPageSize()), query, typeIds);
|
|
@@ -67,14 +75,26 @@ public class AlarmOperationsService {
|
|
|
AlarmVO alarm = mapper.selectDetail(id, query, scope.resolveOperations(query));
|
|
AlarmVO alarm = mapper.selectDetail(id, query, scope.resolveOperations(query));
|
|
|
if (alarm == null) throw new ServiceException("报警不存在或不属于当前管理范围");
|
|
if (alarm == null) throw new ServiceException("报警不存在或不属于当前管理范围");
|
|
|
labels(alarm);
|
|
labels(alarm);
|
|
|
|
|
+ fillWorkOrder(alarm);
|
|
|
return alarm;
|
|
return alarm;
|
|
|
}
|
|
}
|
|
|
private AlarmVO detailInScope(String id, AlarmQuery query, List<Integer> typeIds) {
|
|
private AlarmVO detailInScope(String id, AlarmQuery query, List<Integer> typeIds) {
|
|
|
AlarmVO alarm = mapper.selectMobileDetail(id, query, typeIds);
|
|
AlarmVO alarm = mapper.selectMobileDetail(id, query, typeIds);
|
|
|
if (alarm == null) throw new ServiceException("报警不存在或不属于当前管理范围");
|
|
if (alarm == null) throw new ServiceException("报警不存在或不属于当前管理范围");
|
|
|
labels(alarm);
|
|
labels(alarm);
|
|
|
|
|
+ fillWorkOrder(alarm);
|
|
|
return alarm;
|
|
return alarm;
|
|
|
}
|
|
}
|
|
|
|
|
+ /** 按 alarm_data.work_order_id 关联查询 work_order(含处置日志),避免前端依赖工单模块权限。 */
|
|
|
|
|
+ private void fillWorkOrder(AlarmVO alarm) {
|
|
|
|
|
+ if (alarm.getWorkOrderId() == null) return;
|
|
|
|
|
+ try {
|
|
|
|
|
+ WorkOrderDetailVO detail = workOrderService.getDetail(alarm.getWorkOrderId());
|
|
|
|
|
+ alarm.setWorkOrderDetail(detail);
|
|
|
|
|
+ } catch (RuntimeException ignored) {
|
|
|
|
|
+ // 工单已被删除或不可见时不阻断报警详情
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
public Page<AlarmVO> reminders(AlarmQuery query) {
|
|
public Page<AlarmVO> reminders(AlarmQuery query) {
|
|
|
// 提醒只展示未处理报警,不能通过请求参数切换为历史已恢复事件。
|
|
// 提醒只展示未处理报警,不能通过请求参数切换为历史已恢复事件。
|
|
|
query.setAlarmStatus(AlarmRecordStatusEnum.UNHANDLED.getCode());
|
|
query.setAlarmStatus(AlarmRecordStatusEnum.UNHANDLED.getCode());
|
|
@@ -84,9 +104,14 @@ public class AlarmOperationsService {
|
|
|
return page;
|
|
return page;
|
|
|
}
|
|
}
|
|
|
public List<AlarmLog> logs(String id, AlarmQuery query) {
|
|
public List<AlarmLog> logs(String id, AlarmQuery query) {
|
|
|
- detail(id, query);
|
|
|
|
|
|
|
+ requireAlarm(id, query);
|
|
|
return history(id);
|
|
return history(id);
|
|
|
}
|
|
}
|
|
|
|
|
+ private void requireAlarm(String id, AlarmQuery query) {
|
|
|
|
|
+ if (mapper.selectDetail(id, query, scope.resolveOperations(query)) == null) {
|
|
|
|
|
+ throw new ServiceException("报警不存在或不属于当前管理范围");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
private List<AlarmLog> history(String id) {
|
|
private List<AlarmLog> history(String id) {
|
|
|
List<AlarmLog> result = logs.selectHistory(id);
|
|
List<AlarmLog> result = logs.selectHistory(id);
|
|
|
result.forEach(log -> { AlarmLogOperTypeEnum type = AlarmLogOperTypeEnum.fromCode(log.getOperType());
|
|
result.forEach(log -> { AlarmLogOperTypeEnum type = AlarmLogOperTypeEnum.fromCode(log.getOperType());
|