From 868e21a82b305e01143d71d02211bdb3dd11a473 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Thu, 14 Mar 2024 18:35:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=B8=AD=E5=BF=83-=E7=9F=AD?= =?UTF-8?q?=E4=BF=A1=E5=A4=9A=E4=BA=BA=E6=8E=A8=E9=80=81-=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0param=E5=AD=97=E6=95=B0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/message/fegin/MessageClient.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java index 75d20ed..0dcf5c5 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java @@ -35,10 +35,7 @@ import javax.validation.Valid; import javax.xml.ws.WebServiceException; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; +import java.util.*; import java.util.stream.Collectors; /** @@ -196,7 +193,12 @@ public class MessageClient extends BladeController implements IMessageClient{ record.setCreateDept(record.getDeptId()); record.setUpdateUser(smsImmediatelyPushDTO.getCreateUser()); record.setStatus(MessageConstants.NOT_PUSH); - record.setSmsParam(JSON.toJSONString(smsImmediatelyPushDTO.getParams())); + Map params = smsImmediatelyPushDTO.getParams(); + int maxSize=35; + params.put("ruleDefName",getTruncateString(params.get("ruleDefName"), maxSize)); + params.put("projectName",getTruncateString(params.get("projectName"), maxSize)); + params.put("deviceName",getTruncateString(params.get("deviceName"), maxSize)); + record.setSmsParam(JSON.toJSONString(params)); Boolean flag = recordService.sendSmsImmediatelyMsg(record); if (!flag) { log.error("短信推送失败,参数:" + record.toString()); @@ -210,6 +212,14 @@ public class MessageClient extends BladeController implements IMessageClient{ } } + private String getTruncateString(String ruleDefName, int maxSize) { + if (ruleDefName.length()<= maxSize){ + return ruleDefName; + }else { + return ruleDefName.substring(0, maxSize - 3) + "..."; + } + } + /** * 根据机构ID获取机构名称 * @param deptId 机构ID