Commit 383e2186 by 18356073052

对群发进行优化

1 parent a9d56c44
......@@ -6,6 +6,7 @@ import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.dto.message.AsyncResultDto;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo;
import com.linkwechat.wecom.domain.vo.WeCustomerMessageResultVo;
......@@ -96,10 +97,10 @@ public class WeCustomerMessagePushController extends BaseController {
/**
* 同步消息发送结果
*/
@PreAuthorize("@ss.hasPermi('customerMessagePush:push:asyncResult')")
//@PreAuthorize("@ss.hasPermi('customerMessagePush:push:asyncResult')")
@PostMapping(value = "asyncResult")
public AjaxResult asyncResult(@RequestParam(value = "msgid") String msgid, @RequestParam(value = "messageId") Long messageId) {
weCustomerMessageOriginalService.asyncResult(msgid, messageId);
public AjaxResult asyncResult(@RequestBody AsyncResultDto asyncResultDto) throws JsonProcessingException {
weCustomerMessageOriginalService.asyncResult(asyncResultDto);
return AjaxResult.success();
}
......
......@@ -124,6 +124,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/wecom/ticket/**").anonymous()
.antMatchers("/wecom/user/getUserInfo").anonymous()
.antMatchers("/common/uploadFile2Cos").anonymous()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated()
......
package com.linkwechat.wecom.domain.dto.message;
import lombok.Data;
import java.util.List;
/**
* 同步群发消息dto
* @author Kewen
*/
@Data
public class AsyncResultDto {
private Long messageId;
private List<String> msgids;
}
......@@ -38,4 +38,11 @@ public interface WeCustomerMessgaeResultMapper extends BaseMapper<WeCustomerMess
*/
List<WeCustomerMessageResultVo> customerMessagePushs(@Param("messageId") Long messageId,@Param("status") String status);
/**
* 检查是否已经同步群发结果
*
* @param messageId 微信消息表id
* @return 已发送消息数
*/
int checkSendStatus(@Param("messageId") Long messageId);
}
......@@ -3,6 +3,7 @@ package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.linkwechat.wecom.domain.WeCustomerMessageOriginal;
import com.linkwechat.wecom.domain.dto.message.AsyncResultDto;
import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo;
import java.util.List;
......@@ -44,8 +45,8 @@ public interface IWeCustomerMessageOriginalService extends IService<WeCustomerMe
/**
* 同步发送结果
*
* @param msgid 可以用于获取发送结果
* @param asyncResultDto 可以用于获取发送结果
*/
void asyncResult(String msgid, Long messageId);
void asyncResult(AsyncResultDto asyncResultDto) throws JsonProcessingException;
}
......@@ -8,6 +8,7 @@ import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeCustomerMessagePushClient;
import com.linkwechat.wecom.domain.WeCustomerMessageOriginal;
import com.linkwechat.wecom.domain.dto.message.AsyncResultDto;
import com.linkwechat.wecom.domain.dto.message.DetailMessageStatusResultDto;
import com.linkwechat.wecom.domain.dto.message.QueryCustomerMessageStatusResultDataObjectDto;
import com.linkwechat.wecom.domain.dto.message.QueryCustomerMessageStatusResultDto;
......@@ -64,16 +65,19 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer
CustomerMessagePushVo customerMessagePushDetail = weCustomerMessageOriginalMapper.findCustomerMessagePushDetail(messageId);
//拉取消息发送结果
CompletableFuture.runAsync(() -> syncSendResult(customerMessagePushDetail.getMsgid(), messageId));
//检查是否已经同步发送结果
if( weCustomerMessgaeResultMapper.checkSendStatus(messageId)==0){
//拉取消息发送结果
CompletableFuture.runAsync(() -> syncSendResult(customerMessagePushDetail.getMsgid(), messageId));
}
return customerMessagePushDetail;
}
@Override
public void asyncResult(String msgid, Long messageId) {
syncSendResult(msgid, messageId);
public void asyncResult(AsyncResultDto asyncResultDto) throws JsonProcessingException {
String msgid=new ObjectMapper().writeValueAsString(asyncResultDto.getMsgids());
syncSendResult(msgid, asyncResultDto.getMessageId());
}
public void syncSendResult(String msgid, Long messageId) {
......
......@@ -299,7 +299,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
List<String> owners = groups.stream().map(WeGroup::getOwner).collect(Collectors.toList());
for (String owner : owners) {
WeCustomerMessagePushDto messagePushDto = new WeCustomerMessagePushDto();
messagePushDto.setChat_type(ChatType.of(customerMessagePushDto.getPushType()).getType());
messagePushDto.setChat_type(ChatType.of(customerMessagePushDto.getPushType()).getName());
//客户群的员工id
messagePushDto.setSender(owner);
seedMessage(messagePushDto, customerMessagePushDto);
......
......@@ -38,4 +38,14 @@
</where>
GROUP BY user_name
</select>
<select id="checkSendStatus" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
we_customer_messgaeResult
<where>
message_id =#{messageId} AND `status`='1'
</where>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!