Преглед на файлове

Change stuff and realtime JS made

Guichuan Yu преди 6 години
родител
ревизия
581aa815b8
променени са 4 файла, в които са добавени 190 реда и са изтрити 18 реда
  1. 140 7
      js/common.js
  2. 10 2
      js/lazhang-data.js
  3. 4 0
      js/lazhang-display.js
  4. 36 9
      lazhang.html

+ 140 - 7
js/common.js

@@ -1,7 +1,13 @@
 function load_table_red_rank() {
-    get_data("fcBiWorkerDaily/get?type=0&limit=3", on_red_rank_success);
+    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=0&limit=3", on_black_rank_success1);
 
+}
 function load_table_black_rank() {
     get_data("fcBiWorkerDaily/get?type=4&limit=3", on_black_rank_success);
 
@@ -10,6 +16,8 @@ function load_table_black_rank() {
 
 var goodColor = [];
 var badColor = [];
+var goodColor1 = [];
+var badColor1 = [];
 var userIDs = [];
 var schedulepass = 0, schedulefail = 0, schedulestack = 0;
 var todayotherpass = 0, todayotherfail = 0, todayotherstack = 0;
@@ -112,6 +120,28 @@ function on_red_rank_success(obj, sta) {
     }
 
 }
+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);
@@ -137,6 +167,30 @@ function on_black_rank_success(obj, sta) {
 
 
 }
+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"){
@@ -169,7 +223,7 @@ function getSpotHtml1(htmlbody, i) {
         htmlbody += `<tr>
                     <td> - </td>
                     <td> - </td>
-                    <td> - </td>
+                    
                 </tr>`;
         htmlbody += "</tr>";
         return htmlbody;
@@ -178,7 +232,27 @@ function getSpotHtml1(htmlbody, i) {
     htmlbody += `<tr style="background-color: ${goodColor[i]}">
                     <td>${goodid[i]}</td>
                     <td>${goodpass[i]}</td>
-                    <td>${goodfailrate[i] + '%'}</td>
+                    
+                </tr>`;
+    htmlbody += "</tr>";
+    return htmlbody;
+}
+
+function getSpotHtml3(htmlbody, i) {
+    if(typeof goodid1[i] === "undefined"){
+        htmlbody += "<tr>";
+        htmlbody += `<tr>
+                    <td> - </td>
+                    <td> - </td>
+                    
+                </tr>`;
+        htmlbody += "</tr>";
+        return htmlbody;
+    }
+    htmlbody += "<tr>";
+    htmlbody += `<tr style="background-color: ${goodColor1[i]}">
+                    <td>${goodid1[i]}</td>
+                    <td>${goodfailrate1[i] + '%'}</td>
                 </tr>`;
     htmlbody += "</tr>";
     return htmlbody;
@@ -190,7 +264,7 @@ function getSpotHtml2(htmlbody, i) {
         htmlbody += `<tr>
                     <td> - </td>
                     <td> - </td>
-                    <td> - </td>
+                    
                 </tr>`;
         htmlbody += "</tr>";
         return htmlbody;
@@ -200,19 +274,46 @@ function getSpotHtml2(htmlbody, i) {
         htmlbody += `<tr style="background-color: ${badColor[i]}">
                     <td>${badid[i]}</td>
                     <td>${badpass[i]}</td>
-                    <td>${badfailrate[i] + '%'}</td>
+                    
                 </tr>`;
     }else {
         htmlbody += `<tr style="background-color: ${badColor[i]}">
                     <td>${badid[i]}</td>
                     <td>${badpass[i]}</td>
-                    <td>${badfailrate[i] + '%'}</td>
+                    
+                </tr>`;
+    }
+    htmlbody += "</tr>";
+    return htmlbody;
+}
+function getSpotHtml4(htmlbody, i) {
+    if(typeof badid1[i] === "undefined"){
+        htmlbody += "<tr>";
+        htmlbody += `<tr>
+                    <td> - </td>
+                    <td> - </td>
+                    
+                </tr>`;
+        htmlbody += "</tr>";
+        return htmlbody;
+    }
+    htmlbody += "<tr>";
+    if(typeof badColor1[i] === "undefined"){
+        htmlbody += `<tr style="background-color: ${badColor1[i]}">
+                    <td>${badid1[i]}</td>
+                    
+                    <td>${badfailrate1[i] + '%'}</td>
+                </tr>`;
+    }else {
+        htmlbody += `<tr style="background-color: ${badColor1[i]}">
+                    <td>${badid1[i]}</td>
+                    
+                    <td>${badfailrate1[i] + '%'}</td>
                 </tr>`;
     }
     htmlbody += "</tr>";
     return htmlbody;
 }
-
 
 var lastTimeRank1 = "";
 var lastTimeRank2 = "";
@@ -250,6 +351,22 @@ function showEachSpot1() {
     }
     //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(lastTimeRank2 !== htmlbody){
+        $("#rank-four").html(htmlbody);
+        lastTimeRank2 = htmlbody;
+    }
+    //console.log(htmlbody);
+}
 
 function showEachSpot2() {
     var htmlbody = "", one_person = "";
@@ -262,6 +379,22 @@ function showEachSpot2() {
         htmlbody = getSpotHtml2(htmlbody, i);
     }
     if(lastTimeRank3 !== htmlbody){
+        $("#rank-five").html(htmlbody);
+        lastTimeRank3 = 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(lastTimeRank3 !== htmlbody){
         $("#rank-three").html(htmlbody);
         lastTimeRank3 = htmlbody;
     }

+ 10 - 2
js/lazhang-data.js

@@ -11,9 +11,15 @@ 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 = [];
 var n = 0;
 var sectorID = [];
 var namedata = [];
@@ -103,7 +109,10 @@ 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 load_flows_history_data(nnm) {
@@ -148,8 +157,7 @@ function add_success(obj, sta) {
         hispass[t] = history1[i].passNum + hispass[t];
         hisfail[t] = history1[i].failNum + hisfail[t];
         hisstack[t] = history1[i].avgDue + hisstack[t];
-        hisrate[t] = history1[i].failRate;
-        hisrate[t] = hisrate[t] / 100;
+
     }
 
     if (hispass[t] + hisfail[t] == 0) {

+ 4 - 0
js/lazhang-display.js

@@ -58,6 +58,8 @@ function showChart() {
     showEachSpot();
     showEachSpot1();
     showEachSpot2();
+    showEachSpot3();
+    showEachSpot4();
 
     failratemax = Math.max(failratemax, 5);
     stackmax = Math.max(stackmax, 5);
@@ -230,6 +232,8 @@ function updateChart() {
     showEachSpot();
     showEachSpot1();
     showEachSpot2();
+    showEachSpot3();
+    showEachSpot4();
 
     var secNames = [];
 

+ 36 - 9
lazhang.html

@@ -90,7 +90,7 @@
 <nav class="navbar" style="background-color: red">
     <div class="container-fluid">
         <div class="navbar-header">
-            <a class="navbar-brand" href="index.html">工厂产能监控系统</a>
+            <a class="navbar-brand" href="#" onclick="location.href='denglu.html'">工厂产能监控系统</a>
         </div>
         <div style="color:#fff" class="text-center"><img src="images/logo.jpg" style="width: 10%;"> 深圳市度彼电子有限公司——激光厂产线1</div>
 
@@ -123,36 +123,63 @@
         <div class="col-md-7 text-white">
             <div class="text-center text-lg">本厂今日生产能手榜</div>
             <div class="row">
-                <div class="col-md-6">
+                <div class="col-6 text-center">红榜</div>
+                <div class="col-6 text-center">黑榜</div>
+            </div>
+            <div class="row">
+                <div class="col-md-3">
                     <table class="table table-bordered text-center table-striped">
                         <thead>
                         <tr>
-                            <th scope="col" colspan="3">红榜</th>
+                            <th>人员</th>
+                            <th>良品数</th>
 
                         </tr>
+                        </thead>
+                        <tbody id="rank-two">
+                        </tbody>
+
+                    </table>
+                </div>
+                <div class="col-md-3">
+                    <table class="table table-bordered text-center table-striped">
+                        <thead>
                         <tr>
                             <th>人员</th>
-                            <th>良品数</th>
                             <th>不良率</th>
+
                         </tr>
                         </thead>
-                        <tbody id="rank-two">
+                        <tbody id="rank-four">
                         </tbody>
                     </table>
                 </div>
-                <div class="col-md-6">
+                <div class="col-md-3">
                     <table class="table table-bordered text-center table-striped">
                         <thead>
                         <tr>
-                            <th scope="col" colspan="3">黑榜</th>
+                            <th>人员</th>
+                            <th>良品数</th>
+
+                        </tr>
+                        </thead>
+                        <tbody id="rank-three">
+                        </tbody>
+                    </table>
+                </div>
+                <div class="col-md-3">
+                    <table class="table table-bordered text-center table-striped">
+                        <thead>
+                        <tr>
+
                         </tr>
                         <tr>
                             <th>人员</th>
-                            <th>良品数</th>
+
                             <th>不良率</th>
                         </tr>
                         </thead>
-                        <tbody id="rank-three">
+                        <tbody id="rank-five">
                         </tbody>
                     </table>
                 </div>