whyclxw
2025-05-29 b341245d84fb1e4743e8d34bc9a4f742b0fb9a5e
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
package com.whyc.service;
 
import com.whyc.dto.Real.QuarterData;
import com.whyc.dto.Response;
import com.whyc.mapper.CommonMapper;
import com.whyc.pojo.db_data_history.BattRealdataId;
import com.whyc.util.ActionUtil;
import com.whyc.util.SubTablePageInfoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
 
@Service
public class BattRealdataIdService {
    @Autowired
    private SubTablePageInfoService subTablePageInfoService;
    @Resource
    private CommonMapper commonMapper;
 
    //获取电池组最近一季度的单体数据
    public Response getBattQuarter(Integer battgroupId) {
        HashMap<String,Object> map = new HashMap<>();
        List<String> datelist = ActionUtil.getLastQuarterYearMonths();
        for (String date:datelist) {
            String tableName ="db_data_history.tb_batt_realdata_"+battgroupId+"_"+date;
            String existTableName = commonMapper.existTable("db_data_history", "tb_batt_realdata_"+battgroupId+"_"+date);
            if(existTableName == null){
                continue;
            }
            //判断表是否存在
            List<QuarterData> list=subTablePageInfoService.getBattRealHis(tableName,"mon_vol");
            map.put(date,list);
        }
        return new Response().setII(1,map.size()>0,map,"获取电池组最近一季度的数据");
    }
}