/** * Created by zhang on 2018/1/22. */ let model = require("../../bills_lib/models/bills_lib_model"); let Bills = model.billsMod; let _ = require("lodash"); module.exports={ getSectionInfo : async function (data) { let conditions=[]; let fxList=[]; let sectionInfo ={}; for(let libID in data){ let codes=[]; let temp={}; codes= _.keys(data[libID]); temp['billsLibId']=libID; temp['code'] = {"$in": codes}; conditions.push(temp); } if(conditions.length>0){ fxList = await Bills.find({"$or":conditions}); } if(fxList.length>0){ let sectionIDs = {}; for(let f of fxList){ if(f._doc.sectionInfo){ f._doc.sectionInfo.first?sectionIDs[f._doc.sectionInfo.first]=true:""; f._doc.sectionInfo.second?sectionIDs[f._doc.sectionInfo.second]=true:""; f._doc.sectionInfo.third?sectionIDs[f._doc.sectionInfo.third]=true:""; } } let IDList = _.keys(sectionIDs); let sectionList = await Bills.find({'ID':{'$in':IDList}}); let sectionMap = _.mapKeys(sectionList,'ID'); let fxMap = _.mapKeys(fxList,'code'); sectionInfo={ fxMap:fxMap, sectionMap :sectionMap } return sectionInfo; } return null; }, reorganizeFBFX:async function(data){ console.log(data); } }