修改台区电表参数

This commit is contained in:
lixiaoyuan
2026-02-06 14:29:37 +08:00
parent e9e00713d9
commit 8c68e2a4b0
7 changed files with 82 additions and 57 deletions

View File

@@ -896,7 +896,7 @@ Errcode HttpEntity::queryStationTodayU(const httplib::Request& req, njson& json,
int n = Utils::timeDaySeconds() / 600;
if (catogray == "1")
{
auto device = station->getDeviceByType(int(EDeviceType::E_METER), "2");
auto device = station->getDeviceByType(int(EDeviceType::BMS), "1"); // 使用 BMS 的数据
if (device) {
jsondata["U"] = VectorToJsonArray(device->cacheU, n);
jsondata["I"] = VectorToJsonArray(device->cacheI, n);
@@ -1602,7 +1602,7 @@ Errcode HttpEntity::queryStatCharts(const httplib::Request& req, njson& json, st
njson jsondata;
std::string sql = R"(SELECT hd.*, d.`type` device_type, ddt.category FROM history_day hd
std::string sql = R"(SELECT hd.*, d.`type` device_type, d.code, 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 + "';";
@@ -1621,6 +1621,16 @@ Errcode HttpEntity::queryStatCharts(const httplib::Request& req, njson& json, st
{
int datetype = fields.get<int>("datatype"); // 1: 电压2电流3功率
std::string val = fields.value("value"); // JSON 数组(double)
int deviceType = fields.get<int>("device_type");
int deviceCode = fields.get<int>("code");
if (category == "1")
{
if (!(deviceType == int(EDeviceType::BMS))) // 储能BMS储能设备以BMS电池的数据作为总数据来展示
{
continue;
}
}
njson jsonval;
if (JSON::parse(val, jsonval))
{