From d41bbf67342f6d4966fbdb04558dfd8b0ed1b31c Mon Sep 17 00:00:00 2001 From: erdanergou Date: Fri, 7 Jul 2023 16:01:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E7=89=A9=E6=96=99=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=87=BA=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DepositoryRecordController.java | 29 +- .../service/DepositoryRecordService.java | 2 +- .../impl/DepositoryRecordServiceImpl.java | 34 +- .../pages/depository/Inventory-view_back.html | 297 ++++++++++-------- .../LineChartForInventoryTest.java | 22 +- 5 files changed, 232 insertions(+), 152 deletions(-) diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java index 1b53eb8e..d627dfa0 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java @@ -2316,21 +2316,28 @@ public class DepositoryRecordController { // 获取至今的日期时间戳 List dayTimeSpaces = ObjectFormatUtil.objToList(monthBeginToNow.get("dayTimeSpace"), Long.class); // 获取当前物料的入库总额与数量 - Map> resultForApplicationIn = depositoryRecordService.getApplicationByMaterial(id, dayTimeSpaces, 1); - List amountListForIn = resultForApplicationIn.get("amountList"); - List countListForIn = resultForApplicationIn.get("countList"); + Map seriesForApplicationIn = depositoryRecordService.getApplicationByMaterial(id, dayTimeSpaces, 1); + Object amountItemForIn = seriesForApplicationIn.get("amountItem"); + Object countItemForIn = seriesForApplicationIn.get("countItem"); // 获取当前物料的出库总额与数量 - Map> resultForApplicationOut = depositoryRecordService.getApplicationByMaterial(id, dayTimeSpaces, 2); - List amountListForOut = resultForApplicationOut.get("amountList"); - List countListForOut = resultForApplicationOut.get("countList"); + Map seriesForApplicationOut = depositoryRecordService.getApplicationByMaterial(id, dayTimeSpaces, 2); + Object amountItemForOut = seriesForApplicationOut.get("amountItem"); + Object countItemForOut = seriesForApplicationOut.get("countItem"); Map result = new HashMap<>(); - result.put("applicationInAmount", amountListForIn); - result.put("applicationInCount", countListForIn); - result.put("applicationOutAmount", amountListForOut); - result.put("applicationOutCount", countListForOut); - result.put("dayNames", dayNames); + result.put("amountItemForIn",amountItemForIn); + result.put("countItemForIn",countItemForIn); + result.put("amountItemForOut",amountItemForOut); + result.put("countItemForOut",countItemForOut); + Map> legendItem = new HashMap<>(); + List legends = new ArrayList<>(); + legends.add("count"); + legends.add("amount"); + legendItem.put("data",legends); + result.put("legend",legendItem); + result.put("dayNames",dayNames); + return new RestResponse(result); } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java b/src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java index aaf6efb2..936be8a6 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java @@ -487,7 +487,7 @@ public interface DepositoryRecordService { * @param type 查询类型 1入库2出库 * @return */ - Map> getApplicationByMaterial(Integer id, List days,Integer type); + Map getApplicationByMaterial(Integer id, List days,Integer type); diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java index 11e5dc81..1f133b04 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java @@ -2074,13 +2074,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { * @return */ @Override - public Map> getApplicationByMaterial(Integer id, List days, Integer type) { + public Map getApplicationByMaterial(Integer id, List days, Integer type) { // 声明结果集 - Map> result = new HashMap<>(); + Map result = new HashMap<>(); // 声明总数列表 - List countList = new ArrayList<>(); + List countList = new ArrayList<>(); // 声明总额列表 - List amountList = new ArrayList<>(); + List amountList = new ArrayList<>(); // 获取对应物料 Inventory inventoryById = materialMapper.findInventoryById(id); // 声明用于查询的map @@ -2117,8 +2117,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { countList.add(countProcessed); amountList.add(amount); } - result.put("amountList", amountList); - result.put("countList", countList); + Map amountItem = createStackedAreaChartSeriesItem("amount", amountList); + Map countItem = createStackedAreaChartSeriesItem("count", countList); + result.put("amountItem",amountItem); + result.put("countItem",countItem); return result; } @@ -5618,6 +5620,26 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { return null; } + /** + * 用于构造堆叠面积图的series项目 + * @param name 当前项目名称 + * @param data 数据 + * @return + */ + public Map createStackedAreaChartSeriesItem(String name, List data) { + Map result = new HashMap<>(); + result.put("name", name); + result.put("type", "line"); + result.put("stack", "Total"); + Map areaStyle = new HashMap<>(); + result.put("areaStyle", areaStyle); + Map emphasis = new HashMap<>(); + emphasis.put("focus", "series"); + result.put("emphasis", emphasis); + result.put("data", data); + return result; + } + /** * 用于计算当前主记录下的总额与数量 */ diff --git a/src/main/resources/templates/pages/depository/Inventory-view_back.html b/src/main/resources/templates/pages/depository/Inventory-view_back.html index 35ffddfe..ee323606 100644 --- a/src/main/resources/templates/pages/depository/Inventory-view_back.html +++ b/src/main/resources/templates/pages/depository/Inventory-view_back.html @@ -20,142 +20,156 @@ } + .myEchart { + min-width: 500px; + min-height: 500px; + margin: 0 2px; + } + -
-
-
-
-
物料基本信息 - -
-
- - - - - - - - - - - - - - - - - - -
物料编码:物料名称:规格型号:物料材质:
物料品牌:物料类型: - 计量单位: - - - 物料单价:
物料备注:
-
-
-
-
-
-
-
-
库存基本信息
-
- - - - - - - - - - - - - - - - - - - - - - - -
所属仓库:备注:
所处库位计量单位对应数量金额操作
- - - - - - - - - - 入库 - 出库 -
-
-
-
-
-
-
-
-
-
物料入库明细
+
+
+
+
+
+
物料基本信息 + +
-
-
+ + + + + + + + + + + + + + + + + + +
物料编码:物料名称:规格型号:物料材质:
物料品牌:物料类型: + 计量单位: + + + 物料单价:
物料备注:
-
-
-
物料出库明细
+
+
+
数据图标 +
+
+
+
物料入库明细
+
+
+
+
+
+
+
+
+
物料出库明细
+
+
+
+
+
+
+
+
+
物料库存明细
+
+
+
+
-
-
-
物料库存明细
+
+
+
+
+
库存基本信息
+ + + + + + + + + + + + + + + + + + + + + + + +
所属仓库:备注:
所处库位计量单位对应数量金额操作
+ + + + + + + + + + 入库 + 出库 +
- @@ -349,8 +363,9 @@ // 柱状图 - var echartLineChart = echarts.init(document.getElementById('echarts-line')); - var optionLineChart = { + var echartLineChartIn = echarts.init(document.getElementById('echarts-line-in')); + var echartLineChartOut = echarts.init(document.getElementById('echarts-line-out')); + var optionLineChartIn = { xAxis: { type: 'category', boundaryGap: false, @@ -359,8 +374,23 @@ yAxis: { type: 'value' }, - tooltip:{ - trigger:"axis", + tooltip: { + trigger: "axis", + }, + series: [] + + }; + var optionLineChartOut = { + xAxis: { + type: 'category', + boundaryGap: false, + data: [] + }, + yAxis: { + type: 'value' + }, + tooltip: { + trigger: "axis", }, series: [] @@ -371,7 +401,7 @@ type: 'post', async: true, dataType: "json", - data:JSON.stringify({"id":id}), + data: JSON.stringify({"id": id}), contentType: "application/json;charset=utf-8", complete: function (XHR, TS) { layer.close(this.layerIndex); @@ -383,13 +413,32 @@ this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); }, success: function (result) { - console.log(result); + let data = result.data; + let dayNames = data["dayNames"]; + let amountItemForIn = data["amountItemForIn"]; + let countItemForIn = data["countItemForIn"]; + let amountItemForOut = data["amountItemForOut"]; + let countItemForOut = data["countItemForOut"]; + let legendItem = data["legend"]; + let seriesInItem = []; + let seriesOutItem = []; + seriesInItem.push(amountItemForIn); + seriesInItem.push(countItemForIn); + seriesOutItem.push(amountItemForOut); + seriesOutItem.push(countItemForOut); + optionLineChartIn.series = seriesInItem; + optionLineChartOut.series = seriesOutItem; + + optionLineChartIn.xAxis.data = dayNames; + optionLineChartIn.legend = legendItem; + optionLineChartOut.legend = legendItem; + optionLineChartOut.xAxis.data = dayNames; + echartLineChartIn.setOption(optionLineChartIn); + echartLineChartOut.setOption(optionLineChartOut); } }) - - }); diff --git a/src/test/java/com/dreamchaser/depository_manage/LineChartForInventoryTest.java b/src/test/java/com/dreamchaser/depository_manage/LineChartForInventoryTest.java index fbe83b92..1f46e23a 100644 --- a/src/test/java/com/dreamchaser/depository_manage/LineChartForInventoryTest.java +++ b/src/test/java/com/dreamchaser/depository_manage/LineChartForInventoryTest.java @@ -42,20 +42,22 @@ public class LineChartForInventoryTest { // 获取至今的日期时间戳 List dayTimeSpaces = ObjectFormatUtil.objToList(monthBeginToNow.get("dayTimeSpace"), Long.class); // 获取当前物料的入库总额与数量 - Map> resultForApplicationIn = depositoryRecordService.getApplicationByMaterial(id, dayTimeSpaces, 1); - List amountListForIn = resultForApplicationIn.get("amountList"); - List countListForIn = resultForApplicationIn.get("countList"); + Map seriesForApplicationIn = depositoryRecordService.getApplicationByMaterial(id, dayTimeSpaces, 1); + Object amountItemForIn = seriesForApplicationIn.get("amountItem"); + Object countItemForIn = seriesForApplicationIn.get("countItem"); // 获取当前物料的出库总额与数量 - Map> resultForApplicationOut = depositoryRecordService.getApplicationByMaterial(id, dayTimeSpaces, 2); - List amountListForOut = resultForApplicationOut.get("amountList"); - List countListForOut = resultForApplicationOut.get("countList"); + Map seriesForApplicationOut = depositoryRecordService.getApplicationByMaterial(id, dayTimeSpaces, 2); + Object amountItemForOut = seriesForApplicationOut.get("amountItem"); + Object countItemForOut = seriesForApplicationOut.get("countItem"); Map result = new HashMap<>(); - result.put("applicationInAmount", amountListForIn); - result.put("applicationInCount", countListForIn); - result.put("applicationOutAmount", amountListForOut); - result.put("applicationOutCount", countListForOut); + result.put("amountItemForIn",amountItemForIn); + result.put("countItemForIn",countItemForIn); + result.put("amountItemForOut",amountItemForOut); + result.put("countItemForOut",countItemForOut); + result.put("dayNames",dayNames); + return new RestResponse(result); }