wirelessgateway/jsonparse/SH_JsonCmd.cpp

1227 lines
44 KiB
C++
Raw Normal View History

2021-09-18 13:45:24 +08:00
#include "SH_JsonCmd.hpp"
#include "../dbaccess/SH_SqlDB.hpp"
#include "../platform/SH_PlatformInit.hpp"
namespace{
PlatformInit *platform = PlatformInit::instance();
Calculation *pCalculation = Calculation::instance();
Uart *pUart = Uart::instance();
}
std::string JsonData::JsonCmd_20(Param_20 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["success"] = true;
jsonVal["message"] = "";
if (0 == param.mMode) {
char localtimestamp[32] = { 0 };
GetTimeNet(localtimestamp, 1);
std::string nowTimetamp = std::string(localtimestamp);
WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayName", param.mDataWatchName);
WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAssetId", param.mDataWatchAssetId);
WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedBy", param.mDataWatchAddedBy);
WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedDate", nowTimetamp);
}
std::string boardtype = GetFileContent(BOARDTYPE, 1);
std::string ip = IpAddrInit();
std::string sn = GetFileContent(SN, 1);
jsonVal[JSON_FIELD_CMD] = "20";
jsonVal[JSON_FIELD_dataNodeGatewayNo] = GlobalConfig::MacAddr_G;
jsonVal["cmdSerial"] = param.mCmdSerial;
Json::Value jsSystemInfo;
Json::Value jsBody;
jsSystemInfo[JSON_FIELD_NAME] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayName");
jsSystemInfo[JSON_FIELD_dataNodeGatewayNo] = GlobalConfig::MacAddr_G;
jsSystemInfo[JSON_FIELD_ASSETID] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAssetId");
jsSystemInfo[JSON_FIELD_ADDEDBY] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedBy");
jsSystemInfo[JSON_FIELD_ADDEDDATE] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedDate");
jsSystemInfo[JSON_FIELD_DEVICETYPE] = boardtype;
jsSystemInfo[JSON_FIELD_IPADDRESS] = ip;
jsSystemInfo[JSON_FIELD_SN] = sn;
jsSystemInfo[JSON_FIELD_VERSION] = GlobalConfig::Version;
jsSystemInfo[JSON_FIELD_TIMEZONE] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "timezone");
jsSystemInfo["zigbeePanId"] = GlobalConfig::ZigbeeInfo_G.PanID;
jsSystemInfo["zigbeeChannel"] = GlobalConfig::ZigbeeInfo_G.Channel;
jsSystemInfo["zigbeeAddr"] = GlobalConfig::ZigbeeInfo_G.MyAddr;
jsBody["SystemInfo"] = jsSystemInfo;
std::string dataBody = showValue.write(jsBody);
jsonVal["cmdBody"] = dataBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_22(Param_22 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["success"] = true;
jsonVal["message"] = "";
if (0 == param.mMode) {
WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "timezone", param.mTimeZone);
}
jsonVal[JSON_FIELD_CMD] = "22";
jsonVal[JSON_FIELD_dataNodeGatewayNo] = GlobalConfig::MacAddr_G;
jsonVal["cmdSerial"] = param.mCmdSerial;
Json::Value jsSystemSetting;
Json::Value jsBody;
jsBody[JSON_FIELD_TIMEZONE] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "timezone");
std::string dataBody = showValue.write(jsBody);
jsonVal["cmdBody"] = dataBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_23(Param_23 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["success"] = true;
jsonVal["message"] = "";
if (0 == param.mMode) {
WriteStr2Config(SERVERCONFIG, "Server", "localServerIpAddress", param.mServerIp);
WriteStr2Config(SERVERCONFIG, "Server", "localServerPort", param.mPort);
WriteStr2Config(SERVERCONFIG, "Server", "CommMode", param.mCommMode);
printf("param.mCommMode = %s\n",param.mCommMode.c_str());
if("1" == param.mCommMode){//有线连接
system("mv /etc/init.d/S91quectel-CM.sh /etc/init.d/wireless.sh");
}else if("2" == param.mCommMode){//无线连接
system("mv /etc/init.d/wireless.sh /etc/init.d/S91quectel-CM.sh");
}
sleep(1);
system("reboot");
}
jsonVal[JSON_FIELD_CMD] = "23";
jsonVal[JSON_FIELD_dataNodeGatewayNo] = GlobalConfig::MacAddr_G;
jsonVal["cmdSerial"] = param.mCmdSerial;
Json::Value jsSystemSetting;
Json::Value jsBody;
jsBody[JSON_FIELD_SERVERIP] = ReadStrByOpt(SERVERCONFIG, "Server", "localServerIpAddress");
jsBody[JSON_FIELD_SERVERPORT] = boost::lexical_cast<int>(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort"));
jsBody[JSON_FIELD_CommMode] = boost::lexical_cast<int>(ReadStrByOpt(SERVERCONFIG, "Server", "CommMode"));
std::string dataBody = showValue.write(jsBody);
jsonVal["cmdBody"] = dataBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_25(Param_25 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["success"] = true;
jsonVal["message"] = "";
if (0 == param.mMode) {
WriteStr2Config(NETWORKCONFIG, "Net", "dnsName", param.mDnsName);
WriteStr2Config(NETWORKCONFIG, "Net", "networkPortStatus", param.mNetworkPortStatus);
WriteStr2Config(NETWORKCONFIG, "Net", "gateway", param.mGateway);
WriteStr2Config(NETWORKCONFIG, "Net", "subnetMask", param.mSubnetMask);
WriteStr2Config(NETWORKCONFIG, "Net", "ipAddress", param.mIp);
WriteStr2Config(NETWORKCONFIG, "Net", "hostName", param.mHostName);
}
jsonVal["cmd"] = "25";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["cmdSerial"] = param.mCmdSerial;
Json::Value jsSystemSetting;
Json::Value jsBody;
jsBody["dnsName"] = ReadStrByOpt(NETWORKCONFIG, "Net", "dnsName");
jsBody["networkPortStatus"] = ReadStrByOpt(NETWORKCONFIG, "Net", "networkPortStatus");
jsBody["gateway"] = ReadStrByOpt(NETWORKCONFIG, "Net", "gateway");
jsBody["subnetMask"] = ReadStrByOpt(NETWORKCONFIG, "Net", "subnetMask");
jsBody["dataWatchIpAddress"] = ReadStrByOpt(NETWORKCONFIG, "Net", "ipAddress");
jsBody["hostName"] = ReadStrByOpt(NETWORKCONFIG, "Net", "hostName");
std::string dataBody = showValue.write(jsBody);
jsonVal["cmdBody"] = dataBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_26(Param_26 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["cmd"] = "26";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["cmdSerial"] = param.mCmdSerial;
jsonVal["success"] = true;
jsonVal["message"] = "查询成功";
Json::Value jsArray;
array_t arrRes;
arrRes = sql_ctl->GetDataMultiLine(T_SENSOR_INFO(TNAME), "*", NULL);
int iResult = arrRes.size();
if (iResult > 0) {
for (int j = 0; j < iResult; j++) {
Json::Value jsSensorData;
jsSensorData["dataNodeNo"] = arrRes[j][0];
jsSensorData["dataNodeName"] = arrRes[j][1];
jsSensorData["initFlag"] = boost::lexical_cast<int>(arrRes[j][2]);
jsSensorData["accFlag"] = boost::lexical_cast<int>(arrRes[j][3]);
jsSensorData["zigbeeFlag"] = boost::lexical_cast<int>(arrRes[j][4]);
jsSensorData["temTopFlag"] = boost::lexical_cast<int>(arrRes[j][5]);
jsSensorData["temBotFlag"] = boost::lexical_cast<int>(arrRes[j][6]);
jsSensorData["hardVersion"] = arrRes[j][8];
jsSensorData["softVersion"] = arrRes[j][9];
jsSensorData["bpNo"] = arrRes[j][10];
jsSensorData["serialNo"] = arrRes[j][11];
jsSensorData["firstPowerTime"] = arrRes[j][12];
jsSensorData["configFlag"] = boost::lexical_cast<int>(arrRes[j][13]);
jsSensorData["startBrands"] = arrRes[j][14];
jsSensorData["stopBrands"] = arrRes[j][15];
jsSensorData["featureInterVal"] = boost::lexical_cast<string>(arrRes[j][16]);
jsSensorData["waveInterVal"] = boost::lexical_cast<int>(arrRes[j][17]);
jsSensorData["samplingRate"] = boost::lexical_cast<int>(arrRes[j][18]);
jsSensorData["envelopeBandPass"] = arrRes[j][21];
jsSensorData["faultFrequency"] = arrRes[j][22];
jsSensorData["zigbeePanId"] = arrRes[j][23];
jsSensorData["zigbeeChannel"] = boost::lexical_cast<string>(arrRes[j][24]);
jsSensorData["zigbeeAddr"] = arrRes[j][25];
jsSensorData["zigbeeDesAddr"] = arrRes[j][27];
jsSensorData["status"] = boost::lexical_cast<int>(arrRes[j][28]);
jsSensorData["timeStamp"] = arrRes[j][29];
jsArray.append(jsSensorData);
}
} else {
jsArray.resize(0);
jsonVal["success"] = false;
jsonVal["message"] = "查询失败";
}
Json::Value jsBody;
jsBody["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsBody["dataNodeArray"] = jsArray;
std::string dataBody = showValue.write(jsBody);
jsonVal["cmdBody"] = dataBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_27(Json::Value & recvBody)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["success"] = true;
jsonVal["message"] = "";
jsonVal["cmd"] = "27";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
int nSize = recvBody["dataNodeArray"].size();
if (nSize > 0) {
for (int i = 0; i < nSize; i++) {
char whereCon[128] = { 0 };
sprintf(whereCon, "%s= '%s'", T_SENSOR_INFO(DATANODENO), recvBody["dataNodeArray"][i].asString().c_str());
sql_ctl->DeleteTableData(T_SENSOR_INFO(TNAME), whereCon);
sql_ctl->DeleteTableData(T_DATA_INFO(TNAME), whereCon);
sql_ctl->DeleteTableData(T_DATASTATIC_INFO(TNAME), whereCon);
}
} else {
jsonVal["success"] = false;
jsonVal["message"] = "没有传感器号";
}
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_29(Param_29 &param)
{
Json::Value jsonVal;
Json::Value jsBody;
Json::Value SystemSetting;
jsonVal.clear();
jsonVal["cmd"] = "29";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["cmdSerial"] = param.mCmdSerial;
array_t arrRes;
arrRes = sql_ctl->GetDataMultiLine(T_SENSOR_INFO(TNAME), "*", NULL);
int iResult = arrRes.size();
if (iResult > 0) {
for (int i = 0; i < iResult; i++) {
Json::Value jsDataNode;
jsDataNode["dataNodeNo"] = arrRes[i][1];
jsDataNode["status"] = boost::lexical_cast<int>(arrRes[i][24]);
jsBody["dataNodeArray"].append(jsDataNode);
}
}
std::string strBody = showValue.write(jsBody);
jsonVal["cmdBody"] = strBody;
return showValue.write(jsonVal);
}
void JsonData::JsonCmd_38(Json::Value &recvBody)
{
Json::Value jsChannel = recvBody["channelArray"];
print_info("jsChannel size : %d\n", jsChannel.size());
if (jsChannel.isArray()) {
for (int i = 0; i < jsChannel.size(); i++) {
std::string strChannelid = jsChannel[i].asString();
WAVE_GENERAL wavedata;
WAVE_CONTAIN wave;
memset(wave.channelId, 0, 16);
sprintf(wave.channelId, "%s", strChannelid.c_str());
memset(wave.SensorEngineeringUnit, 0, 32);
sprintf(wave.SensorEngineeringUnit,"%s", wavedata.SensorEngineeringUnit.c_str());
wave.total = 1;
wave.count = 1;
wave.type = 0;
wave.flag = 0;
wave.number = wavedata.number;
memcpy(wave.waveData, wavedata.waveData, wavedata.number * sizeof(float));
// data_publish_wave(&wave, GlobalConfig::Topic_G.mPubSecond.c_str());
}
}
}
void JsonData::JsonCmd_39(Json::Value &recvBody)
{
std::ifstream inFile("/opt/update/a.bin",ios::in|ios::binary);
if (!inFile) {
print_error("read data error\n");
} else {
unsigned char szUpdatePackage[93]={0x00};
while (inFile.read(szUpdatePackage, 92)) {
}
}
}
void JsonData::DataNodeStatusCheck()
{
vec_t vetRes = sql_ctl->GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(DATANODENO), NULL);
int nSize = vetRes.size();
char localtimestamp[32] = { 0 };
GetTimeNet(localtimestamp, 1);
std::string nowTimetamp = std::string(localtimestamp);
int lNowTime = boost::lexical_cast<int>(nowTimetamp);
if (nSize > 0) {
for (int i = 0; i < nSize; i++) {
std::string strDataNodeNo = vetRes[i];
std::string strChannelId= strDataNodeNo + "-X";
char whereCon[64] = {};
sprintf(whereCon, "dataNodeNo='%s' and channelID='%s'", strDataNodeNo.c_str(), strChannelId.c_str());
array_t arrRes;
std::string strTimeRes = sql_ctl->GetData(T_DATA_INFO(TNAME), T_DATA_INFO(TIMESTAMP), whereCon);
if (strTimeRes.length() > 0) {
int llastTime = boost::lexical_cast<int>(strTimeRes);
int lTimeTemp = lNowTime - llastTime;
lTimeTemp = abs(lTimeTemp);
if (lTimeTemp > 21600) {
char whereCon[32] = { 0 };
sprintf(whereCon, "dataNodeNo='%s'", strDataNodeNo.c_str());
sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='0'", whereCon);
}
}
}
}
}
/***************************嵌入式Web协议******************************/
std::string JsonData::JsonCmd_Cgi_01(Param_01 &param)
{
Json::Value jsonVal;
Json::Value jsBody;
jsonVal.clear();
std::string userName = ReadStrByOpt(SYSTEMINFOFILE, "UserInfo", "UserName");
std::string adminPassword = ReadStrByOpt(SYSTEMINFOFILE, "UserInfo", "adminPassword");
std::string userPassword = ReadStrByOpt(SYSTEMINFOFILE, "UserInfo", "userPassword");
std::string message = " ";
bool success = true;
if (0 == param.mMode) {
jsBody["type"] = "login";
if (0 != param.mUserName.compare(userName)) {
message = "0101";
success = false;
} else {
if (0 == param.mPassWord.compare(adminPassword) || 0 == param.mPassWord.compare(userPassword)) {
} else {
message = "0102";
success = false;
}
}
} else if (1 == param.mMode) {
jsBody["type"] = "upDate";
if (0 != param.mUserName.compare(userName)) {
message = "0101";
} else {
if (0 == param.mPassWord.compare(adminPassword) || 0 == param.mPassWord.compare(userPassword)) {
WriteStr2Config(SYSTEMINFOFILE, "UserInfo", "userPassword", param.mPassWordNew);
} else {
message = "0103";
success = false;
}
}
} else {
message = "格式错误";
success = false;
}
jsonVal["cmd"] = "01";
jsonVal["success"] = success;
jsonVal["message"] = message;
jsonVal["content"] = jsBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_02(Param_02 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["success"] = true;
jsonVal["message"] = "校时成功";
jsonVal["cmd"] = "02";
if (0 == param.mMode) {
jsonVal["type"] = "SET";
SetTime((unsigned long)param.mTimeStamp);
boost::this_thread::sleep(boost::posix_time::milliseconds(200));
system("hwclock -w");
} else if (1 == param.mMode) {
char cmd[256] = { 0 };
char localtimestamp[32] = { 0 };
GetTimeNet(localtimestamp, 1);
std::string nowTimetamp = std::string(localtimestamp);
jsonVal["type"] = "GET";
jsonVal["timeStamp"] = boost::lexical_cast<int>(nowTimetamp);
}
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_07()
{
Json::Value jsonVal;
jsonVal.clear();
std::string sysStatus = GetSysStatus();
print_info("sysStatus : %s\n", sysStatus.c_str());
Json::Features f = Json::Features::strictMode();
Json::Reader recvReader(f);
Json::Value recvSys;
jsonVal[JSON_FIELD_CMD] = "07";
jsonVal["success"] = true;
jsonVal["message"] = " ";
if (recvReader.parse(sysStatus, recvSys)){
jsonVal["content"] = recvSys;
} else {
jsonVal["success"] = false;
jsonVal["message"] = "状态获取失败";
}
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_08()
{
Json::Value jsonVal;
jsonVal.clear();
std::string sysStatus = GetSysStatus();
Json::Features f = Json::Features::strictMode();
Json::Reader recvReader(f);
Json::Value recvSys;
jsonVal[JSON_FIELD_CMD] = "08";
jsonVal["success"] = true;
jsonVal["message"] = " ";
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_09()
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal[JSON_FIELD_CMD] = "09";
jsonVal["success"] = true;
jsonVal["message"] = " ";
vec_t vetRes = sql_ctl->GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(DATANODENO), NULL);
int nSize = vetRes.size();
if (nSize > 0) {
for (int i = 0; i < nSize; i++) {
print_info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@vetRes=%s\n",vetRes[i].c_str());
Json::Value jsSensor;
std::string strDataNodeNo = vetRes[i];
char whereCon[64] = {};
sprintf(whereCon, "dataNodeNo='%s'", strDataNodeNo.c_str());
// 自数据库获取传感器特征数据
array_t arrRes;
arrRes = sql_ctl->GetDataMultiLine(T_DATA_INFO(TNAME), "*", whereCon);
int iResult = arrRes.size();
if (iResult > 0) {
for (int j = 0; j < iResult; j++) {
Json::Value jsChannelData;
jsChannelData["ChannelId"] = arrRes[j][1];
jsChannelData["ChannelType"] = "ACCELEROMETER";
jsChannelData["DiagnosisPeak"] = boost::lexical_cast<float>(arrRes[j][2]);
jsChannelData["IntegratPk2Pk/2"] = boost::lexical_cast<float>(arrRes[j][3]);
jsChannelData["IntegratRMS"] = boost::lexical_cast<float>(arrRes[j][4]);
jsChannelData["RMSValues"] = boost::lexical_cast<float>(arrRes[j][5]);
jsChannelData["EnvelopEnergy"] = boost::lexical_cast<float>(arrRes[j][6]);
jsChannelData["1xAmp"] = boost::lexical_cast<float>(arrRes[j][7]);
jsChannelData["2xAmp"] = boost::lexical_cast<float>(arrRes[j][8]);
jsChannelData["3xAmp"] = boost::lexical_cast<float>(arrRes[j][9]);
jsChannelData["4xAmp"] = boost::lexical_cast<float>(arrRes[j][10]);
jsChannelData["5xAmp"] = boost::lexical_cast<float>(arrRes[j][11]);
jsChannelData["1xPhase"] = boost::lexical_cast<float>(arrRes[j][12]);
jsChannelData["2xPhase"] = boost::lexical_cast<float>(arrRes[j][13]);
jsChannelData["3xPhase"] = boost::lexical_cast<float>(arrRes[j][14]);
jsChannelData["4xPhase"] = boost::lexical_cast<float>(arrRes[j][15]);
jsChannelData["TimeStamp"] = boost::lexical_cast<float>(arrRes[j][16]);
jsSensor.append(jsChannelData);
}
}
char selectCon[128] = { 0 };
sprintf(selectCon, "dataNodeNo='%s'", strDataNodeNo.c_str());
vec_t vecRes = sql_ctl->GetDataSingleLine(T_DATASTATIC_INFO(TNAME), "*", selectCon);
Json::Value jsStaticData;
if(vecRes.size()>0){
jsStaticData["TemperatureTop"] = boost::lexical_cast<float>(vecRes[2]);
jsStaticData["TemperatureBot"] = boost::lexical_cast<float>(vecRes[3]);
jsStaticData["Dip"] = boost::lexical_cast<float>(vecRes[4]);
jsStaticData["Voltage"] = boost::lexical_cast<float>(vecRes[5]);
jsStaticData["ChannelType"] = "STATUS";
jsStaticData["ChannelId"] = vecRes[1];
jsStaticData["TimeStamp"] = vecRes[6];
jsStaticData["dataNodeNo"] = strDataNodeNo;
}
jsSensor.append(jsStaticData);
jsonVal["content"].append(jsSensor);
}
} else {
jsonVal["content"].resize(0);
}
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_20(Param_20 &param)
{
Json::Value jsonVal;
jsonVal.clear();
if (0 == param.mMode) {
char localtimestamp[32] = { 0 };
GetTimeNet(localtimestamp, 1);
std::string nowTimetamp = std::string(localtimestamp);
WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayName", param.mDataWatchName);
WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAssetId", param.mDataWatchAssetId);
WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedBy", param.mDataWatchAddedBy);
WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedDate", nowTimetamp);
}
std::string boardtype = GetFileContent(BOARDTYPE, 1);
std::string ip = IpAddrInit();
std::string sn = GetFileContent(SN, 1);
jsonVal[JSON_FIELD_CMD] = "20";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["success"] = true;
jsonVal["message"] = "";
jsonVal["cmdSerial"] = param.mCmdSerial;
Json::Value jsSystemInfo;
Json::Value jsBody;
jsSystemInfo[JSON_FIELD_NAME] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayName");
jsSystemInfo["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsSystemInfo[JSON_FIELD_ASSETID] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAssetId");
jsSystemInfo[JSON_FIELD_ADDEDBY] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedBy");
jsSystemInfo[JSON_FIELD_ADDEDDATE] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedDate");
jsSystemInfo[JSON_FIELD_DEVICETYPE] = boardtype;
jsSystemInfo[JSON_FIELD_IPADDRESS] = ip;
jsSystemInfo[JSON_FIELD_SN] = sn;
jsSystemInfo[JSON_FIELD_VERSION] = GlobalConfig::Version;
jsSystemInfo[JSON_FIELD_TIMEZONE] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "timezone");
jsSystemInfo["zigbeePanId"] = GlobalConfig::ZigbeeInfo_G.PanID;
jsSystemInfo["zigbeeChannel"] = GlobalConfig::ZigbeeInfo_G.Channel;
jsSystemInfo["zigbeeAddr"] = GlobalConfig::ZigbeeInfo_G.MyAddr;
jsBody["SystemInfo"] = jsSystemInfo;
// std::string dataBody = showValue.write(jsBody);
jsonVal["content"] = jsBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_22(Param_22 &param)
{
Json::Value jsonVal;
jsonVal.clear();
if (0 == param.mMode) {
WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "timezone", param.mTimeZone);
}
jsonVal[JSON_FIELD_CMD] = "22";
jsonVal[JSON_FIELD_dataNodeGatewayNo] = GlobalConfig::MacAddr_G;
jsonVal["cmdSerial"] = param.mCmdSerial;
jsonVal["success"] = true;
jsonVal["message"] = " ";
Json::Value jsSystemSetting;
Json::Value jsBody;
jsSystemSetting[JSON_FIELD_TIMEZONE] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "timezone");
jsBody["SystemSettings"] = jsSystemSetting;
jsonVal["content"] = jsBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_23(Param_23 &param)
{
Json::Value jsonVal;
jsonVal.clear();
// SET 指令则param.mMode = 0,将设置的数据写入配置文件中 SERVERCONFIG "/opt/configenv/ServerConfig.json"
if (0 == param.mMode) {
WriteStr2Config(SERVERCONFIG, "Server", "localServerIpAddress", param.mServerIp);
WriteStr2Config(SERVERCONFIG, "Server", "localServerPort", param.mPort);
WriteStr2Config(SERVERCONFIG, "Server", "communicationMode", param.mCommMode);
}
jsonVal[JSON_FIELD_CMD] = "23";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["cmdSerial"] = param.mCmdSerial;
jsonVal["success"] = true;
jsonVal["message"] = " ";
Json::Value jsSystemSetting;
Json::Value jsBody;
jsSystemSetting["ServerIpAddress"] = ReadStrByOpt(SERVERCONFIG, "Server", "localServerIpAddress");
jsSystemSetting["ServerPort"] = boost::lexical_cast<int>(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort"));
jsSystemSetting["CommMode"] = boost::lexical_cast<int>(ReadStrByOpt(SERVERCONFIG, "Server", "communicationMode"));
jsBody["SystemSettings"] = jsSystemSetting;
jsonVal["content"] = jsBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_25(Param_25 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["cmd"] = "25";
if (0 == param.mMode) {
WriteStr2Config(NETWORKCONFIG, "Net", "dnsName", param.mDnsName);
WriteStr2Config(NETWORKCONFIG, "Net", "networkPortStatus", param.mNetworkPortStatus);
WriteStr2Config(NETWORKCONFIG, "Net", "gateway", param.mGateway);
WriteStr2Config(NETWORKCONFIG, "Net", "subnetMask", param.mSubnetMask);
WriteStr2Config(NETWORKCONFIG, "Net", "ipAddress", param.mIp);
WriteStr2Config(NETWORKCONFIG, "Net", "hostName", param.mHostName);
platform->EquipIpInit();
}
jsonVal["success"] = true;
jsonVal["message"] = " ";
jsonVal["content"]["dnsName"] = ReadStrByOpt(NETWORKCONFIG, "Net", "dnsName");
jsonVal["content"]["networkPortStatus"] = ReadStrByOpt(NETWORKCONFIG, "Net", "networkPortStatus");
jsonVal["content"]["gateway"] = ReadStrByOpt(NETWORKCONFIG, "Net", "gateway");
jsonVal["content"]["subnetMask"] = ReadStrByOpt(NETWORKCONFIG, "Net", "subnetMask");
jsonVal["content"]["dataWatchIpAddress"] = ReadStrByOpt(NETWORKCONFIG, "Net", "ipAddress");
jsonVal["content"]["hostName"] = ReadStrByOpt(NETWORKCONFIG, "Net", "hostName");
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_26()
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["cmd"] = "26";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["success"] = true;
jsonVal["message"] = " ";
Json::Value jsArray;
array_t arrRes;
arrRes = sql_ctl->GetDataMultiLine(T_SENSOR_INFO(TNAME), "*", NULL);
int iResult = arrRes.size();
if (iResult > 0) {
for (int j = 0; j < iResult; j++) {
Json::Value jsSensorData;
jsSensorData["dataNodeNo"] = arrRes[j][0];
jsSensorData["dataNodeName"] = arrRes[j][1];
jsSensorData["initFlag"] = boost::lexical_cast<int>(arrRes[j][2]);
jsSensorData["accFlag"] = boost::lexical_cast<int>(arrRes[j][3]);
jsSensorData["zigbeeFlag"] = boost::lexical_cast<int>(arrRes[j][4]);
jsSensorData["temTopFlag"] = boost::lexical_cast<int>(arrRes[j][5]);
jsSensorData["temBotFlag"] = boost::lexical_cast<int>(arrRes[j][6]);
jsSensorData["equipsta"] = boost::lexical_cast<int>(arrRes[j][7]);
jsSensorData["hardVersion"] = arrRes[j][8];
jsSensorData["softVersion"] = arrRes[j][9];
jsSensorData["bpNo"] = arrRes[j][10];
jsSensorData["serialNo"] = arrRes[j][11];
jsSensorData["firstPowerTime"] = arrRes[j][12];
jsSensorData["configFlag"] = boost::lexical_cast<int>(arrRes[j][13]);
jsSensorData["startBrands"] = arrRes[j][14];
jsSensorData["stopBrands"] = arrRes[j][15];
jsSensorData["featureInterVal"] = boost::lexical_cast<int>(arrRes[j][16]);
jsSensorData["waveInterVal"] = boost::lexical_cast<int>(arrRes[j][17]);
jsSensorData["samplingRate"] = boost::lexical_cast<int>(arrRes[j][18]);
jsSensorData["scope"] = arrRes[j][19];
jsSensorData["range"] = boost::lexical_cast<int>(arrRes[j][20]);;
jsSensorData["envelopeBandPass"] = arrRes[j][21];
jsSensorData["faultFrequency"] = arrRes[j][12];
jsSensorData["zigbeePanId"] = arrRes[j][23];
jsSensorData["zigbeeChannel"] = boost::lexical_cast<int>(arrRes[j][24]);
jsSensorData["zigbeeAddr"] = arrRes[j][25];
jsSensorData["zigbeeLongAddr"] = arrRes[j][26];
jsSensorData["zigbeeDesAddr"] = arrRes[j][27];
jsSensorData["status"] = boost::lexical_cast<int>(arrRes[j][28]);
jsSensorData["timeStamp"] = arrRes[j][29];
jsSensorData["viff"] = boost::lexical_cast<int>(arrRes[j][30]);
jsSensorData["RSSI"] = boost::lexical_cast<int>(arrRes[j][31]);
jsArray.append(jsSensorData);
}
} else {
jsArray.resize(0);
}
jsonVal["content"]["dataNodeArray"] = jsArray;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_27(Param_27 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["cmd"] = "27";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["success"] = true;
jsonVal["message"] = " ";
if (param.mDataNodeNo.length() > 0) {
char whereCon[128] = { 0 };
sprintf(whereCon, "%s= '%s'", T_SENSOR_INFO(DATANODENO), param.mDataNodeNo.c_str());
sql_ctl->DeleteTableData(T_SENSOR_INFO(TNAME), whereCon);
sql_ctl->DeleteTableData(T_DATA_INFO(TNAME), whereCon);
sql_ctl->DeleteTableData(T_DATASTATIC_INFO(TNAME), whereCon);
} else {
jsonVal["success"] = false;
jsonVal["message"] = "没有传感器号";
}
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_28(Param_28 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["cmd"] = "28";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["success"] = true;
jsonVal["message"] = "";
if (param.mDataNodeNo.length() > 0) {
char updateColumn[128] = { 0 };
char whereCon[64] = { 0 };
sprintf(whereCon, "dataNodeNo='%s'", param.mDataNodeNo.c_str());
sprintf(updateColumn, "dataNodeName='%s'", param.mDataNodeName.c_str());
sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), updateColumn, whereCon);
} else {
jsonVal["success"] = false;
jsonVal["message"] = "没有传感器号";
}
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_29(Param_29 &param)
{
Json::Value jsonVal;
Json::Value jsBody;
Json::Value SystemSetting;
jsonVal.clear();
jsonVal["cmd"] = "29";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["success"] = true;
jsonVal["message"] = " ";
std::string strWaveData = "";
std::string filename = "/opt/data/" + param.mChannelId + ".dat";
if (access(filename.c_str(), 0) >= 0) {
std::ifstream inFile(filename.c_str(),ios::in|ios::binary);
if (!inFile) {
print_error("read channel data error\n");
jsonVal["success"] = false;
jsonVal["message"] = "error";
} else {
float fTemp = 0;
std::vector<float> vecWave;
while (inFile.read((char *)&fTemp, sizeof(fTemp))) {
vecWave.push_back(fTemp);
}
int flag = param.mPackageFlag;
flag = (flag + 1) * 1024;
int number = vecWave.size();
int start = param.mPackageFlag * 1024;
if (number < 1024) {
flag = number;
start = 0;
}
char buf[32];
for (int i = start; i < flag; i++) {
if ( i == start ) {
memset(buf, 0, 32);
sprintf(buf, "%.2f", vecWave[i]);
std::string waveTemp(buf);
strWaveData = waveTemp;
} else {
memset(buf, 0, 32);
sprintf(buf, "%.2f", vecWave[i]);
std::string waveTemp(buf);
strWaveData = strWaveData + "," + waveTemp;
}
}
int max = number / 1024;
if (max == 0 && number > 0) {
max = 1;
}
jsBody["packageMax"] = max;
}
} else {
jsonVal["success"] = false;
jsonVal["message"] = "没有数据文件";
}
jsBody["channelId"] = param.mChannelId;
jsBody["package"] = param.mPackageFlag;
jsBody["Data"] = strWaveData;
jsonVal["content"] = jsBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_30(Param_30 &param)
{
/*Json::Value jsonVal;
jsonVal.clear();
jsonVal["cmd"] = "30";
jsonVal["success"] = true;
jsonVal["message"] = "";
Json::Value jsBody;
std::string strWaveData;
// if (GlobalConfig::WaveCgi.flag == 1) {
// int number = GlobalConfig::WaveCgi.number;
// char buf[32];
// int flag = param.mPackageFlag;
// flag = (flag + 1) * 1024;
// int start = param.mPackageFlag * 1024;
// if ( number < 1024) {
// flag = number;
// start = 0;
// }
// for (int i = start; i < flag; i++) {
// if ( i == start ) {
// strWaveData = (boost::lexical_cast<std::string>(GlobalConfig::WaveCgi.waveData[i])).substr(0.4);
// } else {
// memset(buf, 0, 32);
// sprintf(buf, "%.2f", GlobalConfig::WaveCgi.waveData[i]);
// std::string waveTemp(buf);
// strWaveData = strWaveData + "," + waveTemp;
// }
// }
// int max = number / 1024;
// if (max == 0 && number > 0) {
// max = 1;
// }
// jsBody["packageMax"] = max;
// } else {
// jsonVal["success"] = false;
// jsonVal["message"] = "数据获取失败";
// }
jsBody["channelId"] = param.mChannelId;
jsBody["package"] = param.mPackageFlag;
jsBody["Data"] = strWaveData;
jsonVal["content"] = jsBody;
return showValue.write(jsonVal);*/
Json::Value jsonVal;
Json::Value jsBody;
Json::Value SystemSetting;
jsonVal.clear();
jsonVal["cmd"] = "30";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["success"] = true;
jsonVal["message"] = "";
int i = 0;
std::string strWaveData;
std::string filename = "/opt/data/" + param.mChannelId + ".dat";
if (access(filename.c_str(), 0) >= 0)
{
std::ifstream inFile(filename.c_str(),ios::in|ios::binary);
if(!inFile)
{
print_error("read channel data error\n");
jsonVal["success"] = "false";
jsonVal["message"] = "error";
}else{
float fTemp = 0;
std::vector<float> vecWave;
std::vector<float> fftWave;
while(inFile.read((char *)&fTemp,sizeof(fTemp)))
{ // 取8K进行计算
if(i < 8192)
{
vecWave.push_back(fTemp);
}else{
break;
}
i++;
}
/*std::string strWaveData1 = "";
char buff[32] = {0};
for(int j=0;j<vecWave.size();j++)
{
if( 0==j )
{
memset(buff,0,32);
sprintf(buff, "%.2f", vecWave[j]);
std::string waveTemp(buff);
strWaveData1 = waveTemp;
}else{
memset(buff, 0, 32);
sprintf(buff, "%.2f", vecWave[j]);
std::string waveTemp(buff);
strWaveData1 = strWaveData1 + "," + waveTemp;
}
}
print_info("befor fft ------------------------------------------------------------> %s,vecWave.size()=%d\n", strWaveData1.c_str(),vecWave.size());*/
//进行傅立叶变换
pCalculation->FFTSpec(vecWave, fftWave);
printf("2---------------------------------------------->%d\n",fftWave.size());
/*std::string strWaveData2 = "";
char bufff[32] = {0};
for(int k=0;k<fftWave.size();k++)
{
if( 0==k )
{
memset(bufff,0,32);
sprintf(bufff, "%.2f", fftWave[k]);
std::string waveTemp(bufff);
strWaveData2 = waveTemp;
}else{
memset(bufff, 0, 32);
sprintf(bufff, "%.2f", fftWave[k]);
std::string waveTemp(bufff);
strWaveData2 = strWaveData2 + "," + waveTemp;
}
}*/
print_info("after fft--------------------------------------------------->fftWave.size()=%d\n", fftWave.size());
//print_info("after fft---------------------------------------------------> %s,fftWave.size()=%d\n", strWaveData2.c_str(),fftWave.size());
int flag = param.mPackageFlag;
//print_info("*********************************param.mPackageFlag=%d\n",param.mPackageFlag);
flag = (flag + 1) * 1024;
int number = fftWave.size();
int start = param.mPackageFlag * 1024;
if (number < 1024)
{
flag = number;
start = 0;
}
char buf[32] = {0};
//print_info("start=%d,flag=%d\n",start,flag);
for (int i = start; i < flag; i++)
{
if (i == start)
{
memset(buf, 0, 32);
sprintf(buf, "%.2f", fftWave[i]);
std::string waveTemp(buf);
if (0 == i)
{
strWaveData = boost::lexical_cast<string>(0);
}else{
strWaveData = waveTemp;
}
}else{
memset(buf, 0, 32);
sprintf(buf, "%.2f", fftWave[i]);
std::string waveTemp(buf);
strWaveData = strWaveData + "," + waveTemp;
}
}
//print_info("@strwavedata=%s@,strWaveData.sizeof=%d,fftWave.size()=%d\n",strWaveData.c_str(),strWaveData.size(),fftWave.size());
int max = number / 1024;
//print_info("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&max=%d\n",max);
if (max == 0 && number > 0)
{
max = 1;
}
jsBody["packageMax"] = max;
}
} else {
jsonVal["success"] = false;
jsonVal["message"] = "数据获取失败";
}
jsBody["channelId"] = param.mChannelId;
jsBody["package"] = param.mPackageFlag;
jsBody["Data"] = strWaveData;
/* 新增代码 */
char whereCon[64] = {};
sprintf(whereCon, "dataNodeNo='%s'",param.mDataNodeNo.c_str());
std::string sample_rate = sql_ctl->GetData(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(SAMPLINGRATE), whereCon);
printf("@@@@@@@@@@@@@@@@@@@@sample_rate=%s\n",sample_rate.c_str());
int SampleRate = boost::lexical_cast<int>(sample_rate.c_str());
double resolution = (double)SampleRate / 8192;
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@the sample rate is %d,the resolution %f\n",SampleRate,resolution);
char buf[32];
memset(buf, 0, 32);
sprintf(buf, "%f", resolution);
jsBody["resolution"] = std::string(buf);
jsonVal["content"] = jsBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_31(Param_31 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["cmd"] = "31";
if(0 == param.mMode)
{
/*char buf[32];
memset(buf, 0, 32);
sprintf(buf, "%d", param.mChannelId);
print_red("@@@@@@@@@@@@@@@@,,,,,%s\n",buf);
WriteStr2Config(ZIGBEECONFIG, "Zigbee", "channel", std::string(buf));*/
WriteStr2Config(ZIGBEECONFIG, "Zigbee", "channel", param.mChannelId);
//pUart->ZigbeeInit();
//pUart->UpdateZigbeeInfoCtrl();
}
Json::Value jsBody;
jsonVal["message"] = "设置完成";
jsonVal["success"] = true;
jsBody["channel"] = ReadStrByOpt(ZIGBEECONFIG, "Zigbee", "channel");
jsBody["panID"] = GlobalConfig::ZigbeeInfo_G.PanID;
jsBody["status"] = "1";
jsonVal["content"] = jsBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_32(Param_32 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["cmd"] = "32";
jsonVal["success"] = true;
jsonVal["message"] = "";
Json::Value jsBody;
std::string strWaveData;
// if (GlobalConfig::WaveFFtCgi.flag == 1) {
// int number = GlobalConfig::WaveFFtCgi.number;
// char buf[32];
// int flag = param.mPackageFlag;
// flag = (flag + 1) * 1024;
// int start = param.mPackageFlag * 1024;
// if ( number < 1024) {
// flag = number;
// start = 0;
// }
// for (int i = start; i < flag; i++) {
// if ( i == start ) {
// strWaveData = (boost::lexical_cast<std::string>(GlobalConfig::WaveFFtCgi.waveData[i])).substr(0.4);
// } else {
// memset(buf, 0, 32);
// sprintf(buf, "%.2f", GlobalConfig::WaveFFtCgi.waveData[i]);
// std::string waveTemp(buf);
// strWaveData = strWaveData + "," + waveTemp;
// }
// }
// int max = number / 1024;
// if (max == 0 && number > 0) {
// max = 1;
// }
// jsBody["packageMax"] = max;
// } else {
// jsonVal["success"] = false;
// jsonVal["message"] = "数据获取失败";
// }
jsBody["channelId"] = param.mChannelId;
jsBody["package"] = param.mPackageFlag;
jsBody["Data"] = strWaveData;
jsonVal["content"] = jsBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_43()
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["success"] = true;
jsonVal["message"] = "";
// int flag = CheckNic("eth0");
// Json::Value jsBody;
// if (0 == flag) {
// jsBody["status"] = 1;
// } else {
// jsBody["status"] = 0;
// }
// jsonVal["content"] = jsBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_default()
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal["success"] = false;
jsonVal["message"] = "功能不支持";
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_45(Param_45 &param)
{
Json::Value jsonVal;
jsonVal.clear();
if (0 == param.mMode) {
char localtimestamp[32] = { 0 };
GetTimeNet(localtimestamp, 1);
std::string nowTimetamp = std::string(localtimestamp);
WriteStr2Config(SYSTEMINFOFILE, "Area", "countryId", param.mCountryId);
WriteStr2Config(SYSTEMINFOFILE, "Area", "provincesId", param.mProvincesId);
WriteStr2Config(SYSTEMINFOFILE, "Area", "cityListId", param.mCityListId);
}
jsonVal[JSON_FIELD_CMD] = "45";
jsonVal["success"] = true;
jsonVal["message"] = "区域配置成功";
Json::Value jsBody;
jsBody["countryId"] = ReadStrByOpt(SYSTEMINFOFILE, "Area", "countryId");
jsBody["provincesId"] = ReadStrByOpt(SYSTEMINFOFILE, "Area", "provincesId");
jsBody["cityListId"] = ReadStrByOpt(SYSTEMINFOFILE, "Area", "cityListId");
jsonVal["content"] = jsBody;
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_46(Param_46 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal[JSON_FIELD_CMD] = "46";
jsonVal["success"] = true;
jsonVal["message"] = "升级失败";
std::string strFile = "/var/" + param.mFileName;
if (access(strFile.c_str(), 0) >= 0) {
std::string strCmd = "mv " + strFile + " /tmp/upgrade.tar.gz";
system(strCmd.c_str());
system("/etc/init.d/sysupgrade.sh");
} else {
jsonVal["success"] = false;
jsonVal["message"] = "没有升级包";
return showValue.write(jsonVal);
}
return showValue.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_47(Param_47 &param)
{
Json::Value jsonVal;
jsonVal.clear();
jsonVal[JSON_FIELD_CMD] = "47";
jsonVal["success"] = true;
jsonVal["message"] = "logo配置成功";
std::string strFile = "/var/" + param.mFileName;
if (access(strFile.c_str(), 0) >= 0) {
std::string strCmd = "mv " + strFile + " /var/www/html/static/media/logo.svg";
system(strCmd.c_str());
} else {
jsonVal["success"] = false;
jsonVal["message"] = "没有找到logo";
return showValue.write(jsonVal);
}
return showValue.write(jsonVal);
}