From 1ecda05983c3357980484d37054c7730ad2c55ad Mon Sep 17 00:00:00 2001 From: wxc <191104855@qq.com> Date: Thu, 31 Jul 2025 18:32:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=92=8C=E5=B1=80=E9=95=BF=E4=BF=A1=E7=AE=B1?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/biutag/ai/service/MailNlpService.java | 4 +-- .../biutag/lan/flow/node/DistributeFlow.java | 26 ++++++++++++++++--- .../java/com/biutag/lan/job/MailboxJob.java | 11 +++++--- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/mailbox-ai/src/main/java/com/biutag/ai/service/MailNlpService.java b/mailbox-ai/src/main/java/com/biutag/ai/service/MailNlpService.java index 0822ea8..2a5e035 100644 --- a/mailbox-ai/src/main/java/com/biutag/ai/service/MailNlpService.java +++ b/mailbox-ai/src/main/java/com/biutag/ai/service/MailNlpService.java @@ -106,10 +106,10 @@ public class MailNlpService extends ServiceImpl { if (depts.get(0).getLevel() == 3) { mailNlp.setThreeDeptId(depts.get(0).getId()).setThreeDeptName(depts.get(0).getName()); Dept dept = deptMapper.selectById(depts.get(0).getPid()); - mailNlp.setSecondDeptId(dept.getId()).setSecondDeptName(dept.getShortName()); + //mailNlp.setSecondDeptId(dept.getId()).setSecondDeptName(dept.getShortName()); } if (depts.get(0).getLevel() == 2) { - mailNlp.setSecondDeptId(depts.get(0).getId()).setSecondDeptName(depts.get(0).getName()); + //mailNlp.setSecondDeptId(depts.get(0).getId()).setSecondDeptName(depts.get(0).getName()); } return saveOrUpdate(mailNlp); } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/DistributeFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/DistributeFlow.java index dd4fd0b..9d5494e 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/DistributeFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/DistributeFlow.java @@ -3,10 +3,13 @@ package com.biutag.lan.flow.node; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.digest.MD5; +import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.biutag.constants.AppConstants; import com.biutag.enums.RoleEnum; import com.biutag.exception.BusinessException; @@ -48,7 +51,7 @@ public class DistributeFlow extends Flow { private final String key = "mailbox"; - @Value("mailbox.url:''") + @Value("${mailbox.url:''}") private String mailboxUrl; @Value("${spring.profiles.active}") @@ -75,6 +78,13 @@ public class DistributeFlow extends Flow { Flow nextNode = next.get(nextActionKey); if (AppConstants.CHANGSHA_DEPT_ID.equals(mainDeptId) && "prod".equals(active)) { + mailService.update(new LambdaUpdateWrapper().eq(Mail::getId, mailId) + .set(Mail::getCurrentOperator, "长沙市公安局专班") + .set(Mail::getFlowKey, nextNode.getFlowNode().getKey()) + .set(Mail::getFlowName, nextNode.getFlowNode().getBeforeName()) + .set(Mail::getFlowLimitedLastHandlerTime, now) + .set(Mail::getFirstDeptId, AppConstants.CHANGSHA_DEPT_ID)); + MailApiV1Req mailApiV1Req = new MailApiV1Req(); BeanUtils.copyProperties(mail, mailApiV1Req); mailApiV1Req.setInvolvedDeptId(null); @@ -95,14 +105,22 @@ public class DistributeFlow extends Flow { jsonObject.put("base64", base64); } } - mail.setAttachments(jsonArray.toJSONString()); + mailApiV1Req.setAttachments(jsonArray.toJSONString()); } long timestamp = new Date().getTime(); // 上传 - HttpUtil.createPost(mailboxUrl + "/v1/mail") + HttpResponse httpResponse = HttpUtil.createPost(mailboxUrl + "/v1/mail") .header("timestamp", String.valueOf(timestamp)) .auth(MD5.create().digestHex(key + timestamp)) - .body(JSON.toJSONString(mailApiV1Req)).execute(); + .body(JSON.toJSONString(mailApiV1Req)) + .execute(); + if (!httpResponse.isOk()) { + throw new RuntimeException("推送数据(长沙局长信箱)异常,状态码:" + httpResponse.getStatus() + "。请联系管理员"); + } + JSONObject result = JSON.parseObject(httpResponse.body()); + if (result.getInteger("code") != 200) { + throw new RuntimeException("推送数据(长沙局长信箱)异常,msg:" + result.getString("msg") + "。请联系管理员"); + } return nextNode; } // 更新信件 diff --git a/mailbox-lan/src/main/java/com/biutag/lan/job/MailboxJob.java b/mailbox-lan/src/main/java/com/biutag/lan/job/MailboxJob.java index 0c9aeaa..55932f8 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/job/MailboxJob.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/job/MailboxJob.java @@ -5,6 +5,7 @@ import cn.hutool.crypto.digest.MD5; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.biutag.constants.AppConstants; @@ -48,24 +49,28 @@ public class MailboxJob { private final String key = "mailbox"; - @Value("mailbox.url:''") + @Value("${mailbox.url:''}") private String mailboxUrl; /** * 每30分钟执行一次 */ - @Scheduled(cron = "0 *,30 * * * *") + @Scheduled(cron = "0 */5 * * * *") public void updateMail() { + log.info("updateMail------------------------------------------------------------------"); List mails = mailService.list(new LambdaQueryWrapper() .eq(Mail::getFirstDeptId, AppConstants.CHANGSHA_DEPT_ID) .in(Mail::getMailState, List.of(MailState.processing.getValue(), MailState.delayed.getValue()))); + log.info("获取信件数量:" + mails.size()); long timestamp = new Date().getTime(); for (Mail mail : mails) { HttpResponse httpResponse = HttpUtil.createGet(mailboxUrl + "/v1/mail/detail?mailId=" + mail.getId()) .header("timestamp", String.valueOf(timestamp)) .auth(MD5.create().digestHex(key + timestamp)) .execute(); - MailDomain mailDomain = JSON.parseObject(httpResponse.body(), MailDomain.class); + JSONObject result = JSON.parseObject(httpResponse.body()); + MailDomain mailDomain = result.getObject("data", MailDomain.class); + log.info("获取信件信息:" + httpResponse.body()); LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); Mail source = mailDomain.getMail(); updateWrapper.eq(Mail::getId, mail.getId())