|
@@ -7,13 +7,16 @@ import com.fs.qw.domain.QwCompany;
|
|
|
import com.fs.qw.domain.audit.QwMsgAuditMessage;
|
|
import com.fs.qw.domain.audit.QwMsgAuditMessage;
|
|
|
import com.fs.qw.domain.audit.QwMsgAuditRaw;
|
|
import com.fs.qw.domain.audit.QwMsgAuditRaw;
|
|
|
import com.fs.qw.domain.audit.QwMsgAuditSeq;
|
|
import com.fs.qw.domain.audit.QwMsgAuditSeq;
|
|
|
|
|
+import com.fs.qw.domain.QwUser;
|
|
|
import com.fs.qw.mapper.QwCompanyMapper;
|
|
import com.fs.qw.mapper.QwCompanyMapper;
|
|
|
import com.fs.qw.mapper.QwMsgAuditMessageMapper;
|
|
import com.fs.qw.mapper.QwMsgAuditMessageMapper;
|
|
|
import com.fs.qw.mapper.QwMsgAuditRawMapper;
|
|
import com.fs.qw.mapper.QwMsgAuditRawMapper;
|
|
|
import com.fs.qw.mapper.QwMsgAuditSeqMapper;
|
|
import com.fs.qw.mapper.QwMsgAuditSeqMapper;
|
|
|
|
|
+import com.fs.qw.mapper.QwUserMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
@@ -32,19 +35,26 @@ public class QwMsgAuditIngestService {
|
|
|
private final QwMsgAuditMessageMapper messageMapper;
|
|
private final QwMsgAuditMessageMapper messageMapper;
|
|
|
private final QwMsgAuditPullService pullService;
|
|
private final QwMsgAuditPullService pullService;
|
|
|
private final List<QwMsgAuditMsgHandler> handlers;
|
|
private final List<QwMsgAuditMsgHandler> handlers;
|
|
|
|
|
+ private final QwUserMapper qwUserMapper;
|
|
|
|
|
+
|
|
|
|
|
+ // 发送方角色,1-内部,2-外部
|
|
|
|
|
+ private static final int FROM_USER_ROLE_INTERNAL = 1;
|
|
|
|
|
+ private static final int FROM_USER_ROLE_EXTERNAL = 2;
|
|
|
|
|
|
|
|
public QwMsgAuditIngestService(QwCompanyMapper qwCompanyMapper,
|
|
public QwMsgAuditIngestService(QwCompanyMapper qwCompanyMapper,
|
|
|
QwMsgAuditSeqMapper seqMapper,
|
|
QwMsgAuditSeqMapper seqMapper,
|
|
|
QwMsgAuditRawMapper rawMapper,
|
|
QwMsgAuditRawMapper rawMapper,
|
|
|
QwMsgAuditMessageMapper messageMapper,
|
|
QwMsgAuditMessageMapper messageMapper,
|
|
|
QwMsgAuditPullService pullService,
|
|
QwMsgAuditPullService pullService,
|
|
|
- List<QwMsgAuditMsgHandler> handlers) {
|
|
|
|
|
|
|
+ List<QwMsgAuditMsgHandler> handlers,
|
|
|
|
|
+ QwUserMapper qwUserMapper) {
|
|
|
this.qwCompanyMapper = qwCompanyMapper;
|
|
this.qwCompanyMapper = qwCompanyMapper;
|
|
|
this.seqMapper = seqMapper;
|
|
this.seqMapper = seqMapper;
|
|
|
this.rawMapper = rawMapper;
|
|
this.rawMapper = rawMapper;
|
|
|
this.messageMapper = messageMapper;
|
|
this.messageMapper = messageMapper;
|
|
|
this.pullService = pullService;
|
|
this.pullService = pullService;
|
|
|
this.handlers = handlers;
|
|
this.handlers = handlers;
|
|
|
|
|
+ this.qwUserMapper = qwUserMapper;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -128,6 +138,8 @@ public class QwMsgAuditIngestService {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
QwMsgAuditMessage msg = handlerOpt.get().buildMessage(corpId, seq, rawId, plain);
|
|
QwMsgAuditMessage msg = handlerOpt.get().buildMessage(corpId, seq, rawId, plain);
|
|
|
|
|
+ // 添加发送人角色判断
|
|
|
|
|
+ fillFromUserRole(msg);
|
|
|
messageMapper.insertQwMsgAuditMessage(msg);
|
|
messageMapper.insertQwMsgAuditMessage(msg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -140,5 +152,32 @@ public class QwMsgAuditIngestService {
|
|
|
|
|
|
|
|
seqMapper.advanceSeq(corpId, maxSeq);
|
|
seqMapper.advanceSeq(corpId, maxSeq);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 发送人角色判断
|
|
|
|
|
+ * 判断前两位为 wm/wo/wb 则为企业外部;否则按 qw_user_id + corp_id 查 qw_user,查到为内部销售,否则外部。from 为空打日志不写角色。
|
|
|
|
|
+ */
|
|
|
|
|
+ private void fillFromUserRole(QwMsgAuditMessage msg) {
|
|
|
|
|
+ String from = msg.getFromUser();
|
|
|
|
|
+ String corpId = msg.getCorpId();
|
|
|
|
|
+ if (!StringUtils.hasText(from)) {
|
|
|
|
|
+ log.warn("消息发送方id有误, corpId={}, seq={}", corpId, msg.getSeq());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String f = from.trim();
|
|
|
|
|
+ if (f.length() >= 2) {
|
|
|
|
|
+ String prefix = f.substring(0, 2).toLowerCase(Locale.ROOT);
|
|
|
|
|
+ if ("wm".equals(prefix) || "wo".equals(prefix) || "wb".equals(prefix)) {
|
|
|
|
|
+ msg.setFromUserRole(FROM_USER_ROLE_EXTERNAL);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ QwUser u = qwUserMapper.selectQwUserByIdByWeComeText2(f, corpId);
|
|
|
|
|
+ if (u != null) {
|
|
|
|
|
+ msg.setFromUserRole(FROM_USER_ROLE_INTERNAL);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msg.setFromUserRole(FROM_USER_ROLE_EXTERNAL);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|