Commit a6ffbb8d by zhouhaibao

refactor(StoreExcelImportService): 优化分账规则数据导出逻辑

- 修改fillRuleDataRow方法签名,增加productCategoryName参数
- 重构分账规则循环逻辑,支持按产品分类逐行填充数据
- 当产品分类列表为空时,仍然填充默认空值的一行数据
- 简化产品分类名称拼接逻辑,直接使用传入的分类名称
- 移除原有的StringBuilder构建分类名称的代码块
1 parent d8aa58f1
......@@ -1885,13 +1885,27 @@ public class StoreExcelImportService {
}
for (ProductCategoryRuleDTO ruleDTO : productCategoryRules) {
Row row = getRowForData(sheet, ruleRowIndex, referenceRowHeight);
log.debug("[步骤3/5] 第{}行:分账规则,行高:{}", ruleRowIndex, row.getHeightInPoints());
fillRuleDataRow(row, ruleDTO, maxColumnNum, isBatchMode,
referenceCellStyle, divisionSceneConfig, reconciliationSceneConfig);
totalRows++;
ruleRowIndex++;
List<ProductDTO> productCategoryList = ruleDTO.getProductCategoryList();
if (productCategoryList != null && !productCategoryList.isEmpty()) {
for (ProductDTO productCategory : productCategoryList) {
Row row = getRowForData(sheet, ruleRowIndex, referenceRowHeight);
log.debug("[步骤3/5] 第{}行:分账规则,行高:{}", ruleRowIndex, row.getHeightInPoints());
fillRuleDataRow(row, ruleDTO, maxColumnNum, isBatchMode,
referenceCellStyle, divisionSceneConfig, reconciliationSceneConfig,
productCategory.getProductCategory());
totalRows++;
ruleRowIndex++;
}
} else {
// 如果没有产品分类,仍然填充一行
Row row = getRowForData(sheet, ruleRowIndex, referenceRowHeight);
log.debug("[步骤3/5] 第{}行:分账规则,行高:{}", ruleRowIndex, row.getHeightInPoints());
fillRuleDataRow(row, ruleDTO, maxColumnNum, isBatchMode,
referenceCellStyle, divisionSceneConfig, reconciliationSceneConfig,
"");
totalRows++;
ruleRowIndex++;
}
}
if (ruleRowIndex>rowIndex){
......@@ -2549,7 +2563,8 @@ public class StoreExcelImportService {
StoreWithProductsDTO.ProductCategoryRuleDTO productCategoryRule,
int maxColumnNum, boolean isBatchMode,
CellStyle referenceCellStyle,
DivisionSceneConfig divisionSceneConfig, ReconciliationSceneConfig reconciliationSceneConfig) {
DivisionSceneConfig divisionSceneConfig, ReconciliationSceneConfig reconciliationSceneConfig,
String productCategoryName) {
int rowNum = row.getRowNum();
log.debug("[行{}] 开始填充数据", rowNum);
......@@ -2564,15 +2579,9 @@ public class StoreExcelImportService {
colIndex=colIndex+9;
// === 产品分类 ===
StringBuilder productCategoryName = new StringBuilder();
List<ProductDTO> productCategoryList = productCategoryRule.getProductCategoryList();
setValueToCell(row, colIndex++, productCategoryName);
List<StoreDistributionRuleDTO> expenseOwnershipRules = productCategoryRule.getExpenseOwnershipRules();
for (ProductDTO productCategory : productCategoryList) {
productCategoryName.append(productCategory.getProductCategory()).append("、");
}
productCategoryName.deleteCharAt(productCategoryName.length() - 1);
String productCategory = productCategoryName.toString();
setValueToCell(row, colIndex++, productCategory);
// === 流量结算模式 ===
String trafficSettlementMode = productCategoryRule != null ?
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!