<?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\lists\ListsSearchInterface; use app\common\model\build\BuildProcessSettings; use app\common\model\build\BuildReport; use app\common\model\project\Project; use app\common\model\project\ProjectMember; /** * 施工计划列表 * Class BuildPlanLists * @package app\adminapi\listsbuild */ class BuildPlanLists extends BaseAdminDataLists implements ListsSearchInterface { /** * @notes 设置搜索条件 * @return \string[][] * @author likeadmin * @date 2023/12/22 11:04 */ public function setSearch(): array { return [ '=' => ['project_id', 'plan_start_date', 'plan_end_date'], '%like%' => ['zy_code','work_user'] ]; } /** * @notes 获取施工计划列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/12/22 11:04 */ public function lists(): array { return BuildPlan::where($this->searchWhere) ->field(['id', 'project_id', 'process_id', 'project_member_id', 'zy_code', 'plan_start_date', 'plan_end_date', 'work_user', 'work_content', 'workload', 'unit', 'price', 'amount']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); $process = BuildProcessSettings::field('division_id,process_step_no,process_step,quality_control_points,annex')->where('id',$item['process_id'])->findOrEmpty(); $division = BuildDivision::field('subentry_engineering,subentry_engineering_code')->where('id',$process['division_id'])->findOrEmpty(); $projectMember = ProjectMember::field('admin_id')->where('id',$item['project_member_id'])->findOrEmpty(); $admin = Admin::field('name')->where('id',$projectMember['admin_id'])->findOrEmpty(); $item['project_name'] = $project['name']; $item['project_code'] = $project['project_code']; $item['subentry_engineering'] = $division['subentry_engineering']; $item['subentry_engineering_code'] = $division['subentry_engineering_code']; $item['process_step_no'] = $process['process_step_no']; $item['process_step'] = $process['process_step']; $item['quality_control_points'] = $process['quality_control_points']; $item['file'] = $process['annex']; $item['project_member_name'] = $admin['name']; $item['done_workload'] = BuildReport::where('plan_id',$item['id'])->sum('report_workload'); $item['residue_workload'] = ($item['workload'] - $item['done_workload']) <=0 ? 0 : $item['workload'] - $item['done_workload']; $item['completion_degree'] = round($item['done_workload'] / $item['workload'],3).'%'; return $item; }) ->toArray(); } /** * @notes 获取施工计划数量 * @return int * @author likeadmin * @date 2023/12/22 11:04 */ public function count(): int { return BuildPlan::where($this->searchWhere)->count(); } }