Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmtakeout
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
李定达
fmtakeout
Commits
5ecf3434
Commit
5ecf3434
authored
Jun 12, 2019
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加对接相关代码
parent
a879ae35
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
236 additions
and
6 deletions
+236
-6
takeout/control/ordergetwork.cpp
+17
-2
takeout/control/rpainterface.cpp
+163
-0
takeout/control/rpainterface.h
+31
-0
takeout/event/posevent.cpp
+3
-1
takeout/event/posevent.h
+4
-0
takeout/takeout.pro
+5
-3
takeout/view/floatForm.cpp
+6
-0
takeout/view/mainForm.cpp
+7
-0
No files found.
takeout/control/ordergetwork.cpp
View file @
5ecf3434
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#include "event/fmapplication.h"
#include "event/fmapplication.h"
#include "event/posevent.h"
#include "event/posevent.h"
#include "base/Network/billSocket.h"
#include "model/posorderpool.h"
#include "model/posorderpool.h"
#include <QNetworkAccessManager>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkReply>
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#include <QEventLoop>
#include <QEventLoop>
#include <QVariantMap>
#include <QVariantMap>
#include <QSettings>
#include <QSettings>
#include "rpainterface.h"
#include "QsLog.h"
#include "QsLog.h"
OrderGetWork
::
OrderGetWork
(
WorkObject
*
parent
)
:
WorkObject
(
parent
)
OrderGetWork
::
OrderGetWork
(
WorkObject
*
parent
)
:
WorkObject
(
parent
)
...
@@ -601,6 +601,21 @@ void OrderGetWork::optOrder(const QJsonArray &orders)
...
@@ -601,6 +601,21 @@ void OrderGetWork::optOrder(const QJsonArray &orders)
//PosOrderPool::TryInsertOrder(orderObject);
//PosOrderPool::TryInsertOrder(orderObject);
POSTEVENTTYPE
(
PosEvent
::
s_inset_orderpool
,
orderObject
,
OrderObject
);
POSTEVENTTYPE
(
PosEvent
::
s_inset_orderpool
,
orderObject
,
OrderObject
);
//是否发送给rpa。这里测试,先写死,后面从配置文件读取
bool
isSendToRPA
=
true
;
if
(
isSendToRPA
){
//已完成的订单才发送给RPA
//if(orderObject.status == ServiceOrder || orderObject.status == CompleteOrder){
if
(
orderObject
.
status
==
FirmOrder
){
QString
error
;
if
(
!
RpaInterface
::
sendToRPA
(
QJsonDocument
(
jsonObject
).
toJson
(
QJsonDocument
::
Compact
),
error
)){
QLOG_ERROR
()
<<
"send to rpa failed:"
<<
error
;
}
else
{
QLOG_INFO
()
<<
"send data to RPA,orderid:"
<<
orderObject
.
order_id
;
}
}
}
}
}
}
}
...
...
takeout/control/rpainterface.cpp
0 → 100644
View file @
5ecf3434
#
include
"rpainterface.h"
#include "QsLog.h"
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonParseError>
#include "event/posevent.h"
#include "event/fmapplication.h"
#define BUFFER_SIZE 1024 //缓冲区大小
#define SEND_PORT 30001 //socket发送端口
#define SERVER_PORT 30002 //socket接收端口
RpaInterface
::
RpaInterface
()
:
QTcpServer
(),
socket
(
nullptr
)
{
if
(
!
this
->
listen
(
QHostAddress
::
Any
,
SERVER_PORT
))
{
QLOG_INFO
()
<<
"Listen error: "
<<
this
->
errorString
();
}
connect
(
this
,
&
QTcpServer
::
newConnection
,
this
,
&
RpaInterface
::
onNewConnection
);
}
void
RpaInterface
::
onNewConnection
()
{
socket
=
nextPendingConnection
();
connect
(
socket
,
&
QTcpSocket
::
disconnected
,
this
,
&
RpaInterface
::
onDisconnected
);
connect
(
socket
,
&
QTcpSocket
::
readyRead
,
this
,
&
RpaInterface
::
onReadyRead
);
}
void
RpaInterface
::
onDisconnected
()
{
QLOG_INFO
()
<<
"Socket disconnected."
;
socket
->
close
();
}
void
RpaInterface
::
onReadyRead
()
{
QLOG_INFO
()
<<
"onReadyRead."
;
char
*
recvBuf
=
new
char
[
BUFFER_SIZE
*
10
];
if
(
socket
->
isOpen
()){
int
length
=
socketRecvData
(
recvBuf
,
BUFFER_SIZE
*
10
,
socket
);
if
(
length
>
0
){
QLOG_INFO
()
<<
"onReadyRead data:"
<<
recvBuf
;
QJsonObject
recvObj
=
QJsonDocument
::
fromJson
(
recvBuf
).
object
();
if
(
recvObj
.
contains
(
"show_window"
)){
bool
show
=
recvObj
[
"show_window"
].
toBool
();
if
(
show
){
DEFAULTPOSTEVENT
(
PosEvent
::
s_show_float
,
""
);
}
else
{
DEFAULTPOSTEVENT
(
PosEvent
::
s_hide_mainform
,
""
);
DEFAULTPOSTEVENT
(
PosEvent
::
s_hide_float
,
""
);
}
}
}
}
socket
->
waitForDisconnected
();
}
//socket 数据接收
//返回值 成功:接收长度
// 失败: -1
int
RpaInterface
::
socketRecvData
(
char
*
recvBuf
,
int
bufSize
,
QTcpSocket
*
sockClient
)
{
int
rcvedLength
=
0
;
int
rcvFlag
=
0
;
//firstly, to rcv header
int
needLength
=
sizeof
(
FMSOCKEHEADER
);
int
rlt
=
0
;
QLOG_INFO
()
<<
"start recv data"
;
FMSOCKEHEADER
headx
;
char
*
pcRcvBufer
=
(
char
*
)(
&
headx
);
while
(
0
<
needLength
)
{
//接收并打印客户端数据
int
length
=
sockClient
->
read
(
pcRcvBufer
+
rcvedLength
,
needLength
);
if
(
0
<
length
)
{
needLength
-=
length
;
rcvedLength
+=
length
;
if
(
0
==
needLength
)
{
if
(
0
==
rcvFlag
)
{
//header rcved complete
rcvFlag
=
1
;
//to rcv payload
int
flag
=
headx
.
flag
;
int
len
=
headx
.
len
;
int
ver
=
headx
.
ver
;
if
(
len
>
bufSize
)
{
rlt
=
-
1
;
QLOG_INFO
()
<<
"socket recv 接收数据长度大于接收缓冲区:"
<<
len
;
break
;
}
needLength
=
len
;
pcRcvBufer
=
recvBuf
;
rcvedLength
=
0
;
continue
;
}
else
{
rlt
=
rcvedLength
;
break
;
}
}
}
else
if
(
length
==
0
)
{
//socket error
rlt
=
-
1
;
QLOG_INFO
()
<<
"socket recv:"
<<
length
;
break
;
}
}
recvBuf
[
rcvedLength
]
=
'\0'
;
return
rlt
;
}
bool
RpaInterface
::
sendToRPA
(
const
QByteArray
&
orderData
,
QString
&
error
)
{
bool
result
=
true
;
QTcpSocket
client
;
qDebug
()
<<
"SendToMonitor to pos: "
<<
orderData
;
int
jsonLength
=
orderData
.
length
();
char
*
m_pFmPackage
=
new
char
[
jsonLength
+
sizeof
(
FMSOCKEHEADER
)];
FMSOCKEHEADER
header
=
{
0
,
0
,
0
};
header
.
flag
=
0x4d46
;
header
.
len
=
jsonLength
;
header
.
ver
=
0x1
;
memcpy
(
m_pFmPackage
,
&
header
,
sizeof
(
FMSOCKEHEADER
));
memcpy
(
m_pFmPackage
+
sizeof
(
FMSOCKEHEADER
),
orderData
,
jsonLength
);
int
toSendLength
=
jsonLength
+
sizeof
(
FMSOCKEHEADER
);
int
curSendLength
=
0
;
client
.
connectToHost
(
"127.0.0.1"
,
SEND_PORT
);
if
(
client
.
waitForConnected
()){
while
(
curSendLength
<
toSendLength
)
{
int
rlt
=
client
.
write
(
m_pFmPackage
+
curSendLength
,
toSendLength
-
curSendLength
);
client
.
waitForBytesWritten
();
if
(
rlt
==-
1
){
error
=
"socket send error"
;
result
=
false
;
break
;
}
curSendLength
+=
rlt
;
}
}
else
{
error
=
"socket connect failed"
;
result
=
false
;
}
client
.
close
();
delete
[]
m_pFmPackage
;
return
result
;
}
takeout/control/rpainterface.h
0 → 100644
View file @
5ecf3434
#
ifndef
RPAINTERFACE_H
#define RPAINTERFACE_H
#include <QTcpServer>
#include <QTcpSocket>
#define FMSOCKFLAG 0x4d46
typedef
struct
{
int
flag
;
int
ver
;
int
len
;
}
FMSOCKEHEADER
;
class
RpaInterface
:
public
QTcpServer
{
Q_OBJECT
public
:
RpaInterface
();
static
bool
sendToRPA
(
const
QByteArray
&
orderData
,
QString
&
error
);
private
slots
:
void
onNewConnection
();
void
onDisconnected
();
void
onReadyRead
();
int
socketRecvData
(
char
*
recvBuf
,
int
bufSize
,
QTcpSocket
*
sockClient
);
private
:
QTcpSocket
*
socket
;
};
#endif // RPAINTERFACE_H
takeout/event/posevent.cpp
View file @
5ecf3434
#include "posevent.h"
#
include
"posevent.h"
#include <QDebug>
#include <QDebug>
#include <QMutexLocker>
#include <QMutexLocker>
...
@@ -17,7 +17,9 @@ QEvent::Type PosEvent::s_change_orderpool = static_cast<QEvent::Type>(QEvent::re
...
@@ -17,7 +17,9 @@ QEvent::Type PosEvent::s_change_orderpool = static_cast<QEvent::Type>(QEvent::re
QEvent
::
Type
PosEvent
::
s_location_orderpool
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_location_orderpool
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_login_storeinfo
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_login_storeinfo
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_show_float
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_show_float
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_hide_float
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_show_mainform
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_show_mainform
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_hide_mainform
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_show_prtform
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_show_prtform
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_show_login
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_show_login
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_network_outtime
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
QEvent
::
Type
PosEvent
::
s_network_outtime
=
static_cast
<
QEvent
::
Type
>
(
QEvent
::
registerEventType
());
...
...
takeout/event/posevent.h
View file @
5ecf3434
...
@@ -90,8 +90,12 @@ public:
...
@@ -90,8 +90,12 @@ public:
static
Type
s_login_storeinfo
;
static
Type
s_login_storeinfo
;
//悬浮窗界面显示
//悬浮窗界面显示
static
Type
s_show_float
;
static
Type
s_show_float
;
//悬浮窗界面隐藏
static
Type
s_hide_float
;
//主界面显示
//主界面显示
static
Type
s_show_mainform
;
static
Type
s_show_mainform
;
//主界面隐藏
static
Type
s_hide_mainform
;
//打印设置界面显示
//打印设置界面显示
static
Type
s_show_prtform
;
static
Type
s_show_prtform
;
//登录界面显示
//登录界面显示
...
...
takeout/takeout.pro
View file @
5ecf3434
...
@@ -21,7 +21,7 @@ LIBS += -L$$PWD/lib -llibeay32 -lssleay32 -lwinspool
...
@@ -21,7 +21,7 @@ LIBS += -L$$PWD/lib -llibeay32 -lssleay32 -lwinspool
LIBS
+=
-
lWs2_32
LIBS
+=
-
lWs2_32
LIBS
+=
-
lDbghelp
LIBS
+=
-
lDbghelp
DEFINES
+=
USE_QAACTION
#
DEFINES += USE_QAACTION
DEFINES
+=
FM_NEW_UI
DEFINES
+=
FM_NEW_UI
#DEFINES += FM_TEST
#DEFINES += FM_TEST
...
@@ -86,7 +86,8 @@ SOURCES += \
...
@@ -86,7 +86,8 @@ SOURCES += \
$$
PWD
/
view
/
newchangeshiftsform
.
cpp
\
$$
PWD
/
view
/
newchangeshiftsform
.
cpp
\
$$
PWD
/
base
/
Arithmetic
/
cretopt
.
cpp
\
$$
PWD
/
base
/
Arithmetic
/
cretopt
.
cpp
\
$$
PWD
/
control
/
driverinfogetwork
.
cpp
\
$$
PWD
/
control
/
driverinfogetwork
.
cpp
\
$$
PWD
/
view
/
newfloatform
.
cpp
$$
PWD
/
view
/
newfloatform
.
cpp
\
control
/
rpainterface
.
cpp
HEADERS
+=
\
HEADERS
+=
\
$$
PWD
/
event
/
fmapplication
.
h
\
$$
PWD
/
event
/
fmapplication
.
h
\
...
@@ -146,7 +147,8 @@ HEADERS += \
...
@@ -146,7 +147,8 @@ HEADERS += \
$$
PWD
/
model
/
prtmodelpool
.
h
\
$$
PWD
/
model
/
prtmodelpool
.
h
\
$$
PWD
/
view
/
newchangeshiftsform
.
h
\
$$
PWD
/
view
/
newchangeshiftsform
.
h
\
$$
PWD
/
control
/
driverinfogetwork
.
h
\
$$
PWD
/
control
/
driverinfogetwork
.
h
\
$$
PWD
/
view
/
newfloatform
.
h
$$
PWD
/
view
/
newfloatform
.
h
\
control
/
rpainterface
.
h
DISTFILES
+=
$$
PWD
/
takeout
.
rc
DISTFILES
+=
$$
PWD
/
takeout
.
rc
...
...
takeout/view/floatForm.cpp
View file @
5ecf3434
...
@@ -31,6 +31,7 @@ FloatForm::FloatForm(QWidget *parent) :
...
@@ -31,6 +31,7 @@ FloatForm::FloatForm(QWidget *parent) :
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_change_order
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_change_order
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_show_float
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_show_float
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_hide_float
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_delete_order
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_delete_order
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_login_status
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_login_status
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_network_outtime
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_network_outtime
);
...
@@ -148,6 +149,11 @@ bool FloatForm::event(QEvent *e)
...
@@ -148,6 +149,11 @@ bool FloatForm::event(QEvent *e)
return
true
;
return
true
;
}
}
if
(
e
->
type
()
==
PosEvent
::
s_hide_float
)
{
this
->
hide
();
return
true
;
}
if
(
e
->
type
()
==
PosEvent
::
s_network_outtime
)
if
(
e
->
type
()
==
PosEvent
::
s_network_outtime
)
{
{
// if(!this->isHidden())
// if(!this->isHidden())
...
...
takeout/view/mainForm.cpp
View file @
5ecf3434
...
@@ -46,6 +46,7 @@ MainForm::MainForm(QWidget *parent) :
...
@@ -46,6 +46,7 @@ MainForm::MainForm(QWidget *parent) :
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_delete_order
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_delete_order
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_login_storeinfo
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_login_storeinfo
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_show_mainform
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_show_mainform
);
FMApplication
::
subscibeEvent
(
this
,
PosEvent
::
s_hide_mainform
);
//FMApplication::subscibeEvent(this, PosEvent::s_network_outtime);
//FMApplication::subscibeEvent(this, PosEvent::s_network_outtime);
...
@@ -132,6 +133,12 @@ bool MainForm::event(QEvent *e)
...
@@ -132,6 +133,12 @@ bool MainForm::event(QEvent *e)
return
true
;
return
true
;
}
}
if
(
e
->
type
()
==
PosEvent
::
s_hide_mainform
)
{
this
->
hide
();
return
true
;
}
if
(
e
->
type
()
==
PosEvent
::
s_delete_order
)
if
(
e
->
type
()
==
PosEvent
::
s_delete_order
)
{
{
QVariantMap
value
;
QVariantMap
value
;
...
...
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