优化根据条码查询商品信息接口,增加仓库参数
This commit is contained in:
@@ -494,6 +494,7 @@ public class MaterialController {
|
|||||||
@GetMapping(value = "/getMaterialByBarCode")
|
@GetMapping(value = "/getMaterialByBarCode")
|
||||||
@ApiOperation(value = "根据条码查询商品信息")
|
@ApiOperation(value = "根据条码查询商品信息")
|
||||||
public BaseResponseInfo getMaterialByBarCode(@RequestParam("barCode") String barCode,
|
public BaseResponseInfo getMaterialByBarCode(@RequestParam("barCode") String barCode,
|
||||||
|
@RequestParam(value = "depotId", required = false) Long depotId,
|
||||||
@RequestParam("mpList") String mpList,
|
@RequestParam("mpList") String mpList,
|
||||||
@RequestParam(required = false, value = "prefixNo") String prefixNo,
|
@RequestParam(required = false, value = "prefixNo") String prefixNo,
|
||||||
HttpServletRequest request) throws Exception {
|
HttpServletRequest request) throws Exception {
|
||||||
@@ -532,18 +533,44 @@ public class MaterialController {
|
|||||||
mvo.setBillPrice(mvo.getWholesaleDecimal());
|
mvo.setBillPrice(mvo.getWholesaleDecimal());
|
||||||
}
|
}
|
||||||
//仓库id
|
//仓库id
|
||||||
|
if (depotId == null) {
|
||||||
JSONArray depotArr = depotService.findDepotByCurrentUser();
|
JSONArray depotArr = depotService.findDepotByCurrentUser();
|
||||||
for (Object obj : depotArr) {
|
for (Object obj : depotArr) {
|
||||||
JSONObject depotObj = JSONObject.parseObject(obj.toString());
|
JSONObject depotObj = JSONObject.parseObject(obj.toString());
|
||||||
if (depotObj.get("isDefault") != null) {
|
if (depotObj.get("isDefault") != null) {
|
||||||
Boolean isDefault = depotObj.getBoolean("isDefault");
|
Boolean isDefault = depotObj.getBoolean("isDefault");
|
||||||
if (isDefault) {
|
if (isDefault) {
|
||||||
Long depotId = depotObj.getLong("id");
|
Long id = depotObj.getLong("id");
|
||||||
if (!"CGDD".equals(prefixNo) && !"XSDD".equals(prefixNo)) {
|
if (!"CGDD".equals(prefixNo) && !"XSDD".equals(prefixNo)) {
|
||||||
//除订单之外的单据才有仓库
|
//除订单之外的单据才有仓库
|
||||||
mvo.setDepotId(depotId);
|
mvo.setDepotId(id);
|
||||||
}
|
}
|
||||||
//库存
|
getStockByMaterialInfo(mvo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mvo.setDepotId(depotId);
|
||||||
|
getStockByMaterialInfo(mvo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.code = 200;
|
||||||
|
res.data = list;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品信息获取库存,进行赋值
|
||||||
|
* @param mvo
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void getStockByMaterialInfo(MaterialVo4Unit mvo) throws Exception {
|
||||||
BigDecimal stock;
|
BigDecimal stock;
|
||||||
if (StringUtil.isNotEmpty(mvo.getSku())) {
|
if (StringUtil.isNotEmpty(mvo.getSku())) {
|
||||||
stock = depotItemService.getSkuStockByParam(mvo.getDepotId(), mvo.getMeId(), null, null);
|
stock = depotItemService.getSkuStockByParam(mvo.getDepotId(), mvo.getMeId(), null, null);
|
||||||
@@ -560,19 +587,6 @@ public class MaterialController {
|
|||||||
}
|
}
|
||||||
mvo.setStock(stock);
|
mvo.setStock(stock);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res.code = 200;
|
|
||||||
res.data = list;
|
|
||||||
} catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
res.code = 500;
|
|
||||||
res.data = "获取数据失败";
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品库存查询
|
* 商品库存查询
|
||||||
|
|||||||
Reference in New Issue
Block a user