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); + } } /**