|
@@ -7,13 +7,23 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zksy.base.warning.domain.*;
|
|
import com.zksy.base.warning.domain.*;
|
|
|
import com.zksy.base.warning.mapper.*;
|
|
import com.zksy.base.warning.mapper.*;
|
|
|
import com.zksy.base.warning.service.EarlyWarningService;
|
|
import com.zksy.base.warning.service.EarlyWarningService;
|
|
|
|
|
+import com.zksy.base.warning.service.WarningSupervisionNotifier;
|
|
|
import com.zksy.common.core.domain.entity.SysDictData;
|
|
import com.zksy.common.core.domain.entity.SysDictData;
|
|
|
|
|
+import com.zksy.common.core.domain.entity.SysUser;
|
|
|
|
|
+import com.zksy.system.mapper.SysUserMapper;
|
|
|
import com.zksy.common.utils.DictUtils;
|
|
import com.zksy.common.utils.DictUtils;
|
|
|
import com.zksy.common.utils.SecurityUtils;
|
|
import com.zksy.common.utils.SecurityUtils;
|
|
|
|
|
+import com.zksy.common.exception.ServiceException;
|
|
|
|
|
+import com.zksy.common.sms.SmsProperties;
|
|
|
|
|
+import com.zksy.common.sms.SmsTemplate;
|
|
|
import com.zksy.service.MinioFileStorageService;
|
|
import com.zksy.service.MinioFileStorageService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.ObjectProvider;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+import org.springframework.transaction.support.TransactionSynchronization;
|
|
|
|
|
+import org.springframework.transaction.support.TransactionSynchronizationManager;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
@@ -21,6 +31,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
|
|
+@Slf4j
|
|
|
public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, EarlyWarning>
|
|
public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, EarlyWarning>
|
|
|
implements EarlyWarningService {
|
|
implements EarlyWarningService {
|
|
|
|
|
|
|
@@ -42,6 +53,14 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
private WarningArchiveMapper warningArchiveMapper;
|
|
private WarningArchiveMapper warningArchiveMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MinioFileStorageService minioFileStorageService;
|
|
private MinioFileStorageService minioFileStorageService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysUserMapper sysUserMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ObjectProvider<SmsTemplate> smsTemplateProvider;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SmsProperties smsProperties;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WarningSupervisionNotifier supervisionNotifier;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public IPage<Map<String, Object>> getWarningList(Page<?> page, String warningName, String warningType, String warningLevel, String status) {
|
|
public IPage<Map<String, Object>> getWarningList(Page<?> page, String warningName, String warningType, String warningLevel, String status) {
|
|
@@ -55,13 +74,29 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public IPage<Map<String, Object>> getTodoList(Page<?> page, String userName, String todoType, String warningName) {
|
|
public IPage<Map<String, Object>> getTodoList(Page<?> page, String userName, String todoType, String warningName) {
|
|
|
- return earlyWarningMapper.selectTodoList(page, userName, todoType, warningName);
|
|
|
|
|
|
|
+ Map<String, String> filters = new HashMap<>();
|
|
|
|
|
+ filters.put("todoType", todoType);
|
|
|
|
|
+ filters.put("warningName", warningName);
|
|
|
|
|
+ return getTodoList(page, filters);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public IPage<Map<String, Object>> getTodoList(Page<?> page, Map<String, String> filters) {
|
|
|
|
|
+ String type = filters.get("todoType");
|
|
|
|
|
+ if (!isBlank(type) && !Arrays.asList("TODO", "DONE", "NOTICE").contains(type)) {
|
|
|
|
|
+ throw new ServiceException("待办类型只能为 TODO、DONE 或 NOTICE");
|
|
|
|
|
+ }
|
|
|
|
|
+ IPage<Map<String, Object>> result = earlyWarningMapper.selectMyTasks(page, currentUser(),
|
|
|
|
|
+ String.valueOf(SecurityUtils.getUserId()), filters);
|
|
|
|
|
+ result.getRecords().forEach(this::addWorkflowActions);
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Map<String, Object> getWarningDetail(String warningId) {
|
|
public Map<String, Object> getWarningDetail(String warningId) {
|
|
|
Map<String, Object> detail = earlyWarningMapper.selectWarningDetail(warningId);
|
|
Map<String, Object> detail = earlyWarningMapper.selectWarningDetail(warningId);
|
|
|
if (detail != null) {
|
|
if (detail != null) {
|
|
|
|
|
+ addWorkflowActions(detail);
|
|
|
detail.put("attachmentList", getAttachmentList(warningId));
|
|
detail.put("attachmentList", getAttachmentList(warningId));
|
|
|
detail.put("disposalList", getDisposalList(warningId));
|
|
detail.put("disposalList", getDisposalList(warningId));
|
|
|
detail.put("alarmList", getLinkedAlarms(warningId));
|
|
detail.put("alarmList", getLinkedAlarms(warningId));
|
|
@@ -78,12 +113,14 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
result.put("basicInfo", basicInfo);
|
|
result.put("basicInfo", basicInfo);
|
|
|
|
|
+ addWorkflowActions(basicInfo);
|
|
|
result.put("gisLocation", getGisLocation(basicInfo));
|
|
result.put("gisLocation", getGisLocation(basicInfo));
|
|
|
result.put("disposalHistory", getDisposalHistory(warningId));
|
|
result.put("disposalHistory", getDisposalHistory(warningId));
|
|
|
result.put("attachmentList", getAttachmentList(warningId));
|
|
result.put("attachmentList", getAttachmentList(warningId));
|
|
|
result.put("supervisionList", getSupervisionList(warningId));
|
|
result.put("supervisionList", getSupervisionList(warningId));
|
|
|
result.put("alarmList", getLinkedAlarms(warningId));
|
|
result.put("alarmList", getLinkedAlarms(warningId));
|
|
|
- result.put("electronicArchive", generateElectronicArchive(basicInfo));
|
|
|
|
|
|
|
+ // 查询详情不能创建归档,只有核查解除后才生成最终档案。
|
|
|
|
|
+ result.put("electronicArchive", getArchiveByWarningId(warningId));
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
@@ -149,7 +186,15 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean saveWarning(EarlyWarning warning, List<String> alarmIds, List<MultipartFile> files) {
|
|
public boolean saveWarning(EarlyWarning warning, List<String> alarmIds, List<MultipartFile> files) {
|
|
|
- String warningNo = "WJ" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
|
|
|
|
|
|
+ warning.setWarningId(null);
|
|
|
|
|
+ warning.setPublisher(null);
|
|
|
|
|
+ warning.setPublishTime(null);
|
|
|
|
|
+ warning.setProcessInstanceId(null);
|
|
|
|
|
+ // 草稿可预选核查人;未选择时在发布时使用当前发布人。
|
|
|
|
|
+ warning.setCreateBy(currentUser());
|
|
|
|
|
+ warning.setUpdateBy(currentUser());
|
|
|
|
|
+ String warningNo = "YJ" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"))
|
|
|
|
|
+ + UUID.randomUUID().toString().substring(0, 6).toUpperCase(Locale.ROOT);
|
|
|
warning.setWarningNo(warningNo);
|
|
warning.setWarningNo(warningNo);
|
|
|
warning.setStatus("DRAFT");
|
|
warning.setStatus("DRAFT");
|
|
|
warning.setCreateTime(LocalDateTime.now());
|
|
warning.setCreateTime(LocalDateTime.now());
|
|
@@ -174,11 +219,22 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
saveAttachments(warningId, null, "REPORT", files);
|
|
saveAttachments(warningId, null, "REPORT", files);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void saveAttachments(String warningId, String disposalId, String stage, List<MultipartFile> files) {
|
|
|
|
|
|
|
+ private List<WarningAttachment> saveAttachments(String warningId, String disposalId, String stage, List<MultipartFile> files) {
|
|
|
|
|
+ List<WarningAttachment> saved = new ArrayList<>();
|
|
|
try {
|
|
try {
|
|
|
for (MultipartFile file : files) {
|
|
for (MultipartFile file : files) {
|
|
|
validateAttachment(file);
|
|
validateAttachment(file);
|
|
|
String path = minioFileStorageService.uploadFile(file, "warning");
|
|
String path = minioFileStorageService.uploadFile(file, "warning");
|
|
|
|
|
+ if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
|
|
|
|
+ TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
|
|
|
|
+ @Override public void afterCompletion(int status) {
|
|
|
|
|
+ if (status == STATUS_ROLLED_BACK) {
|
|
|
|
|
+ try { minioFileStorageService.deleteFile(path); }
|
|
|
|
|
+ catch (Exception ignored) { log.warn("预警附件事务回滚后的文件清理失败"); }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
// 上传文件
|
|
// 上传文件
|
|
|
String fileName = file.getOriginalFilename();
|
|
String fileName = file.getOriginalFilename();
|
|
|
if (fileName == null || fileName.trim().isEmpty()) {
|
|
if (fileName == null || fileName.trim().isEmpty()) {
|
|
@@ -187,14 +243,19 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
// 保存附件信息
|
|
// 保存附件信息
|
|
|
WarningAttachment attachment = new WarningAttachment();
|
|
WarningAttachment attachment = new WarningAttachment();
|
|
|
attachment.setWarningId(warningId);
|
|
attachment.setWarningId(warningId);
|
|
|
- attachment.setAttachmentName(("PROCESS".equals(stage) ? "[处理反馈] " : "[预警报告] ") + fileName);
|
|
|
|
|
|
|
+ attachment.setDisposalId(disposalId);
|
|
|
|
|
+ attachment.setAttachmentStage(stage);
|
|
|
|
|
+ attachment.setCreateBy(currentUser());
|
|
|
|
|
+ attachment.setAttachmentName(("PROCESS".equals(stage) ? "[处理反馈] " : "SUPERVISION".equals(stage) ? "[督办附件] " : "[预警报告] ") + fileName);
|
|
|
attachment.setAttachmentUrl(path);
|
|
attachment.setAttachmentUrl(path);
|
|
|
// 部分 MIME(如 vnd.openxmlformats-officedocument.*)长度超过 64,写入前按 DB 列宽截断兜底
|
|
// 部分 MIME(如 vnd.openxmlformats-officedocument.*)长度超过 64,写入前按 DB 列宽截断兜底
|
|
|
attachment.setAttachmentType(truncateAttachmentType(file.getContentType()));
|
|
attachment.setAttachmentType(truncateAttachmentType(file.getContentType()));
|
|
|
attachment.setAttachmentSize(file.getSize());
|
|
attachment.setAttachmentSize(file.getSize());
|
|
|
attachment.setCreateTime(LocalDateTime.now());
|
|
attachment.setCreateTime(LocalDateTime.now());
|
|
|
warningAttachmentMapper.insert(attachment);
|
|
warningAttachmentMapper.insert(attachment);
|
|
|
|
|
+ saved.add(attachment);
|
|
|
}
|
|
}
|
|
|
|
|
+ return saved;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException("附件保存失败", e);
|
|
throw new RuntimeException("附件保存失败", e);
|
|
|
}
|
|
}
|
|
@@ -203,6 +264,16 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean updateWarning(EarlyWarning warning, List<String> alarmIds, List<MultipartFile> files) {
|
|
public boolean updateWarning(EarlyWarning warning, List<String> alarmIds, List<MultipartFile> files) {
|
|
|
|
|
+ EarlyWarning existing = earlyWarningMapper.selectForUpdate(warning.getWarningId());
|
|
|
|
|
+ WarningWorkflow.requireState(existing, "修改草稿", WarningWorkflow.DRAFT);
|
|
|
|
|
+ warning.setStatus(existing.getStatus());
|
|
|
|
|
+ warning.setWarningNo(existing.getWarningNo());
|
|
|
|
|
+ warning.setCreateBy(existing.getCreateBy());
|
|
|
|
|
+ warning.setCreateTime(existing.getCreateTime());
|
|
|
|
|
+ warning.setPublisher(existing.getPublisher());
|
|
|
|
|
+ warning.setPublishTime(existing.getPublishTime());
|
|
|
|
|
+ warning.setProcessInstanceId(existing.getProcessInstanceId());
|
|
|
|
|
+ warning.setUpdateBy(currentUser());
|
|
|
warning.setUpdateTime(LocalDateTime.now());
|
|
warning.setUpdateTime(LocalDateTime.now());
|
|
|
boolean result = updateById(warning);
|
|
boolean result = updateById(warning);
|
|
|
if (result) {
|
|
if (result) {
|
|
@@ -219,6 +290,7 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean deleteWarning(String warningId) {
|
|
public boolean deleteWarning(String warningId) {
|
|
|
|
|
+ WarningWorkflow.requireState(earlyWarningMapper.selectForUpdate(warningId), "删除", WarningWorkflow.DRAFT);
|
|
|
// 先查询附件列表,删除物理文件
|
|
// 先查询附件列表,删除物理文件
|
|
|
List<WarningAttachment> attachments = warningAttachmentMapper.selectList(
|
|
List<WarningAttachment> attachments = warningAttachmentMapper.selectList(
|
|
|
new LambdaQueryWrapper<WarningAttachment>()
|
|
new LambdaQueryWrapper<WarningAttachment>()
|
|
@@ -279,14 +351,27 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean publishWarning(String warningId, String requestedHandler) {
|
|
public boolean publishWarning(String warningId, String requestedHandler) {
|
|
|
- EarlyWarning warning = getById(warningId);
|
|
|
|
|
- if (warning == null) return false;
|
|
|
|
|
|
|
+ return publishWarning(warningId, requestedHandler, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public boolean publishWarning(String warningId, String requestedHandler, String requestedReviewer) {
|
|
|
|
|
+ EarlyWarning warning = earlyWarningMapper.selectForUpdate(warningId);
|
|
|
|
|
+ WarningWorkflow.requireState(warning, "发布", WarningWorkflow.DRAFT);
|
|
|
|
|
|
|
|
String assignee = isBlank(requestedHandler) ? warning.getHandler() : requestedHandler.trim();
|
|
String assignee = isBlank(requestedHandler) ? warning.getHandler() : requestedHandler.trim();
|
|
|
// 发布不能再自动指派当前登录用户,处置人必须由发布人明确选择或提前保存。
|
|
// 发布不能再自动指派当前登录用户,处置人必须由发布人明确选择或提前保存。
|
|
|
- if (isBlank(assignee)) return false;
|
|
|
|
|
|
|
+ requireActiveUser(assignee, "处置人");
|
|
|
|
|
+ String reviewer = isBlank(requestedReviewer)
|
|
|
|
|
+ ? (isBlank(warning.getReviewer()) ? currentUser() : warning.getReviewer().trim())
|
|
|
|
|
+ : requestedReviewer.trim();
|
|
|
|
|
+ requireActiveUser(reviewer, "核查人");
|
|
|
|
|
+ warning.setReviewer(reviewer);
|
|
|
|
|
|
|
|
warning.setStatus("PENDING");
|
|
warning.setStatus("PENDING");
|
|
|
|
|
+ warning.setPublisher(currentUser());
|
|
|
|
|
+ warning.setUpdateBy(currentUser());
|
|
|
warning.setPublishTime(LocalDateTime.now());
|
|
warning.setPublishTime(LocalDateTime.now());
|
|
|
warning.setUpdateTime(LocalDateTime.now());
|
|
warning.setUpdateTime(LocalDateTime.now());
|
|
|
warning.setHandler(assignee);
|
|
warning.setHandler(assignee);
|
|
@@ -294,8 +379,9 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
boolean result = updateById(warning);
|
|
boolean result = updateById(warning);
|
|
|
|
|
|
|
|
if (result) {
|
|
if (result) {
|
|
|
- addDisposalRecord(warningId, "RELEASE", null, null, assignee, "系统发布预警信息");
|
|
|
|
|
- createTodo(warningId, assignee, "待办预警", "TODO");
|
|
|
|
|
|
|
+ addDisposalRecord(warningId, "RELEASE", null, null, currentUser(),
|
|
|
|
|
+ "发布预警;处置人:" + assignee + ";核查人:" + reviewer);
|
|
|
|
|
+ createTodo(warningId, assignee, "接收并处置预警", "TODO", "HANDLE");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
@@ -304,44 +390,54 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean confirmWarning(String warningId, String assignedUser, String confirmRemark) {
|
|
public boolean confirmWarning(String warningId, String assignedUser, String confirmRemark) {
|
|
|
- EarlyWarning warning = getById(warningId);
|
|
|
|
|
- if (warning == null || "CLOSED".equals(warning.getStatus())) return false;
|
|
|
|
|
|
|
+ EarlyWarning warning = earlyWarningMapper.selectForUpdate(warningId);
|
|
|
|
|
+ WarningWorkflow.requireState(warning, "接收", WarningWorkflow.PENDING);
|
|
|
|
|
+ requireHandler(warning);
|
|
|
|
|
+ if (!isBlank(assignedUser) && !Objects.equals(warning.getHandler(), assignedUser.trim())) {
|
|
|
|
|
+ throw new ServiceException("接收时不能变更发布人指定的处置人");
|
|
|
|
|
+ }
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
String operator = currentUser();
|
|
String operator = currentUser();
|
|
|
- String assignee = isBlank(assignedUser) ? warning.getHandler() : assignedUser;
|
|
|
|
|
- if (isBlank(assignee)) assignee = operator;
|
|
|
|
|
- warning.setStatus("PROCESSING");
|
|
|
|
|
|
|
+ String assignee = warning.getHandler();
|
|
|
|
|
+ // 接收预警:待办(PENDING) → 已接收(RECEIVED)
|
|
|
|
|
+ warning.setStatus("RECEIVED");
|
|
|
warning.setHandler(assignee);
|
|
warning.setHandler(assignee);
|
|
|
- warning.setPublishTime(warning.getPublishTime() == null ? now : warning.getPublishTime());
|
|
|
|
|
warning.setUpdateTime(now);
|
|
warning.setUpdateTime(now);
|
|
|
if (!updateById(warning)) return false;
|
|
if (!updateById(warning)) return false;
|
|
|
- addDisposalRecord(warningId, "CONFIRM", null, null, operator, confirmRemark);
|
|
|
|
|
- createTodo(warningId, assignee, "预警处理", "TODO", "PROCESS");
|
|
|
|
|
|
|
+ addDisposalRecord(warningId, "RECEIVE", null, null, operator, confirmRemark);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public boolean misreportWarning(String warningId, String reason) {
|
|
|
|
|
- EarlyWarning warning = getById(warningId);
|
|
|
|
|
- if (warning == null) return false;
|
|
|
|
|
|
|
+ public boolean startWarningProcess(String warningId, String remark) {
|
|
|
|
|
+ EarlyWarning warning = earlyWarningMapper.selectForUpdate(warningId);
|
|
|
|
|
+ WarningWorkflow.requireState(warning, "开始处置", WarningWorkflow.RECEIVED);
|
|
|
|
|
+ requireHandler(warning);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
String operator = currentUser();
|
|
String operator = currentUser();
|
|
|
- warning.setStatus("CLOSED");
|
|
|
|
|
- warning.setRemark(reason);
|
|
|
|
|
|
|
+ // 开始处置:已接收(RECEIVED) → 处置中(PROCESSING)
|
|
|
|
|
+ warning.setStatus("PROCESSING");
|
|
|
warning.setUpdateTime(now);
|
|
warning.setUpdateTime(now);
|
|
|
if (!updateById(warning)) return false;
|
|
if (!updateById(warning)) return false;
|
|
|
- addDisposalRecord(warningId, "MISREPORT", null, null, operator, reason);
|
|
|
|
|
- completeTodo(warningId);
|
|
|
|
|
- generateArchive(warningId);
|
|
|
|
|
|
|
+ addDisposalRecord(warningId, "START", null, null, operator, remark);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public boolean misreportWarning(String warningId, String reason) {
|
|
|
|
|
+ if (isBlank(reason)) throw new ServiceException("请填写误报核查依据");
|
|
|
|
|
+ return clearWarning(warningId, "误报核查:" + reason.trim());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean submitWarningProcess(String warningId, String processContent, List<MultipartFile> files) {
|
|
public boolean submitWarningProcess(String warningId, String processContent, List<MultipartFile> files) {
|
|
|
- EarlyWarning warning = getById(warningId);
|
|
|
|
|
- if (warning == null || "CLOSED".equals(warning.getStatus())) return false;
|
|
|
|
|
|
|
+ EarlyWarning warning = earlyWarningMapper.selectForUpdate(warningId);
|
|
|
|
|
+ WarningWorkflow.requireState(warning, "提交处置结果", WarningWorkflow.PROCESSING);
|
|
|
|
|
+ requireHandler(warning);
|
|
|
|
|
+ if (isBlank(processContent)) throw new ServiceException("请填写现场处置结果");
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
String operator = currentUser();
|
|
String operator = currentUser();
|
|
|
warning.setStatus("HANDLED");
|
|
warning.setStatus("HANDLED");
|
|
@@ -359,14 +455,17 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
saveAttachments(warningId, disposal.getDisposalId(), "PROCESS", files);
|
|
saveAttachments(warningId, disposal.getDisposalId(), "PROCESS", files);
|
|
|
}
|
|
}
|
|
|
completeTodo(warningId);
|
|
completeTodo(warningId);
|
|
|
|
|
+ createTodo(warningId, reviewerOf(warning), "核查处置结果", "TODO", "REVIEW");
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean clearWarning(String warningId, String clearRemark) {
|
|
public boolean clearWarning(String warningId, String clearRemark) {
|
|
|
- EarlyWarning warning = getById(warningId);
|
|
|
|
|
- if (warning == null || "CLOSED".equals(warning.getStatus())) return false;
|
|
|
|
|
|
|
+ EarlyWarning warning = earlyWarningMapper.selectForUpdate(warningId);
|
|
|
|
|
+ WarningWorkflow.requireState(warning, "核查解除", WarningWorkflow.HANDLED);
|
|
|
|
|
+ requireReviewer(warning);
|
|
|
|
|
+ if (isBlank(clearRemark)) throw new ServiceException("请填写核查通过和解除依据");
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
String operator = currentUser();
|
|
String operator = currentUser();
|
|
|
warning.setStatus("CLOSED");
|
|
warning.setStatus("CLOSED");
|
|
@@ -385,23 +484,80 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String currentUser() {
|
|
private String currentUser() {
|
|
|
- try {
|
|
|
|
|
- String username = SecurityUtils.getUsername();
|
|
|
|
|
- return isBlank(username) ? "system" : username;
|
|
|
|
|
- } catch (Exception ex) {
|
|
|
|
|
- return "system";
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ String username = SecurityUtils.getUsername();
|
|
|
|
|
+ if (isBlank(username)) throw new ServiceException("请登录后操作预警");
|
|
|
|
|
+ return username;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private boolean isBlank(String value) {
|
|
private boolean isBlank(String value) {
|
|
|
return value == null || value.trim().isEmpty();
|
|
return value == null || value.trim().isEmpty();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void requireHandler(EarlyWarning warning) {
|
|
|
|
|
+ if (!Objects.equals(warning.getHandler(), currentUser())) {
|
|
|
|
|
+ throw new ServiceException("只有发布时指定的处置人可以接收和提交处置结果");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String reviewerOf(EarlyWarning warning) {
|
|
|
|
|
+ return isBlank(warning.getReviewer()) ? warning.getPublisher() : warning.getReviewer();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void requireReviewer(EarlyWarning warning) {
|
|
|
|
|
+ if (!Objects.equals(reviewerOf(warning), currentUser())) {
|
|
|
|
|
+ throw new ServiceException("只有指定核查人可以解除或退回预警");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private SysUser requireActiveUser(String username, String role) {
|
|
|
|
|
+ if (isBlank(username)) throw new ServiceException("请选择" + role);
|
|
|
|
|
+ SysUser user = sysUserMapper.selectUserByUserName(username.trim());
|
|
|
|
|
+ if (user == null || !"0".equals(user.getStatus()) || !"0".equals(user.getDelFlag())) {
|
|
|
|
|
+ throw new ServiceException(role + "必须是有效且启用的系统用户");
|
|
|
|
|
+ }
|
|
|
|
|
+ return user;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void addWorkflowActions(Map<String, Object> row) {
|
|
|
|
|
+ String state = Objects.toString(row.get("status"), "");
|
|
|
|
|
+ String username = currentUser();
|
|
|
|
|
+ String reviewer = Objects.toString(row.get("reviewer"), "");
|
|
|
|
|
+ if (isBlank(reviewer)) reviewer = Objects.toString(row.get("publisher"), "");
|
|
|
|
|
+ List<String> actions = new ArrayList<>(WarningWorkflow.actions(state));
|
|
|
|
|
+ if (!Objects.equals(username, row.get("handler"))) {
|
|
|
|
|
+ actions.removeAll(Arrays.asList("RECEIVE", "START", "HANDLE"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!username.equals(reviewer)) actions.removeAll(Arrays.asList("CLEAR", "RETURN"));
|
|
|
|
|
+ if ("DONE".equals(row.get("todo_type"))) actions.clear();
|
|
|
|
|
+ row.put("availableActions", actions);
|
|
|
|
|
+ row.put("statusLabel", WarningWorkflow.label(state));
|
|
|
|
|
+ row.put("reviewer", reviewer);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public boolean uploadReport(String warningId, List<MultipartFile> files) {
|
|
|
|
|
+ EarlyWarning warning = earlyWarningMapper.selectForUpdate(warningId);
|
|
|
|
|
+ WarningWorkflow.requireState(warning, "上传报告", WarningWorkflow.DRAFT, WarningWorkflow.PENDING,
|
|
|
|
|
+ WarningWorkflow.RECEIVED, WarningWorkflow.PROCESSING, WarningWorkflow.HANDLED);
|
|
|
|
|
+ if (files == null || files.isEmpty()) throw new ServiceException("请选择预警报告文件");
|
|
|
|
|
+ saveAttachments(warningId, null, "REPORT", files);
|
|
|
|
|
+ addDisposalRecord(warningId, "REPORT", null, null, currentUser(), "上传预警报告,共" + files.size() + "个附件");
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean upgradeWarning(String warningId, String newLevel, String disposalContent) {
|
|
public boolean upgradeWarning(String warningId, String newLevel, String disposalContent) {
|
|
|
- EarlyWarning warning = getById(warningId);
|
|
|
|
|
- if (warning == null) return false;
|
|
|
|
|
|
|
+ EarlyWarning warning = earlyWarningMapper.selectForUpdate(warningId);
|
|
|
|
|
+ WarningWorkflow.requireState(warning, "升级", WarningWorkflow.PENDING, WarningWorkflow.RECEIVED,
|
|
|
|
|
+ WarningWorkflow.PROCESSING, WarningWorkflow.HANDLED);
|
|
|
|
|
+ if (isBlank(disposalContent)) throw new ServiceException("请填写会商研判意见和升级依据");
|
|
|
|
|
+ if (newLevel == null || !newLevel.matches("[1-4]")
|
|
|
|
|
+ || warning.getWarningLevel() == null || !warning.getWarningLevel().matches("[1-4]")
|
|
|
|
|
+ || Integer.parseInt(newLevel) >= Integer.parseInt(warning.getWarningLevel())) {
|
|
|
|
|
+ throw new ServiceException("只能升级至更严重的级别,一级为最高级");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
String oldLevel = warning.getWarningLevel();
|
|
String oldLevel = warning.getWarningLevel();
|
|
|
warning.setWarningLevel(newLevel);
|
|
warning.setWarningLevel(newLevel);
|
|
@@ -409,7 +565,7 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
|
|
|
|
|
boolean result = updateById(warning);
|
|
boolean result = updateById(warning);
|
|
|
if (result) {
|
|
if (result) {
|
|
|
- addDisposalRecord(warningId, "UPGRADE", oldLevel, newLevel, warning.getHandler(), disposalContent);
|
|
|
|
|
|
|
+ addDisposalRecord(warningId, "UPGRADE", oldLevel, newLevel, currentUser(), disposalContent);
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
@@ -417,80 +573,112 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean resolveWarning(String warningId, String disposalContent) {
|
|
public boolean resolveWarning(String warningId, String disposalContent) {
|
|
|
- EarlyWarning warning = getById(warningId);
|
|
|
|
|
- if (warning == null) return false;
|
|
|
|
|
-
|
|
|
|
|
- warning.setStatus("CLOSED");
|
|
|
|
|
- warning.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
-
|
|
|
|
|
- boolean result = updateById(warning);
|
|
|
|
|
- if (result) {
|
|
|
|
|
- addDisposalRecord(warningId, "RESOLVE", null, null, warning.getHandler(), disposalContent);
|
|
|
|
|
- completeTodo(warningId);
|
|
|
|
|
-
|
|
|
|
|
- // 解除预警时自动创建归档
|
|
|
|
|
- Map<String, Object> warningDetail = earlyWarningMapper.selectWarningDetail(warningId);
|
|
|
|
|
- if (warningDetail != null) {
|
|
|
|
|
- generateElectronicArchive(warningDetail);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return result;
|
|
|
|
|
|
|
+ return clearWarning(warningId, disposalContent);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean returnWarning(String warningId, String disposalContent) {
|
|
public boolean returnWarning(String warningId, String disposalContent) {
|
|
|
- EarlyWarning warning = getById(warningId);
|
|
|
|
|
- if (warning == null) return false;
|
|
|
|
|
-
|
|
|
|
|
- warning.setStatus("DRAFT");
|
|
|
|
|
|
|
+ EarlyWarning warning = earlyWarningMapper.selectForUpdate(warningId);
|
|
|
|
|
+ WarningWorkflow.requireState(warning, "退回重办", WarningWorkflow.HANDLED);
|
|
|
|
|
+ requireReviewer(warning);
|
|
|
|
|
+ if (isBlank(disposalContent)) throw new ServiceException("请填写退回原因和重新处置要求");
|
|
|
|
|
+ requireActiveUser(warning.getHandler(), "原处置人");
|
|
|
|
|
+ warning.setStatus("PROCESSING");
|
|
|
|
|
+ warning.setUpdateBy(currentUser());
|
|
|
warning.setUpdateTime(LocalDateTime.now());
|
|
warning.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
boolean result = updateById(warning);
|
|
boolean result = updateById(warning);
|
|
|
if (result) {
|
|
if (result) {
|
|
|
- addDisposalRecord(warningId, "RETURN", null, null, warning.getHandler(), disposalContent);
|
|
|
|
|
- // 退回后删除待办记录,因为直接回到草稿状态
|
|
|
|
|
- LambdaQueryWrapper<WarningTodo> todoWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- todoWrapper.eq(WarningTodo::getWarningId, warningId);
|
|
|
|
|
- warningTodoMapper.delete(todoWrapper);
|
|
|
|
|
|
|
+ addDisposalRecord(warningId, "RETURN", null, null, currentUser(), disposalContent);
|
|
|
|
|
+ completeTodo(warningId);
|
|
|
|
|
+ createTodo(warningId, warning.getHandler(), "核查退回,重新处置", "TODO", "HANDLE");
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public boolean supervisionWarning(String warningId, String supervisionUser, String supervisionContent, String notificationType, String notificationContent, String attachmentUrl) {
|
|
|
|
|
|
|
+ public WarningSupervision supervisionWarning(String warningId, String supervisionUser, String supervisionContent, String notificationType, String notificationContent, MultipartFile attachment) {
|
|
|
|
|
+ EarlyWarning warning = earlyWarningMapper.selectForUpdate(warningId);
|
|
|
|
|
+ WarningWorkflow.requireState(warning, "督办",
|
|
|
|
|
+ WarningWorkflow.PENDING, WarningWorkflow.RECEIVED, WarningWorkflow.PROCESSING, WarningWorkflow.HANDLED);
|
|
|
|
|
+ if (isBlank(supervisionUser) || isBlank(supervisionContent)) throw new ServiceException("请填写督办人员和督办意见");
|
|
|
|
|
+ if (!"短信".equals(notificationType) && !"系统通知".equals(notificationType)) {
|
|
|
|
|
+ throw new ServiceException("督办通知方式仅支持短信或系统通知");
|
|
|
|
|
+ }
|
|
|
|
|
+ SysUser recipient = requireActiveUser(supervisionUser, "督办人员");
|
|
|
|
|
+ String message = isBlank(notificationContent) ? supervisionContent.trim() : notificationContent.trim();
|
|
|
|
|
+ if (message.length() > 180) throw new ServiceException("通知内容不能超过180字");
|
|
|
|
|
+ if (attachment != null) validateAttachment(attachment);
|
|
|
|
|
+ if ("短信".equals(notificationType)) {
|
|
|
|
|
+ if (isBlank(recipient.getPhonenumber())) throw new ServiceException("督办人员未配置手机号");
|
|
|
|
|
+ if (smsTemplateProvider.getIfAvailable() == null || isBlank(smsProperties.getSupervisionTemplateCode())) {
|
|
|
|
|
+ throw new ServiceException("督办短信服务或模板未配置");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
WarningSupervision supervision = new WarningSupervision();
|
|
WarningSupervision supervision = new WarningSupervision();
|
|
|
supervision.setWarningId(warningId);
|
|
supervision.setWarningId(warningId);
|
|
|
- supervision.setSupervisionUser(supervisionUser);
|
|
|
|
|
|
|
+ supervision.setSupervisionUser(recipient.getUserName());
|
|
|
supervision.setSupervisionContent(supervisionContent);
|
|
supervision.setSupervisionContent(supervisionContent);
|
|
|
supervision.setNotificationType(notificationType);
|
|
supervision.setNotificationType(notificationType);
|
|
|
- supervision.setNotificationContent(notificationContent);
|
|
|
|
|
- supervision.setAttachmentUrl(attachmentUrl);
|
|
|
|
|
|
|
+ supervision.setNotificationContent(message);
|
|
|
|
|
+ supervision.setNotificationStatus("系统通知".equals(notificationType) ? "SENT" : "PENDING");
|
|
|
supervision.setCreateBy(currentUser());
|
|
supervision.setCreateBy(currentUser());
|
|
|
supervision.setCreateTime(LocalDateTime.now());
|
|
supervision.setCreateTime(LocalDateTime.now());
|
|
|
- warningSupervisionMapper.insert(supervision);
|
|
|
|
|
WarningDisposal disposal = new WarningDisposal();
|
|
WarningDisposal disposal = new WarningDisposal();
|
|
|
disposal.setWarningId(warningId);
|
|
disposal.setWarningId(warningId);
|
|
|
disposal.setDisposalType("SUPERVISION");
|
|
disposal.setDisposalType("SUPERVISION");
|
|
|
- disposal.setDisposalUser(supervisionUser);
|
|
|
|
|
|
|
+ disposal.setDisposalUser(currentUser());
|
|
|
disposal.setDisposalContent(supervisionContent);
|
|
disposal.setDisposalContent(supervisionContent);
|
|
|
- disposal.setSupervisionUser(supervisionUser);
|
|
|
|
|
|
|
+ disposal.setSupervisionUser(recipient.getUserName());
|
|
|
disposal.setSupervisionContent(supervisionContent);
|
|
disposal.setSupervisionContent(supervisionContent);
|
|
|
disposal.setNotificationType(notificationType);
|
|
disposal.setNotificationType(notificationType);
|
|
|
disposal.setCreateTime(LocalDateTime.now());
|
|
disposal.setCreateTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
- return warningDisposalMapper.insert(disposal) > 0;
|
|
|
|
|
|
|
+ if (warningDisposalMapper.insert(disposal) <= 0) throw new ServiceException("督办保存失败");
|
|
|
|
|
+ if (attachment != null) {
|
|
|
|
|
+ List<WarningAttachment> files = saveAttachments(warningId, disposal.getDisposalId(), "SUPERVISION", Collections.singletonList(attachment));
|
|
|
|
|
+ supervision.setAttachmentUrl(files.get(0).getAttachmentUrl());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (warningSupervisionMapper.insert(supervision) <= 0) throw new ServiceException("督办保存失败");
|
|
|
|
|
+ if ("系统通知".equals(notificationType)) {
|
|
|
|
|
+ createTodo(warningId, recipient.getUserName(), message, "NOTICE", "NOTICE");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
|
|
|
|
+ @Override public void afterCommit() {
|
|
|
|
|
+ try { supervisionNotifier.send(supervision, recipient.getPhonenumber(), warning.getWarningName()); }
|
|
|
|
|
+ catch (Exception ignored) {
|
|
|
|
|
+ supervision.setNotificationStatus("FAILED");
|
|
|
|
|
+ supervision.setNotificationError("短信发送结果未能确认,请联系管理员核查,勿重复提交");
|
|
|
|
|
+ log.warn("督办短信发送结果保存失败,supervisionId={}", supervision.getSupervisionId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ return supervision;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean readNotification(String todoId) {
|
|
|
|
|
+ WarningTodo todo = warningTodoMapper.selectById(todoId);
|
|
|
|
|
+ if (todo == null || !"NOTICE".equals(todo.getTodoType())
|
|
|
|
|
+ || !Objects.equals(String.valueOf(SecurityUtils.getUserId()), todo.getUserId())) return false;
|
|
|
|
|
+ todo.setReadStatus("READ");
|
|
|
|
|
+ return warningTodoMapper.updateById(todo) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean addLeaderInstruction(String warningId, String leaderName, String instructionContent, String smsReceivers) {
|
|
public boolean addLeaderInstruction(String warningId, String leaderName, String instructionContent, String smsReceivers) {
|
|
|
|
|
+ WarningWorkflow.requireState(earlyWarningMapper.selectForUpdate(warningId), "添加领导批示",
|
|
|
|
|
+ WarningWorkflow.PENDING, WarningWorkflow.RECEIVED, WarningWorkflow.PROCESSING, WarningWorkflow.HANDLED);
|
|
|
|
|
+ if (isBlank(leaderName) || isBlank(instructionContent)) throw new ServiceException("请填写批示领导和批示内容");
|
|
|
WarningDisposal disposal = new WarningDisposal();
|
|
WarningDisposal disposal = new WarningDisposal();
|
|
|
disposal.setWarningId(warningId);
|
|
disposal.setWarningId(warningId);
|
|
|
disposal.setDisposalType("INSTRUCTION");
|
|
disposal.setDisposalType("INSTRUCTION");
|
|
|
- disposal.setDisposalUser(leaderName);
|
|
|
|
|
- disposal.setDisposalContent(instructionContent);
|
|
|
|
|
|
|
+ disposal.setDisposalUser(currentUser());
|
|
|
|
|
+ disposal.setDisposalContent("批示领导:" + leaderName + ";" + instructionContent);
|
|
|
disposal.setCreateTime(LocalDateTime.now());
|
|
disposal.setCreateTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
return warningDisposalMapper.insert(disposal) > 0;
|
|
return warningDisposalMapper.insert(disposal) > 0;
|
|
@@ -499,12 +687,15 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean linkAlarms(String warningId, List<String> alarmIds) {
|
|
public boolean linkAlarms(String warningId, List<String> alarmIds) {
|
|
|
|
|
+ WarningWorkflow.requireState(earlyWarningMapper.selectForUpdate(warningId), "关联报警",
|
|
|
|
|
+ WarningWorkflow.DRAFT, WarningWorkflow.PENDING, WarningWorkflow.RECEIVED, WarningWorkflow.PROCESSING, WarningWorkflow.HANDLED);
|
|
|
LambdaQueryWrapper<AlarmWarningRel> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<AlarmWarningRel> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(AlarmWarningRel::getWarningId, warningId);
|
|
wrapper.eq(AlarmWarningRel::getWarningId, warningId);
|
|
|
alarmWarningRelMapper.delete(wrapper);
|
|
alarmWarningRelMapper.delete(wrapper);
|
|
|
|
|
|
|
|
if (alarmIds != null && !alarmIds.isEmpty()) {
|
|
if (alarmIds != null && !alarmIds.isEmpty()) {
|
|
|
- for (String alarmId : alarmIds) {
|
|
|
|
|
|
|
+ for (String alarmId : new LinkedHashSet<>(alarmIds)) {
|
|
|
|
|
+ if (isBlank(alarmId)) throw new ServiceException("报警编号不能为空");
|
|
|
AlarmWarningRel rel = new AlarmWarningRel();
|
|
AlarmWarningRel rel = new AlarmWarningRel();
|
|
|
rel.setWarningId(warningId);
|
|
rel.setWarningId(warningId);
|
|
|
rel.setAlarmId(alarmId);
|
|
rel.setAlarmId(alarmId);
|
|
@@ -673,8 +864,11 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
map.put("attachmentType", attachment.getAttachmentType());
|
|
map.put("attachmentType", attachment.getAttachmentType());
|
|
|
map.put("attachmentSize", attachment.getAttachmentSize());
|
|
map.put("attachmentSize", attachment.getAttachmentSize());
|
|
|
map.put("createTime", attachment.getCreateTime());
|
|
map.put("createTime", attachment.getCreateTime());
|
|
|
|
|
+ map.put("createBy", attachment.getCreateBy());
|
|
|
|
|
+ map.put("disposalId", attachment.getDisposalId());
|
|
|
String attachmentName = attachment.getAttachmentName();
|
|
String attachmentName = attachment.getAttachmentName();
|
|
|
- map.put("attachmentStage", attachmentName != null && attachmentName.startsWith("[处理反馈]") ? "PROCESS" : "REPORT");
|
|
|
|
|
|
|
+ map.put("attachmentStage", isBlank(attachment.getAttachmentStage())
|
|
|
|
|
+ ? (attachmentName != null && attachmentName.startsWith("[处理反馈]") ? "PROCESS" : "REPORT") : attachment.getAttachmentStage());
|
|
|
result.add(map);
|
|
result.add(map);
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
@@ -690,10 +884,12 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void createTodo(String warningId, String userId, String taskName, String todoType, String actionType) {
|
|
private void createTodo(String warningId, String userId, String taskName, String todoType, String actionType) {
|
|
|
|
|
+ SysUser user = requireActiveUser(userId, "待办接收人");
|
|
|
WarningTodo todo = new WarningTodo();
|
|
WarningTodo todo = new WarningTodo();
|
|
|
todo.setWarningId(warningId);
|
|
todo.setWarningId(warningId);
|
|
|
- todo.setUserId(userId);
|
|
|
|
|
- todo.setUserName(userId);
|
|
|
|
|
|
|
+ todo.setUserId(String.valueOf(user.getUserId()));
|
|
|
|
|
+ todo.setUserName(user.getUserName());
|
|
|
|
|
+ todo.setActionType(actionType);
|
|
|
todo.setTodoType(todoType);
|
|
todo.setTodoType(todoType);
|
|
|
todo.setReadStatus("UNREAD");
|
|
todo.setReadStatus("UNREAD");
|
|
|
todo.setTaskName(taskName);
|
|
todo.setTaskName(taskName);
|
|
@@ -754,6 +950,11 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
private static final Map<String, String> DISPOSAL_TYPE_MAP = new HashMap<>();
|
|
private static final Map<String, String> DISPOSAL_TYPE_MAP = new HashMap<>();
|
|
|
static {
|
|
static {
|
|
|
DISPOSAL_TYPE_MAP.put("RELEASE", "发布预警");
|
|
DISPOSAL_TYPE_MAP.put("RELEASE", "发布预警");
|
|
|
|
|
+ DISPOSAL_TYPE_MAP.put("RECEIVE", "接收预警");
|
|
|
|
|
+ DISPOSAL_TYPE_MAP.put("START", "开始处置");
|
|
|
|
|
+ DISPOSAL_TYPE_MAP.put("HANDLE", "提交处置结果,待核查");
|
|
|
|
|
+ DISPOSAL_TYPE_MAP.put("CLEAR", "核查通过并解除");
|
|
|
|
|
+ DISPOSAL_TYPE_MAP.put("REPORT", "上传预警报告");
|
|
|
DISPOSAL_TYPE_MAP.put("UPGRADE", "升级预警");
|
|
DISPOSAL_TYPE_MAP.put("UPGRADE", "升级预警");
|
|
|
DISPOSAL_TYPE_MAP.put("RESOLVE", "解除预警");
|
|
DISPOSAL_TYPE_MAP.put("RESOLVE", "解除预警");
|
|
|
DISPOSAL_TYPE_MAP.put("RETURN", "退回重办");
|
|
DISPOSAL_TYPE_MAP.put("RETURN", "退回重办");
|
|
@@ -826,16 +1027,17 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
|
|
|
|
|
String status = warning.getStatus();
|
|
String status = warning.getStatus();
|
|
|
String currentStatus = "waiting";
|
|
String currentStatus = "waiting";
|
|
|
- if ("CLOSED".equals(status) || "HANDLED".equals(status)) {
|
|
|
|
|
|
|
+ if ("CLOSED".equals(status)) {
|
|
|
currentStatus = "completed";
|
|
currentStatus = "completed";
|
|
|
- } else if ("PROCESSING".equals(status) || "PENDING".equals(status) || "RELEASED".equals(status)) {
|
|
|
|
|
|
|
+ } else if (!"DRAFT".equals(status)) {
|
|
|
currentStatus = "active";
|
|
currentStatus = "active";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Map<String, Object> endNode = new HashMap<>();
|
|
Map<String, Object> endNode = new HashMap<>();
|
|
|
endNode.put("id", "end");
|
|
endNode.put("id", "end");
|
|
|
- endNode.put("name", "处置完成");
|
|
|
|
|
- endNode.put("type", "endEvent");
|
|
|
|
|
|
|
+ endNode.put("name", "CLOSED".equals(status) ? "核查解除,流程结束" : WarningWorkflow.label(status));
|
|
|
|
|
+ endNode.put("type", "CLOSED".equals(status) ? "endEvent" : "userTask");
|
|
|
|
|
+ endNode.put("disposalUser", "HANDLED".equals(status) ? reviewerOf(warning) : warning.getHandler());
|
|
|
endNode.put("x", x);
|
|
endNode.put("x", x);
|
|
|
endNode.put("y", 150);
|
|
endNode.put("y", 150);
|
|
|
endNode.put("status", currentStatus);
|
|
endNode.put("status", currentStatus);
|
|
@@ -881,8 +1083,10 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
|
|
|
result.put("supervisionUser", disposal.getSupervisionUser());
|
|
result.put("supervisionUser", disposal.getSupervisionUser());
|
|
|
result.put("supervisionContent", disposal.getSupervisionContent());
|
|
result.put("supervisionContent", disposal.getSupervisionContent());
|
|
|
result.put("notificationType", disposal.getNotificationType());
|
|
result.put("notificationType", disposal.getNotificationType());
|
|
|
- result.put("createTime", disposal.getCreateTime() != null ?
|
|
|
|
|
|
|
+ result.put("createTime", disposal.getCreateTime() != null ?
|
|
|
disposal.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null);
|
|
disposal.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null);
|
|
|
|
|
+ result.put("attachmentList", warningAttachmentMapper.selectList(
|
|
|
|
|
+ new LambdaQueryWrapper<WarningAttachment>().eq(WarningAttachment::getDisposalId, disposalId)));
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|