From 401b8a3d1cb9a6d19e3afc11684288df4df410cb Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 5 Jan 2021 23:22:20 +0800 Subject: [PATCH] =?UTF-8?q?monthindexanalysis/barchart=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/impl/IndexServiceImpl.java | 7 ++++++- .../com/epmet/datareport/utils/DateUtils.java | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java index 3e24cb7105..5fcc8ff795 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java @@ -149,7 +149,12 @@ public class IndexServiceImpl implements IndexService { }); List collect = monthBarchartResults.stream().sorted(Comparator.comparing(MonthBarchartResult::getMonthId)).collect(Collectors.toList()); //升序 当前月份在队尾 - List _ymList = dateUtils.getXpro().keySet().stream().collect(Collectors.toList()); + List _ymList = new ArrayList<>(); + if(StringUtils.isNotBlank(monthBarchartFormDTO.getMonthId())){ + _ymList=dateUtils.getXproEndMonth(monthBarchartFormDTO.getMonthId()).keySet().stream().collect(Collectors.toList()); + }else{ + _ymList=dateUtils.getXpro().keySet().stream().collect(Collectors.toList()); + } //针对集合collect的游标 int cursor = NumConstant.ZERO; //针对X轴,数据集合不全则进行数据填充 diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/DateUtils.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/DateUtils.java index b2d99c00f1..62356ad9f5 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/DateUtils.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/DateUtils.java @@ -75,6 +75,22 @@ public class DateUtils { return result; } + public Map getXproEndMonth(String monthId){ + Map xAxis = new HashMap<>(); + for(int i=NumConstant.ZERO;i <= NumConstant.ELEVEN; i++){ + Calendar c = Calendar.getInstance(); + c.setTime(com.epmet.commons.tools.utils.DateUtils.stringToDate(monthId.concat("01"), com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN_YYYYMMDD)); + c.add(Calendar.MONTH, - i); + Date date = c.getTime(); + String month= com.epmet.commons.tools.utils.DateUtils.format(date, com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN_YYYYMM); + xAxis.put(month,month.substring(4,6).concat("月")); + } + Map result = Maps.newLinkedHashMap(); + xAxis.entrySet().stream().sorted(Map.Entry.comparingByKey()) + .forEachOrdered((e -> result.put(e.getKey(),e.getValue()))); + return result; + } + /** * @Description 得到上个月的monthId * @param