|
@@ -630,7 +630,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
goodsCategoryQueryInfo.setRows(9999);
|
|
goodsCategoryQueryInfo.setRows(9999);
|
|
|
|
|
|
List<ProductCategoryDto> categoryList = mallFeignService.listWithChildren();
|
|
List<ProductCategoryDto> categoryList = mallFeignService.listWithChildren();
|
|
- List<ProductCategoryDto> allCategoryList = treeToList(categoryList);
|
|
|
|
|
|
+ List<ProductCategoryDto> allCategoryList = categoryList.stream().map(ProductCategoryDto::getChildren).filter(next->!next.isEmpty()).flatMap(Collection::stream).collect(Collectors.toList());
|
|
Map<String, Long> categoryIdNameMap = allCategoryList
|
|
Map<String, Long> categoryIdNameMap = allCategoryList
|
|
.stream().collect(Collectors.toMap(ProductCategoryDto::getName, ProductCategoryDto::getId));
|
|
.stream().collect(Collectors.toMap(ProductCategoryDto::getName, ProductCategoryDto::getId));
|
|
Set<String> categoryNames = categoryIdNameMap.keySet();
|
|
Set<String> categoryNames = categoryIdNameMap.keySet();
|
|
@@ -668,6 +668,11 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ List<String> snSet = firstSheet.stream().map(next -> next.get("组合商品货号").toString()).filter(StringUtils::isNotEmpty).distinct().collect(Collectors.toList());
|
|
|
|
+ List<String> existSnList = goodsDao.findBySns(snSet).stream().map(Goods::getSn).distinct().collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ Map<String, Long> brandNameIdMap = mallFeignService.getList().stream().collect(Collectors.toMap(BrandDto::getName, BrandDto::getId));
|
|
|
|
+
|
|
List<JSONObject> jsonObjectList = new ArrayList<>();
|
|
List<JSONObject> jsonObjectList = new ArrayList<>();
|
|
for (Map.Entry<String, List<Map<String, Object>>> sheetData : sheetsListMap.entrySet()) {
|
|
for (Map.Entry<String, List<Map<String, Object>>> sheetData : sheetsListMap.entrySet()) {
|
|
List<Map<String, Object>> rows = sheetData.getValue();
|
|
List<Map<String, Object>> rows = sheetData.getValue();
|
|
@@ -686,6 +691,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
String lineErrMsg = "错误行号:第%s行,%s";
|
|
String lineErrMsg = "错误行号:第%s行,%s";
|
|
Map<String, String> beforeGoods = new HashMap<>();
|
|
Map<String, String> beforeGoods = new HashMap<>();
|
|
|
|
|
|
|
|
+ Map<String, String> snNameMap = new HashMap<>();
|
|
for (int i = 0; i < rows.size(); i++) {
|
|
for (int i = 0; i < rows.size(); i++) {
|
|
JSONObject objectMap = new JSONObject();
|
|
JSONObject objectMap = new JSONObject();
|
|
int rowNum = i + 2;
|
|
int rowNum = i + 2;
|
|
@@ -709,24 +715,36 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
if ("subGoodsName".equals(fieldCode) || "sku".equals(fieldCode) || "subGoodsPrice".equals(fieldCode)) {
|
|
if ("subGoodsName".equals(fieldCode) || "sku".equals(fieldCode) || "subGoodsPrice".equals(fieldCode)) {
|
|
lineErrList.add("字段‘" + fieldName + "’为空");
|
|
lineErrList.add("字段‘" + fieldName + "’为空");
|
|
} else {
|
|
} else {
|
|
- if (!beforeGoods.containsKey(fieldCode)) {
|
|
|
|
- lineErrList.add("字段‘" + fieldName + "’为空");
|
|
|
|
- continue;
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (beforeGoods.containsKey(fieldCode)) {
|
|
value = beforeGoods.get(fieldCode);
|
|
value = beforeGoods.get(fieldCode);
|
|
|
|
+ } else {
|
|
|
|
+ if (!("educationShowOrganName".equals(fieldCode)
|
|
|
|
+ || "courseFeeShowOrganName".equals(fieldCode)
|
|
|
|
+ || "memberFeeShowOrganName".equals(fieldCode)
|
|
|
|
+ || "freeFeeShowOrganName".equals(fieldCode)
|
|
|
|
+ || "replacementShowOrganName".equals(fieldCode))) {
|
|
|
|
+ lineErrList.add("字段‘" + fieldName + "’为空");
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
beforeGoods.put(fieldCode, value);
|
|
beforeGoods.put(fieldCode, value);
|
|
}
|
|
}
|
|
-// if("sn".equals(fieldCode)){
|
|
|
|
-// if (snSet.contains(value)) {
|
|
|
|
-// lineErrList.add("货号[" + value + "]重复");
|
|
|
|
-// } else {
|
|
|
|
-// snSet.add(value);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// else
|
|
|
|
|
|
+ if("sn".equals(fieldCode)){
|
|
|
|
+ if (existSnList.contains(value)) {
|
|
|
|
+ lineErrList.add("货号[" + value + "]已存在");
|
|
|
|
+ } else {
|
|
|
|
+ String goodsName = row.get("组合商品名称").toString();
|
|
|
|
+ if (snNameMap.containsKey(value) && !snNameMap.get(value).equals(goodsName)) {
|
|
|
|
+ lineErrList.add("货号[" + value + "]重复");
|
|
|
|
+ } else {
|
|
|
|
+ snNameMap.put(value, goodsName);
|
|
|
|
+ }
|
|
|
|
+ objectMap.put(fieldCode, value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
if ("marketPrice".equals(fieldCode)
|
|
if ("marketPrice".equals(fieldCode)
|
|
|| "discountPrice".equals(fieldCode)
|
|
|| "discountPrice".equals(fieldCode)
|
|
|| "groupPurchasePrice".equals(fieldCode)) {
|
|
|| "groupPurchasePrice".equals(fieldCode)) {
|
|
@@ -761,17 +779,19 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|| "freeFeeShowOrganName".equals(fieldCode)
|
|
|| "freeFeeShowOrganName".equals(fieldCode)
|
|
|| "replacementShowOrganName".equals(fieldCode)
|
|
|| "replacementShowOrganName".equals(fieldCode)
|
|
) {
|
|
) {
|
|
- List<String> orgIds = new ArrayList<>();
|
|
|
|
- for (String orgName : value.split(",")) {
|
|
|
|
- if (!orgNameIdMap.containsKey(orgName)) {
|
|
|
|
- lineErrList.add("字段‘" + fieldName + "’:‘" + value + "’分部不支持");
|
|
|
|
- } else {
|
|
|
|
- orgIds.add(orgNameIdMap.get(orgName).toString());
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(value)) {
|
|
|
|
+ List<String> orgIds = new ArrayList<>();
|
|
|
|
+ for (String orgName : value.split("[,,]")) {
|
|
|
|
+ if (!orgNameIdMap.containsKey(orgName)) {
|
|
|
|
+ lineErrList.add("字段‘" + fieldName + "’:‘" + value + "’分部不支持");
|
|
|
|
+ } else {
|
|
|
|
+ orgIds.add(orgNameIdMap.get(orgName).toString());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ String join = String.join(",", orgIds);
|
|
|
|
+ String fieldKey = fieldCode.replaceAll("Name", "Id");
|
|
|
|
+ objectMap.put(fieldKey, join);
|
|
}
|
|
}
|
|
- String join = String.join(",", orgIds);
|
|
|
|
- String fieldKey = fieldCode.replaceAll("Name", "Id");
|
|
|
|
- objectMap.put(fieldKey, join);
|
|
|
|
} else if ("subGoodsName".equals(fieldCode)) {
|
|
} else if ("subGoodsName".equals(fieldCode)) {
|
|
subGoodsName = value;
|
|
subGoodsName = value;
|
|
if (StringUtils.isNotEmpty(subGoodsSku)) {
|
|
if (StringUtils.isNotEmpty(subGoodsSku)) {
|
|
@@ -805,10 +825,25 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
if (BigDecimal.ZERO.compareTo(subGoodsPrice) > 0) {
|
|
if (BigDecimal.ZERO.compareTo(subGoodsPrice) > 0) {
|
|
lineErrList.add("字段‘" + fieldName + "’不能为负数");
|
|
lineErrList.add("字段‘" + fieldName + "’不能为负数");
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
|
|
+ } else if ("brand".equals(fieldCode)) {
|
|
|
|
+ if (brandNameIdMap.containsKey(value)) {
|
|
|
|
+ objectMap.put("brand", brandNameIdMap.get(value));
|
|
|
|
+ } else {
|
|
|
|
+ lineErrList.add("组合商品品牌‘" + value + "’不支持");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
objectMap.put(fieldCode, value);
|
|
objectMap.put(fieldCode, value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // 校验分部可售是否都为空
|
|
|
|
+ if (!objectMap.containsKey("educationShowOrganId") &&
|
|
|
|
+ !objectMap.containsKey("courseFeeShowOrganId") &&
|
|
|
|
+ !objectMap.containsKey("memberFeeShowOrganId") &&
|
|
|
|
+ !objectMap.containsKey("freeFeeShowOrganId") &&
|
|
|
|
+ !objectMap.containsKey("replacementShowOrganId")) {
|
|
|
|
+ lineErrList.add("可售分部至少需要选择一个");
|
|
|
|
+ }
|
|
if (!lineErrList.isEmpty()) {
|
|
if (!lineErrList.isEmpty()) {
|
|
errList.add(String.format(lineErrMsg, rowNum, String.join(",", lineErrList)));
|
|
errList.add(String.format(lineErrMsg, rowNum, String.join(",", lineErrList)));
|
|
}
|
|
}
|
|
@@ -1341,7 +1376,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
|
|
|
String basePath = new ApplicationHome(this.getClass()).getSource().getParentFile().getPath();
|
|
String basePath = new ApplicationHome(this.getClass()).getSource().getParentFile().getPath();
|
|
String format = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
|
String format = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
|
- File file = new File(basePath + File.separator + "goods_group_import_err" + format + ".csv");
|
|
|
|
|
|
+ File file = new File(basePath + File.separator + format + ".csv");
|
|
try {
|
|
try {
|
|
if (!file.getParentFile().exists()) {
|
|
if (!file.getParentFile().exists()) {
|
|
file.getParentFile().mkdirs();
|
|
file.getParentFile().mkdirs();
|