|
|
|
@ -1,10 +1,15 @@ |
|
|
|
package com.gaotao.modules.warehouse.service.impl; |
|
|
|
|
|
|
|
import com.gaotao.modules.erp.service.ErpInterfaceService; |
|
|
|
import com.gaotao.modules.stock.dao.StockTransactionLogDao; |
|
|
|
import com.gaotao.modules.warehouse.dao.LabelTransactionLogMapper; |
|
|
|
import com.gaotao.modules.warehouse.service.LabelTransactionLogService; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@ -14,9 +19,17 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class LabelTransactionLogServiceImpl implements LabelTransactionLogService { |
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(LabelTransactionLogServiceImpl.class); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private LabelTransactionLogMapper labelTransactionLogMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private StockTransactionLogDao stockTransactionLogDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ErpInterfaceService erpInterfaceService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Map<String, Object>> queryList(Map<String, Object> params) { |
|
|
|
return labelTransactionLogMapper.queryList(params); |
|
|
|
@ -26,5 +39,60 @@ public class LabelTransactionLogServiceImpl implements LabelTransactionLogServic |
|
|
|
public int queryTotal(Map<String, Object> params) { |
|
|
|
return labelTransactionLogMapper.queryTotal(params); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> batchRetry(List<Map<String, Object>> retryList) { |
|
|
|
logger.info("批量手动重试开始,记录数: {}", retryList.size()); |
|
|
|
|
|
|
|
int successCount = 0; |
|
|
|
int failureCount = 0; |
|
|
|
|
|
|
|
for (Map<String, Object> retryItem : retryList) { |
|
|
|
String site = (String) retryItem.get("site"); |
|
|
|
String buNo = (String) retryItem.get("buNo"); |
|
|
|
String transactionId = (String) retryItem.get("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)且传输消息必须有值 |
|
|
|
if ("Y".equalsIgnoreCase(syncedFlag)) { |
|
|
|
logger.warn("该记录已传输成功,不允许重试,transactionId: {}", transactionId); |
|
|
|
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); |
|
|
|
|
|
|
|
successCount++; |
|
|
|
logger.info("手动重试成功,transactionId: {}", transactionId); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("手动重试失败,transactionId: {}, error: {}", transactionId, e.getMessage(), e); |
|
|
|
failureCount++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("批量手动重试完成,成功: {}, 失败: {}", successCount, failureCount); |
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
result.put("successCount", successCount); |
|
|
|
result.put("failureCount", failureCount); |
|
|
|
result.put("totalCount", retryList.size()); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|