|
|
|
@ -2,12 +2,14 @@ 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.sys.dao.InterfaceLogDao; |
|
|
|
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 org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
@ -28,6 +30,9 @@ public class LabelTransactionLogServiceImpl implements LabelTransactionLogServic |
|
|
|
@Autowired |
|
|
|
private StockTransactionLogDao stockTransactionLogDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private InterfaceLogDao interfaceLogDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ErpInterfaceService erpInterfaceService; |
|
|
|
|
|
|
|
@ -117,5 +122,53 @@ public class LabelTransactionLogServiceImpl implements LabelTransactionLogServic |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Map<String, Object> batchClose(List<Map<String, Object>> closeList) { |
|
|
|
logger.info("批量异常关闭开始,记录数: {}", closeList.size()); |
|
|
|
|
|
|
|
int successCount = 0; |
|
|
|
int failureCount = 0; |
|
|
|
List<Map<String, Object>> details = new ArrayList<>(); |
|
|
|
|
|
|
|
for (Map<String, Object> closeItem : closeList) { |
|
|
|
String site = (String) closeItem.get("site"); |
|
|
|
String buNo = (String) closeItem.get("buNo"); |
|
|
|
String transactionId = (String) closeItem.get("transactionId"); |
|
|
|
|
|
|
|
Map<String, Object> detail = new HashMap<>(); |
|
|
|
detail.put("transactionId", transactionId); |
|
|
|
|
|
|
|
try { |
|
|
|
// 1. 更新StockTransactionLog表的synced_flag为'Y' |
|
|
|
stockTransactionLogDao.updateSyncedSuccessBySiteAndTransactionId(site, transactionId); |
|
|
|
|
|
|
|
// 2. 更新api_log表的need_retry_flag为0,status_code为'200' |
|
|
|
interfaceLogDao.closeApiLogByTransactionId(site, transactionId); |
|
|
|
|
|
|
|
successCount++; |
|
|
|
detail.put("status", "success"); |
|
|
|
detail.put("message", "异常关闭成功"); |
|
|
|
logger.info("异常关闭成功,transactionId: {}", transactionId); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("异常关闭失败,transactionId: {}, error: {}", transactionId, e.getMessage(), e); |
|
|
|
detail.put("status", "error"); |
|
|
|
detail.put("message", "异常关闭失败: " + e.getMessage()); |
|
|
|
details.add(detail); |
|
|
|
failureCount++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("批量异常关闭完成,成功: {}, 失败: {}", successCount, failureCount); |
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
result.put("successCount", successCount); |
|
|
|
result.put("failureCount", failureCount); |
|
|
|
result.put("totalCount", closeList.size()); |
|
|
|
result.put("details", details); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|