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
d746014e
Commit
d746014e
authored
Feb 28, 2018
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upd 1:修改日志描述为英文
parent
d28fc2cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
18 deletions
+22
-18
src/JsonModule.cpp
+3
-3
src/main.cpp
+19
-15
No files found.
src/JsonModule.cpp
View file @
d746014e
...
...
@@ -483,7 +483,7 @@ bool JsonModule::getOdsResponseData(int status_code, const std::string &msg, std
{
/*
{
"
type
" : 2,
"
fm_cmd
" : 2,
"order_id" : "xxxxx",
"status" : 1,
"status_code" : 100,
...
...
@@ -494,7 +494,7 @@ bool JsonModule::getOdsResponseData(int status_code, const std::string &msg, std
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
writer
.
Key
(
"
type
"
);
writer
.
Key
(
"
fm_cmd
"
);
writer
.
Int
(
2
);
writer
.
Key
(
"order_id"
);
...
...
@@ -551,7 +551,7 @@ bool JsonModule::getOdsResponseData(const std::string &posResponse, const std::s
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
writer
.
Key
(
"
type
"
);
writer
.
Key
(
"
fm_cmd
"
);
writer
.
Int
(
2
);
writer
.
Key
(
"order_id"
);
...
...
src/main.cpp
View file @
d746014e
...
...
@@ -40,10 +40,10 @@ void* listen_pos_func(void* arg)
if
(
server
.
doListen
(
client_listen_port
)
)
{
LOG
(
INFO
)
<<
"
监听端口: ["
<<
client_listen_port
<<
"] 成功
"
;
LOG
(
INFO
)
<<
"
local listen port: ["
<<
client_listen_port
<<
"] successful
"
;
}
else
{
LOG
(
INFO
)
<<
"
监听端口: ["
<<
client_listen_port
<<
"] 失败
"
;
LOG
(
INFO
)
<<
"
local listen port: ["
<<
client_listen_port
<<
"] failed
"
;
}
while
(
true
)
...
...
@@ -111,11 +111,11 @@ void* listen_pos_func(void* arg)
pos
.
close
();
}
else
{
LOG
(
INFO
)
<<
"
接收POS推送消息失败
"
;
LOG
(
INFO
)
<<
"
recv pos pushDate failed
"
;
}
}
else
{
LOG
(
INFO
)
<<
"
接收POS连接失败
"
;
LOG
(
INFO
)
<<
"
accept pos connect failed
"
;
}
}
}
...
...
@@ -156,12 +156,12 @@ int main()
client_listen_port
=
ZIni
::
readInt
(
"SYS"
,
"port"
,
0
,
strIniPath
.
c_str
());
LOG
(
INFO
)
<<
"[ODS]ip
地址
: "
<<
ods_ip
.
data
()
<<
"-
推送端口
: "
<<
ods_push_port
<<
"-
监听端口
: "
<<
ods_recv_port
;
LOG
(
INFO
)
<<
"[POS]ip
地址
: "
<<
pos_ip
<<
"-
监听端口
: "
<<
pos_listen_port
;
LOG
(
INFO
)
<<
"[
CLIENT]监听端口
: "
<<
client_listen_port
;
LOG
(
INFO
)
<<
"[ODS]ip: "
<<
ods_ip
.
data
()
<<
"-
push port
: "
<<
ods_push_port
<<
"-
recv port
: "
<<
ods_recv_port
;
LOG
(
INFO
)
<<
"[POS]ip: "
<<
pos_ip
<<
"-
listen port
: "
<<
pos_listen_port
;
LOG
(
INFO
)
<<
"[
Local]listen port
: "
<<
client_listen_port
;
//end
// 监听POS请求的线程
...
...
@@ -169,7 +169,7 @@ int main()
/*创建 listen_pos 线程*/
if
(
pthread_create
(
&
listen_pos_id
,
NULL
,
listen_pos_func
,
NULL
))
LOG
(
INFO
)
<<
"
创建listen_pos线程失败
"
;
LOG
(
INFO
)
<<
"
create listen_pos thread failed
"
;
TCPClient
ods
;
JsonModule
jsonTool
;
...
...
@@ -185,12 +185,12 @@ int main()
{
if
(
ods
.
doConnect
(
ods_push_port
,
ods_ip
.
c_str
())
)
{
LOG
(
INFO
)
<<
"
连接ODS成功
"
;
LOG
(
INFO
)
<<
"
connect ODS successful
"
;
// 注册socket信息
while
(
true
)
{
g_init_data
=
"{
\"
fm_cmd
\"
: 1000,
\"
store_id
\"
:
\"
0001
\"
,
\"
pos_id
\"
:
\"
0001
\"
,
\"
operator_id
\"
:
\"
00001
\"
,
\"
business_date
\"
:
\"
20171225
\"
,
\"
is_master
\"
: fals
e,
\"
listen_port
\"
: 3289}"
;
g_init_data
=
"{
\"
fm_cmd
\"
: 1000,
\"
store_id
\"
:
\"
208888
\"
,
\"
pos_id
\"
:
\"
0001
\"
,
\"
operator_id
\"
:
\"
00001
\"
,
\"
business_date
\"
:
\"
20171225
\"
,
\"
is_master
\"
: tru
e,
\"
listen_port
\"
: 3289}"
;
if
(
!
g_init_data
.
empty
())
{
...
...
@@ -205,7 +205,7 @@ int main()
}
}
else
{
LOG
(
INFO
)
<<
"
连接ODS失败
"
;
LOG
(
INFO
)
<<
"
connect ODS failed
"
;
sleep
(
2
);
continue
;
}
...
...
@@ -213,8 +213,12 @@ int main()
if
(
ods
.
receive
(
odsPushData
)
)
{
LOG
(
INFO
)
<<
"----------------recved ODS data------------------"
;
LOG
(
INFO
)
<<
odsPushData
;
if
(
jsonTool
.
convertDataOds2Pos
(
odsPushData
,
pushPosData
)
)
{
LOG
(
INFO
)
<<
"********convert data to pos************"
;
LOG
(
INFO
)
<<
pushPosData
;
TCPClient
pos
;
if
(
pos
.
doConnect
(
pos_listen_port
,
pos_ip
.
c_str
())
)
{
...
...
@@ -248,7 +252,7 @@ int main()
ods
.
send
(
responseData
);
}
else
{
LOG
(
INFO
)
<<
"
接收ODS推送消息失败
"
;
LOG
(
INFO
)
<<
"
recv ODS pushDate failed
"
;
}
}
...
...
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