From 388ca5a47f6f7b41df92e75926361eb601b2536d Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Fri, 8 May 2026 16:59:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=A2=84=E8=AD=A6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../warning/WarningBusinessController.java | 15 ++ .../controller/warning/WarningController.java | 1 + .../pojo/vo/warning/WarningExcelVo.java | 69 +++++++ .../vo/warning/WarningProblemExcelVo.java | 26 +++ .../Warning/WarningBusinessService.java | 13 ++ .../impl/WarningBusinessServiceImpl.java | 187 ++++++++++++++++++ 6 files changed, 311 insertions(+) create mode 100644 src/main/java/com/biutag/supervision/pojo/vo/warning/WarningExcelVo.java create mode 100644 src/main/java/com/biutag/supervision/pojo/vo/warning/WarningProblemExcelVo.java diff --git a/src/main/java/com/biutag/supervision/controller/warning/WarningBusinessController.java b/src/main/java/com/biutag/supervision/controller/warning/WarningBusinessController.java index 8fdecfd..8491110 100644 --- a/src/main/java/com/biutag/supervision/controller/warning/WarningBusinessController.java +++ b/src/main/java/com/biutag/supervision/controller/warning/WarningBusinessController.java @@ -5,12 +5,15 @@ 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.param.Warning.WarningQueryParam; import com.biutag.supervision.pojo.request.warning.*; +import com.biutag.supervision.pojo.vo.entryWindow.EntryWindowVo; 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 jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; @@ -79,4 +82,16 @@ public class WarningBusinessController { public Result> compilePage(@RequestBody CompileQueryParam param) { return Result.success(businessService.compilePage(param)); } + + @Operation(summary = "预警列表分页查询") + @PostMapping("/page") + public Result> getWarningPage(@RequestBody WarningQueryParam queryParam) { + return Result.success(businessService.getWarningPage(queryParam)); + } + + @Operation(summary = "导出预警列表") + @PostMapping("/excelWarningList") + public void excelWarningList(@RequestBody WarningQueryParam param, HttpServletResponse response) { + businessService.excelWarningList(param, response); + } } diff --git a/src/main/java/com/biutag/supervision/controller/warning/WarningController.java b/src/main/java/com/biutag/supervision/controller/warning/WarningController.java index 54a290c..56502a4 100644 --- a/src/main/java/com/biutag/supervision/controller/warning/WarningController.java +++ b/src/main/java/com/biutag/supervision/controller/warning/WarningController.java @@ -55,6 +55,7 @@ public class WarningController { private final SupDepartService departService; //预警督察列表 + @Deprecated @PostMapping("/getPage") public Result> getPage(@RequestBody WarningQueryParam queryParam) { UserAuth user = UserContextHolder.getCurrentUser(); diff --git a/src/main/java/com/biutag/supervision/pojo/vo/warning/WarningExcelVo.java b/src/main/java/com/biutag/supervision/pojo/vo/warning/WarningExcelVo.java new file mode 100644 index 0000000..142abc0 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/warning/WarningExcelVo.java @@ -0,0 +1,69 @@ +package com.biutag.supervision.pojo.vo.warning; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +public class WarningExcelVo { + + @ExcelProperty(value = "项目ID") + private String reportId; + + @ExcelProperty(value = "项目名称") + private String reportName; + + @ExcelProperty(value = "报审类型") + private String reportType; + + @ExcelProperty(value = "项目类别") + private String projectType; + + @ExcelProperty(value = "预警监督状态") + private String warningState; + + @ExcelProperty(value = "预警时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime supervisionTime; + + @ExcelProperty(value = "审计单位") + private String auditUnitStr; + + @ExcelProperty(value = "审计问题数") + private Long warningContent; + + @ExcelProperty(value = "项目单位") + private String projectUnitStr; + + @ExcelProperty(value = "项目负责人") + private String projectPrincipal; + + @ExcelProperty(value = "项目负责人联系方式") + private String projectPhone; + + @ExcelProperty(value = "采购方式") + private String purchaseMethod; + + @ExcelProperty(value = "报审金额") + private BigDecimal reportMoney; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ExcelProperty(value = "报审日期") + private LocalDateTime applicantTime; + + @ExcelProperty(value = "立项金额") + private BigDecimal projectApprovalMoney; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ExcelProperty(value = "立项日期") + private LocalDateTime projectApprovalTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ExcelProperty(value = "归档日期") + private LocalDateTime archiving; +} diff --git a/src/main/java/com/biutag/supervision/pojo/vo/warning/WarningProblemExcelVo.java b/src/main/java/com/biutag/supervision/pojo/vo/warning/WarningProblemExcelVo.java new file mode 100644 index 0000000..cbebf52 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/warning/WarningProblemExcelVo.java @@ -0,0 +1,26 @@ +package com.biutag.supervision.pojo.vo.warning; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +@Data +public class WarningProblemExcelVo { + + @ExcelProperty(value = "项目ID") + private String reportId; + + @ExcelProperty(value = "项目名称") + private String reportName; + + @ExcelProperty(value = "预警类型") + private String type; + + @ExcelProperty(value = "预警标题") + private String title; + + @ExcelProperty(value = "预警内容") + private String content; + + @ExcelProperty(value = "问题详情") + private String remark; +} diff --git a/src/main/java/com/biutag/supervision/service/Warning/WarningBusinessService.java b/src/main/java/com/biutag/supervision/service/Warning/WarningBusinessService.java index 9563162..716cf65 100644 --- a/src/main/java/com/biutag/supervision/service/Warning/WarningBusinessService.java +++ b/src/main/java/com/biutag/supervision/service/Warning/WarningBusinessService.java @@ -4,9 +4,12 @@ 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.param.Warning.WarningQueryParam; import com.biutag.supervision.pojo.request.warning.*; +import com.biutag.supervision.pojo.vo.entryWindow.EntryWindowVo; import com.biutag.supervision.pojo.vo.warning.WarningBusinessVo; import com.baomidou.mybatisplus.core.metadata.IPage; +import jakarta.servlet.http.HttpServletResponse; import java.util.List; @@ -54,4 +57,14 @@ public interface WarningBusinessService { * 预警项目列表(编译台账) */ IPage compilePage(CompileQueryParam param); + + /** + * 预警列表分页查询 + */ + IPage getWarningPage(WarningQueryParam queryParam); + + /** + * 导出预警列表 + */ + void excelWarningList(WarningQueryParam param, HttpServletResponse response); } diff --git a/src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java b/src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java index 6cdf1df..e9124af 100644 --- a/src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java +++ b/src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java @@ -1,12 +1,17 @@ package com.biutag.supervision.service.Warning.impl; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; 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.AppConstants; import com.biutag.supervision.constants.enums.*; import com.biutag.supervision.mapper.InformMessageMapper; import com.biutag.supervision.mapper.Negative.NegativeMapper; @@ -27,21 +32,28 @@ 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.param.Warning.WarningQueryParam; import com.biutag.supervision.pojo.request.warning.*; +import com.biutag.supervision.pojo.vo.entryWindow.EntryWindowVo; import com.biutag.supervision.pojo.vo.warning.WarningBusinessVo; +import com.biutag.supervision.pojo.vo.warning.WarningExcelVo; +import com.biutag.supervision.pojo.vo.warning.WarningProblemExcelVo; 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.Report.ReportProjectService; 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 jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.ArrayList; @@ -50,6 +62,8 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import static com.biutag.supervision.constants.AppConstants.CWLN; + /** * 预警业务服务实现 */ @@ -68,6 +82,7 @@ public class WarningBusinessServiceImpl implements WarningBusinessService { private final WarningContentMapper warningContentMapper; private final NegativeService negativeService; private final NegativeMapper negativeMapper; + private final ReportProjectService reportProjectService; @Override public WarningBusinessVo getDetail(String reportId) { @@ -392,6 +407,178 @@ public class WarningBusinessServiceImpl implements WarningBusinessService { return page; } + @Override + public IPage getWarningPage(WarningQueryParam queryParam) { + UserAuth user = UserContextHolder.getCurrentUser(); + QueryWrapper wrapper = buildWarningWrapper(queryParam, user); + Page page = reportProjectService.getPageWarning( + new Page<>(queryParam.getCurrent(), queryParam.getSize()), wrapper, queryParam.getWarningState()); + + page.getRecords().forEach(this::fillProjectData); + return page; + } + + @Override + public void excelWarningList(WarningQueryParam param, HttpServletResponse response) { + // 1. 调用 getWarningPage 查询全部数据(不分页,size=Integer.MAX_VALUE) + param.setCurrent(1); + param.setSize(Integer.MAX_VALUE); + IPage page = getWarningPage(param); + + // 2. Sheet1 数据转换(项目列表) + List projectList = page.getRecords().stream().map(record -> { + WarningExcelVo vo = new WarningExcelVo(); + vo.setReportId(record.getId()); + vo.setReportName(record.getReportName()); + vo.setReportType(record.getReportType()); + vo.setProjectType(record.getProjectType()); + vo.setWarningState("1".equals(record.getWarningState()) ? "已预警" + : "2".equals(record.getWarningState()) ? "预警中" : "待预警"); + vo.setSupervisionTime(record.getSupervisionTime()); + vo.setAuditUnitStr(record.getAuditUnitStr()); + vo.setWarningContent(record.getWarningContent()); + vo.setProjectUnitStr(record.getProjectUnitStr()); + vo.setProjectPrincipal(record.getProjectPrincipal()); + vo.setProjectPhone(record.getProjectPhone()); + vo.setPurchaseMethod(record.getPurchaseMethod()); + vo.setReportMoney(record.getReportMoney()); + vo.setApplicantTime(record.getApplicantTime()); + vo.setProjectApprovalMoney(record.getProjectApprovalMoney()); + vo.setProjectApprovalTime(record.getProjectApprovalTime()); + vo.setArchiving(record.getArchiving()); + return vo; + }).collect(Collectors.toList()); + + // 3. Sheet2 数据转换(预警问题列表) + List problemList = new ArrayList<>(); + for (EntryWindowVo record : page.getRecords()) { + List contents = warningContentMapper.selectList( + new LambdaQueryWrapper() + .eq(WarningContent::getReportId, record.getId()) + .isNotNull(WarningContent::getRemark) + .ne(WarningContent::getRemark, "") + ); + for (WarningContent content : contents) { + WarningProblemExcelVo vo = new WarningProblemExcelVo(); + vo.setReportId(record.getId()); + vo.setReportName(record.getReportName()); + vo.setType(content.getType()); + vo.setTitle(content.getTitle()); + vo.setContent(content.getContent()); + vo.setRemark(content.getRemark()); + problemList.add(vo); + } + } + + // 4. 导出多 Sheet Excel + try { + String fileName = URLEncoder.encode("预警监督项目列表", "UTF-8"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + ".xlsx\""); + response.setContentType("application/octet-stream"); + + ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()) + .inMemory(Boolean.TRUE) + .build(); + + // Sheet1 + WriteSheet sheet1 = EasyExcel.writerSheet(0, "预警监督项目列表") + .head(WarningExcelVo.class) + .build(); + excelWriter.write(projectList, sheet1); + + // Sheet2 + WriteSheet sheet2 = EasyExcel.writerSheet(1, "预警问题详情") + .head(WarningProblemExcelVo.class) + .build(); + excelWriter.write(problemList, sheet2); + + excelWriter.finish(); + } catch (Exception e) { + log.error("导出预警列表失败", e); + throw new RuntimeException("导出失败", e); + } + } + + /** + * 构建预警列表查询条件 + */ + private QueryWrapper buildWarningWrapper(WarningQueryParam queryParam, UserAuth user) { + QueryWrapper wrapper = new QueryWrapper() + .like(StrUtil.isNotBlank(queryParam.getReportName()), "p.report_name", queryParam.getReportName()) + .eq(StrUtil.isNotBlank(queryParam.getWarningState()), "p.warning_state", queryParam.getWarningState()) + .eq("p.node", FlowStateEnum.End.getLabel()) + .eq("p.delete_flag", DeleteStatusEnum.NO.getCode()); + + // 长望浏宁Tab + if ("cwlnt".equals(queryParam.getSpecialArea())) { + wrapper.in("p.audit_unit_id", departService.getAllNodeIds(CWLN)); + } else { + List excludeOrgIds = new ArrayList<>(departService.getAllNodeIds(AppConstants.DSZD)); + excludeOrgIds.addAll(departService.getAllNodeIds(AppConstants.CWLN)); + wrapper.notIn("p.audit_unit_id", excludeOrgIds); + } + + // 审计单位 + if (StrUtil.isNotBlank(queryParam.getAuditUnitId())) { + wrapper.in("p.audit_unit_id", departService.getAllNodeIds(queryParam.getAuditUnitId())); + } + // 项目单位 + if (StrUtil.isNotBlank(queryParam.getProjectUnitId())) { + wrapper.in("p.project_unit_id", departService.getAllNodeIds(queryParam.getProjectUnitId())); + } + // 权限控制 + if (!AppConstants.USER_TYPE_SUPER.equals(user.getUserType()) + && !user.getRoleCodes().contains(RoleCodeEnum.FIRST_ADMIN.getCode())) { + List orgIds = user.getAuthDepartIds().isEmpty() + ? departService.getAllNodeIds(user.getDepartId()) + : departService.getAllNodeIds(user.getAuthDepartIds()); + wrapper.in("p.project_unit_id", orgIds); + } + // 日期范围 + if (CollectionUtil.isNotEmpty(queryParam.getPublicationDate())) { + wrapper.between(true, "p.publication_date", queryParam.getPublicationDate().get(0), queryParam.getPublicationDate().get(1)); + } + if (CollectionUtil.isNotEmpty(queryParam.getEndDate())) { + wrapper.between(true, "p.archiving", queryParam.getEndDate().get(0), queryParam.getEndDate().get(1)); + } + + return wrapper; + } + + /** + * 填充项目数据 + */ + private void fillProjectData(EntryWindowVo vo) { + // 是否已下发问题:根据 negativeId 判断 + vo.setStateData(StrUtil.isNotBlank(vo.getNegativeId()) ? "1" : "0"); + + // 预警问题数:有 remark 且 remark 不为空的内容条目数 + long contentCount = contentMapper.selectCount( + new LambdaQueryWrapper() + .eq(WarningContent::getReportId, vo.getId()) + .isNotNull(WarningContent::getRemark) + .ne(WarningContent::getRemark, "")); + vo.setWarningContent(contentCount); + + // 格式化单位字符串 + vo.setAuditUnitStr(formatDepartStr(vo.getAuditUnitId())); + vo.setProjectUnitStr(formatDepartStr(vo.getProjectUnitId())); + } + + /** + * 格式化部门字符串 + */ + private String formatDepartStr(String departId) { + if (StrUtil.isBlank(departId)) return "/"; + SupDepart depart = departService.getById(departId); + if (depart == null) return "/"; + if (depart.getLevel() == 3) { + SupDepart parent = departService.getById(depart.getPid()); + return parent.getShortName() + "/" + depart.getShortName(); + } + return depart.getShortName() + "/"; + } + /** * 查找当前用户待处理的预警流程ID */