123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- 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=1;
- var hispass=[];
- var hisfail=[];
- var hisstack=[];
- var hisrate=[];
- var t=0;
- function firsttime_load_spots_data() {
- get_data("fcWorkRaw/allSpots?flowId=" + thisPageFlow, first_success)
- }
- function secondtime_load_spots_data() {
- get_data("fcWorkRaw/allFlows?type=" + num, second_success);
- num++;
- }
- function first_success(obj, sta) {
- var output = first_parse(this, obj);
- //在这里排序 spo\
- console.log(" output : ");
- console.log(output);
- var i, j;
- failnum=0;
- for (i = 0; i < output.length ; i++) {
- passNumber[i] = output[i].passNum;
- passnum=passNumber[i]
- }
- for (i = 0; i < output.length ; i++) {
- failNumber[i] = output[i].failNum;
- failnum=failNumber[i]+failnum;
- }
- for (i = 0; i < output.length ; i++) {
- if (failNumber[i] + passNumber[i] == 0) {
- failrate[i] = 0;
- }
- else {
- failrate[i] = failNumber[i] / (failNumber[i] + passNumber[i]) * 100;
- }
- }
- stackeverynum[0] = 0;
- for (i = 1; i < output.length ; i++) {
- stackeverynum[i] = passNumber[i - 1] - passNumber[i] - failNumber[i];
- stacknum = stackeverynum[i] + stacknum;
- }
- for(i=1;i<5;i++) {
- secondtime_load_spots_data();
- }
- showChart();
- setInterval(function(){
- get_data("fcWorkRaw/allSpots?flowId=" + thisPageFlow, realtime_success);
- },1000);
- document.getElementById("test1").innerHTML = passnum;
- document.getElementById("test2").innerHTML = failnum;
- document.getElementById("test3").innerHTML = Math.floor(passnum/(passnum+failnum)*100)/100+'%';
- document.getElementById("test4").innerHTML = stacknum;
- }
- function second_success(obj, sta) {
- var history = first_parse(this, obj);
- var i, j;
- for (i = 0; i < history.length; i++) {
- if (history[i].flowId == thisPageFlow) {
- hispass[t] = history[t].flowPass;
- hisfail[t] = history[t].flowFail;
- hisstack[t] = 0;
- if (hispass[t] + hisfail[t] == 0) {
- hisrate[t] = 0;
- }
- else {
- hisrate[t] = hisfail[i] / (hispass[i] + hisfail[i]) * 100;
- }
- t++;
- }
- }
- }
- function realtime_success(obj, sta) {
- var output = first_parse(this, obj);
- var i, j;
- for (i = 0; i < output.length ; i++) {
- passNumber[i] = output[i].passNum;
- }
- for (i = 0; i < output.length ; i++) {
- failNumber[i] = output[i].failNum;
- }
- for (i = 0; i < output.length ; i++) {
- if (failNumber[i] + passNumber[i] == 0) {
- failrate[i] = 0;
- }
- else {
- failrate[i] = failNumber[i] / (failNumber[i] + passNumber[i]) * 100;
- }
- }
- stackeverynum[0] = 0;
- for (i = 1; i < output.length ; i++) {
- stackeverynum[i] = passNumber[i - 1] - passNumber[i] - failNumber[i];
- stacknum = stackeverynum[i] + stacknum;
- }
- updateChart();
- document.getElementById("test1").innerHTML = passnum;
- document.getElementById("test2").innerHTML = failnum;
- document.getElementById("test3").innerHTML = Math.floor(passnum/(passnum+failnum)*100)/100+'%';
- document.getElementById("test4").innerHTML = stacknum;
- }
- 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=" + thisPageFlow, on_load_success_spots)
- }
- var namedata = [];
|