浏览代码

bugs 导入相关代码

zhangweicheng 5 年之前
父节点
当前提交
af01271024
共有 3 个文件被更改,包括 69 次插入29 次删除
  1. 61 26
      modules/pm/facade/pm_facade.js
  2. 5 0
      web/building_saas/css/custom.css
  3. 3 3
      web/building_saas/glj/html/project_glj.html

+ 61 - 26
modules/pm/facade/pm_facade.js

@@ -691,13 +691,24 @@ async function copyUnitPriceFile(newProjectID,rootProjectID,userID,originaluUnit
     }
 
     async function copySubList(srcFID,newFID,model,UUID=false) {
-        let mList = await model.find({unit_price_file_id: srcFID}, '-_id');
+        let mList = await model.find({unit_price_file_id: srcFID}, '-_id').lean();
         let rList = [];
-        for(let m of mList){
-            m._doc.unit_price_file_id = newFID;
-            UUID == true?m._doc.ID = uuidV1():m._doc.id = await getCounterID(model.modelName);
-            rList.push(m._doc);
-        }
+        if(UUID == true){
+          for(let m of mList){
+            m.unit_price_file_id = newFID;
+            m.ID = uuidV1();
+            rList.push(m);
+          }
+        }else{
+          let IDcounter = await counter.counterDAO.getIDAfterCountSync(model.modelName, mList.length);
+          let firstID = IDcounter.sequence_value - (mList.length - 1);
+          for(let m of mList){
+              m.unit_price_file_id = newFID;
+              m.id = firstID;    
+              firstID+=1
+              rList.push(m);
+          }
+        }    
         await insertMany(rList,model)
     }
 }
@@ -910,10 +921,10 @@ async function getCounterID(collectionName){
 }
 
 async function insertMany(datas,model) {
-    while (datas.length>1000){//因为mongoose限制了批量插入的条数为1000.所以超出限制后需要分批插入
+   /*  while (datas.length>1000){//因为mongoose限制了批量插入的条数为1000.所以超出限制后需要分批插入
         let newList = datas.splice(0,1000);//一次插入1000条
         await model.insertMany(newList);
-    }
+    } */
     await model.insertMany(datas);
 
 }
@@ -1588,10 +1599,34 @@ async function importProject(data,req,updateData) {
             }
             let [constructionProjectID,projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap] = await handleMainProjectDatas(mainData,updateData,req.session.sessionUser.id);
             result.constructionProjectID = constructionProjectID;
-            if(datas.length > 1 ){
+            if(datas.length > 1 ){//生成后统一次插入 2020-05-29
+              let newProjectSettings=[],bills=[],rations=[],projectGLJs=[],rationGLJs=[],rationCoes=[],quantityDetails=[],rationInstallations=[],rationTemplates=[],newCalcProgramsFiles=[],newLabourCoes=[];
                 for(let i = 1;i<datas.length;i++){
-                    await handleEachProject(datas[i],projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap)
+                  let [newProjectSetting,tbills,trations,tprojectGLJs,trationGLJs,trationCoes,tquantityDetails,trationInstallations,trationTemplates,newCalcProgramsFile,newLabourCoe] =  await handleEachProject(datas[i],projectIDMap,labourCoeFileIDMap,calcProgramFileIDMap)
+                  if(newProjectSetting) newProjectSettings.push(newProjectSetting);
+                  if(tbills.length > 0) bills = bills.concat(tbills);
+                  if(trations.length > 0) rations = rations.concat(trations);
+                  if(tprojectGLJs.length > 0) projectGLJs = projectGLJs.concat(tprojectGLJs); 
+                  if(trationGLJs.length > 0) rationGLJs = rationGLJs.concat(trationGLJs);
+                  if(trationCoes.length > 0) rationCoes = rationCoes.concat(trationCoes);
+                  if(tquantityDetails.length > 0) quantityDetails = quantityDetails.concat(tquantityDetails);
+                  if(trationInstallations.length > 0) rationInstallations= rationInstallations.concat(trationInstallations);
+                  if(trationTemplates.length > 0) rationTemplates = rationTemplates.concat(trationTemplates); 
+                  if(newCalcProgramsFile) newCalcProgramsFiles.push(newCalcProgramsFile);
+                  if(newLabourCoe) newLabourCoes.push(newLabourCoe);
                 }
+
+                if(newProjectSettings.length > 0) await insertMany(newProjectSettings,projectSettingModel);
+                if(bills.length > 0) await insertMany(bills,billsModel);
+                if(rations.length > 0) await insertMany(rations,rationModel);
+                if(projectGLJs.length > 0) await insertMany(projectGLJs,gljListModel);
+                if(rationGLJs.length > 0) await insertMany(rationGLJs,rationGLJModel);
+                if(rationCoes.length > 0) await insertMany(rationCoes,rationCoeModel);
+                if(quantityDetails.length > 0) await insertMany(quantityDetails,quantityDetailModel);
+                if(rationInstallations.length > 0) await insertMany(rationInstallations,rationInstallationModel);
+                if(rationTemplates.length > 0) await insertMany(rationTemplates,rationTemplateModel);
+                if(newCalcProgramsFiles.length > 0) await insertMany(newCalcProgramsFiles,calcProgramsModel);
+                if(newLabourCoes.length>0) await insertMany(newLabourCoes,labourCoesModel);
             }
 
          }
@@ -1670,19 +1705,7 @@ async function handleEachProject(data,projectIDMap,labourCoeFileIDMap,calcProgra
         newLabourCoe = data.labourCoes;
         delete newLabourCoe._id;
     }
-
-    if(newProjectSetting) await projectSettingModel.create(newProjectSetting);
-    if(bills.length > 0) await insertMany(bills,billsModel);
-    if(rations.length > 0) await insertMany(rations,rationModel);
-    if(projectGLJs.length > 0) await insertMany(projectGLJs,gljListModel);
-    if(rationGLJs.length > 0) await insertMany(rationGLJs,rationGLJModel);
-    if(rationCoes.length > 0) await insertMany(rationCoes,rationCoeModel);
-    if(quantityDetails.length > 0) await insertMany(quantityDetails,quantityDetailModel);
-    if(rationInstallations.length > 0) await insertMany(rationInstallations,rationInstallationModel);
-    if(rationTemplates.length > 0) await insertMany(rationTemplates,rationTemplateModel);
-    if(newCalcProgramsFile) await calcProgramsModel.create(newCalcProgramsFile);
-    if(newLabourCoe) await labourCoesModel.create(newLabourCoe);
-
+    return [newProjectSetting,bills,rations,projectGLJs,rationGLJs,rationCoes,quantityDetails,rationInstallations,rationTemplates,newCalcProgramsFile,newLabourCoe]
 
 }
 
@@ -1789,14 +1812,26 @@ async function importUnitPriceFiles(mainData,projectIDMap,unitPriceFileIDMap,use
     if(freights.length > 0) await insertMany(freights,freightModel);
     if(originals.length > 0) await insertMany(originals,originalModel);
     if(com_electrovalences.length > 0) await insertMany(com_electrovalences,comElectrovalenceModel);
-
     async function setSubList(oList,nList,fileID,model,UUID=false) {
-        for(let o of oList){
+        if(UUID == true){
+          for(let o of oList){
             delete o._id;
             o.unit_price_file_id = fileID;
-            UUID == true?o.ID = uuidV1():o.id = await getCounterID(model.modelName);
+            o.ID = uuidV1();
             nList.push(o)
+          }
+        }else{
+          let IDcounter = await counter.counterDAO.getIDAfterCountSync(model.modelName, oList.length);
+          let firstID = IDcounter.sequence_value - (oList.length - 1);
+            for(let o of oList){
+                delete o._id;
+                o.unit_price_file_id = fileID;
+                o.id = firstID;
+                firstID+=1
+                nList.push(o)
+            }
         }
+        
     }
 
 

+ 5 - 0
web/building_saas/css/custom.css

@@ -443,4 +443,9 @@ input.text-right{
 }
 .default-cursor {
     cursor: default !important;
+}
+
+.material_link.active{
+  border:2px solid #ff6501 !important;
+  border-right: 1px solid #fff !important;
 }

+ 3 - 3
web/building_saas/glj/html/project_glj.html

@@ -47,7 +47,7 @@
                         <a class="nav-link " id="mixRatio-nav" data-toggle="tab" href="#ph_div" role="tab" aria-selected="false">组成物计算</a>
                     </li>
                     <li class="nav-item">
-                         <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#calcCoeDiv"></i> 计算系数</a>
+                         <a class="nav-link" href="#" data-toggle="modal" data-target="#calcCoeDiv"></i> 计算系数</a>
                     </li>
                 </ul>
                 <!-- Tab panes -->
@@ -65,8 +65,8 @@
                                 <div class=" left full-h" style="width: 30px" >
                                     <div class="rn-nav cn-nav d-flex align-items-start flex-column"id="calTab">
                                         <ul class="nav nav-tabs">
-                                            <li class="nav-item"><a data-toggle="tab" href="#rnc-yf" role="tab" class="nav-link active">运费计算</a></li>
-                                            <li class="nav-item"><a data-toggle="tab" id="priceTab" href="#rnc-yj" role="tab" class="nav-link">原价计算</a></li>
+                                            <li class="nav-item"><a data-toggle="tab" href="#rnc-yf" role="tab" class="nav-link material_link active">运费计算</a></li>
+                                            <li class="nav-item"><a data-toggle="tab" id="priceTab" href="#rnc-yj" role="tab" class="nav-link material_link">原价计算</a></li>
                                         </ul>
                                     </div>
                                 </div>