wuzeyu
2024-08-08 b306ba3d75769c7d3f5ae9f7b43a8aaa26ed983c
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/intake/IntakeSv.java
@@ -1,22 +1,9 @@
package com.dy.pipIrrStatistics.intake;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoRm.RmOnHourReportHistoryMapper;
import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveHistoryMapper;
import com.dy.pipIrrGlobal.daoRm.RmOnHourReportLastMapper;
import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveLastMapper;
import com.dy.pipIrrGlobal.daoRm.*;
import com.dy.pipIrrGlobal.voSt.*;
import com.dy.pipIrrStatistics.intake.qo.*;
import com.dy.pipIrrGlobal.voSt.VoBatteryVolt;
import com.dy.pipIrrGlobal.voSt.VoCumulativeFlow;
import com.dy.pipIrrGlobal.voSt.VoIntake;
import com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount;
import com.dy.pipIrrGlobal.voSt.VoSignalIntensity;
import com.dy.pipIrrStatistics.intake.qo.BatteryVoltQO;
import com.dy.pipIrrStatistics.intake.qo.CumulativeFlowQO;
import com.dy.pipIrrStatistics.intake.qo.IntakeCountValueQO;
import com.dy.pipIrrStatistics.intake.qo.CommonQO;
import com.dy.pipIrrStatistics.intake.qo.SignalIntensityQO;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +13,7 @@
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -46,9 +34,11 @@
    private RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper;
    @Autowired
    private RmOnHourReportLastMapper rmOnHourReportLastMapper;
    @Autowired
    private RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper;
    @Autowired
    private RmIntakeAmountDayMapper rmIntakeAmountDayMapper;
    @Value("${rtu.batteryVolt}")
    private Double batteryVolt;
@@ -201,7 +191,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);
@@ -240,7 +230,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);
@@ -279,7 +269,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);
@@ -437,7 +427,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);
@@ -477,7 +467,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);
@@ -518,7 +508,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);
@@ -557,7 +547,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);
@@ -592,7 +582,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);
@@ -627,7 +617,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);
@@ -650,4 +640,58 @@
        rsVo.obj = rmOpenCloseValveHistoryMapper.getNoOpenHaveCloseIntakes(params);
        return rsVo ;
    }
    /**
     * 统计指定月份各天用水量
     * @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));
        qo.setYear(year);
        qo.setMonth(month);
        // 生成查询参数
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
        // 获取符合条件的记录数
        Long itemTotal = Optional.ofNullable(rmIntakeAmountDayMapper.getDayIntakeAmountCount(params)).orElse(0L);
        QueryResultVo<List<VoDayIntakeAmount>> rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = qo.pageSize ;
        rsVo.pageCurr = qo.pageCurr ;
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = rmIntakeAmountDayMapper.getDayIntakeAmount(params);
        return rsVo ;
    }
    /**
     * 统计指定年份各月用水量
     * @param qo
     * @return
     */
    public QueryResultVo<List<VoMonthIntakeAmount>> 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<VoMonthIntakeAmount>> rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = qo.pageSize ;
        rsVo.pageCurr = qo.pageCurr ;
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = rmIntakeAmountDayMapper.getMonthIntakeAmount(params);
        return rsVo ;
    }
}