diff --git a/app/Imports/BedFirstSheetImport.php b/app/Imports/BedFirstSheetImport.php index 8a3ec2e..fe8b367 100644 --- a/app/Imports/BedFirstSheetImport.php +++ b/app/Imports/BedFirstSheetImport.php @@ -251,16 +251,17 @@ class BedFirstSheetImport implements ToCollection, WithBatchInserts, WithChunkRe DB::commit(); }catch (\PDOException $e){ - DB::rollBack(); + if ($e->getCode() === '23000') { // 唯一性约束错误处理逻辑 - $errorMessage = "导入表格中存在已入库学生信息,请勿重复导入"; + $errorMessage = "导入表格中存在已入库床位信息,请勿重复导入"; // 可以根据需要进行相关处理 throw new \Exception($errorMessage); } else { // 其他类型的错误处理逻辑 throw new \Exception("导入数据失败2,请重试"); } + DB::rollBack(); }catch (\Exception $e){ DB::rollBack(); throw new \Exception("导入数据失败3,请重试");