From fee17cce9cd46be48e4d13123bf6dc8b07cf17ae Mon Sep 17 00:00:00 2001 From: wxc <191104855@qq.com> Date: Wed, 6 Mar 2024 18:32:02 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=A4=96=E7=BD=91=E4=BF=A1=E4=BB=B6?= =?UTF-8?q?=E3=80=81=E4=BF=A1=E4=BB=B6=E8=AF=84=E4=BB=B7=E3=80=81=E5=81=87?= =?UTF-8?q?=E6=97=A5=E6=95=B0=E6=8D=AE=E6=8E=A8=E9=80=81=E5=88=B0=E5=86=85?= =?UTF-8?q?=E7=BD=91=202.=20=E5=BE=AE=E4=BF=A1=E9=85=8D=E7=BD=AE=E8=B0=83?= =?UTF-8?q?=E6=95=B4=203.=20websocket=20=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flow.json | 3 + mailbox-lan/pom.xml | 13 ++ .../biutag/lan/config/WebSocketConfig.java | 24 +++ .../lan/controller/ApiV1Controller.java | 46 +++++- .../biutag/lan/controller/FileController.java | 6 +- .../biutag/lan/controller/HomeController.java | 2 +- .../main/java/com/biutag/lan/domain/Mail.java | 5 + .../lan/domain/MailExtensionApproval.java | 3 + .../biutag/lan/domain/bo/HolidayV1Req.java | 31 ++++ .../biutag/lan/domain/bo/MailApiV1Req.java | 3 +- .../lan/domain/bo/MailEvaluateApiV1Req.java | 23 +++ .../domain/vo/MailExtensionApprovalVo.java | 20 +++ .../java/com/biutag/lan/domain/vo/MailVo.java | 2 +- .../lan/flow/node/FirstApprovalFlow.java | 5 +- .../biutag/lan/flow/node/ThreeVerifyFlow.java | 10 +- .../biutag/lan/mapper/DataScreenMapper.java | 3 - .../service/MailExtensionApprovalService.java | 10 +- .../biutag/lan/service/MailReturnService.java | 3 +- .../com/biutag/lan/service/MailService.java | 26 +++- .../java/com/biutag/lan/ws/WsController.java | 18 +++ ...erMapper.xml => MailEvaluateEtlMapper.xml} | 0 .../outer/controller/SmsController.java | 14 +- .../java/com/biutag/outer/domain/Mail.java | 10 +- .../biutag/outer/domain/MailEvaluateEtl.java | 27 ++++ .../main/java/com/biutag/outer/job/Job.java | 145 ++++++++++++++++++ .../java/com/biutag/outer/job/MailJob.java | 82 ---------- .../biutag/outer/mapper/HolidayMapper.java | 13 ++ .../outer/mapper/MailEvaluateEtlMapper.java | 10 ++ .../com/biutag/outer/mapper/MailMapper.java | 3 + .../java/com/biutag/outer/util/Weixin.java | 8 +- .../java/com/biutag/outer/util/Weixin2.java | 9 +- .../src/main/resources/application-prod.yml | 11 +- mailbox-outer/src/test/java/SmsTest.java | 35 ++--- .../java/com/biutag/outer/Base64Test.java | 29 ++++ sql/0307.sql | 9 ++ 35 files changed, 515 insertions(+), 146 deletions(-) create mode 100644 mailbox-lan/src/main/java/com/biutag/lan/config/WebSocketConfig.java create mode 100644 mailbox-lan/src/main/java/com/biutag/lan/domain/bo/HolidayV1Req.java create mode 100644 mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailEvaluateApiV1Req.java create mode 100644 mailbox-lan/src/main/java/com/biutag/lan/domain/vo/MailExtensionApprovalVo.java create mode 100644 mailbox-lan/src/main/java/com/biutag/lan/ws/WsController.java rename mailbox-lan/src/main/resources/mapper/{PoliceUserMapper.xml => MailEvaluateEtlMapper.xml} (100%) create mode 100644 mailbox-outer/src/main/java/com/biutag/outer/domain/MailEvaluateEtl.java create mode 100644 mailbox-outer/src/main/java/com/biutag/outer/job/Job.java delete mode 100644 mailbox-outer/src/main/java/com/biutag/outer/job/MailJob.java create mode 100644 mailbox-outer/src/main/java/com/biutag/outer/mapper/HolidayMapper.java create mode 100644 mailbox-outer/src/main/java/com/biutag/outer/mapper/MailEvaluateEtlMapper.java create mode 100644 mailbox-outer/src/test/java/com/biutag/outer/Base64Test.java create mode 100644 sql/0307.sql diff --git a/flow.json b/flow.json index e69de29..752e1f9 100644 --- a/flow.json +++ b/flow.json @@ -0,0 +1,3 @@ +{ + "base64": "data:image/jpg;base64,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z0I/WtyK0SNX8w72l++x79qhNg7L5LzM0XTZgdPTPWmFzRGMcUUUUiT//R7GiiiszMKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/0uxooorMzCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA/9k=" +} \ No newline at end of file diff --git a/mailbox-lan/pom.xml b/mailbox-lan/pom.xml index ea9d3bc..e99659a 100644 --- a/mailbox-lan/pom.xml +++ b/mailbox-lan/pom.xml @@ -39,6 +39,19 @@ spring-boot-starter-websocket + + jakarta.websocket + jakarta.websocket-api + 2.2.0-M1 + provided + + + jakarta.websocket + jakarta.websocket-client-api + 2.2.0-M1 + provided + + com.tongweb.springboot tongweb-spring-boot-starter-3.x diff --git a/mailbox-lan/src/main/java/com/biutag/lan/config/WebSocketConfig.java b/mailbox-lan/src/main/java/com/biutag/lan/config/WebSocketConfig.java new file mode 100644 index 0000000..8e6180e --- /dev/null +++ b/mailbox-lan/src/main/java/com/biutag/lan/config/WebSocketConfig.java @@ -0,0 +1,24 @@ +package com.biutag.lan.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.messaging.simp.config.MessageBrokerRegistry; +import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; +import org.springframework.web.socket.config.annotation.StompEndpointRegistry; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; + +@EnableWebSocketMessageBroker +@Configuration +public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { + + @Override + public void configureMessageBroker(MessageBrokerRegistry registry) { + registry.setApplicationDestinationPrefixes("/app"); + registry.enableSimpleBroker("/topic","/queue"); + } + + @Override + public void registerStompEndpoints(StompEndpointRegistry registry) { + registry.addEndpoint("/port").setAllowedOriginPatterns("*").withSockJS(); + } + +} diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/ApiV1Controller.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/ApiV1Controller.java index 5f85fbd..242651c 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/ApiV1Controller.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/ApiV1Controller.java @@ -2,22 +2,28 @@ package com.biutag.lan.controller; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.digest.MD5; -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.biutag.config.Minio; import com.biutag.core.AjaxResult; +import com.biutag.entity.system.Holiday; import com.biutag.exception.AuthException; import com.biutag.exception.BusinessException; +import com.biutag.lan.domain.Mail; import com.biutag.lan.domain.MailSource; +import com.biutag.lan.domain.bo.HolidayV1Req; import com.biutag.lan.domain.bo.MailApiV1Req; +import com.biutag.lan.domain.bo.MailEvaluateApiV1Req; +import com.biutag.lan.service.HolidayService; +import com.biutag.lan.service.MailService; import com.biutag.lan.service.MailSourceService; +import com.biutag.util.IOUtil; import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; import org.simpleframework.xml.core.Validate; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import java.util.Collections; @@ -32,10 +38,17 @@ public class ApiV1Controller { private final MailSourceService mailSourceService; + private final MailService mailService; + + private final HolidayService holidayService; + private final Minio minio; private final String key = "mailbox"; + @Value("${spring.profiles.active}") + private String active; + @PostMapping("mail") public AjaxResult addMail(@RequestBody @Valid MailApiV1Req mail, HttpServletRequest request) { validAuth(request); @@ -45,7 +58,10 @@ public class ApiV1Controller { if (StrUtil.isNotBlank(mail.getAttachments())) { List attachments = JSON.parseArray(mail.getAttachments()).toList(JSONObject.class); for (JSONObject attachment : attachments) { - //minio.upload(IOUtil.base64ToStream(attachment.getString("base64")), attachment.getString("filepath"), true); + if (active.equals("dev")) { + continue; + } + minio.upload(IOUtil.base64ToStream(attachment.getString("base64")), attachment.getString("filepath"), true); attachment.remove("base64"); } mail.setAttachments(JSON.toJSONString(attachments)); @@ -54,6 +70,30 @@ public class ApiV1Controller { return AjaxResult.success(); } + @PutMapping("mail/evaluate") + public AjaxResult updateMail(@RequestBody @Valid MailEvaluateApiV1Req req, HttpServletRequest request) { + validAuth(request); + Mail mail = mailService.getById(req.getId()); + if (Objects.isNull(mail)) { + throw new BusinessException("信件不存在或信件还未签收"); + } + mail.setSatisfaction(mail.getSatisfaction()); + mailService.updateById(mail); + return AjaxResult.success(); + } + + @PostMapping("holiday") + public AjaxResult addHoliday(@RequestBody @Valid List holidays, HttpServletRequest request) { + validAuth(request); + for (HolidayV1Req holiday : holidays) { + if (holidayService.exists(new LambdaQueryWrapper().eq(Holiday::getDate, holiday.getDate()))) { + continue; + } + holidayService.save(holiday.toEntity()); + } + return AjaxResult.success(); + } + private void validAuth(HttpServletRequest request) { String authorization = request.getHeader("Authorization"); String timestamp = request.getHeader("timestamp"); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/FileController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/FileController.java index 2fcc698..88d8bd7 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/FileController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/FileController.java @@ -39,7 +39,11 @@ public class FileController { @PostMapping("upload/base64") public AjaxResult upload(@RequestBody JSONObject file) { log.info("文件上传 base64: {}", file.toJSONString()); - String filepath = minio.upload(file.getString("base64")); + String base64 = file.getString("base64"); + if (base64.startsWith("data:image")) { + base64 = base64.substring(base64.indexOf(",") + 1); + } + String filepath = minio.upload(base64); return AjaxResult.success(JSONObject.of("filepath", filepath)); } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/HomeController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/HomeController.java index df5bc1d..52662cd 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/HomeController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/HomeController.java @@ -100,7 +100,7 @@ public class HomeController { // 今日办结 long completedToday = mailMarkService.countByCompleted(today); // 累计来信 - long mailTotal = mailSourceService.count(); + long mailTotal = mailMarkService.count(); // 累计办结 long completedTotal = mailMarkService.countByCompleted(); // 累计办结 diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/Mail.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/Mail.java index 44c12ff..d630177 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/Mail.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/Mail.java @@ -315,6 +315,11 @@ public class Mail { */ private String currentOperator; + /** + * 申请延期ID + */ + private String extensionRequestId; + /** * 是否申请延期 */ diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/MailExtensionApproval.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/MailExtensionApproval.java index dba9f96..138ded0 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/MailExtensionApproval.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/MailExtensionApproval.java @@ -15,6 +15,9 @@ public class MailExtensionApproval { @TableId(type = IdType.AUTO) private Integer id; + + private String requestId; + /** * */ diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/HolidayV1Req.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/HolidayV1Req.java new file mode 100644 index 0000000..d333534 --- /dev/null +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/HolidayV1Req.java @@ -0,0 +1,31 @@ +package com.biutag.lan.domain.bo; + +import com.biutag.entity.system.Holiday; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; +import org.springframework.beans.BeanUtils; + +@Setter +@Getter +public class HolidayV1Req { + + @NotBlank + private String date; + + @NotBlank + private String holidayFlag; + + @NotNull + private String detail; + + @NotNull + private Integer year; + + public Holiday toEntity() { + Holiday holiday = new Holiday(); + BeanUtils.copyProperties(this, holiday); + return holiday; + } +} diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailApiV1Req.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailApiV1Req.java index 0459115..1f2978f 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailApiV1Req.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailApiV1Req.java @@ -3,6 +3,7 @@ package com.biutag.lan.domain.bo; import com.biutag.lan.domain.MailSource; import com.biutag.validator.annotation.IdCard; import com.biutag.validator.annotation.Phone; +import com.fasterxml.jackson.annotation.JsonFormat; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Getter; @@ -67,7 +68,7 @@ public class MailApiV1Req { * 创建时间 */ @NotNull - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createTime; /** diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailEvaluateApiV1Req.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailEvaluateApiV1Req.java new file mode 100644 index 0000000..9e1590b --- /dev/null +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/bo/MailEvaluateApiV1Req.java @@ -0,0 +1,23 @@ +package com.biutag.lan.domain.bo; + +import jakarta.validation.constraints.NotBlank; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class MailEvaluateApiV1Req { + + /** + * + */ + @NotBlank + private String id; + + /** + * 满意读 + */ + @NotBlank + private String satisfaction; + +} diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/MailExtensionApprovalVo.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/MailExtensionApprovalVo.java new file mode 100644 index 0000000..ab33361 --- /dev/null +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/MailExtensionApprovalVo.java @@ -0,0 +1,20 @@ +package com.biutag.lan.domain.vo; + +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Accessors(chain = true) +@Setter +@Getter +public class MailExtensionApprovalVo { + + private String name; + + private Boolean active; + + private Boolean returnFlag; + + private String comment; + +} diff --git a/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/MailVo.java b/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/MailVo.java index 698bc5c..46a5875 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/MailVo.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/domain/vo/MailVo.java @@ -358,7 +358,7 @@ public class MailVo { */ private List countersigns = new ArrayList<>(); - private List extensionApprovals = new ArrayList<>(); + private List extensionApprovals = new ArrayList<>(); public static MailVo of(Mail mail) { MailVo mailVo = new MailVo(); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java index d360982..12a2c39 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/FirstApprovalFlow.java @@ -81,6 +81,9 @@ public class FirstApprovalFlow extends Flow { mailService.updateById(mail); // 认定办结 MailMark mailMark = mailMarkService.getById(mailId); + if (Objects.isNull(mailMark)) { + mailMark = new MailMark().setMailId(mailId); + } mailMark.setSecondDeptId(mail.getSecondDeptId()) .setSecondDeptName(mail.getSecondDeptName()) .setThreeDeptId(mail.getThreeDeptId()) @@ -89,7 +92,7 @@ public class FirstApprovalFlow extends Flow { .setCompletionTime(now) .setResolved(problemSolvingStatus ? AppConstants.TRUE : AppConstants.FALSE) .setSatisfied("非常满意".equals(satisfactionStatus) || "基本满意".equals(satisfactionStatus) ? AppConstants.TRUE : AppConstants.FALSE); - mailMarkService.updateById(mailMark); + mailMarkService.saveOrUpdate(mailMark); } public Flow mailReturn(String mailId, JSONObject data) { diff --git a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeVerifyFlow.java b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeVerifyFlow.java index 10c2800..a1031e7 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeVerifyFlow.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/flow/node/ThreeVerifyFlow.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.biutag.entity.system.PoliceUser; @@ -57,6 +58,7 @@ public class ThreeVerifyFlow extends Flow { } throw new BusinessException(); } + public Flow applyExtensionSubmit(String mailId, JSONObject data) { Integer extensionDays = data.getInteger("extensionDays"); Assert.notNull(extensionDays, "延期时长不能为空"); @@ -65,6 +67,9 @@ public class ThreeVerifyFlow extends Flow { Mail mail = mailService.getById(mailId); LocalDateTime now = LocalDateTime.now(); + Work myWork = workService.getOne(mailId, RoleEnum.THREE_DEPT_CLASSES.getRoleId(), AdminThreadLocal.getDeptId()); + myWork.setFlowName("申请延期中"); + workService.updateById(myWork); // 给二级机构增加待办 Work work = workService.getOne(mailId, RoleEnum.SECOND_DEPT_CLASSES.getRoleId(), mail.getSecondDeptId()); work.setWorkState(Work.State.todo.name()).setWorkType(WorkType.extension_approval.name()).setFlowName(FlowNameEnum.PENDING_APPROVAL.getName()).setUpdateTime(now); @@ -73,7 +78,8 @@ public class ThreeVerifyFlow extends Flow { mail.setUpdateTime(now) .setExtensionDays(extensionDays) .setExtensionReason(reason) - .setExtensionState(ExtensionState.applying.name()); + .setExtensionState(ExtensionState.applying.name()) + .setExtensionRequestId(IdUtil.nanoId(16)); mailService.updateById(mail); return null; } @@ -84,7 +90,7 @@ public class ThreeVerifyFlow extends Flow { String verifyFollowupPolice = JSONObject .of("name", verifyFollowupPoliceObj.getString("name"), "empNo", verifyFollowupPoliceObj.getString("empNo"), - "phone", verifyFollowupPoliceObj.getString("phone")).toJSONString(); + "mobile", verifyFollowupPoliceObj.getString("mobile")).toJSONString(); JSONObject contactPolice = data.getJSONObject("contactPolice"); Mail mail = mailService.getById(mailId); Mail source = new Mail() diff --git a/mailbox-lan/src/main/java/com/biutag/lan/mapper/DataScreenMapper.java b/mailbox-lan/src/main/java/com/biutag/lan/mapper/DataScreenMapper.java index cc18e9b..f635503 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/mapper/DataScreenMapper.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/mapper/DataScreenMapper.java @@ -18,9 +18,6 @@ import java.util.Map; public interface DataScreenMapper extends BaseMapper { - - - List> mapData(String deptId); List> mapCountyData(String deptId); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/MailExtensionApprovalService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/MailExtensionApprovalService.java index 2b93f45..0eb6959 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/MailExtensionApprovalService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/MailExtensionApprovalService.java @@ -14,11 +14,11 @@ import java.util.List; @Service public class MailExtensionApprovalService extends ServiceImpl { - public List list(String mailId) { - return list(new LambdaQueryWrapper().eq(MailExtensionApproval::getMailId, mailId)); + public List list(String mailId, String requestId) { + return list(new LambdaQueryWrapper().eq(MailExtensionApproval::getMailId, mailId).eq(MailExtensionApproval::getRequestId, requestId)); } - public boolean save(String mailId, String comment, Boolean returnFlag) { + public boolean save(String mailId, String comment, Boolean returnFlag, String requestId) { LocalDateTime now = LocalDateTime.now(); MailExtensionApproval mailExtensionApproval = new MailExtensionApproval() .setMailId(mailId) @@ -28,11 +28,13 @@ public class MailExtensionApprovalService extends ServiceImpl().eq(MailExtensionApproval::getMailId, mailId)); } + } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/MailReturnService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/MailReturnService.java index 26ea370..a3037b2 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/MailReturnService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/MailReturnService.java @@ -12,7 +12,8 @@ import java.util.List; public class MailReturnService extends ServiceImpl { public List list(String mailId) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper().eq(MailReturn::getMailId, mailId).orderByDesc(MailReturn::getCreateTime); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper().eq(MailReturn::getMailId, mailId) + .orderByDesc(MailReturn::getCreateTime); return list(queryWrapper); } } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java index 125eff9..fbbb601 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/MailService.java @@ -1,6 +1,5 @@ package com.biutag.lan.service; -import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; @@ -8,9 +7,7 @@ import cn.hutool.extra.spring.SpringUtil; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.biutag.constants.AppConstants; import com.biutag.entity.system.Dept; -import com.biutag.entity.system.Holiday; import com.biutag.enums.RoleEnum; import com.biutag.exception.BusinessException; import com.biutag.lan.config.AdminThreadLocal; @@ -19,6 +16,7 @@ import com.biutag.lan.domain.bo.FlowAction; import com.biutag.lan.domain.bo.InvalidCompletion; import com.biutag.lan.domain.bo.MailOuter; import com.biutag.lan.domain.vo.MailApprovalVo; +import com.biutag.lan.domain.vo.MailExtensionApprovalVo; import com.biutag.lan.domain.vo.MailFlowDetail; import com.biutag.lan.domain.vo.MailVo; import com.biutag.lan.enums.CompleteMethod; @@ -36,7 +34,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; -import java.time.Duration; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.*; @@ -156,7 +153,18 @@ public class MailService extends ServiceImpl { } // 申请延期 if (StrUtil.isNotBlank(mail.getExtensionState())) { - mailVo.setExtensionApprovals(mailExtensionApprovalService.list(mailId)); + List approvals = mailExtensionApprovalService.list(mailId, mail.getExtensionRequestId()); + List vos = Arrays.asList(RoleEnum.SECOND_DEPT_CLASSES, RoleEnum.MUNICIPAL_DEPT_CLASSES).stream().map(item -> { + MailExtensionApprovalVo vo = new MailExtensionApprovalVo().setName(item.getName() + "审批"); + MailExtensionApproval approval = approvals.stream().filter(approvalItem -> item.getRoleId().equals(approvalItem.getRoleId())).findFirst().orElse(null); + if (Objects.nonNull(approval)) { + vo.setReturnFlag(approval.getReturnFlag()).setActive(true).setComment(approval.getComment()); + } else { + vo.setReturnFlag(false).setActive(false); + } + return vo; + }).collect(Collectors.toList()); + mailVo.setExtensionApprovals(vos); } if (Objects.nonNull(mail.getFlowKey()) && FlowNodeEnum.get(mail.getFlowKey()).getIndex() >= FlowNodeEnum.THREE_LEADER_APPROVAL.getIndex()) { // 主单位签收时长 @@ -295,14 +303,17 @@ public class MailService extends ServiceImpl { Boolean returnFlag = data.getBoolean("returnFlag"); Assert.notNull(returnFlag, "参数错误"); String comment = data.getString("comment"); + Mail mail = getById(mailId); if (returnFlag) { Assert.hasText(comment, "延期审批驳回理由不能为空"); - Mail mail = getById(mailId); // 驳回 mail.setExtensionState(ExtensionState.reject.name()); updateById(mail); + Work work = workService.getOne(mailId, RoleEnum.THREE_DEPT_CLASSES.getRoleId(), mail.getThreeDeptId()); + work.setFlowName("申请延期驳回"); + workService.updateById(work); } - mailExtensionApprovalService.save(mailId, comment, returnFlag); + mailExtensionApprovalService.save(mailId, comment, returnFlag, mail.getExtensionRequestId()); Integer roleId = AdminThreadLocal.getRoleId(); LocalDateTime now = LocalDateTime.now(); // 二级机构 @@ -322,7 +333,6 @@ public class MailService extends ServiceImpl { work.setUpdateTime(now).setWorkState(Work.State.done.name()).setWorkType(WorkType.processing.name()).setFlowName(FlowNameEnum.PENDING_APPROVAL.getName()); workService.updateById(work); if (!returnFlag) { - Mail mail = getById(mailId); mail.setExtensionState(ExtensionState.completion.name()).setExtensionFlag(true) // 信件状态(已延期) .setMailState(MailState.delayed.name()); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/ws/WsController.java b/mailbox-lan/src/main/java/com/biutag/lan/ws/WsController.java new file mode 100644 index 0000000..0191b19 --- /dev/null +++ b/mailbox-lan/src/main/java/com/biutag/lan/ws/WsController.java @@ -0,0 +1,18 @@ +package com.biutag.lan.ws; + +import com.alibaba.fastjson2.JSONObject; +import com.biutag.core.AjaxResult; +import org.springframework.messaging.handler.annotation.MessageMapping; +import org.springframework.messaging.handler.annotation.SendTo; +import org.springframework.stereotype.Controller; + +@Controller +public class WsController { + + @MessageMapping("/hello") + @SendTo("/topic/greetings") + public AjaxResult greeting(JSONObject message) throws Exception { + return AjaxResult.success(); + } + +} diff --git a/mailbox-lan/src/main/resources/mapper/PoliceUserMapper.xml b/mailbox-lan/src/main/resources/mapper/MailEvaluateEtlMapper.xml similarity index 100% rename from mailbox-lan/src/main/resources/mapper/PoliceUserMapper.xml rename to mailbox-lan/src/main/resources/mapper/MailEvaluateEtlMapper.xml diff --git a/mailbox-outer/src/main/java/com/biutag/outer/controller/SmsController.java b/mailbox-outer/src/main/java/com/biutag/outer/controller/SmsController.java index 3ec8b8f..4985264 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/controller/SmsController.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/controller/SmsController.java @@ -6,6 +6,7 @@ import com.biutag.outer.util.CodeUtil; import com.biutag.outer.util.Sms; import com.biutag.outer.util.SmsSend; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -18,13 +19,20 @@ import java.util.Random; @RestController public class SmsController { + @Value("${spring.profiles.active}") + private String active; + private static final Random random = new Random(); @PostMapping("send") public AjaxResult sendCode(@RequestParam String phone) { String code = String.valueOf(1000 + random.nextInt(9000)); - // 发送短信 -// Sms.send(phone, code); - SmsSend.sendSms(phone,code); + + if (active.equals("prod")) { + SmsSend.sendSms(phone,code); + } else { + + } + // 设置缓存 return AjaxResult.success(JSONObject.of("requestId", CodeUtil.set(code))); } diff --git a/mailbox-outer/src/main/java/com/biutag/outer/domain/Mail.java b/mailbox-outer/src/main/java/com/biutag/outer/domain/Mail.java index f66052a..24be4e4 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/domain/Mail.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/domain/Mail.java @@ -61,11 +61,6 @@ public class Mail { @JSONField(format = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createTime; - /** - * 满意读 - */ - private String satisfaction; - /** * 涉及单位ID */ @@ -76,4 +71,9 @@ public class Mail { */ private String involvedDeptName; + /** + * 满意读 + */ + private String satisfaction; + } diff --git a/mailbox-outer/src/main/java/com/biutag/outer/domain/MailEvaluateEtl.java b/mailbox-outer/src/main/java/com/biutag/outer/domain/MailEvaluateEtl.java new file mode 100644 index 0000000..d6ff4e9 --- /dev/null +++ b/mailbox-outer/src/main/java/com/biutag/outer/domain/MailEvaluateEtl.java @@ -0,0 +1,27 @@ +package com.biutag.outer.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +@Accessors(chain = true) +@Setter +@Getter +public class MailEvaluateEtl { + + @TableId(type = IdType.AUTO) + private Integer id; + + private String mailId; + + private Boolean success; + + private LocalDateTime createTime; + + private String errMsg; + +} diff --git a/mailbox-outer/src/main/java/com/biutag/outer/job/Job.java b/mailbox-outer/src/main/java/com/biutag/outer/job/Job.java new file mode 100644 index 0000000..1055c14 --- /dev/null +++ b/mailbox-outer/src/main/java/com/biutag/outer/job/Job.java @@ -0,0 +1,145 @@ +package com.biutag.outer.job; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.digest.MD5; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import cn.hutool.http.Method; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.biutag.config.Minio; +import com.biutag.entity.system.Holiday; +import com.biutag.outer.domain.Mail; +import com.biutag.outer.domain.MailEtl; +import com.biutag.outer.domain.MailEvaluateEtl; +import com.biutag.outer.mapper.HolidayMapper; +import com.biutag.outer.mapper.MailEtlMapper; +import com.biutag.outer.mapper.MailEvaluateEtlMapper; +import com.biutag.outer.mapper.MailMapper; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; + +@Slf4j +@RequiredArgsConstructor +@Component +public class Job { + + private final MailEtlMapper mailEtlMapper; + + private final MailEvaluateEtlMapper mailEvaluateEtlMapper; + + private final MailMapper mailMapper; + + private final HolidayMapper holidayMapper; + + private final Minio minio; + + @Value("${mailbox.url}") + private String mailboxUrl; + + private final String key = "mailbox"; + + // 30s + @Scheduled(fixedRate = 30000) + public void pushMailData() { + System.out.println(LocalDateTime.now()); + List mails = mailMapper.listByMailEtl(); + for (Mail mail : mails) { + try { + if (StrUtil.isNotBlank(mail.getAttachments())) { + List attachments = JSON.parseArray(mail.getAttachments()).toList(JSONObject.class); + for (JSONObject attachment : attachments) { + attachment.put("base64", minio.getBase64(attachment.getString("filepath"))); + } + mail.setAttachments(JSON.toJSONString(attachments)); + } + long timestamp = new Date().getTime(); + HttpResponse httpResponse = HttpUtil.createPost(mailboxUrl + "mail") + .header("timestamp", String.valueOf(timestamp)) + .auth(MD5.create().digestHex(key + timestamp)) + .body(JSON.toJSONString(mail)) + .execute(); + if (!httpResponse.isOk()) { + throw new RuntimeException(String.format("httpCode: %s", httpResponse.getStatus())); + } + log.info("推送信件内容返回结果:{}", httpResponse.body()); + JSONObject response = JSONObject.parseObject(httpResponse.body()); + if (response.getInteger("code") != 200) { + throw new RuntimeException(response.getString("msg")); + } + MailEtl mailEtl = new MailEtl().setMailId(mail.getId()).setSuccess(true).setCreateTime(LocalDateTime.now()); + mailEtlMapper.insert(mailEtl); + } catch (RuntimeException e) { + log.error("推送信件[{}]异常: {}", mail.getId(), e.getMessage(), e); + MailEtl mailEtl = new MailEtl().setMailId(mail.getId()).setSuccess(false).setCreateTime(LocalDateTime.now()).setErrMsg(e.getMessage()); + mailEtlMapper.insert(mailEtl); + } + } + } + + /** + * 推送信件评价 10分钟 + */ + @Scheduled(fixedRate = 600000) + public void pushMailEvaluate() { + System.out.println(LocalDateTime.now()); + List mails = mailMapper.listByMailEvaluateEtl(); + for (Mail mail : mails) { + try { + long timestamp = new Date().getTime(); + HttpResponse httpResponse = HttpUtil.createRequest(Method.PUT, mailboxUrl + "mail/evaluate") + .header("timestamp", String.valueOf(timestamp)) + .auth(MD5.create().digestHex(key + timestamp)) + .body(JSONObject.of("id", mail.getId(), "satisfaction", mail.getSatisfaction()).toJSONString()) + .execute(); + if (!httpResponse.isOk()) { + throw new RuntimeException(String.format("httpCode: %s", httpResponse.getStatus())); + } + log.info("推送信件评价返回结果:{}", httpResponse.body()); + JSONObject response = JSONObject.parseObject(httpResponse.body()); + if (response.getInteger("code") != 200) { + throw new RuntimeException(response.getString("msg")); + } + MailEvaluateEtl mailEtl = new MailEvaluateEtl().setMailId(mail.getId()).setSuccess(true).setCreateTime(LocalDateTime.now()); + mailEvaluateEtlMapper.insert(mailEtl); + } catch (RuntimeException e) { + log.error("推送信件评价[{}]异常: {}", mail.getId(), e.getMessage(), e); + MailEvaluateEtl mailEtl = new MailEvaluateEtl().setMailId(mail.getId()).setSuccess(false).setCreateTime(LocalDateTime.now()).setErrMsg(e.getMessage()); + mailEvaluateEtlMapper.insert(mailEtl); + } + } + } + + /** + * 每年12月1日 零点执行 + */ + //@Scheduled(cron = "0 0 0 1 12 ? 2024-2099") + public void pushHoliday() { + log.info("开始推送节假日数---------------------------------------"); + int year = LocalDateTime.now().getYear() + 1; + List holidays = holidayMapper.selectList(new LambdaQueryWrapper().eq(Holiday::getYear, year)); + if (holidays.isEmpty()) { + return; + } + long timestamp = new Date().getTime(); + HttpResponse httpResponse = HttpUtil.createPost(mailboxUrl + "holiday") + .header("timestamp", String.valueOf(timestamp)) + .auth(MD5.create().digestHex(key + timestamp)) + .body(JSON.toJSONString(holidays)) + .execute(); + if (!httpResponse.isOk()) { + log.info("推送节假日数据异常,http code:{}", httpResponse.getStatus()); + return; + } + log.info("推送节假日数据返回结果:{}", httpResponse.body()); + } + +} diff --git a/mailbox-outer/src/main/java/com/biutag/outer/job/MailJob.java b/mailbox-outer/src/main/java/com/biutag/outer/job/MailJob.java deleted file mode 100644 index 9abdf2a..0000000 --- a/mailbox-outer/src/main/java/com/biutag/outer/job/MailJob.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.biutag.outer.job; - -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.JSONObject; -import com.biutag.config.Minio; -import com.biutag.outer.domain.Mail; -import com.biutag.outer.domain.MailEtl; -import com.biutag.outer.mapper.MailEtlMapper; -import com.biutag.outer.mapper.MailMapper; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; - -@Slf4j -@RequiredArgsConstructor -@Component -public class MailJob { - - private final MailEtlMapper mailEtlMapper; - - private final MailMapper mailMapper; - - private final Minio minio; - - @Value("${mailbox.url}") - private String mailboxUrl; - - private final String key = "mailbox"; - - // 1分钟 - @Scheduled(fixedRate = 60000) - @Transactional(rollbackFor = Exception.class) - public void pushMailData() { - System.out.println(LocalDateTime.now()); - List mails = mailMapper.listByMailEtl(); - for (Mail mail : mails) { - try { - if (StrUtil.isNotBlank(mail.getAttachments())) { - List attachments = JSON.parseArray(mail.getAttachments()).toList(JSONObject.class); - for (JSONObject attachment : attachments) { - attachment.put("base64", minio.getBase64(attachment.getString("filepath"))); - } - mail.setAttachments(JSON.toJSONString(attachments)); - } - long timestamp = new Date().getTime(); - HttpResponse httpResponse = HttpUtil.createPost(mailboxUrl + "mail") - .header("timestamp", String.valueOf(timestamp)) - .auth(MD5.create().digestHex(key + timestamp)) - .body(JSON.toJSONString(mail)) - .execute(); - if (!httpResponse.isOk()) { - throw new RuntimeException(String.format("httpCode: %s", httpResponse.getStatus())); - } - log.info(httpResponse.body()); - JSONObject response = JSONObject.parseObject(httpResponse.body()); - if (response.getInteger("code") != 200) { - throw new RuntimeException(response.getString("msg")); - } - MailEtl mailEtl = new MailEtl().setMailId(mail.getId()).setSuccess(true).setCreateTime(LocalDateTime.now()); - mailEtlMapper.insert(mailEtl); - } catch (RuntimeException e) { - log.error("推送信件[{}]异常: {}", mail.getId(), e.getMessage(), e); - MailEtl mailEtl = new MailEtl().setMailId(mail.getId()).setSuccess(false).setCreateTime(LocalDateTime.now()).setErrMsg(e.getMessage()); - mailEtlMapper.insert(mailEtl); - } - } - - } - -} diff --git a/mailbox-outer/src/main/java/com/biutag/outer/mapper/HolidayMapper.java b/mailbox-outer/src/main/java/com/biutag/outer/mapper/HolidayMapper.java new file mode 100644 index 0000000..4b9e663 --- /dev/null +++ b/mailbox-outer/src/main/java/com/biutag/outer/mapper/HolidayMapper.java @@ -0,0 +1,13 @@ +package com.biutag.outer.mapper; + +import com.biutag.core.basics.IBaseMapper; +import com.biutag.entity.system.Holiday; +import org.apache.ibatis.annotations.Mapper; + +/** + * 节假日Mapper + * @author oumyye + */ +@Mapper +public interface HolidayMapper extends IBaseMapper { +} diff --git a/mailbox-outer/src/main/java/com/biutag/outer/mapper/MailEvaluateEtlMapper.java b/mailbox-outer/src/main/java/com/biutag/outer/mapper/MailEvaluateEtlMapper.java new file mode 100644 index 0000000..88183b0 --- /dev/null +++ b/mailbox-outer/src/main/java/com/biutag/outer/mapper/MailEvaluateEtlMapper.java @@ -0,0 +1,10 @@ +package com.biutag.outer.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.biutag.outer.domain.MailEtl; +import com.biutag.outer.domain.MailEvaluateEtl; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface MailEvaluateEtlMapper extends BaseMapper { +} diff --git a/mailbox-outer/src/main/java/com/biutag/outer/mapper/MailMapper.java b/mailbox-outer/src/main/java/com/biutag/outer/mapper/MailMapper.java index 3a4e47e..cc6cf74 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/mapper/MailMapper.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/mapper/MailMapper.java @@ -16,4 +16,7 @@ public interface MailMapper extends BaseMapper { @Select("select m.* from mail m left join mail_etl etl on m.id = etl.mail_id and etl.success = 1 where etl.id is null") List listByMailEtl(); + @Select("select m.* from mail m left join mail_evaluate_etl etl on m.id = etl.mail_id and etl.success = 1 where m.satisfaction is not null and etl.id is null") + List listByMailEvaluateEtl(); + } diff --git a/mailbox-outer/src/main/java/com/biutag/outer/util/Weixin.java b/mailbox-outer/src/main/java/com/biutag/outer/util/Weixin.java index 5f8dcec..bcd409a 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/util/Weixin.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/util/Weixin.java @@ -19,8 +19,8 @@ public class Weixin { public static final String SECRET = "7596544a77776be53d10fd78a7b4a441"; public static JSONObject getAccessToken(String code) { - // https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=SECRET&code=%s&grant_type=authorization_code - String url = String.format("https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code", + // http://172.24.138.108:6060/sns/oauth2/access_token?appid=%s&secret=SECRET&code=%s&grant_type=authorization_code + String url = String.format("http://172.24.138.108:6060/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code", APP_ID, SECRET, code); @@ -35,7 +35,7 @@ public class Weixin { } public static JSONObject getAccessToken() { - String url = String.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s", + String url = String.format("http://172.24.138.108:6060/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s", APP_ID, SECRET); HttpResponse httpResponse = HttpUtil.createGet(url) @@ -50,7 +50,7 @@ public class Weixin { public static String getTicket() { JSONObject result = getAccessToken(); - String url = String.format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi", + String url = String.format("http://172.24.138.108:6060/cgi-bin/ticket/getticket?access_token=%s&type=jsapi", result.getString("access_token")); HttpResponse httpResponse = HttpUtil.createGet(url) .execute(); diff --git a/mailbox-outer/src/main/java/com/biutag/outer/util/Weixin2.java b/mailbox-outer/src/main/java/com/biutag/outer/util/Weixin2.java index 99613cb..12c5ef0 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/util/Weixin2.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/util/Weixin2.java @@ -23,8 +23,8 @@ public class Weixin2 { public static final String SECRET = "4d6bc9ab9821f642d185b353893b44ea"; public static JSONObject getAccessToken(String code) { - // https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=SECRET&code=%s&grant_type=authorization_code - String url = String.format("https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code", + // http://172.24.138.108:6060/sns/oauth2/access_token?appid=%s&secret=SECRET&code=%s&grant_type=authorization_code + String url = String.format("http://172.24.138.108:6060/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code", APP_ID, SECRET, code); @@ -39,7 +39,8 @@ public class Weixin2 { } public static JSONObject getAccessToken() { - String url = String.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s", + // http://172.24.138.108:6060/cgi-bin/token + String url = String.format("http://172.24.138.108:6060/cgi-bin/stable_token?grant_type=client_credential&appid=%s&secret=%s", APP_ID, SECRET); HttpResponse httpResponse = HttpUtil.createGet(url) @@ -54,7 +55,7 @@ public class Weixin2 { public static String getTicket() { JSONObject result = getAccessToken(); - String url = String.format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi", + String url = String.format("http://172.24.138.108:6060/cgi-bin/ticket/getticket?access_token=%s&type=jsapi", result.getString("access_token")); HttpResponse httpResponse = HttpUtil.createGet(url) .execute(); diff --git a/mailbox-outer/src/main/resources/application-prod.yml b/mailbox-outer/src/main/resources/application-prod.yml index af2f8aa..292a2c6 100644 --- a/mailbox-outer/src/main/resources/application-prod.yml +++ b/mailbox-outer/src/main/resources/application-prod.yml @@ -6,8 +6,11 @@ spring: oss: minio: - enable: false + enable: true endpoint: http://172.24.12.90:9001 - accessKey: n8yPVAJk4yw879zi - secretKey: eElQ7gCwuNxaFhKEbtRRq0lsovoOTgI1 - bucketName: mailbox \ No newline at end of file + accessKey: qKidAvy2yuwFcwVrAnec + secretKey: PohCwD6AYXfbQx3YwpCknLMeXDFUDlPWRdgtVgAd + bucketName: mailbox + +mailbox: + url: http://59.231.150.85:7979/v1/ \ No newline at end of file diff --git a/mailbox-outer/src/test/java/SmsTest.java b/mailbox-outer/src/test/java/SmsTest.java index 1f7f5bf..79415f0 100644 --- a/mailbox-outer/src/test/java/SmsTest.java +++ b/mailbox-outer/src/test/java/SmsTest.java @@ -3,7 +3,6 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson2.JSONObject; -import com.biutag.outer.util.Md5Util; import com.biutag.outer.util.ReqImsApi; import java.util.Collections; @@ -12,23 +11,23 @@ import java.util.Date; public class SmsTest { public static void main(String[] args) { - String phoneNumber = "15608487213"; - String code = "1234"; - String url = "http://172.31.253.178:5050/ims/sms/sendSms"; - String userName = "cxxjjjbxt"; - String password = "rfrlnK@98"; - String signTime = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_FORMAT); - String signStr = Md5Util.strToMD5(userName+Md5Util.strToMD5(password)+signTime); - - ReqImsApi reqImsApi = new ReqImsApi(); - reqImsApi.setUserName(userName); - reqImsApi.setSignStr(signStr); - reqImsApi.setSignTime(signTime); - reqImsApi.setSmsStr(String.format("您的验证码为:%s,请勿泄露于他人!", code)); - reqImsApi.setMobileList(Collections.singletonList(JSONObject.of("mobile", phoneNumber))); - String json = JsonUtil.toJson(reqImsApi); - HttpResponse response = HttpUtil.createPost(url).body(json).execute(); - System.out.println("手机号: " + phoneNumber + "发送短信结果:" + response.body()); +// String phoneNumber = "15608487213"; +// String code = "1234"; +// String url = "http://172.31.253.178:5050/ims/sms/sendSms"; +// String userName = "cxxjjjbxt"; +// String password = "rfrlnK@98"; +// String signTime = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_FORMAT); +// String signStr = Md5Util.strToMD5(userName+Md5Util.strToMD5(password)+signTime); +// +// ReqImsApi reqImsApi = new ReqImsApi(); +// reqImsApi.setUserName(userName); +// reqImsApi.setSignStr(signStr); +// reqImsApi.setSignTime(signTime); +// reqImsApi.setSmsStr(String.format("您的验证码为:%s,请勿泄露于他人!", code)); +// reqImsApi.setMobileList(Collections.singletonList(JSONObject.of("mobile", phoneNumber))); +// String json = JsonUtil.toJson(reqImsApi); +// HttpResponse response = HttpUtil.createPost(url).body(json).execute(); +// System.out.println("手机号: " + phoneNumber + "发送短信结果:" + response.body()); } } diff --git a/mailbox-outer/src/test/java/com/biutag/outer/Base64Test.java b/mailbox-outer/src/test/java/com/biutag/outer/Base64Test.java new file mode 100644 index 0000000..df31210 --- /dev/null +++ b/mailbox-outer/src/test/java/com/biutag/outer/Base64Test.java @@ -0,0 +1,29 @@ +package com.biutag.outer; + +import cn.hutool.core.io.FileUtil; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.biutag.util.IOUtil; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.io.InputStream; + +public class Base64Test { + + @Test + public void test() { + String s = FileUtil.readString("D:\\Workspace\\创客\\公安项目\\局长信箱\\mailbox-boot\\flow.json", "UTF-8"); + JSONObject jsonObject = JSON.parseObject(s); + String base64 = jsonObject.getString("base64"); + if (base64.startsWith("data:image/jpg;base64,")) { + int length = "data:image/jpg;base64,".length(); + System.out.println(length); + System.out.println(base64.indexOf(",")); + base64 = base64.substring(base64.indexOf(",") + 1); + System.out.println(base64); + } + InputStream is = IOUtil.base64ToStream(base64); + System.out.println(is); + } +} diff --git a/sql/0307.sql b/sql/0307.sql new file mode 100644 index 0000000..b8215e4 --- /dev/null +++ b/sql/0307.sql @@ -0,0 +1,9 @@ +ALTER TABLE "mailbox"."mail" + ADD COLUMN "extension_request_id" varchar(20); + +COMMENT ON COLUMN "mailbox"."mail"."extension_request_id" IS '申请延期ID'; + +ALTER TABLE "mailbox"."mail_extension_approval" + ADD COLUMN "request_id" varchar(20); + +COMMENT ON COLUMN "mailbox"."mail_extension_approval"."request_id" IS '申请延期ID'; \ No newline at end of file