Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[企业微信] 批量审批回调时去重异常 #3088

Closed
nadirvishun opened this issue Jul 18, 2023 · 2 comments
Closed

[企业微信] 批量审批回调时去重异常 #3088

nadirvishun opened this issue Jul 18, 2023 · 2 comments

Comments

@nadirvishun
Copy link

简要描述

当审批人批量审批时,同一个提交人提交了两个审批,由于时间也一致,导致其中一条消息被排重了。

模块版本情况

  • WxJava 模块名: weixin-java-cp
  • WxJava 版本号: 4.4.4.B (最新版本没有改动)

可能的解决方法

  • WxCpMessageRouter类中的isMsgDuplicated方法,增加审批编号的判定:
    private boolean isMsgDuplicated(WxCpXmlMessage wxMessage) {
          StringBuilder messageId = new StringBuilder();
          if (wxMessage.getMsgId() == null) {
              messageId.append(wxMessage.getCreateTime())
                      .append("-").append(StringUtils.trimToEmpty(String.valueOf(wxMessage.getAgentId())))
                      .append("-").append(wxMessage.getFromUserName())
                      .append("-").append(StringUtils.trimToEmpty(wxMessage.getEventKey()))
                      .append("-").append(StringUtils.trimToEmpty(wxMessage.getEvent()));
          } else {
              messageId.append(wxMessage.getMsgId())
                      .append("-").append(wxMessage.getCreateTime())
                      .append("-").append(wxMessage.getFromUserName());
          }
          append(messageId, wxMessage.getUserId());
          append(messageId, wxMessage.getChangeType());
          append(messageId, wxMessage.getTagId());
          append(messageId, wxMessage.getId());
          append(messageId, wxMessage.getChatId());
          append(messageId, wxMessage.getExternalUserId());
    
         //这里,增加审批编号
          if(StringUtils.isNotBlank(wxMessage.getApprovalInfo().getSpNo())){
              append(messageId, wxMessage.getApprovalInfo().getSpNo());
          }
    
          return this.messageDuplicateChecker.isDuplicate(messageId.toString());
      }
  • 或者是此类中是否可以增加个类似setMessageId的相关方法,方便后续开发者自己来定义自己的规则来生成messageId
@binarywang
Copy link
Owner

你可以直接提交PR,把两种方法都加入

@nadirvishun
Copy link
Author

最新版本4.5.0已经修复了,我看漏了以为没有修复:【企业微信】修复不同的消息推送会判断为重复的问题,第二种方法就先不处理了,再遇到其它的再说吧。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants