From aa013c2f4e69e2ba4eb72081dc004d8334d59257 Mon Sep 17 00:00:00 2001
From: wumu <mayi@mayi.com>
Date: 星期一, 28 十月 2024 23:15:27 +0800
Subject: [PATCH] 1028

---
 internal_system_v1/converinfo2.cpp |  222 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 183 insertions(+), 39 deletions(-)

diff --git a/internal_system_v1/converinfo2.cpp b/internal_system_v1/converinfo2.cpp
index a51a114..466e8b9 100644
--- a/internal_system_v1/converinfo2.cpp
+++ b/internal_system_v1/converinfo2.cpp
@@ -15,8 +15,9 @@
     ui->setupUi(this);
     m_menu = nullptr;
     //initUi();
-    readInfo(); // 鍔犺浇琛ㄦ牸
+    //readInfo(); // 鍔犺浇琛ㄦ牸
     addMenu(); // 澧炲姞鑿滃崟
+    disableWheelEvent(); // 绂佺敤涓嬫媺妗嗙殑婊氳疆浜嬩欢
 
     // 鑷�傚簲澶勭悊
     ui->treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
@@ -49,7 +50,7 @@
     it4->setCheckState(0,Qt::Checked);
 
     // 澶嶉�夋鐘舵�佸鐞�
-    connect(ui->treeWidget,QOverload<QTreeWidgetItem*,int>::of(QTreeWidget::itemClicked),this,[=](QTreeWidgetItem* it,int index){
+    connect(ui->treeWidget,QOverload<QTreeWidgetItem*,int>::of(&QTreeWidget::itemClicked),this,[=](QTreeWidgetItem* it,int index){
         qDebug()<<it<<index;
         if(it == top1){
             qDebug()<<"鐐瑰嚮浜嗙爜铓侀泦鍥�";
@@ -90,12 +91,16 @@
 {
     if(m_curItem==nullptr)return;
     qDebug()<<"娣诲姞鍏徃淇℃伅,鍦ㄨ妭鐐癸細"<<m_curItem->text(0);
+    on_pushButton_laodFile_clicked();
 }
 
 void ConverInfo2::deleteInfo()
 {
     if(m_curItem==nullptr)return;
     qDebug()<<"鍒犻櫎鍏徃淇℃伅,鑺傜偣锛�"<<m_curItem->text(0);
+    auto resList = m_curItem->takeChildren();
+
+    qDebug()<<"鍒犻櫎鏁伴噺:"<<resList.size();
 }
 
 void ConverInfo2::on_treeWidget_doubleClicked(const QModelIndex &index)
@@ -103,6 +108,47 @@
     QString name = index.model()->data(index).toString();
     qDebug()<<"鍙屽嚮"<<index<<name;
     ComInfo curCominfo = m_nameAndComInfos[name];
+    if(name.contains("(鏈骇)")){
+        QStringList sps = name.split("(鏈骇)");
+        name = sps.at(0);
+        curCominfo = m_nameAndComInfos[name];
+    }else if(name.contains("(姹囨��)")){
+        name = name.split("(姹囨��)").at(0);
+        qDebug()<<"姹囨�诲鐞�:";
+        // 鍋氫竴涓眹鎬荤殑澶勭悊锛屾妸鎵�鏈変笅绾х殑閮界疮鍔犺捣鏉�
+        ComInfo allCominfo = m_nameAndComInfos[name];
+        for(QString cur:m_treeNodes[name]){
+            if(name != cur){
+                ComInfo &tmp = m_nameAndComInfos[cur];
+                allCominfo.organazationNum += tmp.organazationNum;
+                allCominfo.realNum += tmp.realNum;
+                allCominfo.professionalNum += tmp.professionalNum;
+                allCominfo.CIANum += tmp.CIANum;
+                allCominfo.masterNum += tmp.masterNum;
+                allCominfo.undergraduatesNum += tmp.undergraduatesNum;
+                allCominfo.juniorNum += tmp.juniorNum;
+                allCominfo.seniorNum += tmp.seniorNum;
+                allCominfo.intermediateNum += tmp.intermediateNum;
+                allCominfo.primaryNum += tmp.primaryNum;
+                allCominfo.noTitleNum += tmp.noTitleNum;
+                allCominfo.upFiftyOldNum += tmp.upFiftyOldNum;
+                allCominfo.upThirtyOldNum += tmp.upThirtyOldNum;
+                allCominfo.downThirtyOldNum += tmp.downThirtyOldNum;
+                allCominfo.auditNum += tmp.auditNum;
+                allCominfo.accountingNum += tmp.accountingNum;
+                allCominfo.economyNum += tmp.economyNum;
+                allCominfo.lawNum += tmp.lawNum;
+                allCominfo.managerNum += tmp.managerNum;
+                allCominfo.itNum += tmp.itNum;
+                allCominfo.engineeringNum += tmp.engineeringNum;
+                allCominfo.otherNum += tmp.otherNum;
+            }
+
+        }
+        curCominfo = allCominfo;
+
+    }
+    //ComInfo curCominfo = m_nameAndComInfos[name];
     // 涓�銆佸崟浣嶅熀鏈儏鍐�
     ui->lineEdit_creditCode->setText(curCominfo.creditCode);
     ui->lineEdit_name->setText(QString::fromLocal8Bit( curCominfo.name));
@@ -203,11 +249,15 @@
         it.next();
         list.append(it.fileInfo().absoluteFilePath());
     }
+    int allSize = list.size();
+    float cntIdx=1.0;
     foreach(QString str, list)
     {
         qDebug() << str;
         int index = str.indexOf("鍐呭缁�01琛�");
         qDebug()<<"index:"<<index;
+
+
         if(index > 0){
             QAxObject excel("ket.Application");
             if(!excel.setControl("ket"
@@ -268,8 +318,8 @@
                 QVariant name = valRows[9].toList().at(8);
                 if(name.isValid()){
                     ui->label_name->setText(name.toString());
-                    QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget);
-                    top1->setText(0,name.toString());
+                    //QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget);
+                    //top1->setText(0,name.toString());
                     strcpy(curComInfo.name,name.toString().toLocal8Bit().data());
 
                 }else{
@@ -686,14 +736,37 @@
                 // 鏈�鍚庡瓨鍒癿ap涓�
                 m_nameAndComInfos[name.toString()]=curComInfo;
 
+                // 娣诲姞鏍戝舰鍒楄〃鑺傜偣
+                //addTreeWidgetNode(upName,name);
+
+                if(upName.isValid()){
+                    if(name.isValid()){
+                        m_treeNodes[upName.toString()].push_back(name.toString());
+                    }
+                }else{
+                    if(name.isValid()){
+                        m_treeNodes[name.toString()].push_back(name.toString());
+                    }
+                }
+
             }
             wbs->dynamicCall("Close()");
             excel.dynamicCall("Quit(void)");
 
+
+
             qDebug()<<"鍗曚綅淇℃伅鏁伴噺锛�"<<m_nameAndComInfos.size();
         }
+
+        // 鎺у埗鏄剧ず杩涘害鐩稿叧
+        emit loadProgress((cntIdx/allSize)*100);
+        cntIdx++;
     }
 
+    createTreeNode(); // 鏋勫缓鏍戝舰鑺傜偣
+
+    // 鍙戝皠 鍔犺浇瀹屾垚鐨勪俊鍙�
+    emit loadFinished();
 
 //    QAxObject excel("./debug/Data/闄勪欢2_鍐呭缁�01琛╛鍗曚綅鍙婂唴閮ㄥ璁℃満鏋勫熀鏈儏鍐佃〃-1.301鐗�(1).xls");
 //    excel.setProperty("Visible",true);
@@ -1484,42 +1557,17 @@
 
         // 娣诲姞宸﹁竟鏍戝舰鍥剧浉鍏�
         // 鑿滃崟鐩稿叧  褰撲笂绾у叕鍙镐负绌轰笂绾ф椂锛岃嚜宸卞綋鑷繁鐨勪笂绾э紝骞朵笖缃楀垪杩涘幓褰� 鏈骇
+        addTreeWidgetNode(upName,name);
 
-        if(upName.isValid()) // 鏈夋晥
-        {
-            // 鍒ゆ柇椤跺眰鏍戣妭鐐规槸鍚﹀凡缁忓瓨鍦�
-            QTreeWidgetItem *top = nullptr;
-            for(int k=0;k<ui->treeWidget->topLevelItemCount();++k){
-                QTreeWidgetItem *tmp = ui->treeWidget->topLevelItem(k);
-                qDebug()<<k<<tmp->text(0)<<upName.toString();
-                if(upName.toString()+"(姹囨��)" == tmp->text(0)){
-                    top = tmp;
-                    break;
-                }
-            }
-            if(name.isValid()){
-                if(top){ // 瀛樺湪锛屽垯娣诲姞鍒板瀛愬垪琛ㄤ腑
-                    QTreeWidgetItem *top1 = new QTreeWidgetItem(top);
-                    top1->setText(0,name.toString());
-                }else{ // 涓嶅瓨鍦紝鍒欐柊寤轰竴涓垪琛�
-                    QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget);
-                    top1->setText(0,name.toString()+"(姹囨��)");
-                    QTreeWidgetItem *top2 = new QTreeWidgetItem(top1);
-                    top2->setText(0,name.toString()+"(鏈骇)");
-                }
-            }
-
-
-        }else{
-            qDebug()<<"娌″彂鐜颁笂涓�绾э紝鍙兘鑷繁褰�"<<name;
-            if(name.isValid()){
-                QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget);
-                top1->setText(0,name.toString()+"(姹囨��)");
-                QTreeWidgetItem *top2 = new QTreeWidgetItem(top1);
-                top2->setText(0,name.toString()+"(鏈骇)");
-            }
-
-        }
+//        if(upName.isValid()){
+//            if(name.isValid()){
+//                m_treeNodes[upName.toString()].push_back(name.toString());
+//            }
+//        }else{
+//            if(name.isValid()){
+//                m_treeNodes[name.toString()].push_back(name.toString());
+//            }
+//        }
 
 
     }
@@ -1529,6 +1577,97 @@
     qDebug()<<"鍗曚綅淇℃伅鏁伴噺锛�"<<m_nameAndComInfos.size();
 }
 
+void ConverInfo2::createTreeNode(){
+    qDebug()<<"鏋勫缓鏍戝舰鍒楄〃"<<m_treeNodes.size();
+    for(auto iter=m_treeNodes.begin();iter != m_treeNodes.end();iter++)
+    {
+        // 鍏堟瀯寤轰竴涓瘡绾х殑鐖惰妭鐐�
+        addTreeWidgetNode(iter.key(),iter.key());
+        // 鍐嶆坊鍔犲瀛愯妭鐐�
+        for(QString node:iter.value()){
+            qDebug()<<iter.key()<<node;
+            if(iter.key() != node){
+                addTreeWidgetNode(iter.key(),node);
+            }
+        }
+    }
+}
+
+void ConverInfo2::disableWheelEvent()
+{
+    ui->comboBox_ChiefDesignerLevel->installEventFilter(this);
+    ui->comboBox_comType->installEventFilter(this);
+    ui->comboBox_employmentMode->installEventFilter(this);
+    ui->comboBox_hasChiefDesigner->installEventFilter(this);
+    ui->comboBox_hasSetIntervalAudit->installEventFilter(this);
+    ui->comboBox_hasSetSeparateIA->installEventFilter(this);
+    ui->comboBox_hasUpLegal->installEventFilter(this);
+    ui->comboBox_intavalAuditLeval->installEventFilter(this);
+    ui->comboBox_leadingOrganization->installEventFilter(this);
+    ui->comboBox_scale->installEventFilter(this);
+    ui->comboBox_standardType->installEventFilter(this);
+}
+
+bool ConverInfo2::eventFilter(QObject *watched, QEvent *event)
+{
+    QString cls = watched->metaObject()->className();
+    if(cls == "QComboBox"){
+        //qDebug()<<"鍙戠幇涓嬫媺妗�";
+        if(event->type() == QEvent::Wheel){
+            //qDebug()<<"浣跨敤浜嗘粴杞�";
+            return true;  // 杩斿洖鐪熻〃绀虹鐢紝杩斿洖鍋囧垯鑳界敤
+        }
+    }else{
+        qDebug()<<"鍏朵粬绫诲瀷:"<<cls;
+    }
+
+    return QMainWindow::eventFilter(watched,event);
+
+}
+void ConverInfo2::addTreeWidgetNode(QVariant upName,QVariant name){
+    // 娣诲姞宸﹁竟鏍戝舰鍥剧浉鍏�
+    // 鑿滃崟鐩稿叧  褰撲笂绾у叕鍙镐负绌轰笂绾ф椂锛岃嚜宸卞綋鑷繁鐨勪笂绾э紝骞朵笖缃楀垪杩涘幓褰� 鏈骇
+
+    if(upName.isValid()) // 鏈夋晥
+    {
+        // 鍒ゆ柇椤跺眰鏍戣妭鐐规槸鍚﹀凡缁忓瓨鍦�
+        QTreeWidgetItem *top = nullptr;
+        for(int k=0;k<ui->treeWidget->topLevelItemCount();++k){
+            QTreeWidgetItem *tmp = ui->treeWidget->topLevelItem(k);
+            qDebug()<<k<<tmp->text(0)<<upName.toString();
+            int pos = tmp->text(0).indexOf(upName.toString()+"(姹囨��)");
+            if(upName.toString()+"(姹囨��)" == tmp->text(0) || pos != -1){
+                top = tmp;
+                break;
+            }
+        }
+        if(name.isValid()){
+            if(top){ // 瀛樺湪锛屽垯娣诲姞鍒板瀛愬垪琛ㄤ腑
+                QTreeWidgetItem *top1 = new QTreeWidgetItem(top);
+                top1->setText(0,name.toString());
+                top->setText(0,upName.toString()+"(姹囨��)涓嬬骇鏁�:"+QString::number(top->childCount()-1));
+            }else{ // 涓嶅瓨鍦紝鍒欐柊寤轰竴涓垪琛�
+                QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget);
+                top1->setText(0,name.toString()+"(姹囨��)");
+                QTreeWidgetItem *top2 = new QTreeWidgetItem(top1);
+                top2->setText(0,name.toString()+"(鏈骇)");
+                top1->setText(0,name.toString()+"(姹囨��)涓嬬骇鏁�:"+QString::number(top1->childCount()-1));
+            }
+        }
+
+
+    }else{
+        qDebug()<<"娌″彂鐜颁笂涓�绾э紝鍙兘鑷繁褰�"<<name;
+        if(name.isValid()){
+            QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget);
+            top1->setText(0,name.toString()+"(姹囨��)");
+            QTreeWidgetItem *top2 = new QTreeWidgetItem(top1);
+            top2->setText(0,name.toString()+"(鏈骇)");
+            top1->setText(0,name.toString()+"(姹囨��)涓嬬骇鏁�:"+QString::number(top1->childCount()-1));
+        }
+
+    }
+}
 void ConverInfo2::on_pushButton_laodFile_clicked()
 {
     QString path = QFileDialog::getOpenFileName(this,"閫夋嫨琛ㄦ牸:鍗曚綅鍙婂唴閮ㄥ璁℃満鏋勫熀鏈儏鍐佃〃","./","excel(*鍩烘湰鎯呭喌琛�*.xls)");
@@ -1537,3 +1676,8 @@
         readExcelFromPath(path);
     }
 }
+
+void ConverInfo2::showExcelSlot()
+{
+    readInfo(); // 鍔犺浇琛ㄦ牸
+}

--
Gitblit v1.8.0