mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
实现服务端的QT应用界面
This commit is contained in:
@@ -69,9 +69,9 @@ bool AppData::initFromDB()
|
||||
std::string name = fields.value(DMDefWorkMode::NAME);
|
||||
this->mapping.policyType.push_back({std::to_string(policyTypeId), name});
|
||||
this->mapPolicyType[policyTypeId] = name;
|
||||
str += ("策略类型: {" + std::to_string(policyTypeId) + ":" + name + "},");
|
||||
//str += ("策略类型: {" + std::to_string(policyTypeId) + ":" + name + "},");
|
||||
}
|
||||
spdlog::info(str);
|
||||
//spdlog::info(str);
|
||||
}
|
||||
{ // 数据库读取设备类型定义
|
||||
str = "", result.clear();
|
||||
@@ -87,9 +87,9 @@ bool AppData::initFromDB()
|
||||
item->fieldsAttr.parseJson(item->attr);
|
||||
mapDeviceType[item->typeId] = item;
|
||||
mapping.deviceType.push_back({std::to_string(item->typeId), item->name});
|
||||
str += ("设备类型: {" + std::to_string(item->typeId) + ":" + item->name + "},");
|
||||
//str += ("设备类型: {" + std::to_string(item->typeId) + ":" + item->name + "},");
|
||||
}
|
||||
spdlog::info(str);
|
||||
//spdlog::info(str);
|
||||
}
|
||||
{ // 数据库读取角色定义
|
||||
str = "", result.clear();
|
||||
@@ -103,9 +103,9 @@ bool AppData::initFromDB()
|
||||
item->isOpen = fields.get<int>(DMRole::IS_OPEN);
|
||||
mapRole[item->roleId] = item;
|
||||
mapping.role.push_back({std::to_string(item->roleId), item->name});
|
||||
str += ("角色: {" + std::to_string(item->roleId) + ":" + item->name + "},");
|
||||
//str += ("角色: {" + std::to_string(item->roleId) + ":" + item->name + "},");
|
||||
}
|
||||
spdlog::info(str);
|
||||
//spdlog::info(str);
|
||||
}
|
||||
{ // 数据库读取场站信息
|
||||
str = "", result.clear();
|
||||
@@ -118,9 +118,8 @@ bool AppData::initFromDB()
|
||||
station->setFields(fields);
|
||||
this->mapStation[station->stationId] = station;
|
||||
this->mapping.stationName.push_back({std::to_string(station->stationId), station->name});
|
||||
str += ("场站: {" + std::to_string(station->stationId) + ":" + station->name + "},");
|
||||
spdlog::info("场站: {}:{}, {}", station->stationId, station->name, station->status>0 ? "启用" : "未启用");
|
||||
}
|
||||
spdlog::info(str);
|
||||
}
|
||||
{ // 数据库读取设备信息
|
||||
str = "", result.clear();
|
||||
@@ -158,32 +157,32 @@ bool AppData::initFromDB()
|
||||
}
|
||||
}
|
||||
{ // 数据库读取电价分段信息
|
||||
result.clear();
|
||||
vecElectPeriods.resize(12);
|
||||
DAO::exec(dao, "SELECT * FROM configure;", result);
|
||||
|
||||
Fields info;
|
||||
for (auto& fields: result)
|
||||
{
|
||||
auto k = fields.value("key");
|
||||
auto v = fields.value("val");
|
||||
info.set(k, v);
|
||||
}
|
||||
//result.clear();
|
||||
//vecElectPeriods.resize(12);
|
||||
//DAO::exec(dao, "SELECT * FROM configure;", result);
|
||||
//
|
||||
//Fields info;
|
||||
//for (auto& fields: result)
|
||||
//{
|
||||
// auto k = fields.value("key");
|
||||
// auto v = fields.value("val");
|
||||
// info.set(k, v);
|
||||
//}
|
||||
|
||||
for (int month = 1; month<=12; month++)
|
||||
{
|
||||
if (month-1 < vecElectPeriods.size())
|
||||
{
|
||||
auto& vecItems = vecElectPeriods[month-1];
|
||||
std::string str = info.value("period_" + std::to_string(month));
|
||||
std::vector<std::string> vec;
|
||||
Utils::split(str, ",", vecItems);
|
||||
}
|
||||
}
|
||||
electPriceSuperPeak = info.get<double>("price_super_peak");
|
||||
electPricePeak = info.get<double>("price_peak");
|
||||
electPriceShoulder = info.get<double>("price_shoulder");
|
||||
electPriceOffPeak = info.get<double>("price_off_peak");
|
||||
//for (int month = 1; month<=12; month++)
|
||||
//{
|
||||
// if (month-1 < vecElectPeriods.size())
|
||||
// {
|
||||
// auto& vecItems = vecElectPeriods[month-1];
|
||||
// std::string str = info.value("period_" + std::to_string(month));
|
||||
// std::vector<std::string> vec;
|
||||
// Utils::split(str, ",", vecItems);
|
||||
// }
|
||||
//}
|
||||
//electPriceSuperPeak = info.get<double>("price_super_peak");
|
||||
//electPricePeak = info.get<double>("price_peak");
|
||||
//electPriceShoulder = info.get<double>("price_shoulder");
|
||||
//electPriceOffPeak = info.get<double>("price_off_peak");
|
||||
}
|
||||
{ // 数据库读取统计数据
|
||||
vector<Fields> result;
|
||||
@@ -457,32 +456,32 @@ int AppData::getPolicyTypeId(std::string name)
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> AppData::getElectPreiodVals(int month)
|
||||
{
|
||||
if (month > 0 && month-1 < vecElectPeriods.size())
|
||||
{
|
||||
return vecElectPeriods[month-1];
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string AppData::getElectPreiodVal(int month, int hour)
|
||||
{
|
||||
if (month > 0 && month-1 < vecElectPeriods.size())
|
||||
{
|
||||
auto& vec = vecElectPeriods[month-1];
|
||||
if (hour > 0 && hour-1 < vec.size())
|
||||
{
|
||||
auto& val = vec[hour-1];
|
||||
if (val == "尖") return "尖峰";
|
||||
if (val == "峰") return "高峰";
|
||||
if (val == "平") return "平段";
|
||||
if (val == "谷") return "低谷";
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
//std::vector<std::string> AppData::getElectPreiodVals(int month)
|
||||
//{
|
||||
// if (month > 0 && month-1 < vecElectPeriods.size())
|
||||
// {
|
||||
// return vecElectPeriods[month-1];
|
||||
// }
|
||||
// return {};
|
||||
//}
|
||||
//
|
||||
//std::string AppData::getElectPreiodVal(int month, int hour)
|
||||
//{
|
||||
// if (month > 0 && month-1 < vecElectPeriods.size())
|
||||
// {
|
||||
// auto& vec = vecElectPeriods[month-1];
|
||||
// if (hour > 0 && hour-1 < vec.size())
|
||||
// {
|
||||
// auto& val = vec[hour-1];
|
||||
// if (val == "尖") return "尖峰";
|
||||
// if (val == "峰") return "高峰";
|
||||
// if (val == "平") return "平段";
|
||||
// if (val == "谷") return "低谷";
|
||||
// return val;
|
||||
// }
|
||||
// }
|
||||
// return "";
|
||||
//}
|
||||
|
||||
void AppData::storeRuntimeDB()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user