From d9be5dfb2c89a38c9cbc3854b0720f0f8fac51fe Mon Sep 17 00:00:00 2001 From: wenjy Date: Sun, 12 Jun 2022 14:45:09 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E9=97=A8=E4=BD=93=E5=BA=93?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/BaseLocationServiceImpl.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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