whyclxw
14 小时以前 bca92c7c2376f0e4d8d779251d45155b863b031c
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
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.whyc.dto.Response;
import com.whyc.factory.BattCapFactory;
import com.whyc.mapper.BatttestdataInfMapper;
import com.whyc.mapper.CommonMapper;
import com.whyc.pojo.db_batt_testdata.BatttestdataId;
import com.whyc.pojo.db_batt_testdata.BatttestdataInf;
import com.whyc.pojo.db_station.BattInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
 
@Service
public class BatttestdataIdService {
    @Autowired
    private SubTablePageInfoService subTablePageInfoService;
    @Resource
    private CommonMapper commonMapper;
 
    @Autowired
    private BatttestdataInfService tinfService;
 
    @Autowired
    private BattInfService binfService;
    //找这次放电的指定的一笔数据
    public List<BatttestdataId> getLastDataByBattgroupId(Integer battgroupId, Integer testRecordCount, Integer recordNum) {
        List<BatttestdataId> list=subTablePageInfoService.getLastDataByBattgroupId(battgroupId,  testRecordCount, recordNum);
        return list;
    }
    //历史测试记录具体某一次放电数据详情
    public Response getTinfDataWithTestRecordCount(Integer battgroupId, Integer testRecordCount,Integer recordNum, Integer granularity) {
        String tableName ="db_batt_testdata.tb_batttestdata_"+battgroupId;
        String existTableName = commonMapper.existTable("db_batt_testdata", "tb_batttestdata_"+battgroupId);
        if(existTableName == null){
            return new Response().set(1,false,battgroupId+"电池组找不到第"+testRecordCount+"次放电记录");
        }
        List<BatttestdataId> list=subTablePageInfoService.getTinfDataWithTestRecordCount(tableName,testRecordCount,recordNum,granularity);
        //获取电池组信息
        BattInf binf = binfService.getBinfByBattgroupId(battgroupId);
        //获取这一次的放电信息
        BatttestdataInf tinf=tinfService.getTinfByTestRecordCount(battgroupId,testRecordCount);
        int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
        for (BatttestdataId data:list) {
            Float realCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(),data.getMonVol() , tinf.getGroupVol(), BattCapFactory.CapType_Real);
            Float restcap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest);
            data.setRealCap(realCap);
            data.setRestCap(restcap);
            data.setPercentCap(String.format("%.5f",(realCap/binf.getMoncapstd()*100)));
        }
        return new Response().setII(1,list.size()>0,list,"获取历史测试记录数据详情");
    }
}