import javax.validation.constraints.Size; | import javax.validation.constraints.Size; | ||||
import cn.com.taiji.core.dto.AbstractStaffBizRequestDTO; | import cn.com.taiji.core.dto.AbstractStaffBizRequestDTO; | ||||
import cn.com.taiji.core.entity.dict.msgw.MessageJPushType; | |||||
import cn.com.taiji.core.entity.dict.msgw.MessageType; | import cn.com.taiji.core.entity.dict.msgw.MessageType; | ||||
import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
import lombok.Getter; | import lombok.Getter; | ||||
private List<String> emailAttachmentName; | private List<String> emailAttachmentName; | ||||
@ApiModelProperty(value = "email附件地址", required = true) | @ApiModelProperty(value = "email附件地址", required = true) | ||||
private List<String> emailAttachmentUrl; | private List<String> emailAttachmentUrl; | ||||
@ApiModelProperty(value = "jpush类型", required = true) | |||||
private MessageJPushType jPushType; | |||||
} | } |
public void valid() throws ManagerException { | public void valid() throws ManagerException { | ||||
StringBuffer msg = new StringBuffer(); | StringBuffer msg = new StringBuffer(); | ||||
if (receiverIdList.isEmpty() && !StringTools.hasText(attachmentUrl)) { | |||||
msg.append("用户列表和附件地址不能同时为空,"); | |||||
} | |||||
if (!(StringTools.hasText(attachmentUrl) && StringTools.hasText(attachmentUrl)) && receiverIdList.isEmpty()) { | |||||
msg.append("附件名称和附件地址不能为空,"); | |||||
if (jPushType.equals(MessageJPushType.JPUSHALLRIDN) | |||||
|| jPushType.equals(MessageJPushType.JPUSHALLRIDM) | |||||
|| jPushType.equals(MessageJPushType.JPUSHALLRIDNM)){ | |||||
if (receiverIdList.isEmpty() && !StringTools.hasText(attachmentUrl)) { | |||||
msg.append("用户列表和附件地址不能同时为空,"); | |||||
} | |||||
if (!(StringTools.hasText(attachmentUrl) && StringTools.hasText(attachmentUrl)) && receiverIdList.isEmpty()) { | |||||
msg.append("附件名称和附件地址不能为空,"); | |||||
} | |||||
} | } | ||||
if (jPushType.equals(MessageJPushType.JPUSHALLAPPN) | if (jPushType.equals(MessageJPushType.JPUSHALLAPPN) | ||||
|| jPushType.equals(MessageJPushType.JPUSHALLAPPNM) | || jPushType.equals(MessageJPushType.JPUSHALLAPPNM) | ||||
|| jPushType.equals(MessageJPushType.JPUSHALLRIDN) | || jPushType.equals(MessageJPushType.JPUSHALLRIDN) |
import java.io.IOException; | import java.io.IOException; | ||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import cn.com.taiji.core.entity.dict.msgw.MessageJPushType; | |||||
import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
import org.springframework.beans.BeanUtils; | import org.springframework.beans.BeanUtils; | ||||
apply.setActualSendTime(LocalDateTime.now()); | apply.setActualSendTime(LocalDateTime.now()); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
// 2.7 批量发送失败 | // 2.7 批量发送失败 | ||||
logger.error(e.getMessage()); | |||||
logger.error("报错啦:========================" + e.getMessage()); | |||||
} | } | ||||
apply.setActualSendTime(LocalDateTime.now()); | apply.setActualSendTime(LocalDateTime.now()); | ||||
} else { | } else { | ||||
MsgwSendApply apply = new MsgwSendApply(); | MsgwSendApply apply = new MsgwSendApply(); | ||||
BeanUtils.copyProperties(request, apply); | BeanUtils.copyProperties(request, apply); | ||||
ObjectMapper objectMapper = new ObjectMapper(); | ObjectMapper objectMapper = new ObjectMapper(); | ||||
if (request.getReceiverIdList().size() != 0) { | |||||
String json = null; | |||||
try { | |||||
json = JsonTools.toJsonStr(request.getReceiverIdList()); | |||||
} catch (IOException e) { | |||||
throw new RuntimeException(e); | |||||
// app发送全体用户做过滤 | |||||
if (!request.getJPushType().equals(MessageJPushType.JPUSHALLAPPN) | |||||
&& !request.getJPushType().equals(MessageJPushType.JPUSHALLAPPM) | |||||
&& !request.getJPushType().equals(MessageJPushType.JPUSHALLAPPNM)){ | |||||
if (request.getReceiverIdList().size() != 0) { | |||||
String json = null; | |||||
try { | |||||
json = JsonTools.toJsonStr(request.getReceiverIdList()); | |||||
} catch (IOException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
apply.setReceiverIdList(json); | |||||
} | } | ||||
apply.setReceiverIdList(json); | |||||
}else { | |||||
apply.setReceiverIdList("ALL"); | |||||
} | } | ||||
apply.setStatus(AuditStatus.AUDIT); | apply.setStatus(AuditStatus.AUDIT); | ||||
apply.setInsertTime(LocalDateTime.now()); | apply.setInsertTime(LocalDateTime.now()); | ||||
} else { | } else { | ||||
apply.setSendTime(LocalDateTime.now()); | apply.setSendTime(LocalDateTime.now()); | ||||
} | } | ||||
sendApplyRepo.persist(apply); | |||||
MsgwSendApply sendApply = sendApplyRepo.save(apply); | |||||
// email的存附件表 | // email的存附件表 | ||||
if (MessageType.EMAIL.equals(request.getMessageType()) && request.getEmailAttachmentUrl().size() != 0) { | if (MessageType.EMAIL.equals(request.getMessageType()) && request.getEmailAttachmentUrl().size() != 0) { | ||||
MsgwAttachment attachment = new MsgwAttachment(); | MsgwAttachment attachment = new MsgwAttachment(); | ||||
attachment.setInsertTime(LocalDateTime.now()); | attachment.setInsertTime(LocalDateTime.now()); | ||||
attachment.setApplyId(apply.getId()); | |||||
attachment.setApplyId(sendApply.getId()); | |||||
for (int i = 0; i < request.getEmailAttachmentUrl().size(); i++) { | for (int i = 0; i < request.getEmailAttachmentUrl().size(); i++) { | ||||
attachment.setAttachmentName(request.getEmailAttachmentName().get(i)); | attachment.setAttachmentName(request.getEmailAttachmentName().get(i)); | ||||
attachment.setAttachmentUrl(request.getEmailAttachmentUrl().get(i)); | attachment.setAttachmentUrl(request.getEmailAttachmentUrl().get(i)); | ||||
} | } | ||||
} | } | ||||
MessageImportResponseDto response = new MessageImportResponseDto(apply.getId()); | |||||
MessageImportResponseDto response = new MessageImportResponseDto(sendApply.getId()); | |||||
return response; | return response; | ||||
} | } | ||||
if (apply.getJPushType().equals(MessageJPushType.JPUSHALLAPPM) | if (apply.getJPushType().equals(MessageJPushType.JPUSHALLAPPM) | ||||
|| apply.getJPushType().equals(MessageJPushType.JPUSHALLAPPN) | || apply.getJPushType().equals(MessageJPushType.JPUSHALLAPPN) | ||||
|| apply.getJPushType().equals(MessageJPushType.JPUSHALLAPPNM)) { | || apply.getJPushType().equals(MessageJPushType.JPUSHALLAPPNM)) { | ||||
sendDetailsAddRequestDto.setReceiverId("ALL"); | |||||
importManager.addSendDetail(sendDetailsAddRequestDto); | importManager.addSendDetail(sendDetailsAddRequestDto); | ||||
} else if (apply.getJPushType().equals(MessageJPushType.JPUSHALLRIDN) | } else if (apply.getJPushType().equals(MessageJPushType.JPUSHALLRIDN) | ||||
|| apply.getJPushType().equals(MessageJPushType.JPUSHALLRIDM) | || apply.getJPushType().equals(MessageJPushType.JPUSHALLRIDM) |
package cn.com.taiji.msgw.manager.jPush; | package cn.com.taiji.msgw.manager.jPush; | ||||
import cn.com.taiji.common.pub.BeanTools; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
MessageImportRequestDto importRequestDto = copyProperties(request, new MessageImportRequestDto()); | MessageImportRequestDto importRequestDto = copyProperties(request, new MessageImportRequestDto()); | ||||
// 构建json | // 构建json | ||||
JPushSendMessageRequest messageRequest = new JPushSendMessageRequest(); | JPushSendMessageRequest messageRequest = new JPushSendMessageRequest(); | ||||
BeanTools.copyProperties(request, messageRequest); | |||||
importRequestDto.setRequestDataJson(JsonTools.asJsonStr(messageRequest)); | importRequestDto.setRequestDataJson(JsonTools.asJsonStr(messageRequest)); | ||||
// 创建主表 | // 创建主表 | ||||
MessageImportResponseDto importResponseDto = importManager.addSendApply(importRequestDto); | MessageImportResponseDto importResponseDto = importManager.addSendApply(importRequestDto); |