lazhang-data.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. if(showNetwork) console.log(" factory : ");
  84. if(showNetwork) console.log(factory);
  85. name1=factory.list[0].flowPlace;
  86. name2=factory.list[0].flowName;
  87. document.getElementById("flow_title").innerHTML = name1+"-"+name2 + " 度彼科技";
  88. document.title = name1 + " " + name2 + " | 流水线管理 | 度彼科技";
  89. }
  90. function request_data_realtime() {
  91. get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, realtime_success);
  92. //load_flows_history_realtime_data();
  93. load_table_red_rank();
  94. load_table_red_rank1();
  95. load_table_black_rank();
  96. load_table_black_rank1();
  97. }
  98. function load_flows_history_data(nnm) {
  99. // 请注意type必须在结尾
  100. get_data("fcBiFlowDaily/list?scheduleId="+scheduleId+ "&flowId=" + flowId+"&type=" + nnm , history_success);
  101. }
  102. function load_flows_history_realtime_data() {
  103. // 请注意type必须在结尾
  104. get_data("fcBiFlowDaily/list?flowId=" + flowId +"&type=1", history_success);
  105. }
  106. var executed = false;
  107. var finished = true;
  108. var directCount = -1;
  109. function recurseget(){
  110. if(finished) return;
  111. get_data("endpoint/heartbeat?flowId=" + flowId, onheart);
  112. setTimeout(recurseget,100);
  113. }
  114. function onheart(obj,sta){
  115. var ouy = {};
  116. if(typeof(obj) === "string"){
  117. ouy = JSON.parse(obj);
  118. }else{
  119. ouy = obj;
  120. }
  121. if(typeof(ouy) === "object"){
  122. if(ouy.ret === "10000"){
  123. //ok
  124. if(ouy.model == null || ouy.model === undefined){
  125. executed = true;
  126. finished = true;
  127. }else if(typeof(obj.model) === "object"){
  128. // 没有拿到,继续
  129. if(obj.model.list != null && obj.model.list.length > 0){
  130. var direct = obj.model.list[0];
  131. if(direct.eventType+"" !== "500"){
  132. // OK
  133. executed = true;
  134. finished = true;
  135. }else if(direct.arg2+"" !== ""+$("#handInput").val()){
  136. // OK
  137. executed = true;
  138. finished = true;
  139. }else{
  140. directCount = direct.counter;
  141. }
  142. }
  143. }
  144. }
  145. }
  146. }
  147. function on_timeout_clear(){
  148. finished = true;
  149. if(executed){
  150. // 执行成功
  151. }else{
  152. if(directCount >= 0){
  153. get_data("endpoint/ack?counter="+directCount,function(){console.log("撤销操作成功");console.log(this);});
  154. directCount = -1;
  155. send_alert("请求已经超时!请注意,采集端可能没有执行成功。即将撤销您的请求。");
  156. }else{
  157. send_alert("请求已经超时!请注意,采集端可能没有执行成功。");
  158. }
  159. }
  160. }
  161. function get_stop_scheudle() {
  162. get_data("fcWorkSchedule/stopSchedule?userId="+userId+"&scheduleId=" + scheduleId, stopSuccess);
  163. }
  164. function stopSuccess(obj, sta) {
  165. send_alert("下班操作成功! <a href='denglu.html'> 点击这里返回控制主页 </a>");
  166. }
  167. function add_success(obj, sta) {
  168. var history1 = first_parse(this, obj);
  169. var i, j;
  170. console.log(" history1 : ");
  171. console.log(history1);
  172. hispass[t] = 0;
  173. hisfail[t] = 0;
  174. hisstack[t] = 0;
  175. hisrate[t] = 0;
  176. var lengthnum = history1.length - 1;
  177. for (i = lengthnum; i < history1.length; i++) {
  178. hispass[t] = history1[i].passNum + hispass[t];
  179. hisfail[t] = history1[i].failNum + hisfail[t];
  180. hisstack[t] = history1[i].avgDue + hisstack[t];
  181. }
  182. if (hispass[t] + hisfail[t] == 0) {
  183. hisrate[t] = 0;
  184. }
  185. t++;
  186. }
  187. function realtime_success(obj, sta) {
  188. var output = first_parse(this, obj);
  189. //在这里排序 spo\
  190. if(showNetwork) console.log(" output : ");
  191. if(showNetwork) console.log(output);
  192. var i, j, k, z;
  193. failnum = 0;
  194. var x = 0;
  195. var worksum = [];
  196. var hhp = 0, hhf = 0, hhs = 0;
  197. if (output.list.length > 0) {
  198. sectorID[0] = getSectorId(output.list[0].spotId);
  199. passNumber[0] = 0;
  200. failNumber[0] = 0;
  201. stackeverynum[0] = 0;
  202. z = 0;
  203. for (i = 1; i < output.list.length; i++) {
  204. var thisUid = getSectorId(output.list[i].spotId);
  205. x = 0;
  206. for (j = 0; j < sectorID.length; j++) {
  207. if (sectorID[j] === thisUid) {
  208. x = 1;
  209. break;
  210. }
  211. }
  212. if (x === 0) {
  213. sectorID.push(thisUid);
  214. }
  215. }
  216. j = 0;
  217. for (k = 0; k < sectorID.length; k++) {
  218. var uid = sectorID[k];
  219. z = 0;
  220. passNumber[k] = 0;
  221. failNumber[k] = 0;
  222. stackeverynum[k] = 0;
  223. for (i = 0; i < output.list.length; i++) {
  224. if (uid === getSectorId(output.list[i].spotId)) {
  225. passNumber[k] = output.list[i].passNum + passNumber[k];
  226. failNumber[k] = output.list[i].failNum + failNumber[k];
  227. stackeverynum[k] = output.list[i].due + stackeverynum[k];
  228. z++;
  229. }
  230. }
  231. failrate[k] = get_factor(passNumber[k], failNumber[k]);
  232. }
  233. output.list.forEach(function (val, fid, arr) {
  234. hhp += val.passNum;
  235. hhf += val.failNum;
  236. hhs += val.due;
  237. })
  238. }
  239. schedulepass = hhp;
  240. schedulefail = hhf;
  241. if (output.list.length > 0) {
  242. schedulestack = hhs / output.list.length;
  243. } else {
  244. schedulestack = 0;
  245. }
  246. update_all_history();
  247. updateChart();
  248. }