123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- var SVR_URL = "/server/"; //http://172.30.84.3:8803
- if(location.host.indexOf("niimei") === -1){
- SVR_URL = "http://172.30.84.3:8803/server/";
- }
- function get_data(url, callback) {
- $.ajax({
- url: SVR_URL + url,
- apiName: url,
- sendTime: new Date()
- }).done(callback).fail(on_fail);
- }
- function on_fail(msg) {
- alert("很抱歉,网络错误,请查看Console");
- console.log("----- 网络请求失败 ---------")
- console.log(JSON.stringify(this));
- console.log("----------------------------")
- }
- function on_data_success(obj, status) {
- }
- function first_parse(ajax, obj) {
- if (typeof obj === "string") {
- obj = JSON.parse(obj);
- }
- if (typeof obj !== "object") {
- console.log(ajax);
- throw "Error ! Parsing JSON failed ." + JSON.stringify(obj);
- }
- if (obj.ret == "10000" || obj.ret == 10000 || obj.ret == 1000) {
- return obj.model;
- } else {
- console.log(ajax);
- throw "Error ! Server returned error." + JSON.stringify(obj);
- }
- }
- var flowData;
- var sID = [];
- var passNumber = [];
- var failNumber = [];
- var failrate = [];
- var stacknum = 0;
- var stackeverynum = [];
- var failnum=0;
- var passnum=0
- var passdata=[];
- var faildata=[];
- var num=0;
- var hispass=[];
- var hisfail=[];
- var hisstack=[];
- var hisrate=[];
- var goodpass=[];
- var goodid=[];
- var goodfailrate=[];
- var badpass=[];
- var badid=[];
- var badfailrate=[];
- var t=0;
- var n=0;
- var workID=[];
- function firsttime_load_spots_data() {
- get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, first_success)
- }
- function secondtime_load_spots_data() {
- get_data("fcBiFlowDaily/list?type=" + num +"&flowId="+flowId, second_success);
- num++;
- }
- function chart_load_spots_data() {
- get_data("fcBiWorkerDaily/get?type=0&limit=3", chart_success);
- }
- function chart1_load_spots_data() {
- get_data("fcBiWorkerDaily/get?type=4&limit=3", chart1_success);
- }
- function first_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=[];
- workID[0]=output.list[0].userId;
- passNumber[0]=0;
- failNumber[0]=0;
- stackeverynum[0]=0;
- z=0;
- for(i=1;i<output.list.length;i++){
- var thisUid = output.list[i].userId;
- x = 0;
- for(j=0;j<workID.length;j++){
- if(workID[j] === thisUid){
- x=1;
- break;
- }
- }
- if(x===0){
- workID.push(thisUid);
- }
- }
- j=0;
- for(k=0;k<workID.length;k++){
- var uid = workID[k];
- z=0;
- for(i=0;i<output.list.length;i++){
- if(uid===output.list[i].userId){
- 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;
- }
- stackeverynum[k]=stackeverynum[k]/z;
- ///
- }
- for(i=1;i<5;i++) {
- secondtime_load_spots_data();
- }
- chart_load_spots_data();
- chart1_load_spots_data();
- showChart();
- setInterval(function(){
- get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, realtime_success);
- },1000);
- }
- function second_success(obj, sta) {
- var history = first_parse(this, obj);
- var i, j;
- console.log(" history : ");
- console.log(history);
- hispass[t] = 0;
- hisfail[t] = 0;
- hisstack[t] = 0;
- hisrate[t]=0;
- for(i=0;i<history.length;i++){
- hispass[t] = history[i].passNum+hispass[t];
- hisfail[t] = history[i].failNum+hisfail[t];
- hisstack[t] = history[i].avgDue+hisstack[t];
- hisrate[t] = history[i].failRate;
- hisrate[t]=hisrate[t]/100;
- }
- if(history.length!=1){
- hisrate[t]=Math.floor(hisfail[t]/(hispass[t]+hisfail[t])*10000)/100;
- }
- if(hispass[t]+hisfail[t]==0){
- hisrate[t]=0;
- }
- t++;
- }
- function chart_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<3;i++){
- goodid[i]=redchart.list[i].workerId;
- goodpass[i]=redchart.list[i].passNum;
- goodfailrate[i]=redchart.list[i].failRate/100;
- }
- }
- function chart1_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<3;i++){
- badid[i]=blackchart.list[i].workerId;
- badpass[i]=blackchart.list[i].passNum;
- badfailrate[i]=blackchart.list[i].failRate/100;
- }
- }
- 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=[];
- workID[0]=output.list[0].userId;
- passNumber[0]=0;
- failNumber[0]=0;
- stackeverynum[0]=0;
- z=0;
- for(i=1;i<output.list.length;i++){
- var thisUid = output.list[i].userId;
- x = 0;
- for(j=0;j<workID.length;j++){
- if(workID[j] === thisUid){
- x=1;
- break;
- }
- }
- if(x===0){
- workID.push(thisUid);
- }
- }
- j=0;
- for(k=0;k<workID.length;k++){
- var uid = workID[k];
- z=0;
- for(i=0;i<output.list.length;i++){
- if(uid===output.list[i].userId){
- 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;
- }
- stackeverynum[k]=stackeverynum[k]/z;
- ///
- }
- updateChart();
- }
- /*function on_load_success_spots(obj, status) {
- var spotsList = first_parse(this, obj);
- //在这里排序 spo\
- console.log("spot List : ");
- console.log(spotsList);
- var i, j, temp;
- for (i = 0; i < spotsList.list.length - 1; i++) {
- for (j = 0; j < spotsList.list.length - i - 1; j++) {
- if (spotsList.list[j].orderNum > spotsList.list[j + 1].orderNum) {
- temp = spotsList.list[j];
- spotsList.list[j] = spotsList.list[j + 1];
- spotsList.list[j + 1] = temp;
- }
- }
- }
- flowData = spotsList.list;
- for (i = 0; i < spotsList.list.length ; i++) {
- sID[i] = spotsList.list[i].spotId;
- namedata[i] = spotsList.list[i].spotName;
- }
- firsttime_load_spots_data();
- }*/
- function on_document_load() {
- // First Step
- //get_data("fcSpot/list?flowId=" + scheduleId, on_load_success_spots)
- firsttime_load_spots_data();
- }
- var namedata = [];
|