|
|
@ -22,6 +22,8 @@ import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.*; |
|
|
|
import org.springblade.core.tool.utils.*; |
|
|
|
|
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
@ -46,6 +48,7 @@ public class MessageClient extends BladeController implements IMessageClient{ |
|
|
|
|
|
|
|
|
|
|
|
private final IMessagePushRecordService recordService; |
|
|
|
private final IMessagePushRecordService recordService; |
|
|
|
private final IMessageTemplateService messageTemplateService; |
|
|
|
private final IMessageTemplateService messageTemplateService; |
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@PostMapping(SEND_SMS_MESSAGE) |
|
|
|
@PostMapping(SEND_SMS_MESSAGE) |
|
|
@ -61,6 +64,7 @@ public class MessageClient extends BladeController implements IMessageClient{ |
|
|
|
// 可能存在多种推送类型
|
|
|
|
// 可能存在多种推送类型
|
|
|
|
request.getTypes().forEach(type -> { |
|
|
|
request.getTypes().forEach(type -> { |
|
|
|
MessagePushRecordEntity entity = BeanUtil.copy(request,MessagePushRecordEntity.class); |
|
|
|
MessagePushRecordEntity entity = BeanUtil.copy(request,MessagePushRecordEntity.class); |
|
|
|
|
|
|
|
entity.setDeptName(Func.isNotEmpty(entity.getDeptName()) ? entity.getDeptName() : this.getDeptNameById(entity.getDeptId())); |
|
|
|
entity.setType(type); |
|
|
|
entity.setType(type); |
|
|
|
if(Func.isEmpty(AuthUtil.getUserId())) { |
|
|
|
if(Func.isEmpty(AuthUtil.getUserId())) { |
|
|
|
entity.setCreateUser(request.getCreateUser()); |
|
|
|
entity.setCreateUser(request.getCreateUser()); |
|
|
@ -83,6 +87,7 @@ public class MessageClient extends BladeController implements IMessageClient{ |
|
|
|
// 微信消息推送记录保存
|
|
|
|
// 微信消息推送记录保存
|
|
|
|
List<MessagePushRecordEntity> messages = Func.toLongList(request.getUserIds()).stream().map(userId -> { |
|
|
|
List<MessagePushRecordEntity> messages = Func.toLongList(request.getUserIds()).stream().map(userId -> { |
|
|
|
MessagePushRecordEntity entity = BeanUtil.copy(request, MessagePushRecordEntity.class); |
|
|
|
MessagePushRecordEntity entity = BeanUtil.copy(request, MessagePushRecordEntity.class); |
|
|
|
|
|
|
|
entity.setDeptName(Func.isNotEmpty(entity.getDeptName()) ? entity.getDeptName() : this.getDeptNameById(entity.getDeptId())); |
|
|
|
entity.setMessageId(IdWorker.getId()); |
|
|
|
entity.setMessageId(IdWorker.getId()); |
|
|
|
entity.setPusher(userId.toString()); |
|
|
|
entity.setPusher(userId.toString()); |
|
|
|
entity.setPusherName(Optional.ofNullable(UserCache.getUser(userId)).map(User::getName).orElse(null)); |
|
|
|
entity.setPusherName(Optional.ofNullable(UserCache.getUser(userId)).map(User::getName).orElse(null)); |
|
|
@ -111,6 +116,7 @@ public class MessageClient extends BladeController implements IMessageClient{ |
|
|
|
if(Func.isNotEmpty(template.getType())) { |
|
|
|
if(Func.isNotEmpty(template.getType())) { |
|
|
|
Func.toStrList(",",template.getType()).forEach(type -> { |
|
|
|
Func.toStrList(",",template.getType()).forEach(type -> { |
|
|
|
MessagePushRecordEntity entity = BeanUtil.copy(template,MessagePushRecordEntity.class); |
|
|
|
MessagePushRecordEntity entity = BeanUtil.copy(template,MessagePushRecordEntity.class); |
|
|
|
|
|
|
|
entity.setDeptName(Func.isNotEmpty(entity.getDeptName()) ? entity.getDeptName() : this.getDeptNameById(entity.getDeptId())); |
|
|
|
entity.setId(null); |
|
|
|
entity.setId(null); |
|
|
|
entity.setType(type); |
|
|
|
entity.setType(type); |
|
|
|
entity.setTaskId(request.getTaskId()); |
|
|
|
entity.setTaskId(request.getTaskId()); |
|
|
@ -146,6 +152,7 @@ public class MessageClient extends BladeController implements IMessageClient{ |
|
|
|
long messageId = IdWorker.getId(); |
|
|
|
long messageId = IdWorker.getId(); |
|
|
|
return Lists.newArrayList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH).stream().map(messageType -> { |
|
|
|
return Lists.newArrayList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH).stream().map(messageType -> { |
|
|
|
MessagePushRecordEntity record = BeanUtil.copy(request, MessagePushRecordEntity.class); |
|
|
|
MessagePushRecordEntity record = BeanUtil.copy(request, MessagePushRecordEntity.class); |
|
|
|
|
|
|
|
record.setDeptName(Func.isNotEmpty(record.getDeptName()) ? record.getDeptName() : this.getDeptNameById(record.getDeptId())); |
|
|
|
record.setMessageId(messageId); |
|
|
|
record.setMessageId(messageId); |
|
|
|
record.setPusher(userId.toString()); |
|
|
|
record.setPusher(userId.toString()); |
|
|
|
record.setPusherName(Optional.ofNullable(UserCache.getUser(userId)).map(User::getName).orElse(null)); |
|
|
|
record.setPusherName(Optional.ofNullable(UserCache.getUser(userId)).map(User::getName).orElse(null)); |
|
|
@ -180,6 +187,7 @@ public class MessageClient extends BladeController implements IMessageClient{ |
|
|
|
String pusherName = Optional.ofNullable(smsImmediatelyPushDTO.getPusher()).map(Func::toLong).map(UserCache::getUser).map(User::getName).orElse(null); |
|
|
|
String pusherName = Optional.ofNullable(smsImmediatelyPushDTO.getPusher()).map(Func::toLong).map(UserCache::getUser).map(User::getName).orElse(null); |
|
|
|
record.setPusherName(pusherName); |
|
|
|
record.setPusherName(pusherName); |
|
|
|
record.setPushType(MessageConstants.IMMEDIATELY); |
|
|
|
record.setPushType(MessageConstants.IMMEDIATELY); |
|
|
|
|
|
|
|
record.setDeptName(Func.isNotEmpty(record.getDeptName()) ? record.getDeptName() : this.getDeptNameById(record.getDeptId())); |
|
|
|
record.setPlanTime(LocalDateTime.now()); |
|
|
|
record.setPlanTime(LocalDateTime.now()); |
|
|
|
record.setType(MessageConstants.SMS_PUSH); |
|
|
|
record.setType(MessageConstants.SMS_PUSH); |
|
|
|
record.setCreateDept(record.getDeptId()); |
|
|
|
record.setCreateDept(record.getDeptId()); |
|
|
@ -189,4 +197,13 @@ public class MessageClient extends BladeController implements IMessageClient{ |
|
|
|
return R.data(recordService.sendSmsImmediatelyMsg(record)); |
|
|
|
return R.data(recordService.sendSmsImmediatelyMsg(record)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 根据机构ID获取机构名称 |
|
|
|
|
|
|
|
* @param deptId 机构ID |
|
|
|
|
|
|
|
* @return 机构名称 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private String getDeptNameById(Long deptId) { |
|
|
|
|
|
|
|
return Optional.ofNullable(sysClient.getDeptName(deptId)).filter(r -> r.isSuccess()).map(R::getData).orElse(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|