From 96cd164c690d185586dcbafb903caeff60487791 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 26 Sep 2018 16:31:59 +0800 Subject: [PATCH 01/54] Closed #69 set chatbot menu --- .../main/resources/templates/apps/index.html | 26 +++++++++---------- .../config/sql/cskefu-MySQL-slim.sql | 4 +-- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/contact-center/app/src/main/resources/templates/apps/index.html b/contact-center/app/src/main/resources/templates/apps/index.html index 7898d9b7..b821d1f6 100644 --- a/contact-center/app/src/main/resources/templates/apps/index.html +++ b/contact-center/app/src/main/resources/templates/apps/index.html @@ -299,15 +299,15 @@ --> - <#if models?? && models["xiaoe"]?? && models["xiaoe"] == true> - <#if user?? &&( user.roleAuthMap["A09"]?? || user.usertype == "0") > -
- - - -
- - + + + + + + + + + <#if models?? && models["sales"]?? && models["sales"] == true> <#if user?? &&( user.roleAuthMap["A11"]?? || user.usertype == "0") >
@@ -318,10 +318,10 @@ <#if models?? && models["sales"]?? && models["sales"] == true> - <#if user?? &&( user.roleAuthMap["A11"]?? || user.usertype == "0") > -
- - + <#if user?? &&( user.roleAuthMap["A09"]?? || user.usertype == "0") > +
+ +
diff --git a/contact-center/config/sql/cskefu-MySQL-slim.sql b/contact-center/config/sql/cskefu-MySQL-slim.sql index 073b31c6..e577ed8e 100644 --- a/contact-center/config/sql/cskefu-MySQL-slim.sql +++ b/contact-center/config/sql/cskefu-MySQL-slim.sql @@ -7130,9 +7130,7 @@ INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612ce8b990057e', '在线坐 INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612ce8e6a2057f', '全部坐席', 'pub', 'A08_A04_A02', NULL, 'auth', '402881ef612b1f5b01612cdd1e930570', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:41:56', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/service/user/index.html', 'webim', '3', NULL, 'left'); INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612ce964ae0580', '智能机器人', 'pub', 'A09_A01', NULL, 'auth', '402881ef612b1f5b01612cc602450546', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:42:28', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, 'javascript:;', 'webim', '2', NULL, 'left'); INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612ce996f80581', '语料库配置', 'pub', 'A09_A02', NULL, 'auth', '402881ef612b1f5b01612cc602450546', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:42:41', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, 'javascript:;', 'webim', '2', NULL, 'left'); -INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612ce9d8150582', '机器人选项', 'pub', 'A09_A01_A01', NULL, 'auth', '402881ef612b1f5b01612ce964ae0580', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:42:58', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/apps/xiaoe/index.html', 'webim', '3', NULL, 'left'); -INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612cea04810583', '对话测试', 'pub', 'A09_A01_A02', NULL, 'auth', '402881ef612b1f5b01612ce964ae0580', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:43:09', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/apps/xiaoe/chat.html', 'webim', '3', NULL, 'left'); -INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612cea430f0584', '用户提问历史', 'pub', 'A09_A01_A03', NULL, 'auth', '402881ef612b1f5b01612ce964ae0580', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:43:25', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/apps/xiaoe/history.html', 'webim', '3', NULL, 'left'); +INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612ce9d8150582', '机器人管理', 'pub', 'A09_A01_A01', NULL, 'auth', '402881ef612b1f5b01612ce964ae0580', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:42:58', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/apps/xiaoe/index.html', 'webim', '3', NULL, 'left'); INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612ceaff050587', '对话场景', 'pub', 'A09_A02_A03', NULL, 'auth', '402881ef612b1f5b01612ce996f80581', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:44:13', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/apps/xiaoe/scene.html', 'webim', '3', NULL, 'left'); INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612ced9d5f0588', '知识维护', 'pub', 'A09_A02_A01', NULL, 'auth', '402881ef612b1f5b01612ce996f80581', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:47:05', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/apps/xiaoe/knowledge.html', 'webim', '3', NULL, 'left'); INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612cedca5e0589', '词库配置', 'pub', 'A09_A02_A02', NULL, 'auth', '402881ef612b1f5b01612ce996f80581', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:47:16', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/apps/xiaoe/words.html', 'webim', '3', NULL, 'left'); From 5ccbcda3ffb193c21c7bdd00d47728065d7463c9 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 26 Sep 2018 17:15:57 +0800 Subject: [PATCH 02/54] Closed #20 --- contact-center/app/pom.xml | 2 +- .../cc/app/handler/apps/test/TestController.java | 2 +- .../templates/admin/callcenter/extention/ivr.html | 2 +- .../src/main/resources/templates/admin/config/index.html | 6 +++--- .../src/main/resources/templates/admin/webim/profile.html | 8 ++++---- .../main/resources/templates/apps/business/kbs/index.html | 8 ++++---- .../resources/templates/apps/business/kbs/typelist.html | 8 ++++---- .../app/src/main/resources/templates/apps/entim/chat.html | 8 ++++---- .../src/main/resources/templates/apps/entim/index.html | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/contact-center/app/pom.xml b/contact-center/app/pom.xml index e21195a8..2eb18f9c 100644 --- a/contact-center/app/pom.xml +++ b/contact-center/app/pom.xml @@ -384,7 +384,7 @@ hailiang.hl.wang@gmail.com https://github.com/Samurais Chatopera Inc. - http://www.chatopera.com + https://www.chatopera.com architect developer diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/test/TestController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/test/TestController.java index f5da9d6c..1acaa38d 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/test/TestController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/test/TestController.java @@ -38,7 +38,7 @@ public class TestController extends Handler { for(int i=0 ; i<500; i++){ String user = MainUtils.getUUID(); try { - OnlineUserUtils.newRequestMessage(user, "ukewo", "user", "system", "localhost" , "win10", "test" , MainContext.ChannelTypeEnum.WEBIM.toString() , null , null , "admin" , "标题" , "http://www.ukewo.cn" , "12434" , MainContext.ChatInitiatorType.USER.toString()) ; + OnlineUserUtils.newRequestMessage(user, "ukewo", "user", "system", "localhost" , "win10", "test" , MainContext.ChannelTypeEnum.WEBIM.toString() , null , null , "admin" , "标题" , "https://www.chatopera.com" , "12434" , MainContext.ChatInitiatorType.USER.toString()) ; } catch (Exception e) { e.printStackTrace(); } diff --git a/contact-center/app/src/main/resources/templates/admin/callcenter/extention/ivr.html b/contact-center/app/src/main/resources/templates/admin/callcenter/extention/ivr.html index 20e81757..7984cb65 100644 --- a/contact-center/app/src/main/resources/templates/admin/callcenter/extention/ivr.html +++ b/contact-center/app/src/main/resources/templates/admin/callcenter/extention/ivr.html @@ -32,7 +32,7 @@
- +
diff --git a/contact-center/app/src/main/resources/templates/admin/config/index.html b/contact-center/app/src/main/resources/templates/admin/config/index.html index 90d665bc..0c0b2e8b 100644 --- a/contact-center/app/src/main/resources/templates/admin/config/index.html +++ b/contact-center/app/src/main/resources/templates/admin/config/index.html @@ -15,7 +15,7 @@
-

优客服系统界面颜色风格

+

春松客服系统界面颜色风格

默认的配色是绿色,选择颜色可以在右侧预览风格,点击保存即可生效

@@ -178,7 +178,7 @@

启用权限数据采集功能后,会进入数据采集模式,当前状态:<#if infoace?? && infoace == true>已启用<#else>已关闭

-

启用后,在优客服界面上的任何链接点击操作都会触发数据收集功能

+

启用后,在春松客服界面上的任何链接点击操作都会触发数据收集功能

<#if infoace?? && infoace == true> @@ -192,7 +192,7 @@
-
10、停止优客服系统
+
10、停止春松客服系统
diff --git a/contact-center/app/src/main/resources/templates/admin/webim/profile.html b/contact-center/app/src/main/resources/templates/admin/webim/profile.html index bb2fcab2..4ddbcb2f 100644 --- a/contact-center/app/src/main/resources/templates/admin/webim/profile.html +++ b/contact-center/app/src/main/resources/templates/admin/webim/profile.html @@ -50,7 +50,7 @@

默认显示信息 企业名称

- +
@@ -205,7 +205,7 @@
- +
@@ -472,7 +472,7 @@
- +
@@ -584,7 +584,7 @@
信息提示
- 名称: + 名称:
地址: diff --git a/contact-center/app/src/main/resources/templates/apps/business/kbs/index.html b/contact-center/app/src/main/resources/templates/apps/business/kbs/index.html index c408907c..7409442b 100644 --- a/contact-center/app/src/main/resources/templates/apps/business/kbs/index.html +++ b/contact-center/app/src/main/resources/templates/apps/business/kbs/index.html @@ -193,7 +193,7 @@ [知识概况] 45 浏览 , 15收藏 , 5评论 , 2017-10-02 15:40:33前有效 - 优客服v3.1.0 产品说明书.pdf 等3个附件 + 春松客服v3.1.0 产品说明书.pdf 等3个附件
@@ -233,7 +233,7 @@ [知识概况] 45 浏览 , 15收藏 , 5评论 , 2017-10-02 15:40:33前有效 - 优客服v3.1.0 产品说明书.pdf 等3个附件 + 春松客服v3.1.0 产品说明书.pdf 等3个附件
@@ -273,7 +273,7 @@ [知识概况] 45 浏览 , 15收藏 , 5评论 , 2017-10-02 15:40:33前有效 - 优客服v3.1.0 产品说明书.pdf 等3个附件 + 春松客服v3.1.0 产品说明书.pdf 等3个附件
@@ -311,7 +311,7 @@ [知识概况] 45 浏览 , 15收藏 , 5评论 , 2017-10-02 15:40:33前有效 - 优客服v3.1.0 产品说明书.pdf 等3个附件 + 春松客服v3.1.0 产品说明书.pdf 等3个附件 diff --git a/contact-center/app/src/main/resources/templates/apps/business/kbs/typelist.html b/contact-center/app/src/main/resources/templates/apps/business/kbs/typelist.html index 0cbff68c..46574ba6 100644 --- a/contact-center/app/src/main/resources/templates/apps/business/kbs/typelist.html +++ b/contact-center/app/src/main/resources/templates/apps/business/kbs/typelist.html @@ -94,7 +94,7 @@ [知识概况] 45 浏览 , 15收藏 , 5评论 , 2017-10-02 15:40:33前有效 - 优客服v3.1.0 产品说明书.pdf 等3个附件 + 春松客服v3.1.0 产品说明书.pdf 等3个附件 @@ -134,7 +134,7 @@ [知识概况] 45 浏览 , 15收藏 , 5评论 , 2017-10-02 15:40:33前有效 - 优客服v3.1.0 产品说明书.pdf 等3个附件 + 春松客服v3.1.0 产品说明书.pdf 等3个附件 @@ -174,7 +174,7 @@ [知识概况] 45 浏览 , 15收藏 , 5评论 , 2017-10-02 15:40:33前有效 - 优客服v3.1.0 产品说明书.pdf 等3个附件 + 春松客服v3.1.0 产品说明书.pdf 等3个附件 @@ -212,7 +212,7 @@ [知识概况] 45 浏览 , 15收藏 , 5评论 , 2017-10-02 15:40:33前有效 - 优客服v3.1.0 产品说明书.pdf 等3个附件 + 春松客服v3.1.0 产品说明书.pdf 等3个附件 diff --git a/contact-center/app/src/main/resources/templates/apps/entim/chat.html b/contact-center/app/src/main/resources/templates/apps/entim/chat.html index c598d2eb..ce997988 100644 --- a/contact-center/app/src/main/resources/templates/apps/entim/chat.html +++ b/contact-center/app/src/main/resources/templates/apps/entim/chat.html @@ -77,10 +77,10 @@
-

欢迎使用优客服企业IM

-

QQ群:优客服开源项目

-

优客服企业IM为收费产品

-

详情请咨询:优客服

+

欢迎使用春松客服企业IM

+

QQ群:春松客服开源社区

+

春松客服企业IM为收费产品

+

详情请咨询:春松客服

diff --git a/contact-center/app/src/main/resources/templates/apps/entim/index.html b/contact-center/app/src/main/resources/templates/apps/entim/index.html index 819cb81f..808774b3 100644 --- a/contact-center/app/src/main/resources/templates/apps/entim/index.html +++ b/contact-center/app/src/main/resources/templates/apps/entim/index.html @@ -172,7 +172,7 @@ title: '关于' , btn: '关闭' , shade: 0 , - content : '

欢迎使用优客服企业IM

QQ群:优客服开源项目

优客服企业IM为收费产品

详情请咨询:优客服

'}); + content : '

欢迎使用春松客服企业IM

QQ群:春松客服开源社区

春松客服企业IM为收费产品

详情请咨询:春松客服

'}); } function search(){ layer.open({ From cffdcc2b850564f79b17681289acb3d28ddf90f0 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 26 Sep 2018 17:51:19 +0800 Subject: [PATCH 03/54] #20 --- .../app/src/main/resources/templates/admin/config/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contact-center/app/src/main/resources/templates/admin/config/index.html b/contact-center/app/src/main/resources/templates/admin/config/index.html index 0c0b2e8b..e022d220 100644 --- a/contact-center/app/src/main/resources/templates/admin/config/index.html +++ b/contact-center/app/src/main/resources/templates/admin/config/index.html @@ -165,7 +165,8 @@ <#if entim?? && entim == true> 关闭EntIM功能 <#else> - 启用EntIM功能 + + 启用EntIM功能 From e95d369df4e7048d538fcae9e56fbad437bdc85e Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 27 Sep 2018 11:09:15 +0800 Subject: [PATCH 04/54] =?UTF-8?q?Closed=20#89=20=E5=A2=9E=E5=8A=A0testclie?= =?UTF-8?q?nt.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/static/testclient.html | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 contact-center/app/src/main/resources/static/testclient.html diff --git a/contact-center/app/src/main/resources/static/testclient.html b/contact-center/app/src/main/resources/static/testclient.html new file mode 100644 index 00000000..5d91cdae --- /dev/null +++ b/contact-center/app/src/main/resources/static/testclient.html @@ -0,0 +1,23 @@ + + + + + + + + + + 春松客服 + + + + + + +

春松客服演示客户端

+ +详细文档 + + + + \ No newline at end of file From 29d116120e1af9f87d64dbffe1e67e3b7bd75c59 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sat, 29 Sep 2018 16:26:28 +0800 Subject: [PATCH 05/54] #91 package sql file into WAR --- contact-center/app/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/contact-center/app/pom.xml b/contact-center/app/pom.xml index 2eb18f9c..11f6de78 100644 --- a/contact-center/app/pom.xml +++ b/contact-center/app/pom.xml @@ -346,6 +346,14 @@ true **/WEB-INF **/WEB-INF,**/resources + + + ../config/sql/ + + cskefu-MySQL-slim.sql + + + 2.1.1 From f1651183d7778c76663e25846d3a4f7973e7bb5c Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sat, 29 Sep 2018 19:52:49 +0800 Subject: [PATCH 06/54] #91 set hazelcast-all as provided --- contact-center/app/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contact-center/app/pom.xml b/contact-center/app/pom.xml index 11f6de78..afe87b15 100644 --- a/contact-center/app/pom.xml +++ b/contact-center/app/pom.xml @@ -159,9 +159,9 @@ com.hazelcast - hazelcast - 3.8 - + hazelcast-all + 3.10.5 + provided org.quartz-scheduler From ea2e6af67cdd62e5596f23a528fe475a91a95f41 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sat, 29 Sep 2018 20:00:36 +0800 Subject: [PATCH 07/54] #91 copy the original war --- contact-center/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contact-center/Dockerfile b/contact-center/Dockerfile index d006d099..8a50c559 100644 --- a/contact-center/Dockerfile +++ b/contact-center/Dockerfile @@ -29,7 +29,7 @@ COPY app /app WORKDIR /app RUN mvn clean package && \ rm -rf /opt/apache-tomcat/webapps/ROOT && \ - cp target/contact-center-3.9.0.war /opt/apache-tomcat/webapps/ROOT.war && \ + cp target/contact-center-*.war.original /opt/apache-tomcat/webapps/ROOT.war && \ rm -rf /app && \ rm -rf /root/.m2 From 24ccd8a67e942407d78b6d2e94022ddde3469803 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sat, 29 Sep 2018 20:20:07 +0800 Subject: [PATCH 08/54] #91 refine cluster group name [skip ci] --- contact-center/app/src/main/resources/config/hazelcast.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contact-center/app/src/main/resources/config/hazelcast.xml b/contact-center/app/src/main/resources/config/hazelcast.xml index e7cfeed2..af2e0778 100644 --- a/contact-center/app/src/main/resources/config/hazelcast.xml +++ b/contact-center/app/src/main/resources/config/hazelcast.xml @@ -24,7 +24,7 @@ xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - CSKeFu_U0C + CSKeFu_IMDG CSKeFu-1234567890 From 43a0158bef9eb73618a602e13d909cf5ebf212bd Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sun, 30 Sep 2018 00:05:47 +0800 Subject: [PATCH 09/54] =?UTF-8?q?#89=20=E4=BC=98=E5=8C=96testclient?= =?UTF-8?q?=EF=BC=8C=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/static/testclient.html | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/contact-center/app/src/main/resources/static/testclient.html b/contact-center/app/src/main/resources/static/testclient.html index 5d91cdae..f00a4a64 100644 --- a/contact-center/app/src/main/resources/static/testclient.html +++ b/contact-center/app/src/main/resources/static/testclient.html @@ -10,13 +10,40 @@ 春松客服 - + +

春松客服演示客户端

-详细文档 +

设置网站渠道

+以管理员身份 登录,导航【系统-客服接入-网站列表-创建新网站】,按照如下内容设置网站渠道。 + + + + + + + + + + + + + + + + + +
设置描述
网站名称localhost任意字符串
网站地址localhost网站的域名或IP,端口选填,比如 localhost:8080
+ +然后,刷新本页面,就可以在右下角看到【在线客服】聊天控件,通过详细文档进一步了解在任意网站集成客服控件的方法。 From 73d18ce2cd01206dc8629279356ae69a48188f8c Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sun, 30 Sep 2018 10:48:43 +0800 Subject: [PATCH 10/54] =?UTF-8?q?Closed=20#95=20=E4=B8=8D=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E6=83=85=E5=86=B5=E4=B8=8B=E8=AE=BF=E9=97=AEhealth?= =?UTF-8?q?=E5=92=8Cmetrics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatopera/cc/app/config/WebSecurityConfig.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/config/WebSecurityConfig.java b/contact-center/app/src/main/java/com/chatopera/cc/app/config/WebSecurityConfig.java index 488c6301..cc2e6186 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/config/WebSecurityConfig.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/config/WebSecurityConfig.java @@ -57,14 +57,18 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { RequestMatcher beans = new AntPathRequestMatcher("/beans/**"); RequestMatcher dump = new AntPathRequestMatcher("/dump/**"); RequestMatcher env = new AntPathRequestMatcher("/env/**"); - RequestMatcher health = new AntPathRequestMatcher("/health/**"); RequestMatcher info = new AntPathRequestMatcher("/info/**"); RequestMatcher mappings = new AntPathRequestMatcher("/mappings/**"); - RequestMatcher metrics = new AntPathRequestMatcher("/metrics/**"); RequestMatcher trace = new AntPathRequestMatcher("/trace/**"); RequestMatcher druid = new AntPathRequestMatcher("/druid/**"); - - return new DelegateRequestMatchingFilter(autconfig , configprops , beans , dump , env , health , info , mappings , metrics , trace, druid); + + /** + * Bypass actuator api + */ +// RequestMatcher health = new AntPathRequestMatcher("/health/**"); +// RequestMatcher metrics = new AntPathRequestMatcher("/metrics/**"); +// return new DelegateRequestMatchingFilter(autconfig , configprops , beans , dump , env , health , info , mappings , metrics , trace, druid); + return new DelegateRequestMatchingFilter(autconfig , configprops , beans , dump , env , mappings , trace, druid); } @Bean From 35a459bd3f3410b36140f504fd892ab39f2d4fab Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Mon, 1 Oct 2018 15:06:41 +0800 Subject: [PATCH 11/54] #91 fix docker build err --- contact-center/.dockerignore | 2 ++ contact-center/Dockerfile | 1 + 2 files changed, 3 insertions(+) diff --git a/contact-center/.dockerignore b/contact-center/.dockerignore index e69de29b..4ea25216 100644 --- a/contact-center/.dockerignore +++ b/contact-center/.dockerignore @@ -0,0 +1,2 @@ +./app/target/ +./logs/ diff --git a/contact-center/Dockerfile b/contact-center/Dockerfile index 8a50c559..16410c0f 100644 --- a/contact-center/Dockerfile +++ b/contact-center/Dockerfile @@ -26,6 +26,7 @@ RUN /bin/bash -c "mkdir -p /{data,logs}" # build WAR COPY _m2/settings.xml /root/.m2/settings.xml COPY app /app +COPY config /config WORKDIR /app RUN mvn clean package && \ rm -rf /opt/apache-tomcat/webapps/ROOT && \ From 3b664299a1c25d167b0781dd984a4e4900f65afb Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sat, 6 Oct 2018 08:42:43 +0800 Subject: [PATCH 12/54] #89 update doc [skip ci] --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 9dcc7782..00741422 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ ## 产品演示 +* 坐席工作台 + [http://cc.chatopera.com/](http://cc.chatopera.com/) @@ -42,6 +44,10 @@ | admin | admin1234 | +* 网页端访客程序 + +[http://cc.chatopera.com/testclient.html](http://cc.chatopera.com/testclient.html) + ## 功能 * 账号及组织机构管理:按组织、角色分配账号权限 From 409d9be2086b1fa3a86b5765f52051fd4a633a63 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Tue, 16 Oct 2018 17:03:52 +0800 Subject: [PATCH 13/54] =?UTF-8?q?#98=20=E6=94=AF=E6=8C=81=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E7=BD=91=E7=AB=99=E6=B8=A0=E9=81=93=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatopera/cc/app/handler/admin/channel/WebIMController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java index 6ccc30ce..77483af0 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java @@ -88,7 +88,7 @@ public class WebIMController extends Handler { map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(snsid, super.getOrgi(request))) ; } - return request(super.createAdminTempletResponse("/admin/app/index")); + return request(super.createAdminTempletResponse("/admin/webim/index")); } @RequestMapping("/save") From 7c32b38f4212af84b95eea5774ec682b06d36036 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Tue, 16 Oct 2018 18:03:03 +0800 Subject: [PATCH 14/54] =?UTF-8?q?Closed=20#98=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E6=B8=A0=E9=81=93=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/channel/WebIMController.java | 512 +++++++++--------- .../admin/channel/callout/index.html | 12 +- 2 files changed, 260 insertions(+), 264 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java index 77483af0..0b3f04cc 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java @@ -16,22 +16,17 @@ */ package com.chatopera.cc.app.handler.admin.channel; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import com.chatopera.cc.util.Menu; import com.chatopera.cc.app.cache.CacheHelper; import com.chatopera.cc.app.handler.Handler; import com.chatopera.cc.app.model.CousultInvite; import com.chatopera.cc.app.model.Organ; import com.chatopera.cc.app.model.OrgiSkillRel; import com.chatopera.cc.app.model.User; +import com.chatopera.cc.app.persistence.repository.*; +import com.chatopera.cc.util.Menu; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; @@ -42,274 +37,277 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; -import com.chatopera.cc.app.persistence.repository.ConsultInviteRepository; -import com.chatopera.cc.app.persistence.repository.OrganRepository; -import com.chatopera.cc.app.persistence.repository.OrgiSkillRelRepository; -import com.chatopera.cc.app.persistence.repository.SNSAccountRepository; -import com.chatopera.cc.app.persistence.repository.ServiceAiRepository; -import com.chatopera.cc.app.persistence.repository.UserRepository; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; @Controller @RequestMapping("/admin/webim") public class WebIMController extends Handler { - - @Autowired - private ConsultInviteRepository invite; - - @Autowired - private OrganRepository organRes ; - - @Autowired - private UserRepository userRes ; - - @Autowired - private ServiceAiRepository serviceAiRes ; - - @Autowired - private OrgiSkillRelRepository orgiSkillRelService; - - @Value("${web.upload-path}") + private final static Logger logger = LoggerFactory.getLogger(WebIMController.class); + + @Autowired + private ConsultInviteRepository invite; + + @Autowired + private OrganRepository organRes; + + @Autowired + private UserRepository userRes; + + @Autowired + private ServiceAiRepository serviceAiRes; + + @Autowired + private OrgiSkillRelRepository orgiSkillRelService; + + @Value("${web.upload-path}") private String path; - - @Autowired - private SNSAccountRepository snsAccountRes; + + @Autowired + private SNSAccountRepository snsAccountRes; @RequestMapping("/index") - @Menu(type = "app" , subtype = "app" , admin= true) - public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String snsid) { - - CousultInvite coultInvite = invite.findBySnsaccountidAndOrgi(snsid, super.getOrgi(request)) ; - if(coultInvite!=null){ - map.addAttribute("inviteData", coultInvite); - map.addAttribute("skillList", getOrgans(request)) ; - map.addAttribute("agentList",getUsers(request)) ; - - map.addAttribute("import", request.getServerPort()) ; - - map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(snsid, super.getOrgi(request))) ; - } + @Menu(type = "app", subtype = "app", admin = true) + public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String snsid) { + + CousultInvite coultInvite = invite.findBySnsaccountidAndOrgi(snsid, super.getOrgi(request)); + if (coultInvite != null) { + map.addAttribute("inviteData", coultInvite); + map.addAttribute("skillList", getOrgans(request)); + map.addAttribute("agentList", getUsers(request)); + + map.addAttribute("import", request.getServerPort()); + + map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(snsid, super.getOrgi(request))); + } return request(super.createAdminTempletResponse("/admin/webim/index")); } - + @RequestMapping("/save") - @Menu(type = "admin" , subtype = "app" , admin= true) - public ModelAndView save(HttpServletRequest request , @Valid CousultInvite inviteData , @RequestParam(value = "webimlogo", required = false) MultipartFile webimlogo,@RequestParam(value = "agentheadimg", required = false) MultipartFile agentheadimg) throws IOException { - if(!StringUtils.isBlank(inviteData.getSnsaccountid())){ - CousultInvite tempData = invite.findBySnsaccountidAndOrgi(inviteData.getSnsaccountid() , super.getOrgi(request)) ; - if(tempData!=null){ - tempData.setConsult_vsitorbtn_model(inviteData.getConsult_vsitorbtn_model()); - tempData.setConsult_vsitorbtn_color(inviteData.getConsult_vsitorbtn_color()); - tempData.setConsult_vsitorbtn_position(inviteData.getConsult_vsitorbtn_position()); - tempData.setConsult_vsitorbtn_content(inviteData.getConsult_vsitorbtn_content()); - tempData.setConsult_vsitorbtn_display(inviteData.getConsult_vsitorbtn_display()); - tempData.setConsult_dialog_color(inviteData.getConsult_dialog_color()); - - inviteData = tempData ; - } - }else{ - inviteData.setSnsaccountid(super.getUser(request).getId()); - } - inviteData.setOrgi(super.getOrgi(request)); - if(webimlogo!=null && webimlogo.getOriginalFilename().lastIndexOf(".") > 0){ - File logoDir = new File(path , "logo"); - if(!logoDir.exists()){ - logoDir.mkdirs() ; - } - String fileName = "logo/"+inviteData.getId()+webimlogo.getOriginalFilename().substring(webimlogo.getOriginalFilename().lastIndexOf(".")) ; - FileCopyUtils.copy(webimlogo.getBytes(), new File(path , fileName)); - inviteData.setConsult_dialog_logo(fileName); - } - if(agentheadimg!=null && agentheadimg.getOriginalFilename().lastIndexOf(".") > 0){ - File headimgDir = new File(path , "headimg"); - if(!headimgDir.exists()){ - headimgDir.mkdirs() ; - } - String fileName = "headimg/"+inviteData.getId()+agentheadimg.getOriginalFilename().substring(agentheadimg.getOriginalFilename().lastIndexOf(".")) ; - FileCopyUtils.copy(agentheadimg.getBytes(), new File(path , fileName)); - inviteData.setConsult_dialog_headimg(fileName); - } - invite.save(inviteData) ; - CacheHelper.getSystemCacheBean().put(inviteData.getSnsaccountid(), inviteData, inviteData.getOrgi()); - - return request(super.createRequestPageTempletResponse("redirect:/admin/app/index.html?snsid="+inviteData.getSnsaccountid())); + @Menu(type = "admin", subtype = "app", admin = true) + public ModelAndView save(HttpServletRequest request, @Valid CousultInvite inviteData, @RequestParam(value = "webimlogo", required = false) MultipartFile webimlogo, @RequestParam(value = "agentheadimg", required = false) MultipartFile agentheadimg) throws IOException { + if (!StringUtils.isBlank(inviteData.getSnsaccountid())) { + CousultInvite tempData = invite.findBySnsaccountidAndOrgi(inviteData.getSnsaccountid(), super.getOrgi(request)); + if (tempData != null) { + tempData.setConsult_vsitorbtn_model(inviteData.getConsult_vsitorbtn_model()); + tempData.setConsult_vsitorbtn_color(inviteData.getConsult_vsitorbtn_color()); + tempData.setConsult_vsitorbtn_position(inviteData.getConsult_vsitorbtn_position()); + tempData.setConsult_vsitorbtn_content(inviteData.getConsult_vsitorbtn_content()); + tempData.setConsult_vsitorbtn_display(inviteData.getConsult_vsitorbtn_display()); + tempData.setConsult_dialog_color(inviteData.getConsult_dialog_color()); + + inviteData = tempData; + } + } else { + inviteData.setSnsaccountid(super.getUser(request).getId()); + } + inviteData.setOrgi(super.getOrgi(request)); + if (webimlogo != null && webimlogo.getOriginalFilename().lastIndexOf(".") > 0) { + File logoDir = new File(path, "logo"); + if (!logoDir.exists()) { + logoDir.mkdirs(); + } + String fileName = "logo/" + inviteData.getId() + webimlogo.getOriginalFilename().substring(webimlogo.getOriginalFilename().lastIndexOf(".")); + FileCopyUtils.copy(webimlogo.getBytes(), new File(path, fileName)); + inviteData.setConsult_dialog_logo(fileName); + } + if (agentheadimg != null && agentheadimg.getOriginalFilename().lastIndexOf(".") > 0) { + File headimgDir = new File(path, "headimg"); + if (!headimgDir.exists()) { + headimgDir.mkdirs(); + } + String fileName = "headimg/" + inviteData.getId() + agentheadimg.getOriginalFilename().substring(agentheadimg.getOriginalFilename().lastIndexOf(".")); + FileCopyUtils.copy(agentheadimg.getBytes(), new File(path, fileName)); + inviteData.setConsult_dialog_headimg(fileName); + } + invite.save(inviteData); + CacheHelper.getSystemCacheBean().put(inviteData.getSnsaccountid(), inviteData, inviteData.getOrgi()); + return request(super.createRequestPageTempletResponse("redirect:/admin/webim/index.html?snsid=" + inviteData.getSnsaccountid())); } - + @RequestMapping("/profile") - @Menu(type = "app" , subtype = "profile" , admin= true) - public ModelAndView profile(ModelMap map , HttpServletRequest request , @Valid String snsid) { - CousultInvite coultInvite = invite.findBySnsaccountidAndOrgi(snsid, super.getOrgi(request)) ; - if(coultInvite!=null){ - map.addAttribute("inviteData", coultInvite); - } - map.addAttribute("import", request.getServerPort()) ; - map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(snsid, super.getOrgi(request))) ; - - map.put("serviceAiList",serviceAiRes.findByOrgi(super.getOrgi(request)) ) ; - return request(super.createAdminTempletResponse("/admin/app/profile")); + @Menu(type = "app", subtype = "profile", admin = true) + public ModelAndView profile(ModelMap map, HttpServletRequest request, @Valid String snsid) { + CousultInvite coultInvite = invite.findBySnsaccountidAndOrgi(snsid, super.getOrgi(request)); + if (coultInvite != null) { + map.addAttribute("inviteData", coultInvite); + } + map.addAttribute("import", request.getServerPort()); + map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(snsid, super.getOrgi(request))); + + map.put("serviceAiList", serviceAiRes.findByOrgi(super.getOrgi(request))); + return request(super.createAdminTempletResponse("/admin/webim/profile")); } - + @RequestMapping("/profile/save") - @Menu(type = "admin" , subtype = "profile" , admin= true) - public ModelAndView saveprofile(HttpServletRequest request , @Valid CousultInvite inviteData, @RequestParam(value = "dialogad", required = false) MultipartFile dialogad) throws IOException { - CousultInvite tempInviteData ; - if(inviteData!=null && !StringUtils.isBlank(inviteData.getId())){ - tempInviteData = invite.findOne(inviteData.getId()) ; - if(tempInviteData!=null){ - tempInviteData.setDialog_name(inviteData.getDialog_name()); - tempInviteData.setDialog_address(inviteData.getDialog_address()); - tempInviteData.setDialog_phone(inviteData.getDialog_phone()); - tempInviteData.setDialog_mail(inviteData.getDialog_mail()); - tempInviteData.setDialog_introduction(inviteData.getDialog_introduction()); - tempInviteData.setDialog_message(inviteData.getDialog_message()); - tempInviteData.setLeavemessage(inviteData.isLeavemessage()) ; - tempInviteData.setLvmopentype(inviteData.getLvmopentype()); - tempInviteData.setLvmname(inviteData.isLvmname()); - tempInviteData.setLvmphone(inviteData.isLvmphone()); - tempInviteData.setLvmemail(inviteData.isLvmemail()); - tempInviteData.setLvmaddress(inviteData.isLvmaddress()); - tempInviteData.setLvmqq(inviteData.isLvmqq()); - tempInviteData.setSkill(inviteData.isSkill()); - - tempInviteData.setConsult_skill_title(inviteData.getConsult_skill_title()); - tempInviteData.setConsult_skill_msg(inviteData.getConsult_skill_msg()); - tempInviteData.setConsult_skill_bottomtitle(inviteData.getConsult_skill_bottomtitle()); - tempInviteData.setConsult_skill_maxagent(inviteData.getConsult_skill_maxagent()); - tempInviteData.setConsult_skill_numbers(inviteData.getConsult_skill_numbers()); - tempInviteData.setConsult_skill_agent(inviteData.isConsult_skill_agent()); - - tempInviteData.setOnlyareaskill(inviteData.isOnlyareaskill()); - tempInviteData.setAreaskilltipmsg(inviteData.getAreaskilltipmsg()); - - tempInviteData.setConsult_info(inviteData.isConsult_info()); - tempInviteData.setConsult_info_email(inviteData.isConsult_info_email()); - tempInviteData.setConsult_info_name(inviteData.isConsult_info_name()); - tempInviteData.setConsult_info_phone(inviteData.isConsult_info_phone()); - tempInviteData.setConsult_info_resion(inviteData.isConsult_info_resion()); - tempInviteData.setConsult_info_message(inviteData.getConsult_info_message()); - tempInviteData.setConsult_info_cookies(inviteData.isConsult_info_cookies()); - - tempInviteData.setRecordhis(inviteData.isRecordhis()); - tempInviteData.setTraceuser(inviteData.isTraceuser()); - - - tempInviteData.setAi(inviteData.isAi()); - tempInviteData.setAifirst(inviteData.isAifirst()); - tempInviteData.setAimsg(inviteData.getAimsg()); - tempInviteData.setAisuccesstip(inviteData.getAisuccesstip()); - tempInviteData.setAiname(inviteData.getAiname()); - tempInviteData.setAiid(inviteData.getAiid()); - - - tempInviteData.setMaxwordsnum(inviteData.getMaxwordsnum()); - - tempInviteData.setCtrlenter(inviteData.isCtrlenter()); - - if(dialogad!=null && !StringUtils.isBlank(dialogad.getName()) && dialogad.getBytes()!=null && dialogad.getBytes().length >0){ - String fileName = "ad/"+inviteData.getId()+dialogad.getOriginalFilename().substring(dialogad.getOriginalFilename().lastIndexOf(".")) ; - File file = new File(path , fileName) ; - if(!file.getParentFile().exists()){ - file.getParentFile().mkdirs(); - } - FileCopyUtils.copy(dialogad.getBytes(), file); - tempInviteData.setDialog_ad(fileName); - } - invite.save(tempInviteData) ; - inviteData = tempInviteData ; - } - }else{ - invite.save(inviteData) ; - } - CacheHelper.getSystemCacheBean().put(inviteData.getSnsaccountid(), inviteData, inviteData.getOrgi()); - return request(super.createRequestPageTempletResponse("redirect:/admin/app/profile.html?snsid="+inviteData.getSnsaccountid())); + @Menu(type = "admin", subtype = "profile", admin = true) + public ModelAndView saveprofile(HttpServletRequest request, @Valid CousultInvite inviteData, @RequestParam(value = "dialogad", required = false) MultipartFile dialogad) throws IOException { + CousultInvite tempInviteData; + if (inviteData != null && !StringUtils.isBlank(inviteData.getId())) { + tempInviteData = invite.findOne(inviteData.getId()); + if (tempInviteData != null) { + tempInviteData.setDialog_name(inviteData.getDialog_name()); + tempInviteData.setDialog_address(inviteData.getDialog_address()); + tempInviteData.setDialog_phone(inviteData.getDialog_phone()); + tempInviteData.setDialog_mail(inviteData.getDialog_mail()); + tempInviteData.setDialog_introduction(inviteData.getDialog_introduction()); + tempInviteData.setDialog_message(inviteData.getDialog_message()); + tempInviteData.setLeavemessage(inviteData.isLeavemessage()); + tempInviteData.setLvmopentype(inviteData.getLvmopentype()); + tempInviteData.setLvmname(inviteData.isLvmname()); + tempInviteData.setLvmphone(inviteData.isLvmphone()); + tempInviteData.setLvmemail(inviteData.isLvmemail()); + tempInviteData.setLvmaddress(inviteData.isLvmaddress()); + tempInviteData.setLvmqq(inviteData.isLvmqq()); + tempInviteData.setSkill(inviteData.isSkill()); + + tempInviteData.setConsult_skill_title(inviteData.getConsult_skill_title()); + tempInviteData.setConsult_skill_msg(inviteData.getConsult_skill_msg()); + tempInviteData.setConsult_skill_bottomtitle(inviteData.getConsult_skill_bottomtitle()); + tempInviteData.setConsult_skill_maxagent(inviteData.getConsult_skill_maxagent()); + tempInviteData.setConsult_skill_numbers(inviteData.getConsult_skill_numbers()); + tempInviteData.setConsult_skill_agent(inviteData.isConsult_skill_agent()); + + tempInviteData.setOnlyareaskill(inviteData.isOnlyareaskill()); + tempInviteData.setAreaskilltipmsg(inviteData.getAreaskilltipmsg()); + + tempInviteData.setConsult_info(inviteData.isConsult_info()); + tempInviteData.setConsult_info_email(inviteData.isConsult_info_email()); + tempInviteData.setConsult_info_name(inviteData.isConsult_info_name()); + tempInviteData.setConsult_info_phone(inviteData.isConsult_info_phone()); + tempInviteData.setConsult_info_resion(inviteData.isConsult_info_resion()); + tempInviteData.setConsult_info_message(inviteData.getConsult_info_message()); + tempInviteData.setConsult_info_cookies(inviteData.isConsult_info_cookies()); + + tempInviteData.setRecordhis(inviteData.isRecordhis()); + tempInviteData.setTraceuser(inviteData.isTraceuser()); + + + tempInviteData.setAi(inviteData.isAi()); + tempInviteData.setAifirst(inviteData.isAifirst()); + tempInviteData.setAimsg(inviteData.getAimsg()); + tempInviteData.setAisuccesstip(inviteData.getAisuccesstip()); + tempInviteData.setAiname(inviteData.getAiname()); + tempInviteData.setAiid(inviteData.getAiid()); + + + tempInviteData.setMaxwordsnum(inviteData.getMaxwordsnum()); + + tempInviteData.setCtrlenter(inviteData.isCtrlenter()); + + if (dialogad != null && !StringUtils.isBlank(dialogad.getName()) && dialogad.getBytes() != null && dialogad.getBytes().length > 0) { + String fileName = "ad/" + inviteData.getId() + dialogad.getOriginalFilename().substring(dialogad.getOriginalFilename().lastIndexOf(".")); + File file = new File(path, fileName); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + FileCopyUtils.copy(dialogad.getBytes(), file); + tempInviteData.setDialog_ad(fileName); + } + invite.save(tempInviteData); + inviteData = tempInviteData; + } + } else { + invite.save(inviteData); + } + CacheHelper.getSystemCacheBean().put(inviteData.getSnsaccountid(), inviteData, inviteData.getOrgi()); + return request(super.createRequestPageTempletResponse("redirect:/admin/webim/profile.html?snsid=" + inviteData.getSnsaccountid())); } - + @RequestMapping("/invote") - @Menu(type = "app" , subtype = "invote" , admin= true) - public ModelAndView invote(ModelMap map , HttpServletRequest request , @Valid String snsid) { - CousultInvite coultInvite = invite.findBySnsaccountidAndOrgi(snsid, super.getOrgi(request)) ; - if(coultInvite!=null){ - map.addAttribute("inviteData", coultInvite); - } - map.addAttribute("import", request.getServerPort()) ; - map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(snsid, super.getOrgi(request))) ; - return request(super.createAdminTempletResponse("/admin/app/invote")); + @Menu(type = "app", subtype = "invote", admin = true) + public ModelAndView invote(ModelMap map, HttpServletRequest request, @Valid String snsid) { + CousultInvite coultInvite = invite.findBySnsaccountidAndOrgi(snsid, super.getOrgi(request)); + if (coultInvite != null) { + map.addAttribute("inviteData", coultInvite); + } + map.addAttribute("import", request.getServerPort()); + map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(snsid, super.getOrgi(request))); + return request(super.createAdminTempletResponse("/admin/webim/invote")); } - + @RequestMapping("/invote/save") - @Menu(type = "admin" , subtype = "profile" , admin= true) - public ModelAndView saveinvote(HttpServletRequest request , @Valid CousultInvite inviteData, @RequestParam(value = "invotebg", required = false) MultipartFile invotebg) throws IOException { - CousultInvite tempInviteData ; - if(inviteData!=null && !StringUtils.isBlank(inviteData.getId())){ - tempInviteData = invite.findOne(inviteData.getId()) ; - if(tempInviteData!=null){ - tempInviteData.setConsult_invite_enable(inviteData.isConsult_invite_enable()); - tempInviteData.setConsult_invite_content(inviteData.getConsult_invite_content()); - tempInviteData.setConsult_invite_accept(inviteData.getConsult_invite_accept()); - tempInviteData.setConsult_invite_later(inviteData.getConsult_invite_later()); - tempInviteData.setConsult_invite_delay(inviteData.getConsult_invite_delay()); - - tempInviteData.setConsult_invite_color(inviteData.getConsult_invite_color()); - - if(invotebg!=null && !StringUtils.isBlank(invotebg.getName()) && invotebg.getBytes()!=null && invotebg.getBytes().length >0){ - String fileName = "invote/"+inviteData.getId()+invotebg.getOriginalFilename().substring(invotebg.getOriginalFilename().lastIndexOf(".")) ; - File file = new File(path , fileName) ; - if(!file.getParentFile().exists()){ - file.getParentFile().mkdirs(); - } - FileCopyUtils.copy(invotebg.getBytes(), file); - tempInviteData.setConsult_invite_bg(fileName); - } - invite.save(tempInviteData) ; - inviteData = tempInviteData ; - } - }else{ - invite.save(inviteData) ; - } - CacheHelper.getSystemCacheBean().put(inviteData.getSnsaccountid(), inviteData, inviteData.getOrgi()); - return request(super.createRequestPageTempletResponse("redirect:/admin/app/invote.html?snsid="+inviteData.getSnsaccountid())); + @Menu(type = "admin", subtype = "profile", admin = true) + public ModelAndView saveinvote(HttpServletRequest request, @Valid CousultInvite inviteData, @RequestParam(value = "invotebg", required = false) MultipartFile invotebg) throws IOException { + CousultInvite tempInviteData; + if (inviteData != null && !StringUtils.isBlank(inviteData.getId())) { + tempInviteData = invite.findOne(inviteData.getId()); + if (tempInviteData != null) { + tempInviteData.setConsult_invite_enable(inviteData.isConsult_invite_enable()); + tempInviteData.setConsult_invite_content(inviteData.getConsult_invite_content()); + tempInviteData.setConsult_invite_accept(inviteData.getConsult_invite_accept()); + tempInviteData.setConsult_invite_later(inviteData.getConsult_invite_later()); + tempInviteData.setConsult_invite_delay(inviteData.getConsult_invite_delay()); + + tempInviteData.setConsult_invite_color(inviteData.getConsult_invite_color()); + + if (invotebg != null && !StringUtils.isBlank(invotebg.getName()) && invotebg.getBytes() != null && invotebg.getBytes().length > 0) { + String fileName = "invote/" + inviteData.getId() + invotebg.getOriginalFilename().substring(invotebg.getOriginalFilename().lastIndexOf(".")); + File file = new File(path, fileName); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + FileCopyUtils.copy(invotebg.getBytes(), file); + tempInviteData.setConsult_invite_bg(fileName); + } + invite.save(tempInviteData); + inviteData = tempInviteData; + } + } else { + invite.save(inviteData); + } + CacheHelper.getSystemCacheBean().put(inviteData.getSnsaccountid(), inviteData, inviteData.getOrgi()); + return request(super.createRequestPageTempletResponse("redirect:/admin/webim/invote.html?snsid=" + inviteData.getSnsaccountid())); } - + /** - * 获取当前产品下组织信息 - * @param request - * @return - */ - private List getOrgans(HttpServletRequest request){ - List list = null; - if(super.isTenantshare()) { - List organIdList = new ArrayList<>(); - List orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request)) ; - if(!orgiSkillRelList.isEmpty()) { - for(OrgiSkillRel rel:orgiSkillRelList) { - organIdList.add(rel.getSkillid()); - } - } - list = organRes.findAll(organIdList); - }else { - list = organRes.findByOrgiAndOrgid(super.getOrgi(request),super.getOrgid(request)) ; - } - return list; + * 获取当前产品下组织信息 + * + * @param request + * @return + */ + private List getOrgans(HttpServletRequest request) { + List list = null; + if (super.isTenantshare()) { + List organIdList = new ArrayList<>(); + List orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request)); + if (!orgiSkillRelList.isEmpty()) { + for (OrgiSkillRel rel : orgiSkillRelList) { + organIdList.add(rel.getSkillid()); + } + } + list = organRes.findAll(organIdList); + } else { + list = organRes.findByOrgiAndOrgid(super.getOrgi(request), super.getOrgid(request)); + } + return list; } - /** - * 获取当前产品下人员信息 - * @param request - * @param q - * @return - */ - private List getUsers(HttpServletRequest request){ - List userList = null; - if(super.isTenantshare()) { - List organIdList = new ArrayList<>(); - List orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request)) ; - if(!orgiSkillRelList.isEmpty()) { - for(OrgiSkillRel rel:orgiSkillRelList) { - organIdList.add(rel.getSkillid()); - } - } - userList=userRes.findByOrganInAndAgentAndDatastatus(organIdList,true,false); - }else { - userList=userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true,false) ; - } - return userList; + + /** + * 获取当前产品下人员信息 + * + * @param request + * @param q + * @return + */ + private List getUsers(HttpServletRequest request) { + List userList = null; + if (super.isTenantshare()) { + List organIdList = new ArrayList<>(); + List orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request)); + if (!orgiSkillRelList.isEmpty()) { + for (OrgiSkillRel rel : orgiSkillRelList) { + organIdList.add(rel.getSkillid()); + } + } + userList = userRes.findByOrganInAndAgentAndDatastatus(organIdList, true, false); + } else { + userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false); + } + return userList; } } \ No newline at end of file diff --git a/contact-center/app/src/main/resources/templates/admin/channel/callout/index.html b/contact-center/app/src/main/resources/templates/admin/channel/callout/index.html index 1a4bb9cd..ca7db870 100644 --- a/contact-center/app/src/main/resources/templates/admin/channel/callout/index.html +++ b/contact-center/app/src/main/resources/templates/admin/channel/callout/index.html @@ -32,17 +32,15 @@ <#list snsAccountList.content as snsAccount> - - ${snsAccount.name!''} - + ${snsAccount.name!''} ${snsAccount.baseURL!''} ${snsAccount.createtime?string("yyyy-MM-dd HH:mm:ss")} - - - 编辑 - + + + + <#if !(snsAccount.usertype?? && snsAccount.usertype == "0") && snsAccount.datastatus != true > data-confirm="请输入二次安全验证密码" title="删除语音需要进行二次密码验证,请确认是否删除?" > From d7f135f0ba7b78174969bae5d791ebfc0843d6ad Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 17 Oct 2018 10:04:08 +0800 Subject: [PATCH 15/54] #98 enhance links in web channel --- .../main/resources/templates/admin/channel/im/index.html | 8 +++++--- .../src/main/resources/templates/admin/webim/profile.html | 6 +++--- .../app/src/main/resources/templates/apps/im/text.html | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/contact-center/app/src/main/resources/templates/admin/channel/im/index.html b/contact-center/app/src/main/resources/templates/admin/channel/im/index.html index 157b4ede..37566407 100644 --- a/contact-center/app/src/main/resources/templates/admin/channel/im/index.html +++ b/contact-center/app/src/main/resources/templates/admin/channel/im/index.html @@ -33,14 +33,16 @@ <#list snsAccountList.content as snsAccount> - - ${snsAccount.name!''} - + ${snsAccount.name!''} ${snsAccount.baseURL!''} ${snsAccount.snsid!''} ${snsAccount.createtime?string("yyyy-MM-dd HH:mm:ss")} + + + 接入 + 编辑 diff --git a/contact-center/app/src/main/resources/templates/admin/webim/profile.html b/contact-center/app/src/main/resources/templates/admin/webim/profile.html index 4ddbcb2f..e3ca24c2 100644 --- a/contact-center/app/src/main/resources/templates/admin/webim/profile.html +++ b/contact-center/app/src/main/resources/templates/admin/webim/profile.html @@ -587,13 +587,13 @@ 名称:
- 地址: + 地址:
- 电话: + 电话:
- 邮件: + 邮件:
diff --git a/contact-center/app/src/main/resources/templates/apps/im/text.html b/contact-center/app/src/main/resources/templates/apps/im/text.html index 3d684b82..8f53dc3d 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/text.html +++ b/contact-center/app/src/main/resources/templates/apps/im/text.html @@ -3,9 +3,9 @@ var data ; var config = {} ; /****** id:"xxxxxxxxxxxx", - name:'UKeFu', - email:'ukefu@ukewo.cn', - phone:'18588888888' + name:'CSKefu', + email:'info@chatopera.com', + phone:'185-1935-7507' ****/ <#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}); @@ -44,4 +44,4 @@ new Fingerprint2().get(function(data, components){ ukefu.openChatDialog(); }); - \ No newline at end of file + From 1985dd3f7fe0b4f635a82daa135ae4369c90709b Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 17 Oct 2018 15:43:32 +0800 Subject: [PATCH 16/54] =?UTF-8?q?Closed=20#99=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E9=85=8D=E7=BD=AE=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chatopera/cc/app/Application.java | 76 ++++++++++++------- .../chatopera/cc/util/SystemEnvHelper.java | 32 ++++++++ .../src/main/resources/application.properties | 5 +- .../templates/apps/chatbot/edit.html | 3 +- .../main/resources/templates/apps/index.html | 2 +- 5 files changed, 84 insertions(+), 34 deletions(-) create mode 100644 contact-center/app/src/main/java/com/chatopera/cc/util/SystemEnvHelper.java diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java b/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java index 1895673f..8af3c34f 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java @@ -17,8 +17,10 @@ package com.chatopera.cc.app; import com.chatopera.cc.app.basic.MainContext; -import com.chatopera.cc.util.mobile.MobileNumberUtils; import com.chatopera.cc.app.config.StartedEventListener; +import com.chatopera.cc.util.SystemEnvHelper; +import com.chatopera.cc.util.mobile.MobileNumberUtils; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -42,8 +44,6 @@ import java.io.IOException; @EnableElasticsearchRepositories("com.chatopera.cc.app.persistence.es") @EnableAsync public class Application { - private static final Logger logger = LoggerFactory.getLogger(Application.class); - @Value("${web.upload-path}") private String uploaddir; @@ -51,57 +51,75 @@ public class Application { @Value("${spring.servlet.multipart.max-file-size}") private String multipartMaxUpload; - @Value("${spring.servlet.multipart.max-request-size}") private String multipartMaxRequest; - static{ - MainContext.model.put("contacts", true) ; - MainContext.model.put("sales", true); - MainContext.model.put("chatbot", true); + /** + * 记载模块 + */ + // 外呼模块 + private final static boolean isCalloutModule = SystemEnvHelper.parseModuleFlag("CSKEFU_MODULE_CALLOUT"); + // CRM模块 + private final static boolean isContactsModule = SystemEnvHelper.parseModuleFlag("CSKEFU_MODULE_CONTACTS"); + // 聊天机器人模块 + private final static boolean isChatbotModule = SystemEnvHelper.parseModuleFlag("CSKEFU_MODULE_CHATBOT"); + + static { + // 外呼模块 + if (isCalloutModule) { + MainContext.model.put("sales", true); + } + // CRM模块 + if (isContactsModule) { + MainContext.model.put("contacts", true); + } + // 聊天机器人模块 + if (isChatbotModule) { + MainContext.model.put("chatbot", true); + } } /** * Init local resources */ - protected static void init(){ + protected static void init() { try { - logger.info("init mobile number utils ..."); + System.out.println("init mobile number utils ..."); MobileNumberUtils.init(); } catch (IOException e) { - logger.error("init error ", e); + e.printStackTrace(); System.exit(1); } } - @Bean - public MultipartConfigElement multipartConfigElement() { - MultipartConfigFactory factory = new MultipartConfigFactory(); - factory.setMaxFileSize(multipartMaxUpload); //KB,MB - factory.setMaxRequestSize(multipartMaxRequest); - factory.setLocation(uploaddir); - return factory.createMultipartConfig(); - } - + @Bean + public MultipartConfigElement multipartConfigElement() { + MultipartConfigFactory factory = new MultipartConfigFactory(); + factory.setMaxFileSize(multipartMaxUpload); //KB,MB + factory.setMaxRequestSize(multipartMaxRequest); + factory.setLocation(uploaddir); + return factory.createMultipartConfig(); + } + @Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { - ErrorPage error = new ErrorPage("/error.html"); - container.addErrorPages(error); + ErrorPage error = new ErrorPage("/error.html"); + container.addErrorPages(error); } }; } - - public static void main(String[] args) { + + public static void main(String[] args) { Application.init(); - SpringApplication app = new SpringApplication(Application.class) ; - app.setBannerMode(Banner.Mode.CONSOLE); + SpringApplication app = new SpringApplication(Application.class); + app.setBannerMode(Banner.Mode.CONSOLE); app.setAddCommandLineProperties(false); - app.addListeners(new StartedEventListener()); - MainContext.setApplicationContext(app.run(args)); - } + app.addListeners(new StartedEventListener()); + MainContext.setApplicationContext(app.run(args)); + } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/SystemEnvHelper.java b/contact-center/app/src/main/java/com/chatopera/cc/util/SystemEnvHelper.java new file mode 100644 index 00000000..bd29f142 --- /dev/null +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/SystemEnvHelper.java @@ -0,0 +1,32 @@ +/* + * 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.util; + +import org.apache.commons.lang.StringUtils; + +public class SystemEnvHelper { + + /** + * 分析是否加载模块,在变量为不存在或变量值为true的情况下加载 + * 也就是说,该变量值不为空或为true时时加载 + * @param environmentVariable + * @return + */ + public static boolean parseModuleFlag(final String environmentVariable){ + String val = System.getenv(environmentVariable); + return StringUtils.isBlank(val) || StringUtils.equalsIgnoreCase(val, "true"); + } +} diff --git a/contact-center/app/src/main/resources/application.properties b/contact-center/app/src/main/resources/application.properties index 1f73bf55..5af82aae 100644 --- a/contact-center/app/src/main/resources/application.properties +++ b/contact-center/app/src/main/resources/application.properties @@ -15,10 +15,9 @@ # https://docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/htmlsingle/ # https://stackoverflow.com/questions/35531661/using-env-variable-in-spring-boots-application-properties - # 证书相关信息 -license.client.id=bxzq -application.version=1.0.0 +license.client.id=cskefu +application.version=3.9.0 # security management.security.enabled=false diff --git a/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html b/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html index adbe5be2..0fac1877 100644 --- a/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html +++ b/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html @@ -30,9 +30,10 @@
- disabled>
+
diff --git a/contact-center/app/src/main/resources/templates/apps/index.html b/contact-center/app/src/main/resources/templates/apps/index.html index b821d1f6..f0465ae8 100644 --- a/contact-center/app/src/main/resources/templates/apps/index.html +++ b/contact-center/app/src/main/resources/templates/apps/index.html @@ -317,7 +317,7 @@ - <#if models?? && models["sales"]?? && models["sales"] == true> + <#if models?? && models["chatbot"]?? && models["chatbot"] == true> <#if user?? &&( user.roleAuthMap["A09"]?? || user.usertype == "0") >
From 557607b06a1d264ec34e2837f5812c5ec81fefbc Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 17 Oct 2018 17:05:00 +0800 Subject: [PATCH 17/54] =?UTF-8?q?#90=20=E5=A2=9E=E5=8A=A0=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/apps/chatbot/edit.html | 13 ++++++++++--- .../resources/templates/apps/chatbot/index.html | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html b/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html index 0fac1877..12a52047 100644 --- a/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html +++ b/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html @@ -116,7 +116,7 @@ if (data.rc == 0) { cb(null, data.data); } else { - cb(data.error); + cb(data.data); } }) .fail(function (jqXHR, textStatus) { @@ -129,10 +129,17 @@ var form = layui.form(); form.on('submit(save)', function (data) { var field = data.field; - var submitFinish = function (err, bot) { if (err) { - console.error(err); + layer.confirm(err.data||err.error, { + btn: ['关闭'], + icon: 2, + title: '提示' + }, function (popup, layero) { + layer.close(popup) + }, function (popup) { + // 取消方法 + }); } else { layer.open({ title: '提示' diff --git a/contact-center/app/src/main/resources/templates/apps/chatbot/index.html b/contact-center/app/src/main/resources/templates/apps/chatbot/index.html index 8b67d65b..dcbbe354 100644 --- a/contact-center/app/src/main/resources/templates/apps/chatbot/index.html +++ b/contact-center/app/src/main/resources/templates/apps/chatbot/index.html @@ -68,7 +68,7 @@ if (data.rc == 0) { resolve(data.data); } else { - reject(data.error); + reject(data); } }) .fail(function (jqXHR, textStatus) { @@ -107,7 +107,18 @@ var isEnabled = $(''); isEnabled.change(function () { - change(r.id, $(this).find('input').prop('checked')); + change(r.id, $(this).find('input').prop('checked')) + .then(null, function(err){ + layer.confirm(err.data||err.error, { + btn: ['关闭'], + icon: 2, + title: '提示' + }, function (index, layero) { + layer.close(index) + }, function (index) { + // 取消方法 + }); + }); }) var rows = [ @@ -146,7 +157,7 @@ } function init() { - query(1, 10); + query(1, 50); } layui.use(['form'], function () { From c6f55b8f42d969104f0f65df93154e7ed5bf69fe Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 17 Oct 2018 18:32:26 +0800 Subject: [PATCH 18/54] #88 fix nickname for mobile web page --- .../app/handler/apps/internet/IMController.java | 2 ++ .../cc/app/im/handler/IMEventHandler.java | 4 ++-- .../com/chatopera/cc/util/OnlineUserUtils.java | 2 ++ .../templates/apps/im/chatbot/index.html | 8 ++++---- .../templates/apps/im/chatbot/mobile.html | 16 +++++++++------- .../main/resources/templates/apps/im/index.html | 2 +- .../main/resources/templates/apps/im/mobile.html | 8 ++++---- 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java index ac7fd2ab..b9df9f4f 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java @@ -344,6 +344,7 @@ public class IMController extends Handler { @Valid String purl) throws Exception { ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/index")); BlackEntity black = (BlackEntity) CacheHelper.getSystemCacheBean().getCacheObject(userid, MainContext.SYSTEM_ORGI); + logger.info("index userId {}", userid); if (StringUtils.isNotBlank(appid) && (black == null || (black.getEndtime() != null && black.getEndtime().before(new Date())))) { CousultInvite invite = OnlineUserUtils.cousult(appid, orgi, inviteRepository); String userID = null; @@ -353,6 +354,7 @@ public class IMController extends Handler { userID = MainUtils.genIDByKey(sessionid); } String nickname = "Guest_" + userID; + logger.info("nick name {}", nickname); boolean consult = true; //是否已收集用户信息 SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(orgi); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java index 0e57e0f8..46dc9391 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java @@ -68,7 +68,7 @@ public class IMEventHandler { String nickname = client.getHandshakeData().getSingleUrlParam("nickname"); - if (!StringUtils.isBlank(user)) { + if (StringUtils.isNotBlank(user)) { /** * 用户进入到对话连接 , 排队用户请求 , 如果返回失败,表示当前坐席全忙,用户进入排队状态,当前提示信息 显示 当前排队的队列位置,不可进行对话,用户发送的消息作为留言处理 */ @@ -80,7 +80,7 @@ public class IMEventHandler { // */ NettyClients.getInstance().putIMEventClient(user, client); // - if (newRequestMessage != null && !StringUtils.isBlank(newRequestMessage.getMessage())) { + if (newRequestMessage != null && StringUtils.isNotBlank(newRequestMessage.getMessage())) { MessageOutContent outMessage = new MessageOutContent(); outMessage.setMessage(newRequestMessage.getMessage()); outMessage.setMessageType(MainContext.MessageTypeEnum.MESSAGE.toString()); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/OnlineUserUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/util/OnlineUserUtils.java index 23669882..f3ac8c73 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/OnlineUserUtils.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/OnlineUserUtils.java @@ -908,6 +908,8 @@ public class OnlineUserUtils { if (!StringUtils.isBlank(ip)) { ipdata = IPTools.getInstance().findGeography(ip); } + + logger.info("set new Request message nickname {}", nickname); if (StringUtils.isBlank(nickname)) { nickname = "Guest_" + userid; } diff --git a/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html b/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html index 2c1a5fc4..381d5cd4 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html +++ b/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html @@ -269,9 +269,9 @@ <#if !exchange?? || exchange == "true">
  • 人工坐席
  • -
  • 智能坐席
  • +
  • 智能客服
  • <#else> -
  • 智能坐席
  • +
  • 智能客服
  • @@ -312,7 +312,7 @@
    - +
    @@ -498,7 +498,7 @@ chat = "" ; } if(data.calltype == "呼入"){ - output('
    '+chat+'
    ' , "chat-block"); + output('
    '+chat+'
    ' , "chat-block"); }else if(data.calltype == "呼出"){ output('
    '+chat+'
    ' , "chat-block"); R3Ajax.audioplayer('audioplane', newmessage, false); // 播放 diff --git a/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html b/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html index 9f749aab..ab82f67b 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html +++ b/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html @@ -174,12 +174,14 @@
      - <#if models?? && models["chatbot"]?? && models["chatbot"] == true && inviteData.ai?? && inviteData.ai == true && aiid??> -
    • 智能客服
    • -
    • 人工坐席
    • + <#if models?? && models["chatbot"]?? && models["chatbot"] == true && inviteData.ai && aiid??> + <#if !exchange?? || exchange == "true"> +
    • 人工坐席
    • + +
    • 智能客服
    • <#else> -
    • 人工坐席
    • - +
    • 智能客服
    • +
    @@ -308,9 +310,9 @@ drawCanvasImage(data.attachmentid) ; } if(data.calltype == "呼入"){ - output('
    '+chat+'
    ' , "chat-block"); + output('
    '+chat+'
    ' , "chat-block"); }else if(data.calltype == "呼出"){ - output('
    '+chat+'
    ' , "chat-block"); + output('
    '+chat+'
    ' , "chat-block"); } }); diff --git a/contact-center/app/src/main/resources/templates/apps/im/index.html b/contact-center/app/src/main/resources/templates/apps/im/index.html index 5f7f611e..cd1b0b11 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/index.html +++ b/contact-center/app/src/main/resources/templates/apps/im/index.html @@ -311,7 +311,7 @@
    - +
    diff --git a/contact-center/app/src/main/resources/templates/apps/im/mobile.html b/contact-center/app/src/main/resources/templates/apps/im/mobile.html index b4e1b1ae..12efd967 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/mobile.html +++ b/contact-center/app/src/main/resources/templates/apps/im/mobile.html @@ -174,7 +174,7 @@
      - <#if models?? && models["xiaoe"]?? && models["xiaoe"] == true && inviteData.ai?? && inviteData.ai == true && aiid??> + <#if models?? && models["chatbot"]?? && models["chatbot"] == true && inviteData.ai?? && inviteData.ai == true && aiid??>
    • 智能客服
    • 人工坐席
    • <#else> @@ -223,8 +223,8 @@ src="<#if inviteData?? && inviteData.consult_dialog_headimg??>/res/image.html?id=${inviteData.consult_dialog_headimg?url}<#else>/images/agent.png" alt="">
      - + +
      @@ -281,7 +281,7 @@ // 参数连接 var hostname = location.hostname ; var protocol = window.location.protocol.replace(/:/g,''); - var socket = io.connect(protocol + '://'+hostname+':${port}/im/user?userid=${userid!''}<#if aiid??>&aiid=${aiid}&orgi=${orgi!''}&session=${sessionid!''}&appid=${appid!''}&osname=${(osname!'')?url}&browser=${(browser!'')?url}<#if skill??>&skill=${skill}<#if agent??>&agent=${agent}'); + var socket = io.connect(protocol + '://'+hostname+':${port}/im/user?userid=${userid!''}<#if aiid??>&aiid=${aiid}&orgi=${orgi!''}&session=${sessionid!''}&appid=${appid!''}&osname=${(osname!'')?url}&browser=${(browser!'')?url}<#if skill??>&skill=${skill}<#if username??>&nickname=${username}<#if agent??>&agent=${agent}'); socket.on('connect',function(){ //service.sendRequestMessage(); //output(''+ new Date().format("yyyy-MM-dd hh:mm:ss") + ' 开始沟通' +'' , 'message callOutConnect-message'); From b49df28e69346cb2cace819ea9ef0bdbe5aac7c4 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 17 Oct 2018 18:45:36 +0800 Subject: [PATCH 19/54] =?UTF-8?q?#71=20=E6=94=AF=E6=8C=81=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=97=AE=E5=80=99=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/chatopera/cc/app/model/Chatbot.java | 2 +- .../src/main/resources/templates/apps/chatbot/edit.html | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/model/Chatbot.java b/contact-center/app/src/main/java/com/chatopera/cc/app/model/Chatbot.java index 81f7ef5d..2873239d 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/model/Chatbot.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/model/Chatbot.java @@ -37,7 +37,7 @@ public class Chatbot { private String description; private String primaryLanguage; private String fallback; - private String welcome; + private String welcome; // 问候语 private String baseUrl; // 智能问答引擎服务地址 private String orgi; // 租户标识 private String organ; // 组织机构 diff --git a/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html b/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html index 12a52047..c9bf0cd0 100644 --- a/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html +++ b/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html @@ -51,6 +51,13 @@
    +
    + +
    + +
    +
    From 13623ec2657a975caddd84a12080a4b89ef0891a Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 18 Oct 2018 17:05:02 +0800 Subject: [PATCH 20/54] =?UTF-8?q?Closed=20#100=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=B4=A6=E5=8F=B7bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chatopera/cc/app/Application.java | 7 +- .../chatopera/cc/app/basic/MainContext.java | 12 +- .../handler/admin/users/UsersController.java | 393 +++++++++--------- .../java/com/chatopera/cc/util/Constants.java | 8 + 4 files changed, 227 insertions(+), 193 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java b/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java index 8af3c34f..60e6e8f0 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java @@ -18,6 +18,7 @@ package com.chatopera.cc.app; import com.chatopera.cc.app.basic.MainContext; import com.chatopera.cc.app.config.StartedEventListener; +import com.chatopera.cc.util.Constants; import com.chatopera.cc.util.SystemEnvHelper; import com.chatopera.cc.util.mobile.MobileNumberUtils; import org.apache.commons.lang.StringUtils; @@ -67,15 +68,15 @@ public class Application { static { // 外呼模块 if (isCalloutModule) { - MainContext.model.put("sales", true); + MainContext.model.put(Constants.CSKEFU_MODULE_CALLOUT, true); } // CRM模块 if (isContactsModule) { - MainContext.model.put("contacts", true); + MainContext.model.put(Constants.CSKEFU_MODULE_CONTACTS, true); } // 聊天机器人模块 if (isChatbotModule) { - MainContext.model.put("chatbot", true); + MainContext.model.put(Constants.CSKEFU_MODULE_CHATBOT, true); } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/basic/MainContext.java b/contact-center/app/src/main/java/com/chatopera/cc/app/basic/MainContext.java index d55b1023..0ba913af 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/basic/MainContext.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/basic/MainContext.java @@ -17,6 +17,7 @@ package com.chatopera.cc.app.basic; +import com.chatopera.cc.util.Constants; import com.chatopera.cc.util.DateConverter; import com.chatopera.cc.app.basic.resource.ActivityResource; import com.chatopera.cc.app.basic.resource.BatchResource; @@ -409,7 +410,7 @@ public class MainContext { return this.name; } - public int getIndex(){ + public int getIndex() { return this.index; } } @@ -986,4 +987,13 @@ public class MainContext { public static Class getResource(String resource) { return uKeFuResourceMap.get(resource); } + + /** + * 是否开启外呼模块 + * @return + */ + public static boolean isEnableCalloutModule() { + return model.containsKey(Constants.CSKEFU_MODULE_CALLOUT) && (model.get(Constants.CSKEFU_MODULE_CALLOUT).equals(true)); + } + } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/users/UsersController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/users/UsersController.java index 57ad6a87..79af083a 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/users/UsersController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/users/UsersController.java @@ -16,20 +16,21 @@ */ package com.chatopera.cc.app.handler.admin.users; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Date; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - import com.chatopera.cc.app.algorithm.AutomaticServiceDist; import com.chatopera.cc.app.basic.MainContext; +import com.chatopera.cc.app.basic.MainUtils; import com.chatopera.cc.app.cache.CacheHelper; -import com.chatopera.cc.app.persistence.repository.UserRoleRepository; +import com.chatopera.cc.app.handler.Handler; import com.chatopera.cc.app.model.AgentStatus; +import com.chatopera.cc.app.model.User; +import com.chatopera.cc.app.model.UserRole; +import com.chatopera.cc.app.persistence.repository.UserRepository; +import com.chatopera.cc.app.persistence.repository.UserRoleRepository; +import com.chatopera.cc.util.Menu; +import com.chatopera.cc.util.OnlineUserUtils; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; @@ -38,211 +39,225 @@ import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; -import com.chatopera.cc.util.Menu; -import com.chatopera.cc.app.basic.MainUtils; -import com.chatopera.cc.app.persistence.repository.UserRepository; -import com.chatopera.cc.util.OnlineUserUtils; -import com.chatopera.cc.app.handler.Handler; -import com.chatopera.cc.app.model.User; -import com.chatopera.cc.app.model.UserRole; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Date; +import java.util.List; /** - * * @author 程序猿DD * @version 1.0.0 * @blog http://blog.didispace.com - * */ @Controller @RequestMapping("/admin/user") -public class UsersController extends Handler{ +public class UsersController extends Handler { + private final static Logger logger = LoggerFactory.getLogger(UsersController.class); - @Autowired - private UserRepository userRepository; - - @Autowired - private UserRoleRepository userRoleRes; + @Autowired + private UserRepository userRepository; + + @Autowired + private UserRoleRepository userRoleRes; @RequestMapping("/index") - @Menu(type = "admin" , subtype = "user") - public ModelAndView index(ModelMap map , HttpServletRequest request) throws FileNotFoundException, IOException { - map.addAttribute( - "userList", - userRepository.findByDatastatusAndOrgiAndOrgid( - false, - super.getOrgiByTenantshare(request), - super.getOrgid(request), - new PageRequest( - super.getP(request), - super.getPs(request), - Sort.Direction.ASC, - "createtime" - ) - ) - ); - return request(super.createAdminTempletResponse("/admin/user/index")); + @Menu(type = "admin", subtype = "user") + public ModelAndView index(ModelMap map, HttpServletRequest request) throws FileNotFoundException, IOException { + map.addAttribute( + "userList", + userRepository.findByDatastatusAndOrgiAndOrgid( + false, + super.getOrgiByTenantshare(request), + super.getOrgid(request), + new PageRequest( + super.getP(request), + super.getPs(request), + Sort.Direction.ASC, + "createtime" + ) + ) + ); + return request(super.createAdminTempletResponse("/admin/user/index")); } - + @RequestMapping("/add") - @Menu(type = "admin" , subtype = "user") - public ModelAndView add(ModelMap map , HttpServletRequest request) { + @Menu(type = "admin", subtype = "user") + public ModelAndView add(ModelMap map, HttpServletRequest request) { return request(super.createRequestPageTempletResponse("/admin/user/add")); } - + @RequestMapping("/save") - @Menu(type = "admin" , subtype = "user") - public ModelAndView save(HttpServletRequest request ,@Valid User user) { - String msg = "" ; - msg = validUser(user); - if(!StringUtils.isBlank(msg)){ - return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg="+msg)); - }else{ - if(request.getParameter("admin")!=null){ - user.setUsertype("0"); - }else{ - user.setUsertype(null); - } - if(!StringUtils.isBlank(user.getPassword())){ - user.setPassword(MainUtils.md5(user.getPassword())); - } - - user.setOrgi(super.getOrgiByTenantshare(request)); - if(!StringUtils.isBlank(super.getUser(request).getOrgid())) { - user.setOrgid(super.getUser(request).getOrgid()); - }else { - user.setOrgid(MainContext.SYSTEM_ORGI); - } - userRepository.save(user) ; - OnlineUserUtils.clean(super.getOrgi(request)); - } - return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg="+msg)); + @Menu(type = "admin", subtype = "user") + public ModelAndView save(HttpServletRequest request, @Valid User user) { + String msg = ""; + msg = validUser(user); + if (!StringUtils.isBlank(msg)) { + return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg=" + msg)); + } else { + if (request.getParameter("admin") != null) { + user.setUsertype("0"); + } else { + user.setUsertype(null); + } + if (!StringUtils.isBlank(user.getPassword())) { + user.setPassword(MainUtils.md5(user.getPassword())); + } + + user.setOrgi(super.getOrgiByTenantshare(request)); + if (!StringUtils.isBlank(super.getUser(request).getOrgid())) { + user.setOrgid(super.getUser(request).getOrgid()); + } else { + user.setOrgid(MainContext.SYSTEM_ORGI); + } + userRepository.save(user); + OnlineUserUtils.clean(super.getOrgi(request)); + } + return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg=" + msg)); } - + private String validUser(User user) { - String msg = ""; - User tempUser = userRepository.findByUsernameAndDatastatus(user.getUsername(),false) ; - if(tempUser!=null) { - msg = "username_exist"; - return msg; - } - tempUser = userRepository.findByEmailAndDatastatus(user.getEmail(),false) ; - if(tempUser!=null) { - msg = "email_exist"; - return msg; - } - tempUser = userRepository.findByMobileAndDatastatus(user.getMobile(),false) ; - if(tempUser!=null) { - msg = "mobile_exist"; - return msg; - } - List tempUserList = userRepository.findBySipaccountAndDatastatus(user.getSipaccount(),false) ; - if(tempUserList.size()!=0&&user.getSipaccount()!="") { - msg = "sip_account_exist"; - return msg; - } - return msg; + String msg = ""; + User tempUser = userRepository.findByUsernameAndDatastatus(user.getUsername(), false); + if (tempUser != null) { + msg = "username_exist"; + return msg; + } + tempUser = userRepository.findByEmailAndDatastatus(user.getEmail(), false); + if (tempUser != null) { + msg = "email_exist"; + return msg; + } + tempUser = userRepository.findByMobileAndDatastatus(user.getMobile(), false); + if (tempUser != null) { + msg = "mobile_exist"; + return msg; + } + + if (!validUserCallcenterParams(user)) { + msg = "sip_account_exist"; + return msg; + } + return msg; } - + @RequestMapping("/edit") - @Menu(type = "admin" , subtype = "user") - public ModelAndView edit(ModelMap map ,HttpServletRequest request , @Valid String id) { - ModelAndView view = request(super.createRequestPageTempletResponse("/admin/user/edit")) ; - view.addObject("userData", userRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request))) ; + @Menu(type = "admin", subtype = "user") + public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) { + ModelAndView view = request(super.createRequestPageTempletResponse("/admin/user/edit")); + view.addObject("userData", userRepository.findByIdAndOrgi(id, super.getOrgiByTenantshare(request))); return view; } - + @RequestMapping("/update") - @Menu(type = "admin" , subtype = "user" , admin = true) - public ModelAndView update(HttpServletRequest request ,@Valid User user) { - User tempUser = userRepository.getOne(user.getId()) ; - if(tempUser != null){ - String msg = validUserUpdate(user,tempUser); - if(!StringUtils.isBlank(msg)){ - return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg="+msg)); - } - tempUser.setUname(user.getUname()); - tempUser.setUsername(user.getUsername()); - tempUser.setEmail(user.getEmail()); - tempUser.setMobile(user.getMobile()); - tempUser.setSipaccount(user.getSipaccount()); - //切换成非坐席 判断是否坐席 以及 是否有对话 - if(!user.isAgent()) { - AgentStatus agentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject((super.getUser(request)).getId(), super.getOrgi(request)); - if(!(agentStatus==null && AutomaticServiceDist.getAgentUsers(super.getUser(request).getId(), super.getOrgi(request))==0)) { - return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg=t1")); - } - } - tempUser.setAgent(user.isAgent()); - - tempUser.setOrgi(super.getOrgiByTenantshare(request)); - - if(!StringUtils.isBlank(super.getUser(request).getOrgid())) { - tempUser.setOrgid(super.getUser(request).getOrgid()); - }else { - tempUser.setOrgid(MainContext.SYSTEM_ORGI); - } - - tempUser.setCallcenter(user.isCallcenter()); - if(!StringUtils.isBlank(user.getPassword())){ - tempUser.setPassword(MainUtils.md5(user.getPassword())); - } - - if(request.getParameter("admin")!=null){ - tempUser.setUsertype("0"); - }else{ - tempUser.setUsertype(null); - } - - if(tempUser.getCreatetime() == null){ - tempUser.setCreatetime(new Date()); - } - tempUser.setUpdatetime(new Date()); - userRepository.save(tempUser) ; - OnlineUserUtils.clean(super.getOrgi(request)); - } - return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html")); + @Menu(type = "admin", subtype = "user", admin = true) + public ModelAndView update(HttpServletRequest request, @Valid User user) { + User tempUser = userRepository.getOne(user.getId()); + if (tempUser != null) { + String msg = validUserUpdate(user, tempUser); + if (!StringUtils.isBlank(msg)) { + return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg=" + msg)); + } + tempUser.setUname(user.getUname()); + tempUser.setUsername(user.getUsername()); + tempUser.setEmail(user.getEmail()); + tempUser.setMobile(user.getMobile()); + tempUser.setSipaccount(user.getSipaccount()); + //切换成非坐席 判断是否坐席 以及 是否有对话 + if (!user.isAgent()) { + AgentStatus agentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject((super.getUser(request)).getId(), super.getOrgi(request)); + if (!(agentStatus == null && AutomaticServiceDist.getAgentUsers(super.getUser(request).getId(), super.getOrgi(request)) == 0)) { + return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg=t1")); + } + } + tempUser.setAgent(user.isAgent()); + + tempUser.setOrgi(super.getOrgiByTenantshare(request)); + + if (!StringUtils.isBlank(super.getUser(request).getOrgid())) { + tempUser.setOrgid(super.getUser(request).getOrgid()); + } else { + tempUser.setOrgid(MainContext.SYSTEM_ORGI); + } + + tempUser.setCallcenter(user.isCallcenter()); + if (!StringUtils.isBlank(user.getPassword())) { + tempUser.setPassword(MainUtils.md5(user.getPassword())); + } + + if (request.getParameter("admin") != null) { + tempUser.setUsertype("0"); + } else { + tempUser.setUsertype(null); + } + + if (tempUser.getCreatetime() == null) { + tempUser.setCreatetime(new Date()); + } + tempUser.setUpdatetime(new Date()); + userRepository.save(tempUser); + OnlineUserUtils.clean(super.getOrgi(request)); + } + return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html")); } - - private String validUserUpdate(User user,User oldUser) { - String msg = ""; - User tempUser = userRepository.findByUsernameAndDatastatus(user.getUsername(),false) ; - if(tempUser!=null&&!user.getUsername().equals(oldUser.getUsername())) { - msg = "username_exist"; - return msg; - } - tempUser = userRepository.findByEmailAndDatastatus(user.getEmail(),false) ; - if(tempUser!=null&&!user.getEmail().equals(oldUser.getEmail())) { - msg = "email_exist"; - return msg; - } - tempUser = userRepository.findByMobileAndDatastatus(user.getMobile(),false) ; - if(tempUser!=null&&!user.getMobile().equals(oldUser.getMobile())) { - msg = "mobile_exist"; - return msg; - } - List tempUserList = userRepository.findBySipaccountAndDatastatus(user.getSipaccount(),false) ; - if(tempUserList.size()!=0&&user.getSipaccount()!=""&&!user.getSipaccount().equals(oldUser.getSipaccount())) { - msg = "sip_account_exist"; - return msg; - } - return msg; + + private String validUserUpdate(User user, User oldUser) { + String msg = ""; + User tempUser = userRepository.findByUsernameAndDatastatus(user.getUsername(), false); + if (tempUser != null && !user.getUsername().equals(oldUser.getUsername())) { + msg = "username_exist"; + return msg; + } + tempUser = userRepository.findByEmailAndDatastatus(user.getEmail(), false); + if (tempUser != null && !user.getEmail().equals(oldUser.getEmail())) { + msg = "email_exist"; + return msg; + } + tempUser = userRepository.findByMobileAndDatastatus(user.getMobile(), false); + if (tempUser != null && !user.getMobile().equals(oldUser.getMobile())) { + msg = "mobile_exist"; + return msg; + } + + if (!validUserCallcenterParams(user)) { + msg = "sip_account_exist"; + return msg; + } + + return msg; } - + @RequestMapping("/delete") - @Menu(type = "admin" , subtype = "user") - public ModelAndView delete(HttpServletRequest request ,@Valid User user) { - String msg = "admin_user_delete" ; - if(user!=null){ - List userRole = userRoleRes.findByOrgiAndUser(super.getOrgiByTenantshare(request), user) ; - userRoleRes.delete(userRole); //删除用户的时候,同时删除用户对应的 - user = userRepository.getOne(user.getId()) ; - user.setDatastatus(true); - userRepository.save(user) ; - OnlineUserUtils.clean(super.getOrgi(request)); - }else{ - msg = "admin_user_not_exist" ; - } - return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg="+msg)); + @Menu(type = "admin", subtype = "user") + public ModelAndView delete(HttpServletRequest request, @Valid User user) { + String msg = "admin_user_delete"; + if (user != null) { + List userRole = userRoleRes.findByOrgiAndUser(super.getOrgiByTenantshare(request), user); + userRoleRes.delete(userRole); //删除用户的时候,同时删除用户对应的 + user = userRepository.getOne(user.getId()); + user.setDatastatus(true); + userRepository.save(user); + OnlineUserUtils.clean(super.getOrgi(request)); + } else { + msg = "admin_user_not_exist"; + } + return request(super.createRequestPageTempletResponse("redirect:/admin/user/index.html?msg=" + msg)); } - + + /** + * 根据是否开启呼叫中心模块检测账号 + * @param user + * @return + */ + private boolean validUserCallcenterParams(final User user) { + if (user.isCallcenter() && MainContext.isEnableCalloutModule()) { + List tempUserList = userRepository.findBySipaccountAndDatastatus(user.getSipaccount(), false); + if (tempUserList.size() != 0 && user.getSipaccount() != "") { + return false; + } + } + return true; + } + } \ No newline at end of file diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java b/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java index 53004f80..c83644ba 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java @@ -30,6 +30,14 @@ public class Constants { public final static String IM_MESSAGE_TYPE_MESSAGE = "message"; public final static String CHATBOT_EVENT_TYPE_CHAT = "chat"; + + /** + * Modules + */ + public final static String CSKEFU_MODULE_CALLOUT = "sales"; + public final static String CSKEFU_MODULE_CHATBOT = "chatbot"; + public final static String CSKEFU_MODULE_CONTACTS = "contacts"; + /** * Formatter */ From 0ff50305ee0a8903a3869c1df926683c16dc59a5 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 18 Oct 2018 19:11:16 +0800 Subject: [PATCH 21/54] =?UTF-8?q?Closed=20#101=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E5=9D=90=E5=B8=AD=E5=B7=A5=E4=BD=9C=E5=8F=B0=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/templates/apps/index.html | 2 +- .../config/sql/cskefu-MySQL-slim.sql | 25 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/contact-center/app/src/main/resources/templates/apps/index.html b/contact-center/app/src/main/resources/templates/apps/index.html index f0465ae8..81df176e 100644 --- a/contact-center/app/src/main/resources/templates/apps/index.html +++ b/contact-center/app/src/main/resources/templates/apps/index.html @@ -166,7 +166,7 @@ <#if user?? && user.agent == true> - <#if (user?? && user.roleAuthMap["B01"]?? || user.usertype == "0")> + <#if (user?? && user.roleAuthMap["A01"]?? || user.usertype == "0")>
  • 0 diff --git a/contact-center/config/sql/cskefu-MySQL-slim.sql b/contact-center/config/sql/cskefu-MySQL-slim.sql index e577ed8e..51765cbb 100644 --- a/contact-center/config/sql/cskefu-MySQL-slim.sql +++ b/contact-center/config/sql/cskefu-MySQL-slim.sql @@ -457,7 +457,7 @@ CREATE TABLE `uk_ad_position` ( `AREA` text COMMENT '分类描述', `IMGURL` varchar(255) DEFAULT NULL COMMENT '图片URL', `TIPTEXT` varchar(100) DEFAULT NULL COMMENT '提示文本', - `URL` varchar(255) DEFAULT NULL COMMENT '路径', + `URL` text DEFAULT NULL COMMENT '路径', `CONTENT` text COMMENT '内容', `WEIGHT` int(11) DEFAULT NULL COMMENT '权重', `ADTYPE` varchar(50) DEFAULT NULL COMMENT '广告类型', @@ -498,7 +498,7 @@ CREATE TABLE `uk_agentservice` ( `lastmessage` datetime DEFAULT NULL COMMENT '最后一条消息时间', `waittingtimestart` datetime DEFAULT NULL COMMENT '进入排队时间', `lastgetmessage` datetime DEFAULT NULL COMMENT '坐席最后一条消息时间', - `lastmsg` varchar(100) DEFAULT '' COMMENT '最后一条消息内容', + `lastmsg` text DEFAULT '' COMMENT '最后一条消息内容', `agentskill` varchar(100) DEFAULT '' COMMENT '技能组', `create_time` datetime DEFAULT NULL COMMENT '创建时间', `creater` varchar(255) DEFAULT NULL COMMENT '创建人', @@ -637,7 +637,7 @@ CREATE TABLE `uk_agentuser` ( `lastmessage` datetime DEFAULT NULL COMMENT '最后一条消息时间', `waittingtimestart` datetime DEFAULT NULL COMMENT '进入队列时间', `lastgetmessage` datetime DEFAULT NULL COMMENT '最后一条消息时间', - `lastmsg` varchar(100) DEFAULT '' COMMENT '最后一条消息', + `lastmsg` text DEFAULT '' COMMENT '最后一条消息', `agentskill` varchar(100) DEFAULT '' COMMENT '技能组', `create_time` datetime DEFAULT NULL COMMENT '创建时间', `creater` varchar(255) DEFAULT NULL COMMENT '创建人', @@ -676,7 +676,7 @@ CREATE TABLE `uk_agentuser` ( `avgreplytime` int(11) DEFAULT '0' COMMENT '平均回复时长', `sessionid` varchar(32) DEFAULT NULL COMMENT '会话ID', `title` varchar(255) DEFAULT NULL COMMENT '标题', - `url` varchar(255) DEFAULT NULL COMMENT 'URL', + `url` text DEFAULT NULL COMMENT 'URL', `traceid` varchar(32) DEFAULT NULL COMMENT '跟踪ID', `agenttimeout` int(11) DEFAULT '0' COMMENT '坐席超时时长', `agenttimeouttimes` int(11) DEFAULT '0' COMMENT '坐席超时次数', @@ -781,7 +781,7 @@ CREATE TABLE `uk_attachment_file` ( `organ` varchar(32) DEFAULT NULL COMMENT '组织机构ID', `datastatus` tinyint(4) DEFAULT NULL COMMENT '数据状态(逻辑删除)', `title` varchar(255) DEFAULT NULL COMMENT '标题', - `url` varchar(255) CHARACTER SET utf32 DEFAULT NULL COMMENT '地址', + `url` text CHARACTER SET utf32 DEFAULT NULL COMMENT '地址', `updatetime` datetime DEFAULT NULL COMMENT '更新时间', `filelength` int(11) DEFAULT NULL COMMENT '文件长度', `filetype` varchar(255) DEFAULT NULL COMMENT '文件类型', @@ -2112,7 +2112,7 @@ CREATE TABLE `uk_inviterecord` ( `responsetime` int(11) DEFAULT NULL COMMENT '响应时间', `appid` varchar(32) DEFAULT NULL COMMENT 'SNSID', `title` varchar(255) DEFAULT NULL COMMENT '标题', - `url` varchar(255) DEFAULT NULL COMMENT '地址', + `url` text DEFAULT NULL COMMENT '地址', `traceid` varchar(32) DEFAULT NULL COMMENT '跟踪ID', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='邀请记录表'; @@ -2481,7 +2481,7 @@ CREATE TABLE `uk_onlineuser` ( `keyword` varchar(100) DEFAULT NULL COMMENT '搜索引擎关键词', `source` varchar(50) DEFAULT NULL COMMENT '来源', `title` varchar(255) DEFAULT NULL COMMENT '标题', - `url` varchar(255) DEFAULT NULL COMMENT '来源URL', + `url` text DEFAULT NULL COMMENT '来源URL', `useragent` text COMMENT 'UA', `invitetimes` int(11) DEFAULT NULL COMMENT '要求次数', `invitestatus` varchar(10) DEFAULT NULL COMMENT '邀请状态', @@ -2541,7 +2541,7 @@ CREATE TABLE `uk_onlineuser_his` ( `keyword` varchar(100) DEFAULT NULL COMMENT '搜索引擎关键词', `source` varchar(50) DEFAULT NULL COMMENT '来源', `title` varchar(255) DEFAULT NULL COMMENT '标题', - `url` varchar(255) DEFAULT NULL COMMENT '来源URL', + `url` text DEFAULT NULL COMMENT '来源URL', `useragent` text COMMENT 'UA', `invitetimes` int(11) DEFAULT NULL COMMENT '要求次数', `invitestatus` varchar(10) DEFAULT NULL COMMENT '邀请状态', @@ -2914,7 +2914,7 @@ CREATE TABLE `uk_recentuser` ( `name` varchar(100) DEFAULT NULL COMMENT '名称', `orgi` varchar(100) DEFAULT NULL COMMENT '租户ID', `user_id` varchar(32) DEFAULT NULL COMMENT '用户ID', - `lastmsg` varchar(100) DEFAULT NULL COMMENT '最后一条消息', + `lastmsg` text DEFAULT NULL COMMENT '最后一条消息', `newmsg` int(11) DEFAULT NULL COMMENT '未读消息数量', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='公共已读消息'; @@ -3475,7 +3475,7 @@ CREATE TABLE `uk_sysdic` ( `DICID` varchar(32) DEFAULT NULL COMMENT '目录ID', `DEFAULTVALUE` tinyint(4) DEFAULT NULL COMMENT '默认值', `DISCODE` tinyint(4) DEFAULT NULL COMMENT '编码', - `URL` varchar(255) DEFAULT NULL COMMENT '系统权限资源的URL', + `URL` text DEFAULT NULL COMMENT '系统权限资源的URL', `MODULE` varchar(32) DEFAULT NULL COMMENT '权限资源所属模块', `MLEVEL` varchar(32) DEFAULT NULL COMMENT '菜单级别(一级/二级)', `RULES` varchar(100) DEFAULT NULL, @@ -7144,7 +7144,6 @@ INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612cefb4120590', '语音留 INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612ceffa060591', '漏话列表', 'pub', 'A10_A01_A06', NULL, 'auth', '402881ef612b1f5b01612cee4fbb058a', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:49:40', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/apps/callcenter/misscall/index.html', 'webim', '3', NULL, 'left'); INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612cf03d740592', '在线坐席', 'pub', 'A10_A02_A01', NULL, 'auth', '402881ef612b1f5b01612cee80ed058b', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:49:57', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/apps/callcenter/online/index.html', 'webim', '3', NULL, 'left'); INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612cf065f40593', '全部坐席', 'pub', 'A10_A02_A02', NULL, 'auth', '402881ef612b1f5b01612cee80ed058b', NULL, NULL, '�', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:50:07', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/apps/callcenter/agents/index.html', 'webim', '3', NULL, 'left'); -INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612cf11a140594', '坐席工作台', 'pub', 'B01', NULL, 'auth', '402888815d2fe37f015d2fe75cc80002', NULL, NULL, '', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:50:53', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/agent/index.html', 'webim', '1', NULL, 'left'); INSERT INTO `uk_sysdic` VALUES ('402881ef612b1f5b01612cf147810595', '系统管理', 'pub', 'B02', NULL, 'auth', '402888815d2fe37f015d2fe75cc80002', NULL, NULL, '', NULL, NULL, '297e8c7b455798280145579c73e501c1', '2018-01-25 18:51:05', NULL, 0, 0, '402888815d2fe37f015d2fe75cc80002', 0, 0, '/admin/content.html', 'webim', '1', NULL, 'left'); INSERT INTO `uk_sysdic` VALUES ('402881fb61e49a9a0161e4a8a1260392', '过滤器类型', 'pub', 'com.dic.filter.modeltype', NULL, 'data', '0', '', NULL, NULL, NULL, NULL, '4028cac3614cd2f901614cf8be1f0324', '2018-03-02 11:01:52', NULL, 1, 0, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL); INSERT INTO `uk_sysdic` VALUES ('402881fb61e49a9a0161e4a925a20393', '过滤器取值方式', 'pub', 'com.dic.filter.convalue', NULL, 'data', '0', '', NULL, NULL, NULL, NULL, '4028cac3614cd2f901614cf8be1f0324', '2018-03-02 11:02:25', NULL, 1, 0, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL); @@ -7750,7 +7749,7 @@ CREATE TABLE `uk_system_message` ( `SECLEV` varchar(50) DEFAULT NULL COMMENT '启用SSL', `SSLPORT` varchar(50) DEFAULT NULL COMMENT 'SSL端口', `ORGI` varchar(32) DEFAULT NULL COMMENT '租户ID', - `URL` varchar(255) DEFAULT NULL COMMENT 'URL', + `URL` text DEFAULT NULL COMMENT 'URL', `smstype` varchar(32) DEFAULT NULL COMMENT '短信类型', `APPKEY` varchar(200) DEFAULT NULL COMMENT 'APPKEY', `APPSEC` varchar(200) DEFAULT NULL COMMENT 'APPSEC', @@ -8177,7 +8176,7 @@ CREATE TABLE `uk_userevent` ( `city` varchar(32) DEFAULT NULL COMMENT '城市', `isp` varchar(32) DEFAULT NULL COMMENT '运营商', `province` varchar(32) DEFAULT NULL COMMENT '省份', - `url` varchar(255) DEFAULT NULL COMMENT '接入URL', + `url` text DEFAULT NULL COMMENT '接入URL', `sessionid` varchar(32) DEFAULT NULL COMMENT '会话ID', `param` text COMMENT '请求参数', `times` int(11) DEFAULT NULL COMMENT '访问次数', From 636d3eecd2f40f97334ce118723c85c9f2e539c8 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 18 Oct 2018 19:40:33 +0800 Subject: [PATCH 22/54] =?UTF-8?q?Closed=20#103=20iconstr=E4=BD=BF=E7=94=A8?= =?UTF-8?q?null=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/admin/config/index.html | 58 +++++++++---------- .../templates/admin/include/left.html | 2 + .../config/sql/cskefu-MySQL-slim.sql | 2 +- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/contact-center/app/src/main/resources/templates/admin/config/index.html b/contact-center/app/src/main/resources/templates/admin/config/index.html index e022d220..584f7494 100644 --- a/contact-center/app/src/main/resources/templates/admin/config/index.html +++ b/contact-center/app/src/main/resources/templates/admin/config/index.html @@ -11,7 +11,7 @@
    -
    1、系统颜色风格选择
    +
    系统颜色风格选择
    @@ -29,8 +29,8 @@
    -
    -
    2、请填写服务器的访问地址
    +
  • diff --git a/contact-center/config/sql/cskefu-MySQL-slim.sql b/contact-center/config/sql/cskefu-MySQL-slim.sql index 51765cbb..c212fc83 100644 --- a/contact-center/config/sql/cskefu-MySQL-slim.sql +++ b/contact-center/config/sql/cskefu-MySQL-slim.sql @@ -7834,7 +7834,7 @@ CREATE TABLE `uk_systemconfig` ( -- Records of uk_systemconfig -- ---------------------------- BEGIN; -INSERT INTO `uk_systemconfig` VALUES ('2c93809364e0a6d00164ef6722270582', NULL, '春松客服-全渠道智能客服', NULL, 'cskefu', NULL, NULL, NULL, NULL, 'www.chatopera.com', NULL, NULL, '4028cac3614cd2f901614cf8be1f0324', '2018-07-31 08:14:30', NULL, NULL, NULL, NULL, NULL, '01', 'info', 0, NULL, NULL, '', 0, 0, '', '', '', '', '', '', NULL, 0, 0, 0, 0, '', '', NULL, NULL, '', '', NULL, 0, 0, NULL, NULL, NULL, 0, '', NULL, 0, 0, '租户', 0, 0, NULL, NULL, NULL); +INSERT INTO `uk_systemconfig` VALUES ('2c93809364e0a6d00164ef6722270582', NULL, '春松客服-全渠道智能客服', NULL, 'cskefu', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '4028cac3614cd2f901614cf8be1f0324', '2018-07-31 08:14:30', NULL, NULL, NULL, NULL, NULL, '01', 'info', 0, NULL, NULL, '', 0, 0, '', '', '', '', '', '', NULL, 0, 0, 0, 0, '', '', NULL, NULL, '', '', NULL, 0, 0, NULL, NULL, NULL, 0, '', NULL, 0, 0, '租户', 0, 0, NULL, NULL, NULL); COMMIT; -- ---------------------------- From bd4a956f8ed61b0ff3ee2cc9838593309ac7d2a6 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 18 Oct 2018 19:49:22 +0800 Subject: [PATCH 23/54] Closed #104 pop up error message --- .../main/resources/templates/apps/chatbot/index.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/contact-center/app/src/main/resources/templates/apps/chatbot/index.html b/contact-center/app/src/main/resources/templates/apps/chatbot/index.html index dcbbe354..6ca28b36 100644 --- a/contact-center/app/src/main/resources/templates/apps/chatbot/index.html +++ b/contact-center/app/src/main/resources/templates/apps/chatbot/index.html @@ -134,6 +134,16 @@ }) $('#bots').html(tds); + }, function(err){ + layer.confirm(err.data||err.error, { + btn: ['关闭'], + icon: 2, + title: '提示' + }, function (popup, layero) { + layer.close(popup) + }, function (popup) { + // 取消方法 + }); }) } From f2a32720ff14dd409ced76c417432cb5ed60c5d7 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 18 Oct 2018 20:51:07 +0800 Subject: [PATCH 24/54] #102 fix SQL exection error --- contact-center/config/sql/cskefu-MySQL-slim.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contact-center/config/sql/cskefu-MySQL-slim.sql b/contact-center/config/sql/cskefu-MySQL-slim.sql index c212fc83..4ecc63b4 100644 --- a/contact-center/config/sql/cskefu-MySQL-slim.sql +++ b/contact-center/config/sql/cskefu-MySQL-slim.sql @@ -498,7 +498,7 @@ CREATE TABLE `uk_agentservice` ( `lastmessage` datetime DEFAULT NULL COMMENT '最后一条消息时间', `waittingtimestart` datetime DEFAULT NULL COMMENT '进入排队时间', `lastgetmessage` datetime DEFAULT NULL COMMENT '坐席最后一条消息时间', - `lastmsg` text DEFAULT '' COMMENT '最后一条消息内容', + `lastmsg` text COMMENT '最后一条消息内容', `agentskill` varchar(100) DEFAULT '' COMMENT '技能组', `create_time` datetime DEFAULT NULL COMMENT '创建时间', `creater` varchar(255) DEFAULT NULL COMMENT '创建人', @@ -637,7 +637,7 @@ CREATE TABLE `uk_agentuser` ( `lastmessage` datetime DEFAULT NULL COMMENT '最后一条消息时间', `waittingtimestart` datetime DEFAULT NULL COMMENT '进入队列时间', `lastgetmessage` datetime DEFAULT NULL COMMENT '最后一条消息时间', - `lastmsg` text DEFAULT '' COMMENT '最后一条消息', + `lastmsg` text COMMENT '最后一条消息', `agentskill` varchar(100) DEFAULT '' COMMENT '技能组', `create_time` datetime DEFAULT NULL COMMENT '创建时间', `creater` varchar(255) DEFAULT NULL COMMENT '创建人', @@ -1610,7 +1610,7 @@ CREATE TABLE `cs_contact_notes` ( `createtime` datetime NOT NULL COMMENT '创建时间', `updatetime` datetime NOT NULL COMMENT '更新时间', `category` varchar(200) DEFAULT NULL COMMENT '内容类型', - `content` varchar(1000) DEFAULT NULL COMMENT '内容', + `content` text COMMENT '内容', `creater` varchar(32) DEFAULT NULL COMMENT '创建人', `datastatus` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已删除', `agentuser` varchar(32) DEFAULT NULL COMMENT '在线访客记录ID', @@ -2914,7 +2914,7 @@ CREATE TABLE `uk_recentuser` ( `name` varchar(100) DEFAULT NULL COMMENT '名称', `orgi` varchar(100) DEFAULT NULL COMMENT '租户ID', `user_id` varchar(32) DEFAULT NULL COMMENT '用户ID', - `lastmsg` text DEFAULT NULL COMMENT '最后一条消息', + `lastmsg` text COMMENT '最后一条消息', `newmsg` int(11) DEFAULT NULL COMMENT '未读消息数量', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='公共已读消息'; From 1d9b58efd6f4b8402f0f1f14db55997868727870 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 18 Oct 2018 20:55:44 +0800 Subject: [PATCH 25/54] Fixed #105 add id field on creation --- .../cc/app/handler/api/rest/ApiContactNotesController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiContactNotesController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiContactNotesController.java index 1d1ec5f2..edb1cbb4 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiContactNotesController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiContactNotesController.java @@ -16,6 +16,7 @@ package com.chatopera.cc.app.handler.api.rest; import com.chatopera.cc.app.basic.MainContext; +import com.chatopera.cc.app.basic.MainUtils; import com.chatopera.cc.util.Constants; import com.chatopera.cc.util.Menu; import com.chatopera.cc.exception.CSKefuRestException; @@ -154,6 +155,7 @@ public class ApiContactNotesController extends Handler { } ContactNotes cn = new ContactNotes(); + cn.setId(MainUtils.getUUID()); cn.setCategory(payload.get("category").getAsString()); cn.setContent(payload.get("content").getAsString()); cn.setCreater(payload.get("creater").getAsString()); From 197019f0c789f00b298be70b915ced6271d32c72 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 18 Oct 2018 21:33:43 +0800 Subject: [PATCH 26/54] #88 delete useless log --- .../chatopera/cc/app/handler/apps/internet/IMController.java | 2 -- .../src/main/java/com/chatopera/cc/util/OnlineUserUtils.java | 1 - 2 files changed, 3 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java index b9df9f4f..ac7fd2ab 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java @@ -344,7 +344,6 @@ public class IMController extends Handler { @Valid String purl) throws Exception { ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/index")); BlackEntity black = (BlackEntity) CacheHelper.getSystemCacheBean().getCacheObject(userid, MainContext.SYSTEM_ORGI); - logger.info("index userId {}", userid); if (StringUtils.isNotBlank(appid) && (black == null || (black.getEndtime() != null && black.getEndtime().before(new Date())))) { CousultInvite invite = OnlineUserUtils.cousult(appid, orgi, inviteRepository); String userID = null; @@ -354,7 +353,6 @@ public class IMController extends Handler { userID = MainUtils.genIDByKey(sessionid); } String nickname = "Guest_" + userID; - logger.info("nick name {}", nickname); boolean consult = true; //是否已收集用户信息 SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(orgi); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/OnlineUserUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/util/OnlineUserUtils.java index f3ac8c73..542a24e2 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/OnlineUserUtils.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/OnlineUserUtils.java @@ -909,7 +909,6 @@ public class OnlineUserUtils { ipdata = IPTools.getInstance().findGeography(ip); } - logger.info("set new Request message nickname {}", nickname); if (StringUtils.isBlank(nickname)) { nickname = "Guest_" + userid; } From 9114bf95e8144ca59f1c95e8991a40053bdd4fb2 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 18 Oct 2018 22:33:19 +0800 Subject: [PATCH 27/54] =?UTF-8?q?#75=20=E4=BC=98=E5=8C=96=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E4=BA=BA=E5=AE=A2=E6=9C=8D=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/rest/ApiChatbotController.java | 2 +- .../app/im/handler/ChatbotEventHandler.java | 36 +++++++++++++------ .../templates/apps/chatbot/edit.html | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiChatbotController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiChatbotController.java index f214bba8..ec067674 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiChatbotController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/api/rest/ApiChatbotController.java @@ -582,7 +582,7 @@ public class ApiChatbotController extends Handler { } } catch (ChatbotAPIRuntimeException e) { resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5); - resp.addProperty(RestUtils.RESP_KEY_ERROR, "智能问答引擎服务异常。" + e.toString()); + resp.addProperty(RestUtils.RESP_KEY_ERROR, "智能问答引擎服务异常,该机器人【chatbotID】已经存在或服务不能访问到,请联系 [info@chatopera.com] 获得支持。"); return resp; } catch (MalformedURLException e) { resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java index 4bbbd0bb..a9c2dfb4 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java @@ -80,21 +80,35 @@ public class ChatbotEventHandler { * 加入到 缓存列表 */ NettyClients.getInstance().putChatbotEventClient(user, client); - MessageOutContent outMessage = new MessageOutContent(); CousultInvite invite = OnlineUserUtils.cousult(appid, orgi, MainContext.getContext().getBean(ConsultInviteRepository.class)); + + // send out tip + MessageOutContent tip = new MessageOutContent(); + tip.setMessage("您正在使用机器人客服!"); + tip.setMessageType(MainContext.MessageTypeEnum.MESSAGE.toString()); + tip.setCalltype(MainContext.CallTypeEnum.IN.toString()); + tip.setNickName(invite.getAiname()); + tip.setCreatetime(MainUtils.dateFormate.format(now)); + + client.sendEvent(MainContext.MessageTypeEnum.STATUS.toString(), tip); + + // send out welcome message if (invite != null && StringUtils.isNotBlank(invite.getAisuccesstip())) { - outMessage.setMessage(invite.getAisuccesstip()); - } else { - outMessage.setMessage("欢迎使用华夏春松机器人客服!"); + ChatMessage welcome = new ChatMessage(); + welcome.setCalltype(MainContext.CallTypeEnum.OUT.toString()); + welcome.setAppid(appid); + welcome.setOrgi(orgi); + welcome.setAiid(aiid); + welcome.setMessage(invite.getAisuccesstip()); + welcome.setTouser(user); + welcome.setTousername(nickname); + welcome.setMsgtype(MainContext.MessageTypeEnum.MESSAGE.toString()); + welcome.setUserid(user); + welcome.setUsername(invite.getAiname()); + welcome.setUpdatetime(System.currentTimeMillis()); + client.sendEvent(MainContext.MessageTypeEnum.MESSAGE.toString(), welcome); } - outMessage.setMessageType(MainContext.MessageTypeEnum.MESSAGE.toString()); - outMessage.setCalltype(MainContext.CallTypeEnum.IN.toString()); - outMessage.setNickName(invite.getAiname()); - outMessage.setCreatetime(MainUtils.dateFormate.format(now)); - - client.sendEvent(MainContext.MessageTypeEnum.STATUS.toString(), outMessage); - InetSocketAddress address = (InetSocketAddress) client.getRemoteAddress(); String ip = MainUtils.getIpAddr(client.getHandshakeData().getHttpHeaders(), address.getHostString()); OnlineUser onlineUser = getOnlineUserRes().findOne(user); diff --git a/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html b/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html index c9bf0cd0..6d22f036 100644 --- a/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html +++ b/contact-center/app/src/main/resources/templates/apps/chatbot/edit.html @@ -123,7 +123,7 @@ if (data.rc == 0) { cb(null, data.data); } else { - cb(data.data); + cb(data); } }) .fail(function (jqXHR, textStatus) { From 846e5bd600c2f430962fdb95bded10e5c6fef981 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Fri, 19 Oct 2018 13:40:21 +0800 Subject: [PATCH 28/54] =?UTF-8?q?Closed=20#107=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=A1=AB=E5=86=99=E6=9C=8D=E5=8A=A1=E5=B0=8F=E7=BB=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/apps/agent/AgentController.java | 28 +++++++++++++++---- .../templates/apps/agent/mainagentuser.html | 2 +- .../templates/apps/agent/summary.html | 1 + 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java index b895c670..eb1bc5bb 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java @@ -325,7 +325,10 @@ public class AgentController extends Handler { @RequestMapping("/agentuser") @Menu(type = "apps", subtype = "agent") - public ModelAndView agentuser(ModelMap map , HttpServletRequest request , String id, String channel) throws IOException, TemplateException { + public ModelAndView agentuser(ModelMap map, + HttpServletRequest request, + String id, + String channel) throws IOException, TemplateException { String mainagentuser = "/apps/agent/mainagentuser"; if(channel.equals("phone")) { mainagentuser = "/apps/agent/mainagentuser_callout"; @@ -917,7 +920,12 @@ public class AgentController extends Handler { @RequestMapping(value="/summary") @Menu(type = "apps", subtype = "summary") - public ModelAndView summary(ModelMap map , HttpServletRequest request , @Valid String userid , @Valid String agentserviceid, @Valid String agentuserid){ + public ModelAndView summary(ModelMap map , + HttpServletRequest request , + @Valid String userid , + @Valid String agentserviceid, + @Valid String agentuserid, + @Valid String channel){ if(!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)){ AgentUser agentUser = this.agentUserRepository.findByIdAndOrgi(agentuserid, super.getOrgi(request)) ; if(agentUser!=null && !StringUtils.isBlank(agentUser.getAgentserviceid())){ @@ -926,10 +934,12 @@ public class AgentController extends Handler { map.addAttribute("summary", summaries.get(0)) ; } } + map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.SUMMARY.toString())) ; map.addAttribute("userid", userid) ; map.addAttribute("agentserviceid", agentserviceid) ; map.addAttribute("agentuserid", agentuserid) ; + map.addAttribute("channel", channel); } @@ -938,8 +948,15 @@ public class AgentController extends Handler { @RequestMapping(value="/summary/save") @Menu(type = "apps", subtype = "summarysave") - public ModelAndView summarysave(ModelMap map , HttpServletRequest request , @Valid AgentServiceSummary summary , @Valid String contactsid , @Valid String userid , @Valid String agentserviceid, @Valid String agentuserid){ - if(!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)){ + public ModelAndView summarysave(ModelMap map , + HttpServletRequest request , + @Valid AgentServiceSummary summary , + @Valid String contactsid , + @Valid String userid , + @Valid String agentserviceid, + @Valid String agentuserid, + @Valid String channel){ + if(!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)){ summary.setOrgi(super.getOrgi(request)); summary.setCreater(super.getUser(request).getId()); @@ -951,6 +968,7 @@ public class AgentController extends Handler { summary.setUsername(service.getUsername()); summary.setAgentusername(service.getAgentusername()); summary.setChannel(service.getChannel()); + summary.setContactsid(contactsid); summary.setLogindate(service.getLogindate()); summary.setContactsid(service.getContactsid()); summary.setEmail(service.getEmail()); @@ -958,7 +976,7 @@ public class AgentController extends Handler { serviceSummaryRes.save(summary) ; } - return request(super.createRequestPageTempletResponse("redirect:/agent/agentuser.html?id="+agentuserid)) ; + return request(super.createRequestPageTempletResponse("redirect:/agent/agentuser.html?id="+agentuserid + "&channel=" + channel)) ; } @RequestMapping(value="/transfer") diff --git a/contact-center/app/src/main/resources/templates/apps/agent/mainagentuser.html b/contact-center/app/src/main/resources/templates/apps/agent/mainagentuser.html index 636a8566..59effe80 100644 --- a/contact-center/app/src/main/resources/templates/apps/agent/mainagentuser.html +++ b/contact-center/app/src/main/resources/templates/apps/agent/mainagentuser.html @@ -8,7 +8,7 @@

    <#if curagentuser??>${curagentuser.username!''}(${curagentuser.region!''}) diff --git a/contact-center/app/src/main/resources/templates/apps/agent/summary.html b/contact-center/app/src/main/resources/templates/apps/agent/summary.html index 54533832..697b4985 100644 --- a/contact-center/app/src/main/resources/templates/apps/agent/summary.html +++ b/contact-center/app/src/main/resources/templates/apps/agent/summary.html @@ -5,6 +5,7 @@ +
    From 232319959db08580df719546cc09f8bc315af675 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Fri, 19 Oct 2018 13:56:55 +0800 Subject: [PATCH 29/54] =?UTF-8?q?Closed=20#109=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=B0=8F=E7=BB=93=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/apps/agent/channel/webim.html | 16 +++++++++------- .../templates/apps/agent/channel/weixin.html | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/contact-center/app/src/main/resources/templates/apps/agent/channel/webim.html b/contact-center/app/src/main/resources/templates/apps/agent/channel/webim.html index 37d18973..90c84e8e 100644 --- a/contact-center/app/src/main/resources/templates/apps/agent/channel/webim.html +++ b/contact-center/app/src/main/resources/templates/apps/agent/channel/webim.html @@ -2,14 +2,16 @@
  • 访问渠道: 在线客服 - <#if summary??> - -
  • + +
  • + 服务小结: <#if summary??> + 已记录 + <#else> + 未记录 + +
  • + <#if snsAccount??>
  • 接入网站:${snsAccount.name!''}(${snsAccount.baseURL!''}) diff --git a/contact-center/app/src/main/resources/templates/apps/agent/channel/weixin.html b/contact-center/app/src/main/resources/templates/apps/agent/channel/weixin.html index bdd82641..8e17b08f 100644 --- a/contact-center/app/src/main/resources/templates/apps/agent/channel/weixin.html +++ b/contact-center/app/src/main/resources/templates/apps/agent/channel/weixin.html @@ -5,14 +5,16 @@
  • 访问渠道: 微信 - <#if summary??> - -
  • + +
  • + 服务小结: <#if summary??> + 已记录 + <#else> + 未记录 + +
  • + <#if snsAccount??>
  • 公众号:${snsAccount.name} From 89d680fbf89b6f54aca3ae246ab69fe3b33ae4cf Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Fri, 19 Oct 2018 14:04:25 +0800 Subject: [PATCH 30/54] =?UTF-8?q?Closed=20#108=20=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E6=9A=82=E6=97=B6=E4=B8=8D=E6=94=AF=E6=8C=81=E5=A4=9A?= =?UTF-8?q?=E5=AA=92=E4=BD=93=E5=AF=B9=E8=AF=9D=EF=BC=8C=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/apps/im/chatbot/index.html | 2 +- .../resources/templates/apps/im/chatbot/mobile.html | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html b/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html index 381d5cd4..bf8a0786 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html +++ b/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html @@ -37,7 +37,7 @@ allowInsertUpload:false, //增加的参数,上传图片后是否插入到当前区域 allowImageRemote:false, filterMode:true, - items: ['emoticons', 'cut' , 'image','insertfile'], + items: ['emoticons', 'cut'], htmlTags: {img : ['src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border'] , br:[]} , afterChange : function() { var count = this.count() ; diff --git a/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html b/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html index ab82f67b..0a759547 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html +++ b/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html @@ -238,12 +238,12 @@
  • -
    - - - - -
    + + + + + +
    From 4914541afb8fbb2da77f854fc02a2ed66253024c Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Fri, 19 Oct 2018 15:11:28 +0800 Subject: [PATCH 31/54] #35 rename filename --- .../cc/app/handler/apps/contacts/ContactsController.java | 8 ++++---- .../cc/app/handler/apps/kbs/TopicController.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/contacts/ContactsController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/contacts/ContactsController.java index 357a3113..373a0c7f 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/contacts/ContactsController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/contacts/ContactsController.java @@ -292,7 +292,7 @@ public class ContactsController extends Handler { values.add(MainUtils.transBean2Map(contacts)); } - response.setHeader("content-disposition", "attachment;filename=UCKeFu-Contacts-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls"); + response.setHeader("content-disposition", "attachment;filename=CSKefu-Contacts-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls"); ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream()); excelProcess.process(); @@ -317,7 +317,7 @@ public class ContactsController extends Handler { values.add(MainUtils.transBean2Map(contacts)); } - response.setHeader("content-disposition", "attachment;filename=UCKeFu-Contacts-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls"); + response.setHeader("content-disposition", "attachment;filename=CSKefu-Contacts-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls"); ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream()); excelProcess.process(); @@ -343,7 +343,7 @@ public class ContactsController extends Handler { values.add(MainUtils.transBean2Map(contacts)); } - response.setHeader("content-disposition", "attachment;filename=UCKeFu-Contacts-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls"); + response.setHeader("content-disposition", "attachment;filename=CSKefu-Contacts-" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls"); ExcelExporterProcess excelProcess = new ExcelExporterProcess(values, table, response.getOutputStream()); excelProcess.process(); @@ -430,4 +430,4 @@ public class ContactsController extends Handler { return request(super.createRequestPageTempletResponse("redirect:/apps/contacts/embed/index.html")); } -} \ No newline at end of file +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/kbs/TopicController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/kbs/TopicController.java index 0748d742..8613e183 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/kbs/TopicController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/kbs/TopicController.java @@ -419,7 +419,7 @@ public class TopicController extends Handler{ values.add(MainUtils.transBean2Map(topic)) ; } - response.setHeader("content-disposition", "attachment;filename=UCKeFu-Contacts-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls"); + response.setHeader("content-disposition", "attachment;filename=CSKefu-Contacts-"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+".xls"); if(table!=null){ ExcelExporterProcess excelProcess = new ExcelExporterProcess( values, table, response.getOutputStream()) ; excelProcess.process(); @@ -469,4 +469,4 @@ public class TopicController extends Handler{ } return ; } -} \ No newline at end of file +} From b914c0d5b8052afacda5e00c220e45d0309f85c4 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sat, 20 Oct 2018 17:26:35 +0800 Subject: [PATCH 32/54] #83 add notice in user list --- .../cc/app/schedule/CallOutPlanTask.java | 28 ++++++++++--------- .../resources/templates/admin/user/index.html | 1 + 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/CallOutPlanTask.java b/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/CallOutPlanTask.java index d01cb8e7..ae81a8fb 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/CallOutPlanTask.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/CallOutPlanTask.java @@ -91,20 +91,22 @@ public class CallOutPlanTask { @Scheduled(fixedDelayString = "${cskefu.callout.watch.interval}") // 每分钟执行一次 public void watch() { - logger.debug("[callout executor] check dialplan job running status ..."); - // load all jobs - List dps = callOutDialplanRes.findByStatusAndIsarchive(MainContext.CallOutDialplanStatusEnum.RUNNING.toString(), false); - for (CallOutDialplan dp : dps) { - Long size = redisListOps.size(String.format(Constants.FS_DIALPLAN_TARGET, dp.getVoicechannel().getBaseURL(), dp.getId())); - if (size > 0) { - logger.info("[callout executor] job [{}] is not done yet, remaining [{}]", dp.getName(), size); - } else { - dp.setStatus(MainContext.CallOutDialplanStatusEnum.STOPPED.toString()); - dp.setUpdatetime(new Date()); - callOutDialplanRes.save(dp); + if(MainContext.isEnableCalloutModule()){ + logger.debug("[callout executor] check dialplan job running status ..."); + // load all jobs + List dps = callOutDialplanRes.findByStatusAndIsarchive(MainContext.CallOutDialplanStatusEnum.RUNNING.toString(), false); + for (CallOutDialplan dp : dps) { + Long size = redisListOps.size(String.format(Constants.FS_DIALPLAN_TARGET, dp.getVoicechannel().getBaseURL(), dp.getId())); + if (size > 0) { + logger.info("[callout executor] job [{}] is not done yet, remaining [{}]", dp.getName(), size); + } else { + dp.setStatus(MainContext.CallOutDialplanStatusEnum.STOPPED.toString()); + dp.setUpdatetime(new Date()); + callOutDialplanRes.save(dp); - // 删除状态成员 - delHashKey(String.format(Constants.FS_DIALPLAN_STATUS, dp.getVoicechannel().getBaseURL()), dp.getId()); + // 删除状态成员 + delHashKey(String.format(Constants.FS_DIALPLAN_STATUS, dp.getVoicechannel().getBaseURL()), dp.getId()); + } } } } diff --git a/contact-center/app/src/main/resources/templates/admin/user/index.html b/contact-center/app/src/main/resources/templates/admin/user/index.html index 96223322..321e62bd 100644 --- a/contact-center/app/src/main/resources/templates/admin/user/index.html +++ b/contact-center/app/src/main/resources/templates/admin/user/index.html @@ -9,6 +9,7 @@

    +

    提示:除管理员外,账号必须在【组织结构】中关联一个部门,必须在【系统角色】中关联一个角色,才可以使用资源。设置后,该账号需重新登系统才能生效。

    From a0dbd1ea14bacf85312fe5f0bae5686063abd6e6 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Mon, 22 Oct 2018 17:21:26 +0800 Subject: [PATCH 33/54] =?UTF-8?q?Fixed=20#106=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contact-center/admin/build.sh | 1 + .../com/chatopera/cc/app/basic/MainUtils.java | 2 +- .../handler/apps/agent/AgentController.java | 2283 ++++++++--------- .../handler/apps/internet/IMController.java | 2 +- .../app/handler/resource/MediaController.java | 223 +- .../app/im/handler/ChatbotEventHandler.java | 6 + .../cc/app/im/handler/IMEventHandler.java | 18 +- .../cc/app/im/util/IMServiceUtils.java | 39 + .../cc/app/im/util/RichMediaUtils.java | 2 +- 9 files changed, 1316 insertions(+), 1260 deletions(-) create mode 100644 contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java diff --git a/contact-center/admin/build.sh b/contact-center/admin/build.sh index c3ba0c00..18a63960 100755 --- a/contact-center/admin/build.sh +++ b/contact-center/admin/build.sh @@ -15,5 +15,6 @@ PACKAGE_VERSION=1.0.0 [ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return cd $appHome +set -x docker build --force-rm=true --tag $imagename:$PACKAGE_VERSION . docker tag $imagename:$PACKAGE_VERSION $imagename:develop 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 index ce592ddd..e98cbd60 100644 --- 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 @@ -877,7 +877,7 @@ public class MainUtils { } attachmentFile.setFileid(fileid); attachementRes.save(attachmentFile); - FileUtils.writeByteArrayToFile(new File(path, "app/workorders/" + fileid), file.getBytes()); + FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), file.getBytes()); } } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java index eb1bc5bb..081a4023 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java @@ -16,33 +16,27 @@ */ package com.chatopera.cc.app.handler.apps.agent; -import java.io.File; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -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.app.basic.MainContext; -import com.chatopera.cc.util.*; -import com.chatopera.cc.app.im.client.NettyClients; -import com.chatopera.cc.exception.CSKefuException; -import com.chatopera.cc.exchange.DataExchangeInterface; -import com.chatopera.cc.util.mobile.MobileAddress; -import com.chatopera.cc.util.mobile.MobileNumberUtils; -import com.chatopera.cc.app.model.*; import com.chatopera.cc.app.algorithm.AutomaticServiceDist; +import com.chatopera.cc.app.basic.MainContext; +import com.chatopera.cc.app.basic.MainUtils; import com.chatopera.cc.app.cache.CacheHelper; +import com.chatopera.cc.app.handler.Handler; +import com.chatopera.cc.app.im.client.NettyClients; +import com.chatopera.cc.app.im.message.ChatMessage; +import com.chatopera.cc.app.im.router.OutMessageRouter; +import com.chatopera.cc.app.model.*; import com.chatopera.cc.app.persistence.es.ContactsRepository; import com.chatopera.cc.app.persistence.es.QuickReplyRepository; import com.chatopera.cc.app.persistence.repository.*; -import com.chatopera.cc.app.im.router.OutMessageRouter; -import com.chatopera.cc.app.im.message.ChatMessage; +import com.chatopera.cc.exception.CSKefuException; +import com.chatopera.cc.exchange.DataExchangeInterface; +import com.chatopera.cc.util.Menu; +import com.chatopera.cc.util.OnlineUserUtils; +import com.chatopera.cc.util.PinYinTools; +import com.chatopera.cc.util.PropertiesEventUtils; +import com.chatopera.cc.util.mobile.MobileAddress; +import com.chatopera.cc.util.mobile.MobileNumberUtils; +import freemarker.template.TemplateException; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -62,237 +56,244 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; -import com.chatopera.cc.app.basic.MainUtils; -import com.chatopera.cc.app.handler.Handler; - -import freemarker.template.TemplateException; +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.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; @Controller @RequestMapping("/agent") public class AgentController extends Handler { - static final Logger logger = LoggerFactory.getLogger(AgentController.class); + static final Logger logger = LoggerFactory.getLogger(AgentController.class); @Autowired - private ContactsRepository contactsRes ; + private ContactsRepository contactsRes; @Autowired - private PropertiesEventRepository propertiesEventRes ; + private PropertiesEventRepository propertiesEventRes; - @Autowired - private AgentUserRepository agentUserRepository ; + @Autowired + private AgentUserRepository agentUserRepository; - @Autowired + @Autowired private AgentUserContactsRepository agentUserContactsRepository; - - @Autowired - private AgentStatusRepository agentStatusRepository ; - - @Autowired - private AgentServiceRepository agentServiceRepository; - - @Autowired - private OnlineUserRepository onlineUserRes; - - @Autowired - private WeiXinUserRepository weiXinUserRes; - - @Autowired - private ServiceSummaryRepository serviceSummaryRes ; - - @Autowired - private ChatMessageRepository chatMessageRepository ; - - @Autowired - private AttachmentRepository attachementRes; - - @Autowired - private BlackListRepository blackListRes ; - - @Autowired - private TagRepository tagRes ; - - @Autowired - private OrganRepository organRes ; - - @Autowired - private TagRelationRepository tagRelationRes ; - - @Autowired - private QuickReplyRepository quickReplyRes ; - - @Autowired - private QuickTypeRepository quickTypeRes ; - - @Autowired - private AgentUserTaskRepository agentUserTaskRes ; - - @Autowired - private SNSAccountRepository snsAccountRes ; - - @Autowired - private UserRepository userRes ; - - - @Autowired - private StatusEventRepository statusEventRes ; - - @Autowired - private PbxHostRepository pbxHostRes ; - - - @Autowired - private AgentUserContactsRepository agentUserContactsRes; - - - @Autowired - private ConsultInviteRepository inviteRepository; - - @Value("${web.upload-path}") - private String path; - - @RequestMapping("/index") - @Menu(type = "apps", subtype = "agent") - public ModelAndView index(ModelMap map , HttpServletRequest request ,HttpServletResponse response , @Valid String sort) throws IOException, TemplateException { - ModelAndView view = request(super.createAppsTempletResponse("/apps/agent/index")) ; - User user = super.getUser(request) ; - Sort defaultSort = null ; - if(StringUtils.isBlank(sort)){ - Cookie[] cookies = request.getCookies();//这样便可以获取一个cookie数组 - if(cookies!=null){ - for(Cookie cookie : cookies){ - if(cookie.getName().equals("sort")){ - sort = cookie.getValue() ;break ; - } - } - } - } - if(!StringUtils.isBlank(sort)){ - List list = new ArrayList(); - if(sort.equals("lastmessage")){ - list.add(new Order(Direction.DESC,"status")) ; - list.add(new Order(Direction.DESC,"lastmessage")) ; - }else if(sort.equals("logintime")){ - list.add(new Order(Direction.DESC,"status")) ; - list.add(new Order(Direction.DESC,"createtime")) ; - }else if(sort.equals("default")){ - defaultSort = new Sort(Direction.DESC,"status") ; - Cookie name = new Cookie("sort",null); - name.setMaxAge(0); - response.addCookie(name); - } - if(list.size() > 0){ - defaultSort = new Sort(list) ; - Cookie name = new Cookie("sort",sort); - name.setMaxAge(60*60*24*365); - response.addCookie(name); - map.addAttribute("sort", sort) ; - } - }else{ - defaultSort = new Sort(Direction.DESC,"status") ; - } - List agentUserList = agentUserRepository.findByAgentnoAndOrgi(user.getId() , super.getOrgi(request) , defaultSort); - view.addObject("agentUserList", agentUserList) ; - - SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(super.getOrgi(request)) ; - - view.addObject("sessionConfig", sessionConfig) ; - if(sessionConfig.isOtherquickplay()) { - view.addObject("topicList", OnlineUserUtils.search(null, super.getOrgi(request), super.getUser(request))) ; - } - - if(agentUserList.size() > 0){ - AgentUser agentUser = agentUserList.get(0) ; - agentUser = (AgentUser) agentUserList.get(0); - view.addObject("curagentuser", agentUser); - view.addObject("inviteData", OnlineUserUtils.cousult(agentUser.getAppid(), agentUser.getOrgi(), inviteRepository)); - if(!StringUtils.isBlank(agentUser.getAgentserviceid())){ - List summarizes = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)) ; - if(summarizes.size() > 0){ - view.addObject("summary", summarizes.get(0)) ; - } - } - view.addObject("agentUserMessageList", this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid() , super.getOrgi(request), new PageRequest(0, 20, Direction.DESC , "updatetime"))); - AgentService agentService = null ; - if(!StringUtils.isBlank(agentUser.getAgentserviceid())){ - agentService = this.agentServiceRepository.findOne(agentUser.getAgentserviceid()) ; - view.addObject("curAgentService", agentService) ; - - if(agentService!=null){ - /** - * 获取关联数据 - */ - processRelaData(request, agentService, map); - } - } - - if(MainContext.ChannelTypeEnum.WEIXIN.toString().equals(agentUser.getChannel())){ - List weiXinUserList = weiXinUserRes.findByOpenidAndOrgi(agentUser.getUserid(), super.getOrgi(request)) ; - if(weiXinUserList.size() > 0){ - WeiXinUser weiXinUser = weiXinUserList.get(0) ; - view.addObject("weiXinUser",weiXinUser); - } - }else if(MainContext.ChannelTypeEnum.WEBIM.toString().equals(agentUser.getChannel())){ - List onlineUserList = this.onlineUserRes.findByUseridAndOrgi(agentUser.getUserid(), super.getOrgi(request)) ; - if(onlineUserList.size() > 0){ - OnlineUser onlineUser = onlineUserList.get(0) ; - if(MainContext.OnlineUserOperatorStatus.OFFLINE.toString().equals(onlineUser.getStatus())){ - onlineUser.setBetweentime((int) (onlineUser.getUpdatetime().getTime() - onlineUser.getLogintime().getTime())); - }else{ - onlineUser.setBetweentime((int) (System.currentTimeMillis() - onlineUser.getLogintime().getTime())); - } - view.addObject("onlineUser",onlineUser); - } - }else if(MainContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel())){ - if(agentService!=null && !StringUtils.isBlank(agentService.getOwner())) { - StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner()) ; - if(statusEvent!=null){ - if(!StringUtils.isBlank(statusEvent.getHostid())) { - PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid()) ; - view.addObject("pbxHost",pbxHost); - } - view.addObject("statusEvent",statusEvent); - } + @Autowired + private AgentStatusRepository agentStatusRepository; + + @Autowired + private AgentServiceRepository agentServiceRepository; + + @Autowired + private OnlineUserRepository onlineUserRes; + + @Autowired + private WeiXinUserRepository weiXinUserRes; + + @Autowired + private ServiceSummaryRepository serviceSummaryRes; + + @Autowired + private ChatMessageRepository chatMessageRepository; + + @Autowired + private AttachmentRepository attachementRes; + + @Autowired + private BlackListRepository blackListRes; + + @Autowired + private TagRepository tagRes; + + @Autowired + private OrganRepository organRes; + + @Autowired + private TagRelationRepository tagRelationRes; + + @Autowired + private QuickReplyRepository quickReplyRes; + + @Autowired + private QuickTypeRepository quickTypeRes; + + @Autowired + private AgentUserTaskRepository agentUserTaskRes; + + @Autowired + private SNSAccountRepository snsAccountRes; + + @Autowired + private UserRepository userRes; + + + @Autowired + private StatusEventRepository statusEventRes; + + @Autowired + private PbxHostRepository pbxHostRes; + + + @Autowired + private AgentUserContactsRepository agentUserContactsRes; + + + @Autowired + private ConsultInviteRepository inviteRepository; + + @Value("${web.upload-path}") + private String path; + + @RequestMapping("/index") + @Menu(type = "apps", subtype = "agent") + public ModelAndView index(ModelMap map, HttpServletRequest request, HttpServletResponse response, @Valid String sort) throws IOException, TemplateException { + ModelAndView view = request(super.createAppsTempletResponse("/apps/agent/index")); + User user = super.getUser(request); + Sort defaultSort = null; + if (StringUtils.isBlank(sort)) { + Cookie[] cookies = request.getCookies();//这样便可以获取一个cookie数组 + if (cookies != null) { + for (Cookie cookie : cookies) { + if (cookie.getName().equals("sort")) { + sort = cookie.getValue(); + break; + } + } + } + } + if (!StringUtils.isBlank(sort)) { + List list = new ArrayList(); + if (sort.equals("lastmessage")) { + list.add(new Order(Direction.DESC, "status")); + list.add(new Order(Direction.DESC, "lastmessage")); + } else if (sort.equals("logintime")) { + list.add(new Order(Direction.DESC, "status")); + list.add(new Order(Direction.DESC, "createtime")); + } else if (sort.equals("default")) { + defaultSort = new Sort(Direction.DESC, "status"); + Cookie name = new Cookie("sort", null); + name.setMaxAge(0); + response.addCookie(name); + } + if (list.size() > 0) { + defaultSort = new Sort(list); + Cookie name = new Cookie("sort", sort); + name.setMaxAge(60 * 60 * 24 * 365); + response.addCookie(name); + map.addAttribute("sort", sort); + } + } else { + defaultSort = new Sort(Direction.DESC, "status"); + } + List agentUserList = agentUserRepository.findByAgentnoAndOrgi(user.getId(), super.getOrgi(request), defaultSort); + view.addObject("agentUserList", agentUserList); + + SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(super.getOrgi(request)); + + view.addObject("sessionConfig", sessionConfig); + if (sessionConfig.isOtherquickplay()) { + view.addObject("topicList", OnlineUserUtils.search(null, super.getOrgi(request), super.getUser(request))); + } + + if (agentUserList.size() > 0) { + AgentUser agentUser = agentUserList.get(0); + agentUser = (AgentUser) agentUserList.get(0); + view.addObject("curagentuser", agentUser); + view.addObject("inviteData", OnlineUserUtils.cousult(agentUser.getAppid(), agentUser.getOrgi(), inviteRepository)); + if (!StringUtils.isBlank(agentUser.getAgentserviceid())) { + List summarizes = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)); + if (summarizes.size() > 0) { + view.addObject("summary", summarizes.get(0)); + } + } + + view.addObject("agentUserMessageList", this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid(), super.getOrgi(request), new PageRequest(0, 20, Direction.DESC, "updatetime"))); + AgentService agentService = null; + if (!StringUtils.isBlank(agentUser.getAgentserviceid())) { + agentService = this.agentServiceRepository.findOne(agentUser.getAgentserviceid()); + view.addObject("curAgentService", agentService); + + if (agentService != null) { + /** + * 获取关联数据 + */ + processRelaData(request, agentService, map); + } + } + + if (MainContext.ChannelTypeEnum.WEIXIN.toString().equals(agentUser.getChannel())) { + List weiXinUserList = weiXinUserRes.findByOpenidAndOrgi(agentUser.getUserid(), super.getOrgi(request)); + if (weiXinUserList.size() > 0) { + WeiXinUser weiXinUser = weiXinUserList.get(0); + view.addObject("weiXinUser", weiXinUser); + } + } else if (MainContext.ChannelTypeEnum.WEBIM.toString().equals(agentUser.getChannel())) { + List onlineUserList = this.onlineUserRes.findByUseridAndOrgi(agentUser.getUserid(), super.getOrgi(request)); + if (onlineUserList.size() > 0) { + OnlineUser onlineUser = onlineUserList.get(0); + if (MainContext.OnlineUserOperatorStatus.OFFLINE.toString().equals(onlineUser.getStatus())) { + onlineUser.setBetweentime((int) (onlineUser.getUpdatetime().getTime() - onlineUser.getLogintime().getTime())); + } else { + onlineUser.setBetweentime((int) (System.currentTimeMillis() - onlineUser.getLogintime().getTime())); + } + view.addObject("onlineUser", onlineUser); + } + } else if (MainContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel())) { + if (agentService != null && !StringUtils.isBlank(agentService.getOwner())) { + StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner()); + if (statusEvent != null) { + if (!StringUtils.isBlank(statusEvent.getHostid())) { + PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid()); + view.addObject("pbxHost", pbxHost); + } + view.addObject("statusEvent", statusEvent); + } MobileAddress ma = MobileNumberUtils.getAddress(agentUser.getPhone()); - view.addObject("mobileAddress", ma); - } - } - - view.addObject("serviceCount", Integer - .valueOf(this.agentServiceRepository - .countByUseridAndOrgiAndStatus(agentUser - .getUserid(), super.getOrgi(request), - MainContext.AgentUserStatusEnum.END.toString()))); - - view.addObject("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.USER.toString())) ; - view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid())) ; - view.addObject("quickReplyList", quickReplyRes.findByOrgiAndCreater(super.getOrgi(request) , super.getUser(request).getId() , null)) ; - List quickTypeList = quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request), MainContext.QuickTypeEnum.PUB.toString()) ; - List priQuickTypeList = quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId()) ; - quickTypeList.addAll(priQuickTypeList) ; - view.addObject("pubQuickTypeList", quickTypeList) ; - } - return view ; - } - - @RequestMapping("/agentusers") - @Menu(type = "apps", subtype = "agent") - public ModelAndView agentusers(HttpServletRequest request , String userid) { - ModelAndView view = request(super.createRequestPageTempletResponse("/apps/agent/agentusers")) ; - User user = super.getUser(request) ; - view.addObject("agentUserList", agentUserRepository.findByAgentnoAndOrgi(user.getId() , super.getOrgi(request) , new Sort(Direction.DESC,"status"))) ; - List agentUserList = agentUserRepository.findByUseridAndOrgi(userid, super.getOrgi(request)) ; - view.addObject("curagentuser", agentUserList!=null && agentUserList.size() > 0 ? agentUserList.get(0) : null) ; - - return view ; - } - - private void processRelaData(HttpServletRequest request , AgentService agentService , ModelMap map){ - Sort defaultSort = null ; - defaultSort = new Sort(Direction.DESC,"servicetime"); - map.addAttribute("agentServiceList", + view.addObject("mobileAddress", ma); + } + } + + view.addObject("serviceCount", Integer + .valueOf(this.agentServiceRepository + .countByUseridAndOrgiAndStatus(agentUser + .getUserid(), super.getOrgi(request), + MainContext.AgentUserStatusEnum.END.toString()))); + + view.addObject("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.USER.toString())); + view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid())); + view.addObject("quickReplyList", quickReplyRes.findByOrgiAndCreater(super.getOrgi(request), super.getUser(request).getId(), null)); + List quickTypeList = quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request), MainContext.QuickTypeEnum.PUB.toString()); + List priQuickTypeList = quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId()); + quickTypeList.addAll(priQuickTypeList); + view.addObject("pubQuickTypeList", quickTypeList); + } + return view; + } + + @RequestMapping("/agentusers") + @Menu(type = "apps", subtype = "agent") + public ModelAndView agentusers(HttpServletRequest request, String userid) { + ModelAndView view = request(super.createRequestPageTempletResponse("/apps/agent/agentusers")); + User user = super.getUser(request); + view.addObject("agentUserList", agentUserRepository.findByAgentnoAndOrgi(user.getId(), super.getOrgi(request), new Sort(Direction.DESC, "status"))); + List agentUserList = agentUserRepository.findByUseridAndOrgi(userid, super.getOrgi(request)); + view.addObject("curagentuser", agentUserList != null && agentUserList.size() > 0 ? agentUserList.get(0) : null); + + return view; + } + + private void processRelaData(HttpServletRequest request, AgentService agentService, ModelMap map) { + Sort defaultSort = null; + defaultSort = new Sort(Direction.DESC, "servicetime"); + map.addAttribute("agentServiceList", agentServiceRepository.findByUseridAndOrgiAndStatus( agentService.getUserid(), super.getOrgi(request), @@ -301,950 +302,948 @@ public class AgentController extends Handler { ) ); - if(!StringUtils.isBlank(agentService.getAppid())){ - map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(agentService.getAppid(), super.getOrgi(request)) ); - } - List relaList = agentUserContactsRes.findByUseridAndOrgi(agentService.getUserid(), agentService.getOrgi()) ; - if(relaList.size() > 0){ - AgentUserContacts agentUserContacts = relaList.get(0) ; - if(MainContext.model.get("contacts")!=null && !StringUtils.isBlank(agentUserContacts.getContactsid())){ - DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("contacts") ; - if(dataExchange!=null){ - map.addAttribute("contacts", dataExchange.getDataByIdAndOrgi(agentUserContacts.getContactsid(), super.getOrgi(request))) ; - } - } - if(MainContext.model.get("workorders")!=null && !StringUtils.isBlank(agentUserContacts.getContactsid())){ - DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("workorders") ; - if(dataExchange!=null){ - map.addAttribute("workOrdersList", dataExchange.getListDataByIdAndOrgi(agentUserContacts.getContactsid(), super.getUser(request).getId(), super.getOrgi(request))) ; - } - map.addAttribute("contactsid", agentUserContacts.getContactsid()) ; - } - } - } - - @RequestMapping("/agentuser") - @Menu(type = "apps", subtype = "agent") - public ModelAndView agentuser(ModelMap map, + if (!StringUtils.isBlank(agentService.getAppid())) { + map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(agentService.getAppid(), super.getOrgi(request))); + } + List relaList = agentUserContactsRes.findByUseridAndOrgi(agentService.getUserid(), agentService.getOrgi()); + if (relaList.size() > 0) { + AgentUserContacts agentUserContacts = relaList.get(0); + if (MainContext.model.get("contacts") != null && !StringUtils.isBlank(agentUserContacts.getContactsid())) { + DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("contacts"); + if (dataExchange != null) { + map.addAttribute("contacts", dataExchange.getDataByIdAndOrgi(agentUserContacts.getContactsid(), super.getOrgi(request))); + } + } + if (MainContext.model.get("workorders") != null && !StringUtils.isBlank(agentUserContacts.getContactsid())) { + DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("workorders"); + if (dataExchange != null) { + map.addAttribute("workOrdersList", dataExchange.getListDataByIdAndOrgi(agentUserContacts.getContactsid(), super.getUser(request).getId(), super.getOrgi(request))); + } + map.addAttribute("contactsid", agentUserContacts.getContactsid()); + } + } + } + + @RequestMapping("/agentuser") + @Menu(type = "apps", subtype = "agent") + public ModelAndView agentuser(ModelMap map, HttpServletRequest request, String id, String channel) throws IOException, TemplateException { - String mainagentuser = "/apps/agent/mainagentuser"; - if(channel.equals("phone")) { + String mainagentuser = "/apps/agent/mainagentuser"; + if (channel.equals("phone")) { mainagentuser = "/apps/agent/mainagentuser_callout"; } - ModelAndView view = request(super.createRequestPageTempletResponse(mainagentuser)) ; - AgentUser agentUser = agentUserRepository.findByIdAndOrgi(id, super.getOrgi(request)); - if(agentUser!=null){ - view.addObject("curagentuser", agentUser) ; - view.addObject("inviteData", OnlineUserUtils.cousult(agentUser.getAppid(), agentUser.getOrgi(), inviteRepository)); - List agentUserTaskList = agentUserTaskRes.findByIdAndOrgi(id, super.getOrgi(request)) ; - if(agentUserTaskList.size() > 0){ - AgentUserTask agentUserTask = agentUserTaskList.get(0) ; - agentUserTask.setTokenum(0); - agentUserTaskRes.save(agentUserTask) ; - } + ModelAndView view = request(super.createRequestPageTempletResponse(mainagentuser)); + AgentUser agentUser = agentUserRepository.findByIdAndOrgi(id, super.getOrgi(request)); + if (agentUser != null) { + view.addObject("curagentuser", agentUser); + view.addObject("inviteData", OnlineUserUtils.cousult(agentUser.getAppid(), agentUser.getOrgi(), inviteRepository)); + List agentUserTaskList = agentUserTaskRes.findByIdAndOrgi(id, super.getOrgi(request)); + if (agentUserTaskList.size() > 0) { + AgentUserTask agentUserTask = agentUserTaskList.get(0); + agentUserTask.setTokenum(0); + agentUserTaskRes.save(agentUserTask); + } - if(!StringUtils.isBlank(agentUser.getAgentserviceid())){ - List summarizes = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)) ; - if(summarizes.size() > 0){ - view.addObject("summary", summarizes.get(0)) ; - } - } - - view.addObject("agentUserMessageList", this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid() , super.getOrgi(request), new PageRequest(0, 20, Direction.DESC , "updatetime"))); - AgentService agentService = null ; - if(!StringUtils.isBlank(agentUser.getAgentserviceid())){ - agentService = this.agentServiceRepository.findOne(agentUser.getAgentserviceid()) ; - view.addObject("curAgentService", agentService) ; - if(agentService!=null){ - /** - * 获取关联数据 - */ - processRelaData(request, agentService, map); - } - } - if(MainContext.ChannelTypeEnum.WEIXIN.toString().equals(agentUser.getChannel())){ - List weiXinUserList = weiXinUserRes.findByOpenidAndOrgi(agentUser.getUserid(), super.getOrgi(request)) ; - if(weiXinUserList.size() > 0){ - WeiXinUser weiXinUser = weiXinUserList.get(0) ; - view.addObject("weiXinUser",weiXinUser); - } - }else if(MainContext.ChannelTypeEnum.WEBIM.toString().equals(agentUser.getChannel())){ - List onlineUserList = this.onlineUserRes.findByUseridAndOrgi(agentUser.getUserid(), super.getOrgi(request)) ; - if(onlineUserList.size() > 0){ - OnlineUser onlineUser = onlineUserList.get(0) ; - if(onlineUser.getLogintime()!=null) { - if(MainContext.OnlineUserOperatorStatus.OFFLINE.toString().equals(onlineUser.getStatus())){ - onlineUser.setBetweentime((int) (onlineUser.getUpdatetime().getTime() - onlineUser.getLogintime().getTime())); - }else{ - onlineUser.setBetweentime((int) (System.currentTimeMillis() - onlineUser.getLogintime().getTime())); - } - } - view.addObject("onlineUser",onlineUser); - } - }else if(MainContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel())){ - if(agentService!=null && !StringUtils.isBlank(agentService.getOwner())) { - StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner()) ; - if(statusEvent!=null){ - if(!StringUtils.isBlank(statusEvent.getHostid())) { - PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid()) ; - view.addObject("pbxHost",pbxHost); - } - view.addObject("statusEvent",statusEvent); - } - } - } - - - view.addObject("serviceCount", Integer - .valueOf(this.agentServiceRepository - .countByUseridAndOrgiAndStatus(agentUser - .getUserid(), super.getOrgi(request), - MainContext.AgentUserStatusEnum.END - .toString()))); - view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid())) ; - } - - SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(super.getOrgi(request)) ; - - view.addObject("sessionConfig", sessionConfig) ; - if(sessionConfig.isOtherquickplay()) { - view.addObject("topicList", OnlineUserUtils.search(null, super.getOrgi(request), super.getUser(request))) ; - } - - - view.addObject("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.USER.toString())) ; - view.addObject("quickReplyList", quickReplyRes.findByOrgiAndCreater(super.getOrgi(request) , super.getUser(request).getId() , null)) ; - List quickTypeList = quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request), MainContext.QuickTypeEnum.PUB.toString()) ; - List priQuickTypeList = quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId()) ; - quickTypeList.addAll(priQuickTypeList) ; - view.addObject("pubQuickTypeList", quickTypeList) ; + if (!StringUtils.isBlank(agentUser.getAgentserviceid())) { + List summarizes = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)); + if (summarizes.size() > 0) { + view.addObject("summary", summarizes.get(0)); + } + } - return view ; - } - - @RequestMapping("/other/topic") - @Menu(type = "apps", subtype = "othertopic") - public ModelAndView othertopic(ModelMap map ,HttpServletRequest request , String q) throws IOException, TemplateException { - SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(super.getOrgi(request)) ; - - map.put("sessionConfig", sessionConfig) ; - if(sessionConfig.isOtherquickplay()) { - map.put("topicList", OnlineUserUtils.search(q, super.getOrgi(request), super.getUser(request))) ; - } - - return request(super.createRequestPageTempletResponse("/apps/agent/othertopic")) ; - } - - @RequestMapping("/other/topic/detail") - @Menu(type = "apps", subtype = "othertopicdetail") - public ModelAndView othertopicdetail(ModelMap map ,HttpServletRequest request , String id) throws IOException, TemplateException { - SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(super.getOrgi(request)) ; - - map.put("sessionConfig", sessionConfig) ; - if(sessionConfig.isOtherquickplay()) { - map.put("topic", OnlineUserUtils.detail(id, super.getOrgi(request), super.getUser(request))) ; - } - - return request(super.createRequestPageTempletResponse("/apps/agent/topicdetail")) ; - } - - - - @RequestMapping("/workorders/list") - @Menu(type = "apps", subtype = "workorderslist") - public ModelAndView workorderslist(HttpServletRequest request , String contactsid , ModelMap map) { - if(MainContext.model.get("workorders")!=null && !StringUtils.isBlank(contactsid)){ - DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("workorders") ; - if(dataExchange!=null){ - map.addAttribute("workOrdersList", dataExchange.getListDataByIdAndOrgi(contactsid , super.getUser(request).getId(), super.getOrgi(request))) ; - } - map.addAttribute("contactsid", contactsid) ; - } - return request(super.createRequestPageTempletResponse("/apps/agent/workorders")) ; - } - - - @RequestMapping(value="/ready") - @Menu(type = "apps", subtype = "agent") - public ModelAndView ready(HttpServletRequest request){ - User user = super.getUser(request) ; - List agentStatusList = agentStatusRepository.findByAgentnoAndOrgi(user.getId() , super.getOrgi(request)); - AgentStatus agentStatus = null ; - if(agentStatusList.size() > 0){ - agentStatus = agentStatusList.get(0) ; - }else{ - agentStatus = new AgentStatus() ; - agentStatus.setUserid(user.getId()); - agentStatus.setUsername(user.getUname()); - agentStatus.setAgentno(user.getId()); - agentStatus.setLogindate(new Date()); - - if(!StringUtils.isBlank(user.getOrgan())){ - Organ organ = organRes.findByIdAndOrgi(user.getOrgan(), super.getOrgiByTenantshare(request)) ; - if(organ!=null && organ.isSkill()){ - agentStatus.setSkill(organ.getId()); - agentStatus.setSkillname(organ.getName()); - } - } - agentStatus.setUpdatetime(new Date()); - SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(super.getOrgi(request)) ; - - agentStatus.setUsers(agentUserRepository.countByAgentnoAndStatusAndOrgi(user.getId(), MainContext.AgentUserStatusEnum.INSERVICE.toString(), super.getOrgi(request))); - - agentStatus.setOrgi(super.getOrgi(request)); - agentStatus.setMaxusers(sessionConfig.getMaxuser()); - agentStatusRepository.save(agentStatus) ; - } - if(agentStatus!=null){ - /** - * 更新当前用户状态 - */ - agentStatus.setUsers(AutomaticServiceDist.getAgentUsers(agentStatus.getAgentno(), super.getOrgi(request))); - agentStatus.setStatus(MainContext.AgentStatusEnum.READY.toString()); - CacheHelper.getAgentStatusCacheBean().put(agentStatus.getAgentno(), agentStatus, super.getOrgi(request)); - - AutomaticServiceDist.allotAgent(agentStatus.getAgentno(), super.getOrgi(request)); - - AutomaticServiceDist.recordAgentStatus(agentStatus.getAgentno(),agentStatus.getUsername(), agentStatus.getAgentno(), agentStatus.getSkill(), "0".equals(super.getUser(request).getUsertype()) ,agentStatus.getAgentno(), MainContext.AgentStatusEnum.OFFLINE.toString(), MainContext.AgentStatusEnum.READY.toString(), MainContext.AgentWorkType.MEIDIACHAT.toString() , agentStatus.getOrgi() , null); - } - - return request(super.createRequestPageTempletResponse("/public/success")) ; + view.addObject("agentUserMessageList", this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid(), super.getOrgi(request), new PageRequest(0, 20, Direction.DESC, "updatetime"))); + AgentService agentService = null; + if (!StringUtils.isBlank(agentUser.getAgentserviceid())) { + agentService = this.agentServiceRepository.findOne(agentUser.getAgentserviceid()); + view.addObject("curAgentService", agentService); + if (agentService != null) { + /** + * 获取关联数据 + */ + processRelaData(request, agentService, map); + } + } + if (MainContext.ChannelTypeEnum.WEIXIN.toString().equals(agentUser.getChannel())) { + List weiXinUserList = weiXinUserRes.findByOpenidAndOrgi(agentUser.getUserid(), super.getOrgi(request)); + if (weiXinUserList.size() > 0) { + WeiXinUser weiXinUser = weiXinUserList.get(0); + view.addObject("weiXinUser", weiXinUser); + } + } else if (MainContext.ChannelTypeEnum.WEBIM.toString().equals(agentUser.getChannel())) { + List onlineUserList = this.onlineUserRes.findByUseridAndOrgi(agentUser.getUserid(), super.getOrgi(request)); + if (onlineUserList.size() > 0) { + OnlineUser onlineUser = onlineUserList.get(0); + if (onlineUser.getLogintime() != null) { + if (MainContext.OnlineUserOperatorStatus.OFFLINE.toString().equals(onlineUser.getStatus())) { + onlineUser.setBetweentime((int) (onlineUser.getUpdatetime().getTime() - onlineUser.getLogintime().getTime())); + } else { + onlineUser.setBetweentime((int) (System.currentTimeMillis() - onlineUser.getLogintime().getTime())); + } + } + view.addObject("onlineUser", onlineUser); + } + } else if (MainContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel())) { + if (agentService != null && !StringUtils.isBlank(agentService.getOwner())) { + StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner()); + if (statusEvent != null) { + if (!StringUtils.isBlank(statusEvent.getHostid())) { + PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid()); + view.addObject("pbxHost", pbxHost); + } + view.addObject("statusEvent", statusEvent); + } + } + } + + + view.addObject("serviceCount", Integer + .valueOf(this.agentServiceRepository + .countByUseridAndOrgiAndStatus(agentUser + .getUserid(), super.getOrgi(request), + MainContext.AgentUserStatusEnum.END + .toString()))); + view.addObject("tagRelationList", tagRelationRes.findByUserid(agentUser.getUserid())); + } + + SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(super.getOrgi(request)); + + view.addObject("sessionConfig", sessionConfig); + if (sessionConfig.isOtherquickplay()) { + view.addObject("topicList", OnlineUserUtils.search(null, super.getOrgi(request), super.getUser(request))); + } + + + view.addObject("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.USER.toString())); + view.addObject("quickReplyList", quickReplyRes.findByOrgiAndCreater(super.getOrgi(request), super.getUser(request).getId(), null)); + List quickTypeList = quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request), MainContext.QuickTypeEnum.PUB.toString()); + List priQuickTypeList = quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId()); + quickTypeList.addAll(priQuickTypeList); + view.addObject("pubQuickTypeList", quickTypeList); + + return view; } - - @RequestMapping(value="/notready") - @Menu(type = "apps", subtype = "agent") - public ModelAndView notready(HttpServletRequest request){ - User user = super.getUser(request) ; - if(user!=null) { - AutomaticServiceDist.deleteAgentStatus(user.getId(), user.getOrgi(), "0".equals(user.getUsertype())); - } - return request(super.createRequestPageTempletResponse("/public/success")) ; + + @RequestMapping("/other/topic") + @Menu(type = "apps", subtype = "othertopic") + public ModelAndView othertopic(ModelMap map, HttpServletRequest request, String q) throws IOException, TemplateException { + SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(super.getOrgi(request)); + + map.put("sessionConfig", sessionConfig); + if (sessionConfig.isOtherquickplay()) { + map.put("topicList", OnlineUserUtils.search(q, super.getOrgi(request), super.getUser(request))); + } + + return request(super.createRequestPageTempletResponse("/apps/agent/othertopic")); } - - @RequestMapping(value="/busy") - @Menu(type = "apps", subtype = "agent") - public ModelAndView busy(HttpServletRequest request){ - User user = super.getUser(request) ; - List agentStatusList = agentStatusRepository.findByAgentnoAndOrgi(user.getId() , super.getOrgi(request)); - AgentStatus agentStatus = null ; - if(agentStatusList.size() > 0){ - agentStatus = agentStatusList.get(0) ; - agentStatus.setBusy(true); - AutomaticServiceDist.recordAgentStatus(agentStatus.getAgentno(),agentStatus.getUsername(), agentStatus.getAgentno(), agentStatus.getSkill(), "0".equals(super.getUser(request).getUsertype()),agentStatus.getAgentno(), MainContext.AgentStatusEnum.READY.toString(), MainContext.AgentStatusEnum.BUSY.toString(), MainContext.AgentWorkType.MEIDIACHAT.toString() , agentStatus.getOrgi() , agentStatus.getUpdatetime()); - agentStatus.setUpdatetime(new Date()); - agentStatusRepository.save(agentStatus); - CacheHelper.getAgentStatusCacheBean().put(agentStatus.getAgentno(), agentStatus, super.getOrgi(request)); - } - AutomaticServiceDist.publishMessage(super.getOrgi(request) , "agent" , "busy" , user.getId()); - - return request(super.createRequestPageTempletResponse("/public/success")) ; + + @RequestMapping("/other/topic/detail") + @Menu(type = "apps", subtype = "othertopicdetail") + public ModelAndView othertopicdetail(ModelMap map, HttpServletRequest request, String id) throws IOException, TemplateException { + SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(super.getOrgi(request)); + + map.put("sessionConfig", sessionConfig); + if (sessionConfig.isOtherquickplay()) { + map.put("topic", OnlineUserUtils.detail(id, super.getOrgi(request), super.getUser(request))); + } + + return request(super.createRequestPageTempletResponse("/apps/agent/topicdetail")); } - - @RequestMapping(value="/notbusy") - @Menu(type = "apps", subtype = "agent") - public ModelAndView notbusy(HttpServletRequest request){ - User user = super.getUser(request) ; - List agentStatusList = agentStatusRepository.findByAgentnoAndOrgi(user.getId() , super.getOrgi(request)); - AgentStatus agentStatus = null ; - if(agentStatusList.size() > 0){ - agentStatus = agentStatusList.get(0) ; - agentStatus.setBusy(false); - AutomaticServiceDist.recordAgentStatus(agentStatus.getAgentno(),agentStatus.getUsername(), agentStatus.getAgentno(), agentStatus.getSkill(),"0".equals(super.getUser(request).getUsertype()), agentStatus.getAgentno(), MainContext.AgentStatusEnum.BUSY.toString(), MainContext.AgentStatusEnum.READY.toString(), MainContext.AgentWorkType.MEIDIACHAT.toString() , agentStatus.getOrgi() , agentStatus.getUpdatetime()); - - agentStatus.setUpdatetime(new Date()); - agentStatusRepository.save(agentStatus); - CacheHelper.getAgentStatusCacheBean().put(agentStatus.getAgentno(), agentStatus,super.getOrgi(request)); - AutomaticServiceDist.allotAgent(agentStatus.getAgentno(), super.getOrgi(request)); - } - return request(super.createRequestPageTempletResponse("/public/success")) ; + + + @RequestMapping("/workorders/list") + @Menu(type = "apps", subtype = "workorderslist") + public ModelAndView workorderslist(HttpServletRequest request, String contactsid, ModelMap map) { + if (MainContext.model.get("workorders") != null && !StringUtils.isBlank(contactsid)) { + DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("workorders"); + if (dataExchange != null) { + map.addAttribute("workOrdersList", dataExchange.getListDataByIdAndOrgi(contactsid, super.getUser(request).getId(), super.getOrgi(request))); + } + map.addAttribute("contactsid", contactsid); + } + return request(super.createRequestPageTempletResponse("/apps/agent/workorders")); } - - @RequestMapping(value="/clean") - @Menu(type = "apps", subtype = "clean" , access= false) - public ModelAndView clean(HttpServletRequest request) throws Exception{ - List agentUserList = agentUserRepository.findByAgentnoAndStatusAndOrgi(super.getUser(request).getId(), MainContext.AgentUserStatusEnum.END.toString(), super.getOrgi(request)); - List agentServiceList = new ArrayList(); - for(AgentUser agentUser : agentUserList){ - if(agentUser!=null && super.getUser(request).getId().equals(agentUser.getAgentno())){ - AutomaticServiceDist.deleteAgentUser(agentUser, super.getOrgi(request)); - AgentService agentService = agentServiceRepository.findByIdAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)) ; - if(agentService!=null){ - agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString()); - agentServiceList.add(agentService) ; - } - } - } - agentServiceRepository.save(agentServiceList) ; - return request(super - .createRequestPageTempletResponse("redirect:/agent/index.html")); + + + @RequestMapping(value = "/ready") + @Menu(type = "apps", subtype = "agent") + public ModelAndView ready(HttpServletRequest request) { + User user = super.getUser(request); + List agentStatusList = agentStatusRepository.findByAgentnoAndOrgi(user.getId(), super.getOrgi(request)); + AgentStatus agentStatus = null; + if (agentStatusList.size() > 0) { + agentStatus = agentStatusList.get(0); + } else { + agentStatus = new AgentStatus(); + agentStatus.setUserid(user.getId()); + agentStatus.setUsername(user.getUname()); + agentStatus.setAgentno(user.getId()); + agentStatus.setLogindate(new Date()); + + if (!StringUtils.isBlank(user.getOrgan())) { + Organ organ = organRes.findByIdAndOrgi(user.getOrgan(), super.getOrgiByTenantshare(request)); + if (organ != null && organ.isSkill()) { + agentStatus.setSkill(organ.getId()); + agentStatus.setSkillname(organ.getName()); + } + } + agentStatus.setUpdatetime(new Date()); + SessionConfig sessionConfig = AutomaticServiceDist.initSessionConfig(super.getOrgi(request)); + + agentStatus.setUsers(agentUserRepository.countByAgentnoAndStatusAndOrgi(user.getId(), MainContext.AgentUserStatusEnum.INSERVICE.toString(), super.getOrgi(request))); + + agentStatus.setOrgi(super.getOrgi(request)); + agentStatus.setMaxusers(sessionConfig.getMaxuser()); + agentStatusRepository.save(agentStatus); + } + if (agentStatus != null) { + /** + * 更新当前用户状态 + */ + agentStatus.setUsers(AutomaticServiceDist.getAgentUsers(agentStatus.getAgentno(), super.getOrgi(request))); + agentStatus.setStatus(MainContext.AgentStatusEnum.READY.toString()); + CacheHelper.getAgentStatusCacheBean().put(agentStatus.getAgentno(), agentStatus, super.getOrgi(request)); + + AutomaticServiceDist.allotAgent(agentStatus.getAgentno(), super.getOrgi(request)); + + AutomaticServiceDist.recordAgentStatus(agentStatus.getAgentno(), agentStatus.getUsername(), agentStatus.getAgentno(), agentStatus.getSkill(), "0".equals(super.getUser(request).getUsertype()), agentStatus.getAgentno(), MainContext.AgentStatusEnum.OFFLINE.toString(), MainContext.AgentStatusEnum.READY.toString(), MainContext.AgentWorkType.MEIDIACHAT.toString(), agentStatus.getOrgi(), null); + } + + return request(super.createRequestPageTempletResponse("/public/success")); } - - - @RequestMapping({ "/end" }) - @Menu(type = "apps", subtype = "agent") - public ModelAndView end(HttpServletRequest request, @Valid String userid) - throws Exception { - AgentUser agentUser = agentUserRepository.findByIdAndOrgi(userid, super.getOrgi(request)); - if(agentUser!=null && super.getUser(request).getId().equals(agentUser.getAgentno())){ - AutomaticServiceDist.deleteAgentUser(agentUser, super.getOrgi(request)); - if(!StringUtils.isBlank(agentUser.getAgentserviceid())){ - AgentService agentService = agentServiceRepository.findByIdAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)) ; - agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString()); - agentServiceRepository.save(agentService) ; - } - } - return request(super - .createRequestPageTempletResponse("redirect:/agent/index.html")); - } - - @RequestMapping({ "/readmsg" }) - @Menu(type = "apps", subtype = "agent") - public ModelAndView readmsg(HttpServletRequest request, @Valid String userid) - throws Exception { - List agentUserTaskList = agentUserTaskRes.findByIdAndOrgi(userid, super.getOrgi(request)) ; - if(agentUserTaskList.size() > 0){ - AgentUserTask agentUserTask = agentUserTaskList.get(0) ; - agentUserTask.setTokenum(0); - agentUserTaskRes.save(agentUserTask); - } - return request(super.createRequestPageTempletResponse("/public/success")); - } - - @RequestMapping({ "/blacklist/add" }) - @Menu(type = "apps", subtype = "blacklist") - public ModelAndView blacklistadd(ModelMap map , HttpServletRequest request, @Valid String agentuserid , @Valid String agentserviceid , @Valid String userid) - throws Exception { - map.addAttribute("agentuserid", agentuserid); - map.addAttribute("agentserviceid", agentserviceid); - map.addAttribute("userid", userid); - map.addAttribute("agentUser", agentUserRepository.findByIdAndOrgi(userid, super.getOrgi(request))); - return request(super.createRequestPageTempletResponse("/apps/agent/blacklistadd")) ; - } - - @RequestMapping({ "/blacklist/save" }) - @Menu(type = "apps", subtype = "blacklist") - public ModelAndView blacklist(HttpServletRequest request, @Valid String agentuserid , @Valid String agentserviceid , @Valid String userid , @Valid BlackEntity blackEntity) - throws Exception { - User user = super.getUser(request); - List agentUserList = this.agentUserRepository.findByUseridAndOrgi(userid, super.getOrgi(request)) ; - if(agentUserList.size() > 0){ - AgentUser agentUser = agentUserList.get(0) ; - BlackEntity tempBlackEntiry = blackListRes.findByUseridAndOrgi(agentUser.getUserid(), super.getOrgi(request)) ; - if(tempBlackEntiry == null){ - blackEntity.setUserid(userid); - blackEntity.setCreater(user.getId()); - blackEntity.setOrgi(super.getOrgi(request)); - if(blackEntity.getControltime() > 0){ - blackEntity.setEndtime(new Date(System.currentTimeMillis() + blackEntity.getControltime()*3600*1000L)); - } - blackEntity.setAgentid(user.getId()); - blackEntity.setAgentuser(agentUser.getUsername()); - blackEntity.setSessionid(agentUser.getSessionid()); - blackEntity.setAgentserviceid(agentserviceid); - blackEntity.setChannel(agentUser.getChannel()); - blackListRes.save(blackEntity) ; - }else{ - if(blackEntity.getControltime() > 0){ - tempBlackEntiry.setEndtime(new Date(System.currentTimeMillis() + blackEntity.getControltime()*3600*1000L)); - } - tempBlackEntiry.setDescription(tempBlackEntiry.getDescription()); - tempBlackEntiry.setControltime(blackEntity.getControltime()); - tempBlackEntiry.setAgentuser(agentUser.getUsername()); - blackListRes.save(tempBlackEntiry) ; - blackEntity = tempBlackEntiry ; - } - if(!StringUtils.isBlank(userid)){ - CacheHelper.getSystemCacheBean().put(userid, blackEntity, super.getOrgi(request)); - } - } - return end(request , agentuserid); - } - - @RequestMapping("/tagrelation") - @Menu(type = "apps", subtype = "tagrelation") - public ModelAndView tagrelation(ModelMap map , HttpServletRequest request , @Valid String userid , @Valid String tagid,@Valid String dataid) { - TagRelation tagRelation = tagRelationRes.findByUseridAndTagid(userid, tagid) ; - if(tagRelation==null){ - tagRelation = new TagRelation(); - tagRelation.setUserid(userid); - tagRelation.setTagid(tagid); - tagRelation.setDataid(dataid); - tagRelationRes.save(tagRelation) ; - }else{ - tagRelationRes.delete(tagRelation); - } - return request(super - .createRequestPageTempletResponse("/public/success")); + + @RequestMapping(value = "/notready") + @Menu(type = "apps", subtype = "agent") + public ModelAndView notready(HttpServletRequest request) { + User user = super.getUser(request); + if (user != null) { + AutomaticServiceDist.deleteAgentStatus(user.getId(), user.getOrgi(), "0".equals(user.getUsertype())); + } + return request(super.createRequestPageTempletResponse("/public/success")); } - - @RequestMapping("/image/upload") - @Menu(type = "im" , subtype = "image" , access = false) - public ModelAndView upload(ModelMap map,HttpServletRequest request , @RequestParam(value = "imgFile", required = false) MultipartFile imgFile , @Valid String id, @Valid String paste) throws IOException { - ModelAndView view = request(super.createRequestPageTempletResponse("/apps/agent/upload")) ; - UploadStatus upload = null ; - String fileName = null ; - if(imgFile!=null && imgFile.getOriginalFilename().lastIndexOf(".") > 0){ - File uploadDir = new File(path , "upload"); - if(!uploadDir.exists()){ - uploadDir.mkdirs() ; - } - String fileid = MainUtils.md5(imgFile.getBytes()) , fileURL = null , targetFile = null; - ChatMessage data = new ChatMessage() ; - if(imgFile.getContentType()!=null && imgFile.getContentType().indexOf("image") >= 0){ - fileName = "upload/"+fileid+"_original" ; - File imageFile = new File(path , fileName) ; - FileCopyUtils.copy(imgFile.getBytes(), imageFile); - targetFile = "upload/"+fileid ; - MainUtils.processImage(new File(path , targetFile), imageFile) ; - - - fileURL = "/res/image.html?id="+targetFile ; - if(request.getServerPort() == 80){ - fileURL = "/res/image.html?id="+targetFile; - }else{ - fileURL = "/res/image.html?id="+targetFile; - } - upload = new UploadStatus("0" , fileURL); //图片直接发送给 客户,不用返回 - data.setAttachmentid(fileid); - }else{ - String attachid = processAttachmentFile(imgFile, request) ; - - upload = new UploadStatus("0" , "/res/file.html?id="+attachid); - fileURL = "/res/file.html?id="+attachid ; - if(request.getServerPort() == 80){ - fileURL = "/res/file.html?id="+attachid; - }else{ - fileURL = "/res/file.html?id="+attachid; - } - } - data.setFilename(imgFile.getOriginalFilename()); - data.setFilesize((int) imgFile.getSize()); - - OutMessageRouter router = null ; - AgentUser agentUser = agentUserRepository.findByIdAndOrgi(id, super.getOrgi(request)) ; - - if(agentUser!=null && paste == null){ - router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()) ; - MessageOutContent outMessage = new MessageOutContent() ; - if(router!=null){ - outMessage.setMessage(fileURL); - outMessage.setFilename(imgFile.getOriginalFilename()); - outMessage.setFilesize((int) imgFile.getSize()); - if(imgFile.getContentType()!=null && imgFile.getContentType().indexOf("image") >= 0){ - outMessage.setMessageType(MainContext.MediaTypeEnum.IMAGE.toString()); - data.setMsgtype(MainContext.MediaTypeEnum.IMAGE.toString()); - }else{ - outMessage.setMessageType(MainContext.MediaTypeEnum.FILE.toString()); - data.setMsgtype(MainContext.MediaTypeEnum.FILE.toString()); - } - outMessage.setCalltype(MainContext.CallTypeEnum.OUT.toString()); - outMessage.setCreatetime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); - outMessage.setNickName(super.getUser(request).getUsername()); - - router.handler(agentUser.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), agentUser.getAppid(), outMessage); - } - //同时发送消息给 坐席 - data.setMessage(fileURL); - data.setId(MainUtils.getUUID()); - data.setContextid(agentUser.getContextid()); - - data.setAgentserviceid(agentUser.getAgentserviceid()); - - data.setCalltype(MainContext.CallTypeEnum.OUT.toString()); - if(!StringUtils.isBlank(agentUser.getAgentno())){ - data.setTouser(agentUser.getUserid()); - } - data.setChannel(agentUser.getChannel()); - - data.setUsession(agentUser.getUserid()); - data.setAppid(agentUser.getAppid()); - data.setUserid(super.getUser(request).getId()); - - data.setOrgi(super.getUser(request).getOrgi()); - - data.setCreater(super.getUser(request).getId()); - data.setUsername(super.getUser(request).getUsername()); - - chatMessageRepository.save(data) ; - - NettyClients.getInstance().sendAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data); - } - - }else{ - upload = new UploadStatus("请选择图片文件"); - } - map.addAttribute("upload", upload) ; - return view ; + + @RequestMapping(value = "/busy") + @Menu(type = "apps", subtype = "agent") + public ModelAndView busy(HttpServletRequest request) { + User user = super.getUser(request); + List agentStatusList = agentStatusRepository.findByAgentnoAndOrgi(user.getId(), super.getOrgi(request)); + AgentStatus agentStatus = null; + if (agentStatusList.size() > 0) { + agentStatus = agentStatusList.get(0); + agentStatus.setBusy(true); + AutomaticServiceDist.recordAgentStatus(agentStatus.getAgentno(), agentStatus.getUsername(), agentStatus.getAgentno(), agentStatus.getSkill(), "0".equals(super.getUser(request).getUsertype()), agentStatus.getAgentno(), MainContext.AgentStatusEnum.READY.toString(), MainContext.AgentStatusEnum.BUSY.toString(), MainContext.AgentWorkType.MEIDIACHAT.toString(), agentStatus.getOrgi(), agentStatus.getUpdatetime()); + agentStatus.setUpdatetime(new Date()); + agentStatusRepository.save(agentStatus); + CacheHelper.getAgentStatusCacheBean().put(agentStatus.getAgentno(), agentStatus, super.getOrgi(request)); + } + AutomaticServiceDist.publishMessage(super.getOrgi(request), "agent", "busy", user.getId()); + + return request(super.createRequestPageTempletResponse("/public/success")); } - - @RequestMapping("/message/image") - @Menu(type = "resouce" , subtype = "image" , access = true) - public ModelAndView messageimage(HttpServletResponse response,ModelMap map, @Valid String id, @Valid String t) throws IOException { - ChatMessage message = chatMessageRepository.findById(id) ; - map.addAttribute("chatMessage", message) ; - map.addAttribute("agentUser", CacheHelper.getAgentUserCacheBean().getCacheObject(message.getUserid(), message.getOrgi())) ; + + @RequestMapping(value = "/notbusy") + @Menu(type = "apps", subtype = "agent") + public ModelAndView notbusy(HttpServletRequest request) { + User user = super.getUser(request); + List agentStatusList = agentStatusRepository.findByAgentnoAndOrgi(user.getId(), super.getOrgi(request)); + AgentStatus agentStatus = null; + if (agentStatusList.size() > 0) { + agentStatus = agentStatusList.get(0); + agentStatus.setBusy(false); + AutomaticServiceDist.recordAgentStatus(agentStatus.getAgentno(), agentStatus.getUsername(), agentStatus.getAgentno(), agentStatus.getSkill(), "0".equals(super.getUser(request).getUsertype()), agentStatus.getAgentno(), MainContext.AgentStatusEnum.BUSY.toString(), MainContext.AgentStatusEnum.READY.toString(), MainContext.AgentWorkType.MEIDIACHAT.toString(), agentStatus.getOrgi(), agentStatus.getUpdatetime()); + + agentStatus.setUpdatetime(new Date()); + agentStatusRepository.save(agentStatus); + CacheHelper.getAgentStatusCacheBean().put(agentStatus.getAgentno(), agentStatus, super.getOrgi(request)); + AutomaticServiceDist.allotAgent(agentStatus.getAgentno(), super.getOrgi(request)); + } + return request(super.createRequestPageTempletResponse("/public/success")); + } + + @RequestMapping(value = "/clean") + @Menu(type = "apps", subtype = "clean", access = false) + public ModelAndView clean(HttpServletRequest request) throws Exception { + List agentUserList = agentUserRepository.findByAgentnoAndStatusAndOrgi(super.getUser(request).getId(), MainContext.AgentUserStatusEnum.END.toString(), super.getOrgi(request)); + List agentServiceList = new ArrayList(); + for (AgentUser agentUser : agentUserList) { + if (agentUser != null && super.getUser(request).getId().equals(agentUser.getAgentno())) { + AutomaticServiceDist.deleteAgentUser(agentUser, super.getOrgi(request)); + AgentService agentService = agentServiceRepository.findByIdAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)); + if (agentService != null) { + agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString()); + agentServiceList.add(agentService); + } + } + } + agentServiceRepository.save(agentServiceList); + return request(super + .createRequestPageTempletResponse("redirect:/agent/index.html")); + } + + + @RequestMapping({"/end"}) + @Menu(type = "apps", subtype = "agent") + public ModelAndView end(HttpServletRequest request, @Valid String userid) + throws Exception { + AgentUser agentUser = agentUserRepository.findByIdAndOrgi(userid, super.getOrgi(request)); + if (agentUser != null && super.getUser(request).getId().equals(agentUser.getAgentno())) { + AutomaticServiceDist.deleteAgentUser(agentUser, super.getOrgi(request)); + if (!StringUtils.isBlank(agentUser.getAgentserviceid())) { + AgentService agentService = agentServiceRepository.findByIdAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)); + agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString()); + agentServiceRepository.save(agentService); + } + } + return request(super + .createRequestPageTempletResponse("redirect:/agent/index.html")); + } + + @RequestMapping({"/readmsg"}) + @Menu(type = "apps", subtype = "agent") + public ModelAndView readmsg(HttpServletRequest request, @Valid String userid) + throws Exception { + List agentUserTaskList = agentUserTaskRes.findByIdAndOrgi(userid, super.getOrgi(request)); + if (agentUserTaskList.size() > 0) { + AgentUserTask agentUserTask = agentUserTaskList.get(0); + agentUserTask.setTokenum(0); + agentUserTaskRes.save(agentUserTask); + } + return request(super.createRequestPageTempletResponse("/public/success")); + } + + @RequestMapping({"/blacklist/add"}) + @Menu(type = "apps", subtype = "blacklist") + public ModelAndView blacklistadd(ModelMap map, HttpServletRequest request, @Valid String agentuserid, @Valid String agentserviceid, @Valid String userid) + throws Exception { + map.addAttribute("agentuserid", agentuserid); + map.addAttribute("agentserviceid", agentserviceid); + map.addAttribute("userid", userid); + map.addAttribute("agentUser", agentUserRepository.findByIdAndOrgi(userid, super.getOrgi(request))); + return request(super.createRequestPageTempletResponse("/apps/agent/blacklistadd")); + } + + @RequestMapping({"/blacklist/save"}) + @Menu(type = "apps", subtype = "blacklist") + public ModelAndView blacklist(HttpServletRequest request, @Valid String agentuserid, @Valid String agentserviceid, @Valid String userid, @Valid BlackEntity blackEntity) + throws Exception { + User user = super.getUser(request); + List agentUserList = this.agentUserRepository.findByUseridAndOrgi(userid, super.getOrgi(request)); + if (agentUserList.size() > 0) { + AgentUser agentUser = agentUserList.get(0); + BlackEntity tempBlackEntiry = blackListRes.findByUseridAndOrgi(agentUser.getUserid(), super.getOrgi(request)); + if (tempBlackEntiry == null) { + blackEntity.setUserid(userid); + blackEntity.setCreater(user.getId()); + blackEntity.setOrgi(super.getOrgi(request)); + if (blackEntity.getControltime() > 0) { + blackEntity.setEndtime(new Date(System.currentTimeMillis() + blackEntity.getControltime() * 3600 * 1000L)); + } + blackEntity.setAgentid(user.getId()); + blackEntity.setAgentuser(agentUser.getUsername()); + blackEntity.setSessionid(agentUser.getSessionid()); + blackEntity.setAgentserviceid(agentserviceid); + blackEntity.setChannel(agentUser.getChannel()); + blackListRes.save(blackEntity); + } else { + if (blackEntity.getControltime() > 0) { + tempBlackEntiry.setEndtime(new Date(System.currentTimeMillis() + blackEntity.getControltime() * 3600 * 1000L)); + } + tempBlackEntiry.setDescription(tempBlackEntiry.getDescription()); + tempBlackEntiry.setControltime(blackEntity.getControltime()); + tempBlackEntiry.setAgentuser(agentUser.getUsername()); + blackListRes.save(tempBlackEntiry); + blackEntity = tempBlackEntiry; + } + if (!StringUtils.isBlank(userid)) { + CacheHelper.getSystemCacheBean().put(userid, blackEntity, super.getOrgi(request)); + } + } + return end(request, agentuserid); + } + + @RequestMapping("/tagrelation") + @Menu(type = "apps", subtype = "tagrelation") + public ModelAndView tagrelation(ModelMap map, HttpServletRequest request, @Valid String userid, @Valid String tagid, @Valid String dataid) { + TagRelation tagRelation = tagRelationRes.findByUseridAndTagid(userid, tagid); + if (tagRelation == null) { + tagRelation = new TagRelation(); + tagRelation.setUserid(userid); + tagRelation.setTagid(tagid); + tagRelation.setDataid(dataid); + tagRelationRes.save(tagRelation); + } else { + tagRelationRes.delete(tagRelation); + } + return request(super + .createRequestPageTempletResponse("/public/success")); + } + + @RequestMapping("/image/upload") + @Menu(type = "im", subtype = "image", access = false) + public ModelAndView upload(ModelMap map, HttpServletRequest request, @RequestParam(value = "imgFile", required = false) MultipartFile imgFile, @Valid String id, @Valid String paste) throws IOException { + ModelAndView view = request(super.createRequestPageTempletResponse("/apps/agent/upload")); + UploadStatus upload = null; + String fileName = null; + if (imgFile != null && imgFile.getOriginalFilename().lastIndexOf(".") > 0) { + File uploadDir = new File(path, "upload"); + if (!uploadDir.exists()) { + uploadDir.mkdirs(); + } + String fileid = MainUtils.md5(imgFile.getBytes()), fileURL = null, targetFile = null; + ChatMessage data = new ChatMessage(); + if (imgFile.getContentType() != null && imgFile.getContentType().indexOf("image") >= 0) { + fileName = "upload/" + fileid + "_original"; + File imageFile = new File(path, fileName); + FileCopyUtils.copy(imgFile.getBytes(), imageFile); + targetFile = "upload/" + fileid; + MainUtils.processImage(new File(path, targetFile), imageFile); + + + fileURL = "/res/image.html?id=" + targetFile; + if (request.getServerPort() == 80) { + fileURL = "/res/image.html?id=" + targetFile; + } else { + fileURL = "/res/image.html?id=" + targetFile; + } + upload = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回 + data.setAttachmentid(fileid); + } else { + String attachid = processAttachmentFile(imgFile, request); + + upload = new UploadStatus("0", "/res/file.html?id=" + attachid); + fileURL = "/res/file.html?id=" + attachid; + if (request.getServerPort() == 80) { + fileURL = "/res/file.html?id=" + attachid; + } else { + fileURL = "/res/file.html?id=" + attachid; + } + } + data.setFilename(imgFile.getOriginalFilename()); + data.setFilesize((int) imgFile.getSize()); + + OutMessageRouter router = null; + AgentUser agentUser = agentUserRepository.findByIdAndOrgi(id, super.getOrgi(request)); + + if (agentUser != null && paste == null) { + router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()); + MessageOutContent outMessage = new MessageOutContent(); + if (router != null) { + outMessage.setMessage(fileURL); + outMessage.setFilename(imgFile.getOriginalFilename()); + outMessage.setFilesize((int) imgFile.getSize()); + if (imgFile.getContentType() != null && imgFile.getContentType().indexOf("image") >= 0) { + outMessage.setMessageType(MainContext.MediaTypeEnum.IMAGE.toString()); + data.setMsgtype(MainContext.MediaTypeEnum.IMAGE.toString()); + } else { + outMessage.setMessageType(MainContext.MediaTypeEnum.FILE.toString()); + data.setMsgtype(MainContext.MediaTypeEnum.FILE.toString()); + } + outMessage.setCalltype(MainContext.CallTypeEnum.OUT.toString()); + outMessage.setCreatetime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + outMessage.setNickName(super.getUser(request).getUsername()); + + router.handler(agentUser.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), agentUser.getAppid(), outMessage); + } + //同时发送消息给 坐席 + data.setMessage(fileURL); + data.setId(MainUtils.getUUID()); + data.setContextid(agentUser.getContextid()); + + data.setAgentserviceid(agentUser.getAgentserviceid()); + + data.setCalltype(MainContext.CallTypeEnum.OUT.toString()); + if (!StringUtils.isBlank(agentUser.getAgentno())) { + data.setTouser(agentUser.getUserid()); + } + data.setChannel(agentUser.getChannel()); + + data.setUsession(agentUser.getUserid()); + data.setAppid(agentUser.getAppid()); + data.setUserid(super.getUser(request).getId()); + + data.setOrgi(super.getUser(request).getOrgi()); + + data.setCreater(super.getUser(request).getId()); + data.setUsername(super.getUser(request).getUsername()); + + chatMessageRepository.save(data); + + NettyClients.getInstance().sendAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data); + } + + } else { + upload = new UploadStatus("请选择图片文件"); + } + map.addAttribute("upload", upload); + return view; + } + + @RequestMapping("/message/image") + @Menu(type = "resouce", subtype = "image", access = true) + public ModelAndView messageimage(HttpServletResponse response, ModelMap map, @Valid String id, @Valid String t) throws IOException { + ChatMessage message = chatMessageRepository.findById(id); + map.addAttribute("chatMessage", message); + map.addAttribute("agentUser", CacheHelper.getAgentUserCacheBean().getCacheObject(message.getUserid(), message.getOrgi())); /*if(!StringUtils.isBlank(t)){ map.addAttribute("t", t) ; }*/ - map.addAttribute("t", true) ; - return request(super.createRequestPageTempletResponse("/apps/agent/media/messageimage")) ; + map.addAttribute("t", true); + return request(super.createRequestPageTempletResponse("/apps/agent/media/messageimage")); } - - @RequestMapping("/message/image/upload") - @Menu(type = "im" , subtype = "image" , access = false) - public ModelAndView messageimage(ModelMap map,HttpServletRequest request , @RequestParam(value = "image", required = false) MultipartFile image , @Valid String id, @Valid String userid , @Valid String fileid) throws IOException { - if(image!=null && !StringUtils.isBlank(fileid)){ - File tempFile = File.createTempFile(fileid, ".png") ; - try{ - String fileName = "upload/"+fileid+"_cooperation" ; - File imageFile = new File(path , fileName) ; - if(!tempFile.getParentFile().exists()){ - tempFile.getParentFile().mkdirs(); - } - FileCopyUtils.copy(image.getBytes(), tempFile); - ChatMessage chatMessage = chatMessageRepository.findById(id) ; - chatMessage.setCooperation(true); - chatMessageRepository.save(chatMessage) ; - - MainUtils.scaleImage(imageFile, tempFile , 0.1F) ; - - - - OutMessageRouter router = null ; - AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(chatMessage.getUserid(), chatMessage.getOrgi()) ; - - if(agentUser!=null){ - router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()) ; - MessageOutContent outMessage = new MessageOutContent() ; - if(router!=null){ - outMessage.setMessage("/res/image.html?id="+fileName); - outMessage.setFilename(imageFile.getName()); - - outMessage.setAttachmentid(chatMessage.getAttachmentid()); - - outMessage.setFilesize((int) imageFile.length()); - outMessage.setMessageType(MainContext.MediaTypeEnum.ACTION.toString()); - outMessage.setCalltype(MainContext.CallTypeEnum.INVITE.toString()); - outMessage.setCreatetime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); - outMessage.setNickName(super.getUser(request).getUsername()); - - router.handler(agentUser.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), agentUser.getAppid(), outMessage); - } - } - }finally{ - if(tempFile.exists()){ - tempFile.delete() ; - } - } - } - return request(super.createRequestPageTempletResponse("/public/success")) ; + + @RequestMapping("/message/image/upload") + @Menu(type = "im", subtype = "image", access = false) + public ModelAndView messageimage(ModelMap map, HttpServletRequest request, @RequestParam(value = "image", required = false) MultipartFile image, @Valid String id, @Valid String userid, @Valid String fileid) throws IOException { + if (image != null && !StringUtils.isBlank(fileid)) { + File tempFile = File.createTempFile(fileid, ".png"); + try { + String fileName = "upload/" + fileid + "_cooperation"; + File imageFile = new File(path, fileName); + if (!tempFile.getParentFile().exists()) { + tempFile.getParentFile().mkdirs(); + } + FileCopyUtils.copy(image.getBytes(), tempFile); + ChatMessage chatMessage = chatMessageRepository.findById(id); + chatMessage.setCooperation(true); + chatMessageRepository.save(chatMessage); + + MainUtils.scaleImage(imageFile, tempFile, 0.1F); + + + OutMessageRouter router = null; + AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(chatMessage.getUserid(), chatMessage.getOrgi()); + + if (agentUser != null) { + router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()); + MessageOutContent outMessage = new MessageOutContent(); + if (router != null) { + outMessage.setMessage("/res/image.html?id=" + fileName); + outMessage.setFilename(imageFile.getName()); + + outMessage.setAttachmentid(chatMessage.getAttachmentid()); + + outMessage.setFilesize((int) imageFile.length()); + outMessage.setMessageType(MainContext.MediaTypeEnum.ACTION.toString()); + outMessage.setCalltype(MainContext.CallTypeEnum.INVITE.toString()); + outMessage.setCreatetime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + outMessage.setNickName(super.getUser(request).getUsername()); + + router.handler(agentUser.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), agentUser.getAppid(), outMessage); + } + } + } finally { + if (tempFile.exists()) { + tempFile.delete(); + } + } + } + return request(super.createRequestPageTempletResponse("/public/success")); } - - private String processAttachmentFile(MultipartFile file , HttpServletRequest request) throws IOException{ - String id = null ; - if(file.getSize() > 0){ //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制 - String fileid = MainUtils.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(MainContext.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/app/"+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 = MainUtils.md5(file.getBytes()); //使用 文件的 MD5作为 ID,避免重复上传大文件 + if (StringUtils.isNotBlank(fileid)) { + AttachmentFile attachmentFile = new AttachmentFile(); + attachmentFile.setCreater(super.getUser(request).getId()); + attachmentFile.setOrgi(super.getOrgi(request)); + attachmentFile.setOrgan(super.getUser(request).getOrgan()); + attachmentFile.setModel(MainContext.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.isNotBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) { + attachmentFile.setImage(true); + } + attachmentFile.setFileid(fileid); + attachementRes.save(attachmentFile); + FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), file.getBytes()); + id = attachmentFile.getId(); + } + } + return id; } - - - @RequestMapping(value="/contacts") - @Menu(type = "apps", subtype = "contacts") - public ModelAndView contacts(ModelMap map , HttpServletRequest request , @Valid String contactsid , @Valid String userid , @Valid String agentserviceid, @Valid String agentuserid){ - if(!StringUtils.isBlank(userid) && !StringUtils.isBlank(contactsid)){ - List onlineUserList = this.onlineUserRes.findByUseridAndOrgi(userid, super.getOrgi(request)) ; - if(onlineUserList.size() > 0){ - OnlineUser onlineUser = onlineUserList.get(0) ; - onlineUser.setContactsid(contactsid); - this.onlineUserRes.save(onlineUser) ; - } - AgentService agentService = this.agentServiceRepository.findOne(agentserviceid) ; - if(agentService!=null){ - agentService.setContactsid(contactsid); - this.agentServiceRepository.save(agentService) ; - - List agentUserContactsList = agentUserContactsRes.findByUseridAndOrgi(userid, super.getOrgi(request)) ; - if(agentUserContactsList.size() == 0){ - AgentUserContacts agentUserContacts = new AgentUserContacts() ; - agentUserContacts.setAppid(agentService.getAppid()); - agentUserContacts.setChannel(agentService.getChannel()); - agentUserContacts.setContactsid(contactsid); - agentUserContacts.setUserid(userid); - agentUserContacts.setCreater(super.getUser(request).getId()); - agentUserContacts.setOrgi(super.getOrgi(request)); - agentUserContacts.setCreatetime(new Date()); - agentUserContactsRes.save(agentUserContacts) ; - }else{ - AgentUserContacts agentUserContacts = agentUserContactsList.get(0) ; - agentUserContacts.setContactsid(contactsid); - agentUserContactsRes.save(agentUserContacts) ; - } - } - DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("contacts") ; - if(dataExchange!=null){ - map.addAttribute("contacts", dataExchange.getDataByIdAndOrgi(contactsid, super.getOrgi(request))) ; - } - } - - return request(super.createRequestPageTempletResponse("/apps/agent/contacts")) ; + + + @RequestMapping(value = "/contacts") + @Menu(type = "apps", subtype = "contacts") + public ModelAndView contacts(ModelMap map, HttpServletRequest request, @Valid String contactsid, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid) { + if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(contactsid)) { + List onlineUserList = this.onlineUserRes.findByUseridAndOrgi(userid, super.getOrgi(request)); + if (onlineUserList.size() > 0) { + OnlineUser onlineUser = onlineUserList.get(0); + onlineUser.setContactsid(contactsid); + this.onlineUserRes.save(onlineUser); + } + AgentService agentService = this.agentServiceRepository.findOne(agentserviceid); + if (agentService != null) { + agentService.setContactsid(contactsid); + this.agentServiceRepository.save(agentService); + + List agentUserContactsList = agentUserContactsRes.findByUseridAndOrgi(userid, super.getOrgi(request)); + if (agentUserContactsList.size() == 0) { + AgentUserContacts agentUserContacts = new AgentUserContacts(); + agentUserContacts.setAppid(agentService.getAppid()); + agentUserContacts.setChannel(agentService.getChannel()); + agentUserContacts.setContactsid(contactsid); + agentUserContacts.setUserid(userid); + agentUserContacts.setCreater(super.getUser(request).getId()); + agentUserContacts.setOrgi(super.getOrgi(request)); + agentUserContacts.setCreatetime(new Date()); + agentUserContactsRes.save(agentUserContacts); + } else { + AgentUserContacts agentUserContacts = agentUserContactsList.get(0); + agentUserContacts.setContactsid(contactsid); + agentUserContactsRes.save(agentUserContacts); + } + } + DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("contacts"); + if (dataExchange != null) { + map.addAttribute("contacts", dataExchange.getDataByIdAndOrgi(contactsid, super.getOrgi(request))); + } + } + + return request(super.createRequestPageTempletResponse("/apps/agent/contacts")); } - - @RequestMapping(value="/summary") - @Menu(type = "apps", subtype = "summary") - public ModelAndView summary(ModelMap map , - HttpServletRequest request , - @Valid String userid , + + @RequestMapping(value = "/summary") + @Menu(type = "apps", subtype = "summary") + public ModelAndView summary(ModelMap map, + HttpServletRequest request, + @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid, - @Valid String channel){ - if(!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)){ - AgentUser agentUser = this.agentUserRepository.findByIdAndOrgi(agentuserid, super.getOrgi(request)) ; - if(agentUser!=null && !StringUtils.isBlank(agentUser.getAgentserviceid())){ - List summaries = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)) ; - if(summaries.size() > 0){ - map.addAttribute("summary", summaries.get(0)) ; - } - } + @Valid String channel) { + if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)) { + AgentUser agentUser = this.agentUserRepository.findByIdAndOrgi(agentuserid, super.getOrgi(request)); + if (agentUser != null && !StringUtils.isBlank(agentUser.getAgentserviceid())) { + List summaries = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)); + if (summaries.size() > 0) { + map.addAttribute("summary", summaries.get(0)); + } + } - map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.SUMMARY.toString())) ; - map.addAttribute("userid", userid) ; - map.addAttribute("agentserviceid", agentserviceid) ; - map.addAttribute("agentuserid", agentuserid) ; - map.addAttribute("channel", channel); - - } - - return request(super.createRequestPageTempletResponse("/apps/agent/summary")) ; + map.addAttribute("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.SUMMARY.toString())); + map.addAttribute("userid", userid); + map.addAttribute("agentserviceid", agentserviceid); + map.addAttribute("agentuserid", agentuserid); + map.addAttribute("channel", channel); + + } + + return request(super.createRequestPageTempletResponse("/apps/agent/summary")); } - - @RequestMapping(value="/summary/save") - @Menu(type = "apps", subtype = "summarysave") - public ModelAndView summarysave(ModelMap map , - HttpServletRequest request , - @Valid AgentServiceSummary summary , - @Valid String contactsid , - @Valid String userid , + + @RequestMapping(value = "/summary/save") + @Menu(type = "apps", subtype = "summarysave") + public ModelAndView summarysave(ModelMap map, + HttpServletRequest request, + @Valid AgentServiceSummary summary, + @Valid String contactsid, + @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid, - @Valid String channel){ - if(!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)){ - summary.setOrgi(super.getOrgi(request)); - summary.setCreater(super.getUser(request).getId()); - - summary.setCreatetime(new Date()); - - AgentService service = agentServiceRepository.findByIdAndOrgi(agentserviceid, super.getOrgi(request)) ; - summary.setAgent(service.getAgentno()); - summary.setAgentno(service.getAgentno()); - summary.setUsername(service.getUsername()); - summary.setAgentusername(service.getAgentusername()); - summary.setChannel(service.getChannel()); - summary.setContactsid(contactsid); - summary.setLogindate(service.getLogindate()); - summary.setContactsid(service.getContactsid()); - summary.setEmail(service.getEmail()); - summary.setPhonenumber(service.getPhone()); - serviceSummaryRes.save(summary) ; - } - - return request(super.createRequestPageTempletResponse("redirect:/agent/agentuser.html?id="+agentuserid + "&channel=" + channel)) ; + @Valid String channel) { + if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)) { + summary.setOrgi(super.getOrgi(request)); + summary.setCreater(super.getUser(request).getId()); + + summary.setCreatetime(new Date()); + + AgentService service = agentServiceRepository.findByIdAndOrgi(agentserviceid, super.getOrgi(request)); + summary.setAgent(service.getAgentno()); + summary.setAgentno(service.getAgentno()); + summary.setUsername(service.getUsername()); + summary.setAgentusername(service.getAgentusername()); + summary.setChannel(service.getChannel()); + summary.setContactsid(contactsid); + summary.setLogindate(service.getLogindate()); + summary.setContactsid(service.getContactsid()); + summary.setEmail(service.getEmail()); + summary.setPhonenumber(service.getPhone()); + serviceSummaryRes.save(summary); + } + + return request(super.createRequestPageTempletResponse("redirect:/agent/agentuser.html?id=" + agentuserid + "&channel=" + channel)); } - - @RequestMapping(value="/transfer") - @Menu(type = "apps", subtype = "transfer") - public ModelAndView transfer(ModelMap map , HttpServletRequest request , @Valid String userid , @Valid String agentserviceid, @Valid String agentuserid){ - if(!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)){ - //map.addAttribute("organList", organRes.findByOrgiAndOrgid(super.getOrgi(request),super.getOrgid(request))) ; - - List skillList = OnlineUserUtils.organ(super.getOrgi(request),true) ; - String currentOrgan = super.getUser(request).getOrgan(); - if(StringUtils.isBlank(currentOrgan)) { - if(!skillList.isEmpty()) { - currentOrgan = skillList.get(0).getId(); - } - } - List agentStatusList = AutomaticServiceDist.getAgentStatus(null , super.getOrgi(request)); - List usersids = new ArrayList(); - if(!agentStatusList.isEmpty()) { - for(AgentStatus agentStatus:agentStatusList) { - if(agentStatus!=null && !agentStatus.getAgentno().equals(super.getUser(request).getId())){ - usersids.add(agentStatus.getAgentno()) ; - } - } - - } - List userList = userRes.findAll(usersids); - for(User user : userList){ - user.setAgentStatus((AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(user.getId(), super.getOrgi(request))); - } - map.addAttribute("userList", userList) ; - map.addAttribute("userid", userid) ; - map.addAttribute("agentserviceid", agentserviceid) ; - map.addAttribute("agentuserid", agentuserid) ; - - map.addAttribute("skillList", skillList) ; - - map.addAttribute("agentservice", this.agentServiceRepository.findByIdAndOrgi(agentserviceid, super.getOrgi(request))) ; - map.addAttribute("currentorgan", currentOrgan) ; - } - - return request(super.createRequestPageTempletResponse("/apps/agent/transfer")) ; + + @RequestMapping(value = "/transfer") + @Menu(type = "apps", subtype = "transfer") + public ModelAndView transfer(ModelMap map, HttpServletRequest request, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid) { + if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)) { + //map.addAttribute("organList", organRes.findByOrgiAndOrgid(super.getOrgi(request),super.getOrgid(request))) ; + + List skillList = OnlineUserUtils.organ(super.getOrgi(request), true); + String currentOrgan = super.getUser(request).getOrgan(); + if (StringUtils.isBlank(currentOrgan)) { + if (!skillList.isEmpty()) { + currentOrgan = skillList.get(0).getId(); + } + } + List agentStatusList = AutomaticServiceDist.getAgentStatus(null, super.getOrgi(request)); + List usersids = new ArrayList(); + if (!agentStatusList.isEmpty()) { + for (AgentStatus agentStatus : agentStatusList) { + if (agentStatus != null && !agentStatus.getAgentno().equals(super.getUser(request).getId())) { + usersids.add(agentStatus.getAgentno()); + } + } + + } + List userList = userRes.findAll(usersids); + for (User user : userList) { + user.setAgentStatus((AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(user.getId(), super.getOrgi(request))); + } + map.addAttribute("userList", userList); + map.addAttribute("userid", userid); + map.addAttribute("agentserviceid", agentserviceid); + map.addAttribute("agentuserid", agentuserid); + + map.addAttribute("skillList", skillList); + + map.addAttribute("agentservice", this.agentServiceRepository.findByIdAndOrgi(agentserviceid, super.getOrgi(request))); + map.addAttribute("currentorgan", currentOrgan); + } + + return request(super.createRequestPageTempletResponse("/apps/agent/transfer")); } - - @RequestMapping(value="/transfer/agent") - @Menu(type = "apps", subtype = "transferagent") - public ModelAndView transferagent(ModelMap map , HttpServletRequest request , @Valid String organ){ - if(!StringUtils.isBlank(organ)){ - List usersids = new ArrayList(); - List agentStatusList = AutomaticServiceDist.getAgentStatus(organ , super.getOrgi(request)); - if(!agentStatusList.isEmpty()) { - for(AgentStatus agentStatus:agentStatusList) { - if(agentStatus!=null && !agentStatus.getAgentno().equals(super.getUser(request).getId())){ - usersids.add(agentStatus.getAgentno()) ; - } - } - - } - List userList = userRes.findAll(usersids); - for(User user : userList){ - user.setAgentStatus((AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(user.getId(), super.getOrgi(request))); - } - map.addAttribute("userList", userList) ; - map.addAttribute("currentorgan", organ) ; - } - return request(super.createRequestPageTempletResponse("/apps/agent/transferagentlist")) ; + + @RequestMapping(value = "/transfer/agent") + @Menu(type = "apps", subtype = "transferagent") + public ModelAndView transferagent(ModelMap map, HttpServletRequest request, @Valid String organ) { + if (!StringUtils.isBlank(organ)) { + List usersids = new ArrayList(); + List agentStatusList = AutomaticServiceDist.getAgentStatus(organ, super.getOrgi(request)); + if (!agentStatusList.isEmpty()) { + for (AgentStatus agentStatus : agentStatusList) { + if (agentStatus != null && !agentStatus.getAgentno().equals(super.getUser(request).getId())) { + usersids.add(agentStatus.getAgentno()); + } + } + + } + List userList = userRes.findAll(usersids); + for (User user : userList) { + user.setAgentStatus((AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(user.getId(), super.getOrgi(request))); + } + map.addAttribute("userList", userList); + map.addAttribute("currentorgan", organ); + } + return request(super.createRequestPageTempletResponse("/apps/agent/transferagentlist")); } - - - @RequestMapping(value="/transfer/save") - @Menu(type = "apps", subtype = "transfersave") - public ModelAndView transfersave(ModelMap map , HttpServletRequest request , @Valid String userid , @Valid String agentserviceid, @Valid String agentuserid, @Valid String agentno , @Valid String memo){ - if(!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid) && !StringUtils.isBlank(agentno)){ - AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(userid, super.getOrgi(request)) ; - AgentService agentService = this.agentServiceRepository.findByIdAndOrgi(agentserviceid, super.getOrgi(request)) ; - if(agentUser != null){ - - agentUser.setAgentno(agentno); - CacheHelper.getAgentUserCacheBean().put(userid , agentUser , super.getOrgi(request)) ; - agentUserRepository.save(agentUser) ; - if(MainContext.AgentUserStatusEnum.INSERVICE.toString().equals(agentUser.getStatus())){ //转接 , 发送消息给 目标坐席 - AgentStatus agentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(super.getUser(request).getId(), super.getOrgi(request)) ; - - if(agentStatus!=null){ - AutomaticServiceDist.updateAgentStatus(agentStatus, agentUser, super.getOrgi(request), false); - } - - AgentStatus transAgentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(agentno, super.getOrgi(request)) ; - if(transAgentStatus!=null){ - AutomaticServiceDist.updateAgentStatus(transAgentStatus, agentUser, super.getOrgi(request), true); - agentService.setAgentno(agentno); - agentService.setAgentusername(transAgentStatus.getUsername()); - } - NettyClients.getInstance().sendAgentEventMessage(agentno, MainContext.MessageTypeEnum.NEW.toString(), agentUser); - } - }else{ - agentUser = agentUserRepository.findByIdAndOrgi(agentuserid, super.getOrgi(request)); - if(agentUser!=null){ - agentUser.setAgentno(agentno); - agentUserRepository.save(agentUser) ; - } - } - - if(agentService!=null){ - agentService.setAgentno(agentno); - if(!StringUtils.isBlank(memo)){ - agentService.setTransmemo(memo); - } - agentService.setTrans(true); - agentService.setTranstime(new Date()); - agentServiceRepository.save(agentService) ; - } - } - - return request(super.createRequestPageTempletResponse("redirect:/agent/index.html")) ; + + + @RequestMapping(value = "/transfer/save") + @Menu(type = "apps", subtype = "transfersave") + public ModelAndView transfersave(ModelMap map, HttpServletRequest request, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid, @Valid String agentno, @Valid String memo) { + if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid) && !StringUtils.isBlank(agentno)) { + AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(userid, super.getOrgi(request)); + AgentService agentService = this.agentServiceRepository.findByIdAndOrgi(agentserviceid, super.getOrgi(request)); + if (agentUser != null) { + + agentUser.setAgentno(agentno); + CacheHelper.getAgentUserCacheBean().put(userid, agentUser, super.getOrgi(request)); + agentUserRepository.save(agentUser); + if (MainContext.AgentUserStatusEnum.INSERVICE.toString().equals(agentUser.getStatus())) { //转接 , 发送消息给 目标坐席 + AgentStatus agentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(super.getUser(request).getId(), super.getOrgi(request)); + + if (agentStatus != null) { + AutomaticServiceDist.updateAgentStatus(agentStatus, agentUser, super.getOrgi(request), false); + } + + AgentStatus transAgentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(agentno, super.getOrgi(request)); + if (transAgentStatus != null) { + AutomaticServiceDist.updateAgentStatus(transAgentStatus, agentUser, super.getOrgi(request), true); + agentService.setAgentno(agentno); + agentService.setAgentusername(transAgentStatus.getUsername()); + } + NettyClients.getInstance().sendAgentEventMessage(agentno, MainContext.MessageTypeEnum.NEW.toString(), agentUser); + } + } else { + agentUser = agentUserRepository.findByIdAndOrgi(agentuserid, super.getOrgi(request)); + if (agentUser != null) { + agentUser.setAgentno(agentno); + agentUserRepository.save(agentUser); + } + } + + if (agentService != null) { + agentService.setAgentno(agentno); + if (!StringUtils.isBlank(memo)) { + agentService.setTransmemo(memo); + } + agentService.setTrans(true); + agentService.setTranstime(new Date()); + agentServiceRepository.save(agentService); + } + } + + return request(super.createRequestPageTempletResponse("redirect:/agent/index.html")); } - - - - - @RequestMapping("/quicklist") - @Menu(type = "setting" , subtype = "quickreply" , admin= true) - public ModelAndView quicklist(ModelMap map , HttpServletRequest request , @Valid String typeid) { - map.addAttribute("quickReplyList", quickReplyRes.findByOrgiAndCreater(super.getOrgi(request) , super.getUser(request).getId() , null)) ; - List quickTypeList = quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request), MainContext.QuickTypeEnum.PUB.toString()) ; - List priQuickTypeList = quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId()) ; - quickTypeList.addAll(priQuickTypeList) ; - map.addAttribute("pubQuickTypeList", quickTypeList) ; - - if(!StringUtils.isBlank(typeid)){ - map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ; - } - - return request(super.createRequestPageTempletResponse("/apps/agent/quicklist")); + + + @RequestMapping("/quicklist") + @Menu(type = "setting", subtype = "quickreply", admin = true) + public ModelAndView quicklist(ModelMap map, HttpServletRequest request, @Valid String typeid) { + map.addAttribute("quickReplyList", quickReplyRes.findByOrgiAndCreater(super.getOrgi(request), super.getUser(request).getId(), null)); + List quickTypeList = quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request), MainContext.QuickTypeEnum.PUB.toString()); + List priQuickTypeList = quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId()); + quickTypeList.addAll(priQuickTypeList); + map.addAttribute("pubQuickTypeList", quickTypeList); + + if (!StringUtils.isBlank(typeid)) { + map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))); + } + + return request(super.createRequestPageTempletResponse("/apps/agent/quicklist")); } - - - @RequestMapping("/quickreply/add") - @Menu(type = "setting" , subtype = "quickreplyadd" , admin= true) - public ModelAndView quickreplyadd(ModelMap map , HttpServletRequest request , @Valid String parentid) { - if(!StringUtils.isBlank(parentid)){ - map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(parentid, super.getOrgi(request))) ; - } - map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request) , MainContext.QuickTypeEnum.PRI.toString() , super.getUser(request).getId())) ; + + + @RequestMapping("/quickreply/add") + @Menu(type = "setting", subtype = "quickreplyadd", admin = true) + public ModelAndView quickreplyadd(ModelMap map, HttpServletRequest request, @Valid String parentid) { + if (!StringUtils.isBlank(parentid)) { + map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(parentid, super.getOrgi(request))); + } + map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId())); return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/add")); } - + @RequestMapping("/quickreply/save") - @Menu(type = "setting" , subtype = "quickreply" , admin= true) - public ModelAndView quickreplysave(ModelMap map , HttpServletRequest request , @Valid QuickReply quickReply) { - if(!StringUtils.isBlank(quickReply.getTitle()) && !StringUtils.isBlank(quickReply.getContent())){ - quickReply.setOrgi(super.getOrgi(request)); - quickReply.setCreater(super.getUser(request).getId()); - quickReply.setType(MainContext.QuickTypeEnum.PRI.toString()); - quickReplyRes.save(quickReply) ; - } - return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html?typeid="+quickReply.getCate())); + @Menu(type = "setting", subtype = "quickreply", admin = true) + public ModelAndView quickreplysave(ModelMap map, HttpServletRequest request, @Valid QuickReply quickReply) { + if (!StringUtils.isBlank(quickReply.getTitle()) && !StringUtils.isBlank(quickReply.getContent())) { + quickReply.setOrgi(super.getOrgi(request)); + quickReply.setCreater(super.getUser(request).getId()); + quickReply.setType(MainContext.QuickTypeEnum.PRI.toString()); + quickReplyRes.save(quickReply); + } + return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html?typeid=" + quickReply.getCate())); } - + @RequestMapping("/quickreply/delete") - @Menu(type = "setting" , subtype = "quickreply" , admin= true) - public ModelAndView quickreplydelete(ModelMap map , HttpServletRequest request , @Valid String id) { - QuickReply quickReply = quickReplyRes.findOne(id) ; - if(quickReply!=null){ - quickReplyRes.delete(quickReply); - } - return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html?typeid="+quickReply.getCate())); + @Menu(type = "setting", subtype = "quickreply", admin = true) + public ModelAndView quickreplydelete(ModelMap map, HttpServletRequest request, @Valid String id) { + QuickReply quickReply = quickReplyRes.findOne(id); + if (quickReply != null) { + quickReplyRes.delete(quickReply); + } + return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html?typeid=" + quickReply.getCate())); } + @RequestMapping("/quickreply/edit") - @Menu(type = "setting" , subtype = "quickreply" , admin= true) - public ModelAndView quickreplyedit(ModelMap map , HttpServletRequest request , @Valid String id) { - QuickReply quickReply = quickReplyRes.findOne(id) ; - map.put("quickReply", quickReply) ; - if(quickReply!=null){ - map.put("quickType", quickTypeRes.findByIdAndOrgi(quickReply.getCate(), super.getOrgi(request))) ; - } - map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request) , MainContext.QuickTypeEnum.PUB.toString())) ; + @Menu(type = "setting", subtype = "quickreply", admin = true) + public ModelAndView quickreplyedit(ModelMap map, HttpServletRequest request, @Valid String id) { + QuickReply quickReply = quickReplyRes.findOne(id); + map.put("quickReply", quickReply); + if (quickReply != null) { + map.put("quickType", quickTypeRes.findByIdAndOrgi(quickReply.getCate(), super.getOrgi(request))); + } + map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktype(super.getOrgi(request), MainContext.QuickTypeEnum.PUB.toString())); return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/edit")); } - + @RequestMapping("/quickreply/update") - @Menu(type = "setting" , subtype = "quickreply" , admin= true) - public ModelAndView quickreplyupdate(ModelMap map , HttpServletRequest request , @Valid QuickReply quickReply) { - if(!StringUtils.isBlank(quickReply.getId())){ - QuickReply temp = quickReplyRes.findOne(quickReply.getId()) ; - quickReply.setOrgi(super.getOrgi(request)); - quickReply.setCreater(super.getUser(request).getId()); - if(temp!=null){ - quickReply.setCreatetime(temp.getCreatetime()); - } - quickReply.setType(MainContext.QuickTypeEnum.PUB.toString()); - quickReplyRes.save(quickReply) ; - } - return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html?typeid="+quickReply.getCate())); + @Menu(type = "setting", subtype = "quickreply", admin = true) + public ModelAndView quickreplyupdate(ModelMap map, HttpServletRequest request, @Valid QuickReply quickReply) { + if (!StringUtils.isBlank(quickReply.getId())) { + QuickReply temp = quickReplyRes.findOne(quickReply.getId()); + quickReply.setOrgi(super.getOrgi(request)); + quickReply.setCreater(super.getUser(request).getId()); + if (temp != null) { + quickReply.setCreatetime(temp.getCreatetime()); + } + quickReply.setType(MainContext.QuickTypeEnum.PUB.toString()); + quickReplyRes.save(quickReply); + } + return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html?typeid=" + quickReply.getCate())); } - + @RequestMapping({"/quickreply/addtype"}) - @Menu(type="apps", subtype="kbs") - public ModelAndView addtype(ModelMap map , HttpServletRequest request , @Valid String typeid ){ - map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request) , MainContext.QuickTypeEnum.PRI.toString() , super.getUser(request).getId())) ; - if(!StringUtils.isBlank(typeid)){ - map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))) ; - } - return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/addtype")); - } + @Menu(type = "apps", subtype = "kbs") + public ModelAndView addtype(ModelMap map, HttpServletRequest request, @Valid String typeid) { + map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId())); + if (!StringUtils.isBlank(typeid)) { + map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))); + } + return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/addtype")); + } @RequestMapping("/quickreply/type/save") - @Menu(type = "apps" , subtype = "kbs") - public ModelAndView typesave(HttpServletRequest request ,@Valid QuickType quickType) { - int count = quickTypeRes.countByOrgiAndNameAndParentid(super.getOrgi(request),quickType.getName(), quickType.getParentid()) ; - if(count == 0){ - quickType.setOrgi(super.getOrgi(request)); - quickType.setCreater(super.getUser(request).getId()); - quickType.setCreatetime(new Date()); - quickType.setQuicktype(MainContext.QuickTypeEnum.PRI.toString()); - quickTypeRes.save(quickType) ; - } - return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html?typeid="+quickType.getParentid())); + @Menu(type = "apps", subtype = "kbs") + public ModelAndView typesave(HttpServletRequest request, @Valid QuickType quickType) { + int count = quickTypeRes.countByOrgiAndNameAndParentid(super.getOrgi(request), quickType.getName(), quickType.getParentid()); + if (count == 0) { + quickType.setOrgi(super.getOrgi(request)); + quickType.setCreater(super.getUser(request).getId()); + quickType.setCreatetime(new Date()); + quickType.setQuicktype(MainContext.QuickTypeEnum.PRI.toString()); + quickTypeRes.save(quickType); + } + return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html?typeid=" + quickType.getParentid())); } - + @RequestMapping({"/quickreply/edittype"}) - @Menu(type="apps", subtype="kbs") - public ModelAndView edittype(ModelMap map , HttpServletRequest request , String id){ - map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(id, super.getOrgi(request))) ; - map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request) , MainContext.QuickTypeEnum.PRI.toString() , super.getUser(request).getId())) ; - return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/edittype")); - } - - @RequestMapping("/quickreply/type/update") - @Menu(type = "apps" , subtype = "kbs") - public ModelAndView typeupdate(HttpServletRequest request ,@Valid QuickType quickType) { - QuickType tempQuickType = quickTypeRes.findByIdAndOrgi(quickType.getId(), super.getOrgi(request)) ; - if(tempQuickType !=null){ - tempQuickType.setName(quickType.getName()); - tempQuickType.setDescription(quickType.getDescription()); - tempQuickType.setInx(quickType.getInx()); - tempQuickType.setParentid(quickType.getParentid()); - quickTypeRes.save(tempQuickType) ; - } - return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html?typeid="+quickType.getId())); + @Menu(type = "apps", subtype = "kbs") + public ModelAndView edittype(ModelMap map, HttpServletRequest request, String id) { + map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(id, super.getOrgi(request))); + map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId())); + return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/edittype")); } - + + @RequestMapping("/quickreply/type/update") + @Menu(type = "apps", subtype = "kbs") + public ModelAndView typeupdate(HttpServletRequest request, @Valid QuickType quickType) { + QuickType tempQuickType = quickTypeRes.findByIdAndOrgi(quickType.getId(), super.getOrgi(request)); + if (tempQuickType != null) { + tempQuickType.setName(quickType.getName()); + tempQuickType.setDescription(quickType.getDescription()); + tempQuickType.setInx(quickType.getInx()); + tempQuickType.setParentid(quickType.getParentid()); + quickTypeRes.save(tempQuickType); + } + return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html?typeid=" + quickType.getId())); + } + @RequestMapping({"/quickreply/deletetype"}) - @Menu(type="apps", subtype="kbs") - public ModelAndView deletetype(ModelMap map , HttpServletRequest request , @Valid String id){ - QuickType tempQuickType = quickTypeRes.findByIdAndOrgi(id, super.getOrgi(request)) ; - if(tempQuickType != null){ - quickTypeRes.delete(tempQuickType); - - Page quickReplyList = quickReplyRes.getByOrgiAndCate(super.getOrgi(request), id, null, new PageRequest(0, 10000)) ; - - quickReplyRes.delete(quickReplyList.getContent()); - } - return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html"+(tempQuickType!=null ? "?typeid="+tempQuickType.getParentid():""))); - } + @Menu(type = "apps", subtype = "kbs") + public ModelAndView deletetype(ModelMap map, HttpServletRequest request, @Valid String id) { + QuickType tempQuickType = quickTypeRes.findByIdAndOrgi(id, super.getOrgi(request)); + if (tempQuickType != null) { + quickTypeRes.delete(tempQuickType); + + Page quickReplyList = quickReplyRes.getByOrgiAndCate(super.getOrgi(request), id, null, new PageRequest(0, 10000)); + + quickReplyRes.delete(quickReplyList.getContent()); + } + return request(super.createRequestPageTempletResponse("redirect:/agent/quicklist.html" + (tempQuickType != null ? "?typeid=" + tempQuickType.getParentid() : ""))); + } + @RequestMapping({"/quickreply/content"}) - @Menu(type="apps", subtype="quickreply") - public ModelAndView quickreplycontent(ModelMap map , HttpServletRequest request , @Valid String id){ - QuickReply quickReply = quickReplyRes.findOne(id); - if(quickReply != null){ - map.addAttribute("quickReply", quickReply) ; - } - return request(super.createRequestPageTempletResponse("/apps/agent/quickreplycontent")); - } + @Menu(type = "apps", subtype = "quickreply") + public ModelAndView quickreplycontent(ModelMap map, HttpServletRequest request, @Valid String id) { + QuickReply quickReply = quickReplyRes.findOne(id); + if (quickReply != null) { + map.addAttribute("quickReply", quickReply); + } + return request(super.createRequestPageTempletResponse("/apps/agent/quickreplycontent")); + } @RequestMapping("/calloutcontact/add") - @Menu(type = "apps", subtype = "calloutcontact", admin= true) - public ModelAndView add(ModelMap map , HttpServletRequest request,@Valid String ckind) { - map.addAttribute("ckind",ckind); + @Menu(type = "apps", subtype = "calloutcontact", admin = true) + public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String ckind) { + map.addAttribute("ckind", ckind); return request(super.createRequestPageTempletResponse("/apps/agent/calloutcontact/add")); } @@ -1252,11 +1251,11 @@ public class AgentController extends Handler { @Menu(type = "apps", subtype = "calloutcontact") public ModelAndView calloutcontactsave(ModelMap map, HttpServletRequest request, - @RequestParam(value = "agentuser", required = true) String agentuser, + @RequestParam(value = "agentuser", required = true) String agentuser, @Valid Contacts contacts) throws CSKefuException { logger.info("[agent ctrl] calloutcontactsave agentuser [{}]", agentuser); AgentUser au = agentUserRepository.findOne(agentuser); - if(au == null) + if (au == null) throw new CSKefuException("不存在该服务记录"); User curruser = super.getUser(request); @@ -1265,12 +1264,12 @@ public class AgentController extends Handler { contacts.setOrgi(curruser.getOrgi()); contacts.setOrgan(curruser.getOrgan()); contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName())); - if(StringUtils.isBlank(contacts.getCusbirthday())) { + if (StringUtils.isBlank(contacts.getCusbirthday())) { contacts.setCusbirthday(null); } - contactsRes.save(contacts) ; + contactsRes.save(contacts); - AgentUserContacts auc = new AgentUserContacts(); + AgentUserContacts auc = new AgentUserContacts(); auc.setId(MainUtils.getUUID()); auc.setUsername(au.getUsername()); auc.setOrgi(MainContext.SYSTEM_ORGI); @@ -1287,19 +1286,19 @@ public class AgentController extends Handler { @RequestMapping("/calloutcontact/update") @Menu(type = "apps", subtype = "calloutcontact") public ModelAndView update(HttpServletRequest request, @Valid Contacts contacts) { - Contacts data = contactsRes.findOne(contacts.getId()) ; - if(data!=null){ - List events = PropertiesEventUtils.processPropertiesModify(request, contacts , data , "id" , "orgi" , "creater" ,"createtime" , "updatetime") ; //记录 数据变更 历史 - if(events.size()>0){ - String modifyid = MainUtils.getUUID() ; + Contacts data = contactsRes.findOne(contacts.getId()); + if (data != null) { + List events = PropertiesEventUtils.processPropertiesModify(request, contacts, data, "id", "orgi", "creater", "createtime", "updatetime"); //记录 数据变更 历史 + if (events.size() > 0) { + String modifyid = MainUtils.getUUID(); Date modifytime = new Date(); - for(PropertiesEvent event : events){ + for (PropertiesEvent event : events) { event.setDataid(contacts.getId()); event.setCreater(super.getUser(request).getId()); event.setOrgi(super.getOrgi(request)); event.setModifyid(modifyid); event.setCreatetime(modifytime); - propertiesEventRes.save(event) ; + propertiesEventRes.save(event); } } @@ -1310,7 +1309,7 @@ public class AgentController extends Handler { contacts.setOrgi(curruser.getOrgi()); contacts.setOrgan(curruser.getOrgan()); contacts.setPinyin(PinYinTools.getInstance().getFirstPinYin(contacts.getName())); - if(StringUtils.isBlank(contacts.getCusbirthday())) { + if (StringUtils.isBlank(contacts.getCusbirthday())) { contacts.setCusbirthday(null); } contactsRes.save(contacts); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java index ac7fd2ab..26ab415d 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java @@ -788,7 +788,7 @@ public class IMController extends Handler { } attachmentFile.setFileid(fileid); attachementRes.save(attachmentFile); - FileUtils.writeByteArrayToFile(new File(path, "app/app/" + fileid), file.getBytes()); + FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), file.getBytes()); id = attachmentFile.getId(); } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java index b65f9f1c..020f5802 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java @@ -47,131 +47,132 @@ import com.chatopera.cc.app.model.UploadStatus; @Controller @RequestMapping("/res") -public class MediaController extends Handler{ - - @Value("${web.upload-path}") +public class MediaController extends Handler { + + @Value("${web.upload-path}") private String path; - - private String TEMPLATE_DATA_PATH = "WEB-INF/data/templates/"; - - @Autowired - private AttachmentRepository attachementRes; - + + private String TEMPLATE_DATA_PATH = "WEB-INF/data/templates/"; + + @Autowired + private AttachmentRepository attachementRes; + @RequestMapping("/image") - @Menu(type = "resouce" , subtype = "image" , access = true) + @Menu(type = "resouce", subtype = "image", access = true) public void index(HttpServletResponse response, @Valid String id) throws IOException { - File file = new File(path ,id) ; - if(!StringUtils.isBlank(id) && !(id.endsWith(".png") || id.endsWith(".jpg"))){ - if(id.endsWith("_original") && !file.exists()){ - File orgFile = new File(path , id.substring(0 , id.indexOf("_original"))) ; - if(orgFile.exists()){ - MainUtils.processImage(file = new File(path , id), orgFile) ; - } - }else if(!StringUtils.isBlank(id) && file.exists() && !id.endsWith("_original")){ - File originalFile = new File( path , id+"_original") ; - if(!originalFile.exists()){ - MainUtils.processImage(new File( path , id+"_original"), file) ; - } - }else if(!StringUtils.isBlank(id) && !file.exists() && !id.endsWith("_original")){ - File destFile = new File(path , id+"_original") ; - if(destFile.exists()){ - MainUtils.processImage(new File(path + id), destFile) ; - } - file = new File(path , id) ; - } - } - if(file.exists() && file.isFile()){ - response.setHeader("Content-Type","image/png"); - response.setContentType("image/png"); - response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path ,id))); - } + File file = new File(path, id); + if (!StringUtils.isBlank(id) && !(id.endsWith(".png") || id.endsWith(".jpg"))) { + if (id.endsWith("_original") && !file.exists()) { + File orgFile = new File(path, id.substring(0, id.indexOf("_original"))); + if (orgFile.exists()) { + MainUtils.processImage(file = new File(path, id), orgFile); + } + } else if (!StringUtils.isBlank(id) && file.exists() && !id.endsWith("_original")) { + File originalFile = new File(path, id + "_original"); + if (!originalFile.exists()) { + MainUtils.processImage(new File(path, id + "_original"), file); + } + } else if (!StringUtils.isBlank(id) && !file.exists() && !id.endsWith("_original")) { + File destFile = new File(path, id + "_original"); + if (destFile.exists()) { + MainUtils.processImage(new File(path + id), destFile); + } + file = new File(path, id); + } + } + if (file.exists() && file.isFile()) { + response.setHeader("Content-Type", "image/png"); + response.setContentType("image/png"); + response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, id))); + } } - + @RequestMapping("/voice") - @Menu(type = "resouce" , subtype = "voice" , access = true) + @Menu(type = "resouce", subtype = "voice", access = true) public void voice(HttpServletResponse response, @Valid String id) throws IOException { - File file = new File(path ,id) ; - if(file.exists() && file.isFile()){ - response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path ,id))); - } + File file = new File(path, id); + if (file.exists() && file.isFile()) { + response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, id))); + } } - + @RequestMapping("/url") - @Menu(type = "resouce" , subtype = "image" , access = true) + @Menu(type = "resouce", subtype = "image", access = true) public void url(HttpServletResponse response, @Valid String url) throws IOException { - byte[] data = new byte[1024] ; - int length = 0 ; - OutputStream out = response.getOutputStream(); - if(!StringUtils.isBlank(url)){ - InputStream input = new URL(url).openStream() ; - while((length = input.read(data) )> 0){ - out.write(data, 0, length); - } - input.close(); - } + byte[] data = new byte[1024]; + int length = 0; + OutputStream out = response.getOutputStream(); + if (!StringUtils.isBlank(url)) { + InputStream input = new URL(url).openStream(); + while ((length = input.read(data)) > 0) { + out.write(data, 0, length); + } + input.close(); + } } - + @RequestMapping("/image/upload") - @Menu(type = "resouce" , subtype = "imageupload" , access = false) - public ModelAndView upload(ModelMap map,HttpServletRequest request , @RequestParam(value = "imgFile", required = false) MultipartFile imgFile) throws IOException { - ModelAndView view = request(super.createRequestPageTempletResponse("/public/upload")) ; - UploadStatus upload = null ; - String fileName = null ; - if(imgFile!=null && imgFile.getOriginalFilename().lastIndexOf(".") > 0){ - File uploadDir = new File(path , "upload"); - if(!uploadDir.exists()){ - uploadDir.mkdirs() ; - } - fileName = "upload/"+ MainUtils.md5(imgFile.getBytes())+imgFile.getOriginalFilename().substring(imgFile.getOriginalFilename().lastIndexOf(".")).toLowerCase() ; - FileCopyUtils.copy(imgFile.getBytes(), new File(path , fileName)); - - String fileURL = request.getScheme()+"://"+request.getServerName()+"/res/image.html?id="+fileName ; - if(request.getServerPort() == 80){ - fileURL = request.getScheme()+"://"+request.getServerName()+"/res/image.html?id="+fileName; - }else{ - fileURL = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/res/image.html?id="+fileName; - } - upload = new UploadStatus("0" , fileURL); //图片直接发送给 客户,不用返回 - }else{ - upload = new UploadStatus("请选择图片文件"); - } - map.addAttribute("upload", upload) ; - return view ; + @Menu(type = "resouce", subtype = "imageupload", access = false) + public ModelAndView upload(ModelMap map, HttpServletRequest request, @RequestParam(value = "imgFile", required = false) MultipartFile imgFile) throws IOException { + ModelAndView view = request(super.createRequestPageTempletResponse("/public/upload")); + UploadStatus upload = null; + String fileName = null; + if (imgFile != null && imgFile.getOriginalFilename().lastIndexOf(".") > 0) { + File uploadDir = new File(path, "upload"); + if (!uploadDir.exists()) { + uploadDir.mkdirs(); + } + fileName = "upload/" + MainUtils.md5(imgFile.getBytes()) + imgFile.getOriginalFilename().substring(imgFile.getOriginalFilename().lastIndexOf(".")).toLowerCase(); + FileCopyUtils.copy(imgFile.getBytes(), new File(path, fileName)); + + String fileURL = request.getScheme() + "://" + request.getServerName() + "/res/image.html?id=" + fileName; + if (request.getServerPort() == 80) { + fileURL = request.getScheme() + "://" + request.getServerName() + "/res/image.html?id=" + fileName; + } else { + fileURL = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/res/image.html?id=" + fileName; + } + upload = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回 + } else { + upload = new UploadStatus("请选择图片文件"); + } + map.addAttribute("upload", upload); + return view; } - + @RequestMapping("/file") - @Menu(type = "resouce" , subtype = "file" , access = false) - public void file(HttpServletResponse response,HttpServletRequest request, @Valid String id) throws IOException { - if(!StringUtils.isBlank(id)){ - AttachmentFile attachmentFile = attachementRes.findByIdAndOrgi(id, super.getOrgi(request)) ; - if(attachmentFile!=null){ - response.setContentType(attachmentFile.getFiletype()); - response.setHeader("Content-Disposition", "attachment;filename="+java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8")); - if(!StringUtils.isBlank(attachmentFile.getModel()) && attachmentFile.getModel().equals("app")){ - response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path , "app/app/"+attachmentFile.getFileid()))); - }else{ - response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path , "app/workorders/"+attachmentFile.getFileid()))); - } - } - } + @Menu(type = "resouce", subtype = "file", access = false) + public void file(HttpServletResponse response, HttpServletRequest request, @Valid String id) throws IOException { + if (!StringUtils.isBlank(id)) { + AttachmentFile attachmentFile = attachementRes.findByIdAndOrgi(id, super.getOrgi(request)); + if (attachmentFile != null) { + response.setContentType(attachmentFile.getFiletype()); + response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8")); + if (StringUtils.isNotBlank(attachmentFile.getModel()) && attachmentFile.getModel().equals("app")) { + response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, "app/" + attachmentFile.getFileid()))); + } else { + response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, "upload/" + attachmentFile.getFileid()))); + } + } + } } + @RequestMapping("/template") - @Menu(type = "resouce" , subtype = "template" , access = false) - public void template(HttpServletResponse response,HttpServletRequest request, @Valid String filename) throws IOException { - if(!StringUtils.isBlank(filename)){ - InputStream is = MediaController.class.getClassLoader().getResourceAsStream(TEMPLATE_DATA_PATH+filename); - if(is!=null) { - response.setContentType("text/plain"); - response.setHeader("Content-Disposition", "attachment;filename="+java.net.URLEncoder.encode(filename, "UTF-8")); - int length ; - byte[] data = new byte[1024] ; - while((length = is.read(data)) > 0) { - response.getOutputStream().write(data , 0 , length); - } - is.close(); - } - } - return ; + @Menu(type = "resouce", subtype = "template", access = false) + public void template(HttpServletResponse response, HttpServletRequest request, @Valid String filename) throws IOException { + if (!StringUtils.isBlank(filename)) { + InputStream is = MediaController.class.getClassLoader().getResourceAsStream(TEMPLATE_DATA_PATH + filename); + if (is != null) { + response.setContentType("text/plain"); + response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(filename, "UTF-8")); + int length; + byte[] data = new byte[1024]; + while ((length = is.read(data)) > 0) { + response.getOutputStream().write(data, 0, length); + } + is.close(); + } + } + return; } - + } \ No newline at end of file diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java index a9c2dfb4..40de2613 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java @@ -24,6 +24,7 @@ import com.chatopera.cc.app.im.message.AgentStatusMessage; import com.chatopera.cc.app.im.message.ChatMessage; import com.chatopera.cc.app.im.message.NewRequestMessage; import com.chatopera.cc.app.im.util.ChatbotUtils; +import com.chatopera.cc.app.im.util.IMServiceUtils; import com.chatopera.cc.app.model.*; import com.chatopera.cc.app.persistence.repository.AgentUserRepository; import com.chatopera.cc.app.persistence.repository.ChatbotRepository; @@ -82,6 +83,11 @@ public class ChatbotEventHandler { NettyClients.getInstance().putChatbotEventClient(user, client); CousultInvite invite = OnlineUserUtils.cousult(appid, orgi, MainContext.getContext().getBean(ConsultInviteRepository.class)); + /** + * 更新坐席服务类型 + */ + IMServiceUtils.shiftOpsType(user, orgi, MainContext.OptTypeEnum.CHATBOT); + // send out tip MessageOutContent tip = new MessageOutContent(); tip.setMessage("您正在使用机器人客服!"); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java index 46dc9391..4f08bc40 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java @@ -25,6 +25,7 @@ import com.chatopera.cc.app.im.message.AgentStatusMessage; import com.chatopera.cc.app.im.message.ChatMessage; import com.chatopera.cc.app.im.message.NewRequestMessage; import com.chatopera.cc.app.im.util.HumanUtils; +import com.chatopera.cc.app.im.util.IMServiceUtils; import com.chatopera.cc.app.model.*; import com.chatopera.cc.app.persistence.impl.AgentUserService; import com.chatopera.cc.app.persistence.repository.AgentServiceRepository; @@ -37,6 +38,8 @@ import com.corundumstudio.socketio.annotation.OnConnect; import com.corundumstudio.socketio.annotation.OnDisconnect; import com.corundumstudio.socketio.annotation.OnEvent; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import java.io.UnsupportedEncodingException; @@ -45,6 +48,7 @@ import java.util.Date; import java.util.List; public class IMEventHandler { + private final static Logger logger = LoggerFactory.getLogger(IMEventHandler.class); protected SocketIOServer server; @Autowired @@ -75,11 +79,16 @@ public class IMEventHandler { InetSocketAddress address = (InetSocketAddress) client.getRemoteAddress(); String ip = MainUtils.getIpAddr(client.getHandshakeData().getHttpHeaders(), address.getHostString()); NewRequestMessage newRequestMessage = OnlineUserUtils.newRequestMessage(user, orgi, session, appid, ip, client.getHandshakeData().getSingleUrlParam("osname"), client.getHandshakeData().getSingleUrlParam("browser"), MainContext.ChannelTypeEnum.WEBIM.toString(), skill, agent, nickname, title, url, traceid, MainContext.ChatInitiatorType.USER.toString()); -// /** -// * 加入到 缓存列表 -// */ + /** + * 加入到 缓存列表 + */ NettyClients.getInstance().putIMEventClient(user, client); -// + + /** + * 更新坐席服务类型 + */ + IMServiceUtils.shiftOpsType(user, orgi, MainContext.OptTypeEnum.HUMAN); + if (newRequestMessage != null && StringUtils.isNotBlank(newRequestMessage.getMessage())) { MessageOutContent outMessage = new MessageOutContent(); outMessage.setMessage(newRequestMessage.getMessage()); @@ -137,6 +146,7 @@ public class IMEventHandler { agentUser.setEmail(contacts.getEmail()); agentUser.setResion(contacts.getMemo()); agentUser.setChatbotops(false); // 非机器人客服 + agentUser.setOpttype(MainContext.OptTypeEnum.HUMAN.toString()); service.save(agentUser); CacheHelper.getAgentUserCacheBean().put(agentUser.getUserid(), agentUser, MainContext.SYSTEM_ORGI); } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java new file mode 100644 index 00000000..a5e5a7c4 --- /dev/null +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java @@ -0,0 +1,39 @@ +package com.chatopera.cc.app.im.util; + +import com.chatopera.cc.app.basic.MainContext; +import com.chatopera.cc.app.cache.CacheHelper; +import com.chatopera.cc.app.model.AgentUser; +import com.chatopera.cc.app.persistence.impl.AgentUserService; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class IMServiceUtils { + private final static Logger logger = LoggerFactory.getLogger(IMServiceUtils.class); + + public static void shiftOpsType(final String userId, final String orgi, final MainContext.OptTypeEnum opsType){ + AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(userId, orgi); + AgentUserService service = MainContext.getContext().getBean( + AgentUserService.class); + if (agentUser == null) { + agentUser = service.findByUseridAndOrgi(userId, orgi); + } + if (agentUser != null) { + switch (opsType){ + case CHATBOT: + agentUser.setOpttype(MainContext.OptTypeEnum.CHATBOT.toString()); + agentUser.setChatbotops(true); + break; + case HUMAN: + agentUser.setOpttype(MainContext.OptTypeEnum.HUMAN.toString()); + agentUser.setChatbotops(false); + break; + default: + logger.warn("shiftOpsType unknown type."); + break; + } + } + service.save(agentUser); + CacheHelper.getAgentUserCacheBean().put(agentUser.getUserid(), agentUser, orgi); + } +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/RichMediaUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/RichMediaUtils.java index 97ff51e4..da6fa7d9 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/RichMediaUtils.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/RichMediaUtils.java @@ -103,7 +103,7 @@ public class RichMediaUtils { data.setTouser(agentUser.getAgentno()); data.setAppid(agentUser.getAppid()); data.setOrgi(agentUser.getOrgi()); - if (StringUtils.equals(agentUser.getOpttype(), MainContext.OptTypeEnum.CHATBOT.toString())) { + if (agentUser.isChatbotops()) { // TODO #75 create Chatbot Message // https://github.com/chatopera/cosin/issues/75 logger.info("[createRichMediaMessageWithChannel] TODO #75 create Chatbot Message"); From 9d95a3b21ae4bf54dca361283bcc336e976c8b0d Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Tue, 23 Oct 2018 11:01:03 +0800 Subject: [PATCH 34/54] #111 enhance sequence --- .../cc/app/im/handler/IMEventHandler.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java index 4f08bc40..b5f97bf2 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java @@ -73,15 +73,12 @@ public class IMEventHandler { String nickname = client.getHandshakeData().getSingleUrlParam("nickname"); if (StringUtils.isNotBlank(user)) { - /** - * 用户进入到对话连接 , 排队用户请求 , 如果返回失败,表示当前坐席全忙,用户进入排队状态,当前提示信息 显示 当前排队的队列位置,不可进行对话,用户发送的消息作为留言处理 - */ InetSocketAddress address = (InetSocketAddress) client.getRemoteAddress(); String ip = MainUtils.getIpAddr(client.getHandshakeData().getHttpHeaders(), address.getHostString()); - NewRequestMessage newRequestMessage = OnlineUserUtils.newRequestMessage(user, orgi, session, appid, ip, client.getHandshakeData().getSingleUrlParam("osname"), client.getHandshakeData().getSingleUrlParam("browser"), MainContext.ChannelTypeEnum.WEBIM.toString(), skill, agent, nickname, title, url, traceid, MainContext.ChatInitiatorType.USER.toString()); - /** - * 加入到 缓存列表 - */ + + /** + * 加入到 缓存列表 + */ NettyClients.getInstance().putIMEventClient(user, client); /** @@ -89,6 +86,25 @@ public class IMEventHandler { */ IMServiceUtils.shiftOpsType(user, orgi, MainContext.OptTypeEnum.HUMAN); + /** + * 用户进入到对话连接 , 排队用户请求 , 如果返回失败,表示当前坐席全忙,用户进入排队状态,当前提示信息 显示 当前排队的队列位置,不可进行对话,用户发送的消息作为留言处理 + */ + NewRequestMessage newRequestMessage = OnlineUserUtils.newRequestMessage(user, + orgi, + session, + appid, + ip, + client.getHandshakeData().getSingleUrlParam("osname"), + client.getHandshakeData().getSingleUrlParam("browser"), + MainContext.ChannelTypeEnum.WEBIM.toString(), + skill, + agent, + nickname, + title, + url, + traceid, + MainContext.ChatInitiatorType.USER.toString()); + if (newRequestMessage != null && StringUtils.isNotBlank(newRequestMessage.getMessage())) { MessageOutContent outMessage = new MessageOutContent(); outMessage.setMessage(newRequestMessage.getMessage()); From 901e9aa6210cf907bde9e23dab71e7a967d544c1 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Tue, 23 Oct 2018 11:44:56 +0800 Subject: [PATCH 35/54] #111 format codes --- .../app/algorithm/AutomaticServiceDist.java | 52 +++++------ .../cc/app/im/router/MessageRouter.java | 93 ++++++++++--------- 2 files changed, 73 insertions(+), 72 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java b/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java index d2349223..cb69525e 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java @@ -16,15 +16,15 @@ */ package com.chatopera.cc.app.algorithm; -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.basic.MainContext; +import com.chatopera.cc.app.basic.MainUtils; +import com.chatopera.cc.app.cache.CacheHelper; +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.persistence.repository.*; import com.chatopera.cc.util.WebIMReport; import com.corundumstudio.socketio.SocketIONamespace; @@ -141,9 +141,9 @@ public class AutomaticServiceDist { int queneUsers = 0; PagingPredicate pagingPredicate = null; - if (!StringUtils.isBlank(skill)) { + if (StringUtils.isNotBlank(skill)) { pagingPredicate = new PagingPredicate(new SqlPredicate("status = 'inquene' AND skill = '" + skill + "' AND orgi = '" + orgi + "'"), 100); - } else if (!StringUtils.isBlank(agent)) { + } else if (StringUtils.isNotBlank(agent)) { pagingPredicate = new PagingPredicate(new SqlPredicate("status = 'inquene' AND agent = '" + agent + "' AND orgi = '" + orgi + "'"), 100); } else { pagingPredicate = new PagingPredicate(new SqlPredicate("status = 'inquene' AND orgi = '" + orgi + "'"), 100); @@ -168,7 +168,7 @@ public class AutomaticServiceDist { public static List getAgentStatus(String skill, String orgi) { PagingPredicate pagingPredicate = new PagingPredicate(new SqlPredicate("orgi = '" + orgi + "'"), 100); - if (!StringUtils.isBlank(skill)) { + if (StringUtils.isNotBlank(skill)) { pagingPredicate = new PagingPredicate(new SqlPredicate("skill = '" + skill + "' AND orgi = '" + orgi + "'"), 100); } List agentList = new ArrayList(); @@ -186,7 +186,7 @@ public class AutomaticServiceDist { AgentStatus agentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(agentno, orgi); List agentStatusList = new ArrayList(); PagingPredicate pagingPredicate = null; - if (agentStatus != null && !StringUtils.isBlank(agentStatus.getSkill())) { + if (agentStatus != null && StringUtils.isNotBlank(agentStatus.getSkill())) { pagingPredicate = new PagingPredicate(new SqlPredicate("status = 'inquene' AND ((agent = null AND skill = null) OR (skill = '" + agentStatus.getSkill() + "' AND agent = null) OR agent = '" + agentno + "') AND orgi = '" + orgi + "'"), 10); } else { pagingPredicate = new PagingPredicate(new SqlPredicate("status = 'inquene' AND ((agent = null AND skill = null) OR agent = '" + agentno + "') AND orgi = '" + orgi + "'"), 10); @@ -207,7 +207,7 @@ public class AutomaticServiceDist { outMessage.setNickName(agentStatus.getUsername()); outMessage.setCreatetime(MainUtils.dateFormate.format(new Date())); - if (!StringUtils.isBlank(agentUser.getUserid())) { + if (StringUtils.isNotBlank(agentUser.getUserid())) { OutMessageRouter router = null; router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()); if (router != null) { @@ -269,7 +269,7 @@ public class AutomaticServiceDist { 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())) { + if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) { service = agentServiceRes.findByIdAndOrgi(agentUser.getAgentserviceid(), agentUser.getOrgi()); } if (service == null) {//当做留言处理 @@ -392,7 +392,7 @@ public class AutomaticServiceDist { 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 = MainContext.getContext().getBean(WorkMonitorRepository.class); WorkMonitor workMonitor = new WorkMonitor(); - if (!StringUtils.isBlank(agent) && !StringUtils.isBlank(status)) { + if (StringUtils.isNotBlank(agent) && StringUtils.isNotBlank(status)) { workMonitor.setAgent(agent); workMonitor.setAgentno(agent); workMonitor.setStatus(status); @@ -450,9 +450,9 @@ public class AutomaticServiceDist { /** * 处理ACD 的 技能组请求和 坐席请求 */ - if (!StringUtils.isBlank(agentUser.getAgent())) { + if (StringUtils.isNotBlank(agentUser.getAgent())) { pagingPredicate = new PagingPredicate(new SqlPredicate(" busy = false AND agentno = '" + agentUser.getAgent() + "' AND orgi = '" + orgi + "'"), 1); - } else if (!StringUtils.isBlank(agentUser.getSkill())) { + } else if (StringUtils.isNotBlank(agentUser.getSkill())) { pagingPredicate = new PagingPredicate(new SqlPredicate(" busy = false AND skill = '" + agentUser.getSkill() + "' AND orgi = '" + orgi + "'"), 1); } else { pagingPredicate = new PagingPredicate(new SqlPredicate(" busy = false AND orgi = '" + orgi + "'"), 1); @@ -579,7 +579,7 @@ public class AutomaticServiceDist { */ private static AgentService processAgentService(AgentStatus agentStatus, AgentUser agentUser, String orgi, boolean finished) throws Exception { AgentService agentService = new AgentService(); //放入缓存的对象 - if (!StringUtils.isBlank(agentUser.getAgentserviceid())) { + if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) { agentService.setId(agentUser.getAgentserviceid()); } agentService.setOrgi(orgi); @@ -668,20 +668,20 @@ public class AutomaticServiceDist { AgentServiceRepository agentServiceRes = MainContext.getContext().getBean(AgentServiceRepository.class); - if (!StringUtils.isBlank(agentUser.getName())) { + if (StringUtils.isNotBlank(agentUser.getName())) { agentService.setName(agentUser.getName()); } - if (!StringUtils.isBlank(agentUser.getPhone())) { + if (StringUtils.isNotBlank(agentUser.getPhone())) { agentService.setPhone(agentUser.getPhone()); } - if (!StringUtils.isBlank(agentUser.getEmail())) { + if (StringUtils.isNotBlank(agentUser.getEmail())) { agentService.setEmail(agentUser.getEmail()); } - if (!StringUtils.isBlank(agentUser.getResion())) { + if (StringUtils.isNotBlank(agentUser.getResion())) { agentService.setResion(agentUser.getResion()); } - if (!StringUtils.isBlank(agentUser.getSkill())) { + if (StringUtils.isNotBlank(agentUser.getSkill())) { agentService.setAgentskill(agentUser.getSkill()); } else if (agentStatus != null) { agentService.setAgentskill(agentStatus.getSkill()); @@ -743,7 +743,7 @@ public class AutomaticServiceDist { agentUser.getStatus())) { serviceFinish(agentUser, orgi); } - if (!StringUtils.isBlank(agentUser.getId())) { + if (StringUtils.isNotBlank(agentUser.getId())) { AgentUserRepository agentUserRes = MainContext.getContext().getBean(AgentUserRepository.class); agentUser = agentUserRes.findByIdAndOrgi(agentUser.getId(), orgi); if (agentUser != null) { @@ -766,7 +766,7 @@ public class AutomaticServiceDist { } SessionConfig sessionConfig = initSessionConfig(orgi); String successMsg = "坐席分配成功," + queneTip + "为您服务。"; - if (!StringUtils.isBlank(sessionConfig.getSuccessmsg())) { + if (StringUtils.isNotBlank(sessionConfig.getSuccessmsg())) { successMsg = sessionConfig.getSuccessmsg().replaceAll("\\{agent\\}", queneTip); } return successMsg; @@ -779,7 +779,7 @@ public class AutomaticServiceDist { public static String getServiceFinishMessage(String channel, String orgi) { SessionConfig sessionConfig = initSessionConfig(orgi); String queneTip = "坐席已断开和您的对话"; - if (!StringUtils.isBlank(sessionConfig.getFinessmsg())) { + if (StringUtils.isNotBlank(sessionConfig.getFinessmsg())) { queneTip = sessionConfig.getFinessmsg(); } return queneTip; @@ -795,7 +795,7 @@ public class AutomaticServiceDist { } SessionConfig sessionConfig = initSessionConfig(orgi); String noAgentTipMsg = "坐席全忙,已进入等待队列,您也可以在其他时间再来咨询。"; - if (!StringUtils.isBlank(sessionConfig.getNoagentmsg())) { + if (StringUtils.isNotBlank(sessionConfig.getNoagentmsg())) { noAgentTipMsg = sessionConfig.getNoagentmsg().replaceAll("\\{num\\}", queneTip); } return noAgentTipMsg; @@ -809,7 +809,7 @@ public class AutomaticServiceDist { } SessionConfig sessionConfig = initSessionConfig(orgi); String agentBusyTipMsg = "正在排队,请稍候,在您之前,还有 " + queneTip + " 位等待用户。"; - if (!StringUtils.isBlank(sessionConfig.getAgentbusymsg())) { + if (StringUtils.isNotBlank(sessionConfig.getAgentbusymsg())) { agentBusyTipMsg = sessionConfig.getAgentbusymsg().replaceAll("\\{num\\}", queneTip); } return agentBusyTipMsg; diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/MessageRouter.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/MessageRouter.java index 8b174631..53655660 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/MessageRouter.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/MessageRouter.java @@ -24,52 +24,53 @@ import com.chatopera.cc.app.model.AgentService; import com.chatopera.cc.app.model.MessageDataBean; import com.chatopera.cc.app.model.MessageOutContent; -public class MessageRouter extends Router{ +public class MessageRouter extends Router { - @Override - public MessageDataBean handler(MessageDataBean inMessage) { - MessageOutContent outMessage = new MessageOutContent() ; - try { - outMessage.setOrgi(inMessage.getOrgi()); - outMessage.setFromUser(inMessage.getToUser()); - outMessage.setToUser(inMessage.getFromUser()); - outMessage.setId(MainUtils.genID()); - outMessage.setMessageType(inMessage.getMessageType()); - outMessage.setUser(inMessage.getUser()); - outMessage.setAgentUser(inMessage.getAgentUser()); - /** - * 首先交由 IMR处理 MESSAGE指令 , 如果当前用户是在 坐席对话列表中, 则直接推送给坐席,如果不在,则执行 IMR - */ - if(outMessage.getAgentUser()!=null && outMessage.getAgentUser().getStatus()!=null){ - if(outMessage.getAgentUser().getStatus().equals(MainContext.AgentUserStatusEnum.INQUENE.toString())){ - int queneIndex = AutomaticServiceDist.getQueneIndex(inMessage.getAgentUser().getAgent() , inMessage.getOrgi(), inMessage.getAgentUser().getSkill()) ; - if(MainContext.AgentUserStatusEnum.INQUENE.toString().equals(outMessage.getAgentUser().getStatus())){ - outMessage.setMessage(AutomaticServiceDist.getQueneMessage(queneIndex , outMessage.getAgentUser().getChannel(),inMessage.getOrgi())); - } - }else if(outMessage.getAgentUser().getStatus().equals(MainContext.AgentUserStatusEnum.INSERVICE.toString())){ - - } - }else if(MainContext.MessageTypeEnum.NEW.toString().equals(inMessage.getMessageType())){ - /** - * 找到空闲坐席,如果未找到坐席, 则将该用户放入到 排队队列 - * - */ - AgentService agentService = AutomaticServiceDist.allotAgent(inMessage.getAgentUser(), inMessage.getOrgi()) ; - if(agentService!=null && MainContext.AgentUserStatusEnum.INSERVICE.toString().equals(agentService.getStatus())){ - outMessage.setMessage(AutomaticServiceDist.getSuccessMessage(agentService , inMessage.getAgentUser().getChannel(),inMessage.getOrgi())); - NettyClients.getInstance().sendAgentEventMessage(agentService.getAgentno(), MainContext.MessageTypeEnum.NEW.toString(), inMessage.getAgentUser()); - }else{ - if(agentService.getQueneindex() > 0){ //当前有坐席 - outMessage.setMessage(AutomaticServiceDist.getQueneMessage(agentService.getQueneindex(), inMessage.getAgentUser().getChannel(), inMessage.getOrgi())); - }else{ - outMessage.setMessage(AutomaticServiceDist.getNoAgentMessage(agentService.getQueneindex(), inMessage.getAgentUser().getChannel(), inMessage.getOrgi())); - } - } - } - } catch (Exception e1) { - e1.printStackTrace(); - } - return outMessage ; - } + @Override + public MessageDataBean handler(MessageDataBean inMessage) { + MessageOutContent outMessage = new MessageOutContent(); + try { + outMessage.setOrgi(inMessage.getOrgi()); + outMessage.setFromUser(inMessage.getToUser()); + outMessage.setToUser(inMessage.getFromUser()); + outMessage.setId(MainUtils.genID()); + outMessage.setMessageType(inMessage.getMessageType()); + outMessage.setUser(inMessage.getUser()); + outMessage.setAgentUser(inMessage.getAgentUser()); + /** + * 首先交由 IMR处理 MESSAGE指令 , 如果当前用户是在 坐席对话列表中, 则直接推送给坐席,如果不在,则执行 IMR + */ + if (outMessage.getAgentUser() != null && outMessage.getAgentUser().getStatus() != null) { + if (outMessage.getAgentUser().getStatus().equals(MainContext.AgentUserStatusEnum.INQUENE.toString())) { + int queneIndex = AutomaticServiceDist.getQueneIndex(inMessage.getAgentUser().getAgent(), inMessage.getOrgi(), inMessage.getAgentUser().getSkill()); + if (MainContext.AgentUserStatusEnum.INQUENE.toString().equals(outMessage.getAgentUser().getStatus())) { + outMessage.setMessage(AutomaticServiceDist.getQueneMessage(queneIndex, outMessage.getAgentUser().getChannel(), inMessage.getOrgi())); + } + } else if (outMessage.getAgentUser().getStatus().equals(MainContext.AgentUserStatusEnum.INSERVICE.toString())) { + + } + } else if (MainContext.MessageTypeEnum.NEW.toString().equals(inMessage.getMessageType())) { + /** + * 找到空闲坐席,如果未找到坐席, 则将该用户放入到 排队队列 + * + */ + AgentService agentService = AutomaticServiceDist.allotAgent(inMessage.getAgentUser(), inMessage.getOrgi()); + if (agentService != null && MainContext.AgentUserStatusEnum.INSERVICE.toString().equals(agentService.getStatus())) { + outMessage.setMessage(AutomaticServiceDist.getSuccessMessage(agentService, inMessage.getAgentUser().getChannel(), inMessage.getOrgi())); + // TODO #111 publish to redis + NettyClients.getInstance().sendAgentEventMessage(agentService.getAgentno(), MainContext.MessageTypeEnum.NEW.toString(), inMessage.getAgentUser()); + } else { + if (agentService.getQueneindex() > 0) { //当前有坐席 + outMessage.setMessage(AutomaticServiceDist.getQueneMessage(agentService.getQueneindex(), inMessage.getAgentUser().getChannel(), inMessage.getOrgi())); + } else { + outMessage.setMessage(AutomaticServiceDist.getNoAgentMessage(agentService.getQueneindex(), inMessage.getAgentUser().getChannel(), inMessage.getOrgi())); + } + } + } + } catch (Exception e1) { + e1.printStackTrace(); + } + return outMessage; + } } From 29ebd3125b87a3519f003f1e5901eb4c48919ea6 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Tue, 23 Oct 2018 17:17:02 +0800 Subject: [PATCH 36/54] =?UTF-8?q?Closed=20#111=20=E6=94=AF=E6=8C=81WebIM?= =?UTF-8?q?=E7=9A=84=E9=9B=86=E7=BE=A4=E5=9C=BA=E6=99=AF=E4=B8=8B=E4=BD=BF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/algorithm/AutomaticServiceDist.java | 10 +- .../cc/app/config/RedisConfigure.java | 37 +- .../handler/apps/agent/AgentController.java | 9 +- .../apps/service/ChatServiceController.java | 760 +++++++++--------- .../cc/app/im/client/NettyClients.java | 283 ++++--- .../cc/app/im/handler/AgentEventHandler.java | 398 +++++---- .../app/im/handler/CalloutEventHandler.java | 2 +- .../cc/app/im/router/MessageRouter.java | 2 +- .../app/im/router/WebIMOutMessageRouter.java | 2 +- .../chatopera/cc/app/im/util/HumanUtils.java | 10 +- .../cc/app/im/util/IMServiceUtils.java | 29 + .../cc/app/model/MessageInContent.java | 315 ++++---- .../cc/app/schedule/CallOutWireTask.java | 2 - .../cc/app/schedule/WebIMAgentDispatcher.java | 104 +++ .../schedule/WebIMOnlineUserDispatcher.java | 102 +++ .../chatopera/cc/app/schedule/WebIMTask.java | 51 +- .../java/com/chatopera/cc/util/Constants.java | 12 + .../src/main/resources/application.properties | 4 +- 18 files changed, 1237 insertions(+), 895 deletions(-) create mode 100644 contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMAgentDispatcher.java create mode 100644 contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMOnlineUserDispatcher.java diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java b/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java index cb69525e..0f66550b 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java @@ -214,8 +214,8 @@ public class AutomaticServiceDist { router.handler(agentUser.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), agentUser.getAppid(), outMessage); } } - - NettyClients.getInstance().sendAgentEventMessage(agentService.getAgentno(), MainContext.MessageTypeEnum.NEW.toString(), agentUser); + // TODO #111 为坐席分配访客 + NettyClients.getInstance().publishAgentEventMessage(agentService.getAgentno(), MainContext.MessageTypeEnum.NEW.toString(), agentUser); } catch (Exception ex) { ex.printStackTrace(); } @@ -311,7 +311,8 @@ public class AutomaticServiceDist { NettyClients.getInstance().sendCalloutEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.END.toString(), agentUser); } else { if (agentStatus != null) // WebIM 查看用户状态 - NettyClients.getInstance().sendAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.END.toString(), agentUser); + // TODO #111 结束会话 + NettyClients.getInstance().publishAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.END.toString(), agentUser); OutMessageRouter router = null; router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()); if (router != null) { @@ -500,7 +501,8 @@ public class AutomaticServiceDist { if (agentStatus != null) { agentService = processAgentService(agentStatus, agentUser, orgi); publishMessage(orgi, "invite", "success", agentno); - NettyClients.getInstance().sendAgentEventMessage(agentService.getAgentno(), MainContext.MessageTypeEnum.NEW.toString(), agentUser); + // TODO #111 为坐席分配邀请的访客 + NettyClients.getInstance().publishAgentEventMessage(agentService.getAgentno(), MainContext.MessageTypeEnum.NEW.toString(), agentUser); } else { agentService = allotAgent(agentUser, orgi); } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/config/RedisConfigure.java b/contact-center/app/src/main/java/com/chatopera/cc/app/config/RedisConfigure.java index 4539c90c..599d55ea 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/config/RedisConfigure.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/config/RedisConfigure.java @@ -15,8 +15,10 @@ */ package com.chatopera.cc.app.config; -import com.chatopera.cc.util.Constants; import com.chatopera.cc.app.schedule.CallOutWireTask; +import com.chatopera.cc.app.schedule.WebIMAgentDispatcher; +import com.chatopera.cc.app.schedule.WebIMOnlineUserDispatcher; +import com.chatopera.cc.util.Constants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -38,17 +40,25 @@ public class RedisConfigure { @Autowired CallOutWireTask callOutWireTask; + @Autowired + WebIMAgentDispatcher webIMAgentDispatcher; + + @Autowired + WebIMOnlineUserDispatcher webIMOnlineUserDispatcher; + @Bean RedisMessageListenerContainer redisContainer() { final RedisMessageListenerContainer container = new RedisMessageListenerContainer(); container.setConnectionFactory(jedisConnectionFactory); - container.addMessageListener(messageListener(), pbxEvents()); + container.addMessageListener(pbxMessageListener(), pbxEvents()); + container.addMessageListener(imAgentDispatchListener(), imAgentEvents()); + container.addMessageListener(imOnlineUserDispatchListener(), imOnlineUserEvents()); container.setTaskExecutor(Executors.newFixedThreadPool(50)); return container; } @Bean - MessageListenerAdapter messageListener() { + MessageListenerAdapter pbxMessageListener() { return new MessageListenerAdapter(callOutWireTask); } @@ -57,4 +67,25 @@ public class RedisConfigure { return new PatternTopic(Constants.FS_CHANNEL_FS_TO_CC); } + @Bean + MessageListenerAdapter imAgentDispatchListener() { + return new MessageListenerAdapter(webIMAgentDispatcher); + } + + @Bean + PatternTopic imAgentEvents() { + return new PatternTopic(Constants.INSTANT_MESSAGING_WEBIM_AGENT_CHANNEL); + } + + @Bean + MessageListenerAdapter imOnlineUserDispatchListener(){ + return new MessageListenerAdapter(webIMOnlineUserDispatcher); + } + + @Bean + PatternTopic imOnlineUserEvents() { + return new PatternTopic(Constants.INSTANT_MESSAGING_WEBIM_ONLINE_USER_CHANNEL); + } + + } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java index 081a4023..041611d5 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java @@ -768,8 +768,8 @@ public class AgentController extends Handler { data.setUsername(super.getUser(request).getUsername()); chatMessageRepository.save(data); - - NettyClients.getInstance().sendAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data); + // TODO #111 通知文件上传消息 + NettyClients.getInstance().publishAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data); } } else { @@ -1068,7 +1068,8 @@ public class AgentController extends Handler { agentService.setAgentno(agentno); agentService.setAgentusername(transAgentStatus.getUsername()); } - NettyClients.getInstance().sendAgentEventMessage(agentno, MainContext.MessageTypeEnum.NEW.toString(), agentUser); + // TODO #111 通知转接消息 + NettyClients.getInstance().publishAgentEventMessage(agentno, MainContext.MessageTypeEnum.NEW.toString(), agentUser); } } else { agentUser = agentUserRepository.findByIdAndOrgi(agentuserid, super.getOrgi(request)); @@ -1317,4 +1318,4 @@ public class AgentController extends Handler { return request(super.createRequestPageTempletResponse("redirect:/agent/index.html")); } -} \ No newline at end of file +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/ChatServiceController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/ChatServiceController.java index f641c839..edb6947c 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/ChatServiceController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/ChatServiceController.java @@ -16,27 +16,17 @@ */ package com.chatopera.cc.app.handler.apps.service; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import com.chatopera.cc.app.basic.MainContext; -import com.chatopera.cc.util.IP; -import com.chatopera.cc.app.basic.MainUtils; -import com.chatopera.cc.util.Menu; -import com.chatopera.cc.app.im.client.NettyClients; import com.chatopera.cc.app.algorithm.AutomaticServiceDist; +import com.chatopera.cc.app.basic.MainContext; +import com.chatopera.cc.app.basic.MainUtils; import com.chatopera.cc.app.cache.CacheHelper; -import com.chatopera.cc.util.OnlineUserUtils; import com.chatopera.cc.app.handler.Handler; +import com.chatopera.cc.app.im.client.NettyClients; +import com.chatopera.cc.app.model.*; +import com.chatopera.cc.app.persistence.repository.*; +import com.chatopera.cc.util.IP; +import com.chatopera.cc.util.Menu; +import com.chatopera.cc.util.OnlineUserUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -48,400 +38,402 @@ import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; -import com.chatopera.cc.app.persistence.repository.AgentServiceRepository; -import com.chatopera.cc.app.persistence.repository.AgentStatusRepository; -import com.chatopera.cc.app.persistence.repository.AgentUserRepository; -import com.chatopera.cc.app.persistence.repository.LeaveMsgRepository; -import com.chatopera.cc.app.persistence.repository.OrganRepository; -import com.chatopera.cc.app.persistence.repository.OrgiSkillRelRepository; -import com.chatopera.cc.app.persistence.repository.UserRepository; -import com.chatopera.cc.app.model.AgentService; -import com.chatopera.cc.app.model.AgentStatus; -import com.chatopera.cc.app.model.AgentUser; -import com.chatopera.cc.app.model.AiUser; -import com.chatopera.cc.app.model.LeaveMsg; -import com.chatopera.cc.app.model.Organ; -import com.chatopera.cc.app.model.OrgiSkillRel; -import com.chatopera.cc.app.model.User; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; @Controller @RequestMapping("/service") public class ChatServiceController extends Handler { - - @Autowired - private AgentServiceRepository agentServiceRes ; - - @Autowired - private AgentUserRepository agentUserRes ; - - @Autowired - private AgentStatusRepository agentStatusRepository ; - - @Autowired - private AgentUserRepository agentUserRepository ; - - @Autowired - private LeaveMsgRepository leaveMsgRes ; - - @Autowired - private OrganRepository organRes ; - - @Autowired - private OrganRepository organ ; - - @Autowired - private UserRepository user ; - - @Autowired - private UserRepository userRes ; - @Autowired - private OrgiSkillRelRepository orgiSkillRelService; - - @RequestMapping("/history/index") - @Menu(type = "service" , subtype = "history" , admin= true) - public ModelAndView index(ModelMap map , HttpServletRequest request ,final String username,final String channel ,final String servicetype,final String allocation,final String servicetimetype,final String begin,final String end) { - Page page = agentServiceRes.findAll(new Specification(){ - @Override - public Predicate toPredicate(Root root, CriteriaQuery query,CriteriaBuilder cb) { - List list = new ArrayList(); - if(!StringUtils.isBlank(username)) { - list.add(cb.equal(root.get("username").as(String.class), username)) ; - } - if(!StringUtils.isBlank(channel)) { - list.add(cb.equal(root.get("channel").as(String.class), channel)) ; - } - if(!StringUtils.isBlank(servicetype)&&!StringUtils.isBlank(allocation)) { - list.add(cb.equal(root.get(servicetype).as(String.class), allocation)); - } - if(!StringUtils.isBlank(servicetimetype)) { - try { - if(!StringUtils.isBlank(begin) && begin.matches("[\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}:[\\d]{2}")){ - list.add(cb.greaterThanOrEqualTo(root.get(servicetimetype).as(Date.class), MainUtils.dateFormate.parse(begin))) ; - } - if(!StringUtils.isBlank(end) && end.matches("[\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}:[\\d]{2}")){ - list.add(cb.lessThanOrEqualTo(root.get(servicetimetype).as(Date.class), MainUtils.dateFormate.parse(end))) ; - } - } catch (ParseException e) { - e.printStackTrace(); - } - - } - Predicate[] p = new Predicate[list.size()]; - return cb.and(list.toArray(p)); - } - },new PageRequest(super.getP(request), super.getPs(request), Direction.DESC , "createtime")) ; - map.put("agentServiceList", page) ; - map.put("username", username) ; - map.put("channel", channel) ; - map.put("servicetype", servicetype) ; - map.put("servicetimetype", servicetimetype) ; - map.put("allocation", allocation); - map.put("begin", begin) ; - map.put("end", end) ; - map.put("deptlist",organ.findByOrgi(super.getOrgi(request))); - map.put("userlist",user.findByOrgiAndDatastatus(super.getOrgi(request), false)); - + + @Autowired + private AgentServiceRepository agentServiceRes; + + @Autowired + private AgentUserRepository agentUserRes; + + @Autowired + private AgentStatusRepository agentStatusRepository; + + @Autowired + private AgentUserRepository agentUserRepository; + + @Autowired + private LeaveMsgRepository leaveMsgRes; + + @Autowired + private OrganRepository organRes; + + @Autowired + private OrganRepository organ; + + @Autowired + private UserRepository user; + + @Autowired + private UserRepository userRes; + @Autowired + private OrgiSkillRelRepository orgiSkillRelService; + + @RequestMapping("/history/index") + @Menu(type = "service", subtype = "history", admin = true) + public ModelAndView index(ModelMap map, HttpServletRequest request, final String username, final String channel, final String servicetype, final String allocation, final String servicetimetype, final String begin, final String end) { + Page page = agentServiceRes.findAll(new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) { + List list = new ArrayList(); + if (!StringUtils.isBlank(username)) { + list.add(cb.equal(root.get("username").as(String.class), username)); + } + if (!StringUtils.isBlank(channel)) { + list.add(cb.equal(root.get("channel").as(String.class), channel)); + } + if (!StringUtils.isBlank(servicetype) && !StringUtils.isBlank(allocation)) { + list.add(cb.equal(root.get(servicetype).as(String.class), allocation)); + } + if (!StringUtils.isBlank(servicetimetype)) { + try { + if (!StringUtils.isBlank(begin) && begin.matches("[\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}:[\\d]{2}")) { + list.add(cb.greaterThanOrEqualTo(root.get(servicetimetype).as(Date.class), MainUtils.dateFormate.parse(begin))); + } + if (!StringUtils.isBlank(end) && end.matches("[\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}:[\\d]{2}")) { + list.add(cb.lessThanOrEqualTo(root.get(servicetimetype).as(Date.class), MainUtils.dateFormate.parse(end))); + } + } catch (ParseException e) { + e.printStackTrace(); + } + + } + Predicate[] p = new Predicate[list.size()]; + return cb.and(list.toArray(p)); + } + }, new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime")); + map.put("agentServiceList", page); + map.put("username", username); + map.put("channel", channel); + map.put("servicetype", servicetype); + map.put("servicetimetype", servicetimetype); + map.put("allocation", allocation); + map.put("begin", begin); + map.put("end", end); + map.put("deptlist", organ.findByOrgi(super.getOrgi(request))); + map.put("userlist", user.findByOrgiAndDatastatus(super.getOrgi(request), false)); + return request(super.createAppsTempletResponse("/apps/service/history/index")); } - - @RequestMapping("/current/index") - @Menu(type = "service" , subtype = "current" , admin= true) - public ModelAndView current(ModelMap map , HttpServletRequest request) { - map.put("agentServiceList", agentServiceRes.findByOrgiAndStatus(super.getOrgi(request), MainContext.AgentUserStatusEnum.INSERVICE.toString() ,new PageRequest(super.getP(request), super.getPs(request), Direction.DESC , "createtime"))) ; + + @RequestMapping("/current/index") + @Menu(type = "service", subtype = "current", admin = true) + public ModelAndView current(ModelMap map, HttpServletRequest request) { + map.put("agentServiceList", agentServiceRes.findByOrgiAndStatus(super.getOrgi(request), MainContext.AgentUserStatusEnum.INSERVICE.toString(), new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime"))); return request(super.createAppsTempletResponse("/apps/service/current/index")); } - - @RequestMapping("/current/trans") - @Menu(type = "service" , subtype = "current" , admin= true) - public ModelAndView trans(ModelMap map , HttpServletRequest request , @Valid String id) { - if(!StringUtils.isBlank(id)){ - AgentService agentService = agentServiceRes.findByIdAndOrgi(id, super.getOrgi(request)) ; - List skillList = OnlineUserUtils.organ(super.getOrgi(request),true) ; - String currentOrgan = super.getUser(request).getOrgan(); - if(StringUtils.isBlank(currentOrgan)) { - if(!skillList.isEmpty()) { - currentOrgan = skillList.get(0).getId(); - } - } - List agentStatusList = AutomaticServiceDist.getAgentStatus(null , super.getOrgi(request)); - List usersids = new ArrayList(); - if(!agentStatusList.isEmpty()) { - for(AgentStatus agentStatus:agentStatusList) { - if(agentStatus!=null){ - usersids.add(agentStatus.getAgentno()) ; - } - } - - } - List userList = userRes.findAll(usersids); - for(User user : userList){ - user.setAgentStatus((AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(user.getId(), super.getOrgi(request))); - } - map.addAttribute("userList", userList) ; - map.addAttribute("userid", agentService.getUserid()) ; - map.addAttribute("agentserviceid", agentService.getId()) ; - map.addAttribute("agentuserid", agentService.getAgentuserid()) ; - map.addAttribute("agentservice", agentService) ; - map.addAttribute("skillList", skillList) ; - map.addAttribute("currentorgan", currentOrgan) ; - } - - return request(super.createRequestPageTempletResponse("/apps/service/current/transfer")); + + @RequestMapping("/current/trans") + @Menu(type = "service", subtype = "current", admin = true) + public ModelAndView trans(ModelMap map, HttpServletRequest request, @Valid String id) { + if (!StringUtils.isBlank(id)) { + AgentService agentService = agentServiceRes.findByIdAndOrgi(id, super.getOrgi(request)); + List skillList = OnlineUserUtils.organ(super.getOrgi(request), true); + String currentOrgan = super.getUser(request).getOrgan(); + if (StringUtils.isBlank(currentOrgan)) { + if (!skillList.isEmpty()) { + currentOrgan = skillList.get(0).getId(); + } + } + List agentStatusList = AutomaticServiceDist.getAgentStatus(null, super.getOrgi(request)); + List usersids = new ArrayList(); + if (!agentStatusList.isEmpty()) { + for (AgentStatus agentStatus : agentStatusList) { + if (agentStatus != null) { + usersids.add(agentStatus.getAgentno()); + } + } + + } + List userList = userRes.findAll(usersids); + for (User user : userList) { + user.setAgentStatus((AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(user.getId(), super.getOrgi(request))); + } + map.addAttribute("userList", userList); + map.addAttribute("userid", agentService.getUserid()); + map.addAttribute("agentserviceid", agentService.getId()); + map.addAttribute("agentuserid", agentService.getAgentuserid()); + map.addAttribute("agentservice", agentService); + map.addAttribute("skillList", skillList); + map.addAttribute("currentorgan", currentOrgan); + } + + return request(super.createRequestPageTempletResponse("/apps/service/current/transfer")); } - - @RequestMapping(value="/transfer/save") - @Menu(type = "apps", subtype = "transfersave") - public ModelAndView transfersave(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String agentno , @Valid String memo){ - if(!StringUtils.isBlank(id)){ - AgentService agentService = agentServiceRes.findByIdAndOrgi(id, super.getOrgi(request)) ; - AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(agentService.getUserid(), super.getOrgi(request)) ; - if(agentUser != null){ - agentUser.setAgentno(agentno); - CacheHelper.getAgentUserCacheBean().put(agentService.getUserid() , agentUser , super.getOrgi(request)) ; - agentUserRepository.save(agentUser) ; - if(MainContext.AgentUserStatusEnum.INSERVICE.toString().equals(agentUser.getStatus())){ //转接 , 发送消息给 目标坐席 - AgentStatus agentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(super.getUser(request).getId(), super.getOrgi(request)) ; - - if(agentStatus!=null){ - AutomaticServiceDist.updateAgentStatus(agentStatus, agentUser, super.getOrgi(request), false); - } - - AgentStatus transAgentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(agentno, super.getOrgi(request)) ; - if(transAgentStatus!=null){ - AutomaticServiceDist.updateAgentStatus(transAgentStatus, agentUser, super.getOrgi(request), true); - agentService.setAgentno(agentno); - agentService.setAgentusername(transAgentStatus.getUsername()); - } - NettyClients.getInstance().sendAgentEventMessage(agentno, MainContext.MessageTypeEnum.NEW.toString(), agentUser); - } - }else{ - agentUser = agentUserRepository.findByIdAndOrgi(agentService.getAgentuserid(), super.getOrgi(request)); - if(agentUser!=null){ - agentUser.setAgentno(agentno); - agentUserRepository.save(agentUser) ; - } - } - - if(agentService!=null){ - agentService.setAgentno(agentno); - if(!StringUtils.isBlank(memo)){ - agentService.setTransmemo(memo); - } - agentService.setTrans(true); - agentService.setTranstime(new Date()); - agentServiceRes.save(agentService) ; - } - } - - return request(super.createRequestPageTempletResponse("redirect:/service/current/index.html")) ; - } - - @RequestMapping("/current/end") - @Menu(type = "service" , subtype = "current" , admin= true) - public ModelAndView end(ModelMap map , HttpServletRequest request , @Valid String id) throws Exception { - if(!StringUtils.isBlank(id)){ - AgentService agentService = agentServiceRes.findByIdAndOrgi(id, super.getOrgi(request)) ; - if(agentService!=null){ - User user = super.getUser(request); - AgentUser agentUser = agentUserRepository.findByIdAndOrgi(agentService.getAgentuserid(), super.getOrgi(request)); - if(agentUser!=null){ - AutomaticServiceDist.deleteAgentUser(agentUser, user.getOrgi()); - } - agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString()); - agentServiceRes.save(agentService) ; - } - } + + @RequestMapping(value = "/transfer/save") + @Menu(type = "apps", subtype = "transfersave") + public ModelAndView transfersave(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String agentno, @Valid String memo) { + if (!StringUtils.isBlank(id)) { + AgentService agentService = agentServiceRes.findByIdAndOrgi(id, super.getOrgi(request)); + AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(agentService.getUserid(), super.getOrgi(request)); + if (agentUser != null) { + agentUser.setAgentno(agentno); + CacheHelper.getAgentUserCacheBean().put(agentService.getUserid(), agentUser, super.getOrgi(request)); + agentUserRepository.save(agentUser); + if (MainContext.AgentUserStatusEnum.INSERVICE.toString().equals(agentUser.getStatus())) { //转接 , 发送消息给 目标坐席 + AgentStatus agentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(super.getUser(request).getId(), super.getOrgi(request)); + + if (agentStatus != null) { + AutomaticServiceDist.updateAgentStatus(agentStatus, agentUser, super.getOrgi(request), false); + } + + AgentStatus transAgentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(agentno, super.getOrgi(request)); + if (transAgentStatus != null) { + AutomaticServiceDist.updateAgentStatus(transAgentStatus, agentUser, super.getOrgi(request), true); + agentService.setAgentno(agentno); + agentService.setAgentusername(transAgentStatus.getUsername()); + } + // TODO #111 通知转接消息 + NettyClients.getInstance().publishAgentEventMessage(agentno, MainContext.MessageTypeEnum.NEW.toString(), agentUser); + } + } else { + agentUser = agentUserRepository.findByIdAndOrgi(agentService.getAgentuserid(), super.getOrgi(request)); + if (agentUser != null) { + agentUser.setAgentno(agentno); + agentUserRepository.save(agentUser); + } + } + + if (agentService != null) { + agentService.setAgentno(agentno); + if (!StringUtils.isBlank(memo)) { + agentService.setTransmemo(memo); + } + agentService.setTrans(true); + agentService.setTranstime(new Date()); + agentServiceRes.save(agentService); + } + } + return request(super.createRequestPageTempletResponse("redirect:/service/current/index.html")); } - - @RequestMapping("/current/invite") - @Menu(type = "service" , subtype = "current" , admin= true) - public ModelAndView currentinvite(ModelMap map , HttpServletRequest request , @Valid String id) throws Exception { - if(!StringUtils.isBlank(id)){ - AgentService agentService = agentServiceRes.findByIdAndOrgi(id, super.getOrgi(request)) ; - if(agentService!=null){ - User user = super.getUser(request); - if(StringUtils.isBlank(agentService.getAgentno())) { - AiUser aiUser = (AiUser) CacheHelper.getOnlineUserCacheBean().getCacheObject(agentService.getSessionid(), agentService.getOrgi()) ; - IP ipdata = null ; - if(aiUser != null ) { - ipdata = aiUser.getIpdata() ; - OnlineUserUtils.newRequestMessage(aiUser.getUserid() , aiUser.getUsername(), user.getOrgi(), agentService.getSessionid(), agentService.getAppid() , agentService.getIpaddr(), agentService.getOsname() , agentService.getBrowser() , "" , ipdata!=null ? ipdata : null , agentService.getChannel() , user.getOrgan(), user.getId() , null ,null, agentService.getContactsid(), MainContext.ChatInitiatorType.AGENT.toString() , aiUser.getContextid()) ; - } - } - } - } + + @RequestMapping("/current/end") + @Menu(type = "service", subtype = "current", admin = true) + public ModelAndView end(ModelMap map, HttpServletRequest request, @Valid String id) throws Exception { + if (!StringUtils.isBlank(id)) { + AgentService agentService = agentServiceRes.findByIdAndOrgi(id, super.getOrgi(request)); + if (agentService != null) { + User user = super.getUser(request); + AgentUser agentUser = agentUserRepository.findByIdAndOrgi(agentService.getAgentuserid(), super.getOrgi(request)); + if (agentUser != null) { + AutomaticServiceDist.deleteAgentUser(agentUser, user.getOrgi()); + } + agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString()); + agentServiceRes.save(agentService); + } + } return request(super.createRequestPageTempletResponse("redirect:/service/current/index.html")); } - - - @RequestMapping("/quene/index") - @Menu(type = "service" , subtype = "filter" , admin= true) - public ModelAndView quene(ModelMap map , HttpServletRequest request) { - Page agentUserList = agentUserRes.findByOrgiAndStatus(super.getOrgi(request), MainContext.AgentUserStatusEnum.INQUENE.toString() ,new PageRequest(super.getP(request), super.getPs(request), Direction.DESC , "createtime")) ; - List skillList = new ArrayList(); - for(AgentUser agentUser : agentUserList.getContent()){ - agentUser.setWaittingtime((int) (System.currentTimeMillis() - agentUser.getCreatetime().getTime())); - if(!StringUtils.isBlank(agentUser.getSkill())){ - skillList.add(agentUser.getSkill()) ; - } - } - if(skillList.size() > 0){ - List organList = organRes.findAll(skillList) ; - for(AgentUser agentUser : agentUserList.getContent()){ - if(!StringUtils.isBlank(agentUser.getSkill())){ - for(Organ organ : organList){ - if(agentUser.getSkill().equals(organ.getId())){ - agentUser.setSkillname(organ.getName()); - break ; - } - } - } - } - } - map.put("agentUserList", agentUserList) ; + + @RequestMapping("/current/invite") + @Menu(type = "service", subtype = "current", admin = true) + public ModelAndView currentinvite(ModelMap map, HttpServletRequest request, @Valid String id) throws Exception { + if (!StringUtils.isBlank(id)) { + AgentService agentService = agentServiceRes.findByIdAndOrgi(id, super.getOrgi(request)); + if (agentService != null) { + User user = super.getUser(request); + if (StringUtils.isBlank(agentService.getAgentno())) { + AiUser aiUser = (AiUser) CacheHelper.getOnlineUserCacheBean().getCacheObject(agentService.getSessionid(), agentService.getOrgi()); + IP ipdata = null; + if (aiUser != null) { + ipdata = aiUser.getIpdata(); + OnlineUserUtils.newRequestMessage(aiUser.getUserid(), aiUser.getUsername(), user.getOrgi(), agentService.getSessionid(), agentService.getAppid(), agentService.getIpaddr(), agentService.getOsname(), agentService.getBrowser(), "", ipdata != null ? ipdata : null, agentService.getChannel(), user.getOrgan(), user.getId(), null, null, agentService.getContactsid(), MainContext.ChatInitiatorType.AGENT.toString(), aiUser.getContextid()); + } + } + } + } + return request(super.createRequestPageTempletResponse("redirect:/service/current/index.html")); + } + + + @RequestMapping("/quene/index") + @Menu(type = "service", subtype = "filter", admin = true) + public ModelAndView quene(ModelMap map, HttpServletRequest request) { + Page agentUserList = agentUserRes.findByOrgiAndStatus(super.getOrgi(request), MainContext.AgentUserStatusEnum.INQUENE.toString(), new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime")); + List skillList = new ArrayList(); + for (AgentUser agentUser : agentUserList.getContent()) { + agentUser.setWaittingtime((int) (System.currentTimeMillis() - agentUser.getCreatetime().getTime())); + if (!StringUtils.isBlank(agentUser.getSkill())) { + skillList.add(agentUser.getSkill()); + } + } + if (skillList.size() > 0) { + List organList = organRes.findAll(skillList); + for (AgentUser agentUser : agentUserList.getContent()) { + if (!StringUtils.isBlank(agentUser.getSkill())) { + for (Organ organ : organList) { + if (agentUser.getSkill().equals(organ.getId())) { + agentUser.setSkillname(organ.getName()); + break; + } + } + } + } + } + map.put("agentUserList", agentUserList); return request(super.createAppsTempletResponse("/apps/service/quene/index")); } - - @RequestMapping("/quene/clean") - @Menu(type = "service" , subtype = "queneclean" , admin= true) - public ModelAndView clean(ModelMap map , HttpServletRequest request ,@Valid String id) { - AgentUser agentUser = agentUserRes.findByIdAndOrgi(id, super.getOrgi(request)) ; - if(agentUser!=null && agentUser.getStatus().equals(MainContext.AgentUserStatusEnum.INQUENE.toString())){ - agentUser.setAgent(null); - agentUser.setSkill(null); - agentUserRes.save(agentUser) ; - CacheHelper.getAgentUserCacheBean().put(agentUser.getUserid(), agentUser, super.getOrgi(request)); - AutomaticServiceDist.allotAgent(agentUser, super.getOrgi(request)) ; - } + + @RequestMapping("/quene/clean") + @Menu(type = "service", subtype = "queneclean", admin = true) + public ModelAndView clean(ModelMap map, HttpServletRequest request, @Valid String id) { + AgentUser agentUser = agentUserRes.findByIdAndOrgi(id, super.getOrgi(request)); + if (agentUser != null && agentUser.getStatus().equals(MainContext.AgentUserStatusEnum.INQUENE.toString())) { + agentUser.setAgent(null); + agentUser.setSkill(null); + agentUserRes.save(agentUser); + CacheHelper.getAgentUserCacheBean().put(agentUser.getUserid(), agentUser, super.getOrgi(request)); + AutomaticServiceDist.allotAgent(agentUser, super.getOrgi(request)); + } return request(super.createRequestPageTempletResponse("redirect:/service/quene/index.html")); } - - @RequestMapping("/quene/invite") - @Menu(type = "service" , subtype = "invite" , admin= true) - public ModelAndView invite(ModelMap map , HttpServletRequest request ,@Valid String id) throws Exception { - AgentUser agentUser = agentUserRes.findByIdAndOrgi(id, super.getOrgi(request)) ; - if(agentUser!=null && agentUser.getStatus().equals(MainContext.AgentUserStatusEnum.INQUENE.toString())){ - AutomaticServiceDist.allotAgentForInvite(super.getUser(request).getId() , agentUser, super.getOrgi(request)) ; - } + + @RequestMapping("/quene/invite") + @Menu(type = "service", subtype = "invite", admin = true) + public ModelAndView invite(ModelMap map, HttpServletRequest request, @Valid String id) throws Exception { + AgentUser agentUser = agentUserRes.findByIdAndOrgi(id, super.getOrgi(request)); + if (agentUser != null && agentUser.getStatus().equals(MainContext.AgentUserStatusEnum.INQUENE.toString())) { + AutomaticServiceDist.allotAgentForInvite(super.getUser(request).getId(), agentUser, super.getOrgi(request)); + } return request(super.createRequestPageTempletResponse("redirect:/service/quene/index.html")); } - - @RequestMapping("/agent/index") - @Menu(type = "service" , subtype = "onlineagent" , admin= true) - public ModelAndView agent(ModelMap map , HttpServletRequest request) { - List agentStatusList = agentStatusRepository.findByOrgi(super.getOrgi(request)) ; - for(int i=0 ; i skillList = new ArrayList(); - for(AgentStatus agentStatus : agentStatusList){ - if(!StringUtils.isBlank(agentStatus.getSkill())){ - skillList.add(agentStatus.getSkill()) ; - } - } - if(skillList.size() > 0){ - List organList = organRes.findAll(skillList) ; - for(AgentStatus agentStatus : agentStatusList){ - if(!StringUtils.isBlank(agentStatus.getSkill())){ - for(Organ organ : organList){ - if(agentStatus.getSkill().equals(organ.getId())){ - agentStatus.setSkillname(organ.getName()); - break ; - } - } - } - } - } - map.put("agentStatusList", agentStatusList) ; + + @RequestMapping("/agent/index") + @Menu(type = "service", subtype = "onlineagent", admin = true) + public ModelAndView agent(ModelMap map, HttpServletRequest request) { + List agentStatusList = agentStatusRepository.findByOrgi(super.getOrgi(request)); + for (int i = 0; i < agentStatusList.size(); ) { + AgentStatus agentStatus = agentStatusList.get(i); + if (CacheHelper.getAgentStatusCacheBean().getCacheObject(agentStatus.getAgentno(), super.getOrgi(request)) == null) { + agentStatusRepository.delete(agentStatus); + agentStatusList.remove(i); + continue; + } else { + AgentStatus temp = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(agentStatus.getAgentno(), super.getOrgi(request)); + agentStatusList.set(i, temp); + } + i++; + } + List skillList = new ArrayList(); + for (AgentStatus agentStatus : agentStatusList) { + if (!StringUtils.isBlank(agentStatus.getSkill())) { + skillList.add(agentStatus.getSkill()); + } + } + if (skillList.size() > 0) { + List organList = organRes.findAll(skillList); + for (AgentStatus agentStatus : agentStatusList) { + if (!StringUtils.isBlank(agentStatus.getSkill())) { + for (Organ organ : organList) { + if (agentStatus.getSkill().equals(organ.getId())) { + agentStatus.setSkillname(organ.getName()); + break; + } + } + } + } + } + map.put("agentStatusList", agentStatusList); return request(super.createAppsTempletResponse("/apps/service/agent/index")); } - - @RequestMapping("/agent/offline") - @Menu(type = "service" , subtype = "offline" , admin= true) - public ModelAndView offline(ModelMap map , HttpServletRequest request , @Valid String id) { - - AgentStatus agentStatus = agentStatusRepository.findByIdAndOrgi(id, super.getOrgi(request)); - if(agentStatus!=null){ - agentStatusRepository.delete(agentStatus); - } - CacheHelper.getAgentStatusCacheBean().delete(agentStatus.getAgentno(), super.getOrgi(request));; - AutomaticServiceDist.publishMessage(super.getOrgi(request) , "agent" , "offline" , super.getUser(request).getId()); - - + + @RequestMapping("/agent/offline") + @Menu(type = "service", subtype = "offline", admin = true) + public ModelAndView offline(ModelMap map, HttpServletRequest request, @Valid String id) { + + AgentStatus agentStatus = agentStatusRepository.findByIdAndOrgi(id, super.getOrgi(request)); + if (agentStatus != null) { + agentStatusRepository.delete(agentStatus); + } + CacheHelper.getAgentStatusCacheBean().delete(agentStatus.getAgentno(), super.getOrgi(request)); + ; + AutomaticServiceDist.publishMessage(super.getOrgi(request), "agent", "offline", super.getUser(request).getId()); + + return request(super.createRequestPageTempletResponse("redirect:/service/agent/index.html")); } - /** - * 非管理员坐席 - * @param map - * @param request - * @return - */ - @RequestMapping("/user/index") - @Menu(type = "service" , subtype = "userlist" , admin= true) - public ModelAndView user(ModelMap map , HttpServletRequest request) { - Page userList = null; - if(super.isTenantshare()) { - List organIdList = new ArrayList<>(); - List orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request)) ; - if(!orgiSkillRelList.isEmpty()) { - for(OrgiSkillRel rel:orgiSkillRelList) { - organIdList.add(rel.getSkillid()); - } - } - userList=userRes.findByOrganInAndAgentAndDatastatus(organIdList,true,false,new PageRequest(super.getP(request), super.getPs(request), Direction.DESC , "createtime")); - }else { - userList=userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true,false, new PageRequest(super.getP(request), super.getPs(request), Direction.DESC , "createtime")) ; - } - for(User user : userList.getContent()){ - if(CacheHelper.getAgentStatusCacheBean().getCacheObject(user.getId(), super.getOrgi(request))!=null){ - user.setOnline(true); - } - } - map.put("userList", userList) ; + + /** + * 非管理员坐席 + * + * @param map + * @param request + * @return + */ + @RequestMapping("/user/index") + @Menu(type = "service", subtype = "userlist", admin = true) + public ModelAndView user(ModelMap map, HttpServletRequest request) { + Page userList = null; + if (super.isTenantshare()) { + List organIdList = new ArrayList<>(); + List orgiSkillRelList = orgiSkillRelService.findByOrgi(super.getOrgi(request)); + if (!orgiSkillRelList.isEmpty()) { + for (OrgiSkillRel rel : orgiSkillRelList) { + organIdList.add(rel.getSkillid()); + } + } + userList = userRes.findByOrganInAndAgentAndDatastatus(organIdList, true, false, new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime")); + } else { + userList = userRes.findByOrgiAndAgentAndDatastatus(super.getOrgi(request), true, false, new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime")); + } + for (User user : userList.getContent()) { + if (CacheHelper.getAgentStatusCacheBean().getCacheObject(user.getId(), super.getOrgi(request)) != null) { + user.setOnline(true); + } + } + map.put("userList", userList); return request(super.createAppsTempletResponse("/apps/service/user/index")); } - /** - * 管理员坐席 - * @param map - * @param request - * @return - */ - @RequestMapping("/adminagent/index") - @Menu(type = "service" , subtype = "adminagentlist" , admin= true) - public ModelAndView adminagent(ModelMap map , HttpServletRequest request) { - Page userList = userRes.findByOrgidAndAgentAndDatastatusAndUsertype(super.getOrgid(request), true,false,"0", new PageRequest(super.getP(request), super.getPs(request), Direction.DESC , "createtime")) ; - for(User user : userList.getContent()){ - if(CacheHelper.getAgentStatusCacheBean().getCacheObject(user.getId(), super.getOrgi(request))!=null){ - user.setOnline(true); - } - } - map.put("userList", userList) ; + + /** + * 管理员坐席 + * + * @param map + * @param request + * @return + */ + @RequestMapping("/adminagent/index") + @Menu(type = "service", subtype = "adminagentlist", admin = true) + public ModelAndView adminagent(ModelMap map, HttpServletRequest request) { + Page userList = userRes.findByOrgidAndAgentAndDatastatusAndUsertype(super.getOrgid(request), true, false, "0", new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime")); + for (User user : userList.getContent()) { + if (CacheHelper.getAgentStatusCacheBean().getCacheObject(user.getId(), super.getOrgi(request)) != null) { + user.setOnline(true); + } + } + map.put("userList", userList); return request(super.createAppsTempletResponse("/apps/service/adminagent/index")); } - @RequestMapping("/leavemsg/index") - @Menu(type = "service" , subtype = "leavemsg" , admin= true) - public ModelAndView leavemsg(ModelMap map , HttpServletRequest request) { - Page leaveMsgList = leaveMsgRes.findByOrgi(super.getOrgi(request),new PageRequest(super.getP(request), super.getPs(request), Direction.DESC , "createtime")) ; - map.put("leaveMsgList", leaveMsgList) ; + + @RequestMapping("/leavemsg/index") + @Menu(type = "service", subtype = "leavemsg", admin = true) + public ModelAndView leavemsg(ModelMap map, HttpServletRequest request) { + Page leaveMsgList = leaveMsgRes.findByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request), Direction.DESC, "createtime")); + map.put("leaveMsgList", leaveMsgList); return request(super.createAppsTempletResponse("/apps/service/leavemsg/index")); } - - @RequestMapping("/leavemsg/delete") - @Menu(type = "service" , subtype = "leavemsg" , admin= true) - public ModelAndView leavemsg(ModelMap map , HttpServletRequest request , @Valid String id) { - if(!StringUtils.isBlank(id)){ - leaveMsgRes.delete(id); - } - return request(super.createRequestPageTempletResponse("redirect:/service/leavemsg/index.html")); + + @RequestMapping("/leavemsg/delete") + @Menu(type = "service", subtype = "leavemsg", admin = true) + public ModelAndView leavemsg(ModelMap map, HttpServletRequest request, @Valid String id) { + if (!StringUtils.isBlank(id)) { + leaveMsgRes.delete(id); + } + return request(super.createRequestPageTempletResponse("redirect:/service/leavemsg/index.html")); } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/client/NettyClients.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/client/NettyClients.java index b45af141..ca9a78e2 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/client/NettyClients.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/client/NettyClients.java @@ -16,110 +16,190 @@ */ package com.chatopera.cc.app.im.client; -import java.util.List; - -import com.corundumstudio.socketio.SocketIOClient; +import com.chatopera.cc.app.basic.MainContext; import com.chatopera.cc.app.basic.MainUtils; +import com.chatopera.cc.app.im.util.IMServiceUtils; +import com.chatopera.cc.app.schedule.WebIMAgentDispatcher; +import com.chatopera.cc.app.schedule.WebIMOnlineUserDispatcher; +import com.corundumstudio.socketio.SocketIOClient; +import com.google.gson.JsonObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.io.Serializable; +import java.util.List; + public class NettyClients { private final Logger logger = LoggerFactory.getLogger(NettyClient.class); - private static NettyClients clients = new NettyClients(); - - private NettyIMClient imClients = new NettyIMClient(); - private NettyAgentClient agentClients = new NettyAgentClient(); - private NettyIMClient entIMClients = new NettyIMClient(); - private NettyCallCenterClient callCenterClients = new NettyCallCenterClient(); - private NettyCalloutClient calloutClients = new NettyCalloutClient(); - private NettyChatbotClient chatbotClients = new NettyChatbotClient(); - - public int size(){ - return imClients.size(); - } - - public static NettyClients getInstance(){ - return clients ; - } - - public NettyCallCenterClient getCallCenterClients(){ - return this.callCenterClients ; - } + private static NettyClients clients = new NettyClients(); - public void setImClients(NettyIMClient imClients) { - this.imClients = imClients; - } - public void putIMEventClient(String id , SocketIOClient userClient){ - imClients.putClient(id, userClient); - } - - public void closeIMEventClient(String id , String sessionid, String orgi){ - List userClients = imClients.getClients(id) ; - for(SocketIOClient userClient : userClients){ - if(MainUtils.getContextID(userClient.getSessionId().toString()).equals(sessionid)){ - userClient.disconnect(); - } - } - } - public void removeIMEventClient(String id , String sessionid){ - imClients.removeClient(id, sessionid); - } - public void sendIMEventMessage(String id , String event , Object data){ - List userClients = imClients.getClients(id) ; - for(SocketIOClient userClient : userClients){ - userClient.sendEvent(event, data); - } - } - - public void setAgentClients(NettyAgentClient agentClients) { - this.agentClients = agentClients; - } - public void putAgentEventClient(String id , SocketIOClient agentClient){ - agentClients.putClient(id, agentClient); - } - public void removeAgentEventClient(String id , String sessionid){ - agentClients.removeClient(id, sessionid); - } - public void sendAgentEventMessage(String id , String event , Object data){ - List agents = agentClients.getClients(id) ; - for(SocketIOClient agentClient : agents){ - agentClient.sendEvent(event, data); - } - } - - public void setEntImClients(NettyIMClient entIMClients) { - this.entIMClients = entIMClients; - } - public void putEntIMEventClient(String id , SocketIOClient userClient){ - entIMClients.putClient(id, userClient); - } - public void removeEntIMEventClient(String id , String sessionid){ - entIMClients.removeClient(id, sessionid); - } - public void sendEntIMEventMessage(String id , String event , Object data){ - List entims = entIMClients.getClients(id) ; - for(SocketIOClient userClient : entims){ - userClient.sendEvent(event, data); - } - } - public int getEntIMClientsNum(String user){ - return entIMClients.getClients(user)!=null ? entIMClients.getClients(user).size() : 0; - } - - public void sendCallCenterMessage(String id , String event , Object data){ - List ccClients = callCenterClients.getClients(id) ; - for(SocketIOClient ccClient : ccClients){ - ccClient.sendEvent(event, data); - } - } + private NettyIMClient imClients = new NettyIMClient(); + private NettyAgentClient agentClients = new NettyAgentClient(); + private NettyIMClient entIMClients = new NettyIMClient(); + private NettyCallCenterClient callCenterClients = new NettyCallCenterClient(); + private NettyCalloutClient calloutClients = new NettyCalloutClient(); + private NettyChatbotClient chatbotClients = new NettyChatbotClient(); + + public int size() { + return imClients.size(); + } + + public static NettyClients getInstance() { + return clients; + } + + public NettyCallCenterClient getCallCenterClients() { + return this.callCenterClients; + } + + /** + * 访客连接 + */ + public void setImClients(NettyIMClient imClients) { + this.imClients = imClients; + } + + public void putIMEventClient(String id, SocketIOClient userClient) { + imClients.putClient(id, userClient); + } + + public void closeIMEventClient(String id, String sessionid, String orgi) { + List userClients = imClients.getClients(id); + for (SocketIOClient userClient : userClients) { + if (MainUtils.getContextID(userClient.getSessionId().toString()).equals(sessionid)) { + userClient.disconnect(); + } + } + } + + public void removeIMEventClient(String id, String sessionid) { + imClients.removeClient(id, sessionid); + } + + public void publishIMEventMessage(final String id, final String event, Serializable data) { + // 检测client是否在这台机器上 + if (!sendIMEventMessage(id, event, data)) { + try { + JsonObject payload = new JsonObject(); + payload.addProperty("event", event); + payload.addProperty("id", id); + payload.addProperty("data", IMServiceUtils.serialize(data)); + MainContext.getContext().getBean(WebIMOnlineUserDispatcher.class).publish(payload); + } catch (IOException e) { + logger.error("publishIMEventMessage", e); + } + } + } + + public boolean sendIMEventMessage(final String id, final String event, Object data) { + List userClients = imClients.getClients(id); + for (SocketIOClient userClient : userClients) { + userClient.sendEvent(event, data); + } + return userClients.size() > 0; + } + + /** + * 坐席连接 + */ + public void setAgentClients(NettyAgentClient agentClients) { + this.agentClients = agentClients; + } + + public void putAgentEventClient(String id, SocketIOClient agentClient) { + agentClients.putClient(id, agentClient); + } + + public void removeAgentEventClient(String id, String sessionid) { + agentClients.removeClient(id, sessionid); + } + + // publish to Redis + public void publishAgentEventMessage(String id, String event, Serializable data) { + // 检测client是否在这台机器上 + if (!sendAgentEventMessage(id, event, data)) { + try { + JsonObject payload = new JsonObject(); + payload.addProperty("event", event); + payload.addProperty("id", id); + payload.addProperty("data", IMServiceUtils.serialize(data)); + MainContext.getContext().getBean(WebIMAgentDispatcher.class).publish(payload); + } catch (IOException e) { + logger.error("publishAgentEventMessage", e); + } + } + } + + // 向坐席发送消息 + public boolean sendAgentEventMessage(String id, String event, Object data) { + List agents = agentClients.getClients(id); + for (SocketIOClient agentClient : agents) { + agentClient.sendEvent(event, data); + } + + return agents.size() > 0; + } + + /** + * 企业聊天 + */ + public void setEntImClients(NettyIMClient entIMClients) { + this.entIMClients = entIMClients; + } + + public void putEntIMEventClient(String id, SocketIOClient userClient) { + entIMClients.putClient(id, userClient); + } + + public void removeEntIMEventClient(String id, String sessionid) { + entIMClients.removeClient(id, sessionid); + } + + public void sendEntIMEventMessage(String id, String event, Object data) { + List entims = entIMClients.getClients(id); + for (SocketIOClient userClient : entims) { + userClient.sendEvent(event, data); + } + } + + public int getEntIMClientsNum(String user) { + return entIMClients.getClients(user) != null ? entIMClients.getClients(user).size() : 0; + } + + public void sendCallCenterMessage(String id, String event, Object data) { + List ccClients = callCenterClients.getClients(id); + for (SocketIOClient ccClient : ccClients) { + ccClient.sendEvent(event, data); + } + } + + /** + * Callout Event Server Methods. + */ + public void putCalloutEventClient(String id, SocketIOClient client) { + calloutClients.putClient(id, client); + } + + public void removeCalloutEventClient(String id, String sessionId) { + calloutClients.removeClient(id, sessionId); + } + + public void sendCalloutEventMessage(String id, String event, Object data) { + List _clients = calloutClients.getClients(id); + logger.info("sendCalloutEventMessage get clients size {}", _clients.size()); + for (SocketIOClient c : _clients) { + c.sendEvent(event, data); + } + } /** * Chatbot Event Server Methods. */ - public void putChatbotEventClient(String id, SocketIOClient client){ + public void putChatbotEventClient(String id, SocketIOClient client) { chatbotClients.putClient(id, client); } @@ -127,29 +207,10 @@ public class NettyClients { chatbotClients.removeClient(id, sessionId); } - public void sendChatbotEventMessage(String id, String event, Object data){ + public void sendChatbotEventMessage(String id, String event, Object data) { List _clients = chatbotClients.getClients(id); logger.info("sendChatbotEventMessage get clients size {}", _clients.size()); - for(SocketIOClient c: _clients){ - c.sendEvent(event, data); - } - } - - /** - * Callout Event Server Methods. - */ - public void putCalloutEventClient(String id, SocketIOClient client){ - calloutClients.putClient(id, client); - } - - public void removeCalloutEventClient(String id, String sessionId) { - calloutClients.removeClient(id, sessionId); - } - - public void sendCalloutEventMessage(String id, String event, Object data){ - List _clients = calloutClients.getClients(id); - logger.info("sendCalloutEventMessage get clients size {}", _clients.size()); - for(SocketIOClient c: _clients){ + for (SocketIOClient c : _clients) { c.sendEvent(event, data); } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/AgentEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/AgentEventHandler.java index f18ed5c5..903f65c3 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/AgentEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/AgentEventHandler.java @@ -16,228 +16,212 @@ */ package com.chatopera.cc.app.im.handler; -import java.net.InetSocketAddress; -import java.util.Date; -import java.util.List; - import com.chatopera.cc.app.algorithm.AutomaticServiceDist; 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.cache.CacheHelper; -import com.chatopera.cc.app.im.router.OutMessageRouter; +import com.chatopera.cc.app.im.client.NettyClients; import com.chatopera.cc.app.im.message.AgentServiceMessage; import com.chatopera.cc.app.im.message.AgentStatusMessage; import com.chatopera.cc.app.im.message.ChatMessage; -import org.apache.commons.lang.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; - +import com.chatopera.cc.app.im.router.OutMessageRouter; +import com.chatopera.cc.app.model.*; +import com.chatopera.cc.app.persistence.repository.*; import com.corundumstudio.socketio.AckRequest; import com.corundumstudio.socketio.SocketIOClient; import com.corundumstudio.socketio.SocketIOServer; import com.corundumstudio.socketio.annotation.OnConnect; import com.corundumstudio.socketio.annotation.OnDisconnect; import com.corundumstudio.socketio.annotation.OnEvent; -import com.chatopera.cc.app.persistence.repository.AgentStatusRepository; -import com.chatopera.cc.app.persistence.repository.AgentUserRepository; -import com.chatopera.cc.app.persistence.repository.AgentUserTaskRepository; -import com.chatopera.cc.app.persistence.repository.ChatMessageRepository; -import com.chatopera.cc.app.persistence.repository.WorkSessionRepository; -import com.chatopera.cc.app.model.AgentStatus; -import com.chatopera.cc.app.model.AgentUser; -import com.chatopera.cc.app.model.AgentUserTask; -import com.chatopera.cc.app.model.MessageOutContent; -import com.chatopera.cc.app.model.WorkSession; - -public class AgentEventHandler -{ - protected SocketIOServer server; - - @Autowired - public AgentEventHandler(SocketIOServer server) - { - this.server = server ; - } - - @OnConnect - public void onConnect(SocketIOClient client) - { - String user = client.getHandshakeData().getSingleUrlParam("userid") ; - String orgi = client.getHandshakeData().getSingleUrlParam("orgi") ; - String session = client.getHandshakeData().getSingleUrlParam("session") ; - String admin = client.getHandshakeData().getSingleUrlParam("admin") ; - if(!StringUtils.isBlank(user) && !StringUtils.isBlank(user)){ - client.set("agentno", user); - AgentStatusRepository agentStatusRepository = MainContext.getContext().getBean(AgentStatusRepository.class) ; - List agentStatusList = agentStatusRepository.findByAgentnoAndOrgi(user , orgi); - if(agentStatusList.size() > 0){ - AgentStatus agentStatus = agentStatusList.get(0) ; - agentStatus.setUpdatetime(new Date()); - agentStatusRepository.save(agentStatus); - if(CacheHelper.getAgentStatusCacheBean().getCacheObject(user, orgi)!=null) { - CacheHelper.getAgentStatusCacheBean().put(user, agentStatus , orgi); - } - } - InetSocketAddress address = (InetSocketAddress) client.getRemoteAddress() ; - String ip = MainUtils.getIpAddr(client.getHandshakeData().getHttpHeaders(), address.getHostString()) ; - - - WorkSessionRepository workSessionRepository = MainContext.getContext().getBean(WorkSessionRepository.class) ; - int count = workSessionRepository.countByAgentAndDatestrAndOrgi(user, MainUtils.simpleDateFormat.format(new Date()), orgi) ; - - workSessionRepository.save(MainUtils.createWorkSession(user, MainUtils.getContextID(client.getSessionId().toString()), session, orgi, ip, address.getHostName() , admin , count == 0)) ; - - NettyClients.getInstance().putAgentEventClient(user, client); - } - } - - //添加@OnDisconnect事件,客户端断开连接时调用,刷新客户端信息 - @OnDisconnect - public void onDisconnect(SocketIOClient client) - { - String user = client.getHandshakeData().getSingleUrlParam("userid") ; - String orgi = client.getHandshakeData().getSingleUrlParam("orgi") ; - String admin = client.getHandshakeData().getSingleUrlParam("admin") ; - if(!StringUtils.isBlank(user)){ - AutomaticServiceDist.deleteAgentStatus(user, orgi, !StringUtils.isBlank(admin) && admin.equals("true")); - NettyClients.getInstance().removeAgentEventClient(user , MainUtils.getContextID(client.getSessionId().toString())); - - WorkSessionRepository workSessionRepository = MainContext.getContext().getBean(WorkSessionRepository.class) ; - List workSessionList = workSessionRepository.findByOrgiAndClientid(orgi, MainUtils.getContextID(client.getSessionId().toString())) ; - if(workSessionList.size() > 0) { - WorkSession workSession = workSessionList.get(0) ; - workSession.setEndtime(new Date()); - if(workSession.getBegintime()!=null) { - workSession.setDuration((int) (System.currentTimeMillis() - workSession.getBegintime().getTime())); - }else if(workSession.getCreatetime()!=null) { - workSession.setDuration((int) (System.currentTimeMillis() - workSession.getCreatetime().getTime())); - } - if(workSession.isFirsttime()) { - workSession.setFirsttimes(workSession.getDuration()); - } - workSessionRepository.save(workSession) ; - } - } - } - - //消息接收入口,当接收到消息后,查找发送目标客户端,并且向该客户端发送消息,且给自己发送消息 - @OnEvent(value = "service") - public void onEvent(SocketIOClient client, AckRequest request, AgentServiceMessage data) - { - - } - - //消息接收入口,当接收到消息后,查找发送目标客户端,并且向该客户端发送消息,且给自己发送消息 - @OnEvent(value = "status") - public void onEvent(SocketIOClient client, AckRequest request, AgentStatusMessage data) - { - +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; + +import java.net.InetSocketAddress; +import java.util.Date; +import java.util.List; + +public class AgentEventHandler { + protected SocketIOServer server; + + @Autowired + public AgentEventHandler(SocketIOServer server) { + this.server = server; } - - //消息接收入口,当接收到消息后,查找发送目标客户端,并且向该客户端发送消息,且给自己发送消息 - @OnEvent(value = "message") - public void onEvent(SocketIOClient client, AckRequest request, ChatMessage data) - { - String user = client.getHandshakeData().getSingleUrlParam("userid") ; - AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(data.getTouser(), data.getOrgi()); - MessageOutContent outMessage = new MessageOutContent() ; - outMessage.setMessage(data.getMessage()); - if(MainContext.MediaTypeEnum.COOPERATION.toString().equals(data.getMsgtype())){ - outMessage.setMessageType(MainContext.MediaTypeEnum.COOPERATION.toString()); - }else{ - outMessage.setMessageType(MainContext.MediaTypeEnum.TEXT.toString()); - } - - outMessage.setAttachmentid(data.getAttachmentid()); - - outMessage.setCalltype(MainContext.CallTypeEnum.OUT.toString()); - outMessage.setAgentUser(agentUser); - outMessage.setSnsAccount(null); - AgentStatus agentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(data.getUserid(), data.getOrgi()) ; - - if(agentUser == null){ - agentUser = MainContext.getContext().getBean(AgentUserRepository.class).findByIdAndOrgi(data.getTouser() , data.getOrgi()) ; - try { - AutomaticServiceDist.serviceFinish(agentUser, data.getOrgi()); - } catch (Exception e) { - e.printStackTrace(); - } - } - - if(agentUser!=null && user!=null && user.equals(agentUser.getAgentno())){ - data.setId(MainUtils.getUUID()); - data.setContextid(agentUser.getContextid()); - - data.setAgentserviceid(agentUser.getAgentserviceid()); - data.setCreater(agentUser.getAgentno()); - - if(MainContext.MediaTypeEnum.COOPERATION.toString().equals(data.getMsgtype())){ - data.setMsgtype(MainContext.MediaTypeEnum.COOPERATION.toString()); - }else{ - data.setMsgtype(MainContext.MediaTypeEnum.TEXT.toString()); - } - - data.setCalltype(MainContext.CallTypeEnum.OUT.toString()); - if(!StringUtils.isBlank(agentUser.getAgentno())){ - data.setTouser(agentUser.getUserid()); - } - data.setChannel(agentUser.getChannel()); - - data.setUsession(agentUser.getUserid()); - - outMessage.setContextid(agentUser.getContextid()); - outMessage.setFromUser(data.getUserid()); - outMessage.setToUser(data.getTouser()); - outMessage.setChannelMessage(data); - if(agentStatus!=null){ - data.setUsername(agentStatus.getUsername()); - outMessage.setNickName(agentStatus.getUsername()); - }else{ - outMessage.setNickName(data.getUsername()); - } - outMessage.setCreatetime(data.getCreatetime()); - - AgentUserTaskRepository agentUserTaskRes = MainContext.getContext().getBean(AgentUserTaskRepository.class) ; - AgentUserTask agentUserTask = agentUserTaskRes.getOne(agentUser.getId()) ; - - if(agentUserTask!=null){ - if(agentUserTask.getLastgetmessage() != null && agentUserTask.getLastmessage()!=null){ - data.setLastagentmsgtime(agentUserTask.getLastgetmessage()); - data.setLastmsgtime(agentUserTask.getLastmessage()); - data.setAgentreplyinterval((int)((System.currentTimeMillis() - agentUserTask.getLastgetmessage().getTime())/1000)); //坐席上次回复消息的间隔 - data.setAgentreplytime((int)((System.currentTimeMillis() - agentUserTask.getLastmessage().getTime())/1000)); //坐席回复消息花费时间 - } - - agentUserTask.setAgentreplys(agentUserTask.getAgentreplys()+1); //总咨询记录数量 - agentUserTask.setAgentreplyinterval(agentUserTask.getAgentreplyinterval() + data.getAgentreplyinterval()); //总时长 - if(agentUserTask.getAgentreplys()>0){ - agentUserTask.setAvgreplyinterval(agentUserTask.getAgentreplyinterval() / agentUserTask.getAgentreplys()); - } - - agentUserTask.setLastgetmessage(new Date()); - + + @OnConnect + public void onConnect(SocketIOClient client) { + String user = client.getHandshakeData().getSingleUrlParam("userid"); + String orgi = client.getHandshakeData().getSingleUrlParam("orgi"); + String session = client.getHandshakeData().getSingleUrlParam("session"); + String admin = client.getHandshakeData().getSingleUrlParam("admin"); + if (StringUtils.isNotBlank(user) && StringUtils.isNotBlank(user)) { + client.set("agentno", user); + AgentStatusRepository agentStatusRepository = MainContext.getContext().getBean(AgentStatusRepository.class); + List agentStatusList = agentStatusRepository.findByAgentnoAndOrgi(user, orgi); + if (agentStatusList.size() > 0) { + AgentStatus agentStatus = agentStatusList.get(0); + agentStatus.setUpdatetime(new Date()); + agentStatusRepository.save(agentStatus); + if (CacheHelper.getAgentStatusCacheBean().getCacheObject(user, orgi) != null) { + CacheHelper.getAgentStatusCacheBean().put(user, agentStatus, orgi); + } + } + InetSocketAddress address = (InetSocketAddress) client.getRemoteAddress(); + String ip = MainUtils.getIpAddr(client.getHandshakeData().getHttpHeaders(), address.getHostString()); + + + WorkSessionRepository workSessionRepository = MainContext.getContext().getBean(WorkSessionRepository.class); + int count = workSessionRepository.countByAgentAndDatestrAndOrgi(user, MainUtils.simpleDateFormat.format(new Date()), orgi); + + workSessionRepository.save(MainUtils.createWorkSession(user, MainUtils.getContextID(client.getSessionId().toString()), session, orgi, ip, address.getHostName(), admin, count == 0)); + + NettyClients.getInstance().putAgentEventClient(user, client); + } + } + + //添加@OnDisconnect事件,客户端断开连接时调用,刷新客户端信息 + @OnDisconnect + public void onDisconnect(SocketIOClient client) { + String user = client.getHandshakeData().getSingleUrlParam("userid"); + String orgi = client.getHandshakeData().getSingleUrlParam("orgi"); + String admin = client.getHandshakeData().getSingleUrlParam("admin"); + if (StringUtils.isNotBlank(user)) { + AutomaticServiceDist.deleteAgentStatus(user, orgi, StringUtils.isNotBlank(admin) && admin.equals("true")); + NettyClients.getInstance().removeAgentEventClient(user, MainUtils.getContextID(client.getSessionId().toString())); + + WorkSessionRepository workSessionRepository = MainContext.getContext().getBean(WorkSessionRepository.class); + List workSessionList = workSessionRepository.findByOrgiAndClientid(orgi, MainUtils.getContextID(client.getSessionId().toString())); + if (workSessionList.size() > 0) { + WorkSession workSession = workSessionList.get(0); + workSession.setEndtime(new Date()); + if (workSession.getBegintime() != null) { + workSession.setDuration((int) (System.currentTimeMillis() - workSession.getBegintime().getTime())); + } else if (workSession.getCreatetime() != null) { + workSession.setDuration((int) (System.currentTimeMillis() - workSession.getCreatetime().getTime())); + } + if (workSession.isFirsttime()) { + workSession.setFirsttimes(workSession.getDuration()); + } + workSessionRepository.save(workSession); + } + } + } + + //消息接收入口,当接收到消息后,查找发送目标客户端,并且向该客户端发送消息,且给自己发送消息 + @OnEvent(value = "service") + public void onEvent(SocketIOClient client, AckRequest request, AgentServiceMessage data) { + + } + + //消息接收入口,当接收到消息后,查找发送目标客户端,并且向该客户端发送消息,且给自己发送消息 + @OnEvent(value = "status") + public void onEvent(SocketIOClient client, AckRequest request, AgentStatusMessage data) { + + } + + //消息接收入口,当接收到消息后,查找发送目标客户端,并且向该客户端发送消息,且给自己发送消息 + @OnEvent(value = "message") + public void onEvent(SocketIOClient client, AckRequest request, ChatMessage data) { + String user = client.getHandshakeData().getSingleUrlParam("userid"); + AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(data.getTouser(), data.getOrgi()); + MessageOutContent outMessage = new MessageOutContent(); + outMessage.setMessage(data.getMessage()); + if (MainContext.MediaTypeEnum.COOPERATION.toString().equals(data.getMsgtype())) { + outMessage.setMessageType(MainContext.MediaTypeEnum.COOPERATION.toString()); + } else { + outMessage.setMessageType(MainContext.MediaTypeEnum.TEXT.toString()); + } + + outMessage.setAttachmentid(data.getAttachmentid()); + + outMessage.setCalltype(MainContext.CallTypeEnum.OUT.toString()); + outMessage.setAgentUser(agentUser); + outMessage.setSnsAccount(null); + AgentStatus agentStatus = (AgentStatus) CacheHelper.getAgentStatusCacheBean().getCacheObject(data.getUserid(), data.getOrgi()); + + if (agentUser == null) { + agentUser = MainContext.getContext().getBean(AgentUserRepository.class).findByIdAndOrgi(data.getTouser(), data.getOrgi()); + try { + AutomaticServiceDist.serviceFinish(agentUser, data.getOrgi()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + if (agentUser != null && user != null && user.equals(agentUser.getAgentno())) { + data.setId(MainUtils.getUUID()); + data.setContextid(agentUser.getContextid()); + + data.setAgentserviceid(agentUser.getAgentserviceid()); + data.setCreater(agentUser.getAgentno()); + + if (MainContext.MediaTypeEnum.COOPERATION.toString().equals(data.getMsgtype())) { + data.setMsgtype(MainContext.MediaTypeEnum.COOPERATION.toString()); + } else { + data.setMsgtype(MainContext.MediaTypeEnum.TEXT.toString()); + } + + data.setCalltype(MainContext.CallTypeEnum.OUT.toString()); + if (StringUtils.isNotBlank(agentUser.getAgentno())) { + data.setTouser(agentUser.getUserid()); + } + data.setChannel(agentUser.getChannel()); + + data.setUsession(agentUser.getUserid()); + + outMessage.setContextid(agentUser.getContextid()); + outMessage.setFromUser(data.getUserid()); + outMessage.setToUser(data.getTouser()); + outMessage.setChannelMessage(data); + if (agentStatus != null) { + data.setUsername(agentStatus.getUsername()); + outMessage.setNickName(agentStatus.getUsername()); + } else { + outMessage.setNickName(data.getUsername()); + } + outMessage.setCreatetime(data.getCreatetime()); + + AgentUserTaskRepository agentUserTaskRes = MainContext.getContext().getBean(AgentUserTaskRepository.class); + AgentUserTask agentUserTask = agentUserTaskRes.getOne(agentUser.getId()); + + if (agentUserTask != null) { + if (agentUserTask.getLastgetmessage() != null && agentUserTask.getLastmessage() != null) { + data.setLastagentmsgtime(agentUserTask.getLastgetmessage()); + data.setLastmsgtime(agentUserTask.getLastmessage()); + data.setAgentreplyinterval((int) ((System.currentTimeMillis() - agentUserTask.getLastgetmessage().getTime()) / 1000)); //坐席上次回复消息的间隔 + data.setAgentreplytime((int) ((System.currentTimeMillis() - agentUserTask.getLastmessage().getTime()) / 1000)); //坐席回复消息花费时间 + } + + agentUserTask.setAgentreplys(agentUserTask.getAgentreplys() + 1); //总咨询记录数量 + agentUserTask.setAgentreplyinterval(agentUserTask.getAgentreplyinterval() + data.getAgentreplyinterval()); //总时长 + if (agentUserTask.getAgentreplys() > 0) { + agentUserTask.setAvgreplyinterval(agentUserTask.getAgentreplyinterval() / agentUserTask.getAgentreplys()); + } + + agentUserTask.setLastgetmessage(new Date()); + // agentUserTask.setReptime(null); // agentUserTask.setReptimes("0"); - - agentUserTaskRes.save(agentUserTask) ; - } - - /** - * 保存消息 - */ - MainContext.getContext().getBean(ChatMessageRepository.class).save(data) ; - client.sendEvent(MainContext.MessageTypeEnum.MESSAGE.toString(), data); - - if(!StringUtils.isBlank(data.getTouser())){ - OutMessageRouter router = null ; - router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()) ; - if(router!=null){ - router.handler(data.getTouser(), MainContext.MessageTypeEnum.MESSAGE.toString(), agentUser.getAppid(), outMessage); - } - } - }else if(user!=null && agentUser!=null && !user.equals(agentUser.getAgentno())){ - client.sendEvent(MainContext.MessageTypeEnum.END.toString(), agentUser); - } - } + agentUserTaskRes.save(agentUserTask); + } + + /** + * 保存消息 + */ + MainContext.getContext().getBean(ChatMessageRepository.class).save(data); + + client.sendEvent(MainContext.MessageTypeEnum.MESSAGE.toString(), data); + + if (StringUtils.isNotBlank(data.getTouser())) { + OutMessageRouter router = null; + router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()); + if (router != null) { + router.handler(data.getTouser(), MainContext.MessageTypeEnum.MESSAGE.toString(), agentUser.getAppid(), outMessage); + } + } + } else if (user != null && agentUser != null && !user.equals(agentUser.getAgentno())) { + client.sendEvent(MainContext.MessageTypeEnum.END.toString(), agentUser); + } + } } \ No newline at end of file diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/CalloutEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/CalloutEventHandler.java index aed2980a..8f405846 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/CalloutEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/CalloutEventHandler.java @@ -51,7 +51,7 @@ public class CalloutEventHandler String admin = client.getHandshakeData().getSingleUrlParam("admin") ; logger.info("onConnect userid {}, orgi {}.", user, orgi); - if(!StringUtils.isBlank(user) && !StringUtils.isBlank(user)){ + if(StringUtils.isNotBlank(user) && StringUtils.isNotBlank(user)){ client.set("agentno", user); InetSocketAddress address = (InetSocketAddress) client.getRemoteAddress() ; String ip = MainUtils.getIpAddr(client.getHandshakeData().getHttpHeaders(), address.getHostString()) ; diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/MessageRouter.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/MessageRouter.java index 53655660..647273d1 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/MessageRouter.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/MessageRouter.java @@ -58,7 +58,7 @@ public class MessageRouter extends Router { if (agentService != null && MainContext.AgentUserStatusEnum.INSERVICE.toString().equals(agentService.getStatus())) { outMessage.setMessage(AutomaticServiceDist.getSuccessMessage(agentService, inMessage.getAgentUser().getChannel(), inMessage.getOrgi())); // TODO #111 publish to redis - NettyClients.getInstance().sendAgentEventMessage(agentService.getAgentno(), MainContext.MessageTypeEnum.NEW.toString(), inMessage.getAgentUser()); + NettyClients.getInstance().publishAgentEventMessage(agentService.getAgentno(), MainContext.MessageTypeEnum.NEW.toString(), inMessage.getAgentUser()); } else { if (agentService.getQueneindex() > 0) { //当前有坐席 outMessage.setMessage(AutomaticServiceDist.getQueneMessage(agentService.getQueneindex(), inMessage.getAgentUser().getChannel(), inMessage.getOrgi())); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/WebIMOutMessageRouter.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/WebIMOutMessageRouter.java index 8f60b68d..d9d5e790 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/WebIMOutMessageRouter.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/router/WebIMOutMessageRouter.java @@ -32,7 +32,7 @@ public class WebIMOutMessageRouter implements OutMessageRouter{ @Override public void handler(String touser, String msgtype, String appid, MessageOutContent outMessage) { - NettyClients.getInstance().sendIMEventMessage(touser, msgtype, outMessage); + NettyClients.getInstance().publishIMEventMessage(touser, msgtype, outMessage); } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/HumanUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/HumanUtils.java index da4efde2..0d1ad19a 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/HumanUtils.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/HumanUtils.java @@ -137,14 +137,14 @@ public class HumanUtils { } } if (StringUtils.isNotBlank(data.getUserid()) && MainContext.MessageTypeEnum.MESSAGE.toString().equals(data.getType())) { - NettyClients.getInstance().sendIMEventMessage(data.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), outMessage); + NettyClients.getInstance().publishIMEventMessage(data.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), outMessage); if (statusMessage != null) { - NettyClients.getInstance().sendIMEventMessage(data.getUserid(), MainContext.MessageTypeEnum.STATUS.toString(), statusMessage); + NettyClients.getInstance().publishIMEventMessage(data.getUserid(), MainContext.MessageTypeEnum.STATUS.toString(), statusMessage); } } if (agentUser != null && StringUtils.isNotBlank(agentUser.getAgentno())) { - //将消息发送给 坐席 - NettyClients.getInstance().sendAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data); + // TODO 将消息发送给 坐席 + NettyClients.getInstance().publishAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data); } } @@ -176,7 +176,7 @@ public class HumanUtils { // outMessage.setCreatetime(data.getCreatetime()); // // if (!StringUtils.isBlank(data.getUserid()) && MainContext.MessageTypeEnum.MESSAGE.toString().equals(data.getType())) { -// NettyClients.getInstance().sendIMEventMessage(data.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), outMessage); +// NettyClients.getInstance().publishIMEventMessage(data.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), outMessage); // } // } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java index a5e5a7c4..4e5edc31 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java @@ -8,6 +8,9 @@ import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.*; +import java.util.Base64; + public class IMServiceUtils { private final static Logger logger = LoggerFactory.getLogger(IMServiceUtils.class); @@ -36,4 +39,30 @@ public class IMServiceUtils { service.save(agentUser); CacheHelper.getAgentUserCacheBean().put(agentUser.getUserid(), agentUser, orgi); } + + /** + * Write the object to a Base64 string. + */ + public static String serialize(Serializable o) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(o); + oos.close(); + return Base64.getEncoder().encodeToString(baos.toByteArray()); + } + + + /** + * Read the object from Base64 string. + */ + public static Object deserialize(String s) throws IOException, + ClassNotFoundException { + byte[] data = Base64.getDecoder().decode(s); + ObjectInputStream ois = new ObjectInputStream( + new ByteArrayInputStream(data)); + Object o = ois.readObject(); + ois.close(); + return o; + } + } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/model/MessageInContent.java b/contact-center/app/src/main/java/com/chatopera/cc/app/model/MessageInContent.java index 13e81480..d604dee2 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/model/MessageInContent.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/model/MessageInContent.java @@ -20,143 +20,180 @@ package com.chatopera.cc.app.model; import com.chatopera.cc.app.basic.MainContext; -public class MessageInContent implements MessageDataBean{ - - public String id ; - private String nickName; - private String orgi ; - private String message ; - private String filename ; - private int filesize ; - private String messageType; - private String fromUser; - private String calltype = MainContext.CallTypeEnum.IN.toString() ; - private String toUser; - private SNSAccount snsAccount ; - private AgentUser agentUser ; - private Object channelMessage ; - private String agentserviceid ; - - private String attachmentid ; - - private boolean noagent ; - - private Object user ; - private String contextid ; - private String createtime ; - - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - public String getNickName() { - return nickName; - } - public void setNickName(String nickName) { - this.nickName = nickName; - } - public String getOrgi() { - return orgi; - } - public void setOrgi(String orgi) { - this.orgi = orgi; - } - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - public String getMessageType() { - return messageType; - } - public void setMessageType(String messageType) { - this.messageType = messageType; - } - public String getFromUser() { - return fromUser; - } - public void setFromUser(String fromUser) { - this.fromUser = fromUser; - } - public String getToUser() { - return toUser; - } - public void setToUser(String toUser) { - this.toUser = toUser; - } - public SNSAccount getSnsAccount() { - return snsAccount; - } - public void setSnsAccount(SNSAccount snsAccount) { - this.snsAccount = snsAccount; - } - public AgentUser getAgentUser() { - return agentUser; - } - public void setAgentUser(AgentUser agentUser) { - this.agentUser = agentUser; - } - public Object getChannelMessage() { - return channelMessage; - } - public void setChannelMessage(Object channelMessage) { - this.channelMessage = channelMessage; - } - public Object getUser() { - return user; - } - public void setUser(Object user) { - this.user = user; - } - public String getContextid() { - return contextid; - } - public void setContextid(String contextid) { - this.contextid = contextid; - } - public String getCalltype() { - return calltype; - } - public void setCalltype(String calltype) { - this.calltype = calltype; - } - public String getCreatetime() { - return createtime; - } - public void setCreatetime(String createtime) { - this.createtime = createtime; - } - public String getFilename() { - return filename; - } - public void setFilename(String filename) { - this.filename = filename; - } - public int getFilesize() { - return filesize; - } - public void setFilesize(int filesize) { - this.filesize = filesize; - } - public String getAgentserviceid() { - return agentserviceid; - } - public void setAgentserviceid(String agentserviceid) { - this.agentserviceid = agentserviceid; - } - public String getAttachmentid() { - return attachmentid; - } - public void setAttachmentid(String attachmentid) { - this.attachmentid = attachmentid; - } - public boolean isNoagent() { - return noagent; - } - public void setNoagent(boolean noagent) { - this.noagent = noagent; - } +public class MessageInContent implements MessageDataBean, java.io.Serializable { + + public String id; + private String nickName; + private String orgi; + private String message; + private String filename; + private int filesize; + private String messageType; + private String fromUser; + private String calltype = MainContext.CallTypeEnum.IN.toString(); + private String toUser; + private SNSAccount snsAccount; + private AgentUser agentUser; + private Object channelMessage; + private String agentserviceid; + + private String attachmentid; + + private boolean noagent; + + private Object user; + private String contextid; + private String createtime; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getOrgi() { + return orgi; + } + + public void setOrgi(String orgi) { + this.orgi = orgi; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getMessageType() { + return messageType; + } + + public void setMessageType(String messageType) { + this.messageType = messageType; + } + + public String getFromUser() { + return fromUser; + } + + public void setFromUser(String fromUser) { + this.fromUser = fromUser; + } + + public String getToUser() { + return toUser; + } + + public void setToUser(String toUser) { + this.toUser = toUser; + } + + public SNSAccount getSnsAccount() { + return snsAccount; + } + + public void setSnsAccount(SNSAccount snsAccount) { + this.snsAccount = snsAccount; + } + + public AgentUser getAgentUser() { + return agentUser; + } + + public void setAgentUser(AgentUser agentUser) { + this.agentUser = agentUser; + } + + public Object getChannelMessage() { + return channelMessage; + } + + public void setChannelMessage(Object channelMessage) { + this.channelMessage = channelMessage; + } + + public Object getUser() { + return user; + } + + public void setUser(Object user) { + this.user = user; + } + + public String getContextid() { + return contextid; + } + + public void setContextid(String contextid) { + this.contextid = contextid; + } + + public String getCalltype() { + return calltype; + } + + public void setCalltype(String calltype) { + this.calltype = calltype; + } + + public String getCreatetime() { + return createtime; + } + + public void setCreatetime(String createtime) { + this.createtime = createtime; + } + + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } + + public int getFilesize() { + return filesize; + } + + public void setFilesize(int filesize) { + this.filesize = filesize; + } + + public String getAgentserviceid() { + return agentserviceid; + } + + public void setAgentserviceid(String agentserviceid) { + this.agentserviceid = agentserviceid; + } + + public String getAttachmentid() { + return attachmentid; + } + + public void setAttachmentid(String attachmentid) { + this.attachmentid = attachmentid; + } + + public boolean isNoagent() { + return noagent; + } + + public void setNoagent(boolean noagent) { + this.noagent = noagent; + } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/CallOutWireTask.java b/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/CallOutWireTask.java index 2c4afa4a..fd6cde8c 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/CallOutWireTask.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/CallOutWireTask.java @@ -55,8 +55,6 @@ import java.util.List; @Component public class CallOutWireTask implements MessageListener { private static final Logger logger = LoggerFactory.getLogger(CallOutWireTask.class); - private static final RedisSerializer redisStringSerializer = new StringRedisSerializer(); - @Autowired private CallOutDialplanRepository callOutDialplanRes; diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMAgentDispatcher.java b/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMAgentDispatcher.java new file mode 100644 index 00000000..4d09db99 --- /dev/null +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMAgentDispatcher.java @@ -0,0 +1,104 @@ +/* + * 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.schedule; + +import com.chatopera.cc.app.im.client.NettyClients; +import com.chatopera.cc.app.im.util.IMServiceUtils; +import com.chatopera.cc.util.Constants; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.connection.Message; +import org.springframework.data.redis.connection.MessageListener; +import org.springframework.data.redis.core.HashOperations; +import org.springframework.data.redis.core.ListOperations; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.io.*; +import java.util.Base64; + +/** + * 坐席消息分发 + */ +@Component +public class WebIMAgentDispatcher implements MessageListener { + private final static Logger logger = LoggerFactory.getLogger(WebIMAgentDispatcher.class); + + private ListOperations redisListOps; + private HashOperations redisHashOps; + + @Value("${spring.redis.host}") + private String redisHost; + + @Value("${spring.redis.port}") + private String redisPort; + + @Value("${spring.redis.database}") + private String redisDB; + + @Value("${application.node.id}") + private String appNodeId; + + + /** + * 使用StringRedisTemplate而不是RedisTemplate解决序列化问题 + * https://stackoverflow.com/questions/13215024/weird-redis-key-with-spring-data-jedis + */ + @Autowired + private StringRedisTemplate redis; + + @PostConstruct + private void init() { + redisListOps = redis.opsForList(); + redisHashOps = redis.opsForHash(); + } + + /** + * Publish Message into Channel with redis PubSub + * + * @param j + */ + public void publish(JsonObject j) { + ChannelTopic ct = new ChannelTopic(String.format(Constants.INSTANT_MESSTRING_WEBIM_AGENT_PATTERN, appNodeId)); + j.addProperty("node", appNodeId); + redis.convertAndSend(ct.getTopic(), j.toString()); + } + + @Override + public void onMessage(Message message, byte[] bytes) { + logger.debug("[instant messaging] onMessage {}", message); + String payload = new String(message.getBody()); + JsonParser parser = new JsonParser(); + JsonObject j = parser.parse(payload).getAsJsonObject(); + logger.debug("[instant messaging] message body {}", j.toString()); + try { + NettyClients.getInstance().sendAgentEventMessage(j.get("id").getAsString(), + j.get("event").getAsString(), + IMServiceUtils.deserialize(j.get("data").getAsString())); + } catch (Exception e) { + logger.error("onMessage", e); + } + + } + +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMOnlineUserDispatcher.java b/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMOnlineUserDispatcher.java new file mode 100644 index 00000000..3254d099 --- /dev/null +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMOnlineUserDispatcher.java @@ -0,0 +1,102 @@ +/* + * 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.schedule; + +import com.chatopera.cc.app.im.client.NettyClients; +import com.chatopera.cc.app.im.util.IMServiceUtils; +import com.chatopera.cc.util.Constants; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.connection.Message; +import org.springframework.data.redis.connection.MessageListener; +import org.springframework.data.redis.core.HashOperations; +import org.springframework.data.redis.core.ListOperations; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.io.*; +import java.util.Base64; + +/** + * 访客消息分发 + */ +@Component +public class WebIMOnlineUserDispatcher implements MessageListener { + private final static Logger logger = LoggerFactory.getLogger(WebIMOnlineUserDispatcher.class); + + private ListOperations redisListOps; + private HashOperations redisHashOps; + + @Value("${spring.redis.host}") + private String redisHost; + + @Value("${spring.redis.port}") + private String redisPort; + + @Value("${spring.redis.database}") + private String redisDB; + + @Value("${application.node.id}") + private String appNodeId; + + + /** + * 使用StringRedisTemplate而不是RedisTemplate解决序列化问题 + * https://stackoverflow.com/questions/13215024/weird-redis-key-with-spring-data-jedis + */ + @Autowired + private StringRedisTemplate redis; + + @PostConstruct + private void init() { + redisListOps = redis.opsForList(); + redisHashOps = redis.opsForHash(); + } + + /** + * Publish Message into Channel with redis PubSub + * + * @param j + */ + public void publish(JsonObject j) { + ChannelTopic ct = new ChannelTopic(String.format(Constants.INSTANT_MESSTRING_WEBIM_ONLINE_USER_PATTERN, appNodeId)); + j.addProperty("node", appNodeId); + redis.convertAndSend(ct.getTopic(), j.toString()); + } + + @Override + public void onMessage(Message message, byte[] bytes) { + logger.debug("[instant messaging] onMessage {}", message); + String payload = new String(message.getBody()); + JsonParser parser = new JsonParser(); + JsonObject j = parser.parse(payload).getAsJsonObject(); + logger.debug("[instant messaging] message body {}", j.toString()); + try { + NettyClients.getInstance().sendIMEventMessage(j.get("id").getAsString(), + j.get("event").getAsString(), + IMServiceUtils.deserialize(j.get("data").getAsString())); + } catch (Exception e) { + logger.error("onMessage", e); + } + } +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMTask.java b/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMTask.java index e11dc5b9..433c1268 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMTask.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/schedule/WebIMTask.java @@ -15,25 +15,19 @@ */ package com.chatopera.cc.app.schedule; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; - import com.chatopera.cc.app.algorithm.AutomaticServiceDist; import com.chatopera.cc.app.basic.MainContext; -import com.chatopera.cc.app.im.client.NettyClients; import com.chatopera.cc.app.basic.MainUtils; -import com.chatopera.cc.exchange.DataExchangeInterface; -import com.chatopera.cc.util.freeswitch.model.CallCenterAgent; import com.chatopera.cc.app.cache.CacheHelper; -import com.chatopera.cc.app.persistence.impl.CallOutQuene; -import com.chatopera.cc.app.persistence.repository.AgentUserTaskRepository; -import com.chatopera.cc.app.persistence.repository.JobDetailRepository; -import com.chatopera.cc.app.persistence.repository.OnlineUserRepository; -import com.chatopera.cc.util.OnlineUserUtils; -import com.chatopera.cc.app.im.router.OutMessageRouter; +import com.chatopera.cc.app.im.client.NettyClients; import com.chatopera.cc.app.im.message.ChatMessage; +import com.chatopera.cc.app.im.router.OutMessageRouter; +import com.chatopera.cc.app.model.*; +import com.chatopera.cc.app.persistence.impl.CallOutQuene; +import com.chatopera.cc.app.persistence.repository.*; +import com.chatopera.cc.exchange.DataExchangeInterface; +import com.chatopera.cc.util.OnlineUserUtils; +import com.chatopera.cc.util.freeswitch.model.CallCenterAgent; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; @@ -43,18 +37,10 @@ import org.springframework.data.domain.PageRequest; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; -import com.chatopera.cc.app.persistence.repository.ChatMessageRepository; -import com.chatopera.cc.app.persistence.repository.ConsultInviteRepository; -import com.chatopera.cc.app.model.AgentStatus; -import com.chatopera.cc.app.model.AgentUser; -import com.chatopera.cc.app.model.AgentUserTask; -import com.chatopera.cc.app.model.AiConfig; -import com.chatopera.cc.app.model.AiUser; -import com.chatopera.cc.app.model.CousultInvite; -import com.chatopera.cc.app.model.JobDetail; -import com.chatopera.cc.app.model.MessageOutContent; -import com.chatopera.cc.app.model.OnlineUser; -import com.chatopera.cc.app.model.SessionConfig; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; @Configuration @EnableScheduling @@ -72,7 +58,7 @@ public class WebIMTask { @Autowired private TaskExecutor webimTaskExecutor; - @Scheduled(fixedDelay = 5000) // 每5秒执行一次 + @Scheduled(fixedDelay = 5000) // 处理超时消息,每5秒执行一次 public void task() { List sessionConfigList = AutomaticServiceDist.initSessionConfigList(); if (sessionConfigList != null && sessionConfigList.size() > 0 && MainContext.getContext() != null) { @@ -255,7 +241,7 @@ public class WebIMTask { private void processMessage(SessionConfig sessionConfig, String message, String servicename, AgentUser agentUser, AgentStatus agentStatus, AgentUserTask task) { MessageOutContent outMessage = new MessageOutContent(); - if (!StringUtils.isBlank(message)) { + if (StringUtils.isNotBlank(message)) { outMessage.setMessage(message); outMessage.setMessageType(MainContext.MediaTypeEnum.TEXT.toString()); outMessage.setCalltype(MainContext.CallTypeEnum.OUT.toString()); @@ -279,7 +265,7 @@ public class WebIMTask { data.setAgentserviceid(agentUser.getAgentserviceid()); data.setCalltype(MainContext.CallTypeEnum.OUT.toString()); - if (!StringUtils.isBlank(agentUser.getAgentno())) { + if (StringUtils.isNotBlank(agentUser.getAgentno())) { data.setTouser(agentUser.getUserid()); } data.setChannel(agentUser.getChannel()); @@ -304,11 +290,12 @@ public class WebIMTask { */ MainContext.getContext().getBean(ChatMessageRepository.class).save(data); - if (agentUser != null && !StringUtils.isBlank(agentUser.getAgentno())) { //同时发送消息给双方 - NettyClients.getInstance().sendAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data); + // 同时发送消息给双方 + if (agentUser != null && StringUtils.isNotBlank(agentUser.getAgentno())) { + NettyClients.getInstance().publishAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data); } - if (!StringUtils.isBlank(data.getTouser())) { + if (StringUtils.isNotBlank(data.getTouser())) { OutMessageRouter router = null; router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()); if (router != null) { diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java b/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java index c83644ba..d3ed8ecc 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java @@ -16,6 +16,7 @@ package com.chatopera.cc.util; import com.chatopera.cc.app.basic.MainContext; +import org.apache.commons.lang.StringUtils; import java.text.DecimalFormat; import java.text.SimpleDateFormat; @@ -46,6 +47,17 @@ public class Constants { public final static SimpleDateFormat DISPLAY_DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public final static DecimalFormat DURATION_MINS_FORMATTER = new DecimalFormat("0.00"); + + /** + * Instant Messaging Events + */ + public final static String INSTANT_MESSTRING_WEBIM_AGENT_PATTERN = "im:webim:agent:%s:events"; + public final static String INSTANT_MESSAGING_WEBIM_AGENT_CHANNEL = String.format(INSTANT_MESSTRING_WEBIM_AGENT_PATTERN, "*"); + public final static String INSTANT_MESSTRING_WEBIM_ONLINE_USER_PATTERN = "im:webim:onlineuser:%s:events"; + public final static String INSTANT_MESSAGING_WEBIM_ONLINE_USER_CHANNEL = String.format(INSTANT_MESSTRING_WEBIM_ONLINE_USER_PATTERN, "*"); + + + /** * FreeSwitch Communication */ diff --git a/contact-center/app/src/main/resources/application.properties b/contact-center/app/src/main/resources/application.properties index 5af82aae..248feb69 100644 --- a/contact-center/app/src/main/resources/application.properties +++ b/contact-center/app/src/main/resources/application.properties @@ -18,6 +18,8 @@ # 证书相关信息 license.client.id=cskefu application.version=3.9.0 +# 在集群状态下,每个Node都有自己唯一的ID +application.node.id=localhost # security management.security.enabled=false @@ -131,7 +133,7 @@ spring.redis.port=6379 # Redis服务器连接密码(默认为空) spring.redis.password= # 连接池最大连接数(使用负值表示没有限制) -spring.redis.pool.max-active=20 +spring.redis.pool.max-active=-1 # 连接池最大阻塞等待时间(使用负值表示没有限制) spring.redis.pool.max-wait=-1 # 连接池中的最大空闲连接 From 0d1f15a8568dab038f84d1121e8f39b53d055b45 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Tue, 23 Oct 2018 18:49:51 +0800 Subject: [PATCH 37/54] Closed #112 check null value for agentUser --- .../java/com/chatopera/cc/app/im/util/IMServiceUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java index 4e5edc31..d71df8df 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/util/IMServiceUtils.java @@ -35,9 +35,9 @@ public class IMServiceUtils { logger.warn("shiftOpsType unknown type."); break; } + service.save(agentUser); + CacheHelper.getAgentUserCacheBean().put(agentUser.getUserid(), agentUser, orgi); } - service.save(agentUser); - CacheHelper.getAgentUserCacheBean().put(agentUser.getUserid(), agentUser, orgi); } /** From 0f38a0b998dbc583959f739766ccdc1ebf34b408 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Tue, 23 Oct 2018 19:04:44 +0800 Subject: [PATCH 38/54] =?UTF-8?q?Closed=20#31=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/app/handler/apps/agent/AgentController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java index 041611d5..b4e4025a 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java @@ -741,7 +741,7 @@ public class AgentController extends Handler { } outMessage.setCalltype(MainContext.CallTypeEnum.OUT.toString()); outMessage.setCreatetime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); - outMessage.setNickName(super.getUser(request).getUsername()); + outMessage.setNickName(super.getUser(request).getUname()); router.handler(agentUser.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), agentUser.getAppid(), outMessage); } @@ -765,10 +765,10 @@ public class AgentController extends Handler { data.setOrgi(super.getUser(request).getOrgi()); data.setCreater(super.getUser(request).getId()); - data.setUsername(super.getUser(request).getUsername()); + data.setUsername(super.getUser(request).getUname()); chatMessageRepository.save(data); - // TODO #111 通知文件上传消息 + // 通知文件上传消息 NettyClients.getInstance().publishAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data); } @@ -827,7 +827,7 @@ public class AgentController extends Handler { outMessage.setMessageType(MainContext.MediaTypeEnum.ACTION.toString()); outMessage.setCalltype(MainContext.CallTypeEnum.INVITE.toString()); outMessage.setCreatetime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); - outMessage.setNickName(super.getUser(request).getUsername()); + outMessage.setNickName(super.getUser(request).getUname()); router.handler(agentUser.getUserid(), MainContext.MessageTypeEnum.MESSAGE.toString(), agentUser.getAppid(), outMessage); } @@ -1068,7 +1068,7 @@ public class AgentController extends Handler { agentService.setAgentno(agentno); agentService.setAgentusername(transAgentStatus.getUsername()); } - // TODO #111 通知转接消息 + // 通知转接消息 NettyClients.getInstance().publishAgentEventMessage(agentno, MainContext.MessageTypeEnum.NEW.toString(), agentUser); } } else { From 2adda6408a8fd14d4ed4aca541b48c9b91dd611c Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Tue, 23 Oct 2018 19:35:32 +0800 Subject: [PATCH 39/54] =?UTF-8?q?#113=20=E6=A3=80=E6=B5=8B=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8E=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/apps/internet/IMController.java | 78 +++++++++++-------- .../cc/util/AttachementFormatValidator.java | 52 +++++++++++++ .../java/com/chatopera/cc/util/Constants.java | 6 +- 3 files changed, 103 insertions(+), 33 deletions(-) create mode 100644 contact-center/app/src/main/java/com/chatopera/cc/util/AttachementFormatValidator.java diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java index 26ab415d..43137770 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java @@ -17,13 +17,13 @@ package com.chatopera.cc.app.handler.apps.internet; +import com.chatopera.cc.app.algorithm.AutomaticServiceDist; import com.chatopera.cc.app.basic.MainContext; import com.chatopera.cc.app.basic.MainUtils; +import com.chatopera.cc.app.cache.CacheHelper; import com.chatopera.cc.app.handler.Handler; import com.chatopera.cc.app.im.util.RichMediaUtils; import com.chatopera.cc.app.model.*; -import com.chatopera.cc.app.algorithm.AutomaticServiceDist; -import com.chatopera.cc.app.cache.CacheHelper; import com.chatopera.cc.app.persistence.es.ContactsRepository; import com.chatopera.cc.app.persistence.repository.*; import com.chatopera.cc.util.*; @@ -711,47 +711,61 @@ public class IMController extends Handler { ModelAndView view = request(super.createRequestPageTempletResponse("/apps/im/upload")); UploadStatus upload = null; String fileName = null; - if (imgFile != null && imgFile.getOriginalFilename().lastIndexOf(".") > 0 && StringUtils.isNotBlank(userid)) { + if (imgFile != null + && imgFile.getOriginalFilename().lastIndexOf(".") > 0 + && StringUtils.isNotBlank(userid)) { File uploadDir = new File(path, "upload"); if (!uploadDir.exists()) { uploadDir.mkdirs(); } String fileid = MainUtils.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; - MainUtils.processImage(new File(path, thumbnailsFileName), imageFile); + if (imgFile.getContentType() != null + && imgFile.getContentType().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) { + // 检查文件格式 + String invalid = AttachementFormatValidator.getInstance().validate(Constants.ATTACHMENT_TYPE_IMAGE, imgFile.getOriginalFilename()); + if (invalid == null) { + fileName = "upload/" + fileid + "_original"; + File imageFile = new File(path, fileName); + FileCopyUtils.copy(imgFile.getBytes(), imageFile); + String thumbnailsFileName = "upload/" + fileid; + MainUtils.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.isNotBlank(channel)) { - RichMediaUtils.uploadImageWithChannel(image, fileid, (int) imgFile.getSize(), imgFile.getName(), channel, userid, username, appid, orgi); + 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 { - RichMediaUtils.uploadImage(image, fileid, (int) imgFile.getSize(), imgFile.getName(), userid); + image = "/res/image.html?id=" + thumbnailsFileName; } + if (paste == null) { + if (StringUtils.isNotBlank(channel)) { + RichMediaUtils.uploadImageWithChannel(image, fileid, (int) imgFile.getSize(), imgFile.getName(), channel, userid, username, appid, orgi); + } else { + RichMediaUtils.uploadImage(image, fileid, (int) imgFile.getSize(), imgFile.getName(), userid); + } + } + } else { + upload = new UploadStatus(invalid); } } 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; + String invalid = AttachementFormatValidator.getInstance().validate(Constants.ATTACHMENT_TYPE_FILE, imgFile.getOriginalFilename()); + if (invalid == null) { + 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.isNotBlank(channel)) { + RichMediaUtils.uploadFileWithChannel(file, (int) imgFile.getSize(), tempFile.getName(), channel, userid, username, appid, orgi, id); + } else { + RichMediaUtils.uploadFile(file, (int) imgFile.getSize(), tempFile.getName(), userid, id); + } } else { - file = "/res/file.html?id=" + id; - } - File tempFile = new File(imgFile.getOriginalFilename()); - if (StringUtils.isNotBlank(channel)) { - RichMediaUtils.uploadFileWithChannel(file, (int) imgFile.getSize(), tempFile.getName(), channel, userid, username, appid, orgi, id); - } else { - RichMediaUtils.uploadFile(file, (int) imgFile.getSize(), tempFile.getName(), userid, id); + upload = new UploadStatus(invalid); } } } else { diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/AttachementFormatValidator.java b/contact-center/app/src/main/java/com/chatopera/cc/util/AttachementFormatValidator.java new file mode 100644 index 00000000..df5cd4a5 --- /dev/null +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/AttachementFormatValidator.java @@ -0,0 +1,52 @@ +/* + * 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.util; + +import java.util.Arrays; +import java.util.HashMap; + +public class AttachementFormatValidator { + + private static AttachementFormatValidator singleton = new AttachementFormatValidator(); + + private final HashMap extMap = new HashMap(); + + private AttachementFormatValidator() { + extMap.put(Constants.ATTACHMENT_TYPE_IMAGE, "gif,jpg,jpeg,png,bmp"); + extMap.put(Constants.ATTACHMENT_TYPE_FILE, "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2,c66"); + extMap.put("flash", "swf,flv"); + extMap.put("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb"); + } + + public static AttachementFormatValidator getInstance() { + return singleton; + } + + /** + * Validate file format + * @param type + * @param filename + * @return + */ + public String validate(final String type, final String filename) { + final String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase(); + if (!Arrays.asList(extMap.get(type).split(",")).contains(ext)) { + return "上传文件扩展名是不允许的扩展名。只允许" + extMap.get(type) + "格式。"; + } + return null; + } +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java b/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java index d3ed8ecc..19cd33f7 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/Constants.java @@ -56,7 +56,11 @@ public class Constants { public final static String INSTANT_MESSTRING_WEBIM_ONLINE_USER_PATTERN = "im:webim:onlineuser:%s:events"; public final static String INSTANT_MESSAGING_WEBIM_ONLINE_USER_CHANNEL = String.format(INSTANT_MESSTRING_WEBIM_ONLINE_USER_PATTERN, "*"); - + /** + * Attachment File Type + */ + public final static String ATTACHMENT_TYPE_IMAGE = "image"; + public final static String ATTACHMENT_TYPE_FILE = "file"; /** * FreeSwitch Communication From 9769e501c8b8a64dc20cb7b62caf55301cf355a7 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Tue, 23 Oct 2018 20:34:25 +0800 Subject: [PATCH 40/54] =?UTF-8?q?Fixed=20#114=20=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E4=BC=9A=E8=AF=9D=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chatopera/cc/app/im/handler/IMEventHandler.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java index b5f97bf2..e91c58b4 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java @@ -160,7 +160,6 @@ public class IMEventHandler { agentUser.setName(contacts.getName()); agentUser.setPhone(contacts.getPhone()); agentUser.setEmail(contacts.getEmail()); - agentUser.setResion(contacts.getMemo()); agentUser.setChatbotops(false); // 非机器人客服 agentUser.setOpttype(MainContext.OptTypeEnum.HUMAN.toString()); service.save(agentUser); @@ -172,9 +171,8 @@ public class IMEventHandler { if (agentServiceList.size() > 0) { AgentService agentService = agentServiceList.get(0); agentService.setName(contacts.getName()); - agentService.setPhone(contacts.getName()); - agentService.setEmail(contacts.getName()); - agentService.setRegion(contacts.getMemo()); + agentService.setPhone(contacts.getPhone()); + agentService.setEmail(contacts.getEmail()); agentServiceRes.save(agentService); } } From 97ac1ce8908096a376664e18adeac4061eb0a49d Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Tue, 23 Oct 2018 21:12:34 +0800 Subject: [PATCH 41/54] Closed #115 add commit id --- contact-center/Dockerfile | 5 +++++ contact-center/admin/build.sh | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/contact-center/Dockerfile b/contact-center/Dockerfile index 16410c0f..d23c49c7 100644 --- a/contact-center/Dockerfile +++ b/contact-center/Dockerfile @@ -1,6 +1,11 @@ FROM chatopera/java:1.0.0 MAINTAINER Hai Liang Wang +ARG VCS_REF + +LABEL org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url="https://github.com/chatopera/cosin" + # Set timezone RUN apt-get update && \ apt-get install --no-install-recommends -y tzdata && \ diff --git a/contact-center/admin/build.sh b/contact-center/admin/build.sh index 18a63960..981e8681 100755 --- a/contact-center/admin/build.sh +++ b/contact-center/admin/build.sh @@ -13,8 +13,7 @@ PACKAGE_VERSION=1.0.0 # main [ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return -cd $appHome - set -x -docker build --force-rm=true --tag $imagename:$PACKAGE_VERSION . +cd $appHome +docker build --build-arg VCS_REF=`git rev-parse --short HEAD` --force-rm=true --tag $imagename:$PACKAGE_VERSION . docker tag $imagename:$PACKAGE_VERSION $imagename:develop From 892e85b033cba0807c45c7276126c899c91d6823 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 24 Oct 2018 18:13:58 +0800 Subject: [PATCH 42/54] #116 store image and file into mysql --- .../com/chatopera/cc/app/Application.java | 2 + .../com/chatopera/cc/app/basic/MainUtils.java | 43 +--- .../handler/apps/agent/AgentController.java | 231 ++++++++++-------- .../handler/apps/internet/IMController.java | 128 +++++----- .../app/handler/resource/MediaController.java | 139 +++++------ .../chatopera/cc/app/model/StreamingFile.java | 98 ++++++++ .../app/persistence/blob/JpaBlobHelper.java | 55 +++++ .../repository/StreamingFileRepository.java | 23 ++ ...Validator.java => StreamingFileUtils.java} | 9 +- .../src/main/resources/application.properties | 15 +- .../apps/agent/media/messageimage.html | 4 +- .../templates/apps/im/chatbot/index.html | 2 +- .../templates/apps/im/chatbot/mobile.html | 6 +- .../resources/templates/apps/im/index.html | 2 +- .../templates/apps/im/media/message.html | 2 +- .../resources/templates/apps/im/mobile.html | 6 +- 16 files changed, 472 insertions(+), 293 deletions(-) create mode 100644 contact-center/app/src/main/java/com/chatopera/cc/app/model/StreamingFile.java create mode 100644 contact-center/app/src/main/java/com/chatopera/cc/app/persistence/blob/JpaBlobHelper.java create mode 100644 contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/StreamingFileRepository.java rename contact-center/app/src/main/java/com/chatopera/cc/util/{AttachementFormatValidator.java => StreamingFileUtils.java} (87%) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java b/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java index 60e6e8f0..00b84c4a 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/Application.java @@ -36,6 +36,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.transaction.annotation.EnableTransactionManagement; import javax.servlet.MultipartConfigElement; import java.io.IOException; @@ -44,6 +45,7 @@ import java.io.IOException; @EnableJpaRepositories("com.chatopera.cc.app.persistence.repository") @EnableElasticsearchRepositories("com.chatopera.cc.app.persistence.es") @EnableAsync +@EnableTransactionManagement public class Application { @Value("${web.upload-path}") 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 index e98cbd60..75de78ba 100644 --- 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 @@ -766,14 +766,14 @@ public class MainUtils { return workintTime; } - public static File processImage(File destFile, File imageFile) throws FileNotFoundException, IOException { + public static File processImage(final File destFile, final File imageFile) throws FileNotFoundException, IOException { if (imageFile != null && imageFile.exists()) { Thumbnails.of(imageFile).width(460).keepAspectRatio(true).toFile(destFile); } return destFile; } - public static File scaleImage(File destFile, File imageFile, float quality) throws FileNotFoundException, IOException { + public static File scaleImage(final File destFile, final File imageFile, float quality) throws FileNotFoundException, IOException { if (imageFile != null && imageFile.exists()) { Thumbnails.of(imageFile).scale(1f).outputQuality(quality).toFile(destFile); } @@ -846,45 +846,6 @@ public class MainUtils { return execute; } - public static void processAttachmentFile(MultipartFile[] files, AttachmentRepository attachementRes, String path, User user, String orgi, WorkOrders workOrders, HttpServletRequest request, String dataid, String modelid) throws IOException { - if (files != null && files.length > 0) { - workOrders.setAnonymous(true);//变更用途为是否有 附件 - //保存附件 - for (MultipartFile file : files) { - if (file.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制 - String fileid = MainUtils.md5(file.getBytes()); //使用 文件的 MD5作为 ID,避免重复上传大文件 - if (!StringUtils.isBlank(fileid)) { - AttachmentFile attachmentFile = new AttachmentFile(); - attachmentFile.setCreater(user.getId()); - attachmentFile.setOrgi(orgi); - attachmentFile.setOrgan(user.getOrgan()); - attachmentFile.setDataid(dataid); - attachmentFile.setModelid(modelid); - attachmentFile.setModel(MainContext.ModelType.WORKORDERS.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()); - } - if (file.getOriginalFilename() != null && file.getOriginalFilename().length() > 255) { - attachmentFile.setTitle(file.getOriginalFilename().substring(0, 255)); - } else { - attachmentFile.setTitle(file.getOriginalFilename()); - } - if (!StringUtils.isBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) { - attachmentFile.setImage(true); - } - attachmentFile.setFileid(fileid); - attachementRes.save(attachmentFile); - FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), file.getBytes()); - } - } - } - - } - } - /** * 获取系统配置 * diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java index b4e4025a..70ff8b17 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/agent/AgentController.java @@ -25,15 +25,13 @@ import com.chatopera.cc.app.im.client.NettyClients; import com.chatopera.cc.app.im.message.ChatMessage; import com.chatopera.cc.app.im.router.OutMessageRouter; import com.chatopera.cc.app.model.*; +import com.chatopera.cc.app.persistence.blob.JpaBlobHelper; import com.chatopera.cc.app.persistence.es.ContactsRepository; import com.chatopera.cc.app.persistence.es.QuickReplyRepository; import com.chatopera.cc.app.persistence.repository.*; import com.chatopera.cc.exception.CSKefuException; import com.chatopera.cc.exchange.DataExchangeInterface; -import com.chatopera.cc.util.Menu; -import com.chatopera.cc.util.OnlineUserUtils; -import com.chatopera.cc.util.PinYinTools; -import com.chatopera.cc.util.PropertiesEventUtils; +import com.chatopera.cc.util.*; import com.chatopera.cc.util.mobile.MobileAddress; import com.chatopera.cc.util.mobile.MobileNumberUtils; import freemarker.template.TemplateException; @@ -149,6 +147,12 @@ public class AgentController extends Handler { @Autowired private ConsultInviteRepository inviteRepository; + @Autowired + private StreamingFileRepository streamingFileRepository; + + @Autowired + private JpaBlobHelper jpaBlobHelper; + @Value("${web.upload-path}") private String path; @@ -169,7 +173,7 @@ public class AgentController extends Handler { } } } - if (!StringUtils.isBlank(sort)) { + if (StringUtils.isNotBlank(sort)) { List list = new ArrayList(); if (sort.equals("lastmessage")) { list.add(new Order(Direction.DESC, "status")); @@ -208,7 +212,7 @@ public class AgentController extends Handler { agentUser = (AgentUser) agentUserList.get(0); view.addObject("curagentuser", agentUser); view.addObject("inviteData", OnlineUserUtils.cousult(agentUser.getAppid(), agentUser.getOrgi(), inviteRepository)); - if (!StringUtils.isBlank(agentUser.getAgentserviceid())) { + if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) { List summarizes = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)); if (summarizes.size() > 0) { view.addObject("summary", summarizes.get(0)); @@ -217,7 +221,7 @@ public class AgentController extends Handler { view.addObject("agentUserMessageList", this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid(), super.getOrgi(request), new PageRequest(0, 20, Direction.DESC, "updatetime"))); AgentService agentService = null; - if (!StringUtils.isBlank(agentUser.getAgentserviceid())) { + if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) { agentService = this.agentServiceRepository.findOne(agentUser.getAgentserviceid()); view.addObject("curAgentService", agentService); @@ -247,10 +251,10 @@ public class AgentController extends Handler { view.addObject("onlineUser", onlineUser); } } else if (MainContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel())) { - if (agentService != null && !StringUtils.isBlank(agentService.getOwner())) { + if (agentService != null && StringUtils.isNotBlank(agentService.getOwner())) { StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner()); if (statusEvent != null) { - if (!StringUtils.isBlank(statusEvent.getHostid())) { + if (StringUtils.isNotBlank(statusEvent.getHostid())) { PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid()); view.addObject("pbxHost", pbxHost); } @@ -302,19 +306,19 @@ public class AgentController extends Handler { ) ); - if (!StringUtils.isBlank(agentService.getAppid())) { + if (StringUtils.isNotBlank(agentService.getAppid())) { map.addAttribute("snsAccount", snsAccountRes.findBySnsidAndOrgi(agentService.getAppid(), super.getOrgi(request))); } List relaList = agentUserContactsRes.findByUseridAndOrgi(agentService.getUserid(), agentService.getOrgi()); if (relaList.size() > 0) { AgentUserContacts agentUserContacts = relaList.get(0); - if (MainContext.model.get("contacts") != null && !StringUtils.isBlank(agentUserContacts.getContactsid())) { + if (MainContext.model.get("contacts") != null && StringUtils.isNotBlank(agentUserContacts.getContactsid())) { DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("contacts"); if (dataExchange != null) { map.addAttribute("contacts", dataExchange.getDataByIdAndOrgi(agentUserContacts.getContactsid(), super.getOrgi(request))); } } - if (MainContext.model.get("workorders") != null && !StringUtils.isBlank(agentUserContacts.getContactsid())) { + if (MainContext.model.get("workorders") != null && StringUtils.isNotBlank(agentUserContacts.getContactsid())) { DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("workorders"); if (dataExchange != null) { map.addAttribute("workOrdersList", dataExchange.getListDataByIdAndOrgi(agentUserContacts.getContactsid(), super.getUser(request).getId(), super.getOrgi(request))); @@ -346,7 +350,7 @@ public class AgentController extends Handler { agentUserTaskRes.save(agentUserTask); } - if (!StringUtils.isBlank(agentUser.getAgentserviceid())) { + if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) { List summarizes = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)); if (summarizes.size() > 0) { view.addObject("summary", summarizes.get(0)); @@ -355,7 +359,7 @@ public class AgentController extends Handler { view.addObject("agentUserMessageList", this.chatMessageRepository.findByUsessionAndOrgi(agentUser.getUserid(), super.getOrgi(request), new PageRequest(0, 20, Direction.DESC, "updatetime"))); AgentService agentService = null; - if (!StringUtils.isBlank(agentUser.getAgentserviceid())) { + if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) { agentService = this.agentServiceRepository.findOne(agentUser.getAgentserviceid()); view.addObject("curAgentService", agentService); if (agentService != null) { @@ -385,10 +389,10 @@ public class AgentController extends Handler { view.addObject("onlineUser", onlineUser); } } else if (MainContext.ChannelTypeEnum.PHONE.toString().equals(agentUser.getChannel())) { - if (agentService != null && !StringUtils.isBlank(agentService.getOwner())) { + if (agentService != null && StringUtils.isNotBlank(agentService.getOwner())) { StatusEvent statusEvent = this.statusEventRes.findById(agentService.getOwner()); if (statusEvent != null) { - if (!StringUtils.isBlank(statusEvent.getHostid())) { + if (StringUtils.isNotBlank(statusEvent.getHostid())) { PbxHost pbxHost = pbxHostRes.findById(statusEvent.getHostid()); view.addObject("pbxHost", pbxHost); } @@ -455,7 +459,7 @@ public class AgentController extends Handler { @RequestMapping("/workorders/list") @Menu(type = "apps", subtype = "workorderslist") public ModelAndView workorderslist(HttpServletRequest request, String contactsid, ModelMap map) { - if (MainContext.model.get("workorders") != null && !StringUtils.isBlank(contactsid)) { + if (MainContext.model.get("workorders") != null && StringUtils.isNotBlank(contactsid)) { DataExchangeInterface dataExchange = (DataExchangeInterface) MainContext.getContext().getBean("workorders"); if (dataExchange != null) { map.addAttribute("workOrdersList", dataExchange.getListDataByIdAndOrgi(contactsid, super.getUser(request).getId(), super.getOrgi(request))); @@ -481,7 +485,7 @@ public class AgentController extends Handler { agentStatus.setAgentno(user.getId()); agentStatus.setLogindate(new Date()); - if (!StringUtils.isBlank(user.getOrgan())) { + if (StringUtils.isNotBlank(user.getOrgan())) { Organ organ = organRes.findByIdAndOrgi(user.getOrgan(), super.getOrgiByTenantshare(request)); if (organ != null && organ.isSkill()) { agentStatus.setSkill(organ.getId()); @@ -589,7 +593,7 @@ public class AgentController extends Handler { AgentUser agentUser = agentUserRepository.findByIdAndOrgi(userid, super.getOrgi(request)); if (agentUser != null && super.getUser(request).getId().equals(agentUser.getAgentno())) { AutomaticServiceDist.deleteAgentUser(agentUser, super.getOrgi(request)); - if (!StringUtils.isBlank(agentUser.getAgentserviceid())) { + if (StringUtils.isNotBlank(agentUser.getAgentserviceid())) { AgentService agentService = agentServiceRepository.findByIdAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)); agentService.setStatus(MainContext.AgentUserStatusEnum.END.toString()); agentServiceRepository.save(agentService); @@ -655,7 +659,7 @@ public class AgentController extends Handler { blackListRes.save(tempBlackEntiry); blackEntity = tempBlackEntiry; } - if (!StringUtils.isBlank(userid)) { + if (StringUtils.isNotBlank(userid)) { CacheHelper.getSystemCacheBean().put(userid, blackEntity, super.getOrgi(request)); } } @@ -681,58 +685,58 @@ public class AgentController extends Handler { @RequestMapping("/image/upload") @Menu(type = "im", subtype = "image", access = false) - public ModelAndView upload(ModelMap map, HttpServletRequest request, @RequestParam(value = "imgFile", required = false) MultipartFile imgFile, @Valid String id, @Valid String paste) throws IOException { + public ModelAndView upload(ModelMap map, + HttpServletRequest request, + @RequestParam(value = "imgFile", required = false) MultipartFile multipart, + @Valid String id, + @Valid String paste) throws IOException { ModelAndView view = request(super.createRequestPageTempletResponse("/apps/agent/upload")); - UploadStatus upload = null; - String fileName = null; - if (imgFile != null && imgFile.getOriginalFilename().lastIndexOf(".") > 0) { + UploadStatus notify = null; + if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0) { File uploadDir = new File(path, "upload"); if (!uploadDir.exists()) { uploadDir.mkdirs(); } - String fileid = MainUtils.md5(imgFile.getBytes()), fileURL = null, targetFile = null; + String fileid = MainUtils.getUUID(); + String fileURL = null; ChatMessage data = new ChatMessage(); - if (imgFile.getContentType() != null && imgFile.getContentType().indexOf("image") >= 0) { - fileName = "upload/" + fileid + "_original"; - File imageFile = new File(path, fileName); - FileCopyUtils.copy(imgFile.getBytes(), imageFile); - targetFile = "upload/" + fileid; - MainUtils.processImage(new File(path, targetFile), imageFile); + StreamingFile sf = new StreamingFile(); - - fileURL = "/res/image.html?id=" + targetFile; - if (request.getServerPort() == 80) { - fileURL = "/res/image.html?id=" + targetFile; - } else { - fileURL = "/res/image.html?id=" + targetFile; - } - upload = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回 - data.setAttachmentid(fileid); + if (multipart.getContentType() != null && multipart.getContentType().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) { + // process thumbnail + File original = new File(path, "upload/" + fileid + "_original"); + File thumbnail = new File(path, "upload/" + fileid); + FileCopyUtils.copy(multipart.getBytes(), original); + MainUtils.processImage(thumbnail, original); + sf.setThumbnail(jpaBlobHelper.createBlobWithFile(thumbnail)); + fileURL = "/res/image.html?id=" + fileid; } else { - String attachid = processAttachmentFile(imgFile, request); - - upload = new UploadStatus("0", "/res/file.html?id=" + attachid); + String attachid = processAttachmentFile(multipart, fileid, request); fileURL = "/res/file.html?id=" + attachid; - if (request.getServerPort() == 80) { - fileURL = "/res/file.html?id=" + attachid; - } else { - fileURL = "/res/file.html?id=" + attachid; - } } - data.setFilename(imgFile.getOriginalFilename()); - data.setFilesize((int) imgFile.getSize()); - OutMessageRouter router = null; + sf.setId(fileid); + sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize())); + sf.setName(multipart.getOriginalFilename()); + sf.setMime(multipart.getContentType()); + streamingFileRepository.save(sf); + + data.setFilename(multipart.getOriginalFilename()); + data.setFilesize((int) multipart.getSize()); + data.setAttachmentid(fileid); + + notify = new UploadStatus("0", fileURL); + AgentUser agentUser = agentUserRepository.findByIdAndOrgi(id, super.getOrgi(request)); - if (agentUser != null && paste == null) { - router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()); + if (agentUser != null && paste == null) { // 发送消息 + OutMessageRouter router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()); MessageOutContent outMessage = new MessageOutContent(); - if (router != null) { + if (router != null) { // 发送消息给访客 outMessage.setMessage(fileURL); - outMessage.setFilename(imgFile.getOriginalFilename()); - outMessage.setFilesize((int) imgFile.getSize()); - if (imgFile.getContentType() != null && imgFile.getContentType().indexOf("image") >= 0) { + outMessage.setFilename(multipart.getOriginalFilename()); + outMessage.setFilesize((int) multipart.getSize()); + if (multipart.getContentType() != null && multipart.getContentType().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) { outMessage.setMessageType(MainContext.MediaTypeEnum.IMAGE.toString()); data.setMsgtype(MainContext.MediaTypeEnum.IMAGE.toString()); } else { @@ -753,7 +757,7 @@ public class AgentController extends Handler { data.setAgentserviceid(agentUser.getAgentserviceid()); data.setCalltype(MainContext.CallTypeEnum.OUT.toString()); - if (!StringUtils.isBlank(agentUser.getAgentno())) { + if (StringUtils.isNotBlank(agentUser.getAgentno())) { data.setTouser(agentUser.getUserid()); } data.setChannel(agentUser.getChannel()); @@ -771,11 +775,10 @@ public class AgentController extends Handler { // 通知文件上传消息 NettyClients.getInstance().publishAgentEventMessage(agentUser.getAgentno(), MainContext.MessageTypeEnum.MESSAGE.toString(), data); } - } else { - upload = new UploadStatus("请选择图片文件"); + notify = new UploadStatus("请选择图片文件"); } - map.addAttribute("upload", upload); + map.addAttribute("upload", notify); return view; } @@ -785,7 +788,7 @@ public class AgentController extends Handler { ChatMessage message = chatMessageRepository.findById(id); map.addAttribute("chatMessage", message); map.addAttribute("agentUser", CacheHelper.getAgentUserCacheBean().getCacheObject(message.getUserid(), message.getOrgi())); - /*if(!StringUtils.isBlank(t)){ + /*if(StringUtils.isNotBlank(t)){ map.addAttribute("t", t) ; }*/ map.addAttribute("t", true); @@ -794,22 +797,37 @@ public class AgentController extends Handler { @RequestMapping("/message/image/upload") @Menu(type = "im", subtype = "image", access = false) - public ModelAndView messageimage(ModelMap map, HttpServletRequest request, @RequestParam(value = "image", required = false) MultipartFile image, @Valid String id, @Valid String userid, @Valid String fileid) throws IOException { - if (image != null && !StringUtils.isBlank(fileid)) { + public ModelAndView messageimage(ModelMap map, + HttpServletRequest request, + @RequestParam(value = "image", required = false) MultipartFile image, + @Valid String id, + @Valid String userid, + @Valid String fileid) throws IOException { + logger.info("messageimage id {}, fileid {}", id, fileid); + if (image != null && StringUtils.isNotBlank(fileid)) { File tempFile = File.createTempFile(fileid, ".png"); try { - String fileName = "upload/" + fileid + "_cooperation"; - File imageFile = new File(path, fileName); + // 创建临时图片文件 if (!tempFile.getParentFile().exists()) { tempFile.getParentFile().mkdirs(); } + // 写入临时文件 FileCopyUtils.copy(image.getBytes(), tempFile); ChatMessage chatMessage = chatMessageRepository.findById(id); chatMessage.setCooperation(true); chatMessageRepository.save(chatMessage); + // 写入协作文件 + String fileName = "upload/" + fileid + "_cooperation"; + File imageFile = new File(path, fileName); MainUtils.scaleImage(imageFile, tempFile, 0.1F); + // 保存到数据库 + StreamingFile sf = streamingFileRepository.findOne(fileid); + if (sf != null) { + sf.setCooperation(jpaBlobHelper.createBlobWithFile(imageFile)); + streamingFileRepository.save(sf); + } OutMessageRouter router = null; AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(chatMessage.getUserid(), chatMessage.getOrgi()); @@ -818,7 +836,7 @@ public class AgentController extends Handler { router = (OutMessageRouter) MainContext.getContext().getBean(agentUser.getChannel()); MessageOutContent outMessage = new MessageOutContent(); if (router != null) { - outMessage.setMessage("/res/image.html?id=" + fileName); + outMessage.setMessage("/res/image.html?id=" + fileid + "&cooperation=true"); outMessage.setFilename(imageFile.getName()); outMessage.setAttachmentid(chatMessage.getAttachmentid()); @@ -841,36 +859,33 @@ public class AgentController extends Handler { return request(super.createRequestPageTempletResponse("/public/success")); } - private String processAttachmentFile(MultipartFile file, HttpServletRequest request) throws IOException { + private String processAttachmentFile(final MultipartFile multipart, final String fileid, HttpServletRequest request) throws IOException { String id = null; - if (file.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制 - String fileid = MainUtils.md5(file.getBytes()); //使用 文件的 MD5作为 ID,避免重复上传大文件 - if (StringUtils.isNotBlank(fileid)) { - AttachmentFile attachmentFile = new AttachmentFile(); - attachmentFile.setCreater(super.getUser(request).getId()); - attachmentFile.setOrgi(super.getOrgi(request)); - attachmentFile.setOrgan(super.getUser(request).getOrgan()); - attachmentFile.setModel(MainContext.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.isNotBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) { - attachmentFile.setImage(true); - } - attachmentFile.setFileid(fileid); - attachementRes.save(attachmentFile); - FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), file.getBytes()); - id = attachmentFile.getId(); + if (multipart.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制 + AttachmentFile attachmentFile = new AttachmentFile(); + attachmentFile.setCreater(super.getUser(request).getId()); + attachmentFile.setOrgi(super.getOrgi(request)); + attachmentFile.setOrgan(super.getUser(request).getOrgan()); + attachmentFile.setModel(MainContext.ModelType.WEBIM.toString()); + attachmentFile.setFilelength((int) multipart.getSize()); + if (multipart.getContentType() != null && multipart.getContentType().length() > 255) { + attachmentFile.setFiletype(multipart.getContentType().substring(0, 255)); + } else { + attachmentFile.setFiletype(multipart.getContentType()); } + File uploadFile = new File(multipart.getOriginalFilename()); + if (uploadFile.getName() != null && uploadFile.getName().length() > 255) { + attachmentFile.setTitle(uploadFile.getName().substring(0, 255)); + } else { + attachmentFile.setTitle(uploadFile.getName()); + } + if (StringUtils.isNotBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) { + attachmentFile.setImage(true); + } + attachmentFile.setFileid(fileid); + attachementRes.save(attachmentFile); + FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), multipart.getBytes()); + id = attachmentFile.getId(); } return id; } @@ -879,7 +894,7 @@ public class AgentController extends Handler { @RequestMapping(value = "/contacts") @Menu(type = "apps", subtype = "contacts") public ModelAndView contacts(ModelMap map, HttpServletRequest request, @Valid String contactsid, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid) { - if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(contactsid)) { + if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(contactsid)) { List onlineUserList = this.onlineUserRes.findByUseridAndOrgi(userid, super.getOrgi(request)); if (onlineUserList.size() > 0) { OnlineUser onlineUser = onlineUserList.get(0); @@ -925,9 +940,9 @@ public class AgentController extends Handler { @Valid String agentserviceid, @Valid String agentuserid, @Valid String channel) { - if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)) { + if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) { AgentUser agentUser = this.agentUserRepository.findByIdAndOrgi(agentuserid, super.getOrgi(request)); - if (agentUser != null && !StringUtils.isBlank(agentUser.getAgentserviceid())) { + if (agentUser != null && StringUtils.isNotBlank(agentUser.getAgentserviceid())) { List summaries = this.serviceSummaryRes.findByAgentserviceidAndOrgi(agentUser.getAgentserviceid(), super.getOrgi(request)); if (summaries.size() > 0) { map.addAttribute("summary", summaries.get(0)); @@ -955,7 +970,7 @@ public class AgentController extends Handler { @Valid String agentserviceid, @Valid String agentuserid, @Valid String channel) { - if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)) { + if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) { summary.setOrgi(super.getOrgi(request)); summary.setCreater(super.getUser(request).getId()); @@ -981,7 +996,7 @@ public class AgentController extends Handler { @RequestMapping(value = "/transfer") @Menu(type = "apps", subtype = "transfer") public ModelAndView transfer(ModelMap map, HttpServletRequest request, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid) { - if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid)) { + if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid)) { //map.addAttribute("organList", organRes.findByOrgiAndOrgid(super.getOrgi(request),super.getOrgid(request))) ; List skillList = OnlineUserUtils.organ(super.getOrgi(request), true); @@ -1022,7 +1037,7 @@ public class AgentController extends Handler { @RequestMapping(value = "/transfer/agent") @Menu(type = "apps", subtype = "transferagent") public ModelAndView transferagent(ModelMap map, HttpServletRequest request, @Valid String organ) { - if (!StringUtils.isBlank(organ)) { + if (StringUtils.isNotBlank(organ)) { List usersids = new ArrayList(); List agentStatusList = AutomaticServiceDist.getAgentStatus(organ, super.getOrgi(request)); if (!agentStatusList.isEmpty()) { @@ -1047,7 +1062,7 @@ public class AgentController extends Handler { @RequestMapping(value = "/transfer/save") @Menu(type = "apps", subtype = "transfersave") public ModelAndView transfersave(ModelMap map, HttpServletRequest request, @Valid String userid, @Valid String agentserviceid, @Valid String agentuserid, @Valid String agentno, @Valid String memo) { - if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(agentuserid) && !StringUtils.isBlank(agentno)) { + if (StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(agentuserid) && StringUtils.isNotBlank(agentno)) { AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(userid, super.getOrgi(request)); AgentService agentService = this.agentServiceRepository.findByIdAndOrgi(agentserviceid, super.getOrgi(request)); if (agentUser != null) { @@ -1081,7 +1096,7 @@ public class AgentController extends Handler { if (agentService != null) { agentService.setAgentno(agentno); - if (!StringUtils.isBlank(memo)) { + if (StringUtils.isNotBlank(memo)) { agentService.setTransmemo(memo); } agentService.setTrans(true); @@ -1103,7 +1118,7 @@ public class AgentController extends Handler { quickTypeList.addAll(priQuickTypeList); map.addAttribute("pubQuickTypeList", quickTypeList); - if (!StringUtils.isBlank(typeid)) { + if (StringUtils.isNotBlank(typeid)) { map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))); } @@ -1114,7 +1129,7 @@ public class AgentController extends Handler { @RequestMapping("/quickreply/add") @Menu(type = "setting", subtype = "quickreplyadd", admin = true) public ModelAndView quickreplyadd(ModelMap map, HttpServletRequest request, @Valid String parentid) { - if (!StringUtils.isBlank(parentid)) { + if (StringUtils.isNotBlank(parentid)) { map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(parentid, super.getOrgi(request))); } map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId())); @@ -1124,7 +1139,7 @@ public class AgentController extends Handler { @RequestMapping("/quickreply/save") @Menu(type = "setting", subtype = "quickreply", admin = true) public ModelAndView quickreplysave(ModelMap map, HttpServletRequest request, @Valid QuickReply quickReply) { - if (!StringUtils.isBlank(quickReply.getTitle()) && !StringUtils.isBlank(quickReply.getContent())) { + if (StringUtils.isNotBlank(quickReply.getTitle()) && StringUtils.isNotBlank(quickReply.getContent())) { quickReply.setOrgi(super.getOrgi(request)); quickReply.setCreater(super.getUser(request).getId()); quickReply.setType(MainContext.QuickTypeEnum.PRI.toString()); @@ -1158,7 +1173,7 @@ public class AgentController extends Handler { @RequestMapping("/quickreply/update") @Menu(type = "setting", subtype = "quickreply", admin = true) public ModelAndView quickreplyupdate(ModelMap map, HttpServletRequest request, @Valid QuickReply quickReply) { - if (!StringUtils.isBlank(quickReply.getId())) { + if (StringUtils.isNotBlank(quickReply.getId())) { QuickReply temp = quickReplyRes.findOne(quickReply.getId()); quickReply.setOrgi(super.getOrgi(request)); quickReply.setCreater(super.getUser(request).getId()); @@ -1175,7 +1190,7 @@ public class AgentController extends Handler { @Menu(type = "apps", subtype = "kbs") public ModelAndView addtype(ModelMap map, HttpServletRequest request, @Valid String typeid) { map.addAttribute("quickTypeList", quickTypeRes.findByOrgiAndQuicktypeAndCreater(super.getOrgi(request), MainContext.QuickTypeEnum.PRI.toString(), super.getUser(request).getId())); - if (!StringUtils.isBlank(typeid)) { + if (StringUtils.isNotBlank(typeid)) { map.addAttribute("quickType", quickTypeRes.findByIdAndOrgi(typeid, super.getOrgi(request))); } return request(super.createRequestPageTempletResponse("/apps/agent/quickreply/addtype")); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java index 43137770..ea22db1e 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/internet/IMController.java @@ -24,6 +24,7 @@ import com.chatopera.cc.app.cache.CacheHelper; import com.chatopera.cc.app.handler.Handler; import com.chatopera.cc.app.im.util.RichMediaUtils; import com.chatopera.cc.app.model.*; +import com.chatopera.cc.app.persistence.blob.JpaBlobHelper; import com.chatopera.cc.app.persistence.es.ContactsRepository; import com.chatopera.cc.app.persistence.repository.*; import com.chatopera.cc.util.*; @@ -78,6 +79,12 @@ public class IMController extends Handler { @Value("${web.upload-path}") private String path; + @Autowired + private StreamingFileRepository streamingFileRepository; + + @Autowired + private JpaBlobHelper jpaBlobHelper; + @Autowired private ConsultInviteRepository inviteRepository; @@ -707,62 +714,76 @@ public class IMController extends Handler { @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 { + public ModelAndView upload(ModelMap map, HttpServletRequest request, + @RequestParam(value = "imgFile", required = false) MultipartFile multipart, + @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 + if (multipart != null + && multipart.getOriginalFilename().lastIndexOf(".") > 0 && StringUtils.isNotBlank(userid)) { File uploadDir = new File(path, "upload"); if (!uploadDir.exists()) { uploadDir.mkdirs(); } - String fileid = MainUtils.md5(imgFile.getBytes()); - if (imgFile.getContentType() != null - && imgFile.getContentType().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) { + + String fileid = MainUtils.getUUID(); + StreamingFile sf = new StreamingFile(); + sf.setId(fileid); + sf.setName(multipart.getOriginalFilename()); + sf.setMime(multipart.getContentType()); + if (multipart.getContentType() != null + && multipart.getContentType().indexOf(Constants.ATTACHMENT_TYPE_IMAGE) >= 0) { // 检查文件格式 - String invalid = AttachementFormatValidator.getInstance().validate(Constants.ATTACHMENT_TYPE_IMAGE, imgFile.getOriginalFilename()); + String invalid = StreamingFileUtils.getInstance().validate(Constants.ATTACHMENT_TYPE_IMAGE, multipart.getOriginalFilename()); if (invalid == null) { fileName = "upload/" + fileid + "_original"; File imageFile = new File(path, fileName); - FileCopyUtils.copy(imgFile.getBytes(), imageFile); + FileCopyUtils.copy(multipart.getBytes(), imageFile); String thumbnailsFileName = "upload/" + fileid; - MainUtils.processImage(new File(path, thumbnailsFileName), imageFile); + File thumbnail = new File(path, thumbnailsFileName); + MainUtils.processImage(thumbnail, imageFile); + + // 存储数据库 + sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize())); + sf.setThumbnail(jpaBlobHelper.createBlobWithFile(thumbnail)); + streamingFileRepository.save(sf); + String fileUrl = "/res/image.html?id=" + fileid; + upload = new UploadStatus("0", fileUrl); - 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.isNotBlank(channel)) { - RichMediaUtils.uploadImageWithChannel(image, fileid, (int) imgFile.getSize(), imgFile.getName(), channel, userid, username, appid, orgi); + RichMediaUtils.uploadImageWithChannel(fileUrl, fileid, (int) multipart.getSize(), multipart.getName(), channel, userid, username, appid, orgi); } else { - RichMediaUtils.uploadImage(image, fileid, (int) imgFile.getSize(), imgFile.getName(), userid); + RichMediaUtils.uploadImage(fileUrl, fileid, (int) multipart.getSize(), multipart.getName(), userid); } } } else { upload = new UploadStatus(invalid); } } else { - String invalid = AttachementFormatValidator.getInstance().validate(Constants.ATTACHMENT_TYPE_FILE, imgFile.getOriginalFilename()); + String invalid = StreamingFileUtils.getInstance().validate(Constants.ATTACHMENT_TYPE_FILE, multipart.getOriginalFilename()); if (invalid == null) { - String id = processAttachmentFile(imgFile, request); + // 存储数据库 + sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize())); + streamingFileRepository.save(sf); + + // 存储到本地硬盘 + String id = processAttachmentFile(multipart, fileid, 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()); + + File tempFile = new File(multipart.getOriginalFilename()); if (StringUtils.isNotBlank(channel)) { - RichMediaUtils.uploadFileWithChannel(file, (int) imgFile.getSize(), tempFile.getName(), channel, userid, username, appid, orgi, id); + RichMediaUtils.uploadFileWithChannel(file, (int) multipart.getSize(), tempFile.getName(), channel, userid, username, appid, orgi, id); } else { - RichMediaUtils.uploadFile(file, (int) imgFile.getSize(), tempFile.getName(), userid, id); + RichMediaUtils.uploadFile(file, (int) multipart.getSize(), tempFile.getName(), userid, id); } } else { upload = new UploadStatus(invalid); @@ -775,36 +796,33 @@ public class IMController extends Handler { return view; } - private String processAttachmentFile(MultipartFile file, HttpServletRequest request) throws IOException { + private String processAttachmentFile(final MultipartFile file, final String fileid, HttpServletRequest request) throws IOException { String id = null; if (file.getSize() > 0) { //文件尺寸 限制 ?在 启动 配置中 设置 的最大值,其他地方不做限制 - String fileid = MainUtils.md5(file.getBytes()); //使用 文件的 MD5作为 ID,避免重复上传大文件 - if (StringUtils.isNotBlank(fileid)) { - AttachmentFile attachmentFile = new AttachmentFile(); - attachmentFile.setCreater(super.getUser(request).getId()); - attachmentFile.setOrgi(super.getOrgi(request)); - attachmentFile.setOrgan(super.getUser(request).getOrgan()); - attachmentFile.setModel(MainContext.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.isNotBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) { - attachmentFile.setImage(true); - } - attachmentFile.setFileid(fileid); - attachementRes.save(attachmentFile); - FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), file.getBytes()); - id = attachmentFile.getId(); + AttachmentFile attachmentFile = new AttachmentFile(); + attachmentFile.setCreater(super.getUser(request).getId()); + attachmentFile.setOrgi(super.getOrgi(request)); + attachmentFile.setOrgan(super.getUser(request).getOrgan()); + attachmentFile.setModel(MainContext.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.isNotBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) { + attachmentFile.setImage(true); + } + attachmentFile.setFileid(fileid); + attachementRes.save(attachmentFile); + FileUtils.writeByteArrayToFile(new File(path, "upload/" + fileid), file.getBytes()); + id = attachmentFile.getId(); } return id; } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java index 020f5802..b08c2de2 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java @@ -16,42 +16,53 @@ */ package com.chatopera.cc.app.handler.resource; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; - +import com.chatopera.cc.app.basic.MainUtils; +import com.chatopera.cc.app.handler.Handler; +import com.chatopera.cc.app.model.AttachmentFile; +import com.chatopera.cc.app.model.StreamingFile; +import com.chatopera.cc.app.model.UploadStatus; +import com.chatopera.cc.app.persistence.blob.JpaBlobHelper; +import com.chatopera.cc.app.persistence.repository.AttachmentRepository; +import com.chatopera.cc.app.persistence.repository.StreamingFileRepository; +import com.chatopera.cc.util.Menu; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.tomcat.util.http.fileupload.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; -import com.chatopera.cc.util.Menu; -import com.chatopera.cc.app.basic.MainUtils; -import com.chatopera.cc.app.persistence.repository.AttachmentRepository; -import com.chatopera.cc.app.handler.Handler; -import com.chatopera.cc.app.model.AttachmentFile; -import com.chatopera.cc.app.model.UploadStatus; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.sql.SQLException; @Controller @RequestMapping("/res") public class MediaController extends Handler { + private final static Logger logger = LoggerFactory.getLogger(MediaController.class); @Value("${web.upload-path}") private String path; + @Autowired + private StreamingFileRepository streamingFileRepository; + + @Autowired + private JpaBlobHelper jpaBlobHelper; + private String TEMPLATE_DATA_PATH = "WEB-INF/data/templates/"; @Autowired @@ -59,32 +70,25 @@ public class MediaController extends Handler { @RequestMapping("/image") @Menu(type = "resouce", subtype = "image", access = true) - public void index(HttpServletResponse response, @Valid String id) throws IOException { - File file = new File(path, id); - if (!StringUtils.isBlank(id) && !(id.endsWith(".png") || id.endsWith(".jpg"))) { - if (id.endsWith("_original") && !file.exists()) { - File orgFile = new File(path, id.substring(0, id.indexOf("_original"))); - if (orgFile.exists()) { - MainUtils.processImage(file = new File(path, id), orgFile); - } - } else if (!StringUtils.isBlank(id) && file.exists() && !id.endsWith("_original")) { - File originalFile = new File(path, id + "_original"); - if (!originalFile.exists()) { - MainUtils.processImage(new File(path, id + "_original"), file); - } - } else if (!StringUtils.isBlank(id) && !file.exists() && !id.endsWith("_original")) { - File destFile = new File(path, id + "_original"); - if (destFile.exists()) { - MainUtils.processImage(new File(path + id), destFile); - } - file = new File(path, id); + public void index(HttpServletResponse response, + @Valid String id, + @RequestParam(value = "original", required = false) boolean original, + @RequestParam(value = "cooperation", required = false) boolean cooperation) throws IOException, SQLException { + logger.info("index id {}, original {}, cooperation {}", id, original, cooperation); + StreamingFile sf = streamingFileRepository.findOne(id); + if (sf != null) { + response.setHeader("Content-Type", sf.getMime()); + response.setContentType(sf.getMime()); + if (cooperation && (sf.getCooperation() != null)) { // 协作文件 + IOUtils.copy(sf.getCooperation().getBinaryStream(), response.getOutputStream()); + } else if (original && sf.getData() != null) { // 源文件 + IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream()); + } else if (sf.getThumbnail() != null) { // 缩略图 + IOUtils.copy(sf.getThumbnail().getBinaryStream(), response.getOutputStream()); + } else { + logger.warn("[index] can not get streaming file id {}, original {}, cooperation {}", id, original, cooperation); } } - if (file.exists() && file.isFile()) { - response.setHeader("Content-Type", "image/png"); - response.setContentType("image/png"); - response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, id))); - } } @RequestMapping("/voice") @@ -102,7 +106,7 @@ public class MediaController extends Handler { byte[] data = new byte[1024]; int length = 0; OutputStream out = response.getOutputStream(); - if (!StringUtils.isBlank(url)) { + if (StringUtils.isNotBlank(url)) { InputStream input = new URL(url).openStream(); while ((length = input.read(data)) > 0) { out.write(data, 0, length); @@ -113,44 +117,43 @@ public class MediaController extends Handler { @RequestMapping("/image/upload") @Menu(type = "resouce", subtype = "imageupload", access = false) - public ModelAndView upload(ModelMap map, HttpServletRequest request, @RequestParam(value = "imgFile", required = false) MultipartFile imgFile) throws IOException { + public ModelAndView upload(ModelMap map, + HttpServletRequest request, + @RequestParam(value = "imgFile", required = false) MultipartFile multipart) throws IOException { ModelAndView view = request(super.createRequestPageTempletResponse("/public/upload")); - UploadStatus upload = null; - String fileName = null; - if (imgFile != null && imgFile.getOriginalFilename().lastIndexOf(".") > 0) { + UploadStatus notify = null; + if (multipart != null && multipart.getOriginalFilename().lastIndexOf(".") > 0) { File uploadDir = new File(path, "upload"); if (!uploadDir.exists()) { uploadDir.mkdirs(); } - fileName = "upload/" + MainUtils.md5(imgFile.getBytes()) + imgFile.getOriginalFilename().substring(imgFile.getOriginalFilename().lastIndexOf(".")).toLowerCase(); - FileCopyUtils.copy(imgFile.getBytes(), new File(path, fileName)); - - String fileURL = request.getScheme() + "://" + request.getServerName() + "/res/image.html?id=" + fileName; - if (request.getServerPort() == 80) { - fileURL = request.getScheme() + "://" + request.getServerName() + "/res/image.html?id=" + fileName; - } else { - fileURL = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/res/image.html?id=" + fileName; - } - upload = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回 + String fileid = MainUtils.getUUID(); + StreamingFile sf = new StreamingFile(); + sf.setId(fileid); + sf.setName(multipart.getOriginalFilename()); + sf.setMime(multipart.getContentType()); + sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize())); + streamingFileRepository.save(sf); + String fileURL = "/res/image.html?id=" + fileid; + notify = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回 } else { - upload = new UploadStatus("请选择图片文件"); + notify = new UploadStatus("请选择图片文件"); } - map.addAttribute("upload", upload); + map.addAttribute("upload", notify); return view; } @RequestMapping("/file") @Menu(type = "resouce", subtype = "file", access = false) - public void file(HttpServletResponse response, HttpServletRequest request, @Valid String id) throws IOException { - if (!StringUtils.isBlank(id)) { + public void file(HttpServletResponse response, HttpServletRequest request, @Valid String id) throws IOException, SQLException { + if (StringUtils.isNotBlank(id)) { AttachmentFile attachmentFile = attachementRes.findByIdAndOrgi(id, super.getOrgi(request)); - if (attachmentFile != null) { - response.setContentType(attachmentFile.getFiletype()); - response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8")); - if (StringUtils.isNotBlank(attachmentFile.getModel()) && attachmentFile.getModel().equals("app")) { - response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, "app/" + attachmentFile.getFileid()))); - } else { - response.getOutputStream().write(FileUtils.readFileToByteArray(new File(path, "upload/" + attachmentFile.getFileid()))); + if (attachmentFile != null && attachmentFile.getFileid() != null) { + StreamingFile sf = streamingFileRepository.findOne(attachmentFile.getFileid()); + if (sf != null) { + response.setContentType(attachmentFile.getFiletype()); + response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8")); + IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream()); } } } @@ -159,7 +162,7 @@ public class MediaController extends Handler { @RequestMapping("/template") @Menu(type = "resouce", subtype = "template", access = false) public void template(HttpServletResponse response, HttpServletRequest request, @Valid String filename) throws IOException { - if (!StringUtils.isBlank(filename)) { + if (StringUtils.isNotBlank(filename)) { InputStream is = MediaController.class.getClassLoader().getResourceAsStream(TEMPLATE_DATA_PATH + filename); if (is != null) { response.setContentType("text/plain"); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/model/StreamingFile.java b/contact-center/app/src/main/java/com/chatopera/cc/app/model/StreamingFile.java new file mode 100644 index 00000000..2d2cc041 --- /dev/null +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/model/StreamingFile.java @@ -0,0 +1,98 @@ +/* + * 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.model; + +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Proxy; + +import java.sql.Blob; +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +@Entity +@Table(name = "cs_stream_file") +@Proxy(lazy = false) +public class StreamingFile implements java.io.Serializable { + + private String id; + + @NotNull + private String name; + + private String mime; // Media Type over HTTP + + @NotNull + private Blob data; + + private Blob thumbnail; // 图片缩略图 + + private Blob cooperation; // 图片协作图 + + @Id + @Column(length = 32) + @GeneratedValue(generator = "system-uuid") + @GenericGenerator(name = "system-uuid", strategy = "assigned") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @NotNull + public String getName() { + return name; + } + + public void setName(@NotNull String name) { + this.name = name; + } + + @NotNull + public Blob getData() { + return data; + } + + public void setData(@NotNull Blob data) { + this.data = data; + } + + public Blob getThumbnail() { + return thumbnail; + } + + public void setThumbnail(Blob thumbnail) { + this.thumbnail = thumbnail; + } + + public String getMime() { + return mime; + } + + public void setMime(String mime) { + this.mime = mime; + } + + public Blob getCooperation() { + return cooperation; + } + + public void setCooperation(Blob cooperation) { + this.cooperation = cooperation; + } +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/blob/JpaBlobHelper.java b/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/blob/JpaBlobHelper.java new file mode 100644 index 00000000..36b23d17 --- /dev/null +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/blob/JpaBlobHelper.java @@ -0,0 +1,55 @@ +/* + * 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.persistence.blob; + +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.springframework.transaction.annotation.Transactional; + +import javax.persistence.EntityManagerFactory; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.sql.Blob; + +@Component +@Transactional +public class JpaBlobHelper { + + private final SessionFactory sessionFactory; + + @Autowired + public JpaBlobHelper(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + + public Blob createBlob(InputStream content, long size) { + return sessionFactory.getCurrentSession().getLobHelper().createBlob(content, size); + } + + public Blob createBlobWithFile(final File file) throws FileNotFoundException { + return createBlob(new FileInputStream(file), file.length()); + } + +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/StreamingFileRepository.java b/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/StreamingFileRepository.java new file mode 100644 index 00000000..78fe576c --- /dev/null +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/StreamingFileRepository.java @@ -0,0 +1,23 @@ +/* + * 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.persistence.repository; + +import com.chatopera.cc.app.model.StreamingFile; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface StreamingFileRepository extends JpaRepository { +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/AttachementFormatValidator.java b/contact-center/app/src/main/java/com/chatopera/cc/util/StreamingFileUtils.java similarity index 87% rename from contact-center/app/src/main/java/com/chatopera/cc/util/AttachementFormatValidator.java rename to contact-center/app/src/main/java/com/chatopera/cc/util/StreamingFileUtils.java index df5cd4a5..35a9ae99 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/AttachementFormatValidator.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/StreamingFileUtils.java @@ -19,20 +19,20 @@ package com.chatopera.cc.util; import java.util.Arrays; import java.util.HashMap; -public class AttachementFormatValidator { +public class StreamingFileUtils { - private static AttachementFormatValidator singleton = new AttachementFormatValidator(); + private static StreamingFileUtils singleton = new StreamingFileUtils(); private final HashMap extMap = new HashMap(); - private AttachementFormatValidator() { + private StreamingFileUtils() { extMap.put(Constants.ATTACHMENT_TYPE_IMAGE, "gif,jpg,jpeg,png,bmp"); extMap.put(Constants.ATTACHMENT_TYPE_FILE, "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2,c66"); extMap.put("flash", "swf,flv"); extMap.put("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb"); } - public static AttachementFormatValidator getInstance() { + public static StreamingFileUtils getInstance() { return singleton; } @@ -49,4 +49,5 @@ public class AttachementFormatValidator { } return null; } + } diff --git a/contact-center/app/src/main/resources/application.properties b/contact-center/app/src/main/resources/application.properties index 248feb69..092f7646 100644 --- a/contact-center/app/src/main/resources/application.properties +++ b/contact-center/app/src/main/resources/application.properties @@ -31,11 +31,6 @@ server.log.path=../logs server.log.level=INFO web.upload-path=../data -# multi part -spring.servlet.multipart.enabled=true -spring.servlet.multipart.max-file-size=20MB -spring.servlet.multipart.max-request-size=50MB - # IM Server uk.im.server.port=8036 uk.im.server.host=localhost @@ -153,4 +148,12 @@ cskefu.callout.watch.interval=60000 ############################################## storage.minio.url=http://192.168.2.217:9000 storage.minio.access_key=M19Q8YJ8FzLyQtST7r0 -storage.minio.secret_key=KHv6qjddHD4HfR1m7fjY7HglSO1WOSzIeTERRUUc \ No newline at end of file +storage.minio.secret_key=KHv6qjddHD4HfR1m7fjY7HglSO1WOSzIeTERRUUc + +# multi part +spring.servlet.multipart.enabled=true +spring.servlet.multipart.max-file-size=15MB +spring.servlet.multipart.max-request-size=15MB + +# MySQL Blob +spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext diff --git a/contact-center/app/src/main/resources/templates/apps/agent/media/messageimage.html b/contact-center/app/src/main/resources/templates/apps/agent/media/messageimage.html index 78506c11..d93225d4 100644 --- a/contact-center/app/src/main/resources/templates/apps/agent/media/messageimage.html +++ b/contact-center/app/src/main/resources/templates/apps/agent/media/messageimage.html @@ -35,7 +35,7 @@ //创建新的图片对象 var img = new Image(); //指定图片的URL - img.src = "/res/image.html?id=upload/${chatMessage.attachmentid!''}_cooperation"; + img.src = "/res/image.html?id=${chatMessage.attachmentid!''}&cooperation=true&original=true"; //浏览器加载图片完毕后再绘制图片 img.onload = function(){ //以Canvas画布上的坐标(10,10)为起始点,绘制图像 @@ -49,7 +49,7 @@
    - +
    你的浏览器不支持 canvas 绘图 diff --git a/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html b/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html index bf8a0786..75952ee4 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html +++ b/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html @@ -493,7 +493,7 @@ var chat=document.getElementsByClassName('chatting-left').innerText; chat = data.message; if(data.messageType == "image"){ - chat = "" ; + chat = "" ; }else if(data.messageType == "file"){ chat = "" ; } diff --git a/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html b/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html index 0a759547..2fcb6b5f 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html +++ b/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html @@ -302,7 +302,7 @@ var chat=document.getElementsByClassName('chatting-left').innerText; chat = data.message; if(data.messageType == "image"){ - chat = "" ; + chat = "" ; }else if(data.messageType == "cooperation"){ chat = "您收到一个协作邀请,点击进入协作" ; }else if(data.messageType == "action"){ @@ -324,7 +324,7 @@ } function acceptInvite(msgid,fileid){ document.getElementById("cooperation").style.display = "block" ; - document.getElementById("ukefu_img_ctx").src = "/res/image.html?id=upload/"+fileid ; + document.getElementById("ukefu_img_ctx").src = "/res/image.html?id="+fileid + "&cooperation=true&original=true"; $("#ukefu_img_ctx").load(function() { var height = document.getElementById("ukefu-image-content").offsetHeight; @@ -348,7 +348,7 @@ //创建新的图片对象 var img = new Image(); //指定图片的URL - img.src = "/res/image.html?id=upload/" + fileid + "_cooperation"; + img.src = "/res/image.html?id=" + fileid + "&cooperation=true&original=true"; //浏览器加载图片完毕后再绘制图片 img.onload = function() { ctx.clearRect(0,0,canvas.width,canvas.height); diff --git a/contact-center/app/src/main/resources/templates/apps/im/index.html b/contact-center/app/src/main/resources/templates/apps/im/index.html index cd1b0b11..ec5f2e52 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/index.html +++ b/contact-center/app/src/main/resources/templates/apps/im/index.html @@ -491,7 +491,7 @@ var chat=document.getElementsByClassName('chatting-left').innerText; chat = data.message; if(data.messageType == "image"){ - chat = "" ; + chat = "" ; }else if(data.messageType == "file"){ chat = "" ; } diff --git a/contact-center/app/src/main/resources/templates/apps/im/media/message.html b/contact-center/app/src/main/resources/templates/apps/im/media/message.html index 259fece2..688d62cc 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/media/message.html +++ b/contact-center/app/src/main/resources/templates/apps/im/media/message.html @@ -1,5 +1,5 @@ <#if chatMessage.msgtype?? && chatMessage.msgtype == "image"> - + <#elseif chatMessage.msgtype?? && chatMessage.msgtype == "cooperation"> 您收到一个协作邀请,点击进入协作 <#elseif chatMessage.msgtype?? && chatMessage.msgtype == "file"> diff --git a/contact-center/app/src/main/resources/templates/apps/im/mobile.html b/contact-center/app/src/main/resources/templates/apps/im/mobile.html index 12efd967..e0496030 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/mobile.html +++ b/contact-center/app/src/main/resources/templates/apps/im/mobile.html @@ -300,7 +300,7 @@ var chat=document.getElementsByClassName('chatting-left').innerText; chat = data.message; if(data.messageType == "image"){ - chat = "" ; + chat = "" ; }else if(data.messageType == "cooperation"){ chat = "您收到一个协作邀请,点击进入协作" ; }else if(data.messageType == "action"){ @@ -322,7 +322,7 @@ } function acceptInvite(msgid,fileid){ document.getElementById("cooperation").style.display = "block" ; - document.getElementById("ukefu_img_ctx").src = "/res/image.html?id=upload/"+fileid ; + document.getElementById("ukefu_img_ctx").src = "/res/image.html?id="+fileid + "&cooperation=true&original=true"; $("#ukefu_img_ctx").load(function() { var height = document.getElementById("ukefu-image-content").offsetHeight; @@ -346,7 +346,7 @@ //创建新的图片对象 var img = new Image(); //指定图片的URL - img.src = "/res/image.html?id=upload/" + fileid + "_cooperation"; + img.src = "/res/image.html?id=" + fileid + "&cooperation=true&original=true"; //浏览器加载图片完毕后再绘制图片 img.onload = function() { ctx.clearRect(0,0,canvas.width,canvas.height); From ccfbe7427b82d1bd84388495eefc83b63cf81073 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 24 Oct 2018 18:19:16 +0800 Subject: [PATCH 43/54] =?UTF-8?q?#116=20=E5=A2=9E=E5=8A=A0mysql=E8=A1=A8?= =?UTF-8?q?=E7=94=A8=E6=9D=A5=E5=AD=98=E5=82=A8=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contact-center/config/sql/cskefu-MySQL-slim.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/contact-center/config/sql/cskefu-MySQL-slim.sql b/contact-center/config/sql/cskefu-MySQL-slim.sql index 4ecc63b4..134f7cee 100644 --- a/contact-center/config/sql/cskefu-MySQL-slim.sql +++ b/contact-center/config/sql/cskefu-MySQL-slim.sql @@ -437,6 +437,19 @@ CREATE TABLE `cs_callout_targets` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='外呼计划目标客户'; +-- ---------------------------- +-- Table structure for cs_stream_file +-- ---------------------------- +DROP TABLE IF EXISTS `cs_stream_file`; +CREATE TABLE `cs_stream_file` ( + `id` varchar(32) NOT NULL COMMENT '文件ID', + `name` varchar(300) NOT NULL COMMENT '文件名称', + `data` mediumblob NOT NULL COMMENT '原始文件', + `thumbnail` mediumblob COMMENT '缩略图', + `mime` varchar(200) DEFAULT NULL COMMENT '文件类型 Content Type', + `cooperation` mediumblob COMMENT '协作文件', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT '文件'; -- ---------------------------- -- Table structure for uk_ad_position From 39be3178ef300fc04992027856ed708677598acb Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 24 Oct 2018 19:51:19 +0800 Subject: [PATCH 44/54] =?UTF-8?q?Closed=20#119=20=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=94=9F=E6=97=A5=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatopera/cc/concurrent/chatbot/ChatbotEventProducer.java | 3 +++ .../main/java/com/chatopera/cc/util/StreamingFileUtils.java | 2 +- .../app/src/main/resources/templates/apps/agent/contacts.html | 2 +- .../resources/templates/apps/business/contacts/detail.html | 2 +- .../main/resources/templates/apps/business/customer/add.html | 4 ++-- .../resources/templates/apps/service/online/contacts.html | 4 ++-- .../resources/templates/apps/service/processed/process.html | 4 ++-- .../resources/templates/apps/service/summary/process.html | 4 ++-- 8 files changed, 14 insertions(+), 11 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/concurrent/chatbot/ChatbotEventProducer.java b/contact-center/app/src/main/java/com/chatopera/cc/concurrent/chatbot/ChatbotEventProducer.java index 5cc29ed4..bc993109 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/concurrent/chatbot/ChatbotEventProducer.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/concurrent/chatbot/ChatbotEventProducer.java @@ -17,9 +17,12 @@ package com.chatopera.cc.concurrent.chatbot; import com.chatopera.cc.concurrent.user.UserDataEvent; import com.lmax.disruptor.RingBuffer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings("rawtypes") public class ChatbotEventProducer { + private final static Logger logger = LoggerFactory.getLogger(ChatbotEventProducer.class); private final RingBuffer ringBuffer; public ChatbotEventProducer(RingBuffer ringBuffer) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/StreamingFileUtils.java b/contact-center/app/src/main/java/com/chatopera/cc/util/StreamingFileUtils.java index 35a9ae99..1fac8044 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/StreamingFileUtils.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/StreamingFileUtils.java @@ -27,7 +27,7 @@ public class StreamingFileUtils { private StreamingFileUtils() { extMap.put(Constants.ATTACHMENT_TYPE_IMAGE, "gif,jpg,jpeg,png,bmp"); - extMap.put(Constants.ATTACHMENT_TYPE_FILE, "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2,c66"); + extMap.put(Constants.ATTACHMENT_TYPE_FILE, "pdf,doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2,c66"); extMap.put("flash", "swf,flv"); extMap.put("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb"); } diff --git a/contact-center/app/src/main/resources/templates/apps/agent/contacts.html b/contact-center/app/src/main/resources/templates/apps/agent/contacts.html index 61e1370e..3f07de58 100644 --- a/contact-center/app/src/main/resources/templates/apps/agent/contacts.html +++ b/contact-center/app/src/main/resources/templates/apps/agent/contacts.html @@ -9,7 +9,7 @@ <#if contacts.gender?? && contacts.gender == '-1'>未知
  • - 生日:${contacts.birthday!''} + 生日:${contacts.cusbirthday!''}
  • 电话:${contacts.phone!''} diff --git a/contact-center/app/src/main/resources/templates/apps/business/contacts/detail.html b/contact-center/app/src/main/resources/templates/apps/business/contacts/detail.html index 38be8402..eecbb719 100644 --- a/contact-center/app/src/main/resources/templates/apps/business/contacts/detail.html +++ b/contact-center/app/src/main/resources/templates/apps/business/contacts/detail.html @@ -143,7 +143,7 @@
    - ${contacts.birthday!''} + ${contacts.cusbirthday!''}
  • diff --git a/contact-center/app/src/main/resources/templates/apps/business/customer/add.html b/contact-center/app/src/main/resources/templates/apps/business/customer/add.html index 7d48f34e..49764fa5 100644 --- a/contact-center/app/src/main/resources/templates/apps/business/customer/add.html +++ b/contact-center/app/src/main/resources/templates/apps/business/customer/add.html @@ -178,7 +178,7 @@
    -
    @@ -284,4 +284,4 @@ } }); - \ No newline at end of file + diff --git a/contact-center/app/src/main/resources/templates/apps/service/online/contacts.html b/contact-center/app/src/main/resources/templates/apps/service/online/contacts.html index 1a27387e..3b16438e 100644 --- a/contact-center/app/src/main/resources/templates/apps/service/online/contacts.html +++ b/contact-center/app/src/main/resources/templates/apps/service/online/contacts.html @@ -9,7 +9,7 @@ <#if contacts.gender?? && contacts.gender == '-1'>未知
  • - 生日:${contacts.birthday!''} + 生日:${contacts.cusbirthday!''}
  • 电话:${contacts.phone!''} @@ -43,4 +43,4 @@ }); - \ No newline at end of file + diff --git a/contact-center/app/src/main/resources/templates/apps/service/processed/process.html b/contact-center/app/src/main/resources/templates/apps/service/processed/process.html index 5503c0f3..168703b6 100644 --- a/contact-center/app/src/main/resources/templates/apps/service/processed/process.html +++ b/contact-center/app/src/main/resources/templates/apps/service/processed/process.html @@ -35,7 +35,7 @@
    - ${contacts.birthday!''} + ${contacts.cusbirthday!''}
  • @@ -202,4 +202,4 @@ var element = layui.element(); element.init(); }); - \ No newline at end of file + diff --git a/contact-center/app/src/main/resources/templates/apps/service/summary/process.html b/contact-center/app/src/main/resources/templates/apps/service/summary/process.html index c48d5011..15cd3505 100644 --- a/contact-center/app/src/main/resources/templates/apps/service/summary/process.html +++ b/contact-center/app/src/main/resources/templates/apps/service/summary/process.html @@ -35,7 +35,7 @@
    - ${contacts.birthday!''} + ${contacts.cusbirthday!''}
    @@ -202,4 +202,4 @@ var element = layui.element(); element.init(); }); - \ No newline at end of file + From 0b272744a51a14c9d2957af1bd626c97ffe1b0b0 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 24 Oct 2018 21:42:10 +0800 Subject: [PATCH 45/54] =?UTF-8?q?Fixed=20#117=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E5=9B=9E=E5=A4=8D=E5=8D=A1=E9=A1=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chatopera/cc/app/config/IMServerConfiguration.java | 4 ++-- .../chatopera/cc/app/handler/resource/MediaController.java | 1 - .../chatopera/cc/app/im/handler/ChatbotEventHandler.java | 2 ++ .../src/main/resources/templates/apps/im/chatbot/index.html | 5 ++--- .../main/resources/templates/apps/im/chatbot/mobile.html | 2 +- .../app/src/main/resources/templates/apps/im/index.html | 6 ++++-- .../app/src/main/resources/templates/apps/im/mobile.html | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/config/IMServerConfiguration.java b/contact-center/app/src/main/java/com/chatopera/cc/app/config/IMServerConfiguration.java index 9f0ea440..8f1ebfb6 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/config/IMServerConfiguration.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/config/IMServerConfiguration.java @@ -87,7 +87,7 @@ public class IMServerConfiguration FileInputStream in = new FileInputStream(sslFile); sslProperties.load(in); in.close(); - if(!StringUtils.isBlank(sslProperties.getProperty("key-store")) && !StringUtils.isBlank(sslProperties.getProperty("key-store-password"))){ + if(StringUtils.isNotBlank(sslProperties.getProperty("key-store")) && StringUtils.isNotBlank(sslProperties.getProperty("key-store-password"))){ config.setKeyStorePassword(MainUtils.decryption(sslProperties.getProperty("key-store-password"))); InputStream stream = new FileInputStream(new File(path , "ssl/"+sslProperties.getProperty("key-store"))); config.setKeyStore(stream); @@ -96,7 +96,7 @@ public class IMServerConfiguration // config.setSSLProtocol("https"); - int workThreads = !StringUtils.isBlank(threads) && threads.matches("[\\d]{1,6}") ? Integer.parseInt(threads) : 100 ; + int workThreads = StringUtils.isNotBlank(threads) && threads.matches("[\\d]{1,6}") ? Integer.parseInt(threads) : 100 ; config.setWorkerThreads(workThreads); // config.setStoreFactory(new HazelcastStoreFactory()); config.setAuthorizationListener(new AuthorizationListener() { diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java index b08c2de2..c9fc61b9 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java @@ -74,7 +74,6 @@ public class MediaController extends Handler { @Valid String id, @RequestParam(value = "original", required = false) boolean original, @RequestParam(value = "cooperation", required = false) boolean cooperation) throws IOException, SQLException { - logger.info("index id {}, original {}, cooperation {}", id, original, cooperation); StreamingFile sf = streamingFileRepository.findOne(id); if (sf != null) { response.setHeader("Content-Type", sf.getMime()); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java index 40de2613..6aaf9bac 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java @@ -66,6 +66,7 @@ public class ChatbotEventHandler { @OnConnect public void onConnect(SocketIOClient client) { try { + String user = client.getHandshakeData().getSingleUrlParam("userid"); String nickname = client.getHandshakeData().getSingleUrlParam("nickname"); String orgi = client.getHandshakeData().getSingleUrlParam("orgi"); @@ -74,6 +75,7 @@ public class ChatbotEventHandler { String aiid = client.getHandshakeData().getSingleUrlParam("aiid"); // String agent = client.getHandshakeData().getSingleUrlParam("agent") ; // String skill = client.getHandshakeData().getSingleUrlParam("skill") ; + logger.info("onConnect userid {}, nickname {}", user, nickname); Date now = new Date(); if (StringUtils.isNotBlank(user)) { diff --git a/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html b/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html index 75952ee4..ee208327 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html +++ b/contact-center/app/src/main/resources/templates/apps/im/chatbot/index.html @@ -453,9 +453,9 @@ // 参数连接 var hostname = location.hostname ; var protocol = window.location.protocol.replace(/:/g,''); - var socket = io.connect(protocol + '://'+hostname+':${port}/im/chatbot?userid=${userid!''}&orgi=${orgi!''}&session=${sessionid!''}&appid=${appid!''}&osname=${(osname!'')?url}&browser=${(browser!'')?url}<#if skill??>&skill=${skill}<#if username??>&nickname=${username}<#if agent??>&agent=${agent}<#if title??>&title=${title?url}<#if traceid??>&url=${url?url}<#if traceid??>&traceid=${traceid}<#if aiid??>&aiid=${aiid}'); + var socket = io(protocol + '://'+hostname+':${port}/im/chatbot?userid=${userid!''}&orgi=${orgi!''}&session=${sessionid!''}&appid=${appid!''}&osname=${(osname!'')?url}&browser=${(browser!'')?url}<#if skill??>&skill=${skill}<#if username??>&nickname=${username}<#if agent??>&agent=${agent}<#if title??>&title=${title?url}<#if traceid??>&url=${url?url}<#if traceid??>&traceid=${traceid}<#if aiid??>&aiid=${aiid}', {transports: ['websocket', 'polling']}); socket.on('connect',function(){ - <#if contacts?? && contacts.name??> + <#if contacts?? && contacts.name??> socket.emit('new', { name : "${contacts.name!''}", phone:"${contacts.phone!''}", @@ -489,7 +489,6 @@ } }) socket.on('message', function(data) { - console.log("[chatbot io] message ", data); var chat=document.getElementsByClassName('chatting-left').innerText; chat = data.message; if(data.messageType == "image"){ diff --git a/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html b/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html index 2fcb6b5f..244437ac 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html +++ b/contact-center/app/src/main/resources/templates/apps/im/chatbot/mobile.html @@ -283,7 +283,7 @@ // 参数连接 var hostname = location.hostname ; var protocol = window.location.protocol.replace(/:/g,''); - var socket = io.connect(protocol + '://'+hostname+':${port}/im/chatbot?userid=${userid!''}<#if aiid??>&aiid=${aiid}&orgi=${orgi!''}&session=${sessionid!''}&appid=${appid!''}&osname=${(osname!'')?url}&browser=${(browser!'')?url}<#if skill??>&skill=${skill}<#if agent??>&agent=${agent}'); + var socket = io(protocol + '://'+hostname+':${port}/im/chatbot?userid=${userid!''}<#if aiid??>&aiid=${aiid}&orgi=${orgi!''}&session=${sessionid!''}&appid=${appid!''}&osname=${(osname!'')?url}&browser=${(browser!'')?url}<#if skill??>&skill=${skill}<#if agent??>&agent=${agent}', {transports: ['websocket', 'polling']}); socket.on('connect',function(){ //service.sendRequestMessage(); //output(''+ new Date().format("yyyy-MM-dd hh:mm:ss") + ' 开始沟通' +'' , 'message callOutConnect-message'); diff --git a/contact-center/app/src/main/resources/templates/apps/im/index.html b/contact-center/app/src/main/resources/templates/apps/im/index.html index ec5f2e52..46f61448 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/index.html +++ b/contact-center/app/src/main/resources/templates/apps/im/index.html @@ -452,9 +452,10 @@ // 参数连接 var hostname = location.hostname ; var protocol = window.location.protocol.replace(/:/g,''); - var socket = io.connect(protocol + '://'+hostname+':${port}/im/user?userid=${userid!''}&orgi=${orgi!''}&session=${sessionid!''}&appid=${appid!''}&osname=${(osname!'')?url}&browser=${(browser!'')?url}<#if skill??>&skill=${skill}<#if username??>&nickname=${username}<#if agent??>&agent=${agent}<#if title??>&title=${title?url}<#if traceid??>&url=${url?url}<#if traceid??>&traceid=${traceid}'); + var socket = io(protocol + '://'+hostname+':${port}/im/user?userid=${userid!''}&orgi=${orgi!''}&session=${sessionid!''}&appid=${appid!''}&osname=${(osname!'')?url}&browser=${(browser!'')?url}<#if skill??>&skill=${skill}<#if username??>&nickname=${username}<#if agent??>&agent=${agent}<#if title??>&title=${title?url}<#if traceid??>&url=${url?url}<#if traceid??>&traceid=${traceid}', {transports: ['websocket', 'polling']}); socket.on('connect',function(){ - <#if contacts?? && contacts.name??> + console.log("on connect ..."); + <#if contacts?? && contacts.name??> socket.emit('new', { name : "${contacts.name!''}", phone:"${contacts.phone!''}", @@ -488,6 +489,7 @@ } }) socket.on('message', function(data) { + console.log("on message", data); var chat=document.getElementsByClassName('chatting-left').innerText; chat = data.message; if(data.messageType == "image"){ diff --git a/contact-center/app/src/main/resources/templates/apps/im/mobile.html b/contact-center/app/src/main/resources/templates/apps/im/mobile.html index e0496030..801e5e7d 100644 --- a/contact-center/app/src/main/resources/templates/apps/im/mobile.html +++ b/contact-center/app/src/main/resources/templates/apps/im/mobile.html @@ -281,7 +281,7 @@ // 参数连接 var hostname = location.hostname ; var protocol = window.location.protocol.replace(/:/g,''); - var socket = io.connect(protocol + '://'+hostname+':${port}/im/user?userid=${userid!''}<#if aiid??>&aiid=${aiid}&orgi=${orgi!''}&session=${sessionid!''}&appid=${appid!''}&osname=${(osname!'')?url}&browser=${(browser!'')?url}<#if skill??>&skill=${skill}<#if username??>&nickname=${username}<#if agent??>&agent=${agent}'); + var socket = io(protocol + '://'+hostname+':${port}/im/user?userid=${userid!''}<#if aiid??>&aiid=${aiid}&orgi=${orgi!''}&session=${sessionid!''}&appid=${appid!''}&osname=${(osname!'')?url}&browser=${(browser!'')?url}<#if skill??>&skill=${skill}<#if username??>&nickname=${username}<#if agent??>&agent=${agent}', {transports: ['websocket', 'polling']}); socket.on('connect',function(){ //service.sendRequestMessage(); //output(''+ new Date().format("yyyy-MM-dd hh:mm:ss") + ' 开始沟通' +'' , 'message callOutConnect-message'); From 77643c7ef86a5557e97810e8f76b7d6d288fa05c Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 25 Oct 2018 15:21:13 +0800 Subject: [PATCH 46/54] =?UTF-8?q?Closed=20#122=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=AE=A2=E6=9C=8D=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/channel/WebIMController.java | 61 +++++++++---------- .../app/handler/resource/MediaController.java | 14 +++-- .../apps/business/contacts/detail.html | 2 +- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java index 0b3f04cc..27eed0bf 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java @@ -16,12 +16,11 @@ */ package com.chatopera.cc.app.handler.admin.channel; +import com.chatopera.cc.app.basic.MainUtils; import com.chatopera.cc.app.cache.CacheHelper; import com.chatopera.cc.app.handler.Handler; -import com.chatopera.cc.app.model.CousultInvite; -import com.chatopera.cc.app.model.Organ; -import com.chatopera.cc.app.model.OrgiSkillRel; -import com.chatopera.cc.app.model.User; +import com.chatopera.cc.app.model.*; +import com.chatopera.cc.app.persistence.blob.JpaBlobHelper; import com.chatopera.cc.app.persistence.repository.*; import com.chatopera.cc.util.Menu; import org.apache.commons.lang.StringUtils; @@ -70,6 +69,24 @@ public class WebIMController extends Handler { @Autowired private SNSAccountRepository snsAccountRes; + @Autowired + private JpaBlobHelper jpaBlobHelper; + + @Autowired + private StreamingFileRepository streamingFileRes; + + + private String saveImageFile(MultipartFile multipart) throws IOException { + StreamingFile sf = new StreamingFile(); + final String fileid = MainUtils.getUUID(); + sf.setId(fileid); + sf.setMime(multipart.getContentType()); + sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize())); + sf.setName(multipart.getOriginalFilename()); + streamingFileRes.save(sf); + return fileid; + } + @RequestMapping("/index") @Menu(type = "app", subtype = "app", admin = true) public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String snsid) { @@ -106,23 +123,14 @@ public class WebIMController extends Handler { inviteData.setSnsaccountid(super.getUser(request).getId()); } inviteData.setOrgi(super.getOrgi(request)); + // 网页品牌标识 if (webimlogo != null && webimlogo.getOriginalFilename().lastIndexOf(".") > 0) { - File logoDir = new File(path, "logo"); - if (!logoDir.exists()) { - logoDir.mkdirs(); - } - String fileName = "logo/" + inviteData.getId() + webimlogo.getOriginalFilename().substring(webimlogo.getOriginalFilename().lastIndexOf(".")); - FileCopyUtils.copy(webimlogo.getBytes(), new File(path, fileName)); - inviteData.setConsult_dialog_logo(fileName); + inviteData.setConsult_dialog_logo(saveImageFile(webimlogo)); } + + // 网页坐席头像 if (agentheadimg != null && agentheadimg.getOriginalFilename().lastIndexOf(".") > 0) { - File headimgDir = new File(path, "headimg"); - if (!headimgDir.exists()) { - headimgDir.mkdirs(); - } - String fileName = "headimg/" + inviteData.getId() + agentheadimg.getOriginalFilename().substring(agentheadimg.getOriginalFilename().lastIndexOf(".")); - FileCopyUtils.copy(agentheadimg.getBytes(), new File(path, fileName)); - inviteData.setConsult_dialog_headimg(fileName); + inviteData.setConsult_dialog_headimg(saveImageFile(agentheadimg)); } invite.save(inviteData); CacheHelper.getSystemCacheBean().put(inviteData.getSnsaccountid(), inviteData, inviteData.getOrgi()); @@ -200,13 +208,7 @@ public class WebIMController extends Handler { tempInviteData.setCtrlenter(inviteData.isCtrlenter()); if (dialogad != null && !StringUtils.isBlank(dialogad.getName()) && dialogad.getBytes() != null && dialogad.getBytes().length > 0) { - String fileName = "ad/" + inviteData.getId() + dialogad.getOriginalFilename().substring(dialogad.getOriginalFilename().lastIndexOf(".")); - File file = new File(path, fileName); - if (!file.getParentFile().exists()) { - file.getParentFile().mkdirs(); - } - FileCopyUtils.copy(dialogad.getBytes(), file); - tempInviteData.setDialog_ad(fileName); + tempInviteData.setDialog_ad(saveImageFile(dialogad)); } invite.save(tempInviteData); inviteData = tempInviteData; @@ -246,13 +248,7 @@ public class WebIMController extends Handler { tempInviteData.setConsult_invite_color(inviteData.getConsult_invite_color()); if (invotebg != null && !StringUtils.isBlank(invotebg.getName()) && invotebg.getBytes() != null && invotebg.getBytes().length > 0) { - String fileName = "invote/" + inviteData.getId() + invotebg.getOriginalFilename().substring(invotebg.getOriginalFilename().lastIndexOf(".")); - File file = new File(path, fileName); - if (!file.getParentFile().exists()) { - file.getParentFile().mkdirs(); - } - FileCopyUtils.copy(invotebg.getBytes(), file); - tempInviteData.setConsult_invite_bg(fileName); + tempInviteData.setConsult_invite_bg(saveImageFile(invotebg)); } invite.save(tempInviteData); inviteData = tempInviteData; @@ -291,7 +287,6 @@ public class WebIMController extends Handler { * 获取当前产品下人员信息 * * @param request - * @param q * @return */ private List getUsers(HttpServletRequest request) { diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java index c9fc61b9..40d2bf6c 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/resource/MediaController.java @@ -58,7 +58,7 @@ public class MediaController extends Handler { private String path; @Autowired - private StreamingFileRepository streamingFileRepository; + private StreamingFileRepository streamingFileRes; @Autowired private JpaBlobHelper jpaBlobHelper; @@ -74,7 +74,7 @@ public class MediaController extends Handler { @Valid String id, @RequestParam(value = "original", required = false) boolean original, @RequestParam(value = "cooperation", required = false) boolean cooperation) throws IOException, SQLException { - StreamingFile sf = streamingFileRepository.findOne(id); + StreamingFile sf = streamingFileRes.findOne(id); if (sf != null) { response.setHeader("Content-Type", sf.getMime()); response.setContentType(sf.getMime()); @@ -84,6 +84,8 @@ public class MediaController extends Handler { IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream()); } else if (sf.getThumbnail() != null) { // 缩略图 IOUtils.copy(sf.getThumbnail().getBinaryStream(), response.getOutputStream()); + } else if (sf.getData() != null) { + IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream()); } else { logger.warn("[index] can not get streaming file id {}, original {}, cooperation {}", id, original, cooperation); } @@ -132,7 +134,7 @@ public class MediaController extends Handler { sf.setName(multipart.getOriginalFilename()); sf.setMime(multipart.getContentType()); sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize())); - streamingFileRepository.save(sf); + streamingFileRes.save(sf); String fileURL = "/res/image.html?id=" + fileid; notify = new UploadStatus("0", fileURL); //图片直接发送给 客户,不用返回 } else { @@ -148,12 +150,16 @@ public class MediaController extends Handler { if (StringUtils.isNotBlank(id)) { AttachmentFile attachmentFile = attachementRes.findByIdAndOrgi(id, super.getOrgi(request)); if (attachmentFile != null && attachmentFile.getFileid() != null) { - StreamingFile sf = streamingFileRepository.findOne(attachmentFile.getFileid()); + StreamingFile sf = streamingFileRes.findOne(attachmentFile.getFileid()); if (sf != null) { response.setContentType(attachmentFile.getFiletype()); response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode(attachmentFile.getTitle(), "UTF-8")); IOUtils.copy(sf.getData().getBinaryStream(), response.getOutputStream()); + } else { + logger.warn("[streaming file] can not get file id {}", attachmentFile.getFileid()); } + } else { + logger.warn("[attachment file] can not find attachment file id {}", id); } } } diff --git a/contact-center/app/src/main/resources/templates/apps/business/contacts/detail.html b/contact-center/app/src/main/resources/templates/apps/business/contacts/detail.html index eecbb719..eb6a105d 100644 --- a/contact-center/app/src/main/resources/templates/apps/business/contacts/detail.html +++ b/contact-center/app/src/main/resources/templates/apps/business/contacts/detail.html @@ -43,9 +43,9 @@
    From a2ef70e7cb35261a13cc40a6eaf3dffebd245f6a Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 25 Oct 2018 15:21:40 +0800 Subject: [PATCH 47/54] =?UTF-8?q?Closed=20#123=20=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/app/handler/ApplicationController.java | 2 +- .../com/chatopera/cc/app/handler/Handler.java | 769 +++++++++--------- .../cc/app/handler/LoginController.java | 14 +- .../java/com/chatopera/cc/app/model/User.java | 4 + 4 files changed, 405 insertions(+), 384 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/ApplicationController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/ApplicationController.java index 81f3d52c..d6f66ebf 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/ApplicationController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/ApplicationController.java @@ -39,7 +39,7 @@ public class ApplicationController extends Handler{ view.addObject("istenantshare",super.isEnabletneant()); if(super.isEnabletneant()) { //多租户启用 非超级管理员 一定要选择租户才能进入界面 - if(!user.isSuperuser() && !StringUtils.isBlank(user.getOrgid()) && super.isTenantconsole() && MainContext.SYSTEM_ORGI.equals(user.getOrgi())) { + if(!user.isSuperuser() && StringUtils.isNotBlank(user.getOrgid()) && super.isTenantconsole() && MainContext.SYSTEM_ORGI.equals(user.getOrgi())) { view = request(super.createRequestPageTempletResponse("redirect:/apps/tenant/index")); } if(StringUtils.isBlank(user.getOrgid())) { diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java index 71f70097..c633f9d7 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java @@ -16,23 +16,16 @@ */ package com.chatopera.cc.app.handler; -import static org.elasticsearch.index.query.QueryBuilders.termQuery; -import static org.elasticsearch.index.query.QueryBuilders.termsQuery; - -import java.text.ParseException; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; - import com.chatopera.cc.app.basic.MainContext; import com.chatopera.cc.app.basic.MainUtils; import com.chatopera.cc.app.basic.Viewport; -import com.chatopera.cc.exception.CSKefuException; import com.chatopera.cc.app.cache.CacheHelper; -import com.chatopera.cc.app.persistence.repository.TenantRepository; import com.chatopera.cc.app.handler.api.rest.QueryParams; +import com.chatopera.cc.app.model.SystemConfig; import com.chatopera.cc.app.model.Tenant; import com.chatopera.cc.app.model.User; +import com.chatopera.cc.app.persistence.repository.TenantRepository; +import com.chatopera.cc.exception.CSKefuException; import org.apache.commons.lang.StringUtils; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; @@ -47,7 +40,12 @@ import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.servlet.ModelAndView; -import com.chatopera.cc.app.model.SystemConfig; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import java.text.ParseException; + +import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.elasticsearch.index.query.QueryBuilders.termsQuery; @Controller @@ -55,59 +53,61 @@ import com.chatopera.cc.app.model.SystemConfig; public class Handler { private static final Logger logger = LoggerFactory.getLogger(Handler.class); - @Autowired - private TenantRepository tenantRes; - - public final static int PAGE_SIZE_BG = 1 ; - public final static int PAGE_SIZE_TW = 20 ; - public final static int PAGE_SIZE_FV = 50 ; - public final static int PAGE_SIZE_HA = 100 ; - - private long starttime = System.currentTimeMillis(); - - public User getUser(HttpServletRequest request){ - User user = (User) request.getSession(true).getAttribute(MainContext.USER_SESSION_NAME) ; - if(user==null){ - String authorization = request.getHeader("authorization") ; - if(StringUtils.isBlank(authorization) && request.getCookies()!=null){ - for(Cookie cookie : request.getCookies()){ - if(cookie.getName().equals("authorization")){ - authorization = cookie.getValue() ; break ; - } - } - } - if(!StringUtils.isBlank(authorization)){ - user = (User) CacheHelper.getApiUserCacheBean().getCacheObject(authorization, MainContext.SYSTEM_ORGI) ; - } - if(user==null){ - user = new User(); - user.setId(MainUtils.getContextID(request.getSession().getId())) ; - user.setUsername(MainContext.GUEST_USER+"_"+ MainUtils.genIDByKey(user.getId())) ; - user.setOrgi(MainContext.SYSTEM_ORGI); - user.setSessionid(user.getId()) ; - } - }else{ - user.setSessionid(user.getId()) ; - } - return user ; - } + @Autowired + private TenantRepository tenantRes; + + public final static int PAGE_SIZE_BG = 1; + public final static int PAGE_SIZE_TW = 20; + public final static int PAGE_SIZE_FV = 50; + public final static int PAGE_SIZE_HA = 100; + + private long starttime = System.currentTimeMillis(); + + public User getUser(HttpServletRequest request) { + User user = (User) request.getSession(true).getAttribute(MainContext.USER_SESSION_NAME); + if (user == null) { + String authorization = request.getHeader("authorization"); + if (StringUtils.isBlank(authorization) && request.getCookies() != null) { + for (Cookie cookie : request.getCookies()) { + if (cookie.getName().equals("authorization")) { + authorization = cookie.getValue(); + break; + } + } + } + if (StringUtils.isNotBlank(authorization)) { + user = (User) CacheHelper.getApiUserCacheBean().getCacheObject(authorization, MainContext.SYSTEM_ORGI); + } + if (user == null) { + user = new User(); + user.setId(MainUtils.getContextID(request.getSession().getId())); + user.setUsername(MainContext.GUEST_USER + "_" + MainUtils.genIDByKey(user.getId())); + user.setOrgi(MainContext.SYSTEM_ORGI); + user.setSessionid(user.getId()); + } + } else { + user.setSessionid(user.getId()); + } + return user; + } /** * 构建ElasticSearch基于部门查询的Filter + * * @param request * @param boolQueryBuilder * @return * @throws CSKefuException */ - public boolean esOrganFilter(final HttpServletRequest request, final BoolQueryBuilder boolQueryBuilder) throws CSKefuException { + public boolean esOrganFilter(final HttpServletRequest request, final BoolQueryBuilder boolQueryBuilder) throws CSKefuException { // 组合部门条件 User u = getUser(request); - if( u == null){ + if (u == null) { throw new CSKefuException("[esOrganFilter] 未能获取到登录用户。"); - } else if(u.isSuperuser()){ + } else if (u.isSuperuser()) { // 超级管理员, 查看任何数据 return true; - } else if(u.getMyorgans().size() == 0){ + } else if (u.getMyorgans().size() == 0) { // 用户没有被分配到部门,返回空数据 return false; } else { @@ -117,339 +117,348 @@ public class Handler { return true; } } - - /** - * - * @param queryBuilder - * @param request - */ - public BoolQueryBuilder search(BoolQueryBuilder queryBuilder , ModelMap map, HttpServletRequest request){ - queryBuilder.must(termQuery("orgi", this.getOrgi(request))) ; - - //搜索框 - if(!StringUtils.isBlank(request.getParameter("q"))) { - String q = request.getParameter("q") ; - q = q.replaceAll("(OR|AND|NOT|:|\\(|\\))", "") ; - if(!StringUtils.isBlank(q)){ - queryBuilder.must(QueryBuilders.boolQuery().must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND))) ; - map.put("q", q) ; - } - } - - //筛选表单 - if(!StringUtils.isBlank(request.getParameter("filterid"))) { - queryBuilder.must(termQuery("filterid", request.getParameter("filterid"))) ; - map.put("filterid", request.getParameter("filterid")) ; - } - - //批次 - if(!StringUtils.isBlank(request.getParameter("batid"))) { - queryBuilder.must(termQuery("batid", request.getParameter("batid"))) ; - map.put("batid", request.getParameter("batid")) ; - } - - //活动 - if(!StringUtils.isBlank(request.getParameter("actid"))) { - queryBuilder.must(termQuery("actid", request.getParameter("actid"))) ; - map.put("actid", request.getParameter("actid")) ; - } - - //业务状态 - if(!StringUtils.isBlank(request.getParameter("workstatus"))) { - queryBuilder.must(termQuery("workstatus", request.getParameter("workstatus"))) ; - map.put("workstatus", request.getParameter("workstatus")) ; - } - - //拨打状态 - if(!StringUtils.isBlank(request.getParameter("callstatus"))) { - queryBuilder.must(termQuery("callstatus", request.getParameter("callstatus"))) ; - map.put("callstatus", request.getParameter("callstatus")) ; - } - - //预约状态 - if(!StringUtils.isBlank(request.getParameter("apstatus"))) { - queryBuilder.must(termQuery("apstatus", request.getParameter("apstatus"))) ; - map.put("apstatus", request.getParameter("apstatus")) ; - } - - RangeQueryBuilder rangeQuery = null ; - //拨打时间区间查询 - if(!StringUtils.isBlank(request.getParameter("callbegin")) || !StringUtils.isBlank(request.getParameter("callend"))){ - - if(!StringUtils.isBlank(request.getParameter("callbegin"))) { - try { - - rangeQuery = QueryBuilders.rangeQuery("calltime").from(MainUtils.dateFormate.parse(request.getParameter("callbegin")).getTime()) ; - } catch (ParseException e) { - - e.printStackTrace(); - } - } - if(!StringUtils.isBlank(request.getParameter("callend")) ) { - - try { - - if(rangeQuery == null) { - rangeQuery = QueryBuilders.rangeQuery("calltime").to(MainUtils.dateFormate.parse(request.getParameter("callend")).getTime()) ; - }else { - rangeQuery.to(MainUtils.dateFormate.parse(request.getParameter("callend")).getTime()) ; - } - } catch (ParseException e) { - - e.printStackTrace(); - } - - } - map.put("callbegin", request.getParameter("callbegin")) ; - map.put("callend", request.getParameter("callend")) ; - } - //预约时间区间查询 - if(!StringUtils.isBlank(request.getParameter("apbegin")) || !StringUtils.isBlank(request.getParameter("apend"))){ - - if(!StringUtils.isBlank(request.getParameter("apbegin"))) { - try { - - rangeQuery = QueryBuilders.rangeQuery("aptime").from(MainUtils.dateFormate.parse(request.getParameter("apbegin")).getTime()) ; - } catch (ParseException e) { - - e.printStackTrace(); - } - } - if(!StringUtils.isBlank(request.getParameter("apend")) ) { - - try { - - if(rangeQuery == null) { - rangeQuery = QueryBuilders.rangeQuery("aptime").to(MainUtils.dateFormate.parse(request.getParameter("apend")).getTime()) ; - }else { - rangeQuery.to(MainUtils.dateFormate.parse(request.getParameter("apend")).getTime()) ; - } - } catch (ParseException e) { - - e.printStackTrace(); - } - - - - } - map.put("apbegin", request.getParameter("apbegin")) ; - map.put("apend", request.getParameter("apend")) ; - } - - if(rangeQuery!=null) { - queryBuilder.must(rangeQuery) ; - } - - //外呼任务id - if(!StringUtils.isBlank(request.getParameter("taskid"))) { - queryBuilder.must(termQuery("taskid", request.getParameter("taskid"))) ; - map.put("taskid", request.getParameter("taskid")) ; - } - //坐席 - if(!StringUtils.isBlank(request.getParameter("owneruser"))) { - queryBuilder.must(termQuery("owneruser", request.getParameter("owneruser"))) ; - map.put("owneruser", request.getParameter("owneruser")) ; - } - //部门 - if(!StringUtils.isBlank(request.getParameter("ownerdept"))) { - queryBuilder.must(termQuery("ownerdept", request.getParameter("ownerdept"))) ; - map.put("ownerdept", request.getParameter("ownerdept")) ; - } - //分配状态 - if(!StringUtils.isBlank(request.getParameter("status"))) { - queryBuilder.must(termQuery("status", request.getParameter("status"))) ; - map.put("status", request.getParameter("status")) ; - } - return queryBuilder ; - } - - public User getIMUser(HttpServletRequest request , String userid , String nickname){ - User user = (User) request.getSession(true).getAttribute(MainContext.IM_USER_SESSION_NAME) ; - if(user==null){ - user = new User(); - if(!StringUtils.isBlank(userid)){ - user.setId(userid) ; - }else{ - user.setId(MainUtils.getContextID(request.getSession().getId())) ; - } - if(!StringUtils.isBlank(nickname)){ - user.setUsername(nickname); - }else{ - user.setUsername(MainContext.GUEST_USER+"_"+ MainUtils.genIDByKey(user.getId())) ; - } - user.setSessionid(user.getId()) ; - }else{ - user.setSessionid(MainUtils.getContextID(request.getSession().getId())) ; - } - return user ; - } - - public void setUser(HttpServletRequest request , User user){ - request.getSession(true).removeAttribute(MainContext.USER_SESSION_NAME) ; - request.getSession(true).setAttribute(MainContext.USER_SESSION_NAME , user) ; - } - + /** + * @param queryBuilder + * @param request + */ + public BoolQueryBuilder search(BoolQueryBuilder queryBuilder, ModelMap map, HttpServletRequest request) { + queryBuilder.must(termQuery("orgi", this.getOrgi(request))); - /** - * 创建系统监控的 模板页面 - * @param page - * @return - */ - public Viewport createAdminTempletResponse(String page) { - return new Viewport("/admin/include/tpl" , page); - } - /** - * 创建系统监控的 模板页面 - * @param page - * @return - */ - public Viewport createAppsTempletResponse(String page) { - return new Viewport("/apps/include/tpl" , page); - } - - /** - * 创建系统监控的 模板页面 - * @param page - * @return - */ - public Viewport createEntIMTempletResponse(String page) { - return new Viewport("/apps/entim/include/tpl" , page); - } - - public Viewport createRequestPageTempletResponse(String page) { - return new Viewport(page); - } - - /** - * - * @param data - * @return - */ - public ModelAndView request(Viewport data) { - return new ModelAndView(data.getTemplet()!=null ? data.getTemplet(): data.getPage() , "data", data) ; + //搜索框 + if (StringUtils.isNotBlank(request.getParameter("q"))) { + String q = request.getParameter("q"); + q = q.replaceAll("(OR|AND|NOT|:|\\(|\\))", ""); + if (StringUtils.isNotBlank(q)) { + queryBuilder.must(QueryBuilders.boolQuery().must(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND))); + map.put("q", q); + } + } + + //筛选表单 + if (StringUtils.isNotBlank(request.getParameter("filterid"))) { + queryBuilder.must(termQuery("filterid", request.getParameter("filterid"))); + map.put("filterid", request.getParameter("filterid")); + } + + //批次 + if (StringUtils.isNotBlank(request.getParameter("batid"))) { + queryBuilder.must(termQuery("batid", request.getParameter("batid"))); + map.put("batid", request.getParameter("batid")); + } + + //活动 + if (StringUtils.isNotBlank(request.getParameter("actid"))) { + queryBuilder.must(termQuery("actid", request.getParameter("actid"))); + map.put("actid", request.getParameter("actid")); + } + + //业务状态 + if (StringUtils.isNotBlank(request.getParameter("workstatus"))) { + queryBuilder.must(termQuery("workstatus", request.getParameter("workstatus"))); + map.put("workstatus", request.getParameter("workstatus")); + } + + //拨打状态 + if (StringUtils.isNotBlank(request.getParameter("callstatus"))) { + queryBuilder.must(termQuery("callstatus", request.getParameter("callstatus"))); + map.put("callstatus", request.getParameter("callstatus")); + } + + //预约状态 + if (StringUtils.isNotBlank(request.getParameter("apstatus"))) { + queryBuilder.must(termQuery("apstatus", request.getParameter("apstatus"))); + map.put("apstatus", request.getParameter("apstatus")); + } + + RangeQueryBuilder rangeQuery = null; + //拨打时间区间查询 + if (StringUtils.isNotBlank(request.getParameter("callbegin")) || StringUtils.isNotBlank(request.getParameter("callend"))) { + + if (StringUtils.isNotBlank(request.getParameter("callbegin"))) { + try { + + rangeQuery = QueryBuilders.rangeQuery("calltime").from(MainUtils.dateFormate.parse(request.getParameter("callbegin")).getTime()); + } catch (ParseException e) { + + e.printStackTrace(); + } + } + if (StringUtils.isNotBlank(request.getParameter("callend"))) { + + try { + + if (rangeQuery == null) { + rangeQuery = QueryBuilders.rangeQuery("calltime").to(MainUtils.dateFormate.parse(request.getParameter("callend")).getTime()); + } else { + rangeQuery.to(MainUtils.dateFormate.parse(request.getParameter("callend")).getTime()); + } + } catch (ParseException e) { + + e.printStackTrace(); + } + + } + map.put("callbegin", request.getParameter("callbegin")); + map.put("callend", request.getParameter("callend")); + } + //预约时间区间查询 + if (StringUtils.isNotBlank(request.getParameter("apbegin")) || StringUtils.isNotBlank(request.getParameter("apend"))) { + + if (StringUtils.isNotBlank(request.getParameter("apbegin"))) { + try { + + rangeQuery = QueryBuilders.rangeQuery("aptime").from(MainUtils.dateFormate.parse(request.getParameter("apbegin")).getTime()); + } catch (ParseException e) { + + e.printStackTrace(); + } + } + if (StringUtils.isNotBlank(request.getParameter("apend"))) { + + try { + + if (rangeQuery == null) { + rangeQuery = QueryBuilders.rangeQuery("aptime").to(MainUtils.dateFormate.parse(request.getParameter("apend")).getTime()); + } else { + rangeQuery.to(MainUtils.dateFormate.parse(request.getParameter("apend")).getTime()); + } + } catch (ParseException e) { + + e.printStackTrace(); + } + + + } + map.put("apbegin", request.getParameter("apbegin")); + map.put("apend", request.getParameter("apend")); + } + + if (rangeQuery != null) { + queryBuilder.must(rangeQuery); + } + + //外呼任务id + if (StringUtils.isNotBlank(request.getParameter("taskid"))) { + queryBuilder.must(termQuery("taskid", request.getParameter("taskid"))); + map.put("taskid", request.getParameter("taskid")); + } + //坐席 + if (StringUtils.isNotBlank(request.getParameter("owneruser"))) { + queryBuilder.must(termQuery("owneruser", request.getParameter("owneruser"))); + map.put("owneruser", request.getParameter("owneruser")); + } + //部门 + if (StringUtils.isNotBlank(request.getParameter("ownerdept"))) { + queryBuilder.must(termQuery("ownerdept", request.getParameter("ownerdept"))); + map.put("ownerdept", request.getParameter("ownerdept")); + } + //分配状态 + if (StringUtils.isNotBlank(request.getParameter("status"))) { + queryBuilder.must(termQuery("status", request.getParameter("status"))); + map.put("status", request.getParameter("status")); + } + + return queryBuilder; } - public int getP(HttpServletRequest request) { - int page = 0; - String p = request.getParameter("p") ; - if(!StringUtils.isBlank(p) && p.matches("[\\d]*")){ - page = Integer.parseInt(p) ; - if(page > 0){ - page = page - 1 ; - } - } - return page; - } - - public int getPs(HttpServletRequest request) { - int pagesize = PAGE_SIZE_TW; - String ps = request.getParameter("ps") ; - if(!StringUtils.isBlank(ps) && ps.matches("[\\d]*")){ - pagesize = Integer.parseInt(ps) ; - } - return pagesize; - } - - public int getP(QueryParams params) { - int page = 0; - if(params!=null && !StringUtils.isBlank(params.getP()) && params.getP().matches("[\\d]*")){ - page = Integer.parseInt(params.getP()) ; - if(page > 0){ - page = page - 1 ; - } - } - return page; - } - - public int getPs(QueryParams params) { - int pagesize = PAGE_SIZE_TW; - if(params != null && !StringUtils.isBlank(params.getPs()) && params.getPs().matches("[\\d]*")){ - pagesize = Integer.parseInt(params.getPs()) ; - } - return pagesize; - } - - - public int get50Ps(HttpServletRequest request) { - int pagesize = PAGE_SIZE_FV; - String ps = request.getParameter("ps") ; - if(!StringUtils.isBlank(ps) && ps.matches("[\\d]*")){ - pagesize = Integer.parseInt(ps) ; - } - return pagesize; - } - - public String getOrgi(HttpServletRequest request){ - return getUser(request).getOrgi(); - } - /** - * 机构id - * @param request - * @return - */ - public String getOrgid(HttpServletRequest request){ - User u = getUser(request); - return u.getOrgid(); - } - - public Tenant getTenant(HttpServletRequest request){ - return tenantRes.findById(getOrgi(request)); - } - /** - * 根据是否租户共享获取orgi - * @param request - * @return - */ - public String getOrgiByTenantshare(HttpServletRequest request){ - SystemConfig systemConfig = MainUtils.getSystemConfig(); - if(systemConfig!=null&&systemConfig.isEnabletneant()&&systemConfig.isTenantshare()) { - User user = this.getUser(request) ; - return user.getOrgid(); - } - return getOrgi(request); - } - - /** - * 判断是否租户共享 - * @return - */ - public boolean isTenantshare(){ - SystemConfig systemConfig = MainUtils.getSystemConfig(); - if(systemConfig!=null&&systemConfig.isEnabletneant()&&systemConfig.isTenantshare()) { - return true; - } - return false; - } - - /** - * 判断是否多租户 - * @return - */ - public boolean isEnabletneant(){ - SystemConfig systemConfig = MainUtils.getSystemConfig(); - if(systemConfig!=null&&systemConfig.isEnabletneant()) { - return true; - } - return false; - } - /** - * 判断是否多租户 - * @return - */ - public boolean isTenantconsole(){ - SystemConfig systemConfig = MainUtils.getSystemConfig(); - if(systemConfig!=null&&systemConfig.isEnabletneant()&&systemConfig.isTenantconsole()) { - return true; - } - return false; - } + public User getIMUser(HttpServletRequest request, String userid, String nickname) { + User user = (User) request.getSession(true).getAttribute(MainContext.IM_USER_SESSION_NAME); + if (user == null) { + user = new User(); + if (StringUtils.isNotBlank(userid)) { + user.setId(userid); + } else { + user.setId(MainUtils.getContextID(request.getSession().getId())); + } + if (StringUtils.isNotBlank(nickname)) { + user.setUsername(nickname); + } else { + user.setUsername(MainContext.GUEST_USER + "_" + MainUtils.genIDByKey(user.getId())); + } + user.setSessionid(user.getId()); + } else { + user.setSessionid(MainUtils.getContextID(request.getSession().getId())); + } + return user; + } - public long getStarttime() { - return starttime; - } + public void setUser(HttpServletRequest request, User user) { + request.getSession(true).removeAttribute(MainContext.USER_SESSION_NAME); + request.getSession(true).setAttribute(MainContext.USER_SESSION_NAME, user); + } - public void setStarttime(long starttime) { - this.starttime = starttime; - } + + /** + * 创建系统监控的 模板页面 + * + * @param page + * @return + */ + public Viewport createAdminTempletResponse(String page) { + return new Viewport("/admin/include/tpl", page); + } + + /** + * 创建系统监控的 模板页面 + * + * @param page + * @return + */ + public Viewport createAppsTempletResponse(String page) { + return new Viewport("/apps/include/tpl", page); + } + + /** + * 创建系统监控的 模板页面 + * + * @param page + * @return + */ + public Viewport createEntIMTempletResponse(String page) { + return new Viewport("/apps/entim/include/tpl", page); + } + + public Viewport createRequestPageTempletResponse(String page) { + return new Viewport(page); + } + + /** + * @param data + * @return + */ + public ModelAndView request(Viewport data) { + return new ModelAndView(data.getTemplet() != null ? data.getTemplet() : data.getPage(), "data", data); + } + + public int getP(HttpServletRequest request) { + int page = 0; + String p = request.getParameter("p"); + if (StringUtils.isNotBlank(p) && p.matches("[\\d]*")) { + page = Integer.parseInt(p); + if (page > 0) { + page = page - 1; + } + } + return page; + } + + public int getPs(HttpServletRequest request) { + int pagesize = PAGE_SIZE_TW; + String ps = request.getParameter("ps"); + if (StringUtils.isNotBlank(ps) && ps.matches("[\\d]*")) { + pagesize = Integer.parseInt(ps); + } + return pagesize; + } + + public int getP(QueryParams params) { + int page = 0; + if (params != null && StringUtils.isNotBlank(params.getP()) && params.getP().matches("[\\d]*")) { + page = Integer.parseInt(params.getP()); + if (page > 0) { + page = page - 1; + } + } + return page; + } + + public int getPs(QueryParams params) { + int pagesize = PAGE_SIZE_TW; + if (params != null && StringUtils.isNotBlank(params.getPs()) && params.getPs().matches("[\\d]*")) { + pagesize = Integer.parseInt(params.getPs()); + } + return pagesize; + } + + + public int get50Ps(HttpServletRequest request) { + int pagesize = PAGE_SIZE_FV; + String ps = request.getParameter("ps"); + if (StringUtils.isNotBlank(ps) && ps.matches("[\\d]*")) { + pagesize = Integer.parseInt(ps); + } + return pagesize; + } + + public String getOrgi(HttpServletRequest request) { + return getUser(request).getOrgi(); + } + + /** + * 机构id + * + * @param request + * @return + */ + public String getOrgid(HttpServletRequest request) { + User u = getUser(request); + return u.getOrgid(); + } + + public Tenant getTenant(HttpServletRequest request) { + return tenantRes.findById(getOrgi(request)); + } + + /** + * 根据是否租户共享获取orgi + * + * @param request + * @return + */ + public String getOrgiByTenantshare(HttpServletRequest request) { + SystemConfig systemConfig = MainUtils.getSystemConfig(); + if (systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantshare()) { + User user = this.getUser(request); + return user.getOrgid(); + } + return getOrgi(request); + } + + /** + * 判断是否租户共享 + * + * @return + */ + public boolean isTenantshare() { + SystemConfig systemConfig = MainUtils.getSystemConfig(); + if (systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantshare()) { + return true; + } + return false; + } + + /** + * 判断是否多租户 + * + * @return + */ + public boolean isEnabletneant() { + SystemConfig systemConfig = MainUtils.getSystemConfig(); + if (systemConfig != null && systemConfig.isEnabletneant()) { + return true; + } + return false; + } + + /** + * 判断是否多租户 + * + * @return + */ + public boolean isTenantconsole() { + SystemConfig systemConfig = MainUtils.getSystemConfig(); + if (systemConfig != null && systemConfig.isEnabletneant() && systemConfig.isTenantconsole()) { + return true; + } + return false; + } + + public long getStarttime() { + return starttime; + } + + public void setStarttime(long starttime) { + this.starttime = starttime; + } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/LoginController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/LoginController.java index e4d249cc..f57d6f05 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/LoginController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/LoginController.java @@ -18,13 +18,13 @@ package com.chatopera.cc.app.handler; import com.chatopera.cc.app.basic.MainContext; import com.chatopera.cc.app.basic.MainUtils; -import com.chatopera.cc.util.Menu; -import com.chatopera.cc.app.model.*; import com.chatopera.cc.app.cache.CacheHelper; +import com.chatopera.cc.app.model.*; import com.chatopera.cc.app.persistence.repository.OrganRepository; import com.chatopera.cc.app.persistence.repository.RoleAuthRepository; import com.chatopera.cc.app.persistence.repository.UserRepository; import com.chatopera.cc.app.persistence.repository.UserRoleRepository; +import com.chatopera.cc.util.Menu; import com.chatopera.cc.util.OnlineUserUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -78,10 +78,18 @@ public class LoginController extends Handler { private void organs(final User user, final String organ) { if (organ == null) return; + + if (user.inMyorgans(organ)) + return; + user.getMyorgans().add(organ); List y = organRepository.findByOrgiAndParent(user.getOrgi(), organ); for (Organ x : y) { - organs(user, x.getId()); + try { + organs(user, x.getId()); + } catch (Exception e) { + logger.error("organs", e); + } } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/model/User.java b/contact-center/app/src/main/java/com/chatopera/cc/app/model/User.java index 3d54e472..7691b2fa 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/model/User.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/model/User.java @@ -515,6 +515,10 @@ public class User implements java.io.Serializable{ this.ordertype = ordertype; } + public boolean inMyorgans(final String organ){ + return myorgans.contains(organ); + } + @Transient public HashSet getMyorgans() { return myorgans; From 41763967a92e761f7e04e0193c3aa96841e8d1cb Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 25 Oct 2018 16:40:46 +0800 Subject: [PATCH 48/54] =?UTF-8?q?#122=20=E6=94=AF=E6=8C=81=E6=9B=B4?= =?UTF-8?q?=E5=A4=9A=E8=87=AA=E5=AE=9A=E4=B9=89logo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chatopera/cc/app/handler/Handler.java | 24 + .../admin/channel/WebIMController.java | 26 +- .../admin/config/SystemConfigController.java | 399 +++++++------- .../apps/setting/IMAgentController.java | 501 +++++++++--------- 4 files changed, 465 insertions(+), 485 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java index c633f9d7..b7c3cd3e 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java @@ -21,9 +21,12 @@ import com.chatopera.cc.app.basic.MainUtils; import com.chatopera.cc.app.basic.Viewport; import com.chatopera.cc.app.cache.CacheHelper; import com.chatopera.cc.app.handler.api.rest.QueryParams; +import com.chatopera.cc.app.model.StreamingFile; import com.chatopera.cc.app.model.SystemConfig; import com.chatopera.cc.app.model.Tenant; import com.chatopera.cc.app.model.User; +import com.chatopera.cc.app.persistence.blob.JpaBlobHelper; +import com.chatopera.cc.app.persistence.repository.StreamingFileRepository; import com.chatopera.cc.app.persistence.repository.TenantRepository; import com.chatopera.cc.exception.CSKefuException; import org.apache.commons.lang.StringUtils; @@ -38,10 +41,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.SessionAttributes; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; +import java.io.IOException; import java.text.ParseException; import static org.elasticsearch.index.query.QueryBuilders.termQuery; @@ -56,6 +61,12 @@ public class Handler { @Autowired private TenantRepository tenantRes; + @Autowired + private JpaBlobHelper jpaBlobHelper; + + @Autowired + private StreamingFileRepository streamingFileRes; + public final static int PAGE_SIZE_BG = 1; public final static int PAGE_SIZE_TW = 20; public final static int PAGE_SIZE_FV = 50; @@ -461,4 +472,17 @@ public class Handler { public void setStarttime(long starttime) { this.starttime = starttime; } + + public String saveImageFileWithMultipart(MultipartFile multipart) throws IOException { + StreamingFile sf = new StreamingFile(); + final String fileid = MainUtils.getUUID(); + sf.setId(fileid); + sf.setMime(multipart.getContentType()); + sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize())); + sf.setName(multipart.getOriginalFilename()); + streamingFileRes.save(sf); + return fileid; + } + + } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java index 27eed0bf..1b003875 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java @@ -69,24 +69,6 @@ public class WebIMController extends Handler { @Autowired private SNSAccountRepository snsAccountRes; - @Autowired - private JpaBlobHelper jpaBlobHelper; - - @Autowired - private StreamingFileRepository streamingFileRes; - - - private String saveImageFile(MultipartFile multipart) throws IOException { - StreamingFile sf = new StreamingFile(); - final String fileid = MainUtils.getUUID(); - sf.setId(fileid); - sf.setMime(multipart.getContentType()); - sf.setData(jpaBlobHelper.createBlob(multipart.getInputStream(), multipart.getSize())); - sf.setName(multipart.getOriginalFilename()); - streamingFileRes.save(sf); - return fileid; - } - @RequestMapping("/index") @Menu(type = "app", subtype = "app", admin = true) public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String snsid) { @@ -125,12 +107,12 @@ public class WebIMController extends Handler { inviteData.setOrgi(super.getOrgi(request)); // 网页品牌标识 if (webimlogo != null && webimlogo.getOriginalFilename().lastIndexOf(".") > 0) { - inviteData.setConsult_dialog_logo(saveImageFile(webimlogo)); + inviteData.setConsult_dialog_logo(super.saveImageFileWithMultipart(webimlogo)); } // 网页坐席头像 if (agentheadimg != null && agentheadimg.getOriginalFilename().lastIndexOf(".") > 0) { - inviteData.setConsult_dialog_headimg(saveImageFile(agentheadimg)); + inviteData.setConsult_dialog_headimg(super.saveImageFileWithMultipart(agentheadimg)); } invite.save(inviteData); CacheHelper.getSystemCacheBean().put(inviteData.getSnsaccountid(), inviteData, inviteData.getOrgi()); @@ -208,7 +190,7 @@ public class WebIMController extends Handler { tempInviteData.setCtrlenter(inviteData.isCtrlenter()); if (dialogad != null && !StringUtils.isBlank(dialogad.getName()) && dialogad.getBytes() != null && dialogad.getBytes().length > 0) { - tempInviteData.setDialog_ad(saveImageFile(dialogad)); + tempInviteData.setDialog_ad(super.saveImageFileWithMultipart(dialogad)); } invite.save(tempInviteData); inviteData = tempInviteData; @@ -248,7 +230,7 @@ public class WebIMController extends Handler { tempInviteData.setConsult_invite_color(inviteData.getConsult_invite_color()); if (invotebg != null && !StringUtils.isBlank(invotebg.getName()) && invotebg.getBytes() != null && invotebg.getBytes().length > 0) { - tempInviteData.setConsult_invite_bg(saveImageFile(invotebg)); + tempInviteData.setConsult_invite_bg(super.saveImageFileWithMultipart(invotebg)); } invite.save(tempInviteData); inviteData = tempInviteData; diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/config/SystemConfigController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/config/SystemConfigController.java index 788d5b2f..a3d0fc49 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/config/SystemConfigController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/config/SystemConfigController.java @@ -16,28 +16,20 @@ */ package com.chatopera.cc.app.handler.admin.config; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.sql.SQLException; -import java.util.Date; -import java.util.List; -import java.util.Properties; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - import com.chatopera.cc.app.basic.MainContext; import com.chatopera.cc.app.basic.MainUtils; -import com.chatopera.cc.util.Menu; import com.chatopera.cc.app.cache.CacheHelper; +import com.chatopera.cc.app.handler.Handler; +import com.chatopera.cc.app.model.Secret; +import com.chatopera.cc.app.model.SysDic; +import com.chatopera.cc.app.model.SystemConfig; +import com.chatopera.cc.app.model.UKeFuDic; import com.chatopera.cc.app.persistence.repository.SecretRepository; import com.chatopera.cc.app.persistence.repository.SystemConfigRepository; import com.chatopera.cc.app.persistence.repository.SystemMessageRepository; import com.chatopera.cc.app.persistence.repository.TemplateRepository; -import com.chatopera.cc.app.model.Secret; -import com.chatopera.cc.app.model.SysDic; +import com.chatopera.cc.util.Menu; +import com.corundumstudio.socketio.SocketIOServer; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -50,222 +42,223 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; -import com.corundumstudio.socketio.SocketIOServer; -import com.chatopera.cc.app.handler.Handler; -import com.chatopera.cc.app.model.SystemConfig; -import com.chatopera.cc.app.model.UKeFuDic; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.security.NoSuchAlgorithmException; +import java.sql.SQLException; +import java.util.Date; +import java.util.List; +import java.util.Properties; @Controller @RequestMapping("/admin/config") -public class SystemConfigController extends Handler{ - - @Value("${uk.im.server.port}") +public class SystemConfigController extends Handler { + + @Value("${uk.im.server.port}") private Integer port; - @Value("${web.upload-path}") + @Value("${web.upload-path}") private String path; - - @Autowired - private SocketIOServer server ; - - @Autowired - private SystemConfigRepository systemConfigRes ; - - - @Autowired - private SystemMessageRepository systemMessageRes ; - - @Autowired - private SecretRepository secRes ; - - @Autowired - private TemplateRepository templateRes ; - + + @Autowired + private SocketIOServer server; + + @Autowired + private SystemConfigRepository systemConfigRes; + + + @Autowired + private SystemMessageRepository systemMessageRes; + + @Autowired + private SecretRepository secRes; + + @Autowired + private TemplateRepository templateRes; + @RequestMapping("/index") - @Menu(type = "admin" , subtype = "config" , admin = true) - public ModelAndView index(ModelMap map , HttpServletRequest request , @Valid String execute) throws SQLException { - map.addAttribute("server", server) ; - if(MainContext.model.get("im")!=null){ - map.addAttribute("entim", MainContext.model.get("im")) ; - } - if(request.getSession().getAttribute(MainContext.UKEFU_SYSTEM_INFOACQ)!=null){ - map.addAttribute("entim", request.getSession().getAttribute(MainContext.UKEFU_SYSTEM_INFOACQ)) ; - } - map.addAttribute("server", server) ; - map.addAttribute("imServerStatus", MainContext.getIMServerStatus()) ; - List secretConfig = secRes.findByOrgi(super.getOrgi(request)) ; - if(secretConfig!=null && secretConfig.size() > 0){ - map.addAttribute("secret", secretConfig.get(0)) ; - } - List dicList = UKeFuDic.getInstance().getDic(MainContext.UKEFU_SYSTEM_DIC) ; - SysDic callCenterDic = null , workOrderDic = null , smsDic = null ; - for(SysDic dic : dicList){ - if(dic.getCode().equals(MainContext.UKEFU_SYSTEM_CALLCENTER)){ - callCenterDic = dic ; - } - if(dic.getCode().equals(MainContext.UKEFU_SYSTEM_WORKORDEREMAIL)){ - workOrderDic = dic ; - } - if(dic.getCode().equals(MainContext.UKEFU_SYSTEM_SMSEMAIL)){ - smsDic = dic ; - } - } - if(callCenterDic!=null){ - map.addAttribute("templateList", templateRes.findByTemplettypeAndOrgi(callCenterDic.getId(), super.getOrgi(request))) ; - } - if(workOrderDic!=null){ - map.addAttribute("workOrderList", templateRes.findByTemplettypeAndOrgi(workOrderDic.getId(), super.getOrgi(request))) ; - } - if(smsDic!=null){ - map.addAttribute("smsList", templateRes.findByTemplettypeAndOrgi(smsDic.getId(), super.getOrgi(request))) ; - } - - map.addAttribute("sysMessageList", systemMessageRes.findByMsgtypeAndOrgi(MainContext.SystemMessageType.EMAIL.toString(), super.getOrgi(request))) ; - - if(!StringUtils.isBlank(execute) && execute.equals("false")){ - map.addAttribute("execute", execute) ; - } - if(!StringUtils.isBlank(request.getParameter("msg"))){ - map.addAttribute("msg", request.getParameter("msg")) ; - } + @Menu(type = "admin", subtype = "config", admin = true) + public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String execute) throws SQLException { + map.addAttribute("server", server); + if (MainContext.model.get("im") != null) { + map.addAttribute("entim", MainContext.model.get("im")); + } + if (request.getSession().getAttribute(MainContext.UKEFU_SYSTEM_INFOACQ) != null) { + map.addAttribute("entim", request.getSession().getAttribute(MainContext.UKEFU_SYSTEM_INFOACQ)); + } + map.addAttribute("server", server); + map.addAttribute("imServerStatus", MainContext.getIMServerStatus()); + List secretConfig = secRes.findByOrgi(super.getOrgi(request)); + if (secretConfig != null && secretConfig.size() > 0) { + map.addAttribute("secret", secretConfig.get(0)); + } + List dicList = UKeFuDic.getInstance().getDic(MainContext.UKEFU_SYSTEM_DIC); + SysDic callCenterDic = null, workOrderDic = null, smsDic = null; + for (SysDic dic : dicList) { + if (dic.getCode().equals(MainContext.UKEFU_SYSTEM_CALLCENTER)) { + callCenterDic = dic; + } + if (dic.getCode().equals(MainContext.UKEFU_SYSTEM_WORKORDEREMAIL)) { + workOrderDic = dic; + } + if (dic.getCode().equals(MainContext.UKEFU_SYSTEM_SMSEMAIL)) { + smsDic = dic; + } + } + if (callCenterDic != null) { + map.addAttribute("templateList", templateRes.findByTemplettypeAndOrgi(callCenterDic.getId(), super.getOrgi(request))); + } + if (workOrderDic != null) { + map.addAttribute("workOrderList", templateRes.findByTemplettypeAndOrgi(workOrderDic.getId(), super.getOrgi(request))); + } + if (smsDic != null) { + map.addAttribute("smsList", templateRes.findByTemplettypeAndOrgi(smsDic.getId(), super.getOrgi(request))); + } + + map.addAttribute("sysMessageList", systemMessageRes.findByMsgtypeAndOrgi(MainContext.SystemMessageType.EMAIL.toString(), super.getOrgi(request))); + + if (StringUtils.isNotBlank(execute) && execute.equals("false")) { + map.addAttribute("execute", execute); + } + if (StringUtils.isNotBlank(request.getParameter("msg"))) { + map.addAttribute("msg", request.getParameter("msg")); + } return request(super.createAdminTempletResponse("/admin/config/index")); } - + @RequestMapping("/stopimserver") - @Menu(type = "admin" , subtype = "stopimserver" , access = false , admin = true) - public ModelAndView stopimserver(ModelMap map , HttpServletRequest request , @Valid String confirm) throws SQLException { - boolean execute = false ; - if(execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)){ - server.stop(); - MainContext.setIMServerStatus(false); - } - return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute="+execute)); + @Menu(type = "admin", subtype = "stopimserver", access = false, admin = true) + public ModelAndView stopimserver(ModelMap map, HttpServletRequest request, @Valid String confirm) throws SQLException { + boolean execute = false; + if (execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)) { + server.stop(); + MainContext.setIMServerStatus(false); + } + return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute=" + execute)); } - + @RequestMapping("/startentim") - @Menu(type = "admin" , subtype = "startentim" , access = false , admin = true) - public ModelAndView startentim(ModelMap map , HttpServletRequest request) throws SQLException { - MainContext.model.put("im", true) ; + @Menu(type = "admin", subtype = "startentim", access = false, admin = true) + public ModelAndView startentim(ModelMap map, HttpServletRequest request) throws SQLException { + MainContext.model.put("im", true); return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html")); } - + @RequestMapping("/stopentim") - @Menu(type = "admin" , subtype = "stopentim" , access = false , admin = true) - public ModelAndView stopentim(ModelMap map , HttpServletRequest request) throws SQLException { - MainContext.model.remove("im") ; + @Menu(type = "admin", subtype = "stopentim", access = false, admin = true) + public ModelAndView stopentim(ModelMap map, HttpServletRequest request) throws SQLException { + MainContext.model.remove("im"); return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html")); } - + /** * 危险操作,请谨慎调用 , WebLogic/WebSphere/Oracle等中间件服务器禁止调用 + * * @param map * @param request * @return * @throws SQLException */ @RequestMapping("/stop") - @Menu(type = "admin" , subtype = "stop" , access = false , admin = true) - public ModelAndView stop(ModelMap map , HttpServletRequest request , @Valid String confirm) throws SQLException { - boolean execute = false ; - if(execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)){ - server.stop(); - MainContext.setIMServerStatus(false); - System.exit(0); - } - return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute="+execute)); + @Menu(type = "admin", subtype = "stop", access = false, admin = true) + public ModelAndView stop(ModelMap map, HttpServletRequest request, @Valid String confirm) throws SQLException { + boolean execute = false; + if (execute = MainUtils.secConfirm(secRes, super.getOrgi(request), confirm)) { + server.stop(); + MainContext.setIMServerStatus(false); + System.exit(0); + } + return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?execute=" + execute)); } - - + + @RequestMapping("/save") - @Menu(type = "admin" , subtype = "save" , admin = true) - public ModelAndView save(ModelMap map , HttpServletRequest request , @Valid SystemConfig config ,BindingResult result , @RequestParam(value = "keyfile", required = false) MultipartFile keyfile , @RequestParam(value = "loginlogo", required = false) MultipartFile loginlogo , @RequestParam(value = "consolelogo", required = false) MultipartFile consolelogo , @RequestParam(value = "favlogo", required = false) MultipartFile favlogo , @Valid Secret secret) throws SQLException, IOException, NoSuchAlgorithmException { + @Menu(type = "admin", subtype = "save", admin = true) + public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid SystemConfig config, BindingResult result, @RequestParam(value = "keyfile", required = false) MultipartFile keyfile, @RequestParam(value = "loginlogo", required = false) MultipartFile loginlogo, @RequestParam(value = "consolelogo", required = false) MultipartFile consolelogo, @RequestParam(value = "favlogo", required = false) MultipartFile favlogo, @Valid Secret secret) throws SQLException, IOException, NoSuchAlgorithmException { /*SystemConfig systemConfig = systemConfigRes.findByOrgi(super.getOrgi(request)) ; config.setOrgi(super.getOrgi(request));*/ - SystemConfig systemConfig = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI) ; - config.setOrgi(MainContext.SYSTEM_ORGI); - String msg = "0" ; - if(StringUtils.isBlank(config.getJkspassword())){ - config.setJkspassword(null); - } - if(systemConfig == null){ - config.setCreater(super.getUser(request).getId()); - config.setCreatetime(new Date()); - systemConfig = config ; - }else{ - MainUtils.copyProperties(config,systemConfig); - } - if(config.isEnablessl()){ - if(keyfile!=null && keyfile.getBytes()!=null && keyfile.getBytes().length > 0 && keyfile.getOriginalFilename()!=null && keyfile.getOriginalFilename().length() > 0){ - FileUtils.writeByteArrayToFile(new File(path , "ssl/"+keyfile.getOriginalFilename()), keyfile.getBytes()); - systemConfig.setJksfile(keyfile.getOriginalFilename()); - File sslFilePath = new File(path , "ssl/https.properties") ; - if(!sslFilePath.getParentFile().exists()) { - sslFilePath.getParentFile().mkdirs() ; - } - Properties prop = new Properties(); - FileOutputStream oFile = new FileOutputStream(sslFilePath);//true表示追加打开 - prop.setProperty("key-store-password", MainUtils.encryption(systemConfig.getJkspassword())) ; - prop.setProperty("key-store",systemConfig.getJksfile()) ; - prop.store(oFile , "SSL Properties File"); - oFile.close(); - } - }else if(new File(path , "ssl").exists()){ - File[] sslFiles = new File(path , "ssl").listFiles() ; - for(File sslFile : sslFiles){ - sslFile.delete(); - } - } - - if(loginlogo!=null && !StringUtils.isBlank(loginlogo.getOriginalFilename()) && loginlogo.getOriginalFilename().lastIndexOf(".") > 0) { - String logoFileName = "logo/"+ MainUtils.md5(loginlogo.getOriginalFilename())+loginlogo.getOriginalFilename().substring(loginlogo.getOriginalFilename().lastIndexOf(".")) ; - FileUtils.writeByteArrayToFile(new File(path ,logoFileName), loginlogo.getBytes()); - systemConfig.setLoginlogo(logoFileName); - } - if(consolelogo!=null && !StringUtils.isBlank(consolelogo.getOriginalFilename()) && consolelogo.getOriginalFilename().lastIndexOf(".") > 0) { - String consoleLogoFileName = "logo/"+ MainUtils.md5(consolelogo.getOriginalFilename())+consolelogo.getOriginalFilename().substring(consolelogo.getOriginalFilename().lastIndexOf(".")) ; - FileUtils.writeByteArrayToFile(new File(path ,consoleLogoFileName), consolelogo.getBytes()); - systemConfig.setConsolelogo(consoleLogoFileName); - } - if(favlogo!=null && !StringUtils.isBlank(favlogo.getOriginalFilename()) && consolelogo.getOriginalFilename().lastIndexOf(".") > 0) { - String favLogoFileName = "logo/"+ MainUtils.md5(favlogo.getOriginalFilename())+favlogo.getOriginalFilename().substring(favlogo.getOriginalFilename().lastIndexOf(".")) ; - FileUtils.writeByteArrayToFile(new File(path ,favLogoFileName), favlogo.getBytes()); - systemConfig.setFavlogo(favLogoFileName); - } - - if(secret!=null && !StringUtils.isBlank(secret.getPassword())){ - List secretConfig = secRes.findByOrgi(super.getOrgi(request)) ; - String repassword = request.getParameter("repassword") ; - if(!StringUtils.isBlank(repassword) && repassword.equals(secret.getPassword())){ - if(secretConfig!=null && secretConfig.size() > 0){ - Secret tempSecret = secretConfig.get(0) ; - String oldpass = request.getParameter("oldpass") ; - if(!StringUtils.isBlank(oldpass) && MainUtils.md5(oldpass).equals(tempSecret.getPassword())){ - tempSecret.setPassword(MainUtils.md5(secret.getPassword())); - msg = "1" ; - tempSecret.setEnable(true); - secRes.save(tempSecret) ; - }else{ - msg = "3" ; - } - }else{ - secret.setOrgi(super.getOrgi(request)); - secret.setCreater(super.getUser(request).getId()); - secret.setCreatetime(new Date()); - secret.setPassword(MainUtils.md5(secret.getPassword())); - secret.setEnable(true); - msg = "1" ; - secRes.save(secret) ; - } - }else{ - msg = "2" ; - } - map.addAttribute("msg", msg) ; - } - systemConfigRes.save(systemConfig) ; - - CacheHelper.getSystemCacheBean().put("systemConfig", systemConfig , super.getOrgi(request)); - map.addAttribute("imServerStatus", MainContext.getIMServerStatus()) ; - - return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?msg="+msg)); + SystemConfig systemConfig = systemConfigRes.findByOrgi(MainContext.SYSTEM_ORGI); + config.setOrgi(MainContext.SYSTEM_ORGI); + String msg = "0"; + if (StringUtils.isBlank(config.getJkspassword())) { + config.setJkspassword(null); + } + if (systemConfig == null) { + config.setCreater(super.getUser(request).getId()); + config.setCreatetime(new Date()); + systemConfig = config; + } else { + MainUtils.copyProperties(config, systemConfig); + } + if (config.isEnablessl()) { + if (keyfile != null && keyfile.getBytes() != null && keyfile.getBytes().length > 0 && keyfile.getOriginalFilename() != null && keyfile.getOriginalFilename().length() > 0) { + FileUtils.writeByteArrayToFile(new File(path, "ssl/" + keyfile.getOriginalFilename()), keyfile.getBytes()); + systemConfig.setJksfile(keyfile.getOriginalFilename()); + File sslFilePath = new File(path, "ssl/https.properties"); + if (!sslFilePath.getParentFile().exists()) { + sslFilePath.getParentFile().mkdirs(); + } + Properties prop = new Properties(); + FileOutputStream oFile = new FileOutputStream(sslFilePath);//true表示追加打开 + prop.setProperty("key-store-password", MainUtils.encryption(systemConfig.getJkspassword())); + prop.setProperty("key-store", systemConfig.getJksfile()); + prop.store(oFile, "SSL Properties File"); + oFile.close(); + } + } else if (new File(path, "ssl").exists()) { + File[] sslFiles = new File(path, "ssl").listFiles(); + for (File sslFile : sslFiles) { + sslFile.delete(); + } + } + + if (loginlogo != null && StringUtils.isNotBlank(loginlogo.getOriginalFilename()) && loginlogo.getOriginalFilename().lastIndexOf(".") > 0) { + systemConfig.setLoginlogo(super.saveImageFileWithMultipart(loginlogo)); + } + if (consolelogo != null && StringUtils.isNotBlank(consolelogo.getOriginalFilename()) && consolelogo.getOriginalFilename().lastIndexOf(".") > 0) { + systemConfig.setConsolelogo(super.saveImageFileWithMultipart(consolelogo)); + } + if (favlogo != null && StringUtils.isNotBlank(favlogo.getOriginalFilename()) && consolelogo.getOriginalFilename().lastIndexOf(".") > 0) { + systemConfig.setFavlogo(super.saveImageFileWithMultipart(favlogo)); + } + + if (secret != null && StringUtils.isNotBlank(secret.getPassword())) { + List secretConfig = secRes.findByOrgi(super.getOrgi(request)); + String repassword = request.getParameter("repassword"); + if (StringUtils.isNotBlank(repassword) && repassword.equals(secret.getPassword())) { + if (secretConfig != null && secretConfig.size() > 0) { + Secret tempSecret = secretConfig.get(0); + String oldpass = request.getParameter("oldpass"); + if (StringUtils.isNotBlank(oldpass) && MainUtils.md5(oldpass).equals(tempSecret.getPassword())) { + tempSecret.setPassword(MainUtils.md5(secret.getPassword())); + msg = "1"; + tempSecret.setEnable(true); + secRes.save(tempSecret); + } else { + msg = "3"; + } + } else { + secret.setOrgi(super.getOrgi(request)); + secret.setCreater(super.getUser(request).getId()); + secret.setCreatetime(new Date()); + secret.setPassword(MainUtils.md5(secret.getPassword())); + secret.setEnable(true); + msg = "1"; + secRes.save(secret); + } + } else { + msg = "2"; + } + map.addAttribute("msg", msg); + } + systemConfigRes.save(systemConfig); + + CacheHelper.getSystemCacheBean().put("systemConfig", systemConfig, super.getOrgi(request)); + map.addAttribute("imServerStatus", MainContext.getIMServerStatus()); + + return request(super.createRequestPageTempletResponse("redirect:/admin/config/index.html?msg=" + msg)); } } \ No newline at end of file diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/setting/IMAgentController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/setting/IMAgentController.java index e7c6b97b..94c348f1 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/setting/IMAgentController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/setting/IMAgentController.java @@ -16,26 +16,15 @@ */ package com.chatopera.cc.app.handler.apps.setting; -import java.io.File; -import java.io.IOException; -import java.util.Date; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - +import com.chatopera.cc.app.algorithm.AutomaticServiceDist; import com.chatopera.cc.app.basic.MainContext; import com.chatopera.cc.app.basic.MainUtils; -import com.chatopera.cc.util.Menu; -import com.chatopera.cc.app.algorithm.AutomaticServiceDist; import com.chatopera.cc.app.cache.CacheHelper; -import com.chatopera.cc.app.persistence.repository.AdTypeRepository; -import com.chatopera.cc.app.persistence.repository.SessionConfigRepository; -import com.chatopera.cc.app.persistence.repository.TagRepository; -import com.chatopera.cc.app.persistence.repository.TemplateRepository; -import com.chatopera.cc.app.model.AdType; -import com.chatopera.cc.app.model.SysDic; -import com.chatopera.cc.app.model.Tag; +import com.chatopera.cc.app.handler.Handler; +import com.chatopera.cc.app.model.*; +import com.chatopera.cc.app.persistence.blob.JpaBlobHelper; +import com.chatopera.cc.app.persistence.repository.*; +import com.chatopera.cc.util.Menu; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -43,297 +32,289 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; -import com.chatopera.cc.app.persistence.repository.BlackListRepository; -import com.chatopera.cc.app.handler.Handler; -import com.chatopera.cc.app.model.BlackEntity; -import com.chatopera.cc.app.model.SessionConfig; -import com.chatopera.cc.app.model.UKeFuDic; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Date; +import java.util.List; @Controller @RequestMapping("/setting") -public class IMAgentController extends Handler{ - - @Autowired - private SessionConfigRepository sessionConfigRes ; - - @Autowired - private TagRepository tagRes ; - - @Autowired - private BlackListRepository blackListRes; - - @Autowired - private AdTypeRepository adTypeRes; - - @Autowired - private TemplateRepository templateRes ; - - @Value("${web.upload-path}") +public class IMAgentController extends Handler { + + @Autowired + private SessionConfigRepository sessionConfigRes; + + @Autowired + private TagRepository tagRes; + + @Autowired + private BlackListRepository blackListRes; + + @Autowired + private AdTypeRepository adTypeRes; + + @Autowired + private TemplateRepository templateRes; + + + @Autowired + private StreamingFileRepository streamingFileRes; + + @Autowired + private JpaBlobHelper jpaBlobHelper; + + @Value("${web.upload-path}") private String path; @RequestMapping("/agent/index") - @Menu(type = "setting" , subtype = "sessionconfig" , admin= false) - public ModelAndView index(ModelMap map , HttpServletRequest request) { - SessionConfig sessionConfig = sessionConfigRes.findByOrgi(super.getOrgi(request)) ; - if(sessionConfig == null){ - sessionConfig = new SessionConfig() ; - } - map.put("sessionConfig", sessionConfig) ; - - - List dicList = UKeFuDic.getInstance().getDic(MainContext.UKEFU_SYSTEM_DIC) ; - SysDic inputDic = null , outputDic = null ; - for(SysDic dic : dicList){ - if(dic.getCode().equals(MainContext.UKEFU_SYSTEM_AI_INPUT)){ - inputDic = dic ; - } - if(dic.getCode().equals(MainContext.UKEFU_SYSTEM_AI_OUTPUT)){ - outputDic = dic ; - } - } - if(inputDic!=null){ - map.addAttribute("innputtemlet", templateRes.findByTemplettypeAndOrgi(inputDic.getId(), super.getOrgi(request))) ; - } - if(outputDic!=null){ - map.addAttribute("outputtemlet", templateRes.findByTemplettypeAndOrgi(outputDic.getId(), super.getOrgi(request))) ; - } - + @Menu(type = "setting", subtype = "sessionconfig", admin = false) + public ModelAndView index(ModelMap map, HttpServletRequest request) { + SessionConfig sessionConfig = sessionConfigRes.findByOrgi(super.getOrgi(request)); + if (sessionConfig == null) { + sessionConfig = new SessionConfig(); + } + map.put("sessionConfig", sessionConfig); + + + List dicList = UKeFuDic.getInstance().getDic(MainContext.UKEFU_SYSTEM_DIC); + SysDic inputDic = null, outputDic = null; + for (SysDic dic : dicList) { + if (dic.getCode().equals(MainContext.UKEFU_SYSTEM_AI_INPUT)) { + inputDic = dic; + } + if (dic.getCode().equals(MainContext.UKEFU_SYSTEM_AI_OUTPUT)) { + outputDic = dic; + } + } + if (inputDic != null) { + map.addAttribute("innputtemlet", templateRes.findByTemplettypeAndOrgi(inputDic.getId(), super.getOrgi(request))); + } + if (outputDic != null) { + map.addAttribute("outputtemlet", templateRes.findByTemplettypeAndOrgi(outputDic.getId(), super.getOrgi(request))); + } + return request(super.createAppsTempletResponse("/apps/setting/agent/index")); } - + @RequestMapping("/agent/sessionconfig/save") - @Menu(type = "setting" , subtype = "sessionconfig" , admin= false) - public ModelAndView sessionconfig(ModelMap map , HttpServletRequest request , @Valid SessionConfig sessionConfig) { - SessionConfig tempSessionConfig = sessionConfigRes.findByOrgi(super.getOrgi(request)) ; - if(tempSessionConfig == null){ - tempSessionConfig = sessionConfig; - tempSessionConfig.setCreater(super.getUser(request).getId()); - }else{ - MainUtils.copyProperties(sessionConfig, tempSessionConfig); - } - tempSessionConfig.setOrgi(super.getOrgi(request)); - sessionConfigRes.save(tempSessionConfig) ; - - CacheHelper.getSystemCacheBean().put(MainContext.SYSTEM_CACHE_SESSION_CONFIG+"_"+super.getOrgi(request),tempSessionConfig, super.getOrgi(request)) ; - - CacheHelper.getSystemCacheBean().delete(MainContext.SYSTEM_CACHE_SESSION_CONFIG_LIST , MainContext.SYSTEM_ORGI) ; - - AutomaticServiceDist.initSessionConfigList() ; - map.put("sessionConfig", tempSessionConfig) ; - - - + @Menu(type = "setting", subtype = "sessionconfig", admin = false) + public ModelAndView sessionconfig(ModelMap map, HttpServletRequest request, @Valid SessionConfig sessionConfig) { + SessionConfig tempSessionConfig = sessionConfigRes.findByOrgi(super.getOrgi(request)); + if (tempSessionConfig == null) { + tempSessionConfig = sessionConfig; + tempSessionConfig.setCreater(super.getUser(request).getId()); + } else { + MainUtils.copyProperties(sessionConfig, tempSessionConfig); + } + tempSessionConfig.setOrgi(super.getOrgi(request)); + sessionConfigRes.save(tempSessionConfig); + + CacheHelper.getSystemCacheBean().put(MainContext.SYSTEM_CACHE_SESSION_CONFIG + "_" + super.getOrgi(request), tempSessionConfig, super.getOrgi(request)); + + CacheHelper.getSystemCacheBean().delete(MainContext.SYSTEM_CACHE_SESSION_CONFIG_LIST, MainContext.SYSTEM_ORGI); + + AutomaticServiceDist.initSessionConfigList(); + map.put("sessionConfig", tempSessionConfig); + + return request(super.createRequestPageTempletResponse("redirect:/setting/agent/index.html")); } - + @RequestMapping("/blacklist") - @Menu(type = "setting" , subtype = "blacklist" , admin= false) - public ModelAndView blacklist(ModelMap map , HttpServletRequest request) { - map.put("blackList", blackListRes.findByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "endtime"))) ; - map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type")) ; - return request(super.createAppsTempletResponse("/apps/setting/agent/blacklist")); + @Menu(type = "setting", subtype = "blacklist", admin = false) + public ModelAndView blacklist(ModelMap map, HttpServletRequest request) { + map.put("blackList", blackListRes.findByOrgi(super.getOrgi(request), new PageRequest(super.getP(request), super.getPs(request), Sort.Direction.DESC, "endtime"))); + map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type")); + return request(super.createAppsTempletResponse("/apps/setting/agent/blacklist")); } - + @RequestMapping("/blacklist/delete") - @Menu(type = "setting" , subtype = "tag" , admin= false) - public ModelAndView blacklistdelete(ModelMap map , HttpServletRequest request , @Valid String id) { - if(!StringUtils.isBlank(id)){ - BlackEntity tempBlackEntity = blackListRes.findByIdAndOrgi(id, super.getOrgi(request)) ; - if(tempBlackEntity!=null){ - blackListRes.delete(tempBlackEntity); - CacheHelper.getSystemCacheBean().delete(tempBlackEntity.getUserid(), MainContext.SYSTEM_ORGI) ; - } - } - return request(super.createRequestPageTempletResponse("redirect:/setting/blacklist.html")); + @Menu(type = "setting", subtype = "tag", admin = false) + public ModelAndView blacklistdelete(ModelMap map, HttpServletRequest request, @Valid String id) { + if (!StringUtils.isBlank(id)) { + BlackEntity tempBlackEntity = blackListRes.findByIdAndOrgi(id, super.getOrgi(request)); + if (tempBlackEntity != null) { + blackListRes.delete(tempBlackEntity); + CacheHelper.getSystemCacheBean().delete(tempBlackEntity.getUserid(), MainContext.SYSTEM_ORGI); + } + } + return request(super.createRequestPageTempletResponse("redirect:/setting/blacklist.html")); } - + @RequestMapping("/tag") - @Menu(type = "setting" , subtype = "tag" , admin= false) - public ModelAndView tag(ModelMap map , HttpServletRequest request , @Valid String code) { - SysDic tagType = null ; - List tagList = UKeFuDic.getInstance().getDic("com.dic.tag.type") ; - if(tagList.size() > 0){ - - if(!StringUtils.isBlank(code)){ - for(SysDic dic : tagList){ - if(code.equals(dic.getCode())){ - tagType = dic ; - } - } - }else{ - tagType = tagList.get(0) ; - } - map.put("tagType", tagType) ; - } - if(tagType!=null){ - map.put("tagList", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , tagType.getCode() , new PageRequest(super.getP(request), super.getPs(request)))) ; - } - map.put("tagTypeList", tagList) ; - return request(super.createAppsTempletResponse("/apps/setting/agent/tag")); + @Menu(type = "setting", subtype = "tag", admin = false) + public ModelAndView tag(ModelMap map, HttpServletRequest request, @Valid String code) { + SysDic tagType = null; + List tagList = UKeFuDic.getInstance().getDic("com.dic.tag.type"); + if (tagList.size() > 0) { + + if (!StringUtils.isBlank(code)) { + for (SysDic dic : tagList) { + if (code.equals(dic.getCode())) { + tagType = dic; + } + } + } else { + tagType = tagList.get(0); + } + map.put("tagType", tagType); + } + if (tagType != null) { + map.put("tagList", tagRes.findByOrgiAndTagtype(super.getOrgi(request), tagType.getCode(), new PageRequest(super.getP(request), super.getPs(request)))); + } + map.put("tagTypeList", tagList); + return request(super.createAppsTempletResponse("/apps/setting/agent/tag")); } - + @RequestMapping("/tag/add") - @Menu(type = "setting" , subtype = "tag" , admin= false) - public ModelAndView tagadd(ModelMap map , HttpServletRequest request , @Valid String tagtype) { - map.addAttribute("tagtype", tagtype) ; + @Menu(type = "setting", subtype = "tag", admin = false) + public ModelAndView tagadd(ModelMap map, HttpServletRequest request, @Valid String tagtype) { + map.addAttribute("tagtype", tagtype); return request(super.createRequestPageTempletResponse("/apps/setting/agent/tagadd")); } - + @RequestMapping("/tag/edit") - @Menu(type = "setting" , subtype = "tag" , admin= false) - public ModelAndView tagedit(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String tagtype) { - map.put("tag", tagRes.findOne(id)) ; - map.addAttribute("tagtype", tagtype) ; + @Menu(type = "setting", subtype = "tag", admin = false) + public ModelAndView tagedit(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tagtype) { + map.put("tag", tagRes.findOne(id)); + map.addAttribute("tagtype", tagtype); return request(super.createRequestPageTempletResponse("/apps/setting/agent/tagedit")); } - + @RequestMapping("/tag/update") - @Menu(type = "setting" , subtype = "tag" , admin= false) - public ModelAndView tagupdate(ModelMap map , HttpServletRequest request , @Valid Tag tag , @Valid String tagtype) { - Tag temptag = tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag()) ; - if(temptag == null || tag.getId().equals(temptag.getId())){ - tag.setOrgi(super.getOrgi(request)); - tag.setCreater(super.getUser(request).getId()); - tagRes.save(tag) ; - } - return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code="+tagtype)); + @Menu(type = "setting", subtype = "tag", admin = false) + public ModelAndView tagupdate(ModelMap map, HttpServletRequest request, @Valid Tag tag, @Valid String tagtype) { + Tag temptag = tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag()); + if (temptag == null || tag.getId().equals(temptag.getId())) { + tag.setOrgi(super.getOrgi(request)); + tag.setCreater(super.getUser(request).getId()); + tagRes.save(tag); + } + return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype)); } - + @RequestMapping("/tag/save") - @Menu(type = "setting" , subtype = "tag" , admin= false) - public ModelAndView tagsave(ModelMap map , HttpServletRequest request , @Valid Tag tag , @Valid String tagtype) { - if(tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag()) == null){ - tag.setOrgi(super.getOrgi(request)); - tag.setCreater(super.getUser(request).getId()); - tagRes.save(tag) ; - } - return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code="+tagtype)); + @Menu(type = "setting", subtype = "tag", admin = false) + public ModelAndView tagsave(ModelMap map, HttpServletRequest request, @Valid Tag tag, @Valid String tagtype) { + if (tagRes.findByOrgiAndTag(super.getOrgi(request), tag.getTag()) == null) { + tag.setOrgi(super.getOrgi(request)); + tag.setCreater(super.getUser(request).getId()); + tagRes.save(tag); + } + return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype)); } - + @RequestMapping("/tag/delete") - @Menu(type = "setting" , subtype = "tag" , admin= false) - public ModelAndView tagdelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String tagtype) { - tagRes.delete(id); - return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code="+tagtype)); + @Menu(type = "setting", subtype = "tag", admin = false) + public ModelAndView tagdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tagtype) { + tagRes.delete(id); + return request(super.createRequestPageTempletResponse("redirect:/setting/tag.html?code=" + tagtype)); } - - - + + @RequestMapping("/acd") - @Menu(type = "setting" , subtype = "acd" , admin= false) - public ModelAndView acd(ModelMap map , HttpServletRequest request) { - map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type")) ; - return request(super.createAppsTempletResponse("/apps/setting/agent/acd")); + @Menu(type = "setting", subtype = "acd", admin = false) + public ModelAndView acd(ModelMap map, HttpServletRequest request) { + map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type")); + return request(super.createAppsTempletResponse("/apps/setting/agent/acd")); } - - + + @RequestMapping("/adv") - @Menu(type = "setting" , subtype = "adv" , admin= false) - public ModelAndView adv(ModelMap map , HttpServletRequest request , @Valid String adpos) { - SysDic advType = null ; - List tagList = UKeFuDic.getInstance().getDic("com.dic.adv.type") ; - if(tagList.size() > 0){ - if(!StringUtils.isBlank(adpos)){ - for(SysDic dic : tagList){ - if(adpos.equals(dic.getId())){ - advType = dic ; - } - } - }else{ - advType = tagList.get(0) ; - } - map.put("advType", advType) ; - } - if(advType!=null){ - map.put("adTypeList", adTypeRes.findByAdposAndOrgi(advType.getId() , super.getOrgi(request))) ; - } - - map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type")) ; - - map.put("advTypeList", UKeFuDic.getInstance().getDic("com.dic.adv.type")) ; - - return request(super.createAppsTempletResponse("/apps/setting/agent/adv")); + @Menu(type = "setting", subtype = "adv", admin = false) + public ModelAndView adv(ModelMap map, HttpServletRequest request, @Valid String adpos) { + SysDic advType = null; + List tagList = UKeFuDic.getInstance().getDic("com.dic.adv.type"); + if (tagList.size() > 0) { + if (!StringUtils.isBlank(adpos)) { + for (SysDic dic : tagList) { + if (adpos.equals(dic.getId())) { + advType = dic; + } + } + } else { + advType = tagList.get(0); + } + map.put("advType", advType); + } + if (advType != null) { + map.put("adTypeList", adTypeRes.findByAdposAndOrgi(advType.getId(), super.getOrgi(request))); + } + + map.put("tagTypeList", UKeFuDic.getInstance().getDic("com.dic.tag.type")); + + map.put("advTypeList", UKeFuDic.getInstance().getDic("com.dic.adv.type")); + + return request(super.createAppsTempletResponse("/apps/setting/agent/adv")); } - + @RequestMapping("/adv/add") - @Menu(type = "setting" , subtype = "adv" , admin= false) - public ModelAndView advadd(ModelMap map , HttpServletRequest request , @Valid String adpos) { - map.addAttribute("adpos", adpos) ; + @Menu(type = "setting", subtype = "adv", admin = false) + public ModelAndView advadd(ModelMap map, HttpServletRequest request, @Valid String adpos) { + map.addAttribute("adpos", adpos); return request(super.createRequestPageTempletResponse("/apps/setting/agent/adadd")); } - + @RequestMapping("/adv/save") - @Menu(type = "setting" , subtype = "adv" , admin= false) - public ModelAndView advsave(ModelMap map , HttpServletRequest request , @Valid AdType adv , @Valid String advtype , @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException { - adv.setOrgi(super.getOrgi(request)); - adv.setCreater(super.getUser(request).getId()); - if(!StringUtils.isBlank(adv.getContent())){ - adv.setContent(adv.getContent().replaceAll("\"", "'")); - } - adv.setCreatetime(new Date()); - if(imgfile!=null && imgfile.getSize() > 0){ - File adDir = new File(path , "adv"); - if(!adDir.exists()){ - adDir.mkdirs() ; - } - String fileName = "adv/"+ MainUtils.getUUID()+imgfile.getOriginalFilename().substring(imgfile.getOriginalFilename().lastIndexOf(".")) ; - FileCopyUtils.copy(imgfile.getBytes(), new File(path , fileName)); - adv.setImgurl("/res/image.html?id="+java.net.URLEncoder.encode(fileName , "UTF-8")); - } - adTypeRes.save(adv) ; - - MainUtils.initAdv(super.getOrgi(request)); - - return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos="+adv.getAdpos())); + @Menu(type = "setting", subtype = "adv", admin = false) + public ModelAndView advsave(ModelMap map, HttpServletRequest request, @Valid AdType adv, @Valid String advtype, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException { + adv.setOrgi(super.getOrgi(request)); + adv.setCreater(super.getUser(request).getId()); + if (StringUtils.isNotBlank(adv.getContent())) { + adv.setContent(adv.getContent().replaceAll("\"", "'")); + } + adv.setCreatetime(new Date()); + if (imgfile != null && imgfile.getSize() > 0) { + adv.setImgurl("/res/image.html?id=" + super.saveImageFileWithMultipart(imgfile)); + } + adTypeRes.save(adv); + + MainUtils.initAdv(super.getOrgi(request)); + + return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adv.getAdpos())); } - + @RequestMapping("/adv/edit") - @Menu(type = "setting" , subtype = "adv" , admin= false) - public ModelAndView advedit(ModelMap map , HttpServletRequest request , @Valid String adpos, @Valid String id) { - map.addAttribute("adpos", adpos) ; - map.put("ad", adTypeRes.findByIdAndOrgi(id , super.getOrgi(request))) ; + @Menu(type = "setting", subtype = "adv", admin = false) + public ModelAndView advedit(ModelMap map, HttpServletRequest request, @Valid String adpos, @Valid String id) { + map.addAttribute("adpos", adpos); + map.put("ad", adTypeRes.findByIdAndOrgi(id, super.getOrgi(request))); return request(super.createRequestPageTempletResponse("/apps/setting/agent/adedit")); } - + @RequestMapping("/adv/update") - @Menu(type = "setting" , subtype = "adv" , admin= false) - public ModelAndView advupdate(ModelMap map , HttpServletRequest request , @Valid AdType ad, @Valid String adpos, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException { - AdType tempad = adTypeRes.findByIdAndOrgi(ad.getId(),super.getOrgi(request)) ; - if(tempad != null){ - ad.setOrgi(super.getOrgi(request)); - ad.setCreater(tempad.getCreater()); - ad.setCreatetime(tempad.getCreatetime()); - if(!StringUtils.isBlank(ad.getContent())){ - ad.setContent(ad.getContent().replaceAll("\"", "'")); - } - if(imgfile!=null && imgfile.getSize() > 0){ - File adDir = new File(path , "adv"); - if(!adDir.exists()){ - adDir.mkdirs() ; - } - String fileName = "adv/"+ MainUtils.getUUID()+imgfile.getOriginalFilename().substring(imgfile.getOriginalFilename().lastIndexOf(".")) ; - FileCopyUtils.copy(imgfile.getBytes(), new File(path , fileName)); - ad.setImgurl("/res/image.html?id="+java.net.URLEncoder.encode(fileName , "UTF-8")); - }else{ - ad.setImgurl(tempad.getImgurl()); - } - adTypeRes.save(ad) ; - MainUtils.initAdv(super.getOrgi(request)); - } - return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos="+adpos)); + @Menu(type = "setting", subtype = "adv", admin = false) + public ModelAndView advupdate(ModelMap map, HttpServletRequest request, @Valid AdType ad, @Valid String adpos, @RequestParam(value = "imgfile", required = false) MultipartFile imgfile) throws IOException { + AdType tempad = adTypeRes.findByIdAndOrgi(ad.getId(), super.getOrgi(request)); + if (tempad != null) { + ad.setOrgi(super.getOrgi(request)); + ad.setCreater(tempad.getCreater()); + ad.setCreatetime(tempad.getCreatetime()); + if (StringUtils.isNotBlank(ad.getContent())) { + ad.setContent(ad.getContent().replaceAll("\"", "'")); + } + if (imgfile != null && imgfile.getSize() > 0) { + ad.setImgurl("/res/image.html?id=" + super.saveImageFileWithMultipart(imgfile)); + } else { + ad.setImgurl(tempad.getImgurl()); + } + adTypeRes.save(ad); + MainUtils.initAdv(super.getOrgi(request)); + } + return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adpos)); } - + @RequestMapping("/adv/delete") - @Menu(type = "setting" , subtype = "adv" , admin= false) - public ModelAndView advdelete(ModelMap map , HttpServletRequest request , @Valid String id , @Valid String adpos) { - adTypeRes.delete(id); - MainUtils.initAdv(super.getOrgi(request)); - return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos="+adpos)); + @Menu(type = "setting", subtype = "adv", admin = false) + public ModelAndView advdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String adpos) { + adTypeRes.delete(id); + MainUtils.initAdv(super.getOrgi(request)); + return request(super.createRequestPageTempletResponse("redirect:/setting/adv.html?adpos=" + adpos)); } } \ No newline at end of file From fc9ab870989e30eaff9c06e15f8435be0eaeb2dd Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 25 Oct 2018 17:49:23 +0800 Subject: [PATCH 49/54] =?UTF-8?q?Closed=20#121=20=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E5=9D=90=E5=B8=AD=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/algorithm/AutomaticServiceDist.java | 5 +- .../com/chatopera/cc/app/handler/Handler.java | 6 + .../apps/service/OnlineUserController.java | 291 +++++++++--------- .../app/im/handler/ChatbotEventHandler.java | 5 +- .../cc/app/im/handler/IMEventHandler.java | 2 +- .../repository/AgentServiceRepository.java | 2 +- .../templates/apps/service/history/index.html | 3 +- 7 files changed, 153 insertions(+), 161 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java b/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java index 0f66550b..dc40f81e 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/algorithm/AutomaticServiceDist.java @@ -72,7 +72,6 @@ public class AutomaticServiceDist { /** * 载入坐席 ACD策略配置 * - * @param orgi * @return */ @SuppressWarnings("unchecked") @@ -530,7 +529,7 @@ public class AutomaticServiceDist { * @return * @throws Exception */ - public static AgentService processChatbotService(final AgentUser agentUser, final String orgi) { + public static AgentService processChatbotService(final String botName, final AgentUser agentUser, final String orgi) { AgentService agentService = new AgentService(); //放入缓存的对象 AgentServiceRepository agentServiceRes = MainContext.getContext().getBean(AgentServiceRepository.class); Date now = new Date(); @@ -550,6 +549,8 @@ public class AutomaticServiceDist { agentService.setRegion(agentUser.getRegion()); agentService.setUsername(agentUser.getUsername()); agentService.setChannel(agentUser.getChannel()); + if (botName != null) + agentService.setAgentusername(botName); if (StringUtils.isNotBlank(agentUser.getContextid())) { agentService.setContextid(agentUser.getContextid()); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java index b7c3cd3e..412b9930 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/Handler.java @@ -473,6 +473,12 @@ public class Handler { this.starttime = starttime; } + /** + * 使用Blob保存文件 + * @param multipart + * @return id + * @throws IOException + */ public String saveImageFileWithMultipart(MultipartFile multipart) throws IOException { StreamingFile sf = new StreamingFile(); final String fileid = MainUtils.getUUID(); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/OnlineUserController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/OnlineUserController.java index ed3621f7..4373ce35 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/OnlineUserController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/apps/service/OnlineUserController.java @@ -16,20 +16,14 @@ */ package com.chatopera.cc.app.handler.apps.service; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - import com.chatopera.cc.app.basic.MainContext; -import com.chatopera.cc.util.Menu; +import com.chatopera.cc.app.basic.MainUtils; +import com.chatopera.cc.app.handler.Handler; +import com.chatopera.cc.app.model.*; import com.chatopera.cc.app.persistence.es.ContactsRepository; import com.chatopera.cc.app.persistence.impl.AgentUserService; -import com.chatopera.cc.app.handler.Handler; -import com.chatopera.cc.app.model.AgentServiceSummary; -import com.chatopera.cc.app.model.AgentUser; -import com.chatopera.cc.app.model.AgentUserContacts; -import com.chatopera.cc.app.model.OnlineUser; +import com.chatopera.cc.app.persistence.repository.*; +import com.chatopera.cc.util.Menu; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; @@ -39,156 +33,147 @@ import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; -import com.chatopera.cc.app.basic.MainUtils; -import com.chatopera.cc.app.persistence.repository.AgentServiceRepository; -import com.chatopera.cc.app.persistence.repository.AgentUserContactsRepository; -import com.chatopera.cc.app.persistence.repository.ChatMessageRepository; -import com.chatopera.cc.app.persistence.repository.OnlineUserHisRepository; -import com.chatopera.cc.app.persistence.repository.OnlineUserRepository; -import com.chatopera.cc.app.persistence.repository.ServiceSummaryRepository; -import com.chatopera.cc.app.persistence.repository.TagRelationRepository; -import com.chatopera.cc.app.persistence.repository.TagRepository; -import com.chatopera.cc.app.persistence.repository.UserEventRepository; -import com.chatopera.cc.app.persistence.repository.WeiXinUserRepository; -import com.chatopera.cc.app.model.AgentService; -import com.chatopera.cc.app.model.WeiXinUser; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.List; @Controller @RequestMapping("/service") public class OnlineUserController extends Handler { - @Autowired - private AgentServiceRepository agentServiceRes ; - - @Autowired - private AgentUserService agentUserRes ; - - @Autowired - private OnlineUserRepository onlineUserRes; - - @Autowired - private UserEventRepository userEventRes; - - @Autowired - private ServiceSummaryRepository serviceSummaryRes; - - - @Autowired - private OnlineUserHisRepository onlineUserHisRes; - - @Autowired - private WeiXinUserRepository weiXinUserRes; - - @Autowired - private TagRepository tagRes ; - - @Autowired - private TagRelationRepository tagRelationRes ; - - @Autowired - private ChatMessageRepository chatMessageRepository ; - - @Autowired - private ContactsRepository contactsRes ; - - @Autowired - private AgentUserContactsRepository agentUserContactsRes ; - - @RequestMapping("/online/index") - @Menu(type = "service" , subtype = "online" , admin= true) - public ModelAndView index(ModelMap map , HttpServletRequest request , String userid , String agentservice , @Valid String channel) { - if(!StringUtils.isBlank(userid)){ - map.put("inviteResult", MainUtils.getWebIMInviteResult(onlineUserRes.findByOrgiAndUserid(super.getOrgi(request), userid))) ; - map.put("tagRelationList", tagRelationRes.findByUserid(userid)) ; - map.put("onlineUserHistList", onlineUserHisRes.findByUseridAndOrgi(userid, super.getOrgi(request))) ; - map.put("agentServicesAvg", onlineUserRes.countByUserForAvagTime(super.getOrgi(request), MainContext.AgentUserStatusEnum.END.toString(),userid)) ; - - List agentServiceList = agentServiceRes.findByUseridAndOrgi(userid, super.getOrgi(request)) ; - - map.put("agentServiceList", agentServiceList) ; - if(agentServiceList.size()>0){ - map.put("serviceCount", Integer - .valueOf(this.agentServiceRes - .countByUseridAndOrgiAndStatus(userid, super.getOrgi(request), - MainContext.AgentUserStatusEnum.END.toString()))); - - AgentService agentService = agentServiceList.get(0) ; - if(!StringUtils.isBlank(agentservice)){ - for(AgentService as : agentServiceList){ - if(as.getId().equals(agentservice)){ - agentService = as ; break ; - } - } - } - - if(agentService!=null){ - List summaries = serviceSummaryRes.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request)) ; - if(summaries.size() > 0) - map.put("summary" , summaries.get(0)) ; - } - - List agentUserContactsList = agentUserContactsRes.findByUseridAndOrgi(userid, super.getOrgi(request)) ; - if(agentUserContactsList.size() > 0){ - AgentUserContacts agentUserContacts = agentUserContactsList.get(0) ; - map.put("contacts", contactsRes.findOne(agentUserContacts.getContactsid())) ; - } - - map.put("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.USER.toString())) ; - map.put("summaryTags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.SUMMARY.toString())) ; - map.put("curAgentService", agentService) ; - - - map.put("agentUserMessageList", chatMessageRepository.findByAgentserviceidAndOrgi(agentService.getId() , super.getOrgi(request), new PageRequest(0, 50, Direction.DESC , "updatetime"))); - } - - if(MainContext.ChannelTypeEnum.WEIXIN.toString().equals(channel)){ - List weiXinUserList = weiXinUserRes.findByOpenidAndOrgi(userid, super.getOrgi(request)) ; - if(weiXinUserList.size() > 0){ - WeiXinUser weiXinUser = weiXinUserList.get(0) ; - map.put("weiXinUser",weiXinUser); - } - }else if(MainContext.ChannelTypeEnum.WEBIM.toString().equals(channel)){ - List onlineUserList = onlineUserRes.findByUseridAndOrgi(userid, super.getOrgi(request)) ; - if(onlineUserList.size() >0){ - map.put("onlineUser", onlineUserList.get(0)) ; - } - } - map.put("agentUser", agentUserRes.findByUseridAndOrgi(userid, super.getOrgi(request))) ; - map.put("curragentuser", agentUserRes.findByUseridAndOrgi(userid, super.getOrgi(request))) ; - } + @Autowired + private AgentServiceRepository agentServiceRes; + + @Autowired + private AgentUserService agentUserRes; + + @Autowired + private OnlineUserRepository onlineUserRes; + + @Autowired + private UserEventRepository userEventRes; + + @Autowired + private ServiceSummaryRepository serviceSummaryRes; + + + @Autowired + private OnlineUserHisRepository onlineUserHisRes; + + @Autowired + private WeiXinUserRepository weiXinUserRes; + + @Autowired + private TagRepository tagRes; + + @Autowired + private TagRelationRepository tagRelationRes; + + @Autowired + private ChatMessageRepository chatMessageRepository; + + @Autowired + private ContactsRepository contactsRes; + + @Autowired + private AgentUserContactsRepository agentUserContactsRes; + + @RequestMapping("/online/index") + @Menu(type = "service", subtype = "online", admin = true) + public ModelAndView index(ModelMap map, HttpServletRequest request, String userid, String agentservice, @Valid String channel) { + if (StringUtils.isNotBlank(userid)) { + map.put("inviteResult", MainUtils.getWebIMInviteResult(onlineUserRes.findByOrgiAndUserid(super.getOrgi(request), userid))); + map.put("tagRelationList", tagRelationRes.findByUserid(userid)); + map.put("onlineUserHistList", onlineUserHisRes.findByUseridAndOrgi(userid, super.getOrgi(request))); + map.put("agentServicesAvg", onlineUserRes.countByUserForAvagTime(super.getOrgi(request), MainContext.AgentUserStatusEnum.END.toString(), userid)); + + List agentServiceList = agentServiceRes.findByUseridAndOrgiOrderByLogindateDesc(userid, super.getOrgi(request)); + + map.put("agentServiceList", agentServiceList); + if (agentServiceList.size() > 0) { + map.put("serviceCount", Integer + .valueOf(this.agentServiceRes + .countByUseridAndOrgiAndStatus(userid, super.getOrgi(request), + MainContext.AgentUserStatusEnum.END.toString()))); + + AgentService agentService = agentServiceList.get(0); + if (StringUtils.isNotBlank(agentservice)) { + for (AgentService as : agentServiceList) { + if (as.getId().equals(agentservice)) { + agentService = as; + break; + } + } + } + + if (agentService != null) { + List summaries = serviceSummaryRes.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request)); + if (summaries.size() > 0) + map.put("summary", summaries.get(0)); + } + + List agentUserContactsList = agentUserContactsRes.findByUseridAndOrgi(userid, super.getOrgi(request)); + if (agentUserContactsList.size() > 0) { + AgentUserContacts agentUserContacts = agentUserContactsList.get(0); + map.put("contacts", contactsRes.findOne(agentUserContacts.getContactsid())); + } + + map.put("tags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.USER.toString())); + map.put("summaryTags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.SUMMARY.toString())); + map.put("curAgentService", agentService); + + + map.put("agentUserMessageList", chatMessageRepository.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request), new PageRequest(0, 50, Direction.DESC, "updatetime"))); + } + + if (MainContext.ChannelTypeEnum.WEIXIN.toString().equals(channel)) { + List weiXinUserList = weiXinUserRes.findByOpenidAndOrgi(userid, super.getOrgi(request)); + if (weiXinUserList.size() > 0) { + WeiXinUser weiXinUser = weiXinUserList.get(0); + map.put("weiXinUser", weiXinUser); + } + } else if (MainContext.ChannelTypeEnum.WEBIM.toString().equals(channel)) { + List onlineUserList = onlineUserRes.findByUseridAndOrgi(userid, super.getOrgi(request)); + if (onlineUserList.size() > 0) { + map.put("onlineUser", onlineUserList.get(0)); + } + } + map.put("agentUser", agentUserRes.findByUseridAndOrgi(userid, super.getOrgi(request))); + map.put("curragentuser", agentUserRes.findByUseridAndOrgi(userid, super.getOrgi(request))); + } return request(super.createAppsTempletResponse("/apps/service/online/index")); } - - @RequestMapping("/online/chatmsg") - @Menu(type = "service" , subtype = "chatmsg" , admin= true) - public ModelAndView onlinechat(ModelMap map , HttpServletRequest request , String id , String title) { - AgentService agentService = agentServiceRes.getOne(id) ; - AgentUser curragentuser = agentUserRes.findByUseridAndOrgi(agentService.getUserid(), super.getOrgi(request)) ; - - map.put("curAgentService", agentService) ; - map.put("curragentuser", curragentuser) ; - if(!StringUtils.isBlank(title)){ - map.put("title", title) ; - } - - map.put("summaryTags", tagRes.findByOrgiAndTagtype(super.getOrgi(request) , MainContext.ModelType.SUMMARY.toString())) ; - - if(agentService!=null){ - List summaries = serviceSummaryRes.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request)) ; - if(summaries.size() > 0) - map.put("summary" , summaries.get(0)) ; - } - - map.put("agentUserMessageList", chatMessageRepository.findByAgentserviceidAndOrgi(agentService.getId() , super.getOrgi(request), new PageRequest(0, 50, Direction.DESC , "updatetime"))); - + + @RequestMapping("/online/chatmsg") + @Menu(type = "service", subtype = "chatmsg", admin = true) + public ModelAndView onlinechat(ModelMap map, HttpServletRequest request, String id, String title) { + AgentService agentService = agentServiceRes.getOne(id); + AgentUser curragentuser = agentUserRes.findByUseridAndOrgi(agentService.getUserid(), super.getOrgi(request)); + + map.put("curAgentService", agentService); + map.put("curragentuser", curragentuser); + if (StringUtils.isNotBlank(title)) { + map.put("title", title); + } + + map.put("summaryTags", tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.ModelType.SUMMARY.toString())); + + if (agentService != null) { + List summaries = serviceSummaryRes.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request)); + if (summaries.size() > 0) + map.put("summary", summaries.get(0)); + } + + map.put("agentUserMessageList", chatMessageRepository.findByAgentserviceidAndOrgi(agentService.getId(), super.getOrgi(request), new PageRequest(0, 50, Direction.DESC, "updatetime"))); + return request(super.createRequestPageTempletResponse("/apps/service/online/chatmsg")); } - - @RequestMapping("/trace") - @Menu(type = "service" , subtype = "trace" , admin= false) - public ModelAndView trace(ModelMap map , HttpServletRequest request , @Valid String sessionid) { - if(!StringUtils.isBlank(sessionid)){ - map.addAttribute("traceHisList", userEventRes.findBySessionidAndOrgi(sessionid, super.getOrgi(request), new PageRequest(0, 100))) ; - } + + @RequestMapping("/trace") + @Menu(type = "service", subtype = "trace", admin = false) + public ModelAndView trace(ModelMap map, HttpServletRequest request, @Valid String sessionid) { + if (StringUtils.isNotBlank(sessionid)) { + map.addAttribute("traceHisList", userEventRes.findBySessionidAndOrgi(sessionid, super.getOrgi(request), new PageRequest(0, 100))); + } return request(super.createRequestPageTempletResponse("/apps/service/online/trace")); } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java index 6aaf9bac..3f2a32e1 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/ChatbotEventHandler.java @@ -161,6 +161,7 @@ public class ChatbotEventHandler { agentUser.setCreatetime(now); agentUser.setUpdatetime(now); agentUser.setSessionid(session); + agentUser.setRegion(onlineUser.getRegion()); // 聊天机器人处理的请求 agentUser.setOpttype(MainContext.OptTypeEnum.CHATBOT.toString()); @@ -168,7 +169,7 @@ public class ChatbotEventHandler { agentUser.setCity(onlineUser.getCity()); agentUser.setProvince(onlineUser.getProvince()); agentUser.setCountry(onlineUser.getCountry()); - AgentService agentService = AutomaticServiceDist.processChatbotService(agentUser, orgi); + AgentService agentService = AutomaticServiceDist.processChatbotService(invite != null ? invite.getAiname() : "机器人客服", agentUser, orgi); agentUser.setAgentserviceid(agentService.getId()); // 标记为机器人坐席 @@ -194,7 +195,7 @@ public class ChatbotEventHandler { AgentUser agentUser = (AgentUser) CacheHelper.getAgentUserCacheBean().getCacheObject(user, orgi); OnlineUser onlineUser = (OnlineUser) CacheHelper.getOnlineUserCacheBean().getCacheObject(user, orgi); if (agentUser != null) { - AutomaticServiceDist.processChatbotService(agentUser, orgi); + AutomaticServiceDist.processChatbotService(null, agentUser, orgi); CacheHelper.getAgentUserCacheBean().delete(user, MainContext.SYSTEM_ORGI); CacheHelper.getOnlineUserCacheBean().delete(user, orgi); agentUser.setStatus(MainContext.OnlineUserOperatorStatus.OFFLINE.toString()); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java index e91c58b4..ce649a21 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/im/handler/IMEventHandler.java @@ -167,7 +167,7 @@ public class IMEventHandler { } AgentServiceRepository agentServiceRes = MainContext.getContext().getBean(AgentServiceRepository.class); - List agentServiceList = agentServiceRes.findByUseridAndOrgi(user, orgi); + List agentServiceList = agentServiceRes.findByUseridAndOrgiOrderByLogindateDesc(user, orgi); if (agentServiceList.size() > 0) { AgentService agentService = agentServiceList.get(0); agentService.setName(contacts.getName()); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/AgentServiceRepository.java b/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/AgentServiceRepository.java index 4cc2eeb4..10f897ee 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/AgentServiceRepository.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/persistence/repository/AgentServiceRepository.java @@ -31,7 +31,7 @@ public abstract interface AgentServiceRepository { public abstract AgentService findByIdAndOrgi(String paramString , String orgi); - public abstract List findByUseridAndOrgi(String paramString, String orgi); + public abstract List findByUseridAndOrgiOrderByLogindateDesc(String paramString, String orgi); public abstract Page findByOrgi(String orgi, Pageable paramPageable); diff --git a/contact-center/app/src/main/resources/templates/apps/service/history/index.html b/contact-center/app/src/main/resources/templates/apps/service/history/index.html index a0809a26..75b13d40 100644 --- a/contact-center/app/src/main/resources/templates/apps/service/history/index.html +++ b/contact-center/app/src/main/resources/templates/apps/service/history/index.html @@ -97,9 +97,8 @@
    - + - From f27df5b518fab722406a1fef1df4147ff23a1f34 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 25 Oct 2018 18:26:38 +0800 Subject: [PATCH 50/54] =?UTF-8?q?Closed=20#124=20=E4=BF=9D=E5=AD=98AI?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/channel/WebIMController.java | 22 +++++++++---------- .../templates/admin/webim/index.html | 5 +++++ .../templates/admin/webim/invote.html | 5 +++++ .../templates/admin/webim/profile.html | 5 +++++ 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java index 1b003875..cdcef7f5 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/app/handler/admin/channel/WebIMController.java @@ -16,11 +16,12 @@ */ package com.chatopera.cc.app.handler.admin.channel; -import com.chatopera.cc.app.basic.MainUtils; import com.chatopera.cc.app.cache.CacheHelper; import com.chatopera.cc.app.handler.Handler; -import com.chatopera.cc.app.model.*; -import com.chatopera.cc.app.persistence.blob.JpaBlobHelper; +import com.chatopera.cc.app.model.CousultInvite; +import com.chatopera.cc.app.model.Organ; +import com.chatopera.cc.app.model.OrgiSkillRel; +import com.chatopera.cc.app.model.User; import com.chatopera.cc.app.persistence.repository.*; import com.chatopera.cc.util.Menu; import org.apache.commons.lang.StringUtils; @@ -30,7 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; @@ -38,7 +38,6 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; -import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -74,6 +73,8 @@ public class WebIMController extends Handler { public ModelAndView index(ModelMap map, HttpServletRequest request, @Valid String snsid) { CousultInvite coultInvite = invite.findBySnsaccountidAndOrgi(snsid, super.getOrgi(request)); + logger.info("[index] snsaccount Id {}, AiFirst {}", coultInvite.getSnsaccountid(), coultInvite.isAifirst()); + if (coultInvite != null) { map.addAttribute("inviteData", coultInvite); map.addAttribute("skillList", getOrgans(request)); @@ -89,7 +90,7 @@ public class WebIMController extends Handler { @RequestMapping("/save") @Menu(type = "admin", subtype = "app", admin = true) public ModelAndView save(HttpServletRequest request, @Valid CousultInvite inviteData, @RequestParam(value = "webimlogo", required = false) MultipartFile webimlogo, @RequestParam(value = "agentheadimg", required = false) MultipartFile agentheadimg) throws IOException { - if (!StringUtils.isBlank(inviteData.getSnsaccountid())) { + if (StringUtils.isNotBlank(inviteData.getSnsaccountid())) { CousultInvite tempData = invite.findBySnsaccountidAndOrgi(inviteData.getSnsaccountid(), super.getOrgi(request)); if (tempData != null) { tempData.setConsult_vsitorbtn_model(inviteData.getConsult_vsitorbtn_model()); @@ -98,7 +99,6 @@ public class WebIMController extends Handler { tempData.setConsult_vsitorbtn_content(inviteData.getConsult_vsitorbtn_content()); tempData.setConsult_vsitorbtn_display(inviteData.getConsult_vsitorbtn_display()); tempData.setConsult_dialog_color(inviteData.getConsult_dialog_color()); - inviteData = tempData; } } else { @@ -137,7 +137,7 @@ public class WebIMController extends Handler { @Menu(type = "admin", subtype = "profile", admin = true) public ModelAndView saveprofile(HttpServletRequest request, @Valid CousultInvite inviteData, @RequestParam(value = "dialogad", required = false) MultipartFile dialogad) throws IOException { CousultInvite tempInviteData; - if (inviteData != null && !StringUtils.isBlank(inviteData.getId())) { + if (inviteData != null && StringUtils.isNotBlank(inviteData.getId())) { tempInviteData = invite.findOne(inviteData.getId()); if (tempInviteData != null) { tempInviteData.setDialog_name(inviteData.getDialog_name()); @@ -189,7 +189,7 @@ public class WebIMController extends Handler { tempInviteData.setCtrlenter(inviteData.isCtrlenter()); - if (dialogad != null && !StringUtils.isBlank(dialogad.getName()) && dialogad.getBytes() != null && dialogad.getBytes().length > 0) { + if (dialogad != null && StringUtils.isNotBlank(dialogad.getName()) && dialogad.getBytes() != null && dialogad.getBytes().length > 0) { tempInviteData.setDialog_ad(super.saveImageFileWithMultipart(dialogad)); } invite.save(tempInviteData); @@ -218,7 +218,7 @@ public class WebIMController extends Handler { @Menu(type = "admin", subtype = "profile", admin = true) public ModelAndView saveinvote(HttpServletRequest request, @Valid CousultInvite inviteData, @RequestParam(value = "invotebg", required = false) MultipartFile invotebg) throws IOException { CousultInvite tempInviteData; - if (inviteData != null && !StringUtils.isBlank(inviteData.getId())) { + if (inviteData != null && StringUtils.isNotBlank(inviteData.getId())) { tempInviteData = invite.findOne(inviteData.getId()); if (tempInviteData != null) { tempInviteData.setConsult_invite_enable(inviteData.isConsult_invite_enable()); @@ -229,7 +229,7 @@ public class WebIMController extends Handler { tempInviteData.setConsult_invite_color(inviteData.getConsult_invite_color()); - if (invotebg != null && !StringUtils.isBlank(invotebg.getName()) && invotebg.getBytes() != null && invotebg.getBytes().length > 0) { + if (invotebg != null && StringUtils.isNotBlank(invotebg.getName()) && invotebg.getBytes() != null && invotebg.getBytes().length > 0) { tempInviteData.setConsult_invite_bg(super.saveImageFileWithMultipart(invotebg)); } invite.save(tempInviteData); diff --git a/contact-center/app/src/main/resources/templates/admin/webim/index.html b/contact-center/app/src/main/resources/templates/admin/webim/index.html index 4eca5597..8f8d6f8b 100644 --- a/contact-center/app/src/main/resources/templates/admin/webim/index.html +++ b/contact-center/app/src/main/resources/templates/admin/webim/index.html @@ -30,6 +30,11 @@ <#if inviteData??> + + + + +
    diff --git a/contact-center/app/src/main/resources/templates/admin/webim/invote.html b/contact-center/app/src/main/resources/templates/admin/webim/invote.html index 85e11cb1..46270ca7 100644 --- a/contact-center/app/src/main/resources/templates/admin/webim/invote.html +++ b/contact-center/app/src/main/resources/templates/admin/webim/invote.html @@ -30,6 +30,11 @@ <#if inviteData??> + + + + +
    diff --git a/contact-center/app/src/main/resources/templates/admin/webim/profile.html b/contact-center/app/src/main/resources/templates/admin/webim/profile.html index e3ca24c2..90d4e012 100644 --- a/contact-center/app/src/main/resources/templates/admin/webim/profile.html +++ b/contact-center/app/src/main/resources/templates/admin/webim/profile.html @@ -30,6 +30,11 @@ <#if inviteData??> + + + + +
    From 1c331f8f3f48a131b73b53e68785ed431b533b99 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Thu, 25 Oct 2018 18:50:37 +0800 Subject: [PATCH 51/54] =?UTF-8?q?Closed=20#40=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contact-center/app/src/main/resources/templates/login.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contact-center/app/src/main/resources/templates/login.html b/contact-center/app/src/main/resources/templates/login.html index a2d16ae1..2b8dad3a 100644 --- a/contact-center/app/src/main/resources/templates/login.html +++ b/contact-center/app/src/main/resources/templates/login.html @@ -21,9 +21,9 @@ layui.use('layer', function(){ var layer = layui.layer; <#if msg?? && msg == '0'> - layer.alert('手机或密码错误,请重新填写', {icon: 2}); + layer.alert('用户名或密码错误,请重新填写', {icon: 2}); <#elseif msg?? && msg == '1'> - layer.alert('用户注册成功,请使用手机和密码登陆', {icon: 1}); + layer.alert('用户注册成功,请通过用户名和密码登陆', {icon: 1}); }); layui.use('form', function(){ @@ -49,7 +49,7 @@ + class="form-control required" value="" placeholder="用户名">
    From 2ceaa2f64ceb96f496020dcd97e4ecd97339cc27 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 31 Oct 2018 12:47:56 +0800 Subject: [PATCH 52/54] #125 fix package download issue [skip ci] --- contact-center/app/pom.xml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/contact-center/app/pom.xml b/contact-center/app/pom.xml index afe87b15..b856e7bb 100644 --- a/contact-center/app/pom.xml +++ b/contact-center/app/pom.xml @@ -368,23 +368,6 @@ compile - - - SPRING-LIBS-snapshot - https://repo.spring.io/libs-milestone - - - mvn_repository - MVNREPOSITORY - http://repo1.maven.org/maven2 - - - - - SPRING-LIBS-snapshot - https://repo.spring.io/libs-milestone - - hain From 50b2b8658c40a8e907f19abcf5e7ec291bed7f90 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Wed, 31 Oct 2018 19:49:16 +0800 Subject: [PATCH 53/54] Fixed #125 use anonymous account --- contact-center/_m2/settings.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/contact-center/_m2/settings.xml b/contact-center/_m2/settings.xml index 0a59bfd9..d03e0c5b 100644 --- a/contact-center/_m2/settings.xml +++ b/contact-center/_m2/settings.xml @@ -136,11 +136,6 @@ under the License. --> - - chatopera - ada - L1OBFepgSZ - From 87f80fdd1c8858933ede00ae2793944308022be6 Mon Sep 17 00:00:00 2001 From: Hai Liang Wang Date: Sat, 3 Nov 2018 16:31:39 +0800 Subject: [PATCH 54/54] =?UTF-8?q?#172=20=E6=98=BE=E7=A4=BA=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E6=B8=A0=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/src/main/resources/templates/admin/include/left.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contact-center/app/src/main/resources/templates/admin/include/left.html b/contact-center/app/src/main/resources/templates/admin/include/left.html index f7cce5aa..1ecb1179 100644 --- a/contact-center/app/src/main/resources/templates/admin/include/left.html +++ b/contact-center/app/src/main/resources/templates/admin/include/left.html @@ -24,7 +24,7 @@
    class="layui-this"> 网站列表
    - <#if models?? && models["callout"]?? && models["callout"] == true> + <#if models?? && models["sales"]?? && models["sales"] == true>
    class="layui-this"> 语音渠道
    咨询时间 服务时间 等待时长服务时间服务时长 地域