lazhang-data.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. function get_stop_scheudle1() {
  107. var out = confirm("真的要下班吗?");
  108. if(out == true){
  109. get_stop_scheudle();
  110. }
  111. else{
  112. }
  113. }
  114. function show_clear_panel(){
  115. $("#clearModal").modal('show');
  116. }
  117. var executed = false;
  118. var finished = true;
  119. var directCount = -1;
  120. function clear_one_data(){
  121. executed = false;
  122. directCount = -1;
  123. finished = true;
  124. var hand = $("#handInput").val();
  125. var hd = 0;
  126. if(hand.length > 0){
  127. hd = parseInt(hand);
  128. }
  129. get_data("endpoint/clearBoard?flowId="+flowId+"&handheldId=" + hd, clearSuccess);
  130. }
  131. function clearSuccess(obj, sta){
  132. console.warn("------- 手持设备清空 ----------");
  133. console.warn(this);
  134. send_alert("发送清空请求成功, 正在等待采集端进行处理...");
  135. finished = false;
  136. setTimeout(on_timeout_clear, 8000);
  137. setTimeout(recurseget,300);
  138. //var output = first_success(this, obj);
  139. }
  140. function recurseget(){
  141. if(finished) return;
  142. get_data("endpoint/heartbeat?flowId=" + flowId, onheart);
  143. setTimeout(recurseget,100);
  144. }
  145. function onheart(obj,sta){
  146. var ouy = {};
  147. if(typeof(obj) === "string"){
  148. ouy = JSON.parse(obj);
  149. }else{
  150. ouy = obj;
  151. }
  152. if(typeof(ouy) === "object"){
  153. if(ouy.ret === "10000"){
  154. //ok
  155. if(ouy.model == null || ouy.model === undefined){
  156. executed = true;
  157. finished = true;
  158. }else if(typeof(obj.model) === "object"){
  159. // 没有拿到,继续
  160. if(obj.model.list != null && obj.model.list.length > 0){
  161. var direct = obj.model.list[0];
  162. if(direct.eventType+"" !== "500"){
  163. // OK
  164. executed = true;
  165. finished = true;
  166. }else if(direct.arg2+"" !== ""+$("#handInput").val()){
  167. // OK
  168. executed = true;
  169. finished = true;
  170. }else{
  171. directCount = direct.counter;
  172. }
  173. }
  174. }
  175. }
  176. }
  177. }
  178. function on_timeout_clear(){
  179. finished = true;
  180. if(executed){
  181. // 执行成功
  182. }else{
  183. if(directCount >= 0){
  184. get_data("endpoint/ack?counter="+directCount,function(){console.log("撤销操作成功");console.log(this);});
  185. directCount = -1;
  186. send_alert("请求已经超时!请注意,采集端可能没有执行成功。即将撤销您的请求。");
  187. }else{
  188. send_alert("请求已经超时!请注意,采集端可能没有执行成功。");
  189. }
  190. }
  191. }
  192. function get_stop_scheudle() {
  193. get_data("fcWorkSchedule/stopSchedule?userId="+userId+"&scheduleId=" + scheduleId, stopSuccess);
  194. }
  195. function stopSuccess(obj, sta) {
  196. send_alert("下班操作成功! <a href='denglu.html'> 点击这里返回控制主页 </a>");
  197. }
  198. function add_success(obj, sta) {
  199. var history1 = first_parse(this, obj);
  200. var i, j;
  201. console.log(" history1 : ");
  202. console.log(history1);
  203. hispass[t] = 0;
  204. hisfail[t] = 0;
  205. hisstack[t] = 0;
  206. hisrate[t] = 0;
  207. var lengthnum = history1.length - 1;
  208. for (i = lengthnum; i < history1.length; i++) {
  209. hispass[t] = history1[i].passNum + hispass[t];
  210. hisfail[t] = history1[i].failNum + hisfail[t];
  211. hisstack[t] = history1[i].avgDue + hisstack[t];
  212. }
  213. if (hispass[t] + hisfail[t] == 0) {
  214. hisrate[t] = 0;
  215. }
  216. t++;
  217. }
  218. function realtime_success(obj, sta) {
  219. var output = first_parse(this, obj);
  220. //在这里排序 spo\
  221. if(showNetwork) console.log(" output : ");
  222. if(showNetwork) console.log(output);
  223. var i, j, k, z;
  224. failnum = 0;
  225. var x = 0;
  226. var worksum = [];
  227. var hhp = 0, hhf = 0, hhs = 0;
  228. if (output.list.length > 0) {
  229. sectorID[0] = getSectorId(output.list[0].spotId);
  230. passNumber[0] = 0;
  231. failNumber[0] = 0;
  232. stackeverynum[0] = 0;
  233. z = 0;
  234. for (i = 1; i < output.list.length; i++) {
  235. var thisUid = getSectorId(output.list[i].spotId);
  236. x = 0;
  237. for (j = 0; j < sectorID.length; j++) {
  238. if (sectorID[j] === thisUid) {
  239. x = 1;
  240. break;
  241. }
  242. }
  243. if (x === 0) {
  244. sectorID.push(thisUid);
  245. }
  246. }
  247. j = 0;
  248. for (k = 0; k < sectorID.length; k++) {
  249. var uid = sectorID[k];
  250. z = 0;
  251. passNumber[k] = 0;
  252. failNumber[k] = 0;
  253. stackeverynum[k] = 0;
  254. for (i = 0; i < output.list.length; i++) {
  255. if (uid === getSectorId(output.list[i].spotId)) {
  256. passNumber[k] = output.list[i].passNum + passNumber[k];
  257. failNumber[k] = output.list[i].failNum + failNumber[k];
  258. stackeverynum[k] = output.list[i].due + stackeverynum[k];
  259. z++;
  260. }
  261. }
  262. failrate[k] = get_factor(passNumber[k], failNumber[k]);
  263. }
  264. output.list.forEach(function (val, fid, arr) {
  265. hhp += val.passNum;
  266. hhf += val.failNum;
  267. hhs += val.due;
  268. })
  269. }
  270. schedulepass = hhp;
  271. schedulefail = hhf;
  272. if (output.list.length > 0) {
  273. schedulestack = hhs / output.list.length;
  274. } else {
  275. schedulestack = 0;
  276. }
  277. update_all_history();
  278. updateChart();
  279. }