Browse Source

消息中心-短信多人推送-日志打印

zhongwei
ty 9 months ago
parent
commit
1f4a5820e3
  1. 22
      hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java

22
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,10 +182,13 @@ public class MessageClient extends BladeController implements IMessageClient{
@Override
@PostMapping(SEND_SMS_IMMEDIATELY_MSG)
public R<Boolean> sendSmsImmediatelyMsg(@RequestBody SmsImmediatelyPushDTO smsImmediatelyPushDTO) {
MessagePushRecordEntity record = BeanUtil.copy(smsImmediatelyPushDTO,MessagePushRecordEntity.class);
try {
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);
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());
@ -193,7 +197,17 @@ public class MessageClient extends BladeController implements IMessageClient{
record.setUpdateUser(smsImmediatelyPushDTO.getCreateUser());
record.setStatus(MessageConstants.NOT_PUSH);
record.setSmsParam(JSON.toJSONString(smsImmediatelyPushDTO.getParams()));
return R.data(recordService.sendSmsImmediatelyMsg(record));
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);
}
}
/**

Loading…
Cancel
Save