flexbiz-server
Version:
Flexible Server
5 lines (4 loc) • 1.66 kB
JavaScript
const ckvt=require("../../libs/ckvt"),Dmvt=global.getModel("dmvt"),Dmkho=global.getModel("dmkho"),Sokho=global.getModel("sokho"),async=require("async"),controller=require("../../controllers/controllerRPT");
module.exports=function($router$$){new controller($router$$,"ckvttheotg",function($req$$,$callback$$){const $condition$$=$req$$.query;ckvt($condition$$,function($error$$,$report$$){if($error$$)return $callback$$($error$$);$report$$=$report$$.filter($r$$=>$r$$.ton00||$r$$.du00);async.parallel([function($callback$$){$report$$.joinModel2($condition$$.id_app,Dmvt,[{where:{ma_vt:"ma_vt"},fields:["ten_vt","ma_dvt","tk_vt"]}],function($results$$){$callback$$(null,$results$$)})},function($callback$$){$report$$.filter($r$$=>
$r$$.ma_kho).joinModel2($condition$$.id_app,Dmkho,[{where:{ma_kho:"ma_kho"},fields:["ten_kho"]}],function($results$$){$callback$$(null,$results$$)})},function($callback$$){async.mapLimit($report$$,20,async $vt$$=>{var $latest_import_query$$={ma_vt:$vt$$.ma_vt,id_app:$condition$$.id_app,ma_ct:"PN1"};$vt$$.ma_kho&&($latest_import_query$$.ma_kho=$vt$$.ma_kho);$vt$$.ma_tt1&&($latest_import_query$$.ma_tt1=$vt$$.ma_tt1);$vt$$.ma_tt2&&($latest_import_query$$.ma_tt2=$vt$$.ma_tt2);$vt$$.ma_tt3&&($latest_import_query$$.ma_tt3=
$vt$$.ma_tt3);$vt$$.ma_lo&&($latest_import_query$$.ma_lo=$vt$$.ma_lo);if($latest_import_query$$=await Sokho.findOne($latest_import_query$$).sort({ngay_ct:-1}).lean())$vt$$.thoi_gian_ton_kho=Math.roundBy(((new Date).getTime()-(new Date($latest_import_query$$.ngay_ct)).getTime())/864E5)},$e$$=>{$callback$$($e$$)})}],function($error$$){if($error$$)return $callback$$($error$$);$callback$$(null,$report$$)})})})};