[Frontend] 透過baja 取得設備的異常資訊
This commit is contained in:
		
							parent
							
								
									92f8c45436
								
							
						
					
					
						commit
						821d787ceb
					
				@ -232,9 +232,8 @@
 | 
			
		||||
                    console.log($(oriEle).data("number"))
 | 
			
		||||
                    //基本資料tab block
 | 
			
		||||
                    $("#info").html(drawInfoTabBlo(devGuid));
 | 
			
		||||
                    loadErr($(oriEle).data("number"));
 | 
			
		||||
                    loadOpeRecTable(devGuid);
 | 
			
		||||
                    //loadErrRecTable2($(oriEle).data("number"));
 | 
			
		||||
                    loadErrRecTable();
 | 
			
		||||
                }
 | 
			
		||||
            })
 | 
			
		||||
        })
 | 
			
		||||
@ -285,10 +284,20 @@
 | 
			
		||||
        let opeRecTable = new YourTeam.JqDataTables.getTableByAjax(url, tag, null, columns, column_defs, null, null, null, null, null, null, "tpi");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function loadErrRecTable() {
 | 
			
		||||
    function loadErr(allPath) {
 | 
			
		||||
        if (allPath != undefined && allPath != null) {
 | 
			
		||||
            let _pathArr = allPath.split("_");//TPE_B1_ELEV_EL_R2F_NA_ELEV1_N1
 | 
			
		||||
            let _devicePath = _pathArr[0] + "_" + _pathArr[1] + "_" + _pathArr[2] + "_" + _pathArr[3] + "_" + _pathArr[4] + "_" + _pathArr[5];
 | 
			
		||||
            getOneDeviceAlarmTop10ByBaja(_devicePath, callbackForErr);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            console.log("no device");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function callbackForErr(result) {
 | 
			
		||||
        let tag = "#errRecTable";
 | 
			
		||||
        let datas;
 | 
			
		||||
        //getOneDeviceAlarmTop10ByBaja(_devicePath, callback);
 | 
			
		||||
 | 
			
		||||
        let column_defs = [
 | 
			
		||||
            { "targets": [0], "width": "15%", "sortable": true },
 | 
			
		||||
@ -312,61 +321,19 @@
 | 
			
		||||
                "data": "ackState",
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "title": "發生/賦歸時間",
 | 
			
		||||
                "data": "timestamp",
 | 
			
		||||
                "width": "45%",
 | 
			
		||||
                "title": "發生/完成時間",
 | 
			
		||||
                "data": "normalTime",
 | 
			
		||||
                "render": function (data, type, row) {
 | 
			
		||||
                    return row.timestamp + "<br>" + data;
 | 
			
		||||
                },
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        //let callback = function (result) {
 | 
			
		||||
        //    datas = result;
 | 
			
		||||
        //}
 | 
			
		||||
        let result = '{"count": 2,"data":[{ "uuid": "43dc7846-bd96-4be2-ab35-f11aec729c60","msgText": "","ackState": "1","timestamp": "2022-Nov-16 10:30:24.951 AM UTC+08:00"},{"uuid": "7c309846-d862-4a8b-803b-cdc8e0efa092","msgText": "","ackState": "1","timestamp": "2022-Nov-16 10:00:24.893 AM UTC+08:00"}]}';
 | 
			
		||||
        let json_object = JSON.parse(result);
 | 
			
		||||
        datas = json_object['data'];
 | 
			
		||||
        errRecTable = new YourTeam.JqDataTables.getTableByStatic(tag, datas, columns, column_defs, null, null, null, null, "tpi");
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        //function loadErrRecTable2(allPath) {
 | 
			
		||||
        //    if (allPath != undefined && allPath != null) {
 | 
			
		||||
        //        let _pathArr = allPath.split("_");//TPE_B1_ELEV_EL_R2F_NA_ELEV1_N1
 | 
			
		||||
        //        let _devicePath = _pathArr[0] + "_" + _pathArr[1] + "_" + _pathArr[2] + "_" + _pathArr[3] + "_" + _pathArr[4] + "_" + _pathArr[5];
 | 
			
		||||
        //        //getOneDeviceAlarmTop10ByBaja(_devicePath, callback);
 | 
			
		||||
        //        console.log("devicePath: " + _devicePath);
 | 
			
		||||
        //        let result = '{"count": 2,"0": { "uuid": "43dc7846-bd96-4be2-ab35-f11aec729c60","timestamp": "2022-Nov-16 10:30:24.951 AM UTC+08:00","sourceName": "TPE_B1_ELEV_EL_R2F_NA_ELEV1_N1_TRIP","sourceState": "1","msgText": "","ackState": "1","normalTime": "1970-Jan-1 08:00:00.000 AM UTC+08:00"},"1": {"uuid": "7c309846-d862-4a8b-803b-cdc8e0efa092","timestamp": "2022-Nov-16 10:00:24.893 AM UTC+08:00","sourceName": "TPE_B1_ELEV_EL_R2F_NA_ELEV1_N1_TRIP","sourceState": "0","msgText": "","ackState": "1","normalTime": "2022-Nov-16 10:15:24.939 AM UTC+08:00"}}';
 | 
			
		||||
        //        let result_Json = JSON.parse(result)
 | 
			
		||||
        //        var eachTable = $('.each-table tbody');
 | 
			
		||||
 | 
			
		||||
        //        for (var i = 0; i < result_Json['count']; i++)
 | 
			
		||||
        //        {
 | 
			
		||||
        //            item = result_Json[i.toString()];
 | 
			
		||||
        //            eachTable.append(
 | 
			
		||||
        //                '<tr>' +
 | 
			
		||||
        //                '<td>' + item.uuid + '</td>' +
 | 
			
		||||
        //                '<td>' + item.msgText + '</td>' +
 | 
			
		||||
        //                '<td>' + (item.ackState = 1 ? item.normalTime : '未確認') + '</td>' +
 | 
			
		||||
        //                '<td>' + item.timestamp + '</td>' +
 | 
			
		||||
        //                '</tr>');
 | 
			
		||||
        //        }
 | 
			
		||||
 | 
			
		||||
        //    }
 | 
			
		||||
 | 
			
		||||
        //    let callback = function (result) {
 | 
			
		||||
        //        var eachTable = $('.each-table tbody');
 | 
			
		||||
        //        $.each(result, function (index, element) {
 | 
			
		||||
        //            eachTable.append(
 | 
			
		||||
        //                '<tr>' +
 | 
			
		||||
        //                '<td>' + element[index].uuid + '</td>' +
 | 
			
		||||
        //                '<td>' + element[index].msgText + '</td>' +
 | 
			
		||||
        //                '<td>' + (element[index].ackState = 1 ? element[index].normalTime : '未確認') + '</td>' +
 | 
			
		||||
        //                '<td>' + element[index].timestamp + '</td>' +
 | 
			
		||||
        //                '</tr>');
 | 
			
		||||
        //        });
 | 
			
		||||
        //    }
 | 
			
		||||
        //}
 | 
			
		||||
   // }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
@ -88,35 +88,6 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
 | 
			
		||||
 * @param {any} devicePath
 | 
			
		||||
 * @param {any} callback
 | 
			
		||||
 */
 | 
			
		||||
// function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
 | 
			
		||||
//     var _result = "";
 | 
			
		||||
//     var _ss = "";
 | 
			
		||||
//     var _index = 0;
 | 
			
		||||
//     //{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]}
 | 
			
		||||
//     require(['baja!'], function (baja) {
 | 
			
		||||
//         baja.Ord.make("local:|foxs:|alarm:|bql:select top 10 timestamp, ackState, alarmData, alarmData.sourceName, sourceState, uuid, alarmData.msgText, normalTime where alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc").get()
 | 
			
		||||
//             .then(function (table) {
 | 
			
		||||
//                 return table.cursor({
 | 
			
		||||
//                     each: function (record) {
 | 
			
		||||
//                         if (_index == 0)
 | 
			
		||||
//                             _ss += '{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
 | 
			
		||||
//                         else
 | 
			
		||||
//                             _ss += ',{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
 | 
			
		||||
//                         _index++;
 | 
			
		||||
//                     },
 | 
			
		||||
//                     after: function () {
 | 
			
		||||
//                         _result += '{' + '"count": ' + _index +', "data":[';
 | 
			
		||||
 | 
			
		||||
//                         _result += _ss+']';
 | 
			
		||||
//                         _result += '}';
 | 
			
		||||
//                         if (typeof callback === 'function') {
 | 
			
		||||
//                             callback(_result);
 | 
			
		||||
//                         }
 | 
			
		||||
//                     }
 | 
			
		||||
//                 });
 | 
			
		||||
//             });
 | 
			
		||||
//     });
 | 
			
		||||
// }
 | 
			
		||||
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
 | 
			
		||||
    var _result = "";
 | 
			
		||||
    var _ss = "";
 | 
			
		||||
@ -136,16 +107,16 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
 | 
			
		||||
                        var _timestampTemp = new Date(record.get('timestamp').toString());
 | 
			
		||||
                        _occurrenceTime += _timestampTemp.getFullYear().toString() + "-" + addzero(_timestampTemp.getMonth() + 1).toString() + "-" + addzero(_timestampTemp.getDate()).toString() + " " + addzero(_timestampTemp.getHours()).toString() + ":" + addzero(_timestampTemp.getMinutes()).toString() + ":" + addzero(_timestampTemp.getSeconds()).toString();
 | 
			
		||||
 | 
			
		||||
                        //var _occurrenceTime = _timestamp.format("yyyy-MM-dd hh:mm:ss");//.toLocaleString();
 | 
			
		||||
                        var _normaltime = new Date(record.get('normalTime').toString());
 | 
			
		||||
                        _normalTime += _normaltime.getFullYear().toString() + "-" + addzero(_normaltime.getMonth() + 1).toString() + "-" + addzero(_normaltime.getDate()).toString() + " " + addzero(_normaltime.getHours()).toString() + ":" + addzero(_normaltime.getMinutes()).toString() + ":" + addzero(_normaltime.getSeconds()).toString();
 | 
			
		||||
 | 
			
		||||
                        var _msgText = record.get('alarmData').get('msgText') == 1 ? _occurrenceTime : "未確認";
 | 
			
		||||
                        var _msgText = record.get('alarmData').get('msgText');
 | 
			
		||||
                        var _ackText = record.get('ackState') == 1 ? _occurrenceTime : "未確認";
 | 
			
		||||
 | 
			
		||||
                        if (_index == 0)
 | 
			
		||||
                            _ss += '{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
 | 
			
		||||
                            _ss += '{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + _ackText + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
 | 
			
		||||
                        else
 | 
			
		||||
                            _ss += ',{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
 | 
			
		||||
                            _ss += ',{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + _ackText + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
 | 
			
		||||
                        _index++;
 | 
			
		||||
                    },
 | 
			
		||||
                    after: function () {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user