单据明细导入:校验条码是否存在
This commit is contained in:
parent
be23ba32a7
commit
5baab7fe48
@ -414,6 +414,10 @@ public class ExceptionConstants {
|
||||
//修改单据明细信息失败
|
||||
public static final int DEPOT_ITEM_EDIT_FAILED_CODE = 9000002;
|
||||
public static final String DEPOT_ITEM_EDIT_FAILED_MSG = "修改单据明细信息失败";
|
||||
//单据明细-明细中商品不存在
|
||||
public static final int DEPOT_ITEM_BARCODE_IS_NOT_EXIST_CODE = 9000003;
|
||||
public static final String DEPOT_ITEM_BARCODE_IS_NOT_EXIST_MSG = "抱歉,商品条码:%s在商品管理中不存在";
|
||||
|
||||
/**
|
||||
* 财务信息
|
||||
* type = 95
|
||||
|
||||
@ -934,6 +934,10 @@ public class DepotItemController {
|
||||
}
|
||||
res.data = map;
|
||||
}
|
||||
} catch (BusinessRunTimeException e) {
|
||||
res.code = 500;
|
||||
data.put("message", e.getData().get("message"));
|
||||
res.data = data;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = "导入失败,请检查表格内容";
|
||||
|
||||
@ -1116,75 +1116,74 @@ public class DepotItemService {
|
||||
|
||||
public JSONObject parseMapByExcelData(String barCodes, List<Map<String, String>> detailList, String prefixNo) {
|
||||
JSONObject map = new JSONObject();
|
||||
try {
|
||||
JSONArray arr = new JSONArray();
|
||||
List<MaterialVo4Unit> list = depotItemMapperEx.getBillItemByParam(barCodes);
|
||||
Map<String, MaterialVo4Unit> materialMap = new HashMap<>();
|
||||
for (MaterialVo4Unit material: list) {
|
||||
materialMap.put(material.getmBarCode(), material);
|
||||
}
|
||||
for (Map<String, String> detailMap: detailList) {
|
||||
JSONObject item = new JSONObject();
|
||||
String barCode = detailMap.get("barCode");
|
||||
MaterialVo4Unit m = materialMap.get(barCode);
|
||||
if(m!=null) {
|
||||
item.put("barCode", barCode);
|
||||
item.put("name", m.getName());
|
||||
item.put("standard", m.getStandard());
|
||||
if(StringUtil.isNotEmpty(m.getModel())) {
|
||||
item.put("model", m.getModel());
|
||||
}
|
||||
if(StringUtil.isNotEmpty(m.getColor())) {
|
||||
item.put("color", m.getColor());
|
||||
}
|
||||
if(StringUtil.isNotEmpty(m.getSku())) {
|
||||
item.put("sku", m.getSku());
|
||||
}
|
||||
BigDecimal stock = depotItemMapperEx.getCurrentStockByParam(null, m.getId());
|
||||
item.put("stock", stock);
|
||||
item.put("unit", m.getCommodityUnit());
|
||||
BigDecimal operNumber = BigDecimal.ZERO;
|
||||
BigDecimal unitPrice = BigDecimal.ZERO;
|
||||
BigDecimal taxRate = BigDecimal.ZERO;
|
||||
if(StringUtil.isNotEmpty(detailMap.get("num"))) {
|
||||
operNumber = new BigDecimal(detailMap.get("num"));
|
||||
}
|
||||
if(StringUtil.isNotEmpty(detailMap.get("unitPrice"))) {
|
||||
unitPrice = new BigDecimal(detailMap.get("unitPrice"));
|
||||
} else {
|
||||
if("CGDD".equals(prefixNo)) {
|
||||
unitPrice = m.getPurchaseDecimal();
|
||||
} else if("XSDD".equals(prefixNo)) {
|
||||
unitPrice = m.getWholesaleDecimal();
|
||||
}
|
||||
}
|
||||
if(StringUtil.isNotEmpty(detailMap.get("taxRate"))) {
|
||||
taxRate = new BigDecimal(detailMap.get("taxRate"));
|
||||
}
|
||||
String remark = detailMap.get("remark");
|
||||
item.put("operNumber", operNumber);
|
||||
item.put("unitPrice", unitPrice);
|
||||
BigDecimal allPrice = BigDecimal.ZERO;
|
||||
if(unitPrice!=null && unitPrice.compareTo(BigDecimal.ZERO)!=0) {
|
||||
allPrice = unitPrice.multiply(operNumber);
|
||||
}
|
||||
BigDecimal taxMoney = BigDecimal.ZERO;
|
||||
if(taxRate.compareTo(BigDecimal.ZERO) != 0) {
|
||||
taxMoney = taxRate.multiply(allPrice).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
BigDecimal taxLastMoney = allPrice.add(taxMoney);
|
||||
item.put("allPrice", allPrice);
|
||||
item.put("taxRate", taxRate);
|
||||
item.put("taxMoney", taxMoney);
|
||||
item.put("taxLastMoney", taxLastMoney);
|
||||
item.put("remark", remark);
|
||||
arr.add(item);
|
||||
}
|
||||
}
|
||||
map.put("rows", arr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JSONArray arr = new JSONArray();
|
||||
List<MaterialVo4Unit> list = depotItemMapperEx.getBillItemByParam(barCodes);
|
||||
Map<String, MaterialVo4Unit> materialMap = new HashMap<>();
|
||||
for (MaterialVo4Unit material: list) {
|
||||
materialMap.put(material.getmBarCode(), material);
|
||||
}
|
||||
for (Map<String, String> detailMap: detailList) {
|
||||
JSONObject item = new JSONObject();
|
||||
String barCode = detailMap.get("barCode");
|
||||
MaterialVo4Unit m = materialMap.get(barCode);
|
||||
if(m!=null) {
|
||||
item.put("barCode", barCode);
|
||||
item.put("name", m.getName());
|
||||
item.put("standard", m.getStandard());
|
||||
if(StringUtil.isNotEmpty(m.getModel())) {
|
||||
item.put("model", m.getModel());
|
||||
}
|
||||
if(StringUtil.isNotEmpty(m.getColor())) {
|
||||
item.put("color", m.getColor());
|
||||
}
|
||||
if(StringUtil.isNotEmpty(m.getSku())) {
|
||||
item.put("sku", m.getSku());
|
||||
}
|
||||
BigDecimal stock = depotItemMapperEx.getCurrentStockByParam(null, m.getId());
|
||||
item.put("stock", stock);
|
||||
item.put("unit", m.getCommodityUnit());
|
||||
BigDecimal operNumber = BigDecimal.ZERO;
|
||||
BigDecimal unitPrice = BigDecimal.ZERO;
|
||||
BigDecimal taxRate = BigDecimal.ZERO;
|
||||
if(StringUtil.isNotEmpty(detailMap.get("num"))) {
|
||||
operNumber = new BigDecimal(detailMap.get("num"));
|
||||
}
|
||||
if(StringUtil.isNotEmpty(detailMap.get("unitPrice"))) {
|
||||
unitPrice = new BigDecimal(detailMap.get("unitPrice"));
|
||||
} else {
|
||||
if("CGDD".equals(prefixNo)) {
|
||||
unitPrice = m.getPurchaseDecimal();
|
||||
} else if("XSDD".equals(prefixNo)) {
|
||||
unitPrice = m.getWholesaleDecimal();
|
||||
}
|
||||
}
|
||||
if(StringUtil.isNotEmpty(detailMap.get("taxRate"))) {
|
||||
taxRate = new BigDecimal(detailMap.get("taxRate"));
|
||||
}
|
||||
String remark = detailMap.get("remark");
|
||||
item.put("operNumber", operNumber);
|
||||
item.put("unitPrice", unitPrice);
|
||||
BigDecimal allPrice = BigDecimal.ZERO;
|
||||
if(unitPrice!=null && unitPrice.compareTo(BigDecimal.ZERO)!=0) {
|
||||
allPrice = unitPrice.multiply(operNumber);
|
||||
}
|
||||
BigDecimal taxMoney = BigDecimal.ZERO;
|
||||
if(taxRate.compareTo(BigDecimal.ZERO) != 0) {
|
||||
taxMoney = taxRate.multiply(allPrice).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
BigDecimal taxLastMoney = allPrice.add(taxMoney);
|
||||
item.put("allPrice", allPrice);
|
||||
item.put("taxRate", taxRate);
|
||||
item.put("taxMoney", taxMoney);
|
||||
item.put("taxLastMoney", taxLastMoney);
|
||||
item.put("remark", remark);
|
||||
arr.add(item);
|
||||
} else {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_ITEM_BARCODE_IS_NOT_EXIST_CODE,
|
||||
String.format(ExceptionConstants.DEPOT_ITEM_BARCODE_IS_NOT_EXIST_MSG, barCode));
|
||||
}
|
||||
}
|
||||
map.put("rows", arr);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user