This commit is contained in:
chenbo 2024-02-29 16:22:57 +08:00
parent 6b1ced0607
commit f57706c70e

View File

@ -0,0 +1,110 @@
<?php
namespace app\adminapi\controller;
use app\common\model\cost_project\CostApprovedProject;
use app\common\model\DataReception;
use app\common\model\task\TaskAllocation;
use app\common\model\TaskHandlingThreeLevelReview;
use think\facade\Db;
class CostConsultationReportController extends BaseAdminController
{
// 造价报表控制器
// 造价合同台账
public function cost_approved_project_list()
{
$page_no = $this->request->param('page_no', 1);
$page_size = $this->request->param('page_size', 15);
$params = $this->request->param();
$contract_name = $params['contract_name'] ?? '';
$contract_num = $params['contract_num'] ?? '';
$part_a = $params['part_a'] ?? '';
$query = Db::name('cost_approved_project')->where(function ($query) use ($contract_name, $contract_num, $part_a) {
if ($contract_name) {
$query->where('c.contract_name', 'like', '%'.$contract_name.'%');
}
if ($contract_num) {
$query->where('c.contract_num', '=', $contract_num);
}
if ($part_a) {
$query->where('c.part_a', 'like', '%'.$part_a.'%');
}
});
$count = $query->count();
$list = $query->page($page_no, $page_size)->select()->each(function($item){
$item['start_date'] = date('Y-m-d', $item['start_date']);
$item['end_date'] = date('Y-m-d', $item['end_date']);
$item['due_time'] = date('Y-m-d', $item['due_time']);
$item['create_date'] = date('Y-m-d', $item['create_date']);
return $item;
});
return $this->success('成功', compact('count', 'list', 'page_no', 'page_size'));
}
// 造价项目信息汇总
public function cost_project_report()
{
$page_no = $this->request->param('page_no', 1);
$page_size = $this->request->param('page_size', 15);
$params = $this->request->param();
$project_name = $params['project_name'] ?? '';
$project_num = $params['project_num'] ?? '';
$contract_name = $params['contract_name'] ?? '';
$aunit = $params['aunit'] ?? '';
$query = Db::name('cost_project')->alias('p')->leftJoin('cost_approved_project c', 'p.contract_id=c.id')->where(function ($query) use ($project_name, $project_num, $contract_name, $aunit) {
if ($contract_name) {
$query->where('c.contract_name', 'like', '%'.$contract_name.'%');
}
if ($project_num) {
$query->where('p.project_num', '=', $project_num);
}
if ($project_name) {
$query->where('p.project_name', 'like', '%'.$project_name.'%');
}
if ($aunit) {
$query->where('p.aunit', 'like', '%'.$aunit.'%');
}
});
$count = $query->count();
$list = $query->page($page_no, $page_size)->select();
return $this->success('成功', compact('count', 'list', 'page_no', 'page_size'));
}
// 项目全过程跟踪表
public function project_trace()
{
$page_no = $this->request->param('page_no', 1);
$page_size = $this->request->param('page_size', 15);
$params = $this->request->param();
$project_name = $params['project_name'] ?? '';
$project_num = $params['project_num'] ?? '';
$contract_name = $params['contract_name'] ?? '';
$query = Db::name('cost_project')->alias('p')->leftJoin('cost_approved_project c', 'p.contract_id=c.id')->where(function ($query) use ($project_name, $project_num, $contract_name) {
if ($contract_name) {
$query->where('c.contract_name', 'like', '%'.$contract_name.'%');
}
if ($project_num) {
$query->where('p.project_num', '=', $project_num);
}
if ($project_name) {
$query->where('p.project_name', 'like', '%'.$project_name.'%');
}
})->field('p.*')->append(['task_allocation_status', 'task_handling_three_level_review_status', 'data_reception_status']) ->withAttr('task_allocation_status', function ($data, $value){
$count = TaskAllocation::where('cost_project_id', $value['id'])->count();
return $count > 0 ? 1: 0;
})->withAttr('task_handling_three_level_review_status', function ($data, $value){
$count = TaskHandlingThreeLevelReview::where('project_id', $value['id'])->count();
return $count > 0 ? 1: 0;
})->withAttr('data_reception_status', function ($data, $value){
$count = DataReception::where('project_id', $value['id'])->count();
return $count > 0 ? 1: 0;
});
$count = $query->count();
$list = $query->page($page_no, $page_size)->select();
return $this->success('成功', compact('count', 'list', 'page_no', 'page_size'));
}
}