|
|
|
@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
@ -46,41 +47,60 @@ public class LabelTransactionLogServiceImpl implements LabelTransactionLogServic |
|
|
|
|
|
|
|
int successCount = 0; |
|
|
|
int failureCount = 0; |
|
|
|
List<Map<String, Object>> details = new ArrayList<>(); |
|
|
|
|
|
|
|
for (Map<String, Object> retryItem : retryList) { |
|
|
|
String site = (String) retryItem.get("site"); |
|
|
|
String buNo = (String) retryItem.get("buNo"); |
|
|
|
String transactionId = (String) retryItem.get("transactionId"); |
|
|
|
|
|
|
|
Map<String, Object> detail = new HashMap<>(); |
|
|
|
detail.put("transactionId", transactionId); |
|
|
|
|
|
|
|
try { |
|
|
|
// 1. 校验StockTransactionLog的传输状态 |
|
|
|
Map<String, Object> syncStatus = stockTransactionLogDao.getSyncStatus(site, buNo, transactionId); |
|
|
|
if (syncStatus != null) { |
|
|
|
String syncedFlag = syncStatus.get("syncedFlag") != null ? syncStatus.get("syncedFlag").toString() : ""; |
|
|
|
String syncedErrorMsg = syncStatus.get("syncedErrorMsg") != null ? syncStatus.get("syncedErrorMsg").toString() : ""; |
|
|
|
|
|
|
|
// 传输状态必须是"待传输"(即synced_flag不为Y)且传输消息必须有值 |
|
|
|
// 传输状态必须是"待传输"(即synced_flag不为Y) |
|
|
|
if ("Y".equalsIgnoreCase(syncedFlag)) { |
|
|
|
logger.warn("该记录已传输成功,不允许重试,transactionId: {}", transactionId); |
|
|
|
detail.put("status", "failure"); |
|
|
|
detail.put("message", "该记录已传输成功,不允许重试"); |
|
|
|
details.add(detail); |
|
|
|
failureCount++; |
|
|
|
continue; |
|
|
|
} |
|
|
|
// if (syncedErrorMsg == null || syncedErrorMsg.trim().isEmpty()) { |
|
|
|
// logger.warn("该记录没有错误信息,不允许重试,transactionId: {}", transactionId); |
|
|
|
// failureCount++; |
|
|
|
// continue; |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
// 2. 调用ERP接口(参考PDA的异步调用方法) |
|
|
|
logger.info("开始调用ERP接口,site: {}, buNo: {}, transactionId: {}", site, buNo, transactionId); |
|
|
|
erpInterfaceService.asyncCallErpInterface(site, buNo, transactionId); |
|
|
|
// 2. 同步调用ERP接口(返回调用结果) |
|
|
|
logger.info("开始同步调用ERP接口,site: {}, buNo: {}, transactionId: {}", site, buNo, transactionId); |
|
|
|
Map<String, Object> callResult = erpInterfaceService.syncCallErpInterface(site, buNo, transactionId); |
|
|
|
|
|
|
|
boolean success = callResult.get("success") != null && (Boolean) callResult.get("success"); |
|
|
|
String message = callResult.get("message") != null ? callResult.get("message").toString() : ""; |
|
|
|
String u8CCode = callResult.get("u8CCode") != null ? callResult.get("u8CCode").toString() : ""; |
|
|
|
|
|
|
|
if (success) { |
|
|
|
successCount++; |
|
|
|
logger.info("手动重试成功,transactionId: {}", transactionId); |
|
|
|
detail.put("status", "success"); |
|
|
|
detail.put("message", message); |
|
|
|
detail.put("u8CCode", u8CCode); |
|
|
|
logger.info("手动重试成功,transactionId: {}, U8单号: {}", transactionId, u8CCode); |
|
|
|
} else { |
|
|
|
failureCount++; |
|
|
|
detail.put("status", "failure"); |
|
|
|
detail.put("message", message); |
|
|
|
logger.warn("手动重试失败,transactionId: {}, 错误: {}", transactionId, message); |
|
|
|
} |
|
|
|
details.add(detail); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("手动重试失败,transactionId: {}, error: {}", transactionId, e.getMessage(), e); |
|
|
|
logger.error("手动重试异常,transactionId: {}, error: {}", transactionId, e.getMessage(), e); |
|
|
|
detail.put("status", "error"); |
|
|
|
detail.put("message", "重试异常: " + e.getMessage()); |
|
|
|
details.add(detail); |
|
|
|
failureCount++; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -91,6 +111,7 @@ public class LabelTransactionLogServiceImpl implements LabelTransactionLogServic |
|
|
|
result.put("successCount", successCount); |
|
|
|
result.put("failureCount", failureCount); |
|
|
|
result.put("totalCount", retryList.size()); |
|
|
|
result.put("details", details); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|