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 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]); } todayotherpass = histoire[histoire.length - 1].passNum; todayotherfail = histoire[histoire.length - 1].failNum; todayotherstack = histoire[histoire.length - 1].avgDue; 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]); 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]); } } 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 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 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 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] = ''; } } } 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 getSpotHtml(htmlbody, i) { if(typeof hispass[i] === "undefined"){ htmlbody += ""; htmlbody += ` - - - - - `; htmlbody += ""; return htmlbody; } htmlbody += ""; htmlbody += ` ${timeday[i]} ${hispass[i]} ${hisfail[i]} ${hisstack[i]} ${hisrate[i] + '%'} `; htmlbody += ""; return htmlbody; } function getSpotHtml1(htmlbody, i) { if(typeof goodid[i] === "undefined"){ htmlbody += ""; htmlbody += ` - - - - `; htmlbody += ""; return htmlbody; } htmlbody += ""; htmlbody += ` ${goodid[i]} ${goodpass[i]} ${goodid1[i]} ${goodfailrate1[i] + '%'} `; htmlbody += ""; return htmlbody; } /*function getSpotHtml3(htmlbody, i) { if(typeof goodid1[i] === "undefined"){ htmlbody += ""; htmlbody += ` - - `; htmlbody += ""; return htmlbody; } htmlbody += ""; htmlbody += ` ${goodid1[i]} ${goodfailrate1[i] + '%'} `; htmlbody += ""; return htmlbody; }*/ function getSpotHtml2(htmlbody, i) { if(typeof badid[i] === "undefined"){ htmlbody += ""; htmlbody += ` - - - - `; htmlbody += ""; return htmlbody; } htmlbody += ""; if(typeof badColor[i] === "undefined"){ htmlbody += ` ${badid[i]} ${badpass[i]} ${badid1[i]} ${badfailrate1[i] + '%'} `; }else { htmlbody += ` ${badid[i]} ${badpass[i]} ${badid1[i]} ${badfailrate1[i] + '%'} `; } htmlbody += ""; return htmlbody; } /*function getSpotHtml4(htmlbody, i) { if(typeof badid1[i] === "undefined"){ htmlbody += ""; htmlbody += ` - - `; htmlbody += ""; return htmlbody; } htmlbody += ""; if(typeof badColor1[i] === "undefined"){ htmlbody += ` ${badid1[i]} ${badfailrate1[i] + '%'} `; }else { htmlbody += ` ${badid1[i]} ${badfailrate1[i] + '%'} `; } htmlbody += ""; return htmlbody; }*/ var lastTimeRank0 = ""; var lastTimeRank1 = ""; var lastTimeRank2 = ""; var lastTimeRank3 = ""; var lastTimeRank4 = ""; function showEachSpot() { var htmlbody = "", one_person = ""; var i = 0; var triGap = 4; htmlbody = ""; for (i = 0; i < triGap; i++) { htmlbody = getSpotHtml(htmlbody, i); } if(lastTimeRank0 !== htmlbody) { $("#rank-one").html(htmlbody); lastTimeRank0 = htmlbody; } //console.log(htmlbody); } function showEachSpot1() { var htmlbody = "", one_person = ""; var i = 0; var triGap = 3; htmlbody = ""; for (i = 0; i < triGap; i++) { htmlbody = getSpotHtml1(htmlbody, i); } if(lastTimeRank1 !== htmlbody){ $("#rank-two").html(htmlbody); lastTimeRank1 = htmlbody; } //console.log(htmlbody); } /*function showEachSpot3() { var htmlbody = "", one_person = ""; var i = 0; var triGap = 3; htmlbody = ""; for (i = 0; i < triGap; i++) { htmlbody = getSpotHtml3(htmlbody, i); } if(lastTimeRank3 !== htmlbody){ $("#rank-four").html(htmlbody); lastTimeRank3 = htmlbody; } //console.log(htmlbody); }*/ function showEachSpot2() { var htmlbody = "", one_person = ""; var i = 0; var triGap = 3; htmlbody = ""; for (i = 0; i < triGap; i++) { htmlbody = getSpotHtml2(htmlbody, i); } if(lastTimeRank2 !== htmlbody){ $("#rank-three").html(htmlbody); lastTimeRank2 = htmlbody; } //console.log(htmlbody); } /*function showEachSpot4() { var htmlbody = "", one_person = ""; var i = 0; var triGap = 3; htmlbody = ""; for (i = 0; i < triGap; i++) { htmlbody = getSpotHtml4(htmlbody, i); } if(lastTimeRank4 !== htmlbody){ $("#rank-five").html(htmlbody); lastTimeRank4 = htmlbody; } //console.log(htmlbody); }*/