mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
南瑞意见修改:前端页面和后端接口
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "Constant.h"
|
||||
|
||||
namespace CONST
|
||||
namespace CONSTS
|
||||
{
|
||||
const std::string VAR;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef _CONSTANTS_H_
|
||||
#define _CONSTANTS_H_
|
||||
#ifndef _MYCONSTS_H_
|
||||
#define _MYCONSTS_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace CONST
|
||||
namespace CONSTS
|
||||
{
|
||||
extern const std::string VAR;
|
||||
}
|
||||
|
||||
#endif // !_CONSTANTS_H_
|
||||
#endif // !_MYCONSTS_H_
|
||||
|
||||
@@ -12,9 +12,10 @@ enum class EAlertType
|
||||
|
||||
enum class EDeviceType
|
||||
{
|
||||
NUL = 0,
|
||||
//1 变压器 0
|
||||
//2 配电柜 0
|
||||
//3 电表 1
|
||||
E_METER = 3, //3 电表 1
|
||||
//4 门禁 0
|
||||
//5 空调 0
|
||||
//6 照明 0
|
||||
|
||||
@@ -28,6 +28,9 @@ std::shared_ptr<Device> Device::create(Fields& fields)
|
||||
static const int BCU_UNIT_SIZE = 256;
|
||||
Device::Device()
|
||||
{
|
||||
cacheU = vector<float>(144, 0);
|
||||
cacheI = vector<float>(144, 0);
|
||||
cacheP = vector<float>(144, 0);
|
||||
vecBCUUnit = std::vector<std::vector<float>>(BCU_UNIT_SIZE, std::vector<float>(5, 0.0f));
|
||||
}
|
||||
|
||||
@@ -104,54 +107,54 @@ int Device::startComm()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Device::getCacheVoltage(std::vector<std::string>& vec)
|
||||
{
|
||||
vec.resize(mapCacheVoltage.size());
|
||||
int i = 0;
|
||||
for (auto iter = mapCacheVoltage.begin(); iter != mapCacheVoltage.end(); ++iter)
|
||||
{
|
||||
vec[i] = Utils::toStr(iter->second);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
void Device::getCacheCurrent(std::vector<std::string>& vec)
|
||||
{
|
||||
vec.resize(mapCacheCurrent.size());
|
||||
int i = 0;
|
||||
for (auto iter = mapCacheCurrent.begin(); iter != mapCacheCurrent.end(); ++iter)
|
||||
{
|
||||
vec[i] = Utils::toStr(iter->second);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
void Device::getCachePower(std::vector<std::string>& vec)
|
||||
{
|
||||
vec.resize(mapCachePower.size());
|
||||
int i = 0;
|
||||
for (auto iter = mapCachePower.begin(); iter != mapCachePower.end(); ++iter)
|
||||
{
|
||||
vec[i] = Utils::toStr(iter->second);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
//void Device::getCacheVoltage(std::vector<std::string>& vec)
|
||||
//{
|
||||
// vec.resize(mapCacheVoltage.size());
|
||||
// int i = 0;
|
||||
// for (auto iter = mapCacheVoltage.begin(); iter != mapCacheVoltage.end(); ++iter)
|
||||
// {
|
||||
// vec[i] = Utils::toStr(iter->second);
|
||||
// i++;
|
||||
// }
|
||||
//}
|
||||
//void Device::getCacheCurrent(std::vector<std::string>& vec)
|
||||
//{
|
||||
// vec.resize(mapCacheCurrent.size());
|
||||
// int i = 0;
|
||||
// for (auto iter = mapCacheCurrent.begin(); iter != mapCacheCurrent.end(); ++iter)
|
||||
// {
|
||||
// vec[i] = Utils::toStr(iter->second);
|
||||
// i++;
|
||||
// }
|
||||
//}
|
||||
//void Device::getCachePower(std::vector<std::string>& vec)
|
||||
//{
|
||||
// vec.resize(mapCachePower.size());
|
||||
// int i = 0;
|
||||
// for (auto iter = mapCachePower.begin(); iter != mapCachePower.end(); ++iter)
|
||||
// {
|
||||
// vec[i] = Utils::toStr(iter->second);
|
||||
// i++;
|
||||
// }
|
||||
//}
|
||||
|
||||
void Device::setCache(int datatype, std::vector<float>& vd)
|
||||
{
|
||||
std::map<int, float>* mapptr = NULL;
|
||||
if (datatype == 1) { mapptr = &mapCacheVoltage; }
|
||||
else if (datatype == 2) { mapptr = &mapCacheCurrent; }
|
||||
else if (datatype == 3) { mapptr = &mapCachePower; }
|
||||
std::vector<float>* vecptr = NULL;
|
||||
if (datatype == 1) { vecptr = &cacheU; }
|
||||
else if (datatype == 2) { vecptr = &cacheI; }
|
||||
else if (datatype == 3) { vecptr = &cacheP; }
|
||||
|
||||
if (mapptr)
|
||||
if (vecptr)
|
||||
{
|
||||
const int step = 600;
|
||||
const int N = 86400/step;
|
||||
int64_t tsSeconds = Utils::timeDaySeconds();
|
||||
int npos = tsSeconds / step;
|
||||
for (int i = 0; i<N; ++i)
|
||||
for (int i = 0; i<N && i< vecptr->size(); ++i)
|
||||
{
|
||||
if (i < vd.size()) { (*mapptr)[i] = vd[i]; }
|
||||
else if (i <= npos) { (*mapptr)[i] = 0; }
|
||||
if (i < vd.size()) { (*vecptr)[i] = vd[i]; }
|
||||
else if (i <= npos) { (*vecptr)[i] = 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,9 +167,9 @@ bool Device::cache(int npos)
|
||||
}
|
||||
if (npos == 0)
|
||||
{
|
||||
mapCacheVoltage.clear();
|
||||
mapCacheCurrent.clear();
|
||||
mapCachePower.clear();
|
||||
std::fill(cacheU.begin(), cacheU.end(), 0);
|
||||
std::fill(cacheI.begin(), cacheI.end(), 0);
|
||||
std::fill(cacheP.begin(), cacheP.end(), 0);
|
||||
}
|
||||
|
||||
std::string addrV;
|
||||
@@ -186,9 +189,9 @@ bool Device::cache(int npos)
|
||||
int U = Utils::toInt(this->getParam(addrV, "0"));
|
||||
int I = Utils::toInt(this->getParam(addrI, "0"));
|
||||
int P = addrP.empty() ? U*I*0.001 : Utils::toInt(this->getParam(addrP, "0"));
|
||||
mapCacheVoltage[npos] = U;
|
||||
mapCacheCurrent[npos] = I;
|
||||
mapCachePower[npos] = P;
|
||||
cacheU[npos] = U;
|
||||
cacheI[npos] = I;
|
||||
cacheP[npos] = P;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ public:
|
||||
|
||||
int startComm();
|
||||
|
||||
void getCacheVoltage(std::vector<std::string>& vec);
|
||||
void getCacheCurrent(std::vector<std::string>& vec);
|
||||
void getCachePower(std::vector<std::string>& vec);
|
||||
//void getCacheVoltage(std::vector<std::string>& vec);
|
||||
//void getCacheCurrent(std::vector<std::string>& vec);
|
||||
//void getCachePower(std::vector<std::string>& vec);
|
||||
|
||||
// int datatype: 1: 电压,2:电流,3:功率
|
||||
void setCache(int datatype, std::vector<float>& vec);
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
int type = {0};
|
||||
std::string name;
|
||||
std::string code;
|
||||
int category;
|
||||
int category = 0;
|
||||
bool isOpen = false;
|
||||
std::string attrsJson = "";
|
||||
int sortNo {0};
|
||||
@@ -67,9 +67,13 @@ public:
|
||||
std::shared_ptr<CommEntity> commEntity;
|
||||
|
||||
int64_t tsDataDate {};
|
||||
std::map<int, float> mapCacheVoltage;
|
||||
std::map<int, float> mapCacheCurrent;
|
||||
std::map<int, float> mapCachePower;
|
||||
//std::map<int, float> mapCacheVoltage;
|
||||
//std::map<int, float> mapCacheCurrent;
|
||||
//std::map<int, float> mapCachePower;
|
||||
|
||||
std::vector<float> cacheU;
|
||||
std::vector<float> cacheI;
|
||||
std::vector<float> cacheP;
|
||||
|
||||
// 参数值(保存从设备读取的参数值)
|
||||
std::map<std::string, std::string> mapParams;
|
||||
|
||||
@@ -18,6 +18,18 @@ Station::Station() : stationId(0)
|
||||
predictStorageIn = vector<int>(144, 0);
|
||||
predictStorageOut = vector<int>(144, 0);
|
||||
predictCharge = vector<int>(144, 0);
|
||||
|
||||
storage.U = vector<int>(144, 0);
|
||||
storage.I = vector<int>(144, 0);
|
||||
storage.P = vector<int>(144, 0);
|
||||
|
||||
charge.U = vector<int>(144, 0);
|
||||
charge.I = vector<int>(144, 0);
|
||||
charge.P = vector<int>(144, 0);
|
||||
|
||||
pv.U = vector<int>(144, 0);
|
||||
pv.I = vector<int>(144, 0);
|
||||
pv.P = vector<int>(144, 0);
|
||||
}
|
||||
|
||||
void Station::setFields(Fields& fields)
|
||||
@@ -214,13 +226,13 @@ void Station::setGarewayParams()
|
||||
|
||||
string Station::getGatewayMode()
|
||||
{
|
||||
// 0:手动,1:峰谷套利,2:配网增容,3:应急供电,4:并网保电,5:自定时段
|
||||
// 0:手动,1:峰谷套利,2:配网增容,3:应急供电,4:并网保电,5:运营支撑
|
||||
if (gatewayParam.mode == 0) { return "手动"; }
|
||||
else if (gatewayParam.mode == 1) { return "峰谷套利"; }
|
||||
else if (gatewayParam.mode == 2) { return "配网增容"; }
|
||||
else if (gatewayParam.mode == 3) { return "应急供电"; }
|
||||
else if (gatewayParam.mode == 4) { return "并网保电"; }
|
||||
else if (gatewayParam.mode == 5) { return "自定时段"; }
|
||||
else if (gatewayParam.mode == 5) { return "运营支撑"; }
|
||||
else { return "--"; };
|
||||
}
|
||||
|
||||
@@ -236,7 +248,11 @@ static map<int, string> mapPeriodOper =
|
||||
string Station::getGatewayParam()
|
||||
{
|
||||
stringstream ss;
|
||||
std::string str1 = "峰谷套利时段:<br>";
|
||||
std::string str1 = std::format("运行模式:{}<br>储能EMY状态:{}<br>充电桩状态:{}<br><br>",
|
||||
getGatewayMode(),
|
||||
this->emuStatus == 1 ? "在线" : (this->emuStatus == 0 ? "离线" : "--"),
|
||||
this->cdzStatus == 1 ? "在线" : (this->cdzStatus == 0 ? "离线" : "--"));
|
||||
str1 += "峰谷套利时段:<br>";
|
||||
{
|
||||
njson json;
|
||||
if (JSON::parse(gatewayParam.param1, json))
|
||||
@@ -346,18 +362,24 @@ void Station::readAlert(std::shared_ptr<Device> device, std::string addr, int v,
|
||||
}
|
||||
}
|
||||
|
||||
void Station::readRuntimeData(int deviceNo, string addr, int val)
|
||||
void Station::readEnergyData(int deviceNo, string addr, int val)
|
||||
{
|
||||
if (deviceNo == 1)
|
||||
if (deviceNo == 1) // 入网电表
|
||||
{
|
||||
if (addr == "0x000B") { this->voltage = val; } // A相电压 R uint32 1V 0x000B
|
||||
if (addr == "0x0011") { this->current = val; } // A相电流 R int32 1A 0x0011
|
||||
if (addr == "0x0023") { this->power = val; } // 三相总有功 R int32 1kW 0x0023
|
||||
if (addr == "0x000B") { this->grid.voltage = val; } // A相电压 R uint32 1V 0x000B
|
||||
if (addr == "0x0011") { this->grid.current = val; } // A相电流 R int32 1A 0x0011
|
||||
if (addr == "0x0023") { this->grid.power = val; } // 三相总有功 R int32 1kW 0x0023
|
||||
// 功率因数 ?? 电表没有功率因数数据
|
||||
}
|
||||
else if (deviceNo == 2)
|
||||
else if (deviceNo == 2) // 储能电表
|
||||
{
|
||||
statData.ts = Utils::time();
|
||||
if (addr == "0x002F") { statData.dayElectIn = val; } //日充电电量 R uint32 1kWh 0x002F
|
||||
|
||||
if (addr == "0x000B") { this->storage.voltage = val; } // A相电压 R uint32 1V 0x000B
|
||||
else if (addr == "0x0011") { this->storage.current = val; } // A相电流 R int32 1A 0x0011
|
||||
else if (addr == "0x0023") { this->storage.power = val; } // 三相总有功 R int32 1kW 0x0023
|
||||
// 功率因数 ?? 电表没有功率因数数据
|
||||
else if (addr == "0x002F") { statData.dayElectIn = val; } // 日充电电量 R uint32 1kWh 0x002F
|
||||
else if (addr == "0x0031") { statData.dayElectOut = val; } //日放电电量 R uint32 1kWh 0x0031
|
||||
else if (addr == "0x0033") { statData.dayFeeIn = val; } //日充电费用 R uint32 1RMB 0x0033
|
||||
else if (addr == "0x0035") { statData.dayFeeOut = val; } //日放电费用 R uint32 1RMB 0x0035
|
||||
@@ -392,7 +414,29 @@ void Station::readRuntimeData(int deviceNo, string addr, int val)
|
||||
else if (addr == "0x0069") { statData.totalElectOut_Total = val; } //总反向总有功电能 R uint32 1kWh 0x0069
|
||||
}
|
||||
}
|
||||
// 充电桩
|
||||
void Station::readChargeData(int deviceNo, string addr, int val)
|
||||
{
|
||||
if (addr == "11") { charge.connector1.isCharge = val; } //枪1:状态 R uint16 11
|
||||
//枪1 : 需求电压 R uint16 12
|
||||
//枪1 : 需求电流 R uint16 13
|
||||
//枪1 : 需求功率 R uint16 14
|
||||
else if (addr == "15") { charge.connector1.voltage = val * 0.1; } //枪1 : 输出电压 R uint16 15
|
||||
else if (addr == "16") { charge.connector1.current = val * 0.01; } //枪1 : 输出电流 R uint16 16
|
||||
else if (addr == "17") { charge.connector1.power = val * 0.1; } //枪1 : 输出功率 R uint16 17
|
||||
//枪1 : 功率限值 R uint16 18
|
||||
else if (addr == "21") { charge.connector2.isCharge = val; } //枪2 : 状态 R uint16 21
|
||||
//枪2 : 需求电压 R uint16 22
|
||||
//枪2 : 需求电流 R uint16 23
|
||||
//枪2 : 需求功率 R uint16 24
|
||||
else if (addr == "25") { charge.connector2.voltage = val * 0.1; } //枪2 : 输出电压 R uint16 25
|
||||
else if (addr == "26") { charge.connector2.current = val * 0.01; } //枪2 : 输出电流 R uint16 26
|
||||
else if (addr == "27") { charge.connector2.power = val * 0.1; } //枪2 : 输出功率 R uint16 27
|
||||
//枪2 : 功率限值 R uint16 28
|
||||
|
||||
bool isCharge = (charge.connector1.isCharge || charge.connector2.isCharge);
|
||||
charge.status = isCharge ? 2 : 1;
|
||||
}
|
||||
void Station::readTHData(int deviceNo, string addr, int val)
|
||||
{
|
||||
auto& unit = mapTempHumUnit[deviceNo];
|
||||
@@ -507,6 +551,11 @@ void Station::readGatewayStatus(int deviceNo, int cdzStatus, int emuStatus)
|
||||
device->ts = Utils::time();
|
||||
}
|
||||
|
||||
if (cdzStatus == 0) charge.status = 0;
|
||||
else if (charge.status == 0) charge.status = 1;
|
||||
if (emuStatus == 0) storage.status = 0;
|
||||
else if (storage.status == 0) storage.status = 1;
|
||||
|
||||
//充电桩 1:在线,0:离线
|
||||
if (cdzStatus >= 0)
|
||||
{
|
||||
@@ -565,24 +614,51 @@ void Station::cache()
|
||||
int npos = tDaySeconds / 600;
|
||||
int offset = tDaySeconds % 600;
|
||||
bool save = false;
|
||||
if (offset >= (600-180) && npos + 1 < 144)
|
||||
{
|
||||
npos += 1;
|
||||
save = true;
|
||||
}
|
||||
else if (offset <= 180 && posCache < npos)
|
||||
if (posCache != npos && offset <= 180) // 超过时间点3分钟内没有存储,进行兼容处理
|
||||
{
|
||||
if (npos == 0)
|
||||
{
|
||||
std::fill(storage.U.begin(), storage.U.end(), 0);
|
||||
std::fill(storage.I.begin(), storage.I.end(), 0);
|
||||
std::fill(storage.P.begin(), storage.P.end(), 0);
|
||||
std::fill(charge.U.begin(), charge.U.end(), 0);
|
||||
std::fill(charge.I.begin(), charge.I.end(), 0);
|
||||
std::fill(charge.P.begin(), charge.P.end(), 0);
|
||||
std::fill(pv.U.begin(), pv.U.end(), 0);
|
||||
std::fill(pv.I.begin(), pv.I.end(), 0);
|
||||
std::fill(pv.P.begin(), pv.P.end(), 0);
|
||||
}
|
||||
save = true;
|
||||
posCache = npos;
|
||||
}
|
||||
if (save)
|
||||
if (save && npos < storage.U.size())
|
||||
{
|
||||
mapCacheElectIn[npos] = Utils::random(100, 800); // dayElectIn
|
||||
mapCacheElectOut[npos] = Utils::random(100, 800); // dayElectOut
|
||||
mapCacheElectCharger[npos] = Utils::random(100, 800); // 暂无数据源
|
||||
storage.U[npos] = storage.voltage;
|
||||
storage.I[npos] = storage.current;
|
||||
storage.P[npos] = storage.power;
|
||||
|
||||
charge.U[npos] = charge.connector1.voltage;
|
||||
charge.I[npos] = charge.connector1.current;
|
||||
charge.P[npos] = charge.connector1.power;
|
||||
|
||||
//pv.U[npos];
|
||||
//pv.I[npos];
|
||||
//pv.P[npos];
|
||||
}
|
||||
}
|
||||
|
||||
static njson VectorToJsonArray(vector<float>& vec, int n)
|
||||
{
|
||||
//int v = Utils::random(40, 50);
|
||||
njson jsonArray = njson::array();
|
||||
for (int i = 0; i <= n && i < vec.size(); ++i)
|
||||
{
|
||||
jsonArray.push_back(int(vec[i]));
|
||||
//jsonArray.push_back(v + Utils::random(1, 6) -3);
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
void Station::writeStatistic()
|
||||
{
|
||||
auto dao = DaoEntity::create("history_day");
|
||||
@@ -603,15 +679,15 @@ void Station::writeStatistic()
|
||||
fields.set("station_id", this->stationId);
|
||||
fields.set("device_id", device->deviceId);
|
||||
fields.set("datatype", 1);
|
||||
fields.set("value", MapValueToJson(npos, device->mapCacheVoltage));
|
||||
fields.set("value", VectorToJsonArray(device->cacheU, npos));
|
||||
DAO::insertRuntimeData(dao, fields);
|
||||
|
||||
fields.set("datatype", 2);
|
||||
fields.set("value", MapValueToJson(npos, device->mapCacheCurrent));
|
||||
fields.set("value", VectorToJsonArray(device->cacheI, npos));
|
||||
DAO::insertRuntimeData(dao, fields);
|
||||
|
||||
fields.set("datatype", 3);
|
||||
fields.set("value", MapValueToJson(npos, device->mapCachePower));
|
||||
fields.set("value", VectorToJsonArray(device->cacheP, npos));
|
||||
DAO::insertRuntimeData(dao, fields);
|
||||
//spdlog::info("[device] write runtime date to database, deviceId={}", device->deviceId);
|
||||
}
|
||||
@@ -802,4 +878,10 @@ void Station::predict()
|
||||
// predictStorageOut[i] = v2 >= 0 ? v2 : 0;
|
||||
// predictCharge[i] = v3 >= 0 ? v3 : 0;
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Station::writeDeviceData()
|
||||
{
|
||||
}
|
||||
@@ -119,13 +119,16 @@ public:
|
||||
string getGatewayParam();
|
||||
|
||||
void readAlert(std::shared_ptr<Device> device, std::string addr, int v, std::string text);
|
||||
void readRuntimeData(int deviceNo, string addr, int val);
|
||||
void readEnergyData(int deviceNo, string addr, int val);
|
||||
void readChargeData(int deviceNo, string addr, int val);
|
||||
void readTHData(int deviceNo, string addr, int val);
|
||||
void readFire40Data(int deviceNo, string addr, int val);
|
||||
void readCoolingData(int deviceNo, string addr, int val);
|
||||
void readGatewayMode(int deviceNo, int mode, string p1, string p2, string p3);
|
||||
void readGatewayStatus(int deviceNo, int cdzStatus, int emuStatus);
|
||||
|
||||
void readTDData(int deviceNo);
|
||||
|
||||
void setCache(int datatype, std::vector<float>& vd);
|
||||
void cache();
|
||||
int posCache {0};
|
||||
@@ -135,6 +138,8 @@ public:
|
||||
|
||||
void predict();
|
||||
|
||||
void writeDeviceData();
|
||||
|
||||
public:
|
||||
int stationId {};
|
||||
std::string name;
|
||||
@@ -147,7 +152,6 @@ public:
|
||||
int err = 0;
|
||||
int online = 0;
|
||||
int running = 0;
|
||||
|
||||
bool isConnected {false};
|
||||
|
||||
int workMode {}; // 运行模式
|
||||
@@ -172,6 +176,83 @@ public:
|
||||
int overload {}; // 防过载回差 40059(1KW 10-300)
|
||||
} gatewayParam;
|
||||
|
||||
int cdzStatus{ -1 }; // 充电桩 1:在线,0:离线
|
||||
int emuStatus{ -1 }; // 储能 1:在线,0:离线
|
||||
int pvStatus{ -1 };
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// === 储能相关数据 ===
|
||||
struct {
|
||||
int ts; // 数据更新时间戳(通讯)
|
||||
int num = 1; // 储能设备的数量(储能仓的个数)
|
||||
|
||||
int status = 0; // 储能设备状态: 0:离线,1:空闲,2:充电,3:放电,9:故障
|
||||
|
||||
int voltage = 0;
|
||||
int current = 0;
|
||||
int power = 0;
|
||||
float powerFactor = 0;
|
||||
|
||||
vector<int> U; // 电压曲线(144个点位)
|
||||
vector<int> I; // 电流曲线(144个点位)
|
||||
vector<int> P; // 功率曲线(144个点位)
|
||||
|
||||
} storage;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// === 充电相关数据 ===
|
||||
struct {
|
||||
int ts; // 数据更新时间戳(通讯)
|
||||
int num = 1; // 充电设备的数量
|
||||
int status = 0; // 充电设备状态: 0:离线,1:空闲,2:充电,9:故障
|
||||
|
||||
struct {
|
||||
int isCharge = 0;
|
||||
int voltage = 0;
|
||||
int current = 0;
|
||||
int power = 0;
|
||||
int powerLimit = 0;
|
||||
} connector1;
|
||||
|
||||
struct {
|
||||
int isCharge = 0;
|
||||
int voltage = 0;
|
||||
int current = 0;
|
||||
int power = 0;
|
||||
int powerLimit = 0;
|
||||
} connector2;
|
||||
|
||||
vector<int> U; // 电压曲线(144个点位)
|
||||
vector<int> I; // 电流曲线(144个点位)
|
||||
vector<int> P; // 功率曲线(144个点位)
|
||||
} charge;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// === 光伏相关数据 ===
|
||||
struct {
|
||||
int ts; // 数据更新时间戳(通讯)
|
||||
int status = 0; // 充电设备状态: 0:离线,1:空闲,2:发电,9:故障
|
||||
int voltage = 0;
|
||||
int current = 0;
|
||||
int power = 0;
|
||||
vector<int> U; // 电压曲线(144个点位)
|
||||
vector<int> I; // 电流曲线(144个点位)
|
||||
vector<int> P; // 功率曲线(144个点位)
|
||||
} pv;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// === 电网相关数据 ===
|
||||
struct {
|
||||
int status = 0; // 充电设备状态: 0:离线,1:空闲,2:发电,9:故障
|
||||
|
||||
int voltage = 0;
|
||||
int current = 0;
|
||||
int power = 0;
|
||||
float powerFactor = 0;
|
||||
//vector<int> U; // 电压曲线(144个点位)
|
||||
//vector<int> I; // 电流曲线(144个点位)
|
||||
vector<int> P; // 功率曲线(144个点位)
|
||||
} grid;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// === 系统统计 ===
|
||||
// 累计发电量,单位:kWh
|
||||
@@ -202,10 +283,10 @@ public:
|
||||
double humidity {};
|
||||
int aircStatus {0};
|
||||
int coolingStatus {0};
|
||||
double voltage {0};
|
||||
double current {0};
|
||||
double power {0};
|
||||
double powerFactor {0};
|
||||
//double voltage {0};
|
||||
//double current {0};
|
||||
//double power {0};
|
||||
//double powerFactor {0};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// === 设备信息 ===
|
||||
@@ -272,12 +353,8 @@ public:
|
||||
} runtimeData;
|
||||
|
||||
|
||||
int cdzStatus {-1}; // 充电桩 1:在线,0:离线
|
||||
int emuStatus {-1}; // 储能 1:在线,0:离线
|
||||
|
||||
std::map<std::string, int64_t> mapAlertCache;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// 说明:从电表中读取对应数据:每间隔600秒(10分钟)缓存一个点位,存储到数据库,用于绘制一天的电曲线
|
||||
// 储能充电量缓存,key:位置索引(0->144),val:电量
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
{
|
||||
stringstream ss;
|
||||
ss.precision(precision);
|
||||
ss << val;
|
||||
ss << std::fixed << val;
|
||||
mapFields[key] = ss.str();
|
||||
}
|
||||
|
||||
|
||||
@@ -443,6 +443,11 @@ Errcode DAO::queryDeviceList(PageInfo& pageInfo, vector<Fields>& result)
|
||||
std::string sqlFrom = "FROM device d LEFT JOIN station s ON d.station_id =s.station_id";
|
||||
return QueryPagination("d.*, s.name station_name", sqlFrom, pageInfo, result);
|
||||
}
|
||||
Errcode DAO::queryDeviceListByStation(PageInfo& pageInfo, string stationId, vector<Fields>& result)
|
||||
{
|
||||
std::string sqlFrom = "FROM device d LEFT JOIN station s ON d.station_id =s.station_id WHERE d.station_id='" + stationId + "'";
|
||||
return QueryPagination("d.*, s.name station_name", sqlFrom, pageInfo, result);
|
||||
}
|
||||
|
||||
// 查询设备类型定义
|
||||
Errcode DAO::queryDeviceTypeDef(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
|
||||
@@ -74,6 +74,8 @@ public:
|
||||
|
||||
// 查询设备信息列表(分页)
|
||||
static Errcode queryDeviceList(PageInfo& pageInfo, vector<Fields>& result);
|
||||
// 查询设备信息列表(分页)
|
||||
static Errcode queryDeviceListByStation(PageInfo& pageInfo, string stationId, vector<Fields>& result);
|
||||
// 查询设备信息列表
|
||||
static Errcode queryDeviceList(std::shared_ptr<DaoEntity> dao, vector<Fields>& result, bool sort=false);
|
||||
// 查询设备类型定义
|
||||
@@ -112,16 +114,10 @@ public:
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// === 统计数据管理 ===
|
||||
static Errcode queryStatDataList(std::shared_ptr<DaoEntity> dao, std::string startDate, std::string endDate, vector<Fields>& result);
|
||||
|
||||
static Errcode queryStatStationGroup(std::shared_ptr<DaoEntity> dao, string stationId, string category, string startDate, string endDate, vector<Fields>& result);
|
||||
|
||||
static Errcode queryStatStationList(PageInfo& pageInfo, Fields& params, vector<Fields>& result);
|
||||
|
||||
static Errcode queryWorkModeDef(std::shared_ptr<DaoEntity> dao, vector<Fields>& result);
|
||||
|
||||
static Errcode queryPolicyTypeDef(std::shared_ptr<DaoEntity> dao, vector<Fields>& result);
|
||||
|
||||
|
||||
static Errcode insertStatDay(std::shared_ptr<DaoEntity> dao, Fields& fields);
|
||||
|
||||
|
||||
|
||||
@@ -177,7 +177,6 @@ int main(int argc, char** argv)
|
||||
//OpensslSM2_test();
|
||||
//SM2_test();
|
||||
|
||||
|
||||
// 初始化日志
|
||||
Spdlogger::init(spdlog::level::info, "");
|
||||
spdlog::info("[main] start ... ======================================================================");
|
||||
@@ -192,7 +191,7 @@ int main(int argc, char** argv)
|
||||
QApplication qapp(argc, argv);
|
||||
QString fontFile = QCoreApplication::applicationDirPath() + "/assets/fonts/优设标题黑.ttf";
|
||||
QFontDatabase::addApplicationFont(fontFile);
|
||||
QFont font("微软雅黑", 10, 600);
|
||||
QFont font("Cascadia Code, Microsoft YaHei", 10, 600);
|
||||
QApplication::setFont(font);
|
||||
MainApp mainApp;
|
||||
return qapp.exec();
|
||||
|
||||
@@ -159,7 +159,10 @@ static std::map<std::string, HandlerOptions> g_mapHttpHandlerGet =
|
||||
{"/queryStationData", HandlerOptions(&HttpEntity::queryStationData, { DMStation::STATION_ID})},
|
||||
{"/queryStationOverview", HandlerOptions(&HttpEntity::queryStationOverview, {DMStation::STATION_ID})},
|
||||
|
||||
|
||||
{"/queryStationTodayU", HandlerOptions(&HttpEntity::queryStationTodayU, {DMStation::STATION_ID, "category"})},
|
||||
{"/queryStationTodayI", HandlerOptions(&HttpEntity::queryStationTodayI, {DMStation::STATION_ID, "category"})},
|
||||
{"/queryStationTodayP", HandlerOptions(&HttpEntity::queryStationTodayP, {DMStation::STATION_ID, "category"})},
|
||||
|
||||
{"/queryDeviceList", HandlerOptions(&HttpEntity::queryDeviceList, {})},
|
||||
{"/deleteDevice", HandlerOptions(&HttpEntity::deleteDevice, { DMDevice::DEVICE_ID})},
|
||||
{"/queryDevicTypeDef", HandlerOptions(&HttpEntity::queryDevicTypeDef, {})},
|
||||
@@ -823,28 +826,120 @@ Errcode HttpEntity::queryStationData(const httplib::Request& req, njson& json, s
|
||||
njson jsondata;
|
||||
if (station)
|
||||
{
|
||||
// 温度, 电压、电流、功率、功率因数、
|
||||
jsondata["voltage"] = Utils::toStr(station->voltage, 0);
|
||||
jsondata["current"] = Utils::toStr(station->current, 0);
|
||||
jsondata["power"] = Utils::toStr(station->power, 0);
|
||||
jsondata["powerFactor"] = Utils::toStr(station->powerFactor, 0);
|
||||
jsondata["envTemp"] = Utils::toStr(station->temperature, 0);
|
||||
jsondata["envhum"] = Utils::toStr(station->humidity, 0);
|
||||
jsondata["aircStatus"] = station->aircStatus;
|
||||
jsondata["coolingStatus"] = station->coolingStatus;
|
||||
/// 储能:电压、电流、功率、功率因数
|
||||
{
|
||||
njson json = njson::object();
|
||||
json["U"] = Utils::toStr(station->storage.voltage);
|
||||
json["I"] = Utils::toStr(station->storage.current);
|
||||
json["P"] = Utils::toStr(station->storage.power);
|
||||
//json["PF"] = Utils::toStr(station->storage.powerFactor, 1);
|
||||
jsondata["storage"] = json;
|
||||
}
|
||||
/// 充电:电压、电流、功率、功率因数
|
||||
{
|
||||
njson json = njson::object();
|
||||
json["U"] = Utils::toStr(station->charge.connector1.voltage);
|
||||
json["I"] = Utils::toStr(station->charge.connector1.current);
|
||||
json["P"] = Utils::toStr(station->charge.connector1.power);
|
||||
jsondata["charge"] = json;
|
||||
}
|
||||
/// 光伏
|
||||
{
|
||||
njson json = njson::object();
|
||||
json["P"] = Utils::toStr(station->pv.power);
|
||||
jsondata["pv"] = json;
|
||||
}
|
||||
/// 电网
|
||||
{
|
||||
njson json = njson::object();
|
||||
json["U"] = Utils::toStr(station->grid.voltage);
|
||||
json["I"] = Utils::toStr(station->grid.current);
|
||||
json["P"] = Utils::toStr(station->grid.power);
|
||||
//json["PF"] = Utils::toStr(station->grid.powerFactor, 1);
|
||||
jsondata["grid"] = json;
|
||||
}
|
||||
|
||||
/// 环境:温度、湿度
|
||||
{
|
||||
njson json = njson::object();
|
||||
json["envTemp"] = Utils::toStr(station->temperature, 0);
|
||||
json["envhum"] = Utils::toStr(station->humidity, 0);
|
||||
json["aircStatus"] = station->aircStatus;
|
||||
json["coolingStatus"] = station->coolingStatus;
|
||||
jsondata["env"] = json;
|
||||
}
|
||||
}
|
||||
json["data"] = jsondata;
|
||||
return Errcode::OK;
|
||||
}
|
||||
|
||||
static njson VectorToJsonArray(vector<float>& vec, int n)
|
||||
{
|
||||
njson jsonArray = njson::array();
|
||||
for (int i = 0; i <= n && i < vec.size(); ++i)
|
||||
{
|
||||
jsonArray.push_back(int(vec[i]));
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
// 获取场站今日电压曲线数据,category: 1:储能,2:充电,3:光伏
|
||||
Errcode HttpEntity::queryStationTodayU(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
std::string stationId = req.get_param_value("station_id");
|
||||
std::string catogray = req.get_param_value("category");
|
||||
njson jsondata;
|
||||
|
||||
auto station = Application::data().getStation(Utils::toInt(stationId));
|
||||
if (station)
|
||||
{
|
||||
int n = Utils::timeDaySeconds() / 600;
|
||||
if (catogray == "1")
|
||||
{
|
||||
auto device = station->getDeviceByType(int(EDeviceType::E_METER), "2");
|
||||
if (device) {
|
||||
jsondata["U"] = VectorToJsonArray(device->cacheU, n);
|
||||
jsondata["I"] = VectorToJsonArray(device->cacheI, n);
|
||||
jsondata["P"] = VectorToJsonArray(device->cacheP, n);
|
||||
}
|
||||
}
|
||||
else if (catogray == "2")
|
||||
{
|
||||
auto device = station->getDeviceByType(int(EDeviceType::CHARGER), "1");
|
||||
if (device) {
|
||||
jsondata["U"] = VectorToJsonArray(device->cacheU, n);
|
||||
jsondata["I"] = VectorToJsonArray(device->cacheI, n);
|
||||
jsondata["P"] = VectorToJsonArray(device->cacheP, n);
|
||||
}
|
||||
}
|
||||
else if (catogray == "3")
|
||||
{
|
||||
}
|
||||
}
|
||||
json["data"] = jsondata;
|
||||
return Errcode::OK;
|
||||
}
|
||||
|
||||
// 获取场站今日电流曲线数据,category: 1:储能,2:充电,3:光伏
|
||||
Errcode HttpEntity::queryStationTodayI(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
return Errcode::OK;
|
||||
}
|
||||
|
||||
// 获取场站今日功率曲线数据,category: 1:储能,2:充电,3:光伏
|
||||
Errcode HttpEntity::queryStationTodayP(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
return Errcode::OK;
|
||||
}
|
||||
|
||||
Errcode HttpEntity::queryDeviceList(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
PageInfo pageinfo;
|
||||
pageinfo.index = Utils::toInt(req.get_param_value("page"));
|
||||
pageinfo.size = Utils::toInt(req.get_param_value("page_size"));
|
||||
|
||||
string stationId = req.get_param_value("station_id");
|
||||
std::vector<Fields> result;
|
||||
auto err = DAO::queryDeviceList(pageinfo, result);
|
||||
auto err = DAO::queryDeviceListByStation(pageinfo, stationId, result);
|
||||
HttpHelper::setPagination(pageinfo, result, json);
|
||||
return err;
|
||||
};
|
||||
@@ -983,14 +1078,20 @@ Errcode HttpEntity::queryDevicCharts(const httplib::Request& req, njson& json, s
|
||||
int deviceId = params.get<int>("device_id");
|
||||
auto device = Application::data().getDevice(stationId, deviceId);
|
||||
|
||||
std::vector<std::string> vecV, vecI, vecP;
|
||||
int npos = Utils::timeDaySeconds() / 600;
|
||||
std::vector<int> vecU(npos, 0);
|
||||
std::vector<int> vecI(npos, 0);
|
||||
std::vector<int> vecP(npos, 0);
|
||||
if (device)
|
||||
{
|
||||
device->getCacheVoltage(vecV);
|
||||
device->getCacheCurrent(vecI);
|
||||
device->getCachePower(vecP);
|
||||
for (size_t i = 0; i < npos; ++i)
|
||||
{
|
||||
if (i < device->cacheU.size()) vecU[i] = int(device->cacheU[i]);
|
||||
if (i < device->cacheI.size()) vecI[i] = int(device->cacheI[i]);
|
||||
if (i < device->cacheP.size()) vecP[i] = int(device->cacheP[i]);
|
||||
}
|
||||
}
|
||||
json["data"] = {{"V", vecV}, {"I", vecI}, {"P", vecP}};
|
||||
json["data"] = {{"V", vecU}, {"I", vecI}, {"P", vecP}};
|
||||
return Errcode::OK;
|
||||
}
|
||||
|
||||
@@ -1141,45 +1242,220 @@ Errcode HttpEntity::queryPredictionDetail(const httplib::Request& req, njson& js
|
||||
return Errcode::OK;
|
||||
}
|
||||
|
||||
static void VerifyRequstParamsStatDate(Fields& params)
|
||||
{
|
||||
if (!params.contains("end_date"))
|
||||
{
|
||||
if (!params.contains("start_date"))
|
||||
{
|
||||
params.set("end_date", Utils::dateStr());
|
||||
params.set("start_date", Utils::dateStr(Utils::date() - 86400 * 7));
|
||||
}
|
||||
else
|
||||
{
|
||||
params.set("end_date", Utils::dateStr(Utils::time(params.value("start_date") + " 00:00:00") + 86400 * 7));
|
||||
}
|
||||
}
|
||||
}
|
||||
static std::string VerifyStatSqlCondition(Fields& params)
|
||||
{
|
||||
std::string stationId = params.value("station_id");
|
||||
std::string category = params.value("category");
|
||||
std::string dtStart = params.value("start_date");
|
||||
std::string dtEnd = params.value("end_date");
|
||||
|
||||
std::string sqlCondition;
|
||||
if (!dtStart.empty() && dtEnd.empty())
|
||||
{
|
||||
sqlCondition += "dt BETWEEN '" + dtStart + "' AND '" + dtEnd + "'";
|
||||
}
|
||||
if (!stationId.empty())
|
||||
{
|
||||
if (!sqlCondition.empty()) sqlCondition += " AND ";
|
||||
sqlCondition += "ss.station_id='" + stationId + "'";
|
||||
}
|
||||
if (!category.empty() && category != "0")
|
||||
{
|
||||
//if (!sqlCondition.empty()) sqlCondition += " AND ";
|
||||
//sqlCondition += "ss.category='" + category + "'";;
|
||||
}
|
||||
if (!sqlCondition.empty()) { sqlCondition = " WHERE " + sqlCondition; }
|
||||
return sqlCondition;
|
||||
}
|
||||
static std::string GetRequestStatParams(const httplib::Request& req, Fields& params)
|
||||
{
|
||||
|
||||
GetRequestParams(req, { "station_id", "category", "start_date", "end_date" }, params);
|
||||
VerifyRequstParamsStatDate(params);
|
||||
return VerifyStatSqlCondition(params);
|
||||
}
|
||||
|
||||
static string GetStationStatusStr(int status)
|
||||
{
|
||||
if (status == 1) return "空闲";
|
||||
else if (status == 2) return "充电";
|
||||
else if (status == 2) return "放电";
|
||||
else if (status == 9) return "故障";
|
||||
else return "离线";
|
||||
}
|
||||
|
||||
Errcode HttpEntity::queryStatTotal(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
Fields params;
|
||||
std::string sqlCondition = GetRequestStatParams(req, params);
|
||||
|
||||
njson jsondata;
|
||||
std::string launchDate;
|
||||
float incomeTotal{};
|
||||
int storageDeviceNum = 0;
|
||||
int chargeDeviceNum = 0;
|
||||
int solarDeviceNum = 0;
|
||||
int capacityTotal{};
|
||||
|
||||
bool isQueryStation = params.contains("station_id");
|
||||
if (isQueryStation)
|
||||
{
|
||||
std::string stationId = params.value("station_id");
|
||||
auto station = Application::data().getStation(Utils::toInt(stationId));
|
||||
if (station)
|
||||
{
|
||||
launchDate = station->launchDate;
|
||||
storageDeviceNum = 1; //: 储能设备数量
|
||||
chargeDeviceNum = station->getDeviceCount(2); //: 光伏设备数量
|
||||
solarDeviceNum = station->getDeviceCount(3); //: 光伏设备数量
|
||||
capacityTotal = station->capacity; // : 储能总容量(kWh),精度0.001
|
||||
jsondata["storage_status"] = GetStationStatusStr(station->storage.status);
|
||||
jsondata["charge_status"] = GetStationStatusStr(station->charge.status);
|
||||
jsondata["pv_status"] = "离线";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& appdata = Application::data();
|
||||
launchDate = appdata.launchDate; //: 系统上线启用日期,格式:yyyy-mm-dd
|
||||
for (auto& item : appdata.mapStation)
|
||||
{
|
||||
auto& station = item.second;
|
||||
storageDeviceNum += 1;
|
||||
chargeDeviceNum += station->getDeviceCount(2);
|
||||
solarDeviceNum += station->getDeviceCount(3);
|
||||
capacityTotal += station->capacity;
|
||||
}
|
||||
}
|
||||
|
||||
jsondata["launch_date"] = launchDate; // 场站上线启用日期,格式:yyyy-mm-dd
|
||||
jsondata["storage_device_num"] = storageDeviceNum; //: 储能设备数量
|
||||
jsondata["charge_device_num"] = chargeDeviceNum; //: 储能设备数量
|
||||
jsondata["income_total"] = incomeTotal; // : 累计收益(元),精度0.01
|
||||
jsondata["solar_device_num"] = solarDeviceNum; //: 光伏设备数量
|
||||
jsondata["capacity_total"] = capacityTotal; // : 储能总容量(kWh),精度0.001
|
||||
|
||||
|
||||
|
||||
// 从 stat_total 表中查询日期最新的一条数据
|
||||
std::vector<Fields> result;
|
||||
std::string sql = std::format("SELECT st.* FROM stat_total st INNER JOIN "
|
||||
"(SELECT station_id, MAX(dt) max_dt FROM stat_total ss {} GROUP BY station_id) tmp "
|
||||
"ON st.station_id = tmp.station_id AND st.dt = tmp.max_dt; ", sqlCondition);
|
||||
DaoEntity::execOnce(sql, result);
|
||||
|
||||
int eIn = 0;
|
||||
int eOut = 0;
|
||||
int tIn = 0;
|
||||
int tOut = 0;
|
||||
int nErr = 0;
|
||||
int eGen = 0;
|
||||
int eGrid = 0;
|
||||
int eCharge = 0;
|
||||
int income = 0;
|
||||
int incomeCharge = 0;
|
||||
for (int i=0; i<result.size(); ++i)
|
||||
{
|
||||
auto& fields = result[i];
|
||||
if (isQueryStation)
|
||||
{
|
||||
if (params.value("station_id") == fields.value("station_id"))
|
||||
{
|
||||
eIn = fields.get<int>("E_in");
|
||||
eOut = fields.get<int>("E_out");
|
||||
tIn = fields.get<int>("t_in");
|
||||
tOut = fields.get<int>("t_out");
|
||||
eGen = fields.get<int>("E_gen");
|
||||
eGrid = fields.get<int>("E_grid");
|
||||
eCharge = fields.get<int>("E_charge");
|
||||
income = fields.get<int>("income");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eIn += fields.get<int>("E_in");
|
||||
eOut += fields.get<int>("E_out");
|
||||
tIn += fields.get<int>("t_in");
|
||||
tOut += fields.get<int>("t_out");
|
||||
eGen += fields.get<int>("E_gen");
|
||||
eGrid = fields.get<int>("E_grid");
|
||||
eCharge += fields.get<int>("E_charge");
|
||||
income += fields.get<int>("income");
|
||||
}
|
||||
}
|
||||
|
||||
jsondata["storage_elect_in"] = eIn; //储能充电电量(kWh),精度:0.001
|
||||
jsondata["storage_elect_out"] = eOut; //储能放电电量(kWh),精度:0.001
|
||||
jsondata["storage_num_in"] = tIn; //储能设备充电次数
|
||||
jsondata["storage_num_out"] = tOut; //储能设备放电次数
|
||||
//jsondata["storage_num_err"] = fields.value("n_err"); //储能设备故障次数
|
||||
jsondata["solar_elect_gen"] = eGen; //光伏发电电量(kWh),精度:0.001
|
||||
jsondata["solar_elect_grid"] = eGrid; //光伏入网电量(kWh),精度:0.001
|
||||
//jsondata["solar_num_err"] = fields.value("n_err_solor"); //光伏设备故障次数
|
||||
jsondata["charge_elect"] = eCharge; //充电设备充电电量(kWh),精度:0.001
|
||||
//jsondata["charge_num"] = fields.value("n_charge"); //充电设备充电次数
|
||||
//jsondata["charge_num_err"] = fields.value("n_err_charge"); //充电设备故障次数
|
||||
jsondata["income_elect"] = income; //发电收益(元),精度:0.01
|
||||
//jsondata["income_charge"] = fields.value("income_charge"); //充电收益(元),精度:0.01
|
||||
//jsondata["usage_rate"] = 0; //Utils::toStr(float(fields.get<int>("storage_usage") + fields.get<int>("storage_usage")) * 0.5f, 0);
|
||||
json["data"] = jsondata;
|
||||
|
||||
return Errcode::OK;
|
||||
}
|
||||
|
||||
|
||||
Errcode HttpEntity::queryStatSystem(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
auto& appdata = Application::data();
|
||||
|
||||
float incomeTotal {};
|
||||
float station_num = appdata.getStationCount();
|
||||
float solarDeviceNum {};
|
||||
float capacityTotal {};
|
||||
float electGenTotal {};
|
||||
float electGridTotal {};
|
||||
float electStorageIn {};
|
||||
float electStorageOut {};
|
||||
float income = 0.0;
|
||||
int nStation = 0;
|
||||
int nSolar {};
|
||||
int capacity {};
|
||||
int eGen {};
|
||||
int eGrid {};
|
||||
int eIn {};
|
||||
int eOut {};
|
||||
for (auto& item : appdata.mapStation)
|
||||
{
|
||||
auto& station = item.second;
|
||||
solarDeviceNum += station->getDeviceCount(3);
|
||||
capacityTotal += station->capacity;
|
||||
electGenTotal += station->electGenTotal;
|
||||
electGridTotal += station->electGridTotal;
|
||||
electStorageIn += station->electStorageIn;
|
||||
electStorageOut += station->electStorageOut;
|
||||
nStation += 1;
|
||||
nSolar += station->getDeviceCount(3);
|
||||
capacity += station->capacity;
|
||||
eGen += station->electGenTotal;
|
||||
eGrid += station->electGridTotal;
|
||||
eIn += station->statData.totalElectIn;
|
||||
eOut += station->statData.totalElectOut;
|
||||
}
|
||||
|
||||
float income = 0.0;
|
||||
|
||||
njson jsondata;
|
||||
jsondata["launch_date"] = appdata.launchDate; //: 系统上线启用日期,格式:yyyy-mm-dd
|
||||
jsondata["income_total"] = incomeTotal; // : 累计收益(元),精度0.01
|
||||
jsondata["station_num"] = station_num; // : 能源站数量
|
||||
jsondata["storage_device_num"] = station_num; //: 储能设备数量
|
||||
jsondata["solar_device_num"] = solarDeviceNum; //: 光伏设备数量
|
||||
jsondata["capacity_total"] = capacityTotal; // : 储能总容量(kWh),精度0.001
|
||||
jsondata["solar_elect_gen"] = electGenTotal; // : 发电总电量(kWh),精度0.001
|
||||
jsondata["solar_elect_grid"] = electGridTotal; // : 入网种电量(kWh),精度0.001
|
||||
jsondata["storage_elect_in"] = electStorageIn; // : 储能充电总电量(kWh),精度0.001
|
||||
jsondata["storage_elect_out"] = electStorageOut; // : 储能放电总电量(kWh),精度0.001
|
||||
jsondata["income_total"] = income; // : 累计收益(元),精度0.01
|
||||
jsondata["storage_device_num"] = nStation; //: 储能设备数量
|
||||
jsondata["solar_device_num"] = nSolar; //: 光伏设备数量
|
||||
jsondata["capacity_total"] = capacity; // : 储能总容量(kWh),精度0.001
|
||||
jsondata["solar_elect_gen"] = eGen; // : 发电总电量(kWh),精度0.001
|
||||
jsondata["solar_elect_grid"] = eGrid; // : 入网总电量(kWh),精度0.001
|
||||
jsondata["storage_elect_in"] = eIn; // : 储能充电总电量(kWh),精度0.001
|
||||
jsondata["storage_elect_out"] = eOut; // : 储能放电总电量(kWh),精度0.001
|
||||
|
||||
// 总览页面:累计收益
|
||||
std::string sql = "SELECT * FROM stat_total st INNER JOIN "
|
||||
std::string sql = "SELECT st.* FROM stat_total st INNER JOIN "
|
||||
"(SELECT station_id, MAX(dt) max_dt FROM stat_total GROUP BY station_id) tmp "
|
||||
"ON st.station_id = tmp.station_id AND st.dt = tmp.max_dt; ";
|
||||
std::vector<Fields> result;
|
||||
@@ -1216,119 +1492,7 @@ Errcode HttpEntity::queryStatStationGroup(const httplib::Request& req, njson& js
|
||||
return Errcode(err);
|
||||
}
|
||||
|
||||
static void VerifyRequstParamsStatDate(Fields& params)
|
||||
{
|
||||
if (!params.contains("end_date"))
|
||||
{
|
||||
if (!params.contains("start_date"))
|
||||
{
|
||||
params.set("end_date", Utils::dateStr());
|
||||
params.set("start_date", Utils::dateStr(Utils::date() - 86400*7));
|
||||
}
|
||||
else
|
||||
{
|
||||
params.set("end_date", Utils::dateStr(Utils::time(params.value("start_date") +" 00:00:00") + 86400*7));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static std::string VerifyStatSqlCondition(Fields& params)
|
||||
{
|
||||
std::string stationId = params.value("station_id");
|
||||
std::string category = params.value("category");
|
||||
std::string dtStart = params.value("start_date");
|
||||
std::string dtEnd = params.value("end_date");
|
||||
|
||||
std::string sqlCondition;
|
||||
if (!dtStart.empty() && dtEnd.empty())
|
||||
{
|
||||
sqlCondition += "dt BETWEEN '" + dtStart + "' AND '" + dtEnd + "'";
|
||||
}
|
||||
if (!stationId.empty())
|
||||
{
|
||||
if (!sqlCondition.empty()) sqlCondition += " AND ";
|
||||
sqlCondition += "ss.station_id='" + stationId + "'";
|
||||
}
|
||||
if (!category.empty() && category != "0")
|
||||
{
|
||||
//if (!sqlCondition.empty()) sqlCondition += " AND ";
|
||||
//sqlCondition += "ss.category='" + category + "'";;
|
||||
}
|
||||
if (!sqlCondition.empty()) { sqlCondition = " WHERE " + sqlCondition; }
|
||||
return sqlCondition;
|
||||
}
|
||||
|
||||
static std::string GetRequestStatParams(const httplib::Request& req, Fields& params)
|
||||
{
|
||||
|
||||
GetRequestParams(req, {"station_id", "category", "start_date", "end_date"}, params);
|
||||
VerifyRequstParamsStatDate(params);
|
||||
return VerifyStatSqlCondition(params);
|
||||
}
|
||||
|
||||
Errcode HttpEntity::queryStatTotal(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
Fields params;
|
||||
std::string sqlCondition = GetRequestStatParams(req, params);
|
||||
//std::string sql = R"(SELECT
|
||||
// SUM(storage_elect_in) storage_elect_in,
|
||||
// SUM(storage_elect_out) storage_elect_out,
|
||||
// SUM(storage_num_in) storage_num_in,
|
||||
// SUM(storage_num_out) storage_num_out,
|
||||
// SUM(storage_num_err) storage_num_err,
|
||||
// SUM(solar_elect_gen) solar_elect_gen,
|
||||
// SUM(solar_elect_grid) solar_elect_grid,
|
||||
// SUM(solar_num_err) solar_num_err,
|
||||
// AVG(storage_usage) storage_usage,
|
||||
// SUM(charge_elect) charge_elect,
|
||||
// SUM(charge_num) charge_num,
|
||||
// SUM(charge_num_err) charge_num_err,
|
||||
// AVG(charge_usage) charge_usage,
|
||||
// SUM(income_elect) income_elect,
|
||||
// SUM(income_charge) income_charge
|
||||
// FROM stat_day ss)" + sqlCondition + ";";
|
||||
|
||||
std::string stationId = params.value("station_id");
|
||||
|
||||
njson jsondata;
|
||||
|
||||
auto station = Application::data().getStation(Utils::toInt(stationId));
|
||||
if (station)
|
||||
{
|
||||
jsondata["launch_date"] = station->launchDate;
|
||||
}
|
||||
|
||||
auto& appdata = Application::data();
|
||||
std::vector<Fields> result;
|
||||
std::string sql = std::format("SELECT * FROM stat_total st INNER JOIN "
|
||||
"(SELECT station_id, MAX(dt) max_dt FROM stat_total ss {} GROUP BY station_id) tmp "
|
||||
"ON st.station_id = tmp.station_id AND st.dt = tmp.max_dt; ", sqlCondition);
|
||||
DaoEntity::execOnce(sql, result);
|
||||
if (result.size() > 0)
|
||||
{
|
||||
auto& fields = result[0];
|
||||
|
||||
//jsondata["launch_date"] = appdata.launchDate; //: 系统上线启用日期,格式:yyyy-mm-dd
|
||||
// jsondata["station_id"] = station_id;
|
||||
jsondata["storage_elect_in"] = fields.value("E_in"); //储能充电电量(kWh),精度:0.001
|
||||
jsondata["storage_elect_out"] = fields.value("E_out"); //储能放电电量(kWh),精度:0.001
|
||||
jsondata["storage_num_in"] = fields.value("t_in"); //储能设备充电次数
|
||||
jsondata["storage_num_out"] = fields.value("t_out"); //储能设备放电次数
|
||||
jsondata["storage_num_err"] = fields.value("n_err"); //储能设备故障次数
|
||||
jsondata["solar_elect_gen"] = fields.value("E_gen"); //光伏发电电量(kWh),精度:0.001
|
||||
jsondata["solar_elect_grid"] = fields.value("E_grid"); //光伏入网电量(kWh),精度:0.001
|
||||
jsondata["solar_num_err"] = fields.value("n_err_solor"); //光伏设备故障次数
|
||||
jsondata["charge_elect"] = fields.value("E_charge"); //充电设备充电电量(kWh),精度:0.001
|
||||
jsondata["charge_num"] = fields.value("n_charge"); //充电设备充电次数
|
||||
jsondata["charge_num_err"] = fields.value("n_err_charge"); //充电设备故障次数
|
||||
jsondata["income_elect"] = fields.value("income"); //发电收益(元),精度:0.01
|
||||
jsondata["income_charge"] = fields.value("income_charge"); //充电收益(元),精度:0.01
|
||||
jsondata["usage_rate"] = 0; //Utils::toStr(float(fields.get<int>("storage_usage") + fields.get<int>("storage_usage")) * 0.5f, 0);
|
||||
json["data"] = jsondata;
|
||||
}
|
||||
|
||||
return Errcode::OK;
|
||||
}
|
||||
Errcode HttpEntity::queryStatDayList(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
Fields params;
|
||||
@@ -1362,6 +1526,7 @@ Errcode HttpEntity::queryStatDayList(const httplib::Request& req, njson& json, s
|
||||
njson jsondata = njson::array();
|
||||
for (int64_t t = t0; t<=t1; t += 86400)
|
||||
{
|
||||
i++;
|
||||
njson jsonrow;
|
||||
std::string dt = Utils::dateStr(t);
|
||||
Fields* fields = NULL;
|
||||
@@ -1369,21 +1534,21 @@ Errcode HttpEntity::queryStatDayList(const httplib::Request& req, njson& json, s
|
||||
if (iter != mapTemp.end()) { fields = iter->second; }
|
||||
|
||||
jsonrow["dt"] = dt.substr(5);
|
||||
jsonrow["storage_elect_in"] = fields ? fields->value("storage_elect_in") : "0";
|
||||
jsonrow["storage_elect_in"] = fields ? fields->value("storage_elect_in") : "0";
|
||||
jsonrow["storage_elect_out"] = fields ? fields->value("storage_elect_out") : "0";
|
||||
jsonrow["storage_num_in"] = fields ? fields->value("storage_num_in") : "0";
|
||||
jsonrow["storage_num_out"] = fields ? fields->value("storage_num_out") : "0";
|
||||
jsonrow["storage_num_err"] = fields ? fields->value("storage_num_err") : "0";
|
||||
jsonrow["solar_elect_gen"] = fields ? fields->value("solar_elect_gen") : "0";
|
||||
jsonrow["solar_elect_grid"] = fields ? fields->value("solar_elect_grid") : "0";
|
||||
jsonrow["solar_num_err"] = fields ? fields->value("solar_num_err") : "0";
|
||||
jsonrow["storage_usage"] = fields ? fields->value("storage_usage") : "0";
|
||||
jsonrow["charge_elect"] = fields ? fields->value("charge_elect") : "0";
|
||||
jsonrow["charge_num"] = fields ? fields->value("charge_num") : "0";
|
||||
jsonrow["charge_num_err"] = fields ? fields->value("charge_num_err") : "0";
|
||||
jsonrow["charge_usage"] = fields ? fields->value("charge_usage") : "0";
|
||||
jsonrow["income_elect"] = fields ? fields->value("income_elect") : "0";
|
||||
jsonrow["income_charge"] = fields ? fields->value("income_charge") : "0";
|
||||
jsonrow["storage_num_in"] = fields ? fields->value("storage_num_in") : "0";
|
||||
jsonrow["storage_num_out"] = fields ? fields->value("storage_num_out") : "0";
|
||||
jsonrow["storage_num_err"] = fields ? fields->value("storage_num_err") : "0";
|
||||
jsonrow["solar_elect_gen"] = fields ? fields->value("solar_elect_gen") : "0";
|
||||
jsonrow["solar_elect_grid"] = fields ? fields->value("solar_elect_grid") : "0";
|
||||
jsonrow["solar_num_err"] = fields ? fields->value("solar_num_err") : "0";
|
||||
jsonrow["storage_usage"] = fields ? fields->value("storage_usage") : "0";
|
||||
jsonrow["charge_elect"] = fields ? fields->value("charge_elect") : "0";
|
||||
jsonrow["charge_num"] = fields ? fields->value("charge_num") : "0";
|
||||
jsonrow["charge_num_err"] = fields ? fields->value("charge_num_err") : "0";
|
||||
jsonrow["charge_usage"] = fields ? fields->value("charge_usage") : "0";
|
||||
jsonrow["income_elect"] = fields ? fields->value("income_elect") : "0";
|
||||
jsonrow["income_charge"] = fields ? fields->value("income_charge") : "0";
|
||||
jsondata.push_back(jsonrow);
|
||||
}
|
||||
json["data"] = jsondata;
|
||||
|
||||
@@ -55,9 +55,24 @@ public:
|
||||
Errcode deleteStation(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
Errcode queryStationOverview(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
/// 查询场站信息
|
||||
// @param: station_id
|
||||
// @return: object
|
||||
Errcode queryStationInfo(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
/// 查询场站信息
|
||||
// @param: station_id
|
||||
// @return: object
|
||||
Errcode queryStationData(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
// 获取场站今日电压曲线数据,category: 1:储能,2:充电,3:光伏
|
||||
Errcode queryStationTodayU(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
// 获取场站今日电流曲线数据,category: 1:储能,2:充电,3:光伏
|
||||
Errcode queryStationTodayI(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
// 获取场站今日功率曲线数据,category: 1:储能,2:充电,3:光伏
|
||||
Errcode queryStationTodayP(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
Errcode queryDeviceList(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
Errcode insertDevice(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
Errcode updateDevice(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
@@ -83,12 +98,14 @@ public:
|
||||
|
||||
Errcode queryPredictionDetail(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
// 系统总览所有场站统计 (总览页 运行状况)
|
||||
Errcode queryStatSystem(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
Errcode queryStatStationGroup(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
// 一个场站的累计统计
|
||||
/// 总览: 查询累计统计信息
|
||||
// @param: station_id 可选,无该参数时查询所有场站累计数据
|
||||
Errcode queryStatTotal(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
// 总览: 所有场站统计 (总览页 运行状况)
|
||||
Errcode queryStatSystem(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
Errcode queryStatStationGroup(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
// 场站按类别按天统计
|
||||
Errcode queryStatDayList(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
|
||||
@@ -408,7 +408,8 @@ void MqttClient::ParseArrivedMessage(njson& json, string command, std::shared_pt
|
||||
}
|
||||
device->setParam(addr, val);
|
||||
|
||||
if (command == "MEM_YC") { station->readRuntimeData(deviceNo, addr, val); }
|
||||
if (command == "MEM_YC") { station->readEnergyData(deviceNo, addr, val); }
|
||||
else if (command == "Charger_YC") { station->readChargeData(deviceNo, addr, val); }
|
||||
else if (command == "Fire40_YX") { station->readFire40Data(deviceNo, addr, val); }
|
||||
else if (command == "TH_YC") { station->readTHData(deviceNo, addr, val); }
|
||||
else if (command == "Cooling_YX" || command == "Cooling_YC") { station->readCoolingData(deviceNo, addr, val); }
|
||||
|
||||
@@ -18,7 +18,7 @@ MainApp::MainApp()
|
||||
this->setAutoFillBackground(true);
|
||||
this->setPalette(palette);
|
||||
this->setStyleSheet("color: white;");
|
||||
this->setFixedSize(1440, 900);
|
||||
this->setFixedSize(1600, 900);
|
||||
this->show();
|
||||
this->setAttribute(Qt::WA_StyledBackground, true); // 启用样式表背景绘制
|
||||
|
||||
@@ -43,6 +43,7 @@ QPushButton* MainApp::addMenuItem(int index, string itemName)
|
||||
{
|
||||
auto itemBtn = new QPushButton(itemName.c_str());
|
||||
itemBtn->setStyleSheet(QSS_BTN_MENU.c_str());
|
||||
//itemBtn->setFont(QFont("微软雅黑", 16, 600));
|
||||
mapMenuBtn[itemName] = itemBtn;
|
||||
QObject::connect(itemBtn, &QPushButton::clicked, this, [=]() { this->setActiveMenu(itemName); });
|
||||
|
||||
|
||||
@@ -40,8 +40,9 @@ static const std::string QSS_TABLE =
|
||||
"QTableWidget {"
|
||||
" background-color: transparent;" // 背景色
|
||||
" gridline-color: #C0C0C0;" // 网格线颜色
|
||||
" border: 1px solid gray;" // 边框
|
||||
" color: white;" // 文字颜色
|
||||
" border: 1px solid gray;" // 边框
|
||||
" color: white;" // 文字颜色
|
||||
" outline: 2px solid #409EFF;" // 选中焦点轮廓
|
||||
"}"
|
||||
// 表头样式
|
||||
"QHeaderView { background-color: rgba(150,150,150,50);}"
|
||||
@@ -60,7 +61,6 @@ static const std::string QSS_TABLE =
|
||||
"QTableWidget::item:selected {"
|
||||
" background-color: rgba(184, 214, 255, 50);" // 选中背景色
|
||||
" color: rgb(220,220,220);" // 选中文字颜色
|
||||
" outline: none; "
|
||||
"}";
|
||||
|
||||
static const std::string QSS_BTN_COMBOX =
|
||||
@@ -128,7 +128,7 @@ std::shared_ptr<QTableWidget> MyQUI::TableWidget(QWidget* parent, int x, int y,
|
||||
table->setSelectionMode(QAbstractItemView::SingleSelection); // 设置为单选模式
|
||||
table->setSelectionBehavior(QAbstractItemView::SelectRows); // 设置为整行选中
|
||||
table->horizontalHeader()->setFixedHeight(50);
|
||||
table->horizontalHeader()->setDefaultSectionSize(60);
|
||||
table->horizontalHeader()->setDefaultSectionSize(50); // 设置默认行宽
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ QWHome::QWHome(QWidget* parent) : MyWidget(parent)
|
||||
this->setObjectName("home");
|
||||
this->setStyleSheet("#home { background-color:rgba(100,100,100,50); }");
|
||||
|
||||
|
||||
|
||||
int x = 10, y = 0;
|
||||
{
|
||||
//this->groupSys = MyQUI::GroupBox(this, x, y, 1190, 120, "系统");
|
||||
@@ -47,29 +45,29 @@ QWHome::QWHome(QWidget* parent) : MyWidget(parent)
|
||||
this->addPair("db-n", pw, 20, 20, "数据库名: ", Config::option.database.dbname);
|
||||
this->addPair("db-h", pw, 20, 50, "主机地址: ", Config::option.database.host);
|
||||
this->addPair("db-u", pw, 20, 80, "用 户 名: ", Config::option.database.user);
|
||||
|
||||
QStringList headerTextList;
|
||||
headerTextList << "ID" << "站名" << "编号" << "状态" << "MQTT状态" << "召测(秒)"
|
||||
<< "日充电\n电量" << "日放电\n电量" << "总充电\n电量" << "总放电\n电量"
|
||||
<< "日充电\n费用" << "日放电\n费用" << "总充电\n费用" << "总放电\n费用"
|
||||
<< "日收益" << "总收益" << "--";
|
||||
|
||||
table = MyQUI::TableWidget(this, 10, y += 210, 1190, 265);
|
||||
// 设置为水平表头
|
||||
table->setColumnCount(headerTextList.size());
|
||||
table->setHorizontalHeaderLabels(headerTextList);
|
||||
table->setColumnWidth(0, 50);
|
||||
table->setColumnWidth(1, 120);
|
||||
table->setColumnWidth(2, 50);
|
||||
table->setColumnWidth(4, 80);
|
||||
}
|
||||
|
||||
QStringList headerTextList;
|
||||
headerTextList << "ID" << "站名" << "编号" << "状态" << "MQTT状态" << "召测(秒)"
|
||||
<< "日充电\n电量" << "日放电\n电量" << "总充电\n电量" << "总放电\n电量"
|
||||
<< "日充电\n费用" << "日放电\n费用" << "总充电\n费用" << "总放电\n费用"
|
||||
<< "日收益" << "总收益" << "--";
|
||||
table = MyQUI::TableWidget(this, 10, y += 210, 1350, 265);
|
||||
// 设置为水平表头
|
||||
table->setColumnCount(headerTextList.size());
|
||||
table->setHorizontalHeaderLabels(headerTextList);
|
||||
table->setColumnWidth(0, 40);
|
||||
table->setColumnWidth(1, 120);
|
||||
table->setColumnWidth(2, 40);
|
||||
table->setColumnWidth(4, 80);
|
||||
table->setColumnWidth(5, 70);
|
||||
|
||||
logFilter = MyQUI::PairLine(this, 10, y += 280, "日志过滤: ", "", false);
|
||||
btnLogClean = MyQUI::Button(this, 400, y-1, 80, 28, "清除");
|
||||
QObject::connect(btnLogClean.get(), &QPushButton::clicked, this, &QWHome::slotBtnClearLog);
|
||||
|
||||
texteditLog = std::make_shared<QTextEdit>(this);
|
||||
texteditLog->setGeometry(10, y += 35, 1190, 280);
|
||||
texteditLog->setGeometry(10, y += 35, 1350, 340);
|
||||
texteditLog->setStyleSheet("background-color: transparent; border: 1px solid gray; font-weight: 400;");
|
||||
texteditLog->setReadOnly(true);
|
||||
texteditLog->document()->setMaximumBlockCount(1000);
|
||||
|
||||
@@ -39,7 +39,7 @@ QWMonitor::QWMonitor(QWidget* parent) : MyWidget(parent)
|
||||
}
|
||||
|
||||
QStringList headerTextList;
|
||||
headerTextList << "ID" << "类型ID" << "类型名称" << "设备名称" << "编号" << "状态" << "通讯\n状态" << "工作\n状态" << "故障\n状态";
|
||||
headerTextList << "ID" << "类型ID" << "类型名称" << "设备名称" << "编号" << "状态" << "通讯\n状态" << "工作\n状态" << "故障\n状态" << "--";
|
||||
|
||||
table = MyQUI::TableWidget(this, 10, y += 50, 700, 800);
|
||||
// 设置为水平表头
|
||||
@@ -73,7 +73,7 @@ QWMonitor::QWMonitor(QWidget* parent) : MyWidget(parent)
|
||||
uiReg.scroll->setWidgetResizable(true);
|
||||
|
||||
std::string QSS_LISTVIEW =
|
||||
"QListView { background-color: transparent; color: white; }"
|
||||
"QListView { background-color: transparent; color: white; outline: 1px solid #409EFF;}"
|
||||
"QListView::item { background-color: transparent; border-bottom: 0px solid gray; padding: 0px; height: 20px; }";
|
||||
|
||||
uiReg.listReg = new QListWidget(groupStation.get());
|
||||
|
||||
@@ -24,17 +24,17 @@ QWStatistics::QWStatistics(QWidget* parent) : MyWidget(parent)
|
||||
headerTextList << "日期" << "日充电\n电量" << "日放电\n电量"
|
||||
<< "日充电\n电量(尖)" << "日充电\n电量(峰)" << "日充电\n电量(平)" << "日充电\n电量(谷)"
|
||||
<< "日放电\n电量(尖)" << "日放电\n电量(峰)" << "日放电\n电量(平)" << "日放电\n电量(谷)"
|
||||
<< "日充电\n费用" << "日放电\n费用" << "日收益" ;
|
||||
<< "日充电\n费用" << "日放电\n费用" << "日收益" << "--";
|
||||
//<< "总充电\n电量" << "总放电\n电量"
|
||||
//<< "总充电\n电量(尖)" << "总充电\n电量(峰)" << "总充电\n电量(平)" << "总充电\n电量(谷)"
|
||||
//<< "总放电\n电量(尖)" << "总放电\n电量(峰)" << "总放电\n电量(平)" << "总放电\n电量(谷)";
|
||||
|
||||
table = MyQUI::TableWidget(this, 10, 50, 1190, 800);
|
||||
table = MyQUI::TableWidget(this, 10, 50, 1350, 800);
|
||||
table->horizontalHeader()->setDefaultSectionSize(80);
|
||||
// 设置为水平表头
|
||||
table->setColumnCount(headerTextList.size());
|
||||
table->setHorizontalHeaderLabels(headerTextList);
|
||||
table->setColumnWidth(0, 120);
|
||||
table->setColumnWidth(0, 100);
|
||||
|
||||
btnRefresh = make_shared<QPushButton>("刷新", this);
|
||||
btnRefresh->setGeometry(220, 10, 60, 30);
|
||||
|
||||
@@ -283,7 +283,7 @@ QWSysmgr::QWSysmgr(QWidget* parent) : MyWidget(parent)
|
||||
QStringList headerTextList;
|
||||
//headerTextList << "ID" << "类型ID" << "类型名称" << "设备名称" << "编号" << "状态" << "通讯\n状态" << "工作\n状态" << "故障\n状态";
|
||||
|
||||
table = MyQUI::TableWidget(this, 10, y += 100, 1190, 740);
|
||||
table = MyQUI::TableWidget(this, 10, y += 100, 1350, 740);
|
||||
// 设置为水平表头
|
||||
table->setColumnCount(headerTextList.size());
|
||||
table->setHorizontalHeaderLabels(headerTextList);
|
||||
|
||||
Reference in New Issue
Block a user