Commit 04ef5760 by guanghui.cui

库存预警和通用预警字段修改

parent 69839807
...@@ -91,6 +91,17 @@ int GetJsonIntSafe(rapidjson::Value& obj,const char* key) ...@@ -91,6 +91,17 @@ int GetJsonIntSafe(rapidjson::Value& obj,const char* key)
return 0; return 0;
} }
int64_t GetJsonInt64Safe(rapidjson::Value& obj, const char* key)
{
if (obj.HasMember(key)) {
rapidjson::Value& vObj = obj[key];
if (vObj.IsInt64()) {
return vObj.GetInt64();
}
}
return 0;
}
void JsonModule::jsonTest() void JsonModule::jsonTest()
{ {
std::string json="{\"title\":\"PLAYER INFO\",\"num\":null,\"players\":[{ \"id\":123,\"name\":\"test\"}]}"; std::string json="{\"title\":\"PLAYER INFO\",\"num\":null,\"players\":[{ \"id\":123,\"name\":\"test\"}]}";
...@@ -1628,10 +1639,22 @@ void JsonModule::_getStockWarnObj(IN const char* json,OUT stockWarnObj &warn_obj ...@@ -1628,10 +1639,22 @@ void JsonModule::_getStockWarnObj(IN const char* json,OUT stockWarnObj &warn_obj
detail.safeQty = safeQty.GetInt(); detail.safeQty = safeQty.GetInt();
} }
rapidjson::Value& alertTime = document["alertTime"]; int64_t iDatetime = GetJsonInt64Safe(document, "alertTime");
int64_t iDatetime = alertTime.GetInt64();
detail.alertTime = getdatetime(iDatetime); detail.alertTime = getdatetime(iDatetime);
GetJsonStringSafe(document, "barCounter");
detail.source = GetJsonStringSafe(document, "channel");
GetJsonIntSafe(document, "id");
GetJsonStringSafe(document, "memo");
GetJsonStringSafe(document, "pcId");
GetJsonStringSafe(document, "posId");
detail.stock = GetJsonIntSafe(document, "qty");
detail.safeQty = GetJsonIntSafe(document, "saftQty");
GetJsonStringSafe(document, "selfMacId");
GetJsonStringSafe(document, "shelfNo");
detail.sku = GetJsonStringSafe(document, "sku");
GetJsonStringSafe(document, "storeId");
warn_obj.vecProducts.push_back(detail); warn_obj.vecProducts.push_back(detail);
} }
} }
...@@ -1783,24 +1806,15 @@ std::string JsonModule::_convertToCommonWarnJson(IN const char* json) ...@@ -1783,24 +1806,15 @@ std::string JsonModule::_convertToCommonWarnJson(IN const char* json)
} }
else else
{ {
rapidjson::Value& vNotifyDate = document["notifyDate"]; int64_t iDate = GetJsonInt64Safe(document,"notifyDate");
rapidjson::Value& vNotifyDesc = document["notifyDesc"]; notifyDate = getdatetime(iDate);
rapidjson::Value& vNotifyType = document["notifyType"];
rapidjson::Value& vRackNo = document["rackNo"];
rapidjson::Value& vStoreId = document["storeId"];
rapidjson::Value& vTerminalNo = document["terminalNo"];
int64_t iDate = vNotifyDate.GetInt64(); notifyDesc = GetJsonStringSafe(document, "notifyDesc");
notifyDate=getdatetime(iDate); rackNo = GetJsonStringSafe(document, "rackNo");
storeId = GetJsonStringSafe(document, "storeId");
terminalNo = GetJsonStringSafe(document, "terminalNo");
if(!vNotifyDesc.IsNull()){ notifyType = GetJsonIntSafe(document, "notifyType");
notifyDesc=vNotifyDesc.GetString();
}
notifyType = vNotifyType.GetInt();
rackNo = vRackNo.GetString();
storeId = vStoreId.GetString();
terminalNo = vTerminalNo.GetString();
} }
...@@ -1847,15 +1861,10 @@ bool JsonModule::_getCommonWarnResponseJson(IN const std::string& posResponse, I ...@@ -1847,15 +1861,10 @@ bool JsonModule::_getCommonWarnResponseJson(IN const std::string& posResponse, I
} }
else else
{ {
rapidjson::Value& vNotifyDate = document1["notifyDate"]; iDatetime = GetJsonInt64Safe(document1, "notifyDate");
rapidjson::Value& vRackNo = document1["rackNo"]; rackNo = GetJsonStringSafe(document1, "rackNo");
rapidjson::Value& vStoreId = document1["storeId"]; storeId = GetJsonStringSafe(document1, "storeId");
rapidjson::Value& vTerminalNo = document1["terminalNo"]; terminalNo = GetJsonStringSafe(document1, "terminalNo");
iDatetime = vNotifyDate.GetInt64();
rackNo = vRackNo.GetString();
storeId = vStoreId.GetString();
terminalNo = vTerminalNo.GetString();
pk_id = GetJsonIntSafe(document1,"pk_id"); pk_id = GetJsonIntSafe(document1,"pk_id");
} }
document.Parse(posResponse.c_str()); document.Parse(posResponse.c_str());
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
INITIALIZE_EASYLOGGINGPP INITIALIZE_EASYLOGGINGPP
#define VERSION "1.0.3 Beta 2" //版本号 #define VERSION "1.0.3 Beta 4" //版本号
std::string g_init_data; std::string g_init_data;
std::string g_init_data_ods_back; std::string g_init_data_ods_back;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment