flexbiz-server
Version:
Flexible Server
4 lines (3 loc) • 994 B
JavaScript
'use strict';const giatb=global.getModel("giatb"),controller=require("../../controllers/controllerRPT");
module.exports=function($router$$){new controller($router$$,"banggiatb",async function($query_req$$,$callback$$){$query_req$$=$query_req$$.query;if(!$query_req$$.nam||!$query_req$$.thang)return $callback$$("Ch\u1ee9c n\u0103ng n\u00e0y y\u00eau c\u1ea7u c\u00e1c tham s\u1ed1: nam,thang");const $condition$$={id_app:$query_req$$.id_app,nam:$query_req$$.nam,thang:$query_req$$.thang};$query_req$$.ma_vt&&($condition$$.ma_vt=$query_req$$.ma_vt);$query_req$$.ma_kho&&($condition$$.ma_kho=$query_req$$.ma_kho);
try{let $report$$=await giatb.find($condition$$).lean();await $report$$.asyncJoinModel2($condition$$.id_app,"dmvt",{where:{ma_vt:"ma_vt"},fields:["ten_vt","ma_dvt"]});await $report$$.asyncJoinModel2($condition$$.id_app,"dmkho",{where:{ma_kho:"ma_kho"},fields:["ten_kho"]});$callback$$(null,$report$$)}catch($e$$){$callback$$({error:$e$$.message||$e$$.error||$e$$})}},{stream:!1})};