mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-28 03:09:24 +08:00
调试预制舱通讯协议修改数据解析
This commit is contained in:
@@ -644,7 +644,6 @@ Errcode DAO::insertStatStation(std::shared_ptr<DaoEntity> dao, Fields& fields)
|
||||
{
|
||||
// 根据主键(dt、station_id、category),写入或更新数据
|
||||
if (!dao) { dao = DaoEntity::create("stat_station"); }
|
||||
else { dao->setTableName("stat_station"); }
|
||||
std::vector<std::string> vecKeys = {
|
||||
"storage_elect_in",
|
||||
"storage_elect_out",
|
||||
|
||||
@@ -129,18 +129,21 @@ int DaoEntity::duplicateUpdate(Fields& fields, const vector<string>& keys)
|
||||
string val;
|
||||
for (auto& item : fields.map())
|
||||
{
|
||||
if (!key.empty()) { key += ","; val += ","; }
|
||||
if (!key.empty())
|
||||
{
|
||||
key += ","; val += ",";
|
||||
}
|
||||
key += (item.first);
|
||||
val += ("'" + item.second + "'");
|
||||
}
|
||||
string str;
|
||||
for (auto& k : keys)
|
||||
{
|
||||
if (fields.contains(k))
|
||||
if (!str.empty())
|
||||
{
|
||||
if (!str.empty()) { str += ","; }
|
||||
str += (k + "='" + fields.value(k) + "'");
|
||||
str += ",";
|
||||
}
|
||||
str += (k + "='" + fields.value(k) + "'");
|
||||
}
|
||||
string sql = "INSERT INTO " + tableName + "(" + key + ") VALUES (" + val + ") ON duplicate KEY UPDATE " + str;
|
||||
return this->db->exec(sql);
|
||||
|
||||
Reference in New Issue
Block a user