|
@@ -175,14 +175,13 @@ bool FromWebAPI::getDeviceInfo(QMap<QString, DeviceInfo>& mapDevice)
|
|
bool FromWebAPI::getChannelInfo(QMap<int, ChannelInfo>& mapFreq)
|
|
bool FromWebAPI::getChannelInfo(QMap<int, ChannelInfo>& mapFreq)
|
|
{
|
|
{
|
|
/* 测试,创建几个频率 */
|
|
/* 测试,创建几个频率 */
|
|
- // for(int i = 0; i < 12; i++)
|
|
|
|
- // {
|
|
|
|
- // ChannelInfo freqInfo;
|
|
|
|
- // freqInfo.ChannelID = i + 1;
|
|
|
|
- // freqInfo.ChannelName = QString("频率%1").arg(freqInfo.ChannelID);
|
|
|
|
- // mapFreq.insert(freqInfo.ChannelID, freqInfo);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
|
|
+ for(int i = 0; i < 12; i++)
|
|
|
|
+ {
|
|
|
|
+ ChannelInfo freqInfo;
|
|
|
|
+ freqInfo.ChannelID = i + 1;
|
|
|
|
+ freqInfo.ChannelName = QString("频率%1").arg(freqInfo.ChannelID);
|
|
|
|
+ mapFreq.insert(freqInfo.ChannelID, freqInfo);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
if(m_httpApi == nullptr)
|
|
if(m_httpApi == nullptr)
|
|
@@ -410,6 +409,7 @@ bool FromWebAPI::getExecPlanData(int chnID, QList<OnePlanItemInfo>& list)
|
|
|
|
|
|
bool FromWebAPI::getExecPlanData(QMap<int, QList<OnePlanItemInfo>>& mapPlan)
|
|
bool FromWebAPI::getExecPlanData(QMap<int, QList<OnePlanItemInfo>>& mapPlan)
|
|
{
|
|
{
|
|
|
|
+
|
|
if(m_httpApi == nullptr)
|
|
if(m_httpApi == nullptr)
|
|
{
|
|
{
|
|
LH_WRITE_ERROR("WebAPI is nullptr");
|
|
LH_WRITE_ERROR("WebAPI is nullptr");
|
|
@@ -901,7 +901,7 @@ bool FromWebAPI::saveTemplate(const QString& templateName, QList<OnePlanItemInfo
|
|
}
|
|
}
|
|
|
|
|
|
/* 获取模板内容 */
|
|
/* 获取模板内容 */
|
|
-bool FromWebAPI::getTemplate(QString templateName, QList<OnePlanItemInfo>& list)
|
|
|
|
|
|
+bool FromWebAPI::getOneTemplateData(QString templateName, QList<OnePlanItemInfo>& list)
|
|
{
|
|
{
|
|
if(m_httpApi == nullptr)
|
|
if(m_httpApi == nullptr)
|
|
{
|
|
{
|
|
@@ -935,20 +935,15 @@ bool FromWebAPI::getTemplate(QString templateName, QList<OnePlanItemInfo>& list)
|
|
for(auto& it : result)
|
|
for(auto& it : result)
|
|
{
|
|
{
|
|
OnePlanItemInfo info;
|
|
OnePlanItemInfo info;
|
|
- // info.devName = QString::fromStdString(it["deviceName"].get<std::string>());
|
|
|
|
- // if(!DeviceContainer.findDevice(info.devName))
|
|
|
|
- // {
|
|
|
|
- // LH_WRITE_LOG(QString("未找到设备:%1").arg(info.devName));
|
|
|
|
- // continue;
|
|
|
|
- // }
|
|
|
|
- // auto tmpDate = it["execDate"].is_null() ? "" : it["execDate"].get<std::string>();
|
|
|
|
- // if(!tmpDate.empty())
|
|
|
|
- // {
|
|
|
|
- // info.dateTime.setDate(QDate::fromString(QString::fromStdString(tmpDate),"yyyy-MM-dd"));
|
|
|
|
- // }
|
|
|
|
- // info.dateTime.setTime(QTime::fromString(QString::fromStdString(it["execTime"].get<std::string>()),"hh:mm:ss"));
|
|
|
|
- // info.actionName = QString::fromStdString(it["actionName"].get<std::string>());
|
|
|
|
- // info.actionID = it["actionID"].get<int>();
|
|
|
|
|
|
+
|
|
|
|
+ info.ChannelID = it["channelID"].is_null() ? -1 : it["channelID"].get<int>();
|
|
|
|
+ info.ChannelName = QString::fromStdString(it["channelName"].get<std::string>());
|
|
|
|
+ info.onWeekDay = static_cast<enum_WeekDay>(it["onWeekDay"].get<int>());
|
|
|
|
+ info.onDateTime.setDate(QDate::fromString(QString::fromStdString(it["onDate"].get<std::string>()), "yyyy-MM-dd"));
|
|
|
|
+ info.onDateTime.setTime(QTime::fromString(QString::fromStdString(it["onTime"].get<std::string>()), "hh:mm:ss"));
|
|
|
|
+ info.offWeekDay = static_cast<enum_WeekDay>(it["offWeekDay"].get<int>());
|
|
|
|
+ info.offDateTime.setDate(QDate::fromString(QString::fromStdString(it["offDate"].get<std::string>()), "yyyy-MM-dd"));
|
|
|
|
+ info.offDateTime.setTime(QTime::fromString(QString::fromStdString(it["offTime"].get<std::string>()), "hh:mm:ss"));
|
|
|
|
|
|
list.append(info);
|
|
list.append(info);
|
|
}
|
|
}
|
|
@@ -974,6 +969,91 @@ bool FromWebAPI::getTemplate(QString templateName, QList<OnePlanItemInfo>& list)
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+/* 获取多个模板的内容 */
|
|
|
|
+bool FromWebAPI::getTemplateData(QList<OneTemplateInfo>& listTemplate, QMap<int, QList<OnePlanItemInfo>>& mapPlan)
|
|
|
|
+{
|
|
|
|
+ if(m_httpApi == nullptr)
|
|
|
|
+ {
|
|
|
|
+ LH_WRITE_ERROR("WebAPI is nullptr");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ nJson json0 = nJson::array();
|
|
|
|
+ for(auto& it : listTemplate)
|
|
|
|
+ {
|
|
|
|
+ nJson json1;
|
|
|
|
+ json1["opName"] = "TMS_GetExecPlanTemplateData";
|
|
|
|
+ json1["Key"] = QUuid::createUuid().toString().toStdString();
|
|
|
|
+ json1["templateName"] = it.templateName.toStdString();
|
|
|
|
+ json0.push_back(json1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ QString strCmd = QString::fromStdString(json0.dump());
|
|
|
|
+ QString strRet;
|
|
|
|
+ auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet, true);
|
|
|
|
+ if(ret != 0)
|
|
|
|
+ {
|
|
|
|
+ LH_WRITE_ERROR(QString("获取模板失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ /* 解析获取到的JSON数据 */
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ nJson jsonRet = nJson::parse(strRet.toStdString());
|
|
|
|
+ int retCode = jsonRet["code"].get<int>();
|
|
|
|
+ if(retCode != 0)
|
|
|
|
+ {
|
|
|
|
+ LH_WRITE_ERROR("获取模板失败");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ nJson result = jsonRet["result"];
|
|
|
|
+ for(auto& it : result)
|
|
|
|
+ {
|
|
|
|
+ OnePlanItemInfo info;
|
|
|
|
+
|
|
|
|
+ info.ChannelID = it["channelID"].is_null() ? -1 : it["channelID"].get<int>();
|
|
|
|
+ info.ChannelName = QString::fromStdString(it["channelName"].get<std::string>());
|
|
|
|
+ info.onWeekDay = static_cast<enum_WeekDay>(it["onWeekDay"].get<int>());
|
|
|
|
+ info.onDateTime.setDate(QDate::fromString(QString::fromStdString(it["onDate"].get<std::string>()), "yyyy-MM-dd"));
|
|
|
|
+ info.onDateTime.setTime(QTime::fromString(QString::fromStdString(it["onTime"].get<std::string>()), "hh:mm:ss"));
|
|
|
|
+ info.offWeekDay = static_cast<enum_WeekDay>(it["offWeekDay"].get<int>());
|
|
|
|
+ info.offDateTime.setDate(QDate::fromString(QString::fromStdString(it["offDate"].get<std::string>()), "yyyy-MM-dd"));
|
|
|
|
+ info.offDateTime.setTime(QTime::fromString(QString::fromStdString(it["offTime"].get<std::string>()), "hh:mm:ss"));
|
|
|
|
+
|
|
|
|
+ /* 查找该频率所属的列表 */
|
|
|
|
+ auto list = mapPlan.find(info.ChannelID);
|
|
|
|
+ if(list == mapPlan.end())
|
|
|
|
+ {
|
|
|
|
+ /* 创建一个新的列表 */
|
|
|
|
+ QList<OnePlanItemInfo> listPlan;
|
|
|
|
+ listPlan.append(info);
|
|
|
|
+ mapPlan.insert(info.ChannelID, listPlan);
|
|
|
|
+ }else {
|
|
|
|
+ /* 找到对应的列表 */
|
|
|
|
+ list->append(info);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ catch (const nJson::parse_error& e)
|
|
|
|
+ {
|
|
|
|
+ LH_WRITE_ERROR(QString("解析模板失败:%1").arg(e.what()));
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ catch (const nJson::exception& e)
|
|
|
|
+ {
|
|
|
|
+ LH_WRITE_ERROR(QString("解析模板失败:%1").arg(e.what()));
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ catch(...)
|
|
|
|
+ {
|
|
|
|
+ LH_WRITE_ERROR("解析模板失败");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
/* 获取模板列表 */
|
|
/* 获取模板列表 */
|
|
bool FromWebAPI::getTemplateList(QMultiMap<int, OneTemplateInfo>& mapTemplate)
|
|
bool FromWebAPI::getTemplateList(QMultiMap<int, OneTemplateInfo>& mapTemplate)
|
|
{
|
|
{
|