Browse Source

feat:投诉举报历史数据迁移

feature/tsjb-1.0
buaixuexideshitongxue 3 weeks ago
parent
commit
564c3031f1
  1. 6
      src/main/java/com/biutag/supervision/controller/data/ComplaintCollectionController.java
  2. 5
      src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionService.java
  3. 386
      src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionServiceImpl.java

6
src/main/java/com/biutag/supervision/controller/data/ComplaintCollectionController.java

@ -58,6 +58,12 @@ public class ComplaintCollectionController {
@Operation(description = "查询")
@PostMapping("/getComplaintCollectionPageNew")
public Result<Page<ComplaintCollectionPageDTO>> getComplaintCollectionPageNew(@RequestBody ComplaintCollectionPageRequest request){
if ("我要迁移".equals(request.getPersonInfo())){
complaintCollectionService.moveNegativeTemp(request);
}
if ("我要下发".equals(request.getPersonInfo())){
complaintCollectionService.addNegativeTemp(request);
}
return Result.success(complaintCollectionService.getComplaintCollectionPageNew(request));
}

5
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<ComplaintCollectionDetailVo> getComplaintCollectionDetail(ComplaintCollectionDetailRequest request);
void moveNegativeTemp(ComplaintCollectionPageRequest request);
void addNegativeTemp(ComplaintCollectionPageRequest request);
}

386
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<ComplaintCollection> pendingList = complaintCollectionResourceService.query(queryParam);
// 过滤出 negativeId 为空的数据
List<ComplaintCollection> toMigrate = pendingList.stream()
.filter(cc -> StrUtil.isBlank(cc.getNegativeId()))
.toList();
if (CollectionUtil.isEmpty(toMigrate)) {
log.info("【已办结迁移】没有需要迁移的已办结数据");
return;
}
// 获取字典翻译Map
Map<String, String> 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<String, String> 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<ComplaintCollectionFile> files = complaintCollectionFileResourceService.query(fileParam);
if (CollectionUtil.isEmpty(files)) {
return;
}
List<NegativeThingFile> 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<ComplaintCollectionCheckFile> checkFiles = complaintCollectionCheckFileResourceService.query(fileParam);
if (CollectionUtil.isEmpty(checkFiles)) {
return;
}
List<NegativeFile> 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<ComplaintCollectionBlame> blames = complaintCollectionBlameResourceService.query(blameParam);
if (CollectionUtil.isEmpty(blames)) {
return;
}
List<NegativeBlame> 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<ComplaintCollection> pendingList = complaintCollectionResourceService.query(queryParam);
// 过滤 negativeId 为空的数据
List<ComplaintCollection> toDistribute = pendingList.stream()
.filter(cc -> StrUtil.isBlank(cc.getNegativeId()))
.toList();
if (CollectionUtil.isEmpty(toDistribute)) {
log.info("【我要下发】没有需要下发的数据");
return;
}
// 获取字典
Map<String, String> 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<String, String> 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;
}
}

Loading…
Cancel
Save