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