jason.lu 7 years ago
parent
commit
f0c0c76774
6 changed files with 1237 additions and 713 deletions
  1. 15 33
      js/common.js
  2. 169 168
      js/dapingmu.js
  3. 1 1
      js/entrance.js
  4. 1048 254
      js/lazhang-data.js
  5. 0 253
      js/lazhang-display.js
  6. 4 4
      lazhang.html

+ 15 - 33
js/common.js

@@ -1,20 +1,20 @@
 getUserId();
 
-function load_table_red_rank() {
-    get_data("fcBiWorkerDaily/get?type=1&limit=3", on_red_rank_success);
-}
-
-function load_table_red_rank1() {
-    get_data("fcBiWorkerDaily/get?type=2&limit=3", on_red_rank_success1);
-}
-
-function load_table_black_rank1() {
-    get_data("fcBiWorkerDaily/get?type=3&limit=3", on_black_rank_success1);
-}
-
-function load_table_black_rank() {
-    get_data("fcBiWorkerDaily/get?type=0&limit=3", on_black_rank_success);
-}
+var RedRank = (function() {
+    this.fetchPos = 0;
+    this.loader = (function () {
+        this.load = function(pos) {
+            get_data(`fcBiWorkerDaily/get?type=${RedRank.fetchPos}`, RedRank.loader.onSuccess);
+        };
+        this.consecutiveLoad = function(){
+            RedRank.fetchPos = (RedRank.fetchPos + 1) % 8;
+            load(RedRank.fetchPos);
+        };
+        this.onSuccess = function(res, code){
+
+        };
+    })();
+})();
 
 var RANK_TBL_ROW_COUNT = 4;
 var goodColor = [];
@@ -303,21 +303,3 @@ function showRedRanking() {
     }
     //console.log(htmlbody);
 }
-
-
-function showBlackRanking() {
-    return; // Not Showing Because we now try to scroll pages.
-    //
-    // var htmlbody = "", one_person = "";
-    // var i = 0;
-    // var triGap = RANK_TBL_ROW_COUNT;
-    // htmlbody = "";
-    // for (i = 0; i < triGap; i++) {
-    //     htmlbody = getBlackRanking(htmlbody, i);
-    // }
-    // if (lastTimeRank2 !== htmlbody) {
-    //     $("#rank-three").html(htmlbody);
-    //     lastTimeRank2 = htmlbody;
-    // }
-    //console.log(htmlbody);
-}

+ 169 - 168
js/dapingmu.js

@@ -1,192 +1,193 @@
-var passNumber = [];
-var failNumber = [];
-var failrate = [];
-var stackeverynum = [];
-var failnum = 0;
-var num = 0;
-var hispass = [];
-var hisfail = [];
-var hisstack = [];
-var hisrate = [];
-var n = 0;
-var flowIds = [];
-var namedata = [];
-var lazhang = {};
-
-
-function page_document_load() {
-    get_data("fcWorkScheduleLoad/get", first_success)
-}
-
-function first_success(obj, sta) {
-    let output = first_parse(this, obj);
-    let i, j, k, z;
-    failnum = 0;
-    let x = 0;
-    let worksum = [];
-    z = 0;
-
-    if(typeof output.length =="number"){
-        output.list = output;
+var BigScreen = (function () {
+    this.passNumber = [];
+    this.failNumber = [];
+    this.failrate = [];
+    this.stackeverynum = [];
+    this.failnum = 0;
+    this.num = 0;
+    this.hispass = [];
+    this.hisfail = [];
+    this.hisstack = [];
+    this.hisrate = [];
+    this.n = 0;
+    this.flowIds = [];
+    this.namedata = [];
+    this.lazhang = (function () {
+    })();
+    this.realTimeRequestTimer = 0;
+
+    this.page_document_load = function() {
+        get_data("fcWorkScheduleLoad/get", onFirstTimeSuccess)
     }
 
-    if (output.list == undefined || output.list.length == 0) {
-        send_alert("没有数据");
-    }
+    this.first_success = function(obj, sta) {
+        let output = first_parse(this, obj);
+        let i, j, k, z;
+        failnum = 0;
+        let x = 0;
+        let worksum = [];
+        z = 0;
 
-    if (output.list.length > 0) {
-        flowIds[0] = output.list[0].scheduleId;
+        if (typeof output.length == "number") {
+            output.list = output;
+        }
 
-        for (i = 1; i < output.list.length; i++) {
-            var thisUid = output.list[i].scheduleId;
-            x = 0;
-            for (j = 0; j < flowIds.length; j++) {
-                if (flowIds[j] === thisUid) {
-                    x = 1;
-                    break;
-                }
-            }
-            if (x === 0) {
-                flowIds.push(thisUid);
-            }
+        if (output.list == undefined || output.list.length == 0) {
+            send_alert("没有数据");
         }
 
-        j = 0;
-        for (k = 0; k < flowIds.length; k++) {
-            var uid = flowIds[k];
-            z = 0;
-            passNumber[k] = 0;
-            failNumber[k] = 0;
-            stackeverynum[k] = 0;
-            for (i = 0; i < output.list.length; i++) {
-                if (uid === output.list[i].scheduleId) {
-                    passNumber[k] = output.list[i].passNum + passNumber[j];
-                    failNumber[k] = output.list[i].failNum + failNumber[j];
-                    stackeverynum[k] = output.list[i].due + stackeverynum[j];
-                    z++;
+        if (output.list.length > 0) {
+            flowIds[0] = output.list[0].scheduleId;
+
+            for (i = 1; i < output.list.length; i++) {
+                var thisUid = output.list[i].scheduleId;
+                x = 0;
+                for (j = 0; j < flowIds.length; j++) {
+                    if (flowIds[j] === thisUid) {
+                        x = 1;
+                        break;
+                    }
+                }
+                if (x === 0) {
+                    flowIds.push(thisUid);
                 }
             }
-            if (failNumber[k] + passNumber[k] == 0) {
-                failrate[k] = 0;
-            } else {
-                failrate[k] = Math.floor(failNumber[k] / (failNumber[k] + passNumber[k]) * 10000) / 100;
+
+            j = 0;
+            for (k = 0; k < flowIds.length; k++) {
+                var uid = flowIds[k];
+                z = 0;
+                passNumber[k] = 0;
+                failNumber[k] = 0;
+                stackeverynum[k] = 0;
+                for (i = 0; i < output.list.length; i++) {
+                    if (uid === output.list[i].scheduleId) {
+                        passNumber[k] = output.list[i].passNum + passNumber[j];
+                        failNumber[k] = output.list[i].failNum + failNumber[j];
+                        stackeverynum[k] = output.list[i].due + stackeverynum[j];
+                        z++;
+                    }
+                }
+                if (failNumber[k] + passNumber[k] == 0) {
+                    failrate[k] = 0;
+                } else {
+                    failrate[k] = Math.floor(failNumber[k] / (failNumber[k] + passNumber[k]) * 10000) / 100;
+                }
             }
         }
+        for (i = 1; i <= 3; i++) {
+            loadHistroyOnce(i);
+        }
+        showChart();
+        realTimeRequestTimer = setInterval(mainLoopFunc, 1000);
+
     }
-    for (i = 1; i <= 3; i++) {
-        load_flows_history_data(i);
+
+    this.mainLoopFunc = function() {
+        get_data("fcWorkScheduleLoad/get", realtime_success);
+        //loadHistoryRealTime();
+        load_table_red_rank();
+        load_table_red_rank1();
+        load_table_black_rank();
+        load_table_black_rank1();
     }
-    showChart();
-    lazhang.timer = setInterval(request_data_realtime, 1000);
-
-}
-
-function request_data_realtime() {
-    get_data("fcWorkScheduleLoad/get", realtime_success);
-    //load_flows_history_realtime_data();
-    load_table_red_rank();
-    load_table_red_rank1();
-    load_table_black_rank();
-    load_table_black_rank1();
-}
-
-function load_flows_history_data(nnm) {
-    get_data("fcBiFactoryDaily/list?type=" + nnm, history_success);
-}
-
-function load_flows_history_realtime_data() {
-    get_data("fcBiFactoryDaily/list?type=1" , history_success);
-}
-
-
-function get_stop_scheudle() {
-    location.href='denglu.html';
-}
-
-function realtime_success(obj, sta) {
-    var output = first_parse(this, obj);
-    //在这里排序 spo\
-    console.log(" output : ");
-    console.log(output);
-
-    var i, j, k, z;
-    failnum = 0;
-    var x = 0;
-    var worksum = [];
-    var hhp = 0, hhf = 0, hhs = 0;
-
-
-    if (output.list.length > 0) {
-        flowIds[0] = output.list[0].scheduleId;
-        passNumber[0] = 0;
-        failNumber[0] = 0;
-        stackeverynum[0] = 0;
-        z = 0;
-        for (i = 1; i < output.list.length; i++) {
-            var thisUid = output.list[i].scheduleId;
-            x = 0;
-            for (j = 0; j < flowIds.length; j++) {
-                if (flowIds[j] === thisUid) {
-                    x = 1;
-                    break;
-                }
-            }
-            if (x === 0) {
-                flowIds.push(thisUid);
-            }
 
-        }
-        j = 0;
-        for (k = 0; k < flowIds.length; k++) {
-            var uid = flowIds[k];
+    this.loadHistroyOnce = function(nnm) {
+        get_data("fcBiFactoryDaily/list?type=" + nnm, history_success);
+    }
+
+    this.loadHistoryRealTime = function() {
+        get_data("fcBiFactoryDaily/list?type=1", history_success);
+    }
+
+
+    this.doStopSchedule = function() {
+        location.href = 'denglu.html';
+    }
+
+    this.realtime_success = function(obj, sta) {
+        var output = first_parse(this, obj);
+        //在这里排序 spo\
+        console.log(" output : ");
+        console.log(output);
+
+        var i, j, k, z;
+        failnum = 0;
+        var x = 0;
+        var worksum = [];
+        var hhp = 0, hhf = 0, hhs = 0;
+
+
+        if (output.list.length > 0) {
+            flowIds[0] = output.list[0].scheduleId;
+            passNumber[0] = 0;
+            failNumber[0] = 0;
+            stackeverynum[0] = 0;
             z = 0;
-            passNumber[k] = 0;
-            failNumber[k] = 0;
-            stackeverynum[k] = 0;
-            for (i = 0; i < output.list.length; i++) {
-                if (uid === output.list[i].scheduleId) {
-                    passNumber[k] = output.list[i].passNum + passNumber[k];
-                    failNumber[k] = output.list[i].failNum + failNumber[k];
-                    stackeverynum[k] = output.list[i].due + stackeverynum[k];
-                    z++;
+            for (i = 1; i < output.list.length; i++) {
+                var thisUid = output.list[i].scheduleId;
+                x = 0;
+                for (j = 0; j < flowIds.length; j++) {
+                    if (flowIds[j] === thisUid) {
+                        x = 1;
+                        break;
+                    }
                 }
+                if (x === 0) {
+                    flowIds.push(thisUid);
+                }
+
             }
-            if (failNumber[k] + passNumber[k] == 0) {
-                failrate[k] = 0;
-            } else {
-                failrate[k] = Math.floor(failNumber[k] / (failNumber[k] + passNumber[k]) * 10000) / 100
+            j = 0;
+            for (k = 0; k < flowIds.length; k++) {
+                var uid = flowIds[k];
+                z = 0;
+                passNumber[k] = 0;
+                failNumber[k] = 0;
+                stackeverynum[k] = 0;
+                for (i = 0; i < output.list.length; i++) {
+                    if (uid === output.list[i].scheduleId) {
+                        passNumber[k] = output.list[i].passNum + passNumber[k];
+                        failNumber[k] = output.list[i].failNum + failNumber[k];
+                        stackeverynum[k] = output.list[i].due + stackeverynum[k];
+                        z++;
+                    }
+                }
+                if (failNumber[k] + passNumber[k] == 0) {
+                    failrate[k] = 0;
+                } else {
+                    failrate[k] = Math.floor(failNumber[k] / (failNumber[k] + passNumber[k]) * 10000) / 100
+                }
+                /*stackeverynum[k]=stackeverynum[k]/z;*/
+                ///
+
             }
-            /*stackeverynum[k]=stackeverynum[k]/z;*/
-            ///
+            output.list.forEach(function (val, fid, arr) {
+                hhp += val.passNum;
+                hhf += val.failNum;
+                hhs += val.due;
+            })
+        }
 
+        hispass[0] = hhp;
+        hisfail[0] = hhf;
+        if (output.list.length > 0) {
+            hisstack[0] = hhs / output.list.length;
+        } else {
+            hisstack[0] = 0;
         }
-        output.list.forEach(function (val, fid, arr) {
-            hhp += val.passNum;
-            hhf += val.failNum;
-            hhs += val.due;
-        })
-    }
 
-    hispass[0] = hhp;
-    hisfail[0] = hhf;
-    if (output.list.length > 0) {
-        hisstack[0] = hhs / output.list.length;
-    } else {
-        hisstack[0] = 0;
-    }
+        schedulepass = hhp;
+        schedulefail = hhf;
+        if (output.list.length > 0) {
+            schedulestack = hhs / output.list.length;
+        } else {
+            schedulestack = 0;
+        }
+        update_all_history();
+        updateChart();
 
-    schedulepass = hhp;
-    schedulefail = hhf;
-    if (output.list.length > 0) {
-        schedulestack = hhs / output.list.length;
-    } else {
-        schedulestack = 0;
     }
-    update_all_history();
-    updateChart();
-
-}
-
-
+})();
 
 

+ 1 - 1
js/entrance.js

@@ -18,7 +18,7 @@ function page_document_load() {
 }
 
 function firsttime_load_spots_data() {
-    group_get_data("denglu","fcFlow/list", first_success)
+    group_get_data("denglu","fcFlow/list", onFirstTimeSuccess)
 }
 
 function first_success(obj, sta) {

+ 1048 - 254
js/lazhang-data.js

@@ -1,326 +1,1120 @@
-var passNumber = [];
-var failNumber = [];
-var failrate = [];
-var stackeverynum = [];
-var failnum = 0;
-var num = 0;
-var n = 0;
-var sectorID = [];
-var namedata = [];
-var lazhang = {};
-var scheduleId = utils_get_param("scheduleId");
-var flowId = utils_get_param("flowId");
-var name1,name2;
-
-function first_success(obj, sta) {
-    let output = first_parse(this, obj);
-    let i, j, k, z;
-    failnum = 0;
-    let x = 0;
-    let worksum = [];
-    z = 0;
-
-    if (output.list == undefined || output.list.length == 0) {
-        send_alert("没有数据");
-    }
+getUserId();
 
-    output.list.forEach(function(val,it,arr){
-        var isExist = false;
-        userIDs.forEach(function(vals){
-            if(vals == val.userId){
-                isExist = true;
-            }
-        });
-        if(!isExist) userIDs.push(val.userId);
-    });
+var RedRank = (function() {
+    this.fetchPos = 0;
+    this.loader = (function () {
+        this.load = function(pos) {
+            get_data(`fcBiWorkerDaily/get?type=${RedRank.fetchPos}`, RedRank.loader.onSuccess);
+        };
+        this.consecutiveLoad = function(){
+            RedRank.fetchPos = (RedRank.fetchPos + 1) % 8;
+            load(RedRank.fetchPos);
+        };
+        this.onSuccess = function(res, code){
 
-    if (output.list.length > 0) {
-        sectorID[0] = getSectorId(output.list[0].spotId);
+        };
+    })();
+})();
 
-        for (i = 1; i < output.list.length; i++) {
-            var thisUid = getSectorId(output.list[i].spotId);
-            x = 0;
-            for (j = 0; j < sectorID.length; j++) {
-                if (sectorID[j] === thisUid) {
-                    x = 1;
-                    break;
-                }
-            }
-            if (x === 0) {
-                sectorID.push(thisUid);
-            }
+var RANK_TBL_ROW_COUNT = 4;
+var goodColor = [];
+var badColor = [];
+var goodColor1 = [];
+var badColor1 = [];
+var userIDs = [];
+var schedulepass = 0, schedulefail = 0, schedulestack = 0;
+var todayotherpass = 0, todayotherfail = 0, todayotherstack = 0;
+var lastTimeHistory = "";
+var histoires = [];
 
+var hispass = [];
+var hisfail = [];
+var hisstack = [];
+var hisrate = [];
+var goodpass = [];
+var goodid = [];
+var goodfailrate = [];
+var goodpass1 = [];
+var goodid1 = [];
+var goodfailrate1 = [];
+var badpass = [];
+var badid = [];
+var badfailrate = [];
+var badpass1 = [];
+var badid1 = [];
+var badfailrate1 = [];
+
+function history_success(obj, sta) {
+    var histoire = first_parse(this, obj);
+    var i, j, t;
+    console.log(" histoire : ");
+    console.log(histoire);
+    if (this.url.indexOf("type=1") >= 0) {
+        t = 1;
+    } else if (this.url.indexOf("type=2") >= 0) {
+        t = 2;
+    } else if (this.url.indexOf("type=3") >= 0) {
+        t = 3;
+    } else {
+        t = 0;
+        return;
+    }
+    histoires[t] = histoire;
+    if (t === 2 || t === 3) {
+        hispass[t] = 0;
+        hisfail[t] = 0;
+        hisstack[t] = 0;
+        hisrate[t] = 0;
+        for (i = 0; i < histoire.length - 1; i++) { //除了今日
+            hispass[t] = histoire[i].passNum + hispass[t];
+            hisfail[t] = histoire[i].failNum + hisfail[t];
+            hisstack[t] = histoire[i].avgDue + hisstack[t];
         }
+        orighispass[t] = hispass[t];
+        orighisfail[t] = hisfail[t];
+        orighisstack[t] = hisstack[t];
+        hispass[t] += hispass[0];
+        hisfail[t] += hisfail[0];
+        hisstack[t] += hisstack[0];
+        hisrate[t] = get_factor(hispass[t], hisfail[t]);
+    } else if (t === 1) {
+        hispass[1] = histoire[0].passNum;
+        hisfail[1] = histoire[0].failNum;
+        hisstack[1] = histoire[0].avgDue;
+        hisrate[t] = get_factor(hispass[1], hisfail[1]);
+    }
 
-        j = 0;
-        for (k = 0; k < sectorID.length; k++) {
-            var uid = sectorID[k];
-            z = 0;
-            passNumber[k] = 0;
-            failNumber[k] = 0;
-            stackeverynum[k] = 0;
-            for (i = 0; i < output.list.length; i++) {
-                if (uid === getSectorId(output.list[i].spotId)) {
-                    passNumber[k] = output.list[i].passNum + passNumber[j];
-                    failNumber[k] = output.list[i].failNum + failNumber[j];
-                    stackeverynum[k] = output.list[i].due + stackeverynum[j];
-                    z++;
-                }
-            }
-            if (failNumber[k] + passNumber[k] == 0) {
-                failrate[k] = 0;
-            }
-            else {
-                failrate[k] = failNumber[k] / (failNumber[k] + passNumber[k]) * 100;
+    todayotherpass = histoire[histoire.length - 1].passNum;
+    todayotherfail = histoire[histoire.length - 1].failNum;
+    todayotherstack = histoire[histoire.length - 1].avgDue;
 
-            }
-            /*stackeverynum[k]=stackeverynum[k]/z;*/
+    update_all_history();
+}
 
-            ///
+function update_all_history() {
+    hispass[0] = todayotherpass + schedulepass;
+    hisfail[0] = todayotherfail + schedulefail;
+    hisstack[0] = todayotherstack + schedulestack;
+    hisrate[0] = get_factor(hispass[0], hisfail[0]);
 
-        }
+    if (typeof hisrate[0] == "undefined" || isNaN(hisrate[0])) {
+        send_alert("请重试!");
     }
-    get_data("fcFlow/list?flowId="+ flowId,name_Success);
-
 
-    for (i = 1; i <= 3; i++) {
-        load_flows_history_data(i);
+    for (i = 2; i <= 3; i++) {
+        hispass[i] = orighispass[i] + hispass[0];
+        hisfail[i] = orighisfail[i] + hisfail[0];
+        hisstack[i] = orighisstack[i] + hisstack[0];
+        hisrate[i] = get_factor(hispass[i], hisfail[i]);
     }
-    showChart();
-    lazhang.timer = setInterval(request_data_realtime, 1000);
-
 }
-function name_Success(obj, sta) {
-    var factory = first_parse(this, obj);
-    var i, j, t;
-    console.log(" factory : ");
-    console.log(factory);
 
-    name1=factory.list[0].flowPlace;
-    name2=factory.list[0].flowName;
-    document.getElementById("test1").innerHTML = name1+"-"+name2 + " 度彼科技";
-    document.title =  name1 + " " + name2 + " | 流水线管理 | 度彼科技";
+var todayotherpass, todayotherfail, todayotherstack;
+var orighisfail = [], orighispass = [], orighisstack = [];
 
+function isUserOfThisFlow(uid) {
+    var isExist = false;
+    userIDs.forEach(function (vals) {
+        if (vals == uid) {
+            isExist = true;
+        }
+    });
+    return isExist;
 }
 
-function request_data_realtime() {
-    get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, realtime_success);
-    //load_flows_history_realtime_data();
-    load_table_red_rank();
-    load_table_red_rank1();
-    load_table_black_rank();
-    load_table_black_rank1();
+function on_red_rank_success(obj, sta) {
+    var redchart = first_parse(this, obj);
+    var i, j;
+    i = j = 0;
+    console.log(" redchart : ");
+    console.log(redchart);
+    for (i = 0; i < redchart.list.length; i++) {
+        goodid[i] = getUserName(redchart.list[i].workerId);
+        goodpass[i] = redchart.list[i].passNum;
+        if (redchart.list[i].passNum + redchart.list[i].failNum > 0) {
+            goodfailrate[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
+        } else {
+            goodfailrate[i] = 0;
+        }
+        if (isUserOfThisFlow(redchart.list[i].workerId)) {
+            goodColor[i] = 'red';
+        } else {
+            goodColor[i] = '';
+        }
+    }
 
 }
 
-function load_flows_history_data(nnm) {
-    // 请注意type必须在结尾
-    get_data("fcBiFlowDaily/list?scheduleId="+scheduleId+ "&flowId=" + flowId+"&type=" + nnm , history_success);
-}
+function on_red_rank_success1(obj, sta) {
+    var redchart = first_parse(this, obj);
+    var i, j;
+    i = j = 0;
+    console.log(" redchart : ");
+    console.log(redchart);
+    for (i = 0; i < redchart.list.length; i++) {
+        goodid1[i] = getUserName(redchart.list[i].workerId);
+        goodpass1[i] = redchart.list[i].passNum;
+        if (redchart.list[i].passNum + redchart.list[i].failNum > 0) {
+            goodfailrate1[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
+        } else {
+            goodfailrate1[i] = 0;
+        }
+        if (isUserOfThisFlow(redchart.list[i].workerId)) {
+            goodColor1[i] = 'red';
+        } else {
+            goodColor1[i] = '';
+        }
+    }
 
-function load_flows_history_realtime_data() {
-    // 请注意type必须在结尾
-    get_data("fcBiFlowDaily/list?flowId=" + flowId +"&type=1", history_success);
 }
-function get_stop_scheudle1() {
-    var out = confirm("真的要下班吗?");
-    if(out == true){
-        get_stop_scheudle();
 
+function on_black_rank_success(obj, sta) {
+    var blackchart = first_parse(this, obj);
+    var i, j;
+    i = j = 0;
+    console.log(" black chart : ");
+    console.log(blackchart);
+    for (i = 0; i < blackchart.list.length; i++) {
+        badid[i] = getUserName(blackchart.list[i].workerId);
+        badpass[i] = blackchart.list[i].passNum;
+        //badfailrate[i] = blackchart.list[i].failRate / 100;
+        if (blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
+            badfailrate[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
+        } else {
+            badfailrate[i] = 0;
+        }
+        if (isUserOfThisFlow(blackchart.list[i].workerId)) {
+            badColor[i] = 'green';
+        } else {
+            badColor[i] = '';
+        }
     }
-    else{
 
+
+}
+
+function on_black_rank_success1(obj, sta) {
+    var blackchart = first_parse(this, obj);
+    var i, j;
+    i = j = 0;
+    console.log(" black chart : ");
+    console.log(blackchart);
+    for (i = 0; i < blackchart.list.length; i++) {
+        badid1[i] = getUserName(blackchart.list[i].workerId);
+        badpass1[i] = blackchart.list[i].passNum;
+        //badfailrate[i] = blackchart.list[i].failRate / 100;
+        if (blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
+            badfailrate1[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
+        } else {
+            badfailrate1[i] = 0;
+        }
+        if (isUserOfThisFlow(blackchart.list[i].workerId)) {
+            badColor1[i] = 'green';
+        } else {
+            badColor1[i] = '';
+        }
     }
+
+
 }
 
-function show_clear_panel(){
-    $("#clearModal").modal('show');
+function getHistoryTableBody(htmlbody, i) {
+    if (typeof hispass[i] === "undefined") {
+        htmlbody += "<tr>";
+        htmlbody += `<tr>
+                    <td> - </td>
+                    <td> - </td>
+                    <td> - </td>
+                    <td> - </td>
+                    <td> - </td>
+                </tr>`;
+        htmlbody += "</tr>";
+        return htmlbody;
+    }
+    htmlbody += "<tr>";
+    htmlbody += `<tr>
+                    <td>${timeday[i]}</td>
+                    <td>${hispass[i]}</td>
+                    <td>${hisfail[i]}</td>
+                    <td>${hisstack[i]}</td>
+                    <td>${hisrate[i] + '%'}</td>
+                </tr>`;
+    htmlbody += "</tr>";
+    return htmlbody;
 }
 
-var executed = false;
-var finished = true;
-var directCount = -1;
-
-function clear_one_data(){
-    executed = false;
-    directCount = -1;
-    finished = true;
-    var hand = $("#handInput").val();
-    var hd = 0;
-    if(hand.length > 0){
-       hd = parseInt(hand);
+function getRankingTableBody(htmlbody, i) {
+    if (typeof goodRank === "undefined" || typeof goodRank[i] === "undefined") {
+        htmlbody += "<tr>";
+        htmlbody += `<tr>
+                    <td> - </td>
+                    <td> 0 </td>
+                    <td> 0 </td>
+                    <td> 0 </td>
+                </tr>`;
+        htmlbody += "</tr>";
+        return htmlbody;
     }
-    get_data("endpoint/clearBoard?flowId="+flowId+"&handheldId=" + hd, clearSuccess);
+    htmlbody += "<tr>";
+    htmlbody += `<tr ">
+                    <td style="background-color: ${goodRank[i].color}">${goodRank[i].id}</td>
+                    <td style="background-color: ${goodRank[i].color}">${goodRank[i].pass}</td>
+                    <td style="background-color: ${goodRank[i].color}">${goodRank[i].fail}</td>
+                    <td style="background-color: ${goodRank[i].color}">${goodRank[i].failRate + '%'}</td>
+                </tr>`;
+    htmlbody += "</tr>";
+    return htmlbody;
 }
 
-function clearSuccess(obj, sta){
-    console.warn("-------  手持设备清空  ----------");
-    console.warn(this);
-    send_alert("发送清空请求成功, 正在等待采集端进行处理...");
-    finished = false;
-    setTimeout(on_timeout_clear, 8000);
-    setTimeout(recurseget,300);
-    //var output = first_success(this, obj);
+var lastTimeRank0 = "";
+var lastTimeRank1 = "";
+var lastTimeRank2 = "";
+var lastTimeRank3 = "";
+var lastTimeRank4 = "";
+
+function showHistoryData() {
+    var htmlbody = "", one_person = "";
+    var i = 0;
+    var triGap = 4;
+    htmlbody = "";
+    for (i = 0; i < triGap; i++) {
+
+        htmlbody = getHistoryTableBody(htmlbody, i);
+    }
+    if (lastTimeRank0 !== htmlbody) {
+        $("#rank-one").html(htmlbody);
+        lastTimeRank0 = htmlbody;
+    }
+    //console.log(htmlbody);
 }
 
-function recurseget(){
-    if(finished) return;
-    get_data("endpoint/heartbeat?flowId=" + flowId, onheart);
-    setTimeout(recurseget,100);
+function showRedRanking() {
+    var htmlbody = "", one_person = "";
+    var i = 0;
+    var triGap = RANK_TBL_ROW_COUNT;
+    htmlbody = "";
+    for (i = 0; i < triGap; i++) {
+
+        htmlbody = getRankingTableBody(htmlbody, i);
+    }
+    if (lastTimeRank1 !== htmlbody) {
+        $("#rank-two").html(htmlbody);
+        lastTimeRank1 = htmlbody;
+    }
+    //console.log(htmlbody);
 }
 
-function onheart(obj,sta){
-    var ouy = {};
-    if(typeof(obj) === "string"){
-        ouy = JSON.parse(obj);
-    }else{
-        ouy = obj;
+
+/***
+ * DataObject DO
+ * @param cname
+ * @param serverJsonObj
+ * @constructor
+ */
+var DataObject = function(cname, serverJsonObj){
+    this.ctlName = cname;
+    this.jsonObj = serverJsonObj;
+    this.getVal = function (key) {
+        return jsonObj[key];
+    };
+    this.serVal = function (key, val) {
+        jsonObj[key] = val;
+    };
+};
+
+/***
+ * DataObjectList
+ * @param name
+ * @constructor
+ */
+var DataObjectList = function(name){
+    this.ctlName = name;
+    this.list = null;
+    this.isSorted = false;
+    this.preSort = [];
+    /***
+     * sorting
+     * @param comparator (a,b)  =====>  a - b
+     */
+    this.sortBy = function(comparator){
+        preSort = new Array();
+        for (let i = 0; i < list.length; i++) preSort.push(list[i]);
+        quickSort(preSort, 0, preSort.length - 1, function(l, r){});
+    };
+
+    function clearData() {
+      isSorted = false;
+      preSort = null;
+      list = null;
+    }
+
+    this.len = function() {
+        if(list == null) return 0;
+        return list.length;
+    };
+
+    this.assignJsonData = function (data) {
+        clearData();
+        list = new Array();
+        for (let i = 0; i < list.length; i++) list.push(new DataObject(ctlName, data[i]));
+    };
+    this.getRaw = function (index) {
+        return list[index];
+    };
+    this.getSorted = function (index) {
+        if(!isSorted) return null;
+        return preSort[index];
+    };
+    this.quickSort = function (a,left,right,comp){
+        if(left>right){ //一定要有这个判断,因为有递归left和i-1,若没有这个判断条件,该函数会进入无限死错位递归
+            return;
+        }
+
+        var i=left,
+            j=right,
+            pivot=a[left]; //基准总是取序列开头的元素
+
+        while(i!=j){
+            while((comp(a[j],pivot) > 0)&&i<j){j--}
+            while((comp(a[j],pivot) <= 0)&&i<j){i++}
+            if(i<j){  //如果i==j跳出外层while
+                var t=a[i];
+                a[i]=a[j];
+                a[j]=t;
+            }
+        }
+
+        a[left]=a[i];//交换基准数和k位置上的数
+        a[i]=pivot;
+
+        quicksort(a,left,i-1,comp);
+        quicksort(a,i+1,right,comp);
+    };
+};
+
+/***
+ * DOService
+ * @param controlName
+ * @constructor
+ */
+var DataObjectService = function(controlName, syncType, extparm){
+    this.ctlName    = controlName;
+    // 2=default 4=on-demand, 8=auto, 16:fast, 32=passive
+    this.syncType   = syncType;
+    this.extParm    = extparm;
+    this.isDefault  =  ((syncType & 2)  !== 0);
+    this.isOnDemand = ((syncType & 4)  !== 0);
+    this.isAuto =     ((syncType & 8)  !== 0);
+    this.isFast =     ((syncType & 16) !== 0);
+    this.isPassive =  ((syncType & 32) !== 0);
+    this.failedCount = 0;
+    this.list = new DataObjectList(controlName);
+    this.autoUpdateTimer = 0;
+    this.autoInterval = 1000;
+
+    function setUpInterval() {
+        //URL + exparm
+        if(this.autoUpdateTimer != 0) clearInterval(this.autoUpdateTimer);
+        this.autoUpdateTimer = setInterval(this.selfUpdateTick, this.autoInterval);
     }
 
+    this.init = function(){
+        if(isAuto){
+            // timer
+            if(!isFast){
+                this.autoInterval = 5000;
+            }
+            setUpInterval();
+            selfUpdate();
+        }
+    };
+    this.stopTimers = function () {
+        clearInterval(this.autoUpdateTimer);
+        this.autoUpdateTimer = 0;
+    };
+    this.selfUpdateTick = function(){
+        get_data(controlName+"/list"+extParm, this.onDataReceived);
+    };
+    this.onDemandUpdate = function(){
+        get_data(controlName+"/list"+extParm, this.onDataReceived);
+    };
+    this.onDataReceived = function(data, sta){
+        let output = first_parse(this, obj);
+        if (output.list == undefined || output.list.length == 0) {
+            this.failedCount++;
+            if(this.failedCount > 100){
+                this.failedCount = 0;
+                this.stopTimers();
+                console.log("【错误次数过多");
+                setTimeout(this.setUpInterval, 10000);
+            }
+            if(this.failedCount == 2) {
+                send_alert("没有数据,请尝试重新加载!【DataService】: ctlName[" + controlName + "],  extParm[" + extparm + "]");
+            }
+        }else{
+            this.list.assignJsonData(output.list);
+        }
+    };
+
+    this.passiveUpdate = function(data){
+        this.failedCount = 0;
+        this.list.assignJsonData(data);
+    };
+    this.init();
+};
+
+var SinglePage = function () {
+    this.modules = [];
+};
 
-    if(typeof(ouy) === "object"){
-        if(ouy.ret === "10000"){
+var Module = function(chartContainerSelector, dataCtlName){
+    this.selector = chartContainerSelector;
+    this.dataCtl = dataCtlName;
+    this.activeData = null;
+    this.lastActive = 0;
+    /***
+     * bindData to UI
+     * @param data DataObjectList
+     */
+    this.setData = function (data) {
+        if(data.ctlName == this.dataCtl){
             //ok
-            if(ouy.model == null || ouy.model === undefined){
-                executed = true;
-                finished = true;
-            }else if(typeof(obj.model) === "object"){
-                // 没有拿到,继续
-                if(obj.model.list != null && obj.model.list.length > 0){
-                    var direct = obj.model.list[0];
-                    if(direct.eventType+"" !== "500"){
-                        // OK
-                        executed = true;
-                        finished = true;
-                    }else if(direct.arg2+"" !== ""+$("#handInput").val()){
-                        // OK
-                        executed = true;
-                        finished = true;
-                    }else{
-                        directCount = direct.counter;
+            console.log(`-------- Module ${this.selector} got data ----------- `);
+            this.activeData = data;
+            //cache
+            this.drawData();
+        }else{
+            console.log(`-------- Module ${this.selector} cannot use data of ${data.ctlName} ----------- `);
+        }
+    };
+    this.drawData = function () {
+      // do nothing
+    }
+};
+
+var RealTimeGraph = new Module("", "fcBiSectorLoad");
+RealTimeGraph.drawData = function (data) {
+    var tempo = this.activeData;
+
+};
+
+var FlowRealTime = (function () {
+
+    this.pgName = "flowDashBoard";
+    this.page = new SinglePage(this.pgName);
+    this.scheduleId = utils_get_param("scheduleId");
+    this.flowId = utils_get_param("flowId");
+    if(scheduleId  == null || flowId == null)
+    {
+        send_alert(`清重新进入本页面!<a href='denglu.html'> 返回主页 </a>`);
+        return;
+    }
+    this.flowPlace = " % flowPlace %";
+    this.flowName = " % flowPlace %";
+    this.HistoryBaseURL = "fcBiFlowDaily/list?scheduleId=" + scheduleId + "&flowId=" + flowId;
+
+    this.scheduleLoadDataService = new DataObjectService("fcScheduleLoadService", 2 & 4);
+    this.biFlowDailyService = null;
+    this.oaStaffService = null;
+    this.sectorService = null;
+    this.flowService = null;
+
+    this.initializeUsers = function(list){
+        list.forEach(function (val, it, arr) {
+            var isExist = false;
+            userIDs.forEach(function (vals) {
+                if (vals == val.userId) {
+                    isExist = true;
+                }
+            });
+            if (!isExist) userIDs.push(val.userId);
+        });
+    };
+
+    this.initPage = function(){
+        showHistoryData();
+        showRedRanking();
+        showBlackRanking();
+    };
+
+    /***
+     * On
+     * @param obj
+     * @param sta
+     */
+    this.onFirstTimeSuccess = function (obj, sta) {
+        let output = first_parse(this, obj);
+        let i, j, k, z = 0, x = 0, worksum = [];
+        if (output.list == undefined || output.list.length == 0) {
+            send_alert("没有数据 | 请重新加载页面 ! ");
+        }else{
+            DataLogic.onScheduleData(output.list);
+        }
+        initializeUsers(output.list);
+        Action.loadMultiHistory();
+        showChart();
+    };
+
+
+    /**
+     * DataLogic
+     */
+    this.DataLogic = (function () {
+
+        this.combineAsSector = function(sectorList, scheduleDoList) {
+            var output = new DataObjectList("sectorLoad");
+            output.assignJsonData("");
+            return output;
+        };
+
+        this.onScheduleData = function (scheduleDoList) {
+            sectorID[0] = getSectorId(scheduleDoList[0].spotId);
+            for (let i = 1; i < scheduleDoList.length; i++) {
+                let loadDO = new ScheduleDO(scheduleDoList[i]);
+                x = 0;
+                for (j = 0; j < sectorID.length; j++) {
+                    if (sectorID[j] === thisUid) {
+                        x = 1;
+                        break;
                     }
                 }
+                if (x === 0) {
+                    sectorID.push(thisUid);
+                }
             }
+            DataLogic.CountBySector();
         }
-    }
-}
+        this.CountBySector = function (sectors, spotData) {
+            sectorId, passNumber, failNumber
+            let j = 0, k = 0, z = 0;
+            for (k = 0; k < sectors.length; k++) {
+                var uid = sectors[k].getUid();
+                z = 0;
+                passNumber[k] = 0;
+                failNumber[k] = 0;
+                stackeverynum[k] = 0;
+                for (i = 0; i < output.list.length; i++) {
+                    if (uid === getSectorId(output.list[i].spotId)) {
+                        passNumber[k] = output.list[i].passNum + passNumber[j];
+                        failNumber[k] = output.list[i].failNum + failNumber[j];
+                        stackeverynum[k] = output.list[i].due + stackeverynum[j];
+                        z++;
+                    }
+                }
+                if (failNumber[k] + passNumber[k] == 0) {
+                    failrate[k] = 0;
+                }  else {
+                    failrate[k] = failNumber[k] / (failNumber[k] + passNumber[k]) * 100;
+                }
+                // z is the number of data in one sector
+            }
+        }
+    })();
+
+    this.NameLoader = (function(){
+        this.onNameRetrieved = function (obj, sta) {
+            var factory = first_parse(this, obj);
+            var i, j, t;
+            console.log(" factory : ");
+            console.log(factory);
+            flowPlace = factory.list[0].flowPlace;
+            flowName = factory.list[0].flowName;
+            $("#flow_title").html(flowPlace + "-" + flowName + " 度彼科技");
+            document.title = flowPlace + " " + flowName + " | 流水线管理 | 度彼科技";
+        };
+        this.load = function(){
+            get_data("fcFlow/list?flowId=" + flowId, onNameRetrieved);
+        };
+    })();
 
-function on_timeout_clear(){
-    finished = true;
-    if(executed){
-        // 执行成功
-    }else{
-        if(directCount >= 0){
-            get_data("endpoint/ack?counter="+directCount,function(){console.log("撤销操作成功");console.log(this);});
+
+    this.mainLoopFunc = function () {
+        get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, realtime_success);
+        HistoryData.update();
+    };
+
+    this.Action = (function () {
+        this.clearDataOfDeviceId = function (handId) {
+            executed = false;
             directCount = -1;
-            send_alert("请求已经超时!请注意,采集端可能没有执行成功。即将撤销您的请求。");
-        }else{
-            send_alert("请求已经超时!请注意,采集端可能没有执行成功。");
+            finished = true;
+            var hand = handId;
+            var hd = 0;
+            if (hand.length > 0) {
+                hd = parseInt(hand);
+            }
+            get_data("endpoint/clearBoard?flowId=" + flowId + "&handheldId=" + hd, clearSuccess);
+        };
+        this.doStopSchedule = function () {
+            get_data("fcWorkSchedule/stopSchedule?userId=" + userId + "&scheduleId=" + scheduleId, UI.showStopSuccess);
+        };
+        this.confirmStopSchedule = function () {
+            var out = confirm("真的要下班吗?");
+            if (out == true) {
+                doStopSchedule();
+            } else {
+            }
+        };
+
+    })();
+
+    this.UI = (function () {
+        this.showClearPanel = function () {
+            $("#clearModal").modal('show');
+        };
+        this.showStopSuccess = function (obj, sta) {
+            send_alert("下班操作成功! <a href='denglu.html'> 点击这里返回控制主页 </a>");
+        };
+    })();
+
+    this.HistoryData = (function (){
+
+        this.update = function () {
+            // 请注意type必须在结尾
+            get_data("fcBiFlowDaily/list?flowId=" + flowId + "&type=1", history_success);
+        };
+
+        this.loadHistroyOnce = function (nnm) {
+            // 请注意type必须在结尾
+            get_data(HistoryBaseURL + "&type=" + nnm, history_success);
+        };
+
+        this.loadMultiHistory = function(){
+            for (i = 1; i <= 3; i++) loadHistroyOnce(i);
+        };
+
+        this.add_success = function(obj, sta) {
+            var history1 = first_parse(this, obj);
+            var i, j;
+            console.log(" history1 : ");
+            console.log(history1);
+            hispass[t] = 0;
+            hisfail[t] = 0;
+            hisstack[t] = 0;
+            hisrate[t] = 0;
+            var lengthnum = history1.length - 1;
+            for (i = lengthnum; i < history1.length; i++) {
+                hispass[t] = history1[i].passNum + hispass[t];
+                hisfail[t] = history1[i].failNum + hisfail[t];
+                hisstack[t] = history1[i].avgDue + hisstack[t];
+            }
+            if (hispass[t] + hisfail[t] == 0) {
+                hisrate[t] = 0;
+            }
+            t++;
         }
+    })();
+
+    function realtime_success(obj, sta) {
+        var output = first_parse(this, obj);
+        //在这里排序 spo\
+        console.log(" output : ");
+        console.log(output);
+
+        var i, j, k, z;
+        failnum = 0;
+        var x = 0;
+        var worksum = [];
+        var hhp = 0, hhf = 0, hhs = 0;
+
+
+        if (output.list.length > 0) {
+            sectorID[0] = getSectorId(output.list[0].spotId);
+            passNumber[0] = 0;
+            failNumber[0] = 0;
+            stackeverynum[0] = 0;
+            z = 0;
+            for (i = 1; i < output.list.length; i++) {
+                var thisUid = getSectorId(output.list[i].spotId);
+                x = 0;
+                for (j = 0; j < sectorID.length; j++) {
+                    if (sectorID[j] === thisUid) {
+                        x = 1;
+                        break;
+                    }
+                }
+                if (x === 0) {
+                    sectorID.push(thisUid);
+                }
+
+            }
+            j = 0;
+            for (k = 0; k < sectorID.length; k++) {
+                var uid = sectorID[k];
+                z = 0;
+                passNumber[k] = 0;
+                failNumber[k] = 0;
+                stackeverynum[k] = 0;
+                for (i = 0; i < output.list.length; i++) {
+                    if (uid === getSectorId(output.list[i].spotId)) {
+                        passNumber[k] = output.list[i].passNum + passNumber[k];
+                        failNumber[k] = output.list[i].failNum + failNumber[k];
+                        stackeverynum[k] = output.list[i].due + stackeverynum[k];
+                        z++;
+                    }
+                }
+                failrate[k] = get_factor(passNumber[k], failNumber[k]);
+            }
+            output.list.forEach(function (val, fid, arr) {
+                hhp += val.passNum;
+                hhf += val.failNum;
+                hhs += val.due;
+            })
+        }
+
+        schedulepass = hhp;
+        schedulefail = hhf;
+        if (output.list.length > 0) {
+            schedulestack = hhs / output.list.length;
+        } else {
+            schedulestack = 0;
+        }
+        update_all_history();
+        updateChart();
+
+    };
+
+})();
+
+var ClearDataControl = (function () {
+    this.finished = true;
+    this.executed = false;
+    this.directCount = -1;
+
+    this.Action = (function () {
+
+    })();
+
+    this.clearSuccess = function (obj, sta) {
+        console.warn("-------  手持设备清空  ----------");
+        console.warn(this);
+        send_alert("发送清空请求成功, 正在等待采集端进行处理...");
+        ClearDataControl.finished = false;
+        setTimeout(resultVerifyTimeout, 8000);
+        setTimeout(getVerify, 300);
     }
-}
 
+    this.getVerify = function () {
+        if (ClearDataControl.finished) return;
+        get_data("endpoint/heartbeat?flowId=" + flowId, onVerifyResult);
+        setTimeout(getVerify, 100);
+    };
 
-function get_stop_scheudle() {
-    get_data("fcWorkSchedule/stopSchedule?userId="+userId+"&scheduleId=" + scheduleId, stopSuccess);
+    this.onVerifyResult = function (obj, sta) {
+        var parsed = {};
+        if (typeof(obj) === "string") {
+            parsed = JSON.parse(obj);
+        } else {
+            parsed = obj;
+        }
 
-}
+        if (typeof(parsed) === "object") {
+            if (parsed.ret === "10000") {
+                //ok
+                if (parsed.model == null || parsed.model === undefined) {
+                    executed = true;
+                    finished = true;
+                } else if (typeof(obj.model) === "object") {
+                    // 没有拿到,继续
+                    if (obj.model.list != null && obj.model.list.length > 0) {
+                        var direct = obj.model.list[0];
+                        if (direct.eventType + "" !== "500") {
+                            // OK
+                            executed = true;
+                            finished = true;
+                        } else if (direct.arg2 + "" !== "" + $("#handInput").val()) {
+                            // OK
+                            executed = true;
+                            finished = true;
+                        } else {
+                            directCount = direct.counter;
+                        }
+                    }
+                }
+            }
+        }
+    }
 
-function stopSuccess(obj, sta) {
-    send_alert("下班操作成功! <a href='denglu.html'> 点击这里返回控制主页 </a>");
-}
+    this.resultVerifyTimeout = function () {
+        finished = true;
+        if (executed) {
+            // 执行成功
+        } else {
+            if (directCount >= 0) {
+                get_data("endpoint/ack?counter=" + directCount, function () {
+                    console.log("撤销操作成功");
+                    console.log(this);
+                });
+                directCount = -1;
+                send_alert("请求已经超时!请注意,采集端可能没有执行成功。即将撤销您的请求。");
+            } else {
+                send_alert("请求已经超时!请注意,采集端可能没有执行成功。");
+            }
+        }
+    }
+})();
 
+$(document).ready(function(){
+});
 
-function add_success(obj, sta) {
-    var history1 = first_parse(this, obj);
-    var i, j;
-    console.log(" history1 : ");
-    console.log(history1);
-    hispass[t] = 0;
-    hisfail[t] = 0;
-    hisstack[t] = 0;
-    hisrate[t] = 0;
-    var lengthnum = history1.length - 1;
-    for (i = lengthnum; i < history1.length; i++) {
-        hispass[t] = history1[i].passNum + hispass[t];
-        hisfail[t] = history1[i].failNum + hisfail[t];
-        hisstack[t] = history1[i].avgDue + hisstack[t];
 
+var RealTimeCharts = (function() {
+
+    var timeday = ["今日", "昨日", "本周", "本月"];
+
+    if (flowId == null || scheduleId == null) {
+        send_alert("出错啦!请检查参数完整性");
     }
 
-    if (hispass[t] + hisfail[t] == 0) {
-        hisrate[t] = 0;
+    function page_document_load() {
+        get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, onFirstTimeSuccess);
+
     }
-    t++;
 
-}
+    var compAxis = {
+        categories: namedata,
+        crosshair: true,
+        title: {
+            text: '工位',
+            style: {
+                fontSize: '1.5em'
+            }
+        },
+        labels: {
+            style: {
+                fontSize: '1.5em'
+            }
+        }
+    };
 
-function realtime_success(obj, sta) {
-    var output = first_parse(this, obj);
-    //在这里排序 spo\
-    console.log(" output : ");
-    console.log(output);
-
-    var i, j, k, z;
-    failnum = 0;
-    var x = 0;
-    var worksum = [];
-    var hhp = 0, hhf = 0, hhs = 0;
-
-
-    if (output.list.length > 0) {
-        sectorID[0] = getSectorId(output.list[0].spotId);
-        passNumber[0] = 0;
-        failNumber[0] = 0;
-        stackeverynum[0] = 0;
-        z = 0;
-        for (i = 1; i < output.list.length; i++) {
-            var thisUid = getSectorId(output.list[i].spotId);
-            x = 0;
-            for (j = 0; j < sectorID.length; j++) {
-                if (sectorID[j] === thisUid) {
-                    x = 1;
-                    break;
-                }
+    var getSeperateArrays = function (sectorLoadData){
+        this.data = [];
+        this.len = sectorLoadData.len();
+        this.stackmax = 0;
+        this.failmax = 0;
+        this.passmax = 0;
+        this.failratemax = 0;
+        this.ratedata = [];
+        this.passdata = [];
+        this.faildata = [];
+        for (i = 0; i < len; i++) {
+            var one = sectorLoadData.getRaw(i);
+            if (stackmax < one[i].getVal("stack")) {
+                stackmax = one[i].getVal("stack")
+            }
+            if (failmax < one[i].getVal("failNum")) {
+                failmax = one[i].getVal("failNum");
+            }
+            if (failratemax < one[i].getVal("failRate")) {
+                failratemax = one[i].getVal("failRate");
             }
-            if (x === 0) {
-                sectorID.push(thisUid);
+            if (passmax < one[i].getVal("passNum")) {
+                passmax = one[i].getVal("passNum");
             }
 
+            data.push(one[i].getVal("stack"));
+            this.ratedata.push(Math.floor(one[i].getVal("failRate")));
+            this.passdata.push(one[i].getVal("passNum"));
+            this.faildata.push(one[i].getVal("failNum"));
         }
-        j = 0;
-        for (k = 0; k < sectorID.length; k++) {
-            var uid = sectorID[k];
-            z = 0;
-            passNumber[k] = 0;
-            failNumber[k] = 0;
-            stackeverynum[k] = 0;
-            for (i = 0; i < output.list.length; i++) {
-                if (uid === getSectorId(output.list[i].spotId)) {
-                    passNumber[k] = output.list[i].passNum + passNumber[k];
-                    failNumber[k] = output.list[i].failNum + failNumber[k];
-                    stackeverynum[k] = output.list[i].due + stackeverynum[k];
-                    z++;
+    };
+
+    this.dataArrays = null;
+
+    function showChart(sectorLoadData) {
+        dataArrays = new getSeperateArrays(sectorLoadData);
+
+        failratemax = Math.max(failratemax, 5);
+        stackmax = Math.max(stackmax, 5);
+        failmax = Math.max(failmax, 5);
+        passmax = Math.max(passmax, failmax, stackmax);
+
+        stackAndFailChart = Highcharts.chart('graph-1', {
+            chart: {
+                zoomType: 'xy',
+                //height: (4 / 16 * 100) + '%' // 16:9 ratio
+            },
+            title: {text: '各工位今日产能'},
+            credits: {enabled: false},
+            exporting: {enabled: false},
+            xAxis: [compAxis],
+            yAxis: [{
+                labels: {
+                    format: '{value}',
+                    style: {
+                        color: "#ffffff",
+                        fontSize: '1.5em'
+                    }
+                },
+                min: 0,
+                max: passmax * 1.5,
+                title: {
+                    text: '数量',
+                    style: {
+                        color: '#ffffff',
+                        fontSize: '1em'
+                    },
+                    rotation: 270,
+                }
+            },],
+            tooltip: {shared: true},
+            legend: {
+                layout: 'vertical',
+                align: 'right',
+                x: 0,
+                verticalAlign: 'top',
+                y: 0,
+                floating: true,
+                backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
+            },
+            series: [{
+                name: '良品数',
+                type: 'column',
+                data: passdata,
+
+            }, {
+                name: '不良品数',
+                type: 'column',
+                data: faildata,
+
+            },
+                {
+                    name: '堆积数',
+                    type: 'column',
+                    data: data,
+                }]
+        });
+
+        FailChart = Highcharts.chart('graph-2', {
+            chart: {
+                //height: (4 / 16 * 100) + '%' // 16:9 ratio
+            },
+            title: {
+                text: '各工位今日不良率'
+            },
+            credits: {
+                enabled: false // 禁用版权信息
+            },
+            exporting: {
+                enabled: false
+            },
+            xAxis: [compAxis],
+            yAxis: [{ // Secondary yAxis
+                title: {
+                    text: '不良率',
+                    style: {
+                        color: '#ffffff',
+                        fontSize: '1em'
+                    }
+                },
+                min: 0,
+                max: 1.5 * failratemax,
+                labels: {
+                    formatter: function () {
+                        return Math.floor(this.value) + "%";
+                    },
+                    style: {
+                        color: '#ffffff',
+                        fontSize: '20px'
+                    },
+                    rotation: 270,
+                },
+
+            }],
+            tooltip: {
+                shared: true
+            },
+            legend: {
+                layout: 'vertical',
+                align: 'right',
+                x: 0,
+                verticalAlign: 'top',
+                y: 0,
+                floating: true,
+                backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
+            },
+            series: [{
+                name: '不良率',
+                type: 'spline',
+                data: ratedata,
+                color: 'red',
+                tooltip: {
+                    valueSuffix: '%'
                 }
+            }]
+        });
+
+    }
+
+    function updateChart() {
+        var data = [];
+        var ratedata = [];
+        var stackmax = 0;
+        var failmax = 0;
+        var passdata = [];
+        var faildata = [];
+        var passmax = 0;
+        var failratemax = 0;
+
+        for (i = 0; i < passNumber.length; i++) {
+            if (stackmax < stackeverynum[i]) {
+                stackmax = stackeverynum[i];
+            }
+            if (failmax < failNumber[i]) {
+                failmax = failNumber[i];
+            }
+            if (failratemax < failrate[i]) {
+                failratemax = failrate[i];
             }
-            failrate[k] = get_factor(passNumber[k], failNumber[k]);
+            if (passmax < passNumber[i]) {
+                passmax = passNumber[i];
+            }
+            data.push(stackeverynum[i]);
+            ratedata.push(Math.floor(failrate[i]));
+            passdata.push(passNumber[i]);
+            faildata.push(failNumber[i])
         }
-        output.list.forEach(function (val, fid, arr) {
-            hhp += val.passNum;
-            hhf += val.failNum;
-            hhs += val.due;
-        })
-    }
+        failratemax = Math.max(failratemax, 5);
+        stackmax = Math.max(stackmax, 5);
+        failmax = Math.max(failmax, 5);
+        passmax = Math.max(passmax, failmax, stackmax);
 
-    schedulepass = hhp;
-    schedulefail = hhf;
-    if (output.list.length > 0) {
-        schedulestack = hhs / output.list.length;
-    } else {
-        schedulestack = 0;
+
+        // https://api.hcharts.cn/highcharts#Series.addPoint;
+
+        stackAndFailChart.series[0].setData(passdata);
+        stackAndFailChart.series[1].setData(faildata);
+        stackAndFailChart.series[2].setData(data);
+        FailChart.series[0].setData(ratedata);
+
+        if (failratemax > FailChart.yAxis[0].getExtremes().max * 1.3 || failratemax < FailChart.yAxis[0].getExtremes().max * 0.5) {
+            FailChart.yAxis[0].setExtremes(0, failratemax * 1.5);
+        }
+        if (passmax > stackAndFailChart.yAxis[0].getExtremes().max * 1.3 || passmax < stackAndFailChart.yAxis[0].getExtremes().max * 0.5) {
+            stackAndFailChart.yAxis[0].setExtremes(0, passmax * 1.5);
+        }
+
+        showHistoryData();
+        showRedRanking();
+        showBlackRanking();
+
+
+        var secNames = [];
+
+        sectorID.forEach(function (val) {
+            secNames.push(getSectorName(val));
+        });
+
+        if (JSON.stringify(secNames) !== lastTimeSecNames) {
+            lastTimeSecNames = JSON.stringify(secNames);
+            FailChart.xAxis[0].setCategories(secNames);
+            stackAndFailChart.xAxis[0].setCategories(secNames);
+        }
     }
-    update_all_history();
-    updateChart();
 
-}
+    var lastTimeSecNames = "";
+
+    var stackAndFailChart = null;
+    var FailChart = null;
 
+})();

+ 0 - 253
js/lazhang-display.js

@@ -1,253 +0,0 @@
-var timeday = ["今日", "昨日", "本周", "本月"];
-
-if (flowId == null || scheduleId == null) {
-    send_alert("出错啦!请检查参数完整性");
-}
-
-function page_document_load() {
-    get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, first_success);
-
-}
-
-var compAxis = {
-    categories: namedata,
-    crosshair: true,
-    title: {
-        text: '工位',
-        style: {
-            fontSize: '1.5em'
-        }
-    },
-    labels: {
-        style: {
-            fontSize: '1.5em'
-        }
-    }
-};
-
-function showChart() {
-
-    var data = [];
-    var ratedata = [];
-    var stackmax = 0;
-    var failmax = 0;
-    var passdata = [];
-    var faildata = [];
-    var passmax = 0;
-    var failratemax=0;
-
-    for (i = 0; i < passNumber.length; i++) {
-        if (stackmax < stackeverynum[i]) {
-            stackmax = stackeverynum[i];
-        }
-        if (failmax < failNumber[i]) {
-            failmax = failNumber[i];
-        }
-        if (failratemax< failrate[i]) {
-            failratemax = failrate[i];
-        }
-        if (passmax < passNumber[i]) {
-            passmax = passNumber[i];
-        }
-
-        data.push(stackeverynum[i]);
-        ratedata.push(Math.floor(failrate[i]));
-        passdata.push(passNumber[i]);
-        faildata.push(failNumber[i])
-    }
-
-    showHistoryData();
-    showRedRanking();
-    showBlackRanking();
-
-
-    failratemax = Math.max(failratemax, 5);
-    stackmax = Math.max(stackmax, 5);
-    failmax = Math.max(failmax, 5);
-    passmax =  Math.max(passmax,failmax,stackmax);
-
-    stackAndFailChart = Highcharts.chart('graph-1', {
-        chart: {
-            zoomType: 'xy',
-            //height: (4 / 16 * 100) + '%' // 16:9 ratio
-        },
-        title: {text: '各工位今日产能'},
-        credits: {enabled: false},
-        exporting: {enabled: false},
-        xAxis: [compAxis],
-        yAxis: [{
-            labels: {
-                format: '{value}',
-                style: {
-                    color: "#ffffff",
-                    fontSize: '1.5em'
-                }
-            },
-            min: 0,
-            max: passmax * 1.5,
-            title: {
-                text: '数量',
-                style: {
-                    color: '#ffffff',
-                    fontSize: '1em'
-                },
-                rotation: 270,
-            }
-        },],
-        tooltip: {shared: true},
-        legend: {
-            layout: 'vertical',
-            align: 'right',
-            x: 0,
-            verticalAlign: 'top',
-            y: 0,
-            floating: true,
-            backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
-        },
-        series: [{
-            name: '良品数',
-            type: 'column',
-            data: passdata,
-
-        }, {
-            name: '不良品数',
-            type: 'column',
-            data: faildata,
-
-        },
-            {
-                name: '堆积数',
-                type: 'column',
-                data: data,
-            }]
-    });
-
-    FailChart = Highcharts.chart('graph-2', {
-        chart: {
-            //height: (4 / 16 * 100) + '%' // 16:9 ratio
-        },
-        title: {
-            text: '各工位今日不良率'
-        },
-        credits: {
-            enabled: false // 禁用版权信息
-        },
-        exporting: {
-            enabled: false
-        },
-        xAxis: [compAxis],
-        yAxis: [{ // Secondary yAxis
-            title: {
-                text: '不良率',
-                style: {
-                    color: '#ffffff',
-                    fontSize: '1em'
-                }
-            },
-            min: 0,
-            max: 1.5 * failratemax,
-            labels: {
-                formatter: function () {
-                    return Math.floor(this.value) + "%";
-                },
-                style: {
-                    color: '#ffffff',
-                    fontSize: '20px'
-                },
-                rotation: 270,
-            },
-
-        }],
-        tooltip: {
-            shared: true
-        },
-        legend: {
-            layout: 'vertical',
-            align: 'right',
-            x: 0,
-            verticalAlign: 'top',
-            y: 0,
-            floating: true,
-            backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
-        },
-        series: [{
-            name: '不良率',
-            type: 'spline',
-            data: ratedata,
-            color: 'red',
-            tooltip: {
-                valueSuffix: '%'
-            }
-        }]
-    });
-
-}
-
-function updateChart() {
-    var data = [];
-    var ratedata = [];
-    var stackmax = 0;
-    var failmax = 0;
-    var passdata = [];
-    var faildata = [];
-    var passmax = 0;
-    var failratemax=0;
-
-    for (i = 0; i < passNumber.length; i++) {
-        if (stackmax < stackeverynum[i]) {
-            stackmax = stackeverynum[i];
-        }
-        if (failmax < failNumber[i]) {
-            failmax = failNumber[i];
-        }
-        if (failratemax < failrate[i]) {
-            failratemax= failrate[i];
-        }
-        if (passmax < passNumber[i]) {
-            passmax = passNumber[i];
-        }
-        data.push(stackeverynum[i]);
-        ratedata.push(Math.floor(failrate[i]));
-        passdata.push(passNumber[i]);
-        faildata.push(failNumber[i])
-    }
-    failratemax = Math.max(failratemax, 5);
-    stackmax = Math.max(stackmax, 5);
-    failmax = Math.max(failmax, 5);
-    passmax =  Math.max(passmax,failmax,stackmax);
-
-
-    // https://api.hcharts.cn/highcharts#Series.addPoint;
-
-    stackAndFailChart.series[0].setData(passdata);
-    stackAndFailChart.series[1].setData(faildata);
-    stackAndFailChart.series[2].setData(data);
-    FailChart.series[0].setData(ratedata);
-
-    if (failratemax > FailChart.yAxis[0].getExtremes().max * 1.3 || failratemax < FailChart.yAxis[0].getExtremes().max * 0.5) {
-        FailChart.yAxis[0].setExtremes(0, failratemax * 1.5);
-    }
-    if (passmax > stackAndFailChart.yAxis[0].getExtremes().max * 1.3 || passmax < stackAndFailChart.yAxis[0].getExtremes().max * 0.5) {
-        stackAndFailChart.yAxis[0].setExtremes(0, passmax * 1.5);
-    }
-
-    showHistoryData();
-    showRedRanking();
-    showBlackRanking();
-
-
-    var secNames = [];
-
-    sectorID.forEach(function(val){  secNames.push(getSectorName(val)); });
-
-    if(JSON.stringify(secNames) !== lastTimeSecNames){
-        lastTimeSecNames = JSON.stringify(secNames);
-        FailChart.xAxis[0].setCategories(secNames);
-        stackAndFailChart.xAxis[0].setCategories(secNames);
-    }
-}
-
-var lastTimeSecNames = "";
-
-var stackAndFailChart = null;
-var FailChart = null;

+ 4 - 4
lazhang.html

@@ -88,13 +88,13 @@
                 </div>
             </li>
             <li class="nav-item">
-                <a class="nav-link bg-red text-white" href="javascript:void" id="test1">深圳市度彼电子有限公司</a>
+                <a class="nav-link bg-red text-white" href="javascript:void" id="flow_title">深圳市度彼电子有限公司</a>
             </li>
         </ul>
         <form class="form-inline my-2 my-lg-0 text-white" >
             <button class="btn btn-outline-dark my-2 my-sm-0 text-white" id="nowDateTimeSpan"></button>
-            <button class="btn btn-danger my-2 my-sm-0" onclick="get_stop_scheudle1()">下班</button>
-            <button class="btn btn-warning my-2 my-sm-0" onclick="show_clear_panel()">清除数据</button>
+            <button class="btn btn-danger my-2 my-sm-0" onclick="confirmStopSchedule()">下班</button>
+            <button class="btn btn-warning my-2 my-sm-0" onclick="FlowRealTime.UI.showClearPanel()">清除数据</button>
             <button class="btn btn-success my-2 my-sm-0" onclick="history.go(0)">重新加载</button>
         </form>
     </div>
@@ -128,7 +128,7 @@
                 </div>
                 <div class="modal-footer">
                     <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
-                    <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="clear_one_data()">确认清除</button>
+                    <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="FlowRealTime.Action.clearDataOfDeviceId($("#handInput").val())">确认清除</button>
                 </div>
             </div>
         </div>