瀏覽代碼

1、添加2新字段
2、Json处理加强

scbc 5 年之前
父節點
當前提交
09f53bddfd
共有 2 個文件被更改,包括 19 次插入10 次删除
  1. 17 10
      SATHTTP/SATHTTP/SATHTTP.cpp
  2. 2 0
      SATHTTP/SATHTTP/SATHTTP.h

+ 17 - 10
SATHTTP/SATHTTP/SATHTTP.cpp

@@ -469,13 +469,13 @@ SATHTTP_API int Heartbeat(std::string url, const SATHTTP::STHeartbeatReq &stHear
 										}
 									}
 
-									cJSON *pSomkingCycle = cJSON_GetObjectItem(pTask, "SomkingCycle");
+									cJSON *pSomkingCycle = cJSON_GetObjectItem(pTask, "cycle");
 									if ( pSomkingCycle ) {
 										// 冒烟任务周期;
-										stTask.taskInfo.stSomkingCycle.nType = cJSON_GetObjectItem(pSomkingCycle, "type")->valueint;
-										stTask.taskInfo.stSomkingCycle.nWeek = cJSON_GetObjectItem(pSomkingCycle, "week")->valueint;
-										stTask.taskInfo.stSomkingCycle.nDay = cJSON_GetObjectItem(pSomkingCycle, "day")->valueint;
-										stTask.taskInfo.stSomkingCycle.strTime = cJSON_GetObjectItem(pSomkingCycle, "time")->valuestring;
+										stTask.taskInfo.stSomkingCycle.nType = cJSON_GetObjectItem(pSomkingCycle, "type") ? _tstoi(cJSON_GetObjectItem(pSomkingCycle, "type")->valuestring) : 1;
+										stTask.taskInfo.stSomkingCycle.nWeek = cJSON_GetObjectItem(pSomkingCycle, "week") ? _tstoi(cJSON_GetObjectItem(pSomkingCycle, "week")->valuestring) : 0;
+										stTask.taskInfo.stSomkingCycle.nDay = cJSON_GetObjectItem(pSomkingCycle, "day") ? _tstoi(cJSON_GetObjectItem(pSomkingCycle, "day")->valuestring) : 0;
+										stTask.taskInfo.stSomkingCycle.strTime = cJSON_GetObjectItem(pSomkingCycle, "time") ? cJSON_GetObjectItem(pSomkingCycle, "time")->valuestring : "05:00";
 									}
 
 									// Job内容;
@@ -503,7 +503,8 @@ SATHTTP_API int Heartbeat(std::string url, const SATHTTP::STHeartbeatReq &stHear
 											stTask.Job.strPoweroff = cJSON_GetObjectItem(pJob, "poweroff") ? cJSON_GetObjectItem(pJob, "poweroff")->valuestring : "";
 											stTask.Job.strFilePath = cJSON_GetObjectItem(pJob, "filePath") ? cJSON_GetObjectItem(pJob, "filePath")->valuestring : "";
 											stTask.Job.strScriptFailRepeart = cJSON_GetObjectItem(pJob, "scriptFailRepeat") ? cJSON_GetObjectItem(pJob, "scriptFailRepeat")->valuestring : "";
-											stTask.Job.strTaskInstanceId = cJSON_GetObjectItem(pJob, "taskInstanceId") ? cJSON_GetObjectItem(pJob, "taskInstanceId")->valuestring : "";
+											if (cJSON_GetObjectItem(pJob, "taskInstanceId") && !cJSON_IsNull(cJSON_GetObjectItem(pJob, "taskInstanceId")))
+												stTask.Job.strTaskInstanceId = cJSON_GetObjectItem(pJob, "taskInstanceId") ? cJSON_GetObjectItem(pJob, "taskInstanceId")->valuestring : "";
 											stTask.Job.strUserId = cJSON_GetObjectItem(pJob, "userId") ? cJSON_GetObjectItem(pJob, "userId")->valuestring : "";
 											stTask.Job.strDiffTaskInstanceFlag = cJSON_GetObjectItem(pJob, "diffTaskInstanceFlag") ? cJSON_GetObjectItem(pJob, "diffTaskInstanceFlag")->valuestring : "";
 											stTask.Job.strBusCode = cJSON_GetObjectItem(pJob, "busCode") ? cJSON_GetObjectItem(pJob, "busCode")->valuestring : "";
@@ -590,6 +591,7 @@ SATHTTP_API int SetResult(std::string url, const SATHTTP::STNotifyJobStartReq &s
 		cJSON_AddStringToObject(pData, "deviceId", stNotifyJobStartReq.strDeviceId.c_str());
 		cJSON_AddStringToObject(pData, "taskId", stNotifyJobStartReq.strTaskId.c_str());
 		cJSON_AddStringToObject(pData, "executeId", stNotifyJobStartReq.strExecuteId.c_str());
+		cJSON_AddStringToObject(pData, "taskType", stNotifyJobStartReq.strTaskType.c_str());
 				
 		// 添加到根结点中;
 		cJSON_AddItemToObject(pRoot, "data", pData);
@@ -630,8 +632,10 @@ SATHTTP_API int SetResult(std::string url, const SATHTTP::STNotifyJobStartReq &s
 				if ( pMsg )
 				{
 					stNotifyJobStartResp.strCode = cJSON_GetObjectItem(pMsg, "code") ? cJSON_GetObjectItem(pMsg, "code")->valuestring : "";
-					stNotifyJobStartResp.strMessage = cJSON_GetObjectItem(pMsg, "message") ? cJSON_GetObjectItem(pMsg, "message")->valuestring : "";
-					stNotifyJobStartResp.strStr = cJSON_GetObjectItem(pMsg, "str") ? (cJSON_GetObjectItem(pMsg, "str")->valuestring ? cJSON_GetObjectItem(pMsg, "str")->valuestring : "") : "";
+					if ( cJSON_GetObjectItem(pMsg, "message") && !cJSON_IsNull(cJSON_GetObjectItem(pMsg, "message")) )
+						stNotifyJobStartResp.strMessage = cJSON_GetObjectItem(pMsg, "message") ? cJSON_GetObjectItem(pMsg, "message")->valuestring : "";
+					if ( cJSON_GetObjectItem(pMsg, "message") && !cJSON_IsNull(cJSON_GetObjectItem(pMsg, "message")) )
+						stNotifyJobStartResp.strStr = cJSON_GetObjectItem(pMsg, "str") ? (cJSON_GetObjectItem(pMsg, "str")->valuestring ? cJSON_GetObjectItem(pMsg, "str")->valuestring : "") : "";
 					if ( stNotifyJobStartResp.strCode == "00" )
 					{				
 						cJSON *pObj = cJSON_GetObjectItem(pMsg, "data");
@@ -708,6 +712,7 @@ SATHTTP_API int SetResultList(std::string url, const SATHTTP::STJobProcessReq &s
 		cJSON_AddStringToObject(pData, "round_number", stJobProcessReq.strRoundNumber.c_str());
 		cJSON_AddStringToObject(pData, "result_type", stJobProcessReq.strResultType.c_str());
 		cJSON_AddStringToObject(pData, "operation_step", stJobProcessReq.strOperationStep.c_str());
+		cJSON_AddStringToObject(pData, "instance_type", stJobProcessReq.strInstanceType.c_str());
 
 		// 添加到根结点中;
 		cJSON_AddItemToObject(pRoot, "data", pData);
@@ -748,8 +753,10 @@ SATHTTP_API int SetResultList(std::string url, const SATHTTP::STJobProcessReq &s
 				if ( pMsg )
 				{
 					stJobProcessResp.strCode = cJSON_GetObjectItem(pMsg, "code") ? cJSON_GetObjectItem(pMsg, "code")->valuestring : "";
-					stJobProcessResp.strMessage = cJSON_GetObjectItem(pMsg, "message") ? cJSON_GetObjectItem(pMsg, "message")->valuestring : "";
-					stJobProcessResp.strStr = cJSON_GetObjectItem(pMsg, "str") ? (cJSON_GetObjectItem(pMsg, "str")->valuestring ? cJSON_GetObjectItem(pMsg, "str")->valuestring : "") : "";
+					if ( cJSON_GetObjectItem(pMsg, "message") && !cJSON_IsNull(cJSON_GetObjectItem(pMsg, "message")) )
+						stJobProcessResp.strMessage = cJSON_GetObjectItem(pMsg, "message") ? cJSON_GetObjectItem(pMsg, "message")->valuestring : "";
+					if ( cJSON_GetObjectItem(pMsg, "str") && !cJSON_IsNull(cJSON_GetObjectItem(pMsg, "str")) )
+						stJobProcessResp.strStr = cJSON_GetObjectItem(pMsg, "str") ? (cJSON_GetObjectItem(pMsg, "str")->valuestring ? cJSON_GetObjectItem(pMsg, "str")->valuestring : "") : "";
 					if ( stJobProcessResp.strCode == "00" )
 					{				
 						cJSON *pObj = cJSON_GetObjectItem(pMsg, "data");

+ 2 - 0
SATHTTP/SATHTTP/SATHTTP.h

@@ -301,6 +301,7 @@ namespace SATHTTP{
 		std::string strDeviceId;
 		std::string strTaskId;
 		std::string strExecuteId;
+		std::string strTaskType;
 	}STNotifyJobStartReq, *pSTNotifyJobStartReq;
 
 	typedef struct __ST_NOTIFY_JOB_START_RESP__:__ST_RESPONE__
@@ -349,6 +350,7 @@ namespace SATHTTP{
 		std::string strRoundNumber;
 		std::string strResultType;
 		std::string strOperationStep;
+		std::string strInstanceType;
 	}STJobProcessReq, *pSTJobProcessReq;
 
 	typedef struct __ST_JOB_PROCESS_RESP__:__ST_RESPONE__