吴志根 před 4 roky
rodič
revize
86f036e2fc

+ 6 - 2
src/dsb/com/cnd3b/common/data/db/SQLiteJDBC.java

@@ -17,13 +17,17 @@ public class SQLiteJDBC {
     SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
 
-
     public void open() {
         try {
             OperatingSystemMXBean system = ManagementFactory.getOperatingSystemMXBean();
             String OSName = system.getName();
             Class.forName("org.sqlite.JDBC");
-            c = DriverManager.getConnection("jdbc:sqlite:" + parameter.SQLiteFilePath());
+            if (parameter.isMac) {
+                c = DriverManager.getConnection("jdbc:sqlite:/Users/eganwu/Documents/develop/idea/JS_SERVER/data.db");
+            } else {
+                c = DriverManager.getConnection("jdbc:sqlite:" + parameter.SQLiteFilePath());
+            }
+
             stmt = c.createStatement();
         } catch (ClassNotFoundException e) {
             e.printStackTrace();

+ 1 - 0
src/dsb/com/cnd3b/common/parameter/parameter.java

@@ -25,6 +25,7 @@ public class parameter {
     public static HashMap<Long, Row> userIdList = new HashMap<>(16);
 
     public static String defaultsiteid = "JIUSHENG";
+    public static Boolean isMac = true;
 
     /**
      * µÇ¼-ÊÖ»úºÅ¡¢ÑéÖ¤Âë

+ 1 - 1
src/dsb/com/cnd3b/common/restful/WebClientRest.java

@@ -349,7 +349,7 @@ public class WebClientRest {
         }
 
         if (!password.equals(pwdRows.get(0).getString("fpassword"))) {
-            return new D3BReturnObject_Err().setErrCode(-1).setErrMsg("ÃØÃÜ´íÎó").toString();
+            return new D3BReturnObject_Err().setErrCode(-1).setErrMsg("ÃÜÂë´íÎó").toString();
         }
 
 

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

@@ -0,0 +1,17 @@
+SELECT t1.tuserid,
+       t1.wechat_depid,
+       t1.wechat_userid,
+       t1.wechat_name,
+       t1.wechat_open_userid,
+       t1.wechat_mobile,
+       t1.wechat_position,
+       t1.fusertype,
+       t2.tadministratorsid,
+       t2.fisagent,
+       t2.fissaler,
+       t2.fissysadministrator,
+       t2.fispxxx,
+       t2.fiszl
+FROM tuser t1
+         LEFT JOIN tadministrators t2 ON t1.tuserid = t2.tuserid
+WHERE t1.wechat_userid = $wechat_userid$

+ 51 - 0
src/dsb/com/cnd3b/restcontroller/customer/wechatapplet/wechatapplet.java

@@ -0,0 +1,51 @@
+package com.cnd3b.restcontroller.customer.wechatapplet;
+
+import com.alibaba.fastjson.JSONObject;
+import com.cnd3b.common.Controller;
+import com.cnd3b.common.data.Row;
+import com.cnd3b.common.data.Rows;
+import com.cnd3b.common.data.SQLFactory;
+import com.cnd3b.common.parameter.parameter;
+import com.cnd3b.utility.WebRequest;
+import com.cnd3b.utility.wechatdock.WechatDock_Enterprise;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
+public class wechatapplet extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public wechatapplet(JSONObject content) {
+        super(content);
+    }
+
+    public String wechatappletLogin() {
+        String code = content.getString("code");
+        String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + WechatDock_Enterprise.getAccessToken() + "&code=" + code;
+        System.err.println(url);
+        String response = new WebRequest().doGet(url);
+        JSONObject object = JSONObject.parseObject(response);
+        System.err.println(object);
+        int errcode = object.getIntValue("errcode");
+        String errmsg = object.getString("errmsg");
+        if (errcode != 0) {
+            return getErrReturnObject().setErrMsg(errmsg).toString();
+        }
+        String userid = object.getString("UserId");
+        SQLFactory sqlFactory = new SQLFactory(this, "查询账号");
+        sqlFactory.addParameter("wechat_userid", userid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        for (Row row : rows) {
+            row.put("logintime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()));
+        }
+        if (rows.isEmpty()) {
+            return getErrReturnObject().setErrMsg("未找到用户信息").toString();
+        }
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+}

+ 130 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tarchives_sc/tarchives_sc.java

@@ -0,0 +1,130 @@
+package com.cnd3b.restcontroller.enterprise.tarchives_sc;
+
+import com.alibaba.fastjson.JSONObject;
+import com.cnd3b.common.Controller;
+import p2.common.parse.J;
+import p2.pao.PaoRemote;
+import p2.pao.PaoSetRemote;
+import p2.util.P2Exception;
+
+public class tarchives_sc extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public tarchives_sc(JSONObject content) {
+        super(content);
+    }
+
+    /**
+     * 新增课件
+     *
+     * @return
+     */
+    public String inseretTarchives_sc() throws P2Exception {
+
+        String ttypedetailid = content.getString("ttypedetailid");
+        String fnotes = content.getString("fnotes");
+        String ftitle = content.getString("ftitle");
+        String fiscandownload = content.getString("fiscandownload");
+        String fisontop = content.getString("fisontop");
+
+        //新增
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tarchives_sc");
+        PaoRemote paoRemote = paoSetRemote.addAtEnd();
+        paoRemote.setValue("ttypedetailid", ttypedetailid, 11L);
+        paoRemote.setValue("fnotes", fnotes, 11L);
+        paoRemote.setValue("fstatus", "新建", 11L);
+        paoRemote.setValue("ftitle", ftitle, 11L);
+        paoRemote.setValue("fiscandownload", fiscandownload, 11L);
+        paoRemote.setValue("fisontop", fisontop, 11L);
+        paoSetRemote.save();
+        JSONObject object = new JSONObject();
+        object.put("id", paoRemote.getUniqueIDValue());
+        return getSucReturnObject().setData(object).toString();
+    }
+
+    /**
+     * 更新课件
+     *
+     * @return
+     */
+    public String updateTarchives_sc() throws P2Exception {
+        String tarchives_scid = content.getString("tarchives_scid");
+        String ttypedetailid = content.getString("tagentsid");
+        String fnotes = content.getString("fnotes");
+        String ftitle = content.getString("ftitle");
+
+        String fiscandownload = content.getString("fiscandownload");
+        String fisontop = content.getString("fisontop");
+        //更新体系
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tarchives_sc", "tarchives_scid = '" + tarchives_scid + "'");
+        if (!paoSetRemote.isEmpty()) {
+            PaoRemote paoRemote = paoSetRemote.getPao(0);
+            paoRemote.setValue("ttypedetailid", ttypedetailid, 11L);
+            paoRemote.setValue("fnotes", fnotes, 11L);
+            paoRemote.setValue("fstatus", "新建", 11L);
+            paoRemote.setValue("ftitle", ftitle, 11L);
+            paoRemote.setValue("fiscandownload", fiscandownload, 11L);
+            paoRemote.setValue("fisontop", fisontop, 11L);
+            paoSetRemote.save();
+        } else {
+            return getErrReturnObject().setErrMsg("未找到更新的数据").toString();
+        }
+
+        JSONObject object = new JSONObject();
+        object.put("id", tarchives_scid);
+        return getSucReturnObject().setData(object).toString();
+    }
+
+    /**
+     * 删除课件列表
+     *
+     * @return
+     */
+    public String deleteTarchives_sc() throws P2Exception {
+        String tarchives_scid = content.getString("tarchives_scid");
+
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tarchives_sc", "tarchives_scid = '" + tarchives_scid + "'");
+        if (!paoSetRemote.isEmpty()) {
+            PaoRemote paoRemote = paoSetRemote.getPao(0);
+            paoRemote.delete();
+            paoSetRemote.save();
+        } else {
+            return getErrReturnObject().setErrMsg("删除失败").toString();
+        }
+        return getSucReturnObject().toString();
+    }
+
+    /**
+     * 发布课件
+     *
+     * @return
+     * @throws P2Exception
+     */
+    public String auditTarchives_sc() throws P2Exception {
+        String tarchives_scid = content.getString("tarchives_scid");
+
+        //更新体系
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tarchives_sc", "tarchives_scid = '" + tarchives_scid + "'");
+        if (!paoSetRemote.isEmpty()) {
+            PaoRemote paoRemote = paoSetRemote.getPao(0);
+            paoRemote.setValue("fstatus", "发布", 11L);
+            paoSetRemote.save();
+        } else {
+            return getErrReturnObject().setErrMsg("未找到发布的数据").toString();
+        }
+
+        return getSucReturnObject().toString();
+    }
+
+    /**
+     * 查询课件列表
+     *
+     * @return
+     */
+    public String selectTarchives_scList() {
+        return getSucReturnObject().toString();
+    }
+}

+ 23 - 17
src/dsb/com/cnd3b/service/GetWechatData.java

@@ -24,7 +24,7 @@ public class GetWechatData extends BaseClass implements Runnable {
 
     @Override
     public void run() {
-        if (new SQLiteJDBC().checkServicesUsed("GetWechatData", false)) {
+//        if (new SQLiteJDBC().checkServicesUsed("GetWechatData", false)) {
             try {
                 System.err.println("GetWechatData Service start...");
                 getDepartmentList();
@@ -32,7 +32,7 @@ public class GetWechatData extends BaseClass implements Runnable {
                 e.printStackTrace();
             }
 
-        }
+//        }
     }
 
     /**
@@ -46,25 +46,31 @@ public class GetWechatData extends BaseClass implements Runnable {
         String response = new WebRequest().doGet(url);
         JSONObject object = JSONObject.parseObject(response);
         JSONArray array = object.getJSONArray("department");
-        updateDepartment(array);
-        JSONArray userArray = new JSONArray();
-        JSONArray tagentsArray = new JSONArray();
-        int id = 0;
-        for (Object obj : array) {
-            JSONObject jsonObject = (JSONObject) obj;
-            String name = jsonObject.getString("name");
-            //查询部门名称为经销商的部门id
-            if (name.equals(depname)) {
-                id = jsonObject.getIntValue("id");
+        if (array.size() > 0) {
+            updateDepartment(array);
+            JSONArray userArray = new JSONArray();
+            JSONArray tagentsArray = new JSONArray();
+            int id = 0;
+            for (Object obj : array) {
+                JSONObject jsonObject = (JSONObject) obj;
+                String name = jsonObject.getString("name");
+                //查询部门名称为经销商的部门id
+                if (name.equals(depname)) {
+                    id = jsonObject.getIntValue("id");
+                }
+                userArray.addAll(getDepartmentUsers(jsonObject.getIntValue("id"), 0));
+
             }
-            userArray.addAll(getDepartmentUsers(jsonObject.getIntValue("id"), 0));
+            //更新成员表
+            updateUser(userArray);
+            //更新经销商表
 
+            updateTagents(id);
+        } else {
+            WechatDock_Enterprise.getAccessToken2();
         }
-        //更新成员表
-        updateUser(userArray);
-        //更新经销商表
 
-        updateTagents(id);
+
         return object.getJSONArray("department");
     }
 

+ 20 - 0
src/dsb/com/cnd3b/utility/wechatdock/WechatDock_Enterprise.java

@@ -38,5 +38,25 @@ public class WechatDock_Enterprise extends BaseClass {
         return access_token;
     }
 
+    /**
+     * ÖØÐ»ñȡһ´Îtoken
+     *
+     * @return
+     */
+    public static String getAccessToken2() {
+        long nowtime = Calendar.getInstance().getTimeInMillis();
+
+        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.getString("access_token");
+            access_token_timelimit = nowtime + 1000 * resobject.getIntValue("expires_in");
+        }
+
+        return access_token;
+    }
+
 
 }