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
2483b050
Commit
2483b050
authored
Feb 28, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式修改
parent
d746014e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
26 deletions
+24
-26
src/JsonModule.cpp
+2
-5
src/SocketModule.cpp
+7
-7
src/SocketModule.h
+7
-7
src/main.cpp
+8
-7
No files found.
src/JsonModule.cpp
View file @
2483b050
...
...
@@ -133,7 +133,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
order
.
create_time
=
createTime
.
GetString
();
//用户信息
//TODO 顾客信息为数组 因接口改版目前只有一个顾客信息
//TODO 顾客信息为数组 因接口改版目前只有一个顾客信息
rapidjson
::
Value
&
customer_array
=
orderContent_obj
[
"customer"
];
if
(
customer_array
.
IsArray
())
{
...
...
@@ -276,10 +276,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
{
rapidjson
::
Value
&
points_obj
=
orderContent_obj
[
"points"
];
rapidjson
::
Value
&
totalPoint
=
points_obj
[
"totalPoint"
];
char
temp
[
20
]
=
{
0
};
int
iPoint
=
totalPoint
.
GetInt
();
sprintf
(
temp
,
"%d"
,
iPoint
);
order
.
bonusInfo
.
summary
=
temp
;
order
.
bonusInfo
.
summary
=
std
::
to_string
(
totalPoint
.
GetInt
());
//积分信息详情
{
...
...
src/SocketModule.cpp
View file @
2483b050
...
...
@@ -108,16 +108,16 @@ bool TCPServer::doListen(unsigned short int port, const char *ip, int backlog)
if
(
reuseaddr
()
)
if
(
bind
(
port
,
ip
)
)
if
(
listen
(
backlog
)
)
{
return
true
;
}
{
return
true
;
}
return
false
;
}
bool
TCPServer
::
accept
(
TCPSocket
&
clientSocket
)
const
{
return
TCPSocket
::
accept
(
clientSocket
);
return
TCPSocket
::
accept
(
clientSocket
);
}
/** client端特有的send/receive **/
...
...
@@ -147,7 +147,7 @@ bool TCPClient::send(const std::string& message)
if
(
writen
(
m_sockfd
,
&
buf
,
sizeof
(
buf
.
msgLen
)
+
message
.
length
())
==
-
1
)
{
m_bValid
=
false
;
return
false
;
return
false
;
}
return
true
;
}
...
...
@@ -190,7 +190,7 @@ bool TCPClient::read(void *buf, size_t count)
if
(
readBytes
==
-
1
)
{
m_bValid
=
false
;
return
false
;
return
false
;
}
return
true
;
}
...
...
@@ -200,7 +200,7 @@ bool TCPClient::write(const char *msg)
if
(
::
write
(
m_sockfd
,
msg
,
strlen
(
msg
))
==
-
1
)
{
m_bValid
=
false
;
return
false
;
return
false
;
}
return
true
;
}
...
...
src/SocketModule.h
View file @
2483b050
...
...
@@ -50,14 +50,14 @@ public:
/* 该函数会强制删除现有socket重新创建连接 */
bool
doConnect
(
unsigned
short
port
,
const
char
*
ip
);
bool
read
(
void
*
buf
,
size_t
count
);
bool
read
(
void
*
buf
,
size_t
count
);
bool
write
(
const
char
*
msg
);
bool
receive
(
std
::
string
&
message
);
bool
send
(
const
std
::
string
&
message
);
bool
isValid
(){
return
m_bValid
;
}
bool
send
(
const
std
::
string
&
message
);
bool
isValid
(){
return
m_bValid
;
}
private
:
bool
m_bValid
;
bool
m_bValid
;
};
/** TCP Server **/
...
...
@@ -66,10 +66,10 @@ class TCPServer : public TCPSocket
public
:
TCPServer
(){}
~
TCPServer
(){}
/* 该函数会强制删除现有socket重新创建监听 */
bool
doListen
(
unsigned
short
int
port
,
const
char
*
ip
=
NULL
,
int
backlog
=
SOMAXCONN
);
bool
accept
(
TCPSocket
&
clientSocket
)
const
;
bool
accept
(
TCPSocket
&
clientSocket
)
const
;
};
#endif
src/main.cpp
View file @
2483b050
...
...
@@ -67,6 +67,7 @@ void* listen_pos_func(void* arg)
{
g_init_data
=
posRequestData
;
jsonTool
.
getPosResponseData
(
100
,
"successful!"
,
responseData
);
LOG
(
INFO
)
<<
"POS init data:"
<<
g_init_data
.
c_str
();
}
else
{
jsonTool
.
getPosResponseData
(
101
,
"invalid initdata!"
,
responseData
);
...
...
@@ -122,14 +123,14 @@ void* listen_pos_func(void* arg)
int
main
()
{
{
/* Mark
* 与ODS通信全部加数据头(长度)
* 与POS通信全部不加数据头
* end*/
signal
(
SIGPIPE
,
SIG_IGN
);
// 初始化日志
el
::
Loggers
::
addFlag
(
el
::
LoggingFlag
::
StrictLogFileSizeCheck
);
std
::
string
strBinPath
=
GetProcDir
();
...
...
@@ -141,7 +142,7 @@ int main()
/// 注册回调函数
el
::
Helpers
::
installPreRollOutCallback
(
logRolloutHandler
);
LOG
(
INFO
)
<<
"---------
程序启动
---------"
;
LOG
(
INFO
)
<<
"---------
software start
---------"
;
// 读取配置文件信息
std
::
string
strIniPath
(
strBinPath
.
data
());
...
...
@@ -213,12 +214,12 @@ int main()
if
(
ods
.
receive
(
odsPushData
)
)
{
LOG
(
INFO
)
<<
"----------------recved ODS data------------------"
;
LOG
(
INFO
)
<<
odsPushData
;
LOG
(
INFO
)
<<
"----------------recved ODS data------------------"
;
LOG
(
INFO
)
<<
odsPushData
;
if
(
jsonTool
.
convertDataOds2Pos
(
odsPushData
,
pushPosData
)
)
{
LOG
(
INFO
)
<<
"********convert data to pos************"
;
LOG
(
INFO
)
<<
pushPosData
;
LOG
(
INFO
)
<<
"********convert data to pos************"
;
LOG
(
INFO
)
<<
pushPosData
;
TCPClient
pos
;
if
(
pos
.
doConnect
(
pos_listen_port
,
pos_ip
.
c_str
())
)
{
...
...
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