diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/Application.java b/contact-center/app/src/main/java/com/chatopera/cc/webim/Application.java index f7a1c9ed..72e53f08 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/webim/Application.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/webim/Application.java @@ -58,6 +58,7 @@ public class Application { static{ UKDataContext.model.put("contacts", true) ; UKDataContext.model.put("sales", true); + UKDataContext.model.put("chatbot", true); } /** diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/util/chatbot/ChatbotUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/webim/util/chatbot/ChatbotUtils.java index 955823a2..79a3ca2c 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/webim/util/chatbot/ChatbotUtils.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/webim/util/chatbot/ChatbotUtils.java @@ -22,9 +22,13 @@ import java.util.HashSet; public class ChatbotUtils { public static final HashSet VALID_LANGS = new HashSet(Arrays.asList(new String[]{"zh_CN", "en_US"})); - public static final HashSet VALID_WORKMODELS = new HashSet(Arrays.asList(new String[]{"客服机器人优先", "人工客服优先"})); + public static final String CHATBOT_FIRST = "客服机器人优先"; + public static final String HUMAN_FIRST = "人工客服优先"; + public static final HashSet VALID_WORKMODELS = new HashSet(Arrays.asList(new String[]{CHATBOT_FIRST, HUMAN_FIRST})); + public static final String SNS_TYPE_WEBIM = "webim"; + /** * 使用snsid得到ChatbotID * diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/api/rest/ApiChatbotController.java b/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/api/rest/ApiChatbotController.java index 2aa6899f..c2d96a0b 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/api/rest/ApiChatbotController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/api/rest/ApiChatbotController.java @@ -18,14 +18,13 @@ package com.chatopera.cc.webim.web.handler.api.rest; import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.UKTools; import com.chatopera.cc.util.exception.CallOutRecordException; -import com.chatopera.cc.webim.service.repository.ChatbotRepository; -import com.chatopera.cc.webim.service.repository.OrganRepository; -import com.chatopera.cc.webim.service.repository.SNSAccountRepository; -import com.chatopera.cc.webim.service.repository.UserRepository; +import com.chatopera.cc.webim.service.repository.*; +import com.chatopera.cc.webim.util.OnlineUserUtils; import com.chatopera.cc.webim.util.chatbot.ChatbotUtils; import com.chatopera.cc.webim.web.handler.Handler; import com.chatopera.cc.webim.web.handler.api.request.RestUtils; import com.chatopera.cc.webim.web.model.Chatbot; +import com.chatopera.cc.webim.web.model.CousultInvite; import com.chatopera.cc.webim.web.model.Organ; import com.chatopera.cc.webim.web.model.User; import com.chatopera.chatbot.ChatbotAPI; @@ -79,6 +78,9 @@ public class ApiChatbotController extends Handler { @Autowired private OrganRepository organRes; + @Autowired + private ConsultInviteRepository consultInviteRes; + @RequestMapping(method = RequestMethod.POST) @Menu(type = "apps", subtype = "chatbot", access = true) @ApiOperation("聊天机器人") @@ -147,6 +149,12 @@ public class ApiChatbotController extends Handler { if (c.getApi().exists(c.getChatbotID())) { c.setEnabled(isEnabled); chatbotRes.save(c); + + // 更新访客网站配置 + CousultInvite invite = OnlineUserUtils.cousult(c.getSnsAccountIdentifier(), c.getOrgi(), consultInviteRes); + invite.setAi(isEnabled); + consultInviteRes.save(invite); + resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC); resp.addProperty(RestUtils.RESP_KEY_DATA, "完成。"); } else { @@ -186,12 +194,12 @@ public class ApiChatbotController extends Handler { return resp; } + // 更新访客网站配置 + CousultInvite invite = OnlineUserUtils.cousult(c.getSnsAccountIdentifier(), c.getOrgi(), consultInviteRes); + if (j.has("workmode") && ChatbotUtils.VALID_WORKMODELS.contains(j.get("workmode").getAsString())) { c.setWorkmode(j.get("workmode").getAsString()); - } - - if (j.has("enabled")) { - c.setEnabled(j.get("enabled").getAsBoolean()); + invite.setAifirst(StringUtils.equals(ChatbotUtils.CHATBOT_FIRST, c.getWorkmode())); } String description = j.has("description") ? j.get("description").getAsString() : null; @@ -199,6 +207,13 @@ public class ApiChatbotController extends Handler { String welcome = j.has("welcome") ? j.get("welcome").getAsString() : null; String name = j.has("name") ? j.get("name").getAsString() : null; + + if (j.has("enabled")) { + boolean enabled = j.get("enabled").getAsBoolean(); + c.setEnabled(enabled); + invite.setAi(enabled); + } + if (StringUtils.isNotBlank(description) || StringUtils.isNotBlank(fallback) || StringUtils.isNotBlank(welcome)) { @@ -228,11 +243,19 @@ public class ApiChatbotController extends Handler { if (StringUtils.isNotBlank(fallback)) c.setFallback(fallback); - if (StringUtils.isNotBlank(welcome)) + if (StringUtils.isNotBlank(welcome)) { c.setWelcome(welcome); + invite.setAimsg(welcome); + } + + if (StringUtils.isNotBlank(name)) { + c.setName(name); + invite.setAiname(name); + } c.setUpdatetime(new Date()); chatbotRes.save(c); + consultInviteRes.save(invite); return resp; } @@ -328,6 +351,16 @@ public class ApiChatbotController extends Handler { try { if (c.getApi().deleteByChatbotID(c.getChatbotID())) { + // 更新访客网站配置 + CousultInvite invite = OnlineUserUtils.cousult(c.getSnsAccountIdentifier(), c.getOrgi(), consultInviteRes); + if (invite != null) { + invite.setAi(false); + invite.setAiname(null); + invite.setAimsg(null); + invite.setAifirst(false); + invite.setAiid(null); + consultInviteRes.save(invite); + } chatbotRes.delete(c); resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC); resp.addProperty(RestUtils.RESP_KEY_DATA, "删除成功。"); @@ -464,9 +497,6 @@ public class ApiChatbotController extends Handler { c.setPrimaryLanguage(primaryLanguage); c.setName(name); c.setWelcome(result.getJSONObject("data").getString("welcome")); - - // 默认不开启 - c.setEnabled(false); c.setCreater(creater); c.setOrgan(organ); c.setOrgi(orgi); @@ -477,6 +507,18 @@ public class ApiChatbotController extends Handler { c.setUpdatetime(dt); c.setWorkmode(workmode); + // 默认不开启 + boolean enabled = false; + c.setEnabled(enabled); + + // 更新访客网站配置 + CousultInvite invite = OnlineUserUtils.cousult(c.getSnsAccountIdentifier(), c.getOrgi(), consultInviteRes); + invite.setAi(enabled); + invite.setAifirst(StringUtils.equals(ChatbotUtils.CHATBOT_FIRST, workmode)); + invite.setAiid(c.getId()); + invite.setAiname(c.getName()); + invite.setAimsg(c.getWelcome()); + consultInviteRes.save(invite); chatbotRes.save(c); JsonObject data = new JsonObject(); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/apps/internet/IMController.java b/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/apps/internet/IMController.java index 68b345e0..c4546a07 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/apps/internet/IMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/webim/web/handler/apps/internet/IMController.java @@ -17,27 +17,18 @@ package com.chatopera.cc.webim.web.handler.apps.internet; -import java.io.File; -import java.io.IOException; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.util.Date; -import java.util.List; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; - import com.chatopera.cc.core.UKDataContext; +import com.chatopera.cc.util.*; import com.chatopera.cc.util.extra.DataExchangeInterface; import com.chatopera.cc.util.webim.WebIMClient; import com.chatopera.cc.webim.service.acd.ServiceQuene; import com.chatopera.cc.webim.service.cache.CacheHelper; import com.chatopera.cc.webim.service.es.ContactsRepository; +import com.chatopera.cc.webim.service.repository.*; import com.chatopera.cc.webim.util.MessageUtils; import com.chatopera.cc.webim.util.OnlineUserUtils; import com.chatopera.cc.webim.web.handler.Handler; +import com.chatopera.cc.webim.web.model.*; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -56,214 +47,198 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; -import com.chatopera.cc.util.BrowserClient; -import com.chatopera.cc.util.CheckMobile; -import com.chatopera.cc.util.IP; -import com.chatopera.cc.util.IPTools; -import com.chatopera.cc.util.Menu; -import com.chatopera.cc.util.UKTools; -import com.chatopera.cc.webim.service.repository.AgentServiceSatisRepository; -import com.chatopera.cc.webim.service.repository.AgentUserContactsRepository; -import com.chatopera.cc.webim.service.repository.AttachmentRepository; -import com.chatopera.cc.webim.service.repository.ChatMessageRepository; -import com.chatopera.cc.webim.service.repository.ConsultInviteRepository; -import com.chatopera.cc.webim.service.repository.InviteRecordRepository; -import com.chatopera.cc.webim.service.repository.LeaveMsgRepository; -import com.chatopera.cc.webim.service.repository.SNSAccountRepository; -import com.chatopera.cc.webim.web.model.AgentReport; -import com.chatopera.cc.webim.web.model.AgentServiceSatis; -import com.chatopera.cc.webim.web.model.AgentUserContacts; -import com.chatopera.cc.webim.web.model.AiConfig; -import com.chatopera.cc.webim.web.model.AttachmentFile; -import com.chatopera.cc.webim.web.model.BlackEntity; -import com.chatopera.cc.webim.web.model.Contacts; -import com.chatopera.cc.webim.web.model.CousultInvite; -import com.chatopera.cc.webim.web.model.InviteRecord; -import com.chatopera.cc.webim.web.model.KnowledgeType; -import com.chatopera.cc.webim.web.model.LeaveMsg; -import com.chatopera.cc.webim.web.model.SNSAccount; -import com.chatopera.cc.webim.web.model.SessionConfig; -import com.chatopera.cc.webim.web.model.SystemConfig; -import com.chatopera.cc.webim.web.model.Topic; -import com.chatopera.cc.webim.web.model.UKeFuDic; -import com.chatopera.cc.webim.web.model.UploadStatus; -import com.chatopera.cc.webim.web.model.User; -import com.chatopera.cc.webim.web.model.UserHistory; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.File; +import java.io.IOException; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.util.Date; +import java.util.List; @Controller @RequestMapping("/im") @EnableAsync public class IMController extends Handler { - - @Value("${uk.im.server.host}") - private String host; - - @Value("${uk.im.server.port}") - private Integer port; + + @Value("${uk.im.server.host}") + private String host; + + @Value("${uk.im.server.port}") + private Integer port; @Value("${cs.im.server.ssl.port}") private Integer sslPort; @Value("${web.upload-path}") private String path; - - @Autowired - private ConsultInviteRepository inviteRepository; - - @Autowired - private ChatMessageRepository chatMessageRes ; - - @Autowired - private AgentServiceSatisRepository agentServiceSatisRes ; - - @Autowired - private InviteRecordRepository inviteRecordRes ; - - @Autowired - private LeaveMsgRepository leaveMsgRes ; - - @Autowired - private AttachmentRepository attachementRes; - - @Autowired - private ContactsRepository contactsRes ; - - @Autowired - private AgentUserContactsRepository agentUserContactsRes ; - - @Autowired - private SNSAccountRepository snsAccountRepository ; - + @Autowired + private ConsultInviteRepository inviteRepository; + + @Autowired + private ChatMessageRepository chatMessageRes; + + @Autowired + private AgentServiceSatisRepository agentServiceSatisRes; + + @Autowired + private InviteRecordRepository inviteRecordRes; + + @Autowired + private LeaveMsgRepository leaveMsgRes; + + + @Autowired + private AttachmentRepository attachementRes; + + @Autowired + private ContactsRepository contactsRes; + + @Autowired + private AgentUserContactsRepository agentUserContactsRes; + + @Autowired + private SNSAccountRepository snsAccountRepository; + @RequestMapping("/{id}") - @Menu(type = "im" , subtype = "point" , access = true) - public ModelAndView point(HttpServletRequest request , HttpServletResponse response, @PathVariable String id , @Valid String orgi , @Valid String userid , @Valid String title, @Valid String aiid) { - ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/point")) ; - String sessionid = request.getSession().getId() ; - if(!StringUtils.isBlank(id)){ - view.addObject("hostname", request.getServerName()) ; - - SystemConfig systemConfig = UKTools.getSystemConfig(); - if(systemConfig!=null && systemConfig.isEnablessl()) { - view.addObject("schema","https") ; - if(request.getServerPort() == 80) { - view.addObject("port", 443) ; - }else { - view.addObject("port", request.getServerPort()) ; - } - }else { - view.addObject("schema",request.getScheme()) ; - view.addObject("port", request.getServerPort()) ; - } - view.addObject("appid", id) ; - - - view.addObject("client", UKTools.getUUID()) ; - view.addObject("sessionid", sessionid) ; - - view.addObject("ip", UKTools.md5(request.getRemoteAddr())) ; - - view.addObject("mobile", CheckMobile.check(request.getHeader("User-Agent"))) ; - - - CousultInvite invite = OnlineUserUtils.cousult(id,orgi, inviteRepository); - if(invite!=null){ - orgi = invite.getOrgi() ; - view.addObject("inviteData", invite); - view.addObject("orgi",invite.getOrgi()); - view.addObject("appid",id); - - if(!StringUtils.isBlank(aiid)) { - view.addObject("aiid", aiid) ; - }else if(!StringUtils.isBlank(invite.getAiid())){ - view.addObject("aiid", invite.getAiid()) ; - } - //记录用户行为日志 - UserHistory userHistory = new UserHistory() ; - String url = request.getHeader("referer"); - if(!StringUtils.isBlank(url)){ - if(url.length() >255){ - userHistory.setUrl(url.substring( 0 , 255)); - }else{ - userHistory.setUrl(url); - } - userHistory.setReferer(userHistory.getUrl()); - } - userHistory.setParam(UKTools.getParameter(request)); - if(userHistory!=null){ - userHistory.setMaintype("im"); - userHistory.setSubtype("point"); - userHistory.setName("online"); - userHistory.setAdmin(false); - userHistory.setAccessnum(true); - } - User imUser = super.getIMUser(request , userid, null) ; - if(imUser!=null){ - userHistory.setCreater(imUser.getId()); - userHistory.setUsername(imUser.getUsername()); - userHistory.setOrgi(orgi); - } - if(!StringUtils.isBlank(title)){ - if(title.length() > 255){ - userHistory.setTitle(title.substring(0 , 255)); - }else{ - userHistory.setTitle(title); - } - } - userHistory.setOrgi(invite.getOrgi()); - userHistory.setAppid(id); - userHistory.setSessionid(sessionid); - - String ip = UKTools.getIpAddr(request); - userHistory.setHostname(ip); - userHistory.setIp(ip); - IP ipdata = IPTools.getInstance().findGeography(ip); - userHistory.setCountry(ipdata.getCountry()); - userHistory.setProvince(ipdata.getProvince()); - userHistory.setCity(ipdata.getCity()); - userHistory.setIsp(ipdata.getIsp()); - - BrowserClient client = UKTools.parseClient(request) ; - userHistory.setOstype(client.getOs()); - userHistory.setBrowser(client.getBrowser()); - userHistory.setMobile(CheckMobile.check(request.getHeader("User-Agent")) ? "1" : "0"); - - if(invite.isSkill()){ - /*** - * 查询 技能组 , 缓存? - */ - view.addObject("skillList", OnlineUserUtils.organ(orgi, ipdata , invite,true)) ; - /** - * 查询坐席 , 缓存? - */ - view.addObject("agentList", OnlineUserUtils.agents(orgi,true)) ; - } - view.addObject("traceid", userHistory.getId()) ; - if(invite.isRecordhis()){ - UKTools.published(userHistory); - } - - view.addObject("pointAd", UKTools.getPointAdv(UKDataContext.AdPosEnum.POINT.toString(),orgi)) ; - view.addObject("inviteAd", UKTools.getPointAdv(UKDataContext.AdPosEnum.INVITE.toString(),orgi)) ; - } - } - + @Menu(type = "im", subtype = "point", access = true) + public ModelAndView point(HttpServletRequest request, HttpServletResponse response, + @PathVariable String id, + @Valid String orgi, + @Valid String userid, + @Valid String title, + @Valid String aiid) { + ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/point")); + String sessionid = request.getSession().getId(); + if (!StringUtils.isBlank(id)) { + view.addObject("hostname", request.getServerName()); + + SystemConfig systemConfig = UKTools.getSystemConfig(); + if (systemConfig != null && systemConfig.isEnablessl()) { + view.addObject("schema", "https"); + if (request.getServerPort() == 80) { + view.addObject("port", 443); + } else { + view.addObject("port", request.getServerPort()); + } + } else { + view.addObject("schema", request.getScheme()); + view.addObject("port", request.getServerPort()); + } + view.addObject("appid", id); + + + view.addObject("client", UKTools.getUUID()); + view.addObject("sessionid", sessionid); + + view.addObject("ip", UKTools.md5(request.getRemoteAddr())); + + view.addObject("mobile", CheckMobile.check(request.getHeader("User-Agent"))); + + CousultInvite invite = OnlineUserUtils.cousult(id, orgi, inviteRepository); + if (invite != null) { + orgi = invite.getOrgi(); + view.addObject("inviteData", invite); + view.addObject("orgi", invite.getOrgi()); + view.addObject("appid", id); + + if (!StringUtils.isBlank(aiid)) { + view.addObject("aiid", aiid); + } else if (!StringUtils.isBlank(invite.getAiid())) { + view.addObject("aiid", invite.getAiid()); + } + //记录用户行为日志 + UserHistory userHistory = new UserHistory(); + String url = request.getHeader("referer"); + if (!StringUtils.isBlank(url)) { + if (url.length() > 255) { + userHistory.setUrl(url.substring(0, 255)); + } else { + userHistory.setUrl(url); + } + userHistory.setReferer(userHistory.getUrl()); + } + userHistory.setParam(UKTools.getParameter(request)); + if (userHistory != null) { + userHistory.setMaintype("im"); + userHistory.setSubtype("point"); + userHistory.setName("online"); + userHistory.setAdmin(false); + userHistory.setAccessnum(true); + } + User imUser = super.getIMUser(request, userid, null); + if (imUser != null) { + userHistory.setCreater(imUser.getId()); + userHistory.setUsername(imUser.getUsername()); + userHistory.setOrgi(orgi); + } + if (!StringUtils.isBlank(title)) { + if (title.length() > 255) { + userHistory.setTitle(title.substring(0, 255)); + } else { + userHistory.setTitle(title); + } + } + userHistory.setOrgi(invite.getOrgi()); + userHistory.setAppid(id); + userHistory.setSessionid(sessionid); + + String ip = UKTools.getIpAddr(request); + userHistory.setHostname(ip); + userHistory.setIp(ip); + IP ipdata = IPTools.getInstance().findGeography(ip); + userHistory.setCountry(ipdata.getCountry()); + userHistory.setProvince(ipdata.getProvince()); + userHistory.setCity(ipdata.getCity()); + userHistory.setIsp(ipdata.getIsp()); + + BrowserClient client = UKTools.parseClient(request); + userHistory.setOstype(client.getOs()); + userHistory.setBrowser(client.getBrowser()); + userHistory.setMobile(CheckMobile.check(request.getHeader("User-Agent")) ? "1" : "0"); + + if (invite.isSkill()) { + /*** + * 查询 技能组 , 缓存? + */ + view.addObject("skillList", OnlineUserUtils.organ(orgi, ipdata, invite, true)); + /** + * 查询坐席 , 缓存? + */ + view.addObject("agentList", OnlineUserUtils.agents(orgi, true)); + } + view.addObject("traceid", userHistory.getId()); + if (invite.isRecordhis()) { + UKTools.published(userHistory); + } + + view.addObject("pointAd", UKTools.getPointAdv(UKDataContext.AdPosEnum.POINT.toString(), orgi)); + view.addObject("inviteAd", UKTools.getPointAdv(UKDataContext.AdPosEnum.INVITE.toString(), orgi)); + } + } + return view; } - + @RequestMapping("/{id}/userlist") - @Menu(type = "im" , subtype = "inlist" , access = true) - public void inlist(HttpServletRequest request , HttpServletResponse response, @PathVariable String id , @Valid String userid) throws IOException { - response.setHeader("Content-Type", "text/html;charset=utf-8"); - if(!StringUtils.isBlank(userid)){ - BlackEntity black = (BlackEntity) CacheHelper.getSystemCacheBean().getCacheObject(userid, UKDataContext.SYSTEM_ORGI) ; - if((black != null && (black.getEndtime()==null || black.getEndtime().after(new Date()))) ){ - response.getWriter().write("in");; - } - } + @Menu(type = "im", subtype = "inlist", access = true) + public void inlist(HttpServletRequest request, HttpServletResponse response, @PathVariable String id, @Valid String userid) throws IOException { + response.setHeader("Content-Type", "text/html;charset=utf-8"); + if (!StringUtils.isBlank(userid)) { + BlackEntity black = (BlackEntity) CacheHelper.getSystemCacheBean().getCacheObject(userid, UKDataContext.SYSTEM_ORGI); + if ((black != null && (black.getEndtime() == null || black.getEndtime().after(new Date())))) { + response.getWriter().write("in"); + ; + } + } } + /** * 延时获取用户端浏览器的跟踪ID + * * @param request * @param response * @param orgi @@ -273,519 +248,545 @@ public class IMController extends Handler { * @return */ @RequestMapping("/online") - @Menu(type = "im" , subtype = "online" , access = true) - public SseEmitter callable(HttpServletRequest request , HttpServletResponse response , @Valid Contacts contacts, final @Valid String orgi , final @Valid String sessionid, @Valid String appid, final @Valid String userid , @Valid String sign , final @Valid String client, final @Valid String title, final @Valid String traceid) { - BlackEntity black = (BlackEntity) CacheHelper.getSystemCacheBean().getCacheObject(userid, orgi) ; - SseEmitter retSseEmitter = null ; - if((black == null || (black.getEndtime()!=null && black.getEndtime().before(new Date()))) ){ - final SseEmitter emitter = new SseEmitter(30000L); - if(CacheHelper.getSystemCacheBean().getCacheObject(userid, orgi) == null){ - if(!StringUtils.isBlank(userid)){ - emitter.onCompletion(new Runnable() { - @Override - public void run() { - try { - OnlineUserUtils.webIMClients.removeClient(userid , client , false) ; //执行了 邀请/再次邀请后终端的 - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - emitter.onTimeout(new Runnable() { - @Override - public void run() { - try { - if(emitter!=null){ - emitter.complete(); - } - OnlineUserUtils.webIMClients.removeClient(userid , client , true) ; //正常的超时断开 - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - CousultInvite invite = OnlineUserUtils.cousult(appid, orgi, inviteRepository); - if(invite!=null && invite.isTraceuser()){ - contacts = processContacts(orgi, contacts, appid, userid); - } - if(!StringUtils.isBlank(sign)){ - OnlineUserUtils.online(super.getIMUser(request , sign , contacts!=null ? contacts.getName() : null) , orgi , sessionid , UKDataContext.OnlineUserTypeStatus.WEBIM.toString(), request , UKDataContext.ChannelTypeEnum.WEBIM.toString() , appid , contacts , invite); - } - - OnlineUserUtils.webIMClients.putClient(userid, new WebIMClient(userid , client , emitter)) ; - } - } - retSseEmitter = emitter ; - } - return retSseEmitter; - } - - @RequestMapping("/index") - @Menu(type = "im" , subtype = "index" , access = true) - public ModelAndView index(ModelMap map ,HttpServletRequest request , HttpServletResponse response, @Valid String orgi, @Valid String aiid, @Valid String traceid ,@Valid String exchange, @Valid String title ,@Valid String url,@Valid String mobile ,@Valid String phone , @Valid String ai , @Valid String client , @Valid String type, @Valid String appid, @Valid String userid, @Valid String sessionid , @Valid String skill, @Valid String agent , @Valid Contacts contacts,@Valid String product,@Valid String description,@Valid String imgurl,@Valid String pid,@Valid String purl) throws Exception { - ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/index")) ; - BlackEntity black = (BlackEntity) CacheHelper.getSystemCacheBean().getCacheObject(userid, UKDataContext.SYSTEM_ORGI) ; - if(!StringUtils.isBlank(appid) && (black == null || (black.getEndtime()!=null && black.getEndtime().before(new Date()))) ){ - CousultInvite invite = OnlineUserUtils.cousult(appid, orgi, inviteRepository); - String userID = null; - if(!StringUtils.isBlank(userid)){ - userID = UKTools.genIDByKey(userid) ; - }else{ - userID = UKTools.genIDByKey(sessionid); - } - String nickname = "Guest_" + userID; - boolean consult = true ; //是否已收集用户信息 - SessionConfig sessionConfig = ServiceQuene.initSessionConfig(orgi) ; - - map.addAttribute("sessionConfig", sessionConfig); - - - map.addAttribute("hostname", request.getServerName()) ; + @Menu(type = "im", subtype = "online", access = true) + public SseEmitter callable(HttpServletRequest request, HttpServletResponse response, @Valid Contacts contacts, final @Valid String orgi, final @Valid String sessionid, @Valid String appid, final @Valid String userid, @Valid String sign, final @Valid String client, final @Valid String title, final @Valid String traceid) { + BlackEntity black = (BlackEntity) CacheHelper.getSystemCacheBean().getCacheObject(userid, orgi); + SseEmitter retSseEmitter = null; + if ((black == null || (black.getEndtime() != null && black.getEndtime().before(new Date())))) { + final SseEmitter emitter = new SseEmitter(30000L); + if (CacheHelper.getSystemCacheBean().getCacheObject(userid, orgi) == null) { + if (!StringUtils.isBlank(userid)) { + emitter.onCompletion(new Runnable() { + @Override + public void run() { + try { + OnlineUserUtils.webIMClients.removeClient(userid, client, false); //执行了 邀请/再次邀请后终端的 + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + emitter.onTimeout(new Runnable() { + @Override + public void run() { + try { + if (emitter != null) { + emitter.complete(); + } + OnlineUserUtils.webIMClients.removeClient(userid, client, true); //正常的超时断开 + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + CousultInvite invite = OnlineUserUtils.cousult(appid, orgi, inviteRepository); + if (invite != null && invite.isTraceuser()) { + contacts = processContacts(orgi, contacts, appid, userid); + } + if (!StringUtils.isBlank(sign)) { + OnlineUserUtils.online(super.getIMUser(request, sign, contacts != null ? contacts.getName() : null), orgi, sessionid, UKDataContext.OnlineUserTypeStatus.WEBIM.toString(), request, UKDataContext.ChannelTypeEnum.WEBIM.toString(), appid, contacts, invite); + } - if(sslPort != null){ - map.addAttribute("port", sslPort) ; + OnlineUserUtils.webIMClients.putClient(userid, new WebIMClient(userid, client, emitter)); + } + } + retSseEmitter = emitter; + } + return retSseEmitter; + } + + @RequestMapping("/index") + @Menu(type = "im", subtype = "index", access = true) + public ModelAndView index(ModelMap map, HttpServletRequest request, + HttpServletResponse response, + @Valid String orgi, + @Valid String aiid, + @Valid String traceid, + @Valid String exchange, + @Valid String title, + @Valid String url, + @Valid String mobile, + @Valid String phone, + @Valid String ai, + @Valid String client, + @Valid String type, + @Valid String appid, + @Valid String userid, + @Valid String sessionid, + @Valid String skill, + @Valid String agent, + @Valid Contacts contacts, + @Valid String product, + @Valid String description, + @Valid String imgurl, + @Valid String pid, + @Valid String purl) throws Exception { + ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/index")); + BlackEntity black = (BlackEntity) CacheHelper.getSystemCacheBean().getCacheObject(userid, UKDataContext.SYSTEM_ORGI); + if (!StringUtils.isBlank(appid) && (black == null || (black.getEndtime() != null && black.getEndtime().before(new Date())))) { + CousultInvite invite = OnlineUserUtils.cousult(appid, orgi, inviteRepository); + String userID = null; + if (!StringUtils.isBlank(userid)) { + userID = UKTools.genIDByKey(userid); } else { - map.addAttribute("port", port); + userID = UKTools.genIDByKey(sessionid); + } + String nickname = "Guest_" + userID; + boolean consult = true; //是否已收集用户信息 + SessionConfig sessionConfig = ServiceQuene.initSessionConfig(orgi); + + map.addAttribute("sessionConfig", sessionConfig); + + + map.addAttribute("hostname", request.getServerName()); + + if (sslPort != null) { + map.addAttribute("port", sslPort); + } else { + map.addAttribute("port", port); } - map.addAttribute("appid", appid) ; - map.addAttribute("userid", userid) ; - map.addAttribute("schema", request.getScheme()) ; - map.addAttribute("sessionid", sessionid) ; - - view.addObject("product", product) ; - view.addObject("description", description) ; - view.addObject("imgurl", imgurl) ; - view.addObject("pid", pid) ; - view.addObject("purl", purl) ; - - map.addAttribute("ip", UKTools.md5(request.getRemoteAddr())) ; - - if(!StringUtils.isBlank(traceid)){ - map.addAttribute("traceid", traceid) ; - } - if(!StringUtils.isBlank(exchange)){ - map.addAttribute("exchange", exchange) ; - } - if(!StringUtils.isBlank(title)){ - map.addAttribute("title", title) ; - } - if(!StringUtils.isBlank(traceid)){ - map.addAttribute("url", url) ; - } - - map.addAttribute("ukefport", request.getServerPort()) ; - /** - * 先检查 invite不为空 - */ - if(invite!=null) { - map.addAttribute("orgi",invite.getOrgi()); - map.addAttribute("inviteData", invite); - - if(!StringUtils.isBlank(aiid)) { - map.addAttribute("aiid", aiid) ; - }else if(!StringUtils.isBlank(invite.getAiid())){ - map.addAttribute("aiid", invite.getAiid()) ; - } - - AgentReport report = ServiceQuene.getAgentReport(invite.getOrgi()) ; - - if(report.getAgents() ==0 || (sessionConfig.isHourcheck() && !UKTools.isInWorkingHours(sessionConfig.getWorkinghours()) && invite.isLeavemessage())){ - view = request(super.createRequestPageTempletResponse("/apps/im/leavemsg")) ; - }else if(invite.isConsult_info()){ //启用了信息收集 , 从Request获取 , 或从 Cookies 里去 - //验证 OnlineUser 信息 - if(contacts!=null && !StringUtils.isBlank(contacts.getName())){ //contacts用于传递信息,并不和 联系人表发生 关联,contacts信息传递给 Socket.IO,然后赋值给 AgentUser,最终赋值给 AgentService永久存储 - consult = true ; - //存入 Cookies - if(invite.isConsult_info_cookies()){ - Cookie name = new Cookie("name",UKTools.encryption(URLEncoder.encode(contacts.getName(), "UTF-8"))); - response.addCookie(name); - name.setMaxAge(3600); - if(!StringUtils.isBlank(contacts.getPhone())){ - Cookie phonecookie = new Cookie("phone",UKTools.encryption(URLEncoder.encode(contacts.getPhone(), "UTF-8"))); - phonecookie.setMaxAge(3600); - response.addCookie(phonecookie); - } - if(!StringUtils.isBlank(contacts.getEmail())){ - Cookie email = new Cookie("email",UKTools.encryption(URLEncoder.encode(contacts.getEmail(), "UTF-8"))); - email.setMaxAge(3600); - response.addCookie(email); - } - if(!StringUtils.isBlank(contacts.getMemo())){ - Cookie memo = new Cookie("memo",UKTools.encryption(URLEncoder.encode(contacts.getName(), "UTF-8"))); - memo.setMaxAge(3600); - response.addCookie(memo); - } - } - }else{ - //从 Cookies里尝试读取 - if(invite.isConsult_info_cookies()){ - Cookie[] cookies = request.getCookies();//这样便可以获取一个cookie数组 - contacts = new Contacts(); - if(cookies!=null){ - for(Cookie cookie : cookies){ - if(cookie!=null && !StringUtils.isBlank(cookie.getName()) && !StringUtils.isBlank(cookie.getValue())){ - if(cookie.getName().equals("name")){ - contacts.setName(URLDecoder.decode(UKTools.decryption(cookie.getValue()) , "UTF-8")); - } - if(cookie.getName().equals("phone")){ - contacts.setPhone(URLDecoder.decode(UKTools.decryption(cookie.getValue()) , "UTF-8")); - } - if(cookie.getName().equals("email")){ - contacts.setEmail(URLDecoder.decode(UKTools.decryption(cookie.getValue()) , "UTF-8")); - } - if(cookie.getName().equals("memo")){ - contacts.setMemo(URLDecoder.decode(UKTools.decryption(cookie.getValue()) , "UTF-8")); - } - } - } - } - } - if(StringUtils.isBlank(contacts.getName())){ - consult = false ; - view = request(super.createRequestPageTempletResponse("/apps/im/collecting")) ; - } - } - }else{ - contacts = processContacts(invite.getOrgi(), contacts, appid, userid); - } - - if(!StringUtils.isBlank(client)){ - map.addAttribute("client", client) ; - } - if(!StringUtils.isBlank(skill)){ - map.addAttribute("skill", skill) ; - } - if(!StringUtils.isBlank(agent)){ - map.addAttribute("agent", agent) ; - } - - map.addAttribute("contacts", contacts) ; - - if(!StringUtils.isBlank(type)){ - map.addAttribute("type", type) ; - } - IP ipdata = IPTools.getInstance().findGeography(UKTools.getIpAddr(request)); - map.addAttribute("skillList", OnlineUserUtils.organ(invite.getOrgi() , ipdata , invite,true)) ; - - if(invite!=null && consult){ - if(contacts!=null && !StringUtils.isBlank(contacts.getName())){ - nickname = contacts.getName() ; - } - map.addAttribute("username", nickname) ; - if(UKDataContext.model.get("xiaoe")!=null && !StringUtils.isBlank(invite.getAiid()) && invite.isAi() && ((!StringUtils.isBlank(ai) && ai.equals("true")) || (invite.isAifirst() && ai == null))){ //启用 AI , 并且 AI优先 接待 - DataExchangeInterface dataInterface = (DataExchangeInterface) UKDataContext.getContext().getBean("aiconfig") ; - AiConfig aiConfig = (AiConfig) dataInterface.getDataByIdAndOrgi(aiid, invite.getOrgi()) ; - if(aiConfig!=null){ - map.addAttribute("aiConfig", aiConfig) ; - } - view = request(super.createRequestPageTempletResponse("/apps/im/ai/index")) ; - if(CheckMobile.check(request.getHeader("User-Agent")) || !StringUtils.isBlank(mobile)){ - view = request(super.createRequestPageTempletResponse("/apps/im/ai/mobile")) ; //智能机器人 移动端 - } - if(UKDataContext.model.get("xiaoe")!=null){ - List topicList = OnlineUserUtils.cacheHotTopic((DataExchangeInterface) UKDataContext.getContext().getBean("topic") , super.getUser(request) , orgi , aiid) ; - - /** - * 初步按照地区匹配分类筛选 - */ - List topicTypeList = OnlineUserUtils.topicType(orgi,ipdata,OnlineUserUtils.cacheHotTopicType((DataExchangeInterface) UKDataContext.getContext().getBean("topictype") , super.getUser(request) , orgi , aiid)) ; - - /** - * 第二步按照 有 热点主题的 分类做筛选 - */ - map.addAttribute("topicList", OnlineUserUtils.topic(orgi, topicTypeList, topicList)) ; - /** - * 第三步筛选 分类,如果无热点知识,则不显示分类 - */ - map.addAttribute("topicTypeList",OnlineUserUtils.filterTopicType(topicTypeList, topicList)) ; - } - }else{ - if(CheckMobile.check(request.getHeader("User-Agent")) || !StringUtils.isBlank(mobile)){ - view = request(super.createRequestPageTempletResponse("/apps/im/mobile")) ; //WebIM移动端。再次点选技能组? - } - } - map.addAttribute("chatMessageList", chatMessageRes.findByUsessionAndOrgi(userid , orgi, new PageRequest(0, 20, Direction.DESC , "updatetime"))) ; - } - view.addObject("commentList" , UKeFuDic.getInstance().getDic(UKDataContext.UKEFU_SYSTEM_COMMENT_DIC)) ; - view.addObject("commentItemList" , UKeFuDic.getInstance().getDic(UKDataContext.UKEFU_SYSTEM_COMMENT_ITEM_DIC)) ; - view.addObject("welcomeAd", UKTools.getPointAdv(UKDataContext.AdPosEnum.WELCOME.toString(),orgi)) ; - view.addObject("imageAd", UKTools.getPointAdv(UKDataContext.AdPosEnum.IMAGE.toString(),orgi)) ; - // OnlineUserUtils.sendWebIMClients(userid , "accept"); - - if(invite.isTraceuser()){ - Page inviteRecordList = inviteRecordRes.findByUseridAndOrgi(userid, orgi , new PageRequest(0, 1, Direction.DESC, "createtime")) ; - if(inviteRecordList.getContent()!=null && inviteRecordList.getContent().size()>0){ - InviteRecord record = inviteRecordList.getContent().get(0) ; - record.setUpdatetime(new Date()); - record.setTraceid(traceid); - record.setTitle(title); - record.setUrl(url); - record.setResponsetime((int) (System.currentTimeMillis() - record.getCreatetime().getTime())); - record.setResult(UKDataContext.OnlineUserInviteStatus.ACCEPT.toString()); - inviteRecordRes.save(record) ; - } - } - } - } + map.addAttribute("appid", appid); + map.addAttribute("userid", userid); + map.addAttribute("schema", request.getScheme()); + map.addAttribute("sessionid", sessionid); + + view.addObject("product", product); + view.addObject("description", description); + view.addObject("imgurl", imgurl); + view.addObject("pid", pid); + view.addObject("purl", purl); + + map.addAttribute("ip", UKTools.md5(request.getRemoteAddr())); + + if (!StringUtils.isBlank(traceid)) { + map.addAttribute("traceid", traceid); + } + if (!StringUtils.isBlank(exchange)) { + map.addAttribute("exchange", exchange); + } + if (!StringUtils.isBlank(title)) { + map.addAttribute("title", title); + } + if (!StringUtils.isBlank(traceid)) { + map.addAttribute("url", url); + } + + map.addAttribute("ukefport", request.getServerPort()); + /** + * 先检查 invite不为空 + */ + if (invite != null) { + map.addAttribute("orgi", invite.getOrgi()); + map.addAttribute("inviteData", invite); + + if (!StringUtils.isBlank(aiid)) { + map.addAttribute("aiid", aiid); + } else if (!StringUtils.isBlank(invite.getAiid())) { + map.addAttribute("aiid", invite.getAiid()); + } + + AgentReport report = ServiceQuene.getAgentReport(invite.getOrgi()); + + if (report.getAgents() == 0 || (sessionConfig.isHourcheck() && !UKTools.isInWorkingHours(sessionConfig.getWorkinghours()) && invite.isLeavemessage())) { + view = request(super.createRequestPageTempletResponse("/apps/im/leavemsg")); + } else if (invite.isConsult_info()) { //启用了信息收集 , 从Request获取 , 或从 Cookies 里去 + //验证 OnlineUser 信息 + if (contacts != null && !StringUtils.isBlank(contacts.getName())) { //contacts用于传递信息,并不和 联系人表发生 关联,contacts信息传递给 Socket.IO,然后赋值给 AgentUser,最终赋值给 AgentService永久存储 + consult = true; + //存入 Cookies + if (invite.isConsult_info_cookies()) { + Cookie name = new Cookie("name", UKTools.encryption(URLEncoder.encode(contacts.getName(), "UTF-8"))); + response.addCookie(name); + name.setMaxAge(3600); + if (!StringUtils.isBlank(contacts.getPhone())) { + Cookie phonecookie = new Cookie("phone", UKTools.encryption(URLEncoder.encode(contacts.getPhone(), "UTF-8"))); + phonecookie.setMaxAge(3600); + response.addCookie(phonecookie); + } + if (!StringUtils.isBlank(contacts.getEmail())) { + Cookie email = new Cookie("email", UKTools.encryption(URLEncoder.encode(contacts.getEmail(), "UTF-8"))); + email.setMaxAge(3600); + response.addCookie(email); + } + if (!StringUtils.isBlank(contacts.getMemo())) { + Cookie memo = new Cookie("memo", UKTools.encryption(URLEncoder.encode(contacts.getName(), "UTF-8"))); + memo.setMaxAge(3600); + response.addCookie(memo); + } + } + } else { + //从 Cookies里尝试读取 + if (invite.isConsult_info_cookies()) { + Cookie[] cookies = request.getCookies();//这样便可以获取一个cookie数组 + contacts = new Contacts(); + if (cookies != null) { + for (Cookie cookie : cookies) { + if (cookie != null && !StringUtils.isBlank(cookie.getName()) && !StringUtils.isBlank(cookie.getValue())) { + if (cookie.getName().equals("name")) { + contacts.setName(URLDecoder.decode(UKTools.decryption(cookie.getValue()), "UTF-8")); + } + if (cookie.getName().equals("phone")) { + contacts.setPhone(URLDecoder.decode(UKTools.decryption(cookie.getValue()), "UTF-8")); + } + if (cookie.getName().equals("email")) { + contacts.setEmail(URLDecoder.decode(UKTools.decryption(cookie.getValue()), "UTF-8")); + } + if (cookie.getName().equals("memo")) { + contacts.setMemo(URLDecoder.decode(UKTools.decryption(cookie.getValue()), "UTF-8")); + } + } + } + } + } + if (StringUtils.isBlank(contacts.getName())) { + consult = false; + view = request(super.createRequestPageTempletResponse("/apps/im/collecting")); + } + } + } else { + contacts = processContacts(invite.getOrgi(), contacts, appid, userid); + } + + if (!StringUtils.isBlank(client)) { + map.addAttribute("client", client); + } + if (!StringUtils.isBlank(skill)) { + map.addAttribute("skill", skill); + } + if (!StringUtils.isBlank(agent)) { + map.addAttribute("agent", agent); + } + + map.addAttribute("contacts", contacts); + + if (!StringUtils.isBlank(type)) { + map.addAttribute("type", type); + } + IP ipdata = IPTools.getInstance().findGeography(UKTools.getIpAddr(request)); + map.addAttribute("skillList", OnlineUserUtils.organ(invite.getOrgi(), ipdata, invite, true)); + + if (invite != null && consult) { + if (contacts != null && !StringUtils.isBlank(contacts.getName())) { + nickname = contacts.getName(); + } + map.addAttribute("username", nickname); + if (UKDataContext.model.get("chatbot") != null && + StringUtils.isNotBlank(invite.getAiid()) && + invite.isAi() && + (StringUtils.equals(ai, "true") || (invite.isAifirst() && ai == null))) { //启用 AI , 并且 AI优先 接待 + DataExchangeInterface dataInterface = (DataExchangeInterface) UKDataContext.getContext().getBean("aiconfig"); + AiConfig aiConfig = (AiConfig) dataInterface.getDataByIdAndOrgi(aiid, invite.getOrgi()); + if (aiConfig != null) { + map.addAttribute("aiConfig", aiConfig); + } + view = request(super.createRequestPageTempletResponse("/apps/im/ai/index")); + if (CheckMobile.check(request.getHeader("User-Agent")) || !StringUtils.isBlank(mobile)) { + view = request(super.createRequestPageTempletResponse("/apps/im/ai/mobile")); //智能机器人 移动端 + } + if (UKDataContext.model.get("xiaoe") != null) { + List topicList = OnlineUserUtils.cacheHotTopic((DataExchangeInterface) UKDataContext.getContext().getBean("topic"), super.getUser(request), orgi, aiid); + + /** + * 初步按照地区匹配分类筛选 + */ + List topicTypeList = OnlineUserUtils.topicType(orgi, ipdata, OnlineUserUtils.cacheHotTopicType((DataExchangeInterface) UKDataContext.getContext().getBean("topictype"), super.getUser(request), orgi, aiid)); + + /** + * 第二步按照 有 热点主题的 分类做筛选 + */ + map.addAttribute("topicList", OnlineUserUtils.topic(orgi, topicTypeList, topicList)); + /** + * 第三步筛选 分类,如果无热点知识,则不显示分类 + */ + map.addAttribute("topicTypeList", OnlineUserUtils.filterTopicType(topicTypeList, topicList)); + } + } else { + if (CheckMobile.check(request.getHeader("User-Agent")) || !StringUtils.isBlank(mobile)) { + view = request(super.createRequestPageTempletResponse("/apps/im/mobile")); //WebIM移动端。再次点选技能组? + } + } + map.addAttribute("chatMessageList", chatMessageRes.findByUsessionAndOrgi(userid, orgi, new PageRequest(0, 20, Direction.DESC, "updatetime"))); + } + view.addObject("commentList", UKeFuDic.getInstance().getDic(UKDataContext.UKEFU_SYSTEM_COMMENT_DIC)); + view.addObject("commentItemList", UKeFuDic.getInstance().getDic(UKDataContext.UKEFU_SYSTEM_COMMENT_ITEM_DIC)); + view.addObject("welcomeAd", UKTools.getPointAdv(UKDataContext.AdPosEnum.WELCOME.toString(), orgi)); + view.addObject("imageAd", UKTools.getPointAdv(UKDataContext.AdPosEnum.IMAGE.toString(), orgi)); + // OnlineUserUtils.sendWebIMClients(userid , "accept"); + + if (invite.isTraceuser()) { + Page inviteRecordList = inviteRecordRes.findByUseridAndOrgi(userid, orgi, new PageRequest(0, 1, Direction.DESC, "createtime")); + if (inviteRecordList.getContent() != null && inviteRecordList.getContent().size() > 0) { + InviteRecord record = inviteRecordList.getContent().get(0); + record.setUpdatetime(new Date()); + record.setTraceid(traceid); + record.setTitle(title); + record.setUrl(url); + record.setResponsetime((int) (System.currentTimeMillis() - record.getCreatetime().getTime())); + record.setResult(UKDataContext.OnlineUserInviteStatus.ACCEPT.toString()); + inviteRecordRes.save(record); + } + } + } + } return view; } - - private Contacts processContacts(String orgi ,Contacts contacts , String appid , String userid){ - if(contacts!=null){ - if(contacts != null && (!StringUtils.isBlank(contacts.getName()) || !StringUtils.isBlank(contacts.getPhone()) || !StringUtils.isBlank(contacts.getEmail()))){ - StringBuffer query = new StringBuffer(); - query.append(contacts.getName()) ; - if(!StringUtils.isBlank(contacts.getPhone())){ - query.append(" OR ").append(contacts.getPhone()) ; - } - if(!StringUtils.isBlank(contacts.getEmail())){ - query.append(" OR ").append(contacts.getEmail()) ; - } - Page contactsList = contactsRes.findByOrgi(orgi, false, query.toString(), new PageRequest(0, 1)) ; - if(contactsList.getContent().size() > 0){ - contacts = contactsList.getContent().get(0) ; - }else{ + + private Contacts processContacts(String orgi, Contacts contacts, String appid, String userid) { + if (contacts != null) { + if (contacts != null && (!StringUtils.isBlank(contacts.getName()) || !StringUtils.isBlank(contacts.getPhone()) || !StringUtils.isBlank(contacts.getEmail()))) { + StringBuffer query = new StringBuffer(); + query.append(contacts.getName()); + if (!StringUtils.isBlank(contacts.getPhone())) { + query.append(" OR ").append(contacts.getPhone()); + } + if (!StringUtils.isBlank(contacts.getEmail())) { + query.append(" OR ").append(contacts.getEmail()); + } + Page contactsList = contactsRes.findByOrgi(orgi, false, query.toString(), new PageRequest(0, 1)); + if (contactsList.getContent().size() > 0) { + contacts = contactsList.getContent().get(0); + } else { // contactsRes.save(contacts) ; //需要增加签名验证,避免随便产生垃圾信息,也可以自行修改? - contacts.setId(null); - } - }else{ - contacts.setId(null); - } - if(contacts!=null && !StringUtils.isBlank(contacts.getId())){ - List agentUserContactsList = agentUserContactsRes.findByUseridAndOrgi(userid, orgi) ; - if(agentUserContactsList.size() == 0){ - AgentUserContacts agentUserContacts = new AgentUserContacts() ; - agentUserContacts.setAppid(appid); - agentUserContacts.setChannel(UKDataContext.ChannelTypeEnum.WEBIM.toString()); - agentUserContacts.setContactsid(contacts.getId()); - agentUserContacts.setUserid(userid); - agentUserContacts.setOrgi(orgi); - agentUserContacts.setCreatetime(new Date()); - agentUserContactsRes.save(agentUserContacts) ; - } - }else if(!StringUtils.isBlank(userid)){ - List agentUserContactsList = agentUserContactsRes.findByUseridAndOrgi(userid, orgi) ; - if(agentUserContactsList.size() > 0){ - AgentUserContacts agentUserContacts = agentUserContactsList.get(0) ; - contacts = contactsRes.findOne(agentUserContacts.getContactsid()) ; - } - } - } - return contacts ; + contacts.setId(null); + } + } else { + contacts.setId(null); + } + if (contacts != null && !StringUtils.isBlank(contacts.getId())) { + List agentUserContactsList = agentUserContactsRes.findByUseridAndOrgi(userid, orgi); + if (agentUserContactsList.size() == 0) { + AgentUserContacts agentUserContacts = new AgentUserContacts(); + agentUserContacts.setAppid(appid); + agentUserContacts.setChannel(UKDataContext.ChannelTypeEnum.WEBIM.toString()); + agentUserContacts.setContactsid(contacts.getId()); + agentUserContacts.setUserid(userid); + agentUserContacts.setOrgi(orgi); + agentUserContacts.setCreatetime(new Date()); + agentUserContactsRes.save(agentUserContacts); + } + } else if (!StringUtils.isBlank(userid)) { + List agentUserContactsList = agentUserContactsRes.findByUseridAndOrgi(userid, orgi); + if (agentUserContactsList.size() > 0) { + AgentUserContacts agentUserContacts = agentUserContactsList.get(0); + contacts = contactsRes.findOne(agentUserContacts.getContactsid()); + } + } + } + return contacts; } - + @RequestMapping("/text/{appid}") - @Menu(type = "im" , subtype = "index" , access = true) - public ModelAndView text(HttpServletRequest request , HttpServletResponse response, @PathVariable String appid ,@Valid String traceid,@Valid String aiid ,@Valid String exchange, @Valid String title ,@Valid String url, @Valid String skill, @Valid String id , @Valid String userid , @Valid String agent , @Valid String name , @Valid String email ,@Valid String phone,@Valid String ai,@Valid String orgi ,@Valid String product,@Valid String description,@Valid String imgurl,@Valid String pid,@Valid String purl) throws Exception { - ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/text")) ; - - view.addObject("hostname", request.getServerName()) ; - view.addObject("port", request.getServerPort()) ; - view.addObject("schema", request.getScheme()) ; - view.addObject("appid", appid) ; - - - view.addObject("ip", UKTools.md5(request.getRemoteAddr())) ; - - if(!StringUtils.isBlank(skill)){ - view.addObject("skill", skill) ; - } - if(!StringUtils.isBlank(agent)){ - view.addObject("agent", agent) ; - } - - view.addObject("client", UKTools.getUUID()) ; - view.addObject("sessionid", request.getSession().getId()) ; - - view.addObject("id", id) ; - if(!StringUtils.isBlank(ai)){ - view.addObject("ai", ai) ; - } - if(!StringUtils.isBlank(exchange)){ - view.addObject("exchange", exchange) ; - } - - view.addObject("name", name) ; - view.addObject("email", email) ; - view.addObject("phone", phone) ; - view.addObject("userid", userid) ; - - view.addObject("product", product) ; - view.addObject("description", description) ; - view.addObject("imgurl", imgurl) ; - view.addObject("pid", pid) ; - view.addObject("purl", purl) ; - - - - if(!StringUtils.isBlank(traceid)){ - view.addObject("traceid", traceid) ; - } - if(!StringUtils.isBlank(title)){ - view.addObject("title", title) ; - } - if(!StringUtils.isBlank(traceid)){ - view.addObject("url", url) ; - } - CousultInvite invite = OnlineUserUtils.cousult(appid, orgi, inviteRepository); - if(invite!=null){ - view.addObject("inviteData", invite); - view.addObject("orgi",invite.getOrgi()); - view.addObject("appid",appid); - - if(!StringUtils.isBlank(aiid)) { - view.addObject("aiid", aiid) ; - }else if(!StringUtils.isBlank(invite.getAiid())){ - view.addObject("aiid", invite.getAiid()) ; - } - } - - return view; + @Menu(type = "im", subtype = "index", access = true) + public ModelAndView text(HttpServletRequest request, HttpServletResponse response, @PathVariable String appid, @Valid String traceid, @Valid String aiid, @Valid String exchange, @Valid String title, @Valid String url, @Valid String skill, @Valid String id, @Valid String userid, @Valid String agent, @Valid String name, @Valid String email, @Valid String phone, @Valid String ai, @Valid String orgi, @Valid String product, @Valid String description, @Valid String imgurl, @Valid String pid, @Valid String purl) throws Exception { + ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/text")); + + view.addObject("hostname", request.getServerName()); + view.addObject("port", request.getServerPort()); + view.addObject("schema", request.getScheme()); + view.addObject("appid", appid); + + + view.addObject("ip", UKTools.md5(request.getRemoteAddr())); + + if (!StringUtils.isBlank(skill)) { + view.addObject("skill", skill); + } + if (!StringUtils.isBlank(agent)) { + view.addObject("agent", agent); + } + + view.addObject("client", UKTools.getUUID()); + view.addObject("sessionid", request.getSession().getId()); + + view.addObject("id", id); + if (!StringUtils.isBlank(ai)) { + view.addObject("ai", ai); + } + if (!StringUtils.isBlank(exchange)) { + view.addObject("exchange", exchange); + } + + view.addObject("name", name); + view.addObject("email", email); + view.addObject("phone", phone); + view.addObject("userid", userid); + + view.addObject("product", product); + view.addObject("description", description); + view.addObject("imgurl", imgurl); + view.addObject("pid", pid); + view.addObject("purl", purl); + + + if (!StringUtils.isBlank(traceid)) { + view.addObject("traceid", traceid); + } + if (!StringUtils.isBlank(title)) { + view.addObject("title", title); + } + if (!StringUtils.isBlank(traceid)) { + view.addObject("url", url); + } + CousultInvite invite = OnlineUserUtils.cousult(appid, orgi, inviteRepository); + if (invite != null) { + view.addObject("inviteData", invite); + view.addObject("orgi", invite.getOrgi()); + view.addObject("appid", appid); + + if (!StringUtils.isBlank(aiid)) { + view.addObject("aiid", aiid); + } else if (!StringUtils.isBlank(invite.getAiid())) { + view.addObject("aiid", invite.getAiid()); + } + } + + return view; } - - + + @RequestMapping("/leavemsg/save") - @Menu(type = "admin" , subtype = "user") - public ModelAndView leavemsgsave(HttpServletRequest request ,@Valid String appid ,@Valid LeaveMsg msg) { - if(!StringUtils.isBlank(appid)){ - SNSAccount snsAccount = snsAccountRepository.findBySnsid(appid); - String orgi = snsAccount.getOrgi(); - CousultInvite invite = inviteRepository.findBySnsaccountidAndOrgi(appid, orgi) ; ; - List msgList = leaveMsgRes.findByOrgiAndUserid(invite.getOrgi(), msg.getUserid()) ; - // if(msg!=null && msgList.size() == 0){ - if(msg!=null){ - msg.setOrgi(invite.getOrgi()); - leaveMsgRes.save(msg); - } - } - return request(super.createRequestPageTempletResponse("/apps/im/leavemsgsave")); + @Menu(type = "admin", subtype = "user") + public ModelAndView leavemsgsave(HttpServletRequest request, @Valid String appid, @Valid LeaveMsg msg) { + if (!StringUtils.isBlank(appid)) { + SNSAccount snsAccount = snsAccountRepository.findBySnsid(appid); + String orgi = snsAccount.getOrgi(); + CousultInvite invite = inviteRepository.findBySnsaccountidAndOrgi(appid, orgi); + ; + List msgList = leaveMsgRes.findByOrgiAndUserid(invite.getOrgi(), msg.getUserid()); + // if(msg!=null && msgList.size() == 0){ + if (msg != null) { + msg.setOrgi(invite.getOrgi()); + leaveMsgRes.save(msg); + } + } + return request(super.createRequestPageTempletResponse("/apps/im/leavemsgsave")); } - + @RequestMapping("/refuse") - @Menu(type = "im" , subtype = "refuse" , access = true) - public void refuse(HttpServletRequest request , HttpServletResponse response, @Valid String orgi , @Valid String appid, @Valid String userid, @Valid String sessionid, @Valid String client) throws Exception { - OnlineUserUtils.refuseInvite(userid, orgi); + @Menu(type = "im", subtype = "refuse", access = true) + public void refuse(HttpServletRequest request, HttpServletResponse response, @Valid String orgi, @Valid String appid, @Valid String userid, @Valid String sessionid, @Valid String client) throws Exception { + OnlineUserUtils.refuseInvite(userid, orgi); // OnlineUserUtils.sendWebIMClients(userid , "refuse"); - Page inviteRecordList = inviteRecordRes.findByUseridAndOrgi(userid, orgi , new PageRequest(0, 1, Direction.DESC, "createtime")) ; - if(inviteRecordList.getContent()!=null && inviteRecordList.getContent().size()>0){ - InviteRecord record = inviteRecordList.getContent().get(0) ; - record.setUpdatetime(new Date()); - record.setResponsetime((int) (System.currentTimeMillis() - record.getCreatetime().getTime())); - record.setResult(UKDataContext.OnlineUserInviteStatus.REFUSE.toString()); - inviteRecordRes.save(record) ; - } + Page inviteRecordList = inviteRecordRes.findByUseridAndOrgi(userid, orgi, new PageRequest(0, 1, Direction.DESC, "createtime")); + if (inviteRecordList.getContent() != null && inviteRecordList.getContent().size() > 0) { + InviteRecord record = inviteRecordList.getContent().get(0); + record.setUpdatetime(new Date()); + record.setResponsetime((int) (System.currentTimeMillis() - record.getCreatetime().getTime())); + record.setResult(UKDataContext.OnlineUserInviteStatus.REFUSE.toString()); + inviteRecordRes.save(record); + } return; } - + @RequestMapping("/satis") - @Menu(type = "im" , subtype = "satis" , access = true) - public void satis(HttpServletRequest request , HttpServletResponse response, @Valid AgentServiceSatis satis) throws Exception { - if(satis!=null && !StringUtils.isBlank(satis.getId())){ - int count = agentServiceSatisRes.countById(satis.getId()) ; - if(count == 1){ - if(!StringUtils.isBlank(satis.getSatiscomment()) && satis.getSatiscomment().length() > 255){ - satis.setSatiscomment(satis.getSatiscomment().substring(0 , 255)); - } - satis.setSatisfaction(true); - satis.setSatistime(new Date()); - agentServiceSatisRes.save(satis) ; - } - } + @Menu(type = "im", subtype = "satis", access = true) + public void satis(HttpServletRequest request, HttpServletResponse response, @Valid AgentServiceSatis satis) throws Exception { + if (satis != null && !StringUtils.isBlank(satis.getId())) { + int count = agentServiceSatisRes.countById(satis.getId()); + if (count == 1) { + if (!StringUtils.isBlank(satis.getSatiscomment()) && satis.getSatiscomment().length() > 255) { + satis.setSatiscomment(satis.getSatiscomment().substring(0, 255)); + } + satis.setSatisfaction(true); + satis.setSatistime(new Date()); + agentServiceSatisRes.save(satis); + } + } return; } - + @RequestMapping("/image/upload") - @Menu(type = "im" , subtype = "image" , access = true) - public ModelAndView upload(ModelMap map,HttpServletRequest request , @RequestParam(value = "imgFile", required = false) MultipartFile imgFile , @Valid String channel, @Valid String userid, @Valid String username , @Valid String appid , @Valid String orgi, @Valid String paste) throws IOException { - ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/upload")) ; - UploadStatus upload = null ; - String fileName = null ; - if(imgFile!=null && imgFile.getOriginalFilename().lastIndexOf(".") > 0 && !StringUtils.isBlank(userid)){ - File uploadDir = new File(path , "upload"); - if(!uploadDir.exists()){ - uploadDir.mkdirs() ; - } - String fileid = UKTools.md5(imgFile.getBytes()) ; - if(imgFile.getContentType()!=null && imgFile.getContentType().indexOf("image") >= 0){ - fileName = "upload/"+fileid+"_original" ; - File imageFile = new File(path , fileName) ; - FileCopyUtils.copy(imgFile.getBytes(), imageFile); - String thumbnailsFileName = "upload/"+fileid ; - UKTools.processImage(new File(path , thumbnailsFileName), imageFile) ; - - - upload = new UploadStatus("0" , "/res/image.html?id="+thumbnailsFileName); - - String image = "/res/image.html?id="+thumbnailsFileName ; - if(request.getServerPort() == 80){ - image = "/res/image.html?id="+thumbnailsFileName; - }else{ - image = "/res/image.html?id="+thumbnailsFileName; - } - if(paste == null){ - if(!StringUtils.isBlank(channel)){ - MessageUtils.uploadImage(image , fileid ,(int)imgFile.getSize() , imgFile.getName() , channel, userid , username , appid , orgi); - }else{ - MessageUtils.uploadImage(image , fileid ,(int)imgFile.getSize() , imgFile.getName() , userid); - } - } - }else{ - - String id = processAttachmentFile(imgFile, request); - - upload = new UploadStatus("0" , "/res/file.html?id="+id); - String file = "/res/file.html?id="+id ; - if(request.getServerPort() == 80){ - file = "/res/file.html?id="+id; - }else{ - file = "/res/file.html?id="+id; - } - File tempFile = new File(imgFile.getOriginalFilename()); - if(!StringUtils.isBlank(channel)){ - MessageUtils.uploadFile(file ,(int)imgFile.getSize() , tempFile.getName() , channel, userid , username , appid , orgi , id); - }else{ - MessageUtils.uploadFile(file ,(int)imgFile.getSize() , tempFile.getName() , userid , id); - } - } - }else{ - upload = new UploadStatus("请选择文件"); - } - map.addAttribute("upload", upload) ; - return view ; + @Menu(type = "im", subtype = "image", access = true) + public ModelAndView upload(ModelMap map, HttpServletRequest request, @RequestParam(value = "imgFile", required = false) MultipartFile imgFile, @Valid String channel, @Valid String userid, @Valid String username, @Valid String appid, @Valid String orgi, @Valid String paste) throws IOException { + ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/upload")); + UploadStatus upload = null; + String fileName = null; + if (imgFile != null && imgFile.getOriginalFilename().lastIndexOf(".") > 0 && !StringUtils.isBlank(userid)) { + File uploadDir = new File(path, "upload"); + if (!uploadDir.exists()) { + uploadDir.mkdirs(); + } + String fileid = UKTools.md5(imgFile.getBytes()); + if (imgFile.getContentType() != null && imgFile.getContentType().indexOf("image") >= 0) { + fileName = "upload/" + fileid + "_original"; + File imageFile = new File(path, fileName); + FileCopyUtils.copy(imgFile.getBytes(), imageFile); + String thumbnailsFileName = "upload/" + fileid; + UKTools.processImage(new File(path, thumbnailsFileName), imageFile); + + + upload = new UploadStatus("0", "/res/image.html?id=" + thumbnailsFileName); + + String image = "/res/image.html?id=" + thumbnailsFileName; + if (request.getServerPort() == 80) { + image = "/res/image.html?id=" + thumbnailsFileName; + } else { + image = "/res/image.html?id=" + thumbnailsFileName; + } + if (paste == null) { + if (!StringUtils.isBlank(channel)) { + MessageUtils.uploadImage(image, fileid, (int) imgFile.getSize(), imgFile.getName(), channel, userid, username, appid, orgi); + } else { + MessageUtils.uploadImage(image, fileid, (int) imgFile.getSize(), imgFile.getName(), userid); + } + } + } else { + + String id = processAttachmentFile(imgFile, request); + + upload = new UploadStatus("0", "/res/file.html?id=" + id); + String file = "/res/file.html?id=" + id; + if (request.getServerPort() == 80) { + file = "/res/file.html?id=" + id; + } else { + file = "/res/file.html?id=" + id; + } + File tempFile = new File(imgFile.getOriginalFilename()); + if (!StringUtils.isBlank(channel)) { + MessageUtils.uploadFile(file, (int) imgFile.getSize(), tempFile.getName(), channel, userid, username, appid, orgi, id); + } else { + MessageUtils.uploadFile(file, (int) imgFile.getSize(), tempFile.getName(), userid, id); + } + } + } else { + upload = new UploadStatus("请选择文件"); + } + map.addAttribute("upload", upload); + return view; } - - private String processAttachmentFile(MultipartFile file , HttpServletRequest request) throws IOException{ - String id = null ; - if(file.getSize() > 0){ //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制 - String fileid = UKTools.md5(file.getBytes()) ; //使用 文件的 MD5作为 ID,避免重复上传大文件 - if(!StringUtils.isBlank(fileid)){ - AttachmentFile attachmentFile = new AttachmentFile() ; - attachmentFile.setCreater(super.getUser(request).getId()); - attachmentFile.setOrgi(super.getOrgi(request)); - attachmentFile.setOrgan(super.getUser(request).getOrgan()); - attachmentFile.setModel(UKDataContext.ModelType.WEBIM.toString()); - attachmentFile.setFilelength((int) file.getSize()); - if(file.getContentType()!=null && file.getContentType().length() > 255){ - attachmentFile.setFiletype(file.getContentType().substring(0 , 255)); - }else{ - attachmentFile.setFiletype(file.getContentType()); - } - File uploadFile = new File(file.getOriginalFilename()); - if(uploadFile.getName()!=null && uploadFile.getName().length() > 255){ - attachmentFile.setTitle(uploadFile.getName().substring(0 , 255)); - }else{ - attachmentFile.setTitle(uploadFile.getName()); - } - if(!StringUtils.isBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0){ - attachmentFile.setImage(true); - } - attachmentFile.setFileid(fileid); - attachementRes.save(attachmentFile) ; - FileUtils.writeByteArrayToFile(new File(path , "app/webim/"+fileid), file.getBytes()); - id = attachmentFile.getId(); - } - } - return id ; + + private String processAttachmentFile(MultipartFile file, HttpServletRequest request) throws IOException { + String id = null; + if (file.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制 + String fileid = UKTools.md5(file.getBytes()); //使用 文件的 MD5作为 ID,避免重复上传大文件 + if (!StringUtils.isBlank(fileid)) { + AttachmentFile attachmentFile = new AttachmentFile(); + attachmentFile.setCreater(super.getUser(request).getId()); + attachmentFile.setOrgi(super.getOrgi(request)); + attachmentFile.setOrgan(super.getUser(request).getOrgan()); + attachmentFile.setModel(UKDataContext.ModelType.WEBIM.toString()); + attachmentFile.setFilelength((int) file.getSize()); + if (file.getContentType() != null && file.getContentType().length() > 255) { + attachmentFile.setFiletype(file.getContentType().substring(0, 255)); + } else { + attachmentFile.setFiletype(file.getContentType()); + } + File uploadFile = new File(file.getOriginalFilename()); + if (uploadFile.getName() != null && uploadFile.getName().length() > 255) { + attachmentFile.setTitle(uploadFile.getName().substring(0, 255)); + } else { + attachmentFile.setTitle(uploadFile.getName()); + } + if (!StringUtils.isBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) { + attachmentFile.setImage(true); + } + attachmentFile.setFileid(fileid); + attachementRes.save(attachmentFile); + FileUtils.writeByteArrayToFile(new File(path, "app/webim/" + fileid), file.getBytes()); + id = attachmentFile.getId(); + } + } + return id; } } \ No newline at end of file diff --git a/contact-center/app/src/main/resources/templates/apps/im/point.html b/contact-center/app/src/main/resources/templates/apps/im/point.html index 0fbab9af..0af88ee1 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/point.html +++ b/contact-center/app/src/main/resources/templates/apps/im/point.html @@ -1,11 +1,4 @@ var data = {}; -/****** - id:"xxxxxxxxxxxx", - name:'UKeFu', - email:'ukefu@ukewo.cn', - phone:'18588888888' -****/ - <#if inviteData??> !function(e,t,r){"use strict";"function"==typeof window.define&&window.define.amd?window.define(r):"undefined"!=typeof module&&module.exports?module.exports=r():t.exports?t.exports=r():t.Fingerprint2=r()}(0,this,function(){"use strict";var e=function(t){if(!(this instanceof e))return new e(t);this.options=this.extend(t,{swfContainerId:"fingerprintjs2",swfPath:"flash/compiled/FontList.swf",detectScreenOrientation:!0,sortPluginsFor:[/palemoon/i],userDefinedFonts:[],excludeDoNotTrack:!0,excludePixelRatio:!0}),this.nativeForEach=Array.prototype.forEach,this.nativeMap=Array.prototype.map};return e.prototype={extend:function(e,t){if(null==e)return t;for(var r in e)null!=e[r]&&t[r]!==e[r]&&(t[r]=e[r]);return t},get:function(e){var t=this,r={data:[],addPreprocessedComponent:function(e){var n=e.value;"function"==typeof t.options.preprocessor&&(n=t.options.preprocessor(e.key,n)),r.data.push({key:e.key,value:n})}};r=this.userAgentKey(r),r=this.languageKey(r),r=this.colorDepthKey(r),r=this.deviceMemoryKey(r),r=this.pixelRatioKey(r),r=this.hardwareConcurrencyKey(r),r=this.screenResolutionKey(r),r=this.availableScreenResolutionKey(r),r=this.timezoneOffsetKey(r),r=this.sessionStorageKey(r),r=this.localStorageKey(r),r=this.indexedDbKey(r),r=this.addBehaviorKey(r),r=this.openDatabaseKey(r),r=this.cpuClassKey(r),r=this.platformKey(r),r=this.doNotTrackKey(r),r=this.pluginsKey(r),r=this.canvasKey(r),r=this.webglKey(r),r=this.webglVendorAndRendererKey(r),r=this.adBlockKey(r),r=this.hasLiedLanguagesKey(r),r=this.hasLiedResolutionKey(r),r=this.hasLiedOsKey(r),r=this.hasLiedBrowserKey(r),r=this.touchSupportKey(r),r=this.customEntropyFunction(r),this.fontsKey(r,function(r){var n=[];t.each(r.data,function(e){var t=e.value;t&&"function"==typeof t.join&&(t=t.join(";")),n.push(t)});var i=t.x64hash128(n.join("~~~"),31);return e(i,r.data)})},customEntropyFunction:function(e){return"function"==typeof this.options.customFunction&&e.addPreprocessedComponent({key:"custom",value:this.options.customFunction()}),e},userAgentKey:function(e){return this.options.excludeUserAgent||e.addPreprocessedComponent({key:"user_agent",value:this.getUserAgent()}),e},getUserAgent:function(){return navigator.userAgent},languageKey:function(e){return this.options.excludeLanguage||e.addPreprocessedComponent({key:"language",value:navigator.language||navigator.userLanguage||navigator.browserLanguage||navigator.systemLanguage||""}),e},colorDepthKey:function(e){return this.options.excludeColorDepth||e.addPreprocessedComponent({key:"color_depth",value:window.screen.colorDepth||-1}),e},deviceMemoryKey:function(e){return this.options.excludeDeviceMemory||e.addPreprocessedComponent({key:"device_memory",value:this.getDeviceMemory()}),e},getDeviceMemory:function(){return navigator.deviceMemory||-1},pixelRatioKey:function(e){return this.options.excludePixelRatio||e.addPreprocessedComponent({key:"pixel_ratio",value:this.getPixelRatio()}),e},getPixelRatio:function(){return window.devicePixelRatio||""},screenResolutionKey:function(e){return this.options.excludeScreenResolution?e:this.getScreenResolution(e)},getScreenResolution:function(e){var t;return t=this.options.detectScreenOrientation&&window.screen.height>window.screen.width?[window.screen.height,window.screen.width]:[window.screen.width,window.screen.height],e.addPreprocessedComponent({key:"resolution",value:t}),e},availableScreenResolutionKey:function(e){return this.options.excludeAvailableScreenResolution?e:this.getAvailableScreenResolution(e)},getAvailableScreenResolution:function(e){var t;return window.screen.availWidth&&window.screen.availHeight&&(t=this.options.detectScreenOrientation?window.screen.availHeight>window.screen.availWidth?[window.screen.availHeight,window.screen.availWidth]:[window.screen.availWidth,window.screen.availHeight]:[window.screen.availHeight,window.screen.availWidth]),void 0!==t&&e.addPreprocessedComponent({key:"available_resolution",value:t}),e},timezoneOffsetKey:function(e){return this.options.excludeTimezoneOffset||e.addPreprocessedComponent({key:"timezone_offset",value:(new Date).getTimezoneOffset()}),e},sessionStorageKey:function(e){return!this.options.excludeSessionStorage&&this.hasSessionStorage()&&e.addPreprocessedComponent({key:"session_storage",value:1}),e},localStorageKey:function(e){return!this.options.excludeSessionStorage&&this.hasLocalStorage()&&e.addPreprocessedComponent({key:"local_storage",value:1}),e},indexedDbKey:function(e){return!this.options.excludeIndexedDB&&this.hasIndexedDB()&&e.addPreprocessedComponent({key:"indexed_db",value:1}),e},addBehaviorKey:function(e){return!this.options.excludeAddBehavior&&document.body&&document.body.addBehavior&&e.addPreprocessedComponent({key:"add_behavior",value:1}),e},openDatabaseKey:function(e){return!this.options.excludeOpenDatabase&&window.openDatabase&&e.addPreprocessedComponent({key:"open_database",value:1}),e},cpuClassKey:function(e){return this.options.excludeCpuClass||e.addPreprocessedComponent({key:"cpu_class",value:this.getNavigatorCpuClass()}),e},platformKey:function(e){return this.options.excludePlatform||e.addPreprocessedComponent({key:"navigator_platform",value:this.getNavigatorPlatform()}),e},doNotTrackKey:function(e){return this.options.excludeDoNotTrack||e.addPreprocessedComponent({key:"do_not_track",value:this.getDoNotTrack()}),e},canvasKey:function(e){return!this.options.excludeCanvas&&this.isCanvasSupported()&&e.addPreprocessedComponent({key:"canvas",value:this.getCanvasFp()}),e},webglKey:function(e){return!this.options.excludeWebGL&&this.isWebGlSupported()&&e.addPreprocessedComponent({key:"webgl",value:this.getWebglFp()}),e},webglVendorAndRendererKey:function(e){return!this.options.excludeWebGLVendorAndRenderer&&this.isWebGlSupported()&&e.addPreprocessedComponent({key:"webgl_vendor",value:this.getWebglVendorAndRenderer()}),e},adBlockKey:function(e){return this.options.excludeAdBlock||e.addPreprocessedComponent({key:"adblock",value:this.getAdBlock()}),e},hasLiedLanguagesKey:function(e){return this.options.excludeHasLiedLanguages||e.addPreprocessedComponent({key:"has_lied_languages",value:this.getHasLiedLanguages()}),e},hasLiedResolutionKey:function(e){return this.options.excludeHasLiedResolution||e.addPreprocessedComponent({key:"has_lied_resolution",value:this.getHasLiedResolution()}),e},hasLiedOsKey:function(e){return this.options.excludeHasLiedOs||e.addPreprocessedComponent({key:"has_lied_os",value:this.getHasLiedOs()}),e},hasLiedBrowserKey:function(e){return this.options.excludeHasLiedBrowser||e.addPreprocessedComponent({key:"has_lied_browser",value:this.getHasLiedBrowser()}),e},fontsKey:function(e,t){return this.options.excludeJsFonts?this.flashFontsKey(e,t):this.jsFontsKey(e,t)},flashFontsKey:function(e,t){return this.options.excludeFlashFonts?t(e):this.hasSwfObjectLoaded()&&this.hasMinFlashInstalled()?void 0===this.options.swfPath?t(e):void this.loadSwfAndDetectFonts(function(r){e.addPreprocessedComponent({key:"swf_fonts",value:r.join(";")}),t(e)}):t(e)},jsFontsKey:function(e,t){var r=this;return setTimeout(function(){var n=["monospace","sans-serif","serif"],i=["Andale Mono","Arial","Arial Black","Arial Hebrew","Arial MT","Arial Narrow","Arial Rounded MT Bold","Arial Unicode MS","Bitstream Vera Sans Mono","Book Antiqua","Bookman Old Style","Calibri","Cambria","Cambria Math","Century","Century Gothic","Century Schoolbook","Comic Sans","Comic Sans MS","Consolas","Courier","Courier New","Geneva","Georgia","Helvetica","Helvetica Neue","Impact","Lucida Bright","Lucida Calligraphy","Lucida Console","Lucida Fax","LUCIDA GRANDE","Lucida Handwriting","Lucida Sans","Lucida Sans Typewriter","Lucida Sans Unicode","Microsoft Sans Serif","Monaco","Monotype Corsiva","MS Gothic","MS Outlook","MS PGothic","MS Reference Sans Serif","MS Sans Serif","MS Serif","MYRIAD","MYRIAD PRO","Palatino","Palatino Linotype","Segoe Print","Segoe Script","Segoe UI","Segoe UI Light","Segoe UI Semibold","Segoe UI Symbol","Tahoma","Times","Times New Roman","Times New Roman PS","Trebuchet MS","Verdana","Wingdings","Wingdings 2","Wingdings 3"];r.options.extendedJsFonts&&(i=i.concat(["Abadi MT Condensed Light","Academy Engraved LET","ADOBE CASLON PRO","Adobe Garamond","ADOBE GARAMOND PRO","Agency FB","Aharoni","Albertus Extra Bold","Albertus Medium","Algerian","Amazone BT","American Typewriter","American Typewriter Condensed","AmerType Md BT","Andalus","Angsana New","AngsanaUPC","Antique Olive","Aparajita","Apple Chancery","Apple Color Emoji","Apple SD Gothic Neo","Arabic Typesetting","ARCHER","ARNO PRO","Arrus BT","Aurora Cn BT","AvantGarde Bk BT","AvantGarde Md BT","AVENIR","Ayuthaya","Bandy","Bangla Sangam MN","Bank Gothic","BankGothic Md BT","Baskerville","Baskerville Old Face","Batang","BatangChe","Bauer Bodoni","Bauhaus 93","Bazooka","Bell MT","Bembo","Benguiat Bk BT","Berlin Sans FB","Berlin Sans FB Demi","Bernard MT Condensed","BernhardFashion BT","BernhardMod BT","Big Caslon","BinnerD","Blackadder ITC","BlairMdITC TT","Bodoni 72","Bodoni 72 Oldstyle","Bodoni 72 Smallcaps","Bodoni MT","Bodoni MT Black","Bodoni MT Condensed","Bodoni MT Poster Compressed","Bookshelf Symbol 7","Boulder","Bradley Hand","Bradley Hand ITC","Bremen Bd BT","Britannic Bold","Broadway","Browallia New","BrowalliaUPC","Brush Script MT","Californian FB","Calisto MT","Calligrapher","Candara","CaslonOpnface BT","Castellar","Centaur","Cezanne","CG Omega","CG Times","Chalkboard","Chalkboard SE","Chalkduster","Charlesworth","Charter Bd BT","Charter BT","Chaucer","ChelthmITC Bk BT","Chiller","Clarendon","Clarendon Condensed","CloisterBlack BT","Cochin","Colonna MT","Constantia","Cooper Black","Copperplate","Copperplate Gothic","Copperplate Gothic Bold","Copperplate Gothic Light","CopperplGoth Bd BT","Corbel","Cordia New","CordiaUPC","Cornerstone","Coronet","Cuckoo","Curlz MT","DaunPenh","Dauphin","David","DB LCD Temp","DELICIOUS","Denmark","DFKai-SB","Didot","DilleniaUPC","DIN","DokChampa","Dotum","DotumChe","Ebrima","Edwardian Script ITC","Elephant","English 111 Vivace BT","Engravers MT","EngraversGothic BT","Eras Bold ITC","Eras Demi ITC","Eras Light ITC","Eras Medium ITC","EucrosiaUPC","Euphemia","Euphemia UCAS","EUROSTILE","Exotc350 Bd BT","FangSong","Felix Titling","Fixedsys","FONTIN","Footlight MT Light","Forte","FrankRuehl","Fransiscan","Freefrm721 Blk BT","FreesiaUPC","Freestyle Script","French Script MT","FrnkGothITC Bk BT","Fruitger","FRUTIGER","Futura","Futura Bk BT","Futura Lt BT","Futura Md BT","Futura ZBlk BT","FuturaBlack BT","Gabriola","Galliard BT","Gautami","Geeza Pro","Geometr231 BT","Geometr231 Hv BT","Geometr231 Lt BT","GeoSlab 703 Lt BT","GeoSlab 703 XBd BT","Gigi","Gill Sans","Gill Sans MT","Gill Sans MT Condensed","Gill Sans MT Ext Condensed Bold","Gill Sans Ultra Bold","Gill Sans Ultra Bold Condensed","Gisha","Gloucester MT Extra Condensed","GOTHAM","GOTHAM BOLD","Goudy Old Style","Goudy Stout","GoudyHandtooled BT","GoudyOLSt BT","Gujarati Sangam MN","Gulim","GulimChe","Gungsuh","GungsuhChe","Gurmukhi MN","Haettenschweiler","Harlow Solid Italic","Harrington","Heather","Heiti SC","Heiti TC","HELV","Herald","High Tower Text","Hiragino Kaku Gothic ProN","Hiragino Mincho ProN","Hoefler Text","Humanst 521 Cn BT","Humanst521 BT","Humanst521 Lt BT","Imprint MT Shadow","Incised901 Bd BT","Incised901 BT","Incised901 Lt BT","INCONSOLATA","Informal Roman","Informal011 BT","INTERSTATE","IrisUPC","Iskoola Pota","JasmineUPC","Jazz LET","Jenson","Jester","Jokerman","Juice ITC","Kabel Bk BT","Kabel Ult BT","Kailasa","KaiTi","Kalinga","Kannada Sangam MN","Kartika","Kaufmann Bd BT","Kaufmann BT","Khmer UI","KodchiangUPC","Kokila","Korinna BT","Kristen ITC","Krungthep","Kunstler Script","Lao UI","Latha","Leelawadee","Letter Gothic","Levenim MT","LilyUPC","Lithograph","Lithograph Light","Long Island","Lydian BT","Magneto","Maiandra GD","Malayalam Sangam MN","Malgun Gothic","Mangal","Marigold","Marion","Marker Felt","Market","Marlett","Matisse ITC","Matura MT Script Capitals","Meiryo","Meiryo UI","Microsoft Himalaya","Microsoft JhengHei","Microsoft New Tai Lue","Microsoft PhagsPa","Microsoft Tai Le","Microsoft Uighur","Microsoft YaHei","Microsoft Yi Baiti","MingLiU","MingLiU_HKSCS","MingLiU_HKSCS-ExtB","MingLiU-ExtB","Minion","Minion Pro","Miriam","Miriam Fixed","Mistral","Modern","Modern No. 20","Mona Lisa Solid ITC TT","Mongolian Baiti","MONO","MoolBoran","Mrs Eaves","MS LineDraw","MS Mincho","MS PMincho","MS Reference Specialty","MS UI Gothic","MT Extra","MUSEO","MV Boli","Nadeem","Narkisim","NEVIS","News Gothic","News GothicMT","NewsGoth BT","Niagara Engraved","Niagara Solid","Noteworthy","NSimSun","Nyala","OCR A Extended","Old Century","Old English Text MT","Onyx","Onyx BT","OPTIMA","Oriya Sangam MN","OSAKA","OzHandicraft BT","Palace Script MT","Papyrus","Parchment","Party LET","Pegasus","Perpetua","Perpetua Titling MT","PetitaBold","Pickwick","Plantagenet Cherokee","Playbill","PMingLiU","PMingLiU-ExtB","Poor Richard","Poster","PosterBodoni BT","PRINCETOWN LET","Pristina","PTBarnum BT","Pythagoras","Raavi","Rage Italic","Ravie","Ribbon131 Bd BT","Rockwell","Rockwell Condensed","Rockwell Extra Bold","Rod","Roman","Sakkal Majalla","Santa Fe LET","Savoye LET","Sceptre","Script","Script MT Bold","SCRIPTINA","Serifa","Serifa BT","Serifa Th BT","ShelleyVolante BT","Sherwood","Shonar Bangla","Showcard Gothic","Shruti","Signboard","SILKSCREEN","SimHei","Simplified Arabic","Simplified Arabic Fixed","SimSun","SimSun-ExtB","Sinhala Sangam MN","Sketch Rockwell","Skia","Small Fonts","Snap ITC","Snell Roundhand","Socket","Souvenir Lt BT","Staccato222 BT","Steamer","Stencil","Storybook","Styllo","Subway","Swis721 BlkEx BT","Swiss911 XCm BT","Sylfaen","Synchro LET","System","Tamil Sangam MN","Technical","Teletype","Telugu Sangam MN","Tempus Sans ITC","Terminal","Thonburi","Traditional Arabic","Trajan","TRAJAN PRO","Tristan","Tubular","Tunga","Tw Cen MT","Tw Cen MT Condensed","Tw Cen MT Condensed Extra Bold","TypoUpright BT","Unicorn","Univers","Univers CE 55 Medium","Univers Condensed","Utsaah","Vagabond","Vani","Vijaya","Viner Hand ITC","VisualUI","Vivaldi","Vladimir Script","Vrinda","Westminster","WHITNEY","Wide Latin","ZapfEllipt BT","ZapfHumnst BT","ZapfHumnst Dm BT","Zapfino","Zurich BlkEx BT","Zurich Ex BT","ZWAdobeF"])),i=(i=i.concat(r.options.userDefinedFonts)).filter(function(e,t){return i.indexOf(e)===t});var a=document.getElementsByTagName("body")[0],o=document.createElement("div"),s=document.createElement("div"),l={},d={},h=function(){var e=document.createElement("span");return e.style.position="absolute",e.style.left="-9999px",e.style.fontSize="72px",e.style.fontStyle="normal",e.style.fontWeight="normal",e.style.letterSpacing="normal",e.style.lineBreak="auto",e.style.lineHeight="normal",e.style.textTransform="none",e.style.textAlign="left",e.style.textDecoration="none",e.style.textShadow="none",e.style.whiteSpace="normal",e.style.wordBreak="normal",e.style.wordSpacing="normal",e.innerHTML="mmmmmmmmmmlli",e},c=function(e){for(var t=!1,r=0;rt.name?1:e.name=0?"Windows Phone":t.indexOf("win")>=0?"Windows":t.indexOf("android")>=0?"Android":t.indexOf("linux")>=0?"Linux":t.indexOf("iphone")>=0||t.indexOf("ipad")>=0?"iOS":t.indexOf("mac")>=0?"Mac":"Other",("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)&&"Windows Phone"!==e&&"Android"!==e&&"iOS"!==e&&"Other"!==e)return!0;if(void 0!==r){if((r=r.toLowerCase()).indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e)return!0;if(r.indexOf("linux")>=0&&"Linux"!==e&&"Android"!==e)return!0;if(r.indexOf("mac")>=0&&"Mac"!==e&&"iOS"!==e)return!0;if((-1===r.indexOf("win")&&-1===r.indexOf("linux")&&-1===r.indexOf("mac"))!=("Other"===e))return!0}return n.indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e||((n.indexOf("linux")>=0||n.indexOf("android")>=0||n.indexOf("pike")>=0)&&"Linux"!==e&&"Android"!==e||((n.indexOf("mac")>=0||n.indexOf("ipad")>=0||n.indexOf("ipod")>=0||n.indexOf("iphone")>=0)&&"Mac"!==e&&"iOS"!==e||((-1===n.indexOf("win")&&-1===n.indexOf("linux")&&-1===n.indexOf("mac"))!=("Other"===e)||void 0===navigator.plugins&&"Windows"!==e&&"Windows Phone"!==e)))},getHasLiedBrowser:function(){var e,t=navigator.userAgent.toLowerCase(),r=navigator.productSub;if(("Chrome"===(e=t.indexOf("firefox")>=0?"Firefox":t.indexOf("opera")>=0||t.indexOf("opr")>=0?"Opera":t.indexOf("chrome")>=0?"Chrome":t.indexOf("safari")>=0?"Safari":t.indexOf("trident")>=0?"Internet Explorer":"Other")||"Safari"===e||"Opera"===e)&&"20030107"!==r)return!0;var n,i=eval.toString().length;if(37===i&&"Safari"!==e&&"Firefox"!==e&&"Other"!==e)return!0;if(39===i&&"Internet Explorer"!==e&&"Other"!==e)return!0;if(33===i&&"Chrome"!==e&&"Opera"!==e&&"Other"!==e)return!0;try{throw"a"}catch(e){try{e.toSource(),n=!0}catch(e){n=!1}}return!(!n||"Firefox"===e||"Other"===e)},isCanvasSupported:function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},isWebGlSupported:function(){if(!this.isCanvasSupported())return!1;var e=this.getWebglCanvas();return!!window.WebGLRenderingContext&&!!e},isIE:function(){return"Microsoft Internet Explorer"===navigator.appName||!("Netscape"!==navigator.appName||!/Trident/.test(navigator.userAgent))},hasSwfObjectLoaded:function(){return void 0!==window.swfobject},hasMinFlashInstalled:function(){return window.swfobject.hasFlashPlayerVersion("9.0.0")},addFlashDivNode:function(){var e=document.createElement("div");e.setAttribute("id",this.options.swfContainerId),document.body.appendChild(e)},loadSwfAndDetectFonts:function(e){var t="___fp_swf_loaded";window[t]=function(t){e(t)};var r=this.options.swfContainerId;this.addFlashDivNode();var n={onReady:t};window.swfobject.embedSWF(this.options.swfPath,r,"1","1","9.0.0",!1,n,{allowScriptAccess:"always",menu:"false"},{})},getWebglCanvas:function(){var e=document.createElement("canvas"),t=null;try{t=e.getContext("webgl")||e.getContext("experimental-webgl")}catch(e){}return t||(t=null),t},each:function(e,t,r){if(null!==e)if(this.nativeForEach&&e.forEach===this.nativeForEach)e.forEach(t,r);else if(e.length===+e.length){for(var n=0,i=e.length;n>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]+t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]+t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]+t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]+t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]},x64Multiply:function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]*t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]*t[3],r[1]+=r[2]>>>16,r[2]&=65535,r[2]+=e[3]*t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]*t[3],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[2]*t[2],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[3]*t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]},x64Rotl:function(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])},x64LeftShift:function(e,t){return 0===(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=this.x64Multiply(e,[4283543511,3981806797]),e=this.x64Xor(e,[0,e[0]>>>1]),e=this.x64Multiply(e,[3301882366,444984403]),e=this.x64Xor(e,[0,e[0]>>>1])},x64hash128:function(e,t){e=e||"",t=t||0;for(var r=e.length%16,n=e.length-r,i=[0,t],a=[0,t],o=[0,0],s=[0,0],l=[2277735313,289559509],d=[1291169091,658871167],h=0;h>>0).toString(16)).slice(-8)+("00000000"+(i[1]>>>0).toString(16)).slice(-8)+("00000000"+(a[0]>>>0).toString(16)).slice(-8)+("00000000"+(a[1]>>>0).toString(16)).slice(-8)}},e.VERSION="1.8.0",e}); @@ -331,7 +324,7 @@ var ukefu = { signal = 0 ; checkTimes = 0 ; ukefu.ping(); - console.log("优客服客户端信息校对"); + console.log("春松客服客户端信息校对"); } },5000) ; }