|
|
|
@ -83,30 +83,77 @@ public class BasicdataFactoryCategoryImporter implements ExcelImporter<Basicdata
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 验证三方物料是否已经存在 |
|
|
|
|
* |
|
|
|
|
* @param allBasicdataFactoryCategoryEntities |
|
|
|
|
* @param datum |
|
|
|
|
*/ |
|
|
|
|
private void checkAllBasicdataFactoryCategoryEntities(List<BasicdataFactoryCategoryEntity> allBasicdataFactoryCategoryEntities, BasicdataFactoryCategoryExcel datum) { |
|
|
|
|
for (BasicdataFactoryCategoryEntity allBasicdataFactoryCategoryEntity : allBasicdataFactoryCategoryEntities) { |
|
|
|
|
if (allBasicdataFactoryCategoryEntity.getBrand().equals(datum.getBrand()) && allBasicdataFactoryCategoryEntity.getCategory().equals(datum.getCategory()) ){ |
|
|
|
|
if(ObjectUtil.isNotEmpty(allBasicdataFactoryCategoryEntity.getFirsts())&& ObjectUtil.isNotEmpty(allBasicdataFactoryCategoryEntity.getSeconds())&& ObjectUtil.isNotEmpty(allBasicdataFactoryCategoryEntity.getThirds())){ |
|
|
|
|
if(allBasicdataFactoryCategoryEntity.getFirsts().equals(datum.getFirsts()) && allBasicdataFactoryCategoryEntity.getSeconds().equals(datum.getSeconds()) && allBasicdataFactoryCategoryEntity.getThirds().equals(datum.getThirds())){ |
|
|
|
|
throw new ServiceException("品牌:" + datum.getBrand() + " 品类:" + datum.getCategory() + "一级品:"+datum.getFirsts()+" 二级品:"+datum.getSeconds()+" 三级品:"+datum.getThirds()+"已存在相同的配置内容"); |
|
|
|
|
String equalString = buildEqualString(allBasicdataFactoryCategoryEntity); |
|
|
|
|
String equalString2 = buildEqualString2(datum); |
|
|
|
|
if (equalString2.equals(equalString)) { |
|
|
|
|
throw new ServiceException("品牌:" + datum.getBrand() + " 品类:" + datum.getCategory() + "已存在相同的配置内容"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if(ObjectUtil.isNotEmpty(allBasicdataFactoryCategoryEntity.getFirsts())&& ObjectUtil.isNotEmpty(allBasicdataFactoryCategoryEntity.getSeconds())){ |
|
|
|
|
if (allBasicdataFactoryCategoryEntity.getFirsts().equals(datum.getFirsts()) && allBasicdataFactoryCategoryEntity.getSeconds().equals(datum.getSeconds())){ |
|
|
|
|
throw new ServiceException("品牌:" + datum.getBrand() + " 品类:" + datum.getCategory() + "一级品:"+datum.getFirsts()+" 二级品:"+datum.getSeconds()+"已存在相同的配置内容"); |
|
|
|
|
} |
|
|
|
|
} else if (ObjectUtil.isNotEmpty(allBasicdataFactoryCategoryEntity.getFirsts())) { |
|
|
|
|
if (allBasicdataFactoryCategoryEntity.getFirsts().equals(datum.getFirsts())){ |
|
|
|
|
throw new ServiceException("品牌:" + datum.getBrand() + " 品类:" + datum.getCategory() + "一级品:"+datum.getFirsts()+"已存在相同的配置内容"); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 构建字符串 |
|
|
|
|
* |
|
|
|
|
* @param allBasicdataFactoryCategoryEntity |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private String buildEqualString(BasicdataFactoryCategoryEntity allBasicdataFactoryCategoryEntity) { |
|
|
|
|
StringBuilder stringBuffer = new StringBuilder(); |
|
|
|
|
stringBuffer.append(allBasicdataFactoryCategoryEntity.getBrand()).append(allBasicdataFactoryCategoryEntity.getCategory()); |
|
|
|
|
if (ObjectUtil.isNotEmpty(allBasicdataFactoryCategoryEntity.getFirsts())) { |
|
|
|
|
stringBuffer.append(allBasicdataFactoryCategoryEntity.getFirsts()); |
|
|
|
|
} else { |
|
|
|
|
stringBuffer.append("-"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(allBasicdataFactoryCategoryEntity.getSeconds())) { |
|
|
|
|
stringBuffer.append(allBasicdataFactoryCategoryEntity.getSeconds()); |
|
|
|
|
} else { |
|
|
|
|
stringBuffer.append("-"); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(allBasicdataFactoryCategoryEntity.getThirds())) { |
|
|
|
|
stringBuffer.append(allBasicdataFactoryCategoryEntity.getThirds()); |
|
|
|
|
} else { |
|
|
|
|
stringBuffer.append("-"); |
|
|
|
|
} |
|
|
|
|
return stringBuffer.toString(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 构建匹配字符串 |
|
|
|
|
* @param datum |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private String buildEqualString2(BasicdataFactoryCategoryExcel datum) { |
|
|
|
|
StringBuilder stringBuffer = new StringBuilder(); |
|
|
|
|
stringBuffer.append(datum.getBrand()).append(datum.getCategory()); |
|
|
|
|
if (ObjectUtil.isNotEmpty(datum.getFirsts())) { |
|
|
|
|
stringBuffer.append(datum.getFirsts()); |
|
|
|
|
} else { |
|
|
|
|
stringBuffer.append("-"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(datum.getSeconds())) { |
|
|
|
|
stringBuffer.append(datum.getSeconds()); |
|
|
|
|
} else { |
|
|
|
|
stringBuffer.append("-"); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(datum.getThirds())) { |
|
|
|
|
stringBuffer.append(datum.getThirds()); |
|
|
|
|
} else { |
|
|
|
|
stringBuffer.append("-"); |
|
|
|
|
} |
|
|
|
|
return stringBuffer.toString(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|