pending.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. this.HistoryData = (function (){
  2. this.update = function () {
  3. // 请注意type必须在结尾
  4. get_data("fcBiFlowDaily/list?flowId=" + flowId + "&type=1", history_success);
  5. };
  6. this.loadHistroyOnce = function (nnm) {
  7. // 请注意type必须在结尾
  8. get_data(HistoryBaseURL + "&type=" + nnm, history_success);
  9. };
  10. this.loadMultiHistory = function(){
  11. for (i = 1; i <= 3; i++) loadHistroyOnce(i);
  12. };
  13. this.add_success = function(obj, sta) {
  14. var history1 = first_parse(this, obj);
  15. var i, j;
  16. console.log(" history1 : ");
  17. console.log(history1);
  18. hispass[t] = 0;
  19. hisfail[t] = 0;
  20. hisstack[t] = 0;
  21. hisrate[t] = 0;
  22. var lengthnum = history1.length - 1;
  23. for (i = lengthnum; i < history1.length; i++) {
  24. hispass[t] = history1[i].passNum + hispass[t];
  25. hisfail[t] = history1[i].failNum + hisfail[t];
  26. hisstack[t] = history1[i].avgDue + hisstack[t];
  27. }
  28. if (hispass[t] + hisfail[t] == 0) {
  29. hisrate[t] = 0;
  30. }
  31. t++;
  32. }
  33. })();
  34. function realtime_success(obj, sta) {
  35. var output = first_parse(this, obj);
  36. //在这里排序 spo\
  37. console.log(" output : ");
  38. console.log(output);
  39. var i, j, k, z;
  40. failnum = 0;
  41. var x = 0;
  42. var worksum = [];
  43. var hhp = 0, hhf = 0, hhs = 0;
  44. if (output.list.length > 0) {
  45. sectorID[0] = getSectorId(output.list[0].spotId);
  46. passNumber[0] = 0;
  47. failNumber[0] = 0;
  48. stackeverynum[0] = 0;
  49. z = 0;
  50. for (i = 1; i < output.list.length; i++) {
  51. var thisUid = getSectorId(output.list[i].spotId);
  52. x = 0;
  53. for (j = 0; j < sectorID.length; j++) {
  54. if (sectorID[j] === thisUid) {
  55. x = 1;
  56. break;
  57. }
  58. }
  59. if (x === 0) {
  60. sectorID.push(thisUid);
  61. }
  62. }
  63. j = 0;
  64. for (k = 0; k < sectorID.length; k++) {
  65. var uid = sectorID[k];
  66. z = 0;
  67. passNumber[k] = 0;
  68. failNumber[k] = 0;
  69. stackeverynum[k] = 0;
  70. for (i = 0; i < output.list.length; i++) {
  71. if (uid === getSectorId(output.list[i].spotId)) {
  72. passNumber[k] = output.list[i].passNum + passNumber[k];
  73. failNumber[k] = output.list[i].failNum + failNumber[k];
  74. stackeverynum[k] = output.list[i].due + stackeverynum[k];
  75. z++;
  76. }
  77. }
  78. failrate[k] = get_factor(passNumber[k], failNumber[k]);
  79. }
  80. output.list.forEach(function (val, fid, arr) {
  81. hhp += val.passNum;
  82. hhf += val.failNum;
  83. hhs += val.due;
  84. })
  85. }
  86. schedulepass = hhp;
  87. schedulefail = hhf;
  88. if (output.list.length > 0) {
  89. schedulestack = hhs / output.list.length;
  90. } else {
  91. schedulestack = 0;
  92. }
  93. update_all_history();
  94. updateChart();
  95. };
  96. var RealTimeCharts = (function() {
  97. var timeday = ["今日", "昨日", "本周", "本月"];
  98. if (flowId == null || scheduleId == null) {
  99. send_alert("出错啦!请检查参数完整性");
  100. }
  101. function page_document_load() {
  102. get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, onFirstTimeSuccess);
  103. }
  104. var compAxis = {
  105. categories: namedata,
  106. crosshair: true,
  107. title: {
  108. text: '工位',
  109. style: {
  110. fontSize: '1.5em'
  111. }
  112. },
  113. labels: {
  114. style: {
  115. fontSize: '1.5em'
  116. }
  117. }
  118. };
  119. var getSeperateArrays = function (sectorLoadData){
  120. this.data = [];
  121. this.len = sectorLoadData.len();
  122. this.stackmax = 0;
  123. this.failmax = 0;
  124. this.passmax = 0;
  125. this.failratemax = 0;
  126. this.ratedata = [];
  127. this.passdata = [];
  128. this.faildata = [];
  129. for (i = 0; i < len; i++) {
  130. var one = sectorLoadData.getRaw(i);
  131. if (stackmax < one[i].getVal("stack")) {
  132. stackmax = one[i].getVal("stack")
  133. }
  134. if (failmax < one[i].getVal("failNum")) {
  135. failmax = one[i].getVal("failNum");
  136. }
  137. if (failratemax < one[i].getVal("failRate")) {
  138. failratemax = one[i].getVal("failRate");
  139. }
  140. if (passmax < one[i].getVal("passNum")) {
  141. passmax = one[i].getVal("passNum");
  142. }
  143. data.push(one[i].getVal("stack"));
  144. this.ratedata.push(Math.floor(one[i].getVal("failRate")));
  145. this.passdata.push(one[i].getVal("passNum"));
  146. this.faildata.push(one[i].getVal("failNum"));
  147. }
  148. failratemax = Math.max(failratemax, 5);
  149. stackmax = Math.max(stackmax, 5);
  150. failmax = Math.max(failmax, 5);
  151. passmax = Math.max(passmax, failmax, stackmax);
  152. };
  153. this.dataArrays = null;
  154. function showChart(sectorLoadData) {
  155. dataArrays = new getSeperateArrays(sectorLoadData);
  156. stackAndFailChart = Highcharts.chart('graph-1', {
  157. chart: {
  158. zoomType: 'xy',
  159. //height: (4 / 16 * 100) + '%' // 16:9 ratio
  160. },
  161. title: {text: '各工位今日产能'},
  162. credits: {enabled: false},
  163. exporting: {enabled: false},
  164. xAxis: [compAxis],
  165. yAxis: [{
  166. labels: {
  167. format: '{value}',
  168. style: {
  169. color: "#ffffff",
  170. fontSize: '1.5em'
  171. }
  172. },
  173. min: 0,
  174. max: passmax * 1.5,
  175. title: {
  176. text: '数量',
  177. style: {
  178. color: '#ffffff',
  179. fontSize: '1em'
  180. },
  181. rotation: 270,
  182. }
  183. },],
  184. tooltip: {shared: true},
  185. legend: {
  186. layout: 'vertical',
  187. align: 'right',
  188. x: 0,
  189. verticalAlign: 'top',
  190. y: 0,
  191. floating: true,
  192. backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
  193. },
  194. series: [{
  195. name: '良品数',
  196. type: 'column',
  197. data: passdata,
  198. }, {
  199. name: '不良品数',
  200. type: 'column',
  201. data: faildata,
  202. },
  203. {
  204. name: '堆积数',
  205. type: 'column',
  206. data: data,
  207. }]
  208. });
  209. FailChart = Highcharts.chart('graph-2', {
  210. chart: {
  211. //height: (4 / 16 * 100) + '%' // 16:9 ratio
  212. },
  213. title: {
  214. text: '各工位今日不良率'
  215. },
  216. credits: {
  217. enabled: false // 禁用版权信息
  218. },
  219. exporting: {
  220. enabled: false
  221. },
  222. xAxis: [compAxis],
  223. yAxis: [{ // Secondary yAxis
  224. title: {
  225. text: '不良率',
  226. style: {
  227. color: '#ffffff',
  228. fontSize: '1em'
  229. }
  230. },
  231. min: 0,
  232. max: 1.5 * failratemax,
  233. labels: {
  234. formatter: function () {
  235. return Math.floor(this.value) + "%";
  236. },
  237. style: {
  238. color: '#ffffff',
  239. fontSize: '20px'
  240. },
  241. rotation: 270,
  242. },
  243. }],
  244. tooltip: {
  245. shared: true
  246. },
  247. legend: {
  248. layout: 'vertical',
  249. align: 'right',
  250. x: 0,
  251. verticalAlign: 'top',
  252. y: 0,
  253. floating: true,
  254. backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
  255. },
  256. series: [{
  257. name: '不良率',
  258. type: 'spline',
  259. data: ratedata,
  260. color: 'red',
  261. tooltip: {
  262. valueSuffix: '%'
  263. }
  264. }]
  265. });
  266. }
  267. function updateChart(sectorLoad) {
  268. var data = [];
  269. var ratedata = [];
  270. var stackmax = 0;
  271. var failmax = 0;
  272. var passdata = [];
  273. var faildata = [];
  274. var passmax = 0;
  275. var failratemax = 0;
  276. for (i = 0; i < passNumber.length; i++) {
  277. if (stackmax < stackeverynum[i]) {
  278. stackmax = stackeverynum[i];
  279. }
  280. if (failmax < failNumber[i]) {
  281. failmax = failNumber[i];
  282. }
  283. if (failratemax < failrate[i]) {
  284. failratemax = failrate[i];
  285. }
  286. if (passmax < passNumber[i]) {
  287. passmax = passNumber[i];
  288. }
  289. data.push(stackeverynum[i]);
  290. ratedata.push(Math.floor(failrate[i]));
  291. passdata.push(passNumber[i]);
  292. faildata.push(failNumber[i]);
  293. }
  294. failratemax = Math.max(failratemax, 5);
  295. stackmax = Math.max(stackmax, 5);
  296. failmax = Math.max(failmax, 5);
  297. passmax = Math.max(passmax, failmax, stackmax);
  298. // https://api.hcharts.cn/highcharts#Series.addPoint;
  299. stackAndFailChart.series[0].setData(passdata);
  300. stackAndFailChart.series[1].setData(faildata);
  301. stackAndFailChart.series[2].setData(data);
  302. FailChart.series[0].setData(ratedata);
  303. if (failratemax > FailChart.yAxis[0].getExtremes().max * 1.3 || failratemax < FailChart.yAxis[0].getExtremes().max * 0.5) {
  304. FailChart.yAxis[0].setExtremes(0, failratemax * 1.5);
  305. }
  306. if (passmax > stackAndFailChart.yAxis[0].getExtremes().max * 1.3 || passmax < stackAndFailChart.yAxis[0].getExtremes().max * 0.5) {
  307. stackAndFailChart.yAxis[0].setExtremes(0, passmax * 1.5);
  308. }
  309. showHistoryData();
  310. showRedRanking();
  311. showBlackRanking();
  312. var secNames = [];
  313. sectorID.forEach(function (val) {
  314. secNames.push(getSectorName(val));
  315. });
  316. if (JSON.stringify(secNames) !== lastTimeSecNames) {
  317. lastTimeSecNames = JSON.stringify(secNames);
  318. FailChart.xAxis[0].setCategories(secNames);
  319. stackAndFailChart.xAxis[0].setCategories(secNames);
  320. }
  321. }
  322. var lastTimeSecNames = "";
  323. var stackAndFailChart = null;
  324. var FailChart = null;
  325. })();
  326. function getHistoryTableBody(htmlbody, i) {
  327. if (typeof hispass[i] === "undefined") {
  328. htmlbody += "<tr>";
  329. htmlbody += `<tr>
  330. <td> - </td>
  331. <td> - </td>
  332. <td> - </td>
  333. <td> - </td>
  334. <td> - </td>
  335. </tr>`;
  336. htmlbody += "</tr>";
  337. return htmlbody;
  338. }
  339. htmlbody += "<tr>";
  340. htmlbody += `<tr>
  341. <td>${timeday[i]}</td>
  342. <td>${hispass[i]}</td>
  343. <td>${hisfail[i]}</td>
  344. <td>${hisstack[i]}</td>
  345. <td>${hisrate[i] + '%'}</td>
  346. </tr>`;
  347. htmlbody += "</tr>";
  348. return htmlbody;
  349. }
  350. var goodColor = [];
  351. var badColor = [];
  352. var goodColor1 = [];
  353. var badColor1 = [];
  354. var userIDs = [];
  355. var schedulepass = 0, schedulefail = 0, schedulestack = 0;
  356. var todayotherpass = 0, todayotherfail = 0, todayotherstack = 0;
  357. var lastTimeHistory = "";
  358. var histoires = [];
  359. var hispass = [];
  360. var hisfail = [];
  361. var hisstack = [];
  362. var hisrate = [];
  363. var goodpass = [];
  364. var goodid = [];
  365. var goodfailrate = [];
  366. var goodpass1 = [];
  367. var goodid1 = [];
  368. var goodfailrate1 = [];
  369. var badpass = [];
  370. var badid = [];
  371. var badfailrate = [];
  372. var badpass1 = [];
  373. var badid1 = [];
  374. var badfailrate1 = [];
  375. var todayotherpass, todayotherfail, todayotherstack;
  376. var orighisfail = [], orighispass = [], orighisstack = [];
  377. /*
  378. function isUserOfThisFlow(uid) {
  379. var isExist = false;
  380. userIDs.forEach(function (vals) {
  381. if (vals == uid) {
  382. isExist = true;
  383. }
  384. });
  385. return isExist;
  386. }
  387. var RedRank = (function() {
  388. this.fetchPos = 0;
  389. this.multipleData = [];
  390. this.loader = (function () {
  391. this.load = function(pos) {
  392. this.multipleData = new Array();
  393. for(let i = 0; i < 8; i++){
  394. this.multipleData[i] = new DataObjectService("fcBiWorkderDaily", AUTO & FAST, "?type="+i);
  395. }
  396. get_data(`fcBiWorkerDaily/get?type=${RedRank.fetchPos}`, RedRank.loader.onSuccess);
  397. };
  398. this.consecutiveLoad = function(){
  399. RedRank.fetchPos = (RedRank.fetchPos + 1) % 8;
  400. load(RedRank.fetchPos);
  401. };
  402. this.onSuccess = function(res, code){
  403. };
  404. })();
  405. })();
  406. function on_red_rank_success(obj, sta) {
  407. var redchart = first_parse(this, obj);
  408. var i, j;
  409. i = j = 0;
  410. console.log(" redchart : ");
  411. console.log(redchart);
  412. for (i = 0; i < redchart.list.length; i++) {
  413. goodid[i] = getUserName(redchart.list[i].workerId);
  414. goodpass[i] = redchart.list[i].passNum;
  415. if (redchart.list[i].passNum + redchart.list[i].failNum > 0) {
  416. goodfailrate[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
  417. } else {
  418. goodfailrate[i] = 0;
  419. }
  420. if (isUserOfThisFlow(redchart.list[i].workerId)) {
  421. goodColor[i] = 'red';
  422. } else {
  423. goodColor[i] = '';
  424. }
  425. }
  426. }
  427. function on_red_rank_success1(obj, sta) {
  428. var redchart = first_parse(this, obj);
  429. var i, j;
  430. i = j = 0;
  431. console.log(" redchart : ");
  432. console.log(redchart);
  433. for (i = 0; i < redchart.list.length; i++) {
  434. goodid1[i] = getUserName(redchart.list[i].workerId);
  435. goodpass1[i] = redchart.list[i].passNum;
  436. if (redchart.list[i].passNum + redchart.list[i].failNum > 0) {
  437. goodfailrate1[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
  438. } else {
  439. goodfailrate1[i] = 0;
  440. }
  441. if (isUserOfThisFlow(redchart.list[i].workerId)) {
  442. goodColor1[i] = 'red';
  443. } else {
  444. goodColor1[i] = '';
  445. }
  446. }
  447. }
  448. function on_black_rank_success(obj, sta) {
  449. var blackchart = first_parse(this, obj);
  450. var i, j;
  451. i = j = 0;
  452. console.log(" black chart : ");
  453. console.log(blackchart);
  454. for (i = 0; i < blackchart.list.length; i++) {
  455. badid[i] = getUserName(blackchart.list[i].workerId);
  456. badpass[i] = blackchart.list[i].passNum;
  457. //badfailrate[i] = blackchart.list[i].failRate / 100;
  458. if (blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
  459. badfailrate[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
  460. } else {
  461. badfailrate[i] = 0;
  462. }
  463. if (isUserOfThisFlow(blackchart.list[i].workerId)) {
  464. badColor[i] = 'green';
  465. } else {
  466. badColor[i] = '';
  467. }
  468. }
  469. }
  470. function on_black_rank_success1(obj, sta) {
  471. var blackchart = first_parse(this, obj);
  472. var i, j;
  473. i = j = 0;
  474. console.log(" black chart : ");
  475. console.log(blackchart);
  476. for (i = 0; i < blackchart.list.length; i++) {
  477. badid1[i] = getUserName(blackchart.list[i].workerId);
  478. badpass1[i] = blackchart.list[i].passNum;
  479. //badfailrate[i] = blackchart.list[i].failRate / 100;
  480. if (blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
  481. badfailrate1[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
  482. } else {
  483. badfailrate1[i] = 0;
  484. }
  485. if (isUserOfThisFlow(blackchart.list[i].workerId)) {
  486. badColor1[i] = 'green';
  487. } else {
  488. badColor1[i] = '';
  489. }
  490. }
  491. }*/