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
4c7cb82d
Commit
4c7cb82d
authored
Mar 11, 2019
by
xiaoqing.gu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
外卖 自提 后厨打印模板调试完成
parent
e041f27d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
311 additions
and
72 deletions
+311
-72
takeout/base/Print/newprintlib.cpp
+153
-33
takeout/base/Print/newprintlib.h
+2
-0
takeout/control/orderprintwork.cpp
+2
-2
takeout/control/prtmodelgetwork.cpp
+122
-27
takeout/control/prtmodelgetwork.h
+8
-2
takeout/preDefine.h
+15
-6
takeout/takeout.pro
+2
-2
takeout/view/newmainform.cpp
+7
-0
No files found.
takeout/base/Print/newprintlib.cpp
View file @
4c7cb82d
...
@@ -11,7 +11,9 @@
...
@@ -11,7 +11,9 @@
#include "preDefine.h"
#include "preDefine.h"
#include "calculator.h"
#include "calculator.h"
#include "model/posorderpool.h"
#include <QJsonDocument>
#include <QJsonDocument>
#include <QJsonArray>
NewPrintLib
::
NewPrintLib
()
NewPrintLib
::
NewPrintLib
()
{
{
...
@@ -168,13 +170,28 @@ void NewPrintLib::PrintProcudt(const QList<LineNode*> &list,const QList<int>& pr
...
@@ -168,13 +170,28 @@ void NewPrintLib::PrintProcudt(const QList<LineNode*> &list,const QList<int>& pr
}
}
}
}
#define ORDERINFOCOPY(src, des) do { \
#define ORDERINFOCOPY(src, des) do { \
des
.
create_time
=
src
->
create_time
;
\
des
.
create_time
=
src
->
create_time
;
\
des
.
order_index
=
src
->
order_index
;
\
des
.
order_index
=
src
->
order_index
;
\
des
.
order_id
=
src
->
order_id
;
\
des
.
order_id
=
src
->
order_id
;
\
des
.
store_name
=
src
->
store_name
;
\
des
.
store_name
=
src
->
store_name
;
\
des
.
_orderObject
=
src
->
_orderObject
;
\
des
.
_orderObject
[
"products"
]
=
QJsonArray
();
\
}
while
(
0
);
}
while
(
0
);
void
NewPrintLib
::
AddProdJson
(
OrderObject
&
des_order
,
ProductObject
*
prod
)
{
QJsonArray
array
=
des_order
.
_orderObject
[
"products"
].
toArray
();
QJsonObject
object
;
object
[
"pid"
]
=
prod
->
pid
;
object
[
"price"
]
=
prod
->
price
;
object
[
"name"
]
=
prod
->
name
;
object
[
"product_amount"
]
=
prod
->
product_amount
;
array
.
append
(
object
);
des_order
.
_orderObject
[
"products"
]
=
array
;
}
bool
NewPrintLib
::
GetObjList
(
int
page_depart
,
int
prod_depart
,
QStringList
prodlist
,
QList
<
OrderObject
>
&
orderlist
,
OrderObject
*
order
)
bool
NewPrintLib
::
GetObjList
(
int
page_depart
,
int
prod_depart
,
QStringList
prodlist
,
QList
<
OrderObject
>
&
orderlist
,
OrderObject
*
order
)
{
{
OrderObject
allorder
;
OrderObject
allorder
;
...
@@ -192,12 +209,15 @@ bool NewPrintLib::GetObjList(int page_depart, int prod_depart, QStringList prodl
...
@@ -192,12 +209,15 @@ bool NewPrintLib::GetObjList(int page_depart, int prod_depart, QStringList prodl
ProductObject
*
tmpod
=
new
ProductObject
(
&
tmporder
);
ProductObject
*
tmpod
=
new
ProductObject
(
&
tmporder
);
*
tmpod
=
*
v
;
*
tmpod
=
*
v
;
tmporder
.
proList
.
append
(
tmpod
);
tmporder
.
proList
.
append
(
tmpod
);
AddProdJson
(
tmporder
,
tmpod
);
QLOG_DEBUG
()
<<
"debug2"
<<
tmporder
.
_orderObject
;
orderlist
.
append
(
tmporder
);
orderlist
.
append
(
tmporder
);
}
}
else
else
{
{
OrderObject
tmporder
;
OrderObject
tmporder
;
ORDERINFOCOPY
(
order
,
tmporder
);
ORDERINFOCOPY
(
order
,
tmporder
);
QLOG_DEBUG
()
<<
"222222"
<<
tmporder
.
_orderObject
;
for
(
int
i
=
0
;
i
<
v
->
product_amount
;
++
i
)
for
(
int
i
=
0
;
i
<
v
->
product_amount
;
++
i
)
{
{
...
@@ -205,7 +225,8 @@ bool NewPrintLib::GetObjList(int page_depart, int prod_depart, QStringList prodl
...
@@ -205,7 +225,8 @@ bool NewPrintLib::GetObjList(int page_depart, int prod_depart, QStringList prodl
*
tmpod
=
*
v
;
*
tmpod
=
*
v
;
tmpod
->
product_amount
=
1
;
tmpod
->
product_amount
=
1
;
tmporder
.
proList
.
append
(
tmpod
);
tmporder
.
proList
.
append
(
tmpod
);
AddProdJson
(
tmporder
,
tmpod
);
QLOG_DEBUG
()
<<
"debug3"
<<
tmporder
.
_orderObject
;
}
}
orderlist
.
append
(
tmporder
);
orderlist
.
append
(
tmporder
);
}
}
...
@@ -217,6 +238,8 @@ bool NewPrintLib::GetObjList(int page_depart, int prod_depart, QStringList prodl
...
@@ -217,6 +238,8 @@ bool NewPrintLib::GetObjList(int page_depart, int prod_depart, QStringList prodl
ProductObject
*
tmpod
=
new
ProductObject
(
&
allorder
);
ProductObject
*
tmpod
=
new
ProductObject
(
&
allorder
);
*
tmpod
=
*
v
;
*
tmpod
=
*
v
;
allorder
.
proList
.
append
(
tmpod
);
allorder
.
proList
.
append
(
tmpod
);
AddProdJson
(
allorder
,
tmpod
);
QLOG_DEBUG
()
<<
"debug4"
<<
allorder
.
_orderObject
;
}
}
else
else
{
{
...
@@ -227,6 +250,8 @@ bool NewPrintLib::GetObjList(int page_depart, int prod_depart, QStringList prodl
...
@@ -227,6 +250,8 @@ bool NewPrintLib::GetObjList(int page_depart, int prod_depart, QStringList prodl
*
tmpod
=
*
v
;
*
tmpod
=
*
v
;
tmpod
->
product_amount
=
1
;
tmpod
->
product_amount
=
1
;
allorder
.
proList
.
append
(
tmpod
);
allorder
.
proList
.
append
(
tmpod
);
AddProdJson
(
allorder
,
tmpod
);
QLOG_DEBUG
()
<<
"debug5"
<<
allorder
.
_orderObject
;
}
}
}
}
}
}
...
@@ -260,17 +285,47 @@ bool NewPrintLib::DoPrint(const QString &config, const QString &context, OrderOb
...
@@ -260,17 +285,47 @@ bool NewPrintLib::DoPrint(const QString &config, const QString &context, OrderOb
CONSTCHARTOCHAR
(
prtconfigdata
,
prtconfig
);
CONSTCHARTOCHAR
(
prtconfigdata
,
prtconfig
);
char
*
xml
=
NULL
;
char
*
xml
=
NULL
;
QByteArray
xmldata
=
context
.
toUtf8
();
// QByteArray xmldata = context.toUtf8();
QByteArray
xmldata
=
context
.
toLocal8Bit
();
CONSTCHARTOCHAR
(
xmldata
,
xml
);
CONSTCHARTOCHAR
(
xmldata
,
xml
);
char
*
orderinfo
=
NULL
;
char
*
orderinfo
=
NULL
;
QByteArray
orderdata
=
QString
(
QJsonDocument
(
tmporder
.
_orderObject
).
toJson
()).
toUtf8
();
// QByteArray orderdata = QString(QJsonDocument(tmporder._orderObject).toJson()).toUtf8();
//根据订单号填写打印模板的表头
QJsonObject
orderObj
=
tmporder
.
_orderObject
;
int
type
=
-
100
;
if
(
orderObj
.
contains
(
"order_type"
))
{
type
=
orderObj
[
"order_type"
].
toInt
();
}
QLOG_DEBUG
()
<<
"NewPrintLib::type:"
<<
type
;
switch
(
type
)
{
case
TimelyTakeout
:
tmporder
.
_orderObject
.
insert
(
"source_order_type"
,
QString
::
fromLocal8Bit
(
ORDER_TYPE_TIMELYTAKEOUT
));
break
;
case
AppointmentTakeout
:
tmporder
.
_orderObject
.
insert
(
"source_order_type"
,
QString
::
fromLocal8Bit
(
ORDER_TYPE_APPOINTMENTTAKEOUT
));
break
;
case
TimelyInvite
:
tmporder
.
_orderObject
.
insert
(
"source_order_type"
,
QString
::
fromLocal8Bit
(
ORDER_TYPE_TIMELYINVITE
));
break
;
case
AppointmentInvite
:
tmporder
.
_orderObject
.
insert
(
"source_order_type"
,
QString
::
fromLocal8Bit
(
ORDER_TYPE_APPOINTMENTTAKEOUT
));
break
;
default
:
break
;
}
QByteArray
orderdata
=
QString
(
QJsonDocument
(
tmporder
.
_orderObject
).
toJson
()).
toLocal8Bit
();
CONSTCHARTOCHAR
(
orderdata
,
orderinfo
);
CONSTCHARTOCHAR
(
orderdata
,
orderinfo
);
char
err
[
1024
]
=
{
0
};
char
err
[
1024
]
=
{
0
};
f_DoPrintWithXml
(
prtconfig
,
xml
,
orderinfo
,
err
);
f_DoPrintWithXml
(
prtconfig
,
orderinfo
,
xml
,
err
);
if
(
strlen
(
err
)
>
0
)
if
(
strlen
(
err
)
>
0
)
{
{
...
@@ -394,15 +449,18 @@ bool NewPrintLib::PrintLabel(const QString &config, OrderObject *order)
...
@@ -394,15 +449,18 @@ bool NewPrintLib::PrintLabel(const QString &config, OrderObject *order)
{
{
if
(
order
->
order_type
==
3
||
order
->
order_type
==
4
||
order
->
order_type
==
5
)
if
(
order
->
order_type
==
3
||
order
->
order_type
==
4
||
order
->
order_type
==
5
)
{
{
tmptitle
=
QString
(
"
\xE9\x9D\x9E\xE7\xA0\x81\xE8\x87\xAA\xE6\x8F\x90
"
).
append
(
order
->
code
).
append
(
" "
).
append
(
title
);
// tmptitle = QString("\xE9\x9D\x9E\xE7\xA0\x81\xE8\x87\xAA\xE6\x8F\x90").append(order->code).append(" ").append(title);
tmptitle
=
QString
(
"
\xE8\x87\xAA\xE6\x8F\x90
"
).
append
(
order
->
code
).
append
(
" "
).
append
(
title
);
}
}
else
if
(
order
->
order_type
==
6
)
else
if
(
order
->
order_type
==
6
)
{
{
tmptitle
=
QString
(
"
\xE9\x9D\x9E\xE7\xA0\x81\xE9\xA2\x84\xE7\xBA\xA6
"
).
append
(
order
->
code
).
append
(
" "
).
append
(
title
);
// tmptitle = QString("\xE9\x9D\x9E\xE7\xA0\x81\xE9\xA2\x84\xE7\xBA\xA6").append(order->code).append(" ").append(title);
tmptitle
=
QString
(
"
\xE9\xA2\x84\xE7\xBA\xA6
"
).
append
(
order
->
code
).
append
(
" "
).
append
(
title
);
}
}
else
else
{
{
tmptitle
=
QString
(
"
\xE9\x9D\x9E\xE7\xA0\x81\xE5\xA4\x96\xE5\x8D\x96
"
).
append
(
QString
::
number
(
order
->
order_index
)).
append
(
" "
).
append
(
title
);
// tmptitle = QString("\xE9\x9D\x9E\xE7\xA0\x81\xE5\xA4\x96\xE5\x8D\x96").append(QString::number(order->order_index)).append(" ").append(title);
tmptitle
=
QString
(
"
\xE5\xA4\x96\xE5\x8D\x96
"
).
append
(
QString
::
number
(
order
->
order_index
)).
append
(
" "
).
append
(
title
);
}
}
}
}
else
else
...
@@ -472,6 +530,8 @@ bool NewPrintLib::DoBackPrint(int page_depart, int prod_depart, int page_num, co
...
@@ -472,6 +530,8 @@ bool NewPrintLib::DoBackPrint(int page_depart, int prod_depart, int page_num, co
return
true
;
return
true
;
}
}
QLOG_DEBUG
()
<<
"NewPrintLib::list:"
<<
list
;
QList
<
OrderObject
>
orderlist
;
QList
<
OrderObject
>
orderlist
;
if
(
GetObjList
(
page_depart
,
prod_depart
,
list
,
orderlist
,
order
)
==
false
)
if
(
GetObjList
(
page_depart
,
prod_depart
,
list
,
orderlist
,
order
)
==
false
)
...
@@ -481,6 +541,7 @@ bool NewPrintLib::DoBackPrint(int page_depart, int prod_depart, int page_num, co
...
@@ -481,6 +541,7 @@ bool NewPrintLib::DoBackPrint(int page_depart, int prod_depart, int page_num, co
return
true
;
return
true
;
}
}
int
i
=
0
;
//打印的页数
int
i
=
0
;
//打印的页数
while
(
i
<
page_num
)
while
(
i
<
page_num
)
...
@@ -489,36 +550,95 @@ bool NewPrintLib::DoBackPrint(int page_depart, int prod_depart, int page_num, co
...
@@ -489,36 +550,95 @@ bool NewPrintLib::DoBackPrint(int page_depart, int prod_depart, int page_num, co
while
(
index
<
orderlist
.
size
())
while
(
index
<
orderlist
.
size
())
{
{
QByteArray
data
=
config
.
toUtf8
();
//
QByteArray data = config.toUtf8();
char
*
tmpconfig
=
NULL
;
//
char *tmpconfig = NULL;
CONSTCHARTOCHAR
(
data
,
tmpconfig
);
//
CONSTCHARTOCHAR(data, tmpconfig);
if
(
f_prtopen
(
tmpconfig
)
!=
1
)
// if(f_prtopen(tmpconfig) != 1)
{
// {
QLOG_ERROR
()
<<
"NewPrintLib::DoPrint::f_prtopen failed"
;
// QLOG_ERROR() << "NewPrintLib::DoPrint::f_prtopen failed";
delete
[]
tmpconfig
;
// delete [] tmpconfig;
f_prtclose
();
// f_prtclose();
return
false
;
// return false;
// }
// delete [] tmpconfig;
// bool result;
// QString error;
// PrintDocument doc = PrintDocument::ParseToDocument(context, result, error);
// if(!result)
// {
// f_prtclose();
// QLOG_ERROR() << "NewPrintLib::DoPrint::PrintDocument::ParseToDocument failed";
// return false;
// }
// OrderObject tmporder = orderlist[index];
// PrintLineNode(doc, &tmporder);
// f_prtclose();
OrderObject
tmporder
=
orderlist
[
index
];
QLOG_DEBUG
()
<<
"input2:"
<<
tmporder
.
_orderObject
;
char
*
prtconfig
=
NULL
;
QByteArray
prtconfigdata
=
config
.
toUtf8
();
CONSTCHARTOCHAR
(
prtconfigdata
,
prtconfig
);
char
*
xml
=
NULL
;
QByteArray
xmldata
=
context
.
toLocal8Bit
();
CONSTCHARTOCHAR
(
xmldata
,
xml
);
char
*
orderinfo
=
NULL
;
QJsonObject
orderObj
=
tmporder
.
_orderObject
;
int
type
=
-
100
;
if
(
orderObj
.
contains
(
"order_type"
))
{
type
=
orderObj
[
"order_type"
].
toInt
();
}
}
delete
[]
tmpconfig
;
bool
result
;
QLOG_DEBUG
()
<<
"NewPrintLib::type:"
<<
type
;
QString
error
;
PrintDocument
doc
=
PrintDocument
::
ParseToDocument
(
context
,
result
,
error
);
switch
(
type
)
{
if
(
!
result
)
case
TimelyTakeout
:
{
tmporder
.
_orderObject
.
insert
(
"source_order_type"
,
QString
::
fromLocal8Bit
(
ORDER_TYPE_TIMELYTAKEOUT
));
f_prtclose
();
break
;
QLOG_ERROR
()
<<
"NewPrintLib::DoPrint::PrintDocument::ParseToDocument failed"
;
case
AppointmentTakeout
:
return
false
;
tmporder
.
_orderObject
.
insert
(
"source_order_type"
,
QString
::
fromLocal8Bit
(
ORDER_TYPE_APPOINTMENTTAKEOUT
));
break
;
case
TimelyInvite
:
tmporder
.
_orderObject
.
insert
(
"source_order_type"
,
QString
::
fromLocal8Bit
(
ORDER_TYPE_TIMELYINVITE
));
break
;
case
AppointmentInvite
:
tmporder
.
_orderObject
.
insert
(
"source_order_type"
,
QString
::
fromLocal8Bit
(
ORDER_TYPE_APPOINTMENTTAKEOUT
));
break
;
default
:
break
;
}
}
OrderObject
tmporder
=
orderlist
[
index
];
QByteArray
orderdata
=
QString
(
QJsonDocument
(
tmporder
.
_orderObject
).
toJson
()).
toLocal8Bit
();
CONSTCHARTOCHAR
(
orderdata
,
orderinfo
);
char
err
[
1024
]
=
{
0
};
f_DoPrintWithXml
(
prtconfig
,
orderinfo
,
xml
,
err
);
if
(
strlen
(
err
)
>
0
)
{
QLOG_ERROR
()
<<
"f_DoPrintWithXml failed error : "
<<
err
;
}
PrintLineNode
(
doc
,
&
tmporder
)
;
QLOG_DEBUG
()
<<
"f_DoPrintWithXml success"
;
f_prtclose
();
Sleep
(
200
);
Sleep
(
200
);
...
...
takeout/base/Print/newprintlib.h
View file @
4c7cb82d
...
@@ -77,6 +77,8 @@ private:
...
@@ -77,6 +77,8 @@ private:
void
PrintProcudt
(
const
QList
<
LineNode
*>
&
list
,
const
QList
<
int
>
&
protlist
,
OrderObject
*
_order
);
void
PrintProcudt
(
const
QList
<
LineNode
*>
&
list
,
const
QList
<
int
>
&
protlist
,
OrderObject
*
_order
);
void
AddProdJson
(
OrderObject
&
des_order
,
ProductObject
*
prod
);
bool
GetObjList
(
int
page_depart
,
int
prod_depart
,
QStringList
prodlist
,
QList
<
OrderObject
>
&
orderlist
,
OrderObject
*
order
);
bool
GetObjList
(
int
page_depart
,
int
prod_depart
,
QStringList
prodlist
,
QList
<
OrderObject
>
&
orderlist
,
OrderObject
*
order
);
bool
GetProdObject
(
int
prod_depart
,
QList
<
OrderObject
>
&
orderlist
,
OrderObject
*
order
);
bool
GetProdObject
(
int
prod_depart
,
QList
<
OrderObject
>
&
orderlist
,
OrderObject
*
order
);
...
...
takeout/control/orderprintwork.cpp
View file @
4c7cb82d
...
@@ -116,7 +116,7 @@ bool orderprintwork::GetPrtTemplet(int prttype, int pagew, QString &context, con
...
@@ -116,7 +116,7 @@ bool orderprintwork::GetPrtTemplet(int prttype, int pagew, QString &context, con
}
}
else
if
(
order
.
order_type
==
6
)
else
if
(
order
.
order_type
==
6
)
{
{
file
.
setFileName
(
qApp
->
applicationDirPath
()
+
"/"
+
FILE_PRINTYY80_TEMPLET
);
file
.
setFileName
(
qApp
->
applicationDirPath
()
+
"/"
+
XML_YYINTAKE80_TEMPLATE
);
}
}
else
else
{
{
...
@@ -145,7 +145,7 @@ bool orderprintwork::GetPrtTemplet(int prttype, int pagew, QString &context, con
...
@@ -145,7 +145,7 @@ bool orderprintwork::GetPrtTemplet(int prttype, int pagew, QString &context, con
}
}
else
if
(
order
.
order_type
==
6
)
else
if
(
order
.
order_type
==
6
)
{
{
file
.
setFileName
(
qApp
->
applicationDirPath
()
+
"/"
+
FILE_PRINTYY_TEMPLET
);
file
.
setFileName
(
qApp
->
applicationDirPath
()
+
"/"
+
XML_YYINTAKE56_TEMPLATE
);
}
}
else
else
{
{
...
...
takeout/control/prtmodelgetwork.cpp
View file @
4c7cb82d
...
@@ -5,9 +5,10 @@
...
@@ -5,9 +5,10 @@
#include "base/DB/fm_database.h"
#include "base/DB/fm_database.h"
#include "QsLog.h"
#include "QsLog.h"
#include <QJsonArray>
#include <QJsonArray>
#include <Q
tXml/Q
DomDocument>
#include <QDomDocument>
#include <QApplication>
#include <QApplication>
#include <QDir>
#include <QDir>
#include <Windows.h>
prtModelGetWork
::
prtModelGetWork
(
WorkObject
*
parent
)
:
WorkObject
(
parent
)
prtModelGetWork
::
prtModelGetWork
(
WorkObject
*
parent
)
:
WorkObject
(
parent
)
{
{
...
@@ -169,7 +170,11 @@ bool prtModelGetWork::CheckPrtModelInfo(QJsonObject &json)
...
@@ -169,7 +170,11 @@ bool prtModelGetWork::CheckPrtModelInfo(QJsonObject &json)
for
(
int
i
=
0
;
i
!=
array
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
!=
array
.
size
();
++
i
)
{
if
(
array
.
at
(
i
).
toObject
().
contains
(
"template"
)
&&
array
.
at
(
i
).
toObject
().
contains
(
"print_type"
))
{
if
(
array
.
at
(
i
).
toObject
().
contains
(
"template"
)
&&
array
.
at
(
i
).
toObject
().
contains
(
"print_type"
))
{
if
(
array
.
at
(
i
).
toObject
()[
"template"
].
toString
()
!=
0
)
{
if
(
array
.
at
(
i
).
toObject
()[
"template"
].
toString
()
!=
0
)
{
_templateMap
.
insert
(
array
.
at
(
i
).
toObject
()[
"print_type"
].
toInt
(),
array
.
at
(
i
).
toObject
()[
"template"
].
toString
());
QString
str
=
array
.
at
(
i
).
toObject
()[
"template"
].
toString
();
QLOG_DEBUG
()
<<
array
.
at
(
i
).
toObject
()[
"print_type"
].
toInt
();
if
(
praseXmlPrtModel
(
str
))
{
_templateMap
.
insert
(
array
.
at
(
i
).
toObject
()[
"print_type"
].
toInt
(),
array
.
at
(
i
).
toObject
()[
"template"
].
toString
());
}
}
}
}
else
{
}
else
{
return
false
;
return
false
;
...
@@ -195,16 +200,7 @@ bool prtModelGetWork::CheckPrtModelInfo(QJsonObject &json)
...
@@ -195,16 +200,7 @@ bool prtModelGetWork::CheckPrtModelInfo(QJsonObject &json)
prtModelLocalize
();
prtModelLocalize
();
logoImageLocalize
();
logoImageLocalize
();
qrCodeImageLocalize
();
// for(int i = 0;i != _templateList.size(); ++i) {
// QFile file(QApplication::applicationDirPath() + "/prtinfo/1.xml");
// if(file.open(QIODevice::ReadWrite)) {
// qDebug() << "--------------------4040-----------------" << _templateList.at(i) << QString(_templateList.at(i)).toUtf8();
// file.write(QString(_templateList.at(i)).toUtf8());
// file.close();
// return true;
// }
// }
return
true
;
return
true
;
}
}
...
@@ -212,19 +208,18 @@ bool prtModelGetWork::CheckPrtModelInfo(QJsonObject &json)
...
@@ -212,19 +208,18 @@ bool prtModelGetWork::CheckPrtModelInfo(QJsonObject &json)
bool
prtModelGetWork
::
prtModelLocalize
()
bool
prtModelGetWork
::
prtModelLocalize
()
{
{
qDebug
()
<<
"-------------------------------4040---------------------"
<<
_templateMap
;
qDebug
()
<<
"-------------------------------4040---------------------"
<<
_templateMap
;
// 检查目录是否存在,若不存在则新建
QString
dir_str
=
QApplication
::
applicationDirPath
()
+
QString
(
"/prtinfo"
);
QDir
dir
;
if
(
!
dir
.
exists
(
dir_str
))
{
bool
res
=
dir
.
mkpath
(
dir_str
);
qDebug
()
<<
"新建目录是否成功"
<<
res
;
}
QMap
<
int
,
QString
>::
iterator
it
;
QMap
<
int
,
QString
>::
iterator
it
;
for
(
it
=
_templateMap
.
begin
();
it
!=
_templateMap
.
end
();
++
it
)
{
for
(
it
=
_templateMap
.
begin
();
it
!=
_templateMap
.
end
();
++
it
)
{
QString
dir_str
=
QApplication
::
applicationDirPath
()
+
QString
(
"/prtinfo"
);
// 检查目录是否存在,若不存在则新建
QDir
dir
;
if
(
!
dir
.
exists
(
dir_str
))
{
bool
res
=
dir
.
mkpath
(
dir_str
);
qDebug
()
<<
"新建目录是否成功"
<<
res
;
}
QFile
file
(
QApplication
::
applicationDirPath
()
+
QString
(
"/prtinfo/%1.xml"
).
arg
(
it
.
key
()));
QFile
file
(
QApplication
::
applicationDirPath
()
+
QString
(
"/prtinfo/%1.xml"
).
arg
(
it
.
key
()));
if
(
file
.
open
(
Q
IODevice
::
ReadWri
te
))
{
if
(
file
.
open
(
Q
File
::
WriteOnly
|
QFile
::
Trunca
te
))
{
file
.
write
(
QString
(
it
.
value
()).
toUtf8
());
file
.
write
(
QString
(
it
.
value
()).
toUtf8
());
file
.
close
();
file
.
close
();
}
else
{
}
else
{
...
@@ -243,11 +238,24 @@ bool prtModelGetWork::logoImageLocalize()
...
@@ -243,11 +238,24 @@ bool prtModelGetWork::logoImageLocalize()
}
}
QMap
<
int
,
QString
>::
iterator
it
;
QMap
<
int
,
QString
>::
iterator
it
;
for
(
it
=
_logoMap
.
begin
();
it
!=
_logoMap
.
end
();
++
it
)
{
for
(
it
=
_logoMap
.
begin
();
it
!=
_logoMap
.
end
();
++
it
)
{
downloadImage
(
it
.
value
(),
QApplication
::
applicationDirPath
()
+
QString
(
"/prtinfo/%1.png"
).
arg
(
it
.
key
()));
downloadImage
(
it
.
value
(),
QApplication
::
applicationDirPath
()
+
QString
(
"/prtinfo/%1.bmp"
).
arg
(
it
.
key
()));
}
//将图片二值化
// img_rgb2gray();
return
true
;
}
bool
prtModelGetWork
::
qrCodeImageLocalize
()
{
if
(
_qrCodeMap
.
size
()
==
0
)
{
return
false
;
}
QMap
<
int
,
QString
>::
iterator
it
;
for
(
it
=
_qrCodeMap
.
begin
();
it
!=
_qrCodeMap
.
end
();
++
it
)
{
downloadImage
(
it
.
value
(),
QApplication
::
applicationDirPath
()
+
QString
(
"/prtinfo/%1p.bmp"
).
arg
(
it
.
key
()));
}
}
// downloadImage("https://picture.sandload.cn/1551195158116.png", QApplication::applicationDirPath()+"/prtinfo/1.bmp");
// Downloader downloader;
// downloader.downloadFileFromURL("https://picture.sandload.cn/1551195158116.png", QApplication::applicationDirPath()+"/prtinfo");
return
true
;
return
true
;
}
}
...
@@ -280,7 +288,7 @@ bool prtModelGetWork::downloadImage(QString url, QString fileName)
...
@@ -280,7 +288,7 @@ bool prtModelGetWork::downloadImage(QString url, QString fileName)
reply
->
deleteLater
();
reply
->
deleteLater
();
QFile
file
(
fileName
);
QFile
file
(
fileName
);
if
(
!
file
.
open
(
Q
IODevice
::
WriteOnly
))
if
(
!
file
.
open
(
Q
File
::
WriteOnly
|
QFile
::
Truncate
))
return
false
;
return
false
;
file
.
write
(
reply
->
readAll
());
file
.
write
(
reply
->
readAll
());
file
.
close
();
file
.
close
();
...
@@ -288,4 +296,91 @@ bool prtModelGetWork::downloadImage(QString url, QString fileName)
...
@@ -288,4 +296,91 @@ bool prtModelGetWork::downloadImage(QString url, QString fileName)
return
true
;
return
true
;
}
}
bool
prtModelGetWork
::
praseXmlPrtModel
(
QString
str
)
{
QDomDocument
doc
;
QString
errorMsg
;
int
errorLine
;
int
errorColumn
;
if
(
!
doc
.
setContent
(
str
,
&
errorMsg
,
&
errorLine
,
&
errorColumn
))
{
QLOG_ERROR
()
<<
"xml prtmodel prase failed!"
<<
errorMsg
;
return
false
;
}
return
true
;
}
void
prtModelGetWork
::
img_rgb2gray
()
{
int
threshold
=
200
;
FILE
*
stream
=
fopen
(
"D:
\\
6.bmp"
,
"rb"
);
if
(
stream
==
NULL
)
{
QLOG_ERROR
()
<<
"FILE didn't exist!"
;
return
;
}
int
sizeFileHeader
=
sizeof
(
BITMAPFILEHEADER
);
int
sizeInfoHeader
=
sizeof
(
BITMAPINFOHEADER
);
BITMAPFILEHEADER
*
bitmapFileHeader
=
new
BITMAPFILEHEADER
[
sizeFileHeader
+
1
];
BITMAPINFOHEADER
*
bitmapInfoHeader
=
new
BITMAPINFOHEADER
[
sizeInfoHeader
+
1
];
memset
(
bitmapFileHeader
,
0
,
sizeFileHeader
+
1
);
memset
(
bitmapInfoHeader
,
0
,
sizeInfoHeader
+
1
);
fread
(
bitmapFileHeader
,
sizeof
(
char
),
sizeFileHeader
,
stream
);
fseek
(
stream
,
sizeFileHeader
,
0
);
fread
(
bitmapInfoHeader
,
sizeof
(
char
),
sizeInfoHeader
,
stream
);
fseek
(
stream
,
sizeInfoHeader
+
sizeFileHeader
,
0
);
RGBQUAD
*
pRgbQuards
=
new
RGBQUAD
[
256
];
for
(
int
k
=
0
;
k
<
256
;
k
++
)
{
fread
(
&
pRgbQuards
[
k
],
sizeof
(
RGBQUAD
),
1
,
stream
);
}
int
count
=
(((
bitmapInfoHeader
->
biWidth
)
*
8
+
31
)
/
32
)
*
4
-
bitmapInfoHeader
->
biWidth
*
(
bitmapInfoHeader
->
biBitCount
/
8
);
BYTE
*
tempData
=
new
BYTE
[
count
+
1
];
memset
(
tempData
,
0
,
count
+
1
);
fseek
(
stream
,
sizeFileHeader
+
sizeInfoHeader
+
256
*
sizeof
(
RGBQUAD
),
0
);
BYTE
**
data
=
new
BYTE
*
[
bitmapInfoHeader
->
biHeight
];
for
(
int
i
=
0
;
i
<
bitmapInfoHeader
->
biHeight
;
i
++
)
{
data
[
i
]
=
new
BYTE
[
bitmapInfoHeader
->
biWidth
];
for
(
int
j
=
0
;
j
<
bitmapInfoHeader
->
biWidth
;
j
++
)
{
fread
(
&
data
[
i
][
j
],
sizeof
(
char
),
1
,
stream
);
if
(
data
[
i
][
j
]
>
threshold
)
data
[
i
][
j
]
=
255
;
else
data
[
i
][
j
]
=
0
;
}
for
(
int
n
=
0
;
n
<
count
;
n
++
)
{
fread
(
&
tempData
[
n
],
sizeof
(
char
),
1
,
stream
);
}
}
fclose
(
stream
);
//写入。。
FILE
*
fileWrite
=
fopen
(
"D:
\\
9.bmp"
,
"a+"
);
fwrite
(
bitmapFileHeader
,
sizeof
(
char
),
sizeof
(
BITMAPFILEHEADER
),
fileWrite
);
fwrite
(
bitmapInfoHeader
,
sizeof
(
char
),
sizeof
(
BITMAPINFOHEADER
),
fileWrite
);
fwrite
(
pRgbQuards
,
sizeof
(
RGBQUAD
),
256
,
fileWrite
);
for
(
int
i
=
0
;
i
<
bitmapInfoHeader
->
biHeight
;
i
++
)
{
for
(
int
j
=
0
;
j
<
bitmapInfoHeader
->
biWidth
;
j
++
)
{
fwrite
(
&
data
[
i
][
j
],
sizeof
(
BYTE
),
1
,
fileWrite
);
}
for
(
int
m
=
0
;
m
<
count
;
m
++
)
fwrite
(
&
tempData
[
m
],
sizeof
(
char
),
1
,
fileWrite
);
}
fclose
(
fileWrite
);
}
takeout/control/prtmodelgetwork.h
View file @
4c7cb82d
...
@@ -42,8 +42,14 @@ private:
...
@@ -42,8 +42,14 @@ private:
bool
logoImageLocalize
();
bool
logoImageLocalize
();
bool
qrCodeImageLocalize
();
bool
downloadImage
(
QString
url
,
QString
fileName
);
bool
downloadImage
(
QString
url
,
QString
fileName
);
bool
praseXmlPrtModel
(
QString
str
);
void
img_rgb2gray
();
private
:
private
:
QVariantMap
_storeinfo
;
QVariantMap
_storeinfo
;
...
@@ -70,7 +76,7 @@ private:
...
@@ -70,7 +76,7 @@ private:
switch
(
REQ
)
switch
(
REQ
)
{
{
case
ADVANCEORDER
:
case
ADVANCEORDER
:
action
=
QString
(
"saas.
printFile
.query"
);
action
=
QString
(
"saas.
ticketSet
.query"
);
return
true
;
return
true
;
default
:
default
:
return
false
;
return
false
;
...
@@ -79,7 +85,7 @@ private:
...
@@ -79,7 +85,7 @@ private:
switch
(
REQ
)
switch
(
REQ
)
{
{
case
ADVANCEORDER
:
case
ADVANCEORDER
:
action
=
QString
(
"saas.ticketSet.query"
);
action
=
QString
(
"
qa
saas.ticketSet.query"
);
return
true
;
return
true
;
default
:
default
:
return
false
;
return
false
;
...
...
takeout/preDefine.h
View file @
4c7cb82d
...
@@ -260,6 +260,12 @@
...
@@ -260,6 +260,12 @@
#define OPERATIONNAME_AGREE "同意"
#define OPERATIONNAME_AGREE "同意"
#define OPERATIONNAME_REFUNDNEWORDER "拒绝接单"
#define OPERATIONNAME_REFUNDNEWORDER "拒绝接单"
//订单类型汉化
#define ORDER_TYPE_TIMELYTAKEOUT "小程序外卖"
#define ORDER_TYPE_TIMELYINVITE "小程序自提"
#define ORDER_TYPE_APPOINTMENTTAKEOUT "小程序预约"
#define REJECTUITYPE_REFUSEREFUND 0
#define REJECTUITYPE_REFUSEREFUND 0
#define REJECTUITYPE_AGREEREFUND 1
#define REJECTUITYPE_AGREEREFUND 1
#define REJECTUITYPE_REFUSEORDER 2
#define REJECTUITYPE_REFUSEORDER 2
...
@@ -316,12 +322,15 @@
...
@@ -316,12 +322,15 @@
#define FILE_BACKPRINT_TEMPLET "backtemplet.txt"
#define FILE_BACKPRINT_TEMPLET "backtemplet.txt"
#define FILE_BACKPRINT80_TEMPLET "backtemplet80.txt"
#define FILE_BACKPRINT80_TEMPLET "backtemplet80.txt"
#define XML_TAKEOUT56_TEMPLATE "prtinfo/1.xml"
#define XML_TAKEOUT56_TEMPLATE "prtinfo/1.xml" //外卖小票56
#define XML_INTAKE56_TEMPLATE "prtinfo/2.xml"
#define XML_INTAKE56_TEMPLATE "prtinfo/2.xml" //到店取餐56
#define XML_LABEL_TEMPLATE "prtinfo/3.xml"
#define XML_LABEL_TEMPLATE "prtinfo/3.xml" //杯贴
#define XML_BACK_TEMPLATE "prtinfo/4.xml"
#define XML_BACK_TEMPLATE "prtinfo/4.xml" //厨打56
#define XML_TAKEOUT80_TEMPLATE "prtinfo/5.xml"
#define XML_TAKEOUT80_TEMPLATE "prtinfo/1.xml" //外卖小票80
#define XML_INTAKE80_TEMPLATE "prtinfo/6.xml"
#define XML_INTAKE80_TEMPLATE "prtinfo/2.xml" //到店取餐80
#define XML_YYINTAKE56_TEMPLATE "prtinfo/7.xml" //预约到店56
#define XML_YYINTAKE80_TEMPLATE "prtinfo/8.xml" //预约到店80
#define XML_BACK80_TEMPLATE "prtinfo/9.xml" //厨打80
#define DEFAULT_PRINTF_MAIN_SESSION "Printer"
#define DEFAULT_PRINTF_MAIN_SESSION "Printer"
...
...
takeout/takeout.pro
View file @
4c7cb82d
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#
#
#-------------------------------------------------
#-------------------------------------------------
QT
+=
core
gui
network
multimedia
sql
printsupport
QT
+=
core
gui
network
multimedia
sql
printsupport
xml
greaterThan
(
QT_MAJOR_VERSION
,
4
)
:
QT
+=
widgets
greaterThan
(
QT_MAJOR_VERSION
,
4
)
:
QT
+=
widgets
...
@@ -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
...
...
takeout/view/newmainform.cpp
View file @
4c7cb82d
...
@@ -1660,6 +1660,13 @@ void NewMainForm::on_newmainbtn_prttest_clicked()
...
@@ -1660,6 +1660,13 @@ void NewMainForm::on_newmainbtn_prttest_clicked()
prod3
->
product_amount
=
1
;
prod3
->
product_amount
=
1
;
prod3
->
property_tags
=
QString
::
fromUtf8
(
"
\xE5\x8A\xA0\xE5\x8D\xA4\xE8\x9B\x8B
"
);
prod3
->
property_tags
=
QString
::
fromUtf8
(
"
\xE5\x8A\xA0\xE5\x8D\xA4\xE8\x9B\x8B
"
);
QJsonObject
json
;
json
.
insert
(
"order_id"
,
"888888"
);
json
.
insert
(
"code"
,
"12"
);
json
.
insert
(
"customer"
,
QString
::
fromUtf8
(
"
\xE6\x96\xB9\xE4\xBE\xBF\xE9\x9D\xA2
"
));
order
.
_orderObject
=
json
;
order
.
proList
.
append
(
prod3
);
order
.
proList
.
append
(
prod3
);
QStringList
list
;
QStringList
list
;
...
...
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