吴志根 %!s(int64=4) %!d(string=hai) anos
pai
achega
4e238ac005

+ 26 - 27
src/dsb/com/cnd3b/common/Controller.java

@@ -11,7 +11,6 @@ import com.cnd3b.common.data.SQLFactory;
 import com.cnd3b.common.data.db.DBConnect;
 import com.cnd3b.common.data.db.DataPool;
 import com.cnd3b.common.parameter.parameter;
-import com.cnd3b.common.websocket.WebClientSocket;
 import static com.cnd3b.utility.aliyun.oss.AliyunOSSUtil.*;
 import p2.p2server.P2Server;
 import p2.pao.PaoRemote;
@@ -688,30 +687,30 @@ public class Controller extends BaseClass {
      * 通知前端执行指定方法
      */
     public void sendSystemWebSocketMessage(String classname, String method, long userid) {
-        if (parameter.websocketClients.containsKey(userid)) {
-            JSONObject methodobject = new JSONObject();
-            methodobject.put("type", "callmethod");
-            methodobject.put("classname", classname);
-            methodobject.put("method", method);
-            for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
-                webClientSocket.sendSystemMessage(methodobject);
-            }
-        }
+//        if (parameter.websocketClients.containsKey(userid)) {
+//            JSONObject methodobject = new JSONObject();
+//            methodobject.put("type", "callmethod");
+//            methodobject.put("classname", classname);
+//            methodobject.put("method", method);
+//            for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
+//                webClientSocket.sendSystemMessage(methodobject);
+//            }
+//        }
     }
 
     /**
      * 通知前端执行指定方法
      */
     public void sendSystemWebSocketMessage(String classname, String method) {
-        if (parameter.websocketClients.containsKey(userid)) {
-            JSONObject methodobject = new JSONObject();
-            methodobject.put("type", "callmethod");
-            methodobject.put("classname", classname);
-            methodobject.put("method", method);
-            for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
-                webClientSocket.sendSystemMessage(methodobject);
-            }
-        }
+//        if (parameter.websocketClients.containsKey(userid)) {
+//            JSONObject methodobject = new JSONObject();
+//            methodobject.put("type", "callmethod");
+//            methodobject.put("classname", classname);
+//            methodobject.put("method", method);
+//            for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
+//                webClientSocket.sendSystemMessage(methodobject);
+//            }
+//        }
     }
 
 
@@ -719,14 +718,14 @@ public class Controller extends BaseClass {
      * 发送系统消息
      */
     public void sendSystemWebSocketMessage(long userid, String message) {
-        if (parameter.websocketClients.containsKey(userid)) {
-            JSONObject methodobject = new JSONObject();
-            methodobject.put("type", "remind");//提醒
-            methodobject.put("text", message);
-            for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
-                webClientSocket.sendSystemMessage(methodobject);
-            }
-        }
+//        if (parameter.websocketClients.containsKey(userid)) {
+//            JSONObject methodobject = new JSONObject();
+//            methodobject.put("type", "remind");//提醒
+//            methodobject.put("text", message);
+//            for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
+//                webClientSocket.sendSystemMessage(methodobject);
+//            }
+//        }
     }
 
 

+ 41 - 2
src/dsb/com/cnd3b/common/parameter/parameter.java

@@ -1,7 +1,6 @@
 package com.cnd3b.common.parameter;
 
 import com.cnd3b.common.data.Row;
-import com.cnd3b.common.websocket.WebClientSocket;
 import p2.p2server.P2Server;
 import p2.pao.PaoRemote;
 import p2.pao.PaoSetRemote;
@@ -72,7 +71,7 @@ public class parameter {
 
 
     //websocket连接池 userid:(token:session)
-    public static Map<Long, ConcurrentHashMap<String, WebClientSocket>> websocketClients = new ConcurrentHashMap<Long, ConcurrentHashMap<String, WebClientSocket>>();
+//    public static Map<Long, ConcurrentHashMap<String, WebClientSocket>> websocketClients = new ConcurrentHashMap<Long, ConcurrentHashMap<String, WebClientSocket>>();
     public static Map<Long, Date> loginDate = new HashMap<>();
 
     /**
@@ -141,6 +140,26 @@ public class parameter {
         return Bucket_sk;
     }
 
+    public static String corpid() {
+        parameter_init();
+        return corpid;
+    }
+
+    public static String corpsecret() {
+        parameter_init();
+        return corpsecret;
+    }
+
+    public static String corpsecret1() {
+        parameter_init();
+        return corpsecret1;
+    }
+
+    public static String corpsecret2() {
+        parameter_init();
+        return corpsecret2;
+    }
+
     public static String oss_bucke_name() {
         parameter_init();
         return oss_bucke_name;
@@ -164,6 +183,10 @@ public class parameter {
                 OBS_expireSeconds = pao.getLong("obs_expireseconds");
                 SQLiteFilePath = pao.getString("sqlitefilepath");
                 UpLoadExcelErrFilePath = pao.getString("uploadexcelerrfilepath");
+                corpid = pao.getString("corpid");
+                corpsecret = pao.getString("corpsecret");
+                corpsecret1 = pao.getString("corpsecret1");
+                corpsecret2 = pao.getString("corpsecret2");
                 oss_bucke_name = pao.getString("oss_bucke_name");
                 isparameterinit = true;
             }
@@ -190,6 +213,22 @@ public class parameter {
     private static String Bucket_location;
     private static String Bucket_ak;
     private static String Bucket_sk;
+    /**
+     * 微信企业ID
+     */
+    private static String corpid;
+    /**
+     * 应用的凭证密钥(通讯录)
+     */
+    private static String corpsecret;
+    /**
+     * 应用的凭证密钥(资料中心)
+     */
+    private static String corpsecret1;
+    /**
+     * 应用的凭证密钥(培训学习)
+     */
+    private static String corpsecret2;
     /**
      * oss
      */

+ 298 - 298
src/dsb/com/cnd3b/common/websocket/WebClientSocket.java

@@ -1,298 +1,298 @@
-package com.cnd3b.common.websocket;
-
-import com.alibaba.fastjson.JSONObject;
-import com.cnd3b.common.BaseClass;
-import com.cnd3b.common.D3BReturnObject_Err;
-import com.cnd3b.common.data.Row;
-import com.cnd3b.common.parameter.parameter;
-
-import javax.websocket.*;
-import javax.websocket.server.PathParam;
-import javax.websocket.server.ServerEndpoint;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.concurrent.ConcurrentHashMap;
-
-//ws://127.0.0.1:8080/samex/webSocket/829fef9884bbf7f9fb9c51499d7b332f
-@ServerEndpoint("/webSocket/{accesstoken}")
-public class WebClientSocket extends BaseClass {
-
-    private Session session;
-    //当前连接对象的账号ID
-    private long userid;
-    private Row userRow;
-    private String accesstoken;
-    private Date createdate;
-
-    /**
-     * 连接开启
-     *
-     * @param accesstoken
-     * @param session
-     * @throws IOException
-     */
-    @OnOpen
-    private void onOpen(@PathParam("accesstoken") String accesstoken, Session session) throws IOException {
-        this.session = session;
-        this.accesstoken = accesstoken;
-        createdate = getDateTime();
-        if (parameter.tokenlist.containsKey(accesstoken)) {
-            userid = parameter.tokenlist.get(accesstoken);
-            userRow = parameter.userIdList.get(userid);
-        } else {
-            JSONObject methodobject = new JSONObject();
-            methodobject.put("type", "err");
-            methodobject.put("msg", "请登陆");
-            sendSystemMessage(methodobject);
-            return;
-        }
-        if (parameter.websocketClients.containsKey(userid)) {
-            parameter.websocketClients.get(userid).put(accesstoken, this);
-        } else {
-            ConcurrentHashMap<String, WebClientSocket> map = new ConcurrentHashMap<>();
-            map.put(accesstoken, this);
-            parameter.websocketClients.put(userid, map);
-        }
-        parameter.loginDate.put(userid, createdate);
-        System.err.println("OpenSession:" + userid);
-    }
-
-    /**
-     * 连接关闭
-     *
-     * @throws IOException
-     */
-    @OnClose
-    private void onClose() throws IOException {
-        if (parameter.websocketClients.containsKey(userid)) {
-            parameter.websocketClients.get(userid).remove(accesstoken);
-            if (parameter.websocketClients.get(userid).isEmpty()) {
-                parameter.websocketClients.remove(userid);
-            }
-            System.err.println("CloseSession:" + userid);
-        }
-    }
-
-    /**
-     * {
-     * "dialogid":1,//对话框id
-     * "messagetype":"text",//消息类型
-     * "description":"",//消息摘要
-     * "data":{
-     * "message":""//文字正文,
-     * }
-     * },
-     * {
-     * "dialogid":1,
-     * "messagetype":"file",//text,file,data,image,
-     * "description":"",
-     * "data":{
-     * "ownertable":"",
-     * "ownerid":"",
-     * "serialnumber":"",
-     * "postfix":"",
-     * "fobsurl":"",
-     * "fobsurl_minimage":"",
-     * "fobsurl_hls":"",
-     * "fdocument":""
-     * }
-     * },
-     * {
-     * "dialogid":1,
-     * "messagetype":"data",//text,file,data,image
-     * "description":"",
-     * "data":{
-     * "type":"",
-     * "ownertable":"",
-     * "ownerid":""
-     * }
-     * }
-     *
-     * @param messageObject
-     * @throws IOException
-     */
-    /**
-     * 消息接收
-     *
-     * @param RequestContent
-     * @throws IOException
-     */
-    @OnMessage
-    private void onMessage(String RequestContent) throws IOException {
-        if (RequestContent == null || RequestContent.equals("")) {
-            return;
-        }
-        if ("isalive".equalsIgnoreCase(RequestContent)) {
-            session.getAsyncRemote().sendText("alive");
-            return;
-        }
-
-        /**
-         * 验证请求正文是否为规范的SONObject格式
-         */
-        JSONObject requestcontent = null;
-        try {
-            requestcontent = JSONObject.parseObject(RequestContent);
-        } catch (Exception e) {
-            return;
-        }
-        /**
-         * 验证请求正文中是否包含必填的键值
-         */
-        String[] mustkeys = {"classname", "method", "content"};
-        for (String mustkey : mustkeys) {
-            if (!requestcontent.containsKey(mustkey)) {
-                return;
-            }
-        }
-        /**
-         * 验证请求正文中的content是否为规范的SONObject格式
-         */
-        JSONObject content = new JSONObject();
-        try {
-            content = requestcontent.getJSONObject("content");
-        } catch (Exception e) {
-            return;
-        }
-
-        /**
-         * 验证正文中的token是否有效
-         */
-        String className = requestcontent.getString("classname");
-
-        parameter.requesttime.put(accesstoken, Calendar.getInstance().getTime());
-
-        String methodName = requestcontent.getString("method");
-        if (content.isEmpty()) {
-            content = new JSONObject();
-        }
-        content.put("$classname", className);
-        content.put("$method", methodName);
-        content.put("$accesstoken", accesstoken);
-
-        String key = className + "." + methodName;
-        String result;
-        Object obj = null;
-        try {
-
-            long starttimes = Calendar.getInstance().getTimeInMillis();
-            /**
-             * 执行请求方法
-             */
-            Class clz = Class.forName("com.cnd3b.websocketcontroller." + className);
-            Constructor cla = clz.getDeclaredConstructor(JSONObject.class);
-            obj = cla.newInstance(content);
-            Method method = obj.getClass().getDeclaredMethod(methodName);
-            result = (String) method.invoke(obj);
-            long endtimes = Calendar.getInstance().getTimeInMillis();
-            saveCallMethodMsg(key, true, endtimes - starttimes);
-        } catch (ClassNotFoundException e) {
-            e.printStackTrace();
-            result = new D3BReturnObject_Err().setErrMsg("找不到指定的类" + className).toString();
-        } catch (InstantiationException e) {
-            e.printStackTrace();
-            result = new D3BReturnObject_Err().setErrMsg("类" + className + "实例化异常").toString();
-        } catch (IllegalAccessException e) {
-            e.printStackTrace();
-            result = new D3BReturnObject_Err().setErrMsg("类" + className + "安全权限异常,可能该类为非public类").toString();
-        } catch (NoSuchMethodException e) {
-            e.printStackTrace();
-            result = new D3BReturnObject_Err().setErrMsg("找不到指定的类" + className + "的" + methodName + "方法").toString();
-        } catch (IllegalArgumentException e) {
-            e.printStackTrace();
-            result = new D3BReturnObject_Err().setErrMsg("类" + className + "的" + methodName + "方法参数不合法").toString();
-        } catch (InvocationTargetException e) {
-            Throwable targetException = e.getTargetException();
-            D3BReturnObject_Err d3BReturnObject_err = new D3BReturnObject_Err();
-            d3BReturnObject_err.setErrMsg(targetException.getMessage());
-            result = d3BReturnObject_err.toString();
-        } catch (Exception e) {
-            e.printStackTrace();
-            result = new D3BReturnObject_Err().setErrMsg("发生未知异常" + e.getMessage()).toString();
-        } finally {
-            if (obj != null) {
-                try {
-                    obj.getClass().getMethod("p2ServerSystemPaoSetClose").invoke(obj);
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return;
-    }
-
-    /**
-     * 记录请求数
-     *
-     * @param key
-     * @param fromdb
-     * @param time
-     */
-    private void saveCallMethodMsg(String key, boolean fromdb, long time) {
-        long callmethodTimes = parameter.callmethodTimes.containsKey(key) ? parameter.callmethodTimes.get(key) : 0L;
-
-        //更新请求总数
-        parameter.callmethodTimes.put(key, callmethodTimes + 1L);
-
-        //最新请求时间
-        parameter.lastcallmethodtime.put(key, Calendar.getInstance().getTime());
-
-        //从缓存获取的次数
-        long callmethod_fromcacheTimes = parameter.callmethod_fromcacheTimes.containsKey(key) ? parameter.callmethod_fromcacheTimes.get(key) : 0L;
-        if (!fromdb) {
-            /**
-             * 方法请求从缓存获取次数
-             */
-            parameter.callmethod_fromcacheTimes.put(key, callmethod_fromcacheTimes + 1L);
-        } else {
-            /**
-             * 方法请求查询最新耗时
-             */
-            parameter.callmethodLastTimeLong.put(key, time);
-
-
-            long totaltimes = callmethodTimes - callmethod_fromcacheTimes;
-
-            /**
-             * 方法请求查询平均时间
-             */
-            long callmethodTimeLong = parameter.callmethodTimeLong.containsKey(key) ? parameter.callmethodTimeLong.get(key) : 0L;
-
-            parameter.callmethodTimeLong.put(key, (callmethodTimeLong * totaltimes + time) / (totaltimes + 1));
-        }
-    }
-
-    @OnError
-    private void onError(Session session, Throwable error) {
-        error.printStackTrace();
-    }
-
-    /**
-     * 对当前连接发送对话框消息
-     *
-     * @param message
-     */
-    public void sendDialogMessage(JSONObject message) {
-        JSONObject object = new JSONObject();
-        object.put("msgtype", "imdialog");
-        object.put("message", message);
-        session.getAsyncRemote().sendText(object.toJSONString());
-    }
-
-    /**
-     * 对当前连接发送系统消息
-     *
-     * @param message
-     */
-    public void sendSystemMessage(JSONObject message) {
-        JSONObject object = new JSONObject();
-        object.put("msgtype", "system");
-        object.put("message", message);
-        session.getAsyncRemote().sendText(object.toJSONString());
-    }
-
-}
+//package com.cnd3b.common.websocket;
+//
+//import com.alibaba.fastjson.JSONObject;
+//import com.cnd3b.common.BaseClass;
+//import com.cnd3b.common.D3BReturnObject_Err;
+//import com.cnd3b.common.data.Row;
+//import com.cnd3b.common.parameter.parameter;
+//
+//import javax.websocket.*;
+//import javax.websocket.server.PathParam;
+//import javax.websocket.server.ServerEndpoint;
+//import java.io.IOException;
+//import java.lang.reflect.Constructor;
+//import java.lang.reflect.InvocationTargetException;
+//import java.lang.reflect.Method;
+//import java.util.Calendar;
+//import java.util.Date;
+//import java.util.concurrent.ConcurrentHashMap;
+//
+////ws://127.0.0.1:8080/samex/webSocket/829fef9884bbf7f9fb9c51499d7b332f
+//@ServerEndpoint("/webSocket/{accesstoken}")
+//public class WebClientSocket extends BaseClass {
+//
+//    private Session session;
+//    //当前连接对象的账号ID
+//    private long userid;
+//    private Row userRow;
+//    private String accesstoken;
+//    private Date createdate;
+//
+//    /**
+//     * 连接开启
+//     *
+//     * @param accesstoken
+//     * @param session
+//     * @throws IOException
+//     */
+//    @OnOpen
+//    private void onOpen(@PathParam("accesstoken") String accesstoken, Session session) throws IOException {
+//        this.session = session;
+//        this.accesstoken = accesstoken;
+//        createdate = getDateTime();
+//        if (parameter.tokenlist.containsKey(accesstoken)) {
+//            userid = parameter.tokenlist.get(accesstoken);
+//            userRow = parameter.userIdList.get(userid);
+//        } else {
+//            JSONObject methodobject = new JSONObject();
+//            methodobject.put("type", "err");
+//            methodobject.put("msg", "请登陆");
+//            sendSystemMessage(methodobject);
+//            return;
+//        }
+//        if (parameter.websocketClients.containsKey(userid)) {
+//            parameter.websocketClients.get(userid).put(accesstoken, this);
+//        } else {
+//            ConcurrentHashMap<String, WebClientSocket> map = new ConcurrentHashMap<>();
+//            map.put(accesstoken, this);
+//            parameter.websocketClients.put(userid, map);
+//        }
+//        parameter.loginDate.put(userid, createdate);
+//        System.err.println("OpenSession:" + userid);
+//    }
+//
+//    /**
+//     * 连接关闭
+//     *
+//     * @throws IOException
+//     */
+//    @OnClose
+//    private void onClose() throws IOException {
+//        if (parameter.websocketClients.containsKey(userid)) {
+//            parameter.websocketClients.get(userid).remove(accesstoken);
+//            if (parameter.websocketClients.get(userid).isEmpty()) {
+//                parameter.websocketClients.remove(userid);
+//            }
+//            System.err.println("CloseSession:" + userid);
+//        }
+//    }
+//
+//    /**
+//     * {
+//     * "dialogid":1,//对话框id
+//     * "messagetype":"text",//消息类型
+//     * "description":"",//消息摘要
+//     * "data":{
+//     * "message":""//文字正文,
+//     * }
+//     * },
+//     * {
+//     * "dialogid":1,
+//     * "messagetype":"file",//text,file,data,image,
+//     * "description":"",
+//     * "data":{
+//     * "ownertable":"",
+//     * "ownerid":"",
+//     * "serialnumber":"",
+//     * "postfix":"",
+//     * "fobsurl":"",
+//     * "fobsurl_minimage":"",
+//     * "fobsurl_hls":"",
+//     * "fdocument":""
+//     * }
+//     * },
+//     * {
+//     * "dialogid":1,
+//     * "messagetype":"data",//text,file,data,image
+//     * "description":"",
+//     * "data":{
+//     * "type":"",
+//     * "ownertable":"",
+//     * "ownerid":""
+//     * }
+//     * }
+//     *
+//     * @param messageObject
+//     * @throws IOException
+//     */
+//    /**
+//     * 消息接收
+//     *
+//     * @param RequestContent
+//     * @throws IOException
+//     */
+//    @OnMessage
+//    private void onMessage(String RequestContent) throws IOException {
+//        if (RequestContent == null || RequestContent.equals("")) {
+//            return;
+//        }
+//        if ("isalive".equalsIgnoreCase(RequestContent)) {
+//            session.getAsyncRemote().sendText("alive");
+//            return;
+//        }
+//
+//        /**
+//         * 验证请求正文是否为规范的SONObject格式
+//         */
+//        JSONObject requestcontent = null;
+//        try {
+//            requestcontent = JSONObject.parseObject(RequestContent);
+//        } catch (Exception e) {
+//            return;
+//        }
+//        /**
+//         * 验证请求正文中是否包含必填的键值
+//         */
+//        String[] mustkeys = {"classname", "method", "content"};
+//        for (String mustkey : mustkeys) {
+//            if (!requestcontent.containsKey(mustkey)) {
+//                return;
+//            }
+//        }
+//        /**
+//         * 验证请求正文中的content是否为规范的SONObject格式
+//         */
+//        JSONObject content = new JSONObject();
+//        try {
+//            content = requestcontent.getJSONObject("content");
+//        } catch (Exception e) {
+//            return;
+//        }
+//
+//        /**
+//         * 验证正文中的token是否有效
+//         */
+//        String className = requestcontent.getString("classname");
+//
+//        parameter.requesttime.put(accesstoken, Calendar.getInstance().getTime());
+//
+//        String methodName = requestcontent.getString("method");
+//        if (content.isEmpty()) {
+//            content = new JSONObject();
+//        }
+//        content.put("$classname", className);
+//        content.put("$method", methodName);
+//        content.put("$accesstoken", accesstoken);
+//
+//        String key = className + "." + methodName;
+//        String result;
+//        Object obj = null;
+//        try {
+//
+//            long starttimes = Calendar.getInstance().getTimeInMillis();
+//            /**
+//             * 执行请求方法
+//             */
+//            Class clz = Class.forName("com.cnd3b.websocketcontroller." + className);
+//            Constructor cla = clz.getDeclaredConstructor(JSONObject.class);
+//            obj = cla.newInstance(content);
+//            Method method = obj.getClass().getDeclaredMethod(methodName);
+//            result = (String) method.invoke(obj);
+//            long endtimes = Calendar.getInstance().getTimeInMillis();
+//            saveCallMethodMsg(key, true, endtimes - starttimes);
+//        } catch (ClassNotFoundException e) {
+//            e.printStackTrace();
+//            result = new D3BReturnObject_Err().setErrMsg("找不到指定的类" + className).toString();
+//        } catch (InstantiationException e) {
+//            e.printStackTrace();
+//            result = new D3BReturnObject_Err().setErrMsg("类" + className + "实例化异常").toString();
+//        } catch (IllegalAccessException e) {
+//            e.printStackTrace();
+//            result = new D3BReturnObject_Err().setErrMsg("类" + className + "安全权限异常,可能该类为非public类").toString();
+//        } catch (NoSuchMethodException e) {
+//            e.printStackTrace();
+//            result = new D3BReturnObject_Err().setErrMsg("找不到指定的类" + className + "的" + methodName + "方法").toString();
+//        } catch (IllegalArgumentException e) {
+//            e.printStackTrace();
+//            result = new D3BReturnObject_Err().setErrMsg("类" + className + "的" + methodName + "方法参数不合法").toString();
+//        } catch (InvocationTargetException e) {
+//            Throwable targetException = e.getTargetException();
+//            D3BReturnObject_Err d3BReturnObject_err = new D3BReturnObject_Err();
+//            d3BReturnObject_err.setErrMsg(targetException.getMessage());
+//            result = d3BReturnObject_err.toString();
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            result = new D3BReturnObject_Err().setErrMsg("发生未知异常" + e.getMessage()).toString();
+//        } finally {
+//            if (obj != null) {
+//                try {
+//                    obj.getClass().getMethod("p2ServerSystemPaoSetClose").invoke(obj);
+//                } catch (Exception e) {
+//                    e.printStackTrace();
+//                }
+//            }
+//        }
+//        return;
+//    }
+//
+//    /**
+//     * 记录请求数
+//     *
+//     * @param key
+//     * @param fromdb
+//     * @param time
+//     */
+//    private void saveCallMethodMsg(String key, boolean fromdb, long time) {
+//        long callmethodTimes = parameter.callmethodTimes.containsKey(key) ? parameter.callmethodTimes.get(key) : 0L;
+//
+//        //更新请求总数
+//        parameter.callmethodTimes.put(key, callmethodTimes + 1L);
+//
+//        //最新请求时间
+//        parameter.lastcallmethodtime.put(key, Calendar.getInstance().getTime());
+//
+//        //从缓存获取的次数
+//        long callmethod_fromcacheTimes = parameter.callmethod_fromcacheTimes.containsKey(key) ? parameter.callmethod_fromcacheTimes.get(key) : 0L;
+//        if (!fromdb) {
+//            /**
+//             * 方法请求从缓存获取次数
+//             */
+//            parameter.callmethod_fromcacheTimes.put(key, callmethod_fromcacheTimes + 1L);
+//        } else {
+//            /**
+//             * 方法请求查询最新耗时
+//             */
+//            parameter.callmethodLastTimeLong.put(key, time);
+//
+//
+//            long totaltimes = callmethodTimes - callmethod_fromcacheTimes;
+//
+//            /**
+//             * 方法请求查询平均时间
+//             */
+//            long callmethodTimeLong = parameter.callmethodTimeLong.containsKey(key) ? parameter.callmethodTimeLong.get(key) : 0L;
+//
+//            parameter.callmethodTimeLong.put(key, (callmethodTimeLong * totaltimes + time) / (totaltimes + 1));
+//        }
+//    }
+//
+//    @OnError
+//    private void onError(Session session, Throwable error) {
+//        error.printStackTrace();
+//    }
+//
+//    /**
+//     * 对当前连接发送对话框消息
+//     *
+//     * @param message
+//     */
+//    public void sendDialogMessage(JSONObject message) {
+//        JSONObject object = new JSONObject();
+//        object.put("msgtype", "imdialog");
+//        object.put("message", message);
+//        session.getAsyncRemote().sendText(object.toJSONString());
+//    }
+//
+//    /**
+//     * 对当前连接发送系统消息
+//     *
+//     * @param message
+//     */
+//    public void sendSystemMessage(JSONObject message) {
+//        JSONObject object = new JSONObject();
+//        object.put("msgtype", "system");
+//        object.put("message", message);
+//        session.getAsyncRemote().sendText(object.toJSONString());
+//    }
+//
+//}

+ 10 - 0
src/dsb/com/cnd3b/restcontroller/customer/wechatapplet/SQL/查询视频播放记录.sql

@@ -0,0 +1,10 @@
+select t1.tviewlogid,
+       t1.tuserid,
+       t1.tattachmentid,
+       t1.tprocess,
+       t1.tarchives_scid,
+       t1.changedate
+from tviewlog t1
+where t1.tarchives_scid = $tarchives_scid$
+  and t1.tuserid = $tuserid$
+ORDER BY t1.changedate DESC

+ 61 - 4
src/dsb/com/cnd3b/restcontroller/customer/wechatapplet/wechatapplet.java

@@ -15,6 +15,8 @@ import com.cnd3b.common.data.SQLFactory;
 import com.cnd3b.common.parameter.parameter;
 
 import p2.common.parse.A;
+import p2.pao.PaoRemote;
+import p2.pao.PaoSetRemote;
 import p2.util.P2Exception;
 
 import java.net.URI;
@@ -22,6 +24,8 @@ import java.net.URL;
 import java.net.URLEncoder;
 import java.sql.Date;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 import static com.cnd3b.utility.aliyun.oss.AliyunOSSUtil.*;
@@ -206,7 +210,24 @@ public class wechatapplet extends Controller {
         // 遍历所有文件。
         System.out.println("Objects:");
         List<JSONObject> objectSummaryList = new ArrayList<>();
-        for (OSSObjectSummary objectSummary : listing.getObjectSummaries()) {
+        List<OSSObjectSummary> sums = listing.getObjectSummaries();
+        //按照时间排序
+        Collections.sort(sums, (o1, o2) -> {
+            // TODO Auto-generated method stub
+            long dateTime1 = o1.getLastModified().getTime();
+            long dateTime2 = o2.getLastModified().getTime();
+            if (dateTime1 == dateTime2) {
+                return 0;
+            } else {
+                //时间正序
+//					return dateTime1 > dateTime2 ? 1 : -1;
+                //时间倒序
+                return dateTime1 > dateTime2 ? -1 : 1;
+            }
+
+        });
+
+        for (OSSObjectSummary objectSummary : sums) {
             if (!objectSummary.getKey().equals(folderPath)) {
                 JSONObject object = new JSONObject();
                 object.put("key", objectSummary.getKey());
@@ -297,10 +318,10 @@ public class wechatapplet extends Controller {
                     String frole = row.getString("frole");
                     String fauthtype = row.getString("fauthtype");
                     String tuserid = row.getString("tuserid");
-                    if (frole != null && !frole.equals("")) {
+                    if (!frole.equals("")) {
                         list_Roles.add(frole);
                     }
-                    if (fauthtype != null && !fauthtype.equals("")) {
+                    if (!fauthtype.equals("")) {
                         list_fauthtype.add(fauthtype);
                     }
                     if (!tuserid.equals("0")) {
@@ -324,7 +345,7 @@ public class wechatapplet extends Controller {
                 } else {
 
                     for (String str : list_fauthtype) {
-                        if (list_fauthtype.contains(str)) {
+                        if (listfauthtype.contains(str)) {
                             isFauthtype = true;
                         }
                     }
@@ -453,4 +474,40 @@ public class wechatapplet extends Controller {
         return getSucReturnObject().setData(object).toString();
     }
 
+
+    public String addViewlog() throws P2Exception {
+        Long tarchives_scid = content.getLong("tarchives_scid");
+        Long tattachmentid = content.getLong("tattachmentid");
+        String tprocess = content.getString("tprocess");
+
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tviewlog", "tarchives_scid = '" + tarchives_scid + "' and tattachmentid = '" + tattachmentid + "' and tuserid = '" + parameter.tuserid + "' ");
+        if (paoSetRemote.isEmpty()) {
+            PaoRemote paoRemote = paoSetRemote.addAtEnd();
+            paoRemote.setValue("tarchives_scid", tarchives_scid, 11L);
+            paoRemote.setValue("tattachmentid", tattachmentid, 11L);
+            paoRemote.setValue("tprocess", tprocess, 11L);
+            paoRemote.setValue("tuserid", parameter.tuserid, 11L);
+            paoRemote.setValue("changedate", getDateTime_Str(), 11L);
+            paoSetRemote.save();
+        } else {
+            PaoRemote paoRemote = paoSetRemote.getPao(0);
+            paoRemote.setValue("tprocess", tprocess, 11L);
+            paoRemote.setValue("changedate", getDateTime_Str(), 11L);
+            paoSetRemote.save();
+        }
+
+
+        return getSucReturnObject().toString();
+    }
+
+    public String selectViewlog() throws P2Exception {
+        Long tarchives_scid = content.getLong("tarchives_scid");
+        SQLFactory sqlFactory = new SQLFactory(this, "查询视频播放记录");
+        sqlFactory.addParameter("tuserid", parameter.tuserid);
+        sqlFactory.addParameter("tarchives_scid", tarchives_scid);
+        String sql = sqlFactory.getSQL();
+        Rows rows = dbConnect.runSqlQuery(sql);
+        return getSucReturnObject().setData(rows).toString();
+    }
+
 }

+ 18 - 5
src/dsb/com/cnd3b/restcontroller/enterprise/datacenter/datacenter.java

@@ -12,10 +12,7 @@ import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Base64;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 import static com.cnd3b.utility.aliyun.oss.AliyunOSSUtil.*;
 
@@ -269,7 +266,23 @@ public class datacenter extends Controller {
         // 遍历所有文件。
         System.out.println("Objects:");
         List<JSONObject> objectSummaryList = new ArrayList<>();
-        for (OSSObjectSummary objectSummary : listing.getObjectSummaries()) {
+        List<OSSObjectSummary> sums = listing.getObjectSummaries();
+        //按照时间排序
+        Collections.sort(sums, (o1, o2) -> {
+            // TODO Auto-generated method stub
+            long dateTime1 = o1.getLastModified().getTime();
+            long dateTime2 = o2.getLastModified().getTime();
+            if (dateTime1 == dateTime2) {
+                return 0;
+            } else {
+                //时间正序
+//					return dateTime1 > dateTime2 ? 1 : -1;
+                //时间倒序
+                return dateTime1 > dateTime2 ? -1 : 1;
+            }
+
+        });
+        for (OSSObjectSummary objectSummary : sums) {
             if (!objectSummary.getKey().equals(folderPath)) {
                 JSONObject object = new JSONObject();
                 object.put("key", objectSummary.getKey());

+ 1 - 2
src/dsb/com/cnd3b/restcontroller/enterprise/tadministrators/SQL/更新管理员.sql

@@ -1,5 +1,4 @@
 UPDATE tuser
 SET wechat_name=$wechat_name$,
-    wechat_mobile=$wechat_mobile$,
-    wechat_position=$wechat_position$
+    wechat_mobile=$wechat_mobile$
 WHERE tuserid = $tuserid$

+ 4 - 4
src/dsb/com/cnd3b/restcontroller/enterprise/tadministrators/tadministrators.java

@@ -45,7 +45,7 @@ public class tadministrators extends Controller {
         int fiszl = content.getIntValue("fiszl");
         String wechat_name = content.getString("wechat_name");
         String wechat_mobile = content.getString("wechat_mobile");
-        String wechat_position = content.getString("wechat_position");
+//        String wechat_position = content.getString("wechat_position");
 
         //新增体系
         PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tadministrators", "tuserid = '" + tuserid + "'");
@@ -64,7 +64,7 @@ public class tadministrators extends Controller {
             SQLFactory sqlFactory = new SQLFactory(this, "更新管理员");
             sqlFactory.addParameter("wechat_name", wechat_name);
             sqlFactory.addParameter("wechat_mobile", wechat_mobile);
-            sqlFactory.addParameter("wechat_position", wechat_position);
+//            sqlFactory.addParameter("wechat_position", wechat_position);
             sqlFactory.addParameter("tuserid", tuserid);
             dbConnect.runSqlUpdate(sqlFactory.getSQL());
 
@@ -98,7 +98,7 @@ public class tadministrators extends Controller {
 
         String wechat_name = content.getString("wechat_name");
         String wechat_mobile = content.getString("wechat_mobile");
-        String wechat_position = content.getString("wechat_position");
+//        String wechat_position = content.getString("wechat_position");
 
         //新增体系
         PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tadministrators", "tadministratorsid = '" + tadministratorsid + "'");
@@ -117,7 +117,7 @@ public class tadministrators extends Controller {
             SQLFactory sqlFactory = new SQLFactory(this, "更新管理员");
             sqlFactory.addParameter("wechat_name", wechat_name);
             sqlFactory.addParameter("wechat_mobile", wechat_mobile);
-            sqlFactory.addParameter("wechat_position", wechat_position);
+//            sqlFactory.addParameter("wechat_position", wechat_position);
             sqlFactory.addParameter("tuserid", tuserid);
             dbConnect.runSqlUpdate(sqlFactory.getSQL());
         } else {

+ 1 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tuser/SQL/通过部门查成员.sql

@@ -5,6 +5,7 @@ SELECT t1.tuserid,
        t1.wechat_open_userid,
        t1.wechat_mobile,
        t1.wechat_position,
+       t1.isopenaccount,
        t1.fusertype
 FROM tuser t1
 WHERE t1.wechat_depid = $wechat_depid$

+ 1 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tuser/SQL/部门成员列表.sql

@@ -6,6 +6,7 @@ SELECT t1.tuserid,
        t1.wechat_mobile,
        t1.wechat_position,
        t1.fusertype,
+       t1.isopenaccount,
        t2.wechat_depname
 FROM tuser t1
          LEFT JOIN tdepartment t2

+ 2 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tuser/tuser.java

@@ -63,6 +63,7 @@ public class tuser extends Controller {
         String wechat_name = content.getString("wechat_name");
         String wechat_mobile = content.getString("wechat_mobile");
         String wechat_position = content.getString("wechat_position");
+        Boolean isopenaccount = content.getBoolean("isopenaccount");
 
         PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tuser", "tuserid = '" + tuserid + "'");
         if (!paoSetRemote.isEmpty()) {
@@ -70,6 +71,7 @@ public class tuser extends Controller {
             paoRemote.setValue("wechat_name", wechat_name, 11L);
             paoRemote.setValue("wechat_mobile", wechat_mobile, 11L);
             paoRemote.setValue("wechat_position", wechat_position, 11L);
+            paoRemote.setValue("isopenaccount", isopenaccount, 11L);
             paoSetRemote.save();
         } else {
             return getErrReturnObject().setErrMsg("δÕÒµ½¸üеÄÊý¾Ý").toString();

+ 1 - 0
src/dsb/com/cnd3b/restcontroller/publicmethod/wechatapplet/SQL/查询账号.sql

@@ -6,6 +6,7 @@ SELECT t1.tuserid,
        t1.wechat_mobile,
        t1.wechat_position,
        t1.fusertype,
+       t1.isopenaccount,
        t2.tadministratorsid,
        t2.fisagent,
        t2.fissaler,

+ 3 - 0
src/dsb/com/cnd3b/restcontroller/publicmethod/wechatapplet/wechatapplet.java

@@ -55,6 +55,9 @@ public class wechatapplet extends Controller {
         if (rows.isEmpty()) {
             return getErrReturnObject().setErrMsg("未找到用户信息").toString();
         }
+        if (!rows.get(0).getBoolean("isopenaccount")) {
+            return getErrReturnObject().setErrMsg("您没有权限,请联系管理员开通!").toString();
+        }
 
         return getSucReturnObject().setData(rows).toString();
     }

+ 2 - 4
src/dsb/com/cnd3b/service/GetWechatData.java

@@ -38,8 +38,6 @@ public class GetWechatData extends BaseClass implements Runnable {
         try {
             positionSeller = getPosition(2);
             positionAgent = getPosition(1);
-            System.err.println(positionSeller.length);
-            System.err.println(positionAgent.length);
             System.err.println("开始拉取微信数据......");
             getDepartmentList();
             clearCache();
@@ -87,7 +85,7 @@ public class GetWechatData extends BaseClass implements Runnable {
 
         client.shutdown();
         keysList.clear();
-        String sql = " delete from  TDATALOG where datediff(day,changedate,getdate()) > 3";
+        String sql = " delete from  TDATALOG where datediff(day,changedate,getdate()) > 1";
         dbConnect.runSqlUpdate(sql);
 
     }
@@ -107,7 +105,7 @@ public class GetWechatData extends BaseClass implements Runnable {
         //把当前时间赋给日历
         calendar.setTime(now);
         //设置为7天前
-        calendar.add(Calendar.DAY_OF_MONTH, -7);
+        calendar.add(Calendar.DAY_OF_MONTH, -1);
         //得到7天前的时间
         Date before7days = calendar.getTime();
         if (before7days.getTime() < addtime.getTime()) {

+ 2 - 1
src/dsb/com/cnd3b/service/SQL/插入微信成员.sql

@@ -9,5 +9,6 @@ SET changedate=GETDATE(),
     wechat_name = $wechat_name$,
     wechat_mobile = $wechat_mobile$,
     wechat_depid = $wechat_depid$,
-    wechat_open_userid = $wechat_open_userid$
+    wechat_open_userid = $wechat_open_userid$,
+    wechat_position = $wechat_position$
 WHERE wechat_userid = $wechat_userid$

+ 5 - 29
src/dsb/com/cnd3b/utility/wechatdock/WechatDock_Enterprise.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.BaseClass;
 import com.cnd3b.common.data.db.DBConnect;
+import com.cnd3b.common.parameter.parameter;
 import com.cnd3b.utility.WebRequest;
 import p2.pao.PaoRemote;
 import p2.pao.PaoSetRemote;
@@ -27,13 +28,13 @@ public class WechatDock_Enterprise extends BaseClass {
     public static final String QYWX_GET_JSAPITICKET_URL_PARAM_URL = "url";
     public static final String QYWX_GET_JSAPITICKET_RETURN_SIGNATURE = "signature";
     //企业ID
-    public static String corpid = "ww6e401e63011f9f59";
+    public static String corpid = parameter.corpid();
     //应用的凭证密钥(通讯录)
-    public static String corpsecret = "0UaJC_H6HUp4myFsJTxINeDHRAPj7Z4lYqmDMZFRmT0";
+    public static String corpsecret = parameter.corpsecret();
     //应用的凭证密钥(资料中心)
-    public static String corpsecret1 = "uf8PZCPRPIB9pSLrgQJuK0z4kifrSIcH_VxqeyjYAt4";
+    public static String corpsecret1 = parameter.corpsecret1();
     //应用的凭证密钥(培训学习)
-    public static String corpsecret2 = "hBJRVc0VZ5hNk-3ItOrqcWAImWmimhQMZWhtOcX08yI";
+    public static String corpsecret2 = parameter.corpsecret2();
 
     //企业应用agentid
     public static long agentid = 1000003;
@@ -76,31 +77,6 @@ public class WechatDock_Enterprise extends BaseClass {
         return access_token;
     }
 
-//    /**
-//     * 获取小程序token
-//     *
-//     * @param type
-//     * @return
-//     */
-//    public static String getMiniAppAccessToken(int type) {
-//        String corpsecret = "";
-//        Object access_token = "";
-//        if (type == 1) {
-//            corpsecret = corpsecret1;
-//        } else {
-//            corpsecret = corpsecret2;
-//        }
-//
-//        String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + corpid + "&corpsecret=" + corpsecret;
-//        String res = new WebRequest().doGet(url);
-//        JSONObject resobject = JSONObject.parseObject(res);
-//        System.err.println(resobject);
-//        if (resobject.containsKey("access_token")) {
-//            access_token = resobject.get("access_token");
-//        }
-//
-//        return access_token.toString();
-//    }
 
     private static String access_token_zlzx = "";
     private static long access_token_timelimit_zlzx = 0L;

+ 21 - 22
src/dsb/com/cnd3b/websocketcontroller/message/message.java

@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.Controller;
 import com.cnd3b.common.data.SQLFactory;
 import com.cnd3b.common.parameter.parameter;
-import com.cnd3b.common.websocket.WebClientSocket;
 import com.cnd3b.utility.Encryption;
 import p2.util.P2Exception;
 
@@ -53,13 +52,13 @@ public class message extends Controller {
         messageObject.put("data", msgObject);
 
         ArrayList<Long> userids = getImDialogUserIds(timdialogid);
-        for (long userid : userids) {
-            if (parameter.websocketClients.containsKey(userid)) {
-                for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
-                    webClientSocket.sendDialogMessage(messageObject);
-                }
-            }
-        }
+//        for (long userid : userids) {
+//            if (parameter.websocketClients.containsKey(userid)) {
+//                for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
+//                    webClientSocket.sendDialogMessage(messageObject);
+//                }
+//            }
+//        }
         saveMessage(messageObject, fmessage);
         return getSucReturnObject().toString();
     }
@@ -91,13 +90,13 @@ public class message extends Controller {
         messageObject.put("data", getAttachmentUrl(tattachmentid));
 
         ArrayList<Long> userids = getImDialogUserIds(timdialogid);
-        for (long userid : userids) {
-            if (parameter.websocketClients.containsKey(userid)) {
-                for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
-                    webClientSocket.sendDialogMessage(messageObject);
-                }
-            }
-        }
+//        for (long userid : userids) {
+//            if (parameter.websocketClients.containsKey(userid)) {
+//                for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
+//                    webClientSocket.sendDialogMessage(messageObject);
+//                }
+//            }
+//        }
         saveMessage(messageObject, "null");
         return getSucReturnObject().toString();
     }
@@ -136,13 +135,13 @@ public class message extends Controller {
         messageObject.put("data", msgObject);
 
         ArrayList<Long> userids = getImDialogUserIds(timdialogid);
-        for (long userid : userids) {
-            if (parameter.websocketClients.containsKey(userid)) {
-                for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
-                    webClientSocket.sendDialogMessage(messageObject);
-                }
-            }
-        }
+//        for (long userid : userids) {
+//            if (parameter.websocketClients.containsKey(userid)) {
+//                for (WebClientSocket webClientSocket : parameter.websocketClients.get(userid).values()) {
+//                    webClientSocket.sendDialogMessage(messageObject);
+//                }
+//            }
+//        }
         saveMessage(messageObject, "null");
         return getSucReturnObject().toString();
     }