优化单据明细导入接口的逻辑
This commit is contained in:
@@ -432,6 +432,9 @@ public class ExceptionConstants {
|
||||
//单据明细-明细中商品不存在
|
||||
public static final int DEPOT_ITEM_BARCODE_IS_NOT_EXIST_CODE = 9000003;
|
||||
public static final String DEPOT_ITEM_BARCODE_IS_NOT_EXIST_MSG = "抱歉,商品条码:%s在商品管理中不存在";
|
||||
//单据明细-明细中仓库不存在
|
||||
public static final int DEPOT_ITEM_DEPOTNAME_IS_NOT_EXIST_CODE = 9000004;
|
||||
public static final String DEPOT_ITEM_DEPOTNAME_IS_NOT_EXIST_MSG = "抱歉,仓库:%s在基础资料-仓库信息中不存在";
|
||||
|
||||
/**
|
||||
* 财务信息
|
||||
|
||||
@@ -906,12 +906,31 @@ public class DepotItemController {
|
||||
} else {
|
||||
List<Map<String, String>> detailList = new ArrayList<>();
|
||||
for (int i = 2; i < src.getRows(); i++) {
|
||||
String barCode = ExcelUtils.getContent(src, i, 0);
|
||||
String num = ExcelUtils.getContent(src, i, 2);
|
||||
String unitPrice = ExcelUtils.getContent(src, i, 3);
|
||||
String taxRate = ExcelUtils.getContent(src, i, 4);
|
||||
String remark = ExcelUtils.getContent(src, i, 5);
|
||||
String depotName = "", barCode = "", num = "", unitPrice = "", taxRate = "", remark = "";
|
||||
if("CGDD".equals(prefixNo) || "XSDD".equals(prefixNo)) {
|
||||
barCode = ExcelUtils.getContent(src, i, 0);
|
||||
num = ExcelUtils.getContent(src, i, 2);
|
||||
unitPrice = ExcelUtils.getContent(src, i, 3);
|
||||
taxRate = ExcelUtils.getContent(src, i, 4);
|
||||
remark = ExcelUtils.getContent(src, i, 5);
|
||||
}
|
||||
if("CGRK".equals(prefixNo) || "XSCK".equals(prefixNo)) {
|
||||
depotName = ExcelUtils.getContent(src, i, 0);
|
||||
barCode = ExcelUtils.getContent(src, i, 1);
|
||||
num = ExcelUtils.getContent(src, i, 3);
|
||||
unitPrice = ExcelUtils.getContent(src, i, 4);
|
||||
taxRate = ExcelUtils.getContent(src, i, 5);
|
||||
remark = ExcelUtils.getContent(src, i, 6);
|
||||
}
|
||||
if("QTRK".equals(prefixNo) || "QTCK".equals(prefixNo)) {
|
||||
depotName = ExcelUtils.getContent(src, i, 0);
|
||||
barCode = ExcelUtils.getContent(src, i, 1);
|
||||
num = ExcelUtils.getContent(src, i, 3);
|
||||
unitPrice = ExcelUtils.getContent(src, i, 4);
|
||||
remark = ExcelUtils.getContent(src, i, 5);
|
||||
}
|
||||
Map<String, String> materialMap = new HashMap<>();
|
||||
materialMap.put("depotName", depotName);
|
||||
materialMap.put("barCode", barCode);
|
||||
materialMap.put("num", num);
|
||||
materialMap.put("unitPrice", unitPrice);
|
||||
|
||||
@@ -1125,15 +1125,34 @@ public class DepotItemService {
|
||||
JSONArray arr = new JSONArray();
|
||||
List<MaterialVo4Unit> list = depotItemMapperEx.getBillItemByParam(barCodes);
|
||||
Map<String, MaterialVo4Unit> materialMap = new HashMap<>();
|
||||
Map<String, Long> depotMap = new HashMap<>();
|
||||
for (MaterialVo4Unit material: list) {
|
||||
materialMap.put(material.getmBarCode(), material);
|
||||
}
|
||||
JSONArray depotArr = depotService.findDepotByCurrentUser();
|
||||
for (Object depotObj: depotArr) {
|
||||
if(depotObj!=null) {
|
||||
JSONObject depotObject = JSONObject.parseObject(depotObj.toString());
|
||||
depotMap.put(depotObject.getString("depotName"), depotObject.getLong("id"));
|
||||
}
|
||||
}
|
||||
for (Map<String, String> detailMap: detailList) {
|
||||
JSONObject item = new JSONObject();
|
||||
String barCode = detailMap.get("barCode");
|
||||
if(StringUtil.isNotEmpty(barCode)) {
|
||||
MaterialVo4Unit m = materialMap.get(barCode);
|
||||
if(m!=null) {
|
||||
//判断仓库是否存在
|
||||
String depotName = detailMap.get("depotName");
|
||||
if(StringUtil.isNotEmpty(depotName)) {
|
||||
if(depotMap.get(depotName)!=null) {
|
||||
item.put("depotName", depotName);
|
||||
item.put("depotId", depotMap.get(depotName));
|
||||
} else {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_ITEM_DEPOTNAME_IS_NOT_EXIST_CODE,
|
||||
String.format(ExceptionConstants.DEPOT_ITEM_DEPOTNAME_IS_NOT_EXIST_MSG, depotName));
|
||||
}
|
||||
}
|
||||
item.put("barCode", barCode);
|
||||
item.put("name", m.getName());
|
||||
item.put("standard", m.getStandard());
|
||||
|
||||
Reference in New Issue
Block a user