|
@@ -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();
|