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 79e792d..a85a980 100644 --- a/productionboard/src/main/java/com/productionboard/service/impl/BaseLocationServiceImpl.java +++ b/productionboard/src/main/java/com/productionboard/service/impl/BaseLocationServiceImpl.java @@ -44,16 +44,18 @@ public class BaseLocationServiceImpl implements IBaseLocationService { List baseLocationInfos = lcoationMapper.selectList(wrapper); Map> collect = baseLocationInfos.stream().collect(Collectors.groupingBy(BaseLocationInfo::getMaterialType)); - JSONObject jsonObject = new JSONObject(); - List xValue = new ArrayList<>(); - List yValue = new ArrayList<>(); + List result = new ArrayList<>(); + for (String item : collect.keySet()) { - xValue.add(item); - yValue.add(collect.get(item).size()+""); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("materialName",item); + jsonObject.put("lineStoreAmount",collect.get(item).stream().filter(x->x.getLocationArea().equals("1")).collect(Collectors.toList()).size()); + jsonObject.put("hullStoreAmount",collect.get(item).stream().filter(x->x.getLocationArea().equals("2")).collect(Collectors.toList()).size()); + result.add(jsonObject); } - jsonObject.put("xValue",xValue); - jsonObject.put("yValue",yValue); - return JSONArray.toJSONString(jsonObject); + String s = JSONArray.toJSONString(result); + System.out.println("物料库存统计:"+s); + return s; } @Override