diff --git a/contact-center/app/src/main/java/com/chatopera/cc/Application.java b/contact-center/app/src/main/java/com/chatopera/cc/Application.java index 013cc8c7..ff119469 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/Application.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/Application.java @@ -81,8 +81,6 @@ public class Application { if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.report"), "true")) { MainContext.enableModule(Constants.CSKEFU_MODULE_REPORT); } - - } /** @@ -98,10 +96,11 @@ public class Application { SpringApplication app = new SpringApplicationBuilder(Application.class) .properties("spring.config.name:application,git") .build(); - + BlessingAndUnblessing.print(); app.setBannerMode(Banner.Mode.CONSOLE); app.setAddCommandLineProperties(false); app.addListeners(new AppCtxRefreshEventListener()); + MainContext.setApplicationContext(app.run(args)); } catch (IOException e) { logger.error("Application Startup Error", e); diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java index 3f6e2e46..3a7bf823 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/MainContext.java @@ -940,6 +940,7 @@ public class MainContext { public static void setApplicationContext(ApplicationContext context) { applicationContext = context; + context.getBean(TerminateBean.class); } public static ApplicationContext getContext() { diff --git a/contact-center/app/src/main/java/com/chatopera/cc/basic/TerminateBean.java b/contact-center/app/src/main/java/com/chatopera/cc/basic/TerminateBean.java new file mode 100644 index 00000000..138c8f7b --- /dev/null +++ b/contact-center/app/src/main/java/com/chatopera/cc/basic/TerminateBean.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2022 Chatopera Inc, All rights reserved. + * + * This software and related documentation are provided under a license agreement containing + * restrictions on use and disclosure and are protected by intellectual property laws. + * Except as expressly permitted in your license agreement or allowed by law, you may not use, + * copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, + * publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, + * or decompilation of this software, unless required by law for interoperability, is prohibited. + */ +package com.chatopera.cc.basic; + +import javax.annotation.PreDestroy; + +import com.chatopera.cc.BlessingAndUnblessing; + +public class TerminateBean { + @PreDestroy + public void onDestroy() throws Exception { + BlessingAndUnblessing.print(); + } +} diff --git a/contact-center/app/src/main/java/com/chatopera/cc/config/ShutdownConfig.java b/contact-center/app/src/main/java/com/chatopera/cc/config/ShutdownConfig.java new file mode 100644 index 00000000..98b03c44 --- /dev/null +++ b/contact-center/app/src/main/java/com/chatopera/cc/config/ShutdownConfig.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2022 Chatopera Inc, All rights reserved. + * + * This software and related documentation are provided under a license agreement containing + * restrictions on use and disclosure and are protected by intellectual property laws. + * Except as expressly permitted in your license agreement or allowed by law, you may not use, + * copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, + * publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, + * or decompilation of this software, unless required by law for interoperability, is prohibited. + */ +package com.chatopera.cc.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import com.chatopera.cc.basic.TerminateBean; + +@Configuration +public class ShutdownConfig { + + @Bean + public TerminateBean getTerminateBean() { + return new TerminateBean(); + } +} \ No newline at end of file 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 index 5b6f091e..315be3fd 100644 --- 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 @@ -24,92 +24,94 @@ import java.io.InputStream; import java.util.Properties; public class SystemEnvHelper { - private final static Logger logger = LoggerFactory.getLogger(SystemEnvHelper.class); - private static Properties props; + private final static Logger logger = LoggerFactory.getLogger(SystemEnvHelper.class); + private static Properties props; - /** - * 根据类的全名查找是否存在 - * - * @param classFullName - * @return - */ - public static boolean isClassExistByFullName(final String classFullName) { - try { + /** + * 根据类的全名查找是否存在 + * + * @param classFullName + * @return + */ + public static boolean isClassExistByFullName(final String classFullName) { + try { // Class uriClass = - Class.forName(classFullName); - return true; - } catch (ClassNotFoundException ex) { - return false; - } - } + Class.forName(classFullName); + return true; + } catch (ClassNotFoundException ex) { + return false; + } + } + /** + * 获得环境变量的值,如果不存在,返回默认值 + * + * @param variable + * @param defaultvalue + * @return + */ + public static String getenv(final String variable, final String defaultvalue) { + final String val = System.getenv(variable); - /** - * 获得环境变量的值,如果不存在,返回默认值 - * - * @param variable - * @param defaultvalue - * @return - */ - public static String getenv(final String variable, final String defaultvalue) { - final String val = System.getenv(variable); + if (StringUtils.isBlank(val)) { + return defaultvalue; + } + return val; + } - if (StringUtils.isBlank(val)) { - return defaultvalue; - } - return val; - } + /** + * 加载配置,先检查环境变量,再从application properties加载 + * + * @param property + * @return + */ + public static String parseFromApplicationProps(final String property) { + // 将 property 转化为环境变量 + String P = StringUtils.upperCase(property); + P = StringUtils.replaceChars(P, "-", "_"); + P = StringUtils.replaceChars(P, ".", "_"); + String val = System.getenv(P); - /** - * 加载配置,先检查环境变量,再从application properties加载 - * - * @param property - * @return - */ - public static String parseFromApplicationProps(final String property) { - // 将 property 转化为环境变量 - String P = StringUtils.upperCase(property); + if (StringUtils.isBlank(val)) { + try { + val = getProps().getProperty(property); + } catch (java.lang.NullPointerException ex) { + return "NULL"; + } + } + return val; + } - P = StringUtils.replaceChars(P, "-", "_"); - P = StringUtils.replaceChars(P, ".", "_"); - String val = System.getenv(P); + /** + * Get properties filename + * + * @return + */ + private static String getPropsFileName() { + String profile = getenv("SPRING_PROFILES_ACTIVE", ""); + if (StringUtils.isNotBlank(profile)) { + return "application-" + profile + ".properties"; + } + return "application.properties"; + } - if (StringUtils.isBlank(val)) { - val = getProps().getProperty(property); - } - return val; - } - - /** - * Get properties filename - * @return - */ - private static String getPropsFileName() { - String profile = getenv("SPRING_PROFILES_ACTIVE", ""); - if (StringUtils.isNotBlank(profile)) { - return "application-" + profile + ".properties"; - } - return "application.properties"; - } - - /** - * 加载 application.properties - * - * @return - */ - private static Properties getProps() { - if (props == null) { - try (InputStream input = SystemEnvHelper.class.getClassLoader().getResourceAsStream( - getPropsFileName())) { - // load a properties file - props = new Properties(); - props.load(input); - } catch (IOException ex) { - logger.error("[getProps] error", ex); - } - } - return props; - } + /** + * 加载 application.properties + * + * @return + */ + private static Properties getProps() { + if (props == null) { + try (InputStream input = SystemEnvHelper.class.getClassLoader().getResourceAsStream(getPropsFileName())) { + // load a properties file + props = new Properties(); + props.load(input); + } catch (IOException ex) { + logger.error("[getProps] error", ex); + } + } + return props; + } } diff --git a/contact-center/app/src/main/java/com/chatopera/cc/util/mail/MailSender.java b/contact-center/app/src/main/java/com/chatopera/cc/util/mail/MailSender.java index 52930366..14d8fc39 100644 --- a/contact-center/app/src/main/java/com/chatopera/cc/util/mail/MailSender.java +++ b/contact-center/app/src/main/java/com/chatopera/cc/util/mail/MailSender.java @@ -117,7 +117,7 @@ public class MailSender { props.put("mail.smtp.host", smtpHostName); //ssl if(!StringUtils.isBlank(seclev)&&seclev.equals("true")) { - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); +// Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; props.put("mail.smtp.socketFactory.class", SSL_FACTORY); props.put("mail.smtp.socketFactory.fallback", "false"); diff --git a/contact-center/app/src/main/resources/banner.txt b/contact-center/app/src/main/resources/banner.txt index 8bc3b1e9..35ba69d0 100644 --- a/contact-center/app/src/main/resources/banner.txt +++ b/contact-center/app/src/main/resources/banner.txt @@ -5,11 +5,11 @@ '|...' '|..|' .||. ||. '|.' '|..'|' '|...' '|.' '|...' '|...' .||. ||. '|.' '|...' .||. ==================== Powered by Chatopera Inc. ================= -春松客服: 越是重视客户服务,越是好的企业 v${git.build.version} build ${git.commit.id.abbrev} -版权所有 © 北京华夏春松科技有限公司️ https://www.chatopera.com/ -商业许可授权联系商务顾问 https://www.chatopera.com/mail.html +春松客服: 做好开源客服系统 v${git.build.version} build ${git.commit.id.abbrev} +开源许可证:Apache License 2.0 +开源地址:https://github.com/chatopera/cskefu -第一次安装后,参考系统初始化文档,对系统进行初始化,再使用!!! +第一次安装后,参考系统初始化文档,对系统进行初始化,再使用 https://docs.chatopera.com/products/cskefu/initialization.html 使用过程中,进行维护:备份、回复、升级等,参考文档 @@ -17,9 +17,4 @@ https://docs.chatopera.com/products/cskefu/osc/maintainence.html 开源社区反馈建议& 提交 BUG https://github.com/chatopera/cskefu/issues - -春松客服之所以开源,是基于这样一种信念:爱人也是爱己,利他也是利己。 -对人和人美好关系的向往,对人潜力的信任。让我们相信因春松客服而受益的人,会回报给春松客服开源社区,我们所有贡献者基于共赢的信念合作。 -回报方式包括:提交 PR、购买春松客服相关的付费产品和服务等。 -因春松客服受益,而不回报开源社区的用户,我们不欢迎使用春松客服:我们开源并不是为了你们,你们是不被祝福的。 ---------------------------------------------------------------- \ No newline at end of file diff --git a/contact-center/root/pom.xml b/contact-center/root/pom.xml index 88ca057a..160fbd5a 100644 --- a/contact-center/root/pom.xml +++ b/contact-center/root/pom.xml @@ -6,7 +6,7 @@ 7.0.0-SNAPSHOT pom cc-root - 春松客服:多渠道智能客服系统 + 春松客服:做好开源客服系统 org.springframework.boot spring-boot-starter-parent @@ -18,6 +18,13 @@ 1.8 + + + com.chatopera.cc + pep + 1.0-SNAPSHOT + + org.springframework.boot spring-boot-starter diff --git a/public/plugins/chatbot/classes/ApiChatbotController.java b/public/plugins/chatbot/classes/ApiChatbotController.java index 6f8212d4..f0a706d5 100644 --- a/public/plugins/chatbot/classes/ApiChatbotController.java +++ b/public/plugins/chatbot/classes/ApiChatbotController.java @@ -30,7 +30,10 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; + import org.apache.commons.lang.StringUtils; +import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -699,7 +702,13 @@ public class ApiChatbotController extends Handler { resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5); resp.addProperty(RestUtils.RESP_KEY_DATA, "查询不成功,智能问答引擎服务异常。"); - } + } catch (JsonSyntaxException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } return resp; } diff --git a/public/plugins/chatbot/classes/ChatbotEventSubscription.java b/public/plugins/chatbot/classes/ChatbotEventSubscription.java index fbad7eef..76771d1d 100644 --- a/public/plugins/chatbot/classes/ChatbotEventSubscription.java +++ b/public/plugins/chatbot/classes/ChatbotEventSubscription.java @@ -86,7 +86,12 @@ public class ChatbotEventSubscription { public void onMessage(final String payload) { ChatMessage message = SerializeUtil.deserialize(payload); try { - chat(message); + try { + chat(message); + } catch (JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } catch (MalformedURLException e) { logger.error("[onMessage] error", e); } catch (ChatbotException e) { @@ -346,9 +351,14 @@ public class ChatbotEventSubscription { private void updateAgentUserWithRespData(final String userid, final String orgi, final JSONObject data) throws JSONException { cache.findOneAgentUserByUserIdAndOrgi(userid, orgi).ifPresent(p -> { p.setChatbotround(p.getChatbotround() + 1); - if (data.has("logic_is_unexpected") && data.getBoolean("logic_is_unexpected")) { - p.setChatbotlogicerror(p.getChatbotlogicerror() + 1); - } + try { + if (data.has("logic_is_unexpected") && data.getBoolean("logic_is_unexpected")) { + p.setChatbotlogicerror(p.getChatbotlogicerror() + 1); + } + } catch (JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } agentUserRes.save(p); });