common.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. function load_table_red_rank() {
  2. get_data("fcBiWorkerDaily/get?type=1&limit=3", on_red_rank_success);
  3. }
  4. function load_table_red_rank1() {
  5. get_data("fcBiWorkerDaily/get?type=2&limit=3", on_red_rank_success1);
  6. }
  7. function load_table_black_rank1() {
  8. get_data("fcBiWorkerDaily/get?type=3&limit=3", on_black_rank_success1);
  9. }
  10. function load_table_black_rank() {
  11. get_data("fcBiWorkerDaily/get?type=0&limit=3", on_black_rank_success);
  12. }
  13. var goodColor = [];
  14. var badColor = [];
  15. var goodColor1 = [];
  16. var badColor1 = [];
  17. var userIDs = [];
  18. var schedulepass = 0, schedulefail = 0, schedulestack = 0;
  19. var todayotherpass = 0, todayotherfail = 0, todayotherstack = 0;
  20. var lastTimeHistory = "";
  21. var histoires = [];
  22. var hispass = [];
  23. var hisfail = [];
  24. var hisstack = [];
  25. var hisrate = [];
  26. var goodpass = [];
  27. var goodid = [];
  28. var goodfailrate = [];
  29. var goodpass1 = [];
  30. var goodid1 = [];
  31. var goodfailrate1 = [];
  32. var badpass = [];
  33. var badid = [];
  34. var badfailrate = [];
  35. var badpass1 = [];
  36. var badid1 = [];
  37. var badfailrate1 = [];
  38. function history_success(obj, sta) {
  39. var histoire = first_parse(this, obj);
  40. var i, j, t;
  41. console.log(" histoire : ");
  42. console.log(histoire);
  43. if (this.url.indexOf("type=1") >= 0) {
  44. t = 1;
  45. } else if (this.url.indexOf("type=2") >= 0) {
  46. t = 2;
  47. } else if (this.url.indexOf("type=3") >= 0) {
  48. t = 3;
  49. } else {
  50. t = 0;
  51. return;
  52. }
  53. histoires[t] = histoire;
  54. if (t === 2 || t === 3) {
  55. hispass[t] = 0;
  56. hisfail[t] = 0;
  57. hisstack[t] = 0;
  58. hisrate[t] = 0;
  59. for (i = 0; i < histoire.length - 1; i++) { //除了今日
  60. hispass[t] = histoire[i].passNum + hispass[t];
  61. hisfail[t] = histoire[i].failNum + hisfail[t];
  62. hisstack[t] = histoire[i].avgDue + hisstack[t];
  63. }
  64. orighispass[t] = hispass[t];
  65. orighisfail[t] = hisfail[t];
  66. orighisstack[t] = hisstack[t];
  67. hispass[t] += hispass[0];
  68. hisfail[t] += hisfail[0];
  69. hisstack[t] += hisstack[0];
  70. hisrate[t] = get_factor(hispass[t], hisfail[t]);
  71. } else if (t === 1) {
  72. hispass[1] = histoire[0].passNum;
  73. hisfail[1] = histoire[0].failNum;
  74. hisstack[1] = histoire[0].avgDue;
  75. hisrate[t] = get_factor(hispass[1], hisfail[1]);
  76. }
  77. todayotherpass = histoire[histoire.length - 1].passNum;
  78. todayotherfail = histoire[histoire.length - 1].failNum;
  79. todayotherstack = histoire[histoire.length - 1].avgDue;
  80. update_all_history();
  81. }
  82. function update_all_history(){
  83. hispass[0] = todayotherpass + schedulepass;
  84. hisfail[0] = todayotherfail + schedulefail;
  85. hisstack[0] = todayotherstack + schedulestack;
  86. hisrate[0] = get_factor(hispass[0], hisfail[0]);
  87. for(i=2;i<=3;i++){
  88. hispass[i] = orighispass[i] + hispass[0];
  89. hisfail[i] = orighisfail[i] + hisfail[0];
  90. hisstack[i] = orighisstack[i] + hisstack[0];
  91. hisrate[i] = get_factor(hispass[i], hisfail[i]);
  92. }
  93. }
  94. var todayotherpass , todayotherfail, todayotherstack;
  95. var orighisfail= [], orighispass=[], orighisstack=[];
  96. function isUserOfThisFlow(uid) {
  97. var isExist = false;
  98. userIDs.forEach(function (vals) {
  99. if (vals == uid) {
  100. isExist = true;
  101. }
  102. });
  103. return isExist;
  104. }
  105. function on_red_rank_success(obj, sta) {
  106. var redchart = first_parse(this, obj);
  107. var i, j;
  108. i = j = 0;
  109. console.log(" redchart : ");
  110. console.log(redchart);
  111. for (i = 0; i < redchart.list.length; i++) {
  112. goodid[i] = getUserName(redchart.list[i].workerId);
  113. goodpass[i] = redchart.list[i].passNum;
  114. if(redchart.list[i].passNum + redchart.list[i].failNum > 0) {
  115. goodfailrate[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
  116. }else{
  117. goodfailrate[i] = 0;
  118. }
  119. if(isUserOfThisFlow(redchart.list[i].workerId)){
  120. goodColor[i] = 'red';
  121. }else{
  122. goodColor[i] = '';
  123. }
  124. }
  125. }
  126. function on_red_rank_success1(obj, sta) {
  127. var redchart = first_parse(this, obj);
  128. var i, j;
  129. i = j = 0;
  130. console.log(" redchart : ");
  131. console.log(redchart);
  132. for (i = 0; i < redchart.list.length; i++) {
  133. goodid1[i] = getUserName(redchart.list[i].workerId);
  134. goodpass1[i] = redchart.list[i].passNum;
  135. if(redchart.list[i].passNum + redchart.list[i].failNum > 0) {
  136. goodfailrate1[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
  137. }else{
  138. goodfailrate1[i] = 0;
  139. }
  140. if(isUserOfThisFlow(redchart.list[i].workerId)){
  141. goodColor1[i] = 'red';
  142. }else{
  143. goodColor1[i] = '';
  144. }
  145. }
  146. }
  147. function on_black_rank_success(obj, sta) {
  148. var blackchart = first_parse(this, obj);
  149. var i, j;
  150. i = j = 0;
  151. console.log(" black chart : ");
  152. console.log(blackchart);
  153. for (i = 0; i < blackchart.list.length; i++) {
  154. badid[i] = getUserName(blackchart.list[i].workerId);
  155. badpass[i] = blackchart.list[i].passNum;
  156. //badfailrate[i] = blackchart.list[i].failRate / 100;
  157. if(blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
  158. badfailrate[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
  159. }else{
  160. badfailrate[i] = 0;
  161. }
  162. if(isUserOfThisFlow(blackchart.list[i].workerId)){
  163. badColor[i] = 'green';
  164. }else{
  165. badColor[i] = '';
  166. }
  167. }
  168. }
  169. function on_black_rank_success1(obj, sta) {
  170. var blackchart = first_parse(this, obj);
  171. var i, j;
  172. i = j = 0;
  173. console.log(" black chart : ");
  174. console.log(blackchart);
  175. for (i = 0; i < blackchart.list.length; i++) {
  176. badid1[i] = getUserName(blackchart.list[i].workerId);
  177. badpass1[i] = blackchart.list[i].passNum;
  178. //badfailrate[i] = blackchart.list[i].failRate / 100;
  179. if(blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
  180. badfailrate1[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
  181. }else{
  182. badfailrate1[i] = 0;
  183. }
  184. if(isUserOfThisFlow(blackchart.list[i].workerId)){
  185. badColor1[i] = 'green';
  186. }else{
  187. badColor1[i] = '';
  188. }
  189. }
  190. }
  191. function getSpotHtml(htmlbody, i) {
  192. if(typeof hispass[i] === "undefined"){
  193. htmlbody += "<tr>";
  194. htmlbody += `<tr>
  195. <td> - </td>
  196. <td> - </td>
  197. <td> - </td>
  198. <td> - </td>
  199. <td> - </td>
  200. </tr>`;
  201. htmlbody += "</tr>";
  202. return htmlbody;
  203. }
  204. htmlbody += "<tr>";
  205. htmlbody += `<tr>
  206. <td>${timeday[i]}</td>
  207. <td>${hispass[i]}</td>
  208. <td>${hisfail[i]}</td>
  209. <td>${hisstack[i]}</td>
  210. <td>${hisrate[i] + '%'}</td>
  211. </tr>`;
  212. htmlbody += "</tr>";
  213. return htmlbody;
  214. }
  215. function getSpotHtml1(htmlbody, i) {
  216. if(typeof goodid[i] === "undefined"){
  217. htmlbody += "<tr>";
  218. htmlbody += `<tr>
  219. <td> - </td>
  220. <td> - </td>
  221. <td> - </td>
  222. <td> - </td>
  223. </tr>`;
  224. htmlbody += "</tr>";
  225. return htmlbody;
  226. }
  227. htmlbody += "<tr>";
  228. htmlbody += `<tr ">
  229. <td style="background-color: ${goodColor[i]}">${goodid[i]}</td>
  230. <td style="background-color: ${goodColor[i]}">${goodpass[i]}</td>
  231. <td style="background-color: ${goodColor1[i]}">${goodid1[i]}</td>
  232. <td style="background-color: ${goodColor1[i]}">${goodfailrate1[i] + '%'}</td>
  233. </tr>`;
  234. htmlbody += "</tr>";
  235. return htmlbody;
  236. }
  237. /*function getSpotHtml3(htmlbody, i) {
  238. if(typeof goodid1[i] === "undefined"){
  239. htmlbody += "<tr>";
  240. htmlbody += `<tr>
  241. <td> - </td>
  242. <td> - </td>
  243. </tr>`;
  244. htmlbody += "</tr>";
  245. return htmlbody;
  246. }
  247. htmlbody += "<tr>";
  248. htmlbody += `<tr style="background-color: ${goodColor1[i]}">
  249. <td>${goodid1[i]}</td>
  250. <td>${goodfailrate1[i] + '%'}</td>
  251. </tr>`;
  252. htmlbody += "</tr>";
  253. return htmlbody;
  254. }*/
  255. function getSpotHtml2(htmlbody, i) {
  256. if(typeof badid[i] === "undefined"){
  257. htmlbody += "<tr>";
  258. htmlbody += `<tr>
  259. <td> - </td>
  260. <td> - </td>
  261. <td> - </td>
  262. <td> - </td>
  263. </tr>`;
  264. htmlbody += "</tr>";
  265. return htmlbody;
  266. }
  267. htmlbody += "<tr>";
  268. if(typeof badColor[i] === "undefined"){
  269. htmlbody += `<tr>
  270. <td style="background-color: ${badColor[i]}">${badid[i]}</td>
  271. <td style="background-color: ${badColor[i]}">${badpass[i]}</td>
  272. <td style="background-color: ${badColor1[i]}">${badid1[i]}</td>
  273. <td style="background-color: ${badColor1[i]}">${badfailrate1[i] + '%'}</td>
  274. </tr>`;
  275. }else {
  276. htmlbody += `<tr >
  277. <td style="background-color: ${badColor[i]}">${badid[i]}</td>
  278. <td style="background-color: ${badColor[i]}">${badpass[i]}</td>
  279. <td style="background-color: ${badColor1[i]}">${badid1[i]}</td>
  280. <td style="background-color: ${badColor1[i]}">${badfailrate1[i] + '%'}</td>
  281. </tr>`;
  282. }
  283. htmlbody += "</tr>";
  284. return htmlbody;
  285. }
  286. /*function getSpotHtml4(htmlbody, i) {
  287. if(typeof badid1[i] === "undefined"){
  288. htmlbody += "<tr>";
  289. htmlbody += `<tr>
  290. <td> - </td>
  291. <td> - </td>
  292. </tr>`;
  293. htmlbody += "</tr>";
  294. return htmlbody;
  295. }
  296. htmlbody += "<tr>";
  297. if(typeof badColor1[i] === "undefined"){
  298. htmlbody += `<tr style="background-color: ${badColor1[i]}">
  299. <td>${badid1[i]}</td>
  300. <td>${badfailrate1[i] + '%'}</td>
  301. </tr>`;
  302. }else {
  303. htmlbody += `<tr style="background-color: ${badColor1[i]}">
  304. <td>${badid1[i]}</td>
  305. <td>${badfailrate1[i] + '%'}</td>
  306. </tr>`;
  307. }
  308. htmlbody += "</tr>";
  309. return htmlbody;
  310. }*/
  311. var lastTimeRank0 = "";
  312. var lastTimeRank1 = "";
  313. var lastTimeRank2 = "";
  314. var lastTimeRank3 = "";
  315. var lastTimeRank4 = "";
  316. function showEachSpot() {
  317. var htmlbody = "", one_person = "";
  318. var i = 0;
  319. var triGap = 4;
  320. htmlbody = "";
  321. for (i = 0; i < triGap; i++) {
  322. htmlbody = getSpotHtml(htmlbody, i);
  323. }
  324. if(lastTimeRank0 !== htmlbody) {
  325. $("#rank-one").html(htmlbody);
  326. lastTimeRank0 = htmlbody;
  327. }
  328. //console.log(htmlbody);
  329. }
  330. function showEachSpot1() {
  331. var htmlbody = "", one_person = "";
  332. var i = 0;
  333. var triGap = 3;
  334. htmlbody = "";
  335. for (i = 0; i < triGap; i++) {
  336. htmlbody = getSpotHtml1(htmlbody, i);
  337. }
  338. if(lastTimeRank1 !== htmlbody){
  339. $("#rank-two").html(htmlbody);
  340. lastTimeRank1 = htmlbody;
  341. }
  342. //console.log(htmlbody);
  343. }
  344. /*function showEachSpot3() {
  345. var htmlbody = "", one_person = "";
  346. var i = 0;
  347. var triGap = 3;
  348. htmlbody = "";
  349. for (i = 0; i < triGap; i++) {
  350. htmlbody = getSpotHtml3(htmlbody, i);
  351. }
  352. if(lastTimeRank3 !== htmlbody){
  353. $("#rank-four").html(htmlbody);
  354. lastTimeRank3 = htmlbody;
  355. }
  356. //console.log(htmlbody);
  357. }*/
  358. function showEachSpot2() {
  359. var htmlbody = "", one_person = "";
  360. var i = 0;
  361. var triGap = 3;
  362. htmlbody = "";
  363. for (i = 0; i < triGap; i++) {
  364. htmlbody = getSpotHtml2(htmlbody, i);
  365. }
  366. if(lastTimeRank2 !== htmlbody){
  367. $("#rank-three").html(htmlbody);
  368. lastTimeRank2 = htmlbody;
  369. }
  370. //console.log(htmlbody);
  371. }
  372. /*function showEachSpot4() {
  373. var htmlbody = "", one_person = "";
  374. var i = 0;
  375. var triGap = 3;
  376. htmlbody = "";
  377. for (i = 0; i < triGap; i++) {
  378. htmlbody = getSpotHtml4(htmlbody, i);
  379. }
  380. if(lastTimeRank4 !== htmlbody){
  381. $("#rank-five").html(htmlbody);
  382. lastTimeRank4 = htmlbody;
  383. }
  384. //console.log(htmlbody);
  385. }*/