dushibaiyu il y a 6 ans
Parent
commit
1b495bd426
53 fichiers modifiés avec 862 ajouts et 2120 suppressions
  1. 15 14
      JxcClient.pro
  2. 1 0
      configinfo.cpp
  3. 14 10
      configinfo.h
  4. 82 5
      globalinfo.cpp
  5. 46 17
      globalinfo.h
  6. 0 191
      handle/autopackutils.cpp
  7. 0 39
      handle/autopackutils.h
  8. 24 26
      handle/danjumuban.cpp
  9. 1 1
      handle/danjumuban.h
  10. 0 347
      handle/database.cpp
  11. 0 80
      handle/database.h
  12. 3 1
      handle/packinfomanger.cpp
  13. 1 2
      handle/packinfoseed2server.cpp
  14. 25 0
      handle/printer/baseboxprinter.cpp
  15. 38 0
      handle/printer/baseboxprinter.h
  16. 32 0
      handle/printer/boxtemlateone.cpp
  17. 36 0
      handle/printer/boxtemlateone.h
  18. 187 0
      handle/printer/code39.cpp
  19. 29 0
      handle/printer/code39.h
  20. 74 0
      handle/printer/printermanger.cpp
  21. 29 0
      handle/printer/printermanger.h
  22. 31 0
      handle/printerthreadhandle.cpp
  23. 28 0
      handle/printerthreadhandle.h
  24. 22 9
      handle/projectinfomanger.cpp
  25. 3 2
      handle/projectinfomanger.h
  26. 4 5
      handle/remotepackconfig.cpp
  27. 0 57
      handle/rtuport.cpp
  28. 0 68
      handle/selectspecs.cpp
  29. 0 31
      handle/selectspecs.h
  30. 31 0
      handle/serialthreadhandle.cpp
  31. 25 0
      handle/serialthreadhandle.h
  32. 1 3
      handle/seriport/assictscalet2000.cpp
  33. 1 3
      handle/seriport/logserialport.cpp
  34. 1 3
      handle/seriport/logserialport.h
  35. 47 0
      handle/seriport/rtuport.cpp
  36. 3 1
      handle/seriport/rtuport.h
  37. 0 38
      mainwindow.cpp
  38. 1 3
      mainwindow.h
  39. 1 1
      mainwindow.ui
  40. 1 1
      pqQtlib
  41. 3 2
      struct_/packinfo.cpp
  42. 6 0
      struct_/packinfo.h
  43. 0 1
      struct_/projectinfo.cpp
  44. 5 0
      struct_/projectinfo.h
  45. 0 250
      widget/autopackform.cpp
  46. 0 74
      widget/autopackform.h
  47. 0 807
      widget/autopackform.ui
  48. 1 6
      widget/fixedweightpackform.cpp
  49. 0 6
      widget/fixedweightpackform.h
  50. 1 1
      widget/loginform.cpp
  51. 6 6
      widget/packdetailform.cpp
  52. 2 7
      widget/packdetailform.h
  53. 1 2
      widget/selectvalueform.h

+ 15 - 14
JxcClient.pro

@@ -20,24 +20,25 @@ include($$PWD/pqQtlib/pqQtlib.pri)
 SOURCES += \
 SOURCES += \
     configinfo.cpp \
     configinfo.cpp \
     globalinfo.cpp \
     globalinfo.cpp \
-    handle/autopackutils.cpp \
-    handle/code39.cpp \
+    handle/printer/boxtemlateone.cpp \
+    handle/printer/code39.cpp \
     handle/danjumuban.cpp \
     handle/danjumuban.cpp \
-    handle/database.cpp \
     handle/httprequest.cpp \
     handle/httprequest.cpp \
-    handle//seriport/logserialport.cpp \
+    handle/printerthreadhandle.cpp \
+    handle/seriport/logserialport.cpp \
     handle/packinfomanger.cpp \
     handle/packinfomanger.cpp \
     handle/packinfoseed2server.cpp \
     handle/packinfoseed2server.cpp \
+    handle/printer/baseboxprinter.cpp \
+    handle/printer/printermanger.cpp \
     handle/projectinfomanger.cpp \
     handle/projectinfomanger.cpp \
     handle/remotepackconfig.cpp \
     handle/remotepackconfig.cpp \
-    handle/rtuport.cpp \
-    handle/selectspecs.cpp \
+    handle/seriport/rtuport.cpp \
     handle/seriport/assictscalet2000.cpp \
     handle/seriport/assictscalet2000.cpp \
     handle/seriport/serialbasehandle.cpp \
     handle/seriport/serialbasehandle.cpp \
+    handle/serialthreadhandle.cpp \
     struct_/packinfo.cpp \
     struct_/packinfo.cpp \
     struct_/projectinfo.cpp \
     struct_/projectinfo.cpp \
     widget/addnewspecsform.cpp \
     widget/addnewspecsform.cpp \
-    widget/autopackform.cpp \
     widget/fixedweightpackform.cpp \
     widget/fixedweightpackform.cpp \
     widget/loginform.cpp \
     widget/loginform.cpp \
     main.cpp \
     main.cpp \
@@ -50,24 +51,25 @@ SOURCES += \
 HEADERS += \
 HEADERS += \
     configinfo.h \
     configinfo.h \
     globalinfo.h \
     globalinfo.h \
-    handle/autopackutils.h \
-    handle/code39.h \
+    handle/printer/boxtemlateone.h \
+    handle/printer/code39.h \
     handle/danjumuban.h \
     handle/danjumuban.h \
-    handle/database.h \
     handle/httprequest.h \
     handle/httprequest.h \
     handle/packinfomanger.h \
     handle/packinfomanger.h \
     handle/packinfoseed2server.h \
     handle/packinfoseed2server.h \
+    handle/printer/baseboxprinter.h \
+    handle/printer/printermanger.h \
+    handle/printerthreadhandle.h \
     handle/projectinfomanger.h \
     handle/projectinfomanger.h \
-    handle/selectspecs.h \
     handle/seriport/logserialport.h \
     handle/seriport/logserialport.h \
     handle/remotepackconfig.h \
     handle/remotepackconfig.h \
-    handle/rtuport.h \
+    handle/seriport/rtuport.h \
     handle/seriport/assictscalet2000.h \
     handle/seriport/assictscalet2000.h \
     handle/seriport/serialbasehandle.h \
     handle/seriport/serialbasehandle.h \
+    handle/serialthreadhandle.h \
     struct_/packinfo.h \
     struct_/packinfo.h \
     struct_/projectinfo.h \
     struct_/projectinfo.h \
     widget/addnewspecsform.h \
     widget/addnewspecsform.h \
-    widget/autopackform.h \
     widget/fixedweightpackform.h \
     widget/fixedweightpackform.h \
     widget/loginform.h \
     widget/loginform.h \
     mainwindow.h \
     mainwindow.h \
@@ -78,7 +80,6 @@ HEADERS += \
 
 
 FORMS += \
 FORMS += \
     widget/addnewspecsform.ui \
     widget/addnewspecsform.ui \
-    widget/autopackform.ui \
     widget/fixedweightpackform.ui \
     widget/fixedweightpackform.ui \
     widget/loginform.ui \
     widget/loginform.ui \
     mainwindow.ui \
     mainwindow.ui \

+ 1 - 0
configinfo.cpp

@@ -38,6 +38,7 @@ void ConfigInfo::save()
     obj.insert("portType",0);
     obj.insert("portType",0);
     obj.insert("savePrinter",true);
     obj.insert("savePrinter",true);
     PQ::ConfigFile::writeObject("Config.json",obj);
     PQ::ConfigFile::writeObject("Config.json",obj);
+    emit configUpdate();
 }
 }
 
 
 
 

+ 14 - 10
configinfo.h

@@ -1,20 +1,18 @@
 #ifndef CONFIGINFO_H
 #ifndef CONFIGINFO_H
 #define CONFIGINFO_H
 #define CONFIGINFO_H
 
 
+#include <QObject>
 #include <QString>
 #include <QString>
-#include "QSettings"
-#include "QCoreApplication"
-#include "QDir"
-#include "QDebug"
-#include "QMessageBox"
-#include "QJsonObject"
+#include <QJsonObject>
 #include "pqQtlib/utils/pqfileutils.h"
 #include "pqQtlib/utils/pqfileutils.h"
-#include "QJsonDocument"
+#include <QJsonDocument>
 
 
-class ConfigInfo
+class GlobalInfo;
+
+class ConfigInfo : public QObject
 {
 {
+    Q_OBJECT
 public:
 public:
-    ConfigInfo();
     QString baseUrl;//服务器接口地址
     QString baseUrl;//服务器接口地址
     quint16 packId;
     quint16 packId;
     QString printerName; //打印机名称
     QString printerName; //打印机名称
@@ -22,12 +20,18 @@ public:
     QString portBaudRate; //电子秤串口波特率
     QString portBaudRate; //电子秤串口波特率
     int portType;
     int portType;
 
 
-    bool savePrinter;
+   bool savePrinter;
 
 
 
 
   void load();
   void load();
   void save();
   void save();
 
 
+signals:
+  void configUpdate();
+
+private:
+      ConfigInfo();
+    friend class GlobalInfo;
 };
 };
 
 
 
 

+ 82 - 5
globalinfo.cpp

@@ -2,7 +2,11 @@
 
 
 GlobalInfo::GlobalInfo(QObject *parent) : QObject(parent)
 GlobalInfo::GlobalInfo(QObject *parent) : QObject(parent)
 {
 {
-    isNoLine = false;
+    _isNoLine = false;
+    _config.load();
+    packmanger = nullptr;
+    _printer = nullptr;
+    _serial = nullptr;
 }
 }
 
 
 
 
@@ -23,12 +27,85 @@ QString GlobalInfo::packNum()
     return pack_num;
     return pack_num;
 }
 }
 
 
-scaledata GlobalInfo::GetScaleData()
+bool GlobalInfo::addCacheInfo(QSharedPointer<ProjectInfo> & info)
 {
 {
-    return scale;
+    auto v = project(info->batch_no);
+    if(!v.isNull()) return false;
+    _cacheInfo.append(info);
+    _project.insert(info->batch_no,info);
+    packmanger->syncLocalProjectInfo(_cacheInfo);
 }
 }
 
 
-void GlobalInfo::SetScaleData(scaledata data)
+
+
+void GlobalInfo::start(UserInfo & user,bool online)
+{
+    _users = user;
+    _isNoLine = online;
+    initInfo();
+    _remoteConfig->refConfig();
+    if(online){
+        _projectmanger->syncLocalList();
+    } else {
+        _projectmanger->loadServerList(false);
+    }
+}
+
+void GlobalInfo::initInfo()
+{
+    if(packmanger != nullptr) return;
+    packmanger = new PackInfoManger(this);
+    _printer = new PrinterThreadHandle();
+    _printer->start();
+    _serial = new SerialThreadHandle();
+    _serial->start();
+    _remoteConfig = new RemotePackConfig(this);
+    connect(_remoteConfig,&RemotePackConfig::configUpdate,this,&GlobalInfo::configUpdate);
+    connect(_remoteConfig,&RemotePackConfig::dengJIConfigUp,this,&GlobalInfo::dengJIConfigUp);
+    _projectmanger = new ProjectInfoManger(packmanger,this);
+    connect(_projectmanger,&ProjectInfoManger::inited,this,&GlobalInfo::syncProject);
+    connect(_projectmanger,&ProjectInfoManger::synced,this,&GlobalInfo::syncProject);
+}
+
+void GlobalInfo::printerBox(QSharedPointer<BoxInfo> info)
+{
+    if(_printer){
+        emit _printer->printerBox(info);
+    }
+}
+
+void GlobalInfo::printerPack(QSharedPointer<PackInfo> info)
+{
+    if(_printer){
+        emit _printer->printerPack(info);
+    }
+}
+
+
+void GlobalInfo::syncProject(ProjectInfoManger * manger, bool )
+{
+    _cacheInfo = manger->cacheInfo();
+    _serverInfo = manger->serverInfo();
+    _project.clear();
+    for(int i = 0; i < _cacheInfo.size(); ++i){
+        auto info = _cacheInfo.at(i);
+        _project.insert(info->batch_no,info);
+    }
+
+    for(int i = 0; i < _serverInfo.size(); ++i){
+        auto info = _serverInfo.at(i);
+        _project.insert(info->batch_no,info);
+    }
+    emit doInited();
+}
+
+void GlobalInfo::configUpdate(const DaBaoConfig & config)
+{
+    _dbConfig = config;
+    emit dbConfigUpdated();
+}
+void GlobalInfo::dengJIConfigUp(const QList<DengJiConfigItem> & dengJis)
 {
 {
-    scale = data;
+    _dengJiList = dengJis;
+    emit dengJiUped();
 }
 }

+ 46 - 17
globalinfo.h

@@ -6,13 +6,11 @@
 #include "struct_/projectinfo.h"
 #include "struct_/projectinfo.h"
 #include <QMap>
 #include <QMap>
 #include "handle/projectinfomanger.h"
 #include "handle/projectinfomanger.h"
-
-struct scaledata{
-    double gross_widget = 0.00; //毛重
-    double tare_widget = 0.00;//皮重
-    double net_widget = 0.00;//净重
-    int tongshu = 0;//筒数
-};
+#include "handle/packinfomanger.h"
+#include "handle/printerthreadhandle.h"
+#include "handle/serialthreadhandle.h"
+#include "handle/remotepackconfig.h"
+#include "handle/projectinfomanger.h"
 
 
 class GlobalInfo : public QObject
 class GlobalInfo : public QObject
 {
 {
@@ -20,39 +18,70 @@ class GlobalInfo : public QObject
 private:
 private:
     explicit GlobalInfo(QObject *parent = nullptr);
     explicit GlobalInfo(QObject *parent = nullptr);
 
 
-    ConfigInfo _config;
-    UserInfo _users;
+
 public:
 public:
     static GlobalInfo * this_();
     static GlobalInfo * this_();
 
 
-    inline const ConfigInfo & config() const {return _config;}
-
-    inline void setUser(const UserInfo & users){_users = users;}
+    // 所有配置都从这儿加载和写入,不允许在新建ConfigInfo
+    inline ConfigInfo * config() {return &_config;}
     inline const UserInfo & user() const {return _users;}
     inline const UserInfo & user() const {return _users;}
 
 
     inline QMap<QString,QSharedPointer<ProjectInfo>> project() {return _project;}
     inline QMap<QString,QSharedPointer<ProjectInfo>> project() {return _project;}
     inline QList<QSharedPointer<ProjectInfo>> serverInfo() {return _serverInfo;}
     inline QList<QSharedPointer<ProjectInfo>> serverInfo() {return _serverInfo;}
     inline QList<QSharedPointer<ProjectInfo>> cacheInfo() {return _cacheInfo;}
     inline QList<QSharedPointer<ProjectInfo>> cacheInfo() {return _cacheInfo;}
 
 
+    bool addCacheInfo(QSharedPointer<ProjectInfo> & info);
+    inline PackInfoManger * packInfoManger() {return packmanger;}
+
     QString packNum();
     QString packNum();
 
 
-    scaledata GetScaleData();
-    void SetScaleData(scaledata data);
+    double currentWidght;
+
+    inline bool isNoLine() {return _isNoLine;}
 
 
-    bool isNoLine;
+    inline PackInfoManger * packLocalManger(){return packmanger;}
 
 
     inline QSharedPointer<ProjectInfo> project(const QString & name){return _project.value(name);}
     inline QSharedPointer<ProjectInfo> project(const QString & name){return _project.value(name);}
-signals:
 
 
+    //打包配置
+    inline const DaBaoConfig & dbConfig() const {return _dbConfig;}
+    // 等级配置
+    inline const QList<DengJiConfigItem> & dengJiList() {return _dengJiList;}
+
+    void printerBox(QSharedPointer<BoxInfo> info);
+    void printerPack(QSharedPointer<PackInfo> info);
+signals:
+    void dbConfigUpdated();
+    void dengJiUped();
+    void doInited();
 public slots:
 public slots:
+    void start(UserInfo & user,bool online);
+
+private slots:
+    void syncProject(ProjectInfoManger * manger, bool inited);
+    void configUpdate(const DaBaoConfig & config);
+    void dengJIConfigUp(const QList<DengJiConfigItem> & dengJis);
 private:
 private:
     QMap<QString,QSharedPointer<ProjectInfo>> _project;
     QMap<QString,QSharedPointer<ProjectInfo>> _project;
     QList<QSharedPointer<ProjectInfo>> _serverInfo;
     QList<QSharedPointer<ProjectInfo>> _serverInfo;
     QList<QSharedPointer<ProjectInfo>> _cacheInfo;
     QList<QSharedPointer<ProjectInfo>> _cacheInfo;
     friend class ProjectInfoManger;
     friend class ProjectInfoManger;
+
+    DaBaoConfig _dbConfig;
+    QList<DengJiConfigItem> _dengJiList;
+
+    void initInfo();
 private:
 private:
+    ConfigInfo _config;
     QString pack_num;
     QString pack_num;
-    scaledata scale;
+    UserInfo _users;
+    bool _isNoLine;
+private:
+    PackInfoManger * packmanger;
+    PrinterThreadHandle * _printer;
+    SerialThreadHandle * _serial;
+    RemotePackConfig * _remoteConfig;
+    ProjectInfoManger * _projectmanger;
 };
 };
 
 
 
 

+ 0 - 191
handle/autopackutils.cpp

@@ -1,191 +0,0 @@
-#include "autopackutils.h"
-
-/**
- * @brief AutoPackForm工具类
- */
-AutoPackUtils::AutoPackUtils()
-{
-    connect(&_request,&HttpRequest::result,this,&AutoPackUtils::httpResult);
-}
-
-/**
- * @brief 把打包数据存入本地数据库后,上传服务器打包数据
- * @param info
- */
-void AutoPackUtils::doSend(QJsonObject json)
-{
-    if(GlobalInfo::this_()->isNoLine){
-        return;
-    }
-    if(json.isEmpty()) return;
-    //保存码单,上传服务器成功后,以codeSingle为条件更改同步字段;
-    this->codeSingle = json["code_single"].toString();
-
-    _request.setUserToken(QString::number(GlobalInfo::this_()->user().accountId),GlobalInfo::this_()->user().acessToken);
-//    qDebug()<<QString::number(GlobalInfo::this_()->user().accountId);
-//    qDebug()<<GlobalInfo::this_()->user().acessToken;
-    _request.post(GlobalInfo::this_()->config().baseUrl+"/v1/product/pending",json);
-
-}
-
-void AutoPackUtils::httpResult(int emitcode, const QJsonObject body)
-{
-    qDebug()<<emitcode;
-    qDebug()<<body;
-    if(emitcode==200&&body["message"].toString() == ""){
-        if(database.changeState(codeSingle)){
-                qDebug()<<"同步成功";
-                return;
-        }
-        qDebug()<<"同步失败";
-    }
-}
-
-
-//把BoxInfo数据添加到deetails数据库里;
-void AutoPackUtils::insertDetailsSQL(QSharedPointer<BoxInfo> boxes,QString codeSingle)
-{
-//    qDebug()<<boxes->caseNumber();
-    djmb.printBoxInfo(boxes->caseNumber(),boxes);
-    detailsData.code_single = codeSingle;
-    detailsData.case_number = boxes->caseNumber();
-    detailsData.box_weight = boxes->box_weight;
-    detailsData.tube_number = boxes->tube_number;
-    detailsData.bucket_weight = boxes->bucket_weight;
-    detailsData.gross_weight = boxes->gross_weight;
-    detailsData.net_weight = boxes->net_weight;
-    detailsData.sort = boxes->sort;
-    detailsData.remark = boxes->remark;
-
-    if(database.insertDetails(detailsData)){
-        qDebug()<<"details数据库添加成功";
-        return;
-    }
-    qDebug()<<"details数据库添加失败";
-}
-
-//把PackInfo添加到product数据库里;
-void AutoPackUtils::insertProductSQL(QSharedPointer<PackInfo> packes)
-{
-    if(packes.isNull()) return;
-    if(packes->boxes().isEmpty()) return;
-    djmb.printPackInfo(packes->codeSingle(),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.level_id = packes->level_id;
-    productData.tube_number = packes->tube_number();
-    productData.gross_weight = packes->gross_weight();
-    productData.net_weight = packes->net_weight();
-    productData.machine_no = packes->machine_no;
-    productData.packing_time = packes->packing_time;
-    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.remark = packes->remark;
-
-    if(database.insertProduct(productData)){
-        qDebug()<<"product数据库添加成功";
-        return;
-    }
-    qDebug()<<"product数据库添加失败";
-}
-
-
-
-//将打包数据转换为json数据
-QJsonObject AutoPackUtils::toJson(QSharedPointer<PackInfo> &info)
-{
-
-    QJsonObject json;
-    json.empty();
-
-    if(info.isNull()) return json;
-    if(info->boxes().isEmpty()) return json;
-
-    QJsonObject detailsjson;
-    QJsonArray jsonarray;
-    for(int i = 0;i<info->boxes().size();i++){
-        detailsjson.insert("case_number",info->boxes().at(i)->caseNumber());
-        detailsjson.insert("box_weight",info->boxes().at(i)->box_weight);
-        detailsjson.insert("tube_number",info->boxes().at(i)->tube_number);
-        detailsjson.insert("bucket_weight",info->boxes().at(i)->bucket_weight);
-        detailsjson.insert("gross_weight",info->boxes().at(i)->gross_weight);
-        detailsjson.insert("net_weight",info->boxes().at(i)->net_weight);
-        detailsjson.insert("box_weight",info->boxes().at(i)->box_weight);
-        detailsjson.insert("sort",info->boxes().at(i)->sort);
-        detailsjson.insert("remark",info->boxes().at(i)->remark);
-        jsonarray.append(detailsjson);
-    }
-    json.insert("goods_id",info->goodsID());
-    json.insert("code_single",info->codeSingle());
-    json.insert("quantity",info->quantity);
-    json.insert("level_id",info->level_id);
-    json.insert("tube_number",info->tube_number());
-    json.insert("gross_weight",info->gross_weight());
-    json.insert("net_weight",info->net_weight());
-    json.insert("machine_no",info->machine_no);
-    json.insert("packing_time",info->packing_time);
-    json.insert("packing_type",info->packing_type);
-    json.insert("carton_type",info->carton_type);
-    json.insert("operator",info->operator_id);
-    json.insert("details",jsonarray);
-    json.insert("remark",info->remark);
-
-
-    return json;
-}
-
-QJsonObject AutoPackUtils::toJsonMap(QMap<QString,QString> product,QList<QMap<QString,QString>> details)
-{
-//    qDebug()<<"自动打包测试";
-//    qDebug()<<details.at(0).value("code_single");
-    QJsonObject json;
-    QJsonObject detailsjson;
-    QJsonArray jsonarray;
-
-    if(product.isEmpty()){
-        qDebug()<<"product数据为空";
-        return json;
-    }
-
-    if(details.isEmpty()){
-        qDebug()<<"details数据为空";
-        return json;
-    }
-
-    for(int i = 0;i<details.length();i++){
-        detailsjson.insert("case_number",details.at(i).value("case_number"));
-        detailsjson.insert("box_weight",details.at(i).value("box_weight"));
-        detailsjson.insert("tube_number",details.at(i).value("tube_number"));
-        detailsjson.insert("bucket_weight",details.at(i).value("bucket_weight"));
-        detailsjson.insert("gross_weight",details.at(i).value("gross_weight"));
-        detailsjson.insert("net_weight",details.at(i).value("net_weight"));
-        detailsjson.insert("box_weight",details.at(i).value("box_weight"));
-        detailsjson.insert("sort",details.at(i).value("sort"));
-        detailsjson.insert("remark",details.at(i).value("remark"));
-        jsonarray.append(detailsjson);
-    }
-    json.insert("goods_id",product.value("goods_id"));
-    json.insert("code_single",product.value("code_single"));
-    json.insert("quantity",product.value("quantity"));
-    json.insert("level_id",product.value("level_id"));
-    json.insert("tube_number",product.value("tube_number"));
-    json.insert("gross_weight",product.value("gross_weight"));
-    json.insert("net_weight",product.value("net_weight"));
-    json.insert("machine_no",product.value("machine_no"));
-    json.insert("packing_time",product.value("packing_time"));
-    json.insert("packing_type",product.value("packing_type"));
-    json.insert("carton_type",product.value("carton_type"));
-    json.insert("operator",product.value("operator_id"));
-    json.insert("details",jsonarray);
-    json.insert("remark",product.value("remark"));
-
-    return json;
-}

+ 0 - 39
handle/autopackutils.h

@@ -1,39 +0,0 @@
-#ifndef AUTOPACKUTILS_H
-#define AUTOPACKUTILS_H
-
-#include "QObject"
-#include "qabstractanimation.h"
-#include "httprequest.h"
-#include "database.h"
-#include "struct_/packinfo.h"
-#include "globalinfo.h"
-#include "danjumuban.h"
-
-//打包公用工具类
-class AutoPackUtils : public QObject
-{
-
-    Q_OBJECT
-
-public:
-    AutoPackUtils();
-public slots:
-
-    void doSend(QJsonObject json);
-    void httpResult(int emitcode, const QJsonObject body);
-
-    void insertDetailsSQL(QSharedPointer<BoxInfo> boxes,QString codeSingle);
-    void insertProductSQL(QSharedPointer<PackInfo> packes);
-
-    QJsonObject toJson(QSharedPointer<PackInfo> &info);
-    QJsonObject toJsonMap(QMap<QString,QString> product,QList<QMap<QString,QString>> details);
-private:
-    HttpRequest _request;
-    DanJuMuBan djmb;
-    Database database;
-    details_data detailsData;
-    product_data productData;
-    QString codeSingle;
-};
-
-#endif // AUTOPACKUTILS_H

+ 24 - 26
handle/danjumuban.cpp

@@ -16,8 +16,6 @@ DanJuMuBan::DanJuMuBan()
     if(!dir.exists("rukudan"))
     if(!dir.exists("rukudan"))
         dir.mkdir("rukudan");
         dir.mkdir("rukudan");
     log = PQ::PQLogManger::this_()->getLog("printer");
     log = PQ::PQLogManger::this_()->getLog("printer");
-    ConfigInfo info;
-    info.Start();
     save = true;
     save = true;
 }
 }
 
 
@@ -59,8 +57,8 @@ QImage DanJuMuBan::printBoxInfo(QString bar,QSharedPointer<BoxInfo> info)
     font.setPixelSize(40);
     font.setPixelSize(40);
     font.setWeight(QFont::ExtraLight);
     font.setWeight(QFont::ExtraLight);
     painter.setFont(font);
     painter.setFont(font);
-    painter.drawText(6*5,15*5,pinfo->info().customer);
-    qDebug()<< "公司名称:" <<pinfo->info().customer;
+    painter.drawText(6*5,15*5,pinfo->info()->customer);
+    qDebug()<< "公司名称:" <<pinfo->info()->customer;
 
 
     font.setPixelSize(20);
     font.setPixelSize(20);
     font.setBold(true);
     font.setBold(true);
@@ -76,9 +74,9 @@ QImage DanJuMuBan::printBoxInfo(QString bar,QSharedPointer<BoxInfo> info)
     painter.drawText(8*5,53*5,QStringLiteral("箱号"));
     painter.drawText(8*5,53*5,QStringLiteral("箱号"));
     painter.drawText(50*5,53*5,QStringLiteral("纸管颜色"));
     painter.drawText(50*5,53*5,QStringLiteral("纸管颜色"));
 
 
-    painter.drawText(21*5,25*5,pinfo->info().product_type_code);
-    painter.drawText(21*5,32*5,pinfo->info().batch_no);
-    painter.drawText(21*5,39*5,pinfo->info().specs);
+    painter.drawText(21*5,25*5,pinfo->info()->product_type_code);
+    painter.drawText(21*5,32*5,pinfo->info()->batch_no);
+    painter.drawText(21*5,39*5,pinfo->info()->specs);
     painter.drawText(67*5,25*5,QString("%1 kg").arg(getDecimalbit( info->gross_weight / 1000.00)));//datalist.at(0));
     painter.drawText(67*5,25*5,QString("%1 kg").arg(getDecimalbit( info->gross_weight / 1000.00)));//datalist.at(0));
 
 
     painter.drawText(67*5,32*5,QString("%1 kg").arg(getDecimalbit(info->net_weight / 1000.00)));//datalist.at(1));
     painter.drawText(67*5,32*5,QString("%1 kg").arg(getDecimalbit(info->net_weight / 1000.00)));//datalist.at(1));
@@ -93,7 +91,7 @@ QImage DanJuMuBan::printBoxInfo(QString bar,QSharedPointer<BoxInfo> info)
     painter.drawText(21*5,53*5,info->caseNumber());//datalist.at(5));
     painter.drawText(21*5,53*5,info->caseNumber());//datalist.at(5));
 
 
 
 
-    painter.drawText(4*5,75*5," 电话:"+ pinfo->info().telephone);
+    painter.drawText(4*5,75*5," 电话:"+ info->parentPack()->telephone);
 
 
     print(image);
     print(image);
 
 
@@ -166,9 +164,9 @@ QImage DanJuMuBan::printPackInfo(QString bar, QSharedPointer<PackInfo> info)
     font.setFamily("黑体");
     font.setFamily("黑体");
 
 
     painter.setFont(font);
     painter.setFont(font);
-    painter.drawText(19*5,15*5,info->info().specs);//QStringLiteral("规格"));
-    painter.drawText(70*5,15*5,info->info().category);//QStringLiteral("类型"));
-    painter.drawText(19*5,21*5,info->info().batch_no);//QStringLiteral("批号"));
+    painter.drawText(19*5,15*5,info->info()->specs);//QStringLiteral("规格"));
+    painter.drawText(70*5,15*5,info->info()->category);//QStringLiteral("类型"));
+    painter.drawText(19*5,21*5,info->info()->batch_no);//QStringLiteral("批号"));
     painter.drawText(70*5,21*5,info->level);//info.at(0));
     painter.drawText(70*5,21*5,info->level);//info.at(0));
     for(int i = 0; i < boxSize; ++i)
     for(int i = 0; i < boxSize; ++i)
     {
     {
@@ -238,25 +236,25 @@ if(save)
 
 
 void DanJuMuBan::print(QImage image)
 void DanJuMuBan::print(QImage image)
 {
 {
-    auto name = GlobalInfo::this_()->config().printerName;
+    auto name = GlobalInfo::this_()->config()->printerName;
     pqInfo(log) << "printer " << name;
     pqInfo(log) << "printer " << name;
-        QPrinter printer(QPrinterInfo::printerInfo(GlobalInfo::this_()->config().printerName));
-        printer.setPageSize(QPrinter::Custom);
-        printer.setPageSizeMM(QSizeF(100,70));
+    QPrinter printer(QPrinterInfo::printerInfo(GlobalInfo::this_()->config()->printerName));
+    printer.setPageSize(QPrinter::Custom);
+    printer.setPageSizeMM(QSizeF(100,70));
 
 
 //        printer.setPrinterName();
 //        printer.setPrinterName();
-        QPainter painter(&printer);                         // 创建一个QPainter对象,并指定绘图设备为一个QPainter对象
-        QRect rect =painter.viewport();                     // 获得QPainter对象的视图矩形区域
-        QSize size(image.width(),image.height());                            // 获得图像的大小
-        /* 按照图形的比例大小重新设置视图矩形区域 */
-        size.scale(rect.size(),Qt::KeepAspectRatio);
-        painter.setViewport(rect.x(),rect.y(),size.width()+50,size.height());
+    QPainter painter(&printer);                         // 创建一个QPainter对象,并指定绘图设备为一个QPainter对象
+    QRect rect =painter.viewport();                     // 获得QPainter对象的视图矩形区域
+    QSize size(image.width(),image.height());                            // 获得图像的大小
+    /* 按照图形的比例大小重新设置视图矩形区域 */
+    size.scale(rect.size(),Qt::KeepAspectRatio);
+    painter.setViewport(rect.x(),rect.y(),size.width()+50,size.height());
 //        painter.setViewport(rect.x(),rect.y(),size.width(),size.height());
 //        painter.setViewport(rect.x(),rect.y(),size.width(),size.height());
-        painter.setWindow(image.rect());                      // 设置QPainter窗口大小为图像的大小
-        painter.drawImage(0,0,image);                         // 打印图像
-        painter.end();
-        auto ed = printer.newPage();
-        pqInfo(log) << "printer  newPage:" << ed;
+    painter.setWindow(image.rect());                      // 设置QPainter窗口大小为图像的大小
+    painter.drawImage(0,0,image);                         // 打印图像
+    painter.end();
+    auto ed = printer.newPage();
+    pqInfo(log) << "printer  newPage:" << ed;
 //        printer
 //        printer
 //    }
 //    }
 }
 }

+ 1 - 1
handle/danjumuban.h

@@ -9,7 +9,7 @@
 #include "QPrintDialog"
 #include "QPrintDialog"
 #include "struct_/packinfo.h"
 #include "struct_/packinfo.h"
 #include <pqQtlib/log/pqlog.h>
 #include <pqQtlib/log/pqlog.h>
-
+//TODO:小宋,实现迁移走,然后删除掉
 class DanJuMuBan
 class DanJuMuBan
 {
 {
 public:
 public:

+ 0 - 347
handle/database.cpp

@@ -1,347 +0,0 @@
-#include "database.h"
-#include "QSqlRecord"
-#include <QStringList>
-
-Database::Database(QObject *parent) :
-    QObject(parent)
-{
-
-}
-
-Database::~Database()
-{
-    _database.close();
-}
-
-void Database::SetTableName(QString table)
-{
-    _tableName = table + ".db";
-}
-
-bool Database::openDB()
-{
-    _database = QSqlDatabase::addDatabase("QSQLITE","db");
-//    _database.setDatabaseName(_tableName);
-    _database.setDatabaseName(".//qtDb.db");
-    return _database.open();
-}
-
-bool Database::createProductDatabase()
-{
-    QSqlDatabase db = QSqlDatabase::database("db");
-    QSqlQuery query(db);
-
-
-
-    bool success = query.exec("CREATE TABLE product ("
-                                  "goods_id INTEGER NOT NULL,"              //商品ID
-                                  "code_single VARCHAR NOT NULL,"           //码单
-                                  "quantity INTEGER NOT NULL,"              //箱数
-                                  "batch_no VARCHAR NOT NULL,"              //批号
-                                  "category VARCHAR NOT NULL,"              //类型
-                                  "level_id INTEGER NOT NULL,"              //等级id
-                                  "tube_number INTEGER NOT NULL,"           //筒数
-                                  "gross_weight INTEGER NOT NULL,"          //毛重 单位克
-                                  "net_weight INTEGER NOT NULL,"            //净重 单位克
-                                  "machine_no VARCHAR NOT NULL,"            //机台
-                                  "packing_time VARCHAR NOT NULL,"          //打包时间
-                                  "packing_type VARCHAR NOT NULL,"          //打包种类
-                                  "carton_type VARCHAR NOT NULL,"           //纸箱种类
-                                  "operator_id INTEGER NOT NULL,"           //操作员ID
-                                  "specs VARCHAR NOT NULL,"                 //规格
-                                  "denier VARCHAR,"                         //旦数(D)
-                                  "dtex VARCHAR,"                           //分特(dt)
-                                  "fiber VARCHAR,"                          //孔数(F)
-                                  "tongbu VARCHAR(1) DEFAULT 0,"            //同步状态
-                                  "remark VARCHAR);");                      //备注
-
-//     success = query.exec("drop table product;");
-
-    if(success)
-    {
-        qDebug() << QObject::tr("product数据库表创建成功!\n");
-        return true;
-    }
-    else
-    {
-        qDebug() << QObject::tr("product数据库表已存在!\n");
-        return false;
-    }
-}
-
-bool Database::createDetailsDatabase()
-{
-    QSqlDatabase db = QSqlDatabase::database("db");
-    QSqlQuery query(db);
-
-    bool success = query.exec("CREATE TABLE details ("
-                                  "code_single VARCHAR NOT NULL,"           //码单
-                                  "case_number VARCHAR NOT NULL,"           //箱号
-                                  "box_weight INTEGER NOT NULL,"            //皮重 单位克
-                                  "tube_number INTEGER NOT NULL,"           //筒数
-                                  "bucket_weight INTEGER NOT NULL,"         //筒重 单位克
-                                  "gross_weight INTEGER NOT NULL,"          //毛重 单位克
-                                  "net_weight INTEGER NOT NULL,"            //净重 单位克
-                                  "sort VARCHAR NOT NULL,"                  //排序
-                                  "remark VARCHAR);");                      //备注
-
-//     success = query.exec("drop table details;");
-
-    if(success)
-    {
-        qDebug() << QObject::tr("details数据库表创建成功!");
-        return true;
-    }
-    else
-    {
-        qDebug() << QObject::tr("details数据库表已存在!");
-        return false;
-    }
-}
-
-bool Database::insertProduct(product_data productData)
-{
-    QSqlDatabase db = QSqlDatabase::database("db");
-    QSqlQuery query(db);
-
-    query.prepare("INSERT INTO product(goods_id,"
-                          "code_single, quantity, batch_no, category,level_id, tube_number,"
-                          "gross_weight, net_weight, machine_no, packing_time,"
-                          "packing_type, carton_type, operator_id, specs, denier, dtex, fiber, remark)"
-                          "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
-    query.bindValue(0,productData.goods_id);
-    query.bindValue(1,productData.code_single);
-    query.bindValue(2,productData.quantity);
-    query.bindValue(3,productData.batch_no);
-    query.bindValue(4,productData.category);
-    query.bindValue(5,productData.level_id);
-    query.bindValue(6,productData.tube_number);
-    query.bindValue(7,productData.gross_weight);
-    query.bindValue(8,productData.net_weight);
-    query.bindValue(9,productData.machine_no);
-    query.bindValue(10,productData.packing_time);
-    query.bindValue(11,productData.packing_type);
-    query.bindValue(12,productData.carton_type);
-    query.bindValue(13,productData.operator_id);
-    query.bindValue(14,productData.specs);
-    query.bindValue(15,productData.denier);
-    query.bindValue(16,productData.dtex);
-    query.bindValue(17,productData.fiber);
-    query.bindValue(18,productData.remark);
-
-    bool success=query.exec();
-    return success;
-}
-
-bool Database::insertDetails(details_data detailsData)
-{
-    QSqlDatabase db = QSqlDatabase::database("db");
-    QSqlQuery query(db);
-
-    query.prepare("INSERT INTO details(code_single,"
-                  "case_number, box_weight, tube_number, bucket_weight,"
-                  "gross_weight, net_weight, sort, remark)"
-                  "VALUES(?,?,?,?,?,?,?,?,?)");
-    query.bindValue(0,detailsData.code_single);
-    query.bindValue(1,detailsData.case_number);
-    query.bindValue(2,detailsData.box_weight);
-    query.bindValue(3,detailsData.tube_number);
-    query.bindValue(4,detailsData.bucket_weight);
-    query.bindValue(5,detailsData.gross_weight);
-    query.bindValue(6,detailsData.net_weight);
-    query.bindValue(7,detailsData.sort);
-    query.bindValue(8,detailsData.remark);
-
-    bool success=query.exec();
-    return success;
-}
-
-bool Database::changeState(QString codesingle)
-{
-    QSqlDatabase db = QSqlDatabase::database("db");
-    QSqlQuery query(db);
-
-    bool success = query.exec("update product set tongbu=1 where code_single="+codesingle);
-    if(success)
-    {
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
-bool Database::update(QString &table, QStringList &names, QStringList &values, QString &expression)
-{
-    if (names.size() != values.size())
-        return false;
-    //UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值
-//    QSqlQuery query(QSqlDatabase::database());
-
-    QSqlDatabase db = QSqlDatabase::database("db");
-    QSqlQuery query(db);
-
-    QString sql = QString("update ")+table+QString(" set ");
-    for (int i = 0; i < names.size(); i++)
-    {
-        sql += names.value(i);
-        sql += QString(" = '");
-        sql = sql + values.value(i);
-        sql = sql + QString("'");
-        if (i != names.size()-1)
-            sql = sql + QString(" ,");
-    }
-    sql = sql + QString(" where ") + expression;
-    return (query.exec(sql)) ? true : false;
-}
-
-bool Database::del(QString &table, QString &expression)
-{
-    //DELETE FROM 表名称 WHERE 列名称 = 值
-    QSqlQuery query(QSqlDatabase::database());
-    QString sql = QString("delete from ") + table + QString(" where ") + expression;
-    return (query.exec(sql)) ? true : false;
-}
-
-QList<QMap<QString,QString>> Database::GetValues(QString table, QStringList &values,QString condition)
-{
-    dbmxdata.clear();
-    dbmxlist.clear();
-    QSqlDatabase db = QSqlDatabase::database("db");
-    QSqlQuery query(db);
-
-    QString sql = QString("select * from ") + table +" "+ condition;
-    query.exec(sql);
-
-    qDebug()<<table;
-    while (query.next())
-    {
-        for(int i = 0;i <= values.size()-1;i++){
-            qDebug()<<values.at(i) << query.value(values.at(i)).toString();
-            dbmxdata.insert(values.at(i),query.value(values.at(i)).toString());
-        }
-        dbmxlist.append(dbmxdata);
-        dbmxdata.clear();
-    }
-    return dbmxlist;
-}
-
-//获取单个字段数据,以数组形式返回;
-QStringList Database::GetValuesList(QString table, QString value,QString condition)
-{
-    QStringList list;
-    QSqlDatabase db = QSqlDatabase::database("db");
-    QSqlQuery query(db);
-//    QString value;
-//    for(int i = 0;i<values.size();i++){
-//        value.append(values.at(i));
-//        if(!i == values.size()-1){
-//            value.append(",");
-//        }
-//    }
-    QString sql = "select "+value+" from " + table +" "+ condition;
-    query.exec(sql);
-    while (query.next())
-    {
-            list.append(query.value(value).toString());
-//            qDebug()<<query.value(values.at(i)).toString();
-    }
-    return list;
-}
-
-int Database::GetTablePage()
-{
-    QSqlDatabase db = QSqlDatabase::database("db");
-    QSqlQuery query(db);
-
-    QString sql = QString("select count(*) from product");
-    query.exec(sql);
-    if(query.first())
-    {
-        return query.value(0).toInt();
-    }
-    return 0;
-}
-
-//void Database::connectDB(QString dbName, QString username, QString password)
-//{
-//    if (QSqlDatabase::contains("qt_sql_default_connection"))
-//    {
-//        database = QSqlDatabase::database("qt_sql_default_connection");
-//    }
-//    else
-//    {
-//        database = QSqlDatabase::addDatabase("QSQLITE");
-//        database.setDatabaseName(dbName);
-//        database.setUserName(username);
-//        database.setPassword(password);
-//    }
-
-//    if (!database.open())
-//    {
-//        qDebug() << "Error: Failed to connect database." << database.lastError();
-//    }
-//    else
-//    {
-//        QSqlQuery sql_query;
-//        QString create_sql;
-////        create_sql = "create table login (name varchar(100), logintime DATETIME)";
-//        sql_query.prepare(create_sql);
-//        if(!sql_query.exec())
-//        {
-//            qDebug() << "Error: Fail to create table." << sql_query.lastError();
-//        }
-//        else
-//        {
-//            qDebug() << "Table created!";
-//        }
-//    }
-
-//}
-
-
-//bool Database::insert(QString &table, QStringList &names, QStringList &values)
-//{
-//    if(names.size() != values.size())
-//    {
-//        return false;
-//    }
-
-////    QSqlQuery query(QSqlDatabase::database());
-
-//    QSqlDatabase db = QSqlDatabase::database("db");
-//    QSqlQuery query(db);
-
-//    QString sql = QString("insert into ") + table + QString("(");
-
-//    int i;
-//    for(i = 0; i < names.size(); i++)
-//    {
-//        sql = sql + names.value(i);
-//        if(i != names.size()-1)
-//        {
-//            sql += QString(",");
-//        }
-//        else
-//        {
-//            sql += QString(")");
-//        }
-//    }
-
-//    sql = sql + QString("values (");
-
-//    for(i = 0; i < values.size(); i++)
-//    {
-//        sql = sql + QString("'") + values.value(i) + QString("'");
-//        if (i != values.size()-1)
-//        {
-//            sql += QString(",");
-//        }
-//    }
-//    sql += QString(")");
-
-//    return (query.exec(sql)) ? true : false;
-//}
-
-

+ 0 - 80
handle/database.h

@@ -1,80 +0,0 @@
-#ifndef DATABASE_H
-#define DATABASE_H
-
-#include <QDebug>
-#include <QSqlDatabase>
-#include <QSqlError>
-#include <QSqlQuery>
-#include <QSqlTableModel>
-
-struct product_data
-{
-    int goods_id;
-    QString code_single;
-    int quantity;
-    QString batch_no;
-    QString category;
-    int level_id;
-    int tube_number;
-    int gross_weight;
-    int net_weight;
-    QString machine_no;
-    QString packing_time;
-    QString packing_type;
-    QString carton_type;
-    int operator_id;
-    QString specs;
-    QString denier;
-    QString dtex;
-    QString fiber;
-    QString remark;
-};
-
-struct details_data
-{
-    QString code_single;
-    QString case_number;
-    int box_weight;
-    int tube_number;
-    int bucket_weight;
-    int gross_weight;
-    int net_weight;
-    QString sort;
-    QString remark;
-};
-
-class Database : public QObject
-{
-    Q_OBJECT
-public:
-    explicit Database(QObject *parent = 0);
-    ~Database();
-//    void connectDB(QString dbName, QString username, QString password);
-//    void insertData();
-//    void deleteData();
-    void SetTableName(QString table);
-    bool openDB();
-    bool createProductDatabase();
-    bool createDetailsDatabase();
-//    bool insert(QString &table, QStringList &names, QStringList &values);
-    bool update(QString &table, QStringList &names, QStringList &values, QString &expression);
-    bool del(QString &table, QString &expression);
-    QList<QMap<QString,QString>> GetValues(QString table, QStringList &values,QString condition = "");
-    QStringList GetValuesList(QString table, QString value,QString condition = "");
-    int GetTablePage();
-
-    bool insertProduct(product_data productData);
-    bool insertDetails(details_data detailsData);
-    bool changeState(QString xianghao);
-
-
-
-private:
-    QSqlDatabase _database;
-    QSqlTableModel *model;
-    QString _tableName;
-    QList<QMap<QString,QString>> dbmxlist;
-    QMap<QString,QString> dbmxdata;
-};
-
-#endif // DATABASE_H

+ 3 - 1
handle/packinfomanger.cpp

@@ -99,8 +99,10 @@ QList<QSharedPointer<ProjectInfo>>  PackInfoManger::getLocalProjectInfo()
         for(int i = 0; i < ary.size(); ++i){
         for(int i = 0; i < ary.size(); ++i){
             auto obj = ary.at(i).toObject();
             auto obj = ary.at(i).toObject();
             auto info = ProjectInfo::fromObject(obj);
             auto info = ProjectInfo::fromObject(obj);
-            if(!info.isNull())
+            if(!info.isNull()) {
+                info->isLocal = true;
                 list.append(info);
                 list.append(info);
+            }
         }
         }
     }
     }
     return list;
     return list;

+ 1 - 2
handle/packinfoseed2server.cpp

@@ -25,9 +25,8 @@ void PackInfoSeed2Server::doSend()
 {
 {
     if(_current.isNull() && !_queue.isEmpty()){
     if(_current.isNull() && !_queue.isEmpty()){
         _current = _queue.first();
         _current = _queue.first();
-        // TODO:小宋, 发送 _current 到服务器
         //docs: http://doc.vanlai.net:3001/web/#/1?page_id=64
         //docs: http://doc.vanlai.net:3001/web/#/1?page_id=64
-        QString url = GlobalInfo::this_()->config().baseUrl+"/v1/product/pending";
+        QString url = GlobalInfo::this_()->config()->baseUrl+"/v1/product/pending";
         _requst.post(url,_current->toObject());
         _requst.post(url,_current->toObject());
     }
     }
 }
 }

+ 25 - 0
handle/printer/baseboxprinter.cpp

@@ -0,0 +1,25 @@
+#include "baseboxprinter.h"
+
+BaseBoxPrinter::BaseBoxPrinter()
+{
+
+}
+
+
+BasePackinfoPrinter::BasePackinfoPrinter()
+{
+
+}
+
+BaseBoxPrinter::~BaseBoxPrinter()
+{
+
+}
+
+
+BasePackinfoPrinter::~BasePackinfoPrinter()
+{
+
+}
+
+

+ 38 - 0
handle/printer/baseboxprinter.h

@@ -0,0 +1,38 @@
+#ifndef BASEBOXPRINTER_H
+#define BASEBOXPRINTER_H
+
+#include <QObject>
+#include "struct_/packinfo.h"
+#include <QPainter>
+#include "code39.h"
+#include <QImage>
+
+class BaseBoxPrinter
+{
+public:
+    explicit BaseBoxPrinter();
+    virtual ~BaseBoxPrinter();
+
+    virtual QImage doPrinter(QSharedPointer<BoxInfo> box) = 0;
+
+    virtual QSize printSize() = 0;
+protected:
+    Code39 code;
+};
+
+
+class BasePackinfoPrinter
+{
+public:
+    explicit BasePackinfoPrinter();
+    virtual ~BasePackinfoPrinter();
+
+    virtual QImage doPrinter(QSharedPointer<PackInfo> box) = 0;
+
+    virtual QSize printSize() = 0;
+
+protected:
+    Code39 code;
+};
+
+#endif // BASEBOXPRINTER_H

+ 32 - 0
handle/printer/boxtemlateone.cpp

@@ -0,0 +1,32 @@
+#include "boxtemlateone.h"
+
+BoxTemlateOne::BoxTemlateOne()
+{
+
+}
+
+QImage BoxTemlateOne::doPrinter(QSharedPointer<BoxInfo> box)
+{
+    //TODO: 小宋,迁移打印 箱单的逻辑
+
+//    return img;
+}
+
+QSize BoxTemlateOne::printSize()
+{
+    return QSize(100,80);
+}
+
+
+PackTemlateOne::PackTemlateOne()
+{}
+
+QImage PackTemlateOne::doPrinter(QSharedPointer<PackInfo> pack)
+{
+    //TODO: 小宋,迁移打印 码单的逻辑
+}
+
+QSize PackTemlateOne::printSize()
+{
+    return QSize(100,80);
+}

+ 36 - 0
handle/printer/boxtemlateone.h

@@ -0,0 +1,36 @@
+#ifndef BOXTEMLATEONE_H
+#define BOXTEMLATEONE_H
+
+#include "baseboxprinter.h"
+
+class BoxTemlateOne : public BaseBoxPrinter
+{
+public:
+    BoxTemlateOne();
+
+    virtual QImage doPrinter(QSharedPointer<BoxInfo> box);
+
+    virtual QSize printSize();
+
+private:
+    const int MAXWIDTH=100;
+    const int MAXHEIGHT=80;
+    int FONTHEIGHT=10;
+};
+
+class PackTemlateOne : public BasePackinfoPrinter
+{
+public:
+    PackTemlateOne();
+
+    virtual QImage doPrinter(QSharedPointer<PackInfo> pack);
+
+    virtual QSize printSize();
+private:
+private:
+    const int MAXWIDTH=100;
+    const int MAXHEIGHT=80;
+    int FONTHEIGHT=10;
+};
+
+#endif // BOXTEMLATEONE_H

+ 187 - 0
handle/printer/code39.cpp

@@ -0,0 +1,187 @@
+#include "code39.h"
+
+QMap<QString,QString> InitMap()
+{
+//    if(!map.isEmpty()) return;
+    QMap<QString,QString> ret;
+    ret.insert("A","110101001011");
+    ret.insert("B","101101001011");
+    ret.insert("C","110110100101");
+    ret.insert("D","101011001011");
+    ret.insert("E","110101100101");
+    ret.insert("F","101101100101");
+    ret.insert("G","101010011011");
+    ret.insert("H","110101001101");
+    ret.insert("I","101101001101");
+    ret.insert("J","101011001101");
+    ret.insert("K","110101010011");
+    ret.insert("L","101101010011");
+    ret.insert("M","110110101001");
+    ret.insert("N","101011010011");
+    ret.insert("O","110101101001");
+    ret.insert("P","101101101001");
+    ret.insert("Q","101010110011");
+    ret.insert("R","110101011001");
+    ret.insert("S","101101011001");
+    ret.insert("T","101011011001");
+    ret.insert("U","110010101011");
+    ret.insert("V","100110101011");
+    ret.insert("W","110011010101");
+    ret.insert("X","100101101011");
+    ret.insert("Y","110010110101");
+    ret.insert("Z","100110110101");
+    ret.insert("0","101001101101");
+    ret.insert("1","110100101011");
+    ret.insert("2","101100101011");
+    ret.insert("3","110110010101");
+    ret.insert("4","101001101011");
+    ret.insert("5","110100110101");
+    ret.insert("6","101100110101");
+    ret.insert("7","101001011011");
+    ret.insert("8","110100101101");
+    ret.insert("9","101100101101");
+    ret.insert("+","100101001001");
+    ret.insert("-","100101011011");
+    ret.insert("*","100101101101");
+    ret.insert("/","100100101001");
+    ret.insert("%","101001001001");
+    ret.insert("$","100100100101");
+    ret.insert(".","110010101101");
+    ret.insert(" ","100110101101");
+    return ret;
+}
+
+static QMap<QString,QString> map = InitMap();
+
+Code39::Code39()
+{
+
+//    InitMap();
+}
+
+
+
+void Code39::draw(QPainter & painter, QRect & pos,QString & barcode)
+{
+    QString BinaryNum = CodeBinary(barcode);
+    int MAXHEIGHT = pos.height();
+    int MAXWIDTH = pos.width();
+    int FONTHEIGHT=10; //预留10px的左右空白;
+    int widght = MAXWIDTH - FONTHEIGHT;
+    //设定条码线条宽度px
+    int LineWidth = widght / BinaryNum.size();
+    int move= (MAXWIDTH-LineWidth*BinaryNum.size())/2;
+    //QBitmap bmp(MAXWIDTH,MAXHEIGHT+FONTHEIGHT);
+//    QPainter painter(&image);
+    painter.save();
+//    painter.setWindow(pos);
+    QPen white,black;
+    //    painter.setRenderHint(QPainter::Antialiasing,true);//弧线圆润
+    white.setColor(QColor(255,255,255));
+    black.setColor(QColor(0,0,0));
+    white.setWidth(LineWidth);
+    black.setWidth(LineWidth);
+
+    //背景充填白色
+    painter.setPen(white);
+    painter.drawRect(0,0,MAXWIDTH,MAXHEIGHT+FONTHEIGHT);
+
+    //画线
+    for(int i=0;i<BinaryNum.size();i++)
+    {
+        if(BinaryNum.at(i)=='1') painter.setPen(black);
+        else painter.setPen(white);
+        painter.drawLine(i*LineWidth+LineWidth/2+move,pos.top(),i*LineWidth+LineWidth/2+move,MAXHEIGHT);
+    }
+
+//    qDebug()<<barcode<<endl;
+    //添加底部条形码字符
+    painter.setPen(black);
+    painter.setRenderHint(QPainter::Antialiasing,true);
+    painter.setRenderHint(QPainter::TextAntialiasing,true);
+    painter.setRenderHint(QPainter::HighQualityAntialiasing,true);
+    QFont font;
+    font.setFamily("宋体");
+    font.setPixelSize(5*5);
+    font.setWeight(QFont::ExtraLight);
+    painter.setFont(font);
+    painter.drawText(0*5,MAXHEIGHT+1,MAXWIDTH,17,Qt::AlignCenter,/*"S/N:" +*/ barcode);
+
+    painter.restore();
+}
+/*
+QImage Code39::draw(QString BinaryNum,QString barcode)
+{
+    int MAXWIDTH;
+    int MAXHEIGHT=30;
+    int FONTHEIGHT=10;
+
+    //设定条码线条宽度px
+    int LineWidth=1;
+    //预留10px的左右空白;
+    MAXWIDTH=LineWidth*BinaryNum.size()+5;
+
+    //计算条线宽度时,精度丢失造成条码右边空白,进行右移居中
+    int move=(MAXWIDTH-LineWidth*BinaryNum.size())/2;
+
+    QSize size(MAXWIDTH,MAXHEIGHT+FONTHEIGHT);
+    QImage image(size,QImage::Format_ARGB32);
+    image.fill(qRgba(255, 255, 255, 0));
+
+    //QBitmap bmp(MAXWIDTH,MAXHEIGHT+FONTHEIGHT);
+    QPainter painter(&image);
+    QPen white,black;
+    //    painter.setRenderHint(QPainter::Antialiasing,true);//弧线圆润
+    white.setColor(QColor(255,255,255));
+    black.setColor(QColor(0,0,0));
+    white.setWidth(LineWidth);
+    black.setWidth(LineWidth);
+
+    //背景充填白色
+    painter.setPen(white);
+    painter.drawRect(0,0,MAXWIDTH,MAXHEIGHT+FONTHEIGHT);
+
+    //画线
+    for(int i=0;i<BinaryNum.size();i++)
+    {
+        if(BinaryNum.at(i)=='1') painter.setPen(black);
+        else painter.setPen(white);
+        painter.drawLine(i*LineWidth+LineWidth/2+move,0,i*LineWidth+LineWidth/2+move,MAXHEIGHT);
+    }
+
+//    qDebug()<<barcode<<endl;
+    //添加底部条形码字符
+    painter.setPen(black);
+    painter.setRenderHint(QPainter::Antialiasing,true);
+    painter.setRenderHint(QPainter::TextAntialiasing,true);
+    painter.setRenderHint(QPainter::HighQualityAntialiasing,true);
+    QFont font;
+    font.setFamily("宋体");
+    font.setPixelSize(10);
+    font.setWeight(QFont::ExtraLight);
+    painter.setFont(font);
+    painter.drawText(5,30,MAXWIDTH,10,Qt::AlignCenter,"S/N:"barcode);
+//    bool isSaved = image.save(path + barcode + ".bmp");
+//    qDebug()<<isSaved;
+//    return image;
+//}*/
+
+
+QString Code39::CodeBinary(QString barcode)
+{
+    barcode="*"+barcode+"*";
+    QString str="";
+    for(int i=0;i<barcode.size();i++)
+    {
+        str+= map[barcode.at(i)]+"0";//每个字符的二进制逻辑码之间,用“0”隔开(加一条白线)
+    }
+    return str;
+}
+
+
+
+//void Code39::reset(QString BarCode, QString SavePath)
+//{
+////    barcode=BarCode;
+////    path=SavePath;
+//}

+ 29 - 0
handle/printer/code39.h

@@ -0,0 +1,29 @@
+#ifndef CODE39_H
+#define CODE39_H
+
+#include <QDebug>
+#include <QDateTime>
+#include <QMessageBox>
+#include <QFont>
+#include <QBitmap>
+#include <QPainter>
+#include <QtPrintSupport>
+
+class Code39
+{
+public:
+    Code39();
+
+private:
+//    static QMap<QString,QString> map;
+
+public:
+    void draw(QPainter & painter, QRect & pos, QString &barcode);
+    QString CodeBinary(QString barcode);
+
+private:
+//    static void InitMap();
+
+};
+
+#endif // CODE39_H

+ 74 - 0
handle/printer/printermanger.cpp

@@ -0,0 +1,74 @@
+#include "printermanger.h"
+#include <QPrinterInfo>
+
+PrinterManger::PrinterManger(QObject *parent) : QObject(parent)
+{
+
+}
+
+
+//void PrinterManger::setPrinterBoxName(const QString & name)
+//{}
+
+//void PrinterManger::setPrinterPackName(const QString & name)
+
+
+void PrinterManger::setPrinter(const QSharedPointer<BaseBoxPrinter> box, const QSharedPointer<BasePackinfoPrinter> packInfo)
+{
+    _boxPrinter = box;
+    _packPrinter = packInfo;
+}
+
+void PrinterManger::setPrinterName(const QString & name)
+{
+    _printerName = name;
+
+    if(name.isEmpty()){
+        _printerName = QPrinterInfo::defaultPrinterName();
+    }
+}
+
+void PrinterManger::printerBox(QSharedPointer<BoxInfo> info)
+{
+    if(_boxPrinter.isNull()) return;
+    auto image = _boxPrinter->doPrinter(info);
+    if(image.isNull()) return;
+    QPrinter printer(QPrinterInfo::printerInfo(_printerName));
+    printer.setPageSize(QPrinter::Custom);
+    printer.setPageSizeMM(_boxPrinter->printSize());
+//    for(int i = 0; i < count; ++i) // TODO:
+    {
+        doPrinter(printer,image);
+    }
+}
+
+
+void PrinterManger::doPrinter(QPrinter & printer,QImage & image)
+{
+    QPainter painter(&printer);                         // 创建一个QPainter对象,并指定绘图设备为一个QPainter对象
+//    QRect rect = painter.viewport();                     // 获得QPainter对象的视图矩形区域
+//    QSize size(image.width(),image.height());                            // 获得图像的大小
+    /* 按照图形的比例大小重新设置视图矩形区域 */
+//    size.scale(rect.size(),Qt::KeepAspectRatio);
+//    painter.setViewport(rect.x(),rect.y(),size.width()+50,size.height());
+//        painter.setViewport(rect.x(),rect.y(),size.width(),size.height());
+//    painter.setWindow(image.rect());                      // 设置QPainter窗口大小为图像的大小
+    painter.drawImage(0,0,image);                         // 打印图像
+    painter.end();
+    auto ed = printer.newPage();
+//    pqInfo(log) << "printer  newPage:" << ed;
+}
+
+void PrinterManger::printerPack(QSharedPointer<PackInfo> info)
+{
+    if(_boxPrinter.isNull()) return;
+    auto image = _packPrinter->doPrinter(info);
+    if(image.isNull()) return;
+    QPrinter printer(QPrinterInfo::printerInfo(_printerName));
+    printer.setPageSize(QPrinter::Custom);
+    printer.setPageSizeMM(_packPrinter->printSize());
+//    for(int i = 0; i < count; ++i) // TODO:
+    {
+        doPrinter(printer,image);
+    }
+}

+ 29 - 0
handle/printer/printermanger.h

@@ -0,0 +1,29 @@
+#ifndef PRINTERMANGER_H
+#define PRINTERMANGER_H
+
+#include <QObject>
+#include "baseboxprinter.h"
+
+class PrinterManger : public QObject
+{
+    Q_OBJECT
+public:
+    explicit PrinterManger(QObject *parent = nullptr);
+
+    void setPrinter(const QSharedPointer<BaseBoxPrinter> box, const QSharedPointer<BasePackinfoPrinter> packInfo);
+
+    inline void setPrinterName(const QString & name);
+signals:
+public slots:
+    void printerBox(QSharedPointer<BoxInfo> info);
+    void printerPack(QSharedPointer<PackInfo> info);
+
+private:
+    void doPrinter(QPrinter & printer,QImage & img);
+private:
+    QSharedPointer<BaseBoxPrinter> _boxPrinter;
+    QSharedPointer<BasePackinfoPrinter> _packPrinter;
+    QString _printerName;
+};
+
+#endif // PRINTERMANGER_H

+ 31 - 0
handle/printerthreadhandle.cpp

@@ -0,0 +1,31 @@
+#include "printerthreadhandle.h"
+#include "globalinfo.h"
+#include "handle/printer/boxtemlateone.h"
+
+PrinterThreadHandle::PrinterThreadHandle(QObject *parent) : QObject(parent),manger(nullptr),thread(nullptr)
+{
+}
+
+void PrinterThreadHandle::updateConfig()
+{
+    if(manger == nullptr) return;
+    auto config = GlobalInfo::this_()->config();
+    manger->setPrinterName(config->printerName);
+}
+
+void PrinterThreadHandle::start()
+{
+    if(thread == nullptr){
+        thread = new QThread(this);
+        connect(thread,&QThread::started,this,&PrinterThreadHandle::updateConfig);
+        manger = new PrinterManger(this);
+        connect(this,&PrinterThreadHandle::printerBox,manger,&PrinterManger::printerBox,Qt::QueuedConnection);
+        connect(this,&PrinterThreadHandle::printerPack,manger,&PrinterManger::printerPack,Qt::QueuedConnection);
+        auto config = GlobalInfo::this_()->config();
+        connect(config,&ConfigInfo::configUpdate,this,&PrinterThreadHandle::updateConfig,Qt::QueuedConnection);
+        manger->setPrinter(QSharedPointer<BaseBoxPrinter>(new BoxTemlateOne()),QSharedPointer<BasePackinfoPrinter>(new PackTemlateOne()));
+        this->moveToThread(thread);
+        thread->start();
+    }
+}
+

+ 28 - 0
handle/printerthreadhandle.h

@@ -0,0 +1,28 @@
+#ifndef PRINTERTHREADHANDLE_H
+#define PRINTERTHREADHANDLE_H
+
+#include <QObject>
+#include <QThread>
+#include "printer/printermanger.h"
+
+// 单独线程处理打印事件,不出现批量卡机
+class PrinterThreadHandle : public QObject
+{
+    Q_OBJECT
+public:
+    explicit PrinterThreadHandle(QObject *parent = nullptr);
+
+signals:
+    void printerBox(QSharedPointer<BoxInfo> info);
+    void printerPack(QSharedPointer<PackInfo> info);
+public slots:
+    void start();
+
+private slots:
+        void updateConfig();
+private:
+    PrinterManger * manger;
+    QThread * thread;
+};
+
+#endif // PRINTERTHREADHANDLE_H

+ 22 - 9
handle/projectinfomanger.cpp

@@ -8,15 +8,23 @@
 ProjectInfoManger::ProjectInfoManger(PackInfoManger *manger, QObject *parent) : QObject(parent),_manger(manger)
 ProjectInfoManger::ProjectInfoManger(PackInfoManger *manger, QObject *parent) : QObject(parent),_manger(manger)
 {
 {
     connect(&_requst,&HttpRequest::result,this,&ProjectInfoManger::result);
     connect(&_requst,&HttpRequest::result,this,&ProjectInfoManger::result);
+    _nowJob = 0;
 }
 }
 
 
-bool ProjectInfoManger::loadServerList()
+bool ProjectInfoManger::loadServerList(bool local)
 {
 {
     if(_status != IDIL) return false;
     if(_status != IDIL) return false;
     _serverInfo.clear();
     _serverInfo.clear();
     _cacheInfo.clear();
     _cacheInfo.clear();
+    if(local){
+        auto dt = PQ::CacheFile::readFile("ProjectInfoList.cache");
+        auto ary = QJsonDocument::fromJson(dt).array();
+        hanldeServerList(ary,false);
+        return true;
+    }
     _oneSyncError = 0;
     _oneSyncError = 0;
     _netErrorCount = 0;
     _netErrorCount = 0;
+    _nowJob = 1;
     QTimer::singleShot(0,this,&ProjectInfoManger::doSendLoad);
     QTimer::singleShot(0,this,&ProjectInfoManger::doSendLoad);
     return true;
     return true;
 }
 }
@@ -24,22 +32,22 @@ bool ProjectInfoManger::loadServerList()
 bool ProjectInfoManger::syncLocalList()
 bool ProjectInfoManger::syncLocalList()
 {
 {
     if(_status != IDIL) return false;
     if(_status != IDIL) return false;
-    auto  info =  GlobalInfo::this_()->cacheInfo();
+    auto  info =  _manger->getLocalProjectInfo();
     _serverInfo.clear();
     _serverInfo.clear();
     _cacheInfo.clear();
     _cacheInfo.clear();
     _pushQueue.clear();
     _pushQueue.clear();
+     _nowJob = 2;
     for(int i = 0; i < info.size(); ++i){
     for(int i = 0; i < info.size(); ++i){
         _pushQueue.append(info.at(i));
         _pushQueue.append(info.at(i));
     }
     }
-    QTimer::singleShot(0,this,&ProjectInfoManger::syncLocalList);
+    QTimer::singleShot(0,this,&ProjectInfoManger::doSendCreate);
     return true;
     return true;
 }
 }
 
 
 void ProjectInfoManger::doSendLoad()
 void ProjectInfoManger::doSendLoad()
 {
 {
-    //TODO:小宋,请求获取批号列表信息
     // docs: http://doc.vanlai.net:3001/web/#/1?page_id=60
     // docs: http://doc.vanlai.net:3001/web/#/1?page_id=60
-    QString url = GlobalInfo::this_()->config().baseUrl+"v1/goods/list";
+    QString url = GlobalInfo::this_()->config()->baseUrl+"v1/goods/list";
     _requst.get(url);
     _requst.get(url);
 }
 }
 
 
@@ -48,10 +56,10 @@ void ProjectInfoManger::doSendCreate()
     if(!_pushQueue.isEmpty()){
     if(!_pushQueue.isEmpty()){
         _status = Sync_Local_List;
         _status = Sync_Local_List;
         QSharedPointer<ProjectInfo> info = _pushQueue.first();
         QSharedPointer<ProjectInfo> info = _pushQueue.first();
-        // TODO: 小宋, 调用新建批号的接口
+        // test:  调用新建批号的接口
         // docs: http://doc.vanlai.net:3001/web/#/1?page_id=59
         // docs: http://doc.vanlai.net:3001/web/#/1?page_id=59
 
 
-        QString url = GlobalInfo::this_()->config().baseUrl+"v1/goods/add";
+        QString url = GlobalInfo::this_()->config()->baseUrl+"v1/goods/add";
         _requst.post(url,info->toObject());
         _requst.post(url,info->toObject());
     } else {
     } else {
         _status = IDIL;
         _status = IDIL;
@@ -73,6 +81,11 @@ void ProjectInfoManger::handleList()
             _cacheInfo.append(info);
             _cacheInfo.append(info);
         }
         }
     }
     }
+    _manger->syncLocalProjectInfo(_cacheInfo);
+    if(_nowJob == 1)
+        emit inited(this,true);
+    else
+        emit synced(this,true);
 }
 }
 
 
 void ProjectInfoManger::result(int code, const QJsonObject & body)
 void ProjectInfoManger::result(int code, const QJsonObject & body)
@@ -148,10 +161,10 @@ void ProjectInfoManger::hanldeServerList(QJsonArray & ary,bool inServer)
         PQ::CacheFile::writeFile("ProjectInfoList.cache",dt);
         PQ::CacheFile::writeFile("ProjectInfoList.cache",dt);
     }
     }
 
 
-    //TODO: 小宋 解析返回的到 _serverInfo
+    //TEST:  解析返回的到 _serverInfo
     // docs: http://doc.vanlai.net:3001/web/#/1?page_id=60
     // docs: http://doc.vanlai.net:3001/web/#/1?page_id=60
     for(int i = 0;i<ary.size();i++){
     for(int i = 0;i<ary.size();i++){
         _serverInfo.append(ProjectInfo::fromObject(ary.at(i).toObject()));
         _serverInfo.append(ProjectInfo::fromObject(ary.at(i).toObject()));
     }
     }
-
+    handleList();
 }
 }

+ 3 - 2
handle/projectinfomanger.h

@@ -7,8 +7,8 @@
 #include "struct_/projectinfo.h"
 #include "struct_/projectinfo.h"
 #include "packinfomanger.h"
 #include "packinfomanger.h"
 #include <QJsonArray>
 #include <QJsonArray>
-// 处理批号的管理和同步
 
 
+// 处理批号的管理和同步
 class ProjectInfoManger : public QObject
 class ProjectInfoManger : public QObject
 {
 {
     Q_OBJECT
     Q_OBJECT
@@ -29,7 +29,7 @@ signals:
     void inited(ProjectInfoManger * manger, bool inited);
     void inited(ProjectInfoManger * manger, bool inited);
     void synced(ProjectInfoManger * manger, bool inited);
     void synced(ProjectInfoManger * manger, bool inited);
 public slots:
 public slots:
-    bool loadServerList();
+    bool loadServerList(bool local);
 
 
     bool syncLocalList();
     bool syncLocalList();
 private slots:
 private slots:
@@ -56,6 +56,7 @@ private:
 
 
     uint _oneSyncError;
     uint _oneSyncError;
     uint _netErrorCount;
     uint _netErrorCount;
+    int _nowJob;
 };
 };
 
 
 #endif // PROJECTINFOMANGER_H
 #endif // PROJECTINFOMANGER_H

+ 4 - 5
handle/remotepackconfig.cpp

@@ -100,8 +100,7 @@ void RemotePackConfig::refConfig()
 {
 {
     getDdengji = false;
     getDdengji = false;
     GlobalInfo * glo = GlobalInfo::this_();
     GlobalInfo * glo = GlobalInfo::this_();
-    if(glo->isNoLine){
-
+    if(glo->isNoLine()){
         auto dt = PQ::CacheFile::readFile("config.cache");
         auto dt = PQ::CacheFile::readFile("config.cache");
         auto obj = QJsonDocument::fromJson(dt).object();
         auto obj = QJsonDocument::fromJson(dt).object();
         result(200,obj);
         result(200,obj);
@@ -113,7 +112,7 @@ void RemotePackConfig::refConfig()
 //    _aid = QString::number(body["user_id"].toInt());
 //    _aid = QString::number(body["user_id"].toInt());
 //    _token = body["access_token"].toString();
 //    _token = body["access_token"].toString();
     _request.setUserToken(QString::number( glo->user().accountId) ,glo->user().acessToken);
     _request.setUserToken(QString::number( glo->user().accountId) ,glo->user().acessToken);
-    QString url = glo->config().baseUrl+"/v1/configuration";
+    QString url = glo->config()->baseUrl+"/v1/configuration";
     _request.get(url);
     _request.get(url);
 }
 }
 
 
@@ -134,7 +133,7 @@ void RemotePackConfig::result(int code, const QJsonObject & body)
             handle(obj);
             handle(obj);
         }
         }
         emit configUpdate(_config);
         emit configUpdate(_config);
-if(!GlobalInfo::this_()->isNoLine){refDengJiList();}
+        if(!GlobalInfo::this_()->isNoLine()){refDengJiList();}
 
 
     } else {
     } else {
         // TODO: 解析等级列表
         // TODO: 解析等级列表
@@ -156,7 +155,7 @@ void RemotePackConfig::refDengJiList()
 {
 {
     getDdengji = true;
     getDdengji = true;
     // todo: http://doc.vanlai.net:3001/web/#/1?page_id=35
     // todo: http://doc.vanlai.net:3001/web/#/1?page_id=35
-    QString url = GlobalInfo::this_()->config().baseUrl+"/v1/level/list";
+    QString url = GlobalInfo::this_()->config()->baseUrl+"/v1/level/list";
     _request.setUserToken(QString::number(GlobalInfo::this_()->user().accountId),GlobalInfo::this_()->user().acessToken);
     _request.setUserToken(QString::number(GlobalInfo::this_()->user().accountId),GlobalInfo::this_()->user().acessToken);
     _request.get(url);
     _request.get(url);
 
 

+ 0 - 57
handle/rtuport.cpp

@@ -1,57 +0,0 @@
-#include "rtuport.h"
-
-RtuPort::RtuPort()
-{
-    m_serialPort = new QSerialPort(this);
-    stard = false;
-    _handle = nullptr;
-    //设置参数
-
-//    m_serialPort->setPortName(GlobalInfo::this_()->config().portName);
-//    m_serialPort->setBaudRate(GlobalInfo::this_()->config().portBaudRate.toInt());//设置默认波特率和读写方向
-//    m_serialPort->setDataBits(QSerialPort::Data8);		//数据位为8位
-//    m_serialPort->setFlowControl(QSerialPort::NoFlowControl);//无流控制
-//    m_serialPort->setParity(QSerialPort::NoParity);	//无校验位
-//    m_serialPort->setStopBits(QSerialPort::OneStop); //一位停止位
-    connect(m_serialPort,SIGNAL(readyRead()),this,SLOT(receiveInfo()));
-
-//    ret = QByteArray::fromHex("010300000006C5C8");
-//    portTimer = new QTimer(this);
-//    connect(portTimer,&QTimer::timeout,this,&RtuPort::portStart);
-//    portTimer->start(1000);
-    timer = new QTimer(this);
-    connect(timer,&QTimer::timeout,this,&RtuPort::portWrite);
-}
-
-void RtuPort::start(QString & name, int band, SerialBaseHandle * handle)
-{
-    if(m_serialPort->isOpen()) m_serialPort->close();
-     m_serialPort->setPortName(name);
-      m_serialPort->setBaudRate(band);
-      _handle = handle;
-      m_serialPort->open(QIODevice::ReadWrite);
-    if(!timer->isActive())
-        timer->start(200);
-    stard = true;
-}
-
-void RtuPort::portWrite()
-{
-    if(!m_serialPort->isOpen()){
-        m_serialPort->open(QIODevice::ReadWrite);
-        return;
-    }
-    if(_handle && _handle->needSend()){
-    m_serialPort->write(_handle->sendData());
-    }
-}
-
-void RtuPort::receiveInfo()
-{
-    QByteArray info = m_serialPort->readAll();
-    if(_handle)
-      _handle->handle(info);
-
-}
-
-

+ 0 - 68
handle/selectspecs.cpp

@@ -1,68 +0,0 @@
-#include "selectspecs.h"
-#include "qjsonarray.h"
-
-SelectSpecs::SelectSpecs()
-{
-    connect(&_request,&HttpRequest::result,this,&SelectSpecs::result);
-}
-
-void SelectSpecs::getInfo(int page, int pageListNum)
-{
-    auto glo = GlobalInfo::this_();
-     auto url = glo->config().baseUrl + QString("/v1/goods/list?page=%1&limit=%2").arg(page).arg(pageListNum);
-     _request.setUserToken(QString::number(GlobalInfo::this_()->user().accountId),GlobalInfo::this_()->user().acessToken);
-     _request.get(url);
-}
-
-void SelectSpecs::result(int code, const QJsonObject & body)
-{
-    if(body.value("code").toInt(404) != 200){
-
-        totleNum = 0;
-        return;
-    }
-    currtInfo.clear();
-    totleNum = body.value("total").toInt();
-    QJsonArray ary = body.value("data").toArray();
-    for(int i =0; i < ary.size(); ++i){
-        parseObject(ary.at(i).toObject());
-    }
-    emit change();
-}
-
-
-void SelectSpecs::parseObject(const QJsonObject & obj)
-{
-    ProjectInfo info;
-    info.dtex = obj.value("detx").toString();
-
-    info.goods_id = obj.value("goods_id").toInt();
-    info.batch_no = obj.value("batch_no").toString();
-    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.dtex = obj.value("detx").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();
-
-    currtInfo.append(info);
-
-}

+ 0 - 31
handle/selectspecs.h

@@ -1,31 +0,0 @@
-#ifndef SELECTSPECS_H
-#define SELECTSPECS_H
-
-#include <QObject>
-#include "configinfo.h"
-#include "httprequest.h"
-#include "globalinfo.h"
-
-class SelectSpecs : public QObject
-{
-    Q_OBJECT
-public:
-    SelectSpecs();
-
-    void getInfo(int page, int pageListNum);
-    void result(int code, const QJsonObject & body);
-    void parseObject(const QJsonObject & obj);
-
-    QList<ProjectInfo>  currtInfo;
-
-signals:
-    void change();
-
-public:
-    int totleNum;
-
-private:
-    HttpRequest _request;
-};
-
-#endif // SELECTSPECS_H

+ 31 - 0
handle/serialthreadhandle.cpp

@@ -0,0 +1,31 @@
+#include "serialthreadhandle.h"
+#include "globalinfo.h"
+
+SerialThreadHandle::SerialThreadHandle(QObject *parent) : QObject(parent),th(nullptr),port(nullptr)
+{
+
+}
+
+
+void SerialThreadHandle::start()
+{
+    if(th == nullptr){
+        th = new QThread(this);
+        connect(th,&QThread::started,this,&SerialThreadHandle::updateConfig);
+        port = new RtuPort(this);
+        auto config = GlobalInfo::this_()->config();
+        connect(config,&ConfigInfo::configUpdate,this,&SerialThreadHandle::updateConfig,Qt::QueuedConnection);
+        this->moveToThread(th);
+        th->start();
+    }
+}
+
+void SerialThreadHandle::updateConfig()
+{
+    if(port == nullptr) return;
+    auto config = GlobalInfo::this_()->config();
+    auto old = port->handle();
+    auto handle = SerialBaseHandle::getHandler(config->portType);// todo:
+    port->start(config->portName,config->portBaudRate.toInt(),handle);
+    if(old) delete old;
+}

+ 25 - 0
handle/serialthreadhandle.h

@@ -0,0 +1,25 @@
+#ifndef SERIALTHREADHANDLE_H
+#define SERIALTHREADHANDLE_H
+
+#include <QObject>
+#include <QThread>
+#include "handle/seriport/rtuport.h"
+
+// 单独线程 处理 称的信息,启动后就不用管了
+class SerialThreadHandle : public QObject
+{
+    Q_OBJECT
+public:
+    explicit SerialThreadHandle(QObject *parent = nullptr);
+
+public slots:
+    void start();
+
+private slots:
+    void updateConfig();
+private:
+    QThread * th;
+    RtuPort * port;
+};
+
+#endif // SERIALTHREADHANDLE_H

+ 1 - 3
handle/seriport/assictscalet2000.cpp

@@ -43,8 +43,6 @@ void AssicTScaleT2000::doHandle(const QByteArray & data)
     }
     }
     if (!dt.isEmpty()) {
     if (!dt.isEmpty()) {
         double token = dt.toDouble();
         double token = dt.toDouble();
-        scaledata _scaledata;
-        _scaledata.gross_widget = token;
-        GlobalInfo::this_()->SetScaleData(_scaledata);
+        GlobalInfo::this_()->currentWidght = token;// (_scaledata);
     }
     }
 }
 }

+ 1 - 3
handle/seriport/logserialport.cpp

@@ -73,7 +73,5 @@ void LogSerialPort::doHandle(const QByteArray & data)
     if(rv < min){
     if(rv < min){
         rv = min;
         rv = min;
     }
     }
-    auto tm = QDateTime::currentDateTime();
-    _scaledata.gross_widget = rv;
-    GlobalInfo::this_()->SetScaleData(_scaledata);
+    GlobalInfo::this_()->currentWidght = rv;
 }
 }

+ 1 - 3
handle/seriport/logserialport.h

@@ -23,8 +23,7 @@ class LogSerialPort : public PQ::RTUHelper, public SerialBaseHandle
 public:
 public:
     explicit LogSerialPort();
     explicit LogSerialPort();
     ~LogSerialPort();
     ~LogSerialPort();
-//    inline bool isStart() const {return started;}
-//    inline bool isOpened() const {return opened;}
+
     float toFloat(const QByteArray & ray);
     float toFloat(const QByteArray & ray);
 
 
     bool needSend();
     bool needSend();
@@ -45,7 +44,6 @@ private:
 
 
     QByteArray _getData;
     QByteArray _getData;
     QByteArray _resetData;
     QByteArray _resetData;
-    scaledata _scaledata;
     QByteArray ret;
     QByteArray ret;
 
 
     double buchang;
     double buchang;

+ 47 - 0
handle/seriport/rtuport.cpp

@@ -0,0 +1,47 @@
+#include "rtuport.h"
+
+RtuPort::RtuPort(QObject *p) : QObject(p)
+{
+    m_serialPort = new QSerialPort(this);
+    stard = false;
+    _handle = nullptr;
+    //设置参数
+
+   connect(m_serialPort,SIGNAL(readyRead()),this,SLOT(receiveInfo()));
+
+    timer = new QTimer(this);
+    connect(timer,&QTimer::timeout,this,&RtuPort::portWrite);
+}
+
+void RtuPort::start(QString & name, int band, SerialBaseHandle * handle)
+{
+    if(m_serialPort->isOpen()) m_serialPort->close();
+     m_serialPort->setPortName(name);
+     m_serialPort->setBaudRate(band);
+    _handle = handle;
+    m_serialPort->open(QIODevice::ReadWrite);
+    if(!timer->isActive())
+        timer->start(200);
+    stard = true;
+}
+
+void RtuPort::portWrite()
+{
+    if(!m_serialPort->isOpen()){
+        m_serialPort->open(QIODevice::ReadWrite);
+        return;
+    }
+    if(_handle && _handle->needSend()){
+    m_serialPort->write(_handle->sendData());
+    }
+}
+
+void RtuPort::receiveInfo()
+{
+    QByteArray info = m_serialPort->readAll();
+    if(_handle)
+      _handle->handle(info);
+
+}
+
+

+ 3 - 1
handle/rtuport.h → handle/seriport/rtuport.h

@@ -14,11 +14,13 @@ class RtuPort : public QObject
     Q_OBJECT
     Q_OBJECT
 
 
 public:
 public:
-    RtuPort();
+    RtuPort(QObject * p);
 
 
     void start(QString & name, int band, SerialBaseHandle * handle);
     void start(QString & name, int band, SerialBaseHandle * handle);
 
 
     inline bool isStart() const {return stard;}
     inline bool isStart() const {return stard;}
+
+    inline  SerialBaseHandle * handle() {return _handle;}
 private slots:
 private slots:
     void receiveInfo();
     void receiveInfo();
     void portWrite();
     void portWrite();

+ 0 - 38
mainwindow.cpp

@@ -21,9 +21,6 @@ MainWindow::MainWindow(QWidget *parent)
     connect(ui->widgetLogin,&LoginForm::SettingsClicked,this,&MainWindow::changeToSettings);
     connect(ui->widgetLogin,&LoginForm::SettingsClicked,this,&MainWindow::changeToSettings);
 //    connect(ui->actionQuanping,&QAction::trigger,[this](){this->showFullScreen();});
 //    connect(ui->actionQuanping,&QAction::trigger,[this](){this->showFullScreen();});
     connect(ui->actionMax,&QAction::trigger,[this](){this->showMaximized();});
     connect(ui->actionMax,&QAction::trigger,[this](){this->showMaximized();});
-    database.openDB();
-    database.createDetailsDatabase();
-    database.createProductDatabase();
     ui->checkBox->hide();
     ui->checkBox->hide();
     ui->dingzhongButton->setChecked(true);
     ui->dingzhongButton->setChecked(true);
 }
 }
@@ -66,24 +63,6 @@ void MainWindow::on_pushConfig_clicked()
 
 
 void MainWindow::pageStatusChange(const ProjectInfo & info, int status)
 void MainWindow::pageStatusChange(const ProjectInfo & info, int status)
 {
 {
-    switch (status) {
-    case 1:
-        ui->stackedWidget->setCurrentWidget(ui->pageAutoPack);
-//        ui->pageAutoPack->setProInfo(info);
-//        ui->pageAutoPack->init();
-        break;
-    case 2:
-        ui->stackedWidget->setCurrentWidget(ui->pageDingZhong);
-        ui->pageDingZhong->setProInfo(info);
-        ui->pageDingZhong->init();
-        break;
-    case 3:
-        ui->stackedWidget->setCurrentWidget(ui->pageBuDing);
-        ui->pageBuDing->setProInfo(info);
-        ui->pageBuDing->init();
-        break;
-
-    }
 }
 }
 
 
 void MainWindow::changeToSettings()
 void MainWindow::changeToSettings()
@@ -93,21 +72,6 @@ void MainWindow::changeToSettings()
 
 
 void MainWindow::backMenu()
 void MainWindow::backMenu()
 {
 {
-    int user = GlobalInfo::this_()->user().userId;
-    if(user==0){
-        ui->stackedWidget->setCurrentWidget(ui->pageLogin);
-        return;
-    }
-//    ui->stackedWidget->setCurrentWidget(ui->pageMain);
-    ui->stackedWidget->setCurrentWidget(ui->pageAutoPack);
-    if(!rtuport.isStart()){
-        auto go = GlobalInfo::this_();
-        ConfigInfo info;
-        info.Start();
-        auto handle = SerialBaseHandle::getHandler(info.portType,"");
-        rtuport.start(info.portName,info.portBaudRate.toInt(),handle);
-        on_dingzhongButton_clicked();
-    }
 }
 }
 
 
 void MainWindow::changedjmb(QImage image)
 void MainWindow::changedjmb(QImage image)
@@ -118,12 +82,10 @@ void MainWindow::changedjmb(QImage image)
 
 
 void MainWindow::on_dingzhongButton_clicked()
 void MainWindow::on_dingzhongButton_clicked()
 {
 {
-    ui->stackedWidget_2->setCurrentWidget(ui->dingzhong);
     ui->dingzhong->init();
     ui->dingzhong->init();
 }
 }
 
 
 void MainWindow::on_budingButton_clicked()
 void MainWindow::on_budingButton_clicked()
 {
 {
-    ui->stackedWidget_2->setCurrentWidget(ui->buding);
     ui->buding->init();
     ui->buding->init();
 }
 }

+ 1 - 3
mainwindow.h

@@ -1,9 +1,8 @@
-#ifndef MAINWINDOW_H
+#ifndef MAINWINDOW_H
 #define MAINWINDOW_H
 #define MAINWINDOW_H
 
 
 #include <QMainWindow>
 #include <QMainWindow>
 #include "configinfo.h"
 #include "configinfo.h"
-#include "handle/database.h"
 #include "handle/rtuport.h"
 #include "handle/rtuport.h"
 
 
 QT_BEGIN_NAMESPACE
 QT_BEGIN_NAMESPACE
@@ -37,7 +36,6 @@ private:
     void backMenu();
     void backMenu();
     void pageStatusChange(const ProjectInfo & info, int status);
     void pageStatusChange(const ProjectInfo & info, int status);
     void changedjmb(QImage image);
     void changedjmb(QImage image);
-    Database database;
     void changeToSettings();
     void changeToSettings();
     RtuPort rtuport;
     RtuPort rtuport;
 
 

+ 1 - 1
mainwindow.ui

@@ -424,7 +424,7 @@ color: rgb(255, 255, 255);</string>
      <x>0</x>
      <x>0</x>
      <y>0</y>
      <y>0</y>
      <width>1033</width>
      <width>1033</width>
-     <height>26</height>
+     <height>30</height>
     </rect>
     </rect>
    </property>
    </property>
    <widget class="QMenu" name="menu">
    <widget class="QMenu" name="menu">

+ 1 - 1
pqQtlib

@@ -1 +1 @@
-Subproject commit 8cd7c8b837f42a918bbe7cde3c9310a8ffedf53f
+Subproject commit 22050c82648c33d17c7b589177061ece37db3fb0

+ 3 - 2
struct_/packinfo.cpp

@@ -102,7 +102,6 @@ QJsonObject PackInfo::toObject()
     ret.insert("net_weight",QString::number(this->net_weight()));
     ret.insert("net_weight",QString::number(this->net_weight()));
     ret.insert("goods_id",QString::number(this->goodsID()));
     ret.insert("goods_id",QString::number(this->goodsID()));
 
 
-    //todo: 小宋 ? _boxes存那里去了?
     ret.insert("quantity",quantity);
     ret.insert("quantity",quantity);
     ret.insert("level_id",level_id);
     ret.insert("level_id",level_id);
     ret.insert("level",level);
     ret.insert("level",level);
@@ -116,6 +115,8 @@ QJsonObject PackInfo::toObject()
     ret.insert("customer",customer);
     ret.insert("customer",customer);
     ret.insert("batch_no",_info->batch_no);
     ret.insert("batch_no",_info->batch_no);
 
 
+    ret.insert("packType",packType);
+
     QJsonArray det;
     QJsonArray det;
     for(int i = 0;i<_boxes.size();i++){
     for(int i = 0;i<_boxes.size();i++){
         det.append(_boxes.at(i)->toObject());
         det.append(_boxes.at(i)->toObject());
@@ -136,7 +137,6 @@ QSharedPointer<PackInfo> PackInfo::fromObject(QJsonObject &obj)
     ret->code_single = code_single;
     ret->code_single = code_single;
     ret->_time = obj.value("time").toString().toLongLong();
     ret->_time = obj.value("time").toString().toLongLong();
 
 
-    //todo: 小宋, _boxes 从那里取?
     ret->quantity = obj.value("quantity").toInt();
     ret->quantity = obj.value("quantity").toInt();
     ret->level_id = obj.value("level_id").toInt();
     ret->level_id = obj.value("level_id").toInt();
     ret->level = obj.value("level").toString();
     ret->level = obj.value("level").toString();
@@ -149,6 +149,7 @@ QSharedPointer<PackInfo> PackInfo::fromObject(QJsonObject &obj)
     ret->telephone = obj.value("telephone").toString();
     ret->telephone = obj.value("telephone").toString();
     ret->customer = obj.value("customer").toString();
     ret->customer = obj.value("customer").toString();
 
 
+    ret->packType = obj.value("packType").toInt();
     QJsonArray det = obj.value("details").toArray();
     QJsonArray det = obj.value("details").toArray();
 
 
     for(int i = 0;i<det.size();i++){
     for(int i = 0;i<det.size();i++){

+ 6 - 0
struct_/packinfo.h

@@ -38,6 +38,8 @@ private:
     friend class PackInfo;
     friend class PackInfo;
 };
 };
 
 
+Q_DECLARE_METATYPE(QSharedPointer<BoxInfo>);
+
 class PackInfo : public QEnableSharedFromThis<PackInfo>
 class PackInfo : public QEnableSharedFromThis<PackInfo>
 {
 {
 public:
 public:
@@ -57,6 +59,8 @@ public:
     QString telephone;// 公司
     QString telephone;// 公司
     QString customer;// 抬头
     QString customer;// 抬头
 
 
+    int packType;//0 定重,1 不定重
+
     inline const QList<QSharedPointer<BoxInfo>> & boxes() const {return _boxes;} //array	成品详情
     inline const QList<QSharedPointer<BoxInfo>> & boxes() const {return _boxes;} //array	成品详情
     inline const QSharedPointer<ProjectInfo> & info() const {return _info;}
     inline const QSharedPointer<ProjectInfo> & info() const {return _info;}
     inline QString codeSingle() const {return code_single;} //string	码单
     inline QString codeSingle() const {return code_single;} //string	码单
@@ -96,4 +100,6 @@ private:
     static int lastNum;
     static int lastNum;
 };
 };
 
 
+Q_DECLARE_METATYPE(QSharedPointer<PackInfo>);
+
 #endif // PACKINFO_H
 #endif // PACKINFO_H

+ 0 - 1
struct_/projectinfo.cpp

@@ -4,7 +4,6 @@
 QJsonObject ProjectInfo::toObject()
 QJsonObject ProjectInfo::toObject()
 {
 {
     QJsonObject ret;
     QJsonObject ret;
-    // TODO: 小宋
     ret.insert("goods_id",goods_id);
     ret.insert("goods_id",goods_id);
     ret.insert("batch_no",batch_no);
     ret.insert("batch_no",batch_no);
     ret.insert("category",category);
     ret.insert("category",category);

+ 5 - 0
struct_/projectinfo.h

@@ -48,8 +48,13 @@ struct ProjectInfo
 
 
     QJsonObject toObject();
     QJsonObject toObject();
 
 
+    bool isLocal = false;
+
     static  QSharedPointer<ProjectInfo> fromObject(const QJsonObject & obj);
     static  QSharedPointer<ProjectInfo> fromObject(const QJsonObject & obj);
 //    QString telephone;//
 //    QString telephone;//
 };
 };
 
 
+
+Q_DECLARE_METATYPE(QSharedPointer<ProjectInfo>);
+
 #endif // PROJECTINFO_H
 #endif // PROJECTINFO_H

+ 0 - 250
widget/autopackform.cpp

@@ -1,250 +0,0 @@
-#include "autopackform.h"
-#include "ui_autopackform.h"
-#include "globalinfo.h"
-#include <QMessageBox>
-#include <QTimer>
-#include <pqQtlib/utils/pqfileutils.h>
-AutoPackForm::AutoPackForm(QWidget *parent) :
-    QWidget(parent),
-    ui(new Ui::AutoPackForm)
-{
-    ui->setupUi(this);
-    QTimer *timer = new QTimer(this);
-    connect(timer,&QTimer::timeout,this,&AutoPackForm::scaleData);
-    timer->start(500);
-    ui->addBoxList->setDisabled(true);
-    ui->addPackList->setDisabled(true);
-    netNum = 0.00;
-    connect(&packConfig,&RemotePackConfig::configUpdate,this,&AutoPackForm::upconfig);
-    connect(&packConfig,&RemotePackConfig::dengJIConfigUp,this,&AutoPackForm::upDengjiInfo);
-//    ui->widgetTotle->hide();
-    auto dt = PQ::CacheFile::readFile("autodingzhongInfo.cache");
-    auto list = QString::fromUtf8(dt).split("[,]");
-    if(list.size() == 2){
-        ui->taitou->setText(list.at(0));
-        ui->taiPhone->setText(list.at(1));
-    }
-}
-
-AutoPackForm::~AutoPackForm()
-{
-    delete ui;
-}
-
-//从秤中获取毛重、皮重、净重、筒数------每100毫秒一次
-void AutoPackForm::scaleData()
-{
-    ui->grossWeight_2->setText(QString::number(GlobalInfo::this_()->GetScaleData().gross_widget));
-    ui->tareWeight_2->setText(QString::number(ui->pizhong->currentText().toDouble()));
-    netNum = ui->grossWeight_2->text().toDouble()-ui->tareWeight_2->text().toDouble();
-    if(netNum<0){
-        netNum = 0.00;
-    }
-    ui->netWeight_2->setText(QString::number(netNum));
-//    ui->tongshu->setText(QString::number(GlobalInfo::this_()->GetScaleData().tongshu));
-}
-
-void AutoPackForm::init()
-{
-    // TODO: 页面进入初始化
-    ui->pushStart->setChecked(false);
-    ui->addBoxList->setDisabled(true);
-    ui->addPackList->setDisabled(true);
-    ui->widget->setEnabled(true);
-    packConfig.refConfig();
-    ui->comboBox->clear();
-    for(int i = 1;i<=20;i++){
-        ui->comboBox->addItem(QString::number(i));
-    }
-    ui->comboBox->setCurrentText("20");
-    on_addPackList_clicked();
-}
-
-//void AutoPackForm::on_tongshuguding_currentIndexChanged(const QString &arg1)
-//{
-//    if(arg1=="固定"){
-//        ui->widget_6->setEnabled(false);
-//        return;
-//    }
-//    ui->widget_6->setEnabled(true);
-//}
-
-void AutoPackForm::on_pushBack_clicked()
-{
-    if(!packinfo.isNull()){
-        aputils.insertProductSQL(packinfo);
-        aputils.doSend(aputils.toJson(packinfo));
-    }
-    emit back();
-    QStringList list;
-    list << ui->taitou->text() <<  ui->taiPhone->text();
-    PQ::CacheFile::writeFile("autodingzhongInfo.cache",list.join("[,]").toUtf8());
-}
-
-void AutoPackForm::on_addPackList_clicked()
-{
-    if(!packinfo.isNull()&&packinfo->boxes().size()>0){
-        //packinfo其他数据在new时已经定义好的,需要时直接调就可以了,所以这里只要箱数,等级,机台和类型
-        packinfo->quantity = packinfo->boxes().size();
-        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();
-    }
-
-
-//    qDebug()<<aputils.toJson(packinfo);
-
-    //把数据添加到数据库里
-    aputils.insertProductSQL(packinfo);
-    //TODO: 缓存箱单数据,页面显示情空
-
-    //发送码单 packinfo 数据, 转换为 json数据发送
-    aputils.doSend(aputils.toJson(packinfo));
-    packinfo.clear();
-}
-
-void AutoPackForm::on_pushStart_clicked()
-{
-//    _info.customer = ui->taitou->text();
-//    _info.telephone = ui->taiPhone->text();
-    if(ui->pushStart->isChecked()){
-        ui->pushStart->setChecked(true);
-        ui->addBoxList->setDisabled(false);
-        ui->addPackList->setDisabled(false);
-        ui->widget->setEnabled(false);
-        ui->handleRead->setEnabled(true);
-    } else {
-        init();
-    }
-}
-
-void AutoPackForm::on_addBoxList_clicked()
-{
-        if(ui->tongshu->text()!="0"&&!ui->tongshu->text().toInt()){
-            QMessageBox::information(this,tr("注意"),tr("筒数异常"));
-            return;
-        }
-        if(ui->netWeight_2->text().at(0)=="-"){
-            QMessageBox::information(this,tr("注意"),tr("打包数据异常"));
-            return;
-        }
-
-    if(packinfo.isNull()){
-        packinfo.reset(new PackInfo(_info));
-        packinfo->operator_id = GlobalInfo::this_()->user().userId;
-        packinfo->packing_time = QDate::currentDate().toString("yy-MM-dd");
-        packinfo->packing_type = _info.category;
-        ui->tableWidget->clearContents();
-        ui->tableWidget->setRowCount(0);
-        ui->tableWidget->setColumnWidth(0,20);
-        ui->tableWidget->setColumnWidth(1,20);
-        ui->tableWidget->setColumnWidth(2,80);
-        ui->tableWidget->setColumnWidth(3,80);
-        ui->tableWidget->setColumnWidth(4,80);
-        ui->tableWidget->setColumnWidth(5,40);
-    }
-    auto box = packinfo->addBoxInfo();
-    //TODO: 添加箱单 数据
-    box->box_weight = int(ui->pizhong->currentText().toDouble()*1000);
-    box->tube_number = ui->tongshu->text().toInt();
-    box->bucket_weight = int(ui->pizhong->currentText().toInt()*ui->tongshu->text().toDouble()*1000);
-    box->gross_weight = int(ui->grossWeight_2->text().toDouble()*1000);
-    box->net_weight = int(ui->netWeight_2->text().toDouble()*1000);
-    box->Level = ui->dengji->currentText();
-    box->twist_type = ui->nianxiang->currentText();
-    box->bucket_color = ui->guanse->currentText();
-    box->sort = "1";
-    box->remark = ui->beizhu->toPlainText();
-    packinfo->level = ui->dengji->currentText();
-    packinfo->level_id = ui->dengji->currentData().toInt();
-
-    //TODO: 缓存数据,显示数据
-    ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+1);
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,0,new QTableWidgetItem(QString::number(ui->tableWidget->rowCount())));
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,1,new QTableWidgetItem(QString::number(box->tube_number)));
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,2,new QTableWidgetItem(QString::number(box->gross_weight / 1000.00)));
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,3,new QTableWidgetItem(QString::number(box->box_weight / 1000.00)));
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,4,new QTableWidgetItem(QString::number(box->net_weight / 1000.00)));
-    ui->tableWidget->setItem(ui->tableWidget->rowCount()-1,5,new QTableWidgetItem(box->caseNumber()));
-
-
-//    把box数据添加到packinfo的boxes数据表里;
-    packinfo->addBoxInfoList(box);
-
-    //添加数据库
-    aputils.insertDetailsSQL(box,packinfo->codeSingle());
-
-    ui->labelTongZHong->setText(QString::number(packinfo->tube_number()));
-    ui->labelWight->setText(getDecimalbit(packinfo->gross_weight() / 1000.00));
-    ui->labelJing->setText(getDecimalbit(packinfo->net_weight() / 1000.00));
-
-    //当当前箱数大于等于最大箱数是启动on_addPackList_clicked();
-    if(packinfo->boxes().size()>=ui->comboBox->currentText().toInt()){
-        on_addPackList_clicked();
-    }
-
-}
-
-void AutoPackForm::upconfig(const DaBaoConfig &config)
-{
-
-    qDebug()<<"这里";
-    // TODO:打包配置更新
-    //机台
-    ui->jitai->clear();
-    ui->jitai->addItems(config.jitai);
-
-    //打包工班次
-    ui->comboBox_2->clear();
-    ui->comboBox_2->addItems(config.daBaoGongBanCi);
-
-    //皮重
-    ui->pizhong->clear();
-    for(int i = 0;i<config.xiangzhong.size();i++){
-        ui->pizhong->addItem(QString::number(config.xiangzhong.at(i)));
-    }
-
-    //管色
-    ui->guanse->clear();
-    ui->guanse->addItems(config.guanse);
-
-    //捻向
-    ui->nianxiang->clear();
-    ui->nianxiang->addItems(config.nianxiang);
-
-    //纸箱
-    ui->zhixiang->clear();
-    ui->zhixiang->addItems(config.zhixiang);
-
-    //筒重
-    ui->tongzhong->clear();
-    for(int i = 0;i<config.tongZhong.size();i++){
-        ui->tongzhong->addItem(QString::number(config.tongZhong.at(i)));
-    }
-
-    //设置选择打包界面的数据为首个;
-    ui->pizhong->setCurrentText(QString(_info.box_weight));
-    ui->guanse->setCurrentText(_info.bucket_color);
-    ui->zhixiang->setCurrentText(_info.carton_type);
-    ui->tongzhong->setCurrentText(_info.bucket_weight);
-}
-
-void AutoPackForm::upDengjiInfo(const QList<DengJiConfigItem> & dengJis)
-{
-// TODO: 等级信息更新
-    ui->dengji->clear();
-    for(int i = 0;i<dengJis.size();i++){
-        if(!dengJis.at(i).isEnable){
-            ui->dengji->addItem(dengJis.at(i).value,dengJis.at(i).id);
-        }
-    }
-}
-
-void AutoPackForm::on_handleRead_clicked()
-{
-    scaleData();
-}
-
-

+ 0 - 74
widget/autopackform.h

@@ -1,74 +0,0 @@
-#ifndef AUTOPACKFORM_H
-#define AUTOPACKFORM_H
-
-#include <QWidget>
-#include "globalinfo.h"
-#include "handle/remotepackconfig.h"
-#include "struct_/packinfo.h"
-//#include "httprequestid.h"
-#include "handle/danjumuban.h"
-#include "handle/database.h"
-#include "handle/autopackutils.h"
-#include "QTimer"
-
-namespace Ui {
-class AutoPackForm;
-}
-// NOTE:页面逻辑部份注意耦合,页面可能重用
-class AutoPackForm : public QWidget
-{
-    Q_OBJECT
-
-public:
-    explicit AutoPackForm(QWidget *parent = nullptr);
-    ~AutoPackForm();
-
-    inline void setProInfo(const ProjectInfo & info){_info = info;}
-
-public slots:
-    void upconfig(const DaBaoConfig & config);
-    void upDengjiInfo(const QList<DengJiConfigItem> & dengJis);
-    void init();
-
-signals:
-    void back();
-    void djmbbox(QImage image);
-
-private slots:
-    void on_pushBack_clicked();
-
-    void on_addPackList_clicked();
-
-
-//    void doSend(QSharedPointer<PackInfo> & info);
-    void on_pushStart_clicked();
-
-    void on_addBoxList_clicked();
-//    void httpResult(int emitcode, const QJsonObject body);
-
-//    void insertDetailsSQL(QSharedPointer<BoxInfo> boxes,QString codeSingle);
-//    void insertProductSQL(QSharedPointer<PackInfo> packes);
-//    QJsonObject toJson(QSharedPointer<PackInfo> &info);
-
-//    void packData();
-
-
-    void on_handleRead_clicked();
-
-private:
-    Ui::AutoPackForm *ui;
-    ProjectInfo _info;
-    QSharedPointer<PackInfo> packinfo;
-    QMap<QString,DengJiConfigItem> dengjiMap;// <name,详细信息>
-    RemotePackConfig packConfig;
-    HttpRequest _request;
-    DanJuMuBan djmb;
-    AutoPackUtils aputils;
-
-    double netNum;
-
-    void scaleData();
-
-};
-
-#endif // AUTOPACKFORM_H

+ 0 - 807
widget/autopackform.ui

@@ -1,807 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>AutoPackForm</class>
- <widget class="QWidget" name="AutoPackForm">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>1087</width>
-    <height>677</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Form</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout_3">
-   <property name="leftMargin">
-    <number>11</number>
-   </property>
-   <property name="topMargin">
-    <number>11</number>
-   </property>
-   <item>
-    <widget class="QWidget" name="widget_4" native="true">
-     <property name="minimumSize">
-      <size>
-       <width>0</width>
-       <height>30</height>
-      </size>
-     </property>
-     <layout class="QHBoxLayout" name="horizontalLayout_9">
-      <property name="topMargin">
-       <number>0</number>
-      </property>
-      <property name="bottomMargin">
-       <number>0</number>
-      </property>
-      <item>
-       <widget class="QPushButton" name="pushBack">
-        <property name="text">
-         <string>&lt;返回主页</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <spacer name="horizontalSpacer_2">
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>452</width>
-          <height>20</height>
-         </size>
-        </property>
-       </spacer>
-      </item>
-      <item>
-       <widget class="QLabel" name="label_20">
-        <property name="text">
-         <string>自动打包</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <spacer name="horizontalSpacer_3">
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>451</width>
-          <height>20</height>
-         </size>
-        </property>
-       </spacer>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
-    <widget class="QWidget" name="widget_3" native="true">
-     <property name="styleSheet">
-      <string notr="true">background-color: rgb(0, 170, 255);</string>
-     </property>
-     <layout class="QHBoxLayout" name="horizontalLayout_15">
-      <item>
-       <layout class="QVBoxLayout" name="verticalLayout">
-        <property name="spacing">
-         <number>0</number>
-        </property>
-        <item>
-         <layout class="QHBoxLayout" name="horizontalLayout_2">
-          <item>
-           <widget class="QLabel" name="label_8">
-            <property name="minimumSize">
-             <size>
-              <width>0</width>
-              <height>20</height>
-             </size>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>16777215</width>
-              <height>30</height>
-             </size>
-            </property>
-            <property name="text">
-             <string>毛重(千克/kg)</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QLabel" name="label_14">
-            <property name="minimumSize">
-             <size>
-              <width>0</width>
-              <height>20</height>
-             </size>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>16777215</width>
-              <height>30</height>
-             </size>
-            </property>
-            <property name="text">
-             <string>皮重(千克/kg)</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QLabel" name="label_9">
-            <property name="minimumSize">
-             <size>
-              <width>0</width>
-              <height>20</height>
-             </size>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>16777215</width>
-              <height>30</height>
-             </size>
-            </property>
-            <property name="text">
-             <string>筒数</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QLabel" name="label_15">
-            <property name="minimumSize">
-             <size>
-              <width>0</width>
-              <height>20</height>
-             </size>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>16777215</width>
-              <height>30</height>
-             </size>
-            </property>
-            <property name="text">
-             <string>净重(千克/kg)</string>
-            </property>
-           </widget>
-          </item>
-         </layout>
-        </item>
-        <item>
-         <layout class="QHBoxLayout" name="horizontalLayout_4">
-          <item>
-           <widget class="QLineEdit" name="grossWeight_2">
-            <property name="minimumSize">
-             <size>
-              <width>100</width>
-              <height>100</height>
-             </size>
-            </property>
-            <property name="font">
-             <font>
-              <pointsize>20</pointsize>
-             </font>
-            </property>
-            <property name="text">
-             <string>0</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QLineEdit" name="tareWeight_2">
-            <property name="minimumSize">
-             <size>
-              <width>100</width>
-              <height>100</height>
-             </size>
-            </property>
-            <property name="font">
-             <font>
-              <pointsize>20</pointsize>
-             </font>
-            </property>
-            <property name="text">
-             <string>0</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QLineEdit" name="tongshu">
-            <property name="minimumSize">
-             <size>
-              <width>100</width>
-              <height>100</height>
-             </size>
-            </property>
-            <property name="font">
-             <font>
-              <pointsize>20</pointsize>
-             </font>
-            </property>
-            <property name="text">
-             <string>0</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QLineEdit" name="netWeight_2">
-            <property name="minimumSize">
-             <size>
-              <width>100</width>
-              <height>100</height>
-             </size>
-            </property>
-            <property name="font">
-             <font>
-              <pointsize>20</pointsize>
-             </font>
-            </property>
-            <property name="text">
-             <string>0</string>
-            </property>
-           </widget>
-          </item>
-         </layout>
-        </item>
-       </layout>
-      </item>
-      <item>
-       <layout class="QVBoxLayout" name="verticalLayout_2">
-        <item>
-         <widget class="QPushButton" name="pushStart">
-          <property name="minimumSize">
-           <size>
-            <width>0</width>
-            <height>50</height>
-           </size>
-          </property>
-          <property name="styleSheet">
-           <string notr="true">background-color: rgb(255, 255, 255);
-color: rgb(0, 170, 255);</string>
-          </property>
-          <property name="text">
-           <string>开始打包</string>
-          </property>
-          <property name="checkable">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <layout class="QHBoxLayout" name="horizontalLayout_8">
-          <item>
-           <widget class="QPushButton" name="addBoxList">
-            <property name="enabled">
-             <bool>true</bool>
-            </property>
-            <property name="minimumSize">
-             <size>
-              <width>0</width>
-              <height>50</height>
-             </size>
-            </property>
-            <property name="styleSheet">
-             <string notr="true">background-color: rgb(255, 255, 255);
-color: rgb(0, 170, 255);</string>
-            </property>
-            <property name="text">
-             <string>添加箱单</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QPushButton" name="addPackList">
-            <property name="enabled">
-             <bool>true</bool>
-            </property>
-            <property name="minimumSize">
-             <size>
-              <width>0</width>
-              <height>50</height>
-             </size>
-            </property>
-            <property name="styleSheet">
-             <string notr="true">background-color: rgb(255, 255, 255);
-color: rgb(0, 170, 255);</string>
-            </property>
-            <property name="text">
-             <string>添加码单</string>
-            </property>
-           </widget>
-          </item>
-         </layout>
-        </item>
-       </layout>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
-    <widget class="QWidget" name="widgetTotle" native="true">
-     <layout class="QHBoxLayout" name="horizontalLayout">
-      <item>
-       <layout class="QHBoxLayout" name="horizontalLayout_3">
-        <item>
-         <widget class="QLabel" name="label_16">
-          <property name="text">
-           <string>筒重:</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="labelTongZHong">
-          <property name="text">
-           <string>0</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="label_17">
-          <property name="text">
-           <string>毛重:</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="labelWight">
-          <property name="text">
-           <string>0</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="label_18">
-          <property name="text">
-           <string>净重:</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLabel" name="labelJing">
-          <property name="text">
-           <string>0</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <spacer name="horizontalSpacer">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>40</width>
-            <height>20</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-       </layout>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_5">
-     <property name="spacing">
-      <number>0</number>
-     </property>
-     <item>
-      <widget class="QTableWidget" name="tableWidget">
-       <property name="minimumSize">
-        <size>
-         <width>562</width>
-         <height>0</height>
-        </size>
-       </property>
-       <property name="maximumSize">
-        <size>
-         <width>9999</width>
-         <height>16777215</height>
-        </size>
-       </property>
-       <column>
-        <property name="text">
-         <string>序号</string>
-        </property>
-       </column>
-       <column>
-        <property name="text">
-         <string>筒数</string>
-        </property>
-       </column>
-       <column>
-        <property name="text">
-         <string>毛重</string>
-        </property>
-       </column>
-       <column>
-        <property name="text">
-         <string>皮重</string>
-        </property>
-       </column>
-       <column>
-        <property name="text">
-         <string>净重</string>
-        </property>
-       </column>
-       <column>
-        <property name="text">
-         <string>箱号</string>
-        </property>
-       </column>
-      </widget>
-     </item>
-     <item>
-      <widget class="QWidget" name="widget" native="true">
-       <property name="minimumSize">
-        <size>
-         <width>450</width>
-         <height>402</height>
-        </size>
-       </property>
-       <layout class="QVBoxLayout" name="verticalLayout_16">
-        <item>
-         <layout class="QHBoxLayout" name="horizontalLayout_10">
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_4">
-            <item>
-             <widget class="QLabel" name="label">
-              <property name="text">
-               <string>码数</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="comboBox">
-              <property name="editable">
-               <bool>true</bool>
-              </property>
-              <property name="currentText">
-               <string/>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QHBoxLayout" name="horizontalLayout_6">
-            <property name="spacing">
-             <number>0</number>
-            </property>
-            <item>
-             <widget class="QLabel" name="label_23">
-              <property name="maximumSize">
-               <size>
-                <width>30</width>
-                <height>16777215</height>
-               </size>
-              </property>
-              <property name="text">
-               <string>筒重</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="comboBox_3">
-              <property name="maximumSize">
-               <size>
-                <width>80</width>
-                <height>16777215</height>
-               </size>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QHBoxLayout" name="horizontalLayout_7">
-            <property name="spacing">
-             <number>0</number>
-            </property>
-            <item>
-             <widget class="QCheckBox" name="autoRead">
-              <property name="minimumSize">
-               <size>
-                <width>71</width>
-                <height>41</height>
-               </size>
-              </property>
-              <property name="text">
-               <string>自动读数</string>
-              </property>
-              <property name="checked">
-               <bool>true</bool>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QPushButton" name="handleRead">
-              <property name="minimumSize">
-               <size>
-                <width>71</width>
-                <height>41</height>
-               </size>
-              </property>
-              <property name="text">
-               <string>手动读数</string>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </item>
-         </layout>
-        </item>
-        <item>
-         <layout class="QHBoxLayout" name="horizontalLayout_11">
-          <item>
-           <widget class="QCheckBox" name="xiangdanPrint">
-            <property name="text">
-             <string>打印箱单</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QCheckBox" name="madanPrint">
-            <property name="text">
-             <string>打印码单</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QCheckBox" name="showMaoZhong">
-            <property name="text">
-             <string>显示毛重</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QCheckBox" name="autoPush">
-            <property name="text">
-             <string>6筒自动打包</string>
-            </property>
-           </widget>
-          </item>
-         </layout>
-        </item>
-        <item>
-         <layout class="QHBoxLayout" name="horizontalLayout_13">
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_5">
-            <item>
-             <widget class="QLabel" name="label_2">
-              <property name="text">
-               <string>打包班次</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="comboBox_2"/>
-            </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_6">
-            <item>
-             <widget class="QLabel" name="label_3">
-              <property name="text">
-               <string>机台</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="jitai"/>
-            </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_7">
-            <item>
-             <widget class="QLabel" name="label_4">
-              <property name="text">
-               <string>等级</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="dengji"/>
-            </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_8">
-            <item>
-             <widget class="QLabel" name="label_5">
-              <property name="text">
-               <string>皮重</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="pizhong"/>
-            </item>
-           </layout>
-          </item>
-         </layout>
-        </item>
-        <item>
-         <layout class="QHBoxLayout" name="horizontalLayout_14">
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_9">
-            <item>
-             <widget class="QLabel" name="label_6">
-              <property name="text">
-               <string>管色</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="guanse"/>
-            </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_10">
-            <item>
-             <widget class="QLabel" name="label_7">
-              <property name="text">
-               <string>捻向</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="nianxiang"/>
-            </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_11">
-            <item>
-             <widget class="QLabel" name="label_10">
-              <property name="text">
-               <string>纸箱</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="zhixiang"/>
-            </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_12">
-            <item>
-             <widget class="QLabel" name="label_21">
-              <property name="text">
-               <string>筒重</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="tongzhong"/>
-            </item>
-           </layout>
-          </item>
-         </layout>
-        </item>
-        <item>
-         <layout class="QHBoxLayout" name="horizontalLayout_12">
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_13">
-            <item>
-             <widget class="QLabel" name="label_12">
-              <property name="text">
-               <string>码单</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="madan">
-              <property name="enabled">
-               <bool>false</bool>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QLabel" name="label_11">
-              <property name="text">
-               <string>箱单</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QComboBox" name="xiangdan">
-              <property name="enabled">
-               <bool>false</bool>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <spacer name="verticalSpacer">
-              <property name="orientation">
-               <enum>Qt::Vertical</enum>
-              </property>
-              <property name="sizeHint" stdset="0">
-               <size>
-                <width>20</width>
-                <height>40</height>
-               </size>
-              </property>
-             </spacer>
-            </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_14">
-            <item>
-             <widget class="QLabel" name="label_13">
-              <property name="text">
-               <string>箱单抬头</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QLineEdit" name="taitou"/>
-            </item>
-            <item>
-             <widget class="QLabel" name="label_22">
-              <property name="text">
-               <string>电话</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QLineEdit" name="taiPhone"/>
-            </item>
-            <item>
-             <spacer name="verticalSpacer_2">
-              <property name="orientation">
-               <enum>Qt::Vertical</enum>
-              </property>
-              <property name="sizeHint" stdset="0">
-               <size>
-                <width>20</width>
-                <height>40</height>
-               </size>
-              </property>
-             </spacer>
-            </item>
-           </layout>
-          </item>
-          <item>
-           <layout class="QVBoxLayout" name="verticalLayout_15">
-            <item>
-             <widget class="QLabel" name="label_19">
-              <property name="text">
-               <string>备注</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QTextEdit" name="beizhu"/>
-            </item>
-           </layout>
-          </item>
-         </layout>
-        </item>
-       </layout>
-      </widget>
-     </item>
-    </layout>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>

+ 1 - 6
widget/fixedweightpackform.cpp

@@ -14,7 +14,6 @@ FixedWeightPackForm::FixedWeightPackForm(QWidget *parent) :
     timer->start(500);
     timer->start(500);
     connect(&packConfig,&RemotePackConfig::configUpdate,this,&FixedWeightPackForm::upconfig);
     connect(&packConfig,&RemotePackConfig::configUpdate,this,&FixedWeightPackForm::upconfig);
     connect(&packConfig,&RemotePackConfig::dengJIConfigUp,this,&FixedWeightPackForm::upDengjiInfo);
     connect(&packConfig,&RemotePackConfig::dengJIConfigUp,this,&FixedWeightPackForm::upDengjiInfo);
-    connect(&specs,&SelectSpecs::change,this,&FixedWeightPackForm::changeSpecs);
     auto dt = CacheFile::readFile("dingzhongInfo.cache");
     auto dt = CacheFile::readFile("dingzhongInfo.cache");
     auto list = QString::fromUtf8(dt).split("[,]");
     auto list = QString::fromUtf8(dt).split("[,]");
     if(list.size() == 2){
     if(list.size() == 2){
@@ -33,7 +32,7 @@ FixedWeightPackForm::~FixedWeightPackForm()
 //从秤中获取毛重、皮重、净重、筒数------每100毫秒一次
 //从秤中获取毛重、皮重、净重、筒数------每100毫秒一次
 void FixedWeightPackForm::calcData()
 void FixedWeightPackForm::calcData()
 {
 {
-    ui->grossWeight_2->setText(QString::number(GlobalInfo::this_()->GetScaleData().gross_widget));
+
 //    ui->grossWeight_2->setText(ui->type->currentText());
 //    ui->grossWeight_2->setText(ui->type->currentText());
     netNum = ui->grossWeight_2->text().toDouble()-ui->pizhong->currentText().toDouble()-ui->tongshu->text().toDouble()*ui->tongzhong->currentText().toDouble();
     netNum = ui->grossWeight_2->text().toDouble()-ui->pizhong->currentText().toDouble()-ui->tongshu->text().toDouble()*ui->tongzhong->currentText().toDouble();
     if(netNum<0){
     if(netNum<0){
@@ -46,10 +45,6 @@ void FixedWeightPackForm::calcData()
 
 
 void FixedWeightPackForm::on_pushBack_clicked()
 void FixedWeightPackForm::on_pushBack_clicked()
 {
 {
-    if(!packinfo.isNull()){
-        aputils.insertProductSQL(packinfo);
-        aputils.doSend(aputils.toJson(packinfo));
-    }
     emit back();
     emit back();
     QStringList list;
     QStringList list;
     list << ui->taitou->text() <<  ui->taiPhone->text();
     list << ui->taitou->text() <<  ui->taiPhone->text();

+ 0 - 6
widget/fixedweightpackform.h

@@ -3,13 +3,9 @@
 
 
 #include <QWidget>
 #include <QWidget>
 #include "handle/remotepackconfig.h"
 #include "handle/remotepackconfig.h"
-#include "packinfo.h"
 //#include "httprequestid.h"
 //#include "httprequestid.h"
 #include "handle/danjumuban.h"
 #include "handle/danjumuban.h"
-#include "handle/database.h"
-#include "handle/autopackutils.h"
 #include "QTimer"
 #include "QTimer"
-#include "handle/selectspecs.h"
 
 
 namespace Ui {
 namespace Ui {
 class FixedWeightPackForm;
 class FixedWeightPackForm;
@@ -65,8 +61,6 @@ private:
     HttpRequest _request;
     HttpRequest _request;
     DanJuMuBan djmb;
     DanJuMuBan djmb;
     double netNum = 0.00;
     double netNum = 0.00;
-    AutoPackUtils aputils;
-    SelectSpecs specs;
     int row;
     int row;
 };
 };
 
 

+ 1 - 1
widget/loginform.cpp

@@ -100,7 +100,7 @@ void LoginForm::result(int code, const QJsonObject & body)
     user.headPortrait = data["head_portrait"].toString();
     user.headPortrait = data["head_portrait"].toString();
     user.isVip = data["is_vip"].toInt(-1) == 1 ? true : false;
     user.isVip = data["is_vip"].toInt(-1) == 1 ? true : false;
     user.acessToken = data["access_token"].toString();
     user.acessToken = data["access_token"].toString();
-    GlobalInfo::this_()->setUser(user);
+//    GlobalInfo::this_()->setUser(user);
     emit loginFinish();
     emit loginFinish();
 }
 }
 
 

+ 6 - 6
widget/packdetailform.cpp

@@ -42,12 +42,12 @@ void PackDetailForm::on_pushButton_clicked()
     }
     }
         condition.append("limit 0,20");
         condition.append("limit 0,20");
 //        qDebug()<<condition;
 //        qDebug()<<condition;
-    changeTreeWidget(database.GetValues("product",productSqlList,/*"limit 0,20"*/condition));
-//    ui->pagesNum->setText(QString::number(pageNum)+"/"+QString::number(product.size()/20));
-    int pageListNum = database.GetTablePage();
-    pageNumAll = pageListNum / 20;
-    if(pageListNum % 20 > 0)
-        pageNumAll ++;
+//    changeTreeWidget(database.GetValues("product",productSqlList,/*"limit 0,20"*/condition));
+////    ui->pagesNum->setText(QString::number(pageNum)+"/"+QString::number(product.size()/20));
+//    int pageListNum = database.GetTablePage();
+//    pageNumAll = pageListNum / 20;
+//    if(pageListNum % 20 > 0)
+//        pageNumAll ++;
     ui->pagesNum->setText(QString("%1/%2").arg(nowPageNum+1).arg(pageNumAll));
     ui->pagesNum->setText(QString("%1/%2").arg(nowPageNum+1).arg(pageNumAll));
 }
 }
 
 

+ 2 - 7
widget/packdetailform.h

@@ -1,13 +1,10 @@
-#ifndef PACKDETAILFORM_H
+#ifndef PACKDETAILFORM_H
 #define PACKDETAILFORM_H
 #define PACKDETAILFORM_H
 
 
 #include <QWidget>
 #include <QWidget>
 //#include "handle/remotepackconfig.h"
 //#include "handle/remotepackconfig.h"
-#include "handle/database.h"
 #include "QMessageBox"
 #include "QMessageBox"
 #include "QTreeWidget"
 #include "QTreeWidget"
-#include "packinfo.h"
-#include "autopackform.h"
 #include "handle/danjumuban.h"
 #include "handle/danjumuban.h"
 
 
 namespace Ui {
 namespace Ui {
@@ -48,14 +45,12 @@ signals:
 
 
 private:
 private:
     Ui::PackDetailForm *ui;
     Ui::PackDetailForm *ui;
-//    RemotePackConfig packConfig;
-    Database database;
+
     QList<QMap<QString,QString>> product;
     QList<QMap<QString,QString>> product;
     QList<QMap<QString,QString>> details;
     QList<QMap<QString,QString>> details;
     QStringList productSqlList;
     QStringList productSqlList;
     QStringList detailSqlList;
     QStringList detailSqlList;
     QSharedPointer<PackInfo> packinfo;
     QSharedPointer<PackInfo> packinfo;
-    AutoPackUtils autoPack;
     DanJuMuBan djmb;
     DanJuMuBan djmb;
     int nowPageNum;
     int nowPageNum;
     int pageNumAll;
     int pageNumAll;

+ 1 - 2
widget/selectvalueform.h

@@ -9,6 +9,7 @@ namespace Ui {
 class SelectValueForm;
 class SelectValueForm;
 }
 }
 
 
+//TODO: 小宋 从GlobalInfo::this_()->project().values() 取出所有,保存,然后自己保存下标在上层做分页
 class SelectValueForm : public QWidget
 class SelectValueForm : public QWidget
 {
 {
     Q_OBJECT
     Q_OBJECT
@@ -22,7 +23,6 @@ public:
     inline void setStatus(int staus){status = staus;}
     inline void setStatus(int staus){status = staus;}
 signals:
 signals:
     void back();
     void back();
-    void selectProject(const ProjectInfo & info, int status);
 
 
 
 
 private slots:
 private slots:
@@ -47,7 +47,6 @@ private:
     int pageListNum;
     int pageListNum;
     int totlePage;
     int totlePage;
     int totleNum;
     int totleNum;
-    QList<ProjectInfo>  currtInfo;
     HttpRequest _request;
     HttpRequest _request;
     int status;
     int status;
 };
 };