lxw
2022-12-21 108da8c66924e7fc4015a0598f79b606f7436ad5
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
package com.whyc.service;
 
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.mapper.BattResDataMapper;
import com.whyc.pojo.BattResData;
import com.whyc.pojo.BattResDataInf;
import com.whyc.pojo.BatttestdataInf;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
 
@Service
public class BattResDataService {
 
    @Resource
    private BattResDataMapper mapper;
 
    public BatttestdataInf calcBehindInfo(BatttestdataInf battTestDataInf) {
        //平均截止电压
        Float avgVol = mapper.calcAvgVol(battTestDataInf.getBattGroupId(),battTestDataInf.getTestRecordCount());
        if(avgVol !=null) {
            battTestDataInf.setAvgVol(BigDecimal.valueOf(avgVol).setScale(3, BigDecimal.ROUND_HALF_UP).floatValue());
        }
 
        //最低单体电压和编号
        BattResData resDataInf = mapper.getMinInfo(battTestDataInf.getBattGroupId(),battTestDataInf.getTestRecordCount());
        if(resDataInf !=null) {
            battTestDataInf.setMinMonvol(BigDecimal.valueOf(resDataInf.getMonVol()).setScale(3, BigDecimal.ROUND_HALF_UP).floatValue());
            battTestDataInf.setMinMonnum(resDataInf.getMonNum());
        }
 
        return battTestDataInf;
    }
    //历史内阻数据查询
    public Response getResInfoByBattGroupId(int battGroupId) {
        String dbName="db_batt_testdata";
        String tableName="tb_battresdata_"+String.valueOf(battGroupId);
        String name=mapper.checkTable(dbName,tableName);
        PageInfo pageInfo=new PageInfo();
        if(name!=null){
            List<BattResData> list=mapper.getResInfoByBattGroupId(battGroupId);
            pageInfo.setList(list);
        }
        return new Response().set(1,pageInfo);
    }
}