lazhang-data.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. var passNumber = [];
  2. var failNumber = [];
  3. var failrate = [];
  4. var stackeverynum = [];
  5. var failnum = 0;
  6. var num = 0;
  7. var n = 0;
  8. var sectorID = [];
  9. var namedata = [];
  10. var lazhang = {};
  11. var scheduleId = utils_get_param("scheduleId");
  12. var flowId = utils_get_param("flowId");
  13. var name1,name2;
  14. function first_success(obj, sta) {
  15. let output = first_parse(this, obj);
  16. let i, j, k, z;
  17. failnum = 0;
  18. let x = 0;
  19. let worksum = [];
  20. z = 0;
  21. if (output.list == undefined || output.list.length == 0) {
  22. send_alert("没有数据");
  23. }
  24. output.list.forEach(function(val,it,arr){
  25. var isExist = false;
  26. userIDs.forEach(function(vals){
  27. if(vals == val.userId){
  28. isExist = true;
  29. }
  30. });
  31. if(!isExist) userIDs.push(val.userId);
  32. });
  33. if (output.list.length > 0) {
  34. sectorID[0] = getSectorId(output.list[0].spotId);
  35. for (i = 1; i < output.list.length; i++) {
  36. var thisUid = getSectorId(output.list[i].spotId);
  37. x = 0;
  38. for (j = 0; j < sectorID.length; j++) {
  39. if (sectorID[j] === thisUid) {
  40. x = 1;
  41. break;
  42. }
  43. }
  44. if (x === 0) {
  45. sectorID.push(thisUid);
  46. }
  47. }
  48. j = 0;
  49. for (k = 0; k < sectorID.length; k++) {
  50. var uid = sectorID[k];
  51. z = 0;
  52. passNumber[k] = 0;
  53. failNumber[k] = 0;
  54. stackeverynum[k] = 0;
  55. for (i = 0; i < output.list.length; i++) {
  56. if (uid === getSectorId(output.list[i].spotId)) {
  57. passNumber[k] = output.list[i].passNum + passNumber[j];
  58. failNumber[k] = output.list[i].failNum + failNumber[j];
  59. stackeverynum[k] = output.list[i].due + stackeverynum[j];
  60. z++;
  61. }
  62. }
  63. if (failNumber[k] + passNumber[k] == 0) {
  64. failrate[k] = 0;
  65. }
  66. else {
  67. failrate[k] = failNumber[k] / (failNumber[k] + passNumber[k]) * 100;
  68. }
  69. /*stackeverynum[k]=stackeverynum[k]/z;*/
  70. ///
  71. }
  72. }
  73. get_data("fcFlow/list?flowId="+ flowId,name_Success);
  74. for (i = 1; i <= 3; i++) {
  75. load_flows_history_data(i);
  76. }
  77. showChart();
  78. lazhang.timer = setInterval(request_data_realtime, 1000);
  79. }
  80. function name_Success(obj, sta) {
  81. var factory = first_parse(this, obj);
  82. var i, j, t;
  83. console.log(" factory : ");
  84. console.log(factory);
  85. name1=factory.list.flowPlace;
  86. name2=factory.list.flowName;
  87. document.getElementById("test1").innerHTML = name1;
  88. }
  89. function request_data_realtime() {
  90. get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, realtime_success);
  91. //load_flows_history_realtime_data();
  92. load_table_red_rank();
  93. load_table_red_rank1();
  94. load_table_black_rank();
  95. load_table_black_rank1();
  96. }
  97. function load_flows_history_data(nnm) {
  98. // 请注意type必须在结尾
  99. get_data("fcBiFlowDaily/list?scheduleId="+scheduleId+ "&flowId=" + flowId+"&type=" + nnm , history_success);
  100. }
  101. function load_flows_history_realtime_data() {
  102. // 请注意type必须在结尾
  103. get_data("fcBiFlowDaily/list?flowId=" + flowId +"&type=1", history_success);
  104. }
  105. function get_stop_scheudle1() {
  106. var out = confirm("真的要下班吗?");
  107. if(out == true){
  108. get_stop_scheudle();
  109. }
  110. else{
  111. }
  112. }
  113. function get_stop_scheudle() {
  114. get_data("fcWorkSchedule/stopSchedule?scheduleId=" + scheduleId, stopSuccess);
  115. }
  116. function stopSuccess(obj, sta) {
  117. send_alert("下班操作成功! <a href='denglu.html'> 点击这里返回控制主页 </a>");
  118. }
  119. function add_success(obj, sta) {
  120. var history1 = first_parse(this, obj);
  121. var i, j;
  122. console.log(" history1 : ");
  123. console.log(history1);
  124. hispass[t] = 0;
  125. hisfail[t] = 0;
  126. hisstack[t] = 0;
  127. hisrate[t] = 0;
  128. var lengthnum = history1.length - 1;
  129. for (i = lengthnum; i < history1.length; i++) {
  130. hispass[t] = history1[i].passNum + hispass[t];
  131. hisfail[t] = history1[i].failNum + hisfail[t];
  132. hisstack[t] = history1[i].avgDue + hisstack[t];
  133. }
  134. if (hispass[t] + hisfail[t] == 0) {
  135. hisrate[t] = 0;
  136. }
  137. t++;
  138. }
  139. function realtime_success(obj, sta) {
  140. var output = first_parse(this, obj);
  141. //在这里排序 spo\
  142. console.log(" output : ");
  143. console.log(output);
  144. var i, j, k, z;
  145. failnum = 0;
  146. var x = 0;
  147. var worksum = [];
  148. var hhp = 0, hhf = 0, hhs = 0;
  149. if (output.list.length > 0) {
  150. sectorID[0] = getSectorId(output.list[0].spotId);
  151. passNumber[0] = 0;
  152. failNumber[0] = 0;
  153. stackeverynum[0] = 0;
  154. z = 0;
  155. for (i = 1; i < output.list.length; i++) {
  156. var thisUid = getSectorId(output.list[i].spotId);
  157. x = 0;
  158. for (j = 0; j < sectorID.length; j++) {
  159. if (sectorID[j] === thisUid) {
  160. x = 1;
  161. break;
  162. }
  163. }
  164. if (x === 0) {
  165. sectorID.push(thisUid);
  166. }
  167. }
  168. j = 0;
  169. for (k = 0; k < sectorID.length; k++) {
  170. var uid = sectorID[k];
  171. z = 0;
  172. passNumber[k] = 0;
  173. failNumber[k] = 0;
  174. stackeverynum[k] = 0;
  175. for (i = 0; i < output.list.length; i++) {
  176. if (uid === getSectorId(output.list[i].spotId)) {
  177. passNumber[k] = output.list[i].passNum + passNumber[k];
  178. failNumber[k] = output.list[i].failNum + failNumber[k];
  179. stackeverynum[k] = output.list[i].due + stackeverynum[k];
  180. z++;
  181. }
  182. }
  183. failrate[k] = get_factor(passNumber[k], failNumber[k]);
  184. }
  185. output.list.forEach(function (val, fid, arr) {
  186. hhp += val.passNum;
  187. hhf += val.failNum;
  188. hhs += val.due;
  189. })
  190. }
  191. schedulepass = hhp;
  192. schedulefail = hhf;
  193. if (output.list.length > 0) {
  194. schedulestack = hhs / output.list.length;
  195. } else {
  196. schedulestack = 0;
  197. }
  198. update_all_history();
  199. updateChart();
  200. }