Commit f3e81c8e by guanghui.cui

修改通用预警报文格式

parent ad858604
...@@ -1799,8 +1799,8 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN ...@@ -1799,8 +1799,8 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN
std::string JsonModule::_convertToCommonWarnJson(IN const char* json) std::string JsonModule::_convertToCommonWarnJson(IN const char* json)
{ {
std::string notifyDate,notifyDesc,rackNo,storeId,terminalNo; std::string notifyDate, notifyType, message;
int notifyType=0;
rapidjson::Document document; // 定义一个Document对象 rapidjson::Document document; // 定义一个Document对象
document.Parse(json); // 解析,Parse()无返回值,也不会抛异常 document.Parse(json); // 解析,Parse()无返回值,也不会抛异常
if (document.HasParseError()) // 通过HasParseError()来判断解析是否成功 if (document.HasParseError()) // 通过HasParseError()来判断解析是否成功
...@@ -1813,12 +1813,11 @@ std::string JsonModule::_convertToCommonWarnJson(IN const char* json) ...@@ -1813,12 +1813,11 @@ std::string JsonModule::_convertToCommonWarnJson(IN const char* json)
int64_t iDate = GetJsonInt64Safe(document,"notifyDate"); int64_t iDate = GetJsonInt64Safe(document,"notifyDate");
notifyDate = getdatetime(iDate); notifyDate = getdatetime(iDate);
notifyDesc = GetJsonStringSafe(document, "notifyDesc"); message = GetJsonStringSafe(document, "message");
rackNo = GetJsonStringSafe(document, "rackNo");
storeId = GetJsonStringSafe(document, "storeId");
terminalNo = GetJsonStringSafe(document, "terminalNo");
notifyType = GetJsonIntSafe(document, "notifyType"); int type = 0;
type = GetJsonIntSafe(document, "notifyType");
notifyType = _getCommonWarnStringByCode(type);
} }
...@@ -1832,20 +1831,11 @@ std::string JsonModule::_convertToCommonWarnJson(IN const char* json) ...@@ -1832,20 +1831,11 @@ std::string JsonModule::_convertToCommonWarnJson(IN const char* json)
writer.Key("notifyDate"); writer.Key("notifyDate");
writer.String(notifyDate.c_str()); writer.String(notifyDate.c_str());
writer.Key("notifyDesc"); writer.Key("message");
writer.String(notifyDesc.c_str()); writer.String(message.c_str());
writer.Key("notifyType"); writer.Key("notifyType");
writer.Int(notifyType); writer.String(notifyType.c_str());
writer.Key("rackNo");
writer.String(rackNo.c_str());
writer.Key("storeId");
writer.String(storeId.c_str());
writer.Key("terminalNo");
writer.String(terminalNo.c_str());
writer.EndObject(); writer.EndObject();
...@@ -2034,4 +2024,61 @@ std::string JsonModule::_getPickupCodeString(std::string &channel,std::string &p ...@@ -2034,4 +2024,61 @@ std::string JsonModule::_getPickupCodeString(std::string &channel,std::string &p
#endif // WIN32 #endif // WIN32
return rlt; return rlt;
}
std::string JsonModule::_getCommonWarnStringByCode(int type)
{
std::string rlt;
switch (type)
{
case 1:
rlt = "网络故障";
break;
case 2:
rlt = "纸币器故障";
break;
case 3:
rlt = "硬币器故障";
break;
case 4:
rlt = "卡货";
break;
case 5:
rlt = "齿轮盒故障";
break;
case 6:
rlt = "暂停使用";
break;
case 7:
rlt = "缺货";
break;
case 8:
rlt = "商品未取出";
break;
case 9:
rlt = "温度异常";
break;
case 10:
rlt = "取货口门未关";
break;
case 11:
rlt = "升降机故障";
break;
case 12:
rlt = "升降机质检错误";
break;
case 13:
rlt = "流量异常";
break;
case 14:
rlt = "时间异常";
break;
default:
break;
}
//vs默认编码是gbk,如果是windows系统,需要转换为utf8编码
#ifdef WIN32
rlt = charset_g2u(rlt);
#endif // WIN32
return rlt;
} }
\ No newline at end of file
...@@ -112,6 +112,9 @@ private: ...@@ -112,6 +112,9 @@ private:
int _getODSStatusByPOSReq(int fm_cmd); int _getODSStatusByPOSReq(int fm_cmd);
std::string _getPickupCodeString(std::string &channel,std::string &pickup_code); std::string _getPickupCodeString(std::string &channel,std::string &pickup_code);
//获取通用预警故障字符串
std::string _getCommonWarnStringByCode(int type);
void _getStatusObj(IN orderObj &order_obj,OUT orderStatusObj &status_obj); void _getStatusObj(IN orderObj &order_obj,OUT orderStatusObj &status_obj);
void _getRefundObj(IN orderObj &order_obj,OUT refundObj &refund_obj); void _getRefundObj(IN orderObj &order_obj,OUT refundObj &refund_obj);
void _getStockWarnObj(IN const char* json,OUT stockWarnObj &warn_obj); void _getStockWarnObj(IN const char* json,OUT stockWarnObj &warn_obj);
......
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