data_unique_code('施工汇报'), 'plan_id' => $params['plan_id'], 'scene_file' => !empty($params['scene_file']) ? json_encode($params['scene_file']) : null, 'report_workload' => $params['report_workload'], 'report_amount' => $params['report_amount'], 'remark' => $params['remark'], 'add_user' => $admin_id, ]); foreach($detail as $v){ BuildReportDetail::create([ 'report_id' => $reportRes->id, 'person_id' => $v['person_id'], 'work_num' => $v['work_num'], 'remark' => $v['remark']??'' ]); } Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 获取施工汇报详情 * @param $params * @return array * @author likeadmin * @date 2023/12/22 16:08 */ public static function detail($params): array { $data = BuildReport::findOrEmpty($params['id'])->toArray(); if(empty($data)) return []; $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['add_user_name'] = $admin[$data['add_user']]; $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).'%'; return $data; } }