优化单据明细导入接口的逻辑
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 int DEPOT_ITEM_BARCODE_IS_NOT_EXIST_CODE = 9000003;
|
||||||
public static final String DEPOT_ITEM_BARCODE_IS_NOT_EXIST_MSG = "抱歉,商品条码:%s在商品管理中不存在";
|
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 {
|
} else {
|
||||||
List<Map<String, String>> detailList = new ArrayList<>();
|
List<Map<String, String>> detailList = new ArrayList<>();
|
||||||
for (int i = 2; i < src.getRows(); i++) {
|
for (int i = 2; i < src.getRows(); i++) {
|
||||||
String barCode = ExcelUtils.getContent(src, i, 0);
|
String depotName = "", barCode = "", num = "", unitPrice = "", taxRate = "", remark = "";
|
||||||
String num = ExcelUtils.getContent(src, i, 2);
|
if("CGDD".equals(prefixNo) || "XSDD".equals(prefixNo)) {
|
||||||
String unitPrice = ExcelUtils.getContent(src, i, 3);
|
barCode = ExcelUtils.getContent(src, i, 0);
|
||||||
String taxRate = ExcelUtils.getContent(src, i, 4);
|
num = ExcelUtils.getContent(src, i, 2);
|
||||||
String remark = ExcelUtils.getContent(src, i, 5);
|
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<>();
|
Map<String, String> materialMap = new HashMap<>();
|
||||||
|
materialMap.put("depotName", depotName);
|
||||||
materialMap.put("barCode", barCode);
|
materialMap.put("barCode", barCode);
|
||||||
materialMap.put("num", num);
|
materialMap.put("num", num);
|
||||||
materialMap.put("unitPrice", unitPrice);
|
materialMap.put("unitPrice", unitPrice);
|
||||||
|
|||||||
@@ -1125,15 +1125,34 @@ public class DepotItemService {
|
|||||||
JSONArray arr = new JSONArray();
|
JSONArray arr = new JSONArray();
|
||||||
List<MaterialVo4Unit> list = depotItemMapperEx.getBillItemByParam(barCodes);
|
List<MaterialVo4Unit> list = depotItemMapperEx.getBillItemByParam(barCodes);
|
||||||
Map<String, MaterialVo4Unit> materialMap = new HashMap<>();
|
Map<String, MaterialVo4Unit> materialMap = new HashMap<>();
|
||||||
|
Map<String, Long> depotMap = new HashMap<>();
|
||||||
for (MaterialVo4Unit material: list) {
|
for (MaterialVo4Unit material: list) {
|
||||||
materialMap.put(material.getmBarCode(), material);
|
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) {
|
for (Map<String, String> detailMap: detailList) {
|
||||||
JSONObject item = new JSONObject();
|
JSONObject item = new JSONObject();
|
||||||
String barCode = detailMap.get("barCode");
|
String barCode = detailMap.get("barCode");
|
||||||
if(StringUtil.isNotEmpty(barCode)) {
|
if(StringUtil.isNotEmpty(barCode)) {
|
||||||
MaterialVo4Unit m = materialMap.get(barCode);
|
MaterialVo4Unit m = materialMap.get(barCode);
|
||||||
if(m!=null) {
|
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("barCode", barCode);
|
||||||
item.put("name", m.getName());
|
item.put("name", m.getName());
|
||||||
item.put("standard", m.getStandard());
|
item.put("standard", m.getStandard());
|
||||||
|
|||||||
Reference in New Issue
Block a user