From 1f4a5820e39cf973d84d0f980ab80b824bca2099 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Thu, 14 Mar 2024 16:31:15 +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-=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/message/fegin/MessageClient.java | 40 +++++++++++++++------- 1 file changed, 27 insertions(+), 13 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 1cc8f23..75d20ed 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 @@ -32,6 +32,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import javax.xml.ws.WebServiceException; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.ArrayList; @@ -181,19 +182,32 @@ public class MessageClient extends BladeController implements IMessageClient{ @Override @PostMapping(SEND_SMS_IMMEDIATELY_MSG) public R sendSmsImmediatelyMsg(@RequestBody SmsImmediatelyPushDTO smsImmediatelyPushDTO) { - MessagePushRecordEntity record = BeanUtil.copy(smsImmediatelyPushDTO,MessagePushRecordEntity.class); - record.setMessageId(IdWorker.getId()); - String pusherName = Optional.ofNullable(smsImmediatelyPushDTO.getPusher().split(",")).map(Func::toLong).map(UserCache::getUser).map(User::getName).orElse(null); - record.setPusherName(pusherName); - record.setPushType(MessageConstants.IMMEDIATELY); - record.setDeptName(Func.isNotEmpty(record.getDeptName()) ? record.getDeptName() : this.getDeptNameById(record.getDeptId())); - record.setPlanTime(LocalDateTime.now()); - record.setType(MessageConstants.SMS_PUSH); - record.setCreateDept(record.getDeptId()); - record.setUpdateUser(smsImmediatelyPushDTO.getCreateUser()); - record.setStatus(MessageConstants.NOT_PUSH); - record.setSmsParam(JSON.toJSONString(smsImmediatelyPushDTO.getParams())); - return R.data(recordService.sendSmsImmediatelyMsg(record)); + try { + MessagePushRecordEntity record = BeanUtil.copy(smsImmediatelyPushDTO, MessagePushRecordEntity.class); + record.setMessageId(IdWorker.getId()); + for (Long pushId : Func.toLongList(",", smsImmediatelyPushDTO.getPusher())) { + User user = UserCache.getUser(pushId); + record.setPusherName(user.getName()); + record.setPusher(pushId.toString()); + record.setPushType(MessageConstants.IMMEDIATELY); + record.setDeptName(Func.isNotEmpty(record.getDeptName()) ? record.getDeptName() : this.getDeptNameById(record.getDeptId())); + record.setPlanTime(LocalDateTime.now()); + record.setType(MessageConstants.SMS_PUSH); + record.setCreateDept(record.getDeptId()); + record.setUpdateUser(smsImmediatelyPushDTO.getCreateUser()); + record.setStatus(MessageConstants.NOT_PUSH); + record.setSmsParam(JSON.toJSONString(smsImmediatelyPushDTO.getParams())); + Boolean flag = recordService.sendSmsImmediatelyMsg(record); + if (!flag) { + log.error("短信推送失败,参数:" + record.toString()); + return R.data(false); + } + } + return R.data(true); + }catch (Exception e){ + log.error(e.getMessage()); + return R.data(false); + } } /**