Browse Source

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

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

40
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 org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import javax.xml.ws.WebServiceException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
@ -181,19 +182,32 @@ public class MessageClient extends BladeController implements IMessageClient{
@Override @Override
@PostMapping(SEND_SMS_IMMEDIATELY_MSG) @PostMapping(SEND_SMS_IMMEDIATELY_MSG)
public R<Boolean> sendSmsImmediatelyMsg(@RequestBody SmsImmediatelyPushDTO smsImmediatelyPushDTO) { public R<Boolean> sendSmsImmediatelyMsg(@RequestBody SmsImmediatelyPushDTO smsImmediatelyPushDTO) {
MessagePushRecordEntity record = BeanUtil.copy(smsImmediatelyPushDTO,MessagePushRecordEntity.class); try {
record.setMessageId(IdWorker.getId()); MessagePushRecordEntity record = BeanUtil.copy(smsImmediatelyPushDTO, MessagePushRecordEntity.class);
String pusherName = Optional.ofNullable(smsImmediatelyPushDTO.getPusher().split(",")).map(Func::toLong).map(UserCache::getUser).map(User::getName).orElse(null); record.setMessageId(IdWorker.getId());
record.setPusherName(pusherName); for (Long pushId : Func.toLongList(",", smsImmediatelyPushDTO.getPusher())) {
record.setPushType(MessageConstants.IMMEDIATELY); User user = UserCache.getUser(pushId);
record.setDeptName(Func.isNotEmpty(record.getDeptName()) ? record.getDeptName() : this.getDeptNameById(record.getDeptId())); record.setPusherName(user.getName());
record.setPlanTime(LocalDateTime.now()); record.setPusher(pushId.toString());
record.setType(MessageConstants.SMS_PUSH); record.setPushType(MessageConstants.IMMEDIATELY);
record.setCreateDept(record.getDeptId()); record.setDeptName(Func.isNotEmpty(record.getDeptName()) ? record.getDeptName() : this.getDeptNameById(record.getDeptId()));
record.setUpdateUser(smsImmediatelyPushDTO.getCreateUser()); record.setPlanTime(LocalDateTime.now());
record.setStatus(MessageConstants.NOT_PUSH); record.setType(MessageConstants.SMS_PUSH);
record.setSmsParam(JSON.toJSONString(smsImmediatelyPushDTO.getParams())); record.setCreateDept(record.getDeptId());
return R.data(recordService.sendSmsImmediatelyMsg(record)); 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);
}
} }
/** /**

Loading…
Cancel
Save