带有返回消息的事务回滚

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_40053398/article/details/90710352
@Override
	public Map<String, Object> dealReceiptedAll(WmsMoveDoc moveDoc) {
		Map<String, Object> result = new HashMap<String, Object>();
		result.put(WmsMtAsnDetailShell.ERROR, "");
		String errMsg = null;
		
		if(moveDoc != null) {
			List<WmsMoveDocDetail> details =  getMoveDocDetails(moveDoc.getId());
			if(details != null && details.size() > 0) {
				Double delQty = 0D;
				for (WmsMoveDocDetail detail : details) {
					result = reduceInventory(detail, moveDoc, ALL, null);
					if(StringUtils.isNotBlank((String)result.get(WmsMtAsnDetailShell.ERROR))) {
						//失败,回滚事务
						TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
						return result;
					} else {
						delQty = (Double) result.get("DEL_QTY");
						if(delQty.compareTo(0D) > 0) {
							//同步数据到发运数据中间表
							result = milldleTableManager.kmsDeliverMes(moveDoc, detail, delQty);
							if(StringUtils.isNotEmpty((String)result.get(MilldleTableManager.ERROR))) {
								//失败,回滚事务
								TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
								return result;
							}
						}
					}
				}
			} else {
				errMsg = "该拣货单号下无拣货单明细";
			}
		} else {
			errMsg = "加载拣货单信息失败";
		}
		
		result.put(WmsMtAsnDetailShell.ERROR, errMsg);
		return result;
	}

猜你喜欢

转载自blog.csdn.net/qq_40053398/article/details/90710352