优化根据条码查询商品信息接口,增加仓库参数

This commit is contained in:
季圣华
2021-11-23 00:09:28 +08:00
parent c1cfeadf17
commit 985396ba8a

View File

@@ -494,6 +494,7 @@ public class MaterialController {
@GetMapping(value = "/getMaterialByBarCode")
@ApiOperation(value = "根据条码查询商品信息")
public BaseResponseInfo getMaterialByBarCode(@RequestParam("barCode") String barCode,
@RequestParam(value = "depotId", required = false) Long depotId,
@RequestParam("mpList") String mpList,
@RequestParam(required = false, value = "prefixNo") String prefixNo,
HttpServletRequest request) throws Exception {
@@ -532,18 +533,44 @@ public class MaterialController {
mvo.setBillPrice(mvo.getWholesaleDecimal());
}
//仓库id
if (depotId == null) {
JSONArray depotArr = depotService.findDepotByCurrentUser();
for (Object obj : depotArr) {
JSONObject depotObj = JSONObject.parseObject(obj.toString());
if (depotObj.get("isDefault") != null) {
Boolean isDefault = depotObj.getBoolean("isDefault");
if (isDefault) {
Long depotId = depotObj.getLong("id");
Long id = depotObj.getLong("id");
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;
if (StringUtil.isNotEmpty(mvo.getSku())) {
stock = depotItemService.getSkuStockByParam(mvo.getDepotId(), mvo.getMeId(), null, null);
@@ -560,19 +587,6 @@ public class MaterialController {
}
mvo.setStock(stock);
}
}
}
}
}
res.code = 200;
res.data = list;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 商品库存查询