15 changed files with 931 additions and 44 deletions
@ -0,0 +1,82 @@
|
||||
package com.biutag.supervision.controller.warning; |
||||
|
||||
import com.biutag.supervision.pojo.Result; |
||||
import com.biutag.supervision.pojo.entity.report.ReportFlow; |
||||
import com.biutag.supervision.pojo.entity.report.ReportProject; |
||||
import com.biutag.supervision.pojo.param.Report.FlowQueryParam; |
||||
import com.biutag.supervision.pojo.param.Warning.CompileQueryParam; |
||||
import com.biutag.supervision.pojo.request.warning.*; |
||||
import com.biutag.supervision.pojo.vo.warning.WarningBusinessVo; |
||||
import com.biutag.supervision.service.Warning.WarningBusinessService; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 预警业务控制器 |
||||
*/ |
||||
@Tag(name = "预警业务") |
||||
@RestController |
||||
@RequestMapping("/warning/business") |
||||
@RequiredArgsConstructor |
||||
public class WarningBusinessController { |
||||
|
||||
private final WarningBusinessService businessService; |
||||
|
||||
@Operation(summary = "获取预警详情") |
||||
@GetMapping("/{reportId}") |
||||
public Result<WarningBusinessVo> getDetail(@PathVariable String reportId) { |
||||
return Result.success(businessService.getDetail(reportId)); |
||||
} |
||||
|
||||
@Operation(summary = "保存预警内容") |
||||
@PostMapping("/save") |
||||
public Result<Void> save(@RequestBody WarningSaveRequest request) { |
||||
businessService.save(request); |
||||
return Result.success(); |
||||
} |
||||
|
||||
@Operation(summary = "提交给领导审批") |
||||
@PostMapping("/submit") |
||||
public Result<Void> submit(@RequestBody WarningSubmitRequest request) { |
||||
businessService.submit(request); |
||||
return Result.success(); |
||||
} |
||||
|
||||
@Operation(summary = "直接结束预警") |
||||
@PostMapping("/end") |
||||
public Result<Void> end(@RequestBody WarningEndRequest request) { |
||||
businessService.end(request); |
||||
return Result.success(); |
||||
} |
||||
|
||||
@Operation(summary = "领导审批-驳回") |
||||
@PostMapping("/audit/reject") |
||||
public Result<Void> auditReject(@RequestBody WarningAuditRequest request) { |
||||
businessService.auditReject(request); |
||||
return Result.success(); |
||||
} |
||||
|
||||
@Operation(summary = "领导审批-通过(带问题数据分发)") |
||||
@PostMapping("/audit/pass/distribute") |
||||
public Result<Void> auditPassDistribute(@RequestBody FlowQueryParam queryParam) { |
||||
businessService.auditPassWithDistribute(queryParam); |
||||
return Result.success(); |
||||
} |
||||
|
||||
@Operation(summary = "获取预警审批记录") |
||||
@GetMapping("/flow/{reportId}") |
||||
public Result<List<ReportFlow>> getFlowList(@PathVariable String reportId) { |
||||
return Result.success(businessService.getFlowList(reportId)); |
||||
} |
||||
|
||||
@Operation(summary = "预警项目列表(编译台账)") |
||||
@PostMapping("/compile/page") |
||||
public Result<IPage<ReportProject>> compilePage(@RequestBody CompileQueryParam param) { |
||||
return Result.success(businessService.compilePage(param)); |
||||
} |
||||
} |
||||
@ -0,0 +1,18 @@
|
||||
package com.biutag.supervision.pojo.param.Warning; |
||||
|
||||
import com.biutag.supervision.pojo.param.BasePage; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@Schema(description = "编译台账查询参数") |
||||
public class CompileQueryParam extends BasePage { |
||||
|
||||
@Schema(description = "项目名称(模糊查询)") |
||||
private String name; |
||||
|
||||
@Schema(description = "处理状态:已修复/未修复") |
||||
private String processingStatus; |
||||
} |
||||
@ -0,0 +1,33 @@
|
||||
package com.biutag.supervision.pojo.request.warning; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.biutag.supervision.aop.ParamChecked; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* 预警审批请求 |
||||
*/ |
||||
@Data |
||||
@Schema(description = "预警审批请求") |
||||
public class WarningAuditRequest implements ParamChecked { |
||||
|
||||
@Schema(description = "流程id") |
||||
private String flowId; |
||||
|
||||
@Schema(description = "项目id") |
||||
private String reportId; |
||||
|
||||
@Schema(description = "审批意见") |
||||
private String approverMessage; |
||||
|
||||
@Override |
||||
public void check() { |
||||
if (StrUtil.isBlank(flowId)) { |
||||
throw new IllegalArgumentException("流程id不能为空"); |
||||
} |
||||
if (StrUtil.isBlank(reportId)) { |
||||
throw new IllegalArgumentException("项目id不能为空"); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,42 @@
|
||||
package com.biutag.supervision.pojo.request.warning; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.biutag.supervision.aop.ParamChecked; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 预警保存请求 |
||||
*/ |
||||
@Data |
||||
@Schema(description = "预警保存请求") |
||||
public class WarningSaveRequest implements ParamChecked { |
||||
|
||||
@Schema(description = "项目id") |
||||
private String reportId; |
||||
|
||||
@Schema(description = "预警内容列表") |
||||
private List<WarningContentItem> contents; |
||||
|
||||
@Data |
||||
@Schema(description = "预警内容项") |
||||
public static class WarningContentItem { |
||||
@Schema(description = "类型") |
||||
private String type; |
||||
@Schema(description = "标题") |
||||
private String title; |
||||
@Schema(description = "内容") |
||||
private String content; |
||||
@Schema(description = "问题详情") |
||||
private String remark; |
||||
} |
||||
|
||||
@Override |
||||
public void check() { |
||||
if (StrUtil.isBlank(reportId)) { |
||||
throw new IllegalArgumentException("项目id不能为空"); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,36 @@
|
||||
package com.biutag.supervision.pojo.request.warning; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.biutag.supervision.aop.ParamChecked; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* 预警提交请求(提交给领导) |
||||
* 预警监督人员和预警监督时间由后端通过 UserContextHolder 自动获取 |
||||
*/ |
||||
@Data |
||||
@Schema(description = "预警提交请求") |
||||
public class WarningSubmitRequest implements ParamChecked { |
||||
|
||||
@Schema(description = "领导ID") |
||||
private String approverId; |
||||
|
||||
@Schema(description = "项目id") |
||||
private String reportId; |
||||
|
||||
@Schema(description = "领导名字") |
||||
private String approver; |
||||
|
||||
@Override |
||||
public void check() { |
||||
if (StrUtil.isBlank(approverId)) { |
||||
throw new IllegalArgumentException("领导ID不能为空"); |
||||
} |
||||
|
||||
if (StrUtil.isBlank(reportId)) { |
||||
throw new IllegalArgumentException("项目ID不能为空"); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,27 @@
|
||||
package com.biutag.supervision.pojo.vo.warning; |
||||
|
||||
import com.biutag.supervision.pojo.entity.report.ReportFlow; |
||||
import com.biutag.supervision.pojo.entity.report.ReportProject; |
||||
import com.biutag.supervision.pojo.entity.warning.WarningContent; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 预警业务详情VO |
||||
*/ |
||||
@Data |
||||
@Schema(description = "预警业务详情VO") |
||||
public class WarningBusinessVo { |
||||
|
||||
@Schema(description = "项目信息") |
||||
private ReportProject reportProject; |
||||
|
||||
@Schema(description = "预警内容列表") |
||||
private List<WarningContent> contents; |
||||
|
||||
@Schema(description = "审批记录列表") |
||||
private List<ReportFlow> flowList; |
||||
|
||||
} |
||||
@ -0,0 +1,57 @@
|
||||
package com.biutag.supervision.service.Warning; |
||||
|
||||
import com.biutag.supervision.pojo.entity.report.ReportFlow; |
||||
import com.biutag.supervision.pojo.entity.report.ReportProject; |
||||
import com.biutag.supervision.pojo.param.Report.FlowQueryParam; |
||||
import com.biutag.supervision.pojo.param.Warning.CompileQueryParam; |
||||
import com.biutag.supervision.pojo.request.warning.*; |
||||
import com.biutag.supervision.pojo.vo.warning.WarningBusinessVo; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 预警业务服务接口 |
||||
*/ |
||||
public interface WarningBusinessService { |
||||
|
||||
/** |
||||
* 获取预警详情 |
||||
*/ |
||||
WarningBusinessVo getDetail(String reportId); |
||||
|
||||
/** |
||||
* 保存预警内容 |
||||
*/ |
||||
void save(WarningSaveRequest request); |
||||
|
||||
/** |
||||
* 提交给领导审批 |
||||
*/ |
||||
void submit(WarningSubmitRequest request); |
||||
|
||||
/** |
||||
* 直接结束预警 |
||||
*/ |
||||
void end(WarningEndRequest request); |
||||
|
||||
/** |
||||
* 领导审批-驳回 |
||||
*/ |
||||
void auditReject(WarningAuditRequest request); |
||||
|
||||
/** |
||||
* 领导审批-通过(带问题数据分发) |
||||
*/ |
||||
void auditPassWithDistribute(FlowQueryParam queryParam); |
||||
|
||||
/** |
||||
* 获取预警审批记录 |
||||
*/ |
||||
List<ReportFlow> getFlowList(String reportId); |
||||
|
||||
/** |
||||
* 预警项目列表(编译台账) |
||||
*/ |
||||
IPage<ReportProject> compilePage(CompileQueryParam param); |
||||
} |
||||
@ -0,0 +1,542 @@
|
||||
package com.biutag.supervision.service.Warning.impl; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.biutag.supervision.common.UserContextHolder; |
||||
import com.biutag.supervision.constants.enums.*; |
||||
import com.biutag.supervision.mapper.InformMessageMapper; |
||||
import com.biutag.supervision.mapper.Negative.NegativeMapper; |
||||
import com.biutag.supervision.mapper.Report.ReportFlowMapper; |
||||
import com.biutag.supervision.mapper.Report.ReportProjectMapper; |
||||
import com.biutag.supervision.mapper.Warning.WarningContentMapper; |
||||
import com.biutag.supervision.pojo.entity.InformMessage; |
||||
import com.biutag.supervision.pojo.entity.SupDepart; |
||||
import com.biutag.supervision.pojo.entity.negative.DataDataPetitionComplainDistribute; |
||||
import com.biutag.supervision.pojo.entity.negative.Negative; |
||||
import com.biutag.supervision.pojo.entity.report.ReportFlow; |
||||
import com.biutag.supervision.pojo.entity.report.ReportProject; |
||||
import com.biutag.supervision.pojo.entity.warning.WarningContent; |
||||
import com.biutag.supervision.pojo.entity.warning.WarningRecord; |
||||
import com.biutag.supervision.pojo.enums.FlowStateEnum; |
||||
import com.biutag.supervision.pojo.enums.FlowWarningEnum; |
||||
import com.biutag.supervision.pojo.model.UserAuth; |
||||
import com.biutag.supervision.pojo.model.negative.NegativeDto; |
||||
import com.biutag.supervision.pojo.param.Report.FlowQueryParam; |
||||
import com.biutag.supervision.pojo.param.Warning.CompileQueryParam; |
||||
import com.biutag.supervision.pojo.request.warning.*; |
||||
import com.biutag.supervision.pojo.vo.warning.WarningBusinessVo; |
||||
import com.biutag.supervision.service.Negative.NegativeService; |
||||
import com.biutag.supervision.service.Negative.NegativeThingFileService; |
||||
import com.biutag.supervision.service.Negative.NegativeWorkService; |
||||
import com.biutag.supervision.service.SupDepartService; |
||||
import com.biutag.supervision.service.SupDictDataTwoService; |
||||
import com.biutag.supervision.service.Warning.WarningBusinessService; |
||||
import com.biutag.supervision.service.Warning.WarningRecordService; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import lombok.RequiredArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.text.SimpleDateFormat; |
||||
import java.time.LocalDateTime; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 预警业务服务实现 |
||||
*/ |
||||
@Slf4j |
||||
@Service |
||||
@RequiredArgsConstructor |
||||
public class WarningBusinessServiceImpl implements WarningBusinessService { |
||||
|
||||
private final ReportProjectMapper projectMapper; |
||||
private final ReportFlowMapper flowMapper; |
||||
private final WarningContentMapper contentMapper; |
||||
private final InformMessageMapper informMessageMapper; |
||||
private final WarningRecordService warningRecordService; |
||||
private final ReportProjectMapper reportProjectMapper; |
||||
private final SupDepartService departService; |
||||
private final WarningContentMapper warningContentMapper; |
||||
private final NegativeService negativeService; |
||||
private final NegativeMapper negativeMapper; |
||||
|
||||
@Override |
||||
public WarningBusinessVo getDetail(String reportId) { |
||||
UserAuth user = UserContextHolder.getCurrentUser(); |
||||
WarningBusinessVo vo = new WarningBusinessVo(); |
||||
|
||||
// 查询项目信息
|
||||
ReportProject project = projectMapper.selectById(reportId); |
||||
vo.setReportProject(project); |
||||
|
||||
// 查询预警内容列表
|
||||
List<WarningContent> contents = contentMapper.selectList( |
||||
new LambdaQueryWrapper<WarningContent>() |
||||
.eq(WarningContent::getReportId, reportId) |
||||
.orderByAsc(WarningContent::getId) |
||||
); |
||||
vo.setContents(contents); |
||||
|
||||
// 查询审批记录
|
||||
List<ReportFlow> flows = flowMapper.selectList( |
||||
new LambdaQueryWrapper<ReportFlow>() |
||||
.eq(ReportFlow::getReportId, reportId) |
||||
.eq(ReportFlow::getType, "warning") |
||||
.orderByAsc(ReportFlow::getAreportTime) |
||||
); |
||||
vo.setFlowList(flows); |
||||
|
||||
|
||||
return vo; |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void save(WarningSaveRequest request) { |
||||
UserAuth user = UserContextHolder.getCurrentUser(); |
||||
|
||||
// 更新项目监督信息(由后端自动获取)
|
||||
ReportProject project = new ReportProject(); |
||||
project.setId(request.getReportId()); |
||||
project.setWarningSupervisionId(user.getUserName()); |
||||
project.setWarningSupervision(user.getNickName()); |
||||
project.setSupervisionTime(LocalDateTime.now()); |
||||
projectMapper.updateById(project); |
||||
|
||||
// 保存预警内容
|
||||
saveWarningContents(request.getReportId(), request.getContents()); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void submit(WarningSubmitRequest request) { |
||||
UserAuth user = UserContextHolder.getCurrentUser(); |
||||
|
||||
// 1. 更新项目监督信息(由后端自动获取)
|
||||
ReportProject project = new ReportProject(); |
||||
project.setId(request.getReportId()); |
||||
project.setWarningSupervisionId(user.getUserName()); |
||||
project.setWarningSupervision(user.getNickName()); |
||||
project.setSupervisionTime(LocalDateTime.now()); |
||||
project.setWarningState(WarningStateEnum.YTZ.getCode()); // 预警中
|
||||
projectMapper.updateById(project); |
||||
|
||||
// 2. 自动查找当前用户的有效 flow 并更新状态
|
||||
String currentFlowId = findCurrentUserValidFlowId(request.getReportId()); |
||||
if (currentFlowId != null) { |
||||
ReportFlow currentFlow = new ReportFlow(); |
||||
currentFlow.setId(currentFlowId); |
||||
currentFlow.setApproverState(FlowStateEnum.End.getLabel()); |
||||
currentFlow.setApproverTime(LocalDateTime.now()); |
||||
flowMapper.updateById(currentFlow); |
||||
} |
||||
|
||||
// 创建一条自己提交的记录
|
||||
ReportFlow selfFlow = new ReportFlow(); |
||||
selfFlow.setReportId(request.getReportId()); |
||||
selfFlow.setReportLink(FlowWarningEnum.toleader.getLabel()); |
||||
selfFlow.setReportCode(FlowWarningEnum.toleader.getValue()); |
||||
selfFlow.setAreportTime(LocalDateTime.now()); |
||||
selfFlow.setApproverState(FlowStateEnum.End.getLabel()); |
||||
selfFlow.setApprover(user.getNickName()); |
||||
selfFlow.setApproverId(user.getUserName()); |
||||
selfFlow.setType("warning"); |
||||
flowMapper.insert(selfFlow); |
||||
|
||||
// 3. 创建审批流程记录(提交给领导)
|
||||
ReportFlow flow = new ReportFlow(); |
||||
flow.setReportId(request.getReportId()); |
||||
flow.setReportLink(FlowWarningEnum.leader.getLabel()); |
||||
flow.setReportCode(FlowWarningEnum.leader.getValue()); |
||||
flow.setAreportTime(LocalDateTime.now()); |
||||
flow.setApproverState(FlowStateEnum.Start.getLabel()); |
||||
flow.setApprover(request.getApprover()); |
||||
flow.setApproverId(request.getApproverId()); |
||||
flow.setType("warning"); |
||||
flowMapper.insert(flow); |
||||
// System.out.println(1/0);
|
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void end(WarningEndRequest request) { |
||||
UserAuth user = UserContextHolder.getCurrentUser(); |
||||
|
||||
// 1. 更新项目状态(由后端自动获取预警监督人和时间)
|
||||
ReportProject project = new ReportProject(); |
||||
project.setId(request.getReportId()); |
||||
project.setWarningSupervisionId(user.getUserName()); |
||||
project.setWarningSupervision(user.getNickName()); |
||||
project.setSupervisionTime(LocalDateTime.now()); |
||||
project.setWarningState(WarningStateEnum.YWJ.getCode()); |
||||
projectMapper.updateById(project); |
||||
|
||||
// 2. 保存预警内容
|
||||
saveWarningContents(request.getReportId(), request.getContents()); |
||||
|
||||
// 3. 自动查找当前用户的有效 flow 并结束
|
||||
String currentFlowId = findCurrentUserValidFlowId(request.getReportId()); |
||||
if (currentFlowId != null) { |
||||
ReportFlow currentFlow = new ReportFlow(); |
||||
currentFlow.setId(currentFlowId); |
||||
currentFlow.setApproverState(FlowStateEnum.End.getLabel()); |
||||
currentFlow.setApproverTime(LocalDateTime.now()); |
||||
flowMapper.updateById(currentFlow); |
||||
} |
||||
|
||||
// 4. 创建结束流程记录
|
||||
ReportFlow endFlow = new ReportFlow(); |
||||
endFlow.setReportId(request.getReportId()); |
||||
endFlow.setReportLink(FlowWarningEnum.directend.getLabel()); |
||||
endFlow.setReportCode(FlowWarningEnum.directend.getValue()); |
||||
endFlow.setAreportTime(LocalDateTime.now()); |
||||
endFlow.setApprover(user.getNickName()); |
||||
endFlow.setApproverId(user.getUserName()); |
||||
endFlow.setApproverTime(LocalDateTime.now()); |
||||
endFlow.setApproverState(FlowStateEnum.End.getLabel()); |
||||
endFlow.setType("warning"); |
||||
flowMapper.insert(endFlow); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void auditReject(WarningAuditRequest request) { |
||||
// 1. 更新当前流程状态为驳回
|
||||
ReportFlow currentFlow = new ReportFlow(); |
||||
currentFlow.setId(request.getFlowId()); |
||||
currentFlow.setApproverState(FlowStateEnum.Reject.getLabel()); |
||||
currentFlow.setApproverTime(LocalDateTime.now()); |
||||
currentFlow.setApproverMessage(request.getApproverMessage()); |
||||
flowMapper.updateById(currentFlow); |
||||
|
||||
|
||||
ReportProject reportProject = projectMapper.selectById(request.getReportId()); |
||||
reportProject.setWarningState(WarningStateEnum.WYJ.getCode()); |
||||
int i = projectMapper.updateById(reportProject); |
||||
if (i > 1) { |
||||
throw new RuntimeException("操作错误"); |
||||
} |
||||
|
||||
// 2. 创建新的流程记录给预警人
|
||||
ReportFlow newFlow = new ReportFlow(); |
||||
newFlow.setReportId(request.getReportId()); |
||||
newFlow.setReportLink(FlowWarningEnum.state.getLabel()); |
||||
newFlow.setReportCode(FlowWarningEnum.state.getValue()); |
||||
newFlow.setAreportTime(LocalDateTime.now()); |
||||
newFlow.setApprover(reportProject.getWarningSupervision()); |
||||
newFlow.setApproverId(reportProject.getWarningSupervisionId()); |
||||
newFlow.setApproverState(FlowStateEnum.Start.getLabel()); |
||||
newFlow.setType("warning"); |
||||
flowMapper.insert(newFlow); |
||||
// System.out.println(1/0);
|
||||
} |
||||
|
||||
@Override |
||||
@DSTransactional(rollbackFor = Exception.class) |
||||
public void auditPassWithDistribute(FlowQueryParam queryParam) { |
||||
UserAuth user = UserContextHolder.getCurrentUser(); |
||||
String reportId = queryParam.getReportId(); |
||||
|
||||
// 0. 获取项目信息
|
||||
ReportProject project = projectMapper.selectById(reportId); |
||||
|
||||
// 0.1 通知报审人
|
||||
if ("1".equals(queryParam.getIsInform())) { |
||||
postInfoMessage(queryParam, project); |
||||
} |
||||
|
||||
// 1. 更新当前流程状态为通过
|
||||
if (StrUtil.isNotBlank(queryParam.getFlowId())) { |
||||
ReportFlow currentFlow = new ReportFlow(); |
||||
currentFlow.setId(queryParam.getFlowId()); |
||||
currentFlow.setApproverState(FlowStateEnum.End.getLabel()); |
||||
currentFlow.setApproverTime(LocalDateTime.now()); |
||||
currentFlow.setApproverMessage(queryParam.getMessage()); |
||||
currentFlow.setApprover(user.getNickName()); |
||||
currentFlow.setApproverId(user.getUserName()); |
||||
flowMapper.updateById(currentFlow); |
||||
} |
||||
|
||||
// 2. 生成问题数据
|
||||
if (queryParam.getData() != null) { |
||||
createNegativeDataForBusiness(reportId, queryParam.getData()); |
||||
} |
||||
|
||||
// 3. 更新项目状态为已预警监督
|
||||
projectMapper.update( |
||||
new LambdaUpdateWrapper<ReportProject>() |
||||
.eq(ReportProject::getId, reportId) |
||||
.set(ReportProject::getWarningState, WarningStateEnum.YWJ.getCode()) |
||||
.set(ReportProject::getSupervisionTime, LocalDateTime.now()) |
||||
); |
||||
|
||||
// 4. 创建结束流程记录
|
||||
// ReportFlow endFlow = new ReportFlow();
|
||||
// endFlow.setReportId(reportId);
|
||||
// endFlow.setReportLink(FlowWarningEnum.end.getLabel());
|
||||
// endFlow.setReportCode(FlowWarningEnum.end.getValue());
|
||||
// endFlow.setAreportTime(LocalDateTime.now());
|
||||
// endFlow.setApprover(user.getNickName());
|
||||
// endFlow.setApproverId(user.getUserName());
|
||||
// endFlow.setApproverTime(LocalDateTime.now());
|
||||
// endFlow.setApproverMessage(queryParam.getMessage());
|
||||
// endFlow.setApproverState(FlowStateEnum.End.getLabel());
|
||||
// endFlow.setType("warning");
|
||||
// flowMapper.insert(endFlow);
|
||||
// System.out.println(1/0);
|
||||
} |
||||
|
||||
/** |
||||
* 发送通知(通知报审人) |
||||
*/ |
||||
private void postInfoMessage(FlowQueryParam queryParam, ReportProject project) { |
||||
UserAuth user = UserContextHolder.getCurrentUser(); |
||||
// 获取预警记录信息
|
||||
WarningRecord record = warningRecordService.getOne( |
||||
new LambdaQueryWrapper<WarningRecord>() |
||||
.eq(WarningRecord::getReportId, project.getId()) |
||||
.orderByDesc(WarningRecord::getId) |
||||
.last("limit 1") |
||||
); |
||||
|
||||
String node = record != null ? record.getNode() : FlowWarningEnum.end.getLabel(); |
||||
String recipient = project.getApplicant(); |
||||
String recipientId = project.getApplicantId(); |
||||
|
||||
InformMessage informMessage = new InformMessage(); |
||||
informMessage.setReportId(queryParam.getReportId()); |
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
String newDate = sdf.format(new Date()); |
||||
informMessage.setCrtTime(LocalDateTime.now()); |
||||
informMessage.setNode(FlowWarningEnum.contains(node)); |
||||
informMessage.setMessage(project.getReportName() + "项目于" + newDate + "下发至数字督察平台,意见【" + queryParam.getMessage()+ "】"); |
||||
informMessage.setCrtUserId(StrUtil.isNotBlank(queryParam.getApproverId()) ? queryParam.getApproverId() : user.getUserId()); |
||||
informMessage.setCrtUser(StrUtil.isNotBlank(queryParam.getApprover()) ? queryParam.getApprover() : user.getNickName()); |
||||
informMessage.setRecipient(recipient); |
||||
informMessage.setRecipientId(recipientId); |
||||
informMessage.setFlowState(FlowStateEnum.End.getLabel()); |
||||
informMessageMapper.insert(informMessage); |
||||
} |
||||
|
||||
@Override |
||||
public List<ReportFlow> getFlowList(String reportId) { |
||||
return flowMapper.selectList( |
||||
new LambdaQueryWrapper<ReportFlow>() |
||||
.eq(ReportFlow::getReportId, reportId) |
||||
.eq(ReportFlow::getType, "warning") |
||||
.orderByAsc(ReportFlow::getAreportTime) |
||||
); |
||||
} |
||||
|
||||
@Override |
||||
public IPage<ReportProject> compilePage(CompileQueryParam param) { |
||||
// 1. 查询所有有 negativeId 的 ReportProject,收集 negativeId
|
||||
QueryWrapper<ReportProject> idWrapper = new QueryWrapper<>(); |
||||
idWrapper.isNotNull("negative_id"); |
||||
List<String> allNegativeIds = projectMapper.selectList(idWrapper).stream().map(ReportProject::getNegativeId).toList(); |
||||
|
||||
if (allNegativeIds.isEmpty()) { |
||||
return new Page<>(param.getCurrent(), param.getSize(), 0); |
||||
} |
||||
|
||||
// 2. 批量查询 Negative,获取所有状态
|
||||
LambdaQueryWrapper<Negative> allNegativeWrapper = new LambdaQueryWrapper<Negative>().in(Negative::getId, allNegativeIds); |
||||
List<Negative> negatives = negativeMapper.selectList(allNegativeWrapper); |
||||
Map<String, String> statusMap = negatives.stream().collect(Collectors.toMap(Negative::getId, Negative::getProcessingStatus)); |
||||
|
||||
List<String> filteredNegativeIds = allNegativeIds; |
||||
if (StrUtil.isNotBlank(param.getProcessingStatus())) { |
||||
if ("已修复".equals(param.getProcessingStatus())){ |
||||
filteredNegativeIds = negatives.stream().filter(one -> "completed".equals(one.getProcessingStatus())).map(Negative::getId).toList(); |
||||
} |
||||
if ("未修复".equals(param.getProcessingStatus())){ |
||||
filteredNegativeIds = negatives.stream().filter(one -> !"completed".equals(one.getProcessingStatus())).map(Negative::getId).toList(); |
||||
} |
||||
} |
||||
if (filteredNegativeIds.isEmpty()) { |
||||
return new Page<>(param.getCurrent(), param.getSize(), 0); |
||||
} |
||||
// 4. 构建分页查询条件
|
||||
QueryWrapper<ReportProject> wrapper = new QueryWrapper<>(); |
||||
if (StrUtil.isNotBlank(param.getName())) { |
||||
wrapper.like("report_name", param.getName()); |
||||
} |
||||
if (StrUtil.isNotBlank(param.getProcessingStatus())) { |
||||
wrapper.in("negative_id", filteredNegativeIds); |
||||
} else { |
||||
wrapper.in("negative_id", allNegativeIds); |
||||
} |
||||
wrapper.orderByDesc("supervision_time"); |
||||
|
||||
// 5. 分页查询
|
||||
IPage<ReportProject> page = projectMapper.selectPage( |
||||
new Page<>(param.getCurrent(), param.getSize()), |
||||
wrapper |
||||
); |
||||
|
||||
// 6. 内存关联 processingStatus
|
||||
for (ReportProject record : page.getRecords()) { |
||||
String status = statusMap.get(record.getNegativeId()); |
||||
record.setProcessingStatus("completed".equals(status) ? "已修复" : "未修复"); |
||||
} |
||||
|
||||
return page; |
||||
} |
||||
|
||||
/** |
||||
* 查找当前用户待处理的预警流程ID |
||||
*/ |
||||
private String findCurrentUserValidFlowId(String reportId) { |
||||
UserAuth user = UserContextHolder.getCurrentUser(); |
||||
List<ReportFlow> flows = flowMapper.selectList( |
||||
new LambdaQueryWrapper<ReportFlow>() |
||||
.eq(ReportFlow::getReportId, reportId) |
||||
.eq(ReportFlow::getType, "warning") |
||||
.eq(ReportFlow::getApproverId, user.getUserName()) |
||||
.eq(ReportFlow::getApproverState, FlowStateEnum.Start.getLabel()) |
||||
); |
||||
return flows.isEmpty() ? null : flows.get(0).getId(); |
||||
} |
||||
|
||||
/** |
||||
* 保存预警内容 |
||||
*/ |
||||
private void saveWarningContents(String reportId, List<WarningSaveRequest.WarningContentItem> contents) { |
||||
if (contents == null || contents.isEmpty()) { |
||||
return; |
||||
} |
||||
|
||||
// 先删除旧的预警内容
|
||||
contentMapper.delete(new LambdaQueryWrapper<WarningContent>().eq(WarningContent::getReportId, reportId)); |
||||
|
||||
// 保存新的预警内容
|
||||
List<WarningContent> entities = new ArrayList<>(); |
||||
for (WarningSaveRequest.WarningContentItem item : contents) { |
||||
WarningContent content = new WarningContent(); |
||||
content.setReportId(reportId); |
||||
content.setType(item.getType()); |
||||
content.setTitle(item.getTitle()); |
||||
content.setContent(item.getContent()); |
||||
content.setRemark(item.getRemark()); |
||||
entities.add(content); |
||||
} |
||||
|
||||
if (!entities.isEmpty()) { |
||||
contentMapper.insert(entities.get(0)); |
||||
if (entities.size() > 1) { |
||||
for (int i = 1; i < entities.size(); i++) { |
||||
contentMapper.insert(entities.get(i)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
/** |
||||
* 业务预警通过时生成问题数据(不依赖 WarningRecord) |
||||
* 将所有 remark 合并成一条 negative |
||||
* |
||||
* @param reportId 项目ID |
||||
* @param data 业务数据(业务类别、涉嫌问题、警种、办理时限等) |
||||
*/ |
||||
public void createNegativeDataForBusiness(String reportId, DataDataPetitionComplainDistribute data) { |
||||
// 1. 获取项目信息
|
||||
ReportProject project = reportProjectMapper.selectById(reportId); |
||||
if (project == null) { |
||||
throw new RuntimeException("项目不存在: " + reportId); |
||||
} |
||||
|
||||
// 2. 获取预警内容(过滤出有 remark 的)
|
||||
List<WarningContent> contents = warningContentMapper.selectList( |
||||
new LambdaQueryWrapper<WarningContent>() |
||||
.eq(WarningContent::getReportId, reportId) |
||||
); |
||||
|
||||
List<WarningContent> filteredContents = contents.stream() |
||||
.filter(c -> StrUtil.isNotBlank(c.getRemark())) |
||||
.toList(); |
||||
|
||||
if (filteredContents.isEmpty()) { |
||||
log.warn("预警内容无有效数据,不生成问题: reportId={}", reportId); |
||||
return; |
||||
} |
||||
|
||||
// 3. 合并所有 remark 成一条 thingDesc
|
||||
StringBuilder thingDescBuilder = new StringBuilder("项目名称: " + project.getReportName() +",存在问题:" ) ; |
||||
for (WarningContent content : filteredContents) { |
||||
thingDescBuilder.append(",").append(content.getRemark()); |
||||
} |
||||
thingDescBuilder.append(",请及时查收并在规定时限内完成整改。"); |
||||
|
||||
// 4. 只生成一条 negative
|
||||
NegativeDto negativeDto = new NegativeDto(); |
||||
|
||||
// 时间相关
|
||||
negativeDto.setHappenTime(project.getSupervisionTime()); |
||||
negativeDto.setDiscoveryTime(project.getSupervisionTime()); |
||||
|
||||
// 问题来源
|
||||
negativeDto.setProblemSourcesCode("27"); |
||||
negativeDto.setProblemSources(ProblemSourcesEnum.get("27").getLabel()); |
||||
|
||||
// 业务数据(来自弹窗)
|
||||
negativeDto.setBusinessTypeCode(data.getBusinessTypeCode()); |
||||
negativeDto.setPoliceType(data.getPoliceType()); |
||||
negativeDto.setInvolveProblem(data.getInvolveProblem()); |
||||
|
||||
// 问题描述(合并后的)
|
||||
negativeDto.setThingDesc(thingDescBuilder.toString()); |
||||
|
||||
// 单位处理
|
||||
SupDepart depart = departService.getById(project.getProjectUnitId()); |
||||
if (depart == null) { |
||||
throw new RuntimeException("项目单位不存在: " + project.getProjectUnitId()); |
||||
} |
||||
if (DepartLevelEnum.SECOND.getValue().equals(depart.getLevel())) { |
||||
negativeDto.setDepartId(project.getProjectUnitId()); |
||||
} else if (DepartLevelEnum.THREE.getValue().equals(depart.getLevel())) { |
||||
if (DistributionFlowEnum.SECOND.getValue().equals(data.getDistributionFlow())) { |
||||
negativeDto.setDepartId(depart.getPid()); |
||||
} else { |
||||
negativeDto.setDepartId(depart.getId()); |
||||
} |
||||
} else { |
||||
throw new RuntimeException("指定办理单位 请选择二级或三级单位"); |
||||
} |
||||
|
||||
// 涉及单位
|
||||
negativeDto.setInvolveDepartId(project.getProjectUnitId()); |
||||
negativeDto.setInvolveDepartName(project.getProjectUnit()); |
||||
|
||||
// 审核级别
|
||||
negativeDto.setHostLevel(HostLevelEnums.SECOND.getValue()); |
||||
|
||||
// 流程配置
|
||||
negativeDto.setApprovalFlow(data.getApprovalFlow()); |
||||
negativeDto.setTimeLimit(data.getTimeLimit()); |
||||
negativeDto.setMaxSignDuration(data.getMaxSignDuration()); |
||||
negativeDto.setMaxHandleDuration(data.getMaxHandleDuration()); |
||||
negativeDto.setMaxExtensionDuration(data.getMaxExtensionDuration()); |
||||
|
||||
// 案号(使用项目ID)
|
||||
// negativeDto.setCaseNumber(reportId);
|
||||
negativeDto.setOriginId(reportId); |
||||
// 5. 保存问题数据(只保存一条)
|
||||
Negative save = negativeService.save(negativeDto); |
||||
|
||||
//
|
||||
project.setNegativeId(save.getId()); |
||||
projectMapper.updateById(project); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue