Browse Source

优化录入床位信息报错问题

master
崔茂正 10 months ago
parent
commit
80f7e0bd81
  1. 4
      app/Imports/BedFirstSheetImport.php

4
app/Imports/BedFirstSheetImport.php

@ -251,7 +251,7 @@ class BedFirstSheetImport implements ToCollection, WithBatchInserts, WithChunkRe @@ -251,7 +251,7 @@ class BedFirstSheetImport implements ToCollection, WithBatchInserts, WithChunkRe
DB::commit();
}catch (\PDOException $e){
DB::rollBack(); // 先回滚事务
if ($e->getCode() === '23000') {
// 唯一性约束错误处理逻辑
$errorMessage = "导入表格中存在已入库床位信息,请勿重复导入";
@ -261,7 +261,7 @@ class BedFirstSheetImport implements ToCollection, WithBatchInserts, WithChunkRe @@ -261,7 +261,7 @@ class BedFirstSheetImport implements ToCollection, WithBatchInserts, WithChunkRe
// 其他类型的错误处理逻辑
throw new \Exception("导入数据失败2,请重试");
}
DB::rollBack();
}catch (\Exception $e){
DB::rollBack();
throw new \Exception("导入数据失败3,请重试");

Loading…
Cancel
Save