Commit f3e81c8e by guanghui.cui

修改通用预警报文格式

parent ad858604
......@@ -1799,8 +1799,8 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN
std::string JsonModule::_convertToCommonWarnJson(IN const char* json)
{
std::string notifyDate,notifyDesc,rackNo,storeId,terminalNo;
int notifyType=0;
std::string notifyDate, notifyType, message;
rapidjson::Document document; // 定义一个Document对象
document.Parse(json); // 解析,Parse()无返回值,也不会抛异常
if (document.HasParseError()) // 通过HasParseError()来判断解析是否成功
......@@ -1813,12 +1813,11 @@ std::string JsonModule::_convertToCommonWarnJson(IN const char* json)
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");
message = GetJsonStringSafe(document, "message");
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)
writer.Key("notifyDate");
writer.String(notifyDate.c_str());
writer.Key("notifyDesc");
writer.String(notifyDesc.c_str());
writer.Key("message");
writer.String(message.c_str());
writer.Key("notifyType");
writer.Int(notifyType);
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.String(notifyType.c_str());
writer.EndObject();
......@@ -2035,3 +2025,60 @@ std::string JsonModule::_getPickupCodeString(std::string &channel,std::string &p
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:
int _getODSStatusByPOSReq(int fm_cmd);
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 _getRefundObj(IN orderObj &order_obj,OUT refundObj &refund_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