From fcdb56cf78b63f5b1455bbfab0c2bd7934b0aca5 Mon Sep 17 00:00:00 2001 From: 李宇 <986321569@qq.com> Date: 星期三, 07 四月 2021 18:18:14 +0800 Subject: [PATCH] 去除多余事务 --- src/main/java/com/nanometer/smartlab/service/OpeWarehouseReserveServiceImpl.java | 21 ++++++--------------- 1 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/nanometer/smartlab/service/OpeWarehouseReserveServiceImpl.java b/src/main/java/com/nanometer/smartlab/service/OpeWarehouseReserveServiceImpl.java index 2cf787e..d63916b 100644 --- a/src/main/java/com/nanometer/smartlab/service/OpeWarehouseReserveServiceImpl.java +++ b/src/main/java/com/nanometer/smartlab/service/OpeWarehouseReserveServiceImpl.java @@ -205,7 +205,7 @@ } } - @Transactional(propagation = Propagation.REQUIRED) + @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED) public boolean updateOpeWarehouseReserve(OpeWarehouseReserve opeWarehouseReserve) { try { int row = this.opeWarehouseReserveDao.updateOpeWarehouseReserve(opeWarehouseReserve); @@ -225,26 +225,14 @@ } } - @Transactional(propagation = Propagation.REQUIRED) + @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED) public void claimForPerson(List<OpeApplyReserve> selectedListForPerson,String userId,String projectNum,String laboratoryId,String laboratoryContainerId){ try{ for(OpeApplyReserve app:selectedListForPerson){ List<String> reagentCodes = app.getReagentCode(); if (reagentCodes != null && reagentCodes.size() > 0) { - List<OpeReagentStatus> ss=new ArrayList<>(); - for (String opeReagentStatusId : reagentCodes) { - OpeReagentStatus opeReagentStatus = this.opeReagentStatusService.getOpeReagentStatus(opeReagentStatusId); - opeReagentStatus.setUserId(userId); - opeReagentStatus.setProjectNum(projectNum); - //boolean flag = this.opeReagentStatusService.updateReagentStatus(opeReagentStatus); - ss.add(opeReagentStatus); - //更新试剂状态和 - opeReagentStatus.setHouseId(laboratoryId); - opeReagentStatus.setContainerId(laboratoryContainerId); - this.opeReagentStatusDao.updateOpeReagentStatusDao(opeReagentStatus); - this.opeReagentStatusService.updateReagentStatus3(opeReagentStatus); + this.opeReagentStatusService.updateReagentStatus3(reagentCodes,userId,projectNum,laboratoryId,laboratoryContainerId); - } //更新是现实库存 OpeLaboratoryReserve lr=new OpeLaboratoryReserve(); lr.setReagentId(app.getReagent().getId()); @@ -295,6 +283,9 @@ logger.error(ex.getMessage(), ex); throw new BusinessException(ExceptionEnumCode.DB_ERR, MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), ex); + }catch(Exception e){ + e.printStackTrace(); + throw new RuntimeException(e); } } -- Gitblit v1.9.2