浏览代码

修改jfinal打印日志配置 修改之前 遗留的bug

779513719 5 年之前
父节点
当前提交
0a48715bd3

+ 1 - 1
jim-server/src/main/java/org/jim/server/command/handler/CloseReqHandler.java

@@ -131,7 +131,7 @@ public class CloseReqHandler extends AbstractCmdHandler
 				.append(" and department_id = " + user.getExtras().getString("departmentId"))
 				.append(
 						" and service_account_role_department_middle_id = "
-								+ user.getExtras().getString("serviceAccountRoleDepartmentId")
+								+ user.getId()
 				);
 		return sql.toString();
 	}

+ 1 - 0
jim-server/src/main/java/org/jim/server/command/handler/UserReqHandler.java

@@ -40,6 +40,7 @@ public class UserReqHandler extends AbstractCmdHandler {
 		RespBody resPacket = null;
 		
 		String userId = userReqBody.getUserid();
+		//TODO
 		System.out.println("执行获取用户信息消息命令处理器... ");
 		if(StringUtils.isEmpty(userId)) {
 			return ImKit.ConvertRespPacket(new RespBody(Command.COMMAND_GET_USER_RESP, ImStatus.C10004), channelContext);

+ 23 - 0
server-chat/pom.xml

@@ -30,6 +30,29 @@
             <artifactId>mysql-connector-java</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.16</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.7</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.googlecode.log4jdbc</groupId>
+            <artifactId>log4jdbc</artifactId>
+            <version>1.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+        </dependency>
+
     </dependencies>
     <build>
         <plugins>

+ 9 - 1
server-chat/src/main/java/com/cn/config/PropertyDataBaseConfigBuilder.java

@@ -1,5 +1,7 @@
 package com.cn.config;
 
+import com.jfinal.config.Constants;
+import com.jfinal.config.JFinalConfig;
 import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
 import com.jfinal.plugin.druid.DruidPlugin;
 import org.apache.commons.lang3.StringUtils;
@@ -24,7 +26,9 @@ public class PropertyDataBaseConfigBuilder {
         }
         prop = PropUtil.use(file);
         //创建 Druid 数据库连接池 (jfinal)
-        DruidPlugin druidPlugin = new DruidPlugin(prop.get("jdbcUrl"), prop.get("user"), prop.get("password"));
+        DruidPlugin druidPlugin = new DruidPlugin(
+                prop.get("jdbcUrl"), prop.get("user"), prop.get("password"),prop.get("driverClass")
+        );
         //设置连接池相关数据
         druidPlugin.set(prop.getInt("initialSize"),prop.getInt("minIdle"),prop.getInt("maxActive"));
         druidPlugin.setConnectionInitSql("set names utf8mb4");
@@ -46,6 +50,10 @@ public class PropertyDataBaseConfigBuilder {
         // 与 jfinal web 环境唯一的不同是要手动调用一次相关插件的start()方法
         druidPlugin.start();
         arp.start();
+        //设置开发者模式
+//        arp.setDevMode(true);
+        //设置打印sql
+//        arp.setShowSql(true);
 
     }
 

+ 14 - 3
server-chat/src/main/java/com/cn/service/IMChatLoginServiceProcessor.java

@@ -140,7 +140,10 @@ public class IMChatLoginServiceProcessor implements LoginCmdProcessor {
      */
     private List<Group> initVisitorGroups(User user) {
         List<Group> groups = disposeVisitorGroupData(user);
-        this.createConversation(groups.get(0),user);
+        Boolean noOnlineService = user.getExtras().getBoolean("noOnlineService");
+        if(noOnlineService == null){
+            this.createConversation(groups.get(0),user);
+        }
         return groups;
     }
 
@@ -162,7 +165,7 @@ public class IMChatLoginServiceProcessor implements LoginCmdProcessor {
         //value组成 : Map<String ( serviceAccountRoleDepartmentId ), String (当前连接客户人数)>
         Map<String, String> serviceAccountContainer = jedisTemplate.hashGetAll(serviceAccountContainerKey);
 
-        // //从当前在线的客服中 获取 连接客户数最少的 客服
+        // 从当前在线的客服中 获取 连接客户数最少的 客服
         Map.Entry<String, String> minReceptionNumServiceAccount = this.getServiceAccountMinReceptionNum(serviceAccountContainer);
         if( null != minReceptionNumServiceAccount ){
             //当前平台下部门下 存在客服
@@ -346,7 +349,10 @@ public class IMChatLoginServiceProcessor implements LoginCmdProcessor {
             groups.addAll(this.disposeVisitorGroupData(user));
         }
         if( user.getExtras().getBoolean("isCreateConversation")){
-            this.createConversation(groups.get(0),user);
+            Boolean noOnlineService = user.getExtras().getBoolean("noOnlineService");
+            if(noOnlineService == null){
+                this.createConversation(groups.get(0),user);
+            }
         }
         return groups;
     }
@@ -618,6 +624,11 @@ public class IMChatLoginServiceProcessor implements LoginCmdProcessor {
         List<ChatGroup> onlineChatGroups = ChatGroup.dao.find(sql2.toString());
         if( !CollectionUtils.isEmpty(onlineChatGroups) ){
             chatGroups.addAll(onlineChatGroups);
+            //修改客服离线状态 为 在线
+            for (ChatGroup chatGroup : onlineChatGroups) {
+                chatGroup.set("service_account_type",ServiceAccountOfflineTypeEnum.ON_LINE.getKey())
+                        .update();
+            }
         }
 
         //1.查询 对应平台下 对应部门下 留言群组

+ 3 - 2
server-chat/src/main/resources/application.properties

@@ -1,6 +1,6 @@
 
 #\u6570\u636E\u5E93\u8FDE\u63A5\u5730\u5740
-jdbcUrl=jdbc:mysql://47.244.247.223:3306/customer_service_management?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false&useSSL=false
+jdbcUrl=jdbc:log4jdbc:mysql://47.244.247.223:3306/customer_service_management?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false&useSSL=false
 #\u6570\u636E\u5E93\u8D26\u53F7
 user=root
 #\u6570\u636E\u5E93\u5BC6\u7801
@@ -10,4 +10,5 @@ initialSize=1
 #\u6700\u5C0F\u95F2\u7F6E\u8FDE\u63A5\u6570
 minIdle=1
 #\u6700\u5927\u8FDE\u63A5\u6570
-maxActive=20
+maxActive=20
+driverClass=net.sf.log4jdbc.DriverSpy

+ 1 - 1
server-chat/src/main/resources/jim.properties

@@ -2,7 +2,7 @@
 #ip
 jim.bind.ip = 127.0.0.1
 #\u7AEF\u53E3
-jim.port = 8818
+jim.port = 8888
 #\u5FC3\u8DF3\u8D85\u65F6\u65F6\u957F
 jim.heartbeat.timeout = 0
 #\u662F\u5426\u5F00\u542F\u6D88\u606F\u6301\u4E45\u5316(on:\u5F00\u542F,off:\u4E0D\u5F00\u542F)

+ 35 - 0
server-chat/src/main/resources/log4j.properties

@@ -0,0 +1,35 @@
+log4j.rootLogger=INFO,stdout,file
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%n%-d{yyyy-MM-dd HH:mm:ss}%n[%p]-[Thread: %t]-[%C.%M()]: %m%n
+
+# Output to the File
+log4j.appender.file = org.apache.log4j.DailyRollingFileAppender  
+log4j.appender.Threshold = DEBUG
+log4j.appender.file.DatePattern = '.'yyyy-MM-dd
+log4j.appender.file.File=logs/log.log
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%n%-d{yyyy-MM-dd HH:mm:ss}%n[%p]-[Thread: %t]-[%C.%M()]: %m%n
+
+#\u8BB0\u5F55\u9664ResultSet\u8C03\u7528\u4EE5\u5916\u7684\u6240\u6709JDBC\u8C03\u7528
+log4j.logger.jdbc.audit = INFO,jdbc
+log4j.additivity.jdbc.audit = false
+
+#\u53EA\u8BB0\u5F55\u5BF9ResultSet\u5BF9\u8C61\u7684JDBC\u8C03\u7528
+log4j.logger.jdbc.resultset = INFO,jdbc
+log4j.additivity.jdbc.resultset = false
+
+#\u53EA\u8BB0\u5F55\u6267\u884C\u7684SQL\u3002
+log4j.logger.jdbc.sqlonly = INFO,sql
+log4j.additivity.jdbc.sqlonly = false
+
+#\u8BB0\u5F55\u6709\u5173\u6267\u884C\u7684SQL\u7684\u65F6\u95F4\u4FE1\u606F\u3002
+log4j.logger.jdbc.sqltiming = INFO,console
+log4j.additivity.jdbc.sqltiming = true
+
+#\u8BB0\u5F55\u8FDE\u63A5\u6253\u5F00/\u5173\u95ED\u4E8B\u4EF6\u548C\u8FDE\u63A5\u53F7\u7801\u8F6C\u50A8
+log4j.logger.jdbc.connection = FATAL,\u8FDE\u63A5
+log4j.additivity.jdbc.connection = false
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.SimpleLayout