diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java b/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java index 0f66550b..dc40f81e 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java @@ -72,7 +72,6 @@ public class AutomaticServiceDist { /** * 载入坐席 ACD策略配置 * - * @param orgi * @return */ @SuppressWarnings("unchecked") @@ -530,7 +529,7 @@ public class AutomaticServiceDist { * @return * @throws Exception */ - public static AgentService processChatbotService(final AgentUser agentUser, final String orgi) { + public static AgentService processChatbotService(final String botName, final AgentUser agentUser, final String orgi) { AgentService agentService = new AgentService(); //放入缓存的对象 AgentServiceRepository agentServiceRes = MainContext.getContext().getBean(AgentServiceRepository.class); Date now = new Date(); @@ -550,6 +549,8 @@ public class AutomaticServiceDist { agentService.setRegion(agentUser.getRegion()); agentService.setUsername(agentUser.getUsername()); agentService.setChannel(agentUser.getChannel()); + if (botName != null) + agentService.setAgentusername(botName); if (StringUtils.isNotBlank(agentUser.getContextid())) { agentService.setContextid(agentUser.getContextid()); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java index b7c3cd3e..412b9930 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java @@ -473,6 +473,12 @@ public class Handler { this.starttime = starttime; } + /** + * 使用Blob保存文件 + * @param multipart + * @return id + * @throws IOException + */ public String saveImageFileWithMultipart(MultipartFile multipart) throws IOException { StreamingFile sf = new StreamingFile(); final String fileid = MainUtils.getUUID(); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/OnlineUserController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/OnlineUserController.java index ed3621f7..4373ce35 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/OnlineUserController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/OnlineUserController.java @@ -16,20 +16,14 @@ */ package com.chatopera.cc.app.handler.apps.service; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - import com.chatopera.cc.app.basic.MainContext; -import com.chatopera.cc.util.Menu; +import com.chatopera.cc.app.basic.MainUtils; +import com.chatopera.cc.app.handler.Handler; +import com.chatopera.cc.app.model.*; import com.chatopera.cc.app.persistence.es.ContactsRepository; import com.chatopera.cc.app.persistence.impl.AgentUserService; -import com.chatopera.cc.app.handler.Handler; -import com.chatopera.cc.app.model.AgentServiceSummary; -import com.chatopera.cc.app.model.AgentUser; -import com.chatopera.cc.app.model.AgentUserContacts; -import com.chatopera.cc.app.model.OnlineUser; +import com.chatopera.cc.app.persistence.repository.*; +import com.chatopera.cc.util.Menu; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; @@ -39,156 +33,147 @@ import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; -import com.chatopera.cc.app.basic.MainUtils; -import com.chatopera.cc.app.persistence.repository.AgentServiceRepository; -import com.chatopera.cc.app.persistence.repository.AgentUserContactsRepository; -import com.chatopera.cc.app.persistence.repository.ChatMessageRepository; -import com.chatopera.cc.app.persistence.repository.OnlineUserHisRepository; -import com.chatopera.cc.app.persistence.repository.OnlineUserRepository; -import com.chatopera.cc.app.persistence.repository.ServiceSummaryRepository; -import com.chatopera.cc.app.persistence.repository.TagRelationRepository; -import com.chatopera.cc.app.persistence.repository.TagRepository; -import com.chatopera.cc.app.persistence.repository.UserEventRepository; -import com.chatopera.cc.app.persistence.repository.WeiXinUserRepository; -import com.chatopera.cc.app.model.AgentService; -import com.chatopera.cc.app.model.WeiXinUser; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.List; @Controller @RequestMapping("/service") public class OnlineUserController extends Handler { - @Autowired - private AgentServiceRepository agentServiceRes ; - - @Autowired - private AgentUserService agentUserRes ; - - @Autowired - private OnlineUserRepository onlineUserRes; - - @Autowired - private UserEventRepository userEventRes; - - @Autowired - private ServiceSummaryRepository serviceSummaryRes; - - - @Autowired - private OnlineUserHisRepository onlineUserHisRes; - - @Autowired - private WeiXinUserRepository weiXinUserRes; - - @Autowired - private TagRepository tagRes ; - - @Autowired - private TagRelationRepository tagRelationRes ; - - @Autowired - private ChatMessageRepository chatMessageRepository ; - - @Autowired - private ContactsRepository contactsRes ; - - @Autowired - private AgentUserContactsRepository agentUserContactsRes ; - - @RequestMapping("/online/index") - @Menu(type = "service" , subtype = "online" , admin= true) - public ModelAndView index(ModelMap map , HttpServletRequest request , String userid , String agentservice , @Valid String channel) { - if(!StringUtils.isBlank(userid)){ - map.put("inviteResult", MainUtils.getWebIMInviteResult(onlineUserRes.findByOrgiAndUserid(super.getOrgi(request), userid))) ; - map.put("tagRelationList", tagRelationRes.findByUserid(userid)) ; - map.put("onlineUserHistList", onlineUserHisRes.findByUseridAndOrgi(userid, super.getOrgi(request))) ; - map.put("agentServicesAvg", onlineUserRes.countByUserForAvagTime(super.getOrgi(request), MainContext.AgentUserStatusEnum.END.toString(),userid)) ; - - List agentServiceList = agentServiceRes.findByUseridAndOrgi(userid, super.getOrgi(request)) ; - - map.put("agentServiceList", agentServiceList) ; - if(agentServiceList.size()>0){ - map.put("serviceCount", Integer - .valueOf(this.agentServiceRes - .countByUseridAndOrgiAndStatus(userid, super.getOrgi(request), - MainContext.AgentUserStatusEnum.END.toString()))); - - AgentService agentService = agentServiceList.get(0) ; - if(!StringUtils.isBlank(agentservice)){ - for(AgentService as : agentServiceList){ - if(as.getId().equals(agentservice)){ - agentService = as ; break ; - } - } - } - - if(agentService!=null){ - List summaries = serviceSummaryRes.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request)) ; - if(summaries.size() > 0) - map.put("summary" , summaries.get(0)) ; - } - - List agentUserContactsList = agentUserContactsRes.findByUseridAndOrgi(userid, super.getOrgi(request)) ; - if(agentUserContactsList.size() > 0){ - AgentUserContacts agentUserContacts = agentUserContactsList.get(0) ; - map.put("contacts", contactsRes.findOne(agentUserContacts.getContactsid())) ; - } - - map.put("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.USER.toString())) ; - map.put("summaryTags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.SUMMARY.toString())) ; - map.put("curAgentService", agentService) ; - - - map.put("agentUserMessageList", chatMessageRepository.findByAgentserviceidAndOrgi(agentService.getId() , super.getOrgi(request), new PageRequest(0, 50, Direction.DESC , "updatetime"))); - } - - if(MainContext.ChannelTypeEnum.WEIXIN.toString().equals(channel)){ - List weiXinUserList = weiXinUserRes.findByOpenidAndOrgi(userid, super.getOrgi(request)) ; - if(weiXinUserList.size() > 0){ - WeiXinUser weiXinUser = weiXinUserList.get(0) ; - map.put("weiXinUser",weiXinUser); - } - }else if(MainContext.ChannelTypeEnum.WEBIM.toString().equals(channel)){ - List onlineUserList = onlineUserRes.findByUseridAndOrgi(userid, super.getOrgi(request)) ; - if(onlineUserList.size() >0){ - map.put("onlineUser", onlineUserList.get(0)) ; - } - } - map.put("agentUser", agentUserRes.findByUseridAndOrgi(userid, super.getOrgi(request))) ; - map.put("curragentuser", agentUserRes.findByUseridAndOrgi(userid, super.getOrgi(request))) ; - } + @Autowired + private AgentServiceRepository agentServiceRes; + + @Autowired + private AgentUserService agentUserRes; + + @Autowired + private OnlineUserRepository onlineUserRes; + + @Autowired + private UserEventRepository userEventRes; + + @Autowired + private ServiceSummaryRepository serviceSummaryRes; + + + @Autowired + private OnlineUserHisRepository onlineUserHisRes; + + @Autowired + private WeiXinUserRepository weiXinUserRes; + + @Autowired + private TagRepository tagRes; + + @Autowired + private TagRelationRepository tagRelationRes; + + @Autowired + private ChatMessageRepository chatMessageRepository; + + @Autowired + private ContactsRepository contactsRes; + + @Autowired + private AgentUserContactsRepository agentUserContactsRes; + + @RequestMapping("/online/index") + @Menu(type = "service", subtype = "online", admin = true) + public ModelAndView index(ModelMap map, HttpServletRequest request, String userid, String agentservice, @Valid String channel) { + if (StringUtils.isNotBlank(userid)) { + map.put("inviteResult", MainUtils.getWebIMInviteResult(onlineUserRes.findByOrgiAndUserid(super.getOrgi(request), userid))); + map.put("tagRelationList", tagRelationRes.findByUserid(userid)); + map.put("onlineUserHistList", onlineUserHisRes.findByUseridAndOrgi(userid, super.getOrgi(request))); + map.put("agentServicesAvg", onlineUserRes.countByUserForAvagTime(super.getOrgi(request), MainContext.AgentUserStatusEnum.END.toString(), userid)); + + List agentServiceList = agentServiceRes.findByUseridAndOrgiOrderByLogindateDesc(userid, super.getOrgi(request)); + + map.put("agentServiceList", agentServiceList); + if (agentServiceList.size() > 0) { + map.put("serviceCount", Integer + .valueOf(this.agentServiceRes + .countByUseridAndOrgiAndStatus(userid, super.getOrgi(request), + MainContext.AgentUserStatusEnum.END.toString()))); + + AgentService agentService = agentServiceList.get(0); + if (StringUtils.isNotBlank(agentservice)) { + for (AgentService as : agentServiceList) { + if (as.getId().equals(agentservice)) { + agentService = as; + break; + } + } + } + + if (agentService != null) { + List summaries = serviceSummaryRes.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request)); + if (summaries.size() > 0) + map.put("summary", summaries.get(0)); + } + + List agentUserContactsList = agentUserContactsRes.findByUseridAndOrgi(userid, super.getOrgi(request)); + if (agentUserContactsList.size() > 0) { + AgentUserContacts agentUserContacts = agentUserContactsList.get(0); + map.put("contacts", contactsRes.findOne(agentUserContacts.getContactsid())); + } + + map.put("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.USER.toString())); + map.put("summaryTags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.SUMMARY.toString())); + map.put("curAgentService", agentService); + + + map.put("agentUserMessageList", chatMessageRepository.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request), new PageRequest(0, 50, Direction.DESC, "updatetime"))); + } + + if (MainContext.ChannelTypeEnum.WEIXIN.toString().equals(channel)) { + List weiXinUserList = weiXinUserRes.findByOpenidAndOrgi(userid, super.getOrgi(request)); + if (weiXinUserList.size() > 0) { + WeiXinUser weiXinUser = weiXinUserList.get(0); + map.put("weiXinUser", weiXinUser); + } + } else if (MainContext.ChannelTypeEnum.WEBIM.toString().equals(channel)) { + List onlineUserList = onlineUserRes.findByUseridAndOrgi(userid, super.getOrgi(request)); + if (onlineUserList.size() > 0) { + map.put("onlineUser", onlineUserList.get(0)); + } + } + map.put("agentUser", agentUserRes.findByUseridAndOrgi(userid, super.getOrgi(request))); + map.put("curragentuser", agentUserRes.findByUseridAndOrgi(userid, super.getOrgi(request))); + } return request(super.createAppsTempletResponse("/apps/service/online/index")); } - - @RequestMapping("/online/chatmsg") - @Menu(type = "service" , subtype = "chatmsg" , admin= true) - public ModelAndView onlinechat(ModelMap map , HttpServletRequest request , String id , String title) { - AgentService agentService = agentServiceRes.getOne(id) ; - AgentUser curragentuser = agentUserRes.findByUseridAndOrgi(agentService.getUserid(), super.getOrgi(request)) ; - - map.put("curAgentService", agentService) ; - map.put("curragentuser", curragentuser) ; - if(!StringUtils.isBlank(title)){ - map.put("title", title) ; - } - - map.put("summaryTags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.SUMMARY.toString())) ; - - if(agentService!=null){ - List summaries = serviceSummaryRes.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request)) ; - if(summaries.size() > 0) - map.put("summary" , summaries.get(0)) ; - } - - map.put("agentUserMessageList", chatMessageRepository.findByAgentserviceidAndOrgi(agentService.getId() , super.getOrgi(request), new PageRequest(0, 50, Direction.DESC , "updatetime"))); - + + @RequestMapping("/online/chatmsg") + @Menu(type = "service", subtype = "chatmsg", admin = true) + public ModelAndView onlinechat(ModelMap map, HttpServletRequest request, String id, String title) { + AgentService agentService = agentServiceRes.getOne(id); + AgentUser curragentuser = agentUserRes.findByUseridAndOrgi(agentService.getUserid(), super.getOrgi(request)); + + map.put("curAgentService", agentService); + map.put("curragentuser", curragentuser); + if (StringUtils.isNotBlank(title)) { + map.put("title", title); + } + + map.put("summaryTags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.SUMMARY.toString())); + + if (agentService != null) { + List summaries = serviceSummaryRes.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request)); + if (summaries.size() > 0) + map.put("summary", summaries.get(0)); + } + + map.put("agentUserMessageList", chatMessageRepository.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request), new PageRequest(0, 50, Direction.DESC, "updatetime"))); + return request(super.createRequestPageTempletResponse("/apps/service/online/chatmsg")); } - - @RequestMapping("/trace") - @Menu(type = "service" , subtype = "trace" , admin= false) - public ModelAndView trace(ModelMap map , HttpServletRequest request , @Valid String sessionid) { - if(!StringUtils.isBlank(sessionid)){ - map.addAttribute("traceHisList", userEventRes.findBySessionidAndOrgi(sessionid, super.getOrgi(request), new PageRequest(0, 100))) ; - } + + @RequestMapping("/trace") + @Menu(type = "service", subtype = "trace", admin = false) + public ModelAndView trace(ModelMap map, HttpServletRequest request, @Valid String sessionid) { + if (StringUtils.isNotBlank(sessionid)) { + map.addAttribute("traceHisList", userEventRes.findBySessionidAndOrgi(sessionid, super.getOrgi(request), new PageRequest(0, 100))); + } return request(super.createRequestPageTempletResponse("/apps/service/online/trace")); } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java index 6aaf9bac..3f2a32e1 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java @@ -161,6 +161,7 @@ public class ChatbotEventHandler { agentUser.setCreatetime(now); agentUser.setUpdatetime(now); agentUser.setSessionid(session); + agentUser.setRegion(onlineUser.getRegion()); // 聊天机器人处理的请求 agentUser.setOpttype(MainContext.OptTypeEnum.CHATBOT.toString()); @@ -168,7 +169,7 @@ public class ChatbotEventHandler { agentUser.setCity(onlineUser.getCity()); agentUser.setProvince(onlineUser.getProvince()); agentUser.setCountry(onlineUser.getCountry()); - AgentService agentService = AutomaticServiceDist.processChatbotService(agentUser, orgi); + AgentService agentService = AutomaticServiceDist.processChatbotService(invite != null ? invite.getAiname() : "机器人客服", agentUser, orgi); agentUser.setAgentserviceid(agentService.getId()); // 标记为机器人坐席 @@ -194,7 +195,7 @@ public class ChatbotEventHandler { AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(user, orgi); OnlineUser onlineUser = (OnlineUser) CacheHelper.getOnlineUserCacheBean().getCacheObject(user, orgi); if (agentUser != null) { - AutomaticServiceDist.processChatbotService(agentUser, orgi); + AutomaticServiceDist.processChatbotService(null, agentUser, orgi); CacheHelper.getAgentUserCacheBean().delete(user, MainContext.SYSTEM_ORGI); CacheHelper.getOnlineUserCacheBean().delete(user, orgi); agentUser.setStatus(MainContext.OnlineUserOperatorStatus.OFFLINE.toString()); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java index e91c58b4..ce649a21 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java @@ -167,7 +167,7 @@ public class IMEventHandler { } AgentServiceRepository agentServiceRes = MainContext.getContext().getBean(AgentServiceRepository.class); - List agentServiceList = agentServiceRes.findByUseridAndOrgi(user, orgi); + List agentServiceList = agentServiceRes.findByUseridAndOrgiOrderByLogindateDesc(user, orgi); if (agentServiceList.size() > 0) { AgentService agentService = agentServiceList.get(0); agentService.setName(contacts.getName()); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/AgentServiceRepository.java b/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/AgentServiceRepository.java index 4cc2eeb4..10f897ee 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/AgentServiceRepository.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/AgentServiceRepository.java @@ -31,7 +31,7 @@ public abstract interface AgentServiceRepository { public abstract AgentService findByIdAndOrgi(String paramString , String orgi); - public abstract List findByUseridAndOrgi(String paramString, String orgi); + public abstract List findByUseridAndOrgiOrderByLogindateDesc(String paramString, String orgi); public abstract Page findByOrgi(String orgi, Pageable paramPageable); diff --git a/contact-center/app/src/main/resources/templates/apps/service/history/index.html b/contact-center/app/src/main/resources/templates/apps/service/history/index.html index a0809a26..75b13d40 100644 --- a/contact-center/app/src/main/resources/templates/apps/service/history/index.html +++ b/contact-center/app/src/main/resources/templates/apps/service/history/index.html @@ -97,9 +97,8 @@ 咨询时间 服务时间 等待时长 - 服务时间 + 服务时长 地域 -