@@ -9,6 +9,7 @@ import javax.validation.constraints.NotNull; | |||
import javax.validation.constraints.Size; | |||
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 io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
@@ -44,6 +45,7 @@ public class MessageImportRequestDto extends AbstractStaffBizRequestDTO { | |||
private List<String> emailAttachmentName; | |||
@ApiModelProperty(value = "email附件地址", required = true) | |||
private List<String> emailAttachmentUrl; | |||
@ApiModelProperty(value = "jpush类型", required = true) | |||
private MessageJPushType jPushType; | |||
} |
@@ -60,12 +60,18 @@ public class MessageJPushSendRequestDto extends AbstractStaffBizRequestDTO { | |||
public void valid() throws ManagerException { | |||
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) | |||
|| jPushType.equals(MessageJPushType.JPUSHALLAPPNM) | |||
|| jPushType.equals(MessageJPushType.JPUSHALLRIDN) |
@@ -3,6 +3,7 @@ package cn.com.taiji.msgw.manager.importReview; | |||
import java.io.IOException; | |||
import java.time.LocalDateTime; | |||
import cn.com.taiji.core.entity.dict.msgw.MessageJPushType; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.beans.BeanUtils; | |||
@@ -98,7 +99,7 @@ public class MessageImportManagerImpl extends AbstractCommManager implements Mes | |||
apply.setActualSendTime(LocalDateTime.now()); | |||
} catch (Exception e) { | |||
// 2.7 批量发送失败 | |||
logger.error(e.getMessage()); | |||
logger.error("报错啦:========================" + e.getMessage()); | |||
} | |||
apply.setActualSendTime(LocalDateTime.now()); | |||
} else { | |||
@@ -155,14 +156,21 @@ public class MessageImportManagerImpl extends AbstractCommManager implements Mes | |||
MsgwSendApply apply = new MsgwSendApply(); | |||
BeanUtils.copyProperties(request, apply); | |||
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.setInsertTime(LocalDateTime.now()); | |||
@@ -172,18 +180,18 @@ public class MessageImportManagerImpl extends AbstractCommManager implements Mes | |||
} else { | |||
apply.setSendTime(LocalDateTime.now()); | |||
} | |||
sendApplyRepo.persist(apply); | |||
MsgwSendApply sendApply = sendApplyRepo.save(apply); | |||
// email的存附件表 | |||
if (MessageType.EMAIL.equals(request.getMessageType()) && request.getEmailAttachmentUrl().size() != 0) { | |||
MsgwAttachment attachment = new MsgwAttachment(); | |||
attachment.setInsertTime(LocalDateTime.now()); | |||
attachment.setApplyId(apply.getId()); | |||
attachment.setApplyId(sendApply.getId()); | |||
for (int i = 0; i < request.getEmailAttachmentUrl().size(); i++) { | |||
attachment.setAttachmentName(request.getEmailAttachmentName().get(i)); | |||
attachment.setAttachmentUrl(request.getEmailAttachmentUrl().get(i)); | |||
} | |||
} | |||
MessageImportResponseDto response = new MessageImportResponseDto(apply.getId()); | |||
MessageImportResponseDto response = new MessageImportResponseDto(sendApply.getId()); | |||
return response; | |||
} | |||
@@ -65,6 +65,7 @@ public class JPushImportSendHandler { | |||
if (apply.getJPushType().equals(MessageJPushType.JPUSHALLAPPM) | |||
|| apply.getJPushType().equals(MessageJPushType.JPUSHALLAPPN) | |||
|| apply.getJPushType().equals(MessageJPushType.JPUSHALLAPPNM)) { | |||
sendDetailsAddRequestDto.setReceiverId("ALL"); | |||
importManager.addSendDetail(sendDetailsAddRequestDto); | |||
} else if (apply.getJPushType().equals(MessageJPushType.JPUSHALLRIDN) | |||
|| apply.getJPushType().equals(MessageJPushType.JPUSHALLRIDM) |
@@ -1,5 +1,6 @@ | |||
package cn.com.taiji.msgw.manager.jPush; | |||
import cn.com.taiji.common.pub.BeanTools; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -26,6 +27,7 @@ public class JPushSendManagerImpl extends AbstractCommManager implements JPushSe | |||
MessageImportRequestDto importRequestDto = copyProperties(request, new MessageImportRequestDto()); | |||
// 构建json | |||
JPushSendMessageRequest messageRequest = new JPushSendMessageRequest(); | |||
BeanTools.copyProperties(request, messageRequest); | |||
importRequestDto.setRequestDataJson(JsonTools.asJsonStr(messageRequest)); | |||
// 创建主表 | |||
MessageImportResponseDto importResponseDto = importManager.addSendApply(importRequestDto); |