package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import com.whyc.dto.BattCapFactory;
|
import com.whyc.dto.BattState;
|
import com.whyc.dto.BattTestData;
|
import com.whyc.dto.Response;
|
import com.whyc.dto.result.ReportBattTestDTO;
|
import com.whyc.mapper.BattParamLowMapper;
|
import com.whyc.mapper.BattTestDataStopMapper;
|
import com.whyc.mapper.BatttestdataInfMapper;
|
import com.whyc.pojo.BattParamLow;
|
import com.whyc.pojo.BattTestDataStop;
|
import com.whyc.pojo.Battinf;
|
import com.whyc.pojo.BatttestdataInf;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
@Service
|
public class BatttestdataInfService {
|
|
@Resource
|
private BatttestdataInfMapper mapper;
|
|
@Resource
|
private BattTestDataStopMapper stopMapper;
|
|
@Resource
|
private BattParamLowMapper battParamLowMapper;
|
|
//在线监测-历史监控-获取充放电记录
|
public Response searchBattTestInfDataById(int battGroupId) {
|
QueryWrapper wrapper=new QueryWrapper();
|
wrapper.eq("BattGroupId",battGroupId);
|
wrapper.eq("data_available",1);
|
int judgeNum=mapper.judge(battGroupId);
|
if(judgeNum>0){
|
List<BatttestdataInf> list=mapper.selectList(wrapper);
|
list.stream().forEach(tinf->{
|
//放电终止原因
|
if(battGroupId/100000==6185){
|
//61850设备放电停止原因
|
tinf.setTestStoptypeReason(BattTestData.getStopType_6185(tinf.getTestStoptype()));
|
}else if(battGroupId/100000==4016){
|
//6度设备放电停止原因
|
tinf.setTestStoptypeReason(BattTestData.getStopType_4016(tinf.getTestStoptype()));
|
}else if(battGroupId/100000==9110){
|
//假负载设备放电停止原因
|
tinf.setTestStoptypeReason(BattTestData.getStopType_9110(tinf.getTestStoptype()));
|
}else if(battGroupId/100000==9120){
|
// 逆变设备放电停止原因
|
tinf.setTestStoptypeReason(BattTestData.getStopType_9120(tinf.getTestStoptype()));
|
}else if(battGroupId/100000==8059){
|
//一体机设备放电停止原因
|
tinf.setTestStoptypeReason(BattTestData.getStopType_8059(tinf.getTestStoptype()));
|
}else{
|
tinf.setTestStoptypeReason(BattTestData.getStopType(tinf.getTestStarttype(), tinf.getTestStoptype()));
|
}
|
});
|
PageInfo pageInfo=new PageInfo(list);
|
return new Response().set(1,pageInfo);
|
}else{
|
return new Response().set(0);
|
}
|
}
|
|
//最后一次核容放电数据
|
public Response searchBattLastHrDataById(int battGroupId) {
|
PageHelper.startPage(1,1);
|
QueryWrapper wrapper=new QueryWrapper();
|
wrapper.eq("BattGroupId",battGroupId);
|
wrapper.eq("data_available",1);
|
wrapper.eq("test_type",3);
|
wrapper.eq("test_starttype",3);
|
wrapper.orderByDesc("test_starttime");
|
BatttestdataInf tinf=mapper.selectOne(wrapper);
|
List<BattTestDataStop> list=new ArrayList<BattTestDataStop>();
|
if(tinf!=null){
|
list=stopMapper.getTestDataStop(tinf.getBattGroupId(),tinf.getTestStarttime());
|
tinf.setBatttestdataList(list);
|
}
|
return new Response().set(1,tinf);
|
}
|
|
//报表分析使用
|
public List<BatttestdataInf> searchByTestType(BatttestdataInf tinf){
|
List<BatttestdataInf> list = mapper.searchByTestType(tinf);
|
float cap=0f;//实际容量
|
float restcap=0f;//剩余容量
|
for (BatttestdataInf binf:list) {
|
int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(),binf.getTestCurr());
|
cap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate,binf.getTestCap(), binf.getMaxMonvol(), binf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
|
restcap=(float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate,binf.getTestCap(), binf.getMaxMonvol(), binf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest);
|
binf.setGroupVol(cap);;
|
binf.setMonVol(restcap);
|
}
|
return list;
|
}
|
//1.4电池组性能评估(根据电池组id查询所有的放电记录求出放电总次数,最高历史容量,最低历史容量,平均容量,最新测试容量)
|
public List searchDischargeTest(BatttestdataInf tinf){
|
List<BatttestdataInf> list = mapper.searchDischargeTest(tinf);
|
int sum=0;//总测试次数
|
float cap=0f;//实际容量
|
float allCap=0f;//总容量
|
float maxCap=0f;//最高容量
|
float minCap=10000f;//最低容量
|
float avgCap=0f;//平均容量
|
float lastCap=0f;//最近测试容量
|
for (int i = 0; i <list.size() ; i++) {
|
BatttestdataInf binf = list.get(i);
|
int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(),binf.getTestCurr());
|
cap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate,binf.getTestCap(), binf.getMaxMonvol(), binf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
|
if(sum==0){
|
lastCap=cap;
|
}
|
if(maxCap<=cap){
|
maxCap=cap;//最大
|
}
|
if(minCap>=cap){
|
minCap=cap;//最小
|
}
|
allCap+=cap;
|
sum++;
|
}
|
if(sum!=0){
|
avgCap=allCap/sum;//平均容量
|
}else{
|
avgCap=0;
|
minCap=0;
|
}
|
List list1 = new ArrayList<>();
|
list1.add(tinf.getBattGroupId());
|
list1.add(sum);
|
list1.add(maxCap);
|
list1.add(avgCap);
|
list1.add(minCap);
|
list1.add(lastCap);
|
return list1;
|
}
|
|
public Response searchBattLifeNow(int pageNum,int pageSize,Battinf binf){
|
PageHelper.startPage(pageNum,pageSize);
|
List<BattState> list = mapper.searchBattLifeNow(binf);
|
PageInfo<BattState> pageInfo = new PageInfo<>(list);
|
return new Response().set(1,pageInfo,"查询成功");
|
}
|
|
public Response searchBattLife(int pageNum,int pageSize,Battinf binf){
|
PageHelper.startPage(pageNum,pageSize);
|
List<ReportBattTestDTO> list = mapper.searchBattLife(binf);
|
float param = 0;//容量有效参数
|
double STDAH = 0;//标存容量
|
BattParamLow capLow=new BattParamLow();
|
capLow.setLowType(BattCapFactory.CapType_type);;
|
capLow.setLowNametype(BattCapFactory.CapType_name);
|
capLow.setLowMethod(BattCapFactory.CapType_method);
|
List<BattParamLow> listC = battParamLowMapper.serchByLow(capLow);
|
if (listC!=null && listC.size()>0){
|
param = listC.get(listC.size()-1).getLowValue();
|
}
|
int flag=0;//该次放电是否有效判断
|
List<ReportBattTestDTO> listE=new ArrayList();//存放放电有效的测试
|
if (list!=null &&list.size()>0){
|
for(int i=0;i<list.size();i++){
|
if(list.get(i).getBinf().getMonCapStd()!=null)
|
STDAH=list.get(i).getBinf().getMonCapStd();
|
float testCap=list.get(i).getTdata().getTestCap();//此次放电量统计
|
//System.out.println(list.get(i).getTdata().getBattGroupId()+" "+list.get(i).getTdata().getTest_record_count()+" "+testCap+" "+param+" "+STDAH);
|
flag=BattCapFactory.Judge(testCap, param, STDAH);
|
if(flag==1){
|
if(listE.size()>0){
|
int tdata_battgroupid=list.get(i).getTdata().getBattGroupId();
|
int e_battgroupid=listE.get(listE.size()-1).getTdata().getBattGroupId();
|
if(tdata_battgroupid!=e_battgroupid){
|
listE.add(list.get(i));
|
}else{
|
continue;
|
}
|
}else{
|
listE.add(list.get(i));
|
}
|
flag=0;
|
}
|
}
|
}
|
PageInfo<ReportBattTestDTO> pageInfo = new PageInfo<>(list);
|
return new Response().set(1,pageInfo,"查询成功");
|
}
|
|
|
}
|