From 6c3d3505cfe59ff8999aa8573ed1f46dfd9a7711 Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Wed, 17 Jun 2026 15:55:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B1=80=E9=95=BF=E4=BF=A1=E7=AE=B1?= =?UTF-8?q?=E5=AD=90=E4=BF=A1=E4=BB=B6=E7=94=A8=E7=94=A8=E4=B8=BB=E4=BF=A1?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supervision/mapper/MailSourceMapper.java | 13 ++ .../pojo/entity/mailbox/MailSource.java | 116 ++++++++++++++++++ .../pojo/param/MailSourceQueryParam.java | 67 ++++++++++ .../mail/MailSourceResourceService.java | 87 +++++++++++++ .../service/MailBoxCaptureService.java | 22 ++++ 5 files changed, 305 insertions(+) create mode 100644 src/main/java/com/biutag/supervision/mapper/MailSourceMapper.java create mode 100644 src/main/java/com/biutag/supervision/pojo/entity/mailbox/MailSource.java create mode 100644 src/main/java/com/biutag/supervision/pojo/param/MailSourceQueryParam.java create mode 100644 src/main/java/com/biutag/supervision/repository/mail/MailSourceResourceService.java diff --git a/src/main/java/com/biutag/supervision/mapper/MailSourceMapper.java b/src/main/java/com/biutag/supervision/mapper/MailSourceMapper.java new file mode 100644 index 0000000..f1adc41 --- /dev/null +++ b/src/main/java/com/biutag/supervision/mapper/MailSourceMapper.java @@ -0,0 +1,13 @@ +package com.biutag.supervision.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.biutag.supervision.pojo.entity.mailbox.MailSource; + +/** + * @author + * @date + */ +@DS("mailbox") +public interface MailSourceMapper extends BaseMapper { +} diff --git a/src/main/java/com/biutag/supervision/pojo/entity/mailbox/MailSource.java b/src/main/java/com/biutag/supervision/pojo/entity/mailbox/MailSource.java new file mode 100644 index 0000000..d20c64d --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/entity/mailbox/MailSource.java @@ -0,0 +1,116 @@ +package com.biutag.supervision.pojo.entity.mailbox; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +/** + * @ClassName MailSource + * @Description 信件源数据 + * @Author + * @Date + */ +@Accessors(chain = true) +@Getter +@Setter +@Schema(description = "信件源数据") +@TableName("mail_source") +public class MailSource { + + @Schema(description = "主键ID") + @TableId + @TableField("id") + private String id; + + @Schema(description = "联系人姓名") + @TableField("contact_name") + private String contactName; + + @Schema(description = "联系人性别") + @TableField("contact_sex") + private String contactSex; + + @Schema(description = "联系人身份证号") + @TableField("contact_id_card") + private String contactIdCard; + + @Schema(description = "联系人手机号") + @TableField("contact_phone") + private String contactPhone; + + @Schema(description = "案件编号") + @TableField("case_number") + private String caseNumber; + + @Schema(description = "内容") + @TableField("content") + private String content; + + @Schema(description = "附件") + @TableField("attachments") + private String attachments; + + @Schema(description = "创建时间") + @TableField("create_time") + private LocalDateTime createTime; + + @Schema(description = "更新时间") + @TableField("update_time") + private LocalDateTime updateTime; + + @Schema(description = "来源") + @TableField("source") + private String source; + + @Schema(description = "状态") + @TableField("state") + private String state; + + @Schema(description = "信件ID") + @TableField("mail_id") + private String mailId; + + @Schema(description = "来信时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField("mail_time") + private LocalDateTime mailTime; + + @Schema(description = "信件类别") + @TableField("mail_type") + private String mailType; + + @Schema(description = "涉及单位ID") + @TableField("involved_dept_id") + private Integer involvedDeptId; + + @Schema(description = "涉及单位名称") + @TableField("involved_dept_name") + private String involvedDeptName; + + @Schema(description = "签收标识") + @TableField("sign_flag") + private Boolean signFlag; + + @Schema(description = "AI判断状态") + @TableField("ai_determine_state") + private String aiDetermineState; + + @Schema(description = "AI判断数量") + @TableField("ai_determine_total") + private Integer aiDetermineTotal; + + @Schema(description = "是否复核") + @TableField("revisit") + private Boolean revisit; + + @Schema(description = "数据来源平台") + @TableField("data_source_platform") + private String dataSourcePlatform; +} diff --git a/src/main/java/com/biutag/supervision/pojo/param/MailSourceQueryParam.java b/src/main/java/com/biutag/supervision/pojo/param/MailSourceQueryParam.java new file mode 100644 index 0000000..4aecd3c --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/param/MailSourceQueryParam.java @@ -0,0 +1,67 @@ +package com.biutag.supervision.pojo.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Set; + +/** + * @ClassName MailSourceQueryParam + * @Description 信件源数据查询参数 + * @Author + * @Date + */ +@Getter +@Setter +@Schema(description = "信件源数据查询参数") +public class MailSourceQueryParam extends BasePage { + + @Schema(description = "主键") + private String id; + + @Schema(description = "主键集合") + private Set ids; + + @Schema(description = "信件表ID") + private String mailId; + + @Schema(description = "信件表ID集合") + private Set mailIds; + + @Schema(description = "联系人姓名") + private String contactName; + + @Schema(description = "联系人手机号") + private String contactPhone; + + @Schema(description = "案件编号") + private String caseNumber; + + @Schema(description = "来源") + private String source; + + @Schema(description = "状态") + private String state; + + @Schema(description = "信件类别") + private String mailType; + + @Schema(description = "涉及单位ID") + private Integer involvedDeptId; + + @Schema(description = "AI判断状态") + private String aiDetermineState; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private List createTime = new ArrayList<>(); + + @Schema(description = "来信时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private List mailTime = new ArrayList<>(); +} diff --git a/src/main/java/com/biutag/supervision/repository/mail/MailSourceResourceService.java b/src/main/java/com/biutag/supervision/repository/mail/MailSourceResourceService.java new file mode 100644 index 0000000..d3e9066 --- /dev/null +++ b/src/main/java/com/biutag/supervision/repository/mail/MailSourceResourceService.java @@ -0,0 +1,87 @@ +package com.biutag.supervision.repository.mail; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.biutag.supervision.mapper.MailSourceMapper; +import com.biutag.supervision.pojo.entity.mailbox.MailSource; +import com.biutag.supervision.pojo.param.MailSourceQueryParam; +import com.biutag.supervision.repository.base.BaseDAO; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * @ClassName MailSourceResourceService + * @Description 信件源数据资源层 + * @Author + * @Date + */ +@Service +public class MailSourceResourceService extends BaseDAO { + + @Resource + private MailSourceMapper mailSourceMapper; + + public List query(MailSourceQueryParam param) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + setBatchQuery(param.getMailId(), param.getMailIds(), queryWrapper, MailSource::getMailId); + queryWrapper.eq(StrUtil.isNotBlank(param.getId()), MailSource::getId, param.getId()); + queryWrapper.in(CollectionUtil.isNotEmpty(param.getIds()), MailSource::getId, param.getIds()); + queryWrapper.eq(StrUtil.isNotBlank(param.getContactPhone()), MailSource::getContactPhone, param.getContactPhone()); + queryWrapper.eq(StrUtil.isNotBlank(param.getCaseNumber()), MailSource::getCaseNumber, param.getCaseNumber()); + queryWrapper.eq(StrUtil.isNotBlank(param.getState()), MailSource::getState, param.getState()); + queryWrapper.eq(StrUtil.isNotBlank(param.getSource()), MailSource::getSource, param.getSource()); + queryWrapper.eq(StrUtil.isNotBlank(param.getMailType()), MailSource::getMailType, param.getMailType()); + queryWrapper.eq(StrUtil.isNotBlank(param.getAiDetermineState()), MailSource::getAiDetermineState, param.getAiDetermineState()); + queryWrapper.eq(Objects.nonNull(param.getInvolvedDeptId()), MailSource::getInvolvedDeptId, param.getInvolvedDeptId()); + queryWrapper.eq(StrUtil.isNotBlank(param.getContactName()), MailSource::getContactName, param.getContactName()); + if (!param.getMailTime().isEmpty() && param.getMailTime().size() >= 2) { + queryWrapper.between(MailSource::getMailTime, param.getMailTime().get(0), param.getMailTime().get(1)); + } + if (!param.getCreateTime().isEmpty() && param.getCreateTime().size() >= 2) { + queryWrapper.between(MailSource::getCreateTime, param.getCreateTime().get(0), param.getCreateTime().get(1)); + } + if (queryWrapper.getExpression() == null || queryWrapper.getExpression().getSqlSegment().isEmpty()) { + return Collections.emptyList(); + } + return mailSourceMapper.selectList(queryWrapper); + } + + public long count(MailSourceQueryParam param) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(StrUtil.isNotBlank(param.getId()), MailSource::getId, param.getId()); + queryWrapper.in(CollectionUtil.isNotEmpty(param.getIds()), MailSource::getId, param.getIds()); + queryWrapper.eq(StrUtil.isNotBlank(param.getContactPhone()), MailSource::getContactPhone, param.getContactPhone()); + queryWrapper.eq(StrUtil.isNotBlank(param.getState()), MailSource::getState, param.getState()); + queryWrapper.eq(StrUtil.isNotBlank(param.getMailType()), MailSource::getMailType, param.getMailType()); + if (CollectionUtil.isNotEmpty(param.getCreateTime()) && param.getCreateTime().size() >= 2) { + queryWrapper.between(MailSource::getCreateTime, param.getCreateTime().get(0), param.getCreateTime().get(1)); + } + if (CollectionUtil.isNotEmpty(param.getMailTime()) && param.getMailTime().size() >= 2) { + queryWrapper.between(MailSource::getMailTime, param.getMailTime().get(0), param.getMailTime().get(1)); + } + return mailSourceMapper.selectCount(queryWrapper); + } + + public Page page(MailSourceQueryParam param) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(StrUtil.isNotBlank(param.getId()), MailSource::getId, param.getId()); + queryWrapper.in(CollectionUtil.isNotEmpty(param.getIds()), MailSource::getId, param.getIds()); + queryWrapper.eq(StrUtil.isNotBlank(param.getContactPhone()), MailSource::getContactPhone, param.getContactPhone()); + queryWrapper.eq(StrUtil.isNotBlank(param.getCaseNumber()), MailSource::getCaseNumber, param.getCaseNumber()); + queryWrapper.eq(StrUtil.isNotBlank(param.getState()), MailSource::getState, param.getState()); + queryWrapper.eq(StrUtil.isNotBlank(param.getSource()), MailSource::getSource, param.getSource()); + queryWrapper.eq(StrUtil.isNotBlank(param.getMailType()), MailSource::getMailType, param.getMailType()); + queryWrapper.eq(StrUtil.isNotBlank(param.getContactName()), MailSource::getContactName, param.getContactName()); + if (!param.getMailTime().isEmpty() && param.getMailTime().size() >= 2) { + queryWrapper.between(MailSource::getMailTime, param.getMailTime().get(0), param.getMailTime().get(1)); + } + queryWrapper.orderByDesc(MailSource::getCreateTime); + return mailSourceMapper.selectPage(new Page<>(param.getCurrent(), param.getSize()), queryWrapper); + } +} diff --git a/src/main/java/com/biutag/supervision/service/MailBoxCaptureService.java b/src/main/java/com/biutag/supervision/service/MailBoxCaptureService.java index f6f8362..42b665d 100644 --- a/src/main/java/com/biutag/supervision/service/MailBoxCaptureService.java +++ b/src/main/java/com/biutag/supervision/service/MailBoxCaptureService.java @@ -20,6 +20,7 @@ import com.biutag.supervision.pojo.entity.*; import com.biutag.supervision.pojo.entity.mailbox.Mail; import com.biutag.supervision.pojo.entity.mailbox.MailBlame; import com.biutag.supervision.pojo.entity.mailbox.MailExtension; +import com.biutag.supervision.pojo.entity.mailbox.MailSource; import com.biutag.supervision.pojo.enums.complaintCollection.ComplaintCollectionInitialEnum; import com.biutag.supervision.pojo.enums.complaintCollection.ComplaintCollectionPublicApprovalEnum; import com.biutag.supervision.pojo.enums.complaintCollection.ComplaintCollectionSourceTableEnum; @@ -27,10 +28,12 @@ import com.biutag.supervision.pojo.enums.negative.NegativeSourceTypeEnum; import com.biutag.supervision.pojo.param.ComplaintCollection.ComplaintCollectionQueryParam; import com.biutag.supervision.pojo.param.ComplaintCollection.ComplaintCollectionUpdateParam; import com.biutag.supervision.pojo.param.MailQueryParam; +import com.biutag.supervision.pojo.param.MailSourceQueryParam; 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.mail.MailResourceService; +import com.biutag.supervision.repository.mail.MailSourceResourceService; import com.biutag.supervision.repository.supExternalDepart.SupExternalDepartResourceService; import com.biutag.supervision.repository.supdepart.SupDepartResourceService; import com.biutag.supervision.service.complaintCollection.ComplaintCollectionService; @@ -82,6 +85,7 @@ public class MailBoxCaptureService { private final ComplaintCollectionService complaintCollectionService; private static final DateTimeFormatter INITIAL_REVIEW_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private static final int CHECK_LIMIT_DAYS = 4; + private final MailSourceResourceService mailSourceResourceService ; // ==================== 阶段1:抓取来信 ==================== @@ -162,6 +166,15 @@ public class MailBoxCaptureService { for (ComplaintCollection cc : completedList) { try { String originId = cc.getOriginId(); + // 先去看看有没有主信件 + MailSourceQueryParam mailSourceQueryParam = new MailSourceQueryParam(); + mailSourceQueryParam.setId(originId); + mailSourceQueryParam.setState("merge"); + List mailSourceList = mailSourceResourceService.query(mailSourceQueryParam); + if (CollectionUtil.isNotEmpty(mailSourceList)) { + log.info("这是合并子件:{}, 找到主件{}", originId, mailSourceList.get(0).getMailId()); + originId = mailSourceList.get(0).getMailId(); + } // 查询信件 MailQueryParam param = new MailQueryParam(); param.setId(originId); @@ -778,6 +791,15 @@ public class MailBoxCaptureService { for (ComplaintCollection cc : mailBoxList) { try { String originId = cc.getOriginId(); + // 先看看有没有主信件(合并件场景) + MailSourceQueryParam mailSourceQueryParam = new MailSourceQueryParam(); + mailSourceQueryParam.setId(originId); + mailSourceQueryParam.setState("merge"); + List mailSourceList = mailSourceResourceService.query(mailSourceQueryParam); + if (CollectionUtil.isNotEmpty(mailSourceList)) { + log.info("【延期同步】合并子件:{}, 找到主件{}", originId, mailSourceList.get(0).getMailId()); + originId = mailSourceList.get(0).getMailId(); + } // 查询延期信息(可扩展:后续可能来自多个来源) MailExtension extension = fetchExtensionInfo(originId); if (extension == null) {