给excel导入增加条码重复的校验
This commit is contained in:
@@ -335,6 +335,12 @@ public class ExceptionConstants {
|
||||
//盘点业务不能选择批号或序列号商品
|
||||
public static final int MATERIAL_STOCK_CHECK_ERROR_CODE = 80000019;
|
||||
public static final String MATERIAL_STOCK_CHECK_ERROR_MSG = "抱歉,盘点业务不能选择批号或序列号商品:%s,建议走其它入库和出库单";
|
||||
//EXCEL中存在重复的商品
|
||||
public static final int MATERIAL_EXCEL_IMPORT_EXIST_CODE = 80000020;
|
||||
public static final String MATERIAL_EXCEL_IMPORT_EXIST_MSG = "抱歉,EXCEL中存在重复的商品,具体信息为:%s";
|
||||
//EXCEL中存在重复的条码
|
||||
public static final int MATERIAL_EXCEL_IMPORT_BARCODE_EXIST_CODE = 80000021;
|
||||
public static final String MATERIAL_EXCEL_IMPORT_BARCODE_EXIST_MSG = "抱歉,EXCEL中存在重复的条码,具体条码为:%s";
|
||||
|
||||
/**
|
||||
* 单据信息
|
||||
|
||||
@@ -499,6 +499,8 @@ public class MaterialService {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_UNIT_EMPTY_MSG, i+1));
|
||||
}
|
||||
// 批量校验excel中有无重复商品,是指名称、规格、型号、颜色、单位
|
||||
batchCheckExistMaterialListByParam(mList, name, standard, model, color, unit);
|
||||
MaterialWithInitStock m = new MaterialWithInitStock();
|
||||
m.setName(name);
|
||||
m.setStandard(standard);
|
||||
@@ -550,6 +552,8 @@ public class MaterialService {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_BARCODE_NOT_INTEGER_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_BARCODE_NOT_INTEGER_MSG, manyBarCode));
|
||||
}
|
||||
//批量校验excel中有无重复条码
|
||||
batchCheckExistBarCodeByParam(mList, barCode, manyBarCode);
|
||||
JSONObject materialExObj = new JSONObject();
|
||||
JSONObject basicObj = new JSONObject();
|
||||
basicObj.put("barCode", barCode);
|
||||
@@ -649,7 +653,17 @@ public class MaterialService {
|
||||
insertCurrentStockMaterialList.add(materialCurrentStock);
|
||||
}
|
||||
} else {
|
||||
depotItemService.updateCurrentStockFun(mId, depotId);
|
||||
BigDecimal initStock = getInitStock(mId, depotId);
|
||||
BigDecimal currentNumber = getCurrentStockByMaterialIdAndDepotId(mId, depotId);
|
||||
//当前库存的更新:减去初始库存,再加上导入的新初始库存
|
||||
if(currentNumber!=null && initStock!=null) {
|
||||
currentNumber = currentNumber.subtract(initStock).add(stock);
|
||||
}
|
||||
MaterialCurrentStock materialCurrentStock = new MaterialCurrentStock();
|
||||
materialCurrentStock.setMaterialId(mId);
|
||||
materialCurrentStock.setDepotId(depotId);
|
||||
materialCurrentStock.setCurrentNumber(currentNumber);
|
||||
insertCurrentStockMaterialList.add(materialCurrentStock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -717,6 +731,56 @@ public class MaterialService {
|
||||
return stockMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量校验excel中有无重复商品,是指名称、规格、型号、颜色、单位
|
||||
* @param mList
|
||||
*/
|
||||
public void batchCheckExistMaterialListByParam(List<MaterialWithInitStock> mList, String name, String standard,
|
||||
String model, String color, String unit) {
|
||||
for(MaterialWithInitStock material: mList){
|
||||
if(name.equals(material.getName()) &&
|
||||
standard.equals(material.getStandard()) &&
|
||||
model.equals(material.getModel()) &&
|
||||
color.equals(material.getColor()) &&
|
||||
unit.equals(material.getUnit())){
|
||||
String info = name + "-" + standard + "-" + model + "-" + color + "-" + unit;
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXCEL_IMPORT_EXIST_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_EXCEL_IMPORT_EXIST_MSG, info));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量校验excel中有无重复条码
|
||||
* @param mList
|
||||
*/
|
||||
public void batchCheckExistBarCodeByParam(List<MaterialWithInitStock> mList,
|
||||
String barCode, String manyBarCode) {
|
||||
for(MaterialWithInitStock material: mList){
|
||||
JSONObject materialExObj = material.getMaterialExObj();
|
||||
String basicBarCode = "";
|
||||
String otherBarCode = "";
|
||||
if(materialExObj.get("basic")!=null) {
|
||||
JSONObject basicObj = materialExObj.getJSONObject("basic");
|
||||
basicBarCode = basicObj.getString("barCode");
|
||||
}
|
||||
if(materialExObj.get("other")!=null) {
|
||||
JSONObject otherObj = materialExObj.getJSONObject("other");
|
||||
otherBarCode = otherObj.getString("barCode");
|
||||
}
|
||||
if(barCode.equals(basicBarCode) || barCode.equals(otherBarCode)){
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_EXIST_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_EXIST_MSG, barCode));
|
||||
}
|
||||
if(StringUtil.isNotEmpty(manyBarCode)) {
|
||||
if(manyBarCode.equals(basicBarCode) || manyBarCode.equals(otherBarCode)){
|
||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_EXIST_CODE,
|
||||
String.format(ExceptionConstants.MATERIAL_EXCEL_IMPORT_BARCODE_EXIST_MSG, manyBarCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 给商品新增或更新条码与价格相关信息
|
||||
* @param materialExObj
|
||||
|
||||
Reference in New Issue
Block a user