#include "local_server.hpp"
 #include <unistd.h>
 #include <boost/lexical_cast.hpp>
#include <json/json.h>
#include <zlog.h>

#include "mqttclient/mqtt_client.h"
#include "common/global.hpp"
#include "common/parameter_defination.hpp"
#include "dbaccess/sql_db.hpp"
#include "common/common_func.hpp"
#include "jsonparse/communication_cmd.hpp"

extern zlog_category_t *zct;

std::string LocalServer::HandleCgi_cmd(std::string &pData) {
    try {
        zlog_info(zct,"HandleCgi Data = %s ", pData.c_str());
        Json::Features f = Json::Features::strictMode();
        Json::Reader recvReader(f);
        Json::Value recvValue;
        Json::Value recvBody;
        if (recvReader.parse(pData, recvValue)) {
            int cmdType = atoi(recvValue["cmd"].asString().c_str());
            std::string cmdBody = "";
            if (!recvValue["cmdBody"].isNull()) {
                recvBody = recvValue["cmdBody"];
                Json::FastWriter fw;
                cmdBody = fw.write(recvBody);
            }
            switch (cmdType) {
                case kLoginUpdateAccount: {
                    Param_01 param;
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("login")) {
                        param.mMode = 0;
                        param.mUserName = recvBody["userName"].asString();
                        param.mPassWord = recvBody["passWord"].asString();
                    } else if (0 == type.compare("upDate")) {
                        param.mMode = 1;
                        param.mUserName = recvBody["userName"].asString();
                        param.mPassWord = recvBody["passWord"].asString();
                        param.mPassWordNew = recvBody["passWordNew"].asString();
                    } else {
                        // TODO: add error log here
                    }
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_01(param);
                    return data;
                } break;
                case kWebTiming: {
                    Param_02 param;
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SET")) {
                        param.mMode = 0;
                        param.mTimeStamp = recvBody["timeStamp"].asInt();
                        param.mSetType = recvBody["setType"].asInt();
                    } else if (0 == type.compare("GET")) {
                        param.mMode = 1;
                    }
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_02(param);
                    return data;
                } break;
                case kWebHWStatus: {
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_07();
                    return data;
                } break;
                case kWebRebootSystem: {
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_08();
                    system("sync");
                    sleep(3);
                    system("reboot");
                    return data;
                } break;
                case kGetFeatureData: {
                    JsonData jd;
                    Param_09 param;
                    param.mPackageFlag = recvBody["package"].asInt();
                    std::string data = jd.JsonCmd_Cgi_09(param);
                    return data;
                } break;
                case kGetHistoryFeatureData: {
                    JsonData jd;
                    Param_10 param;
                    param.strDataNode = recvBody["DataNode"].asString();
                    param.strStatic = recvBody["Static"].asString();
                    param.straxis = recvBody["Raxis"].asString();
                    param.mPackageFlag = recvBody["package"].asInt();
                    param.timeStart = recvBody["timeStart"].asString();
                    param.timeEnd = recvBody["timeEnd"].asString();
                    param.MeasurementID = recvBody["MeasurementID"].asString();
                    std::string data = jd.JsonCmd_Cgi_10(param);
                    return data;
                } break;
                case kWebModifyProperty: {
                    Param_20 param;
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SET")) {
                        param.mMode = 0;
                        param.mDataWatchName = recvBody["SystemInfo"]["dataNodeGatewayName"].asString();
                        param.mDataWatchAssetId = recvBody["SystemInfo"]["dataNodeGatewayAssetId"].asString();
                        param.mDataWatchAddedBy = recvBody["SystemInfo"]["dataNodeGatewayAddedBy"].asString();
                    } else {
                        param.mMode = 1;
                    }
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_20(param);
                    return data;
                } break;
                case kWebTimeZone: {
                    Param_22 param;
                    std::string type = recvBody["type"].asString();
                    param.mCmdSerial = recvValue["cmdSerial"].asString();

                    if (0 == type.compare("SET")) {
                        param.mMode = 0;
                        param.mTimeZone = recvBody["SystemSettings"]["timezone"].asString();
                        ZoneConfig(param.mTimeZone);
                    } else {
                        param.mMode = 1;
                    }
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_22(param);
                    return data;
                } break;
                case kWebMqttBrokerCfg: {
                    std::string type = recvBody["type"].asString();
                    Param_23 param;
                    param.mCmdSerial = recvValue["cmdSerial"].asString();
                    if (0 == type.compare("SET")) {
                        param.mMode = 0;
                        param.mServerIp = recvBody["SystemSettings"]["ServerIpAddress"].asString();
                        param.mPort = boost::lexical_cast<std::string>(recvBody["SystemSettings"]["ServerPort"].asInt());
                        param.mCommMode = recvBody["SystemSettings"]["CommMode"].asString();
                        param.mUserName = recvBody["SystemSettings"]["UserName"].asString();
                        param.mPassword = recvBody["SystemSettings"]["Password"].asString();
                        param.mAPN = recvBody["SystemSettings"]["APN"].asString();
                    } else {
                        param.mMode = 1;
                    }
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_23(param);

                    return data;
                } break;
                case kWebNetworkCfg: {
                    Param_25 param;
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SET")) {
                        param.mNet = recvBody["net"].asString();
                        param.mDnsName = recvBody["dnsName"].asString();
                        param.mGateway = recvBody["gateway"].asString();
                        param.mHostName = recvBody["hostName"].asString();
                        param.mIp = recvBody["dataWatchIpAddress"].asString();
                        param.mSubnetMask = recvBody["subnetMask"].asString();
                        param.mNetworkPortStatus = recvBody["networkPortStatus"].asString();
                        param.mMode = 0;
                    } else {
                        param.mMode = 1;
                    }
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_25(param);
                    return data;
                } break;
                case kWebGetTransducerInfo: {
                    JsonData jd;
                    Param_26 param;
                    param.mPackageFlag = recvBody["package"].asInt();
                    std::string data = jd.JsonCmd_Cgi_26(param);
                    return data;
                } break;
                case kWebDeleteTransducerInfo: {
                    std::vector<Param_27>  param;
                    std::string type = recvBody["type"].asString();
                    Json::Value recvBodyTemp;
                    Json::Value recvDataNodeNo = recvBody["dataNodeNo"];
                    if (recvDataNodeNo.size() > 0)
                    {
                        for (size_t i = 0; i < recvDataNodeNo.size(); i++) {
                            Param_27 param_27;
                            Json::Value node = recvDataNodeNo[i];
                            param_27.mDataNodeNo = node[0u].asString();
                            param_27.mMeasurementID = node[1u].asString();
                            param_27.mShortAddr = node[2u].asString();
                            param_27.mType = type;
                            
                            param.push_back(param_27);
                        }
                    }
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_27(param);
                    return data;
                } break;
                case kUpdateTransducerName: {
                    Param_28 param;
                    param.mDataNodeNo = recvBody["dataNodeNo"].asString();
                    param.mDataNodeName = recvBody["dataNodeName"].asString();
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_28(param);
                    return data;
                } break;
                case kGetTimeDomainWave: {
                    JsonData jd;
                    Param_29 param;
                    std::string type = recvBody["type"].asString();
                    if (type == "HIGH") {
                        param.mMode = 0;
                    } else if (type == "LOW") {
                        param.mMode = 1;
                    }
                    param.mChannelId = recvBody["channelId"].asString();
                    param.mPackageFlag = recvBody["package"].asInt();
                    param.mDataNodeNo = recvBody["dataNodeNo"].asString();
                    std::string data = jd.JsonCmd_Cgi_29(param);
                    return data;
                } break;
                case kGetFreqDomainWave: {
                    JsonData jd;
                    Param_30 param;
                    std::string type = recvBody["type"].asString();
                    if (type == "HIGH") {
                        param.mMode = 0;
                    } else if (type == "LOW") {
                        param.mMode = 1;
                    }
                    param.mChannelId = recvBody["channelId"].asString();
                    param.mPackageFlag = recvBody["package"].asInt();
                    param.mDataNodeNo = recvBody["dataNodeNo"].asString();
                    std::string data = jd.JsonCmd_Cgi_30(param);
                    return data;
                } break;
                case kConfigZigbee: {
                    JsonData jd;
                    Param_31 param;
                    std::string data;
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SET")) {
                        param.mMode = 0;
                        param.mChannelId = recvBody["channel"].asString();
                        param.mPanID = recvBody["panID"].asString();
                        data = jd.JsonCmd_Cgi_31(param);
                        sleep(1);
                        system("reboot");
                    } else {
                        param.mMode = 1;
                        data = jd.JsonCmd_Cgi_31(param);
                    }
                    return data;
                } break;
                case kGetEnvolop: {
                    JsonData jd;
                    Param_40 param;
                    param.mChannelId = recvBody["channelId"].asString();
                    param.mPackageFlag = recvBody["package"].asInt();
                    param.mDataNodeNo = recvBody["dataNodeNo"].asString();
                    param.StartFrequency = recvBody["StartFrequency"].asInt();
                    param.EndFrequency = recvBody["EndFrequency"].asInt();
                    std::string data = jd.JsonCmd_Cgi_40(param);
                    return data;
                } break;
                case kModifyTransducerConfig: {
                    JsonData jd;
                    Param_41 param;
                    std::vector<Param_41> param41;
                    for (size_t i = 0; i < recvBody.size(); i++) {
                        param.mdataNodeNo = recvBody[i]["dataNodeNo"].asString();
                        param.msamplingRate = recvBody[i]["samplingRate"].asInt();
                        param.mrange = recvBody[i]["range"].asInt();
                        param.mAccSampleTime = recvBody[i]["ACCSampleTime"].asInt();
                        param.mstartBrands = recvBody[i]["startBrands"].asString();
                        param.mstopBrands = recvBody[i]["stopBrands"].asString();
                        param.menvelopeBandPass = recvBody[i]["envelopeBandPass"].asString();
                        param.mviff = recvBody[i]["viff"].asInt();
                        param.mfaultFrequency = recvBody[i]["faultFrequency"].asString();
                        param.mdataNodeName = recvBody[i]["dataNodeName"].asString();
                        param.ZigbeePower = recvBody[i]["ZigbeePower"].asInt();
                        param.ZigbeeRetry = recvBody[i]["ZigbeeRetry"].asInt();
                        param.mMeasurementID = recvBody[i]["MeasurementID"].asString();
                        param.nodeWaveSend = recvBody[i]["nodeWaveSend"].asString();
                        param.mShortAddr = recvBody[i]["shortAddr"].asString();
                        param41.push_back(param);
                    }
                    std::string data = jd.JsonCmd_Cgi_41(param41);
                    char whereCon[64] = {0};
                    sprintf(whereCon, " UpdateFlag <> 1 ");
                    std::string strData = sqlite_db_ctrl::instance().GetNodeConfigureInfor(whereCon);
                    data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str());
                    return data;
                } break;
                case kWebUpgrade: {
                    JsonData jd;
                    Param_42 param;
                    param.fileName = recvBody["fileName"].asString();
                    std::string data = jd.JsonCmd_Cgi_42(param);
                    return data;
                } break;
                case kGetAllVersionInfo: {
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_50();
                    return data;
                } break;
                case kUpdateInstallPosition: {
                    JsonData jd;
                    Param_51 param;
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SET")) {
                        param.mMode = 0;
                        param.strGateWayMAC = recvBody["gateWayNo"].asString();
                        param.strGateWayLocation = recvBody["gateWayLocation"].asString();

                    } else {
                        param.mMode = 1;
                    }
                    std::string data = jd.JsonCmd_Cgi_51(param);
                    return data;
                } break;
                case kWifiOperation: {
                    Param_52 param;
                    param.mCmdSerial = recvValue["cmdSerial"].asString();
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SCAN")) {
                        param.mMode = 0;
                    } else if (0 == type.compare("SET")) {
                        param.mMode = 1;
                        param.mSsid = recvBody["ssid"].asString();
                        param.mPassWord = recvBody["password"].asString();
                    } else if (0 == type.compare("GET")) {
                        param.mMode = 2;
                    } else if (0 == type.compare("CLEAN")) {
                        param.mMode = 3;
                    } else {
                        // TODO: add error log
                    }
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_52(param);
                    return data;
                } break;
                case kUpdateFreqBandEnergyConfig: {
                    JsonData jd;
                    Param_53 param;
                    std::vector<Param_53> param53;
                    for (size_t i = 0; i < recvBody.size(); i++) {
                        param.mdataNodeNo = recvBody[i]["dataNodeNo"].asString();
                        param.mUpdateKey = recvBody[i]["updateKey"].asString();
                        param.mUpdateValue = recvBody[i]["updateValue"].asString();
                        param.mUpdateKey2 = recvBody[i]["updateKey2"].asString();
                        param.mUpdateValue2 = recvBody[i]["updateValue2"].asString();
                        param.mUpdateKey3 = recvBody[i]["updateKey3"].asString();
                        param.mUpdateValue3 = recvBody[i]["updateValue3"].asString();
                        param53.push_back(param);
                    }
                    std::string data = jd.JsonCmd_Cgi_53(param53);
                    char whereCon[64] = {0};
                    sprintf(whereCon, "UpdateFlag <> 0 ");
                    std::string strData = sqlite_db_ctrl::instance().GetNodeConfigureInfor(whereCon);
                    data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str());
                    return data;
                } break;
                case kBackupGatewayInfo: {
                    JsonData jd;
                    Param_54 param;
                    param.mPackageFlag = recvBody["package"].asInt();
                    std::string data = jd.JsonCmd_Cgi_54(param);
                    return data;
                } break;
                case kVelocityTimeDomain: {
                    JsonData jd;
                    Param_55 param;
                    param.mChannelId = recvBody["channelId"].asString();
                    param.mPackageFlag = recvBody["package"].asInt();
                    param.mDataNodeNo = recvBody["dataNodeNo"].asString();
                    std::string data = jd.JsonCmd_Cgi_55(param);
                    return data;
                } break;
                case kVelocityFreqDomain: {
                    JsonData jd;
                    Param_56 param;
                    param.mChannelId = recvBody["channelId"].asString();
                    param.mPackageFlag = recvBody["package"].asInt();
                    param.mDataNodeNo = recvBody["dataNodeNo"].asString();
                    std::string data = jd.JsonCmd_Cgi_56(param);
                    return data;
                }
                case kEnableZigbeePower: {
                    JsonData jd;
                    Param_57 param;
                    param.mZigbeePowerEnable = recvBody["ZigbeePowerEnable"].asInt();
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SET")) {
                        param.mMode = 1;
                    }
                    if (0 == type.compare("GET")) {
                        param.mMode = 0;
                    }
                    std::string data = jd.JsonCmd_Cgi_57(param);
                    return data;
                } break;
                case kSchedulingConfiguration:{
                    JsonData jd;
                    Param_58 param;
                     std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SET")) {
                        param.mMode = 1;
                    }
                    if (0 == type.compare("GET")) {
                        param.mMode = 0;
                    }
                    param.featureInterVal = recvBody["featureInterVal"].asInt();
                    param.waveInterVal = recvBody["waveInterVal"].asInt();
                    param.maxSensorNum = recvBody["maxSensorNum"].asInt();
                    param.waveResendNum = recvBody["waveResendNum"].asInt();
                    param.resend = recvBody["resend"].asInt();
                    std::string data = jd.JsonCmd_Cgi_58(param);
                    return data;
                }break;
                case kLostRecords:{
                    JsonData jd;
                    Param_59 param;
                    param.mMode = recvBody["type"].asInt();
                    param.DataNodeNo = recvBody["DataNodeNo"].asString();
                    param.straxis = recvBody["Raxis"].asString();
                    std::string data = jd.JsonCmd_Cgi_59(param);
                    return data;
                }break;
                case kTransducerUpgrade:{
                    JsonData jd;
                    Param_60 param;
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("UPDATE")) {
                        param.mMode = 0;
                        param.fileName = recvBody["fileName"].asString();
                        param.product = recvBody["product"].asInt();
                        param.mShortAddr = recvBody["shortAddr"].asString();
                    }
                    if (0 == type.compare("STOP")) {
                        param.mMode = 1;
                    }
                    Json::Value recvDataNodeNo = recvBody["DataNodeNo"];
                    if (recvDataNodeNo.size() > 0)
                    {
                        for (size_t i = 0; i < recvDataNodeNo.size(); i++) {
                        	param.dataNodeNo.push_back(recvDataNodeNo[i].asString());
                        }
                    }
                    std::string data = jd.JsonCmd_Cgi_60(param);
                    return data;
                }break;
                case kWaveRecords:{
                    JsonData jd;
                    Param_61 param;
                    param.straxis = recvBody["Raxis"].asString();
                    param.mPackageFlag = recvBody["package"].asInt();
                    param.timeStart = recvBody["timeStart"].asString();
                    param.timeEnd = recvBody["timeEnd"].asString();
                    param.MeasurementID = recvBody["MeasurementID"].asString();
                    std::string data = jd.JsonCmd_Cgi_61(param);
                    return data;
                }break;
                case kWaveReceive:{
                    JsonData jd;
                    Param_62 param;
                    param.mMode = recvBody["type"].asInt();
                    param.mPackageFlag = recvBody["package"].asInt();
                    param.timeStart = recvBody["timeStart"].asString();
                    param.timeEnd = recvBody["timeEnd"].asString();
                    param.straxis = recvBody["Raxis"].asString();
                    param.MeasurementID = recvBody["MeasurementID"].asString();
                    std::string data = jd.JsonCmd_Cgi_62(param);
                    return data;
                }break;
                case kWaveSend:{
                    JsonData jd;
                    Param_63 param;
                    param.mMode = recvBody["sub_cmd"].asInt();
                    param.partial = recvBody["partial"].asBool();
                    if (param.mMode == 1)
                    {
                        for (const auto &key : recvBody.getMemberNames()) 
                        {
                            if (key != "sub_cmd" && key != "partial")
                            {
                                FeatureEntryUploadCfg tmpCfg;
                                char *end_ptr;
                                if (key == "global")
                                {
                                    tmpCfg.short_addr = 0;
                                }else{
                                    tmpCfg.short_addr = strtol(key.c_str(), &end_ptr, 16);
                                }
                                Json::Value xyz_status =  recvBody[key];
                                for (size_t i = 0; i < xyz_status.size(); ++i) {
                                    if (i == 0) {
                                        tmpCfg.x = xyz_status[i].asInt();
                                    } else if (i == 1) {
                                        tmpCfg.y = xyz_status[i].asInt();
                                    } else if (i == 2) {
                                        tmpCfg.z = xyz_status[i].asInt();
                                    }                         
                                }  
                                param.cfg.push_back(tmpCfg);
                            }
                        }
                    }
                    std::string data = jd.JsonCmd_Cgi_63(param);
                    return data;
                }break;
                case kFeatureSend:{
                    JsonData jd;
                    Param_64 param;
                    param.mMode = recvBody["sub_cmd"].asInt();
                    param.partial = recvBody["partial"].asBool();
                    if (param.mMode == 1)
                    {
                        for (const auto &key : recvBody.getMemberNames()) 
                        {
                            if (key != "sub_cmd" && key != "partial")
                            {
                                FeatureEntryUploadCfg tmpCfg;
                                char *end_ptr;
                                if (key == "global")
                                {
                                    tmpCfg.short_addr = 0;
                                }else{
                                    tmpCfg.short_addr = strtol(key.c_str(), &end_ptr, 16);
                                }
                                Json::Value xyz_status =  recvBody[key];
                                for (size_t i = 0; i < xyz_status.size(); ++i) {
                                    if (i == 0) {
                                        tmpCfg.x = xyz_status[i].asInt();
                                    } else if (i == 1) {
                                        tmpCfg.y = xyz_status[i].asInt();
                                    } else if (i == 2) {
                                        tmpCfg.z = xyz_status[i].asInt();
                                    }                         
                                }  
                                param.cfg.push_back(tmpCfg);
                            }
                        }
                    }
                    std::string data = jd.JsonCmd_Cgi_64(param);
                    return data;
                }break;
                case kFeatureWaveCount:{
                    JsonData jd;
                    Param_65 param;
                    param.mPackageFlag = recvBody["package"].asInt();
                    param.timeStart = recvBody["timeStart"].asString();
                    param.timeEnd = recvBody["timeEnd"].asString();
                    std::string data = jd.JsonCmd_Cgi_65(param);
                    return data;
                }
                break;
                case KSensorLoose:{
                    JsonData jd;
                    Param_66 param;
                    param.mSensorLooseEnable = recvBody["looseEnable"].asInt();
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SET")) {
                       param.mMode = 1;
                   }
                   if (0 == type.compare("GET")) {
                       param.mMode = 0;
                   }
                   std::string data = jd.JsonCmd_Cgi_66(param);
                   return data;
               }
               break;
               case KDebugSensor:{
                    JsonData jd;
                    Param_67 param;
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SET")) {
                       param.mMode = 1;
                       Json::Value recvDataNodeNo = recvBody["DataNodeNo"];
                        if (recvDataNodeNo.size() > 0)
                        {
                            for (size_t i = 0; i < recvDataNodeNo.size(); i++) {
                                param.measurementID.push_back(recvDataNodeNo[i].asString());
                            }
                        }
                   }
                   if (0 == type.compare("GET")) {
                       param.mMode = 0;
                   }
                   if (0 == type.compare("STOP")) {
                        param.mMode = 2;
                   }
                   std::string data = jd.JsonCmd_Cgi_67(param);
                   return data;
                }
                break;
                case KWaveRule:{
                    JsonData jd;
                    Param_68 param;
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SET")) {
                       param.mMode = 1;
                    }else if (0 == type.compare("GET")) {
                       param.mMode = 0;
                    }
                    param.lowSignal = recvBody["lowSignal"].asInt();
                    param.signalThreshold = recvBody["signalThreshold"].asInt();
                    param.lowBatteryLevel = recvBody["lowBatteryLevel"].asInt();
                    param.batteryLevelThreshold = recvBody["batteryLevelThreshold"].asInt();
                    param.shutdownDetection = recvBody["shutdownDetection"].asInt();
                    Json::Value recvDataNodeNo = recvBody["DataNodeNo"];
                    if (recvDataNodeNo.size() > 0)
                    {
                        for (int i = 0; i < recvDataNodeNo.size(); ++i) {
                            Param_68_info vecParam;
                            Json::Value node = recvDataNodeNo[i];
                    
                            vecParam.measurementID = node[0u].asString();
                            vecParam.status = node[1u].asInt();
                            vecParam.statisticType = node[2u].asInt();
                            vecParam.threshold = node[3u].asDouble();
                            param.vecParam68.push_back(vecParam);
                        }
                    }
                    
                    std::string data = jd.JsonCmd_Cgi_68(param);
                    return data;
                }break;
                case KTrigerWaveUpload:{
                    JsonData jd;
                    Param_69 param;
                    std::string type = recvBody["type"].asString();
                    if (0 == type.compare("SET")) {
                       param.mMode = 1;
                    }else if (0 == type.compare("GET")) {
                       param.mMode = 0;
                    }
                    Json::Value recvDataNodeNo = recvBody["DataNodeNo"];
                    param.trigerThresholdEnable = recvBody["threshold"].asBool();
                    if (recvDataNodeNo.size() > 0)
                    {
                        for (size_t i = 0; i < recvDataNodeNo.size(); i++) {
                            Param_69_info vecParam;
                            Json::Value node = recvDataNodeNo[i];
                            vecParam.measurementID = node[0u].asString();
                            vecParam.status = node[1u].asInt();
                            vecParam.trigerType = node[2u].asInt();
                            vecParam.statisticType = node[3u].asInt();
                            vecParam.threshold = node[4u].asDouble();
                            
                            param.vecParam69.push_back(vecParam);
                        }
                    }
                    std::string data = jd.JsonCmd_Cgi_69(param);
                    return data;
                }break;
                case KProcessLog:{
                    JsonData jd;
                    Param_70 param;
                    param.timeStart = recvBody["timeStart"].asString();
                    param.timeEnd = recvBody["timeEnd"].asString();
                    param.mPackageFlag = recvBody["package"].asInt();
                    std::string data = jd.JsonCmd_Cgi_70(param);
                    return data;
                }break;
                case KSystemLog:{

                }break;
                default:
                    JsonData jd;
                    std::string data = jd.JsonCmd_Cgi_default();
                    return data;
                break;
            }
        }
    } catch (...) {
        Json::Value jsVal;
        jsVal["success"] = false;
        jsVal["message"] = "未知错误";
        Json::FastWriter fw;
        return fw.write(jsVal);
    }
    zlog_error(zct, "invalid command");
    return "";
}
