mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
实现削峰套利策略的编辑页面
This commit is contained in:
@@ -18,18 +18,40 @@ bool DAO::count(DaoEntity& dao, std::string tableName, std::string condition, in
|
||||
bool ret = dao.exec(sql, result);
|
||||
if (ret)
|
||||
{
|
||||
count = (result.size() > 0) ? result[0].getInt("count") : 0;
|
||||
count = (result.size() > 0) ? result[0].get<int>("count") : 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Errcode DAO::exec(std::shared_ptr<DaoEntity> dao, std::string sql)
|
||||
{
|
||||
if (!dao) { dao = DaoEntity::create(""); }
|
||||
if (!dao->isConnected())
|
||||
{
|
||||
return Errcode::ERR_DB_CONN;
|
||||
}
|
||||
auto ret = dao->exec(sql);
|
||||
return ret ? Errcode::OK : Errcode::ERR_DB_SQL;
|
||||
}
|
||||
|
||||
Errcode DAO::exec(std::shared_ptr<DaoEntity> dao, std::string sql, vector<Fields>& result)
|
||||
{
|
||||
if (!dao) { dao = DaoEntity::create(""); }
|
||||
if (!dao->isConnected())
|
||||
{
|
||||
return Errcode::ERR_DB_CONN;
|
||||
}
|
||||
auto ret = dao->exec(sql, result);
|
||||
return ret ? Errcode::OK : Errcode::ERR_DB_SQL;
|
||||
}
|
||||
|
||||
static bool QueryCount(DaoEntity& dao, std::string sqlFrom, int& count)
|
||||
{
|
||||
std::vector<Fields> result;
|
||||
bool ret = dao.exec("SELECT COUNT(*) count " + sqlFrom, result);
|
||||
if (ret)
|
||||
{
|
||||
count = (result.size() > 0) ? result[0].getInt("count") : 0;
|
||||
count = (result.size() > 0) ? result[0].get<int>("count") : 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -108,7 +130,7 @@ Errcode DAO::updateUserById(Fields& params)
|
||||
std::string createTime = Utils::timeStr();
|
||||
std::string userId = params.value(DMUser::USER_ID);
|
||||
std::string roleId = "";
|
||||
if (params.hasKey(DMRole::ROLE_ID))
|
||||
if (params.contains(DMRole::ROLE_ID))
|
||||
{
|
||||
roleId = params.value(DMRole::ROLE_ID);
|
||||
params.remove(DMUser::USER_ID);
|
||||
@@ -137,11 +159,10 @@ Errcode DAO::updateUserById(Fields& params)
|
||||
return Errcode::OK;
|
||||
}
|
||||
|
||||
bool DAO::queryRoleList(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
Errcode DAO::queryRoleList(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
{
|
||||
if (!dao) { dao = DaoEntity::create(""); }
|
||||
std::string sql = "SELECT * FROM " + DMRole::TABLENAME + ";";
|
||||
return dao->exec(sql, result);
|
||||
return DAO::exec(dao, sql, result);
|
||||
}
|
||||
|
||||
bool DAO::queryRoleList(PageInfo& pageInfo, vector<Fields>& result)
|
||||
@@ -174,20 +195,16 @@ Errcode DAO::insertStation(Fields& params)
|
||||
params.remove(DMStation::STATION_ID);
|
||||
params.check(DMStation::LATITUDE, "", "NULL");
|
||||
params.check(DMStation::LONGITUDE, "", "NULL");
|
||||
bool ret = dao->insertFields(params);
|
||||
if (!ret)
|
||||
{
|
||||
return Errcode::ERR_DB_SQL;
|
||||
}
|
||||
return Errcode::OK;
|
||||
|
||||
std::string sql = params.toSqlInsert(DMStation::TABLENAME);
|
||||
return DAO::exec(dao, sql);
|
||||
}
|
||||
|
||||
// 查询场站信息列表
|
||||
bool DAO::queryStationList(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
Errcode DAO::queryStationList(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
{
|
||||
if (!dao) { dao = DaoEntity::create(""); }
|
||||
std::string sql = "SELECT * FROM " + DMStation::TABLENAME;
|
||||
return DaoEntity::execOnce(sql, result);
|
||||
return DAO::exec(dao, sql, result);
|
||||
}
|
||||
|
||||
// 分页查询场站信息列表
|
||||
@@ -221,11 +238,10 @@ Errcode DAO::updateStationById(Fields& params)
|
||||
}
|
||||
|
||||
// 查询设备信息列表
|
||||
bool DAO::queryDeviceList(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
Errcode DAO::queryDeviceList(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
{
|
||||
if (!dao) { dao = DaoEntity::create(""); }
|
||||
std::string sql = "SELECT * FROM " + DMDevice::TABLENAME;
|
||||
return DaoEntity::execOnce(sql, result);
|
||||
return DAO::exec(dao, sql, result);
|
||||
}
|
||||
|
||||
// 分页查询设备信息列表
|
||||
@@ -242,23 +258,17 @@ bool DAO::queryDeviceList(PageInfo& pageInfo, vector<Fields>& result)
|
||||
}
|
||||
|
||||
// 查询设备类型定义
|
||||
bool DAO::queryDeviceTypeDef(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
Errcode DAO::queryDeviceTypeDef(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
{
|
||||
if (!dao) { dao = DaoEntity::create(""); }
|
||||
std::string sql = "SELECT * FROM " + DMDeviceTypeDef::TABLENAME + ";";
|
||||
return DaoEntity::execOnce(sql, result);
|
||||
std::string sql = "SELECT * FROM " + DMDefDeviceType::TABLENAME + ";";
|
||||
return DAO::exec(dao, sql, result);
|
||||
}
|
||||
|
||||
Errcode DAO::insertDevice(Fields& params)
|
||||
{
|
||||
auto dao = DaoEntity::create(DMDevice::TABLENAME);
|
||||
bool ret = dao->insertFields(params);
|
||||
if (!ret)
|
||||
{
|
||||
return Errcode::ERR_DB_SQL;
|
||||
}
|
||||
return Errcode::OK;
|
||||
return DAO::exec(NULL, params.toSqlInsert(DMDevice::TABLENAME));
|
||||
}
|
||||
|
||||
Errcode DAO::updateDeviceById(Fields& params)
|
||||
{
|
||||
std::string deviceId = params.value(DMDevice::DEVICE_ID);
|
||||
@@ -266,13 +276,8 @@ Errcode DAO::updateDeviceById(Fields& params)
|
||||
{
|
||||
return Errcode::ERR_DB_SQL;
|
||||
}
|
||||
auto dao = DaoEntity::create(DMDevice::TABLENAME);
|
||||
bool ret = dao->updateFields(params, "WHERE " + DMDevice::DEVICE_ID + "='" + deviceId + "'");
|
||||
if (!ret)
|
||||
{
|
||||
return Errcode::ERR_DB_SQL;
|
||||
}
|
||||
return Errcode::OK;
|
||||
std::string sql = params.toSqlUpdate(DMDevice::TABLENAME, "WHERE " + DMDevice::DEVICE_ID + "='" + deviceId + "'");
|
||||
return DAO::exec(NULL, sql);
|
||||
}
|
||||
|
||||
// 策略管理
|
||||
@@ -288,6 +293,12 @@ bool DAO::queryPolicyList(PageInfo& pageInfo, vector<Fields>& result)
|
||||
return ret;
|
||||
}
|
||||
|
||||
Errcode DAO::queryPolicyList(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
{
|
||||
std::string sql = "SELECT * FROM " + DMPolicy::TABLENAME;
|
||||
return DAO::exec(dao, sql, result);
|
||||
}
|
||||
|
||||
// 系统日志管理
|
||||
bool DAO::querySystemLogList(PageInfo& pageInfo, vector<Fields>& result)
|
||||
{
|
||||
@@ -301,8 +312,21 @@ bool DAO::querySystemLogList(PageInfo& pageInfo, vector<Fields>& result)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DAO::queryStatDataList(std::string startDate, std::string endDate, vector<Fields>& result)
|
||||
Errcode DAO::queryStatDataList(std::shared_ptr<DaoEntity> dao, std::string startDate, std::string endDate, vector<Fields>& result)
|
||||
{
|
||||
std::string sql = "SELECT * FROM " + DMStatStation::TABLENAME + " WHERE dt BETWEEN '" + startDate + "' AND '" + endDate + "';";
|
||||
return DaoEntity::execOnce(sql, result);
|
||||
return DAO::exec(dao, sql, result);
|
||||
}
|
||||
|
||||
Errcode DAO::queryWorkModeDef(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
{
|
||||
std::string sql = "SELECT * FROM " + DMDefWorkMode::TABLENAME + ";";
|
||||
return DAO::exec(dao, sql, result);
|
||||
}
|
||||
|
||||
|
||||
Errcode DAO::queryPolicyTypeDef(std::shared_ptr<DaoEntity> dao, vector<Fields>& result)
|
||||
{
|
||||
std::string sql = "SELECT * FROM " + DMDefPolicyType::TABLENAME + ";";
|
||||
return DAO::exec(dao, sql, result);
|
||||
}
|
||||
Reference in New Issue
Block a user