change - 当前库存接口

master
wenjy 3 years ago
parent 59a5a46b5e
commit 83315b2714

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

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

Loading…
Cancel
Save