common.js 12 KB

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