refactor(sales): 优化销售和退货流程的并发控制
- 在 SoSaleOutPluginInitializerToC 和 SoSaleReturnPluginInitializerToC 类中添加了 ReentrantLock- 为 getSetStock 和 getSetTran 方法添加了并发控制逻辑 - 增加了异常捕获和日志记录,提高了系统的健壮性
This commit is contained in:
parent
329e9f01ea
commit
251930ad8f
|
@ -408,12 +408,19 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
* @author liuyang
|
||||
*/
|
||||
private void getSetStock(List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtoList) throws Exception {
|
||||
LOCK1.lock();
|
||||
try {
|
||||
//过滤成功的数据
|
||||
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtos = filterDataStock(headerDetailsDtoList);
|
||||
//保存到mysql底表
|
||||
batchInsert(headerDetailsDtos);
|
||||
//执行推送主逻辑
|
||||
implementStock(headerDetailsDtos);
|
||||
} catch (Exception e) {
|
||||
logger.error("TOC销售-库存:getSetStock方法抛出异常", e);
|
||||
} finally {
|
||||
LOCK1.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -422,6 +429,8 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
* @author liuyang
|
||||
*/
|
||||
private void getSetTran(List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtoList) throws Exception {
|
||||
LOCK2.lock();
|
||||
try {
|
||||
//先过滤成功的数据,再保存到低表
|
||||
//headerDetailsDtos携带红、蓝单据推送成功与否的明细行
|
||||
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtos = filterDataTran(headerDetailsDtoList);
|
||||
|
@ -429,6 +438,11 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
batchInsert(headerDetailsDtos);
|
||||
//执行推送主逻辑
|
||||
implementTran(headerDetailsDtos);
|
||||
} catch (Exception e) {
|
||||
logger.error("TOC销售-交易成功:getSetTran方法抛出异常", e);
|
||||
} finally {
|
||||
LOCK2.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,7 +57,11 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
|
||||
Logger logger = LoggerFactory.getLogger(SoSaleReturnPluginInitializerToC.class);
|
||||
|
||||
private static final ReentrantLock LOCK = new ReentrantLock(true);
|
||||
// private static final ReentrantLock LOCK = new ReentrantLock(true);
|
||||
|
||||
private static final ReentrantLock LOCK1 = new ReentrantLock(true);
|
||||
|
||||
private static final ReentrantLock LOCK2 = new ReentrantLock(true);
|
||||
|
||||
private static final String STOCK = "stock";
|
||||
|
||||
|
@ -333,12 +337,19 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
* @author liuyang
|
||||
*/
|
||||
private void getSetStock(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList) throws Exception {
|
||||
LOCK1.lock();
|
||||
try {
|
||||
//过滤成功的数据
|
||||
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = filterDataStock(returnGoodHeaderDetailsDataDtoArrayList);
|
||||
//保存到mysql
|
||||
batchInsert(stockinOrderList);
|
||||
//执行推送主逻辑
|
||||
implementStock(stockinOrderList);
|
||||
} catch (Exception e) {
|
||||
logger.error("TOC退货-库存:getSetStock方法抛出异常", e);
|
||||
} finally {
|
||||
LOCK1.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -347,12 +358,19 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
|
|||
* @author liuyang
|
||||
*/
|
||||
private void getSetTran(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList) throws Exception {
|
||||
LOCK2.lock();
|
||||
try {
|
||||
//过滤成功的数据
|
||||
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = filterDataTran(returnGoodHeaderDetailsDataDtoArrayList);
|
||||
//保存到mysql
|
||||
batchInsert(stockinOrderList);
|
||||
//执行推送主逻辑
|
||||
implementTran(stockinOrderList);
|
||||
} catch (Exception e) {
|
||||
logger.error("TOC退货-确认收入:getSetTran方法抛出异常", e);
|
||||
} finally {
|
||||
LOCK2.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue