| | |
| | | package com.whyc.service; |
| | | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.BattTestDataCalcDTO; |
| | | import com.whyc.constant.BattTestEnum; |
| | | import com.whyc.dto.AlarmDaoFactory; |
| | | import com.whyc.dto.BattTestDataDTO; |
| | | import com.whyc.mapper.BattTestDataInf2Mapper; |
| | | 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; |
| | | |
| | | public PageInfo<BattTestDataCalcDTO> calcTestData(BattTestDataDTO paramDto, Integer pageNum, Integer pageSize) { |
| | | @Resource |
| | | private AlarmParamMapper alarmParamMapper; |
| | | |
| | | return null; |
| | | @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 List<String> getStationName1(Long uId) { |
| | | return mapper.getStationName1(uId); |
| | | /*旧版接口包含内阻数据 |
| | | * */ |
| | | 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; |
| | | } |
| | | } |