whycxzp
2024-01-19 a36855e901319feec93c956ba5cdc0c736633244
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.mapper.CKPowerDevBattRtDataMapper;
import com.whyc.pojo.db_ckpwrdev_data_rt.CKPowerDevBattRtData;
import com.whyc.pojo.db_ckpwrdev_data_rt.CKPowerDevBattRtState;
import com.whyc.pojo.db_ckpwrdev_inf.CKPwrDevInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
 
@Service
public class CKPowerDevBattRtDataService {
 
    @Resource
    private CKPowerDevBattRtDataMapper mapper;
 
    @Autowired
    private CKPwrDevInfService ckPwrDevInfService;
 
    /**
     * 首页只显示1组,目前只有1组
     * 但是其他地方,均按多组处理
     * @return
     */
    public List<CKPowerDevBattRtData> getList(Integer index) {
        //查询有单体数量
        CKPwrDevInf ckPwrDevInf = ckPwrDevInfService.get();
 
        QueryWrapper<CKPowerDevBattRtData> query = Wrappers.query();
        if(index!=null) {
            if(index == -1){ //首页查询使用,只查询组1
                query.eq("batt_index", 0);
            }else {
                query.eq("batt_index", index);
            }
        }
        query.le("mon_num",ckPwrDevInf.getBattMonCount());
        return mapper.selectList(query);
    }
 
 
    /**单体列表查询*/
    public List<CKPowerDevBattRtData> getMonList(Integer battIndex, List<Integer> monNumList) {
        QueryWrapper<CKPowerDevBattRtData> query = Wrappers.query();
        if(battIndex!=null) {
            if(battIndex == -1) { //首页上使用,默认只查组1
                query.eq("batt_index", 0);
            }else{
                query.eq("batt_index", battIndex);
            }
        }
        query.in("mon_num",monNumList);
        return mapper.selectList(query);
    }
 
    /**组内所有单体列表查询*/
    public List<CKPowerDevBattRtData> getAllMonList(Integer battIndex) {
        QueryWrapper<CKPowerDevBattRtData> query = Wrappers.query();
        if(battIndex!=null) {
            if(battIndex == -1) { //首页上使用,默认只查组1
                query.eq("batt_index", 0);
            }else{
                query.eq("batt_index", battIndex);
            }
        }
        return mapper.selectList(query);
    }
 
    //获取默认第一组单体数据刷新至第一组0
    public List<CKPowerDevBattRtData> getDataList_index0() {
        QueryWrapper<CKPowerDevBattRtData> wrapper = Wrappers.query();
        wrapper.eq("batt_index",0);
        wrapper.orderByAsc("mon_num");
        return mapper.selectList(wrapper);
    }
}