Commit 2483b050 by guanghui.cui

格式修改

parent d746014e
......@@ -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());
//积分信息详情
{
......
......@@ -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;
}
......
......@@ -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
......@@ -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()) )
{
......
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