给商品excel导入增加校验:校验条码是否是正整数

This commit is contained in:
季圣华
2022-03-16 23:33:00 +08:00
parent 3cfa290847
commit d923c8f11a
3 changed files with 35 additions and 0 deletions

View File

@@ -496,6 +496,16 @@ public class MaterialService {
String wholesaleDecimal = ExcelUtils.getContent(src, i, 13); //销售价
String lowDecimal = ExcelUtils.getContent(src, i, 14); //最低售价
String enabled = ExcelUtils.getContent(src, i, 15); //状态
//校验基础条码是否是正整数
if(!StringUtil.isPositiveInteger(barCode)) {
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_BARCODE_NOT_INTEGER_CODE,
String.format(ExceptionConstants.MATERIAL_BARCODE_NOT_INTEGER_MSG, barCode));
}
//校验副条码是否是正整数
if(StringUtil.isNotEmpty(manyBarCode) && !StringUtil.isPositiveInteger(manyBarCode)) {
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_BARCODE_NOT_INTEGER_CODE,
String.format(ExceptionConstants.MATERIAL_BARCODE_NOT_INTEGER_MSG, manyBarCode));
}
//校验条码是否存在
List<MaterialVo4Unit> basicMaterialList = getMaterialByBarCode(barCode);
if(basicMaterialList!=null && basicMaterialList.size()>0) {