Jason(Fruit Of Eden) 6 years ago
parent
commit
07d2da3af7
3 changed files with 33 additions and 36 deletions
  1. 5 3
      js/basic.js
  2. 19 26
      js/dapingmu-display.js
  3. 9 7
      js/dapingmu.js

+ 5 - 3
js/basic.js

@@ -1,4 +1,4 @@
-let Queue = {IS_LOADED : false, nowuse : 0, SVR_URL:"/server/", groupsCount : 0, groups:[], shouldStop : false, backup:["http://localhost:8803/server/","/server/","http://172.30.84.3:8803/server/","https://1.niimei.com/server/"] ,list:[]};
+let Queue = {IS_LOADED : false, nowuse : 0, SVR_URL:"http://localhost:8803/server/", groupsCount : 0, groups:[], shouldStop : false, backup:["http://localhost:8803/server/","/server/","http://172.30.84.3:8803/server/","https://1.niimei.com/server/"] ,list:[]};
 let Users = {list : []};
 function get_server_url() {
     let output = $.ajax({url: Queue.SVR_URL + "/fcWorker/list?userId=1", timeout:1000 }).fail(on_check_fail).done(function(){
@@ -10,15 +10,17 @@ function get_server_url() {
 }
 
 function on_check_fail(){
-    if(Queue.nowuse === Queue.backup.length){
+    if(Queue.nowuse === Queue.backup.length - 1){
+        console.warn("Backup Failed : " + Queue.backup[Queue.nowuse]);
+        console.warn(this);
         var out = "";
         Queue.backup.forEach(function(val,index,arr){
             out += val + "\n";
         });
         send_alert("抱歉, 服务器连接失败! \n 请确认 " + out + "其中之一可用");
     }else{
-        Queue.SVR_URL = Queue.backup[Queue.nowuse];
         Queue.nowuse ++;
+        Queue.SVR_URL = Queue.backup[Queue.nowuse];
         $.ajax({url: Queue.SVR_URL + "/fcWorker/list?userId=1", timeout:1000 }).fail(on_check_fail).done(function(){
             Queue.IS_LOADED = true;
             console.warn("Using SERVER : ");

+ 19 - 26
js/dapingmu-display.js

@@ -57,19 +57,13 @@ function showChart() {
     stackAndFailChart = Highcharts.chart('graph-1', {
         chart: {
             zoomType: 'xy',
-            height: (4 / 16 * 100) + '%' // 16:9 ratio
-        },
-        title: {
-            text: '各产线今日产能'
-        },
-        credits: {
-            enabled: false // 禁用版权信息
-        },
-        exporting: {
-            enabled: false
+            //height: (4 / 16 * 100) + '%' // 16:9 ratio
         },
+        title: {text: '各产线今日产能'},
+        credits: {enabled: false},
+        exporting: {enabled: false},
         xAxis: [uaxv],
-        yAxis: [{ // Primary yAxis
+        yAxis: [{
             labels: {
                 format: '{value}',
                 style: {
@@ -86,11 +80,8 @@ function showChart() {
                     fontSize: '1em'
                 }
             }
-        },
-        ],
-        tooltip: {
-            shared: true
-        },
+        },],
+        tooltip: {shared: true},
         legend: {
             layout: 'vertical',
             align: 'right',
@@ -115,19 +106,22 @@ function showChart() {
                 name: '堆积数',
                 type: 'column',
                 data: stackdata,
-
-            },]
+            }]
     });
     FailChart = Highcharts.chart('graph-2', {
         chart: {
-            height: (4 / 16 * 100) + '%' // 16:9 ratio
-        }, title: {
-            text: '各产线今日不良率'
-        }, credits: {
+            //height: (4 / 16 * 100) + '%' // 16:9 ratio
+        },
+        title: {
+            text: '不良率'
+        },
+        credits: {
             enabled: false // 禁用版权信息
-        }, exporting: {
+        },
+        exporting: {
             enabled: false
-        }, xAxis: [uaxv],
+        },
+        xAxis: [uaxv],
         yAxis: [{ // Secondary yAxis
             title: {
                 text: '不良率',
@@ -137,7 +131,7 @@ function showChart() {
                 }
             },
             min: 0,
-            max: 1.5 * ratemax,
+            max: 1.5 * failmax,
             labels: {
                 formatter: function () {
                     return Math.floor(this.value) + "%";
@@ -164,7 +158,6 @@ function showChart() {
         series: [{
             name: '不良率',
             type: 'spline',
-
             data: ratedata,
             color: 'red',
             tooltip: {

+ 9 - 7
js/dapingmu.js

@@ -32,6 +32,10 @@ function first_success(obj, sta) {
     let worksum = [];
     z = 0;
 
+    if(typeof output.length =="number"){
+        output.list = output;
+    }
+
     if (output.list == undefined || output.list.length == 0) {
         send_alert("没有数据");
     }
@@ -70,10 +74,8 @@ function first_success(obj, sta) {
             }
             if (failNumber[k] + passNumber[k] == 0) {
                 failrate[k] = 0;
-            }
-            else {
-                failrate[k] = failNumber[k] / (failNumber[k] + passNumber[k]) * 100;
-
+            } else {
+                failrate[k] = Math.floor(failNumber[k] / (failNumber[k] + passNumber[k]) * 10000) / 100;
             }
         }
     }
@@ -179,7 +181,7 @@ function on_red_rank_success(obj, sta) {
     for (i = 0; i < redchart.list.length; i++) {
         goodid[i] = getUserName(redchart.list[i].workerId);
         goodpass[i] = redchart.list[i].passNum;
-        goodfailrate[i] = redchart.list[i].failRate / 100;
+        goodfailrate[i] = Math.floor(100 * redchart.list[i].failRate) / 100;
     }
 
 
@@ -195,7 +197,7 @@ function on_black_rank_success(obj, sta) {
     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;
+        badfailrate[i] = Math.floor(100* blackchart.list[i].failRate )/ 100;
     }
 
 
@@ -277,7 +279,7 @@ function realtime_success(obj, sta) {
             if (failNumber[k] + passNumber[k] == 0) {
                 failrate[k] = 0;
             } else {
-                failrate[k] = failNumber[k] / (failNumber[k] + passNumber[k]) * 100;
+                failrate[k] = Math.floor(failNumber[k] / (failNumber[k] + passNumber[k]) * 10000) / 100
             }
             /*stackeverynum[k]=stackeverynum[k]/z;*/
             ///