Administrator
2024-08-06 efd53d4980b5a0ae537fb7ec6f5a993eae507dac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.dy.pipIrrStatistics.client;
 
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveHistoryMapper;
import com.dy.pipIrrGlobal.voSt.VoClient;
import com.dy.pipIrrStatistics.client.qo.OpenCountQO;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Optional;
 
/**
 * @author ZhuBaoMin
 * @date 2024-08-06 9:43
 * @LastEditTime 2024-08-06 9:43
 * @Description
 */
 
@Slf4j
@Service
public class ClientSv {
    @Autowired
    private RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper;
 
    /**
     * 获取指定时间段内开阀次数超过指定值的农户
     * @param qo
     * @return
     */
    public QueryResultVo<List<VoClient>> getLargeOpenCountClients(OpenCountQO 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";
        }
        qo.setTimeStart(timeStart);
        qo.setTimeStop(timeStop);
 
        // 生成查询参数
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
 
        // 获取符合条件的记录数
        Long itemTotal = Optional.ofNullable(rmOpenCloseValveHistoryMapper.getLargeOpenCountClientsCount(params)).orElse(0L);
 
        QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ;
 
        rsVo.pageSize = qo.pageSize ;
        rsVo.pageCurr = qo.pageCurr ;
 
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = rmOpenCloseValveHistoryMapper.getLargeOpenCountClients(params);
        return rsVo ;
    }
}