|
@@ -29,9 +29,15 @@ import org.springblade.meter.vo.*;
|
|
|
import org.springblade.system.entity.Dict;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
|
+import org.springframework.transaction.TransactionDefinition;
|
|
|
+import org.springframework.transaction.TransactionStatus;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -49,6 +55,7 @@ public class MeterTreeController extends BladeController {
|
|
|
private final MeterTreeContractService meterTreeContractService;
|
|
|
private final IContractInventoryFormService contractInventoryFormService;
|
|
|
private final IInventoryFormMeterService inventoryFormMeterService;
|
|
|
+ private final DataSourceTransactionManager transactionManager;
|
|
|
|
|
|
@GetMapping("/template/detail")
|
|
|
@ApiOperationSupport(order = 1)
|
|
@@ -620,10 +627,25 @@ public class MeterTreeController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
if (ObjectUtil.isNotEmpty(dto.getDecompositionList()) && dto.getDecompositionList().size() > 0) {
|
|
|
+ //校验比例是否在范围之内
|
|
|
+ if (dto.getUpPayRatio() == null || dto.getUpPayRatio().compareTo(BigDecimal.ZERO) < 0 || dto.getUpPayRatio().compareTo(new BigDecimal("100")) > 0){
|
|
|
+ throw new ServiceException("修改失败,请检查支付比例是否在规定范围");
|
|
|
+ }
|
|
|
/*最底层节点修改*/
|
|
|
dto.setUpdateStatus(1); //编辑
|
|
|
- boolean b1 = meterTreeContractService.updateById(dto);
|
|
|
- boolean b2 = inventoryFormMeterService.updateInfo(dto.getDecompositionList(), dto.getId());
|
|
|
+ //控制层手动管理事务,判断未引用清单比例是否超过合同计量单元
|
|
|
+ TransactionDefinition def = new DefaultTransactionDefinition();
|
|
|
+ TransactionStatus status = transactionManager.getTransaction(def);
|
|
|
+ boolean b1 = false;
|
|
|
+ boolean b2 = false;
|
|
|
+ try {
|
|
|
+ b1 = meterTreeContractService.updateById(dto);
|
|
|
+ b2 = inventoryFormMeterService.updateInfo(dto.getDecompositionList(), dto.getId(),dto.getUpPayRatio());
|
|
|
+ transactionManager.commit(status);
|
|
|
+ }catch (Exception e){
|
|
|
+ transactionManager.rollback(status);
|
|
|
+ return R.fail(e.getMessage());
|
|
|
+ }
|
|
|
if (b1 && b2) {
|
|
|
return R.success("操作成功");
|
|
|
}
|