Bläddra i källkod

定额库编辑器-导出内部数据时,多加一列“工作内容”、一列“附注”,同样导入内部数据时更新这两列文本

zhongzewei 5 år sedan
förälder
incheckning
2bbae9e165

+ 2 - 0
modules/ration_repository/controllers/ration_repository_controller.js

@@ -193,7 +193,9 @@ class RationRepositoryController extends baseController {
                     throw 'excel没有对应数据';
                 }
                 const result = type === 'source_file' ?
+                    // 导入原始数据
                     await rationItem.batchAddFromExcel(rationRepId, sheet[0].data) :
+                    // 导入内部数据
                     await rationItem.batchUpdateSectionIdFromExcel(sheet[0].data);
                 if (rationItem.failGLJList && rationItem.failGLJList.length > 0) {
                     responseData.msg = rationItem.failGLJList.join("\r\n");

+ 38 - 13
modules/ration_repository/models/ration_item.js

@@ -10,6 +10,7 @@ let rationRepositoryDao = require('./repository_map');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 const rationItemModel = mongoose.model('std_ration_lib_ration_items');
 const stdRationLibModel = mongoose.model('std_ration_lib_map');
+const stdRationSectionModel = mongoose.model('std_ration_lib_ration_chapter_trees');
 const compleRationModel = mongoose.model('complementary_ration_items');
 import STDGLJListModel from '../../std_glj_lib/models/gljModel';
 
@@ -808,14 +809,14 @@ rationItemDAO.prototype.exportExcelData = async function(rationRepId) {
         rationRepId: rationRepId
     };
     // @todo 限制导出的数量以防内存溢出
-    const rationDataList = await this.getRationItemByCondition(condition, ['name', 'code', 'ID', 'sectionId', 'feeType', 'caption', 'basePrice']);
+    const rationDataList = await this.getRationItemByCondition(condition, ['name', 'code', 'ID', 'sectionId', 'feeType', 'caption', 'basePrice', 'jobContent', 'annotation']);
 
     // 整理数据
     let rationData = [];
     for (const tmp of rationDataList) {
         const sectionId = tmp.sectionId <= 0 || tmp.sectionId === undefined ? null : tmp.sectionId;
         const feeType = tmp.feeType === '' || tmp.feeType === undefined ? null : tmp.feeType;
-        const ration = [sectionId, feeType, tmp.ID, tmp.code, tmp.name, tmp.caption, tmp.basePrice];
+        const ration = [sectionId, feeType, tmp.ID, tmp.code, tmp.name, tmp.caption, tmp.basePrice, tmp.jobContent, tmp.annotation];
         rationData.push(ration);
     }
     //根据编号排序,优先级:number-number-..., number, Anumber....
@@ -881,7 +882,7 @@ rationItemDAO.prototype.exportExcelData = async function(rationRepId) {
         }
         return rst;
     });*/
-    const excelData = [['树ID', '取费专业', '定额ID', '定额编码', '定额名', '定额显示名称', '基价']];
+    const excelData = [['树ID', '取费专业', '定额ID', '定额编码', '定额名', '定额显示名称', '基价', '工作内容', '附注']];
     excelData.push.apply(excelData, rationData);
 
     return excelData;
@@ -898,12 +899,17 @@ rationItemDAO.prototype.batchUpdateSectionIdFromExcel = async function(data) {
         return false;
     }
     // 批量执行update
-    let bulkOprs = [];
+    let rationTasks = [],
+        sectionIDs = [];
     for (const tmp of data) {
         let rationId = parseInt(tmp[2]);
         rationId = isNaN(rationId) || rationId <= 0 ? 0 : rationId;
         let sectionId = parseInt(tmp[0]);
         sectionId = isNaN(sectionId) || sectionId <= 0 ? 0 : sectionId;
+        if (sectionId <= 0 || rationId <= 0) {
+            continue;
+        }
+        sectionIDs.push(sectionId);
         // 取费专业
         let feeType = tmp[1] ? parseInt(tmp[1]) : null;
         feeType = isNaN(feeType) || feeType <= 0 ? null : feeType;
@@ -911,16 +917,35 @@ rationItemDAO.prototype.batchUpdateSectionIdFromExcel = async function(data) {
         name = name ? name : '';
         let caption = tmp[5];
         caption = caption ? caption : '';
-        if (sectionId <= 0 || rationId <= 0) {
-            continue;
-        }
-        bulkOprs.push({updateOne: {filter: {ID: rationId}, update: {$set: {sectionId: sectionId, feeType: feeType, name: name, caption: caption}}}});
-    }
-    if(bulkOprs.length <= 0){
+        let jobContent = tmp[7] ? tmp[7] : '';
+        let annotation = tmp[8] ? tmp[8] : '';
+        rationTasks.push({updateOne: {
+            filter: {ID: rationId},
+            update: {$set: {
+                sectionId,
+                feeType,
+                name,
+                caption,
+                jobContent,
+                annotation
+            }}}});
+    }
+    if(rationTasks.length <= 0){
         throw '无有效数据(树ID、定额ID不为空、且为数值)';
     }
-    await rationItemModel.bulkWrite(bulkOprs);
+    // 更新定额数据
+    await rationItemModel.bulkWrite(rationTasks);
+    // 更新章节树工作内容、附注节点选项(全设置为ALL)
+    sectionIDs = Array.from(new Set(sectionIDs));
+    if (sectionIDs.length) {
+        await stdRationSectionModel.updateMany(
+            {ID: {$in: sectionIDs}},
+            {$set: {
+                jobContentSituation: 'ALL',
+                annotationSituation: 'ALL'
+            }}
+        )
+    }
 };
 
-module.exports = new rationItemDAO();
-
+module.exports = new rationItemDAO();