合并商品的库存到商品列表接口一起查询
This commit is contained in:
@@ -152,77 +152,6 @@ public class DepotItemController {
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 只根据商品id查询库存数量
|
||||
* @param pageSize
|
||||
* @param currentPage
|
||||
* @param mId
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findStockNumByMaterialId")
|
||||
public String findStockNumByMaterialId(
|
||||
@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
|
||||
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
|
||||
@RequestParam("materialId") String mId,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
HttpServletRequest request) throws Exception{
|
||||
Map<String, String> parameterMap = ParamUtils.requestToMap(request);
|
||||
parameterMap.put("mId", mId);
|
||||
parameterMap.put("monthTime", monthTime);
|
||||
PageQueryInfo queryInfo = new PageQueryInfo();
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
if (pageSize != null && pageSize <= 0) {
|
||||
pageSize = 10;
|
||||
}
|
||||
String offset = ParamUtils.getPageOffset(currentPage, pageSize);
|
||||
if (StringUtil.isNotEmpty(offset)) {
|
||||
parameterMap.put(Constants.OFFSET, offset);
|
||||
}
|
||||
List<DepotItemVo4Material> list = depotItemService.findStockNumByMaterialIdList(parameterMap);
|
||||
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != list) {
|
||||
for (DepotItemVo4Material di : list) {
|
||||
JSONObject item = new JSONObject();
|
||||
int InSum = sumNumberByMaterialId("入库", di.getMaterialid());
|
||||
int OutSum = sumNumberByMaterialId("出库", di.getMaterialid());
|
||||
item.put("MaterialId", di.getMaterialid() == null ? "" : di.getMaterialid());
|
||||
item.put("MaterialName", di.getMname());
|
||||
item.put("MaterialModel", di.getMmodel());
|
||||
item.put("thisSum", InSum - OutSum);
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
objectMap.put("page", dataArray);
|
||||
if (list == null) {
|
||||
queryInfo.setRows(new ArrayList<Object>());
|
||||
queryInfo.setTotal(BusinessConstants.DEFAULT_LIST_NULL_NUMBER);
|
||||
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
|
||||
}
|
||||
queryInfo.setRows(list);
|
||||
queryInfo.setTotal(depotItemService.findStockNumByMaterialIdCounts(parameterMap));
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅根据商品Id进行数量合计
|
||||
*
|
||||
* @param type
|
||||
* @param mId
|
||||
* @return
|
||||
*/
|
||||
public int sumNumberByMaterialId(String type, Long mId)throws Exception {
|
||||
int allNumber = 0;
|
||||
try {
|
||||
allNumber = depotItemService.findByTypeAndMaterialId(type, mId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return allNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存明细
|
||||
* @param inserted
|
||||
|
||||
Reference in New Issue
Block a user