Browse Source

feat(all): 修改价格体系品类的校验

dist.1.3.0
zhaoqiaobo 8 months ago
parent
commit
c69fa218dd
  1. 196
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java

196
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java

@ -112,6 +112,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@ -2210,7 +2211,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
if (ObjectUtil.equal(pickupIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode()) || ObjectUtil.equal(trunklineIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) {
// 路径不能为空
if (ObjectUtil.isEmpty(excel.getSendOrg())) {
rowMessage.append("模板配置为不按区域计费,路径不能为空,发货单位必填;");
rowMessage.append("模板配置为不按区域计费,路径不能为空,发货单位必填");
}
}
}
@ -2222,15 +2223,15 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
checkPrice(rowMessage, "【配送-单价】", excel.getDispatchPrice());
// 费用不能都为空
if (ObjectUtil.isAllEmpty(excel.getPickupPrice(), excel.getTrunkLinePrice(), excel.getDispatchPrice())) {
rowMessage.append("单价不能全部为空,请检查;");
rowMessage.append("单价不能全部为空,请检查");
}
// 校验车型
if (StrUtil.isNotEmpty(excel.getVehicleType())) {
if (!vehicleTypeMap.containsKey(excel.getVehicleType())) {
rowMessage.append("车型[").append(excel.getVehicleType()).append("]不存在;");
rowMessage.append("车型[").append(excel.getVehicleType()).append("]不存在");
}
} else {
rowMessage.append("车型不能为空;");
rowMessage.append("车型不能为空");
}
buildErrorMessageExcel(message, rowMessage, firstMessage);
}
@ -2278,7 +2279,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
// 发货单位
checkSendOrgExcel(clientEntityMap, rowMessage, excel.getSendOrg());
if (ObjectUtil.isAllEmpty(excel.getPickupMinCost(), excel.getTrunkLineMinCost(), excel.getDispatchMinCost())) {
rowMessage.append("最低计费不能都为空;");
rowMessage.append("最低计费不能都为空");
}
// 提货干线只要一个是不按区域计费的,就必须要填写路径
if (ObjectUtil.isAllNotEmpty(excel.getClient(), excel.getBrand())) {
@ -2290,7 +2291,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
if (ObjectUtil.equal(pickupIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode()) || ObjectUtil.equal(trunklineIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) {
// 路径不能为空
if (ObjectUtil.isEmpty(excel.getSendOrg())) {
rowMessage.append("模板配置为不按区域计费,路径不能为空,发货单位必填;");
rowMessage.append("模板配置为不按区域计费,路径不能为空,发货单位必填");
}
}
}
@ -2357,7 +2358,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
});
rowMessage.append(columnName).append("只能为:")
.append(CollUtil.join(textSrt, "/"))
.append(";");
.append("");
}
}
@ -2447,6 +2448,12 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
Map<String, String> provinceCityMap, Map<String, String> provinceCityAearMap,
Map<String, BasicdataStoreBrandEntity> clientBrandMap, Map<String, BasicdataPriceTemplateEntity> templateMap) {
if (CollUtil.isNotEmpty(basicExcels)) {
Map<String, BasicdataCategoryEntity> categoryIdMap = new HashMap<>();
if (CollUtil.isNotEmpty(categoryEntityMap)) {
categoryEntityMap.forEach((k, v) -> {
categoryIdMap.put(v.getId().toString(), v);
});
}
// 校验sheet2的数据
for (int i = 0; i < basicExcels.size(); i++) {
BasicdataPriceCategoryV2Excel basicExcel = basicExcels.get(i);
@ -2480,7 +2487,105 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
if (ObjectUtil.equal(pickupIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode()) || ObjectUtil.equal(trunklineIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode())) {
// 路径不能为空
if (ObjectUtil.isEmpty(basicExcel.getSendOrg())) {
rowMessage.append("模板配置为不按区域计费,路径不能为空,发货单位必填;");
rowMessage.append("模板配置为不按区域计费,路径不能为空,发货单位必填;");
}
}
// 校验模版中是否包含填写的品类
// 提货
// 提货是否按品类计费
Integer pickupIsByCategory = templateEntity.getPickupIsByCategory();
if (ObjectUtil.isNotEmpty(pickupIsByCategory) && ObjectUtil.equal(pickupIsByCategory, BooleanZeroOneEnums.YES.getCode())) {
String pickupPieceCategory = templateEntity.getPickupPieceCategory();
String pickupCubeCategory = templateEntity.getPickupCubeCategory();
String pickupWeightCategory = templateEntity.getPickupWeightCategory();
if (ObjectUtil.isAllNotEmpty(basicExcel.getPickupUnit(), basicExcel.getPickupPrice())) {
String pickupUnit = basicExcel.getPickupUnit();
String category = basicExcel.getCategory();
if (ObjectUtil.equal(PickupPricingTypeEnums.PIECE.getText(), pickupUnit)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, pickupPieceCategory, pickupUnit, "配送");
}
if (ObjectUtil.equal(PickupPricingTypeEnums.CUBE.getText(), pickupUnit)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, pickupCubeCategory, pickupUnit, "配送");
}
if (ObjectUtil.equal(PickupPricingTypeEnums.WEIGHT.getText(), pickupUnit)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, pickupWeightCategory, pickupUnit, "配送");
}
}
}
Integer trunkLineIsByCategory = templateEntity.getTrunklineIsByCategory();
if (ObjectUtil.isNotEmpty(trunkLineIsByCategory) && ObjectUtil.equal(trunkLineIsByCategory, BooleanZeroOneEnums.YES.getCode())) {
String trunklinePieceCategory = templateEntity.getTrunklinePieceCategory();
String trunklineCubeCategory = templateEntity.getTrunklineCubeCategory();
String trunklineWeightCategory = templateEntity.getTrunklineWeightCategory();
if (ObjectUtil.isAllNotEmpty(basicExcel.getTrunkLineUnit(), basicExcel.getTrunkLinePrice())) {
String pickupUnit = basicExcel.getTrunkLineUnit();
String category = basicExcel.getCategory();
if (ObjectUtil.equal(TrunkLinePricingTypeEnums.PIECE.getText(), pickupUnit)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, trunklinePieceCategory, pickupUnit, "干线");
}
if (ObjectUtil.equal(TrunkLinePricingTypeEnums.CUBE.getText(), pickupUnit)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, trunklineCubeCategory, pickupUnit, "干线");
}
if (ObjectUtil.equal(TrunkLinePricingTypeEnums.WEIGHT.getText(), pickupUnit)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, trunklineWeightCategory, pickupUnit, "干线");
}
}
}
Integer warehouseIsByCategory = templateEntity.getWarehouseIsByCategory();
if (ObjectUtil.isNotEmpty(warehouseIsByCategory) && ObjectUtil.equal(warehouseIsByCategory, BooleanZeroOneEnums.YES.getCode())) {
String warehousePieceCategory = templateEntity.getWarehousePieceCategory();
if (StrUtil.isNotEmpty(basicExcel.getWithinThirtyPrice())
|| StrUtil.isNotEmpty(basicExcel.getBetweenThirtySixtyPrice())
|| StrUtil.isNotEmpty(basicExcel.getBeyondSixtyPrice())
|| StrUtil.isNotEmpty(basicExcel.getBeyondNinetyPrice())) {
String category = basicExcel.getCategory();
if (StrUtil.isNotEmpty(category)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, warehousePieceCategory, null, "仓储");
}
}
}
Integer warehouseIsCategorySubjoin = templateEntity.getWarehouseIsCategorySubjoin();
if (ObjectUtil.isNotEmpty(warehouseIsCategorySubjoin) && ObjectUtil.equal(warehouseIsCategorySubjoin, BooleanZeroOneEnums.YES.getCode())) {
String warehousePieceCategory = templateEntity.getWarehouseSubjoinCategory();
if (StrUtil.isNotEmpty(basicExcel.getWarehouseSortPrice())
|| StrUtil.isNotEmpty(basicExcel.getWarehouseManagementPrice())
|| StrUtil.isNotEmpty(basicExcel.getWarehouseOperatePrice())) {
String category = basicExcel.getCategory();
if (StrUtil.isNotEmpty(category)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, warehousePieceCategory, null, "仓储附加费");
}
}
}
Integer dispatchIsByCategory = templateEntity.getDispatchIsByCategory();
if (ObjectUtil.isNotEmpty(dispatchIsByCategory) && ObjectUtil.equal(dispatchIsByCategory, BooleanZeroOneEnums.YES.getCode())) {
String trunklinePieceCategory = templateEntity.getDispatchPieceCategory();
String trunklineCubeCategory = templateEntity.getDispatchCubeCategory();
String trunklineWeightCategory = templateEntity.getDispatchWeightCategory();
if (ObjectUtil.isAllNotEmpty(basicExcel.getDispatchUnit(), basicExcel.getDispatchPrice())) {
String pickupUnit = basicExcel.getDispatchUnit();
String category = basicExcel.getCategory();
if (ObjectUtil.equal(DispatchPricingTypeEnums.PIECE.getText(), pickupUnit)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, trunklinePieceCategory, pickupUnit, "配送");
}
if (ObjectUtil.equal(DispatchPricingTypeEnums.CUBE.getText(), pickupUnit)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, trunklineCubeCategory, pickupUnit, "配送");
}
if (ObjectUtil.equal(DispatchPricingTypeEnums.WEIGHT.getText(), pickupUnit)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, trunklineWeightCategory, pickupUnit, "配送");
}
}
}
Integer dispatchIsCategorySubjoin = templateEntity.getDispatchIsCategorySubjoin();
if (ObjectUtil.isNotEmpty(dispatchIsCategorySubjoin) && ObjectUtil.equal(dispatchIsCategorySubjoin, BooleanZeroOneEnums.YES.getCode())) {
String warehousePieceCategory = templateEntity.getDispatchSubjoinCategory();
if (StrUtil.isNotEmpty(basicExcel.getDispatchSortPrice())
|| StrUtil.isNotEmpty(basicExcel.getDispatchHandlingPrice())
|| StrUtil.isNotEmpty(basicExcel.getDispatchRelocationPrice())
|| StrUtil.isNotEmpty(basicExcel.getDispatchDeliveryPrice())) {
String category = basicExcel.getCategory();
if (StrUtil.isNotEmpty(category)) {
checkCategoryByUnit(categoryIdMap, category, rowMessage, warehousePieceCategory, null, "配送附加费");
}
}
}
}
@ -2508,6 +2613,35 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
}
}
private void checkCategoryByUnit(Map<String, BasicdataCategoryEntity> categoryIdMap, String category, StringBuilder rowMessage,
String categoryIdStr, String unit, String type) {
if (StrUtil.isNotEmpty(categoryIdStr)) {
List<String> categoryIds = StrUtil.splitTrim(categoryIdStr, ",");
List<String> categoryNamesFromMap = categoryIds.stream()
.map(categoryIdMap::get)
.filter(Objects::nonNull)
.map(BasicdataCategoryEntity::getName)
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(categoryNamesFromMap)) {
if (!categoryNamesFromMap.contains(category)) {
rowMessage.append("品类【").append(category).append("】不在模板")
.append(type);
if (StrUtil.isNotEmpty(unit)) {
rowMessage.append(unit);
}
rowMessage.append("品类中,请检查;");
}
}else{
rowMessage.append("品类【").append(category).append("】不在模板")
.append(type);
if (StrUtil.isNotEmpty(unit)) {
rowMessage.append(unit);
}
rowMessage.append("品类中,请检查;");
}
}
}
private void buildErrorMessageExcel(StringBuilder message, StringBuilder rowMessage, String firstMessage) {
if (StrUtil.isNotEmpty(rowMessage.toString())) {
message.append("<p>");
@ -2531,7 +2665,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
private void checkCategoryExcel(Map<String, BasicdataCategoryEntity> categoryEntityMap, StringBuilder rowMessage, String category) {
if (StrUtil.isNotEmpty(category)) {
if (!categoryEntityMap.containsKey(category)) {
rowMessage.append("品类不存在;");
rowMessage.append("品类不存在");
}
}
}
@ -2539,7 +2673,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
private void checkSendOrgExcel(Map<String, BasicdataClientEntity> clientEntityMap, StringBuilder rowMessage, String sendOrg) {
if (StrUtil.isNotEmpty(sendOrg)) {
if (!clientEntityMap.containsKey(sendOrg)) {
rowMessage.append("发货单位不存在;");
rowMessage.append("发货单位不存在");
}
}
}
@ -2547,15 +2681,15 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
private void checkReign(Map<String, String> provinceMap, Map<String, String> provinceCityMap, Map<String, String> provinceCityAearMap, StringBuilder rowMessage, String startProvince, String startCity, String startArea, String type) {
if (StrUtil.isNotEmpty(startProvince)) {
if (!provinceMap.containsKey(startProvince)) {
rowMessage.append(type).append("(省)不存在;");
rowMessage.append(type).append("(省)不存在");
} else {
if (StrUtil.isNotEmpty(startCity)) {
if (!provinceCityMap.containsKey(startProvince + startCity)) {
rowMessage.append(type).append("(市)不存在;");
rowMessage.append(type).append("(市)不存在");
} else {
if (StrUtil.isNotEmpty(startArea)) {
if (!provinceCityAearMap.containsKey(startProvince + startCity + startArea)) {
rowMessage.append(type).append("(区)不存在;");
rowMessage.append(type).append("(区)不存在");
}
}
}
@ -2581,15 +2715,15 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
private void checkClientAndBrandV2(Map<String, BasicdataStoreBrandEntity> priceEntityMap, StringBuilder rowMessage, String client, String brand) {
if (StrUtil.isEmpty(client)) {
rowMessage.append("客户名称不能为空;");
rowMessage.append("客户名称不能为空");
}
if (StrUtil.isEmpty(brand)) {
rowMessage.append("品牌不能为空;");
rowMessage.append("品牌不能为空");
}
// 客户+品牌必须在sheet1中存在
if (!ObjectUtil.isAllEmpty(client, brand)) {
if (!priceEntityMap.containsKey(client + brand)) {
rowMessage.append("客户名称+品牌名称不存在;");
rowMessage.append("客户名称+品牌名称不存在");
}
}
}
@ -2977,42 +3111,42 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
// 校验必填项
Boolean clientFlag = Boolean.FALSE;
if (StrUtil.isEmpty(priceExcel.getClient())) {
rowMessage.append("客户名称不能为空;");
rowMessage.append("客户名称不能为空");
} else {
if (!clientEntityMap.containsKey(priceExcel.getClient())) {
rowMessage.append("客户名称[").append(priceExcel.getClient()).append("]在系统中不存在;");
rowMessage.append("客户名称[").append(priceExcel.getClient()).append("]在系统中不存在");
} else {
clientFlag = Boolean.TRUE;
}
}
Boolean brandFlag = Boolean.FALSE;
if (StrUtil.isEmpty(priceExcel.getBrand())) {
rowMessage.append("品牌名称名称不能为空;");
rowMessage.append("品牌名称名称不能为空");
} else {
if (!brandEntityMap.containsKey(priceExcel.getBrand())) {
rowMessage.append("品牌名称[").append(priceExcel.getBrand()).append("]在系统中不存在;");
rowMessage.append("品牌名称[").append(priceExcel.getBrand()).append("]在系统中不存在");
} else {
brandFlag = Boolean.TRUE;
}
}
Boolean templateFlag = Boolean.FALSE;
if (StrUtil.isEmpty(priceExcel.getTemplateName())) {
rowMessage.append("模板名称不能为空;");
rowMessage.append("模板名称不能为空");
} else {
if (!templateEntityMap.containsKey(priceExcel.getTemplateName())) {
rowMessage.append("模板名称[").append(priceExcel.getTemplateName()).append("]在系统中不存在;");
rowMessage.append("模板名称[").append(priceExcel.getTemplateName()).append("]在系统中不存在");
} else {
templateFlag = Boolean.TRUE;
}
}
if (brandFlag && templateFlag) {
if (!ObjectUtil.equal(brandEntityMap.get(priceExcel.getBrand()).getId(), templateEntityMap.get(priceExcel.getTemplateName()).getBrandId())) {
rowMessage.append("品牌名称[").append(priceExcel.getBrand()).append("]与模板对应的品牌").append("不相同,请填写对应品牌的模板;");
rowMessage.append("品牌名称[").append(priceExcel.getBrand()).append("]与模板对应的品牌").append("不相同,请填写对应品牌的模板");
}
}
if (!ObjectUtil.isAllEmpty(priceExcel.getClient(), priceExcel.getBrand())) {
if (!clientBrandMap.containsKey(priceExcel.getClient() + priceExcel.getBrand())) {
rowMessage.append("客户名称[").append(priceExcel.getClient()).append("]下不存在品牌名称[").append(priceExcel.getBrand()).append("],请维护客户和品牌的关系;");
rowMessage.append("客户名称[").append(priceExcel.getClient()).append("]下不存在品牌名称[").append(priceExcel.getBrand()).append("],请维护客户和品牌的关系");
}
}
DateTime startTime = null;
@ -3022,7 +3156,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
try {
startTime = DateUtil.parseDate(priceExcel.getEffectiveTime());
} catch (Exception e) {
rowMessage.append("生效时间格式错误,例:2020-01-01;");
rowMessage.append("生效时间格式错误,例:2020-01-01");
}
}
if (StrUtil.isNotEmpty(priceExcel.getExpiryTime())) {
@ -3030,18 +3164,18 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
try {
endTime = DateUtil.parseDate(priceExcel.getExpiryTime());
} catch (Exception e) {
rowMessage.append("到期时间格式错误,例:2020-01-01;");
rowMessage.append("到期时间格式错误,例:2020-01-01");
}
}
if (!ObjectUtil.isAllEmpty(startTime, endTime)) {
// 校验时间大小关系
if (startTime.isAfter(endTime)) {
rowMessage.append("生效时间不能大于到期时间;");
rowMessage.append("生效时间不能大于到期时间");
} else {
// 校验时间是否合法
// 1 输入的截至时间不能小于当前时间
if (endTime.isBefore(DateUtil.beginOfDay(DateUtil.date()))) {
rowMessage.append("到期时间不能小于当前时间;");
rowMessage.append("到期时间不能小于当前时间");
}
// 2 当前输入的时间范围不能跨越2个已有的价格体系
if (clientFlag && brandFlag) {
@ -3075,7 +3209,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
}
}
if (dataFlag > 1) {
rowMessage.append("生效时间与截至时间范围在系统中存在多个价格体系,请确认;");
rowMessage.append("生效时间与截至时间范围在系统中存在多个价格体系,请确认");
}
}
}
@ -3084,7 +3218,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
}
if (StrUtil.isEmpty(message.toString())) {
if (CollUtil.isNotEmpty(priceEntityMap) && !ObjectUtil.equal(priceExcels.size(), priceEntityMap.size())) {
message.append(sheet1).append("中存在 客户名称+品牌 重复的数据,请检查;");
message.append(sheet1).append("中存在 客户名称+品牌 重复的数据,请检查");
}
}
}
@ -3094,7 +3228,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
private void checkPrice(StringBuilder rowMessage, String cloumName, String price) {
if (StrUtil.isNotEmpty(price)) {
if (!NumberUtil.isNumber(price)) {
rowMessage.append(cloumName).append("只能为数字;");
rowMessage.append(cloumName).append("只能为数字");
}
}
}

Loading…
Cancel
Save