Commit 53bdee9f by zhouhaibao

fix(excel): 修复Excel导入中产品分类为空时的处理逻辑

- 在processSingleStoreMode方法中提取产品分类并添加空值检查
- 当产品分类不为空时才创建和添加商品类别规则DTO
- 移除对门店名称和产品分类同时为空的重复检查
- 在批量处理模式中同样添加产品分类空值检查
- 确保只有当产品分类存在时才执行相关业务逻辑
1 parent 055ebd9f
...@@ -194,6 +194,7 @@ public class CreateBusinessApproveExcelListener extends AnalysisEventListener<Ob ...@@ -194,6 +194,7 @@ public class CreateBusinessApproveExcelListener extends AnalysisEventListener<Ob
private void processSingleStoreMode(SingleStoreExcelDTO data, Integer rowIndex) { private void processSingleStoreMode(SingleStoreExcelDTO data, Integer rowIndex) {
try { try {
String productCategory = data.getProductCategory();
mergedCellHandler.fillMergedCellValues(data); mergedCellHandler.fillMergedCellValues(data);
StoreWithProductsDTO storeDTO = storeMap.get(merchantName); StoreWithProductsDTO storeDTO = storeMap.get(merchantName);
...@@ -202,8 +203,11 @@ public class CreateBusinessApproveExcelListener extends AnalysisEventListener<Ob ...@@ -202,8 +203,11 @@ public class CreateBusinessApproveExcelListener extends AnalysisEventListener<Ob
storeMap.put(merchantName, storeDTO); storeMap.put(merchantName, storeDTO);
storeWithProducts.add(storeDTO); storeWithProducts.add(storeDTO);
} }
StoreWithProductsDTO.ProductCategoryRuleDTO ruleDTO = createProductCategoryRuleDTO(data); if (productCategory != null) {
StoreWithProductsDTO.ProductCategoryRuleDTO ruleDTO = createProductCategoryRuleDTO(
data);
ruleDTOS.add(ruleDTO); ruleDTOS.add(ruleDTO);
}
this.context.incrementSuccessRows(); this.context.incrementSuccessRows();
} catch (Exception e) { } catch (Exception e) {
...@@ -219,7 +223,7 @@ public class CreateBusinessApproveExcelListener extends AnalysisEventListener<Ob ...@@ -219,7 +223,7 @@ public class CreateBusinessApproveExcelListener extends AnalysisEventListener<Ob
try { try {
String storeName = data.getStoreName(); String storeName = data.getStoreName();
String productCategory = data.getProductCategory(); String productCategory = data.getProductCategory();
if (storeName == null && productCategory == null ){ if (storeName == null){
String message = String.format("第 %d 行门店商户号为空", rowIndex + 1); String message = String.format("第 %d 行门店商户号为空", rowIndex + 1);
log.warn(message); log.warn(message);
this.context.addErrorInfo(new ImportErrorInfo(rowIndex + 1, message, data)); this.context.addErrorInfo(new ImportErrorInfo(rowIndex + 1, message, data));
...@@ -234,8 +238,11 @@ public class CreateBusinessApproveExcelListener extends AnalysisEventListener<Ob ...@@ -234,8 +238,11 @@ public class CreateBusinessApproveExcelListener extends AnalysisEventListener<Ob
storeMap.put(storeName, storeDTO); storeMap.put(storeName, storeDTO);
storeWithProducts.add(storeDTO); storeWithProducts.add(storeDTO);
} }
StoreWithProductsDTO.ProductCategoryRuleDTO ruleDTO = createBatchProductCategoryRuleDTO(data); if (productCategory != null) {
StoreWithProductsDTO.ProductCategoryRuleDTO ruleDTO = createBatchProductCategoryRuleDTO(
data);
ruleDTOS.add(ruleDTO); ruleDTOS.add(ruleDTO);
}
this.context.incrementSuccessRows(); this.context.incrementSuccessRows();
} catch (Exception e) { } catch (Exception e) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!