实现QT6启动器,QT版本有qt5升级到qt6

This commit is contained in:
lixiaoyuan
2025-09-10 20:10:51 +08:00
parent 3d03bbe9b5
commit e822d57b67
188 changed files with 1376 additions and 219 deletions

View File

@@ -166,8 +166,8 @@ static std::map<std::string, HandlerOptions> g_mapHttpHandlerGet =
{"/queryStatSystem", HandlerOptions(&HttpEntity::queryStatSystem, {})},
{"/queryStatTotal", HandlerOptions(&HttpEntity::queryStatTotal, {})},
{"/queryStatStation", HandlerOptions(&HttpEntity::queryStatStation, {})},
{"/queryStatDayList", HandlerOptions(&HttpEntity::queryStatDayList, {})},
{"/queryStatCharts", HandlerOptions(&HttpEntity::queryStatCharts, {})},
{"/queryEnvironment", HandlerOptions(&HttpEntity::queryEnvironment, { "station_id"})},
@@ -300,6 +300,7 @@ Errcode HttpEntity::login(const httplib::Request& req, njson& json, std::string&
if (err == Errcode::OK)
{
json["token"] = token;
json["account"] = account;
std::vector<Fields> vecPermission;
int roleId = fields.get<int>(DMRole::ROLE_ID);
@@ -606,7 +607,7 @@ Errcode HttpEntity::queryStationOverview(const httplib::Request& req, njson& jso
{
return Errcode(ret);
}
njson jsonStorage = njson::parse(R"({"category":1, "count":0, "power":0.0})");
njson jsonStorage = njson::parse(R"({"category":1, "gateway":0, "count":0, "power":0.0})");
njson jsonCharge = njson::parse(R"({"category":2, "count":0, "power":0.0})");
njson jsonSolar = njson::parse(R"({"category":3, "count":0, "power":0.0})");
njson jsonSecurity = njson::parse(R"({"category":4, "count":0, "power":0.0})");
@@ -906,7 +907,7 @@ Errcode HttpEntity::queryStatSystem(const httplib::Request& req, njson& json, st
auto& appdata = Application::data();
njson jsondata;
jsondata["launch_date"] = "2025-01-01"; //: 系统上线启用日期格式yyyy-mm-dd
jsondata["launch_date"] = appdata.launchDate; //: 系统上线启用日期格式yyyy-mm-dd
jsondata["income_total"] = std::to_string(Utils::random(100, 200)); // : 累计收益精度0.01
jsondata["station_num"] = Utils::toStr(appdata.getStationCount()); // : 能源站数量
jsondata["storage_device_num "] = Utils::toStr(appdata.getStationCount()); //: 储能设备数量
@@ -924,49 +925,31 @@ Errcode HttpEntity::queryStatTotal(const httplib::Request& req, njson& json, std
{
std::string station_id = req.get_param_value("station_id");
std::string category = req.get_param_value("category");
njson jsondata;
jsondata["station_id"] = "1";
jsondata["launch_date"] = "2025-01-01"; //场站上线日期
jsondata["usage_rate"] = "12";
jsondata["storage_elect_in"] = "123.123"; //储能充电电量kWh精度0.001
jsondata["storage_elect_out"] = "123.123"; //储能放电电量kWh精度0.001
jsondata["storage_num_in"] = "1"; //储能设备充电次数
jsondata["storage_num_out"] = "1"; //储能设备放电次数
jsondata["storage_num_err"] = "1"; //储能设备故障次数
jsondata["solar_elect_gen"] = "123.123"; //光伏发电电量kWh精度0.001
jsondata["solar_elect_grid"] = "123.123"; //光伏入网电量kWh精度0.001
jsondata["solar_num_err"] = "1"; //光伏设备故障次数
jsondata["charge_elect"] = "123.123"; //充电设备充电电量kWh精度0.001
jsondata["charge_num"] = "1"; //充电设备充电次数
jsondata["charge_num_err"] = "1"; //充电设备故障次数
jsondata["income_elect"] = "123.123"; //发电收益(元精度0.01
jsondata["income_charge"] = "123.123"; //充电收益精度0.01
auto station = Application::data().getStation(Utils::toInt(station_id));
if (station)
{
jsondata["station_id"] = station_id;
jsondata["launch_date"] = "2025-09-01"; //场站上线日期
jsondata["usage_rate"] = "12";
jsondata["storage_elect_in"] = "123.123"; //储能充电电量kWh精度0.001
jsondata["storage_elect_out"] = "123.123"; //储能放电电量kWh精度0.001
jsondata["storage_num_in"] = "1"; //储能设备充电次数
jsondata["storage_num_out"] = "1"; //储能设备放电次数
jsondata["storage_num_err"] = "1"; //储能设备故障次数
jsondata["solar_elect_gen"] = "123.123"; //光伏发电电量kWh精度0.001
jsondata["solar_elect_grid"] = "123.123"; //光伏入网电量kWh精度0.001
jsondata["solar_num_err"] = "1"; //光伏设备故障次数
jsondata["charge_elect"] = "123.123"; //充电设备充电电量kWh精度0.001
jsondata["charge_num"] = "1"; //充电设备充电次数
jsondata["charge_num_err"] = "1"; //充电设备故障次数
jsondata["income_elect"] = "123.123"; //发电收益精度0.01
jsondata["income_charge"] = "123.123"; //充电收益精度0.01
json["data"] = jsondata;
return Errcode::OK;
}
Errcode HttpEntity::queryStatStation(const httplib::Request& req, njson& json, std::string& errmsg)
{
std::string station_id = req.get_param_value("station_id");
std::string category = req.get_param_value("category");
njson jsondata;
jsondata["station_id"] = "1";
jsondata["launch_date"] = "2025-01-01"; //场站上线日期
jsondata["usage_rate"] = "12";
jsondata["storage_elect_in"] = "123.123"; //储能充电电量kWh精度0.001
jsondata["storage_elect_out"] = "123.123"; //储能放电电量kWh精度0.001
jsondata["storage_num_in"] = "1"; //储能设备充电次数
jsondata["storage_num_out"] = "1"; //储能设备放电次数
jsondata["storage_num_err"] = "1"; //储能设备故障次数
jsondata["solar_elect_gen"] = "123.123"; //光伏发电电量kWh精度0.001
jsondata["solar_elect_grid"] = "123.123"; //光伏入网电量kWh精度0.001
jsondata["solar_num_err"] = "1"; //光伏设备故障次数
jsondata["charge_elect"] = "123.123"; //充电设备充电电量kWh精度0.001
jsondata["charge_num"] = "1"; //充电设备充电次数
jsondata["charge_num_err"] = "1"; //充电设备故障次数
jsondata["income_elect"] = "123.123"; //发电收益精度0.01
jsondata["income_charge"] = "123.123"; //充电收益精度0.01
}
json["data"] = jsondata;
return Errcode::OK;
@@ -1010,6 +993,65 @@ Errcode HttpEntity::queryStatDayList(const httplib::Request& req, njson& json, s
return Errcode::OK;
}
Errcode HttpEntity::queryStatCharts(const httplib::Request& req, njson& json, std::string& errmsg)
{
std::string dt = req.get_param_value("dt");
std::string stationId = req.get_param_value("station_id");
std::string category = req.get_param_value("category");
if (dt.empty()) { errmsg = "参数[dt]错误"; return Errcode::ERR_PARAM; }
if (stationId.empty()) { errmsg = "参数[station_id]错误"; return Errcode::ERR_PARAM; }
if (category.empty()) { errmsg = "参数[category]错误"; return Errcode::ERR_PARAM; }
njson jsondata;
std::string sql = R"(SELECT hd.*, d.`type` device_type, ddt.category FROM history_day hd
LEFT JOIN device d ON d.device_id = hd.device_id
LEFT JOIN def_device_type ddt ON d.`type` = ddt.device_type_id
WHERE dt=')" + dt + "' AND d.station_id='" + stationId + "' AND ddt.category='" + category + "';";
std::vector<Fields> result;
int ret = DaoEntity::execOnce(sql, result);
if (ret != 0)
{
return Errcode(ret);
}
std::vector<double> vecV;
std::vector<double> vecI;
std::vector<double> vecP;
for (auto fields : result)
{
int datetype = fields.get<int>("datatype"); // 1: 电压2电流3功率
std::string val = fields.value("value"); // JSON 数组(double)
njson jsonval;
if (JSON::parse(val, jsonval))
{
for (int i = 0; i<jsonval.size(); ++i)
{
double val = jsonval[i];
if (datetype == 1)
{
// 电压取最大
i >= vecV.size() ? vecV.push_back(val) : (val > vecV[i] ? (vecV[i] = val, (void)0) : (void)0);
}
else if (datetype == 2)
{
// 电流取最大
i >= vecI.size() ? vecI.push_back(val) : (val > vecI[i] ? (vecI[i] = val, (void)0) : (void)0);
}
else if (datetype == 3)
{
// 功率累加
i >= vecP.size() ? vecP.push_back(val) : (vecP[i] = vecP[i] + val, (void)0);
}
}
}
}
json["data"] = {{"V", vecV}, {"I", vecI}, {"P", vecP}};
return Errcode::OK;
}
Errcode HttpEntity::queryEnvironment(const httplib::Request& req, njson& json, std::string& errmsg)
{
std::string stationId = req.get_param_value("station_id");
@@ -1098,7 +1140,6 @@ Errcode HttpEntity::queryEnvironment(const httplib::Request& req, njson& json, s
return Errcode::OK;
}
Errcode HttpEntity::queryServiceApiList(const httplib::Request& req, njson& json, std::string& errmsg)
{
PageInfo pageinfo;