123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803 |
- 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) => {
- 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
|