Browse Source

feat(all): 修改价格体系路径和品类多重关系时数据丢失问题

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

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

@ -931,10 +931,10 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
if (CollUtil.isNotEmpty(basicEntities)) {
categoryBasicService.saveBatch(basicEntities);
}
if(CollUtil.isNotEmpty(warehouseEntities)){
if (CollUtil.isNotEmpty(warehouseEntities)) {
categoryWarehouseService.saveBatch(warehouseEntities);
}
if(CollUtil.isNotEmpty(dispatchEntities)){
if (CollUtil.isNotEmpty(dispatchEntities)) {
categoryDispatchService.saveBatch(dispatchEntities);
}
// 处理整车费用
@ -1800,19 +1800,13 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
String pickupPrice = basicExcel.getPickupPrice();
String trunkLinePrice = basicExcel.getTrunkLinePrice();
if (StrUtil.isNotEmpty(pickupPrice) && Convert.toDouble(pickupPrice) > 0) {
Long routeId = null;
Integer pickupIsByCategory = templateEntity.getPickupIsByCategory();
// 按品类计费
boolean categoryFlag = ObjectUtil.isNotEmpty(pickupIsByCategory) && ObjectUtil.equal(pickupIsByCategory, BooleanZeroOneEnums.YES.getCode());
// 按区域计费 有路径的
boolean b = ObjectUtil.isNotEmpty(pickupIsUnifyAreaBill) && ObjectUtil.equal(pickupIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode());
BasicdataPriceCategoryBasicEntity basicEntity = null;
if (b) {
basicEntity = new BasicdataPriceCategoryBasicEntity();
} else {
if (pickupEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
basicEntity = pickupEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
basicEntity = new BasicdataPriceCategoryBasicEntity();
pickupEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), basicEntity);
}
}
// 按区域计费
if (b) {
if (!ObjectUtil.isAllEmpty(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getSendOrg())) {
String key = buildRoutKeyV2(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getStartProvince(),
@ -1820,15 +1814,45 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
basicExcel.getEndCity(), basicExcel.getEndArea(), basicExcel.getSendOrg(), "1");
BasicdataPriceRouteEntity routeEntity = routeEntityMap.get(key);
if (ObjectUtil.isNotEmpty(routeEntity)) {
basicEntity.setBoId(routeEntity.getId());
routeId = routeEntity.getId();
}
} else {
basicEntity.setBoId(priceEntity.getId());
log.error("价格体系导入CategoryBasic数据无法处理,模板配置的按区域计费,数据不满足路径条件:{}", JSONUtil.toJsonStr(basicExcel));
continue;
}
}
if (b && categoryFlag) {
// 有路径按品类计费
basicEntity = new BasicdataPriceCategoryBasicEntity();
} else if (b && !categoryFlag) {
// 有路径不按品类计费,一个客户一条路径一个价格
if (pickupEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + routeId)) {
basicEntity = pickupEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + routeId);
} else {
basicEntity = new BasicdataPriceCategoryBasicEntity();
pickupEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + routeId, basicEntity);
}
} else if (!b && categoryFlag) {
// 没路径 按品类计费 一个客户一个品类一个价格
if (pickupEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
basicEntity = pickupEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
basicEntity = new BasicdataPriceCategoryBasicEntity();
pickupEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), basicEntity);
}
} else {
// 没路径 不按品类计费 一个客户一个价格
if (pickupEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand())) {
basicEntity = pickupEntityMap.get(basicExcel.getClient() + basicExcel.getBrand());
} else {
basicEntity = new BasicdataPriceCategoryBasicEntity();
pickupEntityMap.put(basicExcel.getClient() + basicExcel.getBrand(), basicEntity);
}
}
// 按区域计费
if (b) {
basicEntity.setBoId(routeId);
} else {
// 统一计费
basicEntity.setBoId(priceEntity.getId());
}
basicEntity.setServiceType(ServiceTypeEnums.PICK_UP.getCode());
@ -1840,7 +1864,9 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
// 品类
if (StrUtil.isNotEmpty(basicExcel.getCategory())) {
if (ObjectUtil.isNotEmpty(categoryEntityMap.get(basicExcel.getCategory()))) {
basicEntity.setCategoryId(categoryEntityMap.get(basicExcel.getCategory()).getId());
if (categoryFlag) {
basicEntity.setCategoryId(categoryEntityMap.get(basicExcel.getCategory()).getId());
}
}
}
// 价格
@ -1850,19 +1876,13 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
}
}
if (StrUtil.isNotEmpty(trunkLinePrice) && Convert.toDouble(trunkLinePrice) > 0) {
Long routeId = null;
Integer pickupIsByCategory = templateEntity.getTrunklineIsByCategory();
// 按品类计费
boolean categoryFlag = ObjectUtil.isNotEmpty(pickupIsByCategory) && ObjectUtil.equal(pickupIsByCategory, BooleanZeroOneEnums.YES.getCode());
// 按区域计费 有路径的
boolean b = ObjectUtil.isNotEmpty(trunklineIsUnifyAreaBill) && ObjectUtil.equal(trunklineIsUnifyAreaBill, BooleanZeroOneEnums.NO.getCode());
BasicdataPriceCategoryBasicEntity basicEntity = null;
if (b) {
basicEntity = new BasicdataPriceCategoryBasicEntity();
} else {
if (trunkLineEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
basicEntity = trunkLineEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
basicEntity = new BasicdataPriceCategoryBasicEntity();
trunkLineEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), basicEntity);
}
}
// 按区域计费
if (b) {
if (!ObjectUtil.isAllEmpty(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getSendOrg())) {
String key = buildRoutKeyV2(basicExcel.getClient(), basicExcel.getBrand(), basicExcel.getStartProvince(),
@ -1870,15 +1890,45 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
basicExcel.getEndCity(), basicExcel.getEndArea(), basicExcel.getSendOrg(), "2");
BasicdataPriceRouteEntity routeEntity = routeEntityMap.get(key);
if (ObjectUtil.isNotEmpty(routeEntity)) {
basicEntity.setBoId(routeEntity.getId());
routeId = routeEntity.getId();
}
} else {
basicEntity.setBoId(priceEntity.getId());
log.error("价格体系导入CategoryBasic数据无法处理,模板配置的按区域计费,数据不满足路径条件:{}", JSONUtil.toJsonStr(basicExcel));
continue;
}
}
if (b && categoryFlag) {
// 有路径按品类计费
basicEntity = new BasicdataPriceCategoryBasicEntity();
} else if (b && !categoryFlag) {
// 有路径不按品类计费,一个客户一条路径一个价格
if (trunkLineEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + routeId)) {
basicEntity = trunkLineEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + routeId);
} else {
basicEntity = new BasicdataPriceCategoryBasicEntity();
trunkLineEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + routeId, basicEntity);
}
} else if (!b && categoryFlag) {
// 没路径 按品类计费 一个客户一个品类一个价格
if (trunkLineEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
basicEntity = trunkLineEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
basicEntity = new BasicdataPriceCategoryBasicEntity();
trunkLineEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), basicEntity);
}
} else {
// 没路径 不按品类计费 一个客户一个价格
if (trunkLineEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand())) {
basicEntity = trunkLineEntityMap.get(basicExcel.getClient() + basicExcel.getBrand());
} else {
basicEntity = new BasicdataPriceCategoryBasicEntity();
trunkLineEntityMap.put(basicExcel.getClient() + basicExcel.getBrand(), basicEntity);
}
}
// 按区域计费
if (b) {
basicEntity.setBoId(routeId);
} else {
// 统一计费
basicEntity.setBoId(priceEntity.getId());
}
basicEntity.setServiceType(ServiceTypeEnums.TRUNK_LINE.getCode());
@ -1890,7 +1940,9 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
// 品类
if (StrUtil.isNotEmpty(basicExcel.getCategory())) {
if (ObjectUtil.isNotEmpty(categoryEntityMap.get(basicExcel.getCategory()))) {
basicEntity.setCategoryId(categoryEntityMap.get(basicExcel.getCategory()).getId());
if (categoryFlag) {
basicEntity.setCategoryId(categoryEntityMap.get(basicExcel.getCategory()).getId());
}
}
}
// 价格
@ -1908,13 +1960,26 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
|| (ObjectUtil.isNotEmpty(betweenThirtySixtyPrice) && Convert.toDouble(betweenThirtySixtyPrice) > 0)
|| (ObjectUtil.isNotEmpty(beyondSixtyPrice) && Convert.toDouble(beyondSixtyPrice) > 0)
|| (ObjectUtil.isNotEmpty(beyondNinetyPrice) && Convert.toDouble(beyondNinetyPrice) > 0)) {
Integer pickupIsByCategory = templateEntity.getWarehouseIsByCategory();
// 按品类计费
boolean categoryFlag = ObjectUtil.isNotEmpty(pickupIsByCategory) && ObjectUtil.equal(pickupIsByCategory, BooleanZeroOneEnums.YES.getCode());
BasicdataPriceCategoryWarehouseEntity warehouseEntity = null;
if (warehouseEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
warehouseEntity = warehouseEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
warehouseEntity = new BasicdataPriceCategoryWarehouseEntity();
warehouseEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), warehouseEntity);
if(categoryFlag){
if (warehouseEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
warehouseEntity = warehouseEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
warehouseEntity = new BasicdataPriceCategoryWarehouseEntity();
warehouseEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), warehouseEntity);
}
}else{
if (warehouseEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand())) {
warehouseEntity = warehouseEntityMap.get(basicExcel.getClient() + basicExcel.getBrand());
} else {
warehouseEntity = new BasicdataPriceCategoryWarehouseEntity();
warehouseEntityMap.put(basicExcel.getClient() + basicExcel.getBrand(), warehouseEntity);
}
}
if (ObjectUtil.isNotEmpty(priceEntity)) {
warehouseEntity.setPriceId(priceEntity.getId());
warehouseEntity.setBoId(priceEntity.getId());
@ -1922,11 +1987,13 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
if (StrUtil.isNotEmpty(basicExcel.getCategory())) {
BasicdataCategoryEntity basicdataCategoryEntity = categoryEntityMap.get(basicExcel.getCategory());
if (ObjectUtil.isNotEmpty(basicdataCategoryEntity)) {
warehouseEntity.setCategoryId(basicdataCategoryEntity.getId());
if (categoryFlag) {
warehouseEntity.setCategoryId(basicdataCategoryEntity.getId());
}
}
}
warehouseEntity.setCostType(CostTypeEnums.NOMAL.getCode());
warehouseEntity.setType(Convert.toInt(templateEntity.getDispatchPricingType()));
warehouseEntity.setType(Convert.toInt(templateEntity.getWarehousePricingType()));
warehouseEntity.setServiceType(1);
if (StrUtil.isNotEmpty(basicExcel.getWithinThirtyPrice())) {
warehouseEntity.setWithinThirtyPrice(Convert.toDouble(basicExcel.getWithinThirtyPrice()));
@ -1947,12 +2014,24 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
if ((ObjectUtil.isNotEmpty(warehouseOperatePrice) && Convert.toDouble(warehouseOperatePrice) > 0)
|| (ObjectUtil.isNotEmpty(warehouseManagementPrice) && Convert.toDouble(warehouseManagementPrice) > 0)
|| (ObjectUtil.isNotEmpty(warehouseSortPrice) && Convert.toDouble(warehouseSortPrice) > 0)) {
Integer pickupIsByCategory = templateEntity.getWarehouseIsCategorySubjoin();
// 按品类计费
boolean categoryFlag = ObjectUtil.isNotEmpty(pickupIsByCategory) && ObjectUtil.equal(pickupIsByCategory, BooleanZeroOneEnums.YES.getCode());
BasicdataPriceCategoryWarehouseEntity warehouseEntity = null;
if (warehouseAddEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
warehouseEntity = warehouseAddEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
warehouseEntity = new BasicdataPriceCategoryWarehouseEntity();
warehouseAddEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), warehouseEntity);
if(categoryFlag){
if (warehouseAddEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
warehouseEntity = warehouseAddEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
warehouseEntity = new BasicdataPriceCategoryWarehouseEntity();
warehouseAddEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), warehouseEntity);
}
}else{
if (warehouseAddEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand())) {
warehouseEntity = warehouseAddEntityMap.get(basicExcel.getClient() + basicExcel.getBrand());
} else {
warehouseEntity = new BasicdataPriceCategoryWarehouseEntity();
warehouseAddEntityMap.put(basicExcel.getClient() + basicExcel.getBrand(), warehouseEntity);
}
}
if (ObjectUtil.isNotEmpty(priceEntity)) {
warehouseEntity.setPriceId(priceEntity.getId());
@ -1961,11 +2040,13 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
if (StrUtil.isNotEmpty(basicExcel.getCategory())) {
BasicdataCategoryEntity basicdataCategoryEntity = categoryEntityMap.get(basicExcel.getCategory());
if (ObjectUtil.isNotEmpty(basicdataCategoryEntity)) {
warehouseEntity.setCategoryId(basicdataCategoryEntity.getId());
if (categoryFlag) {
warehouseEntity.setCategoryId(basicdataCategoryEntity.getId());
}
}
}
warehouseEntity.setCostType(CostTypeEnums.ADD.getCode());
warehouseEntity.setType(Convert.toInt(templateEntity.getDispatchPricingType()));
warehouseEntity.setType(Convert.toInt(templateEntity.getWarehousePricingType()));
warehouseEntity.setServiceType(1);
if (StrUtil.isNotEmpty(basicExcel.getWarehouseOperatePrice())) {
warehouseEntity.setOperatePrice(Convert.toDouble(basicExcel.getWarehouseOperatePrice()));
@ -1979,12 +2060,24 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
}
String dispatchPrice = basicExcel.getDispatchPrice();
if (StrUtil.isNotEmpty(dispatchPrice) && Convert.toDouble(dispatchPrice) > 0) {
Integer pickupIsByCategory = templateEntity.getDispatchIsByCategory();
// 按品类计费
boolean categoryFlag = ObjectUtil.isNotEmpty(pickupIsByCategory) && ObjectUtil.equal(pickupIsByCategory, BooleanZeroOneEnums.YES.getCode());
BasicdataPriceCategoryDispatchEntity entity = null;
if (dispatchEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
entity = dispatchEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
entity = new BasicdataPriceCategoryDispatchEntity();
dispatchEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), entity);
if(categoryFlag){
if (dispatchEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
entity = dispatchEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
entity = new BasicdataPriceCategoryDispatchEntity();
dispatchEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), entity);
}
}else{
if (dispatchEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand())) {
entity = dispatchEntityMap.get(basicExcel.getClient() + basicExcel.getBrand());
} else {
entity = new BasicdataPriceCategoryDispatchEntity();
dispatchEntityMap.put(basicExcel.getClient() + basicExcel.getBrand(), entity);
}
}
if (ObjectUtil.isNotEmpty(priceEntity)) {
entity.setPriceId(priceEntity.getId());
@ -1993,7 +2086,9 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
if (StrUtil.isNotEmpty(basicExcel.getCategory())) {
BasicdataCategoryEntity basicdataCategoryEntity = categoryEntityMap.get(basicExcel.getCategory());
if (ObjectUtil.isNotEmpty(basicdataCategoryEntity)) {
entity.setCategoryId(basicdataCategoryEntity.getId());
if (categoryFlag) {
entity.setCategoryId(basicdataCategoryEntity.getId());
}
}
}
entity.setCostType(CostTypeEnums.NOMAL.getCode());
@ -2016,12 +2111,24 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
|| (ObjectUtil.isNotEmpty(dispatchHandlingPrice) && Convert.toDouble(dispatchHandlingPrice) > 0)
|| (ObjectUtil.isNotEmpty(dispatchRelocationPrice) && Convert.toDouble(dispatchRelocationPrice) > 0)
|| (ObjectUtil.isNotEmpty(dispatchDeliveryPrice) && Convert.toDouble(dispatchDeliveryPrice) > 0)) {
Integer pickupIsByCategory = templateEntity.getDispatchIsByCategory();
// 按品类计费
boolean categoryFlag = ObjectUtil.isNotEmpty(pickupIsByCategory) && ObjectUtil.equal(pickupIsByCategory, BooleanZeroOneEnums.YES.getCode());
BasicdataPriceCategoryDispatchEntity entity = null;
if (dispatchAddEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
entity = dispatchAddEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
entity = new BasicdataPriceCategoryDispatchEntity();
dispatchAddEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), entity);
if(categoryFlag){
if (dispatchAddEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory())) {
entity = dispatchAddEntityMap.get(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory());
} else {
entity = new BasicdataPriceCategoryDispatchEntity();
dispatchAddEntityMap.put(basicExcel.getClient() + basicExcel.getBrand() + basicExcel.getCategory(), entity);
}
}else{
if (dispatchAddEntityMap.containsKey(basicExcel.getClient() + basicExcel.getBrand())) {
entity = dispatchAddEntityMap.get(basicExcel.getClient() + basicExcel.getBrand());
} else {
entity = new BasicdataPriceCategoryDispatchEntity();
dispatchAddEntityMap.put(basicExcel.getClient() + basicExcel.getBrand(), entity);
}
}
if (ObjectUtil.isNotEmpty(priceEntity)) {
entity.setPriceId(priceEntity.getId());
@ -2030,7 +2137,9 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
if (StrUtil.isNotEmpty(basicExcel.getCategory())) {
BasicdataCategoryEntity basicdataCategoryEntity = categoryEntityMap.get(basicExcel.getCategory());
if (ObjectUtil.isNotEmpty(basicdataCategoryEntity)) {
entity.setCategoryId(basicdataCategoryEntity.getId());
if (categoryFlag) {
entity.setCategoryId(basicdataCategoryEntity.getId());
}
}
}
entity.setCostType(CostTypeEnums.ADD.getCode());
@ -2637,7 +2746,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
}
rowMessage.append("品类中,请检查;");
}
}else{
} else {
rowMessage.append("品类【").append(category).append("】不在模板")
.append(type);
if (StrUtil.isNotEmpty(unit)) {

Loading…
Cancel
Save