findOrEmpty(); if($dangerous_engineering_monitoring['status'] != 0){ self::setError('当前危大工程监控信息已提交方案'); return false; } Db::startTrans(); try { SupervisionDangerousEngineeringCase::create([ 'dangerous_engineering_monitoring_id' => $params['dangerous_engineering_monitoring_id'], 'case_name' => $params['case_name'], 'assessor' => $params['assessor'], 'review_content' => $params['review_content'], 'remark' => $params['remark'], 'annex' => $params['annex'] ? json_encode($params['annex']) : null, 'create_user' => $admin_id ]); SupervisionDangerousEngineeringMonitoring::where('id',$params['dangerous_engineering_monitoring_id'])->update([ 'status' => 1, '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/03/04 14:00 */ public static function edit(array $params): bool { Db::startTrans(); try { SupervisionDangerousEngineeringCase::where('id', $params['id'])->update([ 'case_name' => $params['case_name'], 'assessor' => $params['assessor'], 'review_content' => $params['review_content'], 'remark' => $params['remark'], '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/03/04 14:00 */ public static function delete(array $params): bool { return SupervisionDangerousEngineeringCase::destroy($params['id']); } /** * @notes 获取工程监理--危大方案提交列表详情 * @param $params * @return array * @author likeadmin * @date 2024/03/04 14:00 */ public static function detail($params): array { $data = SupervisionDangerousEngineeringCase::withoutField('update_time,delete_time')->findOrEmpty($params['id']); $dangerous_engineering_monitoring = SupervisionDangerousEngineeringMonitoring::field('project_id,type,partial_project')->where('id',$data['dangerous_engineering_monitoring_id'])->findOrEmpty(); $project = SupervisionProject::field('project_name')->where('id',$dangerous_engineering_monitoring['project_id'])->findOrEmpty(); $create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); $data['dangerous_engineering_monitoring_title'] = $project['project_name']; $data['project_name'] = $project['project_name']; $data['type'] = $dangerous_engineering_monitoring->type_text; $data['partial_project'] = $dangerous_engineering_monitoring->partial_project_text; $data['create_user_name'] = $create_user['name']; return $data->toArray(); } }