UNPKG

flexbiz-server

Version:

Flexible Server

5 lines (4 loc) 1.61 kB
'use strict';const kehoachmh=global.getModel("kehoachmh"),dmvt=global.getModel("dmvt"),congdoansx=global.getModel("congdoansx"),async=require("async"),controller=require("../../controllers/controllerRPT"); module.exports=function($router$$){new controller($router$$,"getkehoachmh4lenhcp",function($req$$,$callback$jscomp$1$$){const $condition$$=$req$$.query;async.series({kehoachmh:function($callback$jscomp$0$$){let $query$$={id_app:$condition$$.id_app,ngay_ct:{$gte:$condition$$.tu_ngay,$lte:$condition$$.den_ngay}};$condition$$.id_lenhsx&&($query$$.id_lenhsx=$condition$$.id_lenhsx);$condition$$.id_contract&&($query$$.id_contract=$condition$$.id_contract);$condition$$.so_ct&&($query$$.so_ct={$regex:$query$$.so_ct, $options:"i"});kehoachmh.find($query$$).lean().exec(($e$$,$khmhs$$)=>{if($e$$)return $callback$jscomp$0$$($e$$.message);$khmhs$$.forEach($khmh$$=>{$khmh$$.details.forEach($d$$=>{$d$$.so_luong=$d$$.sl_ke_hoach})});async.series({ten_vt_sp:$callback$$=>{async.mapSeries($khmhs$$,$khmh$$=>{$khmh$$.details.joinModel2($condition$$.id_app,dmvt,[{where:"ma_vt",fields:"ten_vt"},{where:{ma_sp:"ma_vt"},fields:{ten_sp:"ten_vt"}}],()=>{$callback$$()})},()=>{$callback$$()})},congdoan:$callback$$=>{async.mapSeries($khmhs$$, $khmh$$=>{$khmh$$.details.joinModel2($condition$$.id_app,congdoansx,[{where:{ma_cong_doan:"ma_cong_doan"},fields:{ten_cong_doan:"ten_cong_doan"}}],()=>{$callback$$()})},()=>{$callback$$()})}},()=>{$callback$jscomp$0$$(null,$khmhs$$)})})}},function($error$$,$results$$){if($error$$)return $callback$jscomp$1$$($error$$);$callback$jscomp$1$$(null,$results$$.kehoachmh)})})};