Forráskód Böngészése

Merge branch 'beta'

lsc 1 éve
szülő
commit
fb20eccf32
7 módosított fájl, 532 hozzáadás és 266 törlés
  1. 112 16
      js/Desktop/DeskTop.js
  2. 2 2
      js/Desktop/Onload.js
  3. 66 50
      js/Office/Poll.js
  4. 307 166
      node/message.js
  5. 4 18
      node/mysql.js
  6. 35 9
      node/test.js
  7. 6 5
      uform.js

+ 112 - 16
js/Desktop/DeskTop.js

@@ -202,7 +202,7 @@ U.MD.D.I.orgStemDeskIcon = [
     { "Name": "教学资源", "Url": "source", "style": { "cssText": "background-image:url(/img/icon/source.png)" } },
     { "Name": "AI共创", "Url": "AIChat", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
     { "Name": "AI协同", "Url": "ainew", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
-    { "Name": "知识建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
+    { "Name": "协同建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
     { "Name": "数据看板", "Url": "dataBoard", "style": { "cssText": "background-image:url(/img/icon/dataBoard.png)" } },
     // { "Name": "jupyter", "Url": "jupyter", "style": { "cssText": "background-image:url(/img/icon/jupyter.png)" } },
 ];
@@ -548,12 +548,19 @@ U.MD.D.I.futianAdminDeskIcon = [
 U.MD.D.I.lotechTeacherDeskIcon = [
     { "Name": "课程管理", "Url": "project", "style": { "cssText": "background-image:url(/img/icon/project.png)" } },
     { "Name": "课程中心", "Url": "study", "style": { "cssText": "background-image:url(/img/icon/study.png)" } },
+    { "Name": "学生管理", "Url": "student", "style": { "cssText": "background-image:url(/img/icon/student.png)" } },
+    { "Name": "学生评价", "Url": "evaluate", "style": { "cssText": "background-image:url(/img/icon/evaluation.png)" } },
     { "Name": "项目管理", "Url": "studentCourseS", "style": { "cssText": "background-image:url(/img/icon/studentCourse.png)" } },
     { "Name": "项目中心", "Url": "studentIndex", "style": { "cssText": "background-image:url(/img/icon/studentIndex.png)" } },
     { "Name": "工作管理", "Url": "studioCourse", "style": { "cssText": "background-image:url(/img/icon/studioCourse.png)" } },
     { "Name": "工作中心", "Url": "studioIndex", "style": { "cssText": "background-image:url(/img/icon/studioIndex.png)" } },
-    { "Name": "教学资源", "Url": "source", "style": { "cssText": "background-image:url(/img/icon/source.png)" } },
+    { "Name": "教研室", "Url": "teacherOffice", "style": { "cssText": "background-image:url(/img/icon/teacherOffice.png)" } },
+    { "Name": "年级管理", "Url": "Grade", "style": { "cssText": "background-image:url(/img/icon/Grade.png)" } },
+    { "Name": "班级管理", "Url": "class", "style": { "cssText": "background-image:url(/img/icon/class.png)" } },
+    { "Name": "学习分析", "Url": "learnAna", "style": { "cssText": "background-image:url(/img/icon/learnAna.png)" } },
     { "Name": "AI共创", "Url": "AIChat", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
+    { "Name": "AI协同", "Url": "ainew", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
+    { "Name": "协同建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
 ];
 
 //龙华中心小学教师桌面图标的全局变量
@@ -648,6 +655,8 @@ U.MD.D.I.hkStudentDeskIcon = [
     { "Name": "课程中心", "Url": "studentStudy", "style": { "cssText": "background-image:url(/img/icon/study.png)" } },
     { "Name": "项目管理", "Url": "studentCourse", "style": { "cssText": "background-image:url(/img/icon/studentCourse.png)" } },
     { "Name": "项目中心", "Url": "studentIndex", "style": { "cssText": "background-image:url(/img/icon/studentIndex.png)" } },
+    { "Name": "AI共创", "Url": "AIChat", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
+    { "Name": "AI协同", "Url": "ainew", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
 ];
 
 //香海正覺蓮社佛教正覺中學
@@ -776,7 +785,7 @@ U.MD.D.I.dseiTeacherDeskIcon = [
     { "Name": "学习分析", "Url": "learnAna", "style": { "cssText": "background-image:url(/img/icon/learnAna.png)" } },
     { "Name": "AI共创", "Url": "AIChat", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
     { "Name": "AI协同", "Url": "ainew", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
-    { "Name": "知识建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
+    { "Name": "协同建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
     { "Name": "数据看板", "Url": "dataBoard", "style": { "cssText": "background-image:url(/img/icon/dataBoard.png)" } },
 ];
 
@@ -821,7 +830,7 @@ U.MD.D.I.dseiAdminDeskIcon = [
     { "Name": "学习分析", "Url": "learnAna", "style": { "cssText": "background-image:url(/img/icon/learnAna.png)" } },
     { "Name": "AI共创", "Url": "AIChat", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
     { "Name": "AI协同", "Url": "ainew", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
-    { "Name": "知识建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
+    { "Name": "协同建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
     { "Name": "数据看板", "Url": "dataBoard", "style": { "cssText": "background-image:url(/img/icon/dataBoard.png)" } },
 ];
 
@@ -850,7 +859,7 @@ U.MD.D.I.szjkyTeacherDeskIcon = [
     { "Name": "课程进展", "Url": "case", "style": { "cssText": "background-image:url(/img/icon/case.png)" } },
     { "Name": "AI共创", "Url": "AIChat", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
     { "Name": "AI协同", "Url": "ainew", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
-    { "Name": "知识建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
+    { "Name": "协同建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
     { "Name": "数据看板", "Url": "dataBoard", "style": { "cssText": "background-image:url(/img/icon/dataBoard.png)" } },
 ];
 
@@ -869,7 +878,7 @@ U.MD.D.I.szjkyAdminDeskIcon = [
     { "Name": "课程进展", "Url": "case", "style": { "cssText": "background-image:url(/img/icon/case.png)" } },
     { "Name": "AI共创", "Url": "AIChat", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
     { "Name": "AI协同", "Url": "ainew", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } },
-    { "Name": "知识建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
+    { "Name": "协同建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
     { "Name": "数据看板", "Url": "dataBoard", "style": { "cssText": "background-image:url(/img/icon/dataBoard.png)" } },
 ];
 
@@ -1084,11 +1093,28 @@ U.MD.D.I.initDesktopIcons = function(el, type) {
             { "Name": "AI协同", "Url": "ainew", "style": { "cssText": "background-image:url(/img/icon/AIChat.png)" } }, 
             { "Name": "工作管理", "Url": "studioCourse", "style": { "cssText": "background-image:url(/img/icon/studioCourse.png)" } }, 
             { "Name": "工作中心", "Url": "studioIndex", "style": { "cssText": "background-image:url(/img/icon/studioIndex.png)" } },
-            { "Name": "知识建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
+            { "Name": "协同建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
             { "Name": "数据看板", "Url": "dataBoard", "style": { "cssText": "background-image:url(/img/icon/dataBoard.png)" } },
         )
     }
 
+    if (_org == 'c95e0a56-c205-11ed-8d51-005056b86db5') {
+        _teacherDesktopIconInfo.push(
+            { "Name": "协同建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
+            { "Name": "数据看板", "Url": "dataBoard", "style": { "cssText": "background-image:url(/img/icon/dataBoard.png)" } },
+        )
+        _studentDesktopIconInfo.push(
+            { "Name": "协同建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
+        )
+        
+    }
+
+    if (_oid == 'cf8841e8-c7c0-11ed-9546-005056b86db5') {
+        _teacherDesktopIconInfo.push(
+            { "Name": "协同建构", "Url": "futureClass", "style": { "cssText": "background-image:url(/img/icon/futureClass.png)" } },
+        )   
+    }
+
     if (_oid == '1c3b9def-8fbe-11ed-b13d-005056b86db5') {
         _studentDesktopIconInfo3 = _studentDesktopIconInfo3.filter((el) => {
             if (el.Name == '项目管理') {
@@ -2443,8 +2469,25 @@ window.addEventListener('message', function(e) { // 监听 message 事件
         U.MD.D.I.openApplication("molStr")
     } else if (e.data.tools && e.data.tools == "68") {
         U.MD.D.I.openApplication("timeAxis")
+    } else if (e.data.tools && e.data.tools == "openCourse") {
+        let _data = {
+            typea:e.data.typea || '',
+            typeb:e.data.typeb || '',
+            typed:e.data.typed || '',
+        }
+        U.MD.D.I.openInApplication("index", _data)
+    } else if (e.data.tools && e.data.tools == "openDataClass") {
+        let _data = {
+            classid:e.data.classid || '',
+        }
+        U.MD.D.I.openInApplication("dataClass", _data)
+    } else if (e.data.tools && e.data.tools == "opencCscl") {
+        let _data = {
+            cid:e.data.cid || '',
+            gid:e.data.gid || '',
+        }
+        U.MD.D.I.openInApplication("opencCscl", _data)
     }
-
 });
 
 U.MD.D.I.selectUser = function() {
@@ -2593,8 +2636,61 @@ U.MD.D.I.openInApplication = function(str, data, screenType, tType) {
                 _taskbar = { "id": str + _formdiv.id, "style": { "backgroundImage": "url(/img/icon/hanClass.png)" }, "name": "汉字宫", "forms": _formdiv, "click": function() { U.MD.D.I.openApplication(str, obj, info); } }
                 break;
             }
+        case "index":
+                if (!_userinfo || Object.keys(_userinfo).length === 0) {
+                    setTimeout(() => {
+                        U.MD.U.L.login();
+                    }, 2000);
+                } else {
+                    _formdiv = new U.UF.UI.form(
+                        "课程中心",
+                        $$("iframe", { "allow": "camera *; microphone *;display-capture;midi;encrypted-media;", "webkitallowfullscreen": "", "mozallowfullscreen": "", "allowfullscreen": "", "frameborder": "no", "border": "0", "scrolling ": "no", "style": { "cssText": "border:0;width:100%;height:100%" }, "src": US.Config.bpbl + "/pbl-student-table/dist/#/index?userid=" + _userid + "&oid=" + _oid + "&org=" + _org + "&tType=" + _type + "&cid=" + _classId + "&screenType=2" + "&typea="+  data.typea+ "&typeb=" + data.typeb + "&typed=" + data.typed }), {
+                            "id": "study",
+                            "style": { "width": "100%", "height": "100%", "overflow": 'hidden' },
+                            "onresize": function() {}
+                        }, {
+                            closecallback: function() {}
+                        }, { "style": { "height": "36px" } }).form; //创建窗体
+                    _taskbar = { "id": str + _formdiv.id, "style": { "backgroundImage": "url(/img/icon/studentCourse.png)" }, "name": "课程中心", "forms": _formdiv, "click": function() { U.MD.D.I.openApplication(str, obj, info); } }
+                    break;
+                }
+        case "dataClass":
+                    if (!_userinfo || Object.keys(_userinfo).length === 0) {
+                        setTimeout(() => {
+                            U.MD.U.L.login();
+                        }, 2000);
+                    } else {
+                        _formdiv = new U.UF.UI.form(
+                            "数据报告",
+                            $$("iframe", { "allow": "camera *; microphone *;display-capture;midi;encrypted-media;", "webkitallowfullscreen": "", "mozallowfullscreen": "", "allowfullscreen": "", "frameborder": "no", "border": "0", "scrolling ": "no", "style": { "cssText": "border:0;width:100%;height:100%" }, "src": US.Config.bpbl + "/pbl-teacher-table/dist/#/worksReport?userid=" + _userid + "&oid=" + _oid + "&org=" + _org + "&cid=" + _classId + "&checkid="+  data.classid }), {
+                                "id": "dataClass",
+                                "style": { "width": "90%", "height": "90%", "overflow": 'hidden' },
+                                "onresize": function() {}
+                            }, {
+                                closecallback: function() {}
+                            }, { "style": { "height": "36px" } }).form; //创建窗体
+                        _taskbar = { "id": str + _formdiv.id, "style": { "backgroundImage": "url(/img/icon/evaluation.png)" }, "name": "数据报告", "forms": _formdiv, "click": function() { U.MD.D.I.openApplication(str, obj, info); } }
+                        break;
+                    }
+        case "opencCscl":
+                        if (!_userinfo || Object.keys(_userinfo).length === 0) {
+                            setTimeout(() => {
+                                U.MD.U.L.login();
+                            }, 2000);
+                        } else {
+                            _formdiv = new U.UF.UI.form(
+                                "协同建构",
+                                $$("iframe", { "allow": "camera *; microphone *;display-capture;midi;encrypted-media;", "webkitallowfullscreen": "", "mozallowfullscreen": "", "allowfullscreen": "", "frameborder": "no", "border": "0", "scrolling ": "no", "style": { "cssText": "border:0;width:100%;height:100%" }, "src": "https://cscl.cocorobo.cn?cid="+  data.cid + "&gid=" + data.gid }), {
+                                    "id": "futureClass",
+                                    "style": { "width": "90%", "height": "90%", "overflow": 'hidden' },
+                                    "onresize": function() {}
+                                }, {
+                                    closecallback: function() {}
+                                }, { "style": { "height": "36px" } }).form; //创建窗体
+                            _taskbar = { "id": str + _formdiv.id, "style": { "backgroundImage": "url(/img/icon/futureClass.png)" }, "name": "协同建构", "forms": _formdiv, "click": function() { U.MD.D.I.openApplication(str, obj, info); } }
+                            break;
+                        }
     }
-
 }
 U.MD.D.I.openApplication = function(str, obj, info) {
     obj = obj || {};
@@ -3037,7 +3133,7 @@ U.MD.D.I.openApplication = function(str, obj, info) {
 
                 _formdiv = new U.UF.UI.form(
                     "学生管理",
-                    $$("iframe", { "frameborder": "no", "border": "0", "scrolling ": "no", "style": { "cssText": "border:0;width:100%;height:100%" }, "src": US.Config.bpbl + "/pbl-teacher-table/dist/#/student?userid=" + _userid + "&oid=" + _oid + "&cid=" + _classId + "&org=" + _org }), {
+                    $$("iframe", { "frameborder": "no", "border": "0", "scrolling ": "no", "style": { "cssText": "border:0;width:100%;height:100%" }, "src": US.Config.bpbl + "/pbl-teacher-table/dist/#/student?userid=" + _userid + "&oid=" + _oid + "&cid=" + _classId + "&org=" + _org + "&role=" + _role }), {
                         "id": "student",
                         "style": { "width": "90%", "height": "90%", "overflow": 'hidden' },
                         "onresize": function() {}
@@ -3066,7 +3162,7 @@ U.MD.D.I.openApplication = function(str, obj, info) {
                     "目标管理",
                     $$("iframe", { "frameborder": "no", "border": "0", "scrolling ": "no", "style": { "cssText": "border:0;width:100%;height:100%" }, "src": US.Config.bpbl + "/pbl-teacher-table/dist/#/evaluation?userid=" + _userid + "&oid=" + _oid + "&org=" + _org }), {
                         "id": "sys",
-                        "style": { "width": "90%", "height": "90%", "overflow": 'hidden' },
+                        "style": { "width": "100%", "height": "100%", "overflow": 'hidden' },
                         "onresize": function() {}
                     }, {
                         closecallback: function() {}
@@ -3491,7 +3587,7 @@ U.MD.D.I.openApplication = function(str, obj, info) {
                     "目标管理",
                     $$("iframe", { "frameborder": "no", "border": "0", "scrolling ": "no", "style": { "cssText": "border:0;width:100%;height:100%" }, "src": US.Config.bpbl + "/pbl-teacher-table/dist/#/evaluation?userid=" + _userid + "&oid=" + _oid + "&org=" + _org }), {
                         "id": "sys",
-                        "style": { "width": "90%", "height": "90%", "overflow": 'hidden' },
+                        "style": { "width": "100%", "height": "100%", "overflow": 'hidden' },
                         "onresize": function() {}
                     }, {
                         closecallback: function() {}
@@ -4188,15 +4284,15 @@ U.MD.D.I.openApplication = function(str, obj, info) {
             break;
         case "futureClass": //AI共创
             _formdiv = new U.UF.UI.form(
-                "知识建构",
-                $$("iframe", { "frameborder": "no", "border": "0", "scrolling ": "no", "webkitallowfullscreen": "", "mozallowfullscreen": "", "allowfullscreen": "", "style": { "cssText": "border:0;width:100%;height:100%" }, "src": "https://cscl.cocorobo.cn" }), {
-                    "id": "futureClass",
+                "协同建构",
+                $$("iframe", { "frameborder": "no", "border": "0", "scrolling ": "no", "webkitallowfullscreen": "", "mozallowfullscreen": "", "allowfullscreen": "", "style": { "cssText": "border:0;width:100%;height:100%" }, "src": US.Config.bpbl + "/pbl-teacher-table/dist/#/synergyCourse?userid=" + _userid + "&oid=" + _oid + "&org=" + _org + "&role=" + _role }), {//https://cscl.cocorobo.cn
+                    "id": "synergyCourse",
                     "style": { "width": "100%", "height": "100%", "overflow": 'hidden' },
                     "onresize": function() {}
                 }, {
                     closecallback: function() {}
                 }, { "style": { "height": "36px" } }).form; //创建窗体
-            _taskbar = { "id": str + _formdiv.id, "style": { "backgroundImage": "url(/img/icon/futureClass.png)" }, "name": "知识建构", "forms": _formdiv, "click": function() { U.MD.D.I.openApplication(str, obj, info); } }
+            _taskbar = { "id": str + _formdiv.id, "style": { "backgroundImage": "url(/img/icon/futureClass.png)" }, "name": "协同建构", "forms": _formdiv, "click": function() { U.MD.D.I.openApplication(str, obj, info); } }
 
             break;
         case "dataBoard": //数据看板

+ 2 - 2
js/Desktop/Onload.js

@@ -451,7 +451,7 @@ U.MD.D.getuser = function () {
                                 $(".userName")[0].style.display = "block";
                                 $(".userName")[0].innerHTML = US.userInfo.username || US.userInfo.alias;
                                 $(".exit")[0].style.display = "block";
-                                if(res.value[0][0].org == 'c95e0a56-c205-11ed-8d51-005056b86db5'){
+                                if(res.value[0][0].type === 1 && res.value[0][0].org == 'c95e0a56-c205-11ed-8d51-005056b86db5'){
                                     U.MD.D.I.ModeCheck(2)
                                 }else{
                                     U.MD.D.I.initDesktopIcons($("#U_MD_D_K")[0], 1);
@@ -675,7 +675,7 @@ U.MD.D.getuser2 = function (userid, cid) {
         $(".userName")[0].style.display = "block";
         $(".userName")[0].innerHTML = US.userInfo.username || US.userInfo.alias;
         $(".exit")[0].style.display = "block";
-        if(res.value[0][0].org == 'c95e0a56-c205-11ed-8d51-005056b86db5'){
+        if(res.value[0][0].type === 1 && res.value[0][0].org == 'c95e0a56-c205-11ed-8d51-005056b86db5'){
             U.MD.D.I.ModeCheck(2)
         }else{
             U.MD.D.I.initDesktopIcons($("#U_MD_D_K")[0], 1);

+ 66 - 50
js/Office/Poll.js

@@ -1,6 +1,8 @@
 //轮训处理
 Namespace.register("U.MD.O.P");
 
+//设置是否允许连接
+U.MD.O.P.isconnect = true;
 /*
 * 链接后台,并发送请求
 */
@@ -12,69 +14,83 @@ U.MD.O.P.connect = function () {
             userName: US.userInfo.username,
             type: US.systemId
         })]);
-
-        // U.A.Request(US.SCOKET, ["login", JSON.stringify({     //发送登录请求
-        //     pageId: US.pageId,
-        //     userId: US.userInfo.userid,
-        //     userName: US.userInfo.username,
-        //     type: US.systemId
-        // })], U.MD.O.P.pollingAsyn);       //回调进   U.MD.O.P.pollingAsyn 函数
     }
 };
 
+
+/*
+* 数据处理
+*/
+U.MD.O.P.dataAsyn = function () {
+
+
+}
+
 /*
 * 发送请求进入轮训
 */
 U.MD.O.P.polling = function (params) {
-    params = params || ["polling", US.userInfo.userid, US.pageId, US.systemId]
-    var start = 0;
-    var time = null;
-    var xhr = new XMLHttpRequest();
-    var data = "";
-    xhr.open("POST", US.SCOKET, true);
-    xhr.onreadystatechange = function () {
-        //获取数据
-        if (xhr.readyState == 3 && xhr.status == 200) {
-            clearTimeout(time);
-            var len = xhr.responseText.length;
-            data += xhr.responseText.substring(start, len);
-            start = len;
-            time = setTimeout(function () {
-                clearTimeout(time);
-                try {
-                    U.MD.O.P.pollingAsyn({ value: JSON.parse(data) })
+    if (U.MD.O.P.isconnect) {
+        U.MD.O.P.isconnect = false;
+        params = params || ["polling", US.userInfo.userid, US.pageId, US.systemId]
+        var start = 0;
+        var delimiter = "\r\n"
+        var end = 0;
+        var text = "";
+        var xhr = new XMLHttpRequest();
+        var data = "";
+        //var time = null;
+        //
+        var fun = function () {
+            //clearTimeout(time)
+            text = xhr.responseText;
+            var istrue = true;
+            while (start < text.length && istrue) {
+                end = text.indexOf(delimiter, start);//获取数据的是否已经结束
+                if (end > -1) {
+                    data += text.substring(start, end);
+                    start = end + delimiter.length;
+                    try {
+                        U.MD.O.P.pollingAsyn({ value: JSON.parse(data) })
+                    }
+                    catch (e) {
+                        console.log(e);
+                    }
+                    data = "";
+                }
+                else {
+                    istrue = false;
+                    //time = setTimeout(fun, 500);//
                 }
-                catch (e) { }
-                data = "";
-            }, 100);
+            }
+        };
+        xhr.open("POST", US.SCOKET, true);
+        xhr.onreadystatechange = function () {
+            //获取数据
+            if (xhr.readyState == 3 && xhr.status == 200) {
+                fun();
+            }
+            //结束重连
+            else if (xhr.readyState == 4) {
+                console.log(xhr);
+                U.MD.O.P.isconnect = true;
+                U.MD.O.P.connect();
+            }
+        };
+        //超时重新连接
+        xhr.onerror = function (err) {
+            console.log(err);
+        };
+        try {
+            //发送请求
+            xhr.send(U.A.Request.toAjaxFormat(params));
         }
-        //结束重连
-        else if (xhr.readyState == 4) {
-            console.log(xhr);
-            U.MD.O.P.polling();
+        catch (e) {
+            console.log(e);
         }
-    };
-    //超时重新连接
-    xhr.onerror = function (err) {
-        console.log(err);
-        //U.MD.O.P.polling();
-    };
-    try {
-        //发送请求
-        xhr.send(U.A.Request.toAjaxFormat(params));
     }
-    catch (e) {
-        console.log(e);
-        //U.MD.O.P.polling();
-    }
-
-    // U.A.Request(US.SCOKET, ["polling", US.userInfo.userid, US.pageId, US.systemId], U.MD.O.P.pollingAsyn);
-    //     //发送轮循  回调进  U.MD.O.P.pollingAsyn函数
-    // }
 }
 
-
-
 /* 
 * 处理从后台返回的数据
 *

+ 307 - 166
node/message.js

@@ -5,6 +5,11 @@ us.qs = require("querystring"); //引用文件解析包
 us.http = require("http"); //引用http server服务
 us.mysql = require("./mysql.js"); //引用执行存储过程包
 
+/**
+* 保持知识建构的时间变量
+**/
+us.savecscltime = null;
+
 /**
 * 用户的链接池集合,以用户id作为搜索键
 **/
@@ -84,6 +89,21 @@ us.nav = {
     //}  //导航文档数据结构
 }
 
+//知识建构的数据结构
+us.cscldata = function () {
+    return {
+        id: "",
+        userid: "",
+        name: "",
+        num: "",
+        data: "",
+        isClose: "",
+        create_at: "",
+        createuser: "",
+        smailheadportrait: ""
+    };
+}
+
 /**
 * 用户链接类
 *
@@ -235,6 +255,9 @@ us.server = us.http.createServer(function (requset, response) {
                 case 'quitOffice':
                     us.quitOffice(response, _param[0]);
                     break;
+                case 'quitcscl':
+                    us.quitcscl(response, _param[0]);
+                    break;
                 case 'newWordSave':
                     us.newWordSave(response, _param[0], _param[1], _param[2], _param[3], _param[4]);
                     break;
@@ -393,6 +416,7 @@ us.addUser = function (response, type, fileid, userids, userid, pageid) {
 **/
 us.getuserbytype = function (userids) {
     var _userinfo = [];
+    //console.log(us.user);
     for (var i in userids) {
         if (us.user[i]) {
             _userinfo.push(us.user[i])
@@ -474,10 +498,10 @@ us.unifyDispose = function (req, res, cb) {
     });
 
     //设置30秒后超时
-    res.setTimeout(30000, function () {
+    res.setTimeout(60000, function () {
         try {
             //console.log("响应超时.");
-            //res.end("false"); //返回值
+            res.end(""); //返回值
         }
         catch (e) {
             console.error('process error is:', e.message);
@@ -488,7 +512,6 @@ us.unifyDispose = function (req, res, cb) {
     req.on("error", function (e) {
         try {
             console.log(e);
-            //res.end("false");
         }
         catch (e) {
             console.error('process error is:', e.message);
@@ -520,79 +543,92 @@ us.login = function (requset, response, userid, pageid, username, type) {
 }
 
 /**
-* 用户下线
-* @param {object} response 响应对象
-* @param {string} userid   用户ID
-* @param {string} pageid   页面ID(唯一识别ID)
+* 用户下线,清理用户的数据
 */
-us.offLine = function (response, userid, pageid) {
-    var i, j, z; //定义循环变量
-    var _userid, _fileid, _message, _docinfo, _messageinfo,
-        _csclids = us.offLineMessage[pageid].cscl,
-        _wordids = us.offLineMessage[pageid].word, //得到加入的所有word
-        _excelids = us.offLineMessage[pageid].excel; //得到加入的所有excel
-    console.log(pageid)
-    console.log(us.offLineMessage[pageid])
-    //删除用户连接
-    delete us.connect[userid][pageid];
-
-    //删除用户离校消息记录
-    delete us.offLineMessage[pageid];
-
-    //取消用户
-    if (us.connect[userid]) {
-        for (z in us.connect[userid]) { break }
-        if (!z) {
-            //用户登录数据清理,用于已经下线
-            delete us.user[userid];
-            delete us.connect[userid];
+us.deluser = function (userid, pageid) {
+    if (pageid && us.offLineMessage[pageid]) {
+        var i, j, z; //定义循环变量
+        var _userid, _fileid, _message, _docinfo, _messageinfo,
+            _csclids = us.offLineMessage[pageid].cscl;
+        //其他应用的数据
+        // _wordids = us.offLineMessage[pageid].word, //得到加入的所有word
+        // _excelids = us.offLineMessage[pageid].excel; //得到加入的所有excel
+        console.log("1111111111111")
+        console.log(_csclids)
+        console.log(pageid)
+        console.log(us.offLineMessage[pageid])
+        //删除用户离校消息记录
+        delete us.offLineMessage[pageid];
+        //知识架构的下线的处理
+        for (i = 0; i < _csclids.length; i++) { //循环处理每一个文档
+            _docinfo = us.cscl[_csclids[i]]; //记录文档信息
+            if (_docinfo) { //如果存在文档信息
+                _fileid = _csclids[i];
+                _userid = us.quitUserList(_docinfo, userid, pageid); //将用户在协同列表中删除
+            }
         }
-    }
-    console.log("1111111111111")
-    console.log(_csclids)
-    //知识架构的下线的处理
-    for (i = 0; i < _csclids.length; i++) { //循环处理每一个文档
-        _docinfo = us.cscl[_csclids[i]]; //记录文档信息
-        if (_docinfo) { //如果存在文档信息
-            _fileid = _csclids[i];
-            _userid = us.quitUserList(_docinfo, userid, pageid); //将用户在协同列表中删除
+        console.log(_userid)
+        //下线后通知所有的用户
+        if (_userid) {
+            _message = {};
+            var _messageinfo = us.message(userid, 'us.cscl', {
+                id: us.createGuid(),
+                type: "delUser",
+                userinfo: us.user[_userid],
+                docId: _fileid
+            });
+            _message[_fileid] = [_messageinfo];
+            console.log(_message)
+            us.broadcast(_message, pageid, "cscl");
         }
     }
-    console.log(_userid)
-    //下线后通知所有的用户
-    if (_userid) {
-        _message = {};
-        var _messageinfo = us.message(userid, 'us.cscl', {
-            id: us.createGuid(),
-            type: "delUser",
-            userid: _userid,
-            docId: _fileid
-        });
-        _message[_fileid] = [_messageinfo];
-        console.log(_message)
-        us.broadcast(_message, pageid, "cscl");
-    }
+    //其他应用的处理
+    // //word的下线的处理
+    // for (i = 0; i < _wordids.length; i++) { //循环处理每一个文档
+    //     _docinfo = us.word[_wordids[i]]; //记录文档信息
+    //     if (_docinfo) { //如果存在文档信息
+    //         us.quitUserList(_docinfo, userid, pageid); //将用户在协同列表中删除
+    //         us.insertHistory(_docinfo, 'word'); //插入历史
+    //     }
+    // }
+    // //excel的下线的处理
+    // for (j = 0; i < _excelids.length; j++) {
+    //     _docinfo = us.excel[_excelids[j]]; //记录文档信息
+    //     if (_docinfo) { //如果存在文档信息
+    //         us.quitUserList(_docinfo, userid, pageid); //将用户在协同列表中删除
+    //         us.insertHistory(_docinfo, 'excel'); //插入历史
+    //     }
+    // }
+}
 
-    //word的下线的处理
-    for (i = 0; i < _wordids.length; i++) { //循环处理每一个文档
-        _docinfo = us.word[_wordids[i]]; //记录文档信息
-        if (_docinfo) { //如果存在文档信息
-            us.quitUserList(_docinfo, userid, pageid); //将用户在协同列表中删除
-            us.insertHistory(_docinfo, 'word'); //插入历史
+/**
+* 用户下线,用计时器实时的监控用户是否在线
+*/
+us.offLine = function () {
+    var i, j, istrue = true;
+    var _user, _connect = us.connect;
+    //循环目前所有的连接用户
+    for (i in _connect) {
+        _user = _connect[i];
+        for (j in _user) {
+            //判断用户已下线
+            if (_user[j].response.connection == null || _user[j].response.connection.destroyed) {
+                console.log("================2===============");
+                console.log(i);
+                console.log(j);
+                us.deluser(i, j); //删除用户的数据
+                delete _user[j]
+            }
         }
-    }
-
-    //excel的下线的处理
-    for (j = 0; i < _excelids.length; j++) {
-        _docinfo = us.excel[_excelids[j]]; //记录文档信息
-        if (_docinfo) { //如果存在文档信息
-            us.quitUserList(_docinfo, userid, pageid); //将用户在协同列表中删除
-            us.insertHistory(_docinfo, 'excel'); //插入历史
+        for (j in _user) { istrue = false; break }
+        //这个用户下所有的连接用户都不在了
+        if (istrue) {
+            //用户登录数据清理,用于已经下线
+            delete us.user[i];
+            delete us.connect[i];
         }
+        istrue = true;
     }
-
-
-
 }
 
 /**
@@ -604,36 +640,51 @@ us.offLine = function (response, userid, pageid) {
 **/
 us.polling = function (requset, response, userid, pageid, type) {
     // 监听请求的close事件
-    requset.on('close', () => {
-        console.log("--------" + userid + "-------------" + pageid);
-        //us.offLine(response, userid, pageid)
-    });
+    // requset.on('close', () => {
+    //     console.log("--------" + userid + "-------------" + pageid);
+    //     //us.offLine(response, userid, pageid)
+    // });
     //判断轮询的用户是否在连接池中
     if (us.connect[userid]) {
-        var _userarray = us.connect[userid], //用户连接池,获取制定用户连接的数量,
-            _messagearray = us.offLineMessage[pageid] //用户离校消息
+        var _data,
+            _userarray = us.connect[userid], //用户连接池,获取制定用户连接的数量,
+            _messagearray = us.offLineMessage[pageid] //用户离线信息
             ;
+        const chunkSize = 100;
         //获取当前连接的用户,如果获取成功那么直接修改用户的连接
         if (_userarray[pageid]) {
+            //防止重复多连
+            try {
+                _userarray[pageid].response.end("");
+            }
+            catch (e) {
+
+            }
             _userarray[pageid].response = response;
             if (_messagearray && _messagearray.message.length > 0) {
-                response.write(JSON.stringify(_messagearray.message));
+                _data = JSON.stringify(_messagearray.message);
+                for (let i = 0; i < _data.length; i += chunkSize) {
+                    const chunk = _data.slice(i, i + chunkSize);
+                    response.write(chunk);
+                }
+                response.write("\r\n");
                 _messagearray.message = [];
             }
             else {
-                us.offLineMessage[pageid] = us.userOffLineMessage(type); //初始化用户离线消息记录
+                us.offLineMessage[pageid] = us.offLineMessage[pageid] || us.userOffLineMessage(type); //初始化用户离线消息记录
             }
-            return;
         }
-        //如果用户连接不存在
-        _userarray[pageid] = us.userConnect(pageid, response); //那么直接添加用户连接 添加到用户连接数组里
-        us.offLineMessage[pageid] = us.userOffLineMessage(type); //初始化用户离线消息记录
+        else {
+            //如果用户连接不存在
+            _userarray[pageid] = us.userConnect(pageid, response); //那么直接添加用户连接 添加到用户连接数组里
+            us.offLineMessage[pageid] = us.userOffLineMessage(type); //初始化用户离线消息记录
+        }
     }
     else {
         var _userconect = us.userConnect(pageid, response); //创建用户连接对象
         us.connect[userid] = {}; //添加用户连接对象
         us.connect[userid][pageid] = _userconect;
-        us.offLineMessage[pageid] = us.userOffLineMessage(type); //初始化用户离线消息记录
+        us.offLineMessage[pageid] = us.offLineMessage[pageid] || us.userOffLineMessage(type); //初始化用户离线消息记录
     }
 }
 
@@ -675,9 +726,23 @@ us.send = function (response, messageinfo) {
                 break;
             //未来课堂交互
             case "us.cscl":
+
                 _messagearr = _messageobj[i]; //获取未来消息
-                //得到word所有的用户
+                //得到未来课堂所有的用户
                 for (j = 0; j < _messagearr.length; j++) {
+                    // //如果存在则直接返回内层的文档
+                    // if (!us.cscl[calssid].user[userid]) {
+                    //     us.cscl[calssid].user[userid] = [pageid];
+                    // }
+                    // else if (us.cscl[calssid].user[userid].indexOf(pageid) == -1) {
+                    //     us.cscl[calssid].user[userid].push(pageid);
+                    // }
+                    // try {
+                    //     us.offLineMessage[pageid].cscl.indexOf(calssid) == -1 && us.offLineMessage[pageid].cscl.push(calssid); //添加到用户离线消息的连接wrod记录中
+                    // }
+                    // catch (e) {
+
+                    // }
                     _messagearr[j].messageInfo.type = _messagearr[j].type;
                     //生成发送的消息结构体
                     _message = us.message(_messagearr[j].sendId, "us.cscl", _messagearr[j].messageInfo);
@@ -812,68 +877,71 @@ us.updatemindNetwork = function (messageInfo) {
 * @param {object} message 消息信息
 */
 us.updatecscl = function (messageInfo, classId, ty) {
-    //messageInfo = messageInfo;
     if (us.cscl[classId]) {
         var i, j, _is;
         var _obj = us.cscl[classId].content;
-        _obj.backgroundUrl = messageInfo.backgroundUrl;
-        _obj.edges = _obj.edges || [];
-        _obj.nodes = _obj.nodes || [];
-        // console.log("------------s------------");
-        // console.log(messageInfo);
-        // console.log(_obj);
-        // console.log(ty);
-        for (j = 0; j < messageInfo.edges.length; j++) {
-            _is = true;
-            for (i = 0; i < _obj.edges.length; i++) {
-                if (_obj.edges[i].id == messageInfo.edges[j].id) {
-                    if (ty == "update") {
-                        _obj.edges[i] = messageInfo.edges[j];
-                    }
-                    else {
-                        _obj.edges.splice(i, 1);
+        if (ty == "clean") {
+            _obj = us.cscl[classId].content = {};
+        }
+        else {
+            _obj.backgroundUrl = messageInfo.backgroundUrl;
+            _obj.edges = _obj.edges || [];
+            _obj.nodes = _obj.nodes || [];
+            //循环线的处理
+            for (j = 0; j < messageInfo.edges.length; j++) {
+                _is = true;
+                for (i = 0; i < _obj.edges.length; i++) {
+                    if (_obj.edges[i].id == messageInfo.edges[j].id) {
+                        //如果是修改线同时先又存在那就直接修改
+                        if (ty == "update") {
+                            _obj.edges[i] = messageInfo.edges[j];
+                        }
+                        //如果是删除线的操作
+                        else {
+                            _obj.edges.splice(i, 1);
+                        }
+                        _is = false;
+                        break;
                     }
-                    _is = false;
-                    break;
+                }
+                //修改包含了添加和修改,如果没有修改说明是添加的功能
+                if (_is && ty == "update") {
+                    _obj.edges.push(messageInfo.edges[j])
                 }
             }
-            if (_is && ty == "update") {
-                _obj.edges.push(messageInfo.edges[j])
-            }
-        }
-        for (j = 0; j < messageInfo.nodes.length; j++) {
-            _is = true;
-            for (i = 0; i < _obj.nodes.length; i++) {
-                if (_obj.nodes[i].id == messageInfo.nodes[j].id) {
-                    if (ty == "update") {
-                        _obj.nodes[i] = messageInfo.nodes[j];
-                    }
-                    else {
-                        _obj.nodes.splice(i, 1);
+            for (j = 0; j < messageInfo.nodes.length; j++) {
+                _is = true;
+                for (i = 0; i < _obj.nodes.length; i++) {
+                    if (_obj.nodes[i].id == messageInfo.nodes[j].id) {
+                        //如果是修改节点
+                        if (ty == "update") {
+                            _obj.nodes[i] = messageInfo.nodes[j];
+                        }
+                        //如果是删除节点
+                        else {
+                            _obj.nodes.splice(i, 1);
+                        }
+                        _is = false;
+                        break;
                     }
-                    _is = false;
-                    break;
                 }
-            }
-            if (_is && ty == "update") {
-                _obj.nodes.push(messageInfo.nodes[j])
+                //修改包含了添加和修改,如果没有修改说明是添加的功能
+                if (_is && ty == "update") {
+                    _obj.nodes.push(messageInfo.nodes[j])
+                }
             }
         }
-        console.log(_obj);
         //如果不存在则去数据库查找
-        us.mysql.usselect(['172.16.12.5', 'pbl', 'updateRoomData', JSON.stringify(_obj), classId],
-            function (ret) {
-            });
-
-
-        //"nodes":[{"id":"9f6d7459-d376-4c0c-944b-a6b140085903","type":"icon-start","x":625,"y":145,"properties":{},"zIndex":1002,"text":{"x":625,"y":145,"value":"起始"}},{"id":"16e18308-7517-4162-8b32-a877b7cf42a0","type":"icon-card","x":325,"y":445,"properties":{},"zIndex":1002},{"id":"5c492b0d-092d-4d84-bd70-4d5734de9266","type":"icon-select","x":970,"y":510,"properties":{},"zIndex":1002}],
-        //"edges":[],
-        //"backgroundUrl":"img/bg.ccee1c62.png"
-
+        try {
+            clearTimeout(us.savecscltime);
+        }
+        catch (e) {
 
-        // if (_obj) {
-        //     _obj[messageInfo.id] = messageInfo.content;
-        // }
+        }
+        //每次修改每隔五秒保存一次数据,防止数据操作频繁导致数据库太卡
+        us.savecscltime = setTimeout(function () {
+            us.mysql.usselect(['172.16.12.5', 'pbl', 'updateRoomData', JSON.stringify(_obj), classId], function (ret) { });
+        }, 5000)
     }
 }
 
@@ -1508,14 +1576,16 @@ us.senduser = function (userid, messageinfo) {
 **/
 us.broadcast = function (messageinfo, pageid, type) {
     var i, j, o, //循环变量
+        _data,
         _messageinfo, //消息信息
         _users, //用户ID集合
         _pageids, //用户页面唯一识别集合
         _recievedpageid, //接收用户的页面唯一识别ID
         _issend, // 是否发送
         _userconnect = us.connect; //用户连接池
+    const chunkSize = 100;
     for (i in messageinfo) {
-        _messageinfo = messageinfo[i]; //记录消息消息
+        _messageinfo = messageinfo[i]; //记录消息消息b
         _users = us[type][i] ? us[type][i].user : {}; //记录用户集合
         for (j in _users) { //循环处理每个用户处理 给每个用户集合下的用户发送消息
             _pageids = _users[j]; //记录当前用户在每个端登录的页面唯一识别ID
@@ -1525,10 +1595,19 @@ us.broadcast = function (messageinfo, pageid, type) {
                     try {
                         if (_userconnect[j] && _userconnect[j][_recievedpageid]) {
                             console.log(_recievedpageid);
-                            _issend = _userconnect[j][_recievedpageid].response.write(JSON.stringify(_messageinfo)); //发送消息
-                            if (!_issend) { //如果用户下线了,那么发送消息就会失败
+                            _data = JSON.stringify(_messageinfo);
+                            _issend = _userconnect[j][_recievedpageid].response.write(""); //发送消息
+                            //用户在轮询切换的时候的中间,会产生数据无法接受,这里是存储数据
+                            if (!_issend) {
                                 us.offLineMessage[_recievedpageid].message.push(_messageinfo); //将消息加入用户离线消息中
                             }
+                            else {
+                                for (let i = 0; i < _data.length; i += chunkSize) {
+                                    const chunk = _data.slice(i, i + chunkSize);
+                                    _userconnect[j][_recievedpageid].response.write(chunk);
+                                }
+                                _userconnect[j][_recievedpageid].response.write("\r\n");
+                            }
                         }
                     }
                     catch (e) {
@@ -1581,7 +1660,7 @@ us.addWord = function (response, wordinfo) {
 * @param  {string} wordinfo 文档信息
 **/
 us.quitOffice = function (response, wordinfo) {
-    //获取用户参数  
+    //获取用户参数
     wordinfo = JSON.parse(wordinfo);
     var _docid = wordinfo.docId,
         _userid = wordinfo.userId,
@@ -1605,15 +1684,60 @@ us.quitOffice = function (response, wordinfo) {
     response.end('quitOffice'); //响应退出请求
 }
 
+/**
+* 退出知识建构
+*
+* @param  {object} response 用户相应对象
+* @param  {string} wordinfo 文档信息
+**/
+us.quitcscl = function (response, info) {
+    console.log(info)
+    //获取用户参数
+    info = JSON.parse(info);
+    var _docid = info.docId,
+        _userid = info.userId,
+        _pageid = info.pageId,
+        _type = info.type;
+    var _docinfo = us[_type][_docid]; //获取文档信息
+    //判断是否存在文档信息
+    if (_docinfo) {
+        _userid = us.quitUserList(_docinfo, _userid, _pageid); //将用户在协同列表中删除
+        console.log(_userid)
+        //下线后通知所有的用户
+        if (_userid) {
+            _message = {};
+            var _messageinfo = us.message(_userid, 'us.cscl', {
+                id: us.createGuid(),
+                type: "delUser",
+                userinfo: us.user[_userid],
+                docId: _docid
+            });
+            _message[_docid] = [_messageinfo];
+            console.log(_message)
+            us.broadcast(_message, _pageid, "cscl");
+        }
+
+        // var _j, //创建循环变量
+        //     _message = us.offLineMessage[_pageid] ? us.offLineMessage[_pageid].message : []; //获取该用户的离线消息
+        // for (_j = _message.length - 1; _j > -1; _j--) { //循环移除该文档的离线消息
+        //     if (_message[_j].type == _messagetype && _message[_j].messageInfo.docId == _docid) { //判断是否为word文档
+        //         _message.splice(_j, 1); //删除记录
+        //     }
+        // }
+    }
+    response.end('quitcscl'); //响应退出请求
+}
+
 /**
 * 将用户在协同列表中删除
-* 
+*
 * @param {object} docinfo 文档信息
 * @param {string} userid 用户ID
 * @param {string} pageid 用户页面唯一识别ID
 */
 us.quitUserList = function (docinfo, userid, pageid) {
     var _users = docinfo.user[userid]; //记录文档的用户列表
+    console.log(_users)
     //获取用户在文档用户列表的位置
     if (_users) {
         var _index = _users.indexOf(pageid);
@@ -1673,31 +1797,47 @@ us.insertHistory = function (docinfo, docid, type) {
 * @param {string} pageid 用户页面唯一识别ID
 */
 us.logout = function (response, userid, pageid) {
-    var i, j, _docinfo,
-        _wordids = us.offLineMessage[pageid].word, //得到加入的所有word
-        _excelids = us.offLineMessage[pageid].excel; //得到加入的所有excel
+    console.log("234566666666666666")
+    console.log(userid)
+    var j, istrue = true;
+    var _user = us.connect[userid];
+    //循环目前所有的连接用户
+    us.deluser(userid, pageid); //删除用户的数据
+    delete _user[pageid]
+    for (j in _user) { istrue = false; break }
+    //这个用户下所有的连接用户都不在了
+    if (istrue) {
+        //用户登录数据清理,用于已经下线
+        delete us.user[userid];
+        delete us.connect[userid];
+    }
+    console.log(pageid)
+    response.end('logout'); //响应退出请求
 
-    us.connect[userid][pageid].offLineTime = new Date();
+    // var i, j, _docinfo,
+    //     _wordids = us.offLineMessage[pageid].word, //得到加入的所有word
+    //     _excelids = us.offLineMessage[pageid].excel; //得到加入的所有excel
 
-    for (i = 0; i < _wordids.length; i++) { //循环处理每一个文档
-        _docinfo = us.word[_wordids[i]]; //记录文档信息
-        if (_docinfo) { //如果存在文档信息
-            us.quitUserList(_docinfo, userid, pageid); //将用户在协同列表中删除
-            delete us.offLineMessage[pageid]; //删除用户离线消息记录
-            us.insertHistory(_docinfo, 'word'); //插入历史
-        }
-    }
+    // us.connect[userid][pageid].offLineTime = new Date();
 
-    for (j = 0; i < _excelids.length; j++) {
-        _docinfo = us.excel[_excelids[j]]; //记录文档信息
-        if (_docinfo) { //如果存在文档信息
-            us.quitUserList(_docinfo, userid, pageid); //将用户在协同列表中删除
-            delete us.offLineMessage[pageid]; //删除用户离线消息记录
-            us.insertHistory(_docinfo, 'excel'); //插入历史
-        }
-    }
+    // for (i = 0; i < _wordids.length; i++) { //循环处理每一个文档
+    //     _docinfo = us.word[_wordids[i]]; //记录文档信息
+    //     if (_docinfo) { //如果存在文档信息
+    //         us.quitUserList(_docinfo, userid, pageid); //将用户在协同列表中删除
+    //         delete us.offLineMessage[pageid]; //删除用户离线消息记录
+    //         us.insertHistory(_docinfo, 'word'); //插入历史
+    //     }
+    // }
+
+    // for (j = 0; i < _excelids.length; j++) {
+    //     _docinfo = us.excel[_excelids[j]]; //记录文档信息
+    //     if (_docinfo) { //如果存在文档信息
+    //         us.quitUserList(_docinfo, userid, pageid); //将用户在协同列表中删除
+    //         delete us.offLineMessage[pageid]; //删除用户离线消息记录
+    //         us.insertHistory(_docinfo, 'excel'); //插入历史
+    //     }
+    // }
 
-    response.end('logout'); //响应退出请求
 }
 
 
@@ -2085,20 +2225,17 @@ us.getcscl = function (response, calssid, pageid, userid) {
         catch (e) {
 
         }
-        //如果不存在则去数据库查找
+        //后续优化到redis获取
         us.mysql.usselect(['172.16.12.5', 'pbl', 'select_room', calssid],
             function (ret) {
                 var _user = us.getuserbytype(us.cscl[calssid].user); //获取当前项目下所有的用户信息
                 var _data = us.cscl[calssid].content; //保存在内存的知识建构数据
                 if (ret) {
-                    console.log("eeee");
-                    console.log(us.offLineMessage[pageid]);
                     ret[0][0].user = _user; //这里是项目当前所有用户
                     ret[0][0].data = _data; //把思维网格的内容转化成数组
                     if (userid && us.user[userid]) {
                         us.sendUser(us.user[userid], "cscl", pageid, calssid); //加入知识建构项目后通知所有的用户
                     }
-                    console.log(ret[0][0].user)
                     response.end(JSON.stringify(ret)); //返回文档内容
                 }
                 else {
@@ -2120,11 +2257,13 @@ us.getcscl = function (response, calssid, pageid, userid) {
             function (ret) {
                 var _user = us.getuserbytype(us.cscl[calssid].user);
                 if (ret) {
-                    console.log("bbbbbbbbbbbbbbb");
-                    console.log(us.offLineMessage[pageid]);
                     ret[0][0].user = _user; //这里是项目当前所有用户
-                    us.cscl[calssid].content = JSON.parse(ret[0][0].data); //把思维网格的内容转化成数组
-                    //us.sendUser(us.user[userid], "cscl", pageid, calssid); //加入知识建构项目后通知所有的用户
+                    try {
+                        us.cscl[calssid].content = JSON.parse(ret[0][0].data); //把思维网格的内容转化成数组
+                    }
+                    catch (e) {
+                        us.cscl[calssid].content = ret[0][0].data;
+                    }
                     response.end(JSON.stringify(ret)); //返回文档内容
                 }
                 else {
@@ -2434,6 +2573,8 @@ us.createGuid = function () {
 *
 **/
 us.server.listen('1473', '', function () {
+    //用户下线监控
+    setInterval(function () { us.offLine() }, 10000);
     //在控制台输出监听提示
     console.log("开始监听" + us.server.address().port + "......");
 });

+ 4 - 18
node/mysql.js

@@ -30,19 +30,13 @@ exports.usselect = function (param, callback) {
         console.log(param);
         _mysqlconnection.getConnection(function (error, connection) { //获取连接
             if (error) { //连接错误
-                console.log("连接失败:", error);
+                console.error("连接失败:", error);
             } else { //连接成功
-                for (i = 0; i < param.length; i++) {
-                    param[i] = decodeURIComponent(param[i]);
-
-                } //格式化处理参数
-                var i, _sql = "CALL ";
+                var _sql = "CALL ";
                 var _param = new Array();
                 if (param.length > 3) { //带有参数的sql语句  如:'call test(?, ?, ?);'
                     _param = param.slice(3) //截取有效参数
-                    _sql += (param[2] || "") + "(?"; //拼接存储过程名称 
-                    //_s += (p[2] || "") + "('" + p.slice(3).join("','") + "');";
-                    //, + ? 拼接参数 该方法拼接后比数组长度少一因此上一句代码中默认拼接了第一个参数
+                    _sql += (param[2] || "") + "(?"; //拼接存储过程名称
                     _sql += Array(_param.length).join(",?");
                     _sql += ");"; //拼接结果语句
                 } else { //不带参数的sql语句 如:'call test();'
@@ -51,18 +45,10 @@ exports.usselect = function (param, callback) {
                 console.log("拼凑的MySQl语句为:", _sql);
                 connection.query(_sql, _param, function (error, results, fields) { //执行sql语句 
                     if (results) {
-                        // if (results.pop) {
-                        //     results.pop();
-                        // }
-                        //console.log(JSON.stringify(results)); 输出结果集
-                        //执行回调函数
-                        //results.affectedRows != null 如果受影响行不等于null(空) 则返回受影响行数
-                        //results.affectedRows != null 如果受影响行不等于null(空) 则返回受影响行数
-                        //results.length > 1 ? results : results[0] 如果结果集为单行则直接返回Object对象 否则返回数组对象
                         callback(results.affectedRows != null ? results.affectedRows : results.length > 1 ? results : results[0]);
                     }
                     else { //执行错误
-                        console.log("sql执行失败", error || "");
+                        console.error("sql执行失败", error || "");
                         callback(error);
                     }
                 });

+ 35 - 9
node/test.js

@@ -4,8 +4,10 @@ us = {};
 
 // 引入Express模块
 const express = require('express');
+const qs = require('qs');
 const path = require('path');
 us.http = require("http"); //引用http server服务
+const http = require('http');
 // 创建Express应用
 const app = express();
 
@@ -13,23 +15,47 @@ const app = express();
 app.use(express.static(path.join(__dirname, '/')));
 
 
-us.server = us.http.createServer(function (req, res) {
+us.server = us.http.createServer(function (reqo, reso) {
     // 定义路由
     // app.all('/', (req, res) => {
     //设置跨域
-    res.writeHead(200, {
+    reso.writeHead(200, {
         "Content-Type": "application/json",
         'Access-Control-Allow-Origin': '*',
         "Connection": "keep-alive",
         'Access-Control-Allow-Headers': 'Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With'
     });
-    var data = [{ "name": "John", "age": 30 }];
-    for (var i = 0; i < 100; i++) {
-        data.push(data[0]);
-    }
-    setInterval(function () {
-        res.write(JSON.stringify(data));
-    }, 2000);
+
+    //  http://apis.ssti.net.cn:80/taskcenterapp/sys/taskCenter/taskReceive/pushTask.do
+
+    const options = {
+        hostname: 'apis.ssti.net.cn',
+        port: 80,
+        path: '/taskcenterapp/sys/taskCenter/taskReceive/pushTask.do',
+        method: 'POST',
+        headers: {
+            'Content-Type': 'application/x-www-form-urlencoded',
+            'appId': '36dd21cde3b2f30a',
+            'accessToken': '463e95bdad1a9506bd1b271194f89383'
+        }
+    };
+
+    const req = http.request(options, (res) => {
+        console.log(`statusCode: ${res.statusCode}`);
+
+        res.on('data', (data) => {
+            console.log(data.toString());
+        });
+    });
+
+    req.on('error', (error) => {
+        console.error(error);
+    });
+
+    const bodyData = qs.stringify({ appId: "36dd21cde3b2f30a", taskInfo: '{"inserttasks":[{"app_id":"test11","assignments":[{"assign_dept":"图书部门","assign_id":"ampadmin","assign_name":"ampadmin"}],"biz_domain":"测试部门","biz_key":"bizkey_1000112","created_by_depts":"图书部门","created_by_ids":"ampadmin","created_by_names":"ampadmin","created_on":"2018-01-16 15:06:18","form_url":"https://baidu.com","form_url_view":"https://baidu.com","node_id":"1000112","node_name":"人事审核","priority":0,"process_delete_flag":0,"process_id":"leave_1233211932","process_instance_form_view":"https://taobao.com","process_instance_id":"1233211932","process_instance_image_url":"https://baidu.com","process_instance_initiator":"ampadmin","process_instance_initiator_dp":"图书部门","process_instance_initiator_id":"ampadmin","process_instance_start_date":"2018-01-16 15:06:18","process_instance_status":"RUNNING","process_instance_subject":"请假流程:ampadmin","process_name":"请假流程","process_version":"1.0","status":"ACTIVE","subject":"test_发起请假流程-tstsysys","task_delete_flag":0,"task_id":"1000112"}],"updatetasks":[]}' });
+    req.write(bodyData);
+    req.end();
+    reso.end("")
 });
 
 // 启动服务器

+ 6 - 5
uform.js

@@ -11690,7 +11690,7 @@ U.MD.U.L.defaultCallBack = function (r, iscookie) {
                     U.UF.CI.getUserLocation(U.MD.U.L.addUserAccess); //客户端信息加载,好像只加载了新浪ip地址?
                 }
                 _userinfo = U.MD.U.L.setUserInfo(r); //设置用户基本信息,包括用户信息,好友信息
-                U.MD.U.L.getLoginUserInfo(_username || US.userInfo.username); //去获取用户详细信息
+                U.MD.U.L.getLoginUserInfo(_username || US.userInfo.UserName); //去获取用户详细信息
                 if ($("#U_MD_D_BDI")[0] && U.selectEl('#U_MD_D_BG')[0]) {
                     //登录有用户的信息展示到页面中,包括背景图片、用户头像等
                     U.MD.U.L.printUserInfo(); //用户头部头像个人信息
@@ -11897,7 +11897,7 @@ U.MD.U.L.initUserLogin = function () {
 U.MD.U.L.addUserAccess = function () {
     //如果用户的城市信息不存在,则添加用户用户城市信息,应该不只是单单判断地址,此处逻辑还需要整理!
     if (US.city.userAllLocation) {
-        U.A.Request(US.USER, ["RecordUserClientInfo", US.userInfo.username, "", "", US.city.userAllLocation, ""],
+        U.A.Request(US.USER, ["RecordUserClientInfo", US.userInfo.UserName, "", "", US.city.userAllLocation, ""],
             function () { }); //异步添加地址信息
     }
 }
@@ -11960,10 +11960,11 @@ U.MD.U.LO.logoutSystem = function (callback) {
     if (US.userInfo.userid) {
         //弹出退出登录的提示
         U.UF.UI.confirm("是否退出" + US.userInfo.username + "账号", function () {
-            // U.MD.U.LO.logout(callback);
             U.A.Request(US.Config.server + "logout", [], function (res) {
-                U.alert("退出成功!")
-                window.location.reload();
+                U.A.Request(US.SCOKET, ["logout", US.userInfo.userid, US.pageId], function () {
+                    U.alert("退出成功!")
+                    window.location.reload();
+                }, [], { "type": "POST", "withCredentials": true }); //在状态服务退出
             }, [], { "type": "POST", "withCredentials": true });
         });
     }