error hace 6 años
padre
commit
367344dd7d

+ 8 - 0
JxcClient.pro

@@ -23,7 +23,11 @@ SOURCES += \
     handle/danjumuban.cpp \
     handle/database.cpp \
     handle/httprequest.cpp \
+    handle/logserialport.cpp \
     handle/remotepackconfig.cpp \
+    handle/rtuport.cpp \
+    handle/utils/rtuhelper.cpp \
+    handle/utils/utilsfunc.cpp \
     packinfo.cpp \
     widget/autopackform.cpp \
     widget/loginform.cpp \
@@ -41,7 +45,11 @@ HEADERS += \
     handle/danjumuban.h \
     handle/database.h \
     handle/httprequest.h \
+    handle/logserialport.h \
     handle/remotepackconfig.h \
+    handle/rtuport.h \
+    handle/utils/rtuhelper.h \
+    handle/utils/utilsfunc.h \
     packinfo.h \
     widget/autopackform.h \
     widget/loginform.h \

+ 6 - 8
configinfo.cpp

@@ -2,15 +2,8 @@
 
 ConfigInfo::ConfigInfo()
 {
-//    baseUrl = "http://erp.itwsw.cn/api";
-
     packId = 1031;
-
-//    printerName = "Deli DL-820T";
-
-//    Init();
     Start();
-
 }
 
 void ConfigInfo::Start()
@@ -36,6 +29,11 @@ void ConfigInfo::Start()
 
         //硬件
         printerName = Get("hardware","printerName").toString();//打印机名称
+
+        //电子秤
+        portName = Get("ElectronicScale","portName").toString();//串口名称
+        portBaudRate = Get("ElectronicScale","portBaudRate").toString();//串口波特率
+
 //   }else{
 //        qDebug()<<"配置文件不存在";
 //        //url接口地址
@@ -45,7 +43,7 @@ void ConfigInfo::Start()
 //        Set("user","packId",1031);
 
 //        //硬件
-        Set("hardware","printerName","Deli DL-820T");
+//        Set("hardware","printerName","Deli DL-820T");
 //   }
 }
 

+ 3 - 2
configinfo.h

@@ -15,8 +15,9 @@ public:
 
     QString baseUrl;//服务器接口地址
     quint16 packId;
-    QString printerName;
-
+    QString printerName; //打印机名称
+    QString portName; //电子秤串口名称
+    QString portBaudRate; //电子秤串口波特率
 
 //    QString autoPackUrl;//待入库产品添加接口
 

+ 7 - 2
handle/autopackutils.cpp

@@ -65,6 +65,7 @@ void AutoPackUtils::insertDetailsSQL(QSharedPointer<BoxInfo> boxes,QString codeS
 void AutoPackUtils::insertProductSQL(QSharedPointer<PackInfo> packes)
 {
     if(packes.isNull()) return;
+    if(packes->boxes().isEmpty()) return;
 
     productData.goods_id = packes->goodsID();
     productData.code_single = packes->codeSingle();
@@ -80,6 +81,7 @@ void AutoPackUtils::insertProductSQL(QSharedPointer<PackInfo> packes)
     productData.packing_type = packes->packing_type;
     productData.carton_type = packes->carton_type;
     productData.operator_id = packes->operator_id;
+    productData.specs = packes->info().specs;
     productData.remark = packes->remark;
 
     if(database.insertProduct(productData)){
@@ -96,10 +98,13 @@ QJsonObject AutoPackUtils::toJson(QSharedPointer<PackInfo> &info)
 {
 
     QJsonObject json;
-    QJsonObject detailsjson;
-    QJsonArray jsonarray;
+    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);

+ 84 - 76
handle/danjumuban.cpp

@@ -5,7 +5,7 @@
 
 DanJuMuBan::DanJuMuBan()
 {
- //   path = QDir::currentPath();
+    path = QDir::currentPath();
 }
 
 QImage DanJuMuBan::printBoxInfo(QString bar,QSharedPointer<BoxInfo> info)
@@ -81,31 +81,26 @@ QImage DanJuMuBan::printBoxInfo(QString bar,QSharedPointer<BoxInfo> info)
 
 //    painter.drawText(4*5,75*5," 电话"+telephone+"传真"+fax);
 
-//    print(image);
+    print(image);
     return image;
 
-//    image.save(path+"\\xiangdan\\code"+bar+".bmp");
+    image.save(path+"\\xiangdan\\code"+bar+".bmp");
 }
 
-QImage DanJuMuBan::printPackInfo(QString bar, QSharedPointer<PackInfo> info)
+void DanJuMuBan::printPackModel(QPainter & painter)
 {
-    // TODO: 测试打印出来的单子
-    QSize size(MAXWIDTH*5,MAXHEIGHT*5);
-    QImage image(size,QImage::Format_ARGB32);
-    image.fill(qRgba(255, 255, 255, 255));
-    QPainter painter(&image);
     painter.drawRect(4*5,4*5,92*5,68*5);
 
 //    painter.drawLine(50*5,0,50*5,80*5);
-    painter.drawLine(4*5,16*5,96*5,16*5);
-    painter.drawLine(4*5,22*5,96*5,22*5);
-    painter.drawLine(4*5,28*5,96*5,28*5);
-    painter.drawLine(4*5,34*5,96*5,34*5);
-    painter.drawLine(4*5,40*5,96*5,40*5);
-    painter.drawLine(4*5,46*5,96*5,46*5);
-    painter.drawLine(4*5,52*5,96*5,52*5);
-    painter.drawLine(4*5,58*5,96*5,58*5);
-    painter.drawLine(4*5,65*5,96*5,65*5);
+//    painter.drawLine(4*5,16*5,96*5,16*5);
+//    painter.drawLine(4*5,22*5,96*5,22*5);
+//    painter.drawLine(4*5,28*5,96*5,28*5);
+//    painter.drawLine(4*5,34*5,96*5,34*5);
+//    painter.drawLine(4*5,40*5,96*5,40*5);
+//    painter.drawLine(4*5,46*5,96*5,46*5);
+//    painter.drawLine(4*5,52*5,96*5,52*5);
+//    painter.drawLine(4*5,58*5,96*5,58*5);
+//    painter.drawLine(4*5,65*5,96*5,65*5);
 
     QFont font;
     font.setFamily("宋体");
@@ -122,6 +117,24 @@ QImage DanJuMuBan::printPackInfo(QString bar, QSharedPointer<PackInfo> info)
     painter.drawText(8*5,21*5,QStringLiteral("批号:"));
     painter.drawText(59*5,21*5,QStringLiteral("等级:"));
 
+    font.setPixelSize(15);
+    painter.setFont(font);
+
+    painter.drawText(8*5,64*5,QStringLiteral("总数"));
+    painter.drawText(38*5,64*5,QStringLiteral("总重量"));
+    painter.drawText(68*5,64*5,QStringLiteral("总筒数"));
+
+}
+
+QImage DanJuMuBan::printPackInfo(QString bar, QSharedPointer<PackInfo> info)
+{
+    QSize size(MAXWIDTH*5,MAXHEIGHT*5);
+    QImage image(size,QImage::Format_ARGB32);
+    image.fill(qRgba(255, 255, 255, 255));
+    QPainter painter(&image);
+    printPackModel(painter);
+
+    QFont font;
     font.setPixelSize(15);
     painter.setFont(font);
     int boxSize =  info->boxes().size();
@@ -130,42 +143,12 @@ QImage DanJuMuBan::printPackInfo(QString bar, QSharedPointer<PackInfo> info)
         int cloun = i % 5;
         painter.drawText((9 + line * 19)*5,(27 + cloun * 6)*5,QString("%1.").arg(i + 1));
     }
-    painter.drawText(9*5,27*5,QStringLiteral("1."));
-    painter.drawText(9*5,33*5,QStringLiteral("2."));
-    painter.drawText(9*5,39*5,QStringLiteral("3."));
-    painter.drawText(9*5,45*5,QStringLiteral("4."));
-    painter.drawText(9*5,51*5,QStringLiteral("5."));
-    painter.drawText(9*5,57*5,QStringLiteral("6."));
-
-    painter.drawText(28*5,27*5,QStringLiteral("7."));
-    painter.drawText(28*5,33*5,QStringLiteral("8."));
-    painter.drawText(28*5,39*5,QStringLiteral("9."));
-    painter.drawText(28*5,45*5,QStringLiteral("10."));
-    painter.drawText(28*5,51*5,QStringLiteral("11."));
-    painter.drawText(28*5,57*5,QStringLiteral("12."));
-
-    painter.drawText(47*5,27*5,QStringLiteral("13."));
-    painter.drawText(47*5,33*5,QStringLiteral("14."));
-    painter.drawText(47*5,39*5,QStringLiteral("15."));
-    painter.drawText(47*5,45*5,QStringLiteral("16."));
-    painter.drawText(47*5,51*5,QStringLiteral("17."));
-    painter.drawText(47*5,57*5,QStringLiteral("18."));
-
-    painter.drawText(66*5,27*5,QStringLiteral("19."));
-    painter.drawText(66*5,33*5,QStringLiteral("20."));
-
-    painter.drawText(8*5,64*5,QStringLiteral("总数"));
-    painter.drawText(38*5,64*5,QStringLiteral("总重量"));
-    painter.drawText(68*5,64*5,QStringLiteral("总筒数"));
 
     QRect target(0*5, 67*5, 100*5, 75*5);
     barCode.draw(painter,target,bar);
-//    QRect source(-10*5, 0, 60*5, 40*5);
-//    painter.drawImage(target,barCode.draw(barCode.CodeBinary(bar),bar),source);
-//    barCode.draw(barCode.CodeBinary(bar),bar,&image);
     font.setPixelSize(20);
     font.setFamily("黑体");
-//    font.setBold(true);
+
     painter.setFont(font);
     painter.drawText(19*5,15*5,info->info().specs);//QStringLiteral("规格"));
     painter.drawText(70*5,15*5,info->info().category);//QStringLiteral("类型"));
@@ -178,39 +161,62 @@ QImage DanJuMuBan::printPackInfo(QString bar, QSharedPointer<PackInfo> info)
         int cloun = i % 5;
         painter.drawText((13 + line * 19)*5,(27.5 + cloun * 6 )*5 ,code);
     }
-/*
-    painter.drawText(13*5,27.5*5,info.at(1));
-    painter.drawText(13*5,33.5*5,info.at(2));
-    painter.drawText(13*5,39.5*5,info.at(3));
-    painter.drawText(13*5,45.5*5,info.at(4));
-    painter.drawText(13*5,51.5*5,info.at(5));
-    painter.drawText(13*5,57.5*5,info.at(6));
-
-    painter.drawText(32*5,27.5*5,info.at(7));
-    painter.drawText(32*5,33.5*5,info.at(8));
-    painter.drawText(32*5,39.5*5,info.at(9));
-    painter.drawText(32*5,45.5*5,info.at(10));
-    painter.drawText(32*5,51.5*5,info.at(11));
-    painter.drawText(32*5,57.5*5,info.at(12));
-
-    painter.drawText(51*5,27.5*5,info.at(13));
-    painter.drawText(51*5,33.5*5,info.at(14));
-    painter.drawText(51*5,39.5*5,info.at(15));
-    painter.drawText(51*5,45.5*5,info.at(16));
-    painter.drawText(51*5,51.5*5,info.at(17));
-    painter.drawText(51*5,57.5*5,info.at(18));
-
-    painter.drawText(70*5,27.5*5,info.at(19));
-    painter.drawText(70*5,33.5*5,info.at(20));
-*/
+
     painter.drawText(15*5,64*5,QString::number(info->boxes().size()));
     painter.drawText(48*5,64*5,QString("%1 kg").arg(info->net_weight() / 1000.00));
     painter.drawText(78*5,64*5,QString::number(info->tube_number()));
 
+        print(image);
 
-//    print(image);
+        image.save(path+"\\rukudan\\code"+bar+".bmp");
+
+    return image;
+}
+
+QImage DanJuMuBan::mapPrintPackInfo(QMap<QString, QString> product, QStringList details)
+{
+    QSize size(MAXWIDTH*5,MAXHEIGHT*5);
+    QImage image(size,QImage::Format_ARGB32);
+    image.fill(qRgba(255, 255, 255, 255));
+    QPainter painter(&image);
+    printPackModel(painter);
+
+    QFont font;
+    font.setPixelSize(15);
+    painter.setFont(font);
+    int boxSize =  details.size();
+    for(int i = 0; i < boxSize; ++i){
+        int line = i / 5;
+        int cloun = i % 5;
+        painter.drawText((9 + line * 19)*5,(27 + cloun * 6)*5,QString("%1.").arg(i + 1));
+    }
+
+    QRect target(0*5, 67*5, 100*5, 75*5);
+    QString bar = product.value("code_single");
+    barCode.draw(painter,target,bar);
+    font.setPixelSize(20);
+    font.setFamily("黑体");
+
+    painter.setFont(font);
+    painter.drawText(19*5,15*5,product.value("specs"));//QStringLiteral("规格"));
+    painter.drawText(70*5,15*5,product.value("category"));//QStringLiteral("类型"));
+    painter.drawText(19*5,21*5,product.value("batch_no"));//QStringLiteral("批号"));
+    painter.drawText(70*5,21*5,product.value("level_id"));//info.at(0));
+    for(int i = 0; i < boxSize; ++i)
+    {
+        int line = i / 5;
+        int cloun = i % 5;
+        painter.drawText((13 + line * 19)*5,(27.5 + cloun * 6 )*5 ,details.at(i));
+    }
+
+    painter.drawText(15*5,64*5,QString::number(details.size()));
+    painter.drawText(48*5,64*5,QString("%1 kg").arg(product.value("net_widget").toDouble() / 1000.00));
+    painter.drawText(78*5,64*5,product.value("tube_number"));
+
+        print(image);
+
+        image.save(path+"\\rukudan\\code"+bar+".bmp");
 
-//    image.save(path+"\\rukudan\\code"+bar+".bmp");
     return image;
 }
 
@@ -230,3 +236,5 @@ void DanJuMuBan::print(QImage image)
         painter.drawImage(0,0,image);                         // 打印图像
 //    }
 }
+
+

+ 4 - 1
handle/danjumuban.h

@@ -17,7 +17,10 @@ public:
     QImage printBoxInfo(QString bar,QSharedPointer<BoxInfo> info);//QList<QString> datalist,const QString company);
     // 码单
     QImage printPackInfo(QString bar, QSharedPointer<PackInfo> info);
+    void printPackModel(QPainter & painter);
+    QImage mapPrintPackInfo(QMap<QString,QString> product,QStringList details);
     void print(QImage image);
+//    void mapPrintBoxInfo();
 private:
     int MAXWIDTH=100;
     int MAXHEIGHT=80;
@@ -33,7 +36,7 @@ private:
 //    QString nianxiang;
 //    QString xianghao;
 //    QString guanse;
-//    QString path;
+    QString path;
 //    QDateTime datetime;
 
 //    QString company = "南通市华安袜业有限公司";

+ 57 - 32
handle/database.cpp

@@ -33,24 +33,25 @@ bool Database::createProductDatabase()
 
 
     bool success = query.exec("CREATE TABLE product ("
-                                  "goods_id INTEGER NOT NULL,"
-                                  "code_single VARCHAR NOT NULL,"
-                                  "quantity INTEGER NOT NULL,"
-                                  "batch_no VARCHAR NOT NULL,"
-                                  "category VARCHAR NOT NULL,"
-                                  "level_id INTEGER NOT NULL,"
-                                  "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,"
-                                  "tongbu VARCHAR(1) DEFAULT 0,"
-                                  "remark VARCHAR);");
-
-//    bool success = query.exec("drop 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,"                 //规格
+                                  "tongbu VARCHAR(1) DEFAULT 0,"            //同步状态
+                                  "remark VARCHAR);");                      //备注
+
+//     success = query.exec("drop table product;");
 
     if(success)
     {
@@ -70,17 +71,17 @@ bool Database::createDetailsDatabase()
     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);");
-
-//    bool success = query.exec("drop 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)
     {
@@ -102,8 +103,8 @@ bool Database::insertProduct(product_data productData)
     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, remark)"
-                          "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
+                          "packing_type, carton_type, operator_id, specs, remark)"
+                          "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
     query.bindValue(0,productData.goods_id);
     query.bindValue(1,productData.code_single);
     query.bindValue(2,productData.quantity);
@@ -118,7 +119,8 @@ bool Database::insertProduct(product_data productData)
     query.bindValue(11,productData.packing_type);
     query.bindValue(12,productData.carton_type);
     query.bindValue(13,productData.operator_id);
-    query.bindValue(14,productData.remark);
+    query.bindValue(14,productData.specs);
+    query.bindValue(15,productData.remark);
 
     bool success=query.exec();
     return success;
@@ -216,6 +218,29 @@ QList<QMap<QString,QString>> Database::GetValues(QString table, QStringList &val
     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");

+ 2 - 0
handle/database.h

@@ -23,6 +23,7 @@ struct product_data
     QString packing_type;
     QString carton_type;
     int operator_id;
+    QString specs;
     QString remark;
 };
 
@@ -56,6 +57,7 @@ public:
     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);

+ 71 - 0
handle/logserialport.cpp

@@ -0,0 +1,71 @@
+#include "logserialport.h"
+#include <QCoreApplication>
+#include <QByteArray>
+#include "utils/utilsfunc.h"
+
+
+#ifdef _MSC_VER
+#pragma execution_character_set("utf-8")
+#endif
+
+LogSerialPort::LogSerialPort(QObject *parent) : QObject(parent)
+{
+    buchang  = 0;
+    min = 0;
+    max = 999;
+}
+
+float LogSerialPort::toFloat(const QByteArray & ray){
+    char ch[4] = {0};
+    ch[0] = ray.at(2);
+    ch[1] = ray.at(3);
+    ch[2] = ray.at(0);
+    ch[3] = ray.at(1);
+    float value = UtilsFun::toFloatRTUValue(&ch[0]);
+    return value;
+}
+
+void LogSerialPort::doHandle(const QByteArray & data)
+{
+    if(data.at(1) != 0x03) return;
+    int l = data.length() - 2;
+    QByteArray td = data.right(2);
+    int crcc = static_cast<uchar>(td.at(1));
+    crcc = crcc << 8;
+    crcc = crcc | static_cast<uchar>(td.at(0));
+    int scrc = UtilsFun::CRC(data, l);
+    if(scrc != crcc) {
+//        QLogWarning << " RTC CRC erro : should be : " << scrc << "  rev is : " << crcc << "\n"
+//                 << "data is :  " << data.toHex();
+        qDebug()<< " RTC CRC erro : should be : " << scrc << "  rev is : " << crcc << "\n"
+                                    << "data is :  " << data.toHex();
+       return;
+    }
+
+    QByteArray dt;
+    dt = data.mid(5,4);
+//    qDebug()<<dt;
+//    qDebug()<<data;
+//    qDebug()<<data.mid(1,4);
+    if(dt.isEmpty()) return;
+    needReply = true;
+    float v = toFloat(dt);
+    double rv = v + buchang;
+    if(rv > max){
+//        qDebug() << " get error value  : " << rv << "  mx : " << max << "    min:" << min
+//                 << "   buchang :  " << buchang;
+        rv = max;
+//        return;
+    }
+    if(rv < min){
+//        qDebug() << " get error value  : " << rv << "  mx : " << max << "    min:" << min
+//                 << "   buchang :  " << buchang;
+        rv = min;
+    }
+    auto tm = QDateTime::currentDateTime();
+//    save(0,tm,rv);
+//    emit newValue(0,tm.toMSecsSinceEpoch(),rv);
+//    qDebug()<<rv;
+    scaledata.gross_widget = rv;
+    GlobalInfo::this_()->SetScaleData(scaledata);
+}

+ 63 - 0
handle/logserialport.h

@@ -0,0 +1,63 @@
+#ifndef LOGSERIALPORT_H
+#define LOGSERIALPORT_H
+
+#include <QObject>
+#include <QWidget>
+#include <QSerialPort>
+#include <QQueue>
+#include "utils/rtuhelper.h"
+#include <QPair>
+#include <QDateTime>
+#include <QFile>
+#include <QTimer>
+#include "QDebug"
+#include "globalinfo.h"
+
+#ifdef _MSC_VER
+#pragma execution_character_set("utf-8")
+#endif
+
+class LogSerialPort : public QObject,public UtilsFun::RTUHelper
+{
+    Q_OBJECT
+public:
+    explicit LogSerialPort(QObject *parent = nullptr);
+
+//    inline bool isStart() const {return started;}
+//    inline bool isOpened() const {return opened;}
+    float toFloat(const QByteArray & ray);
+signals:
+//    void refValue();
+//    void newValue(int id,qint64 tm, double v);
+public slots:
+//    void open(const QString & name, int bandwith);
+//    void close();
+
+//    void checkBuchang(double buchang, double max, double min);
+private slots:
+//    void doTimerOut();
+//    void readData();
+    void doHandle(const QByteArray & data);
+
+//    void save(int, const QDateTime &tm, double v);
+private:
+    QSerialPort * _port;
+    QTimer * _timer;
+    QQueue<QByteArray> _sendQueue;
+    bool started;
+    bool needReply;
+    bool opened;
+    QPair<QDateTime,QFile * > _save;
+
+    QByteArray _getData;
+    QByteArray _resetData;
+    scaledata scaledata;
+
+
+    double buchang;
+    double max;
+    double min;
+
+};
+
+#endif // LOGSERIALPORT_H

+ 4 - 4
handle/remotepackconfig.cpp

@@ -39,10 +39,10 @@ RemotePackConfig::RemotePackConfig(QObject *parent) : QObject(parent)
        this->_config.chengZhongJingDuMode = jingdu.second;
    });
 
-//   parsefUNS.insert("A2000213",[this](const QJsonObject & obj){this->_config.buDingZhongTongShuFanWei = this->getConfigpAIR(obj);});
-//   parsefUNS.insert("A2000214",[this](const QJsonObject & obj){this->_config.dingZhongTongShuFanwei = this->getConfigpAIR(obj);});
+   parsefUNS.insert("A2000213",[this](const QJsonObject & obj){this->_config.buDingZhongTongShuFanWei = this->getConfigpAIR(obj);});
+   parsefUNS.insert("A2000214",[this](const QJsonObject & obj){this->_config.dingZhongTongShuFanwei = this->getConfigpAIR(obj);});
    parsefUNS.insert("A2000215",[this](const QJsonObject & obj){this->_config.morenRuKuMaDanFenShu = this->getConfigInt(obj);});
-//   parsefUNS.insert("A2000216",[this](const QJsonObject & obj){this->_config.buDingZhongXianZhiFanWei = this->getConfigpAIR(obj);});
+   parsefUNS.insert("A2000216",[this](const QJsonObject & obj){this->_config.buDingZhongXianZhiFanWei = this->getConfigpAIR(obj);});
    parsefUNS.insert("A2000217",[this](const QJsonObject & obj){this->_config.daBaoZhuangDaYinXiangDanFenShu = this->getConfigInt(obj);});
    parsefUNS.insert("A2000218",[this](const QJsonObject & obj){this->_config.daBaoZhuangMaoZhongFanWei = this->getConfigInt(obj);});
    parsefUNS.insert("A2000219",[this](const QJsonObject & obj){this->_config.ziDongDaBaoXiangZhongFanWei = this->getConfigInt(obj);});
@@ -205,7 +205,7 @@ int RemotePackConfig::getConfigInt(const QJsonObject & data)
 }
 
 
-QPair<int,int> getConfigpAIR(const QJsonObject & data)
+QPair<int,int> RemotePackConfig::getConfigpAIR(const QJsonObject & data)
 {
     QJsonArray value_array = data.value("value").toArray();
     QPair<int,int> list;

+ 57 - 0
handle/rtuport.cpp

@@ -0,0 +1,57 @@
+#include "rtuport.h"
+
+RtuPort::RtuPort()
+{
+    m_serialPort = new QSerialPort();
+    //设置参数
+
+    m_serialPort->setPortName(GlobalInfo::this_()->config().portName);
+    m_serialPort->setBaudRate(GlobalInfo::this_()->config().portBaudRate.toInt(),QSerialPort::AllDirections);//设置默认波特率和读写方向
+    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);
+}
+
+void RtuPort::portStart()
+{
+    m_serialPort->open(QIODevice::ReadWrite);
+    if(!m_serialPort->isOpen()){
+        qDebug()<<"串口未打开";
+        return;
+    }
+    qDebug("串口已开启");
+    portTimer->stop();
+    timer = new QTimer(this);
+    connect(timer,&QTimer::timeout,this,&RtuPort::portWrite);
+    timer->start(200);
+}
+
+void RtuPort::portWrite()
+{
+//    qDebug()<<"测试";
+//    if(hexData.isEmpty()){
+//        qDebug()<<"null";
+//        timer->stop();
+//        portTimer->start(1000);
+//    }
+    m_serialPort->write(ret);
+}
+
+void RtuPort::receiveInfo()
+{
+    QByteArray info = m_serialPort->readAll();
+    QByteArray hexData = info.toHex().data();
+//    qDebug()<<"receiveInfo测试:"<<hexData.toUpper();
+    log.readed(info);
+//    QByteArray data;
+
+}
+
+

+ 35 - 0
handle/rtuport.h

@@ -0,0 +1,35 @@
+#ifndef RTUPORT_H
+#define RTUPORT_H
+
+#include <QObject>
+#include "QDebug"
+#include "QtSerialPort/QSerialPort"
+#include "QtSerialPort/QSerialPortInfo"
+#include "QTimer"
+#include "logserialport.h"
+#include "globalinfo.h"
+
+
+class RtuPort : public QObject
+{
+    Q_OBJECT
+
+public:
+    RtuPort();
+    void portStart();
+
+private slots:
+    void receiveInfo();
+    void portWrite();
+private:
+    QSerialPort *m_serialPort;
+    QStringList m_serialPortName;
+    QTimer *timer;
+    QTimer *portTimer;
+    LogSerialPort log;
+    QByteArray ret;
+
+
+};
+
+#endif // RTUPORT_H

+ 94 - 0
handle/utils/rtuhelper.cpp

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

+ 54 - 0
handle/utils/rtuhelper.h

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

+ 203 - 0
handle/utils/utilsfunc.cpp

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

+ 41 - 0
handle/utils/utilsfunc.h

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

+ 12 - 4
mainwindow.cpp

@@ -17,6 +17,8 @@ MainWindow::MainWindow(QWidget *parent)
     connect(ui->pageAutoPack,&AutoPackForm::djmbbox,this,&MainWindow::changedjmb);
     connect(ui->widgetLogin,&LoginForm::SettingsClicked,this,&MainWindow::changeToSettings);
 
+    rtuport.portStart();
+
     database.openDB();
     database.createDetailsDatabase();
     database.createProductDatabase();
@@ -34,6 +36,16 @@ void MainWindow::on_pushAuto_clicked()
     ui->pageSelectValue->setStatus(1);
 }
 
+void MainWindow::on_pushList_clicked()
+{
+    ui->stackedWidget->setCurrentWidget(ui->pagePackDetail);
+}
+
+void MainWindow::on_pushConfig_clicked()
+{
+    changeToSettings();
+}
+
 void MainWindow::pageStatusChange(const ProjectInfo & info, int status)
 {
     switch (status) {
@@ -66,7 +78,3 @@ void MainWindow::changedjmb(QImage image)
     ui->djmb->setPixmap(QPixmap::fromImage(image));
 }
 
-void MainWindow::on_pushList_clicked()
-{
-    ui->stackedWidget->setCurrentWidget(ui->pagePackDetail);
-}

+ 4 - 0
mainwindow.h

@@ -4,6 +4,7 @@
 #include <QMainWindow>
 #include "configinfo.h"
 #include "handle/database.h"
+#include "handle/rtuport.h"
 
 QT_BEGIN_NAMESPACE
 namespace Ui { class MainWindow; }
@@ -22,12 +23,15 @@ private slots:
 
     void on_pushList_clicked();
 
+    void on_pushConfig_clicked();
+
 private:
     void backMenu();
     void pageStatusChange(const ProjectInfo & info, int status);
     void changedjmb(QImage image);
     Database database;
     void changeToSettings();
+    RtuPort rtuport;
 
 private:
     Ui::MainWindow *ui;

+ 56 - 34
mainwindow.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>800</width>
-    <height>600</height>
+    <width>896</width>
+    <height>575</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -33,7 +33,7 @@
     <item>
      <widget class="QStackedWidget" name="stackedWidget">
       <property name="currentIndex">
-       <number>3</number>
+       <number>0</number>
       </property>
       <widget class="QWidget" name="pageMain">
        <layout class="QHBoxLayout" name="horizontalLayout_2">
@@ -77,7 +77,7 @@ color: rgb(255, 255, 255);</string>
                </property>
               </widget>
              </item>
-             <item row="0" column="1">
+             <item row="0" column="2">
               <widget class="QLabel" name="p2_user_lb">
                <property name="minimumSize">
                 <size>
@@ -94,15 +94,37 @@ color: rgb(255, 255, 255);</string>
                <property name="text">
                 <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;right&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
                </property>
+               <property name="alignment">
+                <set>Qt::AlignCenter</set>
+               </property>
               </widget>
              </item>
+             <item row="0" column="1">
+              <spacer name="horizontalSpacer_3">
+               <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>
            </widget>
           </item>
           <item>
            <layout class="QGridLayout" name="gridLayout_4">
-            <item row="0" column="0">
-             <widget class="QPushButton" name="pushDingZHong">
+            <property name="sizeConstraint">
+             <enum>QLayout::SetDefaultConstraint</enum>
+            </property>
+            <property name="spacing">
+             <number>7</number>
+            </property>
+            <item row="0" column="3">
+             <widget class="QPushButton" name="pushConfig">
               <property name="minimumSize">
                <size>
                 <width>80</width>
@@ -110,21 +132,15 @@ color: rgb(255, 255, 255);</string>
                </size>
               </property>
               <property name="styleSheet">
-               <string notr="true">background-color: rgb(0, 170, 255);</string>
+               <string notr="true">background-color: rgb(0, 85, 255);</string>
               </property>
               <property name="text">
-               <string>定重箱单打印</string>
-              </property>
-              <property name="iconSize">
-               <size>
-                <width>20</width>
-                <height>20</height>
-               </size>
+               <string>硬件配置</string>
               </property>
              </widget>
             </item>
-            <item row="0" column="1">
-             <widget class="QPushButton" name="pushBuDingZhong">
+            <item row="0" column="2">
+             <widget class="QPushButton" name="pushXiaoBiaoqian">
               <property name="minimumSize">
                <size>
                 <width>80</width>
@@ -132,15 +148,15 @@ color: rgb(255, 255, 255);</string>
                </size>
               </property>
               <property name="styleSheet">
-               <string notr="true">background-color: rgb(0, 255, 127);</string>
+               <string notr="true">background-color: rgb(0, 170, 255);</string>
               </property>
               <property name="text">
-               <string>不定重箱单打印</string>
+               <string>小标签打印</string>
               </property>
              </widget>
             </item>
-            <item row="0" column="2">
-             <widget class="QPushButton" name="pushXiaoBiaoqian">
+            <item row="0" column="0">
+             <widget class="QPushButton" name="pushDingZHong">
               <property name="minimumSize">
                <size>
                 <width>80</width>
@@ -151,12 +167,18 @@ color: rgb(255, 255, 255);</string>
                <string notr="true">background-color: rgb(0, 170, 255);</string>
               </property>
               <property name="text">
-               <string>小标签打印</string>
+               <string>定重箱单打印</string>
+              </property>
+              <property name="iconSize">
+               <size>
+                <width>20</width>
+                <height>20</height>
+               </size>
               </property>
              </widget>
             </item>
-            <item row="0" column="3">
-             <widget class="QPushButton" name="pushConfig">
+            <item row="1" column="0">
+             <widget class="QPushButton" name="pushList">
               <property name="minimumSize">
                <size>
                 <width>80</width>
@@ -164,15 +186,15 @@ color: rgb(255, 255, 255);</string>
                </size>
               </property>
               <property name="styleSheet">
-               <string notr="true">background-color: rgb(0, 85, 255);</string>
+               <string notr="true">background-color: rgb(255, 170, 0);</string>
               </property>
               <property name="text">
-               <string>硬件配置</string>
+               <string>打包明细</string>
               </property>
              </widget>
             </item>
-            <item row="1" column="0">
-             <widget class="QPushButton" name="pushList">
+            <item row="1" column="1">
+             <widget class="QPushButton" name="pushBanZiDong">
               <property name="minimumSize">
                <size>
                 <width>80</width>
@@ -180,15 +202,15 @@ color: rgb(255, 255, 255);</string>
                </size>
               </property>
               <property name="styleSheet">
-               <string notr="true">background-color: rgb(255, 170, 0);</string>
+               <string notr="true">background-color: rgb(85, 255, 0);</string>
               </property>
               <property name="text">
-               <string>打包明细</string>
+               <string>半自动箱单打印</string>
               </property>
              </widget>
             </item>
-            <item row="1" column="1">
-             <widget class="QPushButton" name="pushBanZiDong">
+            <item row="0" column="1">
+             <widget class="QPushButton" name="pushBuDingZhong">
               <property name="minimumSize">
                <size>
                 <width>80</width>
@@ -196,10 +218,10 @@ color: rgb(255, 255, 255);</string>
                </size>
               </property>
               <property name="styleSheet">
-               <string notr="true">background-color: rgb(85, 255, 0);</string>
+               <string notr="true">background-color: rgb(0, 255, 127);</string>
               </property>
               <property name="text">
-               <string>半自动箱单打印</string>
+               <string>不定重箱单打印</string>
               </property>
              </widget>
             </item>
@@ -328,7 +350,7 @@ color: rgb(255, 255, 255);</string>
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>800</width>
+     <width>896</width>
      <height>26</height>
     </rect>
    </property>

+ 1 - 0
packinfo.h

@@ -43,6 +43,7 @@ public:
     QString packing_type;//	是	string	打包类型
     QString carton_type;//	是	string	纸箱
     int operator_id = 0;//	是	int	操作员ID
+
     QString remark;//	否	string
 
     inline const QList<QSharedPointer<BoxInfo>> & boxes() const {return _boxes;} //array	成品详情

+ 79 - 69
widget/autopackform.cpp

@@ -9,7 +9,9 @@ AutoPackForm::AutoPackForm(QWidget *parent) :
     ui->setupUi(this);
     QTimer *timer = new QTimer(this);
     connect(timer,&QTimer::timeout,this,&AutoPackForm::scaleData);
-//    timer->start(100);
+    timer->start(500);
+    ui->addBoxList->setDisabled(true);
+    ui->addPackList->setDisabled(true);
 }
 
 AutoPackForm::~AutoPackForm()
@@ -21,36 +23,39 @@ AutoPackForm::~AutoPackForm()
 void AutoPackForm::scaleData()
 {
     ui->grossWeight_2->setText(QString::number(GlobalInfo::this_()->GetScaleData().gross_widget));
-    ui->tareWeight_2->setText(QString::number(GlobalInfo::this_()->GetScaleData().tare_widget));
-    ui->netWeight_2->setText(QString::number(GlobalInfo::this_()->GetScaleData().net_widget));
-    ui->tongshu->setText(QString::number(GlobalInfo::this_()->GetScaleData().tongshu));
-}
-
-void AutoPackForm::on_pushBack_clicked()
-{
-    aputils.insertProductSQL(packinfo);
-    aputils.doSend(aputils.toJson(packinfo));
-    emit back();
+    ui->tareWeight_2->setText(QString::number(ui->pizhong->currentText().toDouble()));
+    ui->netWeight_2->setText(QString::number(ui->grossWeight_2->text().toDouble()-ui->tareWeight_2->text().toDouble()));
+//    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();
     connect(&packConfig,&RemotePackConfig::configUpdate,this,&AutoPackForm::upconfig);
     connect(&packConfig,&RemotePackConfig::dengJIConfigUp,this,&AutoPackForm::upDengjiInfo);
     ui->comboBox->clear();
-    for(int i = 1;i<20;i++){
+    for(int i = 1;i<=20;i++){
         ui->comboBox->addItem(QString::number(i));
     }
-    ui->comboBox->setEditText("20");
+    ui->comboBox->setCurrentText("20");
     on_addPackList_clicked();
 }
 
+void AutoPackForm::on_pushBack_clicked()
+{
+    aputils.insertProductSQL(packinfo);
+    aputils.doSend(aputils.toJson(packinfo));
+    emit back();
+}
+
 void AutoPackForm::on_addPackList_clicked()
 {
+//    qDebug()<<aputils.toJson(packinfo);
 
     //把数据添加到数据库里
     aputils.insertProductSQL(packinfo);
@@ -65,57 +70,12 @@ void AutoPackForm::on_addPackList_clicked()
     packinfo->packing_type = _info.category;
 }
 
-void AutoPackForm::upconfig(const DaBaoConfig &config)
-{
-    // 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)));
-    }
-}
-
-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_pushStart_clicked()
 {
     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 {
@@ -123,18 +83,24 @@ void AutoPackForm::on_pushStart_clicked()
     }
 }
 
-
-
 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()) return;
     auto box = packinfo->addBoxInfo();
     //TODO: 添加箱单 数据
-    box->box_weight = ui->pizhong->currentText().toInt();
+    box->box_weight = int(ui->pizhong->currentText().toDouble()*1000);
     box->tube_number = ui->tongshu->text().toInt();
-    box->bucket_weight = ui->pizhong->currentText().toInt()*ui->tongshu->text().toInt();
-    box->gross_weight = ui->grossWeight_2->text().toInt();
-    box->box_weight = ui->netWeight_2->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->sort = "1";
     box->remark = ui->beizhu->toPlainText();
     packinfo->level = ui->dengji->currentText();
@@ -154,7 +120,7 @@ void AutoPackForm::on_addBoxList_clicked()
 //    qDebug()<<packinfo->boxes().size();
 //    doSend(packinfo);
 
-    //把box数据添加到packinfo的boxes数据表里;
+//    把box数据添加到packinfo的boxes数据表里;
     packinfo->addBoxInfoList(box);
 
     //添加数据库
@@ -166,11 +132,55 @@ void AutoPackForm::on_addBoxList_clicked()
         packinfo->level_id = ui->dengji->currentData().toInt();
         packinfo->machine_no = ui->jitai->currentText();
         packinfo->carton_type = ui->zhixiang->currentText();
-        on_addPackList_clicked();
 //        emit djmbbox(djmb.printPackInfo(packinfo->codeSingle(),packinfo));
-        qDebug()<<"这里";
+        on_addPackList_clicked();
+//        qDebug()<<"这里";
     }
 }
 
+void AutoPackForm::upconfig(const DaBaoConfig &config)
+{
+    // 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)));
+    }
+}
+
+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);
+        }
+    }
+}

+ 28 - 4
widget/autopackform.ui

@@ -106,7 +106,7 @@
              </size>
             </property>
             <property name="text">
-             <string>毛重</string>
+             <string>毛重(千克/kg)</string>
             </property>
            </widget>
           </item>
@@ -125,7 +125,7 @@
              </size>
             </property>
             <property name="text">
-             <string>皮重</string>
+             <string>皮重(千克/kg)</string>
             </property>
            </widget>
           </item>
@@ -163,7 +163,7 @@
              </size>
             </property>
             <property name="text">
-             <string>净重</string>
+             <string>净重(千克/kg)</string>
             </property>
            </widget>
           </item>
@@ -179,6 +179,11 @@
               <height>100</height>
              </size>
             </property>
+            <property name="font">
+             <font>
+              <pointsize>20</pointsize>
+             </font>
+            </property>
             <property name="text">
              <string>0</string>
             </property>
@@ -192,6 +197,11 @@
               <height>100</height>
              </size>
             </property>
+            <property name="font">
+             <font>
+              <pointsize>20</pointsize>
+             </font>
+            </property>
             <property name="text">
              <string>0</string>
             </property>
@@ -205,6 +215,11 @@
               <height>100</height>
              </size>
             </property>
+            <property name="font">
+             <font>
+              <pointsize>20</pointsize>
+             </font>
+            </property>
             <property name="text">
              <string>0</string>
             </property>
@@ -218,6 +233,11 @@
               <height>100</height>
              </size>
             </property>
+            <property name="font">
+             <font>
+              <pointsize>20</pointsize>
+             </font>
+            </property>
             <property name="text">
              <string>0</string>
             </property>
@@ -442,7 +462,11 @@ color: rgb(0, 170, 255);</string>
              </widget>
             </item>
             <item>
-             <widget class="QComboBox" name="comboBox"/>
+             <widget class="QComboBox" name="comboBox">
+              <property name="currentText">
+               <string/>
+              </property>
+             </widget>
             </item>
            </layout>
           </item>

+ 1 - 0
widget/loginform.cpp

@@ -11,6 +11,7 @@ LoginForm::LoginForm(QWidget *parent) :
     connect(this,&LoginForm::loginFinish,this,&LoginForm::clear);
     ui->status->setVisible(false);
     this->setEnabled(true);
+    ui->linePass->setEchoMode(QLineEdit::Password);
 }
 
 LoginForm::~LoginForm()

+ 25 - 22
widget/packdetailform.cpp

@@ -6,11 +6,6 @@ PackDetailForm::PackDetailForm(QWidget *parent) :
     ui(new Ui::PackDetailForm)
 {
     ui->setupUi(this);
-//    connect(&packConfig,&RemotePackConfig::configUpdate,this,&PackDetailForm::upconfig);
-//    ui->tableWidget->resizeColumnsToContents();
-//    ui->tableWidget->resizeRowsToContents();
-//    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
-//    ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
     productList();
     detailsList();
     ui->treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
@@ -64,7 +59,8 @@ void PackDetailForm::changeTreeWidget(QList<QMap<QString,QString>> productList)
 
         ui->treeWidget->clear();
         product = productList;
-/**********************************************************************************************/
+
+/******************************************************************/
         //循环添加数据
         for(int i = 0;i<productList.size();i++){
             QStringList list;
@@ -73,10 +69,9 @@ void PackDetailForm::changeTreeWidget(QList<QMap<QString,QString>> productList)
             }
             list.append(productList.at(i).value("code_single"));
             list.append(productList.at(i).value("batch_no"));
-            list.append(productList.at(i).value("gross_weight"));
-            list.append(productList.at(i).value("net_weight"));
+            list.append(QString::number(productList.at(i).value("gross_weight").toDouble()/1000));
+            list.append(QString::number(productList.at(i).value("net_weight").toDouble()/1000));
             list.append(productList.at(i).value("quantity"));
-            list.append(productList.at(i).value("packing_time"));
 
 
             auto item = new QTreeWidgetItem(list);
@@ -84,7 +79,7 @@ void PackDetailForm::changeTreeWidget(QList<QMap<QString,QString>> productList)
             connect(tongbu_btn,&QPushButton::clicked,[item,i,this](){this->tongbu_clicked(item,i);});
     //        connect(tongbu_btn, SIGNAL(clicked(bool)), this, SLOT(tongbu_clicked()));
             auto code_single_btn = new QPushButton("打印码单");
-            connect(code_single_btn,SIGNAL(clicked(bool)),this,SLOT(code_single_clicked()));
+            connect(code_single_btn,&QPushButton::clicked,[i,this](){this->code_single_clicked(i);});
             auto case_nember_btn = new QPushButton("打印箱单");
             connect(case_nember_btn,SIGNAL(clicked(bool)),this,SLOT(case_number_clicked()));
 
@@ -95,23 +90,27 @@ void PackDetailForm::changeTreeWidget(QList<QMap<QString,QString>> productList)
 
             details = database.GetValues("details",detailSqlList," where code_single = "+product.at(i).value("code_single"));
 
+/*************************子项目****************************/
+            //treewidget子项目标题
+            QStringList columItemList;
+            QTreeWidgetItem *child;
+            columItemList<<"箱号"<<"毛重(千克/kg)"<<"净重(千克/kg)";
+            child = new QTreeWidgetItem(columItemList);
+            item->addChild(child);
+            ui->treeWidget->setCurrentItem(child);
 
-//            QTreeWidgetItem *child;
-//            columItemList<<"箱号";
-//            child = new QTreeWidgetItem(columItemList);
-//            ui->treeWidget->setCurrentItem(child,1);
-
+            //treewidget子项目数据循环添加
             for(int i=0; i<details.length(); ++i)
                 {
                     QStringList columItemList;
                     QTreeWidgetItem *child;
-                    columItemList<<details.at(i).value("case_number");
+                    columItemList<<details.at(i).value("case_number")<<QString::number(details.at(i).value("gross_weight").toDouble()/1000)<<QString::number(details.at(i).value("net_weight").toDouble()/1000);
                     child = new QTreeWidgetItem(columItemList);
                     item->addChild(child);
-        //            ui->tree->setItemWidget(child,1,new QSpinBox);
                     ui->treeWidget->setCurrentItem(child);
                 }
         }
+/**************************************************************/
 
         ui->pageDataNum->setText("本页数据:"+QString::number(product.length()));
         ui->pagesNum->setText(QString("%1/%2").arg(nowPageNum+1).arg(pageNumAll));
@@ -120,8 +119,7 @@ void PackDetailForm::changeTreeWidget(QList<QMap<QString,QString>> productList)
 //同步按钮
 void PackDetailForm::tongbu_clicked(QTreeWidgetItem * item,int row)
 {
-    qDebug()<<"行数:" << row;
-    qDebug()<<item->text(0);
+//    qDebug()<<item->text(0);
     if(item->text(0) != "未同步"){
         QMessageBox::information(this,tr("提示"),tr("请刷新"));
         return;
@@ -130,17 +128,20 @@ void PackDetailForm::tongbu_clicked(QTreeWidgetItem * item,int row)
     details = database.GetValues("details",detailSqlList,condition);
     autoPack.doSend(autoPack.toJsonMap(product.at(row),details));
     item->setText(0,"请刷新");
-    item->setBackground(0,QBrush(QColor(255,255,0)));
 }
 
-void PackDetailForm::code_single_clicked()
+void PackDetailForm::code_single_clicked(int row)
 {
     qDebug()<<"打印码单";
+//    QStringList list;
+//    list.append("net_weight");
+    QString condition = " where code_single="+product.at(row).value("code_single");
+    djmb.mapPrintPackInfo(product.at(row),database.GetValuesList("details","net_weight",condition));
 }
 
 void PackDetailForm::case_number_clicked()
 {
-    qDebug()<<"打印箱单";
+    qDebug()<<"打印箱单";//暂时不知道打哪个
 }
 
 //上一页
@@ -195,6 +196,8 @@ void PackDetailForm::productList()
     productSqlList.append("packing_type");
     productSqlList.append("carton_type");
     productSqlList.append("operator_id");
+    productSqlList.append("category");
+    productSqlList.append("specs");
     productSqlList.append("remark");
 }
 

+ 3 - 1
widget/packdetailform.h

@@ -8,6 +8,7 @@
 #include "QTreeWidget"
 #include "packinfo.h"
 #include "autopackform.h"
+#include "handle/danjumuban.h"
 
 namespace Ui {
 class PackDetailForm;
@@ -28,7 +29,7 @@ private slots:
 
     void changeTreeWidget(QList<QMap<QString,QString>> productList);
     void tongbu_clicked(QTreeWidgetItem * item,int row);
-    void code_single_clicked();
+    void code_single_clicked(int row);
     void case_number_clicked();
 
     void productList();
@@ -55,6 +56,7 @@ private:
     QStringList detailSqlList;
     QSharedPointer<PackInfo> packinfo;
     AutoPackUtils autoPack;
+    DanJuMuBan djmb;
     int nowPageNum;
     int pageNumAll;
 };

+ 461 - 365
widget/packdetailform.ui

@@ -13,7 +13,10 @@
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout_2">
+  <property name="styleSheet">
+   <string notr="true"/>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
    <property name="leftMargin">
     <number>0</number>
    </property>
@@ -28,399 +31,492 @@
    </property>
    <item row="0" column="0">
     <widget class="QWidget" name="widget" 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">
-        <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">
-        <property name="text">
-         <string>自动打包</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <spacer name="horizontalSpacer_2">
-        <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 row="1" column="0">
-    <widget class="QWidget" name="widget_2" native="true">
      <property name="styleSheet">
-      <string notr="true">background-color: rgb(0, 170, 255);</string>
+      <string notr="true">background-color: rgb(172, 224, 255);</string>
      </property>
-     <layout class="QGridLayout" name="gridLayout">
-      <item row="0" column="2">
-       <widget class="QComboBox" name="product_type_codeBox">
-        <property name="currentText">
-         <string/>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="5">
-       <widget class="QLineEdit" name="fiberLine">
-        <property name="placeholderText">
-         <string>孔数</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="7">
-       <widget class="QComboBox" name="UserIDBox"/>
-      </item>
-      <item row="0" column="8">
-       <widget class="QComboBox" name="comboBox_4"/>
-      </item>
-      <item row="0" column="9">
-       <widget class="QPushButton" name="pushButton">
-        <property name="minimumSize">
-         <size>
-          <width>91</width>
-          <height>41</height>
-         </size>
-        </property>
-        <property name="maximumSize">
-         <size>
-          <width>91</width>
-          <height>41</height>
-         </size>
-        </property>
-        <property name="text">
-         <string>搜索</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="4">
-       <widget class="QLineEdit" name="dtexLine">
-        <property name="placeholderText">
-         <string>分特</string>
-        </property>
-       </widget>
-      </item>
+     <layout class="QGridLayout" name="gridLayout_3">
       <item row="0" column="0">
-       <widget class="QLineEdit" name="codeSingleLine">
-        <property name="placeholderText">
-         <string>码单</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="1">
-       <widget class="QLineEdit" name="batch_noLine">
-        <property name="placeholderText">
-         <string>批号</string>
+       <widget class="QWidget" name="widget_2" native="true">
+        <property name="styleSheet">
+         <string notr="true">background-color: rgb(0, 187, 255);</string>
         </property>
+        <layout class="QGridLayout" name="gridLayout_2">
+         <item row="0" column="0">
+          <widget class="QWidget" name="widget_3" native="true">
+           <property name="minimumSize">
+            <size>
+             <width>0</width>
+             <height>30</height>
+            </size>
+           </property>
+           <widget class="QWidget" name="layoutWidget">
+            <property name="geometry">
+             <rect>
+              <x>12</x>
+              <y>0</y>
+              <width>1032</width>
+              <height>30</height>
+             </rect>
+            </property>
+            <layout class="QHBoxLayout" name="horizontalLayout_6">
+             <item>
+              <widget class="QPushButton" name="pushBack">
+               <property name="styleSheet">
+                <string notr="true">background-color: rgb(175, 223, 255);</string>
+               </property>
+               <property name="text">
+                <string>&lt;返回主页</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <spacer name="horizontalSpacer">
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>358</width>
+                 <height>20</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+             <item>
+              <widget class="QLabel" name="label">
+               <property name="styleSheet">
+                <string notr="true">color: rgb(255, 255, 255);</string>
+               </property>
+               <property name="text">
+                <string>自动打包</string>
+               </property>
+               <property name="scaledContents">
+                <bool>false</bool>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <spacer name="horizontalSpacer_2">
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>498</width>
+                 <height>20</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+            </layout>
+           </widget>
+          </widget>
+         </item>
+         <item row="1" column="0">
+          <layout class="QHBoxLayout" name="horizontalLayout_5">
+           <item>
+            <widget class="QLineEdit" name="codeSingleLine">
+             <property name="styleSheet">
+              <string notr="true">background-color: rgb(255, 255, 255);</string>
+             </property>
+             <property name="placeholderText">
+              <string>码单</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLineEdit" name="batch_noLine">
+             <property name="styleSheet">
+              <string notr="true">background-color: rgb(255, 255, 255);</string>
+             </property>
+             <property name="placeholderText">
+              <string>批号</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QComboBox" name="product_type_codeBox">
+             <property name="styleSheet">
+              <string notr="true">background-color: rgb(255, 255, 255);</string>
+             </property>
+             <property name="currentText">
+              <string/>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLineEdit" name="denierLine">
+             <property name="styleSheet">
+              <string notr="true">background-color: rgb(255, 255, 255);</string>
+             </property>
+             <property name="placeholderText">
+              <string>旦数</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLineEdit" name="dtexLine">
+             <property name="styleSheet">
+              <string notr="true">background-color: rgb(255, 255, 255);</string>
+             </property>
+             <property name="placeholderText">
+              <string>分特</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLineEdit" name="fiberLine">
+             <property name="styleSheet">
+              <string notr="true">background-color: rgb(255, 255, 255);</string>
+             </property>
+             <property name="placeholderText">
+              <string>孔数</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QComboBox" name="levelBox">
+             <property name="styleSheet">
+              <string notr="true">background-color: rgb(255, 255, 255);</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QComboBox" name="UserIDBox">
+             <property name="styleSheet">
+              <string notr="true">background-color: rgb(255, 255, 255);</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QComboBox" name="comboBox_4">
+             <property name="styleSheet">
+              <string notr="true">background-color: rgb(255, 255, 255);</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QPushButton" name="pushButton">
+             <property name="enabled">
+              <bool>true</bool>
+             </property>
+             <property name="minimumSize">
+              <size>
+               <width>91</width>
+               <height>41</height>
+              </size>
+             </property>
+             <property name="maximumSize">
+              <size>
+               <width>91</width>
+               <height>41</height>
+              </size>
+             </property>
+             <property name="text">
+              <string>搜索</string>
+             </property>
+            </widget>
+           </item>
+          </layout>
+         </item>
+        </layout>
        </widget>
       </item>
-      <item row="0" column="6">
-       <widget class="QComboBox" name="levelBox"/>
+      <item row="1" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <item>
+         <layout class="QVBoxLayout" name="verticalLayout">
+          <item>
+           <widget class="QLabel" name="label_2">
+            <property name="text">
+             <string>箱单</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QComboBox" name="comboBox_5">
+            <property name="styleSheet">
+             <string notr="true">background-color: rgb(255, 255, 255);</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <layout class="QVBoxLayout" name="verticalLayout_2">
+          <item>
+           <widget class="QLabel" name="label_3">
+            <property name="text">
+             <string>码单</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QComboBox" name="comboBox_6">
+            <property name="styleSheet">
+             <string notr="true">background-color: rgb(255, 255, 255);</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <layout class="QVBoxLayout" name="verticalLayout_3">
+          <item>
+           <widget class="QLabel" name="label_4">
+            <property name="text">
+             <string>箱单抬头</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLineEdit" name="lineEdit_6">
+            <property name="styleSheet">
+             <string notr="true">background-color: rgb(255, 255, 255);</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <layout class="QVBoxLayout" name="verticalLayout_4">
+          <item>
+           <widget class="QLabel" name="label_5">
+            <property name="text">
+             <string>备注</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLineEdit" name="lineEdit_7">
+            <property name="styleSheet">
+             <string notr="true">background-color: rgb(255, 255, 255);</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <widget class="QPushButton" name="pushButton_2">
+          <property name="styleSheet">
+           <string notr="true"/>
+          </property>
+          <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>348</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
       </item>
-      <item row="0" column="3">
-       <widget class="QLineEdit" name="denierLine">
-        <property name="placeholderText">
-         <string>旦数</string>
+      <item row="2" column="0">
+       <widget class="QTreeWidget" name="treeWidget">
+        <property name="styleSheet">
+         <string notr="true">background-color: rgb(228, 244, 255);</string>
         </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item row="2" column="0">
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <layout class="QVBoxLayout" name="verticalLayout">
-       <item>
-        <widget class="QLabel" name="label_2">
+        <column>
          <property name="text">
-          <string>箱单</string>
+          <string>同步状态</string>
          </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QComboBox" name="comboBox_5"/>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <layout class="QVBoxLayout" name="verticalLayout_2">
-       <item>
-        <widget class="QLabel" name="label_3">
+        </column>
+        <column>
          <property name="text">
           <string>码单</string>
          </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QComboBox" name="comboBox_6"/>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <layout class="QVBoxLayout" name="verticalLayout_3">
-       <item>
-        <widget class="QLabel" name="label_4">
+        </column>
+        <column>
          <property name="text">
-          <string>箱单抬头</string>
+          <string>码单详情</string>
          </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLineEdit" name="lineEdit_6"/>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <layout class="QVBoxLayout" name="verticalLayout_4">
-       <item>
-        <widget class="QLabel" name="label_5">
+        </column>
+        <column>
          <property name="text">
-          <string>备注</string>
+          <string>毛重</string>
          </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLineEdit" name="lineEdit_7"/>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <widget class="QPushButton" name="pushButton_2">
-       <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>348</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
-   </item>
-   <item row="3" column="0">
-    <widget class="QTreeWidget" name="treeWidget">
-     <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>
-     <column>
-      <property name="text">
-       <string>打包时间</string>
-      </property>
-     </column>
-     <column>
-      <property name="text">
-       <string/>
-      </property>
-     </column>
-     <column>
-      <property name="text">
-       <string>箱单详情</string>
-      </property>
-     </column>
-     <column>
-      <property name="text">
-       <string/>
-      </property>
-     </column>
-     <column>
-      <property name="text">
-       <string/>
-      </property>
-     </column>
-    </widget>
-   </item>
-   <item row="4" column="0">
-    <layout class="QHBoxLayout" name="horizontalLayout_4">
-     <item>
-      <spacer name="horizontalSpacer_5">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>308</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <layout class="QHBoxLayout" name="horizontalLayout_2">
-       <item>
-        <widget class="QPushButton" name="prevoiusPage">
+        </column>
+        <column>
          <property name="text">
-          <string>上一页</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLabel" name="pagesNum">
-         <property name="minimumSize">
-          <size>
-           <width>100</width>
-           <height>0</height>
-          </size>
+          <string>净重</string>
          </property>
+        </column>
+        <column>
          <property name="text">
-          <string>0/0</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignCenter</set>
+          <string>箱数</string>
          </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="nextPage">
+        </column>
+        <column>
          <property name="text">
-          <string>下一页</string>
+          <string>打包时间</string>
          </property>
-        </widget>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer_4">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>58</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <layout class="QHBoxLayout" name="horizontalLayout_3">
-       <item>
-        <widget class="QLineEdit" name="jumpPage">
-         <property name="maximumSize">
-          <size>
-           <width>50</width>
-           <height>25</height>
-          </size>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="jump">
+        </column>
+        <column>
          <property name="text">
-          <string>跳转</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLabel" name="pageDataNum">
-         <property name="minimumSize">
-          <size>
-           <width>100</width>
-           <height>31</height>
-          </size>
+          <string/>
          </property>
-         <property name="maximumSize">
-          <size>
-           <width>100</width>
-           <height>31</height>
-          </size>
+        </column>
+        <column>
+         <property name="text">
+          <string>箱单详情</string>
          </property>
+        </column>
+        <column>
          <property name="text">
-          <string>0</string>
+          <string/>
          </property>
-         <property name="alignment">
-          <set>Qt::AlignCenter</set>
+        </column>
+        <column>
+         <property name="text">
+          <string/>
          </property>
-        </widget>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer_6">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>188</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
+        </column>
+       </widget>
+      </item>
+      <item row="3" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout_4">
+        <item>
+         <spacer name="horizontalSpacer_5">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>368</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout">
+          <item>
+           <widget class="QPushButton" name="prevoiusPage">
+            <property name="styleSheet">
+             <string notr="true">background-color: rgb(207, 231, 255);</string>
+            </property>
+            <property name="text">
+             <string>上一页</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="pagesNum">
+            <property name="minimumSize">
+             <size>
+              <width>100</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="text">
+             <string>0/0</string>
+            </property>
+            <property name="alignment">
+             <set>Qt::AlignCenter</set>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QPushButton" name="nextPage">
+            <property name="styleSheet">
+             <string notr="true">background-color: rgb(207, 231, 255);</string>
+            </property>
+            <property name="text">
+             <string>下一页</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer_4">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>58</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout_3">
+          <item>
+           <widget class="QLineEdit" name="jumpPage">
+            <property name="maximumSize">
+             <size>
+              <width>50</width>
+              <height>25</height>
+             </size>
+            </property>
+            <property name="styleSheet">
+             <string notr="true">background-color: rgb(207, 231, 255);</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QPushButton" name="jump">
+            <property name="styleSheet">
+             <string notr="true">background-color: rgb(207, 231, 255);</string>
+            </property>
+            <property name="text">
+             <string>跳转</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="pageDataNum">
+            <property name="minimumSize">
+             <size>
+              <width>100</width>
+              <height>31</height>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>100</width>
+              <height>31</height>
+             </size>
+            </property>
+            <property name="text">
+             <string>0</string>
+            </property>
+            <property name="alignment">
+             <set>Qt::AlignCenter</set>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer_6">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>98</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
    </item>
   </layout>
  </widget>

+ 21 - 0
widget/settingsform.cpp

@@ -6,8 +6,11 @@ SettingsForm::SettingsForm(QWidget *parent) :
     ui(new Ui::SettingsForm)
 {
     ui->setupUi(this);
+    Init();
     ui->baseUrlLine->setText(config.baseUrl);
     ui->printerName->setText(config.printerName);
+    ui->portName->setCurrentText(config.portName);
+    ui->portBaudRate->setCurrentText(config.portBaudRate);
 }
 
 SettingsForm::~SettingsForm()
@@ -15,6 +18,22 @@ SettingsForm::~SettingsForm()
     delete ui;
 }
 
+void SettingsForm::Init()
+{
+    //串口名称
+    foreach(const QSerialPortInfo &info,QSerialPortInfo::availablePorts())
+    {
+       ui->portName->addItem(info.portName());
+//               qDebug()<<info.portName();
+    }
+
+    //串口波特率
+    QStringList Baudlist;
+    Baudlist.clear();
+    Baudlist<<"300"<<"600"<<"2400"<<"4800"<<"9600"<<"19200"<<"56000"<<"57600"<<"115200"<<"128000"<<"256000"<<"921600";
+    ui->portBaudRate->addItems(Baudlist);
+}
+
 void SettingsForm::on_back_btn_clicked()
 {
     emit back();
@@ -24,5 +43,7 @@ void SettingsForm::on_save_btn_clicked()
 {
     config.Set("url","baseUrl",ui->baseUrlLine->text());
     config.Set("hardware","printerName",ui->printerName->text());
+    config.Set("ElectronicScale","portName",ui->portName->currentText());
+    config.Set("ElectronicScale","portBaudRate",ui->portBaudRate->currentText());
     config.Start();
 }

+ 4 - 0
widget/settingsform.h

@@ -3,6 +3,7 @@
 
 #include <QWidget>
 #include "configinfo.h"
+#include "QtSerialPort/QSerialPortInfo"
 
 namespace Ui {
 class SettingsForm;
@@ -27,6 +28,9 @@ signals:
 private:
     Ui::SettingsForm *ui;
     ConfigInfo config;
+
+private:
+    void Init();
 };
 
 #endif // SETTINGSFORM_H

+ 237 - 123
widget/settingsform.ui

@@ -6,134 +6,248 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>641</width>
-    <height>511</height>
+    <width>755</width>
+    <height>658</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <widget class="QLabel" name="label">
-   <property name="geometry">
-    <rect>
-     <x>60</x>
-     <y>50</y>
-     <width>72</width>
-     <height>15</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>打印机</string>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_2">
-   <property name="geometry">
-    <rect>
-     <x>60</x>
-     <y>90</y>
-     <width>72</width>
-     <height>15</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>称</string>
-   </property>
-  </widget>
-  <widget class="QComboBox" name="comboBox_2">
-   <property name="geometry">
-    <rect>
-     <x>190</x>
-     <y>90</y>
-     <width>87</width>
-     <height>22</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_3">
-   <property name="geometry">
-    <rect>
-     <x>60</x>
-     <y>130</y>
-     <width>72</width>
-     <height>15</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>服务器</string>
-   </property>
-  </widget>
-  <widget class="QLineEdit" name="baseUrlLine">
-   <property name="geometry">
-    <rect>
-     <x>190</x>
-     <y>130</y>
-     <width>301</width>
-     <height>21</height>
-    </rect>
-   </property>
-   <property name="placeholderText">
-    <string>服务器地址:例http://erp.it.cn/api</string>
-   </property>
-  </widget>
-  <widget class="QLabel" name="label_4">
-   <property name="geometry">
-    <rect>
-     <x>60</x>
-     <y>170</y>
-     <width>72</width>
-     <height>15</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>规则</string>
-   </property>
-  </widget>
-  <widget class="QTextEdit" name="textEdit">
-   <property name="geometry">
-    <rect>
-     <x>190</x>
-     <y>170</y>
-     <width>301</width>
-     <height>171</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QPushButton" name="save_btn">
-   <property name="geometry">
-    <rect>
-     <x>190</x>
-     <y>430</y>
-     <width>93</width>
-     <height>28</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>保存</string>
-   </property>
-  </widget>
-  <widget class="QPushButton" name="back_btn">
-   <property name="geometry">
-    <rect>
-     <x>400</x>
-     <y>430</y>
-     <width>93</width>
-     <height>28</height>
-    </rect>
-   </property>
-   <property name="text">
-    <string>返回</string>
-   </property>
-  </widget>
-  <widget class="QLineEdit" name="printerName">
-   <property name="geometry">
-    <rect>
-     <x>190</x>
-     <y>50</y>
-     <width>301</width>
-     <height>21</height>
-    </rect>
-   </property>
-  </widget>
+  <layout class="QGridLayout" name="gridLayout">
+   <property name="leftMargin">
+    <number>0</number>
+   </property>
+   <property name="topMargin">
+    <number>0</number>
+   </property>
+   <property name="rightMargin">
+    <number>0</number>
+   </property>
+   <property name="bottomMargin">
+    <number>0</number>
+   </property>
+   <item row="0" column="0">
+    <widget class="QWidget" name="widget" native="true">
+     <property name="styleSheet">
+      <string notr="true">background-color: rgb(130, 201, 255);</string>
+     </property>
+     <widget class="QWidget" name="widget_2" native="true">
+      <property name="geometry">
+       <rect>
+        <x>20</x>
+        <y>20</y>
+        <width>491</width>
+        <height>581</height>
+       </rect>
+      </property>
+      <property name="styleSheet">
+       <string notr="true">background-color: rgb(189, 243, 255);</string>
+      </property>
+      <widget class="QLabel" name="label_3">
+       <property name="geometry">
+        <rect>
+         <x>20</x>
+         <y>210</y>
+         <width>72</width>
+         <height>15</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>服务器</string>
+       </property>
+      </widget>
+      <widget class="QTextEdit" name="textEdit">
+       <property name="geometry">
+        <rect>
+         <x>150</x>
+         <y>250</y>
+         <width>301</width>
+         <height>171</height>
+        </rect>
+       </property>
+       <property name="styleSheet">
+        <string notr="true">background-color: rgb(255, 255, 255);</string>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_2">
+       <property name="geometry">
+        <rect>
+         <x>20</x>
+         <y>70</y>
+         <width>72</width>
+         <height>15</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>称</string>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_6">
+       <property name="geometry">
+        <rect>
+         <x>150</x>
+         <y>110</y>
+         <width>41</width>
+         <height>16</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>串口:</string>
+       </property>
+      </widget>
+      <widget class="QComboBox" name="comboBox_2">
+       <property name="geometry">
+        <rect>
+         <x>220</x>
+         <y>70</y>
+         <width>87</width>
+         <height>22</height>
+        </rect>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label">
+       <property name="geometry">
+        <rect>
+         <x>20</x>
+         <y>30</y>
+         <width>72</width>
+         <height>15</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>打印机</string>
+       </property>
+      </widget>
+      <widget class="QComboBox" name="portBaudRate">
+       <property name="geometry">
+        <rect>
+         <x>220</x>
+         <y>150</y>
+         <width>87</width>
+         <height>22</height>
+        </rect>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_7">
+       <property name="geometry">
+        <rect>
+         <x>150</x>
+         <y>150</y>
+         <width>61</width>
+         <height>16</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>波特率:</string>
+       </property>
+      </widget>
+      <widget class="QLineEdit" name="printerName">
+       <property name="geometry">
+        <rect>
+         <x>150</x>
+         <y>30</y>
+         <width>301</width>
+         <height>21</height>
+        </rect>
+       </property>
+       <property name="styleSheet">
+        <string notr="true">background-color: rgb(255, 255, 255);</string>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="placeholderText">
+        <string>打印机名称</string>
+       </property>
+      </widget>
+      <widget class="QComboBox" name="portName">
+       <property name="geometry">
+        <rect>
+         <x>220</x>
+         <y>110</y>
+         <width>87</width>
+         <height>22</height>
+        </rect>
+       </property>
+      </widget>
+      <widget class="QLineEdit" name="baseUrlLine">
+       <property name="geometry">
+        <rect>
+         <x>150</x>
+         <y>210</y>
+         <width>301</width>
+         <height>21</height>
+        </rect>
+       </property>
+       <property name="styleSheet">
+        <string notr="true">background-color: rgb(255, 255, 255);</string>
+       </property>
+       <property name="placeholderText">
+        <string>服务器地址:例http://erp.it.cn/api</string>
+       </property>
+      </widget>
+      <widget class="QPushButton" name="save_btn">
+       <property name="geometry">
+        <rect>
+         <x>150</x>
+         <y>510</y>
+         <width>93</width>
+         <height>28</height>
+        </rect>
+       </property>
+       <property name="styleSheet">
+        <string notr="true">background-color: rgb(130, 201, 255);</string>
+       </property>
+       <property name="text">
+        <string>保存</string>
+       </property>
+      </widget>
+      <widget class="QPushButton" name="back_btn">
+       <property name="geometry">
+        <rect>
+         <x>360</x>
+         <y>510</y>
+         <width>93</width>
+         <height>28</height>
+        </rect>
+       </property>
+       <property name="styleSheet">
+        <string notr="true">background-color: rgb(130, 201, 255);</string>
+       </property>
+       <property name="text">
+        <string>返回</string>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_5">
+       <property name="geometry">
+        <rect>
+         <x>150</x>
+         <y>70</y>
+         <width>41</width>
+         <height>16</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>名称:</string>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_4">
+       <property name="geometry">
+        <rect>
+         <x>20</x>
+         <y>250</y>
+         <width>72</width>
+         <height>15</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>规则</string>
+       </property>
+      </widget>
+     </widget>
+    </widget>
+   </item>
+  </layout>
  </widget>
  <resources/>
  <connections/>