mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
实现启动splash画面,实现天历史数据的处理和数据库存贮
This commit is contained in:
@@ -113,9 +113,9 @@ void AppData::initFromDB()
|
||||
{
|
||||
auto station = std::make_shared<Station>();
|
||||
station->setFields(fields);
|
||||
this->mapStation[station->id] = station;
|
||||
mapping.stationName.push_back({std::to_string(station->id), station->name});
|
||||
str += ("场站: {" + std::to_string(station->id) + ":" + station->name + "},");
|
||||
this->mapStation[station->stationId] = station;
|
||||
mapping.stationName.push_back({std::to_string(station->stationId), station->name});
|
||||
str += ("场站: {" + std::to_string(station->stationId) + ":" + station->name + "},");
|
||||
}
|
||||
spdlog::info(str);
|
||||
}
|
||||
@@ -210,6 +210,34 @@ void AppData::initFromDB()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{ // 初始化场站设备的历史监测数据
|
||||
|
||||
vector<Fields> result;
|
||||
DAO::queryRuntimeData(dao, Utils::dateStr(), result);
|
||||
for (auto& item : result)
|
||||
{
|
||||
int stationId = item.get<int>("station_id");
|
||||
int deviceId = item.get<int>("device_id");
|
||||
auto device = this->getDevice(stationId, deviceId);
|
||||
if (device)
|
||||
{
|
||||
int datatype = item.get<int>("datatype");
|
||||
std::string value = item.value("value");
|
||||
|
||||
njson json;
|
||||
if (JSON::parse(value, json))
|
||||
{
|
||||
std::vector<double> vecVal(json.size());
|
||||
for (int i=0; i<json.size(); ++i)
|
||||
{
|
||||
vecVal[i] = JSON::get<double>(json[i]);
|
||||
}
|
||||
device->setCache(datatype, vecVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AppData::init()
|
||||
|
||||
Reference in New Issue
Block a user