$params['project_name'], 'project_code' => data_unique_code('JLXM'), 'industry' => $params['industry'], 'nature' => $params['nature'], 'build_unit' => $params['build_unit'], 'build_area' => $params['build_area'], 'address' => $params['address'], 'project_level' => $params['project_level'], 'total_investment' => $params['total_investment'], 'initiation_date' => $params['initiation_date'], 'contract' => $params['contract'], 'contract_amount' => $params['contract_amount'], 'actual_start_date' => !empty($params['actual_start_date']) ? strtotime($params['actual_start_date']) : 0, 'actual_end_date' => !empty($params['actual_end_date']) ? strtotime($params['actual_end_date']) : 0, 'planned_start_date' => !empty($params['planned_start_date']) ? strtotime($params['planned_start_date']) : 0, 'planned_end_date' => !empty($params['planned_end_date']) ? strtotime($params['planned_end_date']) : 0, 'contract_content' => $params['contract_content'], 'project_overview' => $params['project_overview'], 'project_requirements' => $params['project_requirements'], 'remark' => $params['remark'], 'supervision_department' => $params['supervision_department'], 'implementation_department' => $params['implementation_department'], 'project_department' => $params['project_department'], 'engineering_status' => $params['engineering_status'], 'project_manager' => $params['project_manager'], 'part_a_unit' => $params['part_a_unit'], 'annex' => $params['annex'] ? json_encode($params['annex']) : null, 'create_user' => $admin_id, ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑工程监理--监理项目信息 * @param array $params * @return bool * @author likeadmin * @date 2024/02/23 09:52 */ public static function edit(array $params): bool { Db::startTrans(); try { SupervisionProject::where('id', $params['id'])->update([ 'project_name' => $params['project_name'], 'industry' => $params['industry'], 'nature' => $params['nature'], 'build_unit' => $params['build_unit'], 'build_area' => $params['build_area'], 'address' => $params['address'], 'project_level' => $params['project_level'], 'total_investment' => $params['total_investment'], 'initiation_date' => $params['initiation_date'], 'contract' => $params['contract'], 'contract_amount' => $params['contract_amount'], 'actual_start_date' => !empty($params['actual_start_date']) ? strtotime($params['actual_start_date']) : 0, 'actual_end_date' => !empty($params['actual_end_date']) ? strtotime($params['actual_end_date']) : 0, 'planned_start_date' => !empty($params['planned_start_date']) ? strtotime($params['planned_start_date']) : 0, 'planned_end_date' =>!empty($params['planned_end_date']) ? strtotime($params['planned_end_date']) : 0, 'contract_content' => $params['contract_content'], 'project_overview' => $params['project_overview'], 'project_requirements' => $params['project_requirements'], 'remark' => $params['remark'], 'supervision_department' => $params['supervision_department'], 'implementation_department' => $params['implementation_department'], 'project_department' => $params['project_department'], 'engineering_status' => $params['engineering_status'], 'project_manager' => $params['project_manager'], 'part_a_unit' => $params['part_a_unit'], 'annex' => $params['annex'] ? json_encode($params['annex']) : null, 'update_time' => time(), ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除工程监理--监理项目信息 * @param array $params * @return bool * @author likeadmin * @date 2024/02/23 09:52 */ public static function delete(array $params): bool { return SupervisionProject::destroy($params['id']); } /** * @notes 获取工程监理--监理项目信息详情 * @param $params * @return array * @author likeadmin * @date 2024/02/23 09:52 */ public static function detail($params): array { $data = SupervisionProject::withoutField('update_time,delete_time')->findOrEmpty($params['id']); $admin = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); $data['create_user_name'] = $admin['name']; $data['industry_text'] = $data->industry_text; $data['nature_text'] = $data->nature_text; $data['build_area_text'] = $data->build_area_text; $data['project_level_text'] = $data->project_level_text; $data['engineering_status_text'] = $data->engineering_status_text; return $data->toArray(); } }