1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804 |
- var prefix = server + "/eap/api/";
- var types = [
- { name: "RUN", desc: "运行", color: "rgb(61, 149, 73)" },
- { name: "DISCONN", desc: "未连接", color: "rgb(178, 178, 178)" },
- { name: "REPAIR", desc: "维修", color: "rgb(178, 0, 89)" },
- { name: "PM", desc: "保养", color: "rgb(178, 98, 0)" },
- { name: "ERROR", desc: "错误", color: "rgb(178, 30, 30)" },
- { name: "IDLE", desc: "空闲", color: "rgba(178, 178, 0, 1)" },
- { name: "CHANGE", desc: "改机", color: "rgb(7, 87, 126)" },
- ];
- var chartLoading = {
- text: "正在加载...",
- color: "#B21E1E",
- textColor: "#B21E1E",
- };
- var macCode = getQueryStringByName("macCode");
- var time = getQueryStringByName("date");
- var shift = "";
- var alarmBarChart;
- var timeOut = null;
- $(function () {
- if (!macCode) {
- alert("请传入正确的设备号");
- return;
- }
- alarmBarChart = echarts.init(document.getElementById("alarmBar"));
- initPage({
- macCode: macCode,
- time: time || dateFormat("yyyy-MM-dd HH:mm:ss", new Date()),
- shift: shift,
- });
- alarmBarChart.on("click", function (params) {
- layer.open({
- type: 2,
- title: `机台【${macCode} ${params.name} ${params.seriesName}】报警明细`,
- shadeClose: true,
- shade: false,
- maxmin: true, //开启最大化最小化按钮
- area: ["993px", "600px"],
- content: `./mac-alarm-detail.html?fcode=${macCode}&date=${
- params.name
- }&shift=${escape(params.seriesName)}`,
- });
- });
- });
- function showLoading() {
- layer.load();
- }
- var intervalOne = "";
- var intervalTwo = "";
- function getMacCode() {
- return {
- date: dateFormat("yyyy-MM-dd", new Date(time)),
- macCode: macCode,
- };
- }
- function showLoading() {
- hideNav($(".rightNav"), $(".bgDiv"));
- layer.load();
- }
- // 检查机台号是否存在
- function checkMchineIfExist(macCode) {
- return axios.get(`${server}/eap/api/machine/getbycode?code=${macCode}`);
- }
- // 初始化页面
- function initPage(obj) {
- macCode = obj.macCode;
- time = new Date(obj.time);
- shift = obj.shift;
- checkMchineIfExist(obj.macCode).then((res) => {
- console.log(res);
- if (res && res.data) {
- var startTime = dateFormat(
- "yyyy-MM-dd HH:mm:ss",
- new Date(getStartTime(obj.time, shift))
- );
- var dateStart = new Date(startTime);
- var et = new Date(startTime);
- var endTime = "";
- var isBetween = isBetweenZeroAndShiftStart(et);
- if (
- dateFormat("yyyy-MM-dd", et) === dateFormat("yyyy-MM-dd", new Date()) ||
- isBetween
- ) {
- endTime = dateFormat("yyyy-MM-dd HH:mm:ss", new Date());
- } else {
- endTime = dateFormat(
- "yyyy-MM-dd HH:mm:ss",
- new Date(et.setHours(et.getHours() + 24))
- );
- }
- $("#equipmentID").text(macCode);
- $("#date").text(dateFormat("yyyy-MM-dd", new Date(startTime)));
- if (intervalOne) {
- clearInterval(intervalOne);
- }
- // if (intervalTwo) {
- // clearInterval(intervalTwo);
- // }
- layer.load();
- initHeader(macCode, startTime, endTime);
- loadStatusAndAlarm(macCode, startTime, endTime);
- loadDayOutput(macCode, startTime, endTime);
- loadTimeOutput(macCode, startTime, endTime);
- renderRunHistory(macCode, startTime, endTime);
- if (
- dateFormat("yyyy-MM-dd", dateStart) ===
- dateFormat("yyyy-MM-dd", new Date()) ||
- isBetweenZeroAndShiftStart(dateStart)
- ) {
- intervalOne = setInterval(() => {
- //if (dateFormat('yyyy-MM-dd', et) === dateFormat('yyyy-MM-dd', new Date())) {
- endTime = dateFormat("yyyy-MM-dd HH:mm:ss", new Date());
- //}
- initHeader(macCode, startTime, endTime);
- loadStatusAndAlarm(macCode, startTime, endTime);
- loadDayOutput(macCode, startTime, endTime);
- loadTimeOutput(macCode, startTime, endTime);
- }, 60 * 1000);
- // intervalTwo = setInterval(() => {
- // //if (dateFormat('yyyy-MM-dd', et) === dateFormat('yyyy-MM-dd', new Date())) {
- // }, 60 * 1000);
- }
- } else {
- layer.closeAll("loading");
- alert("设备ID不存在");
- }
- });
- }
- //获取班别开始时间
- function getStartTime(time, shift) {
- var dateTime = new Date(time);
- var hhmmss = dateFormat("HH:mm", dateTime) + "";
- var startTime;
- // if (typeof shift == "undefined" || shift == null || shift == "") {
- // if ('00:00' <= hhmmss && hhmmss <= '08:00') {
- // startTime = dateFormat('yyyy-MM-dd', (new Date(dateTime.setDate(dateTime.getDate() - 1)))) + ' 20:00:00';
- // } else if ('08:00' <= hhmmss && hhmmss <= '20:00') {
- // startTime = dateFormat('yyyy-MM-dd', dateTime) + ' 08:00:00';
- // } else if ('20:00' <= hhmmss && hhmmss <= '23:59') {
- // startTime = dateFormat('yyyy-MM-dd', dateTime) + ' 20:00:00';
- // }
- startTime = dateFormat("yyyy-MM-dd", new Date(time)) + " 08:30:00";
- var dateNow = new Date();
- if (dateNow < new Date(startTime)) {
- var st = new Date(startTime);
- st = new Date(st.setDate(st.getDate() - 1));
- startTime = dateFormat("yyyy-MM-dd", st) + " 08:30:00";
- }
- //}
- // else if (shift == '1') {
- // startTime = dateFormat('yyyy-MM-dd', new Date(time)) + ' 08:30:00';
- // } else {
- // startTime = dateFormat('yyyy-MM-dd', new Date(time)) + ' 20:30:00';
- // }
- //console.log(startTime, shift);
- return startTime;
- }
- function isBetweenZeroAndShiftStart(time) {
- var dateDiff =
- (new Date().getTime() - time.getTime()) / (24 * 60 * 60 * 1000);
- // alert(dateDiff);
- var todayShiftStartDate = new Date(
- dateFormat("yyyy-MM-dd", new Date()) + " 08:30:00"
- );
- //alert(todayShiftStartDate);
- return dateDiff < 1 && new Date() < todayShiftStartDate;
- }
- // 加载头部数据
- function initHeader(macCode, startTime, endTime) {
- axios
- .get(`${prefix}MacStatusTotalInfo/GetTotalInfoDeatil`, {
- params: {
- macCode: macCode,
- startTime: startTime,
- endTime: endTime,
- t: new Date().getMilliseconds(),
- },
- })
- .then((res) => {
- layer.closeAll("loading");
- if (res && res.code === 1) {
- var obj = res.data;
- $("#alarmCount").text(obj.alarmCount);
- // $('#runTimes').text(obj.runTime);
- // $('#runRate').text(obj.runRate + '%');
- $("#todayOutput").text(obj.todayCount);
- $("#monthOutput").text(obj.monthCount);
- $("#recipe").text(obj.recipe);
- $("#status")
- .removeClass()
- .addClass("conuts")
- .css(
- "color",
- `rgb(${obj.color.red},${obj.color.green},${obj.color.blue})`
- );
- $("#status").text(obj.statusCode);
- $("#regionName").text(obj.factory);
- } else {
- alert("获取数据失败");
- }
- })
- .catch((resp) => {
- console.log("请求失败:" + resp.status + "," + resp.statusText);
- });
- }
- // 加载机台状态分布与报警统计
- function loadStatusAndAlarm(macCode, startTime, endTime) {
- var statusChart = echarts.init(document.getElementById("macStatusPie"));
- var dateNow = new Date();
- alarmBarChart.showLoading(chartLoading);
- statusChart.showLoading(chartLoading);
- axios
- .get(prefix + "MacStatusTotalInfo/GetTotalInfoDeatilForAnalysis", {
- params: {
- macCode,
- startTime: startTime,
- endTime: endTime,
- },
- })
- .then((res) => {
- if (res && res.code === 1) {
- if (res.data.runrate && res.data.runrate.length > 0) {
- var legends = [];
- var data = [];
- var runRates = res.data.runrate;
- var totalTime = 0;
- var runTime = 0;
- runRates.forEach((element) => {
- if (element.name === "运行") runTime = element.value;
- totalTime += element.value;
- legends.push(element.name);
- data.push({
- name: element.name,
- y: element.value,
- dataLabels: {
- distance: 12,
- style: {
- color: "#eee",
- fontSize: "12px",
- textOutline: "none",
- },
- // backgroundColor:`transparent`,
- // fontWeight:'bold',
- // color: `rgb(${element.color.red},${element.color.green},${element.color.blue})`
- formatter: function () {
- return (
- '<p style="color:' +
- this.color +
- '">' +
- this.point.name +
- '</p><br><p style="color:' +
- this.color +
- '">' +
- this.percentage.toFixed(1) +
- "%</p>"
- );
- },
- },
- color: `rgb(${element.color.red},${element.color.green},${element.color.blue})`,
- });
- // data.push({
- // value: element.value,
- // name: element.name,
- // itemStyle: {
- // normal: {
- // color: `rgb(${element.color.red},${element.color.green},${element.color.blue})`
- // }
- // }
- // });
- });
- render3DStatusPie("macStatusPie", legends, data);
- $("#runTimes").text(runTime);
- $("#runRate").text(((runTime / totalTime) * 100).toFixed(2) + "%");
- }
- if (res.data.runTimes && res.data.runTimes.length > 0) {
- //#region
- // var alarms = res.data.runTimes;
- // var xdata = [];
- // var ydata = [];
- // alarms.forEach(item => {
- // item.alarmCount = parseInt(item.alarmCount);
- // xdata.push(item.alarmCode);
- // ydata.push(parseInt(item.alarmCount));
- // });
- // var chartDto = {
- // title: '报警统计图',
- // legend: [],
- // xdata: xdata,
- // ydata: ydata
- // };
- // renderAlarmBar(alarmBarChart, chartDto, res.data.runTimes);
- var datas = res.data.runTimes;
- var xDatas = []; // X轴文字
- var legends = []; // 图例文字
- var seriesData = [];
- datas.forEach((item) => {
- if (xDatas.indexOf(item.day) === -1) {
- xDatas.push(item.day);
- }
- if (legends.indexOf(item.class) === -1) {
- legends.push(item.class);
- }
- });
- if (legends.length > 0) {
- legends.forEach((item) => {
- var classOutPuts = [];
- datas.forEach((element) => {
- if (element.class === item) {
- classOutPuts.push(parseInt(element.count));
- }
- });
- seriesData.push({
- key: item,
- values: classOutPuts,
- });
- });
- }
- var colorStopses = [
- [
- {
- offset: 0,
- color: "#E69D87",
- },
- {
- offset: 1,
- color: "#E69D87",
- },
- ],
- [
- {
- offset: 0,
- color: "#D43239",
- },
- {
- offset: 1,
- color: "#D43239",
- },
- ],
- ];
- var barColors = ["#0035f9", "#25f3e6"];
- var series = [];
- seriesData.forEach((item, index) => {
- //#region ECharts数据
- // var obj = {
- // name: item.key,
- // type: "bar",
- // data: item.values,
- // barWidth: "30%",
- // itemStyle: {
- // normal: {
- // color: {
- // type: "linear",
- // x: 0,
- // y: 0,
- // x2: 0,
- // y2: 1,
- // colorStops: colorStopses[index],
- // globalCoord: false
- // }
- // }
- // },
- // label: {
- // show: true,
- // color: '#fff',
- // position: 'top',
- // formatter: function (params) {
- // if (params.data == 0) {
- // return '';
- // }
- // return params.data;
- // }
- // },
- // barGap: "0"
- // };
- //#endregion
- var obj = {
- name: item.key,
- data: item.values,
- dataLabels: {
- enabled: true,
- color: "#FFFFFF",
- align: "center",
- },
- };
- series.push(obj);
- });
- var chartDto = {
- legends: legends,
- series: series,
- };
- statusChart.hideLoading();
- render3DTwoDayAlarm("alarmBar", series, xDatas);
- } else {
- }
- } else {
- alert("加载机台状态与报警数据失败");
- }
- })
- .catch((resp) => {
- console.log("请求失败:" + resp.status + "," + resp.statusText);
- });
- }
- // 绘制饼图
- function renderMacStatusPie(chart, legends, data) {
- // 基于准备好的dom,初始化echarts实例
- chart.hideLoading();
- var option = {
- tooltip: {
- trigger: "item",
- formatter: "{b} : {c} 分钟 ({d}%)",
- },
- legend: {
- top: "15%",
- data: legends,
- icon: "circle",
- textStyle: {
- color: "rgba(255,255,255,.6)",
- },
- show: false,
- },
- grid: {
- left: "15%",
- top: "15%",
- right: "15%",
- bottom: "15%",
- show: false,
- },
- calculable: true,
- series: [
- {
- name: "",
- color: [
- "#62c98d",
- "#2f89cf",
- "#4cb9cf",
- "#53b666",
- "#62c98d",
- "#205acf",
- "#c9c862",
- "#c98b62",
- "#c962b9",
- "#c96262",
- ],
- type: "pie",
- radius: "70%",
- //饼图的半径,数组的第一项是内半径,第二项是外半径
- radius: ["30%", "70%"],
- //支持设置成百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度
- center: ["50%", "55%"],
- //是否展示成南丁格尔图,通过半径区分数据大小。可选择两种模式:
- // 'radius' 面积展现数据的百分比,半径展现数据的大小。
- // 'area' 所有扇区面积相同,仅通过半径展现数据大小
- // roseType: 'radius',
- //是否启用防止标签重叠策略,默认开启,圆环图这个例子中需要强制所有标签放在中心位置,可以将该值设为 false。
- avoidLabelOverlap: false,
- label: {
- normal: {
- show: true,
- // formatter: '{c}辆'
- },
- // emphasis: {
- // show: true
- // }
- },
- labelLine: {
- normal: {
- show: true,
- length2: 1,
- },
- emphasis: {
- show: true,
- },
- },
- data: data,
- },
- ],
- };
- // 使用刚指定的配置项和数据显示图表。
- chart.setOption(option);
- window.addEventListener("resize", function () {
- chart.resize();
- });
- }
- // 绘制机台状态3D饼图
- function render3DStatusPie(chart, legends, data) {
- var chartPie;
- var option = {
- chart: {
- type: "pie",
- backgroundColor: "transparent",
- options3d: {
- enabled: true,
- alpha: 45,
- },
- renderTo: chart,
- },
- title: {
- text: null,
- },
- plotOptions: {
- pie: {
- innerSize: 45,
- depth: 35,
- },
- },
- credits: {
- enabled: false,
- },
- tooltip: {
- formatter: function () {
- return (
- "<b>" +
- this.point.name +
- "</b>: " +
- Highcharts.numberFormat(this.percentage, 2) +
- "% (" +
- Highcharts.numberFormat(this.y, 2, ".") +
- " 分钟)"
- );
- },
- },
- series: [
- {
- name: "状态",
- // dataLabels: {
- // enabled: true,
- // color:'#fff'
- // },
- data: [],
- },
- ],
- };
- option.series[0].data = data;
- chartPie = Highcharts.chart(option);
- }
- // 加载两日产量
- function loadDayOutput(macCode, startTime, endTime) {
- var myChart = echarts.init(document.getElementById("twoDaysOutputBar"));
- myChart.showLoading(chartLoading);
- axios
- .get(`${prefix}MacStatusTotalInfo/GetTotalInfoDeatilForCount`, {
- params: {
- macCode,
- time: dateFormat("yyyy-MM-dd HH:mm:ss", new Date(startTime)),
- },
- })
- .then((res) => {
- if (res && res.code === 1) {
- var datas = res.data;
- var xDatas = []; // X轴文字
- var legends = []; // 图例文字
- var seriesData = [];
- datas.forEach((item) => {
- if (xDatas.indexOf(item.day) === -1) {
- xDatas.push(item.day);
- }
- if (legends.indexOf(item.class) === -1) {
- legends.push(item.class);
- }
- });
- if (legends.length > 0) {
- legends.forEach((item) => {
- var classOutPuts = [];
- datas.forEach((element) => {
- if (element.class === item) {
- var count = element.count;
- // if (count === '0') {
- // classOutPuts.push(null);
- // } else {
- classOutPuts.push(parseInt(element.count));
- //}
- }
- });
- seriesData.push({
- key: item,
- values: classOutPuts,
- });
- });
- }
- var colorStopses = [
- [
- {
- offset: 0,
- color: "#AE48F2",
- },
- {
- offset: 1,
- color: "#AE48F2",
- },
- ],
- [
- {
- offset: 0,
- color: "#66b8a7",
- },
- {
- offset: 1,
- color: "#66b8a7",
- },
- ],
- ];
- var barColors = ["#45C295", "#75FDD4"];
- var series = [];
- seriesData.forEach((item, index) => {
- //#region Ecahrts数据
- // var obj = {
- // name: item.key,
- // type: "bar",
- // data: item.values,
- // barWidth: "30%",
- // itemStyle: {
- // normal: {
- // color: {
- // type: "linear",
- // x: 0,
- // y: 0,
- // x2: 0,
- // y2: 1,
- // colorStops: colorStopses[index],
- // globalCoord: false
- // }
- // }
- // },
- // label: {
- // show: true,
- // color: '#fff',
- // position: 'top',
- // formatter: function (params) {
- // if (params.data == 0) {
- // return '';
- // }
- // return params.data;
- // }
- // },
- // barGap: "0"
- // };
- //#endregion
- var obj = {
- name: item.key,
- data: item.values,
- dataLabels: {
- enabled: true,
- color: "#FFFFFF",
- align: "center",
- formatter: function () {
- return this.y;
- },
- },
- };
- series.push(obj);
- });
- var chartDto = {
- legends: legends,
- series: series,
- };
- }
- myChart.hideLoading();
- render3DTwoDayOutput("twoDaysOutputBar", series, xDatas);
- // renderTwoDaysOutputBar(myChart, legends, xDatas, series);
- // renderTwoDaysOutputNew(myChart, chartDto);
- })
- .catch((resp) => {
- console.log("请求失败:" + resp.status + "," + resp.statusText);
- });
- }
- function renderTwoDaysOutputNew(chart, chartDto) {
- var myData = chartDto.legends;
- var databeast = {
- 1: [38, 25, 26, 32],
- };
- var databeauty = {
- 1: [11, 38, 23, 30],
- };
- var timeLineData = [1];
- var option = {
- baseOption: {
- backgroundColor: "transparent",
- timeline: {
- show: false,
- top: 0,
- data: [],
- },
- legend: {
- show: true,
- left: "30%",
- top: 30,
- icon: "rect",
- textStyle: {
- itemGap: 12, //图例每项之间的间隔
- color: [],
- fontStyle: "normal",
- fontFamily: "微软雅黑",
- fontSize: 14,
- },
- },
- tooltip: {
- show: true,
- trigger: "axis",
- formatter: "{b}<br/>{c} {a}",
- axisPointer: {
- type: "shadow",
- },
- },
- grid: [
- {
- show: false,
- left: "8%",
- top: 60,
- bottom: 0,
- containLabel: true,
- width: "30%",
- },
- {
- show: false,
- left: "57%",
- top: 60,
- bottom: 0,
- width: "0%",
- },
- {
- show: false,
- right: "8%",
- top: 60,
- bottom: 0,
- containLabel: true,
- width: "30%",
- },
- ],
- xAxis: [
- {
- type: "value",
- inverse: true,
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- position: "top",
- axisLabel: {
- show: false,
- },
- splitLine: {
- show: false,
- },
- },
- {
- gridIndex: 1,
- show: false,
- },
- {
- gridIndex: 2,
- nameTextStyle: {
- color: "#50afff",
- fontSize: 14,
- },
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- position: "top",
- axisLabel: {
- show: false,
- },
- splitLine: {
- show: false,
- },
- },
- ],
- yAxis: [
- {
- type: "category",
- inverse: true,
- position: "right",
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- axisLabel: {
- show: false,
- },
- data: myData,
- },
- {
- gridIndex: 1,
- type: "category",
- inverse: true,
- position: "left",
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- axisLabel: {
- show: true,
- textStyle: {
- color: "#fff",
- fontSize: 14,
- },
- },
- data: myData.map(function (value) {
- return {
- value: value,
- textStyle: {
- align: "center",
- },
- };
- }),
- },
- {
- gridIndex: 2,
- type: "category",
- inverse: true,
- position: "left",
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- axisLabel: {
- show: false,
- },
- data: myData,
- },
- ],
- series: [
- ,
- {
- name: "今天",
- type: "bar",
- barWidth: 18,
- xAxisIndex: 2,
- yAxisIndex: 2,
- label: {
- normal: {
- show: true,
- position: "right",
- offset: [0, 0],
- textStyle: {
- color: "#fff",
- fontSize: 14,
- },
- },
- },
- itemStyle: {
- normal: {
- color: "#25f3e6",
- // barBorderRadius: 50
- },
- },
- data: databeauty[timeLineData[0]],
- },
- ],
- },
- options: [],
- };
- chart.hideLoading();
- chart.setOption(option);
- window.addEventListener("resize", function () {
- chart.resize();
- });
- }
- // 俩日产量3D柱状图
- function render3DTwoDayOutput(elementName, series, xdata) {
- var chart;
- var options = {
- chart: {
- type: "column",
- renderTo: elementName,
- // marginBottom: 30,
- // marginLeft: 20,
- // marginTop: 20,
- // marginRight: 20,
- margin: 30,
- backgroundColor: "rgba(0,0,0,0)",
- options3d: {
- enabled: true,
- alpha: 30,
- beta: 0,
- depth: 100,
- viewDistance: 100, // 视图距离,它对于计算角度影响在柱图和散列图非常重要。此值不能用于3D的饼图
- frame: {
- // Frame框架,3D图包含柱的面板,我们以X ,Y,Z的坐标系来理解,X轴与 Z轴所形成
- // 的面为bottom,Y轴与Z轴所形成的面为side,X轴与Y轴所形成的面为back,bottom、
- // side、back的属性一样,其中size为感官理解的厚度,color为面板颜色
- bottom: {
- size: 20,
- },
- side: {
- size: 1,
- color: "transparent",
- },
- back: {
- size: 1,
- color: "transparent",
- },
- },
- },
- },
- title: {
- text: null,
- },
- plotOptions: {
- column: {
- depth: 25,
- },
- },
- colors: ["#7cb5ec", "#e4d354"],
- credits: {
- enabled: false,
- },
- legend: {
- enabled: false,
- },
- xAxis: {
- categories: xdata,
- labels: {
- style: {
- color: "#fff",
- },
- },
- gridLineColor: "rgba(255,255,255,0.3)",
- },
- yAxis: {
- min: 0,
- minRange: 100,
- title: {
- text: null,
- },
- labels: {
- style: {
- color: "#fff",
- },
- },
- gridLineColor: "rgba(255,255,255,0.3)",
- },
- series: [],
- };
- options.series = series;
- chart = Highcharts.chart(options);
- }
- // 加载分时产量
- function loadTimeOutput(macCode, startTime, endTime) {
- var timeOutputBarCharat = echarts.init(
- document.getElementById("timeOutputBar", "walden")
- );
- timeOutputBarCharat.showLoading(chartLoading);
- axios
- .get(`${prefix}MacStatusTotalInfo/GetTotalInfoDeatilForCountHour`, {
- params: {
- macCode,
- time: dateFormat("yyyy-MM-dd HH:mm:ss", new Date(startTime)),
- },
- })
- .then((res) => {
- if (res && res.code === 1) {
- // appendOutputBar(timeOutputBarCharat, chartDto); // 渲染分时产量柱状图
- appendOutputLine(timeOutputBarCharat, res.data.countHour);
- } else {
- alert("加载分时产量失败");
- }
- })
- .catch((resp) => {
- console.log("请求失败:" + resp.status + "," + resp.statusText);
- });
- }
- // 分时产量折线图
- function appendOutputLine(chart, data) {
- var xData = [];
- var yData = [];
- xData.push(8);
- yData.push(null);
- data.forEach((item) => {
- if (item.hour === 8) {
- xData.push(item.hour + ":" + "30");
- } else {
- xData.push(item.hour);
- }
- yData.push(parseInt(item.count));
- });
- var chartDto = {
- xData: xData,
- yData: yData,
- };
- renderHourOutputLine(chart, chartDto);
- }
- // 根据返回的数据渲染分时产量柱状图
- function appendOutputBar(chart, data) {
- var xdata = [];
- var ydata = [];
- var countHours = res.data.countHour;
- if (countHours && countHours.length > 0) {
- countHours.forEach((item) => {
- xdata.push(item.hour.split(" ")[1].split(":")[0]);
- ydata.push(item.count);
- });
- var chartDto = {
- title: "分时产量",
- legend: [],
- xdata: xdata,
- ydata: ydata,
- };
- }
- renderHourOutputBar(chart, chartDto);
- }
- // 绘制两日报警柱状图
- function renderTwoDaysAlarmBar(chart, legends, xData, series) {
- var option = {
- tooltip: {
- trigger: "axis",
- axisPointer: {
- lineStyle: {
- color: "#57617B",
- },
- },
- },
- legend: {
- data: legends,
- top: "0%",
- textStyle: {
- color: "rgba(255,255,255,0.9)", //图例文字
- },
- show: false,
- },
- xAxis: [
- {
- type: "category",
- data: xData,
- axisLine: { lineStyle: { color: "rgba(255,255,255,.1)" } },
- axisLabel: {
- textStyle: { color: "rgba(255,255,255,1)", fontSize: "14" },
- },
- },
- ],
- yAxis: [
- {
- type: "value",
- name: "",
- // "interval": 10,
- axisLabel: {
- show: true,
- color: "#fff",
- },
- axisLine: { lineStyle: { color: "rgba(255,255,255,.4)" } }, //左线色
- },
- ],
- grid: {
- top: "15%",
- right: "15%",
- bottom: "15%",
- left: "15%",
- show: false,
- },
- series: series,
- };
- // 使用刚指定的配置项和数据显示图表。
- chart.hideLoading();
- chart.setOption(option);
- window.addEventListener("resize", function () {
- chart.resize();
- });
- }
- // 俩日报警3D柱状图
- function render3DTwoDayAlarm(elementName, series, xdata) {
- var chart;
- var options = {
- chart: {
- type: "column",
- renderTo: elementName,
- // marginBottom: 30,
- // marginLeft: 20,
- // marginTop: 20,
- // marginRight: 20,
- margin: 30,
- backgroundColor: "rgba(0,0,0,0)",
- options3d: {
- enabled: true,
- alpha: 30,
- beta: 0,
- depth: 100,
- viewDistance: 100, // 视图距离,它对于计算角度影响在柱图和散列图非常重要。此值不能用于3D的饼图
- frame: {
- // Frame框架,3D图包含柱的面板,我们以X ,Y,Z的坐标系来理解,X轴与 Z轴所形成
- // 的面为bottom,Y轴与Z轴所形成的面为side,X轴与Y轴所形成的面为back,bottom、
- // side、back的属性一样,其中size为感官理解的厚度,color为面板颜色
- bottom: {
- size: 20,
- },
- side: {
- size: 1,
- color: "transparent",
- },
- back: {
- size: 1,
- color: "transparent",
- },
- },
- },
- },
- title: {
- text: null,
- },
- plotOptions: {
- column: {
- depth: 30,
- },
- cursor: "pointer",
- series: {
- cursor: "pointer",
- events: {
- click: function (event) {
- layer.open({
- type: 2,
- title: `机台【${macCode} ${event.point.category} ${event.point.series.name}】报警明细`,
- shadeClose: true,
- shade: false,
- maxmin: true, //开启最大化最小化按钮
- area: ["993px", "600px"],
- content: `./mac-alarm-detail.html?fcode=${macCode}&date=${
- event.point.category
- }&shift=${escape(event.point.series.name)}`,
- });
- },
- },
- },
- },
- colors: ["#E69D87", "#D43239"],
- credits: {
- enabled: false,
- },
- legend: {
- enabled: false,
- },
- xAxis: {
- categories: xdata,
- labels: {
- style: {
- color: "#fff",
- },
- },
- splitLine: {
- show: false,
- },
- gridLineColor: "rgba(255,255,255,0.3)",
- },
- yAxis: {
- min: 0,
- minRange: 100,
- title: {
- text: null,
- },
- labels: {
- style: {
- color: "#fff",
- },
- },
- gridLineColor: "rgba(255,255,255,0.3)",
- },
- series: [],
- };
- options.series = series;
- chart = Highcharts.chart(options);
- }
- // 绘制两日产量柱状图
- function renderTwoDaysOutputBar(chart, legends, xData, series) {
- var option = {
- tooltip: {
- trigger: "axis",
- axisPointer: {
- lineStyle: {
- color: "#57617B",
- },
- },
- },
- legend: {
- data: legends,
- top: "0%",
- textStyle: {
- color: "rgba(255,255,255,0.9)", //图例文字
- },
- show: false,
- },
- xAxis: [
- {
- type: "category",
- data: xData,
- axisLine: { lineStyle: { color: "rgba(255,255,255,.1)" } },
- axisLabel: {
- textStyle: { color: "rgba(255,255,255,1)", fontSize: "14" },
- },
- },
- ],
- yAxis: [
- {
- type: "value",
- name: "",
- // "interval": 10,
- axisLabel: {
- show: true,
- color: "#fff",
- },
- axisLine: { lineStyle: { color: "rgba(255,255,255,.4)" } }, //左线色
- },
- ],
- grid: {
- top: "15%",
- right: "15%",
- bottom: "15%",
- left: "15%",
- show: false,
- },
- series: series,
- };
- // 使用刚指定的配置项和数据显示图表。
- chart.hideLoading();
- chart.setOption(option);
- window.addEventListener("resize", function () {
- chart.resize();
- });
- }
- // 渲染分时产量柱状图
- function renderHourOutputBar(chart, chartDto) {
- var options = {
- title: {
- text: chartDto.text,
- },
- tooltip: {
- // formatter: function (params, ticket, callback) {
- // var toolTip = '';
- // alarms.forEach(item => {
- // if (item.alarmCode === params.name) {
- // toolTip = item.alarmDescribe;
- // }
- // });
- // return toolTip;
- // }
- },
- legend: {
- data: chartDto.legend,
- },
- grid: {
- right: "15%",
- bottom: "15%",
- top: "15%",
- left: "15%",
- },
- xAxis: {
- data: chartDto.xdata,
- axisLabel: {
- interval: 2,
- textStyle: {
- color: "#fff",
- },
- },
- },
- yAxis: {
- axisLabel: {
- textStyle: {
- color: "#fff",
- },
- },
- },
- series: [
- {
- name: "产量",
- type: "bar",
- barMaxWidth: 35,
- data: chartDto.ydata,
- itemStyle: {
- normal: {
- color: "rgb(120,200,235)",
- label: {
- show: false, // 开启显示
- position: "top", // 在上方显示
- textStyle: {
- // 数值样式
- color: "#fff",
- fontSize: 12,
- interval: 2,
- },
- },
- },
- },
- },
- ],
- };
- chart.hideLoading();
- chart.setOption(options);
- window.addEventListener("resize", function () {
- chart.resize();
- });
- }
- // 渲染分时产量折线图
- function renderHourOutputLine(chart, chartDto) {
- var options = {
- tooltip: {
- axisPointer: {
- axis: "x",
- type: "none",
- },
- position: function (pt) {
- return [pt[0], "5%"];
- },
- formatter: function (params) {
- // console.log(params);
- return params.name + "点产量:" + params.value;
- },
- },
- title: {
- left: "left",
- show: false,
- },
- legend: {
- width: "70%",
- show: false,
- },
- grid: {
- right: "15%",
- bottom: "15%",
- top: "15%",
- left: "15%",
- },
- xAxis: {
- type: "category",
- boundaryGap: false,
- data: chartDto.xData,
- axisLabel: {
- // interval: 2,
- textStyle: {
- color: "#fff",
- },
- },
- },
- yAxis: {
- type: "value",
- axisLabel: {
- // interval: 2,
- textStyle: {
- color: "#fff",
- },
- },
- },
- dataZoom: [
- {
- type: "inside",
- start: 0,
- end: 100,
- },
- {
- start: 0,
- end: 10,
- handleSize: "80%",
- show: false,
- handleStyle: {
- color: "#fff",
- shadowBlur: 3,
- shadowColor: "rgba(0, 0, 0, 0.6)",
- shadowOffsetX: 2,
- shadowOffsetY: 2,
- },
- },
- ],
- series: {
- name: "产量",
- type: "line",
- data: chartDto.yData,
- itemStyle: {
- normal: {
- color: "#F6C948",
- label: {
- show: true, // 开启显示
- position: "top", // 在上方显示
- textStyle: {
- // 数值样式
- color: "#fff",
- fontSize: 11,
- interval: 0,
- },
- },
- },
- },
- },
- };
- chart.hideLoading();
- chart.setOption(options);
- window.addEventListener("resize", function () {
- chart.resize();
- });
- }
- // 渲染报警统计柱状图
- function renderAlarmBar(chart, chartDto, alarms) {
- var max = 0;
- if (alarms && alarms.length > 0) {
- max = alarms[0].alarmCount;
- alarms.forEach((item) => {
- if (max < item.alarmCount) {
- max = item.alarmCount;
- }
- });
- }
- var options = {
- title: {
- text: chartDto.text,
- },
- tooltip: {
- formatter: function (params, ticket, callback) {
- var toolTip = "";
- alarms.forEach((item) => {
- if (item.alarmCode === params.name) {
- toolTip = item.alarmDescribe;
- }
- });
- return toolTip;
- },
- },
- legend: {
- data: chartDto.legend,
- },
- grid: {
- right: "15%",
- bottom: "15%",
- top: "15%",
- left: "15%",
- },
- xAxis: {
- data: chartDto.xdata,
- axisLabel: {
- interval: 2,
- textStyle: {
- color: "#fff",
- },
- },
- },
- yAxis: {
- // min: 0,
- // max: max,
- // splitNumber: 2,
- axisLabel: {
- textStyle: {
- color: "#fff",
- },
- },
- },
- series: [
- {
- name: "报警次数",
- type: "bar",
- barMaxWidth: 35,
- data: chartDto.ydata,
- itemStyle: {
- normal: {
- color: "rgb(255,0,0)",
- label: {
- show: true, // 开启显示
- position: "top", // 在上方显示
- textStyle: {
- // 数值样式
- color: "#fff",
- fontSize: 12,
- },
- },
- },
- },
- },
- ],
- };
- chart.hideLoading();
- chart.setOption(options);
- window.addEventListener("resize", function () {
- chart.resize();
- });
- }
- var legends = ["RUN", "DISCONN", "REPAIR", "PM", "ERROR", "IDLE", "CHANGE"];
- //#region 稼动历史
- // 渲染机台稼动历史图表
- function renderRunHistory(macCode, startTime, endTime) {
- var dateNow = new Date();
- var dateStart = startTime;
- var dateEnd = endTime;
- axios
- .get(`${prefix}MacStatusTotalInfo/GetRunHistroy`, {
- params: {
- macCode,
- startTime: dateStart,
- endTime: dateEnd,
- },
- })
- .then((res) => {
- if (res && res.code === 1) {
- var data = [];
- var categories = [""];
- var datas = res.data;
- datas.forEach((item, index) => {
- data.push({
- name: item.name,
- value: [
- index,
- item.startTime,
- item.endTime,
- item.timeLen,
- item.startString,
- item.endString,
- item.statusName,
- item.duration,
- ],
- itemStyle: {
- normal: {
- color: `rgb(${item.color.red},${item.color.green},${item.color.blue})`,
- },
- },
- });
- });
- option = {
- tooltip: {
- formatter: function (params) {
- return (
- params.marker +
- params.value[6] +
- ": " +
- "从 " +
- params.value[4] +
- " 到 " +
- params.value[5] +
- " 持续 " +
- params.value[7]
- );
- },
- },
- title: {
- show: false,
- },
- grid: {
- right: "5%",
- height: 60,
- top: "4%",
- left: "5%",
- },
- legend: {
- data: legends,
- bottom: 0,
- left: "center",
- textStyle: {
- color: "#ffffff",
- },
- },
- dataZoom: [
- {
- type: "slider",
- filterMode: "weakFilter",
- showDataShadow: false,
- show: false,
- top: 150,
- height: 5,
- borderColor: "transparent",
- backgroundColor: "#e2e2e2",
- handleIcon:
- "M10.7,11.9H9.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z", // jshint ignore:line
- handleSize: 10,
- handleStyle: {
- shadowBlur: 6,
- shadowOffsetX: 1,
- shadowOffsetY: 2,
- shadowColor: "#aaa",
- },
- labelFormatter: "",
- },
- {
- type: "inside",
- filterMode: "weakFilter",
- },
- ],
- // grid: {
- //
- // },
- xAxis: {
- type: "time",
- min: dateStart,
- max: dateEnd,
- axisLabel: {
- formatter: function (val) {
- var date = new Date(val);
- var valStr = dateFormat("yyyy-MM-dd H:mm", date);
- return valStr.split(" ")[1];
- },
- color: "#fff",
- interval: 0,
- },
- },
- yAxis: {
- data: categories,
- axisLabel: {
- show: false,
- },
- },
- series: [
- {
- type: "custom",
- progressive: 0,
- progressiveThreshold: 1,
- renderItem: renderItem,
- itemStyle: {
- opacity: 1,
- },
- encode: {
- x: [1, 2],
- y: 0,
- },
- data: data,
- },
- ],
- };
- var runHistoryChart = echarts.init(
- document.getElementById("runHistory", "walden")
- );
- runHistoryChart.setOption(option);
- window.addEventListener("resize", function () {
- runHistoryChart.resize();
- });
- var nowStr = dateFormat("yyyy-MM-dd", new Date()) + " 08:30:00";
- var dayStart = new Date(
- dateFormat("yyyy-MM-dd", new Date()) + " 00:00:00"
- );
- var todayShiftStart = new Date(
- dateFormat("yyyy-MM-dd", new Date()) + " 08:30:00"
- );
- var now = new Date();
- if (timeOut) {
- clearTimeout(timeOut);
- }
- if (
- dateStart == nowStr ||
- isBetweenZeroAndShiftStart(new Date(dateStart))
- ) {
- timeOut = setTimeout(() => {
- appendRunHistory(macCode, runHistoryChart, dateStart, true);
- }, 60 * 1000);
- }
- } else {
- alert("加载机台运行状态失败");
- }
- })
- .catch((resp) => {
- console.log("请求失败:" + resp.status + "," + resp.statusText);
- });
- }
- function renderItem(params, api) {
- var categoryIndex = api.value(0);
- var start = api.coord([api.value(1), categoryIndex]);
- var end = api.coord([api.value(2), categoryIndex]);
- var height = api.size([0, 1])[1] * 1;
- var rectShape = echarts.graphic.clipRectByRect(
- {
- x: start[0],
- y: start[1] - height / 2,
- width: end[0] - start[0],
- height: height,
- },
- {
- x: params.coordSys.x,
- y: params.coordSys.y,
- width: params.coordSys.width,
- height: params.coordSys.height,
- }
- );
- return (
- rectShape && {
- type: "rect",
- shape: rectShape,
- style: api.style(),
- }
- );
- }
- function appendRunHistory(macCode, runHistoryChart, startTime, interval) {
- var dateNow = new Date();
- var dateEndNew = dateFormat("yyyy-MM-dd HH:mm:ss", dateNow);
- axios
- .get(`${prefix}MacStatusTotalInfo/GetRunHistroy`, {
- params: {
- macCode,
- startTime: startTime,
- endTime: dateEndNew,
- },
- })
- .then((res) => {
- if (res && res.code === 1) {
- var data = [];
- var categories = [""];
- var datas = res.data;
- datas.forEach((item, index) => {
- // var typeItem;
- // types.forEach(t => {
- // if (t.name === item.status) {
- // typeItem = t;
- // }
- // });
- data.push({
- name: item.name,
- value: [
- index,
- item.startTime,
- item.endTime,
- item.timeLen,
- item.startString,
- item.endString,
- item.statusName,
- item.duration,
- ],
- itemStyle: {
- normal: {
- color: `rgb(${item.color.red},${item.color.green},${item.color.blue})`,
- },
- },
- });
- });
- runHistoryChart.setOption({
- series: {
- data: data,
- },
- xAxis: {
- max: dateEndNew,
- },
- });
- }
- if (timeOut) {
- clearTimeout(timeOut);
- }
- timeOut = setTimeout(() => {
- appendRunHistory(macCode, runHistoryChart, startTime);
- }, 60 * 1000);
- })
- .catch((resp) => {
- console.log("请求失败:" + resp.status + "," + resp.statusText);
- });
- }
- // 获取状态对应的颜色
- function returnColor(status) {
- var color = "#ccc";
- types.forEach((item) => {
- if (item.desc === status) {
- color = item.color;
- }
- });
- return color;
- }
- //#endregion
|