diff --git a/productionboard/src/main/java/com/productionboard/controller/StorageController.java b/productionboard/src/main/java/com/productionboard/controller/StorageController.java index 3f8b8ad..53224af 100644 --- a/productionboard/src/main/java/com/productionboard/controller/StorageController.java +++ b/productionboard/src/main/java/com/productionboard/controller/StorageController.java @@ -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; } /** diff --git a/productionboard/src/main/java/com/productionboard/service/impl/BaseLocationServiceImpl.java b/productionboard/src/main/java/com/productionboard/service/impl/BaseLocationServiceImpl.java index 0f075bf..e85c63a 100644 --- a/productionboard/src/main/java/com/productionboard/service/impl/BaseLocationServiceImpl.java +++ b/productionboard/src/main/java/com/productionboard/service/impl/BaseLocationServiceImpl.java @@ -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 baseLocationInfos = lcoationMapper.selectList(wrapper); - - return JSONArray.toJSONString(baseLocationInfos); + Map> collect = baseLocationInfos.stream().collect(Collectors.groupingBy(BaseLocationInfo::getMaterialType)); + JSONObject jsonObject = new JSONObject(); + List xValue = new ArrayList<>(); + List 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 diff --git a/productionboard/target/classes/com/productionboard/common/CodeGenerator.class b/productionboard/target/classes/com/productionboard/common/CodeGenerator.class deleted file mode 100644 index 0c43d3e..0000000 Binary files a/productionboard/target/classes/com/productionboard/common/CodeGenerator.class and /dev/null differ diff --git a/productionboard/target/classes/com/productionboard/controller/StorageController.class b/productionboard/target/classes/com/productionboard/controller/StorageController.class deleted file mode 100644 index 9db6972..0000000 Binary files a/productionboard/target/classes/com/productionboard/controller/StorageController.class and /dev/null differ