|
|
@@ -12,6 +12,7 @@ import async from 'async';
|
|
|
let stdRationModel = require ('../../ration_repository/models/ration_item').Model;
|
|
|
let counter = require('../../../public/counter/counter');
|
|
|
const scMathUtil = require('../../../public/scMathUtil').getUtil();
|
|
|
+let gljUtil = require('../../../public/gljUtil');
|
|
|
|
|
|
class CompleRatoinDao {
|
|
|
async updateRation(userID, compilationId, updateData, callback){
|
|
|
@@ -131,7 +132,7 @@ class CompleRatoinDao {
|
|
|
}
|
|
|
|
|
|
//根据章节树获取补充定额
|
|
|
- async getCompleRationBySection(userId, sectionId) {
|
|
|
+ async getCompleRationBySection(userId, sectionId,gUtil) {
|
|
|
const deleteQuery = [{deleteInfo: null}, {'deleteInfo.deleted': false}];
|
|
|
let compleRations = await compleRationModel.find({sectionId: sectionId, $or: deleteQuery});
|
|
|
for(let ration of compleRations){
|
|
|
@@ -157,17 +158,8 @@ class CompleRatoinDao {
|
|
|
if(comGljIds.length > 0) {
|
|
|
comGljs = await complementaryGljModel.find({userId: userId, ID: {$in: comGljIds}});
|
|
|
}
|
|
|
- let gljDatas = stdGljs.concat(comGljs);
|
|
|
- gljDatas.sort(function (a, b) {
|
|
|
- let aV = a.gljType + a.code,
|
|
|
- bV = b.gljType + b.code;
|
|
|
- if(aV > bV) {
|
|
|
- return 1;
|
|
|
- } else if (aV < bV) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
- return 0;
|
|
|
- });
|
|
|
+ if(!gUtil) gUtil = gljUtil;
|
|
|
+ let gljDatas = gUtil.sortRationGLJ(stdGljs.concat(comGljs));
|
|
|
for(let glj of gljDatas){
|
|
|
hintsArr.push(` ${glj.code} ${glj.name}${glj.specs ? ' ' + glj.specs : ''}   ${glj.unit} ${gljAmtMapping[glj.ID]}`)
|
|
|
}
|
|
|
@@ -186,7 +178,7 @@ class CompleRatoinDao {
|
|
|
}
|
|
|
|
|
|
//造价书定额库 根据章节树过去标准定额
|
|
|
- async getRationGljItemsBySection(sectionId, callback){
|
|
|
+ async getRationGljItemsBySection(sectionId,gUtil){
|
|
|
let stdRations = await stdRationModel.find({sectionId: sectionId});
|
|
|
for(let ration of stdRations){
|
|
|
ration._doc.type = 'std';
|
|
|
@@ -243,17 +235,8 @@ class CompleRatoinDao {
|
|
|
if(stdGljIds.length > 0) {
|
|
|
stdGljs = await stdGljModel.find({ID: {$in: stdGljIds}});
|
|
|
}
|
|
|
- let gljDatas = stdGljs;
|
|
|
- gljDatas.sort(function (a, b) {
|
|
|
- let aV = a.gljType + a.code,
|
|
|
- bV = b.gljType + b.code;
|
|
|
- if(aV > bV) {
|
|
|
- return 1;
|
|
|
- } else if (aV < bV) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
- return 0;
|
|
|
- });
|
|
|
+ if(!gUtil) gUtil = gljUtil;
|
|
|
+ let gljDatas = gUtil.sortRationGLJ(stdGljs);
|
|
|
for(let glj of gljDatas){
|
|
|
hintsArr.push(` ${glj.code} ${glj.name}${glj.specs ? ' ' + glj.specs : ''}   ${glj.unit} ${gljAmtMapping[glj.ID]}`)
|
|
|
}
|