123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- $("#date").datepicker({
- format: 'yyyy-mm-dd',
- language: "zh-CN",
- autoclose: true,
- todayBtn: "linked"
- }).on('changeDate', function () {
- zTreeOnClick();
- }).on('keydown', function (e) {
- return false;
- });
- var zTreeObj;
- var setting = {
- callback: {
- onClick: zTreeOnClick
- },
- view: {
- showIcon: false
- }
- };
- $.ajax({
- url: "/ProductionLine/GetProductionLineMachineTree",
- type: "GET",
- async: true,
- success: function (zNodes) {
- zTreeObj = $.fn.zTree.init($("#productionLineTree"), setting, zNodes);
- //zTreeObj.expandAll(false);
- var treeNode = zTreeObj.getNodes()[0];
- zTreeObj.selectNode(treeNode);
- zTreeOnClick();
- }
- });
- function shortcut(key) {
- if (key === -2) {
- var date = new Date();
- var d = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + (date.getDate() - 2);
- $("#date").val(d).datepicker('setDate', d);
- }
- if (key === -1) {
- var date = new Date();
- var d = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + (date.getDate() - 1);
- $("#date").val(d).datepicker('setDate', d);
- }
- if (key === 0) {
- var date = new Date();
- var d = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
- $("#date").val(d).datepicker('setDate', d);
- }
- }
- function zTreeOnClick() {
- var date = $("#date").val();
- var treeNode = zTreeObj.getSelectedNodes()[0];
- if (treeNode.level === 0) {
- $.ajax({
- url: "/ProductionLine/GetProductionLineDayData",
- type: "POST",
- contentType: "application/json",
- async: true,
- dataType: "json",
- data: JSON.stringify({
- "id": treeNode.id,
- "dateTime": date
- }),
- success: function (result) {
- statisticsLine(result.statistics);
- machines(result.machines);
- }
- });
- $.ajax({
- url: "/Fault/GetLineDayTop10Faults",
- type: "GET",
- contentType: "application/json",
- async: true,
- dataType: "json",
- data: {
- "lineId": treeNode.id,
- "day": date,
- "keywords": "安全门,门禁,提示上料,提示卸料"
- },
- success: function (result) {
- alarms(result);
- }
- });
- $("#line").attr("class", "tab-pane active")
- $("#machine").attr("class", "tab-pane")
- }
- if (treeNode.level === 1) {
- $.ajax({
- url: "/ProductionLine/GetMachineDayData",
- type: "POST",
- contentType: "application/json",
- async: true,
- dataType: "json",
- data: JSON.stringify({
- "id": treeNode.id,
- "dateTime": date
- }),
- success: function (result) {
- statistics(result.statistics);
- outPut(result.outPutPerHours);
- alarmsMachine(result.top5FaultRecords);
- }
- });
- $.ajax({
- url: "/Fault/GetMachineDayTop10Faults",
- type: "GET",
- contentType: "application/json",
- async: true,
- dataType: "json",
- data: {
- "machineId": treeNode.id,
- "day": date,
- "keywords": "安全门,门禁,提示上料,提示卸料"
- },
- success: function (result) {
- alarmsMachine(result);
- }
- });
- $("#line").attr("class", "tab-pane")
- $("#machine").attr("class", "tab-pane active")
- }
- }
- function statisticsLine(data) {
- if (data === null || data.length === 0) {
- $("#table_line_oee tbody").html("");
- var tr =
- "<tr>" +
- "<td align='center' colspan='6' >没有找到匹配的记录</td>" +
- "</tr>";
- $("#table_line_oee").append(tr);
- } else {
- $("#table_line_oee tbody").html("");
- for (var i = 0; i < data.length; i++) {
- var tr =
- "<tr>" +
- "<td>" + (i + 1) + "</td>" +
- "<td>" + data[i].moduleType + "</td>" +
- "<td>" + data[i].capacity + "</td>" +
- "<td>" + (data[i].availability === null ? "-" : (data[i].availability * 100).toFixed(1)) + "</td>" +
- "<td>" + (data[i].performance === null ? "-" : (data[i].performance * 100).toFixed(1)) + "</td>" +
- "<td>" + (data[i].oee === null ? "-" : (data[i].oee * 100).toFixed(1)) + "</td>" +
- "</tr>";
- $("#table_line_oee").append(tr);
- }
- }
- }
- function statistics(data) {
- if (data === null || data.length === 0) {
- $("#machine_oee tbody").html("");
- var tr =
- "<tr>" +
- "<td align='center' colspan='6' >没有找到匹配的记录</td>" +
- "</tr>";
- $("#machine_oee").append(tr);
- } else {
- $("#machine_oee tbody").html("");
- for (var i = 0; i < data.length; i++) {
- var tr =
- "<tr>" +
- "<td>" + (i + 1) + "</td>" +
- "<td>" + data[i].moduleType + "</td>" +
- "<td>" + data[i].capacity + "</td>" +
- "<td>" + (data[i].availability === null ? "-" : (data[i].availability * 100).toFixed(1)) + "</td>" +
- "<td>" + (data[i].performance === null ? "-" : (data[i].performance * 100).toFixed(1)) + "</td>" +
- "<td>" + (data[i].oee === null ? "-" : (data[i].oee * 100).toFixed(1)) + "</td>" +
- "</tr>";
- $("#machine_oee").append(tr);
- }
- }
- }
- function outPut(data) {
- if (data === null || data.length === 0) {
- $("#table3 tbody").html("");
- for (var i = 0; i < 1; i++) {
- var tr =
- "<tr>" +
- "<td align='center' colspan='10' >没有找到匹配的记录</td>" +
- "</tr>";
- $("#table3").append(tr);
- }
- $("#table4 tbody").html("");
- for (var i = 0; i < 1; i++) {
- var tr =
- "<tr>" +
- "<td align='center' colspan='10' >没有找到匹配的记录</td>" +
- "</tr>";
- $("#table4").append(tr);
- }
- } else {
- $("#table3 tbody").html("");
- var autoRunTime = 0;
- var alarmTime = 0;
- var idleTime = 0;
- var outPut = 0;
- var alarmSum = 0;
- var loadMATSum = 0;
- var loadMATTime = 0;
- var actualTT = 0;
- for (var i = 0; i < data.length / 2; i++) {
- var tr =
- "<tr>" +
- "<td>" + data[i].period + "</td>" +
- "<td>" + data[i].moduleType + "</td>" +
- "<td>" + data[i].autoRunTime + "</td>" +
- "<td>" + data[i].alarmTime + "</td>" +
- "<td>" + data[i].idleTime + "</td>" +
- "<td>" + data[i].outPut + "</td>" +
- "<td>" + data[i].actualTT + "</td>" +
- "<td>" + data[i].alarmSum + "</td>" +
- "<td>" + data[i].loadMATSum + "</td>" +
- "<td>" + data[i].loadMATTime + "</td>" +
- "</tr>";
- $("#table3").append(tr);
- autoRunTime += data[i].autoRunTime;
- alarmTime += data[i].alarmTime;
- idleTime += data[i].idleTime;
- outPut += data[i].outPut;
- alarmSum += data[i].alarmSum;
- loadMATSum += data[i].loadMATSum;
- loadMATTime += data[i].loadMATTime;
- actualTT += data[i].actualTT;
- }
- var tr =
- "<tr class='total'>" +
- "<td colspan='2'>合计</td>" +
- "<td>" + autoRunTime + "</td>" +
- "<td>" + alarmTime + "</td>" +
- "<td>" + idleTime + "</td>" +
- "<td>" + outPut + "</td>" +
- "<td>" + (actualTT / 12).toFixed(2) + "</td>" +
- "<td>" + alarmSum + "</td>" +
- "<td>" + loadMATSum + "</td>" +
- "<td>" + loadMATTime + "</td>" +
- "</tr>";
- $("#table3").append(tr);
- autoRunTime = 0;
- alarmTime = 0;
- idleTime = 0;
- outPut = 0;
- alarmSum = 0;
- loadMATSum = 0;
- loadMATTime = 0;
- actualTT = 0;
- $("#table4 tbody").html("");
- for (var i = 12; i < data.length; i++) {
- var tr =
- "<tr>" +
- "<td>" + data[i].period + "</td>" +
- "<td>" + data[i].moduleType + "</td>" +
- "<td>" + data[i].autoRunTime + "</td>" +
- "<td>" + data[i].alarmTime + "</td>" +
- "<td>" + data[i].idleTime + "</td>" +
- "<td>" + data[i].outPut + "</td>" +
- "<td>" + data[i].actualTT + "</td>" +
- "<td>" + data[i].alarmSum + "</td>" +
- "<td>" + data[i].loadMATSum + "</td>" +
- "<td>" + data[i].loadMATTime + "</td>" +
- "</tr>";
- $("#table4").append(tr);
- autoRunTime += data[i].autoRunTime;
- alarmTime += data[i].alarmTime;
- idleTime += data[i].idleTime;
- outPut += data[i].outPut;
- alarmSum += data[i].alarmSum;
- loadMATSum += data[i].loadMATSum;
- loadMATTime += data[i].loadMATTime;
- actualTT += data[i].actualTT;
- }
- var tr =
- "<tr class='total'>" +
- "<td colspan='2'>合计</td>" +
- "<td>" + autoRunTime + "</td>" +
- "<td>" + alarmTime + "</td>" +
- "<td>" + idleTime + "</td>" +
- "<td>" + outPut + "</td>" +
- "<td>" + (actualTT / 12).toFixed(2) + "</td>" +
- "<td>" + alarmSum + "</td>" +
- "<td>" + loadMATSum + "</td>" +
- "<td>" + loadMATTime + "</td>" +
- "</tr>";
- $("#table4").append(tr);
- }
- }
- function machines(data) {
- if (data === null || data.length === 0) {
- $("#table1 tbody").html("");
- for (var i = 0; i < 1; i++) {
- var tr =
- "<tr>" +
- "<td align='center' colspan='8' >没有找到匹配的记录</td>" +
- "</tr>";
- $("#table1").append(tr);
- }
- } else {
- $("#table1 tbody").html("");
- for (var i = 0; i < data.length; i++) {
- var td1 = "<td></td>";
- var td2 = "<td></td>";
- var td3 = "<td></td>";
- var td4 = "<td></td>";
- var td5 = "<td></td>";
- if (data[i].statistics !== null && data[i].statistics.length > 0) {
- td1 = "<td><ul style='list-style-type:none;padding-left:0px'>";
- td2 = "<td><ul style='list-style-type:none;padding-left:0px'>";
- td3 = "<td><ul style='list-style-type:none;padding-left:0px'>";
- td4 = "<td><ul style='list-style-type:none;padding-left:0px'>";
- td5 = "<td><ul style='list-style-type:none;padding-left:0px'>";
- for (var j = 0; j < data[i].statistics.length; j++) {
- td1 += "<li>" + data[i].statistics[j].moduleType + "</li>";
- td2 += "<li>" + data[i].statistics[j].capacity + "</li>";
- td3 += "<li>" + (data[i].statistics[j].availability * 100).toFixed(1) + "</li>";
- td4 += "<li>" + (data[i].statistics[j].performance * 100).toFixed(1) + "</li>";
- td5 += "<li>" + (data[i].statistics[j].oee * 100).toFixed(1) + "</li>";
- }
- td1 += "</ul></td>";
- td2 += "</ul></td>";
- td3 += "</ul></td>";
- td4 += "</ul></td>";
- td5 += "</ul></td>";
- }
- var tr =
- "<tr>" +
- "<td>" + (i + 1) + "</td>" +
- "<td>" + data[i].name + "</td>" +
- "<td>" + data[i].type + "</td>" +
- td1 + td2 + td3 + td4 + td5 +
- "</tr>";
- $("#table1").append(tr);
- }
- }
- }
- function alarms(data) {
- if (data === null || data.length === 0) {
- $("#table2 tbody").html("");
- for (var i = 0; i < 1; i++) {
- var tr =
- "<tr>" +
- "<td align='center' colspan='8' >没有找到匹配的记录</td>" +
- "</tr>";
- $("#table2").append(tr);
- }
- } else {
- $("#table2 tbody").html("");
- for (var i = 0; i < data.length; i++) {
- var tr =
- "<tr>" +
- "<td>" + (i + 1) + "</td>" +
- "<td>" + data[i].machineName + "</td>" +
- "<td>" + formatDate(data[i].startTime) + "</td>" +
- "<td>" + formatDate(data[i].endTime) + "</td>" +
- "<td>" + (data[i].machineState === 2 ? "自动" : "手动") + "</td>" +
- "<td>" + (data[i].duration).toFixed(3) + "</td>" +
- "<td>" + data[i].faultCode + "</td>" +
- "<td>" + data[i].faultInfo + "</td>" +
- "</tr>";
- $("#table2").append(tr);
- }
- }
- }
- function alarmsMachine(data) {
- if (data === null || data.length === 0) {
- $("#machine_alarm tbody").html("");
- for (var i = 0; i < 1; i++) {
- var tr =
- "<tr>" +
- "<td align='center' colspan='7' >没有找到匹配的记录</td>" +
- "</tr>";
- $("#machine_alarm").append(tr);
- }
- } else {
- $("#machine_alarm tbody").html("");
- for (var i = 0; i < data.length; i++) {
- var tr =
- "<tr>" +
- "<td>" + (i + 1) + "</td>" +
- "<td>" + formatDate(data[i].startTime) + "</td>" +
- "<td>" + formatDate(data[i].endTime) + "</td>" +
- "<td>" + (data[i].machineState === 2 ? "自动" : "手动") + "</td>" +
- "<td>" + (data[i].duration).toFixed(3) + "</td>" +
- "<td>" + data[i].faultCode + "</td>" +
- "<td>" + data[i].faultInfo + "</td>" +
- "</tr>";
- $("#machine_alarm").append(tr);
- }
- }
- }
|