From b4c6816d3016e26d908c55d3a194d972b998e952 Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期三, 08 一月 2025 14:42:30 +0800 Subject: [PATCH] 优化接口 水卡使用情况(充值、消费、余额) --- pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java | 365 +++++++++++++++++++++++++++++++++++---------------- 1 files changed, 251 insertions(+), 114 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 515bfda..613d661 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 @@ -1,5 +1,6 @@ package com.dy.pipIrrStatistics.intake; +import com.dy.common.util.DateTime; import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.daoRm.*; import com.dy.pipIrrGlobal.voSt.*; @@ -11,8 +12,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 +41,8 @@ @Autowired private RmIntakeAmountDayMapper rmIntakeAmountDayMapper; + @Autowired + private RmLossDayLastMapper rmLossDayLastMapper; @Value("${rtu.batteryVolt}") private Double batteryVolt; @@ -61,13 +65,16 @@ */ String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); - if(timeStart != null) { - timeStart = timeStart + " 00:00:00"; - }else { - timeStart = LocalDate.now() + " 00:00:00"; - } + if(timeStop != null) { timeStop = timeStop + " 23:59:59"; + if(timeStart != null) { + timeStart = timeStart + " 00:00:00"; + }else { + timeStart = LocalDate.now() + " 00:00:00"; + } + }else { + timeStart = null; } qo.setTimeStart(timeStart); qo.setTimeStop(timeStop); @@ -88,7 +95,7 @@ return rsVo ; } - /** + /** ok 1 * 鑾峰彇绱娴侀噺瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙� * @param qo * @return @@ -110,7 +117,7 @@ return rsVo ; } - /** + /** ok 2 * 鑾峰彇绱娴侀噺浣庝簬鎸囧畾鍊肩殑鍙栨按鍙� * @param qo * @return @@ -191,7 +198,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 +237,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 +276,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); @@ -303,39 +310,47 @@ */ public VoCountOfOpenType getCountByOpenType(OpenTypeQO qo) { /** - * 琛ラ綈璧锋鏃堕棿锛屽鏋滃紑濮嬫椂闂翠负绌猴紝鍒欓粯璁や负褰撳墠鏃ユ湡 + * 琛ラ綈璧锋鏃堕棿锛屽鏋滃紑濮嬫椂闂翠负绌猴紝鍒欓粯璁や负褰撳墠鏃ユ湡锛屽鏋滅粨鏉熸椂闂翠负绌猴紝鍒欐煡璇㈡椂闂翠负绌� */ String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); - if(timeStart != null) { - timeStart = timeStart + " 00:00:00"; - }else { - timeStart = LocalDate.now() + " 00:00:00"; - } if(timeStop != null) { timeStop = timeStop + " 23:59:59"; + if(timeStart != null) { + timeStart = timeStart + " 00:00:00"; + }else { + timeStart = LocalDate.now() + " 00:00:00"; + } + }else { + timeStart = null; } qo.setTimeStart(timeStart); qo.setTimeStop(timeStop); Integer openType = qo.getOpenType(); String openTypeName = ""; - switch (openType) { - case 1: - openTypeName = "鍒峰崱寮�闃�"; - break; - case 3: - openTypeName = "涓績绔欏紑闃�"; - break; - case 8: - openTypeName = "鐢ㄦ埛杩滅▼寮�闃�"; - break; - case 11: - openTypeName = "寮�鍏抽榾鍗″紑闃�"; - break; - case 13: - openTypeName = "寮�鍏抽榾鍗″紑闃�"; - break; + if (openType == null){ + openTypeName = "涓嶇煡閬撴偍瑕佹煡閭g寮�闃�绫诲瀷"; + }else { + switch (openType) { + case 1: + openTypeName = "鍒峰崱寮�闃�"; + break; + case 3: + openTypeName = "涓績绔欏紑闃�"; + break; + case 8: + openTypeName = "鐢ㄦ埛杩滅▼寮�闃�"; + break; + case 11: + openTypeName = "宸℃鍗″紑闃�"; + break; + case 13: + openTypeName = "宸℃鍗″紑闃�"; + break; + default: + openTypeName = "涓嶇煡閬撴偍瑕佹煡閭g寮�闃�绫诲瀷"; + } } // 鐢熸垚鏌ヨ鍙傛暟 @@ -360,52 +375,59 @@ */ String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); - if(timeStart != null) { - timeStart = timeStart + " 00:00:00"; - }else { - timeStart = LocalDate.now() + " 00:00:00"; - } if(timeStop != null) { timeStop = timeStop + " 23:59:59"; + if(timeStart != null) { + timeStart = timeStart + " 00:00:00"; + }else { + timeStart = LocalDate.now() + " 00:00:00"; + } + }else { + timeStart = null; } qo.setTimeStart(timeStart); qo.setTimeStop(timeStop); Integer closeType = qo.getCloseType(); String closeTypeName = ""; - switch (closeType) { - case 2: - closeTypeName = "鍒峰崱鍏抽榾"; - break; - case 4: - closeTypeName = "涓績绔欏叧闃�"; - break; - case 5: - closeTypeName = "娆犺垂鍏抽榾"; - break; - case 6: - closeTypeName = "娴侀噺璁℃晠闅滃叧闃�"; - break; - case 7: - closeTypeName = "绱ф�ュ叧闃�"; - break; - case 9: - closeTypeName = "鐢ㄦ埛杩滅▼鍏抽榾"; - break; - case 10: - closeTypeName = "寮�鍏抽榾鍗″叧闃�"; - break; - case 12: - closeTypeName = "榛戝悕鍗曞懡浠ゅ叧闃�"; - break; - case 13: - closeTypeName = "杩滅▼瀹氭椂鍏抽榾"; - break; - case 14: - closeTypeName = "杩滅▼瀹氶噺鍏抽榾"; - break; + if (closeType == null){ + closeTypeName = "涓嶇煡閬撴偍瑕佹煡閭g鍏抽榾绫诲瀷"; + }else { + switch (closeType) { + case 2: + closeTypeName = "鍒峰崱鍏抽榾"; + break; + case 4: + closeTypeName = "涓績绔欏叧闃�"; + break; + case 5: + closeTypeName = "娆犺垂鍏抽榾"; + break; + case 6: + closeTypeName = "娴侀噺璁℃晠闅滃叧闃�"; + break; + case 7: + closeTypeName = "绱ф�ュ叧闃�"; + break; + case 9: + closeTypeName = "鐢ㄦ埛杩滅▼鍏抽榾"; + break; + case 10: + closeTypeName = "宸℃鍗″叧闃�"; + break; + case 12: + closeTypeName = "榛戝悕鍗曞懡浠ゅ叧闃�"; + break; + case 13: + closeTypeName = "杩滅▼瀹氭椂鍏抽榾"; + break; + case 14: + closeTypeName = "杩滅▼瀹氶噺鍏抽榾"; + break; + default: + closeTypeName = "涓嶇煡閬撴偍瑕佹煡閭g鍏抽榾绫诲瀷"; + } } - // 鐢熸垚鏌ヨ鍙傛暟 Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; Integer closeTypeCount = Optional.ofNullable(rmOpenCloseValveLastMapper.getCountByCloseType(params)).orElse(0); @@ -427,7 +449,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,8 +477,7 @@ return rsVo ; } - - /** + /** ok 3 * 鎸囧畾鏃堕棿娈靛唴鐢ㄦ按閲忚秴杩囨寚瀹氬�肩殑鍙栨按鍙� * @param qo * @return @@ -464,40 +485,31 @@ public QueryResultVo<List<VoIntakeAccumulateAmount>> getUseWaterGtValueIntakes(IntakeAmountValueQO qo) { String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); - if(timeStart != null && timeStart != "") { - timeStart = timeStart + " 00:00:00"; - } else { - timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); + if(timeStart == null || timeStart.trim().equals("")) { + timeStart = DateTime.yyyy_MM_dd() ; + qo.setTimeStart(timeStart); } - qo.setTimeStart(timeStart); - - if(timeStop != null && timeStop != "") { - timeStop = timeStop + " 23:59:59"; - }else { - timeStop = LocalDate.now() + " 23:59:59"; + if(timeStop == null || timeStop.trim().equals("")) { + timeStop = DateTime.yyyy_MM_dd() ; + qo.setTimeStop(timeStop); } - qo.setTimeStop(timeStop); - if (qo.getValue() == null){ qo.setValue(0.0); } - Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); - Long itemTotal = rmOpenCloseValveHistoryMapper.getUseWaterGtValueIntakesCount(params); + Long itemTotal = rmIntakeAmountDayMapper.getUseWaterGtValueIntakesCount(params); QueryResultVo<List<VoIntakeAccumulateAmount>> rsVo = new QueryResultVo<>() ; rsVo.pageSize = qo.pageSize ; rsVo.pageCurr = qo.pageCurr ; rsVo.calculateAndSet(itemTotal, params); - rsVo.obj = rmOpenCloseValveHistoryMapper.getUseWaterGtValueIntakes(params); + rsVo.obj = rmIntakeAmountDayMapper.getUseWaterGtValueIntakes(params); return rsVo ; } - - - /** + /** ok 4 * 鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙� * @param qo * @return @@ -505,35 +517,62 @@ public QueryResultVo<List<VoIntakeAccumulateAmount>> getExpenseGtValueIntakes(IntakeAmountValueQO qo) { String timeStart = qo.getTimeStart(); String timeStop = qo.getTimeStop(); - if(timeStart != null && timeStart != "") { - timeStart = timeStart + " 00:00:00"; - } else { - timeStart = LocalDateTime.of(2024, 1, 1, 0, 0, 0).toString(); + if(timeStart == null || timeStart.trim().equals("")) { + timeStart = DateTime.yyyy_MM_dd() ; + qo.setTimeStart(timeStart); } - qo.setTimeStart(timeStart); - - if(timeStop != null && timeStop != "") { - timeStop = timeStop + " 23:59:59"; - }else { - timeStop = LocalDate.now() + " 23:59:59"; + if(timeStop == null || timeStop.trim().equals("")) { + timeStop = DateTime.yyyy_MM_dd() ; + qo.setTimeStop(timeStop); } - qo.setTimeStop(timeStop); - if (qo.getValue() == null){ qo.setValue(0.0); } Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); - Long itemTotal = rmOpenCloseValveHistoryMapper.getExpenseGtValueIntakesCount(params); + Long itemTotal = rmIntakeAmountDayMapper.getExpenseGtValueIntakesCount(params); QueryResultVo<List<VoIntakeAccumulateAmount>> rsVo = new QueryResultVo<>() ; rsVo.pageSize = qo.pageSize ; rsVo.pageCurr = qo.pageCurr ; rsVo.calculateAndSet(itemTotal, params); - rsVo.obj = rmOpenCloseValveHistoryMapper.getExpenseGtValueIntakes(params); + rsVo.obj = rmIntakeAmountDayMapper.getExpenseGtValueIntakes(params); return rsVo ; } + + /** ok 4 + * 鎸囧畾鏃堕棿娈靛唴娑堣垂閲戦瓒呰繃鎸囧畾鍊肩殑鍙栨按鍙� + * @param qo + * @return + */ + public QueryResultVo<List<VoIntakeAccumulateAmount>> getUseWaterTimesGtValueIntakes(IntakeCountValueQO qo) { + String timeStart = qo.getTimeStart(); + String timeStop = qo.getTimeStop(); + if(timeStart == null || timeStart.trim().equals("")) { + timeStart = DateTime.yyyy_MM_dd() ; + qo.setTimeStart(timeStart); + } + if(timeStop == null || timeStop.trim().equals("")) { + timeStop = DateTime.yyyy_MM_dd() ; + qo.setTimeStop(timeStop); + } + if (qo.getValue() == null){ + qo.setValue(0); + } + + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); + Long itemTotal = rmIntakeAmountDayMapper.getUseWaterTimesGtValueIntakesCount(params); + + QueryResultVo<List<VoIntakeAccumulateAmount>> rsVo = new QueryResultVo<>() ; + rsVo.pageSize = qo.pageSize ; + rsVo.pageCurr = qo.pageCurr ; + + rsVo.calculateAndSet(itemTotal, params); + rsVo.obj = rmIntakeAmountDayMapper.getUseWaterTimesGtValueIntakes(params); + return rsVo ; + } + /** @@ -547,7 +586,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 +621,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 +656,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 +685,14 @@ * @param qo * @return */ - public QueryResultVo<List<VoDayIntakeAmount>> getDayIntakeAmount(IntakeAmountQO 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); @@ -674,7 +717,7 @@ * @param qo * @return */ - public QueryResultVo<List<VoMonthIntakeAmount>> getMonthIntakeAmount(IntakeAmountQO qo) { + 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); @@ -685,7 +728,7 @@ // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟 Long itemTotal = Optional.ofNullable(rmIntakeAmountDayMapper.getMonthIntakeAmountCount(params)).orElse(0L); - QueryResultVo<List<VoMonthIntakeAmount>> rsVo = new QueryResultVo<>() ; + QueryResultVo<List<VoMonthAmount>> rsVo = new QueryResultVo<>() ; rsVo.pageSize = qo.pageSize ; rsVo.pageCurr = qo.pageCurr ; @@ -694,4 +737,98 @@ 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 ; + } + + /** + * 鏈�杩戞湭鎶ユ暟鐨勫彇姘村彛 + * @param qo + * @return + */ + public QueryResultVo<List<VoIntakeUnReported>> getUnReportedIntakes(CommonQO qo) { + String timeStart = qo.getTimeStart(); + String timeStop = qo.getTimeStop(); + if(timeStart == "") { + timeStart = null; + } + if(timeStop == "") { + timeStop = null; + } + if(timeStart != null && timeStart != "") { + timeStart = timeStart + " 00:00:00"; + } + qo.setTimeStart(timeStart); + + if(timeStop != null && timeStop != "") { + timeStop = timeStop + " 23:59:59"; + } + qo.setTimeStop(timeStop); + + + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); + Long itemTotal = rmOnHourReportLastMapper.getUnReportedIntakesCount(params); + + QueryResultVo<List<VoIntakeUnReported>> rsVo = new QueryResultVo<>() ; + rsVo.pageSize = qo.pageSize ; + rsVo.pageCurr = qo.pageCurr ; + + rsVo.calculateAndSet(itemTotal, params); + rsVo.obj = rmOnHourReportLastMapper.getUnReportedIntakes(params); + return rsVo ; + } } -- Gitblit v1.8.0