Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
familyMart_takeaway
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanghui.cui
familyMart_takeaway
Commits
f3e81c8e
Commit
f3e81c8e
authored
Jun 06, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改通用预警报文格式
parent
ad858604
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
19 deletions
+70
-19
src/JsonModule.cpp
+67
-19
src/JsonModule.h
+3
-0
No files found.
src/JsonModule.cpp
View file @
f3e81c8e
...
@@ -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
src/JsonModule.h
View file @
f3e81c8e
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment