wuzeyu
2024-01-15 15bf8d8550804f1e853d52a898ebcca7674a5e39
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.dy.pipIrrProject.flowMonitoring;
 
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoPr.PrFlowmeterMapper;
import com.dy.pipIrrGlobal.pojoPr.PrFlowmeter;
import com.dy.pipIrrGlobal.voPr.VoFlowMeter;
import com.dy.pipIrrGlobal.voPr.VoFlowMonitoring;
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.util.List;
import java.util.Map;
 
/**
 * @author ZhuBaoMin
 * @date 2024-01-05 9:20
 * @LastEditTime 2024-01-05 9:20
 * @Description
 */
 
@Slf4j
@Service
public class FlowmeterSv {
    @Autowired
    private PrFlowmeterMapper prFlowmeterMapper;
 
    /**
     * 添加流量计
     * @param prFlowmeter
     * @return
     */
    public Integer addFlowmeter(PrFlowmeter prFlowmeter) {
        return prFlowmeterMapper.insert(prFlowmeter);
    }
 
    /**
     * 删除流量计
     * @param flowmeterId
     * @return
     */
    public Integer deleteFlowmeter(Long flowmeterId) {
        return prFlowmeterMapper.deleteFlowmeterById(flowmeterId);
    }
 
    /**
     * 根据流量计编号获取未删除的流量计数量
     * @param flowmeterId
     * @return
     */
    public Integer getRecordCountOfFlowmeterByCode(Long flowmeterId) {
        return prFlowmeterMapper.getRecordCountOfFlowmeterByCode(flowmeterId);
    }
 
 
    /**
     * 根据指定条件得到流量计实体记录
     * @param queryVo 给的条件
     * @return 流量计实体集合
     */
    public QueryResultVo<List<VoFlowMeter>> getFlowMeters(QueryVoFlowMeter queryVo){
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo) ;
 
        QueryResultVo<List<VoFlowMeter>> rsVo = new QueryResultVo<>() ;
 
        Integer pageCurr = 0;
        Integer pageSize = 10000;
        rsVo.pageCurr = 1;
        rsVo.pageSize = 10000;
        if(queryVo.pageSize != null && queryVo.pageCurr != null) {
            rsVo.pageSize = queryVo.pageSize ;
            rsVo.pageCurr = queryVo.pageCurr;
            pageSize = queryVo.pageSize ;
            pageCurr = (Integer.parseInt(params.get("pageCurr").toString()) - 1) * Integer.parseInt(params.get("pageSize").toString());
        }
        params.put("pageCurr", pageCurr);
        params.put("pageSize", pageSize);
 
        // 计算符合条件的记录数
        Integer itemTotal = prFlowmeterMapper.getRecordCountOfFlowMeterByOthers(params);
        rsVo.calculateAndSet(itemTotal.longValue(), params);
        rsVo.obj = prFlowmeterMapper.getFlowMeters(params);
 
        return rsVo ;
    }
}