| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120 |
- getUserId();
- var RedRank = (function() {
- this.fetchPos = 0;
- this.loader = (function () {
- this.load = function(pos) {
- get_data(`fcBiWorkerDaily/get?type=${RedRank.fetchPos}`, RedRank.loader.onSuccess);
- };
- this.consecutiveLoad = function(){
- RedRank.fetchPos = (RedRank.fetchPos + 1) % 8;
- load(RedRank.fetchPos);
- };
- this.onSuccess = function(res, code){
- };
- })();
- })();
- var RANK_TBL_ROW_COUNT = 4;
- var goodColor = [];
- var badColor = [];
- var goodColor1 = [];
- var badColor1 = [];
- var userIDs = [];
- var schedulepass = 0, schedulefail = 0, schedulestack = 0;
- var todayotherpass = 0, todayotherfail = 0, todayotherstack = 0;
- var lastTimeHistory = "";
- var histoires = [];
- var hispass = [];
- var hisfail = [];
- var hisstack = [];
- var hisrate = [];
- var goodpass = [];
- var goodid = [];
- var goodfailrate = [];
- var goodpass1 = [];
- var goodid1 = [];
- var goodfailrate1 = [];
- var badpass = [];
- var badid = [];
- var badfailrate = [];
- var badpass1 = [];
- var badid1 = [];
- var badfailrate1 = [];
- function history_success(obj, sta) {
- var histoire = first_parse(this, obj);
- var i, j, t;
- console.log(" histoire : ");
- console.log(histoire);
- if (this.url.indexOf("type=1") >= 0) {
- t = 1;
- } else if (this.url.indexOf("type=2") >= 0) {
- t = 2;
- } else if (this.url.indexOf("type=3") >= 0) {
- t = 3;
- } else {
- t = 0;
- return;
- }
- histoires[t] = histoire;
- if (t === 2 || t === 3) {
- hispass[t] = 0;
- hisfail[t] = 0;
- hisstack[t] = 0;
- hisrate[t] = 0;
- for (i = 0; i < histoire.length - 1; i++) { //除了今日
- hispass[t] = histoire[i].passNum + hispass[t];
- hisfail[t] = histoire[i].failNum + hisfail[t];
- hisstack[t] = histoire[i].avgDue + hisstack[t];
- }
- orighispass[t] = hispass[t];
- orighisfail[t] = hisfail[t];
- orighisstack[t] = hisstack[t];
- hispass[t] += hispass[0];
- hisfail[t] += hisfail[0];
- hisstack[t] += hisstack[0];
- hisrate[t] = get_factor(hispass[t], hisfail[t]);
- } else if (t === 1) {
- hispass[1] = histoire[0].passNum;
- hisfail[1] = histoire[0].failNum;
- hisstack[1] = histoire[0].avgDue;
- hisrate[t] = get_factor(hispass[1], hisfail[1]);
- }
- todayotherpass = histoire[histoire.length - 1].passNum;
- todayotherfail = histoire[histoire.length - 1].failNum;
- todayotherstack = histoire[histoire.length - 1].avgDue;
- update_all_history();
- }
- function update_all_history() {
- hispass[0] = todayotherpass + schedulepass;
- hisfail[0] = todayotherfail + schedulefail;
- hisstack[0] = todayotherstack + schedulestack;
- hisrate[0] = get_factor(hispass[0], hisfail[0]);
- if (typeof hisrate[0] == "undefined" || isNaN(hisrate[0])) {
- send_alert("请重试!");
- }
- for (i = 2; i <= 3; i++) {
- hispass[i] = orighispass[i] + hispass[0];
- hisfail[i] = orighisfail[i] + hisfail[0];
- hisstack[i] = orighisstack[i] + hisstack[0];
- hisrate[i] = get_factor(hispass[i], hisfail[i]);
- }
- }
- var todayotherpass, todayotherfail, todayotherstack;
- var orighisfail = [], orighispass = [], orighisstack = [];
- function isUserOfThisFlow(uid) {
- var isExist = false;
- userIDs.forEach(function (vals) {
- if (vals == uid) {
- isExist = true;
- }
- });
- return isExist;
- }
- function on_red_rank_success(obj, sta) {
- var redchart = first_parse(this, obj);
- var i, j;
- i = j = 0;
- console.log(" redchart : ");
- console.log(redchart);
- for (i = 0; i < redchart.list.length; i++) {
- goodid[i] = getUserName(redchart.list[i].workerId);
- goodpass[i] = redchart.list[i].passNum;
- if (redchart.list[i].passNum + redchart.list[i].failNum > 0) {
- goodfailrate[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
- } else {
- goodfailrate[i] = 0;
- }
- if (isUserOfThisFlow(redchart.list[i].workerId)) {
- goodColor[i] = 'red';
- } else {
- goodColor[i] = '';
- }
- }
- }
- function on_red_rank_success1(obj, sta) {
- var redchart = first_parse(this, obj);
- var i, j;
- i = j = 0;
- console.log(" redchart : ");
- console.log(redchart);
- for (i = 0; i < redchart.list.length; i++) {
- goodid1[i] = getUserName(redchart.list[i].workerId);
- goodpass1[i] = redchart.list[i].passNum;
- if (redchart.list[i].passNum + redchart.list[i].failNum > 0) {
- goodfailrate1[i] = Math.floor(redchart.list[i].failNum * 10000 / (redchart.list[i].passNum + redchart.list[i].failNum)) / 100;
- } else {
- goodfailrate1[i] = 0;
- }
- if (isUserOfThisFlow(redchart.list[i].workerId)) {
- goodColor1[i] = 'red';
- } else {
- goodColor1[i] = '';
- }
- }
- }
- function on_black_rank_success(obj, sta) {
- var blackchart = first_parse(this, obj);
- var i, j;
- i = j = 0;
- console.log(" black chart : ");
- console.log(blackchart);
- for (i = 0; i < blackchart.list.length; i++) {
- badid[i] = getUserName(blackchart.list[i].workerId);
- badpass[i] = blackchart.list[i].passNum;
- //badfailrate[i] = blackchart.list[i].failRate / 100;
- if (blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
- badfailrate[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
- } else {
- badfailrate[i] = 0;
- }
- if (isUserOfThisFlow(blackchart.list[i].workerId)) {
- badColor[i] = 'green';
- } else {
- badColor[i] = '';
- }
- }
- }
- function on_black_rank_success1(obj, sta) {
- var blackchart = first_parse(this, obj);
- var i, j;
- i = j = 0;
- console.log(" black chart : ");
- console.log(blackchart);
- for (i = 0; i < blackchart.list.length; i++) {
- badid1[i] = getUserName(blackchart.list[i].workerId);
- badpass1[i] = blackchart.list[i].passNum;
- //badfailrate[i] = blackchart.list[i].failRate / 100;
- if (blackchart.list[i].passNum + blackchart.list[i].failNum > 0) {
- badfailrate1[i] = Math.floor(blackchart.list[i].failNum * 10000 / (blackchart.list[i].passNum + blackchart.list[i].failNum)) / 100;
- } else {
- badfailrate1[i] = 0;
- }
- if (isUserOfThisFlow(blackchart.list[i].workerId)) {
- badColor1[i] = 'green';
- } else {
- badColor1[i] = '';
- }
- }
- }
- function getHistoryTableBody(htmlbody, i) {
- if (typeof hispass[i] === "undefined") {
- htmlbody += "<tr>";
- htmlbody += `<tr>
- <td> - </td>
- <td> - </td>
- <td> - </td>
- <td> - </td>
- <td> - </td>
- </tr>`;
- htmlbody += "</tr>";
- return htmlbody;
- }
- htmlbody += "<tr>";
- htmlbody += `<tr>
- <td>${timeday[i]}</td>
- <td>${hispass[i]}</td>
- <td>${hisfail[i]}</td>
- <td>${hisstack[i]}</td>
- <td>${hisrate[i] + '%'}</td>
- </tr>`;
- htmlbody += "</tr>";
- return htmlbody;
- }
- function getRankingTableBody(htmlbody, i) {
- if (typeof goodRank === "undefined" || typeof goodRank[i] === "undefined") {
- htmlbody += "<tr>";
- htmlbody += `<tr>
- <td> - </td>
- <td> 0 </td>
- <td> 0 </td>
- <td> 0 </td>
- </tr>`;
- htmlbody += "</tr>";
- return htmlbody;
- }
- htmlbody += "<tr>";
- htmlbody += `<tr ">
- <td style="background-color: ${goodRank[i].color}">${goodRank[i].id}</td>
- <td style="background-color: ${goodRank[i].color}">${goodRank[i].pass}</td>
- <td style="background-color: ${goodRank[i].color}">${goodRank[i].fail}</td>
- <td style="background-color: ${goodRank[i].color}">${goodRank[i].failRate + '%'}</td>
- </tr>`;
- htmlbody += "</tr>";
- return htmlbody;
- }
- var lastTimeRank0 = "";
- var lastTimeRank1 = "";
- var lastTimeRank2 = "";
- var lastTimeRank3 = "";
- var lastTimeRank4 = "";
- function showHistoryData() {
- var htmlbody = "", one_person = "";
- var i = 0;
- var triGap = 4;
- htmlbody = "";
- for (i = 0; i < triGap; i++) {
- htmlbody = getHistoryTableBody(htmlbody, i);
- }
- if (lastTimeRank0 !== htmlbody) {
- $("#rank-one").html(htmlbody);
- lastTimeRank0 = htmlbody;
- }
- //console.log(htmlbody);
- }
- function showRedRanking() {
- var htmlbody = "", one_person = "";
- var i = 0;
- var triGap = RANK_TBL_ROW_COUNT;
- htmlbody = "";
- for (i = 0; i < triGap; i++) {
- htmlbody = getRankingTableBody(htmlbody, i);
- }
- if (lastTimeRank1 !== htmlbody) {
- $("#rank-two").html(htmlbody);
- lastTimeRank1 = htmlbody;
- }
- //console.log(htmlbody);
- }
- /***
- * DataObject DO
- * @param cname
- * @param serverJsonObj
- * @constructor
- */
- var DataObject = function(cname, serverJsonObj){
- this.ctlName = cname;
- this.jsonObj = serverJsonObj;
- this.getVal = function (key) {
- return jsonObj[key];
- };
- this.serVal = function (key, val) {
- jsonObj[key] = val;
- };
- };
- /***
- * DataObjectList
- * @param name
- * @constructor
- */
- var DataObjectList = function(name){
- this.ctlName = name;
- this.list = null;
- this.isSorted = false;
- this.preSort = [];
- /***
- * sorting
- * @param comparator (a,b) =====> a - b
- */
- this.sortBy = function(comparator){
- preSort = new Array();
- for (let i = 0; i < list.length; i++) preSort.push(list[i]);
- quickSort(preSort, 0, preSort.length - 1, function(l, r){});
- };
- function clearData() {
- isSorted = false;
- preSort = null;
- list = null;
- }
- this.len = function() {
- if(list == null) return 0;
- return list.length;
- };
- this.assignJsonData = function (data) {
- clearData();
- list = new Array();
- for (let i = 0; i < list.length; i++) list.push(new DataObject(ctlName, data[i]));
- };
- this.getRaw = function (index) {
- return list[index];
- };
- this.getSorted = function (index) {
- if(!isSorted) return null;
- return preSort[index];
- };
- this.quickSort = function (a,left,right,comp){
- if(left>right){ //一定要有这个判断,因为有递归left和i-1,若没有这个判断条件,该函数会进入无限死错位递归
- return;
- }
- var i=left,
- j=right,
- pivot=a[left]; //基准总是取序列开头的元素
- while(i!=j){
- while((comp(a[j],pivot) > 0)&&i<j){j--}
- while((comp(a[j],pivot) <= 0)&&i<j){i++}
- if(i<j){ //如果i==j跳出外层while
- var t=a[i];
- a[i]=a[j];
- a[j]=t;
- }
- }
- a[left]=a[i];//交换基准数和k位置上的数
- a[i]=pivot;
- quicksort(a,left,i-1,comp);
- quicksort(a,i+1,right,comp);
- };
- };
- /***
- * DOService
- * @param controlName
- * @constructor
- */
- var DataObjectService = function(controlName, syncType, extparm){
- this.ctlName = controlName;
- // 2=default 4=on-demand, 8=auto, 16:fast, 32=passive
- this.syncType = syncType;
- this.extParm = extparm;
- this.isDefault = ((syncType & 2) !== 0);
- this.isOnDemand = ((syncType & 4) !== 0);
- this.isAuto = ((syncType & 8) !== 0);
- this.isFast = ((syncType & 16) !== 0);
- this.isPassive = ((syncType & 32) !== 0);
- this.failedCount = 0;
- this.list = new DataObjectList(controlName);
- this.autoUpdateTimer = 0;
- this.autoInterval = 1000;
- function setUpInterval() {
- //URL + exparm
- if(this.autoUpdateTimer != 0) clearInterval(this.autoUpdateTimer);
- this.autoUpdateTimer = setInterval(this.selfUpdateTick, this.autoInterval);
- }
- this.init = function(){
- if(isAuto){
- // timer
- if(!isFast){
- this.autoInterval = 5000;
- }
- setUpInterval();
- selfUpdate();
- }
- };
- this.stopTimers = function () {
- clearInterval(this.autoUpdateTimer);
- this.autoUpdateTimer = 0;
- };
- this.selfUpdateTick = function(){
- get_data(controlName+"/list"+extParm, this.onDataReceived);
- };
- this.onDemandUpdate = function(){
- get_data(controlName+"/list"+extParm, this.onDataReceived);
- };
- this.onDataReceived = function(data, sta){
- let output = first_parse(this, obj);
- if (output.list == undefined || output.list.length == 0) {
- this.failedCount++;
- if(this.failedCount > 100){
- this.failedCount = 0;
- this.stopTimers();
- console.log("【错误次数过多");
- setTimeout(this.setUpInterval, 10000);
- }
- if(this.failedCount == 2) {
- send_alert("没有数据,请尝试重新加载!【DataService】: ctlName[" + controlName + "], extParm[" + extparm + "]");
- }
- }else{
- this.list.assignJsonData(output.list);
- }
- };
- this.passiveUpdate = function(data){
- this.failedCount = 0;
- this.list.assignJsonData(data);
- };
- this.init();
- };
- var SinglePage = function () {
- this.modules = [];
- };
- var Module = function(chartContainerSelector, dataCtlName){
- this.selector = chartContainerSelector;
- this.dataCtl = dataCtlName;
- this.activeData = null;
- this.lastActive = 0;
- /***
- * bindData to UI
- * @param data DataObjectList
- */
- this.setData = function (data) {
- if(data.ctlName == this.dataCtl){
- //ok
- console.log(`-------- Module ${this.selector} got data ----------- `);
- this.activeData = data;
- //cache
- this.drawData();
- }else{
- console.log(`-------- Module ${this.selector} cannot use data of ${data.ctlName} ----------- `);
- }
- };
- this.drawData = function () {
- // do nothing
- }
- };
- var RealTimeGraph = new Module("", "fcBiSectorLoad");
- RealTimeGraph.drawData = function (data) {
- var tempo = this.activeData;
- };
- var FlowRealTime = (function () {
- this.pgName = "flowDashBoard";
- this.page = new SinglePage(this.pgName);
- this.scheduleId = utils_get_param("scheduleId");
- this.flowId = utils_get_param("flowId");
- if(scheduleId == null || flowId == null)
- {
- send_alert(`清重新进入本页面!<a href='denglu.html'> 返回主页 </a>`);
- return;
- }
- this.flowPlace = " % flowPlace %";
- this.flowName = " % flowPlace %";
- this.HistoryBaseURL = "fcBiFlowDaily/list?scheduleId=" + scheduleId + "&flowId=" + flowId;
- this.scheduleLoadDataService = new DataObjectService("fcScheduleLoadService", 2 & 4);
- this.biFlowDailyService = null;
- this.oaStaffService = null;
- this.sectorService = null;
- this.flowService = null;
- this.initializeUsers = function(list){
- list.forEach(function (val, it, arr) {
- var isExist = false;
- userIDs.forEach(function (vals) {
- if (vals == val.userId) {
- isExist = true;
- }
- });
- if (!isExist) userIDs.push(val.userId);
- });
- };
- this.initPage = function(){
- showHistoryData();
- showRedRanking();
- showBlackRanking();
- };
- /***
- * On
- * @param obj
- * @param sta
- */
- this.onFirstTimeSuccess = function (obj, sta) {
- let output = first_parse(this, obj);
- let i, j, k, z = 0, x = 0, worksum = [];
- if (output.list == undefined || output.list.length == 0) {
- send_alert("没有数据 | 请重新加载页面 ! ");
- }else{
- DataLogic.onScheduleData(output.list);
- }
- initializeUsers(output.list);
- Action.loadMultiHistory();
- showChart();
- };
- /**
- * DataLogic
- */
- this.DataLogic = (function () {
- this.combineAsSector = function(sectorList, scheduleDoList) {
- var output = new DataObjectList("sectorLoad");
- output.assignJsonData("");
- return output;
- };
- this.onScheduleData = function (scheduleDoList) {
- sectorID[0] = getSectorId(scheduleDoList[0].spotId);
- for (let i = 1; i < scheduleDoList.length; i++) {
- let loadDO = new ScheduleDO(scheduleDoList[i]);
- x = 0;
- for (j = 0; j < sectorID.length; j++) {
- if (sectorID[j] === thisUid) {
- x = 1;
- break;
- }
- }
- if (x === 0) {
- sectorID.push(thisUid);
- }
- }
- DataLogic.CountBySector();
- }
- this.CountBySector = function (sectors, spotData) {
- sectorId, passNumber, failNumber
- let j = 0, k = 0, z = 0;
- for (k = 0; k < sectors.length; k++) {
- var uid = sectors[k].getUid();
- z = 0;
- passNumber[k] = 0;
- failNumber[k] = 0;
- stackeverynum[k] = 0;
- for (i = 0; i < output.list.length; i++) {
- if (uid === getSectorId(output.list[i].spotId)) {
- passNumber[k] = output.list[i].passNum + passNumber[j];
- failNumber[k] = output.list[i].failNum + failNumber[j];
- stackeverynum[k] = output.list[i].due + stackeverynum[j];
- z++;
- }
- }
- if (failNumber[k] + passNumber[k] == 0) {
- failrate[k] = 0;
- } else {
- failrate[k] = failNumber[k] / (failNumber[k] + passNumber[k]) * 100;
- }
- // z is the number of data in one sector
- }
- }
- })();
- this.NameLoader = (function(){
- this.onNameRetrieved = function (obj, sta) {
- var factory = first_parse(this, obj);
- var i, j, t;
- console.log(" factory : ");
- console.log(factory);
- flowPlace = factory.list[0].flowPlace;
- flowName = factory.list[0].flowName;
- $("#flow_title").html(flowPlace + "-" + flowName + " 度彼科技");
- document.title = flowPlace + " " + flowName + " | 流水线管理 | 度彼科技";
- };
- this.load = function(){
- get_data("fcFlow/list?flowId=" + flowId, onNameRetrieved);
- };
- })();
- this.mainLoopFunc = function () {
- get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, realtime_success);
- HistoryData.update();
- };
- this.Action = (function () {
- this.clearDataOfDeviceId = function (handId) {
- executed = false;
- directCount = -1;
- finished = true;
- var hand = handId;
- var hd = 0;
- if (hand.length > 0) {
- hd = parseInt(hand);
- }
- get_data("endpoint/clearBoard?flowId=" + flowId + "&handheldId=" + hd, clearSuccess);
- };
- this.doStopSchedule = function () {
- get_data("fcWorkSchedule/stopSchedule?userId=" + userId + "&scheduleId=" + scheduleId, UI.showStopSuccess);
- };
- this.confirmStopSchedule = function () {
- var out = confirm("真的要下班吗?");
- if (out == true) {
- doStopSchedule();
- } else {
- }
- };
- })();
- this.UI = (function () {
- this.showClearPanel = function () {
- $("#clearModal").modal('show');
- };
- this.showStopSuccess = function (obj, sta) {
- send_alert("下班操作成功! <a href='denglu.html'> 点击这里返回控制主页 </a>");
- };
- })();
- this.HistoryData = (function (){
- this.update = function () {
- // 请注意type必须在结尾
- get_data("fcBiFlowDaily/list?flowId=" + flowId + "&type=1", history_success);
- };
- this.loadHistroyOnce = function (nnm) {
- // 请注意type必须在结尾
- get_data(HistoryBaseURL + "&type=" + nnm, history_success);
- };
- this.loadMultiHistory = function(){
- for (i = 1; i <= 3; i++) loadHistroyOnce(i);
- };
- this.add_success = function(obj, sta) {
- var history1 = first_parse(this, obj);
- var i, j;
- console.log(" history1 : ");
- console.log(history1);
- hispass[t] = 0;
- hisfail[t] = 0;
- hisstack[t] = 0;
- hisrate[t] = 0;
- var lengthnum = history1.length - 1;
- for (i = lengthnum; i < history1.length; i++) {
- hispass[t] = history1[i].passNum + hispass[t];
- hisfail[t] = history1[i].failNum + hisfail[t];
- hisstack[t] = history1[i].avgDue + hisstack[t];
- }
- if (hispass[t] + hisfail[t] == 0) {
- hisrate[t] = 0;
- }
- t++;
- }
- })();
- function realtime_success(obj, sta) {
- var output = first_parse(this, obj);
- //在这里排序 spo\
- console.log(" output : ");
- console.log(output);
- var i, j, k, z;
- failnum = 0;
- var x = 0;
- var worksum = [];
- var hhp = 0, hhf = 0, hhs = 0;
- if (output.list.length > 0) {
- sectorID[0] = getSectorId(output.list[0].spotId);
- passNumber[0] = 0;
- failNumber[0] = 0;
- stackeverynum[0] = 0;
- z = 0;
- for (i = 1; i < output.list.length; i++) {
- var thisUid = getSectorId(output.list[i].spotId);
- x = 0;
- for (j = 0; j < sectorID.length; j++) {
- if (sectorID[j] === thisUid) {
- x = 1;
- break;
- }
- }
- if (x === 0) {
- sectorID.push(thisUid);
- }
- }
- j = 0;
- for (k = 0; k < sectorID.length; k++) {
- var uid = sectorID[k];
- z = 0;
- passNumber[k] = 0;
- failNumber[k] = 0;
- stackeverynum[k] = 0;
- for (i = 0; i < output.list.length; i++) {
- if (uid === getSectorId(output.list[i].spotId)) {
- passNumber[k] = output.list[i].passNum + passNumber[k];
- failNumber[k] = output.list[i].failNum + failNumber[k];
- stackeverynum[k] = output.list[i].due + stackeverynum[k];
- z++;
- }
- }
- failrate[k] = get_factor(passNumber[k], failNumber[k]);
- }
- output.list.forEach(function (val, fid, arr) {
- hhp += val.passNum;
- hhf += val.failNum;
- hhs += val.due;
- })
- }
- schedulepass = hhp;
- schedulefail = hhf;
- if (output.list.length > 0) {
- schedulestack = hhs / output.list.length;
- } else {
- schedulestack = 0;
- }
- update_all_history();
- updateChart();
- };
- })();
- var ClearDataControl = (function () {
- this.finished = true;
- this.executed = false;
- this.directCount = -1;
- this.Action = (function () {
- })();
- this.clearSuccess = function (obj, sta) {
- console.warn("------- 手持设备清空 ----------");
- console.warn(this);
- send_alert("发送清空请求成功, 正在等待采集端进行处理...");
- ClearDataControl.finished = false;
- setTimeout(resultVerifyTimeout, 8000);
- setTimeout(getVerify, 300);
- }
- this.getVerify = function () {
- if (ClearDataControl.finished) return;
- get_data("endpoint/heartbeat?flowId=" + flowId, onVerifyResult);
- setTimeout(getVerify, 100);
- };
- this.onVerifyResult = function (obj, sta) {
- var parsed = {};
- if (typeof(obj) === "string") {
- parsed = JSON.parse(obj);
- } else {
- parsed = obj;
- }
- if (typeof(parsed) === "object") {
- if (parsed.ret === "10000") {
- //ok
- if (parsed.model == null || parsed.model === undefined) {
- executed = true;
- finished = true;
- } else if (typeof(obj.model) === "object") {
- // 没有拿到,继续
- if (obj.model.list != null && obj.model.list.length > 0) {
- var direct = obj.model.list[0];
- if (direct.eventType + "" !== "500") {
- // OK
- executed = true;
- finished = true;
- } else if (direct.arg2 + "" !== "" + $("#handInput").val()) {
- // OK
- executed = true;
- finished = true;
- } else {
- directCount = direct.counter;
- }
- }
- }
- }
- }
- }
- this.resultVerifyTimeout = function () {
- finished = true;
- if (executed) {
- // 执行成功
- } else {
- if (directCount >= 0) {
- get_data("endpoint/ack?counter=" + directCount, function () {
- console.log("撤销操作成功");
- console.log(this);
- });
- directCount = -1;
- send_alert("请求已经超时!请注意,采集端可能没有执行成功。即将撤销您的请求。");
- } else {
- send_alert("请求已经超时!请注意,采集端可能没有执行成功。");
- }
- }
- }
- })();
- $(document).ready(function(){
- });
- var RealTimeCharts = (function() {
- var timeday = ["今日", "昨日", "本周", "本月"];
- if (flowId == null || scheduleId == null) {
- send_alert("出错啦!请检查参数完整性");
- }
- function page_document_load() {
- get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, onFirstTimeSuccess);
- }
- var compAxis = {
- categories: namedata,
- crosshair: true,
- title: {
- text: '工位',
- style: {
- fontSize: '1.5em'
- }
- },
- labels: {
- style: {
- fontSize: '1.5em'
- }
- }
- };
- var getSeperateArrays = function (sectorLoadData){
- this.data = [];
- this.len = sectorLoadData.len();
- this.stackmax = 0;
- this.failmax = 0;
- this.passmax = 0;
- this.failratemax = 0;
- this.ratedata = [];
- this.passdata = [];
- this.faildata = [];
- for (i = 0; i < len; i++) {
- var one = sectorLoadData.getRaw(i);
- if (stackmax < one[i].getVal("stack")) {
- stackmax = one[i].getVal("stack")
- }
- if (failmax < one[i].getVal("failNum")) {
- failmax = one[i].getVal("failNum");
- }
- if (failratemax < one[i].getVal("failRate")) {
- failratemax = one[i].getVal("failRate");
- }
- if (passmax < one[i].getVal("passNum")) {
- passmax = one[i].getVal("passNum");
- }
- data.push(one[i].getVal("stack"));
- this.ratedata.push(Math.floor(one[i].getVal("failRate")));
- this.passdata.push(one[i].getVal("passNum"));
- this.faildata.push(one[i].getVal("failNum"));
- }
- };
- this.dataArrays = null;
- function showChart(sectorLoadData) {
- dataArrays = new getSeperateArrays(sectorLoadData);
- failratemax = Math.max(failratemax, 5);
- stackmax = Math.max(stackmax, 5);
- failmax = Math.max(failmax, 5);
- passmax = Math.max(passmax, failmax, stackmax);
- stackAndFailChart = Highcharts.chart('graph-1', {
- chart: {
- zoomType: 'xy',
- //height: (4 / 16 * 100) + '%' // 16:9 ratio
- },
- title: {text: '各工位今日产能'},
- credits: {enabled: false},
- exporting: {enabled: false},
- xAxis: [compAxis],
- yAxis: [{
- labels: {
- format: '{value}',
- style: {
- color: "#ffffff",
- fontSize: '1.5em'
- }
- },
- min: 0,
- max: passmax * 1.5,
- title: {
- text: '数量',
- style: {
- color: '#ffffff',
- fontSize: '1em'
- },
- rotation: 270,
- }
- },],
- tooltip: {shared: true},
- legend: {
- layout: 'vertical',
- align: 'right',
- x: 0,
- verticalAlign: 'top',
- y: 0,
- floating: true,
- backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
- },
- series: [{
- name: '良品数',
- type: 'column',
- data: passdata,
- }, {
- name: '不良品数',
- type: 'column',
- data: faildata,
- },
- {
- name: '堆积数',
- type: 'column',
- data: data,
- }]
- });
- FailChart = Highcharts.chart('graph-2', {
- chart: {
- //height: (4 / 16 * 100) + '%' // 16:9 ratio
- },
- title: {
- text: '各工位今日不良率'
- },
- credits: {
- enabled: false // 禁用版权信息
- },
- exporting: {
- enabled: false
- },
- xAxis: [compAxis],
- yAxis: [{ // Secondary yAxis
- title: {
- text: '不良率',
- style: {
- color: '#ffffff',
- fontSize: '1em'
- }
- },
- min: 0,
- max: 1.5 * failratemax,
- labels: {
- formatter: function () {
- return Math.floor(this.value) + "%";
- },
- style: {
- color: '#ffffff',
- fontSize: '20px'
- },
- rotation: 270,
- },
- }],
- tooltip: {
- shared: true
- },
- legend: {
- layout: 'vertical',
- align: 'right',
- x: 0,
- verticalAlign: 'top',
- y: 0,
- floating: true,
- backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
- },
- series: [{
- name: '不良率',
- type: 'spline',
- data: ratedata,
- color: 'red',
- tooltip: {
- valueSuffix: '%'
- }
- }]
- });
- }
- function updateChart() {
- var data = [];
- var ratedata = [];
- var stackmax = 0;
- var failmax = 0;
- var passdata = [];
- var faildata = [];
- var passmax = 0;
- var failratemax = 0;
- for (i = 0; i < passNumber.length; i++) {
- if (stackmax < stackeverynum[i]) {
- stackmax = stackeverynum[i];
- }
- if (failmax < failNumber[i]) {
- failmax = failNumber[i];
- }
- if (failratemax < failrate[i]) {
- failratemax = failrate[i];
- }
- if (passmax < passNumber[i]) {
- passmax = passNumber[i];
- }
- data.push(stackeverynum[i]);
- ratedata.push(Math.floor(failrate[i]));
- passdata.push(passNumber[i]);
- faildata.push(failNumber[i])
- }
- failratemax = Math.max(failratemax, 5);
- stackmax = Math.max(stackmax, 5);
- failmax = Math.max(failmax, 5);
- passmax = Math.max(passmax, failmax, stackmax);
- // https://api.hcharts.cn/highcharts#Series.addPoint;
- stackAndFailChart.series[0].setData(passdata);
- stackAndFailChart.series[1].setData(faildata);
- stackAndFailChart.series[2].setData(data);
- FailChart.series[0].setData(ratedata);
- if (failratemax > FailChart.yAxis[0].getExtremes().max * 1.3 || failratemax < FailChart.yAxis[0].getExtremes().max * 0.5) {
- FailChart.yAxis[0].setExtremes(0, failratemax * 1.5);
- }
- if (passmax > stackAndFailChart.yAxis[0].getExtremes().max * 1.3 || passmax < stackAndFailChart.yAxis[0].getExtremes().max * 0.5) {
- stackAndFailChart.yAxis[0].setExtremes(0, passmax * 1.5);
- }
- showHistoryData();
- showRedRanking();
- showBlackRanking();
- var secNames = [];
- sectorID.forEach(function (val) {
- secNames.push(getSectorName(val));
- });
- if (JSON.stringify(secNames) !== lastTimeSecNames) {
- lastTimeSecNames = JSON.stringify(secNames);
- FailChart.xAxis[0].setCategories(secNames);
- stackAndFailChart.xAxis[0].setCategories(secNames);
- }
- }
- var lastTimeSecNames = "";
- var stackAndFailChart = null;
- var FailChart = null;
- })();
|