|
@@ -155,57 +155,81 @@ public class QwUserVoiceLogServiceImpl extends ServiceImpl<QwUserVoiceLogMapper,
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void addQuUserVoiceByIpadCallback(Long id, Long extUserId, Integer recordType, Integer totalSeconds, String uuid) {
|
|
|
|
- QwUser sendUser = qwUserMapper.selectQwUserById(id);
|
|
|
|
- if (sendUser!=null){
|
|
|
|
- String extId = getExtId(extUserId, uuid, sendUser.getServerId());
|
|
|
|
- QwExternalContact qwExternalContacts = qwExternalContactMapper.selectQwExternalContactByExternalUserIdAndQwUserId(extId, sendUser.getCorpId(),sendUser.getQwUserId());
|
|
|
|
- if (qwExternalContacts==null){
|
|
|
|
- log.error("未找到外部联系人,qwUserId:" + id);
|
|
|
|
- return ;
|
|
|
|
- }
|
|
|
|
|
|
+ public void addQuUserVoiceByIpadCallback(Long id, Long extUserId, Integer recordType, Long totalSeconds, String uuid) {
|
|
|
|
+ // 参数校验
|
|
|
|
+ if (id == null || (extUserId == null && uuid == null)) {
|
|
|
|
+ log.error("参数校验失败: id={}, extUserId={}, uuid={}", id, extUserId, uuid);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- QwUserVoiceLog qwUserVoiceLog = new QwUserVoiceLog();
|
|
|
|
- qwUserVoiceLog.setCorpId(sendUser.getCorpId());
|
|
|
|
- qwUserVoiceLog.setExtId(qwExternalContacts.getId());
|
|
|
|
- qwUserVoiceLog.setQwUserId(sendUser.getId());
|
|
|
|
- qwUserVoiceLog.setCompanyId(qwExternalContacts.getCompanyId());
|
|
|
|
- if(qwExternalContacts.getCompanyUserId() != null){
|
|
|
|
- qwUserVoiceLog.setCompanyUserId(qwExternalContacts.getCompanyUserId());
|
|
|
|
- }
|
|
|
|
|
|
+ try {
|
|
|
|
+ QwUser sendUser = qwUserMapper.selectQwUserById(id);
|
|
|
|
+ if (sendUser != null) {
|
|
|
|
+ String extId = getExtId(extUserId, uuid, sendUser.getServerId());
|
|
|
|
+ // 检查extId是否有效
|
|
|
|
+ if (extId == null || extId.isEmpty()) {
|
|
|
|
+ log.error("获取外部联系人ID失败,qwUserId:" + id + ",extUserId:" + extUserId + ",uuid:" + uuid);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- if(recordType == 2){//2是未接通的处理
|
|
|
|
- qwUserVoiceLog.setStatus(Long.valueOf(recordType));
|
|
|
|
- qwUserVoiceLog.setTitle("通话拒接");
|
|
|
|
- }else{
|
|
|
|
- qwUserVoiceLog.setStatus(1L);
|
|
|
|
- if(totalSeconds != null){
|
|
|
|
- qwUserVoiceLog.setDuration(Long.valueOf(totalSeconds));
|
|
|
|
- }else{
|
|
|
|
- qwUserVoiceLog.setDuration(0L);
|
|
|
|
|
|
+ QwExternalContact qwExternalContacts = qwExternalContactMapper.selectQwExternalContactByExternalUserIdAndQwUserId(extId, sendUser.getCorpId(), sendUser.getQwUserId());
|
|
|
|
+ if (qwExternalContacts == null) {
|
|
|
|
+ log.error("未找到外部联系人,qwUserId:" + id + ",extId:" + extId);
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- qwUserVoiceLog.setTitle("通话已接听");
|
|
|
|
- }
|
|
|
|
- qwUserVoiceLog.setCreateTime(new Date());
|
|
|
|
-
|
|
|
|
- int insert = baseMapper.insertQwUserVoiceLog(qwUserVoiceLog);
|
|
|
|
- //插入成功的情况下就处理定时任务
|
|
|
|
- if(insert == 1){
|
|
|
|
- List<QwWorkTask> qwWorkTaskList = qwWorkTaskMapper.selectQwWorkTaskByExtIdAndQwUserId(qwUserVoiceLog);
|
|
|
|
- if(qwWorkTaskList != null && !qwWorkTaskList.isEmpty()){
|
|
|
|
- for (QwWorkTask qwWorkTask : qwWorkTaskList) {
|
|
|
|
- if(qwUserVoiceLog.getStatus() == 1L){//接通电话
|
|
|
|
- qwWorkTask.setTrackType(3);//1正常处理 2 未接听 3 已接听
|
|
|
|
- qwWorkTask.setDuration(qwUserVoiceLog.getDuration());
|
|
|
|
- }else{
|
|
|
|
- qwWorkTask.setTrackType(2);//1正常处理 2 未接听 3 已接听
|
|
|
|
|
|
+
|
|
|
|
+ QwUserVoiceLog qwUserVoiceLog = new QwUserVoiceLog();
|
|
|
|
+ qwUserVoiceLog.setCorpId(sendUser.getCorpId());
|
|
|
|
+ qwUserVoiceLog.setExtId(qwExternalContacts.getId());
|
|
|
|
+ qwUserVoiceLog.setQwUserId(sendUser.getId());
|
|
|
|
+ qwUserVoiceLog.setCompanyId(qwExternalContacts.getCompanyId());
|
|
|
|
+ if (qwExternalContacts.getCompanyUserId() != null) {
|
|
|
|
+ qwUserVoiceLog.setCompanyUserId(qwExternalContacts.getCompanyUserId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (recordType == 2) {//2是未接通的处理
|
|
|
|
+ qwUserVoiceLog.setStatus(recordType);
|
|
|
|
+ qwUserVoiceLog.setTitle("通话拒接");
|
|
|
|
+ } else {
|
|
|
|
+ qwUserVoiceLog.setStatus(1);
|
|
|
|
+ if (totalSeconds != null) {
|
|
|
|
+ qwUserVoiceLog.setDuration(totalSeconds);
|
|
|
|
+ } else {
|
|
|
|
+ qwUserVoiceLog.setDuration(0L);
|
|
|
|
+ }
|
|
|
|
+ qwUserVoiceLog.setTitle("通话已接听");
|
|
|
|
+ }
|
|
|
|
+ qwUserVoiceLog.setCreateTime(new Date());
|
|
|
|
+
|
|
|
|
+ int insert = baseMapper.insertQwUserVoiceLog(qwUserVoiceLog);
|
|
|
|
+ // 插入成功的情况下就处理定时任务
|
|
|
|
+ if (insert == 1) {
|
|
|
|
+ List<QwWorkTask> qwWorkTaskList = qwWorkTaskMapper.selectQwWorkTaskByExtIdAndQwUserId(qwUserVoiceLog);
|
|
|
|
+ if (qwWorkTaskList != null && !qwWorkTaskList.isEmpty()) {
|
|
|
|
+ for (QwWorkTask qwWorkTask : qwWorkTaskList) {
|
|
|
|
+ try {
|
|
|
|
+ if (qwUserVoiceLog.getStatus() == 1L) {//接通电话
|
|
|
|
+ qwWorkTask.setTrackType(3);//1正常处理 2 未接听 3 已接听
|
|
|
|
+ qwWorkTask.setDuration(qwUserVoiceLog.getDuration());
|
|
|
|
+ } else {
|
|
|
|
+ qwWorkTask.setTrackType(2);//1正常处理 2 未接听 3 已接听
|
|
|
|
+ }
|
|
|
|
+ qwWorkTask.setStatus(1);//0 待处理 1 已处理 3 过期
|
|
|
|
+ qwWorkTask.setUpdateTime(new Date());
|
|
|
|
+ qwWorkTaskMapper.updateQwWorkTask(qwWorkTask);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("更新任务状态失败, taskId: " + qwWorkTask.getId(), e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- qwWorkTask.setStatus(1);//0 待处理 1 已处理 3 过期
|
|
|
|
- qwWorkTask.setUpdateTime(new Date());
|
|
|
|
- qwWorkTaskMapper.updateQwWorkTask(qwWorkTask);
|
|
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ log.error("插入失败,qwUserId:" + id + ",extId:" + extUserId + ",uuid:" + uuid + ",totalSeconds" + totalSeconds);
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ log.error("未找到企微用户,id:" + id + ",extId:" + extUserId + ",uuid:" + uuid + ",totalSeconds" + totalSeconds);
|
|
}
|
|
}
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("处理通话回调异常, id:" + id + ",extUserId:" + extUserId + ",recordType:" + recordType + ",totalSeconds:" + totalSeconds + ",uuid:" + uuid, e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|