166 lines
5.6 KiB
PHP
166 lines
5.6 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\controller\supervision_project;
|
|
|
|
use app\adminapi\controller\BaseAdminController;
|
|
use app\adminapi\logic\supervision_project\SupervisionProjectStatisticsLogic;
|
|
use app\common\model\dict\DictData;
|
|
use app\common\model\financial\FinancialInvoice;
|
|
use app\common\model\financial\FinancialRefund;
|
|
use app\common\model\financial\FinancialSettlement;
|
|
use app\common\model\marketing\MarketingContract;
|
|
use app\common\model\supervision_connect\SupervisionProjectMonthlyReport;
|
|
use app\common\model\supervision_project\SupervisionProject;
|
|
use app\common\model\supervision_work\SupervisionProblem;
|
|
|
|
class SupervisionStatisticsController extends BaseAdminController
|
|
{
|
|
public function index()
|
|
{
|
|
$date = $this->request->get('date', '');
|
|
$where = [];
|
|
$time = getDay($date);
|
|
$res = SupervisionProjectStatisticsLogic::consultStatistics($where, $time);
|
|
return $this->data($res);
|
|
}
|
|
//项目立项统计
|
|
public function project()
|
|
{
|
|
//待立项项目
|
|
$pending_project_num = MarketingContract::field('id')->where([
|
|
['review_status', '=', 1],
|
|
['contract_type', '=', 0],
|
|
['business_nature', '=', 1],
|
|
['status', '=', 0]
|
|
])->count();
|
|
//已立项项目
|
|
$approved_project_num = SupervisionProject::field('id')->count();
|
|
$result['data'] = [
|
|
[
|
|
'name' => '待立项项目',
|
|
'value' => $pending_project_num
|
|
],
|
|
[
|
|
'name' => '已立项项目',
|
|
'value' => $approved_project_num
|
|
]
|
|
];
|
|
return $this->success('success', $result);
|
|
}
|
|
|
|
//项目问题统计
|
|
public function problem()
|
|
{
|
|
$problem_cate = DictData::where('type_value', 'problem_cate')->column('name', 'value');
|
|
$data = [];
|
|
foreach ($problem_cate as $k => $v) {
|
|
$count = SupervisionProblem::where('problem_cate', $k)->count();
|
|
$data[] = [
|
|
'name' => $v,
|
|
'value' => $count
|
|
];
|
|
}
|
|
$result['data'] = $data;
|
|
return $this->success('success', $result);
|
|
}
|
|
|
|
//项目月报统计
|
|
public function month_report()
|
|
{
|
|
$year = $this->request->get('year', date('Y'));
|
|
//统计总的进度
|
|
$total_schedule = SupervisionProjectMonthlyReport::sum('this_month_progress');
|
|
//统计年度进度
|
|
$year_schedule = SupervisionProjectMonthlyReport::whereYear('date', $year)->sum('this_month_progress');
|
|
//统计总的完成
|
|
$total_complete = SupervisionProjectMonthlyReport::sum('total_amount');
|
|
//统计年度完成
|
|
$year_complete = SupervisionProjectMonthlyReport::whereYear('date', $year)->sum('total_amount');
|
|
//统计总的支付
|
|
$total_payment = SupervisionProjectMonthlyReport::sum('total_pay');
|
|
//统计年度支付
|
|
$year_payment = SupervisionProjectMonthlyReport::whereYear('date', $year)->sum('total_pay');
|
|
$column = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];
|
|
$schedule_series = [
|
|
'name' => '工程进度',
|
|
'data' => []
|
|
];
|
|
$complete_series = [
|
|
'name' => '完成总量',
|
|
'data' => []
|
|
];
|
|
$payment_series = [
|
|
'name' => '支付总量',
|
|
'data' => []
|
|
];
|
|
foreach ($column as &$v) {
|
|
$schedule_series['data'][] = SupervisionProjectMonthlyReport::whereMonth('date', $year . '-' . $v)->sum('this_month_progress');
|
|
$complete_series['data'][] = SupervisionProjectMonthlyReport::whereMonth('date', $year . '-' . $v)->sum('total_amount');
|
|
$payment_series['data'][] = SupervisionProjectMonthlyReport::whereMonth('date', $year . '-' . $v)->sum('total_pay');
|
|
$v = $v . '月';
|
|
}
|
|
$result = compact(
|
|
'total_schedule',
|
|
'year_schedule',
|
|
'total_complete',
|
|
'year_complete',
|
|
'total_payment',
|
|
'year_payment',
|
|
'column',
|
|
'schedule_series',
|
|
'complete_series',
|
|
'payment_series'
|
|
);
|
|
return $this->success('success', $result);
|
|
}
|
|
|
|
public function invoice()
|
|
{
|
|
$year = $this->request->get('year', date('Y'));
|
|
$contract_ids = SupervisionProject::column('contract');
|
|
//总开票金额
|
|
$total_invoice_amount = FinancialInvoice::where('contract_id', 'in', $contract_ids)->sum('apply_amount');
|
|
//年度开票金额
|
|
$year_invoice_amount = FinancialInvoice::where('contract_id', 'in', $contract_ids)->whereYear('create_time', $year)->sum('apply_amount');
|
|
//总到账金额
|
|
$total_refund_amount = FinancialRefund::where('contract_id', 'in', $contract_ids)->sum('amount');
|
|
$year_refund_amount = FinancialRefund::where('contract_id', 'in', $contract_ids)->whereYear('date', $year)->sum('amount');
|
|
//总结算金额
|
|
$total_settlement_amount = FinancialSettlement::where('contract_id', 'in', $contract_ids)->sum('amount');
|
|
//年度结算金额
|
|
$year_settlement_amount = FinancialSettlement::where('contract_id', 'in', $contract_ids)->whereYear('date', $year)->sum('amount');
|
|
$column = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];
|
|
$invoice_series = [
|
|
'name' => '开票金额',
|
|
'data' => []
|
|
];
|
|
$refund_series = [
|
|
'name' => '到账金额',
|
|
'data' => []
|
|
];
|
|
$settlement_series = [
|
|
'name' => '结算金额',
|
|
'data' => []
|
|
];
|
|
foreach ($column as &$v) {
|
|
$invoice_series['data'][] = FinancialInvoice::where('contract_id', 'in', $contract_ids)->whereMonth('create_time', $year . '-' . $v)->sum('apply_amount');
|
|
$refund_series['data'][] = FinancialRefund::where('contract_id', 'in', $contract_ids)->whereMonth('date', $year . '-' . $v)->sum('amount');
|
|
$settlement_series['data'][] = FinancialSettlement::where('contract_id', 'in', $contract_ids)->whereMonth('date', $year . '-' . $v)->sum('amount');
|
|
$v = $v . '月';
|
|
}
|
|
$result = compact(
|
|
'total_invoice_amount',
|
|
'year_invoice_amount',
|
|
'total_refund_amount',
|
|
'year_refund_amount',
|
|
'total_settlement_amount',
|
|
'year_settlement_amount',
|
|
'column',
|
|
'invoice_series',
|
|
'refund_series',
|
|
'settlement_series'
|
|
);
|
|
return $this->success('success', $result);
|
|
}
|
|
}
|