1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-07-24 08:31:45 +08:00

enhance tag api, fix chatbot agent transfer bug, fix chatbot tab, etc.

This commit is contained in:
Hai Liang Wang 2019-12-12 14:40:29 +08:00
parent 38ce01bc8f
commit 6abacc646e
7 changed files with 82 additions and 27 deletions

View File

@ -831,40 +831,58 @@ public class IMController extends Handler {
}
map.addAttribute("username", nickname);
boolean isChatbotAgentFirst = false;
boolean isEnableExchangeAgentType = false;
Chatbot bot = null;
// 是否使用机器人客服
Chatbot bot = null;
if (MainContext.hasModule(Constants.CSKEFU_MODULE_CHATBOT) &&
StringUtils.isNotBlank(invite.getAiid()) &&
invite.isAi() &&
((bot = chatbotRes.findOne(invite.getAiid())) != null) &&
((StringUtils.equals(
ai, "true")) || (invite.isAifirst() && ai == null))) { //启用 AI 并且 AI优先 接待
if (invite.isAi() && MainContext.hasModule(Constants.CSKEFU_MODULE_CHATBOT)) {
// 查找机器人
bot = chatbotRes.findOne(invite.getAiid());
if (bot != null) {
// 判断是否接受访客切换坐席类型
isEnableExchangeAgentType = !StringUtils.equals(
bot.getWorkmode(), Constants.CHATBOT_CHATBOT_ONLY);
// 判断是否机器人客服优先
if (((StringUtils.equals(
ai, "true")) || (invite.isAifirst() && ai == null))) {
isChatbotAgentFirst = true;
}
}
}
map.addAttribute(
"exchange", isEnableExchangeAgentType);
if (isChatbotAgentFirst) {
// 机器人坐席
HashMap<String, String> chatbotConfig = new HashMap<String, String>();
chatbotConfig.put("botname", invite.getAiname());
chatbotConfig.put("botid", invite.getAiid());
chatbotConfig.put("botwelcome", invite.getAimsg());
chatbotConfig.put("botfirst", Boolean.toString(invite.isAifirst()));
chatbotConfig.put("isai", Boolean.toString(invite.isAi()));
map.addAttribute(
"exchange", !StringUtils.equals(bot.getWorkmode(), Constants.CHATBOT_CHATBOT_ONLY));
if (chatbotConfig != null) {
map.addAttribute("chatbotConfig", chatbotConfig);
}
view = request(super.createRequestPageTempletResponse("/apps/im/chatbot/index"));
if (MobileDevice.isMobile(request.getHeader("User-Agent")) || StringUtils.isNotBlank(mobile)) {
if (MobileDevice.isMobile(request.getHeader("User-Agent")) || StringUtils.isNotBlank(
mobile)) {
view = request(super.createRequestPageTempletResponse(
"/apps/im/chatbot/mobile")); // 智能机器人 移动端
}
} else {
// 维持人工坐席的设定检查是否进入留言
if (!isLeavemsg && (MobileDevice.isMobile(
request.getHeader("User-Agent")) || StringUtils.isNotBlank(mobile))) {
view = request(
super.createRequestPageTempletResponse("/apps/im/mobile")); // WebIM移动端再次点选技能组
}
}
map.addAttribute(
"chatMessageList", chatMessageRes.findByUsessionAndOrgi(userid, orgi, new PageRequest(0, 20,
Direction.DESC,

View File

@ -0,0 +1,32 @@
package com.chatopera.cc.persistence.impl;
import com.chatopera.cc.model.Tag;
import com.chatopera.cc.model.User;
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
import com.chatopera.cc.persistence.repository.TagRepository;
import com.chatopera.cc.persistence.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.util.List;
@Service("tagdata")
public class TagDataExchangeImpl implements DataExchangeInterface {
@Autowired
private TagRepository tagRes;
public String getDataByIdAndOrgi(String id, String orgi) {
Tag tag = tagRes.findByOrgiAndId(orgi, id);
return tag != null ? tag.getTag() : id;
}
@Override
public List<Serializable> getListDataByIdAndOrgi(String id, String creater, String orgi) {
return null;
}
public void process(Object data, String orgi) {
}
}

View File

@ -27,20 +27,20 @@ import java.util.List;
@Service("userdata")
public class UserDataExchangeImpl implements DataExchangeInterface {
@Autowired
private UserRepository userRes ;
public String getDataByIdAndOrgi(String id, String orgi){
User user = userRes.findById(id);
return user!=null ? user.getUsername() : id;
}
@Autowired
private UserRepository userRes;
@Override
public List<Serializable> getListDataByIdAndOrgi(String id , String creater, String orgi) {
return null ;
}
public void process(Object data , String orgi) {
}
public String getDataByIdAndOrgi(String id, String orgi) {
User user = userRes.findById(id);
return user != null ? user.getUsername() : id;
}
@Override
public List<Serializable> getListDataByIdAndOrgi(String id, String creater, String orgi) {
return null;
}
public void process(Object data, String orgi) {
}
}

View File

@ -242,6 +242,10 @@
var hostname = location.hostname ;
var socket = io.connect(location.protocol+"//"+top.hostname+":"+top.port+"/im/ent?userid=${user.id!''!''}&orgi=${user.orgi!''}&contextid=${contextid!''}",{transports: ['websocket'], upgrade: false});
socket.on('message', function(data) {
if(data.contextid != "${entimuser.id!''}"){
return;
}
console.log('message', data);
data.createtime = formatDate(data.createtime);
var chat=document.getElementsByClassName('chatting-left').innerText;

View File

@ -362,7 +362,7 @@
<div class="ukefu-func-tab">
<ul>
<#if models?seq_contains("chatbot") && inviteData.ai && aiid??>
<#if !exchange?? || exchange == "true">
<#if exchange == "true">
<li><a href="/im/index.html?appid=${appid!''}&orgi=${orgi!''}<#if aiid??>&aiid=${aiid}</#if>&ai=true<#if client??>&client=${client!''}</#if><#if type??>&type=text</#if><#if skill??>&skill=${skill!''}</#if><#if agent??>&agent=${agent!''}</#if><#if title??>&title=${title?url}</#if><#if url??>&url=${url?url}</#if><#if traceid??>&traceid=${traceid}</#if>&userid=${userid!''}&sessionid=${sessionid!''}&t=${.now?long}">智能客服</a></li>
</#if>
<li class="cur"><a href="javascript:void(0)">人工坐席</a></li>

View File

@ -7710,6 +7710,7 @@ INSERT INTO `uk_sysdic` VALUES ('ff8080816de316aa016de31d0e130016', '企业聊
INSERT INTO `uk_sysdic` VALUES ('ff8080816de316aa016de3201ffb001c', '创建群组', 'pub', 'A14_A01', 'cskefu', 'layui-icon', 'ff8080816de316aa016de31d0e130016', '', NULL, '', '', NULL, '4028cac3614cd2f901614cf8be1f0324', '2019-10-19 16:26:36', NULL, 1, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `uk_sysdic` VALUES ('4028c1236170e237016170e4d95a03c6', '类似问题', 'pub', 'topicmore', 'cskefu', 'layui-icon', '402888815e097729015e0999f26e0002', '', NULL, '', '', NULL, '4028cac3614cd2f901614cf8be1f0324', '2018-02-07 23:31:41', NULL, 1, 0, '402888815e097729015e0999f26e0002', 0, 0, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `uk_sysdic` VALUES ('4028c1236173b85b016173bde0fd0333', '用户接口', 'pub', 'userdata', 'cskefu', 'layui-icon', '402888815e097729015e0999f26e0002', '', NULL, '', '', NULL, '4028cac3614cd2f901614cf8be1f0324', '2018-02-08 12:47:59', NULL, 1, 0, '402888815e097729015e0999f26e0002', 0, 0, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `uk_sysdic` VALUES ('4028826a6eeed0f3016eeed9eee7001c', '标签接口', 'pub', 'tagdata', 'cskefu', 'layui-icon', '402888815e097729015e0999f26e0002', '', NULL, '', '', NULL, '4028cac3614cd2f901614cf8be1f0324', '2019-12-10 16:08:10', NULL, 1, 0, '402888815e097729015e0999f26e0002', 0, 0, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `uk_sysdic` VALUES ('4028c1236173b85b016173be114e0335', '部门接口', 'pub', 'organdata', 'cskefu', 'layui-icon', '402888815e097729015e0999f26e0002', '', NULL, '', '', NULL, '4028cac3614cd2f901614cf8be1f0324', '2018-02-08 12:48:11', NULL, 1, 0, '402888815e097729015e0999f26e0002', 0, 0, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `uk_sysdic` VALUES ('4028cba3613c9d2d01613cb0dbf8062d', '全部联系人', 'pub', 'A02_A01_A02_B01', NULL, 'auth', '402881ef612b1f5b01612cc87273054a', NULL, NULL, '', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-28 20:14:39', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, 'javascript:;', 'webim', '4', NULL, 'top');
INSERT INTO `uk_sysdic` VALUES ('4028cba3613c9d2d01613cb15cce062e', '今日新增', 'pub', 'A02_A01_A02_B02', NULL, 'auth', '402881ef612b1f5b01612cc87273054a', NULL, NULL, '', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-28 20:15:12', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, 'javascript:;', 'webim', '4', NULL, 'top');

View File

@ -241,7 +241,7 @@ public class ChatbotEventHandler {
MainContext.getCache().deleteAgentUserByUserIdAndOrgi(p, orgi);
MainContext.getCache().deleteOnlineUserByIdAndOrgi(user, orgi);
p.setStatus(MainContext.OnlineUserStatusEnum.OFFLINE.toString());
p.setStatus(MainContext.AgentUserStatusEnum.END.toString());
onlineUser.setStatus(MainContext.OnlineUserStatusEnum.OFFLINE.toString());
getAgentUserRes().save(p);