Browse Source

涉访涉诉--局长信箱数据自动抓取与自动更新定时任务

master
buaixuexideshitongxue 4 weeks ago
parent
commit
64c6675979
  1. 13
      src/main/java/com/biutag/supervision/controller/data/ComplaintCollectionController.java
  2. 378
      src/main/java/com/biutag/supervision/job/Job.java
  3. 38
      src/main/java/com/biutag/supervision/pojo/dto/complaintCollection/MailBoxCaptureToComplaintCollectionSaveDTO.java
  4. 20
      src/main/java/com/biutag/supervision/pojo/dto/mail/MailAttachmentDTO.java
  5. 2
      src/main/java/com/biutag/supervision/pojo/param/ComplaintCollection/ComplaintCollectionQueryParam.java
  6. 1
      src/main/java/com/biutag/supervision/repository/complaintCollection/ComplaintCollectionResourceService.java
  7. 21
      src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionServiceJob.java
  8. 92
      src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionServiceJobImpl.java

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

@ -1,5 +1,6 @@
package com.biutag.supervision.controller.data;
import com.biutag.supervision.job.Job;
import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.request.complaintCollection.*;
import com.biutag.supervision.pojo.vo.complaintCollection.ComplaintCollectionHandlerDataVo;
@ -16,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
/**
* @ClassName ComplaintCollectionController
* @Description 涉访涉诉控制层
@ -31,6 +34,8 @@ public class ComplaintCollectionController {
private final ComplaintCollectionService complaintCollectionService;
private final Job job;
@Operation(description = "添加")
@PostMapping("/addComplaintCollection")
public Result<Boolean> addComplaintCollection(@RequestBody ComplaintCollectionAddRequest request){
@ -52,6 +57,14 @@ public class ComplaintCollectionController {
@Operation(description = "查询")
@PostMapping("/getComplaintCollectionPage")
public Result<ComplaintCollectionPageVo> getComplaintCollectionPage(@RequestBody ComplaintCollectionPageRequest request){
if ("我要信箱".equals(request.getOriginId())){
LocalDateTime start = LocalDateTime.of(2026, 1, 7, 0, 0);
LocalDateTime end = LocalDateTime.of(2026, 1, 8, 0, 0);
job.mailBoxCaptureToComplaintCollection(start, end);
}
if ("我要更新".equals(request.getOriginId())){
job.updateMailBoxCaptureToComplaintCollection();
}
return complaintCollectionService.getComplaintCollectionPage(request);
}

378
src/main/java/com/biutag/supervision/job/Job.java

@ -2,16 +2,25 @@ package com.biutag.supervision.job;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.*;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.biutag.supervision.constants.enums.ComfortStatus;
import com.biutag.supervision.constants.enums.ProcessingStatusEnum;
import com.biutag.supervision.constants.enums.RightsCaseEnum;
import com.biutag.supervision.constants.enums.RpcApplyTypeEnum;
import com.biutag.supervision.constants.enums.*;
import com.biutag.supervision.mapper.*;
import com.biutag.supervision.pojo.dto.complaintCollection.MailBoxCaptureToComplaintCollectionSaveDTO;
import com.biutag.supervision.pojo.dto.mail.MailAttachmentDTO;
import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.pojo.entity.mailbox.Mail;
import com.biutag.supervision.pojo.enums.complaintCollection.ComplaintCollectionHandleMethodEnum;
import com.biutag.supervision.pojo.param.ComplaintCollection.ComplaintCollectionQueryParam;
import com.biutag.supervision.pojo.param.SupDepartQueryParam;
import com.biutag.supervision.pojo.param.SupExternalDepartQueryParam;
import com.biutag.supervision.repository.complaintCollection.ComplaintCollectionResourceService;
import com.biutag.supervision.repository.supExternalDepart.SupExternalDepartResourceService;
import com.biutag.supervision.repository.supdepart.SupDepartResourceService;
import com.biutag.supervision.service.*;
import com.biutag.supervision.service.complaintCollection.ComplaintCollectionServiceJob;
import com.biutag.supervision.util.CommonUtil;
import com.biutag.supervision.util.TimeUtil;
import lombok.RequiredArgsConstructor;
@ -23,11 +32,9 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneId;
import java.util.*;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.stream.Collectors;
import static com.biutag.supervision.util.TimeUtil.SECONDS_OF_A_DAY;
@ -47,6 +54,10 @@ public class Job {
private final MailService mailService;
private final SupExternalDepartResourceService supExternalDepartResourceService;
private final SupDepartResourceService supDepartResourceService;
private final ComplaintCollectionServiceJob complaintCollectionServiceJob;
private final ComplaintCollectionResourceService complaintCollectionResourceService;
// 更新办理超时
@Scheduled(fixedRate = 600000)
public void updateHandleTimeout() {
@ -60,7 +71,7 @@ public class Job {
list.forEach(item -> {
long remainingDuration = TimeUtil.getRemainingDuration(item.getCrtTime(), item.getCompleteDate(), NumberUtil.mul(item.getMaxHandleDuration(), SECONDS_OF_A_DAY).longValue()) + NumberUtil.mul(item.getMaxExtensionDuration(), SECONDS_OF_A_DAY).longValue();
negativeService.update(new LambdaUpdateWrapper<Negative>()
.set(Negative::getHandleTimeout, remainingDuration >= 0 ? 0: -remainingDuration)
.set(Negative::getHandleTimeout, remainingDuration >= 0 ? 0 : -remainingDuration)
.eq(Negative::getId, item.getId()));
});
}
@ -143,14 +154,14 @@ public class Job {
//获取过滤关键字
List<SupDictData> dictData =dictDataService.list(new LambdaQueryWrapper<SupDictData>().eq(SupDictData::getDictType,"protectRightsFile"));
List<SupDictData> dictData = dictDataService.list(new LambdaQueryWrapper<SupDictData>().eq(SupDictData::getDictType, "protectRightsFile"));
List<String> files = new ArrayList<>();
if(CollectionUtil.isNotEmpty(dictData)){
files=dictData.stream().map(s->s.getDictValue()).toList();
if (CollectionUtil.isNotEmpty(dictData)) {
files = dictData.stream().map(s -> s.getDictValue()).toList();
}
List<DwdAsjZfbaShrxx> shrxxList = dwdAsjZfbaShrxxService.list(startTime,endTime);
if(CollectionUtil.isEmpty(shrxxList)){
List<DwdAsjZfbaShrxx> shrxxList = dwdAsjZfbaShrxxService.list(startTime, endTime);
if (CollectionUtil.isEmpty(shrxxList)) {
log.info("时间范围内无受害人信息");
return;
}
@ -159,26 +170,26 @@ public class Job {
.filter(StrUtil::isNotBlank)
.distinct().toList();
List<TXsshrxxb> tXsshrxxbs = tXsshrxxbService.getListAllByZjs(zjList);
if(CollectionUtil.isEmpty(tXsshrxxbs)){
if (CollectionUtil.isEmpty(tXsshrxxbs)) {
log.info("未找到受伤民辅警");
return;
}
//单位数据 map
List<SupDepart> departs = departService.list();
//单位简称 map
Map<String,SupDepart> ShortNameMap = departs.stream().collect(Collectors.toMap(
Map<String, SupDepart> ShortNameMap = departs.stream().collect(Collectors.toMap(
SupDepart::getShortName, // Key提取函数
Function.identity(), // Value直接使用对象本身
(existing, replacement) -> existing // 解决键冲突(保留已有值)
));
//单位名称 map
Map<String,SupDepart> NameMap = departs.stream().collect(Collectors.toMap(
Map<String, SupDepart> NameMap = departs.stream().collect(Collectors.toMap(
SupDepart::getName, // Key提取函数
Function.identity(), // Value直接使用对象本身
(existing, replacement) -> existing // 解决键冲突(保留已有值)
));
//单位id map
Map<String,SupDepart> departIdMap = departs.stream().collect(Collectors.toMap(
Map<String, SupDepart> departIdMap = departs.stream().collect(Collectors.toMap(
SupDepart::getId, // Key提取函数
Function.identity(), // Value直接使用对象本身
(existing, replacement) -> existing // 解决键冲突(保留已有值)
@ -186,14 +197,14 @@ public class Job {
//受害人信息处理
tXsshrxxbs= tXsshrxxbs.stream().filter(s->StrUtil.isNotBlank(s.getGmsfhm())).map(s->{
tXsshrxxbs = tXsshrxxbs.stream().filter(s -> StrUtil.isNotBlank(s.getGmsfhm())).map(s -> {
SupPolice police = policeService.getByIdCode(s.getGmsfhm());
if(ObjectUtil.isNotEmpty(police)){
if (ObjectUtil.isNotEmpty(police)) {
s.setEmpNo(police.getEmpNo());
String departId = police.getOrgId();
s.setDepartId(departId);
s.setJob(police.getJob());
if(departIdMap.containsKey(departId)){
if (departIdMap.containsKey(departId)) {
s.setDepartName(departIdMap.get(departId).getShortName());
}
}
@ -201,34 +212,34 @@ public class Job {
}).toList();
log.info("受害人信息数量数据:{}条", tXsshrxxbs.size());
//处理为受害人map
Map<String,List<TXsshrxxb>> xsshrxxbMap =tXsshrxxbs.stream()
.filter(s->StrUtil.isNotBlank(s.getAjbh()))
Map<String, List<TXsshrxxb>> xsshrxxbMap = tXsshrxxbs.stream()
.filter(s -> StrUtil.isNotBlank(s.getAjbh()))
.collect(Collectors.groupingBy(TXsshrxxb::getAjbh));
log.info("处理后受害人数量数据:{}条", xsshrxxbMap.size());
List<String> ajbhList =new ArrayList<>(xsshrxxbMap.keySet());
List<String> ajbhList = new ArrayList<>(xsshrxxbMap.keySet());
//办案人员信息List
Map<String,DwdRyZfbaBaryxx> zfbaBaryxxMap=new HashMap<>();
Map<String, DwdRyZfbaBaryxx> zfbaBaryxxMap = new HashMap<>();
//案件 rpc_apply
for (String ajbh : ajbhList){
try{
for (String ajbh : ajbhList) {
try {
//获取案件基本信息
DwdAsjZfbaAjjbxx ajjbxx = dwdAsjZfbaAjjbxxMapper.selectByAjbh(ajbh);
if(ObjectUtil.isEmpty(ajjbxx)){
if (ObjectUtil.isEmpty(ajjbxx)) {
log.info("案件[" + ajbh + "]未找到基本信息");
continue;
}
List<String> file = files.stream().filter(s->ajjbxx.getAjmc().contains(s)).toList();
if(CollectionUtil.isNotEmpty(file)){
log.info("案件["+ajbh+"]已过滤,案件名称为["+ajjbxx.getAjmc()+"]");
List<String> file = files.stream().filter(s -> ajjbxx.getAjmc().contains(s)).toList();
if (CollectionUtil.isNotEmpty(file)) {
log.info("案件[" + ajbh + "]已过滤,案件名称为[" + ajjbxx.getAjmc() + "]");
continue;
}
String ajmc = ajjbxx.getAjmc();
String ajlbmc = ajjbxx.getAjlbmc();
List<String> rightsCaseEnums = Arrays.stream(RightsCaseEnum.values()).map(RightsCaseEnum::getDesc).toList();
if ( !rightsCaseEnums.contains(ajlbmc) && !ajmc.contains("袭警") ){
log.info("案件["+ajbh+"]已过滤,案件名称为["+ajjbxx.getAjmc()+"]");
if (!rightsCaseEnums.contains(ajlbmc) && !ajmc.contains("袭警")) {
log.info("案件[" + ajbh + "]已过滤,案件名称为[" + ajjbxx.getAjmc() + "]");
continue;
}
//获取受害人列表
@ -238,18 +249,18 @@ public class Job {
// continue;
// }
//嫌疑人
List<DwdAsjZfbaWfrwfxx> wfrwfxxes = dwdAsjZfbaWfrwfxxMapper.selectList(new LambdaQueryWrapper<DwdAsjZfbaWfrwfxx>().eq(DwdAsjZfbaWfrwfxx::getAjbh,ajbh));
List<DwdAsjZfbaWfrwfxx> wfrwfxxes = dwdAsjZfbaWfrwfxxMapper.selectList(new LambdaQueryWrapper<DwdAsjZfbaWfrwfxx>().eq(DwdAsjZfbaWfrwfxx::getAjbh, ajbh));
//办案人
DwdRyZfbaBaryxx dwdRyZfbaBaryxx =zfbaBaryxxMap.computeIfAbsent(
DwdRyZfbaBaryxx dwdRyZfbaBaryxx = zfbaBaryxxMap.computeIfAbsent(
ajjbxx.getBar1id(),
k-> dwdRyZfbaBaryxxService.selectDataById(k)
k -> dwdRyZfbaBaryxxService.selectDataById(k)
);
//受害人警号查询
TXsshrxxb oneShr = tXsshrxxbList.get(0);
RpcApply rpcApply =new RpcApply();
RpcApply rpcApply = new RpcApply();
//1、案件基本信息
rpcApply.setNumber(ajbh);
rpcApply.setCaseNumber(ajbh);
@ -281,15 +292,15 @@ public class Job {
rpcApply.setCaseType("2");
}
if(StrUtil.isNotEmpty(ajjbxx.getBadwidmc())){
if (StrUtil.isNotEmpty(ajjbxx.getBadwidmc())) {
String unitName = ajjbxx.getBadwidmc();
log.info("单位名称:",ajjbxx.getBadwidmc());
if(!unitName.contains("长沙市公安局")){
log.info("单位名称:", ajjbxx.getBadwidmc());
if (!unitName.contains("长沙市公安局")) {
unitName = unitName.split("湖南省")[1];
}
if(NameMap.containsKey(unitName)){
if (NameMap.containsKey(unitName)) {
//处理单位
SupDepart supDepart=NameMap.get(unitName);
SupDepart supDepart = NameMap.get(unitName);
rpcApply.setHandleDepartId(supDepart.getId());
rpcApply.setHandleDepartName(supDepart.getShortName());
//获取二级单位的信息
@ -316,13 +327,13 @@ public class Job {
}
}
}
if(ShortNameMap.containsKey(statisticsGroupName)){
SupDepart groupDept= ShortNameMap.get(statisticsGroupName);
if (ShortNameMap.containsKey(statisticsGroupName)) {
SupDepart groupDept = ShortNameMap.get(statisticsGroupName);
rpcApply.setSecondDepartId(groupDept.getId());
}
}
if(StrUtil.isNotBlank(rpcApply.getHandleDepartId())){
if (StrUtil.isNotBlank(rpcApply.getHandleDepartId())) {
rpcApply.setHandleDepartName(ajjbxx.getBadwidmc());
}
@ -332,16 +343,16 @@ public class Job {
// 已办结
rpcApply.setRpcStatus(ComfortStatus.completed.name());
//办案人
if(ObjectUtil.isNotEmpty(dwdRyZfbaBaryxx) && StrUtil.isNotBlank(dwdRyZfbaBaryxx.getZjhm())){
if (ObjectUtil.isNotEmpty(dwdRyZfbaBaryxx) && StrUtil.isNotBlank(dwdRyZfbaBaryxx.getZjhm())) {
SupPolice policeData = policeService.getByIdCode(dwdRyZfbaBaryxx.getZjhm());
if(ObjectUtil.isNotEmpty(policeData)){
if (ObjectUtil.isNotEmpty(policeData)) {
rpcApply.setInputEmpNo(policeData.getEmpNo());
}else{
} else {
log.info("未找到身份证号[" + dwdRyZfbaBaryxx.getZjhm() + "]对应的警察信息");
}
}
//嫌疑人
if(ArrayUtil.isNotEmpty(wfrwfxxes)){
if (ArrayUtil.isNotEmpty(wfrwfxxes)) {
String suspectNames = wfrwfxxes.stream()
.filter(obj -> StrUtil.isNotBlank(obj.getXm()))
.map(DwdAsjZfbaWfrwfxx::getXm)
@ -366,7 +377,7 @@ public class Job {
}
//去除历史数据后,需调整为rpc_id
rpcApplyService.remove(new LambdaQueryWrapper<RpcApply>().eq(RpcApply::getNumber,ajbh).eq(RpcApply::getType,"1"));
rpcApplyService.remove(new LambdaQueryWrapper<RpcApply>().eq(RpcApply::getNumber, ajbh).eq(RpcApply::getType, "1"));
rpcApply.setCaseCategory(ajjbxx.getAjlbmc());
boolean saveSuccess = rpcApplyService.saveOrUpdate(rpcApply);
if (!saveSuccess || ObjectUtils.isEmpty(rpcApply.getRpcId())) {
@ -374,12 +385,12 @@ public class Job {
continue;
}
//嫌疑人
if(CollectionUtil.isNotEmpty(wfrwfxxes)){
if (CollectionUtil.isNotEmpty(wfrwfxxes)) {
for (DwdAsjZfbaWfrwfxx suspect : wfrwfxxes) {
try{
if(StrUtil.isNotEmpty(suspect.getZjhm())){
try {
if (StrUtil.isNotEmpty(suspect.getZjhm())) {
//去除历史数据后,需删除
rpcInfringerResultService.remove(new LambdaQueryWrapper<RpcInfringerResult>().eq(RpcInfringerResult::getIdCode,suspect.getZjhm()));
rpcInfringerResultService.remove(new LambdaQueryWrapper<RpcInfringerResult>().eq(RpcInfringerResult::getIdCode, suspect.getZjhm()));
}
RpcInfringerResult result = new RpcInfringerResult();
result.setId(IdUtil.fastSimpleUUID());
@ -392,30 +403,30 @@ public class Job {
result.setGender(gender);
}
rpcInfringerResultService.saveOrUpdate(result);
}catch (Exception e){
log.info( "处理嫌疑人[" + suspect.getXm() + "]信息时发生异常:" + e.getMessage());
} catch (Exception e) {
log.info("处理嫌疑人[" + suspect.getXm() + "]信息时发生异常:" + e.getMessage());
}
}
}
for (TXsshrxxb victim : tXsshrxxbList){
try{
for (TXsshrxxb victim : tXsshrxxbList) {
try {
RpcApplyPerson person = new RpcApplyPerson();
person.setRpcId(rpcApply.getRpcId());
person.setType(RpcApplyTypeEnum.RIGHTS_PROTECTION.getValue());
person.setEmpNo(victim.getEmpNo());
person.setEmpName(victim.getXm());
person.setIdCode(victim.getGmsfhm());
if(StrUtil.isNotEmpty(victim.getXbmc()) ){
person.setGender("1".equals(victim.getXbmc())?"男":"女");
if (StrUtil.isNotEmpty(victim.getXbmc())) {
person.setGender("1".equals(victim.getXbmc()) ? "男" : "女");
}
rpcApplyPersonService.saveOrUpdate(person);
}catch (Exception e){
} catch (Exception e) {
log.info("处理受害人[" + victim.getXm() + "]信息时发生异常:" + e.getMessage());
}
}
log.info("案件[" + ajbh + "]维权信息处理完成");
}catch (Exception e){
} catch (Exception e) {
log.info("处理案件[" + ajbh + "]时发生异常:" + e.getMessage());
}
@ -423,41 +434,41 @@ public class Job {
}
private final ZhkshDutyScheduleDcMapper zhkshDutyScheduleDcMapper;
private final SupRotaMapper supRotaMapper;
//每天一次 00:20:00
//值班人员
@Scheduled(cron = "0 20 12 * * ?")
public void operator(){
public void operator() {
log.info("operator--------------------");
log.info("值班人员抓取中---------------------");
//1、值班人员数据获取
LocalDate startTime = LocalDate.now();
LocalDate endTime = startTime.plusMonths(1);
List<ZhkshDutyScheduleDc> zhkshDutyScheduleDcs = zhkshDutyScheduleDcMapper.selectList(startTime,endTime);
if(CollectionUtil.isEmpty(zhkshDutyScheduleDcs)){
List<ZhkshDutyScheduleDc> zhkshDutyScheduleDcs = zhkshDutyScheduleDcMapper.selectList(startTime, endTime);
if (CollectionUtil.isEmpty(zhkshDutyScheduleDcs)) {
log.warn("无值班人员");
return;
}
//获取库中已有的值班数据(符合时间条件)
List<SupRota> rotas= supRotaMapper.selectList(new LambdaQueryWrapper<SupRota>().between(SupRota::getStartTime,startTime,endTime));
List<SupRota> rotas = supRotaMapper.selectList(new LambdaQueryWrapper<SupRota>().between(SupRota::getStartTime, startTime, endTime));
//剔除已录入过的数据
if(CollectionUtil.isNotEmpty(rotas)){
if (CollectionUtil.isNotEmpty(rotas)) {
List<String> rotaIds = rotas.stream().map(SupRota::getScheduleId).toList();
zhkshDutyScheduleDcs=zhkshDutyScheduleDcs.stream().filter(x-> !rotaIds.contains(x.getScheduleId())).toList();
zhkshDutyScheduleDcs = zhkshDutyScheduleDcs.stream().filter(x -> !rotaIds.contains(x.getScheduleId())).toList();
}
List<SupRota> supRotaList = CommonUtil.copyBeanList(zhkshDutyScheduleDcs,SupRota.class);
List<SupRota> supRotaList = CommonUtil.copyBeanList(zhkshDutyScheduleDcs, SupRota.class);
//2、值班人员数据处理
supRotaList.forEach(s->{
supRotaList.forEach(s -> {
//获取数字督察一体系统对应的id
List<SupExternalDepart> supExternalDeparts= externalDepartService.list(
List<SupExternalDepart> supExternalDeparts = externalDepartService.list(
new LambdaQueryWrapper<SupExternalDepart>()
.eq(SupExternalDepart::getExternalId,s.getDeptCode())
.eq(SupExternalDepart::getExternalId, s.getDeptCode())
);
if(CollectionUtil.isEmpty(supExternalDeparts)){
if (CollectionUtil.isEmpty(supExternalDeparts)) {
log.info("值班人员对应的值班单位不存在");
}else{
} else {
SupExternalDepart depart = supExternalDeparts.get(0);
s.setDeptCode(depart.getInternalId());
s.setDeptName(depart.getInternalName());
@ -467,4 +478,225 @@ public class Job {
supRotaMapper.insert(supRotaList);
log.info("值班数据录入完成");
}
// 局长信箱数据抓取到涉访涉诉
@Scheduled(cron = "0 0 1 * * ?")
public void mailBoxCaptureToComplaintCollection() {
LocalDateTime start = LocalDate.now().minusDays(1).atStartOfDay();
LocalDateTime end = LocalDate.now().atStartOfDay();
mailBoxCaptureToComplaintCollection(start, end);
}
@Scheduled(cron = "0 0 * * * ?")
public void updateMailBoxCaptureToComplaintCollection() {
log.info("【局长信箱回填】开始同步核查信息到ComplaintCollection...");
ComplaintCollectionQueryParam complaintCollectionQueryParam = new ComplaintCollectionQueryParam();
complaintCollectionQueryParam.setSourceTable("23");
complaintCollectionQueryParam.setStatus("0");
List<ComplaintCollection> collectionList = complaintCollectionResourceService.query(complaintCollectionQueryParam);
if (CollectionUtil.isEmpty(collectionList)) {
log.info("【局长信箱回填】无待同步数据");
return;
}
log.info("【局长信箱回填】获取到待处理 ComplaintCollection 条数:{}", CollectionUtil.size(collectionList));
// 所有局长信箱编号
Set<String> mailIds = collectionList.stream().map(ComplaintCollection::getOriginId).filter(StrUtil::isNotBlank).collect(Collectors.toSet());
if (CollectionUtil.isEmpty(mailIds)) {
log.warn("【局长信箱回填】ComplaintCollection 中无有效 originId");
return;
}
log.info("【局长信箱回填】提取到 originId 数量:{}", mailIds.size());
List<Mail> mailList = mailService.list(new LambdaQueryWrapper<Mail>().in(Mail::getId, mailIds));
if (CollectionUtil.isEmpty(mailList)) {
log.info("【局长信箱回填】Mail 表未查到任何数据");
return;
}
log.info("【局长信箱回填】查询到 Mail 记录条数:{}", mailList.size());
Map<String, Mail> mailMap = mailList.stream().collect(Collectors.toMap(Mail::getId, Function.identity()));
List<ComplaintCollection> toUpdate = new ArrayList<>();
Map<String, List<MailAttachmentDTO>> verifyAttachMap = new HashMap<>();
for (ComplaintCollection cc : collectionList) {
Mail mail = mailMap.get(cc.getOriginId());
if (mail == null) {
log.warn("【局长信箱回填】未找到 Mail,originId={},跳过。", cc.getOriginId());
continue;
}
if ("属实".equals(mail.getVerifyIsTrue())) {
cc.setCheckStatus("1");
cc.setCheckStatusName("属实");
} else if ("基本属实".equals(mail.getVerifyIsTrue())) {
cc.setCheckStatus("2");
cc.setCheckStatusName("基本属实");
}
cc.setCheckStatusDesc(mail.getVerifyDetails());
cc.setProcessingStatus(mail.getMailState());
toUpdate.add(cc);
// 附件
List<MailAttachmentDTO> attachList = parseAttachments(mail.getVerifyAttachments());
if (CollectionUtil.isNotEmpty(attachList)) {
verifyAttachMap.put(cc.getOriginId(), attachList);
}
}
if (CollectionUtil.isEmpty(toUpdate)) {
log.info("【局长信箱回填】无可更新数据");
return;
}
MailBoxCaptureToComplaintCollectionSaveDTO dto = new MailBoxCaptureToComplaintCollectionSaveDTO();
dto.setComplaintCollectionList(toUpdate);
dto.setVerifyAttachMap(verifyAttachMap);
log.info("【局长信箱回填】准备提交更新,更新条数:{},含附件的 originId 数:{}", toUpdate.size(), verifyAttachMap.size());
complaintCollectionServiceJob.saveComplaintAndAttachments(dto);
log.info("【局长信箱回填】处理完成。");
}
public void mailBoxCaptureToComplaintCollection(LocalDateTime start, LocalDateTime end) {
log.info("【局长信箱抓取】时间范围 {} ~ {}", start, end);
long startTimeMillis = System.currentTimeMillis();
log.info("开始抓取局长信箱数据到涉访涉诉--------------------");
log.info("【局长信箱抓取】查询条件:mailFirstCategory in [举报类, 投诉类], 时间范围 {} ~ {}", start, end);
try {
LambdaQueryWrapper<Mail> mailLambdaQueryWrapper = new LambdaQueryWrapper<>();
mailLambdaQueryWrapper.in(Mail::getMailFirstCategory, "举报类", "投诉类");
mailLambdaQueryWrapper.between(Mail::getMailTime, start, end);
List<Mail> mailList = mailService.list(mailLambdaQueryWrapper);
log.info("【局长信箱抓取】查询到 Mail 数量:{}", mailList.size());
if (CollectionUtil.isEmpty(mailList)) {
log.warn("【局长信箱抓取】未查询到任何数据,任务结束");
return;
}
List<ComplaintCollection> complaintCollectionToSave = new ArrayList<>();
Map<String, List<MailAttachmentDTO>> complaintAttachMap = new HashMap<>();
Map<String, List<MailAttachmentDTO>> verifyAttachMap = new HashMap<>();
int successCount = 0;
int failCount = 0;
for (Mail mail : mailList) {
ComplaintCollection complaintCollection = buildComplaintCollection(mail);
// 投诉单位
Integer threeDeptId = mail.getThreeDeptId();
if (threeDeptId == null) {
failCount++;
log.warn("【局长信箱抓取】跳过 mail,threeDeptId 为空,mailId={}, source={}", mail.getId(), mail.getSource());
continue;
}
SupExternalDepartQueryParam threeDepQueryParam = new SupExternalDepartQueryParam();
threeDepQueryParam.setSource("局长信箱");
threeDepQueryParam.setExternalIds(Collections.singleton(String.valueOf(threeDeptId)));
List<SupExternalDepart> supExternalDeparts = supExternalDepartResourceService.query(threeDepQueryParam);
if (CollectionUtil.isEmpty(supExternalDeparts)) {
failCount++;
log.warn("【局长信箱抓取】跳过 mail,未找到 SupExternalDepart,mailId={}, threeDeptId={}", mail.getId(), threeDeptId);
continue;
}
SupExternalDepart supExternalDepart = supExternalDeparts.get(0);
SupDepartQueryParam secondDepartQueryParam = new SupDepartQueryParam();
secondDepartQueryParam.setId(supExternalDepart.getInternalId());
List<SupDepart> threeDeparts = supDepartResourceService.query(secondDepartQueryParam);
if (CollectionUtil.isEmpty(threeDeparts)) {
failCount++;
log.warn("【局长信箱抓取】跳过 mail,未找到对应三级单位,mailId={}, internalId={}", mail.getId(), supExternalDepart.getInternalId());
continue;
}
SupDepart threeDepart = threeDeparts.get(0);
SupDepartQueryParam threeDepartQueryParam = new SupDepartQueryParam();
threeDepartQueryParam.setId(supExternalDepart.getPid());
List<SupDepart> secondDeparts = supDepartResourceService.query(threeDepartQueryParam);
if (CollectionUtil.isEmpty(secondDeparts)) {
failCount++;
log.warn("【局长信箱抓取】跳过 mail,未找对应到二级单位,mailId={}, pid={}", mail.getId(), supExternalDepart.getPid());
continue;
}
SupDepart secondDepart = secondDeparts.get(0);
complaintCollection.setSecondDepartId(secondDepart.getId());
complaintCollection.setSecondDepartName(secondDepart.getShortName());
complaintCollection.setThirdDepartId(threeDepart.getId());
complaintCollection.setThirdDepartName(threeDepart.getShortName());
complaintCollection.setThingDesc(mail.getContent());
complaintAttachMap.put(mail.getId(), parseAttachments(mail.getAttachments()));
verifyAttachMap.put(mail.getId(), parseAttachments(mail.getVerifyAttachments()));
complaintCollectionToSave.add(complaintCollection);
successCount++;
}
if (CollectionUtil.isEmpty(complaintCollectionToSave)) {
log.warn("【局长信箱抓取】所有 Mail 均被跳过,无可保存的主数据");
return;
}
MailBoxCaptureToComplaintCollectionSaveDTO mailBoxCaptureToComplaintCollectionSaveDTO = new MailBoxCaptureToComplaintCollectionSaveDTO();
mailBoxCaptureToComplaintCollectionSaveDTO.setComplaintCollectionList(complaintCollectionToSave);
mailBoxCaptureToComplaintCollectionSaveDTO.setComplaintAttachMap(complaintAttachMap);
mailBoxCaptureToComplaintCollectionSaveDTO.setVerifyAttachMap(verifyAttachMap);
complaintCollectionServiceJob.saveComplaintAndAttachments(mailBoxCaptureToComplaintCollectionSaveDTO);
long cost = System.currentTimeMillis() - startTimeMillis;
log.info("【局长信箱抓取】完成,总数:{},成功:{},失败:{},耗时:{}ms", mailList.size(), successCount, failCount, cost);
} catch (Exception e) {
log.error("【局长信箱抓取】任务执行过程中发生严重异常,任务中断", e);
}
}
private String getSfssSourceTableSubOne(String str) {
if ("厅长信箱".equals(str)) {
return "23_tz";
}
if ("mailbox".equals(str)) {
return "23_jz";
}
if ("110_report_complaints".equals(str)) {
return "23_jb";
}
return "";
}
private ComplaintCollection buildComplaintCollection(Mail mail) {
ComplaintCollection complaintCollection = new ComplaintCollection();
complaintCollection.setSourceTable("23");
complaintCollection.setSourceTableSubOne(getSfssSourceTableSubOne(mail.getSource()));
complaintCollection.setOriginId(mail.getId());
complaintCollection.setDiscoveryTime(mail.getMailTime());
complaintCollection.setResponderName(mail.getContactName());
complaintCollection.setResponderPhone(mail.getContactPhone());
complaintCollection.setResponderIdCode(mail.getContactIdCard());
complaintCollection.setThingDesc(mail.getContent());
complaintCollection.setAccountabilityTarget(AccountabilityTargetEnum.PERSONAL.getValue());
// 核查情况
if ("属实".equals(mail.getVerifyIsTrue())) {
complaintCollection.setCheckStatus(InspectCaseEnum.TRUE.getValue());
complaintCollection.setCheckStatusName(InspectCaseEnum.TRUE.getLabel());
} else if ("基本属实".equals(mail.getVerifyIsTrue())) {
complaintCollection.setCheckStatus(InspectCaseEnum.PARTIALLY_TRUE.getValue());
complaintCollection.setCheckStatusName(InspectCaseEnum.PARTIALLY_TRUE.getLabel());
}
complaintCollection.setCheckStatusDesc(mail.getVerifyDetails());
// 状态字段
complaintCollection.setProcessingStatus(mail.getMailState());
complaintCollection.setProblemSources(ProblemSourcesEnum.JZXX.getLabel());
complaintCollection.setProblemSourcesCode(ProblemSourcesEnum.JZXX.getValue());
// complaintCollection.setBusinessTypeCode(BusinessTypeEnum.QT.getValue());
// complaintCollection.setBusinessTypeName(BusinessTypeEnum.QT.getLabel());
complaintCollection.setHandleMethod(ComplaintCollectionHandleMethodEnum.XF.getCode());
complaintCollection.setStatus("0");
complaintCollection.setCreateTime(LocalDateTime.now());
complaintCollection.setCreateBy("自动抓取");
return complaintCollection;
}
private List<MailAttachmentDTO> parseAttachments(String json) {
if (StrUtil.isBlank(json)) {
return Collections.emptyList();
}
try {
List<MailAttachmentDTO> mailAttachmentDTOS = JSON.parseArray(json, MailAttachmentDTO.class);
mailAttachmentDTOS.forEach(item -> {
String filepath = "http://65.47.60.145/lan-api/api/file/stream/" + item.getFilepath();
item.setFilepath(filepath);
});
return mailAttachmentDTOS;
} catch (Exception e) {
log.warn("【局长信箱抓取】附件 JSON 解析失败,json={}", json, e);
return Collections.emptyList();
}
}
}

38
src/main/java/com/biutag/supervision/pojo/dto/complaintCollection/MailBoxCaptureToComplaintCollectionSaveDTO.java

@ -0,0 +1,38 @@
package com.biutag.supervision.pojo.dto.complaintCollection;
import com.biutag.supervision.pojo.dto.mail.MailAttachmentDTO;
import com.biutag.supervision.pojo.entity.ComplaintCollection;
import com.biutag.supervision.pojo.entity.ComplaintCollectionBlame;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
/**
* @ClassName MailBoxCaptureToComplaintCollectionSaveDTO
* @Description 局长信箱数据到涉访涉诉保存dto
* @Author shihao
* @Date 2026/1/7 14:51
*/
@Getter
@Setter
@Schema(description = "局长信箱数据到涉访涉诉保存dto")
public class MailBoxCaptureToComplaintCollectionSaveDTO {
@Schema(description = "涉访涉诉主信息")
List<ComplaintCollection> complaintCollectionList;
@Schema(description = "局长信箱附件对应的涉访涉诉基本内容附件")
Map<String, List<MailAttachmentDTO>> complaintAttachMap;
@Schema(description = "局长信箱附件对应的涉访涉诉核查内容附件")
Map<String, List<MailAttachmentDTO>> verifyAttachMap;
@Schema(description = "局长信箱对应的责任人数据")
List<ComplaintCollectionBlame> complaintCollectionBlameList;
}

20
src/main/java/com/biutag/supervision/pojo/dto/mail/MailAttachmentDTO.java

@ -0,0 +1,20 @@
package com.biutag.supervision.pojo.dto.mail;
import com.alibaba.fastjson2.annotation.JSONField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "局长信箱附件对象")
public class MailAttachmentDTO {
private String filepath;
@JSONField(alternateNames ={"origiinFilename", "originFilename", "orgiinFilename"})
private String originFilename;
private String type;
/** 前端是字符串,这里建议转成 Long */
private Long size;
}

2
src/main/java/com/biutag/supervision/pojo/param/ComplaintCollection/ComplaintCollectionQueryParam.java

@ -89,6 +89,8 @@ public class ComplaintCollectionQueryParam extends BasePage {
@Schema(description = "联系电话")
private String responderPhone;
@Schema(description = "状态")
private String status;
// @Schema(description = "部门ID集合")
// private Set<String> secondDepartIds;

1
src/main/java/com/biutag/supervision/repository/complaintCollection/ComplaintCollectionResourceService.java

@ -42,6 +42,7 @@ public class ComplaintCollectionResourceService extends BaseDAO {
queryWrapper.eq(StrUtil.isNotBlank(param.getSourceTable()), ComplaintCollection::getSourceTable, param.getSourceTable());
queryWrapper.eq(StrUtil.isNotBlank(param.getResponderName()), ComplaintCollection::getResponderName, param.getResponderName());
queryWrapper.eq(StrUtil.isNotBlank(param.getResponderPhone()), ComplaintCollection::getResponderPhone, param.getResponderPhone());
queryWrapper.eq(StrUtil.isNotBlank(param.getStatus()), ComplaintCollection::getStatus, param.getStatus());
if (queryWrapper.getExpression() == null || queryWrapper.getExpression().getSqlSegment().isEmpty()) {
return Collections.emptyList();
}

21
src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionServiceJob.java

@ -0,0 +1,21 @@
package com.biutag.supervision.service.complaintCollection;
import com.biutag.supervision.pojo.dto.complaintCollection.MailBoxCaptureToComplaintCollectionSaveDTO;
/**
* @ClassName ComplaintCollectionService
* @Description 涉访涉诉服务层JOb
* @Author shihao
* @Date 2025/12/23 17:24
*/
public interface ComplaintCollectionServiceJob {
/**
* 抓取局长信箱数据
* @param mailBoxCaptureToComplaintCollectionSaveDTO
*/
void saveComplaintAndAttachments(MailBoxCaptureToComplaintCollectionSaveDTO mailBoxCaptureToComplaintCollectionSaveDTO);
}

92
src/main/java/com/biutag/supervision/service/complaintCollection/ComplaintCollectionServiceJobImpl.java

@ -0,0 +1,92 @@
package com.biutag.supervision.service.complaintCollection;
import cn.hutool.core.collection.CollectionUtil;
import com.biutag.supervision.pojo.dto.complaintCollection.MailBoxCaptureToComplaintCollectionSaveDTO;
import com.biutag.supervision.pojo.dto.mail.MailAttachmentDTO;
import com.biutag.supervision.pojo.entity.ComplaintCollection;
import com.biutag.supervision.pojo.entity.ComplaintCollectionCheckFile;
import com.biutag.supervision.pojo.entity.ComplaintCollectionFile;
import com.biutag.supervision.repository.complaintCollection.ComplaintCollectionResourceService;
import com.biutag.supervision.repository.complaintCollectionCheckFile.ComplaintCollectionCheckFileResourceService;
import com.biutag.supervision.repository.complaintCollectionFile.ComplaintCollectionFileResourceService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*;
/**
* @ClassName ComplaintCollectionService
* @Description 涉访涉诉服务层JOb
* @Author shihao
* @Date 2025/12/23 17:24
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class ComplaintCollectionServiceJobImpl implements ComplaintCollectionServiceJob {
private final ComplaintCollectionFileResourceService complaintCollectionFileResourceService;
private final ComplaintCollectionCheckFileResourceService complaintCollectionCheckFileResourceService;
private final ComplaintCollectionResourceService complaintCollectionResourceService;
@Override
@Transactional(rollbackFor = Exception.class)
public void saveComplaintAndAttachments(MailBoxCaptureToComplaintCollectionSaveDTO mailBoxCaptureToComplaintCollectionSaveDTO) {
List<ComplaintCollection> toSave = mailBoxCaptureToComplaintCollectionSaveDTO.getComplaintCollectionList();
Map<String, List<MailAttachmentDTO>> complaintAttachMap = Optional.ofNullable(mailBoxCaptureToComplaintCollectionSaveDTO.getComplaintAttachMap())
.orElse(Collections.emptyMap());
Map<String, List<MailAttachmentDTO>> verifyAttachMap = Optional.ofNullable(mailBoxCaptureToComplaintCollectionSaveDTO.getVerifyAttachMap())
.orElse(Collections.emptyMap());
List<ComplaintCollection> saved = complaintCollectionResourceService.saveOrUpdateComplaintCollection(toSave);
for (ComplaintCollection cc : saved) {
String originId = cc.getOriginId();
saveComplaintFiles(cc, complaintAttachMap.getOrDefault(originId, Collections.emptyList()));
saveCheckFiles(cc, verifyAttachMap.getOrDefault(originId, Collections.emptyList()));
}
}
private void saveComplaintFiles(ComplaintCollection collection, List<MailAttachmentDTO> attachments) {
if (CollectionUtil.isEmpty(attachments)) {
return;
}
List<ComplaintCollectionFile> files = new ArrayList<>();
for (MailAttachmentDTO dto : attachments) {
ComplaintCollectionFile file = new ComplaintCollectionFile();
file.setComplaintId(collection.getId());
file.setFilePath(dto.getFilepath());
file.setFileName(dto.getOriginFilename());
file.setCreateBy("自动抓取");
file.setCreateTime(LocalDateTime.now());
files.add(file);
}
complaintCollectionFileResourceService.delByComplaintCollectionId(collection.getId());
complaintCollectionFileResourceService.createComplaintCollectionFile(files);
}
private void saveCheckFiles(ComplaintCollection complaint, List<MailAttachmentDTO> attachments) {
if (CollectionUtil.isEmpty(attachments)) {
return;
}
List<ComplaintCollectionCheckFile> files = new ArrayList<>();
for (MailAttachmentDTO dto : attachments) {
ComplaintCollectionCheckFile file = new ComplaintCollectionCheckFile();
file.setComplaintId(complaint.getId());
file.setFilePath(dto.getFilepath());
file.setFileName(dto.getOriginFilename());
file.setCheckStatus(complaint.getCheckStatus());
file.setCheckStatusName(complaint.getCheckStatusName());
file.setCreateBy("自动抓取");
file.setCreateTime(LocalDateTime.now());
files.add(file);
}
complaintCollectionCheckFileResourceService.delByComplaintCollectionId(complaint.getId());
complaintCollectionCheckFileResourceService.createComplaintCollectionCheckFile(files);
}
}
Loading…
Cancel
Save