Commit e5ce05bd by jackalone

解决退出不能正常退出的bug问题。(打印的操作待打印机来了一并测试)

parent 6f71ce4d
...@@ -19,20 +19,20 @@ ThreadController::ThreadController(QObject *parent) : ...@@ -19,20 +19,20 @@ ThreadController::ThreadController(QObject *parent) :
connect(&_flowcontroll, SIGNAL(finished()), this, SLOT(deleteLater())); connect(&_flowcontroll, SIGNAL(finished()), this, SLOT(deleteLater()));
//拒单线程 //拒单线程
_refusecontroll.setObjectName(QString("refusecontrollThread")); // _refusecontroll.setObjectName(QString("refusecontrollThread"));
reufuseControl::GetInstance().moveToThread(&_refusecontroll); // reufuseControl::GetInstance().moveToThread(&_refusecontroll);
reufuseControl::GetInstance().SetListenPort(ConfigManger::GetInstance().GetListenPort()); // reufuseControl::GetInstance().SetListenPort(ConfigManger::GetInstance().GetListenPort());
connect(&_refusecontroll, SIGNAL(started()), this, SLOT(sltThreadStarted())); // connect(&_refusecontroll, SIGNAL(started()), this, SLOT(sltThreadStarted()));
connect(&_refusecontroll,&QThread::started, &reufuseControl::GetInstance(),&reufuseControl::run); // connect(&_refusecontroll,&QThread::started, &reufuseControl::GetInstance(),&reufuseControl::run);
_refusecontroll.start(); // _refusecontroll.start();
connect(&_refusecontroll, SIGNAL(finished()), this, SLOT(deleteLater())); // connect(&_refusecontroll, SIGNAL(finished()), this, SLOT(deleteLater()));
//其他辅助线程 //其他辅助线程
_othercontroll.setObjectName(QString("_othercontrollThread")); // _othercontroll.setObjectName(QString("_othercontrollThread"));
otherThreadctr::GetInstance().moveToThread(&_othercontroll); // otherThreadctr::GetInstance().moveToThread(&_othercontroll);
connect(&_othercontroll, SIGNAL(started()), this, SLOT(sltThreadStarted())); // connect(&_othercontroll, SIGNAL(started()), this, SLOT(sltThreadStarted()));
_othercontroll.start(); // _othercontroll.start();
connect(&_othercontroll, SIGNAL(finished()), this, SLOT(deleteLater())); // connect(&_othercontroll, SIGNAL(finished()), this, SLOT(deleteLater()));
#if 0 #if 0
// 网络连接获取门店的信息进程 // 网络连接获取门店的信息进程
...@@ -52,24 +52,37 @@ ThreadController::ThreadController(QObject *parent) : ...@@ -52,24 +52,37 @@ ThreadController::ThreadController(QObject *parent) :
ThreadController::~ThreadController() ThreadController::~ThreadController()
{ {
} }
void ThreadController::terminateFlowcontrollThread() void ThreadController::terminateFlowcontrollThread()
{ {
_flowcontroll.terminate(); _flowcontroll.quit();
_flowcontroll.wait(500); _flowcontroll.wait();
//_flowcontroll.terminate();
// _flowcontroll.wait(500);
} }
void ThreadController::terminateRefusecontrollThread() void ThreadController::terminateRefusecontrollThread()
{ {
_refusecontroll.terminate(); while(QThread::currentThread()->isRunning())
_refusecontroll.wait(500); {
QThread::currentThread()->quit();
}
//_refusecontroll.terminate();
// _refusecontroll.wa//t(500);
} }
void ThreadController::terminateOthercontrollThread() void ThreadController::terminateOthercontrollThread()
{ {
_othercontroll.terminate(); while(QThread::currentThread()->isRunning())
_othercontroll.wait(500); {
QThread::currentThread()->quit();
}
//_othercontroll.terminate();
// _othercontroll.wait(500);
} }
//void ThreadController::terminateNetstoreinfoctrlThread() //void ThreadController::terminateNetstoreinfoctrlThread()
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "Ui/DetailForm.h" #include "Ui/DetailForm.h"
#include <QNetworkInterface> #include <QNetworkInterface>
#if 0
int getdata(void* ptr, int size, int nmemb, void* stream) int getdata(void* ptr, int size, int nmemb, void* stream)
{ {
unsigned int i = size * nmemb; unsigned int i = size * nmemb;
...@@ -24,11 +25,11 @@ int getdata(void* ptr, int size, int nmemb, void* stream) ...@@ -24,11 +25,11 @@ int getdata(void* ptr, int size, int nmemb, void* stream)
memcpy((char *)stream + totalSize, ptr, i); memcpy((char *)stream + totalSize, ptr, i);
return size*nmemb; return size*nmemb;
} }
#endif
flowControll::flowControll(QObject *parent) : QObject(parent),m_loginSocket(0), flowControll::flowControll(QObject *parent) : QObject(parent),m_loginSocket(0),
m_pullOrderSocket(0), m_pullOrderSocket(0),
m_procOrderSocket(0), m_procOrderSocket(0),
m_syncStockSocket(0) m_syncStockSocket(0),m_follow(0),m_syncTime(0)
{ {
m_storeId="", m_storeId="",
...@@ -37,6 +38,8 @@ flowControll::flowControll(QObject *parent) : QObject(parent),m_loginSocket(0), ...@@ -37,6 +38,8 @@ flowControll::flowControll(QObject *parent) : QObject(parent),m_loginSocket(0),
m_cashierId="", m_cashierId="",
m_cashiername=""; m_cashiername="";
m_timestamp="0"; m_timestamp="0";
m_time = new QTimer();
} }
...@@ -54,6 +57,8 @@ void flowControll::onStartFlow() ...@@ -54,6 +57,8 @@ void flowControll::onStartFlow()
m_procOrderSocket = new HttpSocket(this); m_procOrderSocket = new HttpSocket(this);
m_syncStockSocket = new HttpSocket(this); m_syncStockSocket = new HttpSocket(this);
qDebug()<<"~~~~~~~~~~~~~~~~~~~~~flowControll work is~~~~~~~~~~~~~~~~~~~~~"<< QThread::currentThread();
if(_GetStoreInfo()) if(_GetStoreInfo())
{ {
_Login(); _Login();
...@@ -76,7 +81,6 @@ bool flowControll::_Login() ...@@ -76,7 +81,6 @@ bool flowControll::_Login()
if(!result) if(!result)
{ {
QLOG_INFO() << "11111111111111111111111111111111";
emit showAlert(alertForm::ERROR, InitClass::GetInstance().GB2312ToUnicode("登录失败![网络错误]")); emit showAlert(alertForm::ERROR, InitClass::GetInstance().GB2312ToUnicode("登录失败![网络错误]"));
} }
else else
...@@ -84,7 +88,7 @@ bool flowControll::_Login() ...@@ -84,7 +88,7 @@ bool flowControll::_Login()
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt()) if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
{ {
result = false; result = false;
//emit showAlert(alertForm::ERROR, InitClass::GetInstance().GB2312ToUnicode("登录失败![%1]").arg( InitClass::GetInstance().GB2312ToUnicode(recvJson[JSON_MESSAGE].toString().toLatin1().data()))); emit showAlert(alertForm::ERROR, InitClass::GetInstance().GB2312ToUnicode("登录失败![%1]").arg( InitClass::GetInstance().GB2312ToUnicode(recvJson[JSON_MESSAGE].toString().toLatin1().data())));
} }
else else
{ {
...@@ -109,6 +113,35 @@ bool flowControll::_Login() ...@@ -109,6 +113,35 @@ bool flowControll::_Login()
return result; return result;
} }
void flowControll::onStopTimer()
{
m_time->stop();
m_follow = 1;
if(m_loginSocket)
{
delete m_loginSocket;
m_loginSocket = 0;
}
if(m_pullOrderSocket)
{
delete m_pullOrderSocket;
m_pullOrderSocket = 0;
}
if(m_syncStockSocket)
{
delete m_syncStockSocket;
m_syncStockSocket = 0;
}
if(m_procOrderSocket)
{
delete m_procOrderSocket;
m_procOrderSocket = 0;
}
emit sgnKillThread();
}
void flowControll::_netData(QJsonObject &sendJson) void flowControll::_netData(QJsonObject &sendJson)
{ {
#if 0 #if 0
...@@ -168,7 +201,21 @@ bool flowControll::_PullOrder() ...@@ -168,7 +201,21 @@ bool flowControll::_PullOrder()
qDebug()<<"m_timestamp is"<<m_timestamp; qDebug()<<"m_timestamp is"<<m_timestamp;
sendJson = DataManger::GetInstance().GetPullOrderData(m_timestamp,ConfigManger::GetInstance().GetAutoConfirm()); sendJson = DataManger::GetInstance().GetPullOrderData(m_timestamp,ConfigManger::GetInstance().GetAutoConfirm());
QLOG_INFO() << QString("[---pull order---][requestData:%1]").arg(_GetJsonStr(sendJson)); QLOG_INFO() << QString("[---pull order---][requestData:%1]").arg(_GetJsonStr(sendJson));
if(m_follow)
{
emit sgnKillThread();
return 0;
}
else
{
if(m_pullOrderSocket)
{
result = m_pullOrderSocket->HttpRequest(sendJson, recvJson, error); result = m_pullOrderSocket->HttpRequest(sendJson, recvJson, error);
}
else {
return 0;
}
}
QLOG_INFO() << QString("pull order finsh. [result:%1][msg:%2]") QLOG_INFO() << QString("pull order finsh. [result:%1][msg:%2]")
.arg(result).arg(error); .arg(result).arg(error);
...@@ -219,6 +266,7 @@ bool flowControll::_PullOrder() ...@@ -219,6 +266,7 @@ bool flowControll::_PullOrder()
.arg(_GetJsonStr(jsonObject)); .arg(_GetJsonStr(jsonObject));
WriteData(orderObject->order_id); WriteData(orderObject->order_id);
emit changeOrderStatus(orderObject); emit changeOrderStatus(orderObject);
// DetailForm::GetInstance().printData();
} }
else else
{ {
...@@ -237,11 +285,12 @@ bool flowControll::_PullOrder() ...@@ -237,11 +285,12 @@ bool flowControll::_PullOrder()
m_timestamp = orderObject->timestamp; m_timestamp = orderObject->timestamp;
} }
syncTime = recvJson[JSON_SYNCTIME].toInt()*1000; syncTime = recvJson[JSON_SYNCTIME].toInt()*1000;
m_syncTime = syncTime;
} }
} }
QLOG_INFO() << QString("%1 msec after pull order...").arg(syncTime); QLOG_INFO() << QString("%1 msec after pull order...").arg(syncTime);
QTimer::singleShot(syncTime, this, &flowControll::_PullOrder); m_time->singleShot(syncTime, this, &flowControll::_PullOrder);
return result; return result;
...@@ -323,7 +372,7 @@ bool flowControll::_SynStock() ...@@ -323,7 +372,7 @@ bool flowControll::_SynStock()
} }
QLOG_INFO() << QString("%1 msec after synStock...").arg(synInterval); QLOG_INFO() << QString("%1 msec after synStock...").arg(synInterval);
QTimer::singleShot(synInterval, this, &flowControll::_SynStock); m_time->singleShot(synInterval, this, &flowControll::_SynStock);
return result; return result;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "Model/cashierObject.h" #include "Model/cashierObject.h"
#include "global/externalinterface.h" #include "global/externalinterface.h"
#include "Tool/HttpSocket.h" #include "Tool/HttpSocket.h"
#include <QTimer>
class flowControll : public QObject class flowControll : public QObject
{ {
...@@ -35,6 +36,8 @@ public: ...@@ -35,6 +36,8 @@ public:
HttpSocket *m_pullOrderSocket; HttpSocket *m_pullOrderSocket;
HttpSocket *m_procOrderSocket; HttpSocket *m_procOrderSocket;
HttpSocket *m_syncStockSocket; HttpSocket *m_syncStockSocket;
QTimer *m_time;
int m_syncTime;
private: private:
// 门店信息 // 门店信息
...@@ -48,6 +51,7 @@ private: ...@@ -48,6 +51,7 @@ private:
QMap<QString, OrderObject*> m_ordersMap; // 订单容器 QMap<QString, OrderObject*> m_ordersMap; // 订单容器
// 当前收银员 // 当前收银员
CashierObject m_cashierObject; CashierObject m_cashierObject;
bool m_follow;
signals: signals:
void showAlert(alertForm::Type type, const QString& msg);//显示通知窗口 void showAlert(alertForm::Type type, const QString& msg);//显示通知窗口
void hideAlert(); //隐藏通知窗口 void hideAlert(); //隐藏通知窗口
...@@ -60,6 +64,8 @@ signals: ...@@ -60,6 +64,8 @@ signals:
void showOrderDetails(OrderObject* orderObject);//获取订单详情信号 void showOrderDetails(OrderObject* orderObject);//获取订单详情信号
void TodetailForm(const QString& str); void TodetailForm(const QString& str);
void updateCashier(QString str); void updateCashier(QString str);
void sgnThreadFollow();
void sgnKillThread();
public slots: public slots:
void onStartFlow(); //线程的初始化工作 void onStartFlow(); //线程的初始化工作
...@@ -80,6 +86,7 @@ public slots: ...@@ -80,6 +86,7 @@ public slots:
void onNetReEntryOrder(const QString &orderId);//发送数据到服务端 void onNetReEntryOrder(const QString &orderId);//发送数据到服务端
void onProcessRejectOrder(const QString& orderId, const int& reason, const int &reasontype); void onProcessRejectOrder(const QString& orderId, const int& reason, const int &reasontype);
bool _RefundOrder(const QString& orderId, QString reason);//退单 bool _RefundOrder(const QString& orderId, QString reason);//退单
void onStopTimer();
}; };
......
...@@ -13,6 +13,7 @@ reufuseControl::reufuseControl(QObject *parent) : ...@@ -13,6 +13,7 @@ reufuseControl::reufuseControl(QObject *parent) :
m_tcpServer(0), m_tcpServer(0),
QObject(parent) QObject(parent)
{ {
qDebug()<<"~~~~~~~~~~~~~~~~~~~~~reufuseControl work is~~~~~~~~~~~~~~~~~~~~~ "<<QThread::currentThread();
refuseSocket = new HttpSocket(this); refuseSocket = new HttpSocket(this);
m_tcpServer = new QTcpServer(this); m_tcpServer = new QTcpServer(this);
} }
......
...@@ -5,15 +5,20 @@ ...@@ -5,15 +5,20 @@
#include <QTimer> #include <QTimer>
#include <QNetworkReply> #include <QNetworkReply>
HttpSocket::HttpSocket(QObject *parent) : QObject(parent) HttpSocket::HttpSocket(QObject *parent) : QObject(parent),m_time(0)
{ {
m_time = new QTimer();
m_networkRequest.setUrl(ConfigManger::GetInstance().GetServerUrl()); m_networkRequest.setUrl(ConfigManger::GetInstance().GetServerUrl());
m_networkRequest.setRawHeader("Content-Type","text/json"); m_networkRequest.setRawHeader("Content-Type","text/json");
} }
HttpSocket::~HttpSocket() HttpSocket::~HttpSocket()
{ {
if(m_time)
{
delete m_time;
m_time = 0;
}
} }
...@@ -23,7 +28,6 @@ HttpSocket::~HttpSocket() ...@@ -23,7 +28,6 @@ HttpSocket::~HttpSocket()
{ {
m_networkManger.setNetworkAccessible(QNetworkAccessManager::Accessible); m_networkManger.setNetworkAccessible(QNetworkAccessManager::Accessible);
} }
QByteArray sendArray = QJsonDocument(requestJson).toJson(QJsonDocument::Compact); QByteArray sendArray = QJsonDocument(requestJson).toJson(QJsonDocument::Compact);
QEventLoop eventLoop; QEventLoop eventLoop;
QNetworkReply *reply = m_networkManger.post(m_networkRequest , sendArray); QNetworkReply *reply = m_networkManger.post(m_networkRequest , sendArray);
...@@ -31,9 +35,12 @@ HttpSocket::~HttpSocket() ...@@ -31,9 +35,12 @@ HttpSocket::~HttpSocket()
connect(reply, SIGNAL(finished()), &eventLoop, SLOT(quit())); connect(reply, SIGNAL(finished()), &eventLoop, SLOT(quit()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), &eventLoop, SLOT(quit())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), &eventLoop, SLOT(quit()));
QTimer::singleShot(VALUE_NETTIMEOUT, &eventLoop, &QEventLoop::quit); // m_time->singleShot(VALUE_NETTIMEOUT, &eventLoop, &QEventLoop::quit);
eventLoop.exec(); eventLoop.exec();
if(reply)
{
qDebug()<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
}
if(reply->error() != QNetworkReply::NoError) if(reply->error() != QNetworkReply::NoError)
{ {
error = reply->errorString(); error = reply->errorString();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <QJsonDocument> #include <QJsonDocument>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QTimer>
class HttpSocket : public QObject class HttpSocket : public QObject
{ {
...@@ -17,6 +18,7 @@ public: ...@@ -17,6 +18,7 @@ public:
private: private:
QNetworkAccessManager m_networkManger; QNetworkAccessManager m_networkManger;
QNetworkRequest m_networkRequest; QNetworkRequest m_networkRequest;
QTimer *m_time;
}; };
#endif // HTTPSOCKET_H #endif // HTTPSOCKET_H
...@@ -37,7 +37,7 @@ int m_netflag = 0; ...@@ -37,7 +37,7 @@ int m_netflag = 0;
char getch[40960] = {0}; char getch[40960] = {0};
Request req = {0}; Request req = {0};
#endif #endif
DbsetForm *m_dbsetWidget = 0;
FloatWidget *m_floatWidget = 0; FloatWidget *m_floatWidget = 0;
MainWindow *m_mainWidget = 0 ; MainWindow *m_mainWidget = 0 ;
...@@ -253,6 +253,27 @@ InitClass::~InitClass() ...@@ -253,6 +253,27 @@ InitClass::~InitClass()
} }
void InitClass::slotThread()
{
g_threadCtl->terminateFlowcontrollThread();
if(g_threadCtl)
{
delete g_threadCtl;
g_threadCtl = 0;
}
if(m_floatWidget)
{
delete m_floatWidget;
m_floatWidget=0;
}
if(m_mainWidget)
{
delete m_mainWidget;
m_mainWidget=0;
}
}
void InitClass::initnetData() void InitClass::initnetData()
{ {
...@@ -336,7 +357,7 @@ void InitClass::startInit() ...@@ -336,7 +357,7 @@ void InitClass::startInit()
void InitClass::initTheme(const QString& theme) void InitClass::initTheme(const QString& theme)
{ {
QString rccPath = QString("%1/image/%2.rcc").arg(strpath).arg(theme); QString rccPath = QString("%1/../rcc/image/%2.rcc").arg(strpath).arg(theme);
qDebug()<<"rccPath is"<<rccPath; qDebug()<<"rccPath is"<<rccPath;
if(!QFile(rccPath).exists()) if(!QFile(rccPath).exists())
{ {
...@@ -381,11 +402,17 @@ void InitClass::InitDialog() ...@@ -381,11 +402,17 @@ void InitClass::InitDialog()
m_floatWidget = new FloatWidget ; m_floatWidget = new FloatWidget ;
m_mainWidget = new MainWindow; m_mainWidget = new MainWindow;
//响声音 //响声音
connect(m_mainWidget,&MainWindow::sgnSound,m_floatWidget,&FloatWidget::onStartRemind); // connect(m_mainWidget,&MainWindow::sgnSound,m_floatWidget,&FloatWidget::onStartRemind);
connect(m_mainWidget,&MainWindow::sgnMainHome,this,&InitClass::sgnHome); connect(m_mainWidget,&MainWindow::sgnMainHome,this,&InitClass::sgnHome);
connect(this, &InitClass::sgnMainUi,m_mainWidget,&MainWindow::OnshowMainUi); connect(this, &InitClass::sgnMainUi,m_mainWidget,&MainWindow::OnshowMainUi);
connect(this, &InitClass::sgnMainUi, m_mainWidget, &MainWindow::show); connect(this, &InitClass::sgnMainUi, m_mainWidget, &MainWindow::show);
connect(m_mainWidget, &MainWindow::sgnStopRemind, this, &InitClass::sgnStopRemind); connect(m_mainWidget, &MainWindow::sgnStopRemind, this, &InitClass::sgnStopRemind);
// 退出线程
connect(this,SIGNAL(sgnGetThreadnet()),m_mainWidget,SIGNAL(sgnThreadNet()));
connect(m_mainWidget,SIGNAL(sgnThreadKillMain()),this,SLOT(slotThread()));
//打印接口 //打印接口
connect(m_mainWidget,&MainWindow::sgnPrintNameInit,this,&InitClass::sgnPrintName2); //发出信号 connect(m_mainWidget,&MainWindow::sgnPrintNameInit,this,&InitClass::sgnPrintName2); //发出信号
......
...@@ -43,5 +43,8 @@ public: ...@@ -43,5 +43,8 @@ public:
Q_SIGNAL void sgnPrintName2(); Q_SIGNAL void sgnPrintName2();
Q_SIGNAL void sgnSendPrintName(QString str); Q_SIGNAL void sgnSendPrintName(QString str);
Q_SIGNAL void sgnReceStatus(bool var); Q_SIGNAL void sgnReceStatus(bool var);
Q_SIGNAL void sgnGetThreadnet();
Q_SIGNAL void sgnGetThread();
Q_SLOT void slotThread();
}; };
#endif // INITCLASS_H #endif // INITCLASS_H
...@@ -390,10 +390,10 @@ QString DetailForm::PrintdataNormal(OrderObject *pData) //传入一般模式的 ...@@ -390,10 +390,10 @@ QString DetailForm::PrintdataNormal(OrderObject *pData) //传入一般模式的
QString str_comd_list; QString str_comd_list;
total=pData->proList.count()*2; total=pData->proList.count()*2;
QString filePath = QString("%1/PrinterModle.txt").arg(QCoreApplication::applicationDirPath()); QString filePath = QString("%1/Printer.template").arg(QCoreApplication::applicationDirPath());
QFile file(filePath); QFile file(filePath);
if( !file.open( QFile::ReadOnly)){ if( !file.open( QFile::ReadOnly)){
return InitClass::GetInstance().GB2312ToUnicode("无法打开PrinterModle.txt!"); return InitClass::GetInstance().GB2312ToUnicode("无法打开Printer.template");
} }
QLOG_INFO()<<"GetPrintData Normal is star"; QLOG_INFO()<<"GetPrintData Normal is star";
...@@ -415,17 +415,17 @@ QString DetailForm::PrintdataNormal(OrderObject *pData) //传入一般模式的 ...@@ -415,17 +415,17 @@ QString DetailForm::PrintdataNormal(OrderObject *pData) //传入一般模式的
{ {
if(!v.compare(InitClass::GetInstance().GB2312ToUnicode("顾客留存"))) if(!v.compare(InitClass::GetInstance().GB2312ToUnicode("顾客留存")))
{ {
fee = Penny2Dollar(pData->user_fee); fee = InitClass::GetInstance().GB2312ToUnicode("应付金额:¥ ")+Penny2Dollar(pData->user_fee);
} }
else if(!v.compare(InitClass::GetInstance().GB2312ToUnicode("商户留存"))) else if(!v.compare(InitClass::GetInstance().GB2312ToUnicode("商户留存")))
{ {
if(!pData->pay_type.compare(InitClass::GetInstance().GB2312ToUnicode("货到付款"))) if(!pData->pay_type.compare(InitClass::GetInstance().GB2312ToUnicode("货到付款")))
{ {
fee= Penny2Dollar(pData->shop_fee); fee= InitClass::GetInstance().GB2312ToUnicode("应收现金:¥ ")+Penny2Dollar(pData->shop_fee);
} }
else else
{ {
fee = "0"; fee = InitClass::GetInstance().GB2312ToUnicode("应收金额:¥ 0");
} }
} }
...@@ -433,7 +433,11 @@ QString DetailForm::PrintdataNormal(OrderObject *pData) //传入一般模式的 ...@@ -433,7 +433,11 @@ QString DetailForm::PrintdataNormal(OrderObject *pData) //传入一般模式的
{ {
if(!pData->pay_type.compare(InitClass::GetInstance().GB2312ToUnicode("货到付款"))) if(!pData->pay_type.compare(InitClass::GetInstance().GB2312ToUnicode("货到付款")))
{ {
fee=Penny2Dollar(pData->user_fee); fee=InitClass::GetInstance().GB2312ToUnicode("应收金额:¥")+Penny2Dollar(pData->user_fee);
}
else
{
fee=InitClass::GetInstance().GB2312ToUnicode("应收金额:¥ 0");
} }
} }
print = str_print.append(v).append("|").append(pData->channelName).append("|").append(pData->order_id).append("|").append(pData->pay_type).append("|") print = str_print.append(v).append("|").append(pData->channelName).append("|").append(pData->order_id).append("|").append(pData->pay_type).append("|")
......
...@@ -91,7 +91,9 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -91,7 +91,9 @@ MainWindow::MainWindow(QWidget *parent) :
connect(&flowControll::GetInstance(),&flowControll::showCashierChooseForm,this,&MainWindow::onShowCashierChooseForm);//显示收银员选择窗 connect(&flowControll::GetInstance(),&flowControll::showCashierChooseForm,this,&MainWindow::onShowCashierChooseForm);//显示收银员选择窗
connect(&flowControll::GetInstance(),&flowControll::showOrderDetails,this,&MainWindow::onShowOrderDetails);//显示订单的详情 connect(&flowControll::GetInstance(),&flowControll::showOrderDetails,this,&MainWindow::onShowOrderDetails);//显示订单的详情
connect(&flowControll::GetInstance(),&flowControll::updateCashier,this,&MainWindow::onUpdateshowCashier); connect(&flowControll::GetInstance(),&flowControll::updateCashier,this,&MainWindow::onUpdateshowCashier);
connect(this,&MainWindow::sgnThreadNet,&flowControll::GetInstance(),&flowControll::sgnThreadFollow); //kill线程
connect(&flowControll::GetInstance(),&flowControll::sgnThreadFollow,&flowControll::GetInstance(),&flowControll::onStopTimer);
connect(&flowControll::GetInstance(),&flowControll::sgnKillThread,this,&MainWindow::sgnThreadKillMain);
psetting = new PrintSetting(this); psetting = new PrintSetting(this);
m_keyBoadForm = new KeyBoardForm(this); m_keyBoadForm = new KeyBoardForm(this);
...@@ -139,19 +141,23 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -139,19 +141,23 @@ MainWindow::MainWindow(QWidget *parent) :
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
g_threadCtl->terminateFlowcontrollThread(); // g_threadCtl->terminateFlowcontrollThread();
g_threadCtl->terminateRefusecontrollThread(); // g_threadCtl->terminateRefusecontrollThread();
// g_threadCtl->terminateOthercontrollThread();
delete g_threadCtl;
g_threadCtl = 0;
//FM_Destroy(); //FM_Destroy();
delete m_dbsetWidget; // delete m_dbsetWidget;
delete m_floatWidget; // delete m_floatWidget;
// FM_deletpr(); // FM_deletpr();
delete ui; // delete ui;
} }
void MainWindow::InitstyleMain() void MainWindow::InitstyleMain()
{ {
QString strpath= QCoreApplication::applicationDirPath(); QString strpath= QCoreApplication::applicationDirPath();
rccPath = QString("%1/image/%2.rcc").arg(strpath).arg(APP_THEME); rccPath = QString("%1/../rcc/image/%2.rcc").arg(strpath).arg(APP_THEME);
qDebug()<<"rccPath is"<<rccPath; qDebug()<<"rccPath is"<<rccPath;
if(!QFile(rccPath).exists()) if(!QFile(rccPath).exists())
{ {
...@@ -182,7 +188,7 @@ void MainWindow::unRegisterInitstyle() ...@@ -182,7 +188,7 @@ void MainWindow::unRegisterInitstyle()
{ {
QString strpath= QCoreApplication::applicationDirPath(); QString strpath= QCoreApplication::applicationDirPath();
qDebug()<<"strpath is"<<strpath; qDebug()<<"strpath is"<<strpath;
rccPath = QString("%1/image/%2.rcc").arg(strpath).arg(APP_THEME); rccPath = QString("%1/../rcc/image/%2.rcc").arg(strpath).arg(APP_THEME);
qDebug()<<"rccPath is"<<rccPath; qDebug()<<"rccPath is"<<rccPath;
if(!QFile(rccPath).exists()) if(!QFile(rccPath).exists())
{ {
...@@ -450,19 +456,20 @@ void MainWindow::onChangeOrderStatus(OrderObject *orderObject, int oldStatus) ...@@ -450,19 +456,20 @@ void MainWindow::onChangeOrderStatus(OrderObject *orderObject, int oldStatus)
// 检测是否需要提示 // 检测是否需要提示
if(ui->mainTableNew->rowCount() > 0) if(ui->mainTableNew->rowCount() > 0)
{ {
emit sgnMainHome(QCoreApplication::applicationDirPath()+"/image/float_remind.png"); emit sgnMainHome(QString("%1/../rcc/image/float_remind.png").arg(QCoreApplication::applicationDirPath()));
// emit sgnSound(0); // emit sgnSound(0);
} }
else if( orderObject->status == 2) else if( orderObject->status == 2)
{ {
if(!ReadData(orderObject->order_id)) if(!ReadData(orderObject->order_id))
{ {
emit sgnMainHome(QCoreApplication::applicationDirPath()+"/image/float_remind.png"); emit sgnMainHome(QString("%1/../rcc/image/float_remind.png").arg(QCoreApplication::applicationDirPath()));
} }
} }
else if(ui->mainTableRefund->rowCount() > 0) else if(ui->mainTableRefund->rowCount() > 0)
{ {
emit sgnMainHome(QCoreApplication::applicationDirPath()+"/image/float_remind.png"); emit sgnMainHome(QString("%1/../rcc/image/float_remind.png").arg(QCoreApplication::applicationDirPath()));
// emit sgnSound(1); // emit sgnSound(1);
} }
else else
......
...@@ -76,6 +76,8 @@ public: ...@@ -76,6 +76,8 @@ public:
Q_SIGNAL void sgnSendPrintNameInit(QString str); Q_SIGNAL void sgnSendPrintNameInit(QString str);
Q_SIGNAL void sgnReceiveStatusInit(bool var); Q_SIGNAL void sgnReceiveStatusInit(bool var);
Q_SIGNAL void sgnResetHide(bool var); Q_SIGNAL void sgnResetHide(bool var);
Q_SIGNAL void sgnThreadNet();
Q_SIGNAL void sgnThreadKillMain();
// //
// Q_SIGNAL void getOrderDetails(const QString& orderId,int i);//获取订单详情信号 // Q_SIGNAL void getOrderDetails(const QString& orderId,int i);//获取订单详情信号
Q_SLOT void OnBtnCashier(); //查看在线收银员 Q_SLOT void OnBtnCashier(); //查看在线收银员
......
...@@ -19,9 +19,7 @@ FMPTakeout::~FMPTakeout() ...@@ -19,9 +19,7 @@ FMPTakeout::~FMPTakeout()
void FMPTakeout::InitService() void FMPTakeout::InitService()
{ {
if (!_inited) {
d_func()->Init(); d_func()->Init();
}
} }
void FMPTakeout::UninitService() void FMPTakeout::UninitService()
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
TEMPLATE = lib TEMPLATE = lib
QT += core gui network sql printsupport QT += core gui network sql printsupport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
DESTDIR = ./bin DESTDIR = ./bin
MOC_DIR = ./tmp MOC_DIR = ./tmp
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
#include <QDebug> #include <QDebug>
#include "fmp_home_i.h" #include "fmp_home_i.h"
#include "fmp_printer_i.h" #include "fmp_printer_i.h"
#include "fmp_te_handlers.h"
FMPTakeoutPrivate::FMPTakeoutPrivate(FMPTakeout *q) FMPTakeoutPrivate::FMPTakeoutPrivate(FMPTakeout *parent)
: q_ptr(q) : q_ptr(parent)
{ {
} }
...@@ -38,7 +38,8 @@ int FMPTakeoutPrivate::Init() ...@@ -38,7 +38,8 @@ int FMPTakeoutPrivate::Init()
connect(&InitClass::GetInstance(),&InitClass::sgnPrintName2,this,&FMPTakeoutPrivate::sltPrintName); connect(&InitClass::GetInstance(),&InitClass::sgnPrintName2,this,&FMPTakeoutPrivate::sltPrintName);
connect(this,&FMPTakeoutPrivate::sgnSendPrintName,&InitClass::GetInstance(),&InitClass::sgnSendPrintName); connect(this,&FMPTakeoutPrivate::sgnSendPrintName,&InitClass::GetInstance(),&InitClass::sgnSendPrintName);
connect(this,&FMPTakeoutPrivate::sgnReceiveStatus,&InitClass::GetInstance(),&InitClass::sgnReceStatus); connect(this,&FMPTakeoutPrivate::sgnReceiveStatus,&InitClass::GetInstance(),&InitClass::sgnReceStatus);
// FMPStartEventHandler* handler = new FMPStartEventHandler(q->_ctx, q); connect(this,&FMPTakeoutPrivate::sgnStopTime,&InitClass::GetInstance(),&InitClass::sgnGetThreadnet);
FMPStartEventHandler* handler = new FMPStartEventHandler(q->_ctx, q);
InitClass::GetInstance().inItGloal(); InitClass::GetInstance().inItGloal();
// InitClass::GetInstance().LoadDll(); // InitClass::GetInstance().LoadDll();
InitClass::GetInstance().InitLogger(); InitClass::GetInstance().InitLogger();
...@@ -47,6 +48,7 @@ int FMPTakeoutPrivate::Init() ...@@ -47,6 +48,7 @@ int FMPTakeoutPrivate::Init()
return FMP_SUCCESS; return FMP_SUCCESS;
} }
else{ else{
//InitClass::GetInstance().inItGloal();
emit sgnGetFromHome(); emit sgnGetFromHome();
return 1; return 1;
} }
...@@ -61,32 +63,24 @@ FMPTakeoutPrivate::~FMPTakeoutPrivate() ...@@ -61,32 +63,24 @@ FMPTakeoutPrivate::~FMPTakeoutPrivate()
int FMPTakeoutPrivate::Uninit() int FMPTakeoutPrivate::Uninit()
{ {
Q_Q(FMPTakeout); Q_Q(FMPTakeout);
emit sgnStopTime();
if(_Printer != nullptr) if(_Printer != nullptr)
{ {
delete _Printer;
_Printer = 0; _Printer = 0;
} }
if(_Home!= nullptr) if(_Home!= nullptr)
{ {
delete _Home;
_Home = 0; _Home = 0;
} }
if(_settings!= nullptr) if(_settings!= nullptr)
{ {
delete _settings;
_settings = 0; _settings = 0;
} }
q->_inited = false; q->_inited = false;
return FMP_SUCCESS; return FMP_SUCCESS;
} }
void FMPTakeoutPrivate::ShowForm()
{
}
// home 提供接口 // home 提供接口
void FMPTakeoutPrivate::sltHome(QString path) void FMPTakeoutPrivate::sltHome(QString path)
{ {
...@@ -101,14 +95,14 @@ void FMPTakeoutPrivate::sltStopBlink(int type) ...@@ -101,14 +95,14 @@ void FMPTakeoutPrivate::sltStopBlink(int type)
void FMPTakeoutPrivate::sltPrint(QString data) void FMPTakeoutPrivate::sltPrint(QString data)
{ {
// emit sgnReceiveStatus(_Printer->DoPrint(data)); emit sgnReceiveStatus(_Printer->DoPrint(data));
} }
void FMPTakeoutPrivate::sltPrintName() void FMPTakeoutPrivate::sltPrintName()
{ {
// if(_Printer) if(_Printer)
// { {
// emit sgnSendPrintName(_Printer->GetPrintName()); emit sgnSendPrintName(_Printer->GetPrintName());
// } }
} }
...@@ -14,7 +14,6 @@ public: ...@@ -14,7 +14,6 @@ public:
int Init(); int Init();
int Uninit(); int Uninit();
~FMPTakeoutPrivate(); ~FMPTakeoutPrivate();
void ShowForm();
private: private:
...@@ -22,15 +21,16 @@ public: ...@@ -22,15 +21,16 @@ public:
FMPTakeout *q_ptr; FMPTakeout *q_ptr;
FMPHomeInterface *_Home; FMPHomeInterface *_Home;
FMPPrinterInterface *_Printer; FMPPrinterInterface *_Printer;
private:
FMPSettingsInterface *_settings; FMPSettingsInterface *_settings;
Q_SLOT void sltHome(QString path); Q_SLOT void sltHome(QString path);
Q_SLOT void sltStopBlink(int type); Q_SLOT void sltStopBlink(int type);
Q_SLOT void sltPrint(QString data); Q_SLOT void sltPrint(QString data);
Q_SLOT void sltPrintName(); Q_SLOT void sltPrintName();
Q_SIGNAL void sgnGetFromHome(); Q_SIGNAL void sgnGetFromHome();
Q_SIGNAL void sgnQuitThread();
Q_SIGNAL void sgnSendPrintName(QString str); Q_SIGNAL void sgnSendPrintName(QString str);
Q_SIGNAL void sgnReceiveStatus(bool var); Q_SIGNAL void sgnReceiveStatus(bool var);
Q_SIGNAL void sgnStopTime();
}; };
#endif // FMP_TAKEOUT_P_H #endif // FMP_TAKEOUT_P_H
...@@ -29,24 +29,26 @@ ...@@ -29,24 +29,26 @@
#include <QDebug> #include <QDebug>
FMPTakeoutPlugin::FMPTakeoutPlugin() FMPTakeoutPlugin::FMPTakeoutPlugin()
: _Takeout_service(0) : _takeout_service(0)
{ {
} }
void FMPTakeoutPlugin::start(ctkPluginContext* context) void FMPTakeoutPlugin::start(ctkPluginContext* context)
{ {
_Takeout_service = new FMPTakeout(context); _takeout_service = new FMPTakeout(context);
context->registerService<FMPTakeoutInterface>( _Takeout_service); context->registerService<FMPTakeoutInterface>( _takeout_service);
} }
void FMPTakeoutPlugin::stop(ctkPluginContext* context) void FMPTakeoutPlugin::stop(ctkPluginContext* context)
{ {
Q_UNUSED(context) Q_UNUSED(context)
if (_Takeout_service) if (_takeout_service)
{ {
delete _Takeout_service; delete _takeout_service;
_Takeout_service = 0; _takeout_service = 0;
} }
int a = 0;
} }
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0)) #if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
......
...@@ -21,7 +21,7 @@ public: ...@@ -21,7 +21,7 @@ public:
private: private:
FMPTakeout* _Takeout_service; FMPTakeout* _takeout_service;
}; // FMPTakeoutPlugin }; // FMPTakeoutPlugin
......
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