Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bft_takeout
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
bft_takeout
Commits
254bed60
Commit
254bed60
authored
Oct 29, 2017
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
打印跳转
parent
bce5f769
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
16 deletions
+124
-16
fmTakeaway/Util/wbillcontrol.cpp
+121
-14
fmTakeaway/Util/wbillcontrol.h
+3
-2
No files found.
fmTakeaway/Util/wbillcontrol.cpp
View file @
254bed60
...
@@ -57,6 +57,7 @@ WBillControl::WBillControl()
...
@@ -57,6 +57,7 @@ WBillControl::WBillControl()
obj
.
service_fee
=
1000
;
obj
.
service_fee
=
1000
;
obj
.
dis_shop_fee
=
1300
;
obj
.
dis_shop_fee
=
1300
;
obj
.
create_time
=
1508640524
;
obj
.
create_time
=
1508640524
;
obj
.
remark
=
"4套餐具"
;
ComdObject
comd1
;
ComdObject
comd1
;
comd1
.
pid
=
"001101"
;
comd1
.
pid
=
"001101"
;
comd1
.
productAmount
=
4
;
comd1
.
productAmount
=
4
;
...
@@ -72,12 +73,12 @@ WBillControl::WBillControl()
...
@@ -72,12 +73,12 @@ WBillControl::WBillControl()
comd3
.
productAmount
=
1
;
comd3
.
productAmount
=
1
;
comd3
.
price
=
789
;
comd3
.
price
=
789
;
obj
.
proList
.
push_back
(
&
comd3
);
obj
.
proList
.
push_back
(
&
comd3
);
//
PrintLable(&obj);
PrintLable
(
&
obj
);
//printMenu(&obj);
//printMenu(&obj);
//printTakeout(&obj);
//printTakeout(&obj);
// printBill(&obj);
// printBill(&obj);
printCook
(
&
obj
,
"061301"
,
4
);
//
printCook(&obj,"061301",4);
}
}
WBillControl
::~
WBillControl
()
WBillControl
::~
WBillControl
()
...
@@ -383,19 +384,27 @@ void WBillControl::PrintLable(const OrderObject *obj)
...
@@ -383,19 +384,27 @@ void WBillControl::PrintLable(const OrderObject *obj)
}
}
//厨房单打印
//厨房单打印
void
WBillControl
::
printCook
(
const
OrderObject
*
obj
,
const
QString
&
menuId
,
int
num
)
void
WBillControl
::
printCook
(
const
OrderObject
*
obj
,
const
QString
&
menuId
,
int
num
,
bool
bJump
)
{
{
for
(
PrinterMenu
menu
:
vecMenu
){
for
(
PrinterMenu
menu
:
vecMenu
){
if
(
menu
.
strMenuId
==
menuId
){
if
(
menu
.
strMenuId
==
menuId
){
//print
//print
QJsonObject
rObj
;
QJsonObject
rObj
;
//rObj.insert("device", menu.strDevice.toStdString().data());
//不是打印跳转
//rObj.insert("baud", menu.iBaud);
if
(
!
bJump
){
rObj
.
insert
(
"device"
,
menu
.
strDevice
.
toStdString
().
data
());
rObj
.
insert
(
"baud"
,
menu
.
iBaud
);
//rObj.insert("device", "/dev/ttyM2");
//rObj.insert("baud", 9600);
}
else
{
rObj
.
insert
(
"device"
,
menu
.
strOrderDevice
.
toStdString
().
data
());
rObj
.
insert
(
"baud"
,
menu
.
iOrderBaud
);
//rObj.insert("device", "/dev/ttyS1");
//rObj.insert("baud", 9600);
}
rObj
.
insert
(
"device"
,
"/dev/ttyS1"
);
rObj
.
insert
(
"baud"
,
9600
);
QJsonArray
tAry
;
QJsonArray
tAry
;
QJsonObject
tObj
;
QJsonObject
tObj
;
...
@@ -459,15 +468,81 @@ void WBillControl::printCook(const OrderObject *obj,const QString& menuId,int nu
...
@@ -459,15 +468,81 @@ void WBillControl::printCook(const OrderObject *obj,const QString& menuId,int nu
QJsonDocument
doc
(
rObj
);
QJsonDocument
doc
(
rObj
);
QByteArray
strArray
=
doc
.
toJson
(
QJsonDocument
::
Compact
);
QByteArray
strArray
=
doc
.
toJson
(
QJsonDocument
::
Compact
);
QLOG_INFO
()
<<
"------ json string:"
<<
strArray
;
QLOG_INFO
()
<<
"------ json string:"
<<
strArray
;
sendToPrintServer
(
strArray
);
QString
sDateTime
=
QDateTime
::
currentDateTime
().
toString
(
" 时间 :yyyy-MM-dd hh:mm:ss"
);
if
(
!
sendToPrintServer
(
strArray
)){
QLOG_INFO
()
<<
"打印失败,开始跳转打印"
;
if
(
!
bJump
){
QJsonObject
rObjNew
;
rObjNew
.
insert
(
"device"
,
menu
.
strOrderDevice
.
toStdString
().
data
());
rObjNew
.
insert
(
"baud"
,
menu
.
iOrderBaud
);
//rObjNew.insert("device", "/dev/ttyS1");
//rObjNew.insert("baud", 9600);
QJsonArray
tAryNew
;
QJsonObject
tObjNew
;
tObjNew
.
insert
(
"text"
,
"**************************************"
);
tObjNew
.
insert
(
"type"
,
1
);
tAryNew
.
insert
(
0
,
tObjNew
);
tObjNew
.
insert
(
"text"
,
" 打印跳转"
);
tObjNew
.
insert
(
"type"
,
5
);
tAryNew
.
insert
(
1
,
tObjNew
);
tObjNew
.
insert
(
"text"
,
"从"
);
tObjNew
.
insert
(
"type"
,
1
);
tAryNew
.
insert
(
2
,
tObjNew
);
QString
sPrinter
=
" 打印列 :"
;
sPrinter
+=
QTextCodec
::
codecForName
(
"GBK"
)
->
toUnicode
(
menu
.
strTitle
.
toLatin1
());
tObjNew
.
insert
(
"text"
,
sPrinter
);
tObjNew
.
insert
(
"type"
,
1
);
tAryNew
.
insert
(
3
,
tObjNew
);
tObjNew
.
insert
(
"text"
,
sDateTime
);
tObjNew
.
insert
(
"type"
,
1
);
tAryNew
.
insert
(
4
,
tObjNew
);
tObjNew
.
insert
(
"text"
,
"到"
);
tObjNew
.
insert
(
"type"
,
1
);
tAryNew
.
insert
(
5
,
tObjNew
);
QString
ePrinter
=
" 打印列 :"
;
ePrinter
+=
QTextCodec
::
codecForName
(
"GBK"
)
->
toUnicode
(
menu
.
strOrderTitle
.
toLatin1
());
tObjNew
.
insert
(
"text"
,
ePrinter
);
tObjNew
.
insert
(
"type"
,
1
);
tAryNew
.
insert
(
6
,
tObjNew
);
QString
eDateTime
=
QDateTime
::
currentDateTime
().
toString
(
" 时间 :yyyy-MM-dd hh:mm:ss"
);
tObjNew
.
insert
(
"text"
,
eDateTime
);
tObjNew
.
insert
(
"type"
,
1
);
tAryNew
.
insert
(
7
,
tObjNew
);
tObjNew
.
insert
(
"text"
,
"**************************************"
);
tObjNew
.
insert
(
"type"
,
1
);
tAryNew
.
insert
(
8
,
tObjNew
);
rObjNew
.
insert
(
"print"
,
tAryNew
);
QJsonDocument
docNew
(
rObjNew
);
QByteArray
strArrayNew
=
docNew
.
toJson
(
QJsonDocument
::
Compact
);
QLOG_INFO
()
<<
"------jump json string:"
<<
strArrayNew
;
if
(
sendToPrintServer
(
strArrayNew
)){
printCook
(
obj
,
menuId
,
num
,
true
);
}
else
{
QLOG_INFO
()
<<
"------jump print failed"
;
}
}
}
break
;
break
;
}
}
}
}
}
}
void
WBillControl
::
sendToPrintServer
(
QByteArray
&
JsonPrint
)
bool
WBillControl
::
sendToPrintServer
(
QByteArray
&
JsonPrint
)
{
{
bool
result
=
false
;
QTcpSocket
*
socket
=
new
QTcpSocket
(
this
);
QTcpSocket
*
socket
=
new
QTcpSocket
(
this
);
// 连接
// 连接
QByteArray
byteSlip
=
JsonPrint
;
QByteArray
byteSlip
=
JsonPrint
;
...
@@ -485,10 +560,14 @@ void WBillControl::sendToPrintServer(QByteArray &JsonPrint)
...
@@ -485,10 +560,14 @@ void WBillControl::sendToPrintServer(QByteArray &JsonPrint)
{
{
QLOG_INFO
()
<<
"write order failed:"
<<
recvJson
[
"msg"
].
toString
();
QLOG_INFO
()
<<
"write order failed:"
<<
recvJson
[
"msg"
].
toString
();
}
}
else
{
result
=
true
;
}
}
}
}
}
}
}
socket
->
close
();
socket
->
close
();
return
result
;
}
}
//外卖单打印
//外卖单打印
...
@@ -589,6 +668,11 @@ void WBillControl::printTakeout(const OrderObject *obj)
...
@@ -589,6 +668,11 @@ void WBillControl::printTakeout(const OrderObject *obj)
std
::
string
stdId
=
strId
.
toStdString
();
std
::
string
stdId
=
strId
.
toStdString
();
print
(
charset_u2g
(
stdId
).
data
(),
3
);
print
(
charset_u2g
(
stdId
).
data
(),
3
);
QString
strRemark
=
"备注:"
;
strRemark
+=
obj
->
remark
;
std
::
string
stdRemark
=
strRemark
.
toStdString
();
print
(
charset_u2g
(
stdRemark
).
data
(),
3
);
//为空时换行
//为空时换行
print
(
""
,
1
);
print
(
""
,
1
);
QString
end
=
"*********"
;
QString
end
=
"*********"
;
...
@@ -630,7 +714,7 @@ void WBillControl::printMenu(const OrderObject *obj)
...
@@ -630,7 +714,7 @@ void WBillControl::printMenu(const OrderObject *obj)
return
;
return
;
}
}
print
(
menu
.
strOrderTitle
.
toLatin1
().
data
(),
3
);
print
(
menu
.
strOrderTitle
.
toLatin1
().
data
(),
5
);
QString
strDesk
=
" 台号:"
;
QString
strDesk
=
" 台号:"
;
strDesk
+=
obj
->
channelName
;
strDesk
+=
obj
->
channelName
;
...
@@ -638,21 +722,44 @@ void WBillControl::printMenu(const OrderObject *obj)
...
@@ -638,21 +722,44 @@ void WBillControl::printMenu(const OrderObject *obj)
std
::
string
stdDesk
=
strDesk
.
toStdString
();
std
::
string
stdDesk
=
strDesk
.
toStdString
();
print
(
charset_u2g
(
stdDesk
).
data
(),
4
);
print
(
charset_u2g
(
stdDesk
).
data
(),
4
);
print
(
""
,
1
);
QString
order
=
"单据:"
;
QString
order
=
"单据:"
;
order
+=
obj
->
order_id
;
order
+=
obj
->
order_id
;
std
::
string
stdOrder
=
order
.
toStdString
();
std
::
string
stdOrder
=
order
.
toStdString
();
print
(
charset_u2g
(
stdOrder
).
data
(),
2
);
print
(
charset_u2g
(
stdOrder
).
data
(),
1
);
QString
datetime
=
QDateTime
::
currentDateTime
().
toString
(
"日期:yyyy-MM-dd 时间:hh:mm"
);
QString
datetime
=
QDateTime
::
currentDateTime
().
toString
(
"日期:yyyy-MM-dd 时间:hh:mm"
);
std
::
string
stdDatetime
=
datetime
.
toStdString
();
std
::
string
stdDatetime
=
datetime
.
toStdString
();
print
(
charset_u2g
(
stdDatetime
).
data
(),
2
);
print
(
charset_u2g
(
stdDatetime
).
data
(),
1
);
print
(
"----------------------------------------"
,
1
);
print
(
"----------------------------------------"
,
1
);
}
}
QByteArray
menuName
=
QString
::
number
(
num
).
toLatin1
();
QByteArray
menuName
=
QString
::
number
(
num
).
toLatin1
();
menuName
.
append
(
" "
);
menuName
.
append
(
" "
);
menuName
.
append
(
menu
.
strMenuName
.
toLatin1
());
menuName
.
append
(
menu
.
strMenuName
.
toLatin1
());
print
(
menuName
.
data
(),
3
);
print
(
menuName
.
data
(),
5
);
//如果是套餐,列出子项
QMap
<
QString
,
QVector
<
SetMenuItem
>>::
ConstIterator
it
;
it
=
mapSetMenu
.
find
(
pid
);
if
(
it
!=
mapSetMenu
.
end
()){
QLOG_INFO
()
<<
"------ 上菜单,打印套餐子项 pid:"
<<
pid
;
QVector
<
SetMenuItem
>
vecItem
=
it
.
value
();
for
(
SetMenuItem
item
:
vecItem
){
QLOG_INFO
()
<<
"------ child menu id:"
<<
item
.
strMenuId
;
for
(
PrinterMenu
childMenu
:
vecMenu
){
if
(
childMenu
.
strMenuId
==
item
.
strMenuId
){
QByteArray
name
;
name
.
append
(
" "
);
name
.
append
(
QString
::
number
(
item
.
num
).
toLatin1
());
name
.
append
(
" "
);
name
.
append
(
childMenu
.
strMenuName
.
toLatin1
());
print
(
name
.
data
(),
5
);
}
}
}
}
break
;
break
;
}
}
...
...
fmTakeaway/Util/wbillcontrol.h
View file @
254bed60
...
@@ -101,9 +101,10 @@ private:
...
@@ -101,9 +101,10 @@ private:
* 参数:[1]订单信息
* 参数:[1]订单信息
* 参数:[2]菜单id
* 参数:[2]菜单id
* 参数:[3]数量
* 参数:[3]数量
* 参数:[4]打印跳转
* 返回:
* 返回:
* */
* */
void
printCook
(
const
OrderObject
*
obj
,
const
QString
&
menuId
,
int
num
);
void
printCook
(
const
OrderObject
*
obj
,
const
QString
&
menuId
,
int
num
,
bool
bJump
=
false
);
//外卖单打印
//外卖单打印
void
printTakeout
(
const
OrderObject
*
obj
);
void
printTakeout
(
const
OrderObject
*
obj
);
...
@@ -115,7 +116,7 @@ private:
...
@@ -115,7 +116,7 @@ private:
void
printBill
(
const
OrderObject
*
obj
);
void
printBill
(
const
OrderObject
*
obj
);
//厨房小票信息发送到monitor
//厨房小票信息发送到monitor
void
sendToPrintServer
(
QByteArray
&
JsonPrint
);
bool
sendToPrintServer
(
QByteArray
&
JsonPrint
);
//上菜单打印
//上菜单打印
QString
getPrintTitle
(
const
QString
&
channel
,
int
index
);
QString
getPrintTitle
(
const
QString
&
channel
,
int
index
);
...
...
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