From 564c3031f152713d47b16475c7dab8875db5e3d7 Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Mon, 13 Apr 2026 17:35:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=8A=95=E8=AF=89=E4=B8=BE=E6=8A=A5?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/ComplaintCollectionController.java | 6 + .../ComplaintCollectionService.java | 5 +- .../ComplaintCollectionServiceImpl.java | 386 ++++++++++++++++++ 3 files changed, 396 insertions(+), 1 deletion(-) 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 5daee89..e4f2d3f 100644 --- a/src/main/java/com/biutag/supervision/controller/data/ComplaintCollectionController.java +++ b/src/main/java/com/biutag/supervision/controller/data/ComplaintCollectionController.java @@ -58,6 +58,12 @@ public class ComplaintCollectionController { @Operation(description = "查询") @PostMapping("/getComplaintCollectionPageNew") public Result> getComplaintCollectionPageNew(@RequestBody ComplaintCollectionPageRequest request){ + if ("我要迁移".equals(request.getPersonInfo())){ + complaintCollectionService.moveNegativeTemp(request); + } + if ("我要下发".equals(request.getPersonInfo())){ + complaintCollectionService.addNegativeTemp(request); + } return Result.success(complaintCollectionService.getComplaintCollectionPageNew(request)); } 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 a0311b2..8fb7df7 100644 --- a/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionService.java +++ b/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionService.java @@ -5,7 +5,6 @@ import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.dto.complaintCollection.ComplaintCollectionPageDTO; import com.biutag.supervision.pojo.request.complaintCollection.*; import com.biutag.supervision.pojo.vo.complaintCollection.ComplaintCollectionDetailVo; -import com.biutag.supervision.pojo.vo.complaintCollection.ComplaintCollectionHandlerDataVo; import com.biutag.supervision.pojo.vo.complaintCollection.ComplaintCollectionMailRepeattVo; import com.biutag.supervision.pojo.vo.complaintCollection.ComplaintCollectionWatchDetailVO; import jakarta.servlet.http.HttpServletResponse; @@ -99,4 +98,8 @@ public interface ComplaintCollectionService { * @return */ Result getComplaintCollectionDetail(ComplaintCollectionDetailRequest request); + + void moveNegativeTemp(ComplaintCollectionPageRequest request); + + void addNegativeTemp(ComplaintCollectionPageRequest request); } 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 54d6051..60ea77c 100644 --- a/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionServiceImpl.java +++ b/src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionServiceImpl.java @@ -110,6 +110,8 @@ public class ComplaintCollectionServiceImpl implements ComplaintCollectionServic private final MailResourceService mailResourceService; private final NegativeHistoryService negativeHistoryService; + private final NegativeThingFileService negativeThingFileService; + private final NegativeFileService negativeFileService; private static final DateTimeFormatter INITIAL_REVIEW_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private static final int CHECK_LIMIT_DAYS = 4; @@ -910,4 +912,388 @@ public class ComplaintCollectionServiceImpl implements ComplaintCollectionServic } + + + @Override + @Transactional(rollbackFor = Exception.class) + public void moveNegativeTemp(ComplaintCollectionPageRequest request) { + if (StrUtil.isBlank(request.getOriginId())){ + + } + // 1. 查询已办结(status=1)且未迁移(negativeId为空)的数据 + ComplaintCollectionQueryParam queryParam = new ComplaintCollectionQueryParam(); + queryParam.setStatus("1"); // 已办结 + queryParam.setOriginId(request.getOriginId()); + List pendingList = complaintCollectionResourceService.query(queryParam); + + // 过滤出 negativeId 为空的数据 + List toMigrate = pendingList.stream() + .filter(cc -> StrUtil.isBlank(cc.getNegativeId())) + .toList(); + + if (CollectionUtil.isEmpty(toMigrate)) { + log.info("【已办结迁移】没有需要迁移的已办结数据"); + return; + } + + // 获取字典翻译Map + Map sourceDict = buildDictLabelMap(SupDictEnum.SFSS_SOURCE_TABLE.getCode()); + + int successCount = 0; + int skipCount = 0; + int failCount = 0; + + for (ComplaintCollection cc : toMigrate) { + try { + // 2. 判重检查:检查 Negative 表中是否已存在该 originId + if (negativeService.exists(cc.getOriginId())) { + log.info("【已办结迁移】跳过(Negative已存在): originId={}", cc.getOriginId()); + skipCount++; + continue; + } + + // 3. 构建 Negative 对象 + Negative negative = buildNegativeFromComplaintCollection(cc, sourceDict); + negativeService.save(negative); + String newNegativeId = negative.getId(); + + // 4. 迁移附件 + migrateFilesToNegative(cc.getId(), newNegativeId); + // 5. 迁移核查附件 + migrateCheckFilesToNegative(cc.getId(), newNegativeId); + + // 6. 迁移涉及人 + migrateBlamesToNegative(cc.getId(), newNegativeId); + + // 6. 更新 ComplaintCollection.negativeId + ComplaintCollectionUpdateParam updateParam = new ComplaintCollectionUpdateParam(); + updateParam.setId(cc.getId()); + updateParam.setNegativeId(newNegativeId); + updateParam.setUpdateTime(LocalDateTime.now()); + updateParam.setUpdateBy(UserContextHolder.getCurrentUser().getUserName()); + complaintCollectionResourceService.updateSelectiveById(updateParam); + + log.info("【已办结迁移】迁移成功: id={}, originId={}", cc.getId(), cc.getOriginId()); + successCount++; + + } catch (Exception e) { + log.error("【已办结迁移】迁移失败: id={}, originId={}, error={}", cc.getId(), cc.getOriginId(), e.getMessage(), e); + failCount++; + } + } + + log.info("【已办结迁移】迁移完成: 成功={}, 跳过={}, 失败={}", successCount, skipCount, failCount); + } + + /** + * 从 ComplaintCollection 构建 Negative 对象(用于已办结迁移) + */ + private Negative buildNegativeFromComplaintCollection(ComplaintCollection cc, Map sourceDict) { + Negative negative = new Negative(); + // 基本字段映射 + negative.setOriginId(cc.getOriginId()); + negative.setDiscoveryTime(cc.getDiscoveryTime()); + negative.setHappenTime(cc.getHappenTime()); + negative.setBusinessTypeCode(cc.getBusinessTypeCode()); + negative.setBusinessTypeName(cc.getBusinessTypeName()); + negative.setThingDesc(cc.getThingDesc()); + + // 问题来源 + if (ComplaintCollectionSourceTableEnum.LEADER_ASSIGN.getCode().equals(cc.getSourceTable())) { + negative.setProblemSourcesCode(cc.getSourceTableSubOne()); + negative.setProblemSources(sourceDict.get(cc.getSourceTableSubOne())); + } else { + negative.setProblemSourcesCode(cc.getSourceTable()); + negative.setProblemSources(sourceDict.get(cc.getSourceTable())); + } + + // 涉及单位 + negative.setInvolveDepartId(cc.getSecondDepartId()); + negative.setInvolveDepartName(cc.getSecondDepartName()); + negative.setSecondInvolveDepartId(cc.getSecondDepartId()); + negative.setThreeInvolveDepartId(cc.getThirdDepartId()); + + // 反映人信息 + negative.setResponderName(cc.getResponderName()); + negative.setContactPhone(cc.getResponderPhone()); + + // 警种 + negative.setPoliceTypeName(cc.getPoliceTypeName()); + negative.setPoliceType(cc.getPoliceType()); + + // 核查情况 + negative.setCheckStatus(cc.getCheckStatus()); + negative.setCheckStatusName(cc.getCheckStatusName()); + negative.setCheckStatusDesc(cc.getCheckStatusDesc()); + + // 办结时间 + negative.setCompleteDate(cc.getCompletedTime()); + + // 涉及案件编号 + negative.setCaseNumber(cc.getCaseNumber()); + + // 状态设置 - 已办结 + negative.setProcessingStatus("completed"); + negative.setStatus("0"); + + // 来源设置 + negative.setSourceType(NegativeSourceTypeEnum.COMPLAINT_REPORT.getCode()); + negative.setSourceTypeDesc(NegativeSourceTypeEnum.COMPLAINT_REPORT.getDesc()); + + // 创建信息 + negative.setCrtTime(LocalDateTime.now()); + String userName = "system"; + try { + userName = UserContextHolder.getCurrentUser().getUserName(); + } catch (Exception ignored) {} + return negative; + } + + /** + * 迁移附件:ComplaintCollectionFile -> NegativeThingFile + */ + private void migrateFilesToNegative(String complaintId, String negativeId) { + ComplaintCollectionFileQueryParam fileParam = new ComplaintCollectionFileQueryParam(); + fileParam.setComplaintId(complaintId); + List files = complaintCollectionFileResourceService.query(fileParam); + + if (CollectionUtil.isEmpty(files)) { + return; + } + + List negativeFiles = files.stream().map(file -> { + NegativeThingFile negativeFile = new NegativeThingFile(); + negativeFile.setNegativeId(negativeId); + negativeFile.setFileName(file.getFileName()); + negativeFile.setFilePath(file.getFilePath()); + negativeFile.setCreateTime(file.getCreateTime()); + return negativeFile; + }).toList(); + + negativeThingFileService.saveBatch(negativeFiles); + log.info("【已办结迁移】迁移附件: complaintId={}, count={}", complaintId, negativeFiles.size()); + } + + /** + * 迁移核查附件:ComplaintCollectionCheckFile -> NegativeFile + */ + private void migrateCheckFilesToNegative(String complaintId, String negativeId) { + ComplaintCollectionCheckFileQueryParam fileParam = new ComplaintCollectionCheckFileQueryParam(); + fileParam.setComplaintId(complaintId); + List checkFiles = complaintCollectionCheckFileResourceService.query(fileParam); + + if (CollectionUtil.isEmpty(checkFiles)) { + return; + } + + List negativeFiles = checkFiles.stream().map(file -> { + NegativeFile negativeFile = new NegativeFile(); + negativeFile.setNegtiveId(negativeId); + negativeFile.setFileName(file.getFileName()); + negativeFile.setFilePath(file.getFilePath()); + negativeFile.setCrtTime(file.getCreateTime()); + negativeFile.setCrtUser(file.getCreateBy()); + return negativeFile; + }).toList(); + + negativeFileService.saveBatch(negativeFiles); + log.info("【已办结迁移】迁移核查附件: complaintId={}, count={}", complaintId, negativeFiles.size()); + } + + /** + * 迁移涉及人:ComplaintCollectionBlame -> NegativeBlame + */ + private void migrateBlamesToNegative(String complaintId, String negativeId) { + ComplaintCollectionBlameQueryParam blameParam = new ComplaintCollectionBlameQueryParam(); + blameParam.setComplaintId(complaintId); + List blames = complaintCollectionBlameResourceService.query(blameParam); + + if (CollectionUtil.isEmpty(blames)) { + return; + } + + List negativeBlames = blames.stream().map(blame -> { + NegativeBlame negativeBlame = new NegativeBlame(); + negativeBlame.setNegativeId(negativeId); + negativeBlame.setType(blame.getType()); + negativeBlame.setBlameName(blame.getBlameName()); + negativeBlame.setBlameIdCode(blame.getBlameIdCode()); + negativeBlame.setBlameEmpNo(blame.getBlameEmpNo()); + negativeBlame.setBlameDepartId(blame.getBlameDepartId()); + negativeBlame.setBlameDepartName(blame.getBlameDepartName()); + negativeBlame.setIvPersonTypeCode(blame.getIvPersonTypeCode()); + negativeBlame.setIvPersonType(blame.getIvPersonTypeName()); +// negativeBlame.setPoliceTypeName(blame.getPoliceTypeName()); +// negativeBlame.setPoliceTypeCode(blame.getPoliceType()); + + // 问题类型JSON + negativeBlame.setInspectCaseCode(blame.getProblems()); + negativeBlame.setResponsibilityTypeCode(blame.getResponsibilityTypeCode()); + negativeBlame.setResponsibilityTypeName(blame.getResponsibilityTypeName()); + negativeBlame.setSubjectiveAspectCode(blame.getSubjectiveAspectCode()); + negativeBlame.setSubjectiveAspectName(blame.getSubjectiveAspectName()); + negativeBlame.setHandleResultCode(blame.getHandleResultCode()); + negativeBlame.setHandleResultName(blame.getHandleResultName()); + negativeBlame.setHandleResultNameOther(blame.getHandleResultNameOther()); + negativeBlame.setProtectRightsCode(blame.getProtectRightsCode()); + negativeBlame.setProtectRightsName(blame.getProtectRightsName()); + negativeBlame.setSuperviseMeasuresCode(blame.getSuperviseMeasuresCode()); + negativeBlame.setSuperviseMeasuresName(blame.getSuperviseMeasuresName()); + + // 责任领导 + negativeBlame.setLeadName(blame.getLeadName()); + negativeBlame.setLeadIdCode(blame.getLeadIdCode()); + negativeBlame.setLeadEmpNo(blame.getLeadEmpNo()); + negativeBlame.setLeadDepartId(blame.getLeadDepartId()); + negativeBlame.setLeadDepartName(blame.getLeadDepartName()); + negativeBlame.setLeadResponsibilityTypeCode(blame.getLeadResponsibilityTypeCode()); + negativeBlame.setLeadResponsibilityTypeName(blame.getLeadResponsibilityTypeName()); + negativeBlame.setLeadHandleResultCode(blame.getLeadHandleResultCode()); + negativeBlame.setLeadHandleResultName(blame.getLeadHandleResultName()); + negativeBlame.setLeadHandleResultNameOther(blame.getLeadHandleResultNameOther()); + negativeBlame.setLeadProtectRightsCode(blame.getLeadProtectRightsCode()); + negativeBlame.setLeadProtectRightsName(blame.getLeadProtectRightsName()); + negativeBlame.setLeadMeasuresCode(blame.getLeadResponsibilityTypeCode()); + negativeBlame.setLeadMeasuresName(blame.getLeadResponsibilityTypeName()); + + // 创建信息 + negativeBlame.setCrtTime(blame.getCreateTime()); + negativeBlame.setCrtUser(blame.getCreateBy()); + negativeBlame.setStatus("0"); + + return negativeBlame; + }).toList(); + + negativeBlameService.saveBatch(negativeBlames); + log.info("【已办结迁移】迁移涉及人: complaintId={}, count={}", complaintId, negativeBlames.size()); + } + + + + + @Override + @Transactional(rollbackFor = Exception.class) + public void addNegativeTemp(ComplaintCollectionPageRequest request) { + // 1. 查询待下发数据(status=0 且 negativeId为空) + ComplaintCollectionQueryParam queryParam = new ComplaintCollectionQueryParam(); + queryParam.setStatus("0"); // 初始状态 + queryParam.setOriginId(request.getOriginId()); + List pendingList = complaintCollectionResourceService.query(queryParam); + + // 过滤 negativeId 为空的数据 + List toDistribute = pendingList.stream() + .filter(cc -> StrUtil.isBlank(cc.getNegativeId())) + .toList(); + + if (CollectionUtil.isEmpty(toDistribute)) { + log.info("【我要下发】没有需要下发的数据"); + return; + } + + // 获取字典 + Map sourceDict = buildDictLabelMap(SupDictEnum.SFSS_SOURCE_TABLE.getCode()); + + int successCount = 0; + int skipCount = 0; + int failCount = 0; + + for (ComplaintCollection cc : toDistribute) { + try { + // 2. 判重检查 + if (negativeService.exists(cc.getOriginId())) { + log.info("【我要下发】跳过(Negative已存在): originId={}", cc.getOriginId()); + skipCount++; + continue; + } + + // 3. 构建 NegativeDto(调用 negativeService.save 走完整下发流程) + NegativeDto dto = buildNegativeDtoForDistribute(cc, sourceDict); + Negative negative = negativeService.save(dto); + + // 附件 + migrateFilesToNegative(cc.getId(), negative.getId()); + + // 4. 更新 ComplaintCollection.negativeId + ComplaintCollectionUpdateParam updateParam = new ComplaintCollectionUpdateParam(); + updateParam.setId(cc.getId()); + updateParam.setNegativeId(negative.getId()); + updateParam.setUpdateTime(LocalDateTime.now()); + updateParam.setUpdateBy(UserContextHolder.getCurrentUser().getUserName()); + complaintCollectionResourceService.updateSelectiveById(updateParam); + + log.info("【我要下发】下发成功: id={}, originId={}, negativeId={}", cc.getId(), cc.getOriginId(), negative.getId()); + successCount++; + + } catch (Exception e) { + log.error("【我要下发】下发失败: id={}, originId={}, error={}", cc.getId(), cc.getOriginId(), e.getMessage(), e); + failCount++; + } + } + + log.info("【我要下发】下发完成: 成功={}, 跳过={}, 失败={}", successCount, skipCount, failCount); + } + + /** + * 构建下发用的 NegativeDto + * 调用 negativeService.save() 走完整下发流程 + */ + private NegativeDto buildNegativeDtoForDistribute(ComplaintCollection cc, Map sourceDict) { + NegativeDto dto = new NegativeDto(); + + // ========== 从 ComplaintCollection 读取的字段 ========== + dto.setDiscoveryTime(cc.getDiscoveryTime()); + dto.setOriginId(cc.getOriginId()); + dto.setHappenTime(cc.getHappenTime()); + dto.setThingDesc(cc.getThingDesc()); + dto.setResponderName(cc.getResponderName()); + dto.setContactPhone(cc.getResponderPhone()); + dto.setCaseNumber(cc.getCaseNumber()); + dto.setPoliceType(cc.getPoliceType()); + dto.setPoliceTypeName(cc.getPoliceTypeName()); +// dto.setCheckStatus(cc.getCheckStatus()); +// dto.setCheckStatusName(cc.getCheckStatusName()); + + // 问题来源 + if (ComplaintCollectionSourceTableEnum.LEADER_ASSIGN.getCode().equals(cc.getSourceTable())) { + dto.setProblemSourcesCode(cc.getSourceTableSubOne()); + dto.setProblemSources(sourceDict.get(cc.getSourceTableSubOne())); + } else { + dto.setProblemSourcesCode(cc.getSourceTable()); + dto.setProblemSources(sourceDict.get(cc.getSourceTable())); + } + + // 业务类别 + dto.setBusinessTypeCode(cc.getBusinessTypeCode()); + + // 涉及单位用现在的二级单位 + dto.setInvolveDepartId(cc.getSecondDepartId()); + dto.setInvolveDepartName(cc.getSecondDepartName()); + + // 涉嫌问题 + if (StrUtil.isNotBlank(cc.getInvolveProblem())) { + dto.setInvolveProblem(Arrays.asList(cc.getInvolveProblem().split("[,,]"))); + } + + // ========== 写死字段(预留配置)========== + // 来源类型:投诉举报 + dto.setSourceType(NegativeSourceTypeEnum.COMPLAINT_REPORT.getCode()); + dto.setSourceTypeDesc(NegativeSourceTypeEnum.COMPLAINT_REPORT.getDesc()); + + // 主办层级(可配置) + dto.setHostLevel("2"); // TODO: 可配置 - 二级机构主办 + + // 办理时限(可配置) + dto.setTimeLimit("30+30"); // TODO: 可配置 - 30天 + + // 审批流程(可配置) + dto.setApprovalFlow("3"); + + // 办理单位 = 涉及单位 + dto.setDepartId(cc.getSecondDepartId()); + + + return dto; + } + + }