lxw
2023-11-01 deb57e744d70f6fe0d60291a7fdaa1301c709cad
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package com.whyc.service;
 
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.constant.BattTestEnum;
import com.whyc.dto.AlarmDaoFactory;
import com.whyc.dto.BattTestDataDTO;
import com.whyc.dto.TestDaoFactory;
import com.whyc.mapper.*;
import com.whyc.pojo.BatttestdataInf;
import com.whyc.pojo.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
 
@Service
public class BattTestDataInf2Service {
 
    @Resource
    private BattTestDataInf2Mapper mapper;
 
    @Resource
    private AlarmParamMapper alarmParamMapper;
 
    @Resource
    private CommonMapper commonMapper;
 
    @Resource
    private BatttestdataInfMapper testDataInfMapper;
 
    @Resource
    private BattResDataInfMapper resDataInfMapper;
 
    @Resource
    private BatttestdataMapper testDataMapper;
 
    @Resource
    private BattResDataMapper resDataMapper;
 
    @Autowired
    private BattTestDataStopService testStopService;
 
    @Autowired
    private BattResDataService resDataService;
 
    @Autowired
    private PageParamService pageParamService;
 
    @Autowired
    private SubTablePageInfoService subService;
 
    /*新版接口不包含内阻数据
     * */
    public PageInfo<BatttestdataInf> calcTestData(BattTestDataDTO paramDto, Integer pageNum, Integer pageSize) {
        //获取充放电时间过滤参数
        List<PageParam> pageParamList = pageParamService.getList2ByCategoryId(14);
        int jcDischargeFilterTime = pageParamList.get(2).getStatus() * 60;
        int jcChargeFilterTime = pageParamList.get(3).getStatus() * 60;
        paramDto.setJcDischargeFilterTime(jcDischargeFilterTime);
        paramDto.setJcChargeFilterTime(jcChargeFilterTime);
 
        List<BatttestdataInf> calcDataList = new LinkedList<>();
        //查询电池组 电池信息或者电导信息
        PageHelper.startPage(pageNum, pageSize, true);
        List<BatttestdataInf> battTestInfList = mapper.getTestInfList(paramDto);
        PageInfo<BatttestdataInf> pageInfo = new PageInfo(battTestInfList);
 
        //查询电池测试过程具体电池组的落后单体相关信息
        //获取容量告警和容量更换告警参数
        List<Float> paramList = alarmParamMapper.getParamInfoList(AlarmDaoFactory.Alarm_CapAlarm, AlarmDaoFactory.Alarm_CapChange);
        Float alarmLowCoe4CapAlarm = paramList.get(0);
        Float alarmLowCoe4CapChange = paramList.get(1);
        //电池test测试
        battTestInfList.forEach(battTestDataInf -> {
            battTestDataInf.setAlarmLowCoe4CapAlarm(alarmLowCoe4CapAlarm);
            battTestDataInf.setAlarmLowCoe4CapChange(alarmLowCoe4CapChange);
            //获取测试仪表类型
            battTestDataInf.setTeststarttypeHex(TestDaoFactory.getTest_starttypeHex(battTestDataInf.getTestStarttype(), battTestDataInf.getTestType(), battTestDataInf.getTestDatatype()));
 
            //通过stop表获取落后单体信息
            String exist = commonMapper.existTable("db_batt_testdata", "tb_batttestdatastop_" + battTestDataInf.getBattGroupId());
            if (exist != null) {
                //计算落后信息
                battTestDataInf = testStopService.calcBehindInfo(battTestDataInf);
            }
            battTestDataInf.setMinMonvol(BigDecimal.valueOf(battTestDataInf.getMinMonvol()).setScale(3, BigDecimal.ROUND_HALF_UP).floatValue());
 
            calcDataList.add(battTestDataInf);
        });
        pageInfo.setList(calcDataList);
        return pageInfo;
    }
 
    /*旧版接口包含内阻数据
     * */
    public PageInfo<BatttestdataInf> calcTestData1(BattTestDataDTO paramDto, Integer pageNum, Integer pageSize) {
        List<BatttestdataInf> calcDataList = new LinkedList<>();
        //查询电池组 电池信息或者电导信息
        PageHelper.startPage(pageNum, pageSize, true);
        List<BatttestdataInf> battTestInfList = mapper.getTestInfList1(paramDto);
        PageInfo<BatttestdataInf> pageInfo = new PageInfo(battTestInfList);
 
        //查询电池测试过程具体电池组的落后单体相关信息
        //获取容量告警和容量更换告警参数
        List<Float> paramList = alarmParamMapper.getParamInfoList(AlarmDaoFactory.Alarm_CapAlarm, AlarmDaoFactory.Alarm_CapChange);
        Float alarmLowCoe4CapAlarm = paramList.get(0);
        Float alarmLowCoe4CapChange = paramList.get(1);
        //电池test测试
        if (paramDto.getTestType().intValue() != BattTestEnum.TEST_TYPE_RES_SER.getValue()) {
            battTestInfList.forEach(battTestDataInf -> {
                battTestDataInf.setAlarmLowCoe4CapAlarm(alarmLowCoe4CapAlarm);
                battTestDataInf.setAlarmLowCoe4CapChange(alarmLowCoe4CapChange);
                //获取测试仪表类型
                battTestDataInf.setTeststarttypeHex(TestDaoFactory.getTest_starttypeHex1(battTestDataInf.getTestStarttype(), battTestDataInf.getTestType()));
 
                //通过stop表获取落后单体信息
                String exist = commonMapper.existTable("db_batt_testdata", "tb_batttestdatastop_" + battTestDataInf.getBattGroupId());
                if (exist != null) {
                    //计算落后信息
                    battTestDataInf = testStopService.calcBehindInfo(battTestDataInf);
                }
                battTestDataInf.setMinMonvol(BigDecimal.valueOf(battTestDataInf.getMinMonvol()).setScale(3, BigDecimal.ROUND_HALF_UP).floatValue());
 
                calcDataList.add(battTestDataInf);
            });
        }else{//电池res测试
            battTestInfList.forEach(battTestDataInf -> {
                //获取仪表类型
                battTestDataInf.setTeststarttypeHex(TestDaoFactory.getRes_starttypeHex(battTestDataInf.getTestDevType()));
                //通过stop表获取落后单体信息
                String exist = commonMapper.existTable("db_batt_testdata","tb_battresdata_"+battTestDataInf.getBattGroupId());
                if(exist!=null){
                    //求截至平均电压和最低电压单体编号和电压值
                    battTestDataInf = resDataService.calcBehindInfo(battTestDataInf);
                }
                calcDataList.add(battTestDataInf);
            });
        }
 
        pageInfo.setList(calcDataList);
        return pageInfo;
    }
 
    @Transactional
    public boolean delete(Integer num, Integer battGroupId, Integer testRecordCount, Integer testType) {
 
        //充电,放电,在线监测
        /*if(testType == BattTestEnum.TEST_TYPE_CHARGE.getValue() ||
                testType == BattTestEnum.TEST_TYPE_DISCHARGE.getValue()||
                testType == BattTestEnum.TEST_TYPE_MONITOR.getValue()
        )*/
        if(testType.equals(BattTestEnum.TEST_TYPE_CHARGE.getValue())  ||
                testType.equals(BattTestEnum.TEST_TYPE_DISCHARGE.getValue())||
                testType.equals(BattTestEnum.TEST_TYPE_MONITOR.getValue())
        ){
            //删除 测试表inf里的信息
            testDataInfMapper.deleteById(num);
            //删除 测试表_battGroupId里面对应的单体信息
            testDataMapper.deleteByTestRecordCount(battGroupId,testRecordCount);
 
        }else{ //电导或电阻
            //删除 测试表inf里的信息
            resDataInfMapper.deleteById(num);
            //删除 测试表_battGroupId里面对应的单体信息
            //resDataMapper.deleteByTestRecordCount(battGroupId,testRecordCount);
            subService.deleteByTestRecordCount(battGroupId,testRecordCount);
        }
        return true;
    }
}