Browse Source

和局长信箱对接

厅长信箱
wxc 4 months ago
parent
commit
1ecda05983
  1. 4
      mailbox-ai/src/main/java/com/biutag/ai/service/MailNlpService.java
  2. 26
      mailbox-lan/src/main/java/com/biutag/lan/flow/node/DistributeFlow.java
  3. 11
      mailbox-lan/src/main/java/com/biutag/lan/job/MailboxJob.java

4
mailbox-ai/src/main/java/com/biutag/ai/service/MailNlpService.java

@ -106,10 +106,10 @@ public class MailNlpService extends ServiceImpl<MailNlpMapper, MailNlp> {
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);
}

26
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<Mail>().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;
}
// 更新信件

11
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<Mail> mails = mailService.list(new LambdaQueryWrapper<Mail>()
.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<Mail> updateWrapper = new LambdaUpdateWrapper<>();
Mail source = mailDomain.getMail();
updateWrapper.eq(Mail::getId, mail.getId())

Loading…
Cancel
Save