|
|
@@ -0,0 +1,909 @@
|
|
|
+#include "formwoolfinished.h"
|
|
|
+#include "ui_formwoolfinished.h"
|
|
|
+#include "sncdatabase.h"
|
|
|
+#include "respdlresultfile.h"
|
|
|
+#include "zip.h"
|
|
|
+FormWoolFinished::FormWoolFinished(QWidget *parent) :
|
|
|
+ QWidget(parent),
|
|
|
+ ui(new Ui::FormWoolFinished)
|
|
|
+{
|
|
|
+ ui->setupUi(this);
|
|
|
+ initVariables();
|
|
|
+ initUI();
|
|
|
+ setTableWidgetNoData(ui->tableWidget);
|
|
|
+ setDetailNoData();
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::setClientID(QString clientID)
|
|
|
+{
|
|
|
+ m_clientID = clientID;
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::setClientName(QString clientName)
|
|
|
+{
|
|
|
+ m_clientName = clientName;
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::setHost(QString host, QString port)
|
|
|
+{
|
|
|
+ m_host = host;
|
|
|
+ m_port = port;
|
|
|
+// m_wool->setHost(m_host,m_port);
|
|
|
+}
|
|
|
+
|
|
|
+FormWoolFinished::~FormWoolFinished()
|
|
|
+{
|
|
|
+ m_wool->abort();
|
|
|
+ m_movieBig->stop();
|
|
|
+ delete m_movieBig;
|
|
|
+ delete m_wool;
|
|
|
+ delete ui;
|
|
|
+ qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
|
|
|
+ <<"FormWool.FormWoolFinished Destroyed.";
|
|
|
+}
|
|
|
+void FormWoolFinished::initVariables()
|
|
|
+{
|
|
|
+ m_movieBig = new QMovie(":/fetchfromserver.gif");
|
|
|
+ m_movieBig->start();
|
|
|
+
|
|
|
+
|
|
|
+ m_keys<<"batchid"<<"isdeliver"<<"ispass"<<"detail"<<"resulttj"<<"submittime"<<"finishtime"\
|
|
|
+ <<"finishcount"<<"settlefee"<<"giftfee";
|
|
|
+
|
|
|
+ m_headers<<""<<"状态"<<"是否放行"<<"原始文件"<<"详细统计"<<"提交时间"<<"完成时间"\
|
|
|
+ <<"已检测"<<"费用"<<"赠送消耗"<<"下载";
|
|
|
+ m_state = NotLogin;
|
|
|
+ m_curLtfid = "";
|
|
|
+ m_curQryid = "";
|
|
|
+ m_lastLtfid = "";
|
|
|
+
|
|
|
+ m_wool = new WSWool();
|
|
|
+}
|
|
|
+void FormWoolFinished::setAccountInfo(QMap<QString, QString> info)
|
|
|
+{
|
|
|
+ m_account = info;
|
|
|
+ QString ssoHash = info.value("ssohash");
|
|
|
+ QString userCode = info.value("usercode");
|
|
|
+ QString userHash = info.value("userhash");
|
|
|
+ if(!ssoHash.isEmpty())
|
|
|
+ {
|
|
|
+ if(!userHash.isEmpty())
|
|
|
+ {
|
|
|
+ m_state = LoginOk;
|
|
|
+ setTableWidgetSyncData(ui->tableWidget);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(!userCode.isEmpty())
|
|
|
+ {
|
|
|
+ m_state = LoginError;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_state = NotBind;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_state = NotLogin;
|
|
|
+ }
|
|
|
+ if(m_state!=LoginOk)
|
|
|
+ {
|
|
|
+ setTableWidgetNoData(ui->tableWidget);
|
|
|
+ setDetailNoData();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::initUI()
|
|
|
+{
|
|
|
+ ui->tableWidget->setColumnCount(m_headers.size());
|
|
|
+ ui->tableWidget->setHorizontalHeaderLabels(m_headers);
|
|
|
+
|
|
|
+ ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
+ ui->tableWidget->setShowGrid(false);
|
|
|
+ ui->tableWidget->setAlternatingRowColors(true);
|
|
|
+ ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
+ ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
+ ui->tableWidget->verticalHeader()->setVisible(false);
|
|
|
+ ui->tableWidget->horizontalHeader()->setStyleSheet("font:12px");
|
|
|
+ ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Fixed);
|
|
|
+ ui->tableWidget->verticalHeader()->setResizeMode(QHeaderView::Fixed);
|
|
|
+ ui->tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
+ ui->tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
|
|
+ ui->tableWidget->verticalHeader()->setFixedWidth(30);
|
|
|
+ ui->tableWidget->setSortingEnabled(true);
|
|
|
+
|
|
|
+ int col = 0;
|
|
|
+ ui->tableWidget->setColumnWidth(col++,20);
|
|
|
+ ui->tableWidget->setColumnWidth(col++,30);
|
|
|
+ ui->tableWidget->setColumnWidth(col++,0);
|
|
|
+ ui->tableWidget->setColumnWidth(col++,110);
|
|
|
+ ui->tableWidget->setColumnWidth(col++,0);//
|
|
|
+ ui->tableWidget->setColumnWidth(col++,140);
|
|
|
+ ui->tableWidget->setColumnWidth(col++,140);
|
|
|
+ ui->tableWidget->setColumnWidth(col++,73);
|
|
|
+ ui->tableWidget->setColumnWidth(col++,61);
|
|
|
+ ui->tableWidget->setColumnWidth(col++,60);
|
|
|
+ ui->tableWidget->setColumnWidth(col++,40);
|
|
|
+
|
|
|
+ ui->widgetExactCheck->setProperty("class","lowframe2");
|
|
|
+
|
|
|
+ //初始化预检测 实号、空、停、关机对应的显示图片exact_result_bg.jpg
|
|
|
+ QPixmap exact_result_bg(":/exact_result_bg.jpg");
|
|
|
+ int nHeight = exact_result_bg.height()/10;
|
|
|
+ int nWidth = exact_result_bg.width();
|
|
|
+
|
|
|
+ ui->labelBarQwld->setPixmap(exact_result_bg.copy(QRect(0 , 0 * nHeight, nWidth, nHeight)));
|
|
|
+ ui->labelBarLaji->setPixmap(exact_result_bg.copy(QRect(0 , 1 * nHeight, nWidth, nHeight)));
|
|
|
+ ui->labelBarShiHao->setPixmap(exact_result_bg.copy(QRect(0 , 2 * nHeight, nWidth, nHeight)));
|
|
|
+ ui->labelBarKong->setPixmap(exact_result_bg.copy(QRect(0 , 3 * nHeight, nWidth, nHeight)));
|
|
|
+ ui->labelBarTing->setPixmap(exact_result_bg.copy(QRect(0 , 4 * nHeight, nWidth, nHeight)));
|
|
|
+ ui->labelBarGuan->setPixmap(exact_result_bg.copy(QRect(0 , 5 * nHeight, nWidth, nHeight)));
|
|
|
+
|
|
|
+ ui->labelBarHrxz->setPixmap(exact_result_bg.copy(QRect(0 , 6 * nHeight, nWidth, nHeight)));
|
|
|
+ ui->labelBarWfjt->setPixmap(exact_result_bg.copy(QRect(0 , 7 * nHeight, nWidth, nHeight)));
|
|
|
+ ui->labelBarLdtx->setPixmap(exact_result_bg.copy(QRect(0 , 8 * nHeight, nWidth, nHeight)));
|
|
|
+ ui->labelBarOther->setPixmap(exact_result_bg.copy(QRect(0 , 9 * nHeight, nWidth, nHeight)));
|
|
|
+
|
|
|
+ //初始化图例图标实号、空、停、关机对应的显示图片sample_small.jpg
|
|
|
+ QPixmap sample_small(":/sample_small.jpg");
|
|
|
+ nHeight = sample_small.height();
|
|
|
+ nWidth = sample_small.width()/10;
|
|
|
+
|
|
|
+ ui->labelSampleQwdr->setPixmap(sample_small.copy(QRect(0 * nWidth , 0 , nWidth, nHeight)));
|
|
|
+ ui->labelSampleLaji->setPixmap(sample_small.copy(QRect(1 * nWidth , 0 , nWidth, nHeight)));
|
|
|
+ ui->labelSampleShiHao->setPixmap(sample_small.copy(QRect(2 * nWidth , 0 , nWidth, nHeight)));
|
|
|
+ ui->labelSampleKong->setPixmap(sample_small.copy(QRect(3 * nWidth , 0 , nWidth, nHeight)));
|
|
|
+ ui->labelSampleTing->setPixmap(sample_small.copy(QRect(4 * nWidth , 0 , nWidth, nHeight)));
|
|
|
+ ui->labelSampleGuan->setPixmap(sample_small.copy(QRect(5 * nWidth , 0 , nWidth, nHeight)));
|
|
|
+ ui->labelSampleHrxz->setPixmap(sample_small.copy(QRect(6 * nWidth , 0 , nWidth, nHeight)));
|
|
|
+ ui->labelSampleWfjt->setPixmap(sample_small.copy(QRect(7 * nWidth , 0 , nWidth, nHeight)));
|
|
|
+ ui->labelSampleLdtx->setPixmap(sample_small.copy(QRect(8 * nWidth , 0 , nWidth, nHeight)));
|
|
|
+ ui->labelSampleOther->setPixmap(sample_small.copy(QRect(9 * nWidth , 0 , nWidth, nHeight)));
|
|
|
+
|
|
|
+ ui->pushButtonDel->setVisible(false);
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::setTableWidgetNoData(QTableWidget *tableWidget)
|
|
|
+{
|
|
|
+ prepareTableWidgetCells(tableWidget,8);
|
|
|
+ tableWidget->setEnabled(false);
|
|
|
+ QTableWidgetItem *item = new QTableWidgetItem();
|
|
|
+ item->setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
|
|
|
+ item->setText("暂无信息");
|
|
|
+ tableWidget->setItem(4,6,item);
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::setDetailNoData()
|
|
|
+{
|
|
|
+ ui->labelShiHao->setText("实号");
|
|
|
+ ui->labelKong->setText("空号");
|
|
|
+ ui->labelTing->setText("停机");
|
|
|
+ ui->labelGuan->setText("关机");
|
|
|
+ ui->labelWfjt->setText("无法接通");
|
|
|
+ ui->labelLdtx->setText("来电提醒");
|
|
|
+ ui->labelHrxz->setText("呼入限制");
|
|
|
+ ui->labelQwld->setText("请勿来电");
|
|
|
+ ui->labelLaji->setText("垃圾号码");
|
|
|
+ ui->labelOther->setText("其他");
|
|
|
+
|
|
|
+ //设置上述状态比例的默认宽度为0
|
|
|
+ ui->labelBarShiHao->setFixedWidth(0);
|
|
|
+ ui->labelBarKong->setFixedWidth(0);
|
|
|
+ ui->labelBarTing->setFixedWidth(0);
|
|
|
+ ui->labelBarGuan->setFixedWidth(0);
|
|
|
+ ui->labelBarWfjt->setFixedWidth(0);
|
|
|
+ ui->labelBarLdtx->setFixedWidth(0);
|
|
|
+ ui->labelBarHrxz->setFixedWidth(0);
|
|
|
+ ui->labelBarQwld->setFixedWidth(0);
|
|
|
+ ui->labelBarLaji->setFixedWidth(0);
|
|
|
+ ui->labelBarOther->setFixedWidth(0);
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::setTableWidgetSyncData(QTableWidget *tableWidget)
|
|
|
+{
|
|
|
+ prepareTableWidgetCells(tableWidget,8);
|
|
|
+ tableWidget->setEnabled(false);
|
|
|
+ QLabel *lbl = new QLabel();
|
|
|
+
|
|
|
+ QTableWidgetItem *item = new QTableWidgetItem("正在读取...");
|
|
|
+ lbl->setMovie(m_movieBig);
|
|
|
+ lbl->setAlignment(Qt::AlignRight);
|
|
|
+ item->setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
|
|
|
+ tableWidget->setItem(4,6,item);
|
|
|
+ tableWidget->setCellWidget(4,5,lbl);
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::prepareTableWidgetCells(QTableWidget *tableWidget, int rows)
|
|
|
+{
|
|
|
+ tableWidget->setRowCount(0);
|
|
|
+ tableWidget->setRowCount(rows);
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::fillDataList(QTableWidget *tableWidget,QStringList keys,
|
|
|
+ QMultiMap<QString, QString> list, int rowCount)
|
|
|
+{
|
|
|
+ setTableWidgetNoData(tableWidget);
|
|
|
+ if(rowCount==0)
|
|
|
+ {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ prepareTableWidgetCells(tableWidget,rowCount);
|
|
|
+ tableWidget->setEnabled(true);
|
|
|
+ for(int row = 0;row < rowCount;row++)
|
|
|
+ {
|
|
|
+ QMap<QString,QString> map;
|
|
|
+ for(int col=0;col<keys.size();col++)
|
|
|
+ {
|
|
|
+ QString key = keys.at(col);
|
|
|
+ QString value = list.values(key).at(row);
|
|
|
+ map.insert(key,value);
|
|
|
+ }
|
|
|
+ for(int col=0;col<keys.size();col++)
|
|
|
+ {
|
|
|
+ QString key = keys.at(col);
|
|
|
+ QString value = list.values(key).at(row);
|
|
|
+ setCellElement(tableWidget,row,col,key,value,map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //添加按钮
|
|
|
+ for(int row = 0;row < rowCount;row++)
|
|
|
+ {
|
|
|
+ QPushButton *button = new QPushButton();
|
|
|
+ button->setCursor(Qt::PointingHandCursor);
|
|
|
+ button->setProperty("class","imagebutton");
|
|
|
+ connect(button,SIGNAL(clicked()),this,SLOT(onSingleDownloadClick()));
|
|
|
+
|
|
|
+ ui->tableWidget->setCellWidget(row,tableWidget->columnCount()-1,button);
|
|
|
+ }
|
|
|
+ tableWidget->sortByColumn(0);
|
|
|
+ tableWidget->sortByColumn(0);
|
|
|
+}
|
|
|
+void FormWoolFinished::setCellElement(QTableWidget *tableWidget, int row, int col,
|
|
|
+ QString key,QString value,QMap<QString,QString> data)
|
|
|
+{
|
|
|
+ QTableWidgetItem* item = new QTableWidgetItem();
|
|
|
+ QVariant display = value;
|
|
|
+ QVariant tooltip = value;
|
|
|
+ item->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
|
|
+ //进行数据翻译
|
|
|
+
|
|
|
+ if(key=="batchid")
|
|
|
+ {
|
|
|
+ display = "";
|
|
|
+ tooltip = "";
|
|
|
+ item->setCheckState(Qt::Unchecked);
|
|
|
+ }
|
|
|
+ else if(key=="detail")
|
|
|
+ {
|
|
|
+ QStringList info = display.toString().split("\r\n");
|
|
|
+ QString filename;
|
|
|
+ if(info.size()>4)
|
|
|
+ {
|
|
|
+ if(info.at(4).split(":").size()>1)
|
|
|
+ {
|
|
|
+ filename = info.at(4).split(":").at(1);
|
|
|
+ }
|
|
|
+ display = filename;
|
|
|
+ }
|
|
|
+ item->setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
|
|
|
+ }
|
|
|
+ else if(key=="finishcount")
|
|
|
+ {
|
|
|
+ display = value.toInt();
|
|
|
+ tooltip = display;
|
|
|
+ }
|
|
|
+ else if(key=="settlefee")
|
|
|
+ {
|
|
|
+ display = value.toDouble();
|
|
|
+ tooltip = display;
|
|
|
+ }
|
|
|
+ else if(key=="giftfee")
|
|
|
+ {
|
|
|
+ display = value.toDouble();
|
|
|
+ tooltip = display;
|
|
|
+ }
|
|
|
+ //设置单元格显示形式,是用item填充还是widget填充
|
|
|
+
|
|
|
+ if(key == "isdeliver")
|
|
|
+ {
|
|
|
+ delete item;
|
|
|
+ QLabel *lbl = new QLabel(this);
|
|
|
+ lbl->setAlignment(Qt::AlignCenter|Qt::AlignHCenter);
|
|
|
+ lbl->setProperty("value",value);
|
|
|
+ if(value=="0")
|
|
|
+ {
|
|
|
+ QString ispass = data.value("ispass");
|
|
|
+ if(ispass=="0")
|
|
|
+ {
|
|
|
+ lbl->setPixmap(QPixmap(":/task_nopass.png"));
|
|
|
+ lbl->setToolTip("未放行");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lbl->setPixmap(QPixmap(":/todown.png"));
|
|
|
+ lbl->setToolTip("未下载");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(value=="1")
|
|
|
+ {
|
|
|
+ lbl->setPixmap(QPixmap(":/task_ok.png"));
|
|
|
+ lbl->setToolTip("已下载");
|
|
|
+ }
|
|
|
+ tableWidget->setCellWidget(row,col,lbl);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ item->setData(Qt::DisplayRole,display);
|
|
|
+ item->setData(Qt::UserRole,value);
|
|
|
+ item->setData(Qt::ToolTipRole,tooltip);
|
|
|
+ tableWidget->setItem(row,col,item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+void FormWoolFinished::query(QString dealstatus)
|
|
|
+{
|
|
|
+ QString userCode = m_account.value("usercode");
|
|
|
+ QMultiMap<QString,QString> list = SNCDataBase::getWoolCheckFinishInfos(userCode,m_clientID,dealstatus);
|
|
|
+ int cols = list.uniqueKeys().size();
|
|
|
+ int rows = 0;
|
|
|
+ if(cols!=0)
|
|
|
+ rows = list.size()/cols;
|
|
|
+ if(list.size()==0)
|
|
|
+ {
|
|
|
+ setTableWidgetNoData(ui->tableWidget);
|
|
|
+ setDetailNoData();
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ QStringList ids;
|
|
|
+ QString curId;
|
|
|
+ for(int i=0;i<ui->tableWidget->rowCount();i++)
|
|
|
+ {
|
|
|
+ QTableWidgetItem *item = ui->tableWidget->item(i,0);
|
|
|
+ if(item)
|
|
|
+ {
|
|
|
+ if(item->checkState()==Qt::Checked)
|
|
|
+ {
|
|
|
+ ids<<item->data(Qt::UserRole).toString();
|
|
|
+ }
|
|
|
+ if(item->isSelected())
|
|
|
+ {
|
|
|
+ curId = item->data(Qt::UserRole).toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fillDataList(ui->tableWidget,m_keys,list,rows);
|
|
|
+ for(int i=0;i<ui->tableWidget->rowCount();i++)
|
|
|
+ {
|
|
|
+ if(curId.isEmpty())
|
|
|
+ {
|
|
|
+ ui->tableWidget->selectRow(i);
|
|
|
+ on_tableWidget_cellClicked(i,0);
|
|
|
+ ui->tableWidget->setFocus();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ QTableWidgetItem *item = ui->tableWidget->item(i,0);
|
|
|
+ if(item)
|
|
|
+ {
|
|
|
+ QString id = item->data(Qt::UserRole).toString();
|
|
|
+ if(curId==id)
|
|
|
+ {
|
|
|
+ ui->tableWidget->selectRow(i);
|
|
|
+ on_tableWidget_cellClicked(i,0);
|
|
|
+ ui->tableWidget->setFocus();
|
|
|
+ }
|
|
|
+ for(int i=0;i<ids.size();i++)
|
|
|
+ {
|
|
|
+ if(id==ids.at(i))
|
|
|
+ {
|
|
|
+ item->setCheckState(Qt::Checked);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::showRtnMessage(int row)
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+bool FormWoolFinished::addFileToZip(QString zipName, QStringList files)
|
|
|
+{
|
|
|
+ Zip::ErrorCode ec;
|
|
|
+ Zip uz;
|
|
|
+
|
|
|
+ QFile file(zipName);
|
|
|
+ if(!file.open(QIODevice::WriteOnly)){
|
|
|
+ return false ;
|
|
|
+ }
|
|
|
+ file.close();
|
|
|
+ ec = uz.createArchive(zipName);
|
|
|
+ if (ec != Zip::Ok) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ ec = uz.addFiles(files);
|
|
|
+ if (ec != Zip::Ok) {
|
|
|
+ uz.closeArchive();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (uz.closeArchive() != Zip::Ok) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::displaySelected(QString detail)
|
|
|
+{
|
|
|
+ QStringList list = detail.split("\r\n");
|
|
|
+ qDebug()<<list.size()<<list;
|
|
|
+ int i=0;
|
|
|
+ int k = 0;
|
|
|
+ if(list.size()==10)
|
|
|
+ {
|
|
|
+ k=0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ setDetailNoData();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ QStringList rates;
|
|
|
+ for(int i=0;i<list.size();i++)
|
|
|
+ {
|
|
|
+ QRegExp rx("\\((.+)\\)");
|
|
|
+ int pos = rx.indexIn(list.at(i));
|
|
|
+ if(pos>0)
|
|
|
+ {
|
|
|
+ QString match = rx.capturedTexts().at(1);
|
|
|
+ rates<<match.replace("%","");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ rates<<"0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ i = k;
|
|
|
+ ui->labelKong->setText(list.at(i++));
|
|
|
+ ui->labelTing->setText(list.at(i++));
|
|
|
+ ui->labelGuan->setText(list.at(i++));
|
|
|
+ ui->labelHrxz->setText(list.at(i++));
|
|
|
+ ui->labelWfjt->setText(list.at(i++));
|
|
|
+ ui->labelLdtx->setText(list.at(i++));
|
|
|
+ ui->labelShiHao->setText(list.at(i++));
|
|
|
+ ui->labelQwld->setText(list.at(i++));
|
|
|
+ ui->labelLaji->setText(list.at(i++));
|
|
|
+ ui->labelOther->setText(list.at(i++));
|
|
|
+ i = k;
|
|
|
+ int barLength = 650;
|
|
|
+
|
|
|
+ ui->labelBarKong->setFixedWidth(rates.at(i++).toDouble()*barLength/100);
|
|
|
+ ui->labelBarTing->setFixedWidth(rates.at(i++).toDouble()*barLength/100);
|
|
|
+ ui->labelBarGuan->setFixedWidth(rates.at(i++).toDouble()*barLength/100);
|
|
|
+ ui->labelBarWfjt->setFixedWidth(rates.at(i++).toDouble()*barLength/100);
|
|
|
+ ui->labelBarHrxz->setFixedWidth(rates.at(i++).toDouble()*barLength/100);
|
|
|
+ ui->labelBarLdtx->setFixedWidth(rates.at(i++).toDouble()*barLength/100);
|
|
|
+ ui->labelBarShiHao->setFixedWidth(rates.at(i++).toDouble()*barLength/100);
|
|
|
+ ui->labelBarQwld->setFixedWidth(rates.at(i++).toDouble()*barLength/100);
|
|
|
+ ui->labelBarLaji->setFixedWidth(rates.at(i++).toDouble()*barLength/100);
|
|
|
+ ui->labelBarOther->setFixedWidth(rates.at(i++).toDouble()*barLength/100);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void FormWoolFinished::onDataUpdated()
|
|
|
+{
|
|
|
+ if(ui->radioButtonAll->isChecked())
|
|
|
+ {
|
|
|
+ query("");
|
|
|
+ }
|
|
|
+ else if(ui->radioButtonUndown->isChecked())
|
|
|
+ {
|
|
|
+ query("0");
|
|
|
+ }
|
|
|
+ else if(ui->radioButtonDown->isChecked())
|
|
|
+ {
|
|
|
+ query("1");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+QString FormWoolFinished::getSingleZipFileName(QString id)
|
|
|
+{
|
|
|
+ QFileDialog::Options options;
|
|
|
+ QString selectedFilter;
|
|
|
+ QString exportDir = SNCDataBase::getExportDir();
|
|
|
+
|
|
|
+ QString defaultZipFileName = m_clientName + "_" + id ;
|
|
|
+ QString saveZipFileName = QFileDialog::getSaveFileName(this,"另存为",exportDir + "\\" + defaultZipFileName,
|
|
|
+ tr("ZIP Files (*.zip)"),
|
|
|
+ &selectedFilter,
|
|
|
+ options);
|
|
|
+ if(!saveZipFileName.isEmpty())
|
|
|
+ {
|
|
|
+ QFileInfo fileInfo(saveZipFileName);
|
|
|
+ exportDir = fileInfo.absolutePath();
|
|
|
+ SNCDataBase::updateExportDir(exportDir);
|
|
|
+ }
|
|
|
+ return saveZipFileName;
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::on_pushButtonDownload_clicked()
|
|
|
+{
|
|
|
+ if(!chkAccountState(m_state))
|
|
|
+ return;
|
|
|
+ int selected = 0;
|
|
|
+ for(int i=0;i<ui->tableWidget->rowCount();i++)
|
|
|
+ {
|
|
|
+ QTableWidgetItem *item = ui->tableWidget->item(i,0);
|
|
|
+ if(item)
|
|
|
+ {
|
|
|
+ if(item->checkState()==Qt::Checked)
|
|
|
+ selected++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(selected==0)
|
|
|
+ {
|
|
|
+ QMessageBox::critical(this,"提示","请选择要下载的数据!",QMessageBox::Ok);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ QString saveZipFileName = getPackZipFileName();
|
|
|
+ if(saveZipFileName.isEmpty())
|
|
|
+ return ;
|
|
|
+
|
|
|
+ QDir dir;
|
|
|
+ if(!dir.exists(QDir::tempPath()+"/speednumcube"))
|
|
|
+ {
|
|
|
+ dir.mkdir(QDir::tempPath()+"/speednumcube");
|
|
|
+ }
|
|
|
+ QString tmpDir = QDir::tempPath()+"/speednumcube/";
|
|
|
+ QStringList files;
|
|
|
+ ui->pushButtonDownload->setEnabled(false);
|
|
|
+ this->setCursor(Qt::WaitCursor);
|
|
|
+ for(int i=0;i<ui->tableWidget->rowCount();i++)
|
|
|
+ {
|
|
|
+ QTableWidgetItem *item = ui->tableWidget->item(i,0);
|
|
|
+ if(item->checkState()==Qt::Checked)
|
|
|
+ {
|
|
|
+ QString id = item->data(Qt::UserRole).toString();
|
|
|
+ QString fileName = tmpDir + id + ".zip";
|
|
|
+ QFile::remove(fileName);
|
|
|
+ if(download(id,fileName,false))
|
|
|
+ {
|
|
|
+ files.append(fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this->setCursor(Qt::ArrowCursor);
|
|
|
+ if(files.size()>0)
|
|
|
+ {
|
|
|
+ if(addFileToZip(saveZipFileName,files))
|
|
|
+ {
|
|
|
+ QMessageBox::information(this,"结果",QString("您选择%1个文件,%2个文件下载成功!")\
|
|
|
+ .arg(selected).arg(files.size()),QMessageBox::Ok);
|
|
|
+ QFileInfo fileinfo(saveZipFileName);
|
|
|
+ SNCDataBase::updateExportDir(fileinfo.absolutePath());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ QMessageBox::critical(this,"结果","检测结果文件下载失败!",QMessageBox::Ok);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ QMessageBox::critical(this,"结果","检测结果文件下载失败!",QMessageBox::Ok);
|
|
|
+ }
|
|
|
+ ui->pushButtonDownload->setEnabled(true);
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::on_tableWidget_cellClicked(int row, int column)
|
|
|
+{
|
|
|
+ if(row>=0&&column>=0)
|
|
|
+ {
|
|
|
+ QString detail = ui->tableWidget->item(row,4)->data(Qt::UserRole).toString();
|
|
|
+ displaySelected(detail);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::on_radioButtonAll_clicked()
|
|
|
+{
|
|
|
+ if(!chkAccountState(m_state))
|
|
|
+ return;
|
|
|
+ if(ui->radioButtonAll->isChecked())
|
|
|
+ {
|
|
|
+ query("");
|
|
|
+ }
|
|
|
+ else if(ui->radioButtonUndown->isChecked())
|
|
|
+ {
|
|
|
+ query("0");
|
|
|
+ }
|
|
|
+ else if(ui->radioButtonDown->isChecked())
|
|
|
+ {
|
|
|
+ query("1");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::on_radioButtonUndown_clicked()
|
|
|
+{
|
|
|
+ if(!chkAccountState(m_state))
|
|
|
+ return;
|
|
|
+ on_radioButtonAll_clicked();
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::on_radioButtonDown_clicked()
|
|
|
+{
|
|
|
+ if(!chkAccountState(m_state))
|
|
|
+ return;
|
|
|
+ on_radioButtonAll_clicked();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void FormWoolFinished::on_checkBoxAll_clicked()
|
|
|
+{
|
|
|
+ Qt::CheckState state;
|
|
|
+ state = ui->checkBoxAll->checkState();
|
|
|
+ for(int i=0;i<ui->tableWidget->rowCount();i++)
|
|
|
+ {
|
|
|
+ QTableWidgetItem *item = ui->tableWidget->item(i,0);
|
|
|
+ if(item)
|
|
|
+ {
|
|
|
+ item->setCheckState(state);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::on_tableWidget_cellDoubleClicked(int row, int column)
|
|
|
+{
|
|
|
+ QString id = "";
|
|
|
+ QString ispass = "";
|
|
|
+
|
|
|
+ QTableWidgetItem *item;
|
|
|
+ item = ui->tableWidget->item(row,0);
|
|
|
+ if(item)
|
|
|
+ {
|
|
|
+ id = item->data(Qt::UserRole).toString();
|
|
|
+ }
|
|
|
+ item = ui->tableWidget->item(row,2);
|
|
|
+ if(item)
|
|
|
+ {
|
|
|
+ ispass = item->data(Qt::UserRole).toString();
|
|
|
+ }
|
|
|
+ if(id.isEmpty())
|
|
|
+ {
|
|
|
+ QMessageBox::critical(this,"结果","未能获取有效的文件编号!",QMessageBox::Ok);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if(ispass!="1")
|
|
|
+ {
|
|
|
+ QMessageBox::critical(this,"结果","单子还未放行!",QMessageBox::Ok);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ QString saveFile = getSingleZipFileName(id);
|
|
|
+ if(saveFile.isEmpty())
|
|
|
+ return ;
|
|
|
+ this->setCursor(Qt::WaitCursor);
|
|
|
+ download(id,saveFile,true);
|
|
|
+ this->setCursor(Qt::ArrowCursor);
|
|
|
+
|
|
|
+}
|
|
|
+bool FormWoolFinished::download(QString srvID,QString saveZipFileName,bool show)
|
|
|
+{
|
|
|
+
|
|
|
+ QString cachePath = SNCDataBase::getWoolCachePath(srvID);
|
|
|
+ bool iscached = false;
|
|
|
+
|
|
|
+ if(!cachePath.isEmpty())
|
|
|
+ {
|
|
|
+ if(QFile::exists(cachePath))
|
|
|
+ {
|
|
|
+ iscached = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(iscached)
|
|
|
+ {
|
|
|
+ return downloadFromLocal(saveZipFileName,cachePath,show);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return downloadFromServer(saveZipFileName,srvID,show);
|
|
|
+ }
|
|
|
+}
|
|
|
+bool FormWoolFinished::downloadFromLocal(QString saveFileName,QString cacheFile,bool show)
|
|
|
+{
|
|
|
+
|
|
|
+ QFile::copy(cacheFile,saveFileName);
|
|
|
+ if(show)
|
|
|
+ QMessageBox::information(this,"提示","下载成功!",QMessageBox::Ok);
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+bool FormWoolFinished::downloadFromServer(QString saveFileName, QString srvID, bool show)
|
|
|
+{
|
|
|
+ QString userHash = m_account.value("userhash");
|
|
|
+ QString json = m_wool->dlResultFile(srvID,userHash);
|
|
|
+
|
|
|
+ RespDlResultFile response(json);
|
|
|
+ if(response.getRtnCode()==2)
|
|
|
+ {
|
|
|
+ QString fileContent = response.getFileContent();
|
|
|
+ QByteArray array = QByteArray::fromBase64(fileContent.toAscii());
|
|
|
+ QFile file(saveFileName);
|
|
|
+ file.open(QIODevice::WriteOnly);
|
|
|
+ file.write(array);
|
|
|
+ file.close();
|
|
|
+ QString cachPath = cacheDownloadFile(saveFileName);
|
|
|
+ SNCDataBase::updateWoolCachePath(srvID,cachPath);
|
|
|
+ if(show)
|
|
|
+ QMessageBox::information(this,"结果","单子下载成功",QMessageBox::Ok);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(show)
|
|
|
+ QMessageBox::critical(this,"结果",response.getRtnMemo(),QMessageBox::Ok);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+QString FormWoolFinished::cacheDownloadFile(QString fileName)
|
|
|
+{
|
|
|
+ QString userCode = m_account.value("usercode");
|
|
|
+ QString date = QDate::currentDate().toString("yyyyMM");
|
|
|
+ QString cachePath = QCoreApplication::applicationDirPath()+\
|
|
|
+ QString("/../data/%1/cache/Wool/download/%2/").arg(userCode).arg(date);
|
|
|
+ QDir dir;
|
|
|
+ dir.mkpath(cachePath);
|
|
|
+ QFileInfo fileinfo(fileName);
|
|
|
+ QFile::copy(fileName,cachePath + fileinfo.fileName());
|
|
|
+ return cachePath + fileinfo.fileName();
|
|
|
+}
|
|
|
+
|
|
|
+bool FormWoolFinished::chkAccountState(AccountLoginState state)
|
|
|
+{
|
|
|
+
|
|
|
+ bool ret = false;
|
|
|
+ switch(state)
|
|
|
+ {
|
|
|
+ case NotLogin:
|
|
|
+ QMessageBox::critical(this,"提示","您现在还没有登录系统,请登录后再操作!",QMessageBox::Ok);
|
|
|
+ break;
|
|
|
+ case NotBind:
|
|
|
+ QMessageBox::critical(this,"提示","此项服务尚未开通,请开通后再操作!",QMessageBox::Ok);
|
|
|
+ break;
|
|
|
+ case LoginError:
|
|
|
+ QMessageBox::critical(this,"提示","此项服务暂时无法连接,请稍候重试!",QMessageBox::Ok);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ ret = true;
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+QString FormWoolFinished::getPackZipFileName()
|
|
|
+{
|
|
|
+ QFileDialog::Options options;
|
|
|
+ QString selectedFilter;
|
|
|
+ QString exportDir = SNCDataBase::getExportDir();
|
|
|
+
|
|
|
+ QString defaultZipFileName = QString(m_clientName);
|
|
|
+ int count = 0;
|
|
|
+ QString str ="";
|
|
|
+ QString download = "";
|
|
|
+ for(int i=0;i<ui->tableWidget->rowCount();i++)
|
|
|
+ {
|
|
|
+ QTableWidgetItem *item = ui->tableWidget->item(i,0);
|
|
|
+ if(item)
|
|
|
+ {
|
|
|
+ if(item->checkState()==Qt::Checked)
|
|
|
+ {
|
|
|
+ count++;
|
|
|
+ str += "_" + item->text();
|
|
|
+ QTableWidgetItem *item2 = ui->tableWidget->item(i,2);
|
|
|
+ if(item2)
|
|
|
+ {
|
|
|
+ if(item2->data(Qt::UserRole).toString()!="1")
|
|
|
+ {
|
|
|
+ download += item->data(Qt::UserRole).toString()+ " ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(count==0)
|
|
|
+ return "";
|
|
|
+ if(!download.isEmpty())
|
|
|
+ {
|
|
|
+ QMessageBox::critical(this,"提示","您选择的单子" + download + "现在还没有放行,暂时无法下载,请稍候再试!",QMessageBox::Ok);
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ defaultZipFileName += "_" + QString::number(count) + str ;
|
|
|
+ QString saveZipFileName = QFileDialog::getSaveFileName(this,"另存为",exportDir + "\\" + defaultZipFileName,
|
|
|
+ tr("ZIP Files (*.zip)"),
|
|
|
+ &selectedFilter,
|
|
|
+ options);
|
|
|
+ if(!saveZipFileName.isEmpty())
|
|
|
+ {
|
|
|
+ QFileInfo fileInfo(saveZipFileName);
|
|
|
+ exportDir = fileInfo.absolutePath();
|
|
|
+ SNCDataBase::updateExportDir(exportDir);
|
|
|
+ }
|
|
|
+ return saveZipFileName;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void FormWoolFinished::on_pushButtonDel_clicked()
|
|
|
+{
|
|
|
+ if(!chkAccountState(m_state))
|
|
|
+ return ;
|
|
|
+ bool nodata = true;
|
|
|
+ for(int i=0;i<ui->tableWidget->rowCount();i++)
|
|
|
+ {
|
|
|
+ QTableWidgetItem *item = ui->tableWidget->item(i,0);
|
|
|
+ if(item)
|
|
|
+ {
|
|
|
+ if(item->checkState()==Qt::Checked)
|
|
|
+ {
|
|
|
+ nodata = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(nodata)
|
|
|
+ {
|
|
|
+ QMessageBox::critical(this,"提示","请选择要删除的单子",QMessageBox::Ok);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ for(int i=0;i<ui->tableWidget->rowCount();i++)
|
|
|
+ {
|
|
|
+ QTableWidgetItem *item = ui->tableWidget->item(i,0);
|
|
|
+ if(item)
|
|
|
+ {
|
|
|
+ if(item->checkState()==Qt::Checked)
|
|
|
+ {
|
|
|
+ QTableWidgetItem *item = ui->tableWidget->item(i,6);
|
|
|
+ if(item)
|
|
|
+ {
|
|
|
+ QDateTime datetime = QDateTime::currentDateTime();
|
|
|
+ QDateTime datetime2 = QDateTime::fromString(item->data(Qt::UserRole).toString(),"yyyy-MM-dd hh:mm:ss");
|
|
|
+ if(datetime2>datetime.addDays(-3))
|
|
|
+ {
|
|
|
+ QMessageBox::critical(this,"提示","你只能删除3天前的单子,3天内的单子系统会自动同步",QMessageBox::Ok);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(int i=0;i<ui->tableWidget->rowCount();i++)
|
|
|
+ {
|
|
|
+ QTableWidgetItem *item = ui->tableWidget->item(i,0);
|
|
|
+ if(item)
|
|
|
+ {
|
|
|
+ if(item->checkState()==Qt::Checked)
|
|
|
+ {
|
|
|
+ QString id = item->data(Qt::UserRole).toString();
|
|
|
+ SNCDataBase::delShkjByID(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ on_radioButtonAll_clicked();
|
|
|
+}
|
|
|
+
|
|
|
+void FormWoolFinished::onSingleDownloadClick()
|
|
|
+{
|
|
|
+ QPushButton *btn = qobject_cast<QPushButton*>(sender());
|
|
|
+ for(int i=0;i<ui->tableWidget->rowCount();i++)
|
|
|
+ {
|
|
|
+ QWidget *widget = ui->tableWidget->cellWidget(i,10);
|
|
|
+ if(widget)
|
|
|
+ {
|
|
|
+ if(btn==qobject_cast<QPushButton*>(widget))
|
|
|
+ {
|
|
|
+ on_tableWidget_cellDoubleClicked(i,1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|