| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.TransactionStatus; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.support.DefaultTransactionDefinition; |
| | | import org.springframework.transaction.support.TransactionTemplate; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | */ |
| | | @Autowired |
| | | private FormulaServiceImpl formulaService; |
| | | |
| | | // 注入事务管理器 |
| | | @Autowired |
| | | private TransactionTemplate transactionTemplate; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | if(!CollectionUtils.isEmpty(editCodeDOs)){ |
| | | codeAllCodeService.updateBatchById(editCodeDOs); |
| | | } |
| | | // 获取事务定义 |
| | | DefaultTransactionDefinition def = new DefaultTransactionDefinition(); |
| | | // 开始事务 |
| | | TransactionStatus status = transactionTemplate.getTransactionManager().getTransaction(def); |
| | | if(!CollectionUtils.isEmpty(addCodeDOs)){ |
| | | Map<String, String> statusMap = addCodeDOs.stream().collect(Collectors.toMap(s -> s.getOid(), s -> s.getLcStatus())); |
| | | addCodeDOs.stream().filter(s -> StringUtils.equalsIgnoreCase("codeallcode",s.getBtmname())).forEach(s -> { |
| | |
| | | if(takeBack.size()>0){ |
| | | codeAllCodeService.updateBatchById(takeBack); |
| | | } |
| | | |
| | | codeAllCodeService.saveBatch(addCodeDOs); |
| | | } |
| | | |
| | | mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList); |
| | | try { |
| | | mdmEngineService.insertBatchByType(dataCBOList.get(0).getBtmname(),dataCBOList); |
| | | // 提交事务 |
| | | transactionTemplate.getTransactionManager().commit(status); |
| | | }catch (Exception e){ |
| | | // 出现异常时回滚事务 |
| | | transactionTemplate.getTransactionManager().rollback(status); |
| | | } |
| | | |
| | | } |
| | | return codeList; |
| | | }else { |