115 lines
5.1 KiB
PHP
115 lines
5.1 KiB
PHP
<?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('contract_name', 'like', '%'.$contract_name.'%');
|
|
}
|
|
if ($contract_num) {
|
|
$query->where('contract_num', '=', $contract_num);
|
|
}
|
|
if ($part_a) {
|
|
$query->where('part_a', 'like', '%'.$part_a.'%');
|
|
}
|
|
});
|
|
$count = $query->count();
|
|
$lists = $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', 'lists', '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();
|
|
$lists = $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']);
|
|
return $item;
|
|
});
|
|
return $this->success('成功', compact('count', 'lists', '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.'%');
|
|
}
|
|
})->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();
|
|
$lists = $query->page($page_no, $page_size)->select();
|
|
return $this->success('成功', compact('count', 'lists', 'page_no', 'page_size'));
|
|
}
|
|
} |