|
|
@@ -906,11 +906,6 @@ int DealPosttRetesionForce(const char* body_ptr, const size_t body_len, const st
|
|
|
str_conf = yyjson_mut_write(doc, 0, &len);
|
|
|
yyjson_mut_doc_free(doc);
|
|
|
CResistAlarmMng::Instance()->Insert(mo, mp, posi, (uint8_t)eZL_ALARMTYPE::RETENSION_FORCE, pInfo);
|
|
|
-
|
|
|
- time_t tt;
|
|
|
- time(&tt);
|
|
|
- sql.Format("INSERT INTO [rm_alarm_set]([mo],[mp],[no],[type],[conf],[time]) VALUES ('%s','%s',%d, %d,'%s','%I64u')",
|
|
|
- mo, mp, posi, eZL_ALARMTYPE::RETENSION_FORCE, str_conf, tt);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -943,21 +938,27 @@ int DealPosttRetesionForce(const char* body_ptr, const size_t body_len, const st
|
|
|
|
|
|
str_conf = yyjson_mut_write(doc, 0, &len);
|
|
|
yyjson_mut_doc_free(doc);
|
|
|
- sql.Format("update rm_alarm_set SET conf = '%s' WHERE mo = '%s' and mp = '%s' and no = %d and type = %d",
|
|
|
- str_conf, mo, mp, posi, eZL_ALARMTYPE::RETENSION_FORCE);
|
|
|
- }
|
|
|
-
|
|
|
- if (str_conf) free(str_conf);
|
|
|
|
|
|
+ }
|
|
|
+ time_t tt;
|
|
|
+ time(&tt);
|
|
|
+ sql.Format("IF EXISTS (SELECT 1 FROM rm_alarm_set WHERE mo = '%s' and mp = '%s' and no = %d and type = %d)\
|
|
|
+ update rm_alarm_set SET conf = '%s' WHERE mo = '%s' and mp = '%s' and no = % d and type = % d\
|
|
|
+ ELSE\
|
|
|
+ INSERT INTO[rm_alarm_set]([mo], [mp], [no], [type], [conf], [time]) VALUES('%s', '%s', % d, % d, '%s', '%I64u')",
|
|
|
+ mo, mp, posi, eZL_ALARMTYPE::RETENSION_FORCE,
|
|
|
+ str_conf, mo, mp, posi, eZL_ALARMTYPE::RETENSION_FORCE,
|
|
|
+ mo, mp, posi, eZL_ALARMTYPE::RETENSION_FORCE, str_conf, tt);
|
|
|
if (CDBConnectPool::Instance()->DBExecuteSQL(sql) == FALSE)
|
|
|
{
|
|
|
ASSERT(FALSE);
|
|
|
msg = "Óï¾äÖ´ÐÐʧ°Ü" + sql;
|
|
|
CSimpleLog::Error(msg.c_str());
|
|
|
code = 500;
|
|
|
+ if (str_conf) free(str_conf);
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+ if (str_conf) free(str_conf);
|
|
|
code = 200;
|
|
|
|
|
|
} while (false);
|