Selaa lähdekoodia

V1.1.2
1、添加了一些弱提示
2、新增了保存全局配置的功能
3、修复了一些其他bug

Apple 1 kuukausi sitten
vanhempi
commit
72436d7d21

+ 35 - 0
SwitchOnOff.sql

@@ -49,6 +49,10 @@ SELECT *
 FROM tExecPlanTemplate
 WHERE "TemplateName" = :templateName;
 
+#删除表格中的所有数据
+DELETE
+FROM tExecPlanTemplate;
+
 SELECT *
 FROM TMONITORPIN;
 
@@ -124,3 +128,34 @@ WHERE PTTypeCode = :PTTypeCode;
 #删除表格
 DROP TABLE IF EXISTS "EQM_CESHI"."tExecPlan";
 
+
+#===============================================
+# 执行计划页面全局配置表格-tExecPlanConfig
+#===============================================
+
+#删除表格
+DROP TABLE IF EXISTS "EQM_CESHI"."tExecPlanConfig";
+
+#清空表格
+DELETE
+FROM tExecPlanConfig;
+
+#创建表格
+CREATE TABLE IF NOT EXISTS "EQM_CESHI"."tExecPlanConfig" (
+    "KeyWord" INT PRIMARY KEY,
+    "Value1" INT
+)
+
+#查询表格
+SELECT *
+FROM tExecPlanConfig;
+
+#插入数据
+INSERT INTO "tExecPlanConfig" ("KeyWord", "Value1")
+VALUES (:keyWord, :value1);
+
+
+#根据关键字删除数据
+DELETE
+FROM tExecPlanConfig
+WHERE KeyWord = :keyWord;

+ 3 - 0
TransmitterSwitch/CMakeLists.txt

@@ -34,6 +34,8 @@ file(GLOB LOCAL_SRC
     ${CMAKE_CURRENT_SOURCE_DIR}/common/warning/*.cpp
     # ${CMAKE_CURRENT_SOURCE_DIR}/common/LHLog/*.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/common/Logs/*.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/common/TipWidget/*.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/common/TipWidget/*.qrc
 
     # ${LHQLog_SOURCE_DIRS}/*.cpp
     ${LHHTTPAPI_SOURCE_DIRS}/*.cpp
@@ -75,6 +77,7 @@ target_include_directories(${lib_name} PRIVATE
     ${CMAKE_CURRENT_SOURCE_DIR}/common/warning
     ${CMAKE_CURRENT_SOURCE_DIR}/common/LHLog
     ${CMAKE_CURRENT_SOURCE_DIR}/common/Logs
+    ${CMAKE_CURRENT_SOURCE_DIR}/common/TipWidget
 
     # ${LHQLog_INCLUDE_DIRS}
     ${LHHTTPAPI_INCLUDE_DIRS}

+ 1 - 1
TransmitterSwitch/Template/importtemplate.cpp

@@ -88,7 +88,7 @@ ImportTemplate::ImportTemplate(QMap<QString, int> tabList, int type, QWidget *pa
     QStringList list;
     for(auto begin = tabList.begin(); begin != tabList.end(); begin++)
     {
-        LH_WRITE_LOG_DEBUG(QString("模版名称:%1, 类型:%2").arg(begin.key()).arg(begin.value()));
+        // LH_WRITE_LOG_DEBUG(QString("模版名称:%1, 类型:%2").arg(begin.key()).arg(begin.value()));
         if(begin.value() != m_type)
         {
             continue;

+ 18 - 4
TransmitterSwitch/Template/savetotemplate.cpp

@@ -70,10 +70,24 @@ void SaveToTemplate::setItemEmpty(bool flag)
 }
 
 
-/* 传入所有的模板名称 */
-void SaveToTemplate::setTemplateName(const QMap<QString, int> list)
+/* 传入所有的模板名称,会进行判断,只传入相同类型的模板名称 */
+void SaveToTemplate::setTemplateName(const QMap<QString, int> list, int type)
 {
+    // m_templateNameList.clear();
+    // for(auto begin = list.begin(); begin != list.end(); begin++)
+    // {
+    //     if(begin.value() != type)
+    //     {
+    //         continue;
+    //     }
+    //     m_templateNameList.insert(begin.key(), begin.value());
+    // }
+
     m_templateNameList = list;
+    // for(auto begin = m_templateNameList.begin(), end = m_templateNameList.end(); begin != end; ++begin)
+    // {
+    //     LH_WRITE_LOG_DEBUG(QString("模板名称:%1, 类型:%2").arg(begin.key()).arg(begin.value()));
+    // }
 }
 
 
@@ -125,9 +139,9 @@ void SaveToTemplate::do_ok()
     }
     /* 检查模板名称是否重复 */
     bool flag = false;
-    for(const auto& it : m_templateNameList)
+    for(auto begin = m_templateNameList.begin(), end = m_templateNameList.end(); begin != end; ++begin)
     {
-        if(it == m_templateName)
+        if(begin.key() == m_templateName)
         {
             flag = true;
             break;

+ 1 - 1
TransmitterSwitch/Template/savetotemplate.h

@@ -26,7 +26,7 @@ public:
     /* 传入计划项是否为空 */
     void setItemEmpty(bool flag);
     /* 传入所有的模板名称 */
-    void setTemplateName(const QMap<QString, int> list);
+    void setTemplateName(const QMap<QString, int> list, int type);
 
     /* 获取是否点击了确定 */
     bool isOk() { return m_isOk; }

+ 19 - 0
TransmitterSwitch/TransmitterSwitchInfo.h

@@ -45,6 +45,25 @@ enum class enum_UIStyle
     UI_Dark = 1                 /* 暗色 */
 };
 
+/**
+ * @brief tExecPlanConfig表格的关键字
+ * 
+ */
+enum class enum_ExecPlanConfig : int
+{
+    DefaultPlan = 1,            /* 执行计划 */
+    ExecMode = 2                /* 执行模式 */
+};
+
+/**
+ * @brief 默认计划选项
+ * 
+ */
+ enum class enum_DefaultPlan : int
+ {
+    DefaultPlan_ON = 0,             /* 默认计划关 */
+    DefaultPlan_OFF = 1             /* 默认计划开 */
+ };
 
 struct InitData
 {

+ 181 - 18
TransmitterSwitch/WebAPI/FromWebAPI.cpp

@@ -33,7 +33,7 @@ bool FromWebAPI::initWebApi(const QString& url, const QString& serverID, const Q
     }
 #if defined(Q_OS_WIN)
     #ifdef QT_DEBUG
-    QString libFile = QString("%1/LHSqlWebInterfaced.dll").arg(QApplication::applicationDirPath());
+    QString libFile = QString("%1/LHSqlWebInterface.dll").arg(QApplication::applicationDirPath());
     #else
     QString libFile = QString("%1/LHSqlWebInterface.dll").arg(QApplication::applicationDirPath());
     #endif
@@ -53,7 +53,7 @@ bool FromWebAPI::initWebApi(const QString& url, const QString& serverID, const Q
     LH_WRITE_LOG_DEBUG(QString("ServerID:%1").arg(serverID));
     LH_WRITE_LOG_DEBUG(QString("ServerKey:%1").arg(serverKey));
 
-    m_httpApi->DBInit(url.toStdString().c_str());
+    auto pHttp = m_httpApi->DBInit(url.toStdString().c_str());
     
     int ret = 0;
 
@@ -70,7 +70,7 @@ bool FromWebAPI::initWebApi(const QString& url, const QString& serverID, const Q
 #endif
 
     /* 登录,第二个参数是限制的服务 */
-    ret = m_httpApi->DBLogin("", serverID, serverKey, m_userToken);
+    ret = m_httpApi->DBLogin("", serverID, serverKey, m_userToken, true, pHttp);
     if(ret < 0)
     {
         LH_WRITE_ERROR(QString("Login failed:%1, error info:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
@@ -94,7 +94,7 @@ bool FromWebAPI::getDeviceInfo(QMap<QString, DeviceInfo>& mapDevice)
     json0["opName"] = "ESM8C_GetDevice";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret < 0)
     {
         LH_WRITE_ERROR(QString("从数据库获取设备失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
@@ -256,14 +256,13 @@ bool FromWebAPI::insertData(QList<ExecPlanItemInfo>& list)
     /* 写入EQM数据库 */
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet, true);
     if(ret < 0)
     {
         LH_WRITE_ERROR(QString("写入EQM数据库失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
         return false;
     }
-    LH_WRITE_LOG("写入EQM数据库成功");
-
+    LH_WRITE_LOG(QString("计划写入EQM数据库成功, 计划数目:%1").arg(QString::number(list.size())));
 
     return true;
 }
@@ -287,7 +286,7 @@ bool FromWebAPI::getExecPlanData(QList<ExecPlanItemInfo>& list)
     json0["opName"] = "ESM8C_GetExecPlan";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret < 0)
     {
         LH_WRITE_ERROR(QString("从EQM获取tExecPlan表格数据失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
@@ -346,9 +345,168 @@ bool FromWebAPI::getExecPlanData(QList<ExecPlanItemInfo>& list)
         return false;
     }
 
-    LH_WRITE_LOG_DEBUG(QString("从EQM.tExecPlan表格获取数据成功,数据数目:%1").arg(list.size()));
+    LH_WRITE_LOG_DEBUG(QString("从EQM.tExecPlan表格获取数据成功,计划数目:%1").arg(list.size()));
+
+
+    return true;
+}
+
+/* 将页面的配置写入数据库 */
+bool FromWebAPI::insertConfigData(QMap<int, int>& mapConfig)
+{
+    if(m_httpApi == nullptr)
+    {
+        LH_WRITE_ERROR("WebAPI is nullptr");
+        return false;
+    }
+
+    deleteConfigData(mapConfig);
+
+    nJson json0 = nJson::array();
+    try{
+        for(auto begin = mapConfig.begin(), end = mapConfig.end(); begin != end; begin++)
+        {
+            nJson json1;
+            json1["opName"] = "ESM8C_InsertExecPlanConfig";
+            json1["Key"] = QUuid::createUuid().toString().toStdString();
+            nJson json2;
+            json2["keyWord"] = begin.key();
+            json2["value1"] = begin.value();
+            json1["paramList"] = json2;
+            json0.push_back(json1);
+        }
+    }catch (const nJson::parse_error& e) {
+        SPDLOG_ERROR("生成json数据失败:{}", e.what());
+        return false;
+    }
+    catch (const nJson::exception& e)
+    {
+        SPDLOG_ERROR("生成json数据失败:{}", e.what());
+        return false;
+    }
+    catch (...)
+    {
+        SPDLOG_ERROR("生成json数据失败");
+        return false;
+    }
+
+    /* 写入EQM数据库 */
+    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("写入tExecPlanConfig失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
+        return false;
+    }
+    LH_WRITE_LOG(QString("页面配置写入tExecPlanConfig成功, 计划数目:%1").arg(QString::number(mapConfig.size())));
+
+    return true;
+}
+
+/* 删除配置数据 */
+bool FromWebAPI::deleteConfigData(QMap<int, int>& mapConfig)
+{
+    if(m_httpApi == nullptr)
+    {
+        LH_WRITE_ERROR("WebAPI is nullptr");
+        return false;
+    }
+
+    nJson json0 = nJson::array();
+    try{
+        for(auto begin = mapConfig.begin(), end = mapConfig.end(); begin != end; begin++)
+        {
+            nJson json1;
+            json1["opName"] = "ESM8C_DeleteExecPlanConfig";
+            json1["Key"] = QUuid::createUuid().toString().toStdString();
+            nJson json2;
+            json2["keyWord"] = begin.key();
+            json1["paramList"] = json2;
+            json0.push_back(json1);
+        }
+    }catch (const nJson::parse_error& e) {
+        SPDLOG_ERROR("生成json数据失败:{}", e.what());
+        return false;
+    }
+    catch (const nJson::exception& e)
+    {
+        SPDLOG_ERROR("生成json数据失败:{}", e.what());
+        return false;
+    }
+    catch (...)
+    {
+        SPDLOG_ERROR("生成json数据失败");
+        return false;
+    }
+
+    /* 写入EQM数据库 */
+    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("删除tExecPlanConfig表格数据失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
+        return false;
+    }
+    LH_WRITE_LOG_DEBUG(QString("删除tExecPlanConfig表格数据成功, 计划数目:%1").arg(QString::number(mapConfig.size())));
+
+    return true;
+}
+
+/* 获取配置数据 */
+bool FromWebAPI::getConfigData(QMap<int, int>& mapConfig)
+{
+    if(m_httpApi == nullptr)
+    {
+        LH_WRITE_ERROR("WebAPI is nullptr");
+        return false;
+    }
+    nJson json0;
+    json0["opName"] = "ESMC_GetExecPlanConfig";
+    QString strCmd = QString::fromStdString(json0.dump());
+    QString strRet;
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
+    if(ret < 0)
+    {
+        LH_WRITE_ERROR(QString("获取tExecPlanConfig表格数据失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
+        return false;
+    }
+    /* 解析获取到的JSON数据 */
+    LH_WRITE_LOG_DEBUG(strRet);
+    try{
+        nJson json1 = nJson::parse(strRet.toStdString());
+        int retCode = json1["code"].get<int>();
+        if(retCode != 0)
+        {
+            LH_WRITE_ERROR("获取tExecPlanConfig失败");
+            return false;
+        }
+        nJson result = json1["result"];
+        for(auto& it : result)
+        {
+            int keyWord = it["keyWord"].get<int>();
+            int value1 = it["value1"].get<int>();
+            mapConfig.insert(keyWord, value1);
+        }
 
+    } 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;
+    }
 
+    LH_WRITE_LOG_DEBUG(QString("获取tExecPlanConfig表格数据成功,数据数目:%1").arg(mapConfig.size()));
+    
     return true;
 }
 
@@ -365,7 +523,7 @@ bool FromWebAPI::getEQMTemplateID(QList<int>& listId)
     json0["opName"] = "ESMC_GetTemplateNumFromExecPlan";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret < 0)
     {
         LH_WRITE_ERROR(QString("从EQM获取模版编号失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
@@ -429,7 +587,7 @@ bool FromWebAPI::deleteAllRow()
     json0["opName"] = "ESM8C_DeleteAllRow";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet, true);
     if(ret < 0)
     {
         LH_WRITE_ERROR(QString("删除所有行失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
@@ -464,7 +622,7 @@ bool FromWebAPI::deleteAllTransmitterPlan()
         json0["paramList"].push_back(json1);
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet);
+        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet, true);
         if(ret < 0)
         {
             LH_WRITE_ERROR(QString("删除发射机(%3)计划失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)).arg(it));
@@ -494,7 +652,7 @@ bool FromWebAPI::saveTemplate(const QString& templateName, const int type, QList
         nJson json2;
 
         json2["templateName"] = templateName.toStdString();
-        json2["type"] = type;
+        json2["templateType"] = type;
         json2["execDate"] = it.date.toString("yyyy-MM-dd").toStdString();
         json2["execTime"] = it.execTime.toString("hh:mm:ss").toStdString();
         json2["deviceName"] = it.devName.toStdString();
@@ -513,13 +671,13 @@ bool FromWebAPI::saveTemplate(const QString& templateName, const int type, QList
     /* 写入EQM数据库 */
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, 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;
     }
-    LH_WRITE_LOG("保存到模板成功");
+    LH_WRITE_LOG("保存到模板成功,模板名称:" + templateName + ", 类型:" + QString::number(type) + ", 计划数目:" + QString::number(list.size()));
 
     return true;
     
@@ -541,7 +699,7 @@ bool FromWebAPI::getTemplate(QString templateName, QList<ExecPlanItemInfo>& list
     json0["paramList"] = json1;
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret < 0)
     {
         LH_WRITE_ERROR(QString("获取模板失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
@@ -613,7 +771,7 @@ bool FromWebAPI::getTemplateList(QMap<QString, int>& list)
     json0["opName"] = "TMS_GetExecPlanTemplateList";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret < 0)
     {
         LH_WRITE_ERROR(QString("获取模板列表失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
@@ -662,6 +820,11 @@ bool FromWebAPI::getTemplateList(QMap<QString, int>& list)
         return false;
     }
 
+    // for(auto it = list.begin(); it != list.end(); it++)
+    // {
+    //     LH_WRITE_LOG_DEBUG(QString("模板名称:%1, 类型:%2").arg(it.key()).arg(it.value()));
+    // }
+
     return true;
 }
 
@@ -681,7 +844,7 @@ bool FromWebAPI::deleteTemplate(const QString& name)
     json0["paramList"] = json1;
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet, true);
     if(ret < 0)
     {
         LH_WRITE_ERROR(QString("删除模板失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));

+ 6 - 0
TransmitterSwitch/WebAPI/FromWebAPI.h

@@ -22,6 +22,12 @@ public:
     bool insertData(QList<ExecPlanItemInfo>& list);
     /* 获取tExecPlan表格数据 */
     bool getExecPlanData(QList<ExecPlanItemInfo>& list);
+    /* 将页面的配置写入数据库 */
+    bool insertConfigData(QMap<int, int>& mapConfig);
+    /* 删除配置数据 */
+    bool deleteConfigData(QMap<int, int>& mapConfig);
+    /* 获取配置数据 */
+    bool getConfigData(QMap<int, int>& mapConfig);
 
     /* 获取EQM数据库中的模版编号 */
     bool getEQMTemplateID(QList<int>& listId);

+ 0 - 151
TransmitterSwitch/common/LHHTTPAPI/inc/lhhttpapi.h_

@@ -1,151 +0,0 @@
-#pragma once
-#include <QString>
-#include <QObject>
-#include <QLibrary>
-#include <QDateTime>
-#include <QMutex>
-#include <QWaitCondition>
-// #include "Common/singleton.h"
-#include "threadcontroller.h"
-
-#define LH_HTTPAPI_SUCC 0
-
-// 用New
-#define LHAPI_BUFFER_SIZE_NEW 2048000
-#define LHAPI_BUFFER_SIZE_ARY 4096
-
-extern int g_nHttpTimeOut;
-
-// 操作类型【1查询 2更新 3删除 4插入 5存储过程】
-enum enDBOperatorType
-{
-    EDBOT_Select = 1,
-    EDBOT_Update,
-    EDBOT_Delete,
-    EDBOT_Insert,
-    EDBOT_Procedure,
-    EDBOT_Batch,    // 单动作批量操作,失败全部回滚
-    EDBOT_BatchTransAction // 多动作批量操作,失败回滚
-};
-
-class lhhttpapi : public QObject
-{
-    Q_OBJECT
-public:
-    typedef int (*FunDBInit)(const char* lpUrl);
-    typedef int (*FunDBLogin)(const char *pLocalIP, const char *pSerid, const char* CType, char *pszUserToken, int nSize);
-    typedef int (*FunDBGetServerList)(char *pszList, int nSize);
-    typedef int (*FunDBGetServerInfo)(const char* pSerid, const char* pszUserToken, char* pServerInfo, int nSize);
-    typedef int (*FunDBGetChannelList)(const char* pSerid,char *pszList, int nSize);
-    typedef int (*FunDBDoInterface)(const char* pSerid,const char* CType,const char* strtoken,int nOperatorType, const char * strParam, char *strRet, int nSize);
-    typedef int (*FunDoGetLastError)(char *pError, int nLen, int *nErrorCode);
-
-    typedef int (*FunSetHttpTimeOut)(int nTimeout);
-
-    // 获取网络文件大小,返回文件大小
-    typedef int64_t (*FunDoGetHttpFileSize)(const char *pszHttpAddr);
-
-    // 获取网络文件内容,返回内容大小
-    typedef int64_t (*FunDoGetHttpFileContent)(const char* pHttpAddr, char *pszContent, int nSize);
-
-    // 获取汉字拼音首字母,空格、数字等其它字符保持不动
-    typedef int (*FunDoWord2Pyjc)(const char* pszWord, char *pszContent, int nSize);
-
-    // 文件上传FTP
-    typedef int (*FunDoUploadFtpFile)(const char* pszLocalFilePath, const char* pszFtpFilePath);
-    typedef int (*FunDoUploadFtpFileContent)(const char* pszFileContent, int size, const char* pszFtpFilePath);
-
-    // FTP
-    typedef int (*FunDoCurlDeleteFtpFile)(const char* user, const char* pwd, const char* pszFtpFile);
-    typedef int (*FunDoCurlUploadFtpFile)(const char* user, const char* pwd, const char* pszLocalFilePath, const char* pszFtpFile);
-    typedef int (*FunDoCurlUploadFtpFileContent)(const char* user, const char* pwd, const char* pszFileContent, int nSize, const char* pszFtpFile);
-
-    // 获取数据库信息
-    typedef int (*FunDoGetDBInfo)(const char* strSerid, const char* strtoken, char* pDBInfo, int nsize);
-public:
-    explicit lhhttpapi(QObject *parent = nullptr);
-    ~lhhttpapi();
-
-public:
-    QLibrary *m_pQLib;
-
-    FunDBInit fnDBInit;
-    FunDBLogin fnDBLogin;
-    FunDBGetServerList fnDBGettServerList;
-    FunDBGetChannelList fnDBGetChannelList;
-    FunDBGetServerInfo fnDBGetServerInfo;
-
-    FunSetHttpTimeOut fnSetHttpTimeOut;
-    FunDoGetHttpFileSize fnGetHttpFileSize;
-    FunDoGetHttpFileContent fnGetHttpFileContent;
-    FunDoGetLastError fnGetLastError;
-    FunDoWord2Pyjc    fnDoWord2Pyjc;
-    FunDoUploadFtpFile fnDoUploadFtpFile;
-    FunDoUploadFtpFileContent fnDoUploadFtpFileContent;
-
-    FunDoCurlDeleteFtpFile  fnDoCurlDeleteFtpFile;
-    FunDoCurlUploadFtpFile  fnDoCurlUploadFtpFile;
-    FunDoCurlUploadFtpFileContent fnDoCurlUploadFtpFileContent;
-
-    FunDoGetDBInfo  fnDoGetDBInfo;
-
-    QMutex m_mutexWorkerDestroy;
-    QWaitCondition m_Condition;
-    FunDBDoInterface fnDBDoInterface;
-
-public:
-    bool Load(QString file);
-    bool UnLoad();
-
-    int SetHttpTimeOut(int nTimeout);
-    QString DoGetLastError(int *nErrorCode);
-    QString GetServerID() const {return m_serID;}
-    QString GetClientType() const {return m_clientType;}
-
-    int DBQInit(QString strUrl);
-    int DBQGetServerList(QString& serverList);
-    int DBQGetServerInfo(const QString& serid, QString& serverInfo);
-    /**
-     * @brief 登录数据库
-     * 
-     * @param LocalIP 
-     * @param Serid 
-     * @param CType 
-     * @param strUserToken 传出参数
-     * @return int 
-     */
-    int DBQLogin(QString LocalIP, QString Serid, QString CType, QString &strUserToken);
-    int DBQDoInterface(int nOperatorType, const QString &strParamXml, QString &strRetXml, bool wait = true);
-
-private slots:
-    void OnWorkerFinished();
-private:
-    QString m_token;
-    QMutex m_mtx;
-    QString m_serID;
-    QString m_clientType;
-    QTimer* m_tUpToken;
-};
-
-class DoInterfaceObject : public ThreadWorker
-{
-    Q_OBJECT
-public:
-    explicit DoInterfaceObject(lhhttpapi *pApi, const QString &strToken, int nOperatorType, const QString &strParamXml);
-    virtual ~DoInterfaceObject() override {}
-    QString GetRetXML() const {return m_strRetXml;}
-    int GetResult() const {return m_nResult;}
-public slots:
-    void DoInit() override {}
-    void DoWork() override;
-signals:
-    void sig_WorkFinished();
-public:
-    lhhttpapi *m_pApi;
-    QString m_strToken;
-    int m_nOperatorType;
-    QString m_strParamXml;
-    QString m_strRetXml;
-    int m_nResult;
-};
-

+ 201 - 0
TransmitterSwitch/common/LHHTTPAPI/src/lhhttpapi(副本).cpp_

@@ -0,0 +1,201 @@
+#include "lhhttpapi.h"
+
+lhhttpapi::lhhttpapi(QObject *parent)
+    : QObject(parent)
+    , m_pQLib(nullptr)
+    , fnDBInit(nullptr)
+    , fnDBLogin(nullptr)
+    , fnDBGettServerList(nullptr)
+    , fnDBGetChannelList(nullptr)
+    , fnDBDoInterface(nullptr)
+    , fnDoGetHttpFileSize(nullptr)
+    , fnDoGetHttpFileContent(nullptr)
+    , fnDoUploadFtpFile(nullptr)
+    , fnDoUploadFtpFileContent(nullptr)
+    , fnDoCurlDeleteFtpFile(nullptr)
+    , fnDoCurlUploadFtpFile(nullptr)
+    , fnDoCurlUploadFtpFileContent(nullptr)
+    , fnGetLastError(nullptr)
+
+{
+
+}
+
+lhhttpapi::~lhhttpapi()
+{
+    UnLoad();
+}
+
+bool lhhttpapi::UnLoad()
+{
+    if(m_pQLib == nullptr)
+    {
+        return false;
+    }
+    bool bRet = m_pQLib->unload();
+    delete m_pQLib;
+    m_pQLib = nullptr;
+    return bRet;
+}
+
+bool lhhttpapi::Load(QString file)
+{
+    m_pQLib = new QLibrary(file);
+    if (!m_pQLib->load())
+    {
+        qDebug() << QString("模块%1加载失败-1").arg(file);
+        return false;
+    }
+    fnDBInit = reinterpret_cast<FunDBInit>(m_pQLib->resolve("DBInitex"));
+    fnDBLogin = reinterpret_cast<FunDBLogin>(m_pQLib->resolve("DBLogin"));
+    fnDBGettServerList = reinterpret_cast<FunDBGetServerList>(m_pQLib->resolve("DBGetServerList"));
+    fnDBGetChannelList = reinterpret_cast<FunDBGetChannelList>(m_pQLib->resolve("DBGetChannelList"));
+    fnDBDoInterface = reinterpret_cast<FunDBDoInterface>(m_pQLib->resolve("DBDoInterface"));
+    fnDoGetHttpFileSize = reinterpret_cast<FunDoGetHttpFileSize>(m_pQLib->resolve("DoGetHttpFileSize"));
+    fnDoGetHttpFileContent = reinterpret_cast<FunDoGetHttpFileContent>(m_pQLib->resolve("DoGetHttpFileContent"));
+    fnDoUploadFtpFile = reinterpret_cast<FunDoUploadFtpFile>(m_pQLib->resolve("DoUploadFtpFile"));
+    fnDoUploadFtpFileContent = reinterpret_cast<FunDoUploadFtpFileContent>(m_pQLib->resolve("DoUploadFtpFileContent"));
+    fnDoCurlDeleteFtpFile = reinterpret_cast<FunDoCurlDeleteFtpFile>(m_pQLib->resolve("DoCurlDeleteFtpFile"));
+    fnDoCurlUploadFtpFile = reinterpret_cast<FunDoCurlUploadFtpFile>(m_pQLib->resolve("DoCurlUploadFtpFile"));
+    fnDoCurlUploadFtpFileContent = reinterpret_cast<FunDoCurlUploadFtpFileContent>(m_pQLib->resolve("DoCurlUploadFtpFileContent"));
+    fnGetLastError = reinterpret_cast<FunDoGetLastError>(m_pQLib->resolve("DBGetLastError"));
+
+    if(fnDBInit == nullptr||fnDBLogin == nullptr||fnDBGetChannelList == nullptr||
+            fnDBDoInterface == nullptr|| fnDBGettServerList == nullptr || fnGetLastError == nullptr
+            || fnDoGetHttpFileSize == nullptr || fnDoGetHttpFileContent == nullptr 
+            || fnDoUploadFtpFile == nullptr || fnDoUploadFtpFileContent == nullptr
+            || fnDoCurlDeleteFtpFile == nullptr || fnDoCurlUploadFtpFile == nullptr || fnDoCurlUploadFtpFileContent == nullptr )
+    {
+        return false;
+    }
+    return true;
+}
+
+
+void* lhhttpapi::DBInit(const char* lpUrl,bool bismulti)
+{
+    if(fnDBInit == nullptr) return nullptr;
+    return fnDBInit(lpUrl,bismulti);
+}
+
+int lhhttpapi::DoGetToken(QString &szToken, bool bismulti, void* phttpip)
+{
+    return DBLogin(m_Localip,m_Serid,m_appType,szToken, bismulti, phttpip);
+}
+
+int lhhttpapi::DBLogin(const QString& pLocalip,const QString &pSerid, const QString &appType,  QString &pszUserToken, bool bismulti, void* phttpip)
+{
+    if(fnDBLogin == nullptr) return -1;
+    //char buffer[LHHTTPAPI_BUFFER_SIZE] = {0};
+    char *buffer = (char*)malloc(LHHTTPAPI_BUFFER_SIZE);
+    memset(buffer, 0, LHHTTPAPI_BUFFER_SIZE);
+    int ret =  fnDBLogin(pLocalip.toUtf8().data(),pSerid.toUtf8().data(),appType.toUtf8().data(), buffer, LHHTTPAPI_BUFFER_SIZE, bismulti, phttpip);
+    pszUserToken = QString::fromUtf8(buffer);
+    free(buffer);
+    buffer = nullptr;
+
+    m_Localip = pLocalip;
+    m_Serid = pSerid;
+    m_appType = appType;
+
+    return ret;
+}
+
+int lhhttpapi::DBGetServerList(char *pszList, int nSize,bool bismulti , void* phttpip)
+{
+    if(fnDBGettServerList == nullptr) return -1;
+    return fnDBGettServerList(pszList, nSize,bismulti,phttpip);
+}
+
+int lhhttpapi::DBGetChannelList(const char* pSerid,char *pszList, int nSize,bool bismulti, void* phttpip)
+{
+    if(fnDBGetChannelList == nullptr) return -1;
+    return fnDBGetChannelList(pSerid,pszList, nSize,bismulti,phttpip);
+}
+
+int lhhttpapi::DBDoInterface(const QString &strToken, int nOperatorType, const QString &strParamXml, QString &strRetXml, bool bismulti, void* phttpip)
+{
+    if(fnDBDoInterface == nullptr) return -1;
+    QString serid = m_Serid;
+    //QString appType = APPTYPE;//singletonWork::skm_type;
+    QString appType = WEBAPPTYPE;//singletonWork::skm_type;
+    char *buffer = (char*)malloc(LHHTTPAPI_BUFFER_SIZE);
+    memset(buffer, 0, LHHTTPAPI_BUFFER_SIZE);
+    int ret = fnDBDoInterface(serid.toUtf8().data(), appType.toUtf8().data(), strToken.toUtf8().data(), nOperatorType, strParamXml.toUtf8().data(), buffer, LHHTTPAPI_BUFFER_SIZE, bismulti, phttpip);
+    strRetXml = QString::fromUtf8(buffer);
+    free(buffer);
+    buffer = nullptr;
+    return ret;
+}
+
+
+int64_t lhhttpapi::DoGetHttpFileContent(const QString &url, char *pszContent, int nSize)
+{
+    if(fnDoGetHttpFileContent == nullptr) return 0;
+    return fnDoGetHttpFileContent(url.toUtf8().data(), pszContent, nSize);
+}
+
+bool lhhttpapi::DoUploadFtpFile(const QString &localFilePath, const QString &ftpFilePath)
+{
+    if(fnDoUploadFtpFile == nullptr) return -1;
+    return (fnDoUploadFtpFile(localFilePath.toUtf8(), ftpFilePath.toUtf8()) == 0);
+}
+
+bool lhhttpapi::DoUploadFtpFileContent(const char * szFileContent, int nSize, const QString &ftpFilePath)
+{
+    if(fnDoUploadFtpFileContent == nullptr) return -1;
+    return (fnDoUploadFtpFileContent(szFileContent, nSize, ftpFilePath.toUtf8()) == 0);
+}
+bool lhhttpapi::DoCurlDeleteFtpFile(const QString &targetFilePath)
+{
+    return DoCurlDeleteFtpFile("","",targetFilePath);
+}
+bool lhhttpapi::DoCurlDeleteFtpFile(const QString &user, const QString &pwd, const QString &targetFilePath)
+{
+    if(fnDoCurlDeleteFtpFile == nullptr) return -1;
+    return (fnDoCurlDeleteFtpFile(user.toUtf8(), pwd.toUtf8(), targetFilePath.toUtf8()) == 0);
+}
+bool lhhttpapi::DoCurlUploadFtpFile(const QString &localFilePath, const QString &destFilePath)
+{
+    return DoCurlUploadFtpFile("", "", localFilePath, destFilePath);
+}
+bool lhhttpapi::DoCurlUploadFtpFile(const QString &user, const QString &pwd, const QString &localFilePath, const QString &destFilePath)
+{
+    if(fnDoCurlUploadFtpFile == nullptr) return -1;
+    return (fnDoCurlUploadFtpFile(user.toUtf8(), pwd.toUtf8(), localFilePath.toUtf8(), destFilePath.toUtf8()) == 0);
+}
+
+bool lhhttpapi::DoCurlUploadFtpFileContent(const char *szFileContent, int nSize, const QString &destFilePath)
+{
+    return DoCurlUploadFtpFileContent("", "", szFileContent, nSize, destFilePath);
+}
+
+bool lhhttpapi::DoCurlUploadFtpFileContent(const QString &user, const QString &pwd, const char *szFileContent, int nSize, const QString &destFilePath)
+{
+    if(fnDoCurlUploadFtpFileContent == nullptr) return -1;
+    return (fnDoCurlUploadFtpFileContent(user.toUtf8(), pwd.toUtf8(), szFileContent, nSize, destFilePath.toUtf8()) == 0);
+}
+
+int64_t lhhttpapi::DoGetHttpFileSize(const QString &url)
+{
+    if(fnDoGetHttpFileSize == nullptr) return 0;
+    return fnDoGetHttpFileSize(url.toUtf8().data());
+}
+
+int lhhttpapi::DoGetLastError(char *pError, int nLen, int *nErrorCode,bool bismulti , void* phttpip)
+{
+    if(fnGetLastError == nullptr) return -1;
+    return fnGetLastError(pError, nLen, nErrorCode,bismulti,phttpip);
+}
+
+QString lhhttpapi::DoGetLastError(int *nErrorCode,bool bismulti , void* phttpip)
+{
+    if(fnGetLastError == nullptr) return QString();
+    int nLen = 1024;
+    char pError[1024] = {0};
+    if(fnGetLastError(pError, nLen, nErrorCode,bismulti,phttpip) != 0) return QString();
+    return QString::fromLocal8Bit(pError).toLocal8Bit();
+}
+
+
+

+ 87 - 140
TransmitterSwitch/common/LHHTTPAPI/inc/lhhttpapi.h → TransmitterSwitch/common/LHHTTPAPI/src/lhhttpapi(副本).h_

@@ -1,140 +1,87 @@
-#pragma once
-#include <QString>
-#include <QObject>
-#include <QLibrary>
-#include <QDateTime>
-#include "Thread/threadcontroller.h"
-
-#define LH_HTTPAPI_SUCC 0
-
-const int LHHTTPAPI_BUFFER_SIZE = 1024*1024;
-// 用New
-#define LHAPI_BUFFER_SIZE_NEW 2048000
-#define LHAPI_BUFFER_SIZE_ARY 4096
-
-// token 超时
-#define  TOKENTIME 20*60
-extern int g_nHttpTimeOut;
-
-// 操作类型【1查询 2更新 3删除 4插入 5存储过程】
-enum enDBOperatorType
-{
-    EDBOT_Select = 1,
-    EDBOT_Update,
-    EDBOT_Delete,
-    EDBOT_Insert,
-    EDBOT_Procedure,
-};
-
-
-class lhhttpapi : public QObject
-{
-    Q_OBJECT
-public:
-    typedef void* (*FunDBInit)(const char* lpUrl,bool bismulti);
-    typedef int (*FunDBLogin)(const char *plocalip,const char *pSerid, const char* CType, char *pszUserToken, int nSize,bool bismulti, void* phttpip);
-    typedef int (*FunDBGetServerList)(char *pszList, int nSize,bool bismulti, void* phttpip);
-    typedef int (*FunDBGetChannelList)(const char* pSerid,char *pszList, int nSize,bool bismulti, void* phttpip);
-    typedef int (*FunDBDoInterface)(const char* pSerid,const char* CType,const char* strtoken,int nOperatorType, const char * strParamXml, char *strRetXml, int nSize,bool bismulti, void* phttpip);
-    typedef int64_t (*FunDoGetHttpFileSize)(const char* pHttAddr);
-    typedef int64_t (*FunDoGetHttpFileContent)(const char* lpHttpAddr, char *pszContent, int nSize);
-    typedef int (*FunDoUploadFtpFile)(const char* pszLocalFilePath, const char* pszFtpFilePath);
-    typedef int (*FunDoUploadFtpFileContent)(const char * szFileContent, int nSize, const char* strFtpFilePath);
-
-    typedef int (*FunDoCurlDeleteFtpFile)(const char* user, const char* pwd, const char* pszFtpFile);
-    typedef int (*FunDoCurlUploadFtpFile)(const char* user, const char* pwd, const char* pszLocalFilePath, const char* pszFtpFile);
-    typedef int (*FunDoCurlUploadFtpFileContent)(const char* user, const char* pwd, const char* pszFileContent, int nSize, const char* pszFtpFile);
-
-//    typedef int (*FunUnInit)();
-    typedef int (*FunDoGetLastError)(char *pError, int nLen, int *nErrorCode);
-    typedef int (*FunDoRelease)(bool bismulti, void* phttpip);
-public:
-    explicit lhhttpapi(QObject *parent = nullptr);
-    ~lhhttpapi();
-public:
-    QLibrary *m_pQLib;
-
-    FunDoRelease fnDoRelease;
-    FunDBInit fnDBInit;
-    FunDBLogin fnDBLogin;
-    FunDBGetServerList fnDBGettServerList;
-    FunDBGetChannelList fnDBGetChannelList;
-    FunDBDoInterface fnDBDoInterface;
-    FunDoGetHttpFileSize fnDoGetHttpFileSize;
-    FunDoGetHttpFileContent fnDoGetHttpFileContent;
-    FunDoUploadFtpFile fnDoUploadFtpFile;
-    FunDoUploadFtpFileContent fnDoUploadFtpFileContent;
-    FunDoCurlDeleteFtpFile fnDoCurlDeleteFtpFile;
-    FunDoCurlUploadFtpFile fnDoCurlUploadFtpFile;
-    FunDoCurlUploadFtpFileContent fnDoCurlUploadFtpFileContent;
-//    FunUnInit fnUnInit;
-    FunDoGetLastError fnGetLastError;
-
-    QMutex m_mutexWorkerDestroy;
-    QWaitCondition m_Condition;
-public:
-    bool Load(QString file);
-    bool UnLoad();
-    int  DoRelease(bool bismulti = false, void* phttpip=nullptr);
-    int DBLogin(const QString& pLocalip,const QString &pSerid,const QString &appType, QString &pszUserToken,bool bismulti = false, void* phttpip=nullptr);
-    int DoGetToken(QString &szToken,bool bismulti = false, void* phttpip=nullptr);
-
-//    void DoGetTokenAgain();
-
-    int DBGetServerList(char *pszList, int nSize,bool bismulti = false, void* phttpip=nullptr);
-    int DBGetChannelList(const char* pSerid,char *pszList, int nSize,bool bismulti = false, void* phttpip=nullptr);
-    int DBDoInterface(int nOperatorType, const QString &strParamXml, QString &strRetXml, bool wait = false,bool bismulti = false, void* phttpip=nullptr);
-    void* DBInit (const char *lpUrl,bool bismulti = false);
-    int DoGetLastError(char *pError, int nLen, int *nErrorCode);
-
-    QString DoGetLastError(int *nErrorCode);
-    int64_t DoGetHttpFileSize(const QString &url);
-    int64_t DoGetHttpFileContent(const QString &url, char *pszContent, int nSize);
-   // int64_t DoGetHttpPNGFile(const QString &url, QPixmap &outPixmap);
-    bool DoUploadFtpFile(const QString &localFilePath, const QString &ftpFilePath);
-    bool DoUploadFtpFileContent(const char * szFileContent, int nSize, const QString &ftpFilePath);
-    bool DoCurlDeleteFtpFile(const QString &targetFilePath);
-    bool DoCurlDeleteFtpFile(const QString &user, const QString &pwd, const QString &targetFilePath);
-    bool DoCurlUploadFtpFile(const QString &localFilePath, const QString &destFilePath);
-    bool DoCurlUploadFtpFile(const QString &user, const QString &pwd, const QString &localFilePath, const QString &destFilePath);
-    bool DoCurlUploadFtpFileContent(const char * szFileContent, int nSize, const QString &destFilePath);
-    bool DoCurlUploadFtpFileContent(const QString &user, const QString &pwd, const char * szFileContent, int nSize, const QString &destFilePath);
-private slots:
-
-    void OnWorkerFinished();
-
-private:
-    QString m_Localip; // localip
-
-    QString m_Serid; // 当前服务数据库id
-
-    QString m_appType; // 设备类型
-
-    QString m_strtoken;// token
-
-    QDateTime m_lasttimer; // 最后一个获取token的时间
-};
-
-class DoInterfaceObject : public ThreadWorker
-{
-    Q_OBJECT
-public:
-    explicit DoInterfaceObject(lhhttpapi *pApi, const QString &strToken, int nOperatorType, const QString &strParamXml,bool bismulti = false,void* phttpip=nullptr);
-    virtual ~DoInterfaceObject() override {}
-    QString GetRetXML() const {return m_strRetXml;}
-    int GetResult() const {return m_nResult;}
-public slots:
-    virtual void DoInit() override {}
-    virtual void DoWork() override;
-signals:
-    void sig_WorkFinished();
-public:
-    lhhttpapi *m_pApi;
-    QString m_strToken;
-    int m_nOperatorType;
-    QString m_strParamXml;
-    QString m_strRetXml;
-    int m_nResult;
-    bool m_bismulti;
-    void* m_phttpip;
-};
+#pragma once
+#include <QString>
+#include <QLibrary>
+#include <QDateTime>
+#include <QObject>
+#include <QtDebug>
+
+//webApi链接数据库的类型根据web接口改变
+#define WEBAPPTYPE         "TMS"
+//webApi接口返回成功标记
+#define RERUNSUCCESS        0
+
+//不要超过4M, 4M是栈空间极限
+const int LHHTTPAPI_BUFFER_SIZE = 1024*1024;
+
+class lhhttpapi : public QObject
+{
+    Q_OBJECT
+public:
+    typedef void* (*FunDBInit)(const char* lpUrl,bool bismulti);
+    typedef int (*FunDBLogin)(const char *plocalip,const char *pSerid, const char* CType, char *pszUserToken, int nSize,bool bismulti, void* phttpip);
+    typedef int (*FunDBGetServerList)(char *pszList, int nSize,bool bismulti, void* phttpip);
+    typedef int (*FunDBGetChannelList)(const char* pSerid,char *pszList, int nSize,bool bismulti, void* phttpip);
+    typedef int (*FunDBDoInterface)(const char* pSerid,const char* CType,const char* strtoken,int nOperatorType, const char * strParamXml, char *strRetXml, int nSize,bool bismulti, void* phttpip);
+    typedef int64_t (*FunDoGetHttpFileSize)(const char* pHttAddr);
+    typedef int64_t (*FunDoGetHttpFileContent)(const char* lpHttpAddr, char *pszContent, int nSize);
+    typedef int (*FunDoUploadFtpFile)(const char* pszLocalFilePath, const char* pszFtpFilePath);
+    typedef int (*FunDoUploadFtpFileContent)(const char * szFileContent, int nSize, const char* strFtpFilePath);
+
+    typedef int (*FunDoCurlDeleteFtpFile)(const char* user, const char* pwd, const char* pszFtpFile);
+    typedef int (*FunDoCurlUploadFtpFile)(const char* user, const char* pwd, const char* pszLocalFilePath, const char* pszFtpFile);    
+    typedef int (*FunDoCurlUploadFtpFileContent)(const char* user, const char* pwd, const char* pszFileContent, int nSize, const char* pszFtpFile);
+    
+//    typedef int (*FunUnInit)();
+    typedef int (*FunDoGetLastError)(char *pError, int nLen, int *nErrorCode,bool bismulti, void* phttpip);
+    typedef int (*FunDoRelease)(bool bismulti, void* phttpip);
+public:
+    explicit lhhttpapi(QObject *parent = nullptr);
+    ~lhhttpapi();
+public:
+    QLibrary *m_pQLib;
+
+    FunDBInit fnDBInit;
+    FunDBLogin fnDBLogin;
+    FunDBGetServerList fnDBGettServerList;
+    FunDBGetChannelList fnDBGetChannelList;
+    FunDBDoInterface fnDBDoInterface;
+    FunDoGetHttpFileSize fnDoGetHttpFileSize;
+    FunDoGetHttpFileContent fnDoGetHttpFileContent;
+    FunDoUploadFtpFile fnDoUploadFtpFile;
+    FunDoUploadFtpFileContent fnDoUploadFtpFileContent;
+    FunDoCurlDeleteFtpFile fnDoCurlDeleteFtpFile;
+    FunDoCurlUploadFtpFile fnDoCurlUploadFtpFile;
+    FunDoCurlUploadFtpFileContent fnDoCurlUploadFtpFileContent;
+//    FunUnInit fnUnInit;
+    FunDoGetLastError fnGetLastError;
+    
+public:
+    bool Load(QString file);
+    bool UnLoad();
+    int  DoRelease(bool bismulti = false, void* phttpip=nullptr);
+    int DBLogin(const QString& pLocalip,const QString &pSerid,const QString &appType, QString &pszUserToken,bool bismulti = false, void* phttpip=nullptr);
+    int DoGetToken(QString &szToken,bool bismulti = false, void* phttpip=nullptr);
+
+    int DBGetServerList(char *pszList, int nSize,bool bismulti = false, void* phttpip=nullptr);
+    int DBGetChannelList(const char* pSerid,char *pszList, int nSize,bool bismulti = false, void* phttpip=nullptr);
+    int DBDoInterface(const QString &strToken, int nOperatorType, const QString &strParamXml, QString &strRetXml,bool bismulti = false, void* phttpip=nullptr);
+    void* DBInit (const char *lpUrl,bool bismulti = false);
+    int DoGetLastError(char *pError, int nLen, int *nErrorCode,bool bismulti = false, void* phttpip=nullptr);
+    QString DoGetLastError(int *nErrorCode,bool bismulti = false, void* phttpip=nullptr);
+    int64_t DoGetHttpFileSize(const QString &url);
+    int64_t DoGetHttpFileContent(const QString &url, char *pszContent, int nSize);
+   // int64_t DoGetHttpPNGFile(const QString &url, QPixmap &outPixmap);
+    bool DoUploadFtpFile(const QString &localFilePath, const QString &ftpFilePath);
+    bool DoUploadFtpFileContent(const char * szFileContent, int nSize, const QString &ftpFilePath);
+    bool DoCurlDeleteFtpFile(const QString &targetFilePath);
+    bool DoCurlDeleteFtpFile(const QString &user, const QString &pwd, const QString &targetFilePath);
+    bool DoCurlUploadFtpFile(const QString &localFilePath, const QString &destFilePath);
+    bool DoCurlUploadFtpFile(const QString &user, const QString &pwd, const QString &localFilePath, const QString &destFilePath);
+    bool DoCurlUploadFtpFileContent(const char * szFileContent, int nSize, const QString &destFilePath);
+    bool DoCurlUploadFtpFileContent(const QString &user, const QString &pwd, const char * szFileContent, int nSize, const QString &destFilePath);
+
+private:
+    QString m_Localip;  // localip
+    QString m_Serid;    // 当前服务数据库id
+    QString m_appType;  // 设备类型
+};

+ 94 - 60
TransmitterSwitch/common/LHHTTPAPI/src/lhhttpapi.cpp

@@ -162,6 +162,11 @@ int lhhttpapi::DBLogin(const QString& pLocalip,const QString &pSerid, const QStr
 
     m_appType = appType;
 
+    if(bismulti)
+    {
+        m_phttpip = phttpip;
+    }
+
     return ret;
 }
 
@@ -187,77 +192,106 @@ void lhhttpapi::OnWorkerFinished()
 }
 
 
-int lhhttpapi::DBDoInterface( int nOperatorType, const QString &strParamXml, QString &strRetXml, bool wait,bool bismulti, void* phttpip)
+// int lhhttpapi::DBDoInterface( int nOperatorType, const QString &strParamXml, QString &strRetXml, bool wait,bool bismulti, void* phttpip)
+// {
+//     QString strToken="";
+//     DoGetToken(strToken, bismulti, phttpip);
+//     if(wait)
+//     {
+//         DoInterfaceObject *pWorker = new DoInterfaceObject(this, strToken, nOperatorType, strParamXml,bismulti,phttpip);
+//         connect(pWorker, &DoInterfaceObject::sig_WorkFinished, this, &lhhttpapi::OnWorkerFinished, Qt::DirectConnection);
+//         pWorker->Start(100000);
+//         QMutexLocker locker(&m_mutexWorkerDestroy);
+//         m_Condition.wait(&m_mutexWorkerDestroy);
+//         strRetXml = pWorker->GetRetXML();
+//         int ret = pWorker->GetResult();
+//         pWorker->BlockStop();
+//         if(ret != 0)
+//         {
+//             int nerror = 0;
+//             QString strerror = QString("访问DBDoInterface 接口失败: token:%1,optype:%2,param:%3,ret:%4,error:%5")
+//                     .arg(strToken).
+//                     arg(nOperatorType).
+//                     arg(strParamXml).
+//                     arg(strRetXml).
+//                     arg(DoGetLastError(&nerror));
+
+//             //if(strerr)
+//             LH_WRITE_ERROR(strerror);
+//             if(strerror.contains("票据"))
+//             {
+//                 LH_WRITE_ERROR("重新获取票据,并再次执行命令");
+//                 QString szToken;
+//                 int nret1 = DBLogin(m_Localip,m_Serid,m_appType,szToken,bismulti,phttpip);
+
+//                 m_strtoken = szToken;
+
+//                 DoInterfaceObject *pWorker = new DoInterfaceObject(this, szToken, nOperatorType, strParamXml,bismulti,phttpip);
+//                 connect(pWorker, &DoInterfaceObject::sig_WorkFinished, this, &lhhttpapi::OnWorkerFinished, Qt::DirectConnection);
+//                 pWorker->Start(20000);
+//                 QMutexLocker locker(&m_mutexWorkerDestroy);
+//                 m_Condition.wait(&m_mutexWorkerDestroy);
+//                 strRetXml = pWorker->GetRetXML();
+//                 int ret = pWorker->GetResult();
+//                 pWorker->BlockStop();
+
+//                 if(ret != 0)
+//                 {
+//                     int nerror = 0;
+//                     QString strerror = QString("再次访问DBDoInterface 接口失败: token:%1,optype:%2,param:%3,ret:%4,error:%5")
+//                             .arg(strToken).
+//                             arg(nOperatorType).
+//                             arg(strParamXml).
+//                             arg(strRetXml).
+//                             arg(DoGetLastError(&nerror));
+//                       LH_WRITE_ERROR(strerror);
+//                 }
+//             }
+//         }
+//         return ret;
+//     }
+//     else
+//     {
+//         if(fnDBDoInterface == nullptr) return -1;
+//         QString serid = m_Serid;
+//         QString appType = m_appType;
+//         //char buffer[LHHTTPAPI_BUFFER_SIZE] = {0};
+//         char *buffer = new char[LHHTTPAPI_BUFFER_SIZE]{0};
+//         // memset(buffer, 0, LHHTTPAPI_BUFFER_SIZE);
+//         int ret = fnDBDoInterface(serid.toUtf8().data(), appType.toUtf8().data(), strToken.toUtf8().data(), nOperatorType, strParamXml.toUtf8().data(), buffer, LHHTTPAPI_BUFFER_SIZE - 1, bismulti, phttpip);
+//         strRetXml = QString::fromUtf8(buffer);
+//         delete [] buffer;
+//         return ret;
+//     }
+// }
+
+int lhhttpapi::DBDoInterface(int nOperatorType, const QString &strParamXml, QString &strRetXml, bool bismulti)
 {
-    QString strToken="";
-    DoGetToken(strToken,bismulti,phttpip);
-    if(wait)
+    if(fnDBDoInterface == nullptr) return -1;
+    int ret = 0;
+    if(bismulti)
     {
-        DoInterfaceObject *pWorker = new DoInterfaceObject(this, strToken, nOperatorType, strParamXml,bismulti,phttpip);
-        connect(pWorker, &DoInterfaceObject::sig_WorkFinished, this, &lhhttpapi::OnWorkerFinished, Qt::DirectConnection);
-        pWorker->Start(100000);
-        QMutexLocker locker(&m_mutexWorkerDestroy);
-        m_Condition.wait(&m_mutexWorkerDestroy);
-        strRetXml = pWorker->GetRetXML();
-        int ret = pWorker->GetResult();
-        pWorker->BlockStop();
-        if(ret != 0)
-        {
-            int nerror = 0;
-            QString strerror = QString("访问DBDoInterface 接口失败: token:%1,optype:%2,param:%3,ret:%4,error:%5")
-                    .arg(strToken).
-                    arg(nOperatorType).
-                    arg(strParamXml).
-                    arg(strRetXml).
-                    arg(DoGetLastError(&nerror));
-
-            //if(strerr)
-            LH_WRITE_ERROR(strerror);
-            if(strerror.contains("票据"))
-            {
-                LH_WRITE_ERROR("重新获取票据,并再次执行命令");
-                QString szToken;
-                int nret1 = DBLogin(m_Localip,m_Serid,m_appType,szToken,bismulti,phttpip);
-
-                m_strtoken = szToken;
-
-                DoInterfaceObject *pWorker = new DoInterfaceObject(this, szToken, nOperatorType, strParamXml,bismulti,phttpip);
-                connect(pWorker, &DoInterfaceObject::sig_WorkFinished, this, &lhhttpapi::OnWorkerFinished, Qt::DirectConnection);
-                pWorker->Start(20000);
-                QMutexLocker locker(&m_mutexWorkerDestroy);
-                m_Condition.wait(&m_mutexWorkerDestroy);
-                strRetXml = pWorker->GetRetXML();
-                int ret = pWorker->GetResult();
-                pWorker->BlockStop();
-
-                if(ret != 0)
-                {
-                    int nerror = 0;
-                    QString strerror = QString("再次访问DBDoInterface 接口失败: token:%1,optype:%2,param:%3,ret:%4,error:%5")
-                            .arg(strToken).
-                            arg(nOperatorType).
-                            arg(strParamXml).
-                            arg(strRetXml).
-                            arg(DoGetLastError(&nerror));
-                      LH_WRITE_ERROR(strerror);
-                }
-            }
-        }
-        return ret;
+        QString strToken="";
+        DoGetToken(strToken, bismulti, m_phttpip);
+        QString serid = m_Serid;
+        QString appType = m_appType;
+        char *buffer = new char[LHHTTPAPI_BUFFER_SIZE]{0};
+        ret = fnDBDoInterface(serid.toUtf8().data(), appType.toUtf8().data(), strToken.toUtf8().data(), nOperatorType, strParamXml.toUtf8().data(), buffer, LHHTTPAPI_BUFFER_SIZE - 1, bismulti, m_phttpip);
+        strRetXml = QString::fromUtf8(buffer);
+        delete [] buffer;
     }
     else
     {
-        if(fnDBDoInterface == nullptr) return -1;
+        QString strToken="";
+        DoGetToken(strToken, bismulti, nullptr);
         QString serid = m_Serid;
         QString appType = m_appType;
-        //char buffer[LHHTTPAPI_BUFFER_SIZE] = {0};
         char *buffer = new char[LHHTTPAPI_BUFFER_SIZE]{0};
-        // memset(buffer, 0, LHHTTPAPI_BUFFER_SIZE);
-        int ret = fnDBDoInterface(serid.toUtf8().data(), appType.toUtf8().data(), strToken.toUtf8().data(), nOperatorType, strParamXml.toUtf8().data(), buffer, LHHTTPAPI_BUFFER_SIZE - 1,bismulti,phttpip);
+        ret = fnDBDoInterface(serid.toUtf8().data(), appType.toUtf8().data(), strToken.toUtf8().data(), nOperatorType, strParamXml.toUtf8().data(), buffer, LHHTTPAPI_BUFFER_SIZE - 1, bismulti, nullptr);
         strRetXml = QString::fromUtf8(buffer);
         delete [] buffer;
-        return ret;
     }
+    return ret;
 }
 
 

+ 5 - 2
TransmitterSwitch/common/LHHTTPAPI/src/lhhttpapi.h

@@ -99,6 +99,7 @@ public:
     bool Load();
     bool UnLoad();
     int  DoRelease(bool bismulti = false, void* phttpip=nullptr);
+    void* DBInit (const char *lpUrl,bool bismulti = false);
     int DBLogin(const QString& pLocalip,const QString &pSerid,const QString &appType, QString &pszUserToken,bool bismulti = false, void* phttpip=nullptr);
     int DoGetToken(QString &szToken,bool bismulti = false, void* phttpip=nullptr);
 
@@ -106,8 +107,8 @@ public:
 
     int DBGetServerList(char *pszList, int nSize,bool bismulti = false, void* phttpip=nullptr);
     int DBGetChannelList(const char* pSerid,char *pszList, int nSize,bool bismulti = false, void* phttpip=nullptr);
-    int DBDoInterface(int nOperatorType, const QString &strParamXml, QString &strRetXml, bool wait = true, bool bismulti = true, void* phttpip=nullptr);
-    void* DBInit (const char *lpUrl,bool bismulti = false);
+    // int DBDoInterface(int nOperatorType, const QString &strParamXml, QString &strRetXml, bool wait = false, bool bismulti = false, void* phttpip=nullptr);
+    int DBDoInterface(int nOperatorType, const QString &strParamXml, QString &strRetXml, bool bismulti = false);
     int DoGetLastError(char *pError, int nLen, int *nErrorCode);
 
     QString DoGetLastError(int *nErrorCode);
@@ -136,6 +137,8 @@ private:
     QString m_strtoken;// token
 
     QDateTime m_lasttimer; // 最后一个获取token的时间
+
+    void* m_phttpip = nullptr;
 };
 
 class DoInterfaceObject : public ThreadWorker

BIN
TransmitterSwitch/common/TipWidget/Tip/Complete2x.png


BIN
TransmitterSwitch/common/TipWidget/Tip/Failed2x.png


BIN
TransmitterSwitch/common/TipWidget/Tip/Tips2x.png


BIN
TransmitterSwitch/common/TipWidget/Tip/Wait2x.png


+ 8 - 0
TransmitterSwitch/common/TipWidget/tip.qrc

@@ -0,0 +1,8 @@
+<RCC>
+    <qresource prefix="/">
+        <file>Tip/Complete2x.png</file>
+        <file>Tip/Failed2x.png</file>
+        <file>Tip/Tips2x.png</file>
+        <file>Tip/Wait2x.png</file>
+    </qresource>
+</RCC>

+ 244 - 0
TransmitterSwitch/common/TipWidget/tipwidget.cpp

@@ -0,0 +1,244 @@
+#include "tipwidget.h"
+#include "ui_tipwidget.h"
+#include <QPainter>
+#include <QTimer>
+#include <QPropertyAnimation>
+#include <QGraphicsOpacityEffect>
+#include <QPixmap>
+#include <QElapsedTimer>
+#include <QTime>
+#include <QDebug>
+
+static QList<TipWidget*> sl_tipWdgs{Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR};
+
+void TipWidget::display(FormType type, QWidget* parent, int nTitleHeight)
+{
+    if (Q_NULLPTR == parent || sl_tipWdgs.count() > 4)
+        return;
+    static QElapsedTimer s_timer;
+    if (s_timer.elapsed() > 5 && s_timer.restart() < 500)
+    {
+        return;
+    }
+
+    int nPosX = (parent->width() - WIDTH) / 2;
+    int nPosY = nTitleHeight;
+    TipWidget* obj = Q_NULLPTR;
+    for (int i = 0; i < sl_tipWdgs.count(); ++i)
+    {
+        if (sl_tipWdgs.at(i) == Q_NULLPTR)
+        {
+            obj = new TipWidget(type, parent);
+            obj->setEndPos(nPosX, nPosY + i * HEIGHT + 10);
+            if (!obj->isVisible())
+                obj->show();
+            obj->run();
+            sl_tipWdgs[i] = obj;
+            break;
+        }
+    }
+}
+/* 这个是上面的重载函数,可以自定义文本 */
+void TipWidget::display(FormType type, QString text, QWidget *parent, int nTitleHeight)
+{
+    if (Q_NULLPTR == parent || sl_tipWdgs.count() > 4)
+        return;
+    static QElapsedTimer s_timer;
+    if (s_timer.elapsed() > 5 && s_timer.restart() < 500)
+    {
+        return;
+    }
+
+    int nPosX = (parent->width() - WIDTH) / 2;
+    int nPosY = nTitleHeight;
+    TipWidget* obj = Q_NULLPTR;
+    for (int i = 0; i < sl_tipWdgs.count(); ++i)
+    {
+        if (sl_tipWdgs.at(i) == Q_NULLPTR)
+        {
+            obj = new TipWidget(type, text, parent);
+
+            obj->setEndPos(nPosX, nPosY + i * HEIGHT + 10);
+            if (!obj->isVisible())
+                obj->show();
+            obj->run();
+            sl_tipWdgs[i] = obj;
+            break;
+        }
+    }
+}
+
+TipWidget::TipWidget(FormType type, QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::TipWidget)
+{
+    ui->setupUi(this);
+    setWindowFlag(Qt::FramelessWindowHint);
+    _endRect = rect();
+    setFormType(type);
+//    ui->label_tipIcon->hide();
+    m_customText = false;
+}
+
+TipWidget::TipWidget(FormType type, QString& text, QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::TipWidget),
+    m_tipText(text)
+{
+    ui->setupUi(this);
+    setWindowFlag(Qt::FramelessWindowHint);
+    _endRect = rect();
+    m_customText = true;
+    setFormType(type);
+    /* 设置字体居中 */
+    ui->label_tipTitle->setAlignment(Qt::AlignCenter);
+    if(text.count() > 5)
+    {
+        QFontMetrics fm(ui->label_tipTitle->font());
+        auto textWidth = fm.width(text);
+        int width = textWidth + this->width() - ui->label_tipTitle->width();
+        this->setFixedWidth(width);
+    }
+}
+
+TipWidget::~TipWidget()
+{
+    delete ui;
+}
+
+void TipWidget::setFormType(FormType type)
+{
+    QPixmap img;
+    switch(type)
+    {
+    case OPERATOR_OK:
+        _backgroundColor = QColor(246, 255, 237);
+        _borderColor = QColor(183, 235, 143);
+        img.load(R"(:/Tip/Complete2x.png)");
+        if(m_customText)
+        {
+            ui->label_tipTitle->setText(m_tipText);
+        }else
+        {
+            ui->label_tipTitle->setText("操作成功!");
+        }
+        break;
+    case OPERATOR_FAIL:
+        _backgroundColor = QColor(255, 241, 240);
+        _borderColor = QColor(255, 163, 158);
+        img.load(":/Tip/Failed2x.png");
+        if(m_customText)
+        {
+            ui->label_tipTitle->setText(m_tipText);
+        }else
+        {
+            ui->label_tipTitle->setText("操作失败!");
+        }
+        break;
+    case OPERATOR_TIP:
+        _backgroundColor = QColor(236, 238, 254);
+        _borderColor = QColor(68, 88, 254);
+        img.load(":/Tip/Wait2x.png");
+        if(m_customText)
+        {
+            ui->label_tipTitle->setText(m_tipText);
+        }else
+        {
+            ui->label_tipTitle->setText("普通提示!");
+        }
+        break;
+    case OPERATOR_WARN:
+        _backgroundColor = QColor(255, 251, 230);
+        _borderColor = QColor(255, 229, 143);
+        img.load(":/Tip/Tips2x.png");
+        if(m_customText)
+        {
+            ui->label_tipTitle->setText(m_tipText);
+        }else
+        {
+            ui->label_tipTitle->setText("需注意!");
+        }
+        break;
+
+    default:
+        break;
+    }
+    img = img.scaled(ui->label_tipIcon->width(), ui->label_tipIcon->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+    ui->label_tipIcon->setPixmap(img);
+}
+
+void TipWidget::setEndPos(int x, int y)
+{
+    _endRect.moveTo(x, y);
+}
+
+void TipWidget::run()
+{
+    if (nullptr == _animation)
+        _animation = new QPropertyAnimation(this, "geometry");
+    _animation->setDuration(1 * 1000);
+    _animation->setStartValue(QRect(_endRect.x(), _endRect.y() + 150, _endRect.width(), _endRect.height()));
+    _animation->setEndValue(_endRect);
+    connect(_animation, &QPropertyAnimation::finished, this, [this]{
+        if (nullptr == _pKillTimer)
+            _pKillTimer = new QTimer(this);
+        _pKillTimer->start(1 * 1000);
+        connect(_pKillTimer, &QTimer::timeout, this, &TipWidget::onFadeOut);
+    });
+    _animation->start();
+}
+
+void TipWidget::onFadeOut()
+{
+    if (nullptr != _pKillTimer && _pKillTimer->isActive())
+    {
+        _pKillTimer->stop();
+    }
+    QGraphicsOpacityEffect* effect = new QGraphicsOpacityEffect(this);
+    this->setGraphicsEffect(effect);
+    if (nullptr == _animFadeOut)
+        _animFadeOut = new QPropertyAnimation(effect, "opacity");
+    _animFadeOut->setDuration(1 * 1000);
+    _animFadeOut->setStartValue(1.0);
+    _animFadeOut->setEndValue(0.0);
+    connect(_animFadeOut, &QPropertyAnimation::finished, this, [this]{
+        onBtnClose();
+    });
+    _animFadeOut->start();
+}
+
+void TipWidget::onBtnClose()
+{
+    close();
+    for (int i = 0; i < sl_tipWdgs.count(); ++i)
+    {
+        if (sl_tipWdgs.at(i) == this)
+        {
+            sl_tipWdgs[i] = Q_NULLPTR;
+        }
+    }
+    deleteLater();
+}
+
+void TipWidget::paintEvent(QPaintEvent *event)
+{
+    QRect rc(rect());
+    rc.adjust(1, 1, -2, -2);
+    QPainter painter(this);
+    painter.setRenderHint(QPainter::Antialiasing, true);
+    painter.save();
+    QBrush brush(_backgroundColor);
+    painter.setBrush(brush);
+    painter.drawRoundedRect(rc, 2.0, 2.0);
+    painter.restore();
+
+    painter.save();
+    QPen pen;
+    pen.setWidth(2);
+    pen.setColor(_borderColor);
+    painter.setPen(pen);
+    painter.setBrush(Qt::transparent);
+    painter.drawRoundedRect(rc, 2.0, 2.0);
+    painter.restore();
+    QWidget::paintEvent(event);
+}

+ 54 - 0
TransmitterSwitch/common/TipWidget/tipwidget.h

@@ -0,0 +1,54 @@
+#ifndef TIPWIDGET_H
+#define TIPWIDGET_H
+
+#include <QWidget>
+
+class QPropertyAnimation;
+namespace Ui {
+class TipWidget;
+}
+
+class TipWidget : public QWidget
+{
+    Q_OBJECT
+public:
+    enum FormType
+    {
+        OPERATOR_OK = 0,        // 操作成功!
+        OPERATOR_FAIL,          // 操作失败!
+        OPERATOR_TIP,           // 普通提示!
+        OPERATOR_WARN,          // 需注意!
+    };
+public:
+    static const int WIDTH = 168;
+    static const int HEIGHT = 56;
+    static void display(FormType type, QWidget* parent = Q_NULLPTR, int nTitleHeight = 48);
+    static void display(FormType type, QString text, QWidget* parent = Q_NULLPTR, int nTitleHeight = 48);
+
+    explicit TipWidget(FormType type, QWidget *parent = 0);
+    TipWidget(FormType type, QString& text, QWidget *parent = 0);
+    ~TipWidget();
+
+    void setEndPos(int x, int y);
+    void run();
+public slots:
+    void onBtnClose();
+    void onFadeOut();
+protected:
+    void paintEvent(QPaintEvent *event) override;
+private:
+    void setFormType(FormType type);
+private:
+    Ui::TipWidget *ui;
+    QColor _backgroundColor{246, 255, 237};
+    QColor _borderColor{183, 235, 143};
+    QRect _endRect;
+    QTimer* _pKillTimer{nullptr};
+    QPropertyAnimation* _animation{nullptr};
+    QPropertyAnimation* _animFadeOut{nullptr};
+
+    QString m_tipText;              /* 提示文本 */
+    bool m_customText;              /* 自定义文本标志 */
+};
+
+#endif // TIPWIDGET_H

+ 84 - 0
TransmitterSwitch/common/TipWidget/tipwidget.ui

@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TipWidget</class>
+ <widget class="QWidget" name="TipWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>168</width>
+    <height>56</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <property name="styleSheet">
+   <string notr="true">QLabel
+{
+background:transparent;
+}
+
+QLabel#label_tipIcon
+{
+font-weight: 500;
+font-size: 16px;
+color: rgba(0,0,0,0.85);
+line-height: 24px;
+text-align: left;
+font-style: normal;
+}
+</string>
+  </property>
+  <layout class="QHBoxLayout" name="horizontalLayout">
+   <item>
+    <widget class="QLabel" name="label_tipIcon">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="minimumSize">
+      <size>
+       <width>24</width>
+       <height>24</height>
+      </size>
+     </property>
+     <property name="maximumSize">
+      <size>
+       <width>24</width>
+       <height>24</height>
+      </size>
+     </property>
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLabel" name="label_tipTitle">
+     <property name="styleSheet">
+      <string notr="true">font-family:&quot;Source Han Sans CN&quot;;
+font-size: 16px;
+font-weight: 500;
+color: rgba(0,0,0,0.85);</string>
+     </property>
+     <property name="text">
+      <string>保存成功!</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+  <zorder>label_tipTitle</zorder>
+  <zorder>label_tipIcon</zorder>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 69 - 11
TransmitterSwitch/transmitterswitch.cpp

@@ -24,6 +24,7 @@
 #include "savetotemplate.h"
 #include "importtemplate.h"
 #include "warning.h"
+#include "tipwidget.h"
 
 TransmitterSwitch::TransmitterSwitch(QWidget *parent) :
     QWidget(parent),
@@ -147,8 +148,42 @@ void TransmitterSwitch::getExecPlanFromEQM()
     /* 清空本地的计划数据 */
     IData.clearAllItem();
 
+    /* 获取页面的配置信息 */
+    QMap<int, int> mapConfig;
+    if(m_fromWebAPI->getConfigData(mapConfig))
+    {
+        TipWidget::display(TipWidget::OPERATOR_OK, "获取配置成功", this);
+    }else {
+        TipWidget::display(TipWidget::OPERATOR_FAIL, "获取配置失败", this);
+        return;
+    }
+    /* 设置计划配置 */
+    for(auto begin = mapConfig.begin(), end = mapConfig.end(); begin != end; begin++)
+    {
+        if(begin.key() == static_cast<int>(enum_ExecPlanConfig::DefaultPlan))
+        {
+            ui->pBtn_defaultPlan->setChecked(begin.value() == 1 ? true : false);
+        }
+        else if(begin.key() == static_cast<int>(enum_ExecPlanConfig::ExecMode))
+        {
+            if(begin.value() == 0)
+            {
+                ui->rBtn_moment->setChecked(true);
+            }else {
+                ui->rBtn_day->setChecked(true);
+            }
+        }
+    }
+
+    /* 获取计划 */
     QList<ExecPlanItemInfo> list;
-    m_fromWebAPI->getExecPlanData(list);
+    if(m_fromWebAPI->getExecPlanData(list))
+    {
+        TipWidget::display(TipWidget::OPERATOR_OK, "获取计划成功", this);
+    }else {
+        TipWidget::display(TipWidget::OPERATOR_FAIL, "获取计划失败", this);
+        return;
+    }
 
     /* 添加计划项 */
     for(const auto& it : list)
@@ -198,12 +233,26 @@ void TransmitterSwitch::saveExecPlanToEQM()
             list.push_back(info);
         }
     }
-    /* 判断计划条数,如果为0就阻止 */
-    // if(list.size() == 0)
-    // {
-    //     return;
-    // }
-    m_fromWebAPI->insertData(list);
+    /* 写入数据库 */
+    if(m_fromWebAPI->insertData(list))
+    {
+        TipWidget::display(TipWidget::OPERATOR_OK, "保存计划成功", this);
+    }else {
+        TipWidget::display(TipWidget::OPERATOR_FAIL, "保存计划失败", this);
+    }
+
+    /* 保存“默认计划”和“执行模式” */
+    QMap<int, int> mapConfig;
+    mapConfig.insert(static_cast<int>(enum_ExecPlanConfig::DefaultPlan), ui->pBtn_defaultPlan->isChecked() ? 1 : 0);
+    mapConfig.insert(static_cast<int>(enum_ExecPlanConfig::ExecMode), execType);
+    /* 将配置写入数据库 */
+    if(m_fromWebAPI->insertConfigData(mapConfig))
+    {
+        TipWidget::display(TipWidget::OPERATOR_OK, "保存配置成功", this);
+    }else {
+        TipWidget::display(TipWidget::OPERATOR_FAIL, "保存配置失败", this);
+    }
+
 }
 
 /* 亮/暗换肤,0是亮色,1是暗色 */
@@ -499,8 +548,17 @@ void TransmitterSwitch::do_exportData()
     {
         stt->setItemEmpty(false);
     }
+    /* 判断当前是正常日还是特殊日 */
+    int type = -1;
+    if(weekDay < 7 && weekDay >= 0)
+    {
+        type = 0;
+    }else if(weekDay == 7)
+    {
+        type = 1;
+    }
     /* 获取所有的模板名称,并设置 */
-    stt->setTemplateName(tabList);
+    stt->setTemplateName(tabList, type);
 
     stt->exec();
     if(stt->isOk())
@@ -508,11 +566,11 @@ void TransmitterSwitch::do_exportData()
         /* 获取一天的数据 */
         auto list = IData.getOneDayExecPlan(weekDay);
         /* 保存到模板 */
-        if(weekDay < 7 && weekDay >= 0)
+        if(m_fromWebAPI->saveTemplate(stt->getTemplateName(), type, list))
         {
-            m_fromWebAPI->saveTemplate(stt->getTemplateName(), 0, list);
+            TipWidget::display(TipWidget::OPERATOR_OK, "保存模版成功", this);
         }else {
-            m_fromWebAPI->saveTemplate(stt->getTemplateName(), 1, list);
+            TipWidget::display(TipWidget::OPERATOR_FAIL, "保存模版失败", this);
         }
     }
 }