dushibaiyu 6 лет назад
Родитель
Сommit
49e89591cd

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "pqQtlib"]
+	path = pqQtlib
+	url = http://git.pqitech.com/PQLib/pqQtlib.git

+ 5 - 9
JxcClient.pro

@@ -15,7 +15,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
 # You can also select to disable deprecated APIs only up to a certain version of Qt.
 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
-include($$PWD/QLog/QLogClass.pri)
+include($$PWD/pqQtlib/pqQtlib.pri)
 
 SOURCES += \
     configinfo.cpp \
@@ -31,10 +31,8 @@ SOURCES += \
     handle/selectspecs.cpp \
     handle/seriport/assictscalet2000.cpp \
     handle/seriport/serialbasehandle.cpp \
-    handle/utils/cachefile.cpp \
-    handle/utils/rtuhelper.cpp \
-    handle/utils/utilsfunc.cpp \
-    packinfo.cpp \
+    struct_/packinfo.cpp \
+    struct_/projectinfo.cpp \
     widget/addnewspecsform.cpp \
     widget/autopackform.cpp \
     widget/fixedweightpackform.cpp \
@@ -60,10 +58,8 @@ HEADERS += \
     handle/rtuport.h \
     handle/seriport/assictscalet2000.h \
     handle/seriport/serialbasehandle.h \
-    handle/utils/cachefile.h \
-    handle/utils/rtuhelper.h \
-    handle/utils/utilsfunc.h \
-    packinfo.h \
+    struct_/packinfo.h \
+    struct_/projectinfo.h \
     widget/addnewspecsform.h \
     widget/autopackform.h \
     widget/fixedweightpackform.h \

+ 0 - 4
QLog/QLogClass.pri

@@ -1,4 +0,0 @@
-CONFIG += c++11
-SOURCES += $$PWD/qlog.cpp
-HEADERS += $$PWD/qlog.h
-INCLUDEPATH += $$PWD

+ 0 - 340
QLog/qlog.cpp

@@ -1,340 +0,0 @@
-#include "qlog.h"
-#include <QTime>
-#include <QEvent>
-#include <QThread>
-#include <QCoreApplication>
-#include <iostream>
-#include <QDir>
-#include <QDate>
-#include <memory>
-#include <QDebug>
-#include <QDateTime>
-
-namespace QLOG {
-
-static const char * LevelName[6] = {"Test","Debug","Info","Warning","Critical","Fatal"};
-
-void customMessageHandler(QtMsgType type, const QMessageLogContext &context,const QString & msg)
-{
-    auto log = QLogManger::this_()->qDebugLog();
-    switch (type) {
-    //调试信息提示
-    case QtDebugMsg:
-        if (log->checkLevel(DebugMsg)) {
-            LogMessage(log,context.file,context.line,DebugMsg).stream()  << msg ;
-        }
-        break;
-        //一般的warning提示
-    case QtWarningMsg:
-        if (log->checkLevel(WarningMsg)) {
-            LogMessage(log,context.file,context.line,WarningMsg).stream() << msg ;
-        }
-        break;
-        //严重错误提示
-    case QtCriticalMsg:
-        if (log->checkLevel(CriticalMsg)) {
-            LogMessage(log,context.file,context.line,CriticalMsg).stream() << msg ;
-        }
-        break;
-        //致命错误提示
-    case QtFatalMsg:
-        if (log->checkLevel(FatalMsg)) {
-            LogMessage(log,context.file,context.line,FatalMsg).stream() << msg ;
-        }
-        break;
-    case QtInfoMsg :
-        if (log->checkLevel(InfoMsg)) {
-            LogMessage(log,context.file,context.line,InfoMsg).stream() << msg ;
-        }
-        break;
-    }
-}
-
-QLogManger::QLogManger()
-{
-    _thread.start();
-    auto nm = QCoreApplication::applicationName();
-    _baseLog.reset(new QLog(nm,STD_OUT));
-    _baseLog->moveToThread(&_thread);
-    _qtLog.reset(new QLog("qtdebug",STD_OUT));
-    _qtLog->moveToThread(&_thread);
-    _logs.insert(nm,_baseLog);
-    _logs.insert("qtdebug",_qtLog);
-    connect(this,&QLogManger::updateSavePath,_baseLog.data(),&QLog::restLog,Qt::QueuedConnection);
-    connect(this,&QLogManger::updateSavePath,_qtLog.data(),&QLog::restLog,Qt::QueuedConnection);
-    setSaveFilePath(QDir::homePath() + "/qlog");
-}
-
-QLogManger * QLogManger::this_()
-{
-    static QLogManger logManger;
-    return &logManger;
-}
-
-QLogManger::~QLogManger()
-{
-    _thread.quit();
-    _thread.wait(1000);
-    if(_thread.isRunning()){
-        _thread.terminate();
-    }
-}
-
-bool QLogManger::setSaveFilePath(const QString & path)
-{
-    QDir dir(path);
-    if(dir.exists() || dir.mkpath(dir.absolutePath())) {
-        QFileInfo info(path);
-        if(info.isWritable()){
-            path_ = dir.absolutePath();
-            emit updateSavePath();
-        }
-    }
-    return false;
-}
-
-QLog * QLogManger::enbleQtMessage()
-{
-    qInstallMessageHandler(customMessageHandler);
-    return _qtLog.data();
-}
-
-QLog * QLogManger::getLog(const QString & name)
-{
-    _locker.lockForRead();
-    auto log = _logs.value(name);
-    _locker.unlock();
-    if(log.isNull()){
-        _locker.lockForWrite();
-        log = _logs.value(name);
-        if(log.isNull()){
-            log.reset(new QLog(name));
-            log->moveToThread(&_thread);
-            connect(this,&QLogManger::updateSavePath,log.data(),&QLog::restLog,Qt::QueuedConnection);
-            _logs.insert(name,log);
-        }
-        _locker.unlock();
-    }
-    return log.data();
-}
-
-class LogEvent : public QEvent
-{
-public:
-    LogEvent(QString && str,LogLevel lv): QEvent(eventType),level(lv),str_(str) {}
-    ~LogEvent() {}
-
-    const QString & getString() const {return str_;}
-
-    static QEvent::Type eventType;
-    LogLevel level;
-private:
-    QString str_;
-};
-
-QEvent::Type LogEvent::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
-
-class UpEventOutStatus : public QEvent
-{
-public:
-    UpEventOutStatus(OutState state): QEvent(eventType),state(state) {}
-    ~UpEventOutStatus() {}
-
-
-    static QEvent::Type eventType;
-    OutState state;
-};
-
-QEvent::Type UpEventOutStatus::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
-
-LogMessage::LogMessage(QLog * log,const char * file, int line,LogLevel level) : log(log), ts(&str_),level_(level)
-{
-    if(log == nullptr || level < log->level) return;
-    if(log->writeTime){
-        ts << "[" << QTime::currentTime().toString("hh:mm:ss.zzz") << "]:";
-    }
-    if(log->writeFileInfo) {
-        ts << "[@ " << file << " : " << line << "]:";
-    }
-    if(log->writeLevel){
-        ts << "[" << LevelName[level] << "]:";
-    }
-}
-
-LogMessage::LogMessage(QLog * log,LogLevel level): log(log), ts(&str_),level_(level)
-{
-    if(log == nullptr || level < log->level) return;
-    if(log->writeTime){
-        ts << "[" << QTime::currentTime().toString("hh:mm:ss.zzz") << "]:";
-    }
-    if(log->writeFileInfo) {
-        ts << "[@ ]:";
-    }
-    if(log->writeLevel){
-        ts << "[" << LevelName[level] << "]:";
-    }
-}
-
-LogMessage::~LogMessage()
-{
-    if (log != nullptr && level_ >= log->level ) {
-        if(log->writeEndLine)
-            ts << "\r\n";
-        ts.setDevice(nullptr);
-        QCoreApplication::postEvent(log,new LogEvent(std::move(str_),level_));
-        if (level_ == FatalMsg) {
-            QCoreApplication::exit(-1);
-        }
-    }
-}
-
-
-QLog::QLog(const QString & name, OutState state)
-        : QObject(nullptr),state_(state),file_(nullptr),_name(name)
-{
-    level = TestMsg;
-    writeTime = true;
-    writeFileInfo = true;
-    writeLevel = true;
-    writeEndLine = true;
-    fileCreateType = DayOne;
-    ts_.setDevice(nullptr);
-    _fileCreateId = -1;
-}
-
-QLog::~QLog()
-{
-    releaseLogFile();
-
-}
-
-void QLog::setOutState(OutState outState)
-{
-    QCoreApplication::postEvent(this,new UpEventOutStatus(outState));
-}
-
-void QLog::restLog()
-{
-    if(state_ == File){
-        releaseLogFile();
-    }
-}
-
-void QLog::releaseLogFile()
-{
-  ts_.setDevice(nullptr);
-  if(file_){
-      file_->close();
-      delete file_;
-      file_ = nullptr;
-  }
-}
-
-void QLog::customEvent(QEvent * event)
-{
-    if(event->type() == UpEventOutStatus::eventType){
-        UpEventOutStatus * ev = static_cast<UpEventOutStatus *>(event);
-        if(state_ != ev->state) {
-            state_ = ev->state;
-            releaseLogFile();
-
-        }
-    } else if (event->type() == LogEvent::eventType) {
-        LogEvent * ev = static_cast<LogEvent *>(event);
-        if(ev->level >= level) {
-            switch (state_) {
-            case STD_OUT :{
-                if(file_ == nullptr){
-                    file_ = new QFile(this);
-                    file_->open(1,QFile::Append);
-                    ts_.setDevice(file_);
-                }
-            }
-                break;
-            case STD_ERROR:{
-                if(file_ == nullptr){
-                    if(file_ == nullptr){
-                        file_ = new QFile(this);
-                        file_->open(2,QFile::Append);
-                        ts_.setDevice(file_);
-                    }
-                }
-            }
-                break;
-            case File : {
-                if(file_){
-                    int id = _fileCreateId;
-                    switch (fileCreateType) {
-                    case DayOne: {
-                        id = QDate::currentDate().day();
-                    }
-                        break;
-                    case HourOne:
-                        id = QTime::currentTime().hour();
-                        break;
-                    case MonthOne:
-                        id = QDate::currentDate().month();
-                        break;
-                    default:
-                        id = _fileCreateId;
-                        break;
-                    }
-                    if(id != _fileCreateId)
-                        releaseLogFile();
-                }
-                if(file_ == nullptr){
-                    QString fname = QLogManger::this_()->getSaveFilePath() + "/" + _name;
-                    switch (fileCreateType) {
-                    case OneStartOne:{
-                        auto pid = QCoreApplication::applicationPid();
-                        fname += "_";
-                        fname += QDateTime::currentDateTime().toString("yyyy-MM-dd.hh-mm-ss.zzz");
-                        fname += "_";
-                        fname += QString::number(pid);
-                        _fileCreateId = 0;
-                    }
-                    case DayOne: {
-                        auto dt = QDate::currentDate();
-                        fname += "_";
-                        fname += dt.toString("yyyy-MM-dd");
-                        _fileCreateId = dt.day();
-                    }
-                        break;
-                    case HourOne:{
-                        auto dt = QDateTime::currentDateTime();
-                        fname += "_";
-                        fname += dt.toString("yyyy-MM-dd.hh");
-                        _fileCreateId = dt.time().hour();
-                    }
-                        break;
-                    case MonthOne:{
-                        auto dt = QDate::currentDate();
-                        fname += "_";
-                        fname += dt.toString("yyyy-MM");
-                        _fileCreateId = dt.month();
-                    }
-                        break;
-                    default:
-                        break;
-                    }
-                    fname += ".logs";
-                    file_ = new QFile(fname,this);
-                    file_->open(QFile::Append);
-                    ts_.setDevice(file_);
-                }
-            }
-            break;
-        default:
-            break;
-        }
-        if (ts_.device() != nullptr) {
-            ts_ << ev->getString();
-            ts_.flush();
-        }
-        }
-    }
-    event->accept();
-
-}
-
-}//namespace QLOG

+ 0 - 164
QLog/qlog.h

@@ -1,164 +0,0 @@
-#ifndef QLOG_H
-#define QLOG_H
-
-#include <QObject>
-#include <QTextStream>
-#include <QFile>
-#include <QCoreApplication>
-#include <QSharedPointer>
-#include <QReadWriteLock>
-#include <QThread>
-
-//QtDebugMsg	0	A message generated by the qDebug() function.
-//QtInfoMsg	    4	A message generated by the qInfo() function.
-//QtWarningMsg	1	A message generated by the qWarning() function.
-//QtCriticalMsg	2	A message generated by the qCritical() function.
-//QtFatalMsg	3	A message generated by the qFatal() function.
-
-
-
-#define LOG(log,Level) if (log->checkLevel(Level)) \
-    QLOG::LogMessage(log,__FILE__, __LINE__,Level).stream()
-
-#define QLogTest(log) LOG(log,QLOG::TestMsg)
-#define QLogDebug(log) LOG(log,QLOG::DebugMsg)
-#define QLogInfo(log) LOG(log,QLOG::InfoMsg)
-#define QLogWarning(log) LOG(log,QLOG::WarningMsg)
-#define QLogCritical(log) LOG(log,QLOG::CriticalMsg)
-#define QLogFatal(log) LOG(log,QLOG::FatalMsg)
-
-#define LOGD(Level) if (QLOG::QLogManger::this_()->baseLog()->checkLevel(Level)) \
-    QLOG::LogMessage(QLOG::QLogManger::this_()->baseLog(),__FILE__, __LINE__,Level).stream()
-
-#define QDTest LOGD(QLOG::TestMsg)
-#define QDDebug LOGD(QLOG::DebugMsg)
-#define QDInfo LOGD(QLOG::InfoMsg)
-#define QDWarning LOGD(QLOG::WarningMsg)
-#define QDCritical LOGD(QLOG::CriticalMsg)
-#define QDFatal LOGD(QLOG::FatalMsg)
-
-namespace QLOG {
-class QLog;
-
-enum LogLevel{
-    TestMsg = 0,
-    DebugMsg = 1,
-    InfoMsg = 2,
-    WarningMsg = 3,
-    CriticalMsg = 4,
-    FatalMsg = 5,
-};
-
-enum OutState{
-    STD_OUT = 0,
-    STD_ERROR = 1,
-    File = 2
-};
-
-enum FileCreateType
-{
-    OnlyOne,
-    OneStartOne,
-    DayOne,
-    HourOne,
-    MonthOne
-};
-
-
-
-class LogMessage
-{
-public:
-    LogMessage(QLog * log, const char * file, int line, LogLevel level);
-    LogMessage(QLog * log,LogLevel level);
-    ~LogMessage();
-    inline QTextStream & stream() {return ts;}
-private:
-    QLog * log;
-    QString str_;
-    QTextStream ts;
-    LogLevel level_;
-};
-
-class LogEvent;
-
-
-// TODO:
-class QLogManger : public QObject
-{
-    Q_OBJECT
-public:
-    ~QLogManger();
-
-    static QLogManger * this_();
-
-    inline QLog * baseLog()const {
-        return _baseLog.data();
-    }
-
-    inline QLog * qDebugLog()const {
-        return _baseLog.data();
-    }
-
-    bool setSaveFilePath(const QString & path);
-
-    QLog * enbleQtMessage();
-
-    QLog * getLog(const QString & name);
-
-    inline QString getSaveFilePath() const {return path_;}
-signals:
-    void updateSavePath();
-private:
-    QString path_;
-    QLogManger();
-    QReadWriteLock _locker;
-    QHash<QString, QSharedPointer<QLog>> _logs;
-    QSharedPointer<QLog> _baseLog;
-    QSharedPointer<QLog> _qtLog;
-    QThread _thread;
-};
-
-class QLog : public QObject
-{
-    Q_OBJECT
-public:
-    ~QLog();
-    inline  bool checkLevel(LogLevel level) {
-        if (level < this->level) {
-            return false;
-        }
-        return true;
-    }
-
-    bool writeTime;
-    bool writeFileInfo;
-    bool writeLevel;
-    bool writeEndLine;
-    LogLevel level;
-    FileCreateType fileCreateType;;
-
-    void setOutState(OutState outState);
-    inline OutState getOutState() const {return state_;}
-protected:
-    void customEvent(QEvent * event);
-
-protected slots:
-    void restLog();
-
-    void releaseLogFile();
-private:
-    OutState state_;
-    QFile * file_;
-    QTextStream ts_;
-    QString _name;
-    int  _fileCreateId;
-private:
-    explicit QLog(const QString & name,OutState state = File);
-    friend class QLogManger;
-    friend class LogMessage;
-};
-
-} //namespace QLOG
-
-#endif // QLOG_H

+ 0 - 43
configinfo.h

@@ -45,48 +45,5 @@ private:
 
 };
 
-struct UserInfo
-{
-    QString userName;
-    int userId;
-    int accountId;
-    QString name;
-    QString headPortrait;
-    bool isVip;
-    QString acessToken;
-
-};
-
-struct ProjectInfo
-{
-    int goods_id;//	int	商品ID
-    QString batch_no;//	string	批号
-    QString category;//	string	类型
-    QString product_type_code;//	string	品种
-    QString spec_role;//	string	规格录入
-    QString denier;//	string	旦数(D)
-    QString dtex;//	string	分特(dt)
-    QString fiber;//	string	孔数(F)
-    QString specs;//	string	规格
-    QString color;//	string	颜色
-    QString twist_type;//	string	捻向
-    QString bucket_color;//	string	管色
-    QString box_weight;//	string	皮重
-    QString bucket_weight;//	string	筒重
-    QString machine_no;//	string	机台
-    QString carton_type;//	string	纸箱
-    QString limit_number;//	string	限制打包
-    QString bucket_number;//	string	筒数
-    QString cake_float;//	string	丝饼浮动
-    QString box_float;//	string	纸箱浮动
-    QString box_rule;//	string	箱号规则
-    QString customer;//	string	箱单抬头
-    QString remark;//	string	备注
-    bool is_disable;//	bool	是否禁用
-    qint64 create_time;//	int	创建时间
-    qint64 modified_time;//	int	更新时间
-
-    QString telephone;//
-};
 
 #endif // CONFIGINFO_H

+ 8 - 1
globalinfo.h

@@ -3,6 +3,8 @@
 
 #include <QObject>
 #include "configinfo.h"
+#include "struct_/projectinfo.h"
+#include <QMap>
 
 struct scaledata{
     double gross_widget = 0.00; //毛重
@@ -33,10 +35,15 @@ public:
     void SetScaleData(scaledata data);
 
     bool isNoLine;
+
+    inline QSharedPointer<ProjectInfo> project(const QString & name){return _project.value(name);}
 signals:
 
 public slots:
-
+private:
+    QMap<QString,QSharedPointer<ProjectInfo>> _project;
+    QList<QSharedPointer<ProjectInfo>> _serverInfo;
+    QList<QSharedPointer<ProjectInfo>> _cacheInfo;
 private:
     QString pack_num;
     scaledata scale;

+ 6 - 6
handle/autopackutils.cpp

@@ -73,8 +73,8 @@ void AutoPackUtils::insertProductSQL(QSharedPointer<PackInfo> packes)
     productData.goods_id = packes->goodsID();
     productData.code_single = packes->codeSingle();
     productData.quantity = packes->quantity;
-    productData.batch_no = packes->info().batch_no;
-    productData.category = packes->info().category;
+    productData.batch_no = packes->info()->batch_no;
+    productData.category = packes->info()->category;
     productData.level_id = packes->level_id;
     productData.tube_number = packes->tube_number();
     productData.gross_weight = packes->gross_weight();
@@ -84,10 +84,10 @@ void AutoPackUtils::insertProductSQL(QSharedPointer<PackInfo> packes)
     productData.packing_type = packes->packing_type;
     productData.carton_type = packes->carton_type;
     productData.operator_id = packes->operator_id;
-    productData.specs = packes->info().specs;
-    productData.denier = packes->info().denier;
-    productData.dtex = packes->info().dtex;
-    productData.fiber = packes->info().fiber;
+    productData.specs = packes->info()->specs;
+    productData.denier = packes->info()->denier;
+    productData.dtex = packes->info()->dtex;
+    productData.fiber = packes->info()->fiber;
     productData.remark = packes->remark;
 
     if(database.insertProduct(productData)){

+ 2 - 2
handle/autopackutils.h

@@ -1,11 +1,11 @@
-#ifndef AUTOPACKUTILS_H
+#ifndef AUTOPACKUTILS_H
 #define AUTOPACKUTILS_H
 
 #include "QObject"
 #include "qabstractanimation.h"
 #include "httprequest.h"
 #include "database.h"
-#include "packinfo.h"
+#include "struct_/packinfo.h"
 #include "globalinfo.h"
 #include "danjumuban.h"
 

+ 7 - 6
handle/danjumuban.cpp

@@ -4,17 +4,18 @@
 #include "globalinfo.h"
 #include <QDir>
 #include "configinfo.h"
-#include "handle/utils/cachefile.h"
+#include <pqQtlib/utils/pqfileutils.h>
+#include <pqQtlib/log/pqlog.h>
 
 DanJuMuBan::DanJuMuBan()
 {
-    path = QLOG::QLogManger::this_()->getSaveFilePath();
+    path = PQ::PQLogManger::this_()->getSaveFilePath();
     QDir dir(path);
     if(!dir.exists("xiangdan"))
         dir.mkdir("xiangdan");
     if(!dir.exists("rukudan"))
         dir.mkdir("rukudan");
-    log = QLOG::QLogManger::this_()->getLog("printer");
+    log = PQ::PQLogManger::this_()->getLog("printer");
     ConfigInfo info;
     info.Start();
     save = true;
@@ -26,7 +27,7 @@ QImage DanJuMuBan::printBoxInfo(QString bar,QSharedPointer<BoxInfo> info)
 //    if(datalist.isEmpty()){
 //        return;
 //    }
-    QLogInfo(log) << "prnter " << bar<< "  " << info->caseNumber();
+//    QLogInfo(log) << "prnter " << bar<< "  " << info->caseNumber();
     QSharedPointer<PackInfo> pinfo = info->parentPack();
     if(pinfo.isNull()) return QImage();
     QSize size(MAXWIDTH*5,MAXHEIGHT*5);
@@ -238,7 +239,7 @@ if(save)
 void DanJuMuBan::print(QImage image)
 {
     auto name = GlobalInfo::this_()->config().printerName;
-    QLogInfo(log) << "printer " << name;
+    pqInfo(log) << "printer " << name;
         QPrinter printer(QPrinterInfo::printerInfo(GlobalInfo::this_()->config().printerName));
         printer.setPageSize(QPrinter::Custom);
         printer.setPageSizeMM(QSizeF(100,70));
@@ -255,7 +256,7 @@ void DanJuMuBan::print(QImage image)
         painter.drawImage(0,0,image);                         // 打印图像
         painter.end();
         auto ed = printer.newPage();
-        QLogInfo(log) << "printer  newPage:" << ed;
+        pqInfo(log) << "printer  newPage:" << ed;
 //        printer
 //    }
 }

+ 3 - 3
handle/danjumuban.h

@@ -7,8 +7,8 @@
 #include "code39.h"
 #include <QList>
 #include "QPrintDialog"
-#include "packinfo.h"
-#include <QLog/qlog.h>
+#include "struct_/packinfo.h"
+#include <pqQtlib/log/pqlog.h>
 
 class DanJuMuBan
 {
@@ -43,7 +43,7 @@ private:
 //    QString company = "南通市华安袜业有限公司";
 //    QString telephone = "0513-88249588";
 //    QString fax = "0513-88249589";
-    QLOG::QLog * log;
+    PQ::PQLog * log;
     bool save;
 };
 

+ 12 - 24
handle/httprequest.cpp

@@ -2,6 +2,7 @@
 #include <QUrl>
 #include <QJsonParseError>
 #include <QNetworkReply>
+#include <pqQtlib/transport/pqhttpformdata.h>
 
 HttpRequest::HttpRequest(QObject *parent) : QObject(parent)
 {
@@ -29,34 +30,13 @@ void HttpRequest::post(const QString & url, const QJsonObject & body)
 void HttpRequest::post(const QString & url, const QMap<QString, QString> &body)
 {
     QNetworkRequest req;
-    QHttpMultiPart * part = new QHttpMultiPart();
-    part->setContentType(QHttpMultiPart::FormDataType);
     req.setUrl(QUrl(url));
     initRequest(req, 1);
-    auto v = QString("multipart/form-data;boundary=%1").arg(QString(part->boundary()));
-    req.setHeader(QNetworkRequest::ContentTypeHeader,v);
-    initMultiPart(*part, body);
-    auto rep = _manager.post(req, part);
-    part->setParent(rep);
-
+    PQ::PQHttpFormData * dt = new PQ::PQHttpFormData();
+    dt->set(body);
+    dt->postThis(&_manager,req);
 }
 
-//void HttpRequest::post(const QString & url,const QMap<QString,QVariant> body)
-//{
-////    qDebug()<<body;
-//    QNetworkRequest req;
-//    QHttpMultiPart * part = new QHttpMultiPart();
-//    part->setContentType(QHttpMultiPart::FormDataType);
-//    req.setUrl(QUrl(url));
-//    initRequest(req, 1);
-//    auto v = QString("multipart/form-data;boundary=%1").arg(QString(part->boundary()));
-//    req.setHeader(QNetworkRequest::ContentTypeHeader,v);
-//    initMultiPart(*part, body);
-//    auto rep = _manager.post(req, part);
-//    part->setParent(rep);
-
-//}
-
 void HttpRequest::finishRequest(QNetworkReply * reply)
 {
     if (reply->error()){
@@ -80,6 +60,14 @@ void HttpRequest::finishRequest(QNetworkReply * reply)
     reply->deleteLater();
 }
 
+QNetworkRequest HttpRequest::request(const QString & url)
+{
+    QNetworkRequest req;
+    req.setUrl(url);
+    initRequest(req, 1);
+    return req;
+}
+
 void HttpRequest::initRequest(QNetworkRequest & req, bool post)
 {
     if(!_aid.isEmpty()){

+ 4 - 2
handle/httprequest.h

@@ -30,6 +30,10 @@ public:
         return _token;
     }
 
+
+    inline QNetworkAccessManager * manger() {return &_manager;}
+
+    QNetworkRequest request(const QString & url);
 signals:
     void result(int code, const QJsonObject & body);
 
@@ -37,8 +41,6 @@ public slots:
     void get(const QString & url);
     void post(const QString & url, const QMap<QString,QString>  & body);
     void post(const QString & url, const QJsonObject & body);
-//    void post(const QString & url, const QMap<QString,QVariant> body);
-
 
 private slots:
     void finishRequest(QNetworkReply*);

+ 6 - 8
handle/remotepackconfig.cpp

@@ -1,6 +1,6 @@
 #include "remotepackconfig.h"
 #include "globalinfo.h"
-#include "handle/utils/cachefile.h"
+#include <pqQtlib/utils/pqfileutils.h>
 #include <QJsonDocument>
 
 RemotePackConfig::RemotePackConfig(QObject *parent) : QObject(parent)
@@ -101,12 +101,12 @@ void RemotePackConfig::refConfig()
     getDdengji = false;
     GlobalInfo * glo = GlobalInfo::this_();
     if(glo->isNoLine){
-        CacheFile f;
-        auto dt = f.readFile("config.cache");
+
+        auto dt = PQ::CacheFile::readFile("config.cache");
         auto obj = QJsonDocument::fromJson(dt).object();
         result(200,obj);
         getDdengji = true;
-        dt = f.readFile("dengjiList.cache");
+        dt = PQ::CacheFile::readFile("dengjiList.cache");
         obj = QJsonDocument::fromJson(dt).object();
         result(200,obj);
     }
@@ -125,8 +125,7 @@ void RemotePackConfig::result(int code, const QJsonObject & body)
         return;
     }
     if(!getDdengji){
-        CacheFile f;
-        f.writeFile("config.cache",QJsonDocument(body).toJson());
+        PQ::CacheFile::writeFile("config.cache",QJsonDocument(body).toJson());
         QJsonArray object = body.value("data").toArray();
         for(int i = 0; i < object.size(); ++ i){
             QJsonObject obj = object.at(i).toObject();
@@ -139,8 +138,7 @@ if(!GlobalInfo::this_()->isNoLine){refDengJiList();}
 
     } else {
         // TODO: 解析等级列表
-        CacheFile f;
-        f.writeFile("dengjiList.cache",QJsonDocument(body).toJson());
+        PQ::CacheFile::writeFile("dengjiList.cache",QJsonDocument(body).toJson());
         QJsonArray object = body.value("data").toArray();
         DengJiConfigItem dengJiConfig;
         for(int i = 0; i<object.size();i++){

+ 2 - 27
handle/seriport/assictscalet2000.cpp

@@ -1,7 +1,6 @@
 #include "assictscalet2000.h"
 #include <QList>
 #include "globalinfo.h"
-#include <QLog/qlog.h>
 
 AssicTScaleT2000::AssicTScaleT2000()
 {
@@ -26,35 +25,11 @@ QByteArray AssicTScaleT2000::sendData()
 
 void AssicTScaleT2000::handle(QByteArray &data)
 {
-    int newstart = 0;
-    int scan = m_inbuffer.size();
-
-    m_inbuffer.append(data);
-
-    while (newstart < m_inbuffer.size()) {
-        int start = newstart;
-        int end = m_inbuffer.indexOf('\n', scan);
-        if (end < 0) {
-            m_inbuffer.remove(0, start);
-            return;
-        }
-        newstart = end + 1;
-        scan = newstart;
-        if (end == start)
-            continue;
-        if (m_inbuffer.at(end - 1) == '\r') {
-            --end;
-            if (end == start)
-                continue;
-        }
-        QByteArray line(m_inbuffer.constData() + start, end - start);
-        readData(line);
-    }
-    m_inbuffer.clear();
+    readed(data);
 
 }
 
-void AssicTScaleT2000::readData(QByteArray & data)
+void AssicTScaleT2000::doHandle(const QByteArray & data)
 {
     QList<QByteArray> list = data.split(',');
     auto buff = list.last();

+ 4 - 4
handle/seriport/assictscalet2000.h

@@ -2,8 +2,9 @@
 #define ASSICTSCALET2000_H
 
 #include "serialbasehandle.h"
+#include <pqQtlib/serialport/pqassicbrhelp.h>
 
-class AssicTScaleT2000 : public SerialBaseHandle
+class AssicTScaleT2000 : public SerialBaseHandle,public PQ::AssicBrHelp
 {
 public:
     AssicTScaleT2000();
@@ -11,9 +12,8 @@ public:
     virtual bool needSend();
     virtual QByteArray sendData();
     virtual void handle(QByteArray & data);
-
-    void readData(QByteArray & data);
-    QByteArray m_inbuffer;
+protected:
+    virtual void doHandle(const QByteArray & data);
 };
 
 #endif // ASSICTSCALET2000_H

+ 4 - 16
handle/seriport/logserialport.cpp

@@ -1,7 +1,8 @@
 #include "logserialport.h"
 #include <QCoreApplication>
 #include <QByteArray>
-#include "handle/utils/utilsfunc.h"
+#include <pqQtlib/utils/pqutilsfunc.h>
+#include <pqQtlib/utils/pqendian.h>
 
 
 #ifdef _MSC_VER
@@ -26,7 +27,7 @@ float LogSerialPort::toFloat(const QByteArray & ray){
     ch[1] = ray.at(3);
     ch[2] = ray.at(0);
     ch[3] = ray.at(1);
-    float value = UtilsFun::toFloatRTUValue(&ch[0]);
+    float value = qFromLittleEndian<float>(reinterpret_cast<EndianPointType *>(&ch[0]));
     return value;
 }
 
@@ -53,10 +54,8 @@ void LogSerialPort::doHandle(const QByteArray & data)
     int crcc = static_cast<uchar>(td.at(1));
     crcc = crcc << 8;
     crcc = crcc | static_cast<uchar>(td.at(0));
-    int scrc = UtilsFun::CRC(data, l);
+    int scrc = PQ::CRC(data, l);
     if(scrc != crcc) {
-//        QLogWarning << " RTC CRC erro : should be : " << scrc << "  rev is : " << crcc << "\n"
-//                 << "data is :  " << data.toHex();
         qDebug()<< " RTC CRC erro : should be : " << scrc << "  rev is : " << crcc << "\n"
                                     << "data is :  " << data.toHex();
        return;
@@ -64,28 +63,17 @@ void LogSerialPort::doHandle(const QByteArray & data)
 
     QByteArray dt;
     dt = data.mid(5,4);
-//    qDebug()<<dt;
-//    qDebug()<<data;
-//    qDebug()<<data.mid(1,4);
     if(dt.isEmpty()) return;
     needReply = true;
     float v = toFloat(dt);
     double rv = v + buchang;
     if(rv > max){
-//        qDebug() << " get error value  : " << rv << "  mx : " << max << "    min:" << min
-//                 << "   buchang :  " << buchang;
         rv = max;
-//        return;
     }
     if(rv < min){
-//        qDebug() << " get error value  : " << rv << "  mx : " << max << "    min:" << min
-//                 << "   buchang :  " << buchang;
         rv = min;
     }
     auto tm = QDateTime::currentDateTime();
-//    save(0,tm,rv);
-//    emit newValue(0,tm.toMSecsSinceEpoch(),rv);
-//    qDebug()<<rv;
     _scaledata.gross_widget = rv;
     GlobalInfo::this_()->SetScaleData(_scaledata);
 }

+ 2 - 2
handle/seriport/logserialport.h

@@ -5,7 +5,7 @@
 #include <QWidget>
 #include <QSerialPort>
 #include <QQueue>
-#include "handle/utils/rtuhelper.h"
+#include <pqQtlib/serialport/pqrtuhelper.h>
 #include <QPair>
 #include <QDateTime>
 #include <QFile>
@@ -18,7 +18,7 @@
 #pragma execution_character_set("utf-8")
 #endif
 
-class LogSerialPort : public UtilsFun::RTUHelper, public SerialBaseHandle
+class LogSerialPort : public PQ::RTUHelper, public SerialBaseHandle
 {
 public:
     explicit LogSerialPort();

+ 2 - 3
handle/seriport/serialbasehandle.cpp

@@ -1,8 +1,7 @@
 #include "serialbasehandle.h"
 #include "logserialport.h"
 #include "assictscalet2000.h"
-#include <QLog/qlog.h>
-
+#include <pqQtlib/log/pqlog.h>
 SerialBaseHandle::SerialBaseHandle()
 {
 
@@ -16,7 +15,7 @@ SerialBaseHandle::~SerialBaseHandle()
 
 SerialBaseHandle * SerialBaseHandle::getHandler(int type, const QString & result)
 {
-    QDInfo << " getHandler <<" << type;
+    pqDInfo << " getHandler <<" << type;
     SerialBaseHandle *ret = nullptr;
     switch (type) {
         case 0:

+ 0 - 75
handle/utils/cachefile.cpp

@@ -1,75 +0,0 @@
-#include "cachefile.h"
-
-#include <QFile>
-#include "QDebug"
-
-CacheFile::CacheFile()
-{
-    dir = QDir::home();
-    if(!dir.exists("jxcCache")){
-        dir.mkdir("jxcCache");
-    }
-    dir.cd("jxcCache");
-}
-
-
-bool CacheFile::writeFile(const QString & name, const QByteArray & data)
-{
-    QFile f(dir.absoluteFilePath(name));
-    if(f.open(QFile::WriteOnly)){
-        f.write(data);
-        f.close();
-    }
-    return false;
-}
-
-QByteArray CacheFile::readFile(const QString & name)
-{
-    QByteArray dt;
-    QFile f(dir.absoluteFilePath(name));
-    if(f.open(QFile::ReadOnly)){
-        dt = f.readAll();
-        f.close();
-    }
-    return dt;
-}
-
-
-QString getDecimalbit(double v,int i)
-{
-    QString tmp;
-    switch(i)
-    {
-    case 0 :
-       tmp.sprintf("%.0lf",v);
-        break;
-    case 1:
-        tmp.sprintf("%.1lf",v);
-         break;
-    case 2:
-        tmp.sprintf("%.2lf",v);
-         break;
-    case 3:
-        tmp.sprintf("%.3lf",v);
-         break;
-    case 4:
-        tmp.sprintf("%.4lf",v);
-         break;
-    case 5:
-        tmp.sprintf("%.5lf",v);
-         break;
-    case 6:
-        tmp.sprintf("%.6lf",v);
-         break;
-    case 7:
-        tmp.sprintf("%.7lf",v);
-         break;
-    case 8:
-        tmp.sprintf("%.8lf",v);
-         break;
-    default:
-        tmp.sprintf("%.9lf",v);
-         break;
-    }
-    return tmp;
-}

+ 0 - 20
handle/utils/cachefile.h

@@ -1,20 +0,0 @@
-#ifndef CACHEFILE_H
-#define CACHEFILE_H
-
-#include <QDir>
-
-class CacheFile
-{
-public:
-    CacheFile();
-
-    bool writeFile(const QString & name, const QByteArray & data);
-
-    QByteArray readFile(const QString & name);
-private:
-    QDir dir;
-};
-
-QString getDecimalbit(double v,int i = 2);
-
-#endif // CACHEFILE_H

+ 0 - 97
handle/utils/rtuhelper.cpp

@@ -1,97 +0,0 @@
-#include "rtuhelper.h"
-
-
-#ifdef _MSC_VER
-#pragma execution_character_set("utf-8")
-#endif
-
-
-namespace UtilsFun {
-
-RTUHelper::RTUHelper():
-    readType(SubAddress),toReadlen(0),_checkSubAddress(false)
-{
-
-}
-
-RTUHelper::~RTUHelper(){}
-
-void RTUHelper::readed(const QByteArray &data)
-{
-    int index = 0;
-    while (index < data.length())
-    {
-        const char ch = data.at(index);
-//        qDebug()<<"ch"<<ch;
-//        qDebug()<<data.at(index);
-        switch (readType)
-        {
-        case SubAddress:
-        {
-            ++ index;
-            if (!_checkSubAddress || _subAddress.contains(ch))
-            {
-                if(!buffer.isEmpty()) buffer.clear();
-                buffer.append(ch);
-                readType = GetType;
-            }
-            continue;
-        }
-        case GetType:
-        {
-            buffer.append(ch);
-            ++ index;
-            readType = NumLength;
-            continue;
-        }
-        case NumLength: //需要读数据
-        {
-            ++ index;
-            toReadlen = static_cast<uchar>(ch);
-            buffer.append(ch);
-            readType = ReadData;
-            continue;
-        }
-        case ReadData: //需要读数据
-        {
-            const int canread = data.length() - index;
-            if (canread >= toReadlen)
-            {
-                buffer.append(data.mid(index, toReadlen));
-                index += toReadlen;
-                toReadlen = 0;
-                readType = CRCUL;
-            }
-            else
-            {
-                buffer.append(data.mid(index, canread));
-                index += canread;
-                toReadlen -= canread;
-            }
-            continue;
-        }
-        case CRCUL: //需要读数据
-        {
-            buffer.append(ch);
-            index ++;
-            readType = CRCUH;
-            continue;
-        }
-        case CRCUH: //需要读数据
-        {
-            buffer.append(ch);
-            index ++;
-            readType = SubAddress;
-            doHandle(this->buffer);
-            buffer.clear();
-        }
-            break;
-        default:
-        {
-            readType = SubAddress;
-            continue;
-        }
-        }
-    }
-}
-}

+ 0 - 55
handle/utils/rtuhelper.h

@@ -1,55 +0,0 @@
-#ifndef RTUHELPER_H
-#define RTUHELPER_H
-
-#include <QByteArray>
-#include "QDebug"
-
-#ifdef _MSC_VER
-#pragma execution_character_set("utf-8")
-#endif
-
-/***
- * 通讯处理的公共函数
-*/
-
-namespace UtilsFun {
-
-class RTUHelper
-{
-public:
-    RTUHelper();
-    virtual ~RTUHelper();
-
-    enum RType
-    {
-        SubAddress,//从站地址
-        GetType, //要数类型
-        NumLength, //需要的长度
-        ReadData, //需要读取数据
-        CRCUL, //CRC 低位
-        CRCUH // CRC 高位
-    };
-
-    inline void setCheckSubAddress(bool check){
-        _checkSubAddress = check;
-
-    }
-    inline void addCheckSubAddress(char ch){
-        _subAddress.append(ch);
-    }
-
-    void readed(const QByteArray & data);
-protected:
-    virtual void doHandle(const QByteArray & data) = 0;
-private:
-    QByteArray buffer;
-    RType readType;
-    int toReadlen;
-private:
-    bool _checkSubAddress;
-    QByteArray _subAddress;
-};
-
-}
-
-#endif // RTUHELPER_H

+ 0 - 203
handle/utils/utilsfunc.cpp

@@ -1,203 +0,0 @@
-#include "utilsfunc.h"
-#include <QDateTime>
-#include <QtEndian>
-#include <cstring>
-
-#ifdef _MSC_VER
-#pragma execution_character_set("utf-8")
-#endif
-
-namespace UtilsFun {
-
-union TMPUN{
-    float f;
-    uint v;
-};
-
-const static uchar _auchCRCHi[256] = {0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,
-            0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
-            0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
-            0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
-            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
-            0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
-            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
-            0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
-            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
-            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
-            0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
-            0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
-            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
-            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
-            0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
-            0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
-            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
-            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
-            0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
-            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
-            0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
-            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
-            0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
-            0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
-            0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
-            0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 };
-            // CRC低位字节值表
-const static uchar  _auchCRCLo[256] = {0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06,
-            0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD,
-            0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09,
-            0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A,
-            0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4,
-            0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,
-            0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3,
-            0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4,
-            0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A,
-            0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29,
-            0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED,
-            0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,
-            0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60,
-            0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67,
-            0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F,
-            0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68,
-            0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E,
-            0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,
-            0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71,
-            0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92,
-            0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C,
-            0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B,
-            0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B,
-            0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,
-            0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42,
-            0x43, 0x83, 0x41, 0x81, 0x80, 0x40 } ;
-
-
-uchar daiMaHe(const QByteArray &ch,  int len )
-{
-    long rv = 0;
-    for(int i = 0; i < len; ++i)
-    {
-        rv += ch.at(i);
-    }
-    return static_cast<uchar>(rv);
-}
-
-ushort CRC(const QByteArray & ch,int len)
-{
-   uchar crcLo = 0xff; // 初始化校验结果低字节
-   uchar crcHi = 0xff; // 初始化校验结果高字节
-   for (int i = 0; i < len; i++)
-   {
-       int crcIndex = crcLo ^ static_cast<uchar>(ch.at(i));
-       crcLo = static_cast<uchar>(crcHi ^ _auchCRCHi[crcIndex]);
-       crcHi = _auchCRCLo[crcIndex];
-
-      /* uIndex = uchCRCHi ^ *puchMsg++;
-       uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex];
-       uchCRCLo = auchCRCLo[uIndex]; */
-
-   }
-  return static_cast<ushort>(crcHi << 8 | crcLo);
-}
-
-uchar LRC(const QByteArray & ch,int len)
-{
-    long rv = 0;
-    for(int i = 0; i < len; ++i)
-    {
-        rv += static_cast<uchar>(ch.at(i));
-    }
-    return static_cast<uchar>((rv ^ 0xFF) + 1);
-}
-
-uchar XOR(const QByteArray & ch,int len)
-{
-    uchar A = 0;
-    for (int i = 1; i < len; i++)
-    {
-        A ^= static_cast<uchar>(ch.at(i));
-    }
-    return A;
-}
-
-QByteArray reverse(const QByteArray & ch){
-    QByteArray rv;
-    rv.resize(ch.size());
-    for(int  i = 0, j = ch.length() -1; j >= 0; j--, i++){
-        rv[i] = ch[j];
-    }
-    return rv;
-}
-
-QBitArray getBits(const QByteArray & ch){
-    QBitArray ary;
-    ary.resize(ch.length() * 8);
-    int k = 0;
-    for(int i = 0; i < ch.length(); ++i){
-        uchar th = ch.at(i);
-        uint t = 1;
-        for(int j = 0; j < 8; ++j, t = (t << 1)){
-            bool b = t & th;
-            ary.setBit(k,b);
-            ++k;
-        }
-    }
-    return ary;
-}
-
-QByteArray toBytes(const QBitArray & bits)
-{
-    uchar ch = 0x00;
-    QByteArray ary;
-    int index = 0;
-    for(int i = 0; i < bits.count(); ++i)
-    {
-        bool th = bits[i];
-        if(th){
-            ch = static_cast<uchar>(ch | (0x01 << index));
-        }
-        ++ index;
-        if(index == 7){
-            ary.append(ch);
-            ch = 0x00;
-        }
-    }
-    if(index > 0)
-        ary.append(ch);
-    return ary;
-}
-
-
-void getRTUBytes(float v, char * ary)
-{
-    TMPUN t;
-    t.f = v;
-    qToBigEndian(t.v, reinterpret_cast<uchar *>(ary));
-}
-
-void getRTUBytes(int v, char * ary)
-{
-    qToBigEndian(v, reinterpret_cast<uchar *>(ary));
-}
-
-void getRTUBytes(short v, char * ary)
-{
-    qToBigEndian(v, reinterpret_cast<uchar *>(ary));
-}
-
-float toFloatRTUValue(const char * ary)
-{
-    TMPUN t;
-    t.v = qFromBigEndian<uint>(reinterpret_cast<const uchar *>(ary));
-
-    return t.f;
-}
-
-int toIntRTUValue(const char * ary)
-{
-    return qFromBigEndian<int>(reinterpret_cast<const uchar *>(ary));
-}
-
-short toShortRTUValue(const char * ary)
-{
-    return qFromBigEndian<short>(reinterpret_cast<const uchar *>(ary));
-}
-
-}

+ 0 - 41
handle/utils/utilsfunc.h

@@ -1,41 +0,0 @@
-#ifndef UTILS_FUNC_H
-#define UTILS_FUNC_H
-
-#include <QByteArray>
-#include <QBitArray>
-
-#ifdef _MSC_VER
-#pragma execution_character_set("utf-8")
-#endif
-
-/***
- * 通讯处理的公共函数
-*/
-
-namespace UtilsFun {
-    /// 代码和校验
-    uchar daiMaHe(const QByteArray & ch,  int len );
-    /// CRC 校验
-    ushort CRC(const QByteArray & ch,int len);
-    /// LRC 校验
-    uchar LRC(const QByteArray & ch,int len);
-    /// BCC 异或校验和
-    uchar XOR(const QByteArray & ch,int len);
-    void getRTUBytes(float v, char * ary);
-    void getRTUBytes(int v, char * ary);
-    void getRTUBytes(short v, char * ary);
-
-    float toFloatRTUValue(const char * ary);
-    int toIntRTUValue(const char * ary);
-    short toShortRTUValue(const char * ary);
-
-    /// 反转 QByteArray
-    QByteArray reverse(const QByteArray & ch);
-    /// 获取 QByteArray 的每一位的值
-    QBitArray getBits(const QByteArray & ch);
-    /// 把 QBitArray 转换为字节数组
-    QByteArray toBytes(const QBitArray & bits);
-}
-
-
-#endif // DATAPACK_H

+ 7 - 9
main.cpp

@@ -1,18 +1,16 @@
 #include "mainwindow.h"
 
 #include <QApplication>
-#include <QLog/qlog.h>
-
+#include <pqQtlib/log/pqlog.h>
 int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);
-    QLOG::QLogManger::this_()->setSaveFilePath("D:/logs/");
-    auto qtlog = QLOG::QLogManger::this_()->qDebugLog();
-    qtlog->setOutState(QLOG::File);
-    auto log = QLOG::QLogManger::this_()->baseLog();
-    log->setOutState(QLOG::File);
-        MainWindow w;
-        w.showMaximized();
+    auto log = PQ::PQLogManger::this_()->qDebugLog();
+    log->setOutState(PQ::File);
+    log = PQ::PQLogManger::this_()->baseLog();
+    log->setOutState(PQ::File);
+    MainWindow w;
+    w.showMaximized();
     return a.exec();
 }
 

+ 0 - 91
packinfo.cpp

@@ -1,91 +0,0 @@
-#include "packinfo.h"
-#include "globalinfo.h"
-#include <QDateTime>
-
-int PackInfo::lastMin = 0;
-int PackInfo::lastNum = 1;
-
-PackInfo::PackInfo(const ProjectInfo & info) : _info(info)
-{
-    code_single = buildPackId();
-    goods_id = info.goods_id;
-}
-
-
-BoxInfo::BoxInfo(QSharedPointer<PackInfo> pack,QString code):case_number(code),parent(pack)
-{}
-
-
-QString PackInfo::buildPackId()
-{
-    QDateTime now = QDateTime::currentDateTime();
-    int min = now.time().minute();
-    if(min != lastMin) lastNum = 1;
-    else lastNum ++;
-    QString packId = GlobalInfo::this_()->packNum() + now.toString("yyMMddhhmmss") + QString::asprintf("%03d",lastNum);
-    if(lastNum > 999) return QString();
-    return packId;
-}
-
-QString PackInfo::buildBoxId()
-{
-     int nowNum = boxes().size() + 1;
-     QDateTime now = QDateTime::currentDateTime();
-     QString id = now.toString("yyMMddhhmmss") + /*GlobalInfo::this_()->packNum() +*/ QString::asprintf("%03d",nowNum);
-     return id;
-}
-
-int PackInfo::tube_number()
-{
-    int ret = 0;
-    for(int i = 0; i < _boxes.size();++i){
-        ret += _boxes.at(i)->tube_number;
-    }
-    return ret;
-}
-
-int PackInfo::gross_weight()
-{
-    int ret = 0;
-    for(int i = 0; i < _boxes.size();++i){
-        ret += _boxes.at(i)->gross_weight;
-    }
-    return ret;
-}
-
-int PackInfo::net_weight()
-{
-    int ret = 0;
-    for(int i = 0; i < _boxes.size();++i){
-        ret += _boxes.at(i)->net_weight;
-    }
-    return ret;
-}
-
-QSharedPointer<BoxInfo> PackInfo::addBoxInfo()
-{
-    QSharedPointer<BoxInfo> ret(new BoxInfo(sharedFromThis(),buildBoxId()));
-    return ret;
-}
-
-void PackInfo::addBoxInfoList(QSharedPointer<BoxInfo> boxes)
-{
-    _boxes.append(boxes);
-}
-
-void PackInfo::delBoxInfoAt(int num)
-{
-    qDebug()<<"size"<<_boxes.size();
-    qDebug()<<"num"<<num;
-    _boxes.removeAt(num);
-}
-
-QSharedPointer<BoxInfo> PackInfo::boxInfoAt(int num)
-{
-    return _boxes.at(num);
-}
-
-int PackInfo::boxInfoSize()
-{
-    return _boxes.size();
-}

+ 1 - 0
pqQtlib

@@ -0,0 +1 @@
+Subproject commit 8cd7c8b837f42a918bbe7cde3c9310a8ffedf53f

+ 172 - 0
struct_/packinfo.cpp

@@ -0,0 +1,172 @@
+#include "packinfo.h"
+#include "globalinfo.h"
+#include <QDateTime>
+
+int PackInfo::lastMin = 0;
+int PackInfo::lastNum = 1;
+
+QString getDecimalbit(double v, int i)
+{
+    QString tmp;
+    switch(i)
+    {
+    case 0 :
+       tmp.sprintf("%.0lf",v);
+        break;
+    case 1:
+        tmp.sprintf("%.1lf",v);
+         break;
+    case 2:
+        tmp.sprintf("%.2lf",v);
+         break;
+    case 3:
+        tmp.sprintf("%.3lf",v);
+         break;
+    case 4:
+        tmp.sprintf("%.4lf",v);
+         break;
+    case 5:
+        tmp.sprintf("%.5lf",v);
+         break;
+    case 6:
+        tmp.sprintf("%.6lf",v);
+         break;
+    case 7:
+        tmp.sprintf("%.7lf",v);
+         break;
+    case 8:
+        tmp.sprintf("%.8lf",v);
+         break;
+    default:
+        tmp.sprintf("%.9lf",v);
+         break;
+    }
+    return tmp;
+}
+
+PackInfo::PackInfo(const QSharedPointer<ProjectInfo> & info) : _info(info)
+{
+    code_single = buildPackId();
+    if(!info.isNull())
+        goods_id = info->goods_id;
+    _time = QDateTime::currentSecsSinceEpoch();
+}
+
+
+BoxInfo::BoxInfo(QSharedPointer<PackInfo> pack,QString code):case_number(code),parent(pack)
+{}
+
+
+QJsonObject BoxInfo::toObject()
+{
+    QJsonObject ret;
+    //todo: 小宋
+    return ret;
+}
+
+QSharedPointer<BoxInfo> BoxInfo::fromObject(QSharedPointer<PackInfo> & pack,QJsonObject & obj)
+{
+    QString case_number = obj.value("case_number").toString();
+    if(case_number.isEmpty()) return QSharedPointer<BoxInfo>();
+    QSharedPointer<BoxInfo> ret(new BoxInfo(pack,""));
+    ret->case_number = case_number;
+    // TODO 小宋
+    return ret;
+}
+
+QJsonObject PackInfo::toObject()
+{
+    QJsonObject ret;
+    ret.insert("time",QString::number(this->time()));
+    //todo: 小宋
+    return ret;
+}
+
+QSharedPointer<PackInfo> PackInfo::fromObject(QJsonObject &obj)
+{
+    QSharedPointer<PackInfo> ret;
+    QString code_single = obj.value("code_single").toString();
+    QString batch_no = obj.value("batch_no").toString();
+    auto project = GlobalInfo::this_()->project(batch_no);
+    if(code_single.isEmpty()) return ret;
+    ret.reset(new PackInfo(project));
+    ret->code_single = code_single;
+    ret->_time = obj.value("time").toString().toLongLong();
+
+    //todo: 小宋
+    return ret;
+}
+
+QString PackInfo::buildPackId()
+{
+    QDateTime now = QDateTime::currentDateTime();
+    int min = now.time().minute();
+    if(min != lastMin) lastNum = 1;
+    else lastNum ++;
+    QString packId = GlobalInfo::this_()->packNum() + now.toString("yyMMddhhmmss") + QString::asprintf("%03d",lastNum);
+    if(lastNum > 999) return QString();
+    return packId;
+}
+
+QString PackInfo::buildBoxId()
+{
+     int nowNum = boxes().size() + 1;
+     QDateTime now = QDateTime::currentDateTime();
+     QString id = now.toString("yyMMddhhmmss") + /*GlobalInfo::this_()->packNum() +*/ QString::asprintf("%03d",nowNum);
+     return id;
+}
+
+int PackInfo::tube_number()
+{
+    int ret = 0;
+    for(int i = 0; i < _boxes.size();++i){
+        ret += _boxes.at(i)->tube_number;
+    }
+    return ret;
+}
+
+int PackInfo::gross_weight()
+{
+    int ret = 0;
+    for(int i = 0; i < _boxes.size();++i){
+        ret += _boxes.at(i)->gross_weight;
+    }
+    return ret;
+}
+
+int PackInfo::net_weight()
+{
+    int ret = 0;
+    for(int i = 0; i < _boxes.size();++i){
+        ret += _boxes.at(i)->net_weight;
+    }
+    return ret;
+}
+
+QSharedPointer<BoxInfo> PackInfo::addBoxInfo()
+{
+    QSharedPointer<BoxInfo> ret(new BoxInfo(sharedFromThis(),buildBoxId()));
+    return ret;
+}
+
+void PackInfo::addBoxInfoList(QSharedPointer<BoxInfo> boxes)
+{
+    _boxes.append(boxes);
+}
+
+void PackInfo::delBoxInfoAt(int num)
+{
+    qDebug()<<"size"<<_boxes.size();
+    qDebug()<<"num"<<num;
+    _boxes.removeAt(num);
+}
+
+QSharedPointer<BoxInfo> PackInfo::boxInfoAt(int num)
+{
+    return _boxes.at(num);
+}
+
+int PackInfo::boxInfoSize()
+{
+    return _boxes.size();
+}

+ 26 - 5
packinfo.h → struct_/packinfo.h

@@ -3,13 +3,14 @@
 
 #include <QString>
 #include <QSharedPointer>
-#include "configinfo.h"
+#include "projectinfo.h"
+
+QString getDecimalbit(double v,int i = 2);
 
 class PackInfo;
 
 struct BoxInfo
 {
-
     inline QSharedPointer<PackInfo> parentPack() {
         return parent.toStrongRef();
     }
@@ -26,6 +27,10 @@ struct BoxInfo
     QString bucket_color;//	string	管色
     QString sort;//	是	string	排序
     QString remark;//	否	string	备注
+
+    QJsonObject toObject();
+
+    static QSharedPointer<BoxInfo> fromObject(QSharedPointer<PackInfo> & pack, QJsonObject &obj);
 private:
     BoxInfo(QSharedPointer<PackInfo> pack,QString code);
     QString case_number;//	是	string	箱号
@@ -36,7 +41,7 @@ private:
 class PackInfo : public QEnableSharedFromThis<PackInfo>
 {
 public:
-    PackInfo(const ProjectInfo & info);
+    PackInfo(const QSharedPointer<ProjectInfo> & info);
 
     int quantity = 0;//	是	int	箱数
     int level_id = 0;//	是	int	等级ID
@@ -49,8 +54,11 @@ public:
 
     QString remark;//	否	string
 
+    QString telephone;// 公司
+    QString customer;// 抬头
+
     inline const QList<QSharedPointer<BoxInfo>> & boxes() const {return _boxes;} //array	成品详情
-    inline const ProjectInfo & info() const {return _info;}
+    inline const QSharedPointer<ProjectInfo> & info() const {return _info;}
     inline QString codeSingle() const {return code_single;} //string	码单
 
     int tube_number(); //int	筒数
@@ -58,19 +66,32 @@ public:
     int net_weight(); //单位:克
     int goodsID() {return goods_id;}
 
+    inline qint64 time() {return _time;}
+
     QSharedPointer<BoxInfo> addBoxInfo();
     void addBoxInfoList(QSharedPointer<BoxInfo> boxes);
     void delBoxInfoAt(int num);
     QSharedPointer<BoxInfo> boxInfoAt(int num);
     int boxInfoSize();
+
+    void upInfo(const QSharedPointer<ProjectInfo> & info){
+        _info = info;
+        if(!info.isNull())
+            goods_id = info->goods_id;
+    }
+
+    QJsonObject toObject();
+
+    static QSharedPointer<PackInfo> fromObject(QJsonObject &obj);
 private:
     QString buildPackId();
     QString buildBoxId();
 private:
     QList<QSharedPointer<BoxInfo>> _boxes;
-    ProjectInfo _info;
+    QSharedPointer<ProjectInfo> _info;
     QString code_single;
     int goods_id;
+    qint64 _time;
     static int lastMin;
     static int lastNum;
 };

+ 44 - 0
struct_/projectinfo.cpp

@@ -0,0 +1,44 @@
+#include "projectinfo.h"
+
+
+QJsonObject ProjectInfo::toObject()
+{
+    QJsonObject ret;
+    // TODO: 小宋
+    return ret;
+}
+
+QSharedPointer<ProjectInfo> ProjectInfo::fromObject(const QJsonObject & obj)
+{
+    QString name = obj.value("batch_no").toString();
+    if(name.isEmpty()) return QSharedPointer<ProjectInfo>();
+    QSharedPointer<ProjectInfo> info(new ProjectInfo());
+    info->dtex = obj.value("detx").toString();
+
+    info->goods_id = obj.value("goods_id").toInt();
+    info->batch_no = name;
+    info->category = obj.value("category").toString();
+    info->product_type_code = obj.value("product_type_code").toString();
+    info->spec_role = obj.value("spec_role").toString();
+    info->denier = obj.value("denier").toString();
+    info->fiber = obj.value("fiber").toString();
+    info->specs = obj.value("specs").toString();
+    info->color = obj.value("color").toString();
+    info->twist_type = obj.value("twist_type").toString();
+    info->bucket_color = obj.value("bucket_color").toString();
+    info->box_weight = obj.value("box_weight").toString();
+    info->bucket_weight = obj.value("bucket_weight").toString();
+    info->machine_no = obj.value("machine_no").toString();
+    info->carton_type = obj.value("carton_type").toString();
+    info->limit_number = obj.value("limit_number").toString();
+    info->bucket_number = obj.value("bucket_number").toString();
+    info->cake_float = obj.value("cake_float").toString();
+    info->box_float = obj.value("box_float").toString();
+    info->box_rule = obj.value("box_rule").toString();
+    info->customer = obj.value("customer").toString();
+    info->remark = obj.value("remark").toString();
+    info->is_disable  = obj.value("is_disable").toBool();
+    info->create_time = obj.value("create_time").toInt();
+    info->modified_time = obj.value("modified_time").toInt();
+    return info;
+}

+ 55 - 0
struct_/projectinfo.h

@@ -0,0 +1,55 @@
+#ifndef PROJECTINFO_H
+#define PROJECTINFO_H
+
+#include <QString>
+#include <QSharedPointer>
+#include <QJsonObject>
+
+struct UserInfo
+{
+    QString userName;
+    int userId;
+    int accountId;
+    QString name;
+    QString headPortrait;
+    bool isVip;
+    QString acessToken;
+
+};
+
+struct ProjectInfo
+{
+    int goods_id = -1;//	int	商品ID
+    QString batch_no;//	string	批号
+    QString category;//	string	类型
+    QString product_type_code;//	string	品种
+    QString spec_role;//	string	规格录入
+    QString denier;//	string	旦数(D)
+    QString dtex;//	string	分特(dt)
+    QString fiber;//	string	孔数(F)
+    QString specs;//	string	规格
+    QString color;//	string	颜色
+    QString twist_type;//	string	捻向
+    QString bucket_color;//	string	管色
+    QString box_weight;//	string	皮重
+    QString bucket_weight;//	string	筒重
+    QString machine_no;//	string	机台
+    QString carton_type;//	string	纸箱
+    QString limit_number;//	string	限制打包
+    QString bucket_number;//	string	筒数
+    QString cake_float;//	string	丝饼浮动
+    QString box_float;//	string	纸箱浮动
+    QString box_rule;//	string	箱号规则
+    QString customer;//	string	箱单抬头
+    QString remark;//	string	备注
+    bool is_disable;//	bool	是否禁用
+    qint64 create_time;//	int	创建时间
+    qint64 modified_time;//	int	更新时间
+
+    QJsonObject toObject();
+
+    static  QSharedPointer<ProjectInfo> fromObject(const QJsonObject & obj);
+//    QString telephone;//
+};
+
+#endif // PROJECTINFO_H

+ 7 - 8
widget/autopackform.cpp

@@ -3,8 +3,7 @@
 #include "globalinfo.h"
 #include <QMessageBox>
 #include <QTimer>
-#include "handle/utils/cachefile.h"
-
+#include <pqQtlib/utils/pqfileutils.h>
 AutoPackForm::AutoPackForm(QWidget *parent) :
     QWidget(parent),
     ui(new Ui::AutoPackForm)
@@ -19,8 +18,7 @@ AutoPackForm::AutoPackForm(QWidget *parent) :
     connect(&packConfig,&RemotePackConfig::configUpdate,this,&AutoPackForm::upconfig);
     connect(&packConfig,&RemotePackConfig::dengJIConfigUp,this,&AutoPackForm::upDengjiInfo);
 //    ui->widgetTotle->hide();
-    CacheFile f;
-    auto dt = f.readFile("autodingzhongInfo.cache");
+    auto dt = PQ::CacheFile::readFile("autodingzhongInfo.cache");
     auto list = QString::fromUtf8(dt).split("[,]");
     if(list.size() == 2){
         ui->taitou->setText(list.at(0));
@@ -80,8 +78,7 @@ void AutoPackForm::on_pushBack_clicked()
     emit back();
     QStringList list;
     list << ui->taitou->text() <<  ui->taiPhone->text();
-    CacheFile f;
-    f.writeFile("autodingzhongInfo.cache",list.join("[,]").toUtf8());
+    PQ::CacheFile::writeFile("autodingzhongInfo.cache",list.join("[,]").toUtf8());
 }
 
 void AutoPackForm::on_addPackList_clicked()
@@ -92,6 +89,8 @@ void AutoPackForm::on_addPackList_clicked()
         packinfo->level_id = ui->dengji->currentData().toInt();
         packinfo->machine_no = ui->jitai->currentText();
         packinfo->carton_type = ui->zhixiang->currentText();
+        packinfo->customer = ui->taitou->text();
+        packinfo->telephone = ui->taiPhone->text();
     }
 
 
@@ -108,8 +107,8 @@ void AutoPackForm::on_addPackList_clicked()
 
 void AutoPackForm::on_pushStart_clicked()
 {
-    _info.customer = ui->taitou->text();
-    _info.telephone = ui->taiPhone->text();
+//    _info.customer = ui->taitou->text();
+//    _info.telephone = ui->taiPhone->text();
     if(ui->pushStart->isChecked()){
         ui->pushStart->setChecked(true);
         ui->addBoxList->setDisabled(false);

+ 1 - 1
widget/autopackform.h

@@ -4,7 +4,7 @@
 #include <QWidget>
 #include "globalinfo.h"
 #include "handle/remotepackconfig.h"
-#include "packinfo.h"
+#include "struct_/packinfo.h"
 //#include "httprequestid.h"
 #include "handle/danjumuban.h"
 #include "handle/database.h"

+ 10 - 7
widget/fixedweightpackform.cpp

@@ -1,6 +1,8 @@
 #include "fixedweightpackform.h"
 #include "ui_fixedweightpackform.h"
-#include "handle/utils/cachefile.h"
+#include <pqQtlib/utils/pqfileutils.h>
+
+using namespace PQ;
 
 FixedWeightPackForm::FixedWeightPackForm(QWidget *parent) :
     QWidget(parent),
@@ -13,8 +15,7 @@ FixedWeightPackForm::FixedWeightPackForm(QWidget *parent) :
     connect(&packConfig,&RemotePackConfig::configUpdate,this,&FixedWeightPackForm::upconfig);
     connect(&packConfig,&RemotePackConfig::dengJIConfigUp,this,&FixedWeightPackForm::upDengjiInfo);
     connect(&specs,&SelectSpecs::change,this,&FixedWeightPackForm::changeSpecs);
-    CacheFile f;
-    auto dt = f.readFile("dingzhongInfo.cache");
+    auto dt = CacheFile::readFile("dingzhongInfo.cache");
     auto list = QString::fromUtf8(dt).split("[,]");
     if(list.size() == 2){
         ui->taitou->setText(list.at(0));
@@ -52,8 +53,8 @@ void FixedWeightPackForm::on_pushBack_clicked()
     emit back();
     QStringList list;
     list << ui->taitou->text() <<  ui->taiPhone->text();
-    CacheFile f;
-    f.writeFile("dingzhongInfo.cache",list.join("[,]").toUtf8());
+//    CacheFile f;
+    PQ::CacheFile::writeFile("dingzhongInfo.cache",list.join("[,]").toUtf8());
 
 }
 
@@ -66,6 +67,8 @@ void FixedWeightPackForm::on_addPackList_clicked()
         packinfo->level_id = ui->dengji->currentData().toInt();
         packinfo->machine_no = ui->jitai->currentText();
         packinfo->carton_type = ui->zhixiang->currentText();
+        packinfo->customer = ui->taitou->text();
+        packinfo->telephone = ui->taiPhone->text();
     }
 
 
@@ -82,8 +85,8 @@ void FixedWeightPackForm::on_addPackList_clicked()
 
 void FixedWeightPackForm::on_pushStart_clicked()
 {
-    _info.customer = ui->taitou->text();
-    _info.telephone = ui->taiPhone->text();
+//    _info.customer = ui->taitou->text();
+//    _info.telephone = ui->taiPhone->text();
 
     if(ui->pushStart->isChecked()){
         ui->pushStart->setChecked(true);

+ 6 - 7
widget/loginform.cpp

@@ -2,9 +2,11 @@
 #include "ui_loginform.h"
 #include <QMessageBox>
 #include "globalinfo.h"
-#include "handle/utils/cachefile.h"
+#include <pqQtlib/utils/pqfileutils.h>
 #include <QJsonDocument>
 
+using namespace PQ;
+
 LoginForm::LoginForm(QWidget *parent) :
     QWidget(parent),
     ui(new Ui::LoginForm),_request(nullptr)
@@ -14,8 +16,7 @@ LoginForm::LoginForm(QWidget *parent) :
     ui->status->setVisible(false);
     this->setEnabled(true);
     ui->linePass->setEchoMode(QLineEdit::Password);
-    CacheFile f;
-    auto dt = f.readFile("userpass.cache");
+    auto dt = PQ::CacheFile::readFile("userpass.cache");
     auto list = QString::fromUtf8(dt).split("[,]");
     if(list.size() == 2){
         ui->lineUser->setText(list.at(0));
@@ -84,10 +85,8 @@ void LoginForm::result(int code, const QJsonObject & body)
 
     QStringList list;
     list << ui->lineUser->text() <<  ui->linePass->text();
-    CacheFile f;
-    f.writeFile("userpass.cache",list.join("[,]").toUtf8());
-    CacheFile cf;
-    cf.writeFile("userlogin.cache",QJsonDocument(body).toJson());
+    CacheFile::writeFile("userpass.cache",list.join("[,]").toUtf8());
+    CacheFile::writeFile("userlogin.cache",QJsonDocument(body).toJson());
     auto data  = body.value("data").toObject();
     if(data.isEmpty()){
         QMessageBox msg(QMessageBox::Information, "错误", "用户名或密码错误", QMessageBox::Ok, this);

+ 2 - 1
widget/packdetailform.cpp

@@ -1,6 +1,7 @@
 #include "packdetailform.h"
 #include "ui_packdetailform.h"
-#include "handle/utils/cachefile.h"
+#include "packinfo.h"
+#include <pqQtlib/utils/pqfileutils.h>
 
 PackDetailForm::PackDetailForm(QWidget *parent) :
     QWidget(parent),

+ 8 - 5
widget/uncertainweightpackform.cpp

@@ -1,8 +1,10 @@
 #include "uncertainweightpackform.h"
 #include "ui_uncertainweightpackform.h"
-#include "handle/utils/cachefile.h"
+#include <pqQtlib/utils/pqfileutils.h>
 
 
+using namespace PQ;
+
 UncertainWeightPackForm::UncertainWeightPackForm(QWidget *parent) :
     QWidget(parent),
     ui(new Ui::UncertainWeightPackForm)
@@ -18,8 +20,7 @@ UncertainWeightPackForm::UncertainWeightPackForm(QWidget *parent) :
     ui->widget_6->setEnabled(false);
     //筒数限制,true限制
     istubeNumTure = false;
-    CacheFile f;
-    auto dt = f.readFile("budingzhongInfo.cache");
+    auto dt = CacheFile::readFile("budingzhongInfo.cache");
     auto list = QString::fromUtf8(dt).split("[,]");
     if(list.size() == 2){
         ui->taitou->setText(list.at(0));
@@ -77,6 +78,8 @@ void UncertainWeightPackForm::on_addPackList_clicked()
         packinfo->level_id = ui->dengji->currentData().toInt();
         packinfo->machine_no = ui->jitai->currentText();
         packinfo->carton_type = ui->zhixiang->currentText();
+        packinfo->customer = ui->taitou->text();
+        packinfo->telephone = ui->taiPhone->text();
     }
 
 
@@ -92,8 +95,8 @@ void UncertainWeightPackForm::on_addPackList_clicked()
 
 void UncertainWeightPackForm::on_pushStart_clicked()
 {
-    _info.customer = ui->taitou->text();
-    _info.telephone = ui->taiPhone->text();
+//    _info.customer = ui->taitou->text();
+//    _info.telephone = ui->taiPhone->text();
     if(ui->pushStart->isChecked()){
         ui->pushStart->setChecked(true);
         ui->addBoxList->setDisabled(false);