From f82fbbac566b8d8908c48847fe9b5e37e67a68d3 Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Thu, 8 Jan 2026 18:00:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=89=E8=AE=BF=E6=B6=89=E8=AF=89--=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/ComplaintCollectionController.java | 7 + .../ComplaintCollectionExcelDTO.java | 82 +++++++++ .../ComplaintCollectionPersonExcelDTO.java | 110 ++++++++++++ .../ComplaintCollectionService.java | 9 + .../ComplaintCollectionServiceImpl.java | 164 +++++++++++++++++- 5 files changed, 371 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/biutag/supervision/pojo/dto/complaintCollection/ComplaintCollectionExcelDTO.java create mode 100644 src/main/java/com/biutag/supervision/pojo/dto/complaintCollection/ComplaintCollectionPersonExcelDTO.java diff --git a/src/main/java/com/biutag/supervision/controller/data/ComplaintCollectionController.java b/src/main/java/com/biutag/supervision/controller/data/ComplaintCollectionController.java index 1b64038..4442197 100644 --- a/src/main/java/com/biutag/supervision/controller/data/ComplaintCollectionController.java +++ b/src/main/java/com/biutag/supervision/controller/data/ComplaintCollectionController.java @@ -10,6 +10,7 @@ import com.biutag.supervision.pojo.vo.complaintCollection.ComplaintCollectionWat import com.biutag.supervision.service.complaintCollection.ComplaintCollectionService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; @@ -93,4 +94,10 @@ public class ComplaintCollectionController { public Result handlerData(@RequestBody ComplaintCollectionHandlerDataRequest request){ return complaintCollectionService.handlerData(request); } + + @Operation(description = "导出数据") + @PostMapping("/exportData") + public void exportData(@RequestBody ComplaintCollectionPageRequest request, HttpServletResponse response){ + complaintCollectionService.exportData(request, response); + } } diff --git a/src/main/java/com/biutag/supervision/pojo/dto/complaintCollection/ComplaintCollectionExcelDTO.java b/src/main/java/com/biutag/supervision/pojo/dto/complaintCollection/ComplaintCollectionExcelDTO.java new file mode 100644 index 0000000..5966c68 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/dto/complaintCollection/ComplaintCollectionExcelDTO.java @@ -0,0 +1,82 @@ +package com.biutag.supervision.pojo.dto.complaintCollection; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; + +/** + * @ClassName ComplaintCollectionExcelDTO + * @Description 涉访涉诉导出Dto + * @Author shihao + * @Date 2026/1/8 11:16 + */ +@Getter +@Setter +@Schema(description = "涉访涉诉台账sheet") +public class ComplaintCollectionExcelDTO { + + @ExcelProperty("信件编号") + @ColumnWidth(20) + private String originId; + + @ExcelProperty("来源") + @ColumnWidth(20) + private String sourceTablePath; + + @ExcelProperty(value = "登记/受理时间") + @ColumnWidth(20) + private String discoveryTime; + + @ExcelProperty("来件人姓名") + @ColumnWidth(20) + private String responderName; + + @ExcelProperty("身份证号") + @ColumnWidth(20) + private String responderIdCode; + + @ExcelProperty("联系电话") + @ColumnWidth(20) + private String responderPhone; + + @ExcelProperty("被投诉机构") + @ColumnWidth(20) + private String secondDepartName; + + @ExcelProperty("来信内容") + @ColumnWidth(20) + private String thingDesc; + + @ExcelProperty("涉嫌问题") + @ColumnWidth(20) + @Schema(description = "涉嫌问题字符串") + private String involveProblemStr; + + @ExcelProperty("是否重复件") + @ColumnWidth(20) + private String repeatt; + + @ExcelProperty("标签") + @ColumnWidth(20) + private String tag; + + @ExcelProperty("办结情况") + @ColumnWidth(20) + private String completionStatus; + + @ExcelProperty("群众认可") + @ColumnWidth(20) + private String publicRecognition; + + @ExcelProperty("办理方式") + @ColumnWidth(20) + private String handleMethod; + + @ExcelProperty("业务类别") + @ColumnWidth(20) + private String businessTypeName; + + +} diff --git a/src/main/java/com/biutag/supervision/pojo/dto/complaintCollection/ComplaintCollectionPersonExcelDTO.java b/src/main/java/com/biutag/supervision/pojo/dto/complaintCollection/ComplaintCollectionPersonExcelDTO.java new file mode 100644 index 0000000..79d3bbe --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/dto/complaintCollection/ComplaintCollectionPersonExcelDTO.java @@ -0,0 +1,110 @@ +package com.biutag.supervision.pojo.dto.complaintCollection; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; + +import java.time.LocalDateTime; + +/** + * @ClassName ComplaintCollectionExcelDTO + * @Description 涉访涉诉台账涉及人员sheet + * @Author shihao + * @Date 2026/1/8 11:16 + */ +@Getter +@Setter +@Schema(description = "涉访涉诉台账涉及人员sheet") +public class ComplaintCollectionPersonExcelDTO { + + @ExcelProperty("信件编号") + @ColumnWidth(20) + private String originId; + + @ExcelProperty({"登记/受理时间"}) + @ColumnWidth(20) + private LocalDateTime discoveryTime; + + @ExcelProperty("来源") + @ColumnWidth(20) + private String sourceTablePath; + + @ExcelProperty({"业务类别"}) + @ColumnWidth(20) + private String businessTypeName; + + @ExcelProperty({"涉嫌问题"}) + @ColumnWidth(20) + private String involveProblemStr; + + @ExcelProperty({"简要描述"}) + @ColumnWidth(20) + private String thingDesc; + + @ExcelProperty({"涉及单位"}) + @ColumnWidth(20) + private String secondDepartName; + + @ExcelProperty({"办理单位(二级)"}) + @ColumnWidth(20) + private String handleSecondDepartName; + + @ExcelProperty({"办理单位(三级)"}) + @ColumnWidth(20) + private String handleThreeDepartName; + + @ExcelProperty({"核查情况(是否属实)"}) + @ColumnWidth(20) + private String checkStatusName; + +// @ExcelProperty({"是否整改"}) +// private String isRectifyName; +// +// @ExcelProperty({"整改情况"}) +// private String rectifyDesc; + + @ExcelProperty({"追责对象"}) + @ColumnWidth(20) + private String accountabilityTarget; + + @ExcelProperty({"涉及人员姓名"}) + @ColumnWidth(20) + private String blameName; + + @ExcelProperty({"警号"}) + @ColumnWidth(20) + private String blameEmpNo; + + @ExcelProperty({"身份证"}) + @ColumnWidth(20) + private String blameIdCode; + + @ExcelProperty({"人员属性"}) + @ColumnWidth(20) + private String ivPersonType; + + @ExcelProperty({"责任领导姓名"}) + @ColumnWidth(20) + private String leadName; + + @ExcelProperty({"责任领导警号"}) + @ColumnWidth(20) + private String leadEmpNo; + + @ExcelProperty({"责任领导身份证"}) + @ColumnWidth(20) + private String leadIdCode; + + + @ExcelProperty({"责任追责"}) + @ColumnWidth(20) + private String handleResultName; + + @ExcelProperty({"问题类型"}) + @ColumnWidth(20) + private String problemType; + + +} diff --git a/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionService.java b/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionService.java index ab178b8..da16591 100644 --- a/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionService.java +++ b/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionService.java @@ -6,6 +6,7 @@ import com.biutag.supervision.pojo.vo.complaintCollection.ComplaintCollectionHan import com.biutag.supervision.pojo.vo.complaintCollection.ComplaintCollectionMailRepeattVo; import com.biutag.supervision.pojo.vo.complaintCollection.ComplaintCollectionPageVo; import com.biutag.supervision.pojo.vo.complaintCollection.ComplaintCollectionWatchDetailVO; +import jakarta.servlet.http.HttpServletResponse; /** @@ -73,4 +74,12 @@ public interface ComplaintCollectionService { * @return */ Result handlerData(ComplaintCollectionHandlerDataRequest request); + + /** + * 数据导出 + * @param request + * @param response + * @return + */ + void exportData(ComplaintCollectionPageRequest request, HttpServletResponse response); } diff --git a/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionServiceImpl.java b/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionServiceImpl.java index 91072d9..aa0200e 100644 --- a/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionServiceImpl.java +++ b/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionServiceImpl.java @@ -6,7 +6,11 @@ import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Opt; import cn.hutool.core.map.MapUtil; 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.alibaba.fastjson2.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.biutag.supervision.common.UserContextHolder; import com.biutag.supervision.constants.enums.*; @@ -14,10 +18,15 @@ import com.biutag.supervision.flow.action.ApplyCompletionAction; import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.domain.Blame; import com.biutag.supervision.pojo.dto.NegativeDto; +import com.biutag.supervision.pojo.dto.complaintCollection.ComplaintCollectionExcelDTO; import com.biutag.supervision.pojo.dto.complaintCollection.ComplaintCollectionPageDTO; +import com.biutag.supervision.pojo.dto.complaintCollection.ComplaintCollectionPersonExcelDTO; import com.biutag.supervision.pojo.dto.complaintCollection.ComplaintCollectionRepeatDTO; import com.biutag.supervision.pojo.dto.flow.VerifyData; import com.biutag.supervision.pojo.entity.*; +import com.biutag.supervision.pojo.enums.complaintCollection.ComplaintCollectionClosingStatusEnum; +import com.biutag.supervision.pojo.enums.complaintCollection.ComplaintCollectionHandleMethodEnum; +import com.biutag.supervision.pojo.enums.complaintCollection.ComplaintCollectionPublicApprovalEnum; import com.biutag.supervision.pojo.enums.supDict.SupDictEnum; import com.biutag.supervision.pojo.param.ComplaintCollection.ComplaintCollectionExistParam; import com.biutag.supervision.pojo.param.ComplaintCollection.ComplaintCollectionQueryParam; @@ -47,13 +56,19 @@ import com.biutag.supervision.repository.supdepart.SupDepartResourceService; import com.biutag.supervision.service.*; import com.biutag.supervision.util.CodeTranslateUtil; import com.biutag.supervision.util.SfssUtil; +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.ValidationException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -85,7 +100,7 @@ public class ComplaintCollectionServiceImpl implements ComplaintCollectionServic private final ComplaintCollectionCheckFileResourceService complaintCollectionCheckFileResourceService; private final DataPetitionComplaintResourceService dataPetitionComplaintResourceService; private final DataCaseVerifResourceService dataCaseVerifResourceService; - private final ComplaintCollectionServiceJob complaintCollectionServiceJob; + private final NegativeProblemRelationService negativeProblemRelationService; @Override @Transactional(rollbackFor = Exception.class) @@ -460,6 +475,153 @@ public class ComplaintCollectionServiceImpl implements ComplaintCollectionServic return Result.success(complaintCollectionHandlerDataVo); } + @Override + public void exportData(ComplaintCollectionPageRequest request, HttpServletResponse response) { + request.setSize(10000); + request.setCurrent(1); + // 涉访涉诉台账 + List complaintCollectionPageDTOS = getComplaintCollectionPage(request).getData().getComplaintCollectionPageDTOS(); + List dataList = this.buildComplaintCollectionExcelDTO(complaintCollectionPageDTOS); + if (dataList.size() > 10000) { + throw new RuntimeException("导出数据量过大,请缩小筛选范围"); + } + // 涉访涉诉涉及人数据 + ComplaintCollectionBlameQueryParam complaintCollectionBlameQueryParam = new ComplaintCollectionBlameQueryParam(); + Set complaintCollectionIds = complaintCollectionPageDTOS.stream().map(ComplaintCollectionPageDTO::getId).collect(Collectors.toSet()); + complaintCollectionBlameQueryParam.setComplaintIds(complaintCollectionIds); + List blameList = complaintCollectionBlameResourceService.query(complaintCollectionBlameQueryParam); + List negativeBlames = negativeBlameService.listByNegativeIds(complaintCollectionIds); + List personList = this.buildComplaintCollectionPersonExcelDTO(blameList, negativeBlames, complaintCollectionPageDTOS); + try { + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + String fileName = URLEncoder.encode("涉访涉诉导出", "UTF-8").replaceAll("\\+", "%20"); + response.setHeader( + "Content-disposition", + "attachment;filename*=utf-8''" + fileName + ".xlsx" + ); + try (ServletOutputStream outputStream = response.getOutputStream()) { + ExcelWriter excelWriter = EasyExcel.write(outputStream).build(); + // Sheet1: 台账 + WriteSheet sheet1 = EasyExcel.writerSheet(0, "涉访涉诉台账") + .head(ComplaintCollectionExcelDTO.class) + .build(); + excelWriter.write(dataList, sheet1); + // Sheet2: 涉及人 + WriteSheet sheet2 = EasyExcel.writerSheet(1, "涉访涉诉涉及人数据") + .head(ComplaintCollectionPersonExcelDTO.class) + .build(); + excelWriter.write(personList, sheet2); + excelWriter.finish(); + } + } catch (UnsupportedEncodingException e) { + log.error("文件名编码失败", e); + throw new RuntimeException("导出失败:文件名编码错误", e); + } catch (IOException e) { + log.error("Excel导出失败:IO异常", e); + throw new RuntimeException("导出失败:写入文件出错", e); + } catch (Exception e) { + log.error("Excel导出失败:未知异常", e); + throw new RuntimeException("导出失败:系统异常", e); + } + } + + private List buildComplaintCollectionPersonExcelDTO(List blameList, List negativeBlames, List dataList) { + List res = new ArrayList<>(); + Map> complaintCollectionBlameMap = blameList.stream() + .filter(blame -> blame.getComplaintId() != null) + .collect(Collectors.groupingBy(ComplaintCollectionBlame::getComplaintId, Collectors.toList())); + Map> negativeBlameMap = negativeBlames.stream() + .filter(blame -> blame.getNegativeId() != null) + .collect(Collectors.groupingBy(NegativeBlame::getNegativeId, Collectors.toList())); + List negativeProblemRelations = negativeProblemRelationService.list(new LambdaQueryWrapper().in(NegativeProblemRelation::getNegativeId, dataList.stream().map(ComplaintCollectionPageDTO::getId).toList())); + for (ComplaintCollectionPageDTO dto : dataList) { + String checkStatus = dto.getCheckStatus(); + boolean itTure = InspectCaseEnum.isItTure(checkStatus); + if (itTure) { + List nBlame = negativeBlameMap.getOrDefault(dto.getId(), new ArrayList<>()); + nBlame.forEach(item -> { + String problemTypeList = negativeProblemRelations.stream().filter(problem -> item.getBlameId().equals(problem.getBlameId()) && StrUtil.isNotBlank(problem.getOneLevelContent())).map(problem -> { + if ("其他".equals(problem.getThreeLevelContent())) { + return String.format("%s / %s / %s(%s)", problem.getOneLevelContent(), problem.getTwoLevelContent(), problem.getThreeLevelContent(), problem.getThreeLevelContentOther()); + } + return String.format("%s / %s / %s", problem.getOneLevelContent(), problem.getTwoLevelContent(), problem.getThreeLevelContent()); + }).collect(Collectors.joining("、")); + ComplaintCollectionPersonExcelDTO complaintCollectionPersonExcelDTO = new ComplaintCollectionPersonExcelDTO(); + complaintCollectionPersonExcelDTO.setOriginId(dto.getOriginId()); + complaintCollectionPersonExcelDTO.setDiscoveryTime(dto.getDiscoveryTime()); + complaintCollectionPersonExcelDTO.setSourceTablePath(dto.getSourceTablePath()); + complaintCollectionPersonExcelDTO.setBusinessTypeName(dto.getBusinessTypeName()); + complaintCollectionPersonExcelDTO.setInvolveProblemStr(dto.getInvolveProblemStr()); + complaintCollectionPersonExcelDTO.setThingDesc(dto.getThingDesc()); + complaintCollectionPersonExcelDTO.setSecondDepartName(dto.getSecondDepartName()); + complaintCollectionPersonExcelDTO.setCheckStatusName(dto.getCheckStatusName()); + complaintCollectionPersonExcelDTO.setAccountabilityTarget(BlameType.personal.name().equals(item.getType()) ? "涉及个人" : "涉及单位"); + complaintCollectionPersonExcelDTO.setBlameName(item.getBlameName()); + complaintCollectionPersonExcelDTO.setBlameEmpNo(item.getBlameEmpNo()); + complaintCollectionPersonExcelDTO.setBlameIdCode(item.getBlameIdCode()); + complaintCollectionPersonExcelDTO.setIvPersonType(item.getIvPersonType()); + complaintCollectionPersonExcelDTO.setLeadName(item.getLeadName()); + complaintCollectionPersonExcelDTO.setLeadEmpNo(item.getLeadEmpNo()); + complaintCollectionPersonExcelDTO.setLeadIdCode(item.getLeadIdCode()); + complaintCollectionPersonExcelDTO.setHandleResultName(item.getHandleResultName()); + complaintCollectionPersonExcelDTO.setProblemType(problemTypeList); + res.add(complaintCollectionPersonExcelDTO); + }); + } else { + List complaintCollectionBlames = complaintCollectionBlameMap.getOrDefault(dto.getId(), new ArrayList<>()); + complaintCollectionBlames.forEach(item -> { +// String problemTypeList = negativeProblemRelations.stream().filter(problem -> item.getBlameId().equals(problem.getBlameId()) && StrUtil.isNotBlank(problem.getOneLevelContent())).map(problem -> { +// if ("其他".equals(problem.getThreeLevelContent())) { +// return String.format("%s / %s / %s(%s)", problem.getOneLevelContent(), problem.getTwoLevelContent(), problem.getThreeLevelContent(), problem.getThreeLevelContentOther()); +// } +// return String.format("%s / %s / %s", problem.getOneLevelContent(), problem.getTwoLevelContent(), problem.getThreeLevelContent()); +// }).collect(Collectors.joining("、")); + ComplaintCollectionPersonExcelDTO complaintCollectionPersonExcelDTO = new ComplaintCollectionPersonExcelDTO(); + complaintCollectionPersonExcelDTO.setOriginId(dto.getOriginId()); + complaintCollectionPersonExcelDTO.setDiscoveryTime(dto.getDiscoveryTime()); + complaintCollectionPersonExcelDTO.setSourceTablePath(dto.getSourceTablePath()); + complaintCollectionPersonExcelDTO.setBusinessTypeName(dto.getBusinessTypeName()); + complaintCollectionPersonExcelDTO.setInvolveProblemStr(dto.getInvolveProblemStr()); + complaintCollectionPersonExcelDTO.setThingDesc(dto.getThingDesc()); + complaintCollectionPersonExcelDTO.setSecondDepartName(dto.getSecondDepartName()); + complaintCollectionPersonExcelDTO.setCheckStatusName(dto.getCheckStatusName()); + complaintCollectionPersonExcelDTO.setAccountabilityTarget(BlameType.personal.name().equals(item.getType()) ? "涉及个人" : "涉及单位"); + complaintCollectionPersonExcelDTO.setBlameName(item.getBlameName()); + complaintCollectionPersonExcelDTO.setBlameEmpNo(item.getBlameEmpNo()); + complaintCollectionPersonExcelDTO.setBlameIdCode(item.getBlameIdCode()); + complaintCollectionPersonExcelDTO.setIvPersonType(item.getIvPersonTypeName()); + complaintCollectionPersonExcelDTO.setLeadName(item.getLeadName()); + complaintCollectionPersonExcelDTO.setLeadEmpNo(item.getLeadEmpNo()); + complaintCollectionPersonExcelDTO.setLeadIdCode(item.getLeadIdCode()); + complaintCollectionPersonExcelDTO.setHandleResultName(item.getHandleResultName()); +// complaintCollectionPersonExcelDTO.setProblemType(problemTypeList); + res.add(complaintCollectionPersonExcelDTO); + }); + } + } + return res; + } + + private List buildComplaintCollectionExcelDTO(List complaintCollectionPageDTOS) { + List res = new ArrayList<>(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + for (ComplaintCollectionPageDTO dto : complaintCollectionPageDTOS) { + ComplaintCollectionExcelDTO excelDTO = new ComplaintCollectionExcelDTO(); + BeanUtil.copyProperties(dto, excelDTO); + if (dto.getDiscoveryTime() != null) { + excelDTO.setDiscoveryTime(dto.getDiscoveryTime().format(formatter)); + } + String repeatt = dto.getRepeatt(); + repeatt = "1".equals(repeatt) ? "是" : "否"; + excelDTO.setRepeatt(repeatt); + excelDTO.setCompletionStatus(ComplaintCollectionClosingStatusEnum.getDescByCode(dto.getCompletionStatus())); + excelDTO.setPublicRecognition(ComplaintCollectionPublicApprovalEnum.getDescByCode(dto.getPublicRecognition())); + excelDTO.setHandleMethod(ComplaintCollectionHandleMethodEnum.getDescByCode(dto.getHandleMethod())); + res.add(excelDTO); + } + return res; + } public VerifyData buildVerifyData(ComplaintCollectionAndBlameAddRequest request) { VerifyData verifyData = new VerifyData();