Commit a6ffbb8d by zhouhaibao

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

- 修改fillRuleDataRow方法签名,增加productCategoryName参数
- 重构分账规则循环逻辑,支持按产品分类逐行填充数据
- 当产品分类列表为空时,仍然填充默认空值的一行数据
- 简化产品分类名称拼接逻辑,直接使用传入的分类名称
- 移除原有的StringBuilder构建分类名称的代码块
1 parent d8aa58f1
...@@ -1885,13 +1885,27 @@ public class StoreExcelImportService { ...@@ -1885,13 +1885,27 @@ public class StoreExcelImportService {
} }
for (ProductCategoryRuleDTO ruleDTO : productCategoryRules) { for (ProductCategoryRuleDTO ruleDTO : productCategoryRules) {
List<ProductDTO> productCategoryList = ruleDTO.getProductCategoryList();
Row row = getRowForData(sheet, ruleRowIndex, referenceRowHeight); if (productCategoryList != null && !productCategoryList.isEmpty()) {
log.debug("[步骤3/5] 第{}行:分账规则,行高:{}", ruleRowIndex, row.getHeightInPoints()); for (ProductDTO productCategory : productCategoryList) {
fillRuleDataRow(row, ruleDTO, maxColumnNum, isBatchMode, Row row = getRowForData(sheet, ruleRowIndex, referenceRowHeight);
referenceCellStyle, divisionSceneConfig, reconciliationSceneConfig); log.debug("[步骤3/5] 第{}行:分账规则,行高:{}", ruleRowIndex, row.getHeightInPoints());
totalRows++; fillRuleDataRow(row, ruleDTO, maxColumnNum, isBatchMode,
ruleRowIndex++; 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){ if (ruleRowIndex>rowIndex){
...@@ -2549,7 +2563,8 @@ public class StoreExcelImportService { ...@@ -2549,7 +2563,8 @@ public class StoreExcelImportService {
StoreWithProductsDTO.ProductCategoryRuleDTO productCategoryRule, StoreWithProductsDTO.ProductCategoryRuleDTO productCategoryRule,
int maxColumnNum, boolean isBatchMode, int maxColumnNum, boolean isBatchMode,
CellStyle referenceCellStyle, CellStyle referenceCellStyle,
DivisionSceneConfig divisionSceneConfig, ReconciliationSceneConfig reconciliationSceneConfig) { DivisionSceneConfig divisionSceneConfig, ReconciliationSceneConfig reconciliationSceneConfig,
String productCategoryName) {
int rowNum = row.getRowNum(); int rowNum = row.getRowNum();
log.debug("[行{}] 开始填充数据", rowNum); log.debug("[行{}] 开始填充数据", rowNum);
...@@ -2564,15 +2579,9 @@ public class StoreExcelImportService { ...@@ -2564,15 +2579,9 @@ public class StoreExcelImportService {
colIndex=colIndex+9; colIndex=colIndex+9;
// === 产品分类 === // === 产品分类 ===
StringBuilder productCategoryName = new StringBuilder(); setValueToCell(row, colIndex++, productCategoryName);
List<ProductDTO> productCategoryList = productCategoryRule.getProductCategoryList();
List<StoreDistributionRuleDTO> expenseOwnershipRules = productCategoryRule.getExpenseOwnershipRules(); 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 ? 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!