|
|
@@ -4,12 +4,7 @@
|
|
|
|
|
|
FromEQM::FromEQM()
|
|
|
{
|
|
|
- m_logger = spdlog::get("WebAPI");
|
|
|
- if(m_logger == nullptr)
|
|
|
- {
|
|
|
- SPDLOG_ERROR("WebAPI logger is nullptr");
|
|
|
- return;
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
FromEQM::~FromEQM()
|
|
|
@@ -31,12 +26,12 @@ bool FromEQM::initWebApi(const QString& url, const QString& serverIP, const QStr
|
|
|
}
|
|
|
if(!m_httpApi->Load())
|
|
|
{
|
|
|
- SPDLOG_LOGGER_ERROR(m_logger,"Load WebApi failed");
|
|
|
+ SPDLOG_ERROR("Load WebApi failed");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
int ret = 0;
|
|
|
- m_httpApi->DBInit(url.toStdString().c_str());
|
|
|
+ auto pHttp = m_httpApi->DBInit(url.toStdString().c_str(), true);
|
|
|
// if(ret < 0)
|
|
|
// {
|
|
|
// SPDLOG_LOGGER_ERROR(m_logger,"Init WebApi failed:{}, error Info:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
@@ -45,22 +40,86 @@ bool FromEQM::initWebApi(const QString& url, const QString& serverIP, const QStr
|
|
|
// SPDLOG_LOGGER_TRACE(m_logger,"初始化WebApi成功!");
|
|
|
// QString serverList;
|
|
|
char serverList[8192] = {0};
|
|
|
- ret = m_httpApi->DBGetServerList(serverList, 8192);
|
|
|
+ ret = m_httpApi->DBGetServerList(serverList, 8192-1);
|
|
|
if(ret < 0)
|
|
|
{
|
|
|
- SPDLOG_LOGGER_ERROR(m_logger,"Get server list failed:{}, error info:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
+ SPDLOG_ERROR("Get server list failed:{}, error info:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
// return false;
|
|
|
}
|
|
|
// SPDLOG_LOGGER_TRACE(m_logger,"Server list:{}",serverList.toStdString());
|
|
|
- SPDLOG_LOGGER_DEBUG(m_logger,"WebAPI Sucess!");
|
|
|
+ SPDLOG_DEBUG("WebAPI Sucess!");
|
|
|
/* 登录,第二个参数是限制的服务 */
|
|
|
- ret = m_httpApi->DBLogin(serverIP, serID, "FACS", m_userToken);
|
|
|
+ ret = m_httpApi->DBLogin(serverIP, serID, "SPSC", m_userToken, true, pHttp);
|
|
|
if(ret < 0)
|
|
|
{
|
|
|
- SPDLOG_LOGGER_ERROR(m_logger,"WebAPI Login failed:{}, error info:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
+ SPDLOG_ERROR("WebAPI Login failed:{}, error info:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ SPDLOG_INFO("WebAPI Login sucess!");
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+bool FromEQM::test()
|
|
|
+{
|
|
|
+ if(m_httpApi == nullptr)
|
|
|
+ {
|
|
|
+ SPDLOG_ERROR("WebAPI is nullptr");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ nJson json0 = nJson::array();
|
|
|
+
|
|
|
+ nJson jsonData1;
|
|
|
+ jsonData1["opName"] = "SPSC_test";
|
|
|
+ jsonData1["Key"] = 1;
|
|
|
+ nJson jsonParam1;
|
|
|
+ jsonParam1["pkid"] = 2807;
|
|
|
+ jsonData1["paramList"] = jsonParam1;
|
|
|
+ json0.push_back(jsonData1);
|
|
|
+
|
|
|
+ nJson jsonData2;
|
|
|
+ jsonData2["opName"] = "SPSC_test";
|
|
|
+ // jsonData2["Key"] = 2;
|
|
|
+ nJson jsonParam2;
|
|
|
+ jsonParam2["pkid"] = 2808;
|
|
|
+ jsonData2["paramList"] = jsonParam2;
|
|
|
+ json0.push_back(jsonData2);
|
|
|
+
|
|
|
+ SPDLOG_INFO("json: {}", jsonData2.dump(4));
|
|
|
+ QString strCmd = QString::fromStdString(jsonData2.dump());
|
|
|
+ QString strRet;
|
|
|
+ auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
|
|
|
+ if(ret != 0)
|
|
|
+ {
|
|
|
+ SPDLOG_ERROR("DBDoInterface failed: {}, error info: {}", ret, m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ SPDLOG_INFO("DBDoInterface sucess: {}", nJson::parse(strRet.toStdString()).dump(4));
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+bool FromEQM::test2()
|
|
|
+{
|
|
|
+ nJson json0;
|
|
|
+ json0["opName"] = "SPSC_GetOnWorkInfoByTime";
|
|
|
+ nJson jsonData;
|
|
|
+ jsonData["startTime"] = "2024-10-01 00:00:00";
|
|
|
+ jsonData["endTime"] = "2024-10-02 23:59:59";
|
|
|
+ json0["paramList"] = jsonData;
|
|
|
+
|
|
|
+ SPDLOG_INFO("strCmd: {}", json0.dump(4));
|
|
|
+ QString strCmd = QString::fromStdString(json0.dump());
|
|
|
+ QString strRet;
|
|
|
+ int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
|
|
|
+ if(ret != 0)
|
|
|
+ {
|
|
|
+ SPDLOG_ERROR("DBDoInterface failed: {}, error info: {}", ret, m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
+
|
|
|
return false;
|
|
|
}
|
|
|
- SPDLOG_LOGGER_INFO(m_logger,"WebAPI Login sucess!");
|
|
|
+
|
|
|
+ SPDLOG_INFO("DBDoInterface sucess: {}", nJson::parse(strRet.toStdString()).dump(4));
|
|
|
|
|
|
return true;
|
|
|
}
|