diff --git a/README.md b/README.md
index cd35bb8e..9dcc7782 100644
--- a/README.md
+++ b/README.md
@@ -59,50 +59,61 @@
序号 |
内容 |
- 视频地址 |
+ 腾讯视频 |
+ 百度网盘 |
No. 1 |
产品概述 |
- 链接 |
+ 观看 |
+ 下载 |
No. 2 |
安装部署 |
- 链接 |
+ 观看 |
+ 下载 |
No. 3 |
功能演示 |
- 链接 |
+ 观看 |
+ 下载 |
No. 4 |
账号体系 |
- 链接 |
+ 观看 |
+ 下载 |
No. 5 |
客户关系管理 |
- 链接 |
+ 观看 |
+ 下载 |
No. 6 |
即时通信 |
- 链接 |
+ 观看 |
+ 下载 |
No. 7 |
呼叫中心 |
- 链接 |
+ 观看 |
+ 下载 |
No. 8 |
数据报表 |
- 链接 |
+ 观看 |
+ 下载 |
+[*下载视频合集*](https://pan.baidu.com/s/1YH7d7nMm5wZQp7P8kID3KA)
+
## 开发文档
@@ -144,11 +155,14 @@
-
## 产品体系
-
-
+
+ 观看视频介绍
+
+
+
+
## 鸣谢
diff --git a/cc-chatbot/app/.classpath b/cc-chatbot/app/.classpath
new file mode 100644
index 00000000..f0257c5a
--- /dev/null
+++ b/cc-chatbot/app/.classpath
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cc-chatbot/app/.project b/cc-chatbot/app/.project
new file mode 100644
index 00000000..5c1f81b8
--- /dev/null
+++ b/cc-chatbot/app/.project
@@ -0,0 +1,23 @@
+
+
+ sdk
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/cc-chatbot/app/.settings/org.eclipse.core.resources.prefs b/cc-chatbot/app/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..f9fe3459
--- /dev/null
+++ b/cc-chatbot/app/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/test/java=UTF-8
+encoding/=UTF-8
diff --git a/cc-chatbot/app/.settings/org.eclipse.jdt.apt.core.prefs b/cc-chatbot/app/.settings/org.eclipse.jdt.apt.core.prefs
new file mode 100644
index 00000000..d4313d4b
--- /dev/null
+++ b/cc-chatbot/app/.settings/org.eclipse.jdt.apt.core.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.apt.aptEnabled=false
diff --git a/cc-chatbot/app/.settings/org.eclipse.jdt.core.prefs b/cc-chatbot/app/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..5592a0a1
--- /dev/null
+++ b/cc-chatbot/app/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.processAnnotations=disabled
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/cc-chatbot/app/.settings/org.eclipse.m2e.core.prefs b/cc-chatbot/app/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 00000000..f897a7f1
--- /dev/null
+++ b/cc-chatbot/app/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/cc-chatbot/app/pom.xml b/cc-chatbot/app/pom.xml
index 64cc275d..09879747 100644
--- a/cc-chatbot/app/pom.xml
+++ b/cc-chatbot/app/pom.xml
@@ -6,7 +6,7 @@
com.chatopera.chatbot
sdk
- 1.0.3
+ 1.1.0
jar
sdk
@@ -20,16 +20,6 @@
-
- org.slf4j
- slf4j-api
- 1.7.25
-
-
- org.slf4j
- slf4j-simple
- 1.7.25
-
org.apache.commons
commons-lang3
diff --git a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPI.java b/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPI.java
index 2c1d5494..1a65bea7 100644
--- a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPI.java
+++ b/cc-chatbot/app/src/main/java/com/chatopera/chatbot/ChatbotAPI.java
@@ -18,15 +18,12 @@ package com.chatopera.chatbot;
import com.mashape.unirest.http.exceptions.UnirestException;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
public class ChatbotAPI {
- private static final Logger logger = LoggerFactory.getLogger(ChatbotAPI.class);
private String schema;
private String hostname;
private int port;
@@ -179,6 +176,7 @@ public class ChatbotAPI {
* @throws ChatbotAPIRuntimeException
*/
public boolean updateByChatbotID(final String chatbotID,
+ final String name,
final String description,
final String fallback,
final String welcome) throws ChatbotAPIRuntimeException {
@@ -192,6 +190,8 @@ public class ChatbotAPI {
body.put("fallback", fallback);
if (StringUtils.isNotBlank(welcome))
body.put("welcome", welcome);
+ if (StringUtils.isNotBlank(name))
+ body.put("name", name);
try {
JSONObject result = RestAPI.put(this.baseUrl + "/chatbot/" + chatbotID, body, null);
@@ -275,8 +275,6 @@ public class ChatbotAPI {
body.put("textMessage", textMessage);
body.put("isDebug", debug);
- logger.info("conversation body {}", body);
-
try {
JSONObject resp = RestAPI.post(this.getBaseUrl() + "/chatbot/" + chatbotID + "/conversation/query", body);
return resp;
diff --git a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/RestAPI.java b/cc-chatbot/app/src/main/java/com/chatopera/chatbot/RestAPI.java
index d85a693c..ee5f7e57 100644
--- a/cc-chatbot/app/src/main/java/com/chatopera/chatbot/RestAPI.java
+++ b/cc-chatbot/app/src/main/java/com/chatopera/chatbot/RestAPI.java
@@ -22,8 +22,6 @@ import com.mashape.unirest.http.exceptions.UnirestException;
import com.mashape.unirest.request.GetRequest;
import com.mashape.unirest.request.HttpRequestWithBody;
import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.HashMap;
@@ -31,7 +29,6 @@ import java.util.HashMap;
* RestAPI接口
*/
public class RestAPI {
- private static final Logger logger = LoggerFactory.getLogger(RestAPI.class);
/**
* patch headers
@@ -66,7 +63,6 @@ public class RestAPI {
*/
public static JSONObject post(final String url, final HashMap body, final HashMap query, HashMap headers) throws UnirestException {
HttpRequestWithBody request = Unirest.post(url);
- logger.info("post body {}", body.toString());
x(headers);
HttpResponse resp = request
.headers(headers)
diff --git a/cc-chatbot/app/src/test/java/com/chatopera/chatbot/ChatbotAPITest.java b/cc-chatbot/app/src/test/java/com/chatopera/chatbot/ChatbotAPITest.java
index 7dfb4ec6..303ed688 100644
--- a/cc-chatbot/app/src/test/java/com/chatopera/chatbot/ChatbotAPITest.java
+++ b/cc-chatbot/app/src/test/java/com/chatopera/chatbot/ChatbotAPITest.java
@@ -19,8 +19,6 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.net.MalformedURLException;
@@ -29,7 +27,6 @@ import java.net.MalformedURLException;
*/
public class ChatbotAPITest
extends TestCase {
- private static final Logger logger = LoggerFactory.getLogger(ChatbotAPITest.class);
private ChatbotAPI cb;
/**
@@ -62,7 +59,7 @@ public class ChatbotAPITest
public void testGetChatbot() {
try {
JSONObject resp = this.cb.getChatbot("co_bot_1");
- logger.info("[testGetChatbot] {}", resp.toString());
+ System.out.println("[testGetChatbot] " + resp.toString());
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
}
@@ -71,7 +68,7 @@ public class ChatbotAPITest
public void testGetChatbots() {
try {
JSONObject resp = this.cb.getChatbots("name chatbotID", null, 0, 10);
- logger.info("[testGetChatbots] resp {}", resp.toString());
+ System.out.println("[testGetChatbots] resp " + resp.toString());
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
}
@@ -80,7 +77,7 @@ public class ChatbotAPITest
public void testConversation() {
try {
JSONObject resp = this.cb.conversation("co_bot_1", "sdktest", "华夏春松在哪里", false);
- logger.info("[testConversation] resp {}", resp.toString());
+ System.out.println("[testConversation] resp " + resp.toString());
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
}
@@ -89,7 +86,7 @@ public class ChatbotAPITest
public void testFaq() {
try {
JSONObject resp = this.cb.faq("co_bot_1", "sdktest", "华夏春松在哪里", false);
- logger.info("[testFaq] resp {}", resp.toString());
+ System.out.print("[testFaq] resp " + resp.toString());
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
}
@@ -98,7 +95,7 @@ public class ChatbotAPITest
public void testParseUrl() {
try {
ChatbotAPI c = new ChatbotAPI("https://local:8000/");
- logger.info("chatbot baseUrl {}", c.getBaseUrl());
+ System.out.println("chatbot baseUrl " + c.getBaseUrl());
assertEquals("https://local:8000/api/v1", c.getBaseUrl());
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
@@ -124,7 +121,6 @@ public class ChatbotAPITest
"我不了解。",
"小云机器人",
"你好,我是小云。");
- logger.info("[testCreateBot] {}", j);
} catch (ChatbotAPIRuntimeException e) {
e.printStackTrace();
}
diff --git a/contact-center/app/pom.xml b/contact-center/app/pom.xml
index 8c5efd09..e21195a8 100644
--- a/contact-center/app/pom.xml
+++ b/contact-center/app/pom.xml
@@ -312,7 +312,7 @@
com.chatopera.chatbot
sdk
- 1.0.3
+ 1.1.0
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/aggregation/CallOutHangupAggsResult.java b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/CallOutHangupAggsResult.java
similarity index 96%
rename from contact-center/app/src/main/java/com/chatopera/cc/util/aggregation/CallOutHangupAggsResult.java
rename to contact-center/app/src/main/java/com/chatopera/cc/aggregation/CallOutHangupAggsResult.java
index ee502a56..34f336f0 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/util/aggregation/CallOutHangupAggsResult.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/CallOutHangupAggsResult.java
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.util.aggregation;
+package com.chatopera.cc.aggregation;
-import com.chatopera.cc.util.exception.CallOutRecordException;
+import com.chatopera.cc.exception.CallOutRecordException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/aggregation/CallOutHangupAuditResult.java b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/CallOutHangupAuditResult.java
similarity index 98%
rename from contact-center/app/src/main/java/com/chatopera/cc/util/aggregation/CallOutHangupAuditResult.java
rename to contact-center/app/src/main/java/com/chatopera/cc/aggregation/CallOutHangupAuditResult.java
index 60a25f28..2be6c094 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/util/aggregation/CallOutHangupAuditResult.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/CallOutHangupAuditResult.java
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.util.aggregation;
+package com.chatopera.cc.aggregation;
-import com.chatopera.cc.util.exception.CallOutRecordException;
+import com.chatopera.cc.exception.CallOutRecordException;
import com.google.gson.JsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/aggregation/MathHelper.java b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/MathHelper.java
similarity index 98%
rename from contact-center/app/src/main/java/com/chatopera/cc/util/aggregation/MathHelper.java
rename to contact-center/app/src/main/java/com/chatopera/cc/aggregation/MathHelper.java
index 060ea338..e43b23ba 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/util/aggregation/MathHelper.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/MathHelper.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.util.aggregation;
+package com.chatopera.cc.aggregation;
import java.util.Date;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentCallOutFilter.java b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentCallOutFilter.java
similarity index 77%
rename from contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentCallOutFilter.java
rename to contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentCallOutFilter.java
index bc125f51..1ca4dc45 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentCallOutFilter.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentCallOutFilter.java
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.webim.service.quene;
+package com.chatopera.cc.aggregation.filter;
-import com.chatopera.cc.webim.service.cache.CacheHelper;
+import com.chatopera.cc.app.cache.CacheHelper;
import org.apache.commons.lang.StringUtils;
import com.hazelcast.mapreduce.KeyPredicate;
-import com.chatopera.cc.core.UKDataContext;
-import com.chatopera.cc.webim.web.model.UKefuCallOutNames;
+import com.chatopera.cc.app.basic.MainContext;
+import com.chatopera.cc.app.model.UKefuCallOutNames;
@SuppressWarnings("deprecation")
public class AgentCallOutFilter implements KeyPredicate{
@@ -38,6 +38,6 @@ public class AgentCallOutFilter implements KeyPredicate{
}
public boolean evaluate(String key) {
UKefuCallOutNames ukefuCallOutNames = (UKefuCallOutNames) CacheHelper.getCallOutCacheBean().getCacheObject(key, orgi);
- return ukefuCallOutNames !=null && !StringUtils.isBlank(orgi) && orgi.equals(ukefuCallOutNames.getOrgi()) && UKDataContext.CallOutType.AGENT.toString().equals(ukefuCallOutNames.getCalltype());
+ return ukefuCallOutNames !=null && !StringUtils.isBlank(orgi) && orgi.equals(ukefuCallOutNames.getOrgi()) && MainContext.CallOutType.AGENT.toString().equals(ukefuCallOutNames.getCalltype());
}
}
\ No newline at end of file
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentStatusBusyOrgiFilter.java b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentStatusBusyOrgiFilter.java
similarity index 87%
rename from contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentStatusBusyOrgiFilter.java
rename to contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentStatusBusyOrgiFilter.java
index 133145c2..367c28b3 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentStatusBusyOrgiFilter.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentStatusBusyOrgiFilter.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.webim.service.quene;
+package com.chatopera.cc.aggregation.filter;
-import com.chatopera.cc.webim.service.cache.CacheHelper;
-import com.chatopera.cc.webim.web.model.AgentStatus;
+import com.chatopera.cc.app.cache.CacheHelper;
+import com.chatopera.cc.app.model.AgentStatus;
import org.apache.commons.lang.StringUtils;
import com.hazelcast.mapreduce.KeyPredicate;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentStatusOrgiFilter.java b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentStatusOrgiFilter.java
similarity index 86%
rename from contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentStatusOrgiFilter.java
rename to contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentStatusOrgiFilter.java
index 8e5aa7c2..8e638cf9 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentStatusOrgiFilter.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentStatusOrgiFilter.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.webim.service.quene;
+package com.chatopera.cc.aggregation.filter;
-import com.chatopera.cc.webim.service.cache.CacheHelper;
-import com.chatopera.cc.webim.web.model.AgentStatus;
+import com.chatopera.cc.app.cache.CacheHelper;
+import com.chatopera.cc.app.model.AgentStatus;
import org.apache.commons.lang.StringUtils;
import com.hazelcast.mapreduce.KeyPredicate;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentUserOrgiFilter.java b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentUserOrgiFilter.java
similarity index 87%
rename from contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentUserOrgiFilter.java
rename to contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentUserOrgiFilter.java
index 9a57e1d6..e225acea 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AgentUserOrgiFilter.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AgentUserOrgiFilter.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.webim.service.quene;
+package com.chatopera.cc.aggregation.filter;
-import com.chatopera.cc.webim.service.cache.CacheHelper;
-import com.chatopera.cc.webim.web.model.AgentUser;
+import com.chatopera.cc.app.cache.CacheHelper;
+import com.chatopera.cc.app.model.AgentUser;
import org.apache.commons.lang.StringUtils;
import com.hazelcast.mapreduce.KeyPredicate;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AiCallOutFilter.java b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AiCallOutFilter.java
similarity index 77%
rename from contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AiCallOutFilter.java
rename to contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AiCallOutFilter.java
index ab98453d..f743d3c8 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/quene/AiCallOutFilter.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/aggregation/filter/AiCallOutFilter.java
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.webim.service.quene;
+package com.chatopera.cc.aggregation.filter;
-import com.chatopera.cc.webim.service.cache.CacheHelper;
-import com.chatopera.cc.webim.web.model.UKefuCallOutNames;
+import com.chatopera.cc.app.basic.MainContext;
+import com.chatopera.cc.app.cache.CacheHelper;
+import com.chatopera.cc.app.model.UKefuCallOutNames;
import org.apache.commons.lang.StringUtils;
import com.hazelcast.mapreduce.KeyPredicate;
-import com.chatopera.cc.core.UKDataContext;
@SuppressWarnings("deprecation")
public class AiCallOutFilter implements KeyPredicate{
@@ -38,6 +38,6 @@ public class AiCallOutFilter implements KeyPredicate{
}
public boolean evaluate(String key) {
UKefuCallOutNames ukefuCallOutNames = (UKefuCallOutNames) CacheHelper.getCallOutCacheBean().getCacheObject(key, orgi);
- return ukefuCallOutNames !=null && !StringUtils.isBlank(orgi) && orgi.equals(ukefuCallOutNames.getOrgi()) && UKDataContext.CallOutType.AI.toString().equals(ukefuCallOutNames.getCalltype());
+ return ukefuCallOutNames !=null && !StringUtils.isBlank(orgi) && orgi.equals(ukefuCallOutNames.getOrgi()) && MainContext.CallOutType.AI.toString().equals(ukefuCallOutNames.getCalltype());
}
}
\ No newline at end of file
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/app/Application.java
similarity index 88%
rename from contact-center/app/src/main/java/com/chatopera/cc/webim/Application.java
rename to contact-center/app/src/main/java/com/chatopera/cc/app/Application.java
index f7a1c9ed..7e55984d 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/Application.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java
@@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.webim;
+package com.chatopera.cc.app;
-import com.chatopera.cc.core.UKDataContext;
+import com.chatopera.cc.app.basic.MainContext;
import com.chatopera.cc.util.mobile.MobileNumberUtils;
-import com.chatopera.cc.webim.config.web.StartedEventListener;
+import com.chatopera.cc.app.config.StartedEventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -38,8 +38,8 @@ import javax.servlet.MultipartConfigElement;
import java.io.IOException;
@SpringBootApplication
-@EnableJpaRepositories("com.chatopera.cc.webim.service.repository")
-@EnableElasticsearchRepositories("com.chatopera.cc.webim.service.es")
+@EnableJpaRepositories("com.chatopera.cc.app.persistence.repository")
+@EnableElasticsearchRepositories("com.chatopera.cc.app.persistence.es")
@EnableAsync
public class Application {
private static final Logger logger = LoggerFactory.getLogger(Application.class);
@@ -56,8 +56,9 @@ public class Application {
private String multipartMaxRequest;
static{
- UKDataContext.model.put("contacts", true) ;
- UKDataContext.model.put("sales", true);
+ MainContext.model.put("contacts", true) ;
+ MainContext.model.put("sales", true);
+ MainContext.model.put("chatbot", true);
}
/**
@@ -100,7 +101,7 @@ public class Application {
app.setBannerMode(Banner.Mode.OFF);
app.setAddCommandLineProperties(false);
app.addListeners(new StartedEventListener());
- UKDataContext.setApplicationContext(app.run(args));
+ MainContext.setApplicationContext(app.run(args));
}
}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/ServletInitializer.java b/contact-center/app/src/main/java/com/chatopera/cc/app/ServletInitializer.java
similarity index 94%
rename from contact-center/app/src/main/java/com/chatopera/cc/webim/ServletInitializer.java
rename to contact-center/app/src/main/java/com/chatopera/cc/app/ServletInitializer.java
index f38169af..8f5c787d 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/ServletInitializer.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/app/ServletInitializer.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.webim;
+package com.chatopera.cc.app;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/acd/ServiceQuene.java b/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java
similarity index 73%
rename from contact-center/app/src/main/java/com/chatopera/cc/webim/service/acd/ServiceQuene.java
rename to contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java
index 8503c961..d2349223 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/webim/service/acd/ServiceQuene.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java
@@ -14,19 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.chatopera.cc.webim.service.acd;
+package com.chatopera.cc.app.algorithm;
-import com.chatopera.cc.core.UKDataContext;
-import com.chatopera.cc.util.UKTools;
+import com.chatopera.cc.app.basic.MainContext;
+import com.chatopera.cc.app.basic.MainUtils;
+import com.chatopera.cc.app.im.client.NettyClients;
+import com.chatopera.cc.app.im.router.OutMessageRouter;
+import com.chatopera.cc.app.model.*;
+import com.chatopera.cc.app.cache.CacheHelper;
+import com.chatopera.cc.aggregation.filter.AgentStatusBusyOrgiFilter;
+import com.chatopera.cc.aggregation.filter.AgentStatusOrgiFilter;
+import com.chatopera.cc.aggregation.filter.AgentUserOrgiFilter;
+import com.chatopera.cc.app.persistence.repository.*;
import com.chatopera.cc.util.WebIMReport;
-import com.chatopera.cc.util.client.NettyClients;
-import com.chatopera.cc.webim.service.cache.CacheHelper;
-import com.chatopera.cc.webim.service.quene.AgentStatusBusyOrgiFilter;
-import com.chatopera.cc.webim.service.quene.AgentStatusOrgiFilter;
-import com.chatopera.cc.webim.service.quene.AgentUserOrgiFilter;
-import com.chatopera.cc.webim.service.repository.*;
-import com.chatopera.cc.webim.util.router.OutMessageRouter;
-import com.chatopera.cc.webim.web.model.*;
import com.corundumstudio.socketio.SocketIONamespace;
import com.hazelcast.core.IMap;
import com.hazelcast.mapreduce.aggregation.Aggregations;
@@ -46,8 +46,8 @@ import java.util.concurrent.locks.Lock;
* Automatic Call Distribution
*/
@SuppressWarnings("deprecation")
-public class ServiceQuene {
- private final static Logger logger = LoggerFactory.getLogger(ServiceQuene.class);
+public class AutomaticServiceDist {
+ private final static Logger logger = LoggerFactory.getLogger(AutomaticServiceDist.class);
/**
* 载入坐席 ACD策略配置
@@ -57,13 +57,13 @@ public class ServiceQuene {
*/
public static SessionConfig initSessionConfig(String orgi) {
SessionConfig sessionConfig = null;
- if (UKDataContext.getContext() != null && (sessionConfig = (SessionConfig) CacheHelper.getSystemCacheBean().getCacheObject(UKDataContext.SYSTEM_CACHE_SESSION_CONFIG + "_" + orgi, orgi)) == null) {
- SessionConfigRepository sessionConfigRes = UKDataContext.getContext().getBean(SessionConfigRepository.class);
+ if (MainContext.getContext() != null && (sessionConfig = (SessionConfig) CacheHelper.getSystemCacheBean().getCacheObject(MainContext.SYSTEM_CACHE_SESSION_CONFIG + "_" + orgi, orgi)) == null) {
+ SessionConfigRepository sessionConfigRes = MainContext.getContext().getBean(SessionConfigRepository.class);
sessionConfig = sessionConfigRes.findByOrgi(orgi);
if (sessionConfig == null) {
sessionConfig = new SessionConfig();
} else {
- CacheHelper.getSystemCacheBean().put(UKDataContext.SYSTEM_CACHE_SESSION_CONFIG + "_" + orgi, sessionConfig, orgi);
+ CacheHelper.getSystemCacheBean().put(MainContext.SYSTEM_CACHE_SESSION_CONFIG + "_" + orgi, sessionConfig, orgi);
}
}
return sessionConfig;
@@ -78,11 +78,11 @@ public class ServiceQuene {
@SuppressWarnings("unchecked")
public static List initSessionConfigList() {
List sessionConfigList = null;
- if (UKDataContext.getContext() != null && (sessionConfigList = (List) CacheHelper.getSystemCacheBean().getCacheObject(UKDataContext.SYSTEM_CACHE_SESSION_CONFIG_LIST, UKDataContext.SYSTEM_ORGI)) == null) {
- SessionConfigRepository sessionConfigRes = UKDataContext.getContext().getBean(SessionConfigRepository.class);
+ if (MainContext.getContext() != null && (sessionConfigList = (List) CacheHelper.getSystemCacheBean().getCacheObject(MainContext.SYSTEM_CACHE_SESSION_CONFIG_LIST, MainContext.SYSTEM_ORGI)) == null) {
+ SessionConfigRepository sessionConfigRes = MainContext.getContext().getBean(SessionConfigRepository.class);
sessionConfigList = sessionConfigRes.findAll();
if (sessionConfigList != null && sessionConfigList.size() > 0) {
- CacheHelper.getSystemCacheBean().put(UKDataContext.SYSTEM_CACHE_SESSION_CONFIG_LIST, sessionConfigList, UKDataContext.SYSTEM_ORGI);
+ CacheHelper.getSystemCacheBean().put(MainContext.SYSTEM_CACHE_SESSION_CONFIG_LIST, sessionConfigList, MainContext.SYSTEM_ORGI);
}
}
return sessionConfigList;
@@ -113,10 +113,10 @@ public class ServiceQuene {
* 统计当前服务中的用户数量
*/
IMap agentUserMap = (IMap) CacheHelper.getAgentUserCacheBean().getCache();
- Long users = (Long) agentUserMap.aggregate(Supplier.fromKeyPredicate(new AgentUserOrgiFilter(orgi, UKDataContext.AgentUserStatusEnum.INSERVICE.toString())), Aggregations.count());
+ Long users = (Long) agentUserMap.aggregate(Supplier.fromKeyPredicate(new AgentUserOrgiFilter(orgi, MainContext.AgentUserStatusEnum.INSERVICE.toString())), Aggregations.count());
report.setUsers(users.intValue());
- Long queneUsers = (Long) agentUserMap.aggregate(Supplier.fromKeyPredicate(new AgentUserOrgiFilter(orgi, UKDataContext.AgentUserStatusEnum.INQUENE.toString())), Aggregations.count());
+ Long queneUsers = (Long) agentUserMap.aggregate(Supplier.fromKeyPredicate(new AgentUserOrgiFilter(orgi, MainContext.AgentUserStatusEnum.INQUENE.toString())), Aggregations.count());
report.setInquene(queneUsers.intValue());
return report;
@@ -193,29 +193,29 @@ public class ServiceQuene {
}
agentStatusList.addAll(((IMap) CacheHelper.getAgentUserCacheBean().getCache()).values(pagingPredicate));
for (AgentUser agentUser : agentStatusList) {
- SessionConfig sessionConfig = ServiceQuene.initSessionConfig(orgi);
- long maxusers = sessionConfig != null ? sessionConfig.getMaxuser() : UKDataContext.AGENT_STATUS_MAX_USER;
+ SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(orgi);
+ long maxusers = sessionConfig != null ? sessionConfig.getMaxuser() : MainContext.AGENT_STATUS_MAX_USER;
if (agentStatus != null && agentStatus.getUsers() < maxusers) { //坐席未达到最大咨询访客数量
CacheHelper.getAgentUserCacheBean().delete(agentUser.getUserid(), orgi); //从队列移除,进入正在处理的队列, 避免使用 分布式锁
try {
AgentService agentService = processAgentService(agentStatus, agentUser, orgi);
MessageOutContent outMessage = new MessageOutContent();
- outMessage.setMessage(ServiceQuene.getSuccessMessage(agentService, agentUser.getChannel(), orgi));
- outMessage.setMessageType(UKDataContext.MediaTypeEnum.TEXT.toString());
- outMessage.setCalltype(UKDataContext.CallTypeEnum.IN.toString());
+ outMessage.setMessage(AutomaticServiceDist.getSuccessMessage(agentService, agentUser.getChannel(), orgi));
+ outMessage.setMessageType(MainContext.MediaTypeEnum.TEXT.toString());
+ outMessage.setCalltype(MainContext.CallTypeEnum.IN.toString());
outMessage.setNickName(agentStatus.getUsername());
- outMessage.setCreatetime(UKTools.dateFormate.format(new Date()));
+ outMessage.setCreatetime(MainUtils.dateFormate.format(new Date()));
if (!StringUtils.isBlank(agentUser.getUserid())) {
OutMessageRouter router = null;
- router = (OutMessageRouter) UKDataContext.getContext().getBean(agentUser.getChannel());
+ router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel());
if (router != null) {
- router.handler(agentUser.getUserid(), UKDataContext.MessageTypeEnum.MESSAGE.toString(), agentUser.getAppid(), outMessage);
+ router.handler(agentUser.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), agentUser.getAppid(), outMessage);
}
}
- NettyClients.getInstance().sendAgentEventMessage(agentService.getAgentno(), UKDataContext.MessageTypeEnum.NEW.toString(), agentUser);
+ NettyClients.getInstance().sendAgentEventMessage(agentService.getAgentno(), MainContext.MessageTypeEnum.NEW.toString(), agentUser);
} catch (Exception ex) {
ex.printStackTrace();
}
@@ -235,17 +235,17 @@ public class ServiceQuene {
public static void serviceFinish(AgentUser agentUser, String orgi) throws Exception {
if (agentUser != null) {
AgentStatus agentStatus = null;
- if (UKDataContext.AgentUserStatusEnum.INSERVICE.toString().equals(agentUser.getStatus()) && agentUser.getAgentno() != null) {
+ if (MainContext.AgentUserStatusEnum.INSERVICE.toString().equals(agentUser.getStatus()) && agentUser.getAgentno() != null) {
agentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(agentUser.getAgentno(), orgi);
}
CacheHelper.getAgentUserCacheBean().delete(agentUser.getUserid(), orgi);
- AgentUserRepository agentUserRepository = UKDataContext.getContext().getBean(AgentUserRepository.class);
+ AgentUserRepository agentUserRepository = MainContext.getContext().getBean(AgentUserRepository.class);
AgentUser agentUseDataBean = agentUserRepository.findByIdAndOrgi(agentUser.getId(), agentUser.getOrgi());
- SessionConfig sessionConfig = ServiceQuene.initSessionConfig(orgi);
+ SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(orgi);
if (agentUseDataBean != null) {
- agentUseDataBean.setStatus(UKDataContext.AgentUserStatusEnum.END.toString());
+ agentUseDataBean.setStatus(MainContext.AgentUserStatusEnum.END.toString());
if (agentUser.getServicetime() != null) {
agentUseDataBean.setSessiontimes(System.currentTimeMillis() - agentUser.getServicetime().getTime());
}
@@ -255,19 +255,19 @@ public class ServiceQuene {
/**
* 更新OnlineUser对象,变更为服务中,不可邀请 , WebIM渠道专用
*/
- if (UKDataContext.ChannelTypeEnum.WEBIM.toString().equals(agentUser.getChannel())) {
- OnlineUserRepository onlineUserRes = UKDataContext.getContext().getBean(OnlineUserRepository.class);
+ if (MainContext.ChannelTypeEnum.WEBIM.toString().equals(agentUser.getChannel())) {
+ OnlineUserRepository onlineUserRes = MainContext.getContext().getBean(OnlineUserRepository.class);
List onlineUserList = onlineUserRes.findByUseridAndOrgi(agentUser.getUserid(), agentUser.getOrgi());
if (onlineUserList.size() > 0) {
OnlineUser onlineUser = onlineUserList.get(0);
- onlineUser.setInvitestatus(UKDataContext.OnlineUserInviteStatus.DEFAULT.toString());
+ onlineUser.setInvitestatus(MainContext.OnlineUserInviteStatus.DEFAULT.toString());
onlineUserRes.save(onlineUser);
}
}
}
- final boolean isPhone = UKDataContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel());
- AgentServiceRepository agentServiceRes = UKDataContext.getContext().getBean(AgentServiceRepository.class);
+ final boolean isPhone = MainContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel());
+ AgentServiceRepository agentServiceRes = MainContext.getContext().getBean(AgentServiceRepository.class);
AgentService service = null;
if (!StringUtils.isBlank(agentUser.getAgentserviceid())) {
service = agentServiceRes.findByIdAndOrgi(agentUser.getAgentserviceid(), agentUser.getOrgi());
@@ -276,13 +276,13 @@ public class ServiceQuene {
service = processAgentService(agentStatus, agentUser, orgi, true);
}
if (service != null) {
- service.setStatus(UKDataContext.AgentUserStatusEnum.END.toString());
+ service.setStatus(MainContext.AgentUserStatusEnum.END.toString());
service.setEndtime(new Date());
if (service.getServicetime() != null) {
service.setSessiontimes(System.currentTimeMillis() - service.getServicetime().getTime());
}
- AgentUserTaskRepository agentUserTaskRes = UKDataContext.getContext().getBean(AgentUserTaskRepository.class);
+ AgentUserTaskRepository agentUserTaskRes = MainContext.getContext().getBean(AgentUserTaskRepository.class);
List agentUserTaskList = agentUserTaskRes.findByIdAndOrgi(agentUser.getId(), agentUser.getOrgi());
if (agentUserTaskList.size() > 0) {
AgentUserTask agentUserTask = agentUserTaskList.get(0);
@@ -300,41 +300,41 @@ public class ServiceQuene {
* 启用了质检任务,开启质检
*/
if (sessionConfig.isQuality() && service.getUserasks() > 0) { //开启了质检,并且是有效对话
- service.setQualitystatus(UKDataContext.QualityStatus.NODIS.toString()); //未分配质检任务
+ service.setQualitystatus(MainContext.QualityStatus.NODIS.toString()); //未分配质检任务
} else {
- service.setQualitystatus(UKDataContext.QualityStatus.NO.toString()); //未开启质检 或无效对话无需质检
+ service.setQualitystatus(MainContext.QualityStatus.NO.toString()); //未开启质检 或无效对话无需质检
}
agentServiceRes.save(service);
}
if (isPhone) { // 语音渠道,强制发送
- NettyClients.getInstance().sendCalloutEventMessage(agentUser.getAgentno(), UKDataContext.MessageTypeEnum.END.toString(), agentUser);
+ NettyClients.getInstance().sendCalloutEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.END.toString(), agentUser);
} else {
if (agentStatus != null) // WebIM 查看用户状态
- NettyClients.getInstance().sendAgentEventMessage(agentUser.getAgentno(), UKDataContext.MessageTypeEnum.END.toString(), agentUser);
+ NettyClients.getInstance().sendAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.END.toString(), agentUser);
OutMessageRouter router = null;
- router = (OutMessageRouter) UKDataContext.getContext().getBean(agentUser.getChannel());
+ router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel());
if (router != null) {
MessageOutContent outMessage = new MessageOutContent();
- outMessage.setMessage(ServiceQuene.getServiceFinishMessage(agentUser.getChannel(), orgi));
- outMessage.setMessageType(UKDataContext.AgentUserStatusEnum.END.toString());
- outMessage.setCalltype(UKDataContext.CallTypeEnum.IN.toString());
+ outMessage.setMessage(AutomaticServiceDist.getServiceFinishMessage(agentUser.getChannel(), orgi));
+ outMessage.setMessageType(MainContext.AgentUserStatusEnum.END.toString());
+ outMessage.setCalltype(MainContext.CallTypeEnum.IN.toString());
if (agentStatus != null) {
outMessage.setNickName(agentStatus.getUsername());
} else {
outMessage.setNickName(agentUser.getUsername());
}
- outMessage.setCreatetime(UKTools.dateFormate.format(new Date()));
+ outMessage.setCreatetime(MainUtils.dateFormate.format(new Date()));
outMessage.setAgentserviceid(agentUser.getAgentserviceid());
- router.handler(agentUser.getUserid(), UKDataContext.MessageTypeEnum.STATUS.toString(), agentUser.getAppid(), outMessage);
+ router.handler(agentUser.getUserid(), MainContext.MessageTypeEnum.STATUS.toString(), agentUser.getAppid(), outMessage);
}
}
if (agentStatus != null) {
updateAgentStatus(agentStatus, agentUser, orgi, false);
- long maxusers = sessionConfig != null ? sessionConfig.getMaxuser() : UKDataContext.AGENT_STATUS_MAX_USER;
+ long maxusers = sessionConfig != null ? sessionConfig.getMaxuser() : MainContext.AGENT_STATUS_MAX_USER;
if (agentStatus.getUsers() < maxusers) {
allotAgent(agentStatus.getAgentno(), orgi);
}
@@ -367,8 +367,8 @@ public class ServiceQuene {
/**
* 坐席状态改变,通知监测服务
*/
- AgentReport agentReport = ServiceQuene.getAgentReport(orgi);
- AgentReportRepository agentReportRes = UKDataContext.getContext().getBean(AgentReportRepository.class);
+ AgentReport agentReport = AutomaticServiceDist.getAgentReport(orgi);
+ AgentReportRepository agentReportRes = MainContext.getContext().getBean(AgentReportRepository.class);
if (agentReportRes != null) {
agentReport.setOrgi(orgi);
agentReport.setWorktype(worktype);
@@ -377,7 +377,7 @@ public class ServiceQuene {
agentReportRes.save(agentReport);
}
- UKDataContext.getContext().getBean("agentNamespace", SocketIONamespace.class).getBroadcastOperations().sendEvent("status", agentReport);
+ MainContext.getContext().getBean("agentNamespace", SocketIONamespace.class).getBroadcastOperations().sendEvent("status", agentReport);
}
/**
@@ -390,7 +390,7 @@ public class ServiceQuene {
* @param lasttime
*/
public static void recordAgentStatus(String agent, String username, String extno, String skill, boolean admin, String userid, String status, String current, String worktype, String orgi, Date lasttime) {
- WorkMonitorRepository workMonitorRes = UKDataContext.getContext().getBean(WorkMonitorRepository.class);
+ WorkMonitorRepository workMonitorRes = MainContext.getContext().getBean(WorkMonitorRepository.class);
WorkMonitor workMonitor = new WorkMonitor();
if (!StringUtils.isBlank(agent) && !StringUtils.isBlank(status)) {
workMonitor.setAgent(agent);
@@ -403,17 +403,17 @@ public class ServiceQuene {
if (lasttime != null) {
workMonitor.setDuration((int) (System.currentTimeMillis() - lasttime.getTime()) / 1000);
}
- if (status.equals(UKDataContext.AgentStatusEnum.BUSY.toString())) {
+ if (status.equals(MainContext.AgentStatusEnum.BUSY.toString())) {
workMonitor.setBusy(true);
}
- if (status.equals(UKDataContext.AgentStatusEnum.READY.toString())) {
- int count = workMonitorRes.countByAgentAndDatestrAndStatusAndOrgi(agent, UKTools.simpleDateFormat.format(new Date()), UKDataContext.AgentStatusEnum.READY.toString(), orgi);
+ if (status.equals(MainContext.AgentStatusEnum.READY.toString())) {
+ int count = workMonitorRes.countByAgentAndDatestrAndStatusAndOrgi(agent, MainUtils.simpleDateFormat.format(new Date()), MainContext.AgentStatusEnum.READY.toString(), orgi);
if (count == 0) {
workMonitor.setFirsttime(true);
}
}
- if (current.equals(UKDataContext.AgentStatusEnum.NOTREADY.toString())) {
- List workMonitorList = workMonitorRes.findByOrgiAndAgentAndDatestrAndFirsttime(orgi, agent, UKTools.simpleDateFormat.format(new Date()), true);
+ if (current.equals(MainContext.AgentStatusEnum.NOTREADY.toString())) {
+ List workMonitorList = workMonitorRes.findByOrgiAndAgentAndDatestrAndFirsttime(orgi, agent, MainUtils.simpleDateFormat.format(new Date()), true);
if (workMonitorList.size() > 0) {
WorkMonitor firstWorkMonitor = workMonitorList.get(0);
if (firstWorkMonitor.getFirsttimes() == 0) {
@@ -423,7 +423,7 @@ public class ServiceQuene {
}
}
workMonitor.setCreatetime(new Date());
- workMonitor.setDatestr(UKTools.simpleDateFormat.format(new Date()));
+ workMonitor.setDatestr(MainUtils.simpleDateFormat.format(new Date()));
workMonitor.setName(agent);
workMonitor.setOrgi(orgi);
@@ -474,14 +474,14 @@ public class ServiceQuene {
}
try {
agentService = processAgentService(agentStatus, agentUser, orgi);
- if (agentService.getStatus().equals(UKDataContext.AgentUserStatusEnum.INQUENE.toString())) {
+ if (agentService.getStatus().equals(MainContext.AgentUserStatusEnum.INQUENE.toString())) {
agentService.setQueneindex(getQueneIndex(agentUser.getAgent(), orgi, agentUser.getSkill()));
}
} catch (Exception ex) {
ex.printStackTrace();
}
- publishMessage(orgi, "user", agentService != null && agentService.getStatus().equals(UKDataContext.AgentUserStatusEnum.INSERVICE.toString()) ? "inservice" : "inquene", agentUser.getId());
+ publishMessage(orgi, "user", agentService != null && agentService.getStatus().equals(MainContext.AgentUserStatusEnum.INSERVICE.toString()) ? "inservice" : "inquene", agentUser.getId());
return agentService;
}
@@ -500,7 +500,7 @@ public class ServiceQuene {
if (agentStatus != null) {
agentService = processAgentService(agentStatus, agentUser, orgi);
publishMessage(orgi, "invite", "success", agentno);
- NettyClients.getInstance().sendAgentEventMessage(agentService.getAgentno(), UKDataContext.MessageTypeEnum.NEW.toString(), agentUser);
+ NettyClients.getInstance().sendAgentEventMessage(agentService.getAgentno(), MainContext.MessageTypeEnum.NEW.toString(), agentUser);
} else {
agentService = allotAgent(agentUser, orgi);
}
@@ -523,47 +523,44 @@ public class ServiceQuene {
/**
* 为访客 分配坐席, ACD策略,此处 AgentStatus 是建议 的 坐席, 如果启用了 历史服务坐席 优先策略, 则会默认检查历史坐席是否空闲,如果空闲,则分配,如果不空闲,则 分配当前建议的坐席
*
- * @param agentStatus
* @param agentUser
* @param orgi
* @return
* @throws Exception
*/
- public static AgentService processAiService(AiUser aiUser, String orgi) throws Exception {
+ public static AgentService processChatbotService(final AgentUser agentUser, final String orgi) {
AgentService agentService = new AgentService(); //放入缓存的对象
- AgentServiceRepository agentServiceRes = UKDataContext.getContext().getBean(AgentServiceRepository.class);
- if (!StringUtils.isBlank(aiUser.getAgentserviceid())) {
- agentService = agentServiceRes.findByIdAndOrgi(aiUser.getAgentserviceid(), orgi);
- agentService.setEndtime(new Date());
+ AgentServiceRepository agentServiceRes = MainContext.getContext().getBean(AgentServiceRepository.class);
+ Date now = new Date();
+ if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) {
+ agentService = agentServiceRes.findByIdAndOrgi(agentUser.getAgentserviceid(), orgi);
+ agentService.setEndtime(now);
if (agentService.getServicetime() != null) {
agentService.setSessiontimes(System.currentTimeMillis() - agentService.getServicetime().getTime());
}
- agentService.setStatus(UKDataContext.AgentUserStatusEnum.END.toString());
+ agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString());
} else {
- agentService.setServicetime(new Date());
- agentService.setLogindate(new Date());
+ agentService.setServicetime(now);
+ agentService.setLogindate(now);
agentService.setOrgi(orgi);
- agentService.setOwner(aiUser.getContextid());
- agentService.setSessionid(aiUser.getSessionid());
- if (aiUser.getIpdata() != null) {
- agentService.setRegion(aiUser.getIpdata().getRegion());
- }
+ agentService.setOwner(agentUser.getContextid());
+ agentService.setSessionid(agentUser.getSessionid());
+ agentService.setRegion(agentUser.getRegion());
+ agentService.setUsername(agentUser.getUsername());
+ agentService.setChannel(agentUser.getChannel());
- agentService.setUsername(aiUser.getUsername());
- agentService.setChannel(aiUser.getChannel());
-
- if (!StringUtils.isBlank(aiUser.getContextid())) {
- agentService.setContextid(aiUser.getContextid());
+ if (StringUtils.isNotBlank(agentUser.getContextid())) {
+ agentService.setContextid(agentUser.getContextid());
} else {
- agentService.setContextid(aiUser.getSessionid());
+ agentService.setContextid(agentUser.getSessionid());
}
- agentService.setUserid(aiUser.getUserid());
- agentService.setAiid(aiUser.getAiid());
+ agentService.setUserid(agentUser.getUserid());
+ agentService.setAiid(agentUser.getAgentno());
agentService.setAiservice(true);
- agentService.setStatus(UKDataContext.AgentUserStatusEnum.INSERVICE.toString());
+ agentService.setStatus(MainContext.AgentUserStatusEnum.INSERVICE.toString());
- agentService.setAppid(aiUser.getAppid());
+ agentService.setAppid(agentUser.getAppid());
agentService.setLeavemsg(false);
}
@@ -587,12 +584,12 @@ public class ServiceQuene {
}
agentService.setOrgi(orgi);
- UKTools.copyProperties(agentUser, agentService); //复制属性
+ MainUtils.copyProperties(agentUser, agentService); //复制属性
agentService.setChannel(agentUser.getChannel());
agentService.setSessionid(agentUser.getSessionid());
- OnlineUserRepository onlineUserRes = UKDataContext.getContext().getBean(OnlineUserRepository.class);
+ OnlineUserRepository onlineUserRes = MainContext.getContext().getBean(OnlineUserRepository.class);
agentUser.setLogindate(new Date());
List onlineUserList = onlineUserRes.findByUseridAndOrgi(agentUser.getUserid(), agentUser.getOrgi());
OnlineUser onlineUser = null;
@@ -607,7 +604,7 @@ public class ServiceQuene {
agentService.setSkill(agentUser.getSkill());
if (sessionConfig.isLastagent()) { //启用了历史坐席优先 , 查找 历史服务坐席
- List webIMaggList = UKTools.getWebIMDataAgg(onlineUserRes.findByOrgiForDistinctAgent(orgi, agentUser.getUserid()));
+ List webIMaggList = MainUtils.getWebIMDataAgg(onlineUserRes.findByOrgiForDistinctAgent(orgi, agentUser.getUserid()));
if (webIMaggList.size() > 0) {
for (WebIMReport report : webIMaggList) {
if (report.getData().equals(agentStatus.getAgentno())) {
@@ -624,27 +621,27 @@ public class ServiceQuene {
}
}
- agentUser.setStatus(UKDataContext.AgentUserStatusEnum.INSERVICE.toString());
- agentService.setStatus(UKDataContext.AgentUserStatusEnum.INSERVICE.toString());
+ agentUser.setStatus(MainContext.AgentUserStatusEnum.INSERVICE.toString());
+ agentService.setStatus(MainContext.AgentUserStatusEnum.INSERVICE.toString());
- agentService.setSessiontype(UKDataContext.AgentUserStatusEnum.INSERVICE.toString());
+ agentService.setSessiontype(MainContext.AgentUserStatusEnum.INSERVICE.toString());
agentService.setAgentno(agentStatus.getUserid());
agentService.setAgentusername(agentStatus.getUsername()); //agent
} else {
if (finished == true) {
- agentUser.setStatus(UKDataContext.AgentUserStatusEnum.END.toString());
- agentService.setStatus(UKDataContext.AgentUserStatusEnum.END.toString());
- agentService.setSessiontype(UKDataContext.AgentUserStatusEnum.END.toString());
+ agentUser.setStatus(MainContext.AgentUserStatusEnum.END.toString());
+ agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString());
+ agentService.setSessiontype(MainContext.AgentUserStatusEnum.END.toString());
if (agentStatus == null) {
agentService.setLeavemsg(true); //是留言
- agentService.setLeavemsgstatus(UKDataContext.LeaveMsgStatus.NOTPROCESS.toString()); //未处理的留言
+ agentService.setLeavemsgstatus(MainContext.LeaveMsgStatus.NOTPROCESS.toString()); //未处理的留言
}
} else {
- agentUser.setStatus(UKDataContext.AgentUserStatusEnum.INQUENE.toString());
- agentService.setStatus(UKDataContext.AgentUserStatusEnum.INQUENE.toString());
+ agentUser.setStatus(MainContext.AgentUserStatusEnum.INQUENE.toString());
+ agentService.setStatus(MainContext.AgentUserStatusEnum.INQUENE.toString());
- agentService.setSessiontype(UKDataContext.AgentUserStatusEnum.INQUENE.toString());
+ agentService.setSessiontype(MainContext.AgentUserStatusEnum.INQUENE.toString());
}
}
if (finished || agentStatus != null) {
@@ -652,7 +649,7 @@ public class ServiceQuene {
agentService.setAgentuserid(agentUser.getId());
- agentService.setInitiator(UKDataContext.ChatInitiatorType.USER.toString());
+ agentService.setInitiator(MainContext.ChatInitiatorType.USER.toString());
long waittingtime = 0;
if (agentUser.getWaittingtimestart() != null) {
@@ -669,7 +666,7 @@ public class ServiceQuene {
agentService.setTimes(0);
agentUser.setAgentno(agentService.getAgentno());
- AgentServiceRepository agentServiceRes = UKDataContext.getContext().getBean(AgentServiceRepository.class);
+ AgentServiceRepository agentServiceRes = MainContext.getContext().getBean(AgentServiceRepository.class);
if (!StringUtils.isBlank(agentUser.getName())) {
agentService.setName(agentUser.getName());
@@ -714,14 +711,14 @@ public class ServiceQuene {
/**
* 将 AgentUser 放入到 当前坐席的 服务队列
*/
- AgentUserRepository agentUserRepository = UKDataContext.getContext().getBean(AgentUserRepository.class);
+ AgentUserRepository agentUserRepository = MainContext.getContext().getBean(AgentUserRepository.class);
/**
* 更新OnlineUser对象,变更为服务中,不可邀请
*/
if (onlineUser != null) {
- onlineUser.setInvitestatus(UKDataContext.OnlineUserInviteStatus.INSERV.toString());
+ onlineUser.setInvitestatus(MainContext.OnlineUserInviteStatus.INSERV.toString());
onlineUserRes.save(onlineUser);
}
@@ -730,7 +727,7 @@ public class ServiceQuene {
*/
agentUserRepository.save(agentUser);
- CacheHelper.getAgentUserCacheBean().put(agentUser.getUserid(), agentUser, UKDataContext.SYSTEM_ORGI);
+ CacheHelper.getAgentUserCacheBean().put(agentUser.getUserid(), agentUser, MainContext.SYSTEM_ORGI);
if (agentStatus != null) {
updateAgentStatus(agentStatus, agentUser, orgi, true);
@@ -742,12 +739,12 @@ public class ServiceQuene {
public static AgentUser deleteAgentUser(AgentUser agentUser, String orgi)
throws Exception {
if (agentUser != null) {
- if (!UKDataContext.AgentUserStatusEnum.END.toString().equals(
+ if (!MainContext.AgentUserStatusEnum.END.toString().equals(
agentUser.getStatus())) {
serviceFinish(agentUser, orgi);
}
if (!StringUtils.isBlank(agentUser.getId())) {
- AgentUserRepository agentUserRes = UKDataContext.getContext().getBean(AgentUserRepository.class);
+ AgentUserRepository agentUserRes = MainContext.getContext().getBean(AgentUserRepository.class);
agentUser = agentUserRes.findByIdAndOrgi(agentUser.getId(), orgi);
if (agentUser != null) {
agentUserRes.delete(agentUser);
@@ -764,7 +761,7 @@ public class ServiceQuene {
*/
public static String getSuccessMessage(AgentService agentService, String channel, String orgi) {
String queneTip = "" + agentService.getAgentusername() + "";
- if (!UKDataContext.ChannelTypeEnum.WEBIM.toString().equals(channel)) {
+ if (!MainContext.ChannelTypeEnum.WEBIM.toString().equals(channel)) {
queneTip = agentService.getAgentusername();
}
SessionConfig sessionConfig = initSessionConfig(orgi);
@@ -793,7 +790,7 @@ public class ServiceQuene {
queneIndex = 0;
}
String queneTip = "" + queneIndex + "";
- if (!UKDataContext.ChannelTypeEnum.WEBIM.toString().equals(channel)) {
+ if (!MainContext.ChannelTypeEnum.WEBIM.toString().equals(channel)) {
queneTip = String.valueOf(queneIndex);
}
SessionConfig sessionConfig = initSessionConfig(orgi);
@@ -807,7 +804,7 @@ public class ServiceQuene {
public static String getQueneMessage(int queneIndex, String channel, String orgi) {
String queneTip = "" + queneIndex + "";
- if (!UKDataContext.ChannelTypeEnum.WEBIM.toString().equals(channel)) {
+ if (!MainContext.ChannelTypeEnum.WEBIM.toString().equals(channel)) {
queneTip = String.valueOf(queneIndex);
}
SessionConfig sessionConfig = initSessionConfig(orgi);
@@ -825,13 +822,13 @@ public class ServiceQuene {
* @param status
*/
public static void deleteAgentStatus(String userid, String orgi, boolean isAdmin) {
- AgentStatusRepository agentStatusRes = UKDataContext.getContext().getBean(AgentStatusRepository.class);
+ AgentStatusRepository agentStatusRes = MainContext.getContext().getBean(AgentStatusRepository.class);
List agentStatusList = agentStatusRes.findByAgentnoAndOrgi(userid, orgi);
for (AgentStatus agentStatus : agentStatusList) {
- ServiceQuene.recordAgentStatus(agentStatus.getAgentno(), agentStatus.getUsername(), agentStatus.getAgentno(), agentStatus.getSkill(), isAdmin, agentStatus.getAgentno(), agentStatus.isBusy() ? UKDataContext.AgentStatusEnum.BUSY.toString() : UKDataContext.AgentStatusEnum.NOTREADY.toString(), UKDataContext.AgentStatusEnum.NOTREADY.toString(), UKDataContext.AgentWorkType.MEIDIACHAT.toString(), agentStatus.getOrgi(), agentStatus.getUpdatetime());
+ AutomaticServiceDist.recordAgentStatus(agentStatus.getAgentno(), agentStatus.getUsername(), agentStatus.getAgentno(), agentStatus.getSkill(), isAdmin, agentStatus.getAgentno(), agentStatus.isBusy() ? MainContext.AgentStatusEnum.BUSY.toString() : MainContext.AgentStatusEnum.NOTREADY.toString(), MainContext.AgentStatusEnum.NOTREADY.toString(), MainContext.AgentWorkType.MEIDIACHAT.toString(), agentStatus.getOrgi(), agentStatus.getUpdatetime());
agentStatusRes.delete(agentStatus);
}
CacheHelper.getAgentStatusCacheBean().delete(userid, orgi);
- ServiceQuene.publishMessage(orgi, "agent", "leave", userid);
+ AutomaticServiceDist.publishMessage(orgi, "agent", "leave", userid);
}
}
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/core/UKDataContext.java b/contact-center/app/src/main/java/com/chatopera/cc/app/basic/MainContext.java
similarity index 91%
rename from contact-center/app/src/main/java/com/chatopera/cc/core/UKDataContext.java
rename to contact-center/app/src/main/java/com/chatopera/cc/app/basic/MainContext.java
index 55ee0066..d55b1023 100644
--- a/contact-center/app/src/main/java/com/chatopera/cc/core/UKDataContext.java
+++ b/contact-center/app/src/main/java/com/chatopera/cc/app/basic/MainContext.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package com.chatopera.cc.core;
+package com.chatopera.cc.app.basic;
import com.chatopera.cc.util.DateConverter;
-import com.chatopera.cc.webim.service.resource.ActivityResource;
-import com.chatopera.cc.webim.service.resource.BatchResource;
-import com.chatopera.cc.webim.web.model.Log;
+import com.chatopera.cc.app.basic.resource.ActivityResource;
+import com.chatopera.cc.app.basic.resource.BatchResource;
+import com.chatopera.cc.app.model.Log;
import org.apache.commons.beanutils.ConvertUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
@@ -30,7 +30,7 @@ import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
-public class UKDataContext {
+public class MainContext {
public static final String USER_SESSION_NAME = "user";
public static final String GUEST_USER = "guest";
@@ -39,8 +39,8 @@ public class UKDataContext {
public static final String UKEFU_SYSTEM_AUTH_DIC = "com.dic.auth.resource";
public static final String UKEFU_SYSTEM_AREA_DIC = "com.dic.address.area";
public static final String UKEFU_SYSTEM_ADPOS_DIC = "com.dic.adv.type";
- public static final String UKEFU_SYSTEM_COMMENT_DIC = "com.dic.webim.comment";
- public static final String UKEFU_SYSTEM_COMMENT_ITEM_DIC = "com.dic.webim.comment.item";
+ public static final String UKEFU_SYSTEM_COMMENT_DIC = "com.dic.app.comment";
+ public static final String UKEFU_SYSTEM_COMMENT_ITEM_DIC = "com.dic.app.comment.item";
public static final String UKEFU_SYSTEM_DIS_AI = "ownerai";
public static final String UKEFU_SYSTEM_DIS_AGENT = "owneruser";
@@ -335,6 +335,28 @@ public class UKDataContext {
}
}
+ // 服务处理类型
+ public enum OptTypeEnum {
+ CHATBOT("机器人客服", 1),
+ HUMAN("人工客服", 2);
+
+ private final String name;
+ private final int index;
+
+ private OptTypeEnum(String name, int index) {
+ this.name = name;
+ this.index = index;
+ }
+
+ public String toLetters() {
+ return super.toString().toLowerCase();
+ }
+
+ public String toString() {
+ return this.name;
+ }
+ }
+
// 外呼计划状态
public enum CallOutDialplanStatusEnum {
RUNNING("执行中", 1),
@@ -486,9 +508,9 @@ public class UKDataContext {
}
- public enum AiItemType {
+ public enum ChatbotItemType {
USERINPUT,
- AIREPLY;
+ BOTREPLY;
public String toString() {
return super.toString().toLowerCase();
@@ -705,9 +727,9 @@ public class UKDataContext {
IM("/im/user"),
AGENT("/im/agent"),
ENTIM("/im/ent"),
- AIIM("/im/ai"),
- CALLCENTER("/callcenter/event"),
- CALLOUT("/callout/event");
+ CHATBOT("/im/chatbot"),
+ CALLCENTER("/callcenter/exchange"),
+ CALLOUT("/callout/exchange");
private String namespace;
@@ -834,7 +856,7 @@ public class UKDataContext {
}
public static void setTemplet(ElasticsearchTemplate templet) {
- UKDataContext.templet = templet;
+ MainContext.templet = templet;
}
public static int getWebIMPort() {
@@ -928,7 +950,7 @@ public class UKDataContext {
}
}
- public enum AiType {
+ public enum ChatbotType {
SMARTAI,
BUSINESSAI;
@@ -938,7 +960,7 @@ public class UKDataContext {
}
- public enum AiBussType {
+ public enum ChatbotBussType {
SALE,
QUESURVEY;
diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/basic/MainUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/app/basic/MainUtils.java
new file mode 100644
index 00000000..ce592ddd
--- /dev/null
+++ b/contact-center/app/src/main/java/com/chatopera/cc/app/basic/MainUtils.java
@@ -0,0 +1,1426 @@
+/*
+ * Copyright (C) 2017 优客服-多渠道客服系统
+ * Modifications copyright (C) 2018 Chatopera Inc,
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.chatopera.cc.app.basic;
+
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
+import com.aliyuncs.http.MethodType;
+import com.aliyuncs.profile.DefaultProfile;
+import com.aliyuncs.profile.IClientProfile;
+import com.chatopera.cc.app.cache.CacheHelper;
+import com.chatopera.cc.app.model.*;
+import com.chatopera.cc.app.persistence.repository.*;
+import com.chatopera.cc.concurrent.chatbot.ChatbotEvent;
+import com.chatopera.cc.concurrent.multiupdate.MultiUpdateEvent;
+import com.chatopera.cc.concurrent.user.UserDataEvent;
+import com.chatopera.cc.exchange.UserEvent;
+import com.chatopera.cc.util.*;
+import com.chatopera.cc.util.WebIMReport;
+import com.chatopera.cc.util.asr.AsrResult;
+import com.chatopera.cc.util.mail.MailSender;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.googlecode.aviator.AviatorEvaluator;
+import com.lmax.disruptor.dsl.Disruptor;
+import freemarker.template.Configuration;
+import freemarker.template.TemplateException;
+import io.netty.handler.codec.http.HttpHeaders;
+import net.coobird.thumbnailator.Thumbnails;
+import org.apache.commons.beanutils.BeanUtilsBean;
+import org.apache.commons.beanutils.ConversionException;
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.jasypt.util.text.BasicTextEncryptor;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.util.Assert;
+import org.springframework.util.ClassUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.security.NoSuchAlgorithmException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+public class MainUtils {
+ private static MD5 md5 = new MD5();
+
+ public static SimpleDateFormat dateFormate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+ public static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
+ public static SimpleDateFormat timeRangeDateFormat = new SimpleDateFormat("HH:mm");
+
+ /**
+ * 当前时间+已过随机生成的 长整形数字
+ *
+ * @return
+ */
+ public static String genID() {
+ return Base62.encode(getUUID()).toLowerCase();
+ }
+
+ public static String genIDByKey(String key) {
+ return Base62.encode(key).toLowerCase();
+ }
+
+ public static String getUUID() {
+ return UUID.randomUUID().toString().replace("-", "");
+ }
+
+ public static String getContextID(String session) {
+ return session.replaceAll("-", "");
+ }
+
+ public static String md5(String str) {
+ return md5.getMD5ofStr(md5.getMD5ofStr(str));
+ }
+
+ public static String md5(byte[] bytes) {
+ return md5.getMD5ofByte(bytes);
+ }
+
+ public static void copyProperties(Object source, Object target, String... ignoreProperties)
+ throws BeansException {
+
+ Assert.notNull(source, "Source must not be null");
+ Assert.notNull(target, "Target must not be null");
+
+ Class> actualEditable = target.getClass();
+ PropertyDescriptor[] targetPds = BeanUtils.getPropertyDescriptors(actualEditable);
+ List ignoreList = (ignoreProperties != null) ? Arrays.asList(ignoreProperties) : null;
+
+ for (PropertyDescriptor targetPd : targetPds) {
+ Method writeMethod = targetPd.getWriteMethod();
+ if (writeMethod != null && (ignoreProperties == null || (!ignoreList.contains(targetPd.getName())))) {
+ PropertyDescriptor sourcePd = BeanUtils.getPropertyDescriptor(source.getClass(), targetPd.getName());
+ if (sourcePd != null && !targetPd.getName().equalsIgnoreCase("id")) {
+ Method readMethod = sourcePd.getReadMethod();
+ if (readMethod != null &&
+ ClassUtils.isAssignable(writeMethod.getParameterTypes()[0], readMethod.getReturnType())) {
+ try {
+ if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) {
+ readMethod.setAccessible(true);
+ }
+ Object value = readMethod.invoke(source);
+ if (value != null) { //只拷贝不为null的属性 by zhao
+ if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) {
+ writeMethod.setAccessible(true);
+ }
+ writeMethod.invoke(target, value);
+ }
+ } catch (Throwable ex) {
+ throw new FatalBeanException(
+ "Could not copy property '" + targetPd.getName() + "' from source to target", ex);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static long ipToLong(String ipAddress) {
+ long result = 0;
+ String[] ipAddressInArray = ipAddress.split("\\.");
+ if (ipAddressInArray != null && ipAddressInArray.length == 4) {
+ for (int i = 3; i >= 0; i--) {
+ long ip = Long.parseLong(ipAddressInArray[3 - i]);
+
+ // left shifting 24,16,8,0 and bitwise OR
+
+ // 1. 192 << 24
+ // 1. 168 << 16
+ // 1. 1 << 8
+ // 1. 2 << 0
+ result |= ip << (i * 8);
+
+ }
+ }
+ return result;
+ }
+
+ public static String longToIp2(long ip) {
+
+ return ((ip >> 24) & 0xFF) + "." + ((ip >> 16) & 0xFF) + "."
+ + ((ip >> 8) & 0xFF) + "." + (ip & 0xFF);
+ }
+
+ /***
+ * ID编码 , 发送对话的时候使用
+ * @param id
+ * @param nid
+ * @return
+ */
+ public static String genNewID(String id, String nid) {
+ StringBuffer strb = new StringBuffer();
+ if (id != null && nid != null) {
+ int length = Math.max(id.length(), nid.length());
+ for (int i = 0; i < length; i++) {
+ if (nid.length() > i && id.length() > i) {
+ int cur = (id.charAt(i) + nid.charAt(i)) / 2;
+ strb.append((char) cur);
+ } else if (nid.length() > i) {
+ strb.append(nid.charAt(i));
+ } else {
+ strb.append(id.charAt(i));
+ }
+ }
+ }
+ return strb.toString();
+ }
+
+ public static void published(UserEvent event) {
+ @SuppressWarnings("unchecked")
+ Disruptor disruptor = (Disruptor) MainContext.getContext().getBean("disruptor");
+ long seq = disruptor.getRingBuffer().next();
+ disruptor.getRingBuffer().get(seq).setEvent(event);
+ ;
+ disruptor.getRingBuffer().publish(seq);
+ }
+
+ /**
+ * @param request
+ * @return
+ */
+ public static Map getRequestParam(HttpServletRequest request) {
+ Map values = new HashMap();
+ Enumeration enums = request.getParameterNames();
+ while (enums.hasMoreElements()) {
+ String param = enums.nextElement();
+ values.put(param, request.getParameter(param));
+ }
+ return values;
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public static void multiupdate(MultiUpdateEvent event) {
+ Disruptor disruptor = (Disruptor) MainContext.getContext().getBean("multiupdate");
+ long seq = disruptor.getRingBuffer().next();
+ disruptor.getRingBuffer().get(seq).setEvent(event);
+ disruptor.getRingBuffer().publish(seq);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public static void chatbot(ChatbotEvent event) {
+ Disruptor disruptor = (Disruptor) MainContext.getContext().getBean("chatbot");
+ long seq = disruptor.getRingBuffer().next();
+ disruptor.getRingBuffer().get(seq).setEvent(event);
+ disruptor.getRingBuffer().publish(seq);
+ }
+
+ /**
+ * @param request
+ * @return
+ */
+ public static String getParameter(HttpServletRequest request) {
+ Enumeration names = request.getParameterNames();
+ StringBuffer strb = new StringBuffer();
+ while (names.hasMoreElements()) {
+ String name = names.nextElement();
+ if (name.indexOf("password") < 0) { //不记录 任何包含 password 的参数内容
+ if (strb.length() > 0) {
+ strb.append(",");
+ }
+ strb.append(name).append("=").append(request.getParameter(name));
+ }
+ }
+ return strb.toString();
+
+ }
+
+ /**
+ * 获取一天的开始时间
+ *
+ * @return
+ */
+ public static Date getStartTime() {
+ Calendar todayStart = Calendar.getInstance();
+ todayStart.set(Calendar.HOUR_OF_DAY, 0);
+ todayStart.set(Calendar.MINUTE, 0);
+ todayStart.set(Calendar.SECOND, 0);
+ todayStart.set(Calendar.MILLISECOND, 0);
+ return todayStart.getTime();
+ }
+
+ /**
+ * 获取一天的开始时间
+ *
+ * @return
+ */
+ public static Date getWeekStartTime() {
+ Calendar weekStart = Calendar.getInstance();
+ weekStart.set(weekStart.get(Calendar.YEAR), weekStart.get(Calendar.MONDAY), weekStart.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
+ weekStart.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
+ return weekStart.getTime();
+ }
+
+ /**
+ * 获取一天的开始时间
+ *
+ * @return
+ */
+ public static Date getLast30Day() {
+ Calendar todayStart = Calendar.getInstance();
+ todayStart.set(Calendar.DAY_OF_MONTH, -30);
+ todayStart.set(Calendar.HOUR_OF_DAY, 0);
+ todayStart.set(Calendar.MINUTE, 0);
+ todayStart.set(Calendar.SECOND, 0);
+ todayStart.set(Calendar.MILLISECOND, 0);
+ return todayStart.getTime();
+ }
+
+ /**
+ * 获取一天的开始时间
+ *
+ * @return
+ */
+ public static Date getLastDay(int days) {
+ Calendar todayStart = Calendar.getInstance();
+ todayStart.set(Calendar.DAY_OF_MONTH, -days);
+ todayStart.set(Calendar.HOUR_OF_DAY, 0);
+ todayStart.set(Calendar.MINUTE, 0);
+ todayStart.set(Calendar.SECOND, 0);
+ todayStart.set(Calendar.MILLISECOND, 0);
+ return todayStart.getTime();
+ }
+
+ /**
+ * 获取一天的结束时间
+ *
+ * @return
+ */
+ public static Date getEndTime() {
+ Calendar todayEnd = Calendar.getInstance();
+ todayEnd.set(Calendar.HOUR_OF_DAY, 23);
+ todayEnd.set(Calendar.MINUTE, 59);
+ todayEnd.set(Calendar.SECOND, 59);
+ todayEnd.set(Calendar.MILLISECOND, 999);
+ return todayEnd.getTime();
+ }
+
+ /**
+ * 获取一天的结束时间
+ *
+ * @return
+ */
+ public static Date getLastTime(int secs) {
+ Calendar todayEnd = Calendar.getInstance();
+ todayEnd.add(Calendar.SECOND, secs * -1);
+ return todayEnd.getTime();
+ }
+
+ public static void noCacheResponse(HttpServletResponse response) {
+ response.setDateHeader("Expires", 0);
+ response.setHeader("Buffer", "True");
+ response.setHeader("Cache-Control", "no-cache");
+ response.setHeader("Cache-Control", "no-store");
+ response.setHeader("Expires", "0");
+ response.setHeader("ETag", String.valueOf(System.currentTimeMillis()));
+ response.setHeader("Pragma", "no-cache");
+ response.setHeader("Date", String.valueOf(new Date()));
+ response.setHeader("Last-Modified", String.valueOf(new Date()));
+ }
+
+ public static BrowserClient parseClient(HttpServletRequest request) {
+ BrowserClient client = new BrowserClient();
+ String browserDetails = request.getHeader("User-Agent");
+ String userAgent = browserDetails;
+ String user = userAgent.toLowerCase();
+ String os = "";
+ String browser = "", version = "";
+
+
+ //=================OS=======================
+ if (userAgent.toLowerCase().indexOf("windows") >= 0) {
+ os = "windows";
+ } else if (userAgent.toLowerCase().indexOf("mac") >= 0) {
+ os = "mac";
+ } else if (userAgent.toLowerCase().indexOf("x11") >= 0) {
+ os = "unix";
+ } else if (userAgent.toLowerCase().indexOf("android") >= 0) {
+ os = "android";
+ } else if (userAgent.toLowerCase().indexOf("iphone") >= 0) {
+ os = "iphone";
+ } else {
+ os = "UnKnown";
+ }
+ //===============Browser===========================
+ if (user.contains("qqbrowser")) {
+ browser = "QQBrowser";
+ } else if (user.contains("msie") || user.indexOf("rv:11") > -1) {
+ if (user.indexOf("rv:11") >= 0) {
+ browser = "IE11";
+ } else {
+ String substring = userAgent.substring(userAgent.indexOf("MSIE")).split(";")[0];
+ browser = substring.split(" ")[0].replace("MSIE", "IE") + substring.split(" ")[1];
+ }
+ } else if (user.contains("trident")) {
+ browser = "IE 11";
+ } else if (user.contains("edge")) {
+ browser = "Edge";
+ } else if (user.contains("safari") && user.contains("version")) {
+ browser = (userAgent.substring(userAgent.indexOf("Safari")).split(" ")[0]).split("/")[0];
+ version = (userAgent.substring(userAgent.indexOf("Version")).split(" ")[0]).split("/")[1];
+ } else if (user.contains("opr") || user.contains("opera")) {
+ if (user.contains("opera"))
+ browser = (userAgent.substring(userAgent.indexOf("Opera")).split(" ")[0]).split("/")[0] + "-" + (userAgent.substring(userAgent.indexOf("Version")).split(" ")[0]).split("/")[1];
+ else if (user.contains("opr"))
+ browser = ((userAgent.substring(userAgent.indexOf("OPR")).split(" ")[0]).replace("/", "-")).replace("OPR", "Opera");
+ } else if (user.contains("chrome")) {
+ browser = "Chrome";
+ } else if ((user.indexOf("mozilla/7.0") > -1) || (user.indexOf("netscape6") != -1) || (user.indexOf("mozilla/4.7") != -1) || (user.indexOf("mozilla/4.78") != -1) || (user.indexOf("mozilla/4.08") != -1) || (user.indexOf("mozilla/3") != -1)) {
+ //browser=(userAgent.substring(userAgent.indexOf("MSIE")).split(" ")[0]).replace("/", "-");
+ browser = "Netscape-?";
+
+ } else if ((user.indexOf("mozilla") > -1)) {
+ //browser=(userAgent.substring(userAgent.indexOf("MSIE")).split(" ")[0]).replace("/", "-");
+ if (browserDetails.indexOf(" ") > 0) {
+ browser = browserDetails.substring(0, browserDetails.indexOf(" "));
+ } else {
+ browser = "Mozilla";
+ }
+
+ } else if (user.contains("firefox")) {
+ browser = (userAgent.substring(userAgent.indexOf("Firefox")).split(" ")[0]).replace("/", "-");
+ } else if (user.contains("rv")) {
+ browser = "ie";
+ } else {
+ browser = "UnKnown";
+ }
+ client.setUseragent(browserDetails);
+ client.setOs(os);
+ client.setBrowser(browser);
+ client.setVersion(version);
+
+ return client;
+ }
+
+ /**
+ * 活动JPA统计结果
+ *
+ * @param values
+ * @return
+ */
+ public static WebIMReport getWebIMReport(List