Commit 04ef5760 by guanghui.cui

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

parent 69839807
......@@ -91,6 +91,17 @@ int GetJsonIntSafe(rapidjson::Value& obj,const char* key)
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()
{
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
detail.safeQty = safeQty.GetInt();
}
rapidjson::Value& alertTime = document["alertTime"];
int64_t iDatetime = alertTime.GetInt64();
int64_t iDatetime = GetJsonInt64Safe(document, "alertTime");
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);
}
}
......@@ -1783,24 +1806,15 @@ std::string JsonModule::_convertToCommonWarnJson(IN const char* json)
}
else
{
rapidjson::Value& vNotifyDate = document["notifyDate"];
rapidjson::Value& vNotifyDesc = document["notifyDesc"];
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();
notifyDate=getdatetime(iDate);
if(!vNotifyDesc.IsNull()){
notifyDesc=vNotifyDesc.GetString();
}
int64_t iDate = GetJsonInt64Safe(document,"notifyDate");
notifyDate = getdatetime(iDate);
notifyDesc = GetJsonStringSafe(document, "notifyDesc");
rackNo = GetJsonStringSafe(document, "rackNo");
storeId = GetJsonStringSafe(document, "storeId");
terminalNo = GetJsonStringSafe(document, "terminalNo");
notifyType = vNotifyType.GetInt();
rackNo = vRackNo.GetString();
storeId = vStoreId.GetString();
terminalNo = vTerminalNo.GetString();
notifyType = GetJsonIntSafe(document, "notifyType");
}
......@@ -1847,15 +1861,10 @@ bool JsonModule::_getCommonWarnResponseJson(IN const std::string& posResponse, I
}
else
{
rapidjson::Value& vNotifyDate = document1["notifyDate"];
rapidjson::Value& vRackNo = document1["rackNo"];
rapidjson::Value& vStoreId = document1["storeId"];
rapidjson::Value& vTerminalNo = document1["terminalNo"];
iDatetime = vNotifyDate.GetInt64();
rackNo = vRackNo.GetString();
storeId = vStoreId.GetString();
terminalNo = vTerminalNo.GetString();
iDatetime = GetJsonInt64Safe(document1, "notifyDate");
rackNo = GetJsonStringSafe(document1, "rackNo");
storeId = GetJsonStringSafe(document1, "storeId");
terminalNo = GetJsonStringSafe(document1, "terminalNo");
pk_id = GetJsonIntSafe(document1,"pk_id");
}
document.Parse(posResponse.c_str());
......
......@@ -18,7 +18,7 @@
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_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