change - 当前库存接口

master
wenjy 2 years ago
parent 59a5a46b5e
commit 83315b2714

@ -1,5 +1,7 @@
package com.productionboard.controller;
import com.productionboard.service.IBaseLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
@ -15,6 +17,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/storage")
public class StorageController {
@Autowired
private IBaseLocationService locationService;
private String prefix = "storage/index";
/**
@ -103,8 +109,8 @@ public class StorageController {
@GetMapping("/getStoreStatistics")
@ResponseBody
public String getStoreStatistics(String ids){
return null;
String storeStatistics = locationService.getStoreStatistics(ids);
return storeStatistics;
}
/**

@ -1,6 +1,7 @@
package com.productionboard.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.productionboard.entity.BaseLocationInfo;
import com.productionboard.mapper.BaseLocationInfoMapper;
@ -8,7 +9,10 @@ import com.productionboard.service.IBaseLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author WenJY
@ -35,8 +39,17 @@ public class BaseLocationServiceImpl implements IBaseLocationService {
}
List<BaseLocationInfo> baseLocationInfos = lcoationMapper.selectList(wrapper);
return JSONArray.toJSONString(baseLocationInfos);
Map<String, List<BaseLocationInfo>> collect = baseLocationInfos.stream().collect(Collectors.groupingBy(BaseLocationInfo::getMaterialType));
JSONObject jsonObject = new JSONObject();
List<String> xValue = new ArrayList<>();
List<String> yValue = new ArrayList<>();
for (String item : collect.keySet()) {
xValue.add(item);
yValue.add(collect.get(item).size()+"");
}
jsonObject.put("xValue",xValue);
jsonObject.put("yValue",yValue);
return JSONArray.toJSONString(jsonObject);
}
@Override

Loading…
Cancel
Save