|
|
@@ -2856,8 +2856,83 @@ char* service_ds_ack_to_json(char* chn_name,char* chn_id,_PowerDSManage_t* __pow
|
|
|
cJSON_Delete(root);
|
|
|
return str;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+/// @brief 返回所有定时设置
|
|
|
+/// @param chn_name
|
|
|
+/// @param chn_id
|
|
|
+/// @param __powerDSManage_t
|
|
|
+/// @return
|
|
|
+char* service_ds_all_ack_to_json(char* pDate,char* strName,char* strchID,GlobalPowerManger* _powerAll)
|
|
|
+{
|
|
|
+ if (!_powerAll)
|
|
|
+ {
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+ char* str = NULL;
|
|
|
+ int nchID=0;
|
|
|
+ char datetemp[32]={0};
|
|
|
+ char temp[64]={0};
|
|
|
+ _PowerDSManage_t* _powerDsManageTemp = NULL ;
|
|
|
+ // 创建 JSON 对象
|
|
|
+ cJSON* root = cJSON_CreateObject();
|
|
|
+ // 添加基本键值对
|
|
|
+ cJSON_AddNumberToObject(root, "code", 200);
|
|
|
+ //创建数据
|
|
|
+ cJSON* data_root_array = cJSON_CreateArray();
|
|
|
+ GlobalPowerManger* _globalPowerMangerTemp=NULL;
|
|
|
+ list_for_each_entry(_globalPowerMangerTemp, &_powerAll->list, list)
|
|
|
+ {
|
|
|
+ if (!(strchID == NULL || *strchID == '\0'))//ID号
|
|
|
+ {
|
|
|
+ nchID=atoi(strchID);
|
|
|
+ if (nchID>0)
|
|
|
+ {
|
|
|
+ if (nchID != _globalPowerMangerTemp->product_ch_id)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!(strName == NULL || *strName == '\0'))//名称
|
|
|
+ {
|
|
|
+ if (strcmp(_globalPowerMangerTemp->product_ch_name, strName) != 0)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 循环添加数据s
|
|
|
+ _powerDsManageTemp=NULL;
|
|
|
+ list_for_each_entry(_powerDsManageTemp, &_globalPowerMangerTemp->list_DS,list)
|
|
|
+ {
|
|
|
+ if (!(pDate == NULL || *pDate == '\0'))
|
|
|
+ {
|
|
|
+ if (strcmp(_powerDsManageTemp->ds_date, pDate) != 0)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cJSON *data_filed = cJSON_CreateObject();
|
|
|
+ sprintf(temp,"%d %s %s",_globalPowerMangerTemp->product_ch_id,_powerDsManageTemp->ds_date,_powerDsManageTemp->ds_time);
|
|
|
+ cJSON_AddStringToObject(data_filed, "idx", temp);
|
|
|
+ cJSON_AddStringToObject(data_filed, "productChName", _globalPowerMangerTemp->product_ch_name);
|
|
|
+ sprintf(temp,"%d",_globalPowerMangerTemp->product_ch_id);
|
|
|
+ cJSON_AddStringToObject(data_filed, "productChId", temp);
|
|
|
+ cJSON_AddStringToObject(data_filed, "setDate", _powerDsManageTemp->ds_date);
|
|
|
+ cJSON_AddStringToObject(data_filed, "setTime", _powerDsManageTemp->ds_time);
|
|
|
+ cJSON_AddNumberToObject(data_filed, "setStatus", _powerDsManageTemp->set_stats);
|
|
|
+ cJSON_AddNumberToObject(data_filed, "triggerStatus", _powerDsManageTemp->ds_is_triggered);
|
|
|
+ cJSON_AddItemToObject(data_root_array, "data", data_filed);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //添加汇总
|
|
|
+ cJSON_AddItemToObject(root, "data", data_root_array);
|
|
|
+ //添加结果
|
|
|
+ cJSON_AddStringToObject(root, "msg", "操作成功");
|
|
|
+ //转换
|
|
|
+ str = cJSON_Print(root);
|
|
|
+ //释放资源
|
|
|
+ cJSON_Delete(root);
|
|
|
+ return str;
|
|
|
+}
|
|
|
|
|
|
/// @brief 告警信息请求
|
|
|
/// @param str
|
|
|
@@ -3232,11 +3307,22 @@ cJSON* json_to_service_manage(const char* str,_ServiceManageRequestInfo* _servic
|
|
|
else if(strcmp(_serviceManageRequestInfo->type,"listDsQuery")==0)
|
|
|
{
|
|
|
cJSON* cjson_ds_ch_name = cJSON_GetObjectItem(cjson,"productChName");
|
|
|
- cJSON* cjson_ds_ch_id = cJSON_GetObjectItem(cjson,"productChId");
|
|
|
- if(cjson_ds_ch_name!=NULL)
|
|
|
- _serviceManageRequestInfo->_ds_info.productChName = cjson_ds_ch_name->valuestring ;
|
|
|
- if(cjson_ds_ch_id!=NULL)
|
|
|
- _serviceManageRequestInfo->_ds_info.productChId = cjson_ds_ch_id->valuestring ;
|
|
|
+ cJSON* cjson_ds_ch_id = cJSON_GetObjectItem(cjson,"productChId");
|
|
|
+ cJSON* cjson_ds_ch_date = cJSON_GetObjectItem(cjson,"setDate");
|
|
|
+ if (cjson_ds_ch_name != NULL)
|
|
|
+ {
|
|
|
+ _serviceManageRequestInfo->_ds_info.productChName = cjson_ds_ch_name->valuestring;
|
|
|
+ }
|
|
|
+ if (cjson_ds_ch_id != NULL)
|
|
|
+ {
|
|
|
+ _serviceManageRequestInfo->_ds_info.productChId = cjson_ds_ch_id->valuestring;
|
|
|
+ }
|
|
|
+ if (cjson_ds_ch_date != NULL)
|
|
|
+ {
|
|
|
+ _serviceManageRequestInfo->_ds_info.channelDate = cjson_ds_ch_date->valuestring;
|
|
|
+ }else{
|
|
|
+ _serviceManageRequestInfo->_ds_info.channelDate =NULL;
|
|
|
+ }
|
|
|
}
|
|
|
else if(strcmp(_serviceManageRequestInfo->type,"listSxQuery")==0)
|
|
|
{
|
|
|
@@ -3255,20 +3341,43 @@ cJSON* json_to_service_manage(const char* str,_ServiceManageRequestInfo* _servic
|
|
|
{
|
|
|
cJSON* cjson_ds_ch_name = cJSON_GetObjectItem(cjson,"productChName");
|
|
|
cJSON* cjson_ds_ch_id = cJSON_GetObjectItem(cjson,"productChId");
|
|
|
- cJSON* cjson_ds_date = cJSON_GetObjectItem(cjson,"channelDate");
|
|
|
+ cJSON* cjson_ds_dateS = cJSON_GetObjectItem(cjson,"startDate");
|
|
|
+ cJSON* cjson_ds_dateE = cJSON_GetObjectItem(cjson,"endDate");
|
|
|
cJSON* cjson_ds_time = cJSON_GetObjectItem(cjson,"channelTime");
|
|
|
cJSON* cjson_ds_sts = cJSON_GetObjectItem(cjson,"setStatus");
|
|
|
if(cjson_ds_ch_name!=NULL)
|
|
|
_serviceManageRequestInfo->_ds_info.productChName = cjson_ds_ch_name->valuestring ;
|
|
|
if(cjson_ds_ch_id!=NULL)
|
|
|
- _serviceManageRequestInfo->_ds_info.productChId = cjson_ds_ch_id->valuestring ;
|
|
|
- if(cjson_ds_date!=NULL)
|
|
|
- _serviceManageRequestInfo->_ds_info.channelDate = cjson_ds_date->valuestring ;
|
|
|
- if(cjson_ds_time!=NULL)
|
|
|
- _serviceManageRequestInfo->_ds_info.channelTime = cjson_ds_time->valuestring ;
|
|
|
- if(cjson_ds_sts!=NULL)
|
|
|
+ {
|
|
|
+ memset(_serviceManageRequestInfo->_ds_info.productChIds,-1,sizeof(_serviceManageRequestInfo->_ds_info.productChIds));
|
|
|
+ int nIndex =0;
|
|
|
+ for (cJSON* cjson_ds_ch_id_child = cjson_ds_ch_id->child; cjson_ds_ch_id_child != NULL; cjson_ds_ch_id_child = cjson_ds_ch_id_child->next,nIndex++)
|
|
|
+ {
|
|
|
+ _serviceManageRequestInfo->_ds_info.productChIds[nIndex]=cjson_ds_ch_id_child->valueint;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (cjson_ds_dateS != NULL)
|
|
|
+ _serviceManageRequestInfo->_ds_info.StartDate = cjson_ds_dateS->valuestring;
|
|
|
+ if (cjson_ds_dateE != NULL)
|
|
|
+ _serviceManageRequestInfo->_ds_info.Enddate = cjson_ds_dateE->valuestring;
|
|
|
+ if (cjson_ds_time != NULL)
|
|
|
+ _serviceManageRequestInfo->_ds_info.channelTime = cjson_ds_time->valuestring;
|
|
|
+ if (cjson_ds_sts != NULL)
|
|
|
_serviceManageRequestInfo->_ds_info.setStatus = cjson_ds_sts->valuestring ;
|
|
|
}
|
|
|
+ else if(strcmp(_serviceManageRequestInfo->type,"deleteDs")==0)
|
|
|
+ {
|
|
|
+ cJSON *cjson_ds_ch_id = cJSON_GetObjectItem(cjson, "idx");
|
|
|
+ if (cjson_ds_ch_id != NULL)
|
|
|
+ {
|
|
|
+ memset(_serviceManageRequestInfo->_ds_info.idx, '\0', sizeof(_serviceManageRequestInfo->_ds_info.idx));
|
|
|
+ int nIndex = 0;
|
|
|
+ for (cJSON *cjson_ds_ch_id_child = cjson_ds_ch_id->child; cjson_ds_ch_id_child != NULL&&nIndex<64; cjson_ds_ch_id_child = cjson_ds_ch_id_child->next, nIndex++)
|
|
|
+ {
|
|
|
+ _serviceManageRequestInfo->_ds_info.idx[nIndex] = cjson_ds_ch_id_child->valuestring;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
else if(strcmp(_serviceManageRequestInfo->type,"sXTimeSave")==0)
|
|
|
{
|
|
|
cJSON* cjson_sx_ch_name = cJSON_GetObjectItem(cjson,"productChName");
|