lazhang-data.js 8.7 KB

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