|
|
@@ -1937,8 +1937,9 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
sendAIParam.setKey(user.getAppKey());
|
|
|
redisTemplate.opsForList().leftPush("AiMsg:"+user.getAppKey(), JSON.toJSONString(sendAIParam));
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
- public R qwHookNotifyAddMsg(Long qwUserID, Long sender,String count,String uid) {
|
|
|
+ public R qwHookNotifyAddMsgNew(Long qwUserID, Long sender,String count,String uid,Integer type) {
|
|
|
QwUser sendUser = qwUserMapper.selectQwUserById(qwUserID);
|
|
|
|
|
|
|
|
|
@@ -1952,6 +1953,25 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
FastGptChatSession fastGptChatSession = fastGptChatSessionMapper.selectFastGptChatSessionByQwExternalContactsAndUserId(qwExternalContacts.getId(), sendUser.getId());
|
|
|
if (fastGptChatSession!=null){
|
|
|
saveQwUserMsg(fastGptChatSession,2,count);
|
|
|
+ // 客服进行回复后就转人工10分钟
|
|
|
+ if(type == 1){
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.add(Calendar.MINUTE, -5);
|
|
|
+ Date lastTime = calendar.getTime();
|
|
|
+ if(lastTime.after(fastGptChatSession.getCreateTime())){
|
|
|
+ Calendar calendar1 = Calendar.getInstance();
|
|
|
+ //定时任务会处理10分钟以内的,所以设置20分钟
|
|
|
+ calendar1.add(Calendar.MINUTE, 10);
|
|
|
+ Date expireTime = calendar1.getTime();
|
|
|
+
|
|
|
+ FastGptChatSession chatSession = new FastGptChatSession();
|
|
|
+ chatSession.setLastTime(expireTime);
|
|
|
+ chatSession.setIsArtificial(1);
|
|
|
+ chatSession.setSessionId(fastGptChatSession.getSessionId());
|
|
|
+
|
|
|
+ fastGptChatSessionMapper.updateFastGptChatSession(chatSession);
|
|
|
+ }
|
|
|
+ }
|
|
|
}else {
|
|
|
|
|
|
if(qwExternalContacts.getType()!=null&&qwExternalContacts.getType()==1){
|
|
|
@@ -1978,19 +1998,50 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 客服进行回复后就转人工10分钟
|
|
|
- if(fastGptChatSession != null){
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- //定时任务会处理10分钟以内的,所以设置20分钟
|
|
|
- calendar.add(Calendar.MINUTE, 30);
|
|
|
- Date expireTime = calendar.getTime();
|
|
|
-
|
|
|
- FastGptChatSession chatSession = new FastGptChatSession();
|
|
|
- chatSession.setLastTime(expireTime);
|
|
|
- chatSession.setIsArtificial(1);
|
|
|
- chatSession.setSessionId(fastGptChatSession.getSessionId());
|
|
|
-
|
|
|
- fastGptChatSessionMapper.updateFastGptChatSession(chatSession);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R qwHookNotifyAddMsg(Long qwUserID, Long sender,String count,String uid) {
|
|
|
+ QwUser sendUser = qwUserMapper.selectQwUserById(qwUserID);
|
|
|
+
|
|
|
+
|
|
|
+ if (sendUser!=null){
|
|
|
+
|
|
|
+ String extId = getExtId(sender, uid, sendUser.getServerId());
|
|
|
+ QwExternalContact qwExternalContacts = qwExternalContactMapper.selectQwExternalContactByExternalUserIdAndQwUserId(extId, sendUser.getCorpId(),sendUser.getQwUserId());
|
|
|
+ if (qwExternalContacts==null){
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ FastGptChatSession fastGptChatSession = fastGptChatSessionMapper.selectFastGptChatSessionByQwExternalContactsAndUserId(qwExternalContacts.getId(), sendUser.getId());
|
|
|
+ if (fastGptChatSession!=null){
|
|
|
+ saveQwUserMsg(fastGptChatSession,2,count);
|
|
|
+ }else {
|
|
|
+
|
|
|
+ if(qwExternalContacts.getType()!=null&&qwExternalContacts.getType()==1){
|
|
|
+ if(sendUser.getFastGptRoleId()!=null){
|
|
|
+ fastGptChatSession = new FastGptChatSession();
|
|
|
+ String chatId = UUID.randomUUID().toString();
|
|
|
+ fastGptChatSession.setChatId(chatId);
|
|
|
+ fastGptChatSession.setKfId(sendUser.getFastGptRoleId().toString());
|
|
|
+ fastGptChatSession.setStatus(1);
|
|
|
+ fastGptChatSession.setRemindCount(0);
|
|
|
+ fastGptChatSession.setRemindStatus(0);
|
|
|
+ fastGptChatSession.setCreateTime(new Date());
|
|
|
+ fastGptChatSession.setQwExtId(qwExternalContacts.getId());
|
|
|
+ fastGptChatSession.setQwUserId(sendUser.getId());
|
|
|
+ fastGptChatSession.setIsArtificial(0);
|
|
|
+ fastGptChatSession.setAvatar(qwExternalContacts.getAvatar());
|
|
|
+ fastGptChatSession.setNickName(qwExternalContacts.getName());
|
|
|
+ fastGptChatSession.setCompanyId(sendUser.getCompanyId());
|
|
|
+ fastGptChatSession.setLastTime(new Date());
|
|
|
+ fastGptChatSession.setIsReply(0);
|
|
|
+ fastGptChatSessionMapper.insertFastGptChatSession(fastGptChatSession);
|
|
|
+ addUserSex(qwExternalContacts);
|
|
|
+ saveQwUserMsg(fastGptChatSession,2,count);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return R.ok();
|