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,"获取历史测试记录数据详情");
|
}
|
}
|