From 4b5fd908d86303738df19ab2d35b552071d13af0 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期四, 22 八月 2024 08:36:24 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java | 123 ++++++++++++++++++++++++++++++++++------ 1 files changed, 104 insertions(+), 19 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java index 08ea83e..596eeea 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java @@ -11,8 +11,9 @@ import org.springframework.stereotype.Service; import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.time.LocalDate; -import java.time.LocalDateTime; import java.util.Calendar; import java.util.List; import java.util.Map; @@ -39,6 +40,8 @@ @Autowired private RmIntakeAmountDayMapper rmIntakeAmountDayMapper; + @Autowired + private RmLossDayLastMapper rmLossDayLastMapper; @Value("${rtu.batteryVolt}") private Double batteryVolt; @@ -191,7 +194,7 @@ if(timeStart != null && timeStart != "") { timeStart = timeStart + " 00:00:00"; } else { - timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); + timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); @@ -230,7 +233,7 @@ if(timeStart != null && timeStart != "") { timeStart = timeStart + " 00:00:00"; } else { - timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); + timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); @@ -269,7 +272,7 @@ if(timeStart != null && timeStart != "") { timeStart = timeStart + " 00:00:00"; } else { - timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); + timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); @@ -427,7 +430,7 @@ if(timeStart != null && timeStart != "") { timeStart = timeStart + " 00:00:00"; } else { - timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); + timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); @@ -455,7 +458,6 @@ return rsVo ; } - /** * 鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忚秴杩囨寚瀹氬�肩殑鍙栨按鍙� * @param qo @@ -467,7 +469,7 @@ if(timeStart != null && timeStart != "") { timeStart = timeStart + " 00:00:00"; } else { - timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); + timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); @@ -482,7 +484,6 @@ qo.setValue(0.0); } - Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); Long itemTotal = rmOpenCloseValveHistoryMapper.getUseWaterGtValueIntakesCount(params); @@ -495,8 +496,6 @@ return rsVo ; } - - /** * 鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙� * @param qo @@ -508,7 +507,7 @@ if(timeStart != null && timeStart != "") { timeStart = timeStart + " 00:00:00"; } else { - timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); + timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); @@ -535,7 +534,6 @@ return rsVo ; } - /** * 鎸囧畾鏃堕棿娈靛唴鐢ㄦ按鏃堕暱瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙� * @param qo @@ -547,7 +545,7 @@ if(timeStart != null && timeStart != "") { timeStart = timeStart + " 00:00:00"; } else { - timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); + timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); @@ -582,7 +580,7 @@ if(timeStart != null && timeStart != "") { timeStart = timeStart + " 00:00:00"; } else { - timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); + timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); @@ -617,7 +615,7 @@ if(timeStart != null && timeStart != "") { timeStart = timeStart + " 00:00:00"; } else { - timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); + timeStart = LocalDate.now() + " 00:00:00"; } qo.setTimeStart(timeStart); @@ -646,10 +644,14 @@ * @param qo * @return */ - public QueryResultVo<List<VoDayIntakeAmount>> getDayIntakeAmount(DayIntakeAmountQO qo) { - Calendar calendar = Calendar.getInstance(); - Integer year = Optional.ofNullable(qo.getYear()).orElse(calendar.get(Calendar.YEAR)); - Integer month = Optional.ofNullable(qo.getMonth()).orElse(calendar.get(Calendar.MONTH)); + public QueryResultVo<List<VoDayIntakeAmount>> getDayIntakeAmount(IntakeAmountQO qo) throws ParseException { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String yearMonth = qo.getYearMonth(); + yearMonth = yearMonth + "-01"; + yearMonth = dateFormat.format(dateFormat.parse(yearMonth)); + + Integer year = Integer.parseInt(yearMonth.substring(0,4)); + Integer month = Integer.parseInt(yearMonth.substring(5,7)); qo.setYear(year); qo.setMonth(month); @@ -668,4 +670,87 @@ rsVo.obj = rmIntakeAmountDayMapper.getDayIntakeAmount(params); return rsVo ; } + + /** + * 缁熻鎸囧畾骞翠唤鍚勬湀鐢ㄦ按閲� + * @param qo + * @return + */ + public QueryResultVo<List<VoMonthAmount>> getMonthIntakeAmount(IntakeAmountQO qo) { + Calendar calendar = Calendar.getInstance(); + Integer year = Optional.ofNullable(qo.getYear()).orElse(calendar.get(Calendar.YEAR)); + qo.setYear(year); + + // 鐢熸垚鏌ヨ鍙傛暟 + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; + + // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟 + Long itemTotal = Optional.ofNullable(rmIntakeAmountDayMapper.getMonthIntakeAmountCount(params)).orElse(0L); + + QueryResultVo<List<VoMonthAmount>> rsVo = new QueryResultVo<>() ; + + rsVo.pageSize = qo.pageSize ; + rsVo.pageCurr = qo.pageCurr ; + + rsVo.calculateAndSet(itemTotal, params); + rsVo.obj = rmIntakeAmountDayMapper.getMonthIntakeAmount(params); + return rsVo ; + } + + /** + * 缁熻鎸囧畾鏈堜唤鍚勫ぉ婕忔崯閲� + * @param qo + * @return + */ + public QueryResultVo<List<VoDayLoss>> getDayLossAmount(IntakeAmountQO qo) throws ParseException { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String yearMonth = qo.getYearMonth(); + yearMonth = yearMonth + "-01"; + yearMonth = dateFormat.format(dateFormat.parse(yearMonth)); + Integer year = Integer.parseInt(yearMonth.substring(0,4)); + Integer month = Integer.parseInt(yearMonth.substring(5,7)); + qo.setYear(year); + qo.setMonth(month); + + // 鐢熸垚鏌ヨ鍙傛暟 + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; + + // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟 + Long itemTotal = Optional.ofNullable(rmLossDayLastMapper.getDayLossAmountCount(params)).orElse(0L); + + QueryResultVo<List<VoDayLoss>> rsVo = new QueryResultVo<>() ; + + rsVo.pageSize = qo.pageSize ; + rsVo.pageCurr = qo.pageCurr ; + + rsVo.calculateAndSet(itemTotal, params); + rsVo.obj = rmLossDayLastMapper.getDayLossAmount(params); + return rsVo ; + } + + /** + * 缁熻鎸囧畾骞翠唤鍚勬湀婕忔崯閲� + * @param qo + * @return + */ + public QueryResultVo<List<VoMonthAmount>> getMonthLossAmount(IntakeAmountQO qo) { + Calendar calendar = Calendar.getInstance(); + Integer year = Optional.ofNullable(qo.getYear()).orElse(calendar.get(Calendar.YEAR)); + qo.setYear(year); + + // 鐢熸垚鏌ヨ鍙傛暟 + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; + + // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟 + Long itemTotal = Optional.ofNullable(rmLossDayLastMapper.getMonthLossAmountCount(params)).orElse(0L); + + QueryResultVo<List<VoMonthAmount>> rsVo = new QueryResultVo<>() ; + + rsVo.pageSize = qo.pageSize ; + rsVo.pageCurr = qo.pageCurr ; + + rsVo.calculateAndSet(itemTotal, params); + rsVo.obj = rmLossDayLastMapper.getMonthLossAmount(params); + return rsVo ; + } } -- Gitblit v1.8.0