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 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")); } failratemax = Math.max(failratemax, 5); stackmax = Math.max(stackmax, 5); failmax = Math.max(failmax, 5); passmax = Math.max(passmax, failmax, stackmax); }; this.dataArrays = null; function showChart(sectorLoadData) { dataArrays = new getSeperateArrays(sectorLoadData); 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(sectorLoad) { 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; })(); function getHistoryTableBody(htmlbody, i) { if (typeof hispass[i] === "undefined") { htmlbody += "