|
|
@ -133,49 +133,317 @@ public class ErpInterfaceServiceImpl implements ErpInterfaceService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据接口名称获取KdType值 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String getKdType(String interfaceName) { |
|
|
|
|
|
if (interfaceName == null) { |
|
|
|
|
|
return ""; |
|
|
|
|
|
} |
|
|
|
|
|
switch (interfaceName) { |
|
|
|
|
|
case "GetSaveurchaseReturn": |
|
|
|
|
|
return "红字"; |
|
|
|
|
|
case "GetSaveurchaseIn": |
|
|
|
|
|
return "蓝字"; |
|
|
|
|
|
case "GetSaveSalesOut": |
|
|
|
|
|
return "发货"; |
|
|
|
|
|
case "GetSaveSalesReturn": |
|
|
|
|
|
return "退货"; |
|
|
|
|
|
case "GetSaveOthersStorageOut": |
|
|
|
|
|
return "出库"; |
|
|
|
|
|
case "GetSaveOthersStorage": |
|
|
|
|
|
return "入库"; |
|
|
|
|
|
case "GetSaveroductionIssue": |
|
|
|
|
|
return "领料"; |
|
|
|
|
|
case "GetSaveroductionReturn": |
|
|
|
|
|
return "退料"; |
|
|
|
|
|
default: |
|
|
|
|
|
return ""; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 组装接口请求参数 |
|
|
* 组装接口请求参数 |
|
|
*/ |
|
|
*/ |
|
|
private Map<String, Object> buildRequestBody(List<StockTransactionLogEntity> transactionLogs) { |
|
|
private Map<String, Object> buildRequestBody(List<StockTransactionLogEntity> transactionLogs) { |
|
|
StockTransactionLogEntity firstLog = transactionLogs.get(0); |
|
|
StockTransactionLogEntity firstLog = transactionLogs.get(0); |
|
|
|
|
|
String interfaceName = firstLog.getInterfaceName(); |
|
|
|
|
|
|
|
|
Map<String, Object> requestBody = new LinkedHashMap<>(); |
|
|
Map<String, Object> requestBody = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 根据接口名称组装不同的请求参数 |
|
|
|
|
|
if ("GetSaveurchaseReturn".equals(interfaceName) || "GetSaveurchaseIn".equals(interfaceName)) { |
|
|
|
|
|
// 采购退货/采购入库 |
|
|
|
|
|
requestBody = buildPurchaseRequestBody(transactionLogs, interfaceName); |
|
|
|
|
|
} else if ("GetSaveSalesOut".equals(interfaceName) || "GetSaveSalesReturn".equals(interfaceName)) { |
|
|
|
|
|
// 销售出库/销售退货 |
|
|
|
|
|
requestBody = buildSalesRequestBody(transactionLogs, interfaceName); |
|
|
|
|
|
} else if ("GetSaveOthersStorageOut".equals(interfaceName) || "GetSaveOthersStorage".equals(interfaceName)) { |
|
|
|
|
|
// 其他出库/其他入库 |
|
|
|
|
|
requestBody = buildOthersStorageRequestBody(transactionLogs, interfaceName); |
|
|
|
|
|
} else if ("GetSaveroductionIssue".equals(interfaceName) || "GetSaveroductionReturn".equals(interfaceName)) { |
|
|
|
|
|
// 生产领料/生产退料 |
|
|
|
|
|
requestBody = buildProductionIssueRequestBody(transactionLogs, interfaceName); |
|
|
|
|
|
} else if ("GetSaveroductionIn".equals(interfaceName)) { |
|
|
|
|
|
// 生产入库 |
|
|
|
|
|
requestBody = buildProductionInRequestBody(transactionLogs, interfaceName); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 默认格式 |
|
|
|
|
|
requestBody = buildDefaultRequestBody(transactionLogs, interfaceName); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return requestBody; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 采购退货/采购入库请求参数 |
|
|
|
|
|
*/ |
|
|
|
|
|
private Map<String, Object> buildPurchaseRequestBody(List<StockTransactionLogEntity> transactionLogs, String interfaceName) { |
|
|
|
|
|
StockTransactionLogEntity firstLog = transactionLogs.get(0); |
|
|
|
|
|
Map<String, Object> requestBody = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
// 主表字段 |
|
|
// 主表字段 |
|
|
requestBody.put("MESCCode", firstLog.getDocumentNo() != null ? firstLog.getDocumentNo() : ""); |
|
|
|
|
|
requestBody.put("KdType", firstLog.getTransactionType() != null ? firstLog.getTransactionType() : ""); |
|
|
|
|
|
|
|
|
requestBody.put("MESCCode", nullToEmpty(firstLog.getDocumentNo())); |
|
|
|
|
|
requestBody.put("KdType", getKdType(interfaceName)); |
|
|
requestBody.put("DDate", formatDate(firstLog.getTransactionDate())); |
|
|
requestBody.put("DDate", formatDate(firstLog.getTransactionDate())); |
|
|
requestBody.put("CRdCode", firstLog.getDocumentNoType() != null ? firstLog.getDocumentNoType() : ""); |
|
|
|
|
|
|
|
|
requestBody.put("CRdCode", nullToEmpty(firstLog.getDocumentNoType())); |
|
|
|
|
|
requestBody.put("CSTCode", ""); |
|
|
|
|
|
requestBody.put("CBusType", ""); |
|
|
|
|
|
requestBody.put("CDepCode", ""); |
|
|
|
|
|
requestBody.put("CVenCode", ""); |
|
|
|
|
|
requestBody.put("ITaxRate", ""); |
|
|
|
|
|
requestBody.put("CPersonCode", ""); |
|
|
|
|
|
requestBody.put("IExchRate", ""); |
|
|
|
|
|
requestBody.put("Cexch_name", ""); |
|
|
requestBody.put("CMemo", ""); |
|
|
requestBody.put("CMemo", ""); |
|
|
requestBody.put("CWhCode", firstLog.getWarehouseId() != null ? firstLog.getWarehouseId() : ""); |
|
|
|
|
|
|
|
|
requestBody.put("CWhCode", nullToEmpty(firstLog.getWarehouseId())); |
|
|
|
|
|
|
|
|
|
|
|
// 明细列表 |
|
|
|
|
|
List<Map<String, Object>> detailList = new ArrayList<>(); |
|
|
|
|
|
int rowNo = 1; |
|
|
|
|
|
for (StockTransactionLogEntity log : transactionLogs) { |
|
|
|
|
|
Map<String, Object> detail = new LinkedHashMap<>(); |
|
|
|
|
|
detail.put("MESIrowNo", String.valueOf(rowNo)); |
|
|
|
|
|
detail.put("OutCode", nullToEmpty(log.getOrderNo())); |
|
|
|
|
|
detail.put("OutIrowNo", nullToEmpty(log.getOrderLineNo())); |
|
|
|
|
|
detail.put("CInvCode", nullToEmpty(log.getPartNo())); |
|
|
|
|
|
detail.put("IQuantity", log.getRollQty() != null ? log.getRollQty().toString() : "0"); |
|
|
|
|
|
detail.put("INum", ""); |
|
|
|
|
|
detail.put("CUnitID", ""); |
|
|
|
|
|
detail.put("ITaxRate", ""); |
|
|
|
|
|
detail.put("ITaxUnitPrice", ""); |
|
|
|
|
|
detail.put("CBatch", nullToEmpty(log.getRollNo())); |
|
|
|
|
|
detail.put("CbMemo", ""); |
|
|
|
|
|
detailList.add(detail); |
|
|
|
|
|
} |
|
|
|
|
|
requestBody.put("DetailList", detailList); |
|
|
|
|
|
|
|
|
|
|
|
return requestBody; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 销售出库/销售退货请求参数 |
|
|
|
|
|
*/ |
|
|
|
|
|
private Map<String, Object> buildSalesRequestBody(List<StockTransactionLogEntity> transactionLogs, String interfaceName) { |
|
|
|
|
|
StockTransactionLogEntity firstLog = transactionLogs.get(0); |
|
|
|
|
|
Map<String, Object> requestBody = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 主表字段 |
|
|
|
|
|
requestBody.put("MESCCode", nullToEmpty(firstLog.getDocumentNo())); |
|
|
|
|
|
requestBody.put("KdType", getKdType(interfaceName)); |
|
|
|
|
|
requestBody.put("DDate", formatDate(firstLog.getTransactionDate())); |
|
|
|
|
|
requestBody.put("CBusType", ""); |
|
|
|
|
|
requestBody.put("CDepCode", ""); |
|
|
|
|
|
requestBody.put("CSTCode", ""); |
|
|
|
|
|
requestBody.put("CCusCode", ""); |
|
|
|
|
|
requestBody.put("CVenCode", ""); |
|
|
|
|
|
requestBody.put("CPersonCode", ""); |
|
|
|
|
|
requestBody.put("IExchRate", ""); |
|
|
|
|
|
requestBody.put("Cexch_name", ""); |
|
|
|
|
|
requestBody.put("Cgatheringplan", ""); |
|
|
requestBody.put("CCusOAddress", ""); |
|
|
requestBody.put("CCusOAddress", ""); |
|
|
requestBody.put("CDepCode", firstLog.getDepartmentId() != null ? firstLog.getDepartmentId() : ""); |
|
|
|
|
|
|
|
|
requestBody.put("CMemo", ""); |
|
|
|
|
|
|
|
|
|
|
|
// 明细列表 |
|
|
|
|
|
List<Map<String, Object>> detailList = new ArrayList<>(); |
|
|
|
|
|
int rowNo = 1; |
|
|
|
|
|
for (StockTransactionLogEntity log : transactionLogs) { |
|
|
|
|
|
Map<String, Object> detail = new LinkedHashMap<>(); |
|
|
|
|
|
detail.put("MESIrowNo", String.valueOf(rowNo)); |
|
|
|
|
|
detail.put("OutCode", nullToEmpty(log.getOrderNo())); |
|
|
|
|
|
detail.put("OutIrowNo", nullToEmpty(log.getOrderLineNo())); |
|
|
|
|
|
detail.put("CInvCode", nullToEmpty(log.getPartNo())); |
|
|
|
|
|
detail.put("IQuantity", log.getRollQty() != null ? log.getRollQty().toString() : "0"); |
|
|
|
|
|
detail.put("INum", ""); |
|
|
|
|
|
detail.put("CUnitID", ""); |
|
|
|
|
|
detail.put("ITaxRate", ""); |
|
|
|
|
|
detail.put("ITaxUnitPrice", ""); |
|
|
|
|
|
detail.put("CWhCode", nullToEmpty(log.getWarehouseId())); |
|
|
|
|
|
detail.put("CBatch", nullToEmpty(log.getRollNo())); |
|
|
|
|
|
detailList.add(detail); |
|
|
|
|
|
} |
|
|
|
|
|
requestBody.put("DetailList", detailList); |
|
|
|
|
|
|
|
|
|
|
|
return requestBody; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 其他出库/其他入库请求参数 |
|
|
|
|
|
*/ |
|
|
|
|
|
private Map<String, Object> buildOthersStorageRequestBody(List<StockTransactionLogEntity> transactionLogs, String interfaceName) { |
|
|
|
|
|
StockTransactionLogEntity firstLog = transactionLogs.get(0); |
|
|
|
|
|
Map<String, Object> requestBody = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 主表字段 |
|
|
|
|
|
requestBody.put("MESCCode", nullToEmpty(firstLog.getDocumentNo())); |
|
|
|
|
|
requestBody.put("KdType", getKdType(interfaceName)); |
|
|
|
|
|
requestBody.put("DDate", formatDate(firstLog.getTransactionDate())); |
|
|
|
|
|
requestBody.put("CRdCode", nullToEmpty(firstLog.getDocumentNoType())); |
|
|
|
|
|
requestBody.put("Cmemo", ""); |
|
|
|
|
|
requestBody.put("CWhCode", nullToEmpty(firstLog.getWarehouseId())); |
|
|
|
|
|
requestBody.put("CDepCode", nullToEmpty(firstLog.getDepartmentId())); |
|
|
|
|
|
|
|
|
// 明细列表 |
|
|
// 明细列表 |
|
|
List<Map<String, Object>> detailList = new ArrayList<>(); |
|
|
List<Map<String, Object>> detailList = new ArrayList<>(); |
|
|
int rowNo = 1; |
|
|
int rowNo = 1; |
|
|
for (StockTransactionLogEntity log : transactionLogs) { |
|
|
for (StockTransactionLogEntity log : transactionLogs) { |
|
|
Map<String, Object> detail = new LinkedHashMap<>(); |
|
|
Map<String, Object> detail = new LinkedHashMap<>(); |
|
|
detail.put("MESIrowNo", String.valueOf(rowNo++)); |
|
|
|
|
|
detail.put("OutCode", log.getOrderNo() != null ? log.getOrderNo() : ""); |
|
|
|
|
|
detail.put("OutIrowNo", log.getOrderLineNo() != null ? log.getOrderLineNo() : ""); |
|
|
|
|
|
detail.put("CInvCode", log.getPartNo() != null ? log.getPartNo() : ""); |
|
|
|
|
|
|
|
|
detail.put("MESIrowNo", String.valueOf(rowNo)); |
|
|
|
|
|
detail.put("CInvCode", nullToEmpty(log.getPartNo())); |
|
|
detail.put("IQuantity", log.getRollQty() != null ? log.getRollQty().toString() : "0"); |
|
|
detail.put("IQuantity", log.getRollQty() != null ? log.getRollQty().toString() : "0"); |
|
|
detail.put("CBatch", ""); |
|
|
|
|
|
|
|
|
detail.put("INum", ""); |
|
|
|
|
|
detail.put("CUnitID", ""); |
|
|
detail.put("CbMemo", ""); |
|
|
detail.put("CbMemo", ""); |
|
|
detail.put("CWhCode", log.getWarehouseId() != null ? log.getWarehouseId() : ""); |
|
|
|
|
|
detail.put("OutMocode", log.getOrderNo() != null ? log.getOrderNo() : ""); |
|
|
|
|
|
detail.put("OutIrowNo_zj", log.getBomItemNo() != null ? log.getBomItemNo() : ""); |
|
|
|
|
|
|
|
|
detail.put("CBatch", nullToEmpty(log.getRollNo())); |
|
|
|
|
|
detailList.add(detail); |
|
|
|
|
|
} |
|
|
|
|
|
requestBody.put("DetailList", detailList); |
|
|
|
|
|
|
|
|
|
|
|
return requestBody; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 生产领料/生产退料请求参数 |
|
|
|
|
|
*/ |
|
|
|
|
|
private Map<String, Object> buildProductionIssueRequestBody(List<StockTransactionLogEntity> transactionLogs, String interfaceName) { |
|
|
|
|
|
StockTransactionLogEntity firstLog = transactionLogs.get(0); |
|
|
|
|
|
Map<String, Object> requestBody = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 主表字段 |
|
|
|
|
|
requestBody.put("MESCCode", nullToEmpty(firstLog.getDocumentNo())); |
|
|
|
|
|
requestBody.put("KdType", getKdType(interfaceName)); |
|
|
|
|
|
requestBody.put("DDate", formatDate(firstLog.getTransactionDate())); |
|
|
|
|
|
requestBody.put("CWhCode", nullToEmpty(firstLog.getWarehouseId())); |
|
|
|
|
|
requestBody.put("CMemo", ""); |
|
|
|
|
|
requestBody.put("CRdCode", nullToEmpty(firstLog.getDocumentNoType())); |
|
|
|
|
|
requestBody.put("CDepCode", ""); |
|
|
|
|
|
|
|
|
|
|
|
// 明细列表 |
|
|
|
|
|
List<Map<String, Object>> detailList = new ArrayList<>(); |
|
|
|
|
|
int rowNo = 1; |
|
|
|
|
|
for (StockTransactionLogEntity log : transactionLogs) { |
|
|
|
|
|
Map<String, Object> detail = new LinkedHashMap<>(); |
|
|
|
|
|
detail.put("MESIrowNo", String.valueOf(rowNo)); |
|
|
|
|
|
detail.put("CInvCode", nullToEmpty(log.getPartNo())); |
|
|
|
|
|
detail.put("IQuantity", log.getRollQty() != null ? log.getRollQty().toString() : "0"); |
|
|
|
|
|
detail.put("CUnitID", ""); |
|
|
|
|
|
detail.put("INum", ""); |
|
|
|
|
|
detail.put("CBatch", nullToEmpty(log.getRollNo())); |
|
|
|
|
|
detail.put("OutMocode", nullToEmpty(log.getOrderref1())); // erp_order_no |
|
|
|
|
|
detail.put("OutIrowNo", nullToEmpty(log.getOrderLineNo())); |
|
|
|
|
|
detail.put("OutIrowNo_zj", nullToEmpty(log.getBomItemNo())); |
|
|
|
|
|
detailList.add(detail); |
|
|
|
|
|
} |
|
|
|
|
|
requestBody.put("DetailList", detailList); |
|
|
|
|
|
|
|
|
|
|
|
return requestBody; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 生产入库请求参数 |
|
|
|
|
|
*/ |
|
|
|
|
|
private Map<String, Object> buildProductionInRequestBody(List<StockTransactionLogEntity> transactionLogs, String interfaceName) { |
|
|
|
|
|
StockTransactionLogEntity firstLog = transactionLogs.get(0); |
|
|
|
|
|
Map<String, Object> requestBody = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 主表字段 |
|
|
|
|
|
requestBody.put("MESCCode", nullToEmpty(firstLog.getDocumentNo())); |
|
|
|
|
|
requestBody.put("DDate", formatDate(firstLog.getTransactionDate())); |
|
|
|
|
|
requestBody.put("CDepCode", nullToEmpty(firstLog.getDepartmentId())); |
|
|
|
|
|
requestBody.put("CRdCode", nullToEmpty(firstLog.getDocumentNoType())); |
|
|
|
|
|
requestBody.put("CMemo", ""); |
|
|
|
|
|
requestBody.put("CWhCode", nullToEmpty(firstLog.getWarehouseId())); |
|
|
|
|
|
|
|
|
|
|
|
// 明细列表 |
|
|
|
|
|
List<Map<String, Object>> detailList = new ArrayList<>(); |
|
|
|
|
|
int rowNo = 1; |
|
|
|
|
|
for (StockTransactionLogEntity log : transactionLogs) { |
|
|
|
|
|
Map<String, Object> detail = new LinkedHashMap<>(); |
|
|
|
|
|
detail.put("MESIrowNo", String.valueOf(rowNo)); |
|
|
|
|
|
detail.put("CInvCode", nullToEmpty(log.getPartNo())); |
|
|
|
|
|
detail.put("IQuantity", log.getRollQty() != null ? log.getRollQty().toString() : "0"); |
|
|
|
|
|
detail.put("CUnitID", nullToEmpty(log.getUmid())); |
|
|
|
|
|
detail.put("INum", nullToEmpty(log.getOrderref2())); // piece_qty |
|
|
detail.put("NumberOfCases", ""); |
|
|
detail.put("NumberOfCases", ""); |
|
|
|
|
|
|
|
|
|
|
|
detail.put("CbMemo", ""); |
|
|
|
|
|
detail.put("CBatch", nullToEmpty(log.getRollNo())); |
|
|
|
|
|
detail.put("OutMocode", nullToEmpty(log.getOrderref1())); // erp_order_no |
|
|
|
|
|
detail.put("OutIrowNo", nullToEmpty(log.getOrderLineNo())); |
|
|
|
|
|
detail.put("OutIrowNo_zj", ""); |
|
|
detailList.add(detail); |
|
|
detailList.add(detail); |
|
|
} |
|
|
} |
|
|
|
|
|
requestBody.put("DetailList", detailList); |
|
|
|
|
|
|
|
|
|
|
|
return requestBody; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 默认请求参数格式 |
|
|
|
|
|
*/ |
|
|
|
|
|
private Map<String, Object> buildDefaultRequestBody(List<StockTransactionLogEntity> transactionLogs, String interfaceName) { |
|
|
|
|
|
StockTransactionLogEntity firstLog = transactionLogs.get(0); |
|
|
|
|
|
Map<String, Object> requestBody = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 主表字段 |
|
|
|
|
|
requestBody.put("MESCCode", nullToEmpty(firstLog.getDocumentNo())); |
|
|
|
|
|
requestBody.put("KdType", getKdType(interfaceName)); |
|
|
|
|
|
requestBody.put("DDate", formatDate(firstLog.getTransactionDate())); |
|
|
|
|
|
requestBody.put("CRdCode", nullToEmpty(firstLog.getDocumentNoType())); |
|
|
|
|
|
requestBody.put("CMemo", ""); |
|
|
|
|
|
requestBody.put("CWhCode", nullToEmpty(firstLog.getWarehouseId())); |
|
|
|
|
|
requestBody.put("CCusOAddress", ""); |
|
|
|
|
|
requestBody.put("CDepCode", nullToEmpty(firstLog.getDepartmentId())); |
|
|
|
|
|
|
|
|
|
|
|
// 明细列表 |
|
|
|
|
|
List<Map<String, Object>> detailList = new ArrayList<>(); |
|
|
|
|
|
int rowNo = 1; |
|
|
|
|
|
for (StockTransactionLogEntity log : transactionLogs) { |
|
|
|
|
|
Map<String, Object> detail = new LinkedHashMap<>(); |
|
|
|
|
|
detail.put("MESIrowNo", String.valueOf(rowNo)); |
|
|
|
|
|
detail.put("OutCode", nullToEmpty(log.getOrderNo())); |
|
|
|
|
|
detail.put("OutIrowNo", nullToEmpty(log.getOrderLineNo())); |
|
|
|
|
|
detail.put("CInvCode", nullToEmpty(log.getPartNo())); |
|
|
|
|
|
detail.put("IQuantity", log.getRollQty() != null ? log.getRollQty().toString() : "0"); |
|
|
|
|
|
detail.put("CBatch", nullToEmpty(log.getRollNo())); |
|
|
|
|
|
detail.put("CbMemo", ""); |
|
|
|
|
|
detail.put("CWhCode", nullToEmpty(log.getWarehouseId())); |
|
|
|
|
|
detail.put("OutMocode", nullToEmpty(log.getOrderNo())); |
|
|
|
|
|
detail.put("OutIrowNo_zj", nullToEmpty(log.getBomItemNo())); |
|
|
|
|
|
detail.put("NumberOfCases", ""); |
|
|
|
|
|
detailList.add(detail); |
|
|
|
|
|
} |
|
|
requestBody.put("DetailList", detailList); |
|
|
requestBody.put("DetailList", detailList); |
|
|
|
|
|
|
|
|
return requestBody; |
|
|
return requestBody; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 将null转换为空字符串 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String nullToEmpty(String value) { |
|
|
|
|
|
return value != null ? value : ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 保存失败日志到api_log表 |
|
|
* 保存失败日志到api_log表 |
|
|
*/ |
|
|
*/ |
|
|
@ -215,43 +483,14 @@ public class ErpInterfaceServiceImpl implements ErpInterfaceService { |
|
|
|
|
|
|
|
|
interfaceLogDao.insert(apiLog); |
|
|
interfaceLogDao.insert(apiLog); |
|
|
|
|
|
|
|
|
// 3. 插入api_log_values_head |
|
|
|
|
|
ApiLogValuesHeadEntity headEntity = new ApiLogValuesHeadEntity(); |
|
|
|
|
|
headEntity.setSite(site); |
|
|
|
|
|
headEntity.setBuNo(buNo); |
|
|
|
|
|
headEntity.setRequestId(requestId); |
|
|
|
|
|
headEntity.setRequestGroupId(requestGroupId); |
|
|
|
|
|
headEntity.setOrderref1(firstLog.getDocumentNo()); |
|
|
|
|
|
headEntity.setOrderref2(firstLog.getTransactionType()); |
|
|
|
|
|
headEntity.setOrderref3(formatDate(firstLog.getTransactionDate())); |
|
|
|
|
|
headEntity.setOrderref4(firstLog.getDocumentNoType()); |
|
|
|
|
|
headEntity.setOrderref5(""); |
|
|
|
|
|
headEntity.setOrderref6(firstLog.getWarehouseId()); |
|
|
|
|
|
headEntity.setOrderref7(""); |
|
|
|
|
|
headEntity.setOrderref8(firstLog.getDepartmentId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 插入api_log_values_head(根据接口类型设置不同字段) |
|
|
|
|
|
ApiLogValuesHeadEntity headEntity = buildLogValuesHead(site, buNo, requestId, requestGroupId, interfaceName, firstLog); |
|
|
interfaceLogDao.insertApiLogValuesHead(headEntity); |
|
|
interfaceLogDao.insertApiLogValuesHead(headEntity); |
|
|
|
|
|
|
|
|
// 4. 插入api_log_values_detail |
|
|
|
|
|
|
|
|
// 4. 插入api_log_values_detail(根据接口类型设置不同字段) |
|
|
int rowNo = 1; |
|
|
int rowNo = 1; |
|
|
for (StockTransactionLogEntity log : transactionLogs) { |
|
|
for (StockTransactionLogEntity log : transactionLogs) { |
|
|
ApiLogValuesDetailEntity detailEntity = new ApiLogValuesDetailEntity(); |
|
|
|
|
|
detailEntity.setSite(site); |
|
|
|
|
|
detailEntity.setBuNo(buNo); |
|
|
|
|
|
detailEntity.setRequestId(requestId); |
|
|
|
|
|
detailEntity.setRequestGroupId(requestGroupId); |
|
|
|
|
|
detailEntity.setOrderref1(String.valueOf(rowNo++)); |
|
|
|
|
|
detailEntity.setOrderref2(log.getOrderNo()); |
|
|
|
|
|
detailEntity.setOrderref3(log.getOrderLineNo()); |
|
|
|
|
|
detailEntity.setOrderref4(log.getPartNo()); |
|
|
|
|
|
detailEntity.setOrderref5(log.getRollQty() != null ? log.getRollQty().toString() : "0"); |
|
|
|
|
|
detailEntity.setOrderref6(""); |
|
|
|
|
|
detailEntity.setOrderref7(""); |
|
|
|
|
|
detailEntity.setOrderref8(log.getWarehouseId()); |
|
|
|
|
|
detailEntity.setOrderref9(log.getOrderNo()); |
|
|
|
|
|
detailEntity.setOrderref10(log.getBomItemNo()); |
|
|
|
|
|
detailEntity.setOrderref11(""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ApiLogValuesDetailEntity detailEntity = buildLogValuesDetail(site, buNo, requestId, requestGroupId, interfaceName, log, rowNo); |
|
|
interfaceLogDao.insertApiLogValuesDetail(detailEntity); |
|
|
interfaceLogDao.insertApiLogValuesDetail(detailEntity); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -265,6 +504,189 @@ public class ErpInterfaceServiceImpl implements ErpInterfaceService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据接口类型构建api_log_values_head |
|
|
|
|
|
*/ |
|
|
|
|
|
private ApiLogValuesHeadEntity buildLogValuesHead(String site, String buNo, String requestId, |
|
|
|
|
|
Integer requestGroupId, String interfaceName, StockTransactionLogEntity firstLog) { |
|
|
|
|
|
ApiLogValuesHeadEntity headEntity = new ApiLogValuesHeadEntity(); |
|
|
|
|
|
headEntity.setSite(site); |
|
|
|
|
|
headEntity.setBuNo(buNo); |
|
|
|
|
|
headEntity.setRequestId(requestId); |
|
|
|
|
|
headEntity.setRequestGroupId(requestGroupId); |
|
|
|
|
|
|
|
|
|
|
|
// orderref2 根据接口名称设置不同的值 |
|
|
|
|
|
String kdType = getKdType(interfaceName); |
|
|
|
|
|
|
|
|
|
|
|
if ("GetSaveurchaseReturn".equals(interfaceName) || "GetSaveurchaseIn".equals(interfaceName)) { |
|
|
|
|
|
// 采购退货/采购入库 |
|
|
|
|
|
headEntity.setOrderref1(nullToEmpty(firstLog.getDocumentNo())); // MESCCode |
|
|
|
|
|
headEntity.setOrderref2(kdType); // KdType |
|
|
|
|
|
headEntity.setOrderref3(formatDate(firstLog.getTransactionDate())); // DDate |
|
|
|
|
|
headEntity.setOrderref4(nullToEmpty(firstLog.getDocumentNoType())); // CRdCode |
|
|
|
|
|
headEntity.setOrderref5(""); |
|
|
|
|
|
headEntity.setOrderref6(nullToEmpty(firstLog.getWarehouseId())); // CWhCode |
|
|
|
|
|
headEntity.setOrderref7(""); // CMemo |
|
|
|
|
|
headEntity.setOrderref8(""); // CDepCode |
|
|
|
|
|
} else if ("GetSaveSalesOut".equals(interfaceName) || "GetSaveSalesReturn".equals(interfaceName)) { |
|
|
|
|
|
// 销售出库/销售退货 |
|
|
|
|
|
headEntity.setOrderref1(nullToEmpty(firstLog.getDocumentNo())); // MESCCode |
|
|
|
|
|
headEntity.setOrderref2(kdType); // KdType |
|
|
|
|
|
headEntity.setOrderref3(formatDate(firstLog.getTransactionDate())); // DDate |
|
|
|
|
|
headEntity.setOrderref4(""); // CBusType |
|
|
|
|
|
headEntity.setOrderref5(""); // CMemo |
|
|
|
|
|
headEntity.setOrderref6(""); // CWhCode (主表没有) |
|
|
|
|
|
headEntity.setOrderref7(""); // CCusOAddress |
|
|
|
|
|
headEntity.setOrderref8(""); // CDepCode |
|
|
|
|
|
} else if ("GetSaveOthersStorageOut".equals(interfaceName) || "GetSaveOthersStorage".equals(interfaceName)) { |
|
|
|
|
|
// 其他出库/其他入库 |
|
|
|
|
|
headEntity.setOrderref1(nullToEmpty(firstLog.getDocumentNo())); // MESCCode |
|
|
|
|
|
headEntity.setOrderref2(kdType); // KdType |
|
|
|
|
|
headEntity.setOrderref3(formatDate(firstLog.getTransactionDate())); // DDate |
|
|
|
|
|
headEntity.setOrderref4(firstLog.getDocumentNoType()); // CRdCode |
|
|
|
|
|
headEntity.setOrderref5(""); |
|
|
|
|
|
headEntity.setOrderref6(firstLog.getWarehouseId()); |
|
|
|
|
|
headEntity.setOrderref7(""); |
|
|
|
|
|
headEntity.setOrderref8(firstLog.getDepartmentId()); |
|
|
|
|
|
} else if ("GetSaveroductionIssue".equals(interfaceName) || "GetSaveroductionReturn".equals(interfaceName)) { |
|
|
|
|
|
// 生产领料/生产退料 |
|
|
|
|
|
headEntity.setOrderref1(nullToEmpty(firstLog.getDocumentNo())); // MESCCode |
|
|
|
|
|
headEntity.setOrderref2(kdType); // KdType |
|
|
|
|
|
headEntity.setOrderref3(formatDate(firstLog.getTransactionDate())); // DDate |
|
|
|
|
|
headEntity.setOrderref4(nullToEmpty(firstLog.getDocumentNoType())); // CRdCode |
|
|
|
|
|
headEntity.setOrderref5(""); // CMemo |
|
|
|
|
|
headEntity.setOrderref6(nullToEmpty(firstLog.getWarehouseId())); // CWhCode |
|
|
|
|
|
headEntity.setOrderref7(""); |
|
|
|
|
|
headEntity.setOrderref8(""); // CDepCode |
|
|
|
|
|
} else if ("GetSaveroductionIn".equals(interfaceName)) { |
|
|
|
|
|
// 生产入库 |
|
|
|
|
|
headEntity.setOrderref1(nullToEmpty(firstLog.getDocumentNo())); // MESCCode |
|
|
|
|
|
headEntity.setOrderref2(""); // 生产入库没有KdType |
|
|
|
|
|
headEntity.setOrderref3(formatDate(firstLog.getTransactionDate())); // DDate |
|
|
|
|
|
headEntity.setOrderref4(nullToEmpty(firstLog.getDocumentNoType())); // CRdCode |
|
|
|
|
|
headEntity.setOrderref5(""); // CMemo |
|
|
|
|
|
headEntity.setOrderref6(nullToEmpty(firstLog.getWarehouseId())); // CWhCode |
|
|
|
|
|
headEntity.setOrderref7(""); |
|
|
|
|
|
headEntity.setOrderref8(nullToEmpty(firstLog.getDepartmentId())); // CDepCode |
|
|
|
|
|
} else { |
|
|
|
|
|
// 默认格式 |
|
|
|
|
|
headEntity.setOrderref1(nullToEmpty(firstLog.getDocumentNo())); |
|
|
|
|
|
headEntity.setOrderref2(kdType); |
|
|
|
|
|
headEntity.setOrderref3(formatDate(firstLog.getTransactionDate())); |
|
|
|
|
|
headEntity.setOrderref4(nullToEmpty(firstLog.getDocumentNoType())); |
|
|
|
|
|
headEntity.setOrderref5(""); |
|
|
|
|
|
headEntity.setOrderref6(nullToEmpty(firstLog.getWarehouseId())); |
|
|
|
|
|
headEntity.setOrderref7(""); |
|
|
|
|
|
headEntity.setOrderref8(nullToEmpty(firstLog.getDepartmentId())); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return headEntity; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据接口类型构建api_log_values_detail |
|
|
|
|
|
*/ |
|
|
|
|
|
private ApiLogValuesDetailEntity buildLogValuesDetail(String site, String buNo, String requestId, |
|
|
|
|
|
Integer requestGroupId, String interfaceName, StockTransactionLogEntity log, int rowNo) { |
|
|
|
|
|
ApiLogValuesDetailEntity detailEntity = new ApiLogValuesDetailEntity(); |
|
|
|
|
|
detailEntity.setSite(site); |
|
|
|
|
|
detailEntity.setBuNo(buNo); |
|
|
|
|
|
detailEntity.setRequestId(requestId); |
|
|
|
|
|
detailEntity.setRequestGroupId(requestGroupId); |
|
|
|
|
|
|
|
|
|
|
|
if ("GetSaveurchaseReturn".equals(interfaceName) || "GetSaveurchaseIn".equals(interfaceName)) { |
|
|
|
|
|
// 采购退货/采购入库 |
|
|
|
|
|
detailEntity.setOrderref1(String.valueOf(rowNo)); // MESIrowNo |
|
|
|
|
|
detailEntity.setOrderref2(nullToEmpty(log.getOrderNo())); // OutCode |
|
|
|
|
|
detailEntity.setOrderref3(nullToEmpty(log.getOrderLineNo())); // OutIrowNo |
|
|
|
|
|
detailEntity.setOrderref4(nullToEmpty(log.getPartNo())); // CInvCode |
|
|
|
|
|
detailEntity.setOrderref5(log.getRollQty() != null ? log.getRollQty().toString() : "0"); // IQuantity |
|
|
|
|
|
detailEntity.setOrderref6(nullToEmpty(log.getBatchFlag())); // CBatch |
|
|
|
|
|
detailEntity.setOrderref7(""); // CbMemo |
|
|
|
|
|
detailEntity.setOrderref8(""); // INum |
|
|
|
|
|
detailEntity.setOrderref9(""); // CUnitID |
|
|
|
|
|
detailEntity.setOrderref10(""); // ITaxRate |
|
|
|
|
|
detailEntity.setOrderref11(""); // ITaxUnitPrice |
|
|
|
|
|
detailEntity.setOrderref12(""); |
|
|
|
|
|
detailEntity.setOrderref13(""); |
|
|
|
|
|
} else if ("GetSaveSalesOut".equals(interfaceName) || "GetSaveSalesReturn".equals(interfaceName)) { |
|
|
|
|
|
// 销售出库/销售退货 |
|
|
|
|
|
detailEntity.setOrderref1(String.valueOf(rowNo)); // MESIrowNo |
|
|
|
|
|
detailEntity.setOrderref2(nullToEmpty(log.getOrderNo())); // OutCode |
|
|
|
|
|
detailEntity.setOrderref3(nullToEmpty(log.getOrderLineNo())); // OutIrowNo |
|
|
|
|
|
detailEntity.setOrderref4(nullToEmpty(log.getPartNo())); // CInvCode |
|
|
|
|
|
detailEntity.setOrderref5(log.getRollQty() != null ? log.getRollQty().toString() : "0"); // IQuantity |
|
|
|
|
|
detailEntity.setOrderref6(nullToEmpty(log.getBatchFlag())); // CBatch |
|
|
|
|
|
detailEntity.setOrderref7(""); // INum |
|
|
|
|
|
detailEntity.setOrderref8(nullToEmpty(log.getWarehouseId())); // CWhCode |
|
|
|
|
|
detailEntity.setOrderref9(""); // CUnitID |
|
|
|
|
|
detailEntity.setOrderref10(""); // ITaxRate |
|
|
|
|
|
detailEntity.setOrderref11(""); // ITaxUnitPrice |
|
|
|
|
|
detailEntity.setOrderref12(""); |
|
|
|
|
|
detailEntity.setOrderref13(""); |
|
|
|
|
|
} else if ("GetSaveOthersStorageOut".equals(interfaceName) || "GetSaveOthersStorage".equals(interfaceName)) { |
|
|
|
|
|
// 其他出库/其他入库 |
|
|
|
|
|
detailEntity.setOrderref1(String.valueOf(rowNo)); // MESIrowNo |
|
|
|
|
|
detailEntity.setOrderref2(""); // CInvCode |
|
|
|
|
|
detailEntity.setOrderref3(""); // IQuantity |
|
|
|
|
|
detailEntity.setOrderref4(nullToEmpty(log.getPartNo())); // INum |
|
|
|
|
|
detailEntity.setOrderref5(log.getRollQty() != null ? log.getRollQty().toString() : "0"); // CUnitID |
|
|
|
|
|
detailEntity.setOrderref6(nullToEmpty(log.getBatchFlag())); // CbMemo |
|
|
|
|
|
detailEntity.setOrderref7(""); // CBatch |
|
|
|
|
|
detailEntity.setOrderref8(""); |
|
|
|
|
|
detailEntity.setOrderref9(""); |
|
|
|
|
|
detailEntity.setOrderref10(""); |
|
|
|
|
|
detailEntity.setOrderref11(""); |
|
|
|
|
|
detailEntity.setOrderref12(""); |
|
|
|
|
|
detailEntity.setOrderref13(""); |
|
|
|
|
|
} else if ("GetSaveroductionIssue".equals(interfaceName) || "GetSaveroductionReturn".equals(interfaceName)) { |
|
|
|
|
|
// 生产领料/生产退料 |
|
|
|
|
|
detailEntity.setOrderref1(String.valueOf(rowNo)); // MESIrowNo |
|
|
|
|
|
detailEntity.setOrderref2(""); // CInvCode |
|
|
|
|
|
detailEntity.setOrderref3(nullToEmpty(log.getOrderLineNo())); // IQuantity |
|
|
|
|
|
detailEntity.setOrderref4(nullToEmpty(log.getPartNo())); // CUnitID |
|
|
|
|
|
detailEntity.setOrderref5(log.getRollQty() != null ? log.getRollQty().toString() : "0"); // INum |
|
|
|
|
|
detailEntity.setOrderref6(nullToEmpty(log.getBatchFlag())); // CBatch |
|
|
|
|
|
detailEntity.setOrderref7(""); // OutMocode (erp_order_no) |
|
|
|
|
|
detailEntity.setOrderref8(nullToEmpty(log.getErpOrderNo())); // OutIrowNo |
|
|
|
|
|
detailEntity.setOrderref9(""); // OutIrowNo_zj |
|
|
|
|
|
detailEntity.setOrderref10(nullToEmpty(log.getBomItemNo())); |
|
|
|
|
|
detailEntity.setOrderref11(""); |
|
|
|
|
|
detailEntity.setOrderref12(""); |
|
|
|
|
|
detailEntity.setOrderref13(""); |
|
|
|
|
|
} else if ("GetSaveroductionIn".equals(interfaceName)) { |
|
|
|
|
|
// 生产入库 |
|
|
|
|
|
detailEntity.setOrderref1(String.valueOf(rowNo)); // MESIrowNo |
|
|
|
|
|
detailEntity.setOrderref2(""); // CInvCode |
|
|
|
|
|
detailEntity.setOrderref3(nullToEmpty(log.getOrderLineNo())); // IQuantity |
|
|
|
|
|
detailEntity.setOrderref4(nullToEmpty(log.getPartNo())); // CUnitID |
|
|
|
|
|
detailEntity.setOrderref5(log.getRollQty() != null ? log.getRollQty().toString() : "0"); // INum (piece_qty) |
|
|
|
|
|
detailEntity.setOrderref6(nullToEmpty(log.getBatchFlag())); // CBatch |
|
|
|
|
|
detailEntity.setOrderref7(""); // CbMemo |
|
|
|
|
|
detailEntity.setOrderref8(nullToEmpty(log.getErpOrderNo())); // OutIrowNo |
|
|
|
|
|
detailEntity.setOrderref9(""); // OutMocode (erp_order_no) |
|
|
|
|
|
detailEntity.setOrderref10(""); // OutIrowNo |
|
|
|
|
|
detailEntity.setOrderref11(""); // OutIrowNo_zj |
|
|
|
|
|
detailEntity.setOrderref12(log.getPieceQty() != null ? log.getPieceQty().toString() : "0"); |
|
|
|
|
|
detailEntity.setOrderref13(nullToEmpty(log.getUmid())); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 默认格式 |
|
|
|
|
|
detailEntity.setOrderref1(String.valueOf(rowNo)); |
|
|
|
|
|
detailEntity.setOrderref2(nullToEmpty(log.getOrderNo())); |
|
|
|
|
|
detailEntity.setOrderref3(nullToEmpty(log.getOrderLineNo())); |
|
|
|
|
|
detailEntity.setOrderref4(nullToEmpty(log.getPartNo())); |
|
|
|
|
|
detailEntity.setOrderref5(log.getRollQty() != null ? log.getRollQty().toString() : "0"); |
|
|
|
|
|
detailEntity.setOrderref6(nullToEmpty(log.getRollNo())); |
|
|
|
|
|
detailEntity.setOrderref7(""); |
|
|
|
|
|
detailEntity.setOrderref8(nullToEmpty(log.getWarehouseId())); |
|
|
|
|
|
detailEntity.setOrderref9(nullToEmpty(log.getOrderNo())); |
|
|
|
|
|
detailEntity.setOrderref10(nullToEmpty(log.getBomItemNo())); |
|
|
|
|
|
detailEntity.setOrderref11(""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return detailEntity; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 格式化日期 |
|
|
* 格式化日期 |
|
|
*/ |
|
|
*/ |
|
|
|