update:调整异步策略
This commit is contained in:
parent
c0b98c69c4
commit
9a8decd608
|
@ -30,6 +30,7 @@ import com.google.common.collect.Lists;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
|
@ -65,6 +66,9 @@ import static cn.iocoder.yudao.module.haoka.enums.ErrorCodeConstants.*;
|
|||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> implements OrdersService {
|
||||
@Lazy
|
||||
@Resource
|
||||
private OrdersServiceImpl ordersService;
|
||||
@Resource
|
||||
private OrdersMapper ordersMapper;
|
||||
@Resource
|
||||
|
@ -162,13 +166,14 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
ordersDO
|
||||
);
|
||||
// 异步判断是否自动提交审核订单
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
|
||||
@Override
|
||||
public void afterCommit() {
|
||||
//异步操作
|
||||
asyncSubmitAuditOrders(ordersDO);
|
||||
}
|
||||
});
|
||||
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
|
||||
// @Override
|
||||
// public void afterCommit() {
|
||||
// //异步操作
|
||||
// asyncSubmitAuditOrders(ordersDO);
|
||||
// }
|
||||
// });
|
||||
ordersService.asyncSubmitAuditOrders(ordersDO);
|
||||
// 返回
|
||||
return orders.getId();
|
||||
}
|
||||
|
@ -186,7 +191,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
OrdersSaveReqVO ordersSaveReqVO = new OrdersSaveReqVO();
|
||||
ordersSaveReqVO.setId(ordersDO.getId());
|
||||
ordersSaveReqVO.setStatus(120L);
|
||||
this.updateOrders(ordersSaveReqVO);
|
||||
ordersService.updateOrders(ordersSaveReqVO);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,13 +323,14 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
Integer autoType = oldOrderDo.getAutoType();
|
||||
// 联合条件: 自动生产 && 审核通过 && 提交初审
|
||||
if(2 == autoType && canAudit && submit){
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
|
||||
@Override
|
||||
public void afterCommit() {
|
||||
//异步操作
|
||||
asyncAuditOrders(updateObj);
|
||||
}
|
||||
});
|
||||
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
|
||||
// @Override
|
||||
// public void afterCommit() {
|
||||
// //异步操作
|
||||
// asyncAuditOrders(updateObj);
|
||||
// }
|
||||
// });
|
||||
ordersService.asyncAuditOrders(updateObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +343,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
// 自动生产 调用审核
|
||||
OrdersSaveReqVO ordersSaveReqVO = BeanUtils.toBean(ordersDO, OrdersSaveReqVO.class);
|
||||
ordersSaveReqVO.setStatus(450L);
|
||||
this.auditOrders(ordersSaveReqVO);
|
||||
ordersService.auditOrders(ordersSaveReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue