bill_facade.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * Created by zhang on 2018/1/22.
  3. */
  4. let model = require("../../bills_lib/models/bills_lib_model");
  5. let Bills = model.billsMod;
  6. let _ = require("lodash");
  7. module.exports={
  8. getSectionInfo : async function (data) {
  9. let conditions=[];
  10. let fxList=[];
  11. let sectionInfo ={};
  12. for(let libID in data){
  13. let codes=[];
  14. let temp={};
  15. codes= _.keys(data[libID]);
  16. temp['billsLibId']=libID;
  17. temp['code'] = {"$in": codes};
  18. conditions.push(temp);
  19. }
  20. if(conditions.length>0){
  21. fxList = await Bills.find({"$or":conditions});
  22. }
  23. if(fxList.length>0){
  24. let sectionIDs = {};
  25. for(let f of fxList){
  26. if(f._doc.sectionInfo){
  27. f._doc.sectionInfo.first?sectionIDs[f._doc.sectionInfo.first]=true:"";
  28. f._doc.sectionInfo.second?sectionIDs[f._doc.sectionInfo.second]=true:"";
  29. f._doc.sectionInfo.third?sectionIDs[f._doc.sectionInfo.third]=true:"";
  30. }
  31. }
  32. let IDList = _.keys(sectionIDs);
  33. let sectionList = await Bills.find({'ID':{'$in':IDList}});
  34. let sectionMap = _.mapKeys(sectionList,'ID');
  35. let fxMap = _.mapKeys(fxList,'code');
  36. sectionInfo={
  37. fxMap:fxMap,
  38. sectionMap :sectionMap
  39. }
  40. return sectionInfo;
  41. }
  42. return null;
  43. },
  44. reorganizeFBFX:async function(data){
  45. console.log(data);
  46. }
  47. }