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
8b923ad8
Commit
8b923ad8
authored
Dec 04, 2017
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复同一个订单在两个状态都有显示的bug.如:配送中、已完成状态都显示某一订单
parent
ec2b356b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
30 deletions
+130
-30
fmTakeaway/MainForm.cpp
+61
-26
fmTakeaway/MainForm.h
+1
-0
fmTakeaway/fmTakeaway.pro.user
+1
-1
print_bft/pos_print.c
+67
-3
No files found.
fmTakeaway/MainForm.cpp
View file @
8b923ad8
...
@@ -154,32 +154,33 @@ void MainForm::onOrderTableChanged(int last, int curr, OrderObject *orderObj)
...
@@ -154,32 +154,33 @@ void MainForm::onOrderTableChanged(int last, int curr, OrderObject *orderObj)
table
=
_GetTableByVID
(
last
);
table
=
_GetTableByVID
(
last
);
if
(
table
)
{
if
(
table
)
{
for
(
int
i
=
0
;
i
<
table
->
rowCount
();
i
++
)
{
delOrderFromTable
(
table
,
last
,
orderObj
);
if
(
!
table
->
item
(
i
,
1
)
->
text
().
compare
(
orderObj
->
order_id
))
{
// for(int i=0; i<table->rowCount(); i++) {
qDebug
()
<<
table
->
objectName
()
<<
"222222"
;
// if(!table->item(i, 1)->text().compare(orderObj->order_id)) {
table
->
removeRow
(
i
);
// qDebug()<<table->objectName()<<"222222";
QRichButton
*
btn
=
_GetTableBtnByVID
(
last
);
// table->removeRow(i);
QString
text
;
// QRichButton *btn = _GetTableBtnByVID(last);
if
(
0
==
table
->
rowCount
())
{
// QString text;
text
=
QString
(
"%1"
).
arg
(
btn
->
property
(
"name"
).
toString
());
// if(0==table->rowCount()) {
// 新订单栏目里为空
// text = QString("%1").arg(btn->property("name").toString());
if
(
last
==
TABLE_VID_SHIPSELF
||
last
==
TABLE_VID_CONFIRM_MATE
||
table
==
ui
->
tableOther
)
{
// // 新订单栏目里为空
emit
floatStopBlink
();
// if (last == TABLE_VID_SHIPSELF || last == TABLE_VID_CONFIRM_MATE || table == ui->tableOther) {
btn
->
setCounter
(
0
);
// emit floatStopBlink();
btn
->
setEnableRich
(
false
);
// btn->setCounter(0);
}
// btn->setEnableRich(false);
}
// }
else
{
// }
text
=
QString
(
"%1(%2)"
).
arg
(
btn
->
property
(
"name"
).
toString
()).
arg
(
table
->
rowCount
());
// else {
if
(
isVisible
())
{
// text = QString("%1(%2)").arg(btn->property("name").toString()).arg(table->rowCount());
emit
floatStopBlink
();
// if (isVisible()) {
}
// emit floatStopBlink();
}
// }
btn
->
setText
(
text
);
// }
btn
->
setCounter
(
table
->
rowCount
());
// btn->setText(text);
QLOG_INFO
()
<<
QString
(
"delete order[%1] from table[%2]!"
).
arg
(
orderObj
->
order_id
).
arg
(
table
->
objectName
());
// btn->setCounter(table->rowCount());
}
// QLOG_INFO() << QString("delete order[%1] from table[%2]!").arg(orderObj->order_id).arg(table->objectName());
}
// }
// }
}
}
else
{
else
{
if
(
TABLE_VID_NO_DRIVER
!=
last
)
{
if
(
TABLE_VID_NO_DRIVER
!=
last
)
{
...
@@ -194,6 +195,7 @@ void MainForm::onOrderTableChanged(int last, int curr, OrderObject *orderObj)
...
@@ -194,6 +195,7 @@ void MainForm::onOrderTableChanged(int last, int curr, OrderObject *orderObj)
return
;
return
;
}
}
delOrderFromTable
(
table
,
-
1
,
orderObj
);
int
crtIndex
=
0
;
int
crtIndex
=
0
;
table
->
insertRow
(
crtIndex
);
table
->
insertRow
(
crtIndex
);
...
@@ -944,3 +946,36 @@ void MainForm::setFloatWId(WId id)
...
@@ -944,3 +946,36 @@ void MainForm::setFloatWId(WId id)
{
{
floatWId
=
id
;
floatWId
=
id
;
}
}
void
MainForm
::
delOrderFromTable
(
QTableWidget
*
table
,
int
last
,
OrderObject
*
orderObj
)
{
for
(
int
i
=
0
;
i
<
table
->
rowCount
();
i
++
)
{
if
(
!
table
->
item
(
i
,
1
)
->
text
().
compare
(
orderObj
->
order_id
))
{
qDebug
()
<<
table
->
objectName
()
<<
"222222"
;
table
->
removeRow
(
i
);
if
(
-
1
!=
last
){
QRichButton
*
btn
=
_GetTableBtnByVID
(
last
);
QString
text
;
if
(
0
==
table
->
rowCount
())
{
text
=
QString
(
"%1"
).
arg
(
btn
->
property
(
"name"
).
toString
());
// 新订单栏目里为空
if
(
last
==
TABLE_VID_SHIPSELF
||
last
==
TABLE_VID_CONFIRM_MATE
||
table
==
ui
->
tableOther
)
{
emit
floatStopBlink
();
btn
->
setCounter
(
0
);
btn
->
setEnableRich
(
false
);
}
}
else
{
text
=
QString
(
"%1(%2)"
).
arg
(
btn
->
property
(
"name"
).
toString
()).
arg
(
table
->
rowCount
());
if
(
isVisible
())
{
emit
floatStopBlink
();
}
}
btn
->
setText
(
text
);
btn
->
setCounter
(
table
->
rowCount
());
}
QLOG_INFO
()
<<
QString
(
"delete order[%1] from table[%2]!"
).
arg
(
orderObj
->
order_id
).
arg
(
table
->
objectName
());
}
}
}
fmTakeaway/MainForm.h
View file @
8b923ad8
...
@@ -89,6 +89,7 @@ private slots:
...
@@ -89,6 +89,7 @@ private slots:
void
onOrderMateChanged
(
const
QString
&
order_id
);
void
onOrderMateChanged
(
const
QString
&
order_id
);
void
on_ClearTable
();
void
on_ClearTable
();
void
delOrderFromTable
(
QTableWidget
*
table
,
int
last
,
OrderObject
*
orderObj
);
signals
:
signals
:
void
floatFormShow
();
void
floatFormShow
();
...
...
fmTakeaway/fmTakeaway.pro.user
View file @
8b923ad8
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2017-1
0-20T16:52:07
. -->
<!-- Written by QtCreator 3.5.1, 2017-1
2-01T11:58:58
. -->
<qtcreator>
<qtcreator>
<data>
<data>
<variable>
EnvironmentId
</variable>
<variable>
EnvironmentId
</variable>
...
...
print_bft/pos_print.c
View file @
8b923ad8
...
@@ -6,21 +6,81 @@
...
@@ -6,21 +6,81 @@
#include <string.h>
#include <string.h>
#include <iconv.h>
#include <iconv.h>
#include <stdlib.h>
#include <stdlib.h>
#include <sys/file.h>
#include "pos_print.h"
#include "pos_print.h"
#define INVALID_HANDLE_VALUE -1
#define INVALID_HANDLE_VALUE -1
int
g_Handle
=
INVALID_HANDLE_VALUE
;
int
g_Handle
=
INVALID_HANDLE_VALUE
;
int
g_uBaudrate
=
0
;
int
g_uBaudrate
=
0
;
int
lock_set
(
int
fd
,
int
type
)
{
struct
flock
old_lock
,
lock
;
lock
.
l_whence
=
SEEK_SET
;
lock
.
l_start
=
0
;
lock
.
l_len
=
0
;
lock
.
l_type
=
type
;
lock
.
l_pid
=
getpid
();
fcntl
(
fd
,
F_GETLK
,
&
lock
);
if
(
lock
.
l_type
!=
F_UNLCK
)
{
if
(
lock
.
l_type
==
F_RDLCK
)
{
printf
(
"Read lock already set by %d
\n
"
,
lock
.
l_pid
);
}
else
if
(
lock
.
l_type
==
F_WRLCK
)
{
printf
(
"Write lock already set by %d
\n
"
,
lock
.
l_pid
);
}
}
lock
.
l_type
=
type
;
if
((
fcntl
(
fd
,
F_SETLKW
,
&
lock
))
<
0
)
{
printf
(
"Lock failed : type = %d
\n
"
,
lock
.
l_type
);
return
1
;
}
switch
(
lock
.
l_type
)
{
case
F_RDLCK
:
{
printf
(
"Read lock set by %d
\n
"
,
getpid
());
}
break
;
case
F_WRLCK
:
{
printf
(
"write lock set by %d
\n
"
,
getpid
());
}
break
;
case
F_UNLCK
:
{
printf
(
"Release lock by %d
\n
"
,
getpid
());
return
1
;
}
break
;
default:
break
;
}
return
0
;
}
int
open_port
(
const
char
*
szPort
)
int
open_port
(
const
char
*
szPort
)
{
{
//if(g_Handle != INVALID_HANDLE_VALUE)
//if(g_Handle != INVALID_HANDLE_VALUE)
// close(g_Handle);
// close(g_Handle);
g_Handle
=
open
(
szPort
,
O_RDWR
|
O_NOCTTY
|
O_
NDELAY
);
g_Handle
=
open
(
szPort
,
O_RDWR
|
O_NOCTTY
|
O_
APPEND
/* | O_NDELAY*/
);
if
(
g_Handle
==
INVALID_HANDLE_VALUE
)
if
(
g_Handle
==
INVALID_HANDLE_VALUE
)
printf
(
"open_port failed
\n
"
);
printf
(
"open_port failed
\n
"
);
else
else
printf
(
"port is open ok
\n
"
);
printf
(
"port is open ok
\n
"
);
//lock_set(g_Handle, F_WRLCK);
return
(
g_Handle
);
return
(
g_Handle
);
}
}
...
@@ -69,10 +129,13 @@ bool set_port(int Baudrate)
...
@@ -69,10 +129,13 @@ bool set_port(int Baudrate)
write
(
g_Handle
,
&
strCutPaper
,
4
);
write
(
g_Handle
,
&
strCutPaper
,
4
);
//sleep(1);
//sleep(1);
char
temp
[
3
]
=
{
0
};
char
temp
[
4
]
=
{
0
};
int
recvLen
=
read
(
g_Handle
,
temp
,
3
);
int
recvLen
=
read
(
g_Handle
,
temp
,
3
);
temp
[
recvLen
]
=
'\0'
;
temp
[
recvLen
]
=
'\0'
;
printf
(
"-----length:%d recv:%d
\n
"
,
recvLen
,
temp
[
0
]);
for
(
int
i
=
0
;
i
<
recvLen
;
i
++
)
{
printf
(
"-----length:%d recv[%d]:%d
\n
"
,
recvLen
,
i
,
temp
[
i
]);
}
if
(
0
==
recvLen
){
if
(
0
==
recvLen
){
tcflush
(
g_Handle
,
TCIOFLUSH
);
//清空终端未完成的输入/输出请求及数据
tcflush
(
g_Handle
,
TCIOFLUSH
);
//清空终端未完成的输入/输出请求及数据
close_port
();
close_port
();
...
@@ -86,6 +149,7 @@ void close_port()
...
@@ -86,6 +149,7 @@ void close_port()
if
(
g_Handle
!=
INVALID_HANDLE_VALUE
)
if
(
g_Handle
!=
INVALID_HANDLE_VALUE
)
{
{
sleep
(
2
);
sleep
(
2
);
// lock_set(g_Handle, F_UNLCK); /* 给文件解锁*/
// int res = tcflush(g_Handle,TCIOFLUSH);
// int res = tcflush(g_Handle,TCIOFLUSH);
printf
(
"close begin
\n
"
);
printf
(
"close begin
\n
"
);
close
(
g_Handle
);
close
(
g_Handle
);
...
...
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