kpiplus
Version:
KPI+
1 lines • 996 B
JavaScript
var pbl=require("../models/pbl"),so1=require("../models/so1"),hd7=require("../models/hd7"),arrayfuncs=require("./array-funcs"),async=require("async"),trangthai=require("../models/trangthai"),underscore=require("underscore");module.exports=function(n,e){if(!n.id_app)return e("Hàm này yêu cầu tham số id_app");async.parallel({pbl:function(e){pbl.find(n).lean().exec(function(n,t){if(n)return e(n);e(null,t)})},so:function(e){let t={};underscore.extend(t,n),t.trang_thai={$in:["3","4"]},so1.find(t).lean().exec(function(n,t){if(n)return e(n);e(null,t)})},tl:function(e){hd7.find(n).lean().exec(function(n,t){if(n)return e(n);e(null,t)})}},function(n,t){n&&e(n),t.so.forEach(function(n){t.pbl.push(n)}),t.tl.forEach(function(n){n.details_tl=n.details,n.details=n.details_doi,t.pbl.push(n)}),t.pbl.joinModel2(null,trangthai,[{where:{trang_thai:"ma_trang_thai",ma_ct:"ma_ct"},fields:["post_sokho","post","post_socai","ten_trang_thai"]}],function(n){let r=t.pbl.filter(n=>n.post);e(null,r)})})};