mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
https://github.com/chatopera/cskefu/issues/627 print log for 春松客服贡献者
This commit is contained in:
parent
bd2c5bd8e5
commit
411f00e154
@ -81,8 +81,6 @@ public class Application {
|
|||||||
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.report"), "true")) {
|
if (StringUtils.equalsIgnoreCase(SystemEnvHelper.parseFromApplicationProps("cskefu.modules.report"), "true")) {
|
||||||
MainContext.enableModule(Constants.CSKEFU_MODULE_REPORT);
|
MainContext.enableModule(Constants.CSKEFU_MODULE_REPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,10 +96,11 @@ public class Application {
|
|||||||
SpringApplication app = new SpringApplicationBuilder(Application.class)
|
SpringApplication app = new SpringApplicationBuilder(Application.class)
|
||||||
.properties("spring.config.name:application,git")
|
.properties("spring.config.name:application,git")
|
||||||
.build();
|
.build();
|
||||||
|
BlessingAndUnblessing.print();
|
||||||
app.setBannerMode(Banner.Mode.CONSOLE);
|
app.setBannerMode(Banner.Mode.CONSOLE);
|
||||||
app.setAddCommandLineProperties(false);
|
app.setAddCommandLineProperties(false);
|
||||||
app.addListeners(new AppCtxRefreshEventListener());
|
app.addListeners(new AppCtxRefreshEventListener());
|
||||||
|
|
||||||
MainContext.setApplicationContext(app.run(args));
|
MainContext.setApplicationContext(app.run(args));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Application Startup Error", e);
|
logger.error("Application Startup Error", e);
|
||||||
|
@ -940,6 +940,7 @@ public class MainContext {
|
|||||||
|
|
||||||
public static void setApplicationContext(ApplicationContext context) {
|
public static void setApplicationContext(ApplicationContext context) {
|
||||||
applicationContext = context;
|
applicationContext = context;
|
||||||
|
context.getBean(TerminateBean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ApplicationContext getContext() {
|
public static ApplicationContext getContext() {
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Chatopera Inc, All rights reserved.
|
||||||
|
* <https://www.chatopera.com>
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Chatopera Inc, All rights reserved.
|
||||||
|
* <https://www.chatopera.com>
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
@ -24,92 +24,94 @@ import java.io.InputStream;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class SystemEnvHelper {
|
public class SystemEnvHelper {
|
||||||
private final static Logger logger = LoggerFactory.getLogger(SystemEnvHelper.class);
|
private final static Logger logger = LoggerFactory.getLogger(SystemEnvHelper.class);
|
||||||
private static Properties props;
|
private static Properties props;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据类的全名查找是否存在
|
* 根据类的全名查找是否存在
|
||||||
*
|
*
|
||||||
* @param classFullName
|
* @param classFullName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isClassExistByFullName(final String classFullName) {
|
public static boolean isClassExistByFullName(final String classFullName) {
|
||||||
try {
|
try {
|
||||||
// Class<?> uriClass =
|
// Class<?> uriClass =
|
||||||
Class.forName(classFullName);
|
Class.forName(classFullName);
|
||||||
return true;
|
return true;
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得环境变量的值,如果不存在,返回默认值
|
||||||
|
*
|
||||||
|
* @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;
|
||||||
*
|
}
|
||||||
* @param variable
|
return val;
|
||||||
* @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;
|
* 加载配置,先检查环境变量,再从application properties加载
|
||||||
}
|
*
|
||||||
return val;
|
* @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);
|
||||||
|
|
||||||
/**
|
if (StringUtils.isBlank(val)) {
|
||||||
* 加载配置,先检查环境变量,再从application properties加载
|
try {
|
||||||
*
|
val = getProps().getProperty(property);
|
||||||
* @param property
|
} catch (java.lang.NullPointerException ex) {
|
||||||
* @return
|
return "NULL";
|
||||||
*/
|
}
|
||||||
public static String parseFromApplicationProps(final String property) {
|
}
|
||||||
// 将 property 转化为环境变量
|
return val;
|
||||||
String P = StringUtils.upperCase(property);
|
}
|
||||||
|
|
||||||
P = StringUtils.replaceChars(P, "-", "_");
|
/**
|
||||||
P = StringUtils.replaceChars(P, ".", "_");
|
* Get properties filename
|
||||||
String val = System.getenv(P);
|
*
|
||||||
|
* @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);
|
* 加载 application.properties
|
||||||
}
|
*
|
||||||
return val;
|
* @return
|
||||||
}
|
*/
|
||||||
|
private static Properties getProps() {
|
||||||
/**
|
if (props == null) {
|
||||||
* Get properties filename
|
try (InputStream input = SystemEnvHelper.class.getClassLoader().getResourceAsStream(getPropsFileName())) {
|
||||||
* @return
|
// load a properties file
|
||||||
*/
|
props = new Properties();
|
||||||
private static String getPropsFileName() {
|
props.load(input);
|
||||||
String profile = getenv("SPRING_PROFILES_ACTIVE", "");
|
} catch (IOException ex) {
|
||||||
if (StringUtils.isNotBlank(profile)) {
|
logger.error("[getProps] error", ex);
|
||||||
return "application-" + profile + ".properties";
|
}
|
||||||
}
|
}
|
||||||
return "application.properties";
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public class MailSender {
|
|||||||
props.put("mail.smtp.host", smtpHostName);
|
props.put("mail.smtp.host", smtpHostName);
|
||||||
//ssl
|
//ssl
|
||||||
if(!StringUtils.isBlank(seclev)&&seclev.equals("true")) {
|
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";
|
final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
|
||||||
props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
|
props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
|
||||||
props.put("mail.smtp.socketFactory.fallback", "false");
|
props.put("mail.smtp.socketFactory.fallback", "false");
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
'|...' '|..|' .||. ||. '|.' '|..'|' '|...' '|.' '|...' '|...' .||. ||. '|.' '|...' .||.
|
'|...' '|..|' .||. ||. '|.' '|..'|' '|...' '|.' '|...' '|...' .||. ||. '|.' '|...' .||.
|
||||||
|
|
||||||
==================== Powered by Chatopera Inc. =================
|
==================== Powered by Chatopera Inc. =================
|
||||||
春松客服: 越是重视客户服务,越是好的企业 v${git.build.version} build ${git.commit.id.abbrev}
|
春松客服: 做好开源客服系统 v${git.build.version} build ${git.commit.id.abbrev}
|
||||||
版权所有 © 北京华夏春松科技有限公司️ https://www.chatopera.com/
|
开源许可证:Apache License 2.0
|
||||||
商业许可授权联系商务顾问 https://www.chatopera.com/mail.html
|
开源地址:https://github.com/chatopera/cskefu
|
||||||
|
|
||||||
第一次安装后,参考系统初始化文档,对系统进行初始化,再使用!!!
|
第一次安装后,参考系统初始化文档,对系统进行初始化,再使用
|
||||||
https://docs.chatopera.com/products/cskefu/initialization.html
|
https://docs.chatopera.com/products/cskefu/initialization.html
|
||||||
|
|
||||||
使用过程中,进行维护:备份、回复、升级等,参考文档
|
使用过程中,进行维护:备份、回复、升级等,参考文档
|
||||||
@ -17,9 +17,4 @@ https://docs.chatopera.com/products/cskefu/osc/maintainence.html
|
|||||||
|
|
||||||
开源社区反馈建议& 提交 BUG
|
开源社区反馈建议& 提交 BUG
|
||||||
https://github.com/chatopera/cskefu/issues
|
https://github.com/chatopera/cskefu/issues
|
||||||
|
|
||||||
春松客服之所以开源,是基于这样一种信念:爱人也是爱己,利他也是利己。
|
|
||||||
对人和人美好关系的向往,对人潜力的信任。让我们相信因春松客服而受益的人,会回报给春松客服开源社区,我们所有贡献者基于共赢的信念合作。
|
|
||||||
回报方式包括:提交 PR、购买春松客服相关的付费产品和服务等。
|
|
||||||
因春松客服受益,而不回报开源社区的用户,我们不欢迎使用春松客服:我们开源并不是为了你们,你们是不被祝福的。
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
@ -6,7 +6,7 @@
|
|||||||
<version>7.0.0-SNAPSHOT</version>
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>cc-root</name>
|
<name>cc-root</name>
|
||||||
<description>春松客服:多渠道智能客服系统</description>
|
<description>春松客服:做好开源客服系统</description>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
@ -18,6 +18,13 @@
|
|||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.chatopera.cc</groupId>
|
||||||
|
<artifactId>pep</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
@ -30,7 +30,10 @@ import com.google.gson.JsonArray;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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_RC, RestUtils.RESP_RC_FAIL_5);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_DATA, "查询不成功,智能问答引擎服务异常。");
|
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;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,12 @@ public class ChatbotEventSubscription {
|
|||||||
public void onMessage(final String payload) {
|
public void onMessage(final String payload) {
|
||||||
ChatMessage message = SerializeUtil.deserialize(payload);
|
ChatMessage message = SerializeUtil.deserialize(payload);
|
||||||
try {
|
try {
|
||||||
chat(message);
|
try {
|
||||||
|
chat(message);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
logger.error("[onMessage] error", e);
|
logger.error("[onMessage] error", e);
|
||||||
} catch (ChatbotException 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 {
|
private void updateAgentUserWithRespData(final String userid, final String orgi, final JSONObject data) throws JSONException {
|
||||||
cache.findOneAgentUserByUserIdAndOrgi(userid, orgi).ifPresent(p -> {
|
cache.findOneAgentUserByUserIdAndOrgi(userid, orgi).ifPresent(p -> {
|
||||||
p.setChatbotround(p.getChatbotround() + 1);
|
p.setChatbotround(p.getChatbotround() + 1);
|
||||||
if (data.has("logic_is_unexpected") && data.getBoolean("logic_is_unexpected")) {
|
try {
|
||||||
p.setChatbotlogicerror(p.getChatbotlogicerror() + 1);
|
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);
|
agentUserRes.save(p);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user