修改运行监控显示信息,提交electron代码

This commit is contained in:
lixiaoyuan
2025-09-26 16:51:09 +08:00
parent cb3d3aa4b1
commit 4ce1368321
13 changed files with 337 additions and 125 deletions

View File

@@ -711,13 +711,18 @@ Errcode HttpEntity::queryStationOverview(const httplib::Request& req, njson& jso
{
return Errcode(ret);
}
njson jsonStorage = njson::parse(R"({"category":1, "gateway":0, "count":0, "power":0.0})");
auto station = Application::data().getStation(Utils::toInt(stationId));
jsonStorage["workmode"] = station ? station->getGatewayMode() : "--";
njson jsonStorage = njson::parse(R"({"category":1, "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})");
//auto station = Application::data().getStation(Utils::toInt(stationId));
//if (station)
//{
// jsonStorage["msg"] = station->getGatewayParam();
// jsonStorage["workmode"] = station->getGatewayMode();
// jsonStorage["emu"] = station->emuStatus == 1 ? "在线" : (station->emuStatus == 0 ? "离线" : "--");
// jsonStorage["cdz"] = station->cdzStatus == 1 ? "在线" : (station->cdzStatus == 0 ? "离线" : "--");
//}
auto videoInfo = Config::getVideoInfo(stationId);
if (videoInfo)
{
@@ -922,6 +927,16 @@ Errcode HttpEntity::queryDevicByCategory(const httplib::Request& req, njson& jso
}
}
json["data"] = jsondata;
njson jsongateway = njson::object();
if (station)
{
jsongateway["msg"] = station->getGatewayParam();
jsongateway["workmode"] = station->getGatewayMode();
jsongateway["emu"] = station->emuStatus == 1 ? "在线" : (station->emuStatus == 0 ? "离线" : "--");
jsongateway["cdz"] = station->cdzStatus == 1 ? "在线" : (station->cdzStatus == 0 ? "离线" : "--");
}
json["gateway"] = jsongateway;
return Errcode::OK;
}
@@ -1011,6 +1026,7 @@ Errcode HttpEntity::queryPolicyByType(const httplib::Request& req, njson& json,
std::string sql = "SELECT policy_id, `type`, name from policy WHERE `type`='" + type + "';";
std::vector<Fields> result;
int ret = DaoEntity::execOnce(sql, result);
json["data"] = FieldsToJsonArray(result);
return Errcode(ret);
}
@@ -1080,14 +1096,14 @@ Errcode HttpEntity::queryStatSystem(const httplib::Request& req, njson& json, st
{
auto& appdata = Application::data();
double incomeTotal {};
double station_num = appdata.getStationCount();
double solarDeviceNum {};
double capacityTotal {};
double electGenTotal {};
double electGridTotal {};
double electStorageIn {};
double electStorageOut {};
float incomeTotal {};
float station_num = appdata.getStationCount();
float solarDeviceNum {};
float capacityTotal {};
float electGenTotal {};
float electGridTotal {};
float electStorageIn {};
float electStorageOut {};
for (auto& item : appdata.mapStation)
{
auto& station = item.second;
@@ -1111,6 +1127,14 @@ Errcode HttpEntity::queryStatSystem(const httplib::Request& req, njson& json, st
jsondata["storage_elect_in"] = electStorageIn; // : 储能充电总电量kWh精度0.001
jsondata["storage_elect_out"] = electStorageOut; // : 储能放电总电量kWh精度0.001
std::string sql = "SELECT SUM(income_elect) income_total FROM stat_day;";
std::vector<Fields> result;
DAO::exec(NULL, sql, result);
if (result.size() > 0)
{
jsondata["income_total"] = result[0].get<float>("income_total");
}
json["data"] = jsondata;
return Errcode::OK;
}