Browse Source

消息中心-短信多人推送-增加param字数限制

zhongwei
ty 8 months ago
parent
commit
868e21a82b
  1. 20
      hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java

20
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<String, String> 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

Loading…
Cancel
Save