|
|
@@ -8,12 +8,40 @@ const gljClassModel = mongoose.model('std_glj_lib_gljClass');
|
|
|
const compilationModel = mongoose.model('compilation');
|
|
|
const scMathUtil = require('../../../public/scMathUtil').getUtil();
|
|
|
const rationModel = mongoose.model('std_ration_lib_ration_items');
|
|
|
+const complementaryRationModel = mongoose.model('complementary_ration_items');
|
|
|
import {OprDao} from "./gljMapModel";
|
|
|
import moment from "moment";
|
|
|
import counter from "../../../public/counter/counter";
|
|
|
import async from "async";
|
|
|
|
|
|
class GljDao extends OprDao{
|
|
|
+ async getReference(repositoryId, gljId) {
|
|
|
+ const gljLib = await gljMapModel.findOne({ID: repositoryId});
|
|
|
+ const rationLibIds = [];
|
|
|
+ const rationLibNameMapping = {};
|
|
|
+ gljLib.rationLibs.forEach(item => {
|
|
|
+ rationLibIds.push(item.ID);
|
|
|
+ rationLibNameMapping[item.ID] = item.dispName;
|
|
|
+ });
|
|
|
+ const stdRations = await rationModel.find({rationRepId: {$in: rationLibIds}, 'rationGljList.gljId': gljId}, '-_id code rationRepId');
|
|
|
+ const rst = {};
|
|
|
+ const unknownLib = '未知定额库';
|
|
|
+ const complementaryLib = '补充定额库';
|
|
|
+ stdRations.forEach(ration => {
|
|
|
+ const libName = rationLibNameMapping[ration.rationRepId] || unknownLib;
|
|
|
+ if (!rst[libName]) {
|
|
|
+ rst[libName] = [];
|
|
|
+ }
|
|
|
+ rst[libName].push(ration);
|
|
|
+ });
|
|
|
+ const complementaryRations = await complementaryRationModel.find({'rationGljList.gljId': gljId}, '-_id code');
|
|
|
+ if (complementaryRations.length) {
|
|
|
+ rst[complementaryLib] = [];
|
|
|
+ }
|
|
|
+ complementaryRations.forEach(ration => rst[complementaryLib].push({code: ration.code}));
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
+
|
|
|
getGljTypes (gljLibId, callback){
|
|
|
gljClassModel.find({"repositoryId": gljLibId, "$or": [{"isDeleted": null}, {"isDeleted": false}, {deleted: false} ]},
|
|
|
'-_id', {lean: true}, function(err,data){
|