From 39b4916463160a8767e055d1cf5dcffc5a57008d Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Wed, 31 Jan 2024 09:48:36 +0800 Subject: [PATCH] aa --- .../project/ProjectStatisticsController.php | 58 ++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/app/adminapi/controller/project/ProjectStatisticsController.php b/app/adminapi/controller/project/ProjectStatisticsController.php index 93b318c25..f32adcf6f 100644 --- a/app/adminapi/controller/project/ProjectStatisticsController.php +++ b/app/adminapi/controller/project/ProjectStatisticsController.php @@ -25,10 +25,17 @@ use app\common\model\finance\FinanceReturnedMoney; use app\common\model\finance\FinanceReturnedRecord; use app\common\model\project\Competitor; + use app\common\model\project\ProjectCostBudget; + use app\common\model\project\ProjectCostBudgetDetail; + use app\common\model\project\ProjectEquipmentBudgetDetail; use app\common\model\project\ProjectEstimate; use app\common\model\project\ProjectFollowUp; + use app\common\model\project\ProjectLaborBudgetDetail; + use app\common\model\project\ProjectMaterialBudgetDetail; use app\common\model\project\ProjectSettlement; use app\common\model\project\ProjectSubcontractSettlement; + use app\common\model\project\ProjectSubpackageBudgetDetail; + use app\common\model\project\ProjectTotalBudget; use think\response\Json; class ProjectStatisticsController extends BaseAdminController @@ -138,12 +145,59 @@ } //项目预算统计 - public function budget() { + public function budget(): Json + { $id = $this->request->get('project_id'); if(empty($id)){ return $this->fail('缺少必要参数'); } $column = ['总预算','材料预算','分包预算','人工预算','费用预算','机具预算']; - halt(); + //总预算 + $project_budget = ProjectTotalBudget::field('id,cl_cost,fb_cost,rg_cost,fy_cost,jj_cost')->where('project_id',$id)->findOrEmpty(); + $total_budget = $project_budget['cl_cost'] + $project_budget['fb_cost'] + $project_budget['rg_cost'] + $project_budget['fy_cost'] + $project_budget['jj_cost']; + //材料清单预算 + $material_budget = ProjectMaterialBudgetDetail::where('project_id',$id)->sum('amount'); + //分包清单预算 + $subpackage_budget = ProjectSubpackageBudgetDetail::where('project_id',$id)->sum('amount'); + //人工清单预算 + $labor_budget = ProjectLaborBudgetDetail::where('project_id',$id)->sum('amount'); + //费用清单预算 + $cost_budget = ProjectCostBudgetDetail::where('project_id',$id)->sum('amount'); + //机具清单预算 + $equipment_budget = ProjectEquipmentBudgetDetail::where('project_id',$id)->sum('amount'); + $total_budget_series = [ + 'name' => '总预算', + 'data' => [$total_budget,($material_budget+$subpackage_budget+$labor_budget+$cost_budget+$equipment_budget)] + ]; + $material_budget_series = [ + 'name' => '材料预算', + 'data' => [$project_budget['cl_cost'],$material_budget] + ]; + $subpackage_budget_series = [ + 'name' => '分包预算', + 'data' => [$project_budget['fb_cost'],$subpackage_budget] + ]; + $labor_budget_series = [ + 'name' => '人工预算', + 'data' => [$project_budget['rg_cost'],$labor_budget] + ]; + $cost_budget_series = [ + 'name' => '费用预算', + 'data' => [$project_budget['fy_cost'],$cost_budget] + ]; + $equipment_budget_series = [ + 'name' => '机具预算', + 'data' => [$project_budget['jj_cost'],$equipment_budget] + ]; + $result = [ + 'total_budget_series' => $total_budget_series, + 'material_budget_series' => $material_budget_series, + 'subpackage_budget_series' => $subpackage_budget_series, + 'labor_budget_series' => $labor_budget_series, + 'cost_budget_series' => $cost_budget_series, + 'equipment_budget_series' => $equipment_budget_series, + 'column' => $column, + ]; + return $this->success('success',$result); } } \ No newline at end of file