121 lines
4.9 KiB
PHP
121 lines
4.9 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | 开源版本可自由商用,可去除界面版权logo
|
||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||
// | 访问官网:https://www.likeadmin.cn
|
||
// | likeadmin团队 版权所有 拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeadminTeam
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\adminapi\lists\build;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\build\BuildDivision;
|
||
use app\common\model\build\BuildPlan;
|
||
use app\common\model\build\BuildProcessSettings;
|
||
use app\common\model\build\BuildReport;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\build\BuildReportDetail;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectMember;
|
||
|
||
|
||
/**
|
||
* 施工汇报列表
|
||
* Class BuildReportLists
|
||
* @package app\adminapi\listsbuild
|
||
*/
|
||
class BuildReportLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2023/12/22 16:08
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['plan_id']
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取施工汇报列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2023/12/22 16:08
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
$params = $this->request->get(['project_id']);
|
||
$where = [];
|
||
if(isset($params['project_id']) && $params['project_id'] != 0){
|
||
$plan_ids = BuildPlan::where('project_id',$params['project_id'])->column('id');
|
||
$where[] = ['plan_id','in',$plan_ids];
|
||
}
|
||
return BuildReport::where($this->searchWhere)->where($where)
|
||
->field(['id', 'report_code', 'plan_id', 'scene_file', 'report_workload', 'report_amount', 'remark', 'add_user'])
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function($data){
|
||
$plan = BuildPlan::where('id',$data['plan_id'])->findOrEmpty();
|
||
$project = Project::field('name')->where('id',$plan['project_id'])->findOrEmpty();
|
||
$process = BuildProcessSettings::field('division_id,process_step_no,process_step,quality_control_points,annex')->where('id',$plan['process_id'])->findOrEmpty();
|
||
$division = BuildDivision::field('subentry_engineering')->where('id',$process['division_id'])->findOrEmpty();
|
||
$projectMember = ProjectMember::field('admin_id')->where('id',$plan['project_member_id'])->findOrEmpty();
|
||
$admin = Admin::field('name')->where('id','in',[$projectMember['admin_id'],$data['add_user']])->column('name','id');
|
||
$data['zy_code'] = $plan['zy_code'];
|
||
$data['project_name'] = $project['name'];
|
||
$data['subentry_engineering'] = $division['subentry_engineering'];
|
||
$data['process_step'] = $process['process_step'];
|
||
$data['process_step_no'] = $process['process_step_no'];
|
||
$data['quality_control_points'] = $process['quality_control_points'];
|
||
$data['process_file'] = $process['annex'];
|
||
$data['project_member_name'] = $admin[$projectMember['admin_id']];
|
||
$data['work_user'] = $plan['work_user'];
|
||
$data['work_content'] = $plan['work_content'];
|
||
$data['plan_start_date'] = $plan['plan_start_date'];
|
||
$data['plan_end_date'] = $plan['plan_end_date'];
|
||
$data['unit'] = $plan['unit'];
|
||
$data['workload'] = $plan['workload'];
|
||
$data['price'] = $plan['price'];
|
||
$data['residue_workload'] = ($data['workload'] - $data['report_workload']) <=0 ? 0 : $data['workload'] - $data['report_workload'];
|
||
$data['completion_degree'] = round($data['report_workload'] / $data['workload'],3).'%';
|
||
$data['add_user_name'] = $admin[$data['add_user']];
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取施工汇报数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2023/12/22 16:08
|
||
*/
|
||
public function count(): int
|
||
{
|
||
$params = $this->request->get(['project_id']);
|
||
$where = [];
|
||
if(isset($params['project_id']) && $params['project_id'] != 0){
|
||
$plan_ids = BuildPlan::where('project_id',$params['project_id'])->column('id');
|
||
$where[] = ['plan_id','in',$plan_ids];
|
||
}
|
||
return BuildReport::where($this->searchWhere)->where($where)->count();
|
||
}
|
||
|
||
} |