SOURCE

async getGzAlarm(active_status, start_time, end_time, condition, fields) {
    // let url = 'http://10.243.105.156:9080/gateway/event-data-share/dpnode/alarm-query/v1/alarms?pageSize=100&';
    let params = [];
    let condition_arr = [];
    if (condition.length > 1) {
        for (let i = 0; i < condition.length; i++) {
            let field = condition[i].field;
            if (condition[i].value.length > 1) {
                for (let j = 0; j < condition[i].value.length; j++) {
                    let value = condition[i].value;
                }
            } else {
                let value = condition[i].value
            }
            let condition_field_value = { "field": field, "value": value }
            condition_arr.push({ condition_field_value })
        }
    } else {
        let field = condition[0].field;
        if (condition[0].value.length > 1) {
            for (let j = 0; j < condition[0].value.length; j++) {
                let value = condition[0].value;
            }
        } else {
            let value = condition[0].value
        }
        let condition_field_value = { "field": field, "value": value }
        condition_arr.push({ condition_field_value })
    }
    if (fields.length) {
        let fields = fields;
    } else {
        let fields = []
    }
    var send_json = {
        "orgSeverity": orgSeverity,
        "active_status": 1,
        "start_time": start_time,
        "end_time": end_time,
        "condition": condition_arr,
        // [
        //     { "field": "professional_type", "value": [3] },
        //     { "field": "alarm_title_text", "value": ["分支光纤断或OLT检测不到ONT的预期的光信号(LOSi/LOBi)"] },
        //     { "field": "object_class", "value": [200, 300, 8105] }
        // ],
        "fields": fields
    }
    let result = await this.ctx.curl(url, { dataType: 'json' });
    let alarm_list = result.data;
    for (let i = 0; i < alarm_list.length; i++) {
        var json_data = {
            "fp": alarm_list[i].fp,
            "title_text": alarm_list[i].alarm_title_text,
            "city_name": alarm_list[i].region_name,
            "event_time": alarm_list[i].event_time,
            "cancel_time": alarm_list[i].cancel_time,
            "eqp_label": alarm_list[i].eqp_label,
            "ne_label": alarm_list[i].ne_label
        }
        params.push(json_data)
    }
    let result_alarm = params;
    let filter_alarm_list = [];
    if (result_alarm && result_alarm.length) {
        if (group && group.length) {
            for (var i = 0; i < group.length; i++) {
                var result_group = await this.app.redis.get('alarm').smembers(group[i]);
                let alarm = getAlarmForGroup(result_group, result_alarm);
                filter_alarm_list = filter_alarm_list.concat(alarm);
            }
        } else {
            filter_alarm_list = result_alarm;
        }

    }
    return { result: filter_alarm_list };
}











——————————————————————————————————————————————————————————————————————————————————————————————————————————————
async showOspfNeighbor(ne){
    let data = {
        "ne": ne,
        "command_type": "2",
        "vendor": "xx",
        "name": "showOspfInfo"
    }
    let params = {
        params: JSON.stringify(data)
    }
    let result = await this.postToCmdService(params);


    return result
}

async showIsIsNeighbor(ne){
    let data = {
        "ne": ne,
        "command_type": "2",
        "vendor": "xx",
        "name": "showVerbose"
    }
    let params = {
        params: JSON.stringify(data)
    }
    let result = await this.postToCmdService(params);


    return result
}

async showPower(ne){
    let data = {
        "ne": ne,
        "command_type": "2",
        "vendor": "xx",
        "name": "showPower"
    }
    let params = {
        params: JSON.stringify(data)
    }
    let result = await this.postToCmdService(params);


    return result
}
async showLogBuffer(ne){
    let data = {
        "ne": ne,
        "command_type": "2",
        "vendor": "xx",
        "name": "showLogBuffer"
    }
    let params = {
        params: JSON.stringify(data)
    }
    let result = await this.postToCmdService(params);


    return result
}

------------------------------

    async getSysLogLst(starttime, endtime, sourceip) {
    var url = cno_url + 'getSysLogLst';
    var jsonData = {
        "sourceip": sourceip,
        "starttime": starttime,
        "endtime": endtime
    };
    // var result = await this.ctx.curl(url, {
    //     method: 'post',
    //     contentType: 'json',
    //     timeout: [5000, 30000],
    //     dataType: 'json',
    //     data: jsonData,
    // });
    // result = result.data
    var result = {
        "code": 200,
        "attachList": [
            {
                "log": "Apr 21 12:15:18 ::ffff:221.130.208.27 GSLZ-BC-IPNET-RT02-NE40EX16C %%01CLI/5/CMDRECORD(s):CID=0x80ca2713;Recorded command information. (Task=VTY0, RemoteIp=10.7.249.3, VpnName=_public_, User=ipnet_CIOMSS, AuthenticationMethod=\\\"Local-user\\\", Command=\\\"ping -s 64 -c 5 -t 12 10.1.27.254\\\", LocalIp=221.130.208.27.)",
                "timestamp": "2023-04-21 12:15:18"
            },
            {
                "log": "Apr 21 12:15:20 ::ffff:221.130.208.27 GSLZ-BC-IPNET-RT02-NE40EX16C %%01CLI/5/CMDRECORD(s):CID=0x80ca2713;Recorded command information. (Task=VTY0, RemoteIp=10.7.249.3, VpnName=_public_, User=ipnet_CIOMSS, AuthenticationMethod=\\\"Local-user\\\", Command=\\\"ping -s 64 -c 5 -t 12 10.1.27.250\\\", LocalIp=221.130.208.27.)",
                "timestamp": "2023-04-21 12:15:20"
            },
            {
                "log": "Apr 21 12:15:23 ::ffff:221.130.208.27 GSLZ-BC-IPNET-RT02-NE40EX16C %%01CLI/5/CMDRECORD(s):CID=0x80ca2713;Recorded command information. (Task=VTY0, RemoteIp=10.7.249.3, VpnName=_public_, User=ipnet_CIOMSS, AuthenticationMethod=\\\"Local-user\\\", Command=\\\"reset slot\\\", LocalIp=221.130.208.27.)",
                "timestamp": "2023-04-21 12:15:23"
            },
            {
                "log": "Apr 21 12:15:25 ::ffff:221.130.208.27 GSLZ-BC-IPNET-RT02-NE40EX16C %%01CLI/5/CMDRECORD(s):CID=0x80ca2713;Recorded command information. (Task=VTY0, RemoteIp=10.7.249.3, VpnName=_public_, User=ipnet_CIOMSS, AuthenticationMethod=\\\"Local-user\\\", Command=\\\"reboot\\\", LocalIp=221.130.208.27.)",
                "timestamp": "2023-04-21 12:15:25"
            }
        ],
        "msg": "123"
    }

    if (result.code == '200') {
        result = result.attachList;
        let log_array = [];
        for (let i = 0; i < result.length; i++) {
            if (result[i].log.indexOf('reboot') != -1 ||
                result[i].log.indexOf('admin reboot') != -1 ||
                result[i].log.indexOf('admin reboot now') != -1 ||
                result[i].log.indexOf('reload system force') != -1 ||
                result[i].log.indexOf('admin redundancy force-switchover') != -1 ||
                result[i].log.indexOf('admin reboot active') != -1 ||
                result[i].log.indexOf('redundancy switch sc grace') != -1 ||
                result[i].log.indexOf('reset slot') != -1 ||
                result[i].log.indexOf('clear card X') != -1 ||
                result[i].log.indexOf('clear mda X/Y') != -1 ||
                result[i].log.indexOf('reload slot x x grace') != -1 ||
                result[i].log.indexOf('reload slot x x force') != -1 ||
                result[i].log.indexOf('power off  slot  xx') != -1 ||
                result[i].log.indexOf('tools perform card X power-cycle') != -1 ||
                result[i].log.indexOf('power offline shelf x slot x') != -1 ||
                result[i].log.indexOf('power x x off force') != -1 ||
                result[i].log.indexOf('shutdown') != -1 ||
                result[i].log.indexOf('undo shutdown') != -1 ||
                result[i].log.indexOf('shutdown') != -1 ||
                result[i].log.indexOf('no shutdown') != -1 ||
                result[i].log.indexOf('shutdown') != -1 ||
                result[i].log.indexOf('no shutdown') != -1
            ) {
                log_array.push(result[i])
            }
        }
        return { result: log_array }
        // return {result: result}
    } else {
        result = result.msg
        return { result: result }
    }
    // return {result:result}
}

----------------------------------------------------------------------------------------

    function getGzAlarm(active_status, start_time, end_time, condition, fields) {
        let url = 'http://192.168.162.16:8080/msb-consumer/consumer/queryCondition';
        let params = [];
        // let condition_arr = [];
        var send_json = {
            "orgSeverity": "1,2,3",
            "active_status": active_status,
            "start_time": start_time,
            "end_time": end_time
            // "condition": condition_arr,

            // [
            //     { "field": "professional_type", "value": [3] },
            //     { "field": "alarm_title_text", "value": ["分支光纤断或OLT检测不到ONT的预期的光信号(LOSi/LOBi)"] },
            //     { "field": "object_class", "value": [200, 300, 8105] }
            // ],

            // "fields": fields
        }
        if (condition.length > 1) {//查询条件条数大于1条
            for (let i = 0; i < condition.length; i++) {
                let field = condition[i].field;
                if (condition[i].value.length > 1) {//单条查询条件内value值大于1条
                    for (let j = 0; j < condition[i].value.length; j++) {
                        let value = condition[i].value;
                    }
                } else {//单条查询条件内value值仅有1条
                    let value = condition[i].value
                }
                //
                let condition_field_value = { field: value }
                send_json = { send_json, condition_field_value }
                // condition_arr.push({ condition_field_value })
            }
        } else {//查询条件条数仅有1条
            let field = condition[0].field;
            if (condition[0].value.length > 1) {//单条查询条件内value值大于1条
                for (let j = 0; j < condition[0].value.length; j++) {
                    let value = condition[0].value;
                }
            } else {//单条查询条件内value值仅有1条
                let value = condition[0].value
            }
            //
            let condition_field_value = { field: value }
            send_json = { send_json, condition_field_value }
            // condition_arr.push({ condition_field_value })
        }
        //定义需要返回参数
        if (fields.length) {
            let fields = fields;
        } else {
            let fields = []
        }

        var send_msb_json = {
            "orgSeverity": "1,2,3",
            "activeStatus": active_status,
            "startTime": send_json.start_time,
            "endTime": send_json.end_time,
            "eqpLabel": send_json.eqp_label,
            "specialField19": send_json.special_field19,
            "specialField22": send_json.special_field22,
            "typeKeycode": send_json.type_key_code,
            "alarmTitleText": send_json.title_text,
            "regionName": send_json.city_name,
            "vendorName": send_json.vendor,
            "eqpObjectClass": send_json.eqp_object_class
            // "objectClass": send_json.end_time,
            // "networkTypeTop": send_json.end_time,
            // "networkType": send_json.end_time,
            // "subAlarmType": send_json.end_time
        }
        for (let ii = 0; ii < send_msb_json.length; i++) {
            if (send_msb_json[ii] === '') {
                delete send_msb_json[ii]
            }
        }

        var result = await this.ctx.curl(url, {
            method: 'post',
            contentType: 'json',
            timeout: [5000, 30000],
            dataType: 'json',
            data: send_msb_json,
        });

        let alarm_list = result.data;
        for (let i = 0; i < alarm_list.length; i++) {
            var json_data = {
                "fp": alarm_list[i].fp0 + "|" + alarm_list[i].fp1 + "|" + alarm_list[i].fp2 + "|" + alarm_list[i].fp3,
                "title_text": alarm_list[i].alarmTitleText,
                "city_name": alarm_list[i].cityName,
                "event_time": alarm_list[i].eventTime,
                "cancel_time": alarm_list[i].cancelTime,
                "eqp_label": alarm_list[i].eqpLabel,
                "ne_label": alarm_list[i].neLabel
            }
            params.push(json_data)
        }
        // let result_alarm = params;
        // let filter_alarm_list = [];
        // if (result_alarm && result_alarm.length) {
        //     if (group && group.length) {
        //         for (var i = 0; i < group.length; i++) {
        //             var result_group = await this.app.redis.get('alarm').smembers(group[i]);
        //             let alarm = getAlarmForGroup(result_group, result_alarm);
        //             filter_alarm_list = filter_alarm_list.concat(alarm);
        //         }
        //     } else {
        //         filter_alarm_list = result_alarm;
        //     }

        // }
        // return { result: filter_alarm_list };
        return params
    }



for (let i = 0; i < alarm_list.length; i++) {
    var json_data = {
        "fp": alarm_list[i].fp0 + "|" + alarm_list[i].fp1 + "|" + alarm_list[i].fp2 + "|" + alarm_list[i].fp3,
        "title_text": alarm_list[i].alarmTitleText,
        "city_name": alarm_list[i].cityName,
        "event_time": alarm_list[i].eventTime,
        "cancel_time": alarm_list[i].cancelTime,
        "eqp_label": alarm_list[i].eqpLabel,
        "ne_label": alarm_list[i].neLabel,
        "region_name": alarm_list[i].regionName,
        "vendor": alarm_list[i].vendorName,
        "org_severity": alarm_list[i].orgSeverity,
        "active_status": alarm_list[i].activeStatus,
        "resource_status": alarm_list[i].resourceStatus,
        "eqp_object_class": alarm_list[i].eqpObjectClass,
        "object_level": alarm_list[i].objectLevel,
        "object_class": alarm_list[i].objectClass,
        "alarm_resource_status": alarm_list[i].alarmResourceStatus,
        "sheet_send_status": alarm_list[i].sheetSendStatus,
        "sheet_status": alarm_list[i].sheetstatus,
        "sheet_no": alarm_list[i].sheetNo,
        "alarm_ne_status": alarm_list[i].alarmNeStatus,
        "ne_status": alarm_list[i].neStatus,
        "standard_alarm_name": alarm_list[i].standardAlarmName,
        "standard_flag": alarm_list[i].standardFlag,
        "standard_alarm_id": alarm_list[i].standardAlarmId,
        "vendor_severity": alarm_list[i].vendorSeverity,
        "sub_alarm_type": alarm_list[i].subAlarmType,
        "corr_str": alarm_list[i].corrStr,
        "locate_info": alarm_list[i].locateInfo,
        "time_stamp": alarm_list[i].timeStamp,
        "alarm_content": alarm_list[i].alarmContent,
        "alarm_unit": alarm_list[i].alarmUnit,
        "event_id": alarm_list[i].eventId,
        "site_type": alarm_list[i].siteType,
        "network_type_top": alarm_list[i].networkTypeTop,
        "network_type": alarm_list[i].networkType,
        "special_field16": alarm_list[i].specialField16,
        "extra_id3": alarm_list[i].extraId3,
        "special_field22": alarm_list[i].specialField22,
        "alarm_text": alarm_list[i].alarmText,
        "remote_eqp_label": alarm_list[i].remoteEqpLabel,
        "remote_eqp_alias": alarm_list[i].remoteEqpAlias,
        "alarm_reason": alarm_list[i].alarmReason,
        "home_client_num": alarm_list[i].homeClientNum,
        "special_field19": alarm_list[i].specialField19,
        "type_keycode": alarm_list[i].typeKeycode
    }
    params.push(json_data)
}

olt_bng
api
olt_port
getBngByOlt(olt, olt_port)
输入olt_port返回一条数据,非数组。
输入olt,返回
返回[{ olt:,olt_port: }]


async getBngByOlt(olt, olt_port){
    if (olt) {
        var params = [];
        const results = await this.app.mysql.select('posts', { // 搜索 post 表
            where: { olt: olt }, // WHERE 条件
            columns: ['*'], // 要查询的表字段
        });
        for (let i = 0; i < results.length; i++) {
            var olt_port_json = {
                olt: olt,
                olt_port:results.olt_port[i],
                bng: result.bng[i],
                bng_port: result.bng_port[i]
            }
            params.push(olt_port_json);
        }
        return params;
    } else {
        const results = await this.app.mysql.select('posts', { // 搜索 post 表
            where: { olt_port: olt_port }, // WHERE 条件
            columns: ['olt','olt_port','bng','bng_port'], // 要查询的表字段
        });
        // return { bng: results };
        return { bng: results };
    }
}

[{ olt: 123, olt_port: a }, { olt: 123, olt_port: b }]
console 命令行工具 X clear

                    
>
console