|
|
@ -69,6 +69,20 @@ import java.util.stream.Stream; |
|
|
@Service |
|
|
@Service |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class CoDelExcelServiceImpl implements CoDelExcelService { |
|
|
public class CoDelExcelServiceImpl implements CoDelExcelService { |
|
|
|
|
|
/** |
|
|
|
|
|
* batchSaveEcssCoDelNotifyDetail 每行参数个数(与 CoDelMapper.xml 中 values 字段保持一致) |
|
|
|
|
|
*/ |
|
|
|
|
|
private static final int NOTIFY_DETAIL_PARAM_COUNT_PER_ROW = 39; |
|
|
|
|
|
/** |
|
|
|
|
|
* 明细分批插入条数,避免单次请求参数超限 |
|
|
|
|
|
*/ |
|
|
|
|
|
private static final int SQL_SERVER_PARAM_SAFE_LIMIT = 2000; |
|
|
|
|
|
/** |
|
|
|
|
|
* 使用安全阈值(2000)而不是理论上限(2100),给 SQL 预留余量 |
|
|
|
|
|
*/ |
|
|
|
|
|
private static final int NOTIFY_DETAIL_BATCH_SIZE = |
|
|
|
|
|
Math.max(1, SQL_SERVER_PARAM_SAFE_LIMIT / NOTIFY_DETAIL_PARAM_COUNT_PER_ROW); |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private QcMapper qcMapper; |
|
|
private QcMapper qcMapper; |
|
|
@Autowired |
|
|
@Autowired |
|
|
@ -305,7 +319,7 @@ public class CoDelExcelServiceImpl implements CoDelExcelService { |
|
|
list.get(i).setDelNo(transNo); |
|
|
list.get(i).setDelNo(transNo); |
|
|
list.get(i).setItemNo(i + 1); |
|
|
list.get(i).setItemNo(i + 1); |
|
|
} |
|
|
} |
|
|
coDelMapper.batchSaveEcssCoDelNotifyDetail(list); |
|
|
|
|
|
|
|
|
batchSaveNotifyDetailSafely(list); |
|
|
|
|
|
|
|
|
// 加入成功列表 |
|
|
// 加入成功列表 |
|
|
successList.add("发票号:" + cmcInvoice + " 导入成功"); |
|
|
successList.add("发票号:" + cmcInvoice + " 导入成功"); |
|
|
@ -321,6 +335,20 @@ public class CoDelExcelServiceImpl implements CoDelExcelService { |
|
|
return resultMap; |
|
|
return resultMap; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 分批保存明细,规避 SQL Server 单次请求 2100 参数上限 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void batchSaveNotifyDetailSafely(List<EcssCoDelNotifyData> detailList) { |
|
|
|
|
|
if (detailList == null || detailList.isEmpty()) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
for (int start = 0; start < detailList.size(); start += NOTIFY_DETAIL_BATCH_SIZE) { |
|
|
|
|
|
int end = Math.min(start + NOTIFY_DETAIL_BATCH_SIZE, detailList.size()); |
|
|
|
|
|
List<EcssCoDelNotifyData> subList = new ArrayList<>(detailList.subList(start, end)); |
|
|
|
|
|
coDelMapper.batchSaveEcssCoDelNotifyDetail(subList); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 安全获取字符串列值(支持可选列) |
|
|
* 安全获取字符串列值(支持可选列) |
|
|
@ -1212,7 +1240,7 @@ public class CoDelExcelServiceImpl implements CoDelExcelService { |
|
|
boolean hasPnOrQtyModified = excelList.stream() |
|
|
boolean hasPnOrQtyModified = excelList.stream() |
|
|
.anyMatch(item -> item.getModifyQtyFlag() != null && item.getModifyQtyFlag()); |
|
|
.anyMatch(item -> item.getModifyQtyFlag() != null && item.getModifyQtyFlag()); |
|
|
|
|
|
|
|
|
coDelMapper.batchSaveEcssCoDelNotifyDetail(excelList); |
|
|
|
|
|
|
|
|
batchSaveNotifyDetailSafely(excelList); |
|
|
headerData.setModifyFlag(true); |
|
|
headerData.setModifyFlag(true); |
|
|
// 更新头表字段,包括ReadyDate、ShippingMode、Destination |
|
|
// 更新头表字段,包括ReadyDate、ShippingMode、Destination |
|
|
coDelMapper.updateEcssDelHeader(headerData); |
|
|
coDelMapper.updateEcssDelHeader(headerData); |
|
|
|