package com.whyc.service;
|
|
import com.sun.org.glassfish.gmbal.NameValue;
|
import com.whyc.constant.Capperformance;
|
import com.whyc.dto.*;
|
import com.whyc.factory.BattCapFactory;
|
import com.whyc.factory.ThreadPoolExecutorFactory;
|
import com.whyc.pojo.db_batt_testdata.BatttestdataId;
|
import com.whyc.pojo.db_batt_testdata.BatttestdataInf;
|
import com.whyc.pojo.db_param.AppParam;
|
import com.whyc.pojo.db_station.BattInf;
|
import com.whyc.pojo.db_station.PowerInf;
|
import com.whyc.pojo.db_station.StationInf;
|
import com.whyc.util.DateUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.*;
|
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.stream.Collectors;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
|
import static com.whyc.util.DateUtil.convertToLocalDateTime;
|
|
|
@Service
|
public class LeaderHomeService {
|
|
@Autowired
|
private PowerInfService powerInfService;
|
|
@Autowired
|
private BattInfService battInfService;
|
|
@Autowired
|
private StationInfService stationInfService;
|
|
@Autowired
|
private BatttestdataInfService battTestDataInfService;
|
|
@Autowired
|
private PwrdevAlarmService powerAlarmService;
|
|
@Autowired
|
private DevalarmDataService devAlarmService;
|
|
@Autowired
|
private BattalarmDataService battAlarmService;
|
|
@Autowired
|
private AppParamService appParamService;
|
|
@Autowired
|
private BatttestdataIdService battTestDataIdService;
|
|
|
|
public Response getAll(Integer userId) {
|
Response response = new Response();
|
Map<String,Object> map = new HashMap<>();
|
|
CountDownLatch latch = new CountDownLatch(6);
|
ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor();
|
|
//站点信息统计,
|
poolExecutor.execute(() -> {
|
stationInfoStatistics(userId, map);
|
latch.countDown();
|
});
|
|
//电源信息(品牌及电压)统计
|
poolExecutor.execute(() -> {
|
powerInfoStatistics(userId, map);
|
latch.countDown();
|
});
|
//蓄电池信息(品牌及电压)统计
|
poolExecutor.execute(() -> {
|
batteryInfoStatistics(userId, map);
|
latch.countDown();
|
});
|
//测试数据信息统计
|
poolExecutor.execute(() -> {
|
testDataInfoStatistics(userId, map);
|
latch.countDown();
|
});
|
//TODO 设备数量信息统计
|
poolExecutor.execute(() -> {
|
//deviceInfoStatistics(userId, map);
|
latch.countDown();
|
});
|
//TODO 实时告警信息统计
|
/**
|
* 逻辑更新:
|
*/
|
poolExecutor.execute(() -> {
|
//alarmRealtimeStatistics(userId, map);
|
latch.countDown();
|
});
|
|
return response;
|
}
|
|
|
private void testDataInfoStatistics(Integer userId, Map<String, Object> map) {
|
List<BatttestdataInf> testInfList = battTestDataInfService.getListByUserId(userId);
|
//过滤出本月的
|
LocalDateTime startOfMonth = DateUtil.getStartOfMonth();
|
List<BatttestdataInf> testInfListOfMonth = testInfList.stream()
|
.filter(testData -> {
|
LocalDateTime startTime = convertToLocalDateTime(testData.getTestStarttime());
|
return !startTime.isBefore(startOfMonth);
|
})
|
.collect(Collectors.toList());
|
|
//统计本月各种充放电类型及数量
|
List<NameValueDto> testInfOfMonth = getChargeAndDischargeStatistics(testInfListOfMonth);
|
map.put("testInf_month",testInfOfMonth);
|
|
//过滤出本季度的
|
LocalDateTime startOfQuarter = DateUtil.getStartOfQuarter();
|
List<BatttestdataInf> testInfListOfQuarter = testInfList.stream()
|
.filter(testData -> {
|
LocalDateTime startTime = convertToLocalDateTime(testData.getTestStarttime());
|
return !startTime.isBefore(startOfQuarter);
|
})
|
.collect(Collectors.toList());
|
|
//统计本季度各种充放电类型及数量
|
List<NameValueDto> testInfOfQuarter = getChargeAndDischargeStatistics(testInfListOfQuarter);
|
map.put("testInf_quarter",testInfOfQuarter);
|
|
//过滤出本年的
|
LocalDateTime startOfYear = DateUtil.getStartOfYear();
|
List<BatttestdataInf> testInfListOfYear = testInfList.stream()
|
.filter(testData -> {
|
LocalDateTime startTime = convertToLocalDateTime(testData.getTestStarttime());
|
return !startTime.isBefore(startOfYear);
|
})
|
.collect(Collectors.toList());
|
|
//统计本年各种充放电类型及数量
|
List<NameValueDto> testInfOfYear = getChargeAndDischargeStatistics(testInfListOfYear);
|
map.put("testInf_year",testInfOfYear);
|
}
|
|
/**
|
* 统计各种充放电类型及数量
|
* @param testInfListOfMonth 被统计的列表
|
* @return
|
*/
|
private List<NameValueDto> getChargeAndDischargeStatistics(List<BatttestdataInf> testInfListOfMonth) {
|
List<NameValueDto> testInfOfMonth = new ArrayList<>();
|
int chargeHr = 0;
|
int chargeJc = 0;
|
int dischargeHr = 0;
|
int dischargeJc = 0;
|
for (int i = 0; i < testInfListOfMonth.size(); i++) {
|
BatttestdataInf testData = testInfListOfMonth.get(i);
|
if (testData.getTestType() == 3) { // 测试类型为放电
|
if (testData.getTestStarttype() == 3) { //核容放电
|
dischargeHr++;
|
} else if(testData.getTestStarttype() != 4){ //监测放电
|
dischargeJc++;
|
}
|
} else if (testData.getTestType() == 2) { // 测试类型为充电
|
if (testData.getTestStarttype() == 3) { //核容充电
|
chargeHr++;
|
} else { //监测充电
|
chargeJc++;
|
}
|
}
|
}
|
//核容放电,核容充电,监测放电,检测充电
|
testInfOfMonth.add(new NameValueDto("核容放电",String.valueOf(dischargeHr)));
|
testInfOfMonth.add(new NameValueDto("核容充电",String.valueOf(chargeHr)));
|
testInfOfMonth.add(new NameValueDto("监测放电",String.valueOf(dischargeJc)));
|
testInfOfMonth.add(new NameValueDto("监测充电",String.valueOf(chargeJc)));
|
return testInfOfMonth;
|
}
|
|
private void batteryInfoStatistics(Integer userId, Map<String, Object> map) {
|
List<BattInf> battInfList = battInfService.getListByUserId(userId);
|
Map<String, List<BattInf>> brandMap = battInfList.stream().collect(Collectors.groupingBy(BattInf::getProduct));
|
Map<Float, List<BattInf>> volMap = battInfList.stream().collect(Collectors.groupingBy(BattInf::getMonvolstd));
|
|
List<NameValueDto> brandList = new ArrayList<>();
|
brandMap.forEach((k,v)->{
|
NameValueDto brandDto = new NameValueDto(k, String.valueOf(v.size()));
|
brandList.add(brandDto);
|
});
|
map.put("battGroupInfo_brand",brandList);
|
|
List<NameValueDto> volList = new ArrayList<>();
|
volMap.forEach((k,v)->{
|
NameValueDto volDto = new NameValueDto(String.valueOf(k), String.valueOf(v.size()));
|
volList.add(volDto);
|
});
|
map.put("battGroupInfo_vol",volList);
|
}
|
|
private void powerInfoStatistics(Integer userId, Map<String, Object> map) {
|
List<PowerInf> powerInfList = powerInfService.getListByUserId(userId);
|
Map<String, List<PowerInf>> brandMap = powerInfList.stream().collect(Collectors.groupingBy(PowerInf::getCompany));
|
Map<Integer, List<PowerInf>> typeMap = powerInfList.stream().collect(Collectors.groupingBy(PowerInf::getPowerType));
|
|
List<NameValueDto> brandList = new ArrayList<>();
|
brandMap.forEach((k,v)->{
|
NameValueDto brandDto = new NameValueDto(k, String.valueOf(v.size()));
|
brandList.add(brandDto);
|
});
|
map.put("powerInfo_brand",brandList);
|
|
List<NameValueDto> typeList = new ArrayList<>();
|
//电源类型:1:直流,2:通讯,3:配网
|
typeMap.forEach((k,v)->{
|
NameValueDto typeDto = new NameValueDto();
|
switch (k){
|
case 1:
|
typeDto.setName("直流");
|
break;
|
case 2:
|
typeDto.setName("通讯");
|
break;
|
case 3:
|
typeDto.setName("配网");
|
break;
|
}
|
typeDto.setValue(String.valueOf(v.size()));
|
typeList.add(typeDto);
|
});
|
map.put("powerInfo_type",typeList);
|
|
}
|
|
/**
|
* 按站点类型和站点电压
|
* 站点类型:节点/非节点
|
*/
|
private void stationInfoStatistics(Integer userId, Map<String, Object> map) {
|
List<StationInf> stationInfList =stationInfService.getListByUserId(userId);
|
Map<Integer, List<StationInf>> nodeMap = stationInfList.stream().collect(Collectors.groupingBy(StationInf::getNodeStation));
|
Map<String, List<StationInf>> volMap = stationInfList.stream().collect(Collectors.groupingBy(StationInf::getStationType));
|
|
List<NameValueDto> stationTypeList = new ArrayList<>();
|
List<NameValueDto> stationVolList = new ArrayList<>();
|
nodeMap.forEach((k,v)->{
|
NameValueDto stationTypeDto = new NameValueDto(k == 0 ? "非节点" : "节点", String.valueOf(v.size()));
|
stationTypeList.add(stationTypeDto);
|
});
|
volMap.forEach((k,v)->{
|
NameValueDto stationVolDto = new NameValueDto(k, String.valueOf(v.size()));
|
stationVolList.add(stationVolDto);
|
});
|
|
map.put("stationInfo_stationType",stationTypeList);
|
map.put("stationInfo_stationVol",stationVolList);
|
}
|
|
//同一时间同一品牌电池性能统计
|
public Response getBattPerformanceOfSameTimeSameBrand(Integer userId, NameValueIntDto nameValueDto) {
|
String brand = nameValueDto.getName();
|
Integer year = nameValueDto.getValue();
|
//投入使用时间条件筛选
|
LocalDateTime startTime = LocalDateTime.now().minusYears(year);
|
Date inuseTimeStart = DateUtil.convertToDate(startTime);
|
BattInf battInf = new BattInf();
|
battInf.setInuseTime(inuseTimeStart);
|
battInf.setProduct(brand);
|
//查询满足条件的蓄电池列表
|
List<BattInf> battInfList = battInfService.getListByCondition(userId,battInf);
|
List<BattCapInfoDto> battCapInfoList = getBattCapInfo(battInfList);
|
//data,和data2分别返回 统计数量和 站点优良,劣化,损坏 前二的信息
|
List<NameValueIntDto> data = new ArrayList<>();
|
List<NameValueListDto> data2 = new ArrayList<>();
|
//筛选出 站点优良,劣化,损坏 的电池组,并按照这个字段分组
|
List<BattCapInfoDto> goodList = battCapInfoList.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_1.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap).reversed()).collect(Collectors.toList());
|
if(goodList.size()==0){
|
data.add(new NameValueIntDto("优良",0));
|
data2.add(new NameValueListDto("优良",goodList));
|
}else{
|
data.add(new NameValueIntDto("优良",goodList.size()));
|
data2.add(new NameValueListDto("优良",goodList.subList(0, Math.min(goodList.size(), 2))));
|
}
|
List<BattCapInfoDto> badList = battCapInfoList.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_2.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap)).collect(Collectors.toList());
|
if(badList.size()==0){
|
data.add(new NameValueIntDto("劣化",0));
|
data2.add(new NameValueListDto("劣化",badList));
|
}else{
|
data.add(new NameValueIntDto("劣化",badList.size()));
|
data2.add(new NameValueListDto("劣化",badList.subList(0, Math.min(badList.size(), 2))));
|
}
|
List<BattCapInfoDto> damageList = battCapInfoList.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_3.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap)).collect(Collectors.toList());
|
if(damageList.size()==0){
|
data.add(new NameValueIntDto("损坏",0));
|
data2.add(new NameValueListDto("损坏",damageList));
|
}else{
|
data.add(new NameValueIntDto("损坏",damageList.size()));
|
data2.add(new NameValueListDto("损坏",damageList.subList(0, Math.min(damageList.size(), 2))));
|
}
|
return new Response().setII(1,data,data2,"");
|
|
}
|
|
public Response getBattPerformanceOfSameTimeDiffBrand(Integer userId, int year) {
|
//投入使用时间条件筛选
|
LocalDateTime startTime = LocalDateTime.now().minusYears(year);
|
Date inuseTimeStart = DateUtil.convertToDate(startTime);
|
BattInf battInf = new BattInf();
|
battInf.setInuseTime(inuseTimeStart);
|
//查询满足条件的蓄电池列表
|
List<BattInf> battInfList = battInfService.getListByCondition(userId,battInf);
|
List<BattCapInfoDto> battCapInfoList = getBattCapInfo(battInfList);
|
|
//data,根据品牌分组统计百分比
|
Map<String, List<BattCapInfoDto>> brandMap = battCapInfoList.stream().collect(Collectors.groupingBy(BattCapInfoDto::getProduct));
|
List<NameValueListDto<NameValueDto>> data = new ArrayList<>();
|
brandMap.forEach((brand,battCapInfoListTemp)->{
|
//k -品牌
|
long goodCount = battCapInfoListTemp.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_1.getStateName())).count();
|
long badCount = battCapInfoListTemp.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_2.getStateName())).count();
|
long damageCount = battCapInfoListTemp.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_3.getStateName())).count();
|
long total = goodCount + badCount + damageCount;
|
//良好,劣化,损坏的百分比.(保留0位小数)
|
int goodPercent = Math.round((float) goodCount / total * 100);
|
int badPercent = Math.round((float) badCount / total * 100);
|
int damagePercent = Math.round((float) damageCount / total * 100);
|
|
List<NameValueDto> performanceList = new ArrayList<>();
|
performanceList.add(new NameValueDto("优良",String.format("%d%%",goodPercent)));
|
performanceList.add(new NameValueDto("劣化",String.format("%d%%",badPercent)));
|
performanceList.add(new NameValueDto("损坏",String.format("%d%%",damagePercent)));
|
|
NameValueListDto brandPerformance = new NameValueListDto(brand,performanceList);
|
data.add(brandPerformance);
|
});
|
//data2,优良里面最大的和最小的品牌
|
List<NameValueListDto<NameValueDto>> data2 = new ArrayList<>();
|
List<BattCapInfoDto> goodList = battCapInfoList.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_1.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap)).collect(Collectors.toList());
|
NameValueListDto<NameValueDto> goodListDto = new NameValueListDto<>();
|
List<NameValueDto> goodListValue = new ArrayList<>();
|
NameValueDto goodMaxDto = new NameValueDto();
|
NameValueDto goodMinDto = new NameValueDto();
|
goodMaxDto.setName("max");
|
goodMinDto.setName("min");
|
if (goodList.size()==0){
|
goodMaxDto.setValue("-");
|
goodMinDto.setValue("-");
|
}else{
|
goodMinDto.setValue(goodList.get(0).getProduct());
|
goodMaxDto.setValue(goodList.get(goodList.size()-1).getProduct());
|
}
|
goodListValue.add(goodMaxDto);
|
goodListValue.add(goodMinDto);
|
|
goodListDto.setName("优良");
|
goodListDto.setValue(goodListValue);
|
data2.add(goodListDto);
|
//劣化里面最大的和最小的品牌
|
List<BattCapInfoDto> badList = battCapInfoList.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_2.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap)).collect(Collectors.toList());
|
NameValueListDto<NameValueDto> badListDto = new NameValueListDto<>();
|
List<NameValueDto> badListValue = new ArrayList<>();
|
NameValueDto badMaxDto = new NameValueDto();
|
NameValueDto badMinDto = new NameValueDto();
|
badMaxDto.setName("max");
|
badMinDto.setName("min");
|
if (badList.size()==0){
|
badMaxDto.setValue("-");
|
badMinDto.setValue("-");
|
}else{
|
badMinDto.setValue(badList.get(0).getProduct());
|
badMaxDto.setValue(badList.get(badList.size()-1).getProduct());
|
}
|
badListValue.add(badMaxDto);
|
badListValue.add(badMinDto);
|
|
badListDto.setName("劣化");
|
badListDto.setValue(badListValue);
|
data2.add(badListDto);
|
|
//损坏里面最大的和最小的品牌
|
List<BattCapInfoDto> damageList = battCapInfoList.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_3.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap)).collect(Collectors.toList());
|
|
NameValueListDto<NameValueDto> damageListDto = new NameValueListDto<>();
|
List<NameValueDto> damageListValue = new ArrayList<>();
|
NameValueDto damageMaxDto = new NameValueDto();
|
NameValueDto damageMinDto = new NameValueDto();
|
damageMaxDto.setName("max");
|
damageMinDto.setName("min");
|
if (damageList.size()==0){
|
damageMaxDto.setValue("-");
|
damageMinDto.setValue("-");
|
}else if (damageList.size()==1){
|
damageMaxDto.setValue(damageList.get(0).getProduct());
|
damageMinDto.setValue(damageList.get(0).getProduct());
|
}else{
|
damageMinDto.setValue(damageList.get(0).getProduct());
|
damageMaxDto.setValue(damageList.get(damageList.size()-1).getProduct());
|
}
|
damageListValue.add(damageMaxDto);
|
damageListValue.add(damageMinDto);
|
|
damageListDto.setName("损坏");
|
damageListDto.setValue(damageListValue);
|
data2.add(damageListDto);
|
|
//data3. 性能最佳品牌 TODO 威尔逊置信区间法以及贝叶斯平均法,通过设置的权重,计算各个品牌在指定投运时间内的得分
|
return new Response().setIII(1,data,data2,"性能最佳品牌:TODO 威尔逊置信区间法以及贝叶斯平均法,通过设置的权重,计算各个品牌在指定投运时间内的得分",null);
|
|
}
|
|
public Response getBattPerformanceOfDiffTimeSameBrand(Integer userId, String brand) {
|
BattInf battInf = new BattInf();
|
battInf.setProduct(brand);
|
//查询满足条件的蓄电池列表
|
List<BattInf> battInfList = battInfService.getListByCondition(userId,battInf);
|
List<BattCapInfoDto> battCapInfoList = getBattCapInfo(battInfList);
|
|
//data,TODO 投运时间的维度参数,先固定变量,后续从数据库获取
|
//time1和time2的单位为年
|
int time1 = 3;
|
int time2 = 5;
|
|
//筛选battCapInfoList中对象的inuseTime属性 跟当前时间对比,年份差在time1之内,time1-time2之间,time2之后的数据
|
// --------------time2Limit------time1Limit-------now
|
LocalDateTime time1DateLimit = LocalDateTime.now().minusYears(time1);
|
Date time1Limit = DateUtil.convertToDate(time1DateLimit);
|
LocalDateTime time2DateLimit = LocalDateTime.now().minusYears(time2);
|
Date time2Limit = DateUtil.convertToDate(time2DateLimit);
|
|
//大于time1的数据
|
List<BattCapInfoDto> time1List = battCapInfoList.stream().
|
filter(battCapInfo -> battCapInfo.getInuseTime().compareTo(time1Limit)>=0).collect(Collectors.toList());
|
//在time1和time2之间的数据
|
List<BattCapInfoDto> time12List = battCapInfoList.stream().
|
filter(battCapInfo -> battCapInfo.getInuseTime().compareTo(time2Limit)>0 && battCapInfo.getInuseTime().compareTo(time1Limit)<=0).collect(Collectors.toList());
|
//小于time2的数据
|
List<BattCapInfoDto> time2List = battCapInfoList.stream().
|
filter(battCapInfo -> battCapInfo.getInuseTime().compareTo(time2Limit)<0).collect(Collectors.toList());
|
|
//data
|
List<NameValueListDto<NameValueIntDto>> data = new ArrayList<>();
|
NameValueListDto<NameValueIntDto> time1Dto = new NameValueListDto<>();
|
time1Dto.setName(time1+"年内");
|
List<BattCapInfoDto> badListOfTime1 = time1List.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_2.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap)).collect(Collectors.toList());
|
List<BattCapInfoDto> damageListOfTime1 = time1List.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_3.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap)).collect(Collectors.toList());
|
NameValueIntDto time1BadDto = new NameValueIntDto();
|
time1BadDto.setName("劣化");
|
time1BadDto.setValue(badListOfTime1.size());
|
NameValueIntDto time1DamageDto = new NameValueIntDto();
|
time1DamageDto.setName("损坏");
|
time1DamageDto.setValue(damageListOfTime1.size());
|
time1Dto.setValue(Arrays.asList(time1BadDto,time1DamageDto));
|
|
NameValueListDto<NameValueIntDto> time12Dto = new NameValueListDto<>();
|
time12Dto.setName(time1+"-"+time2+"年");
|
List<BattCapInfoDto> badListOfTime12 = time12List.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_2.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap)).collect(Collectors.toList());
|
List<BattCapInfoDto> damageListOfTime12 = time12List.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_3.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap)).collect(Collectors.toList());
|
NameValueIntDto time12BadDto = new NameValueIntDto();
|
time12BadDto.setName("劣化");
|
time12BadDto.setValue(badListOfTime12.size());
|
NameValueIntDto time12DamageDto = new NameValueIntDto();
|
time12DamageDto.setName("损坏");
|
time12DamageDto.setValue(damageListOfTime12.size());
|
time12Dto.setValue(Arrays.asList(time12BadDto,time12DamageDto));
|
|
NameValueListDto<NameValueIntDto> time2Dto = new NameValueListDto<>();
|
time2Dto.setName(time2+"年以上");
|
List<BattCapInfoDto> badListOfTime2 = time2List.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_2.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap)).collect(Collectors.toList());
|
List<BattCapInfoDto> damageListOfTime2 = time2List.stream().filter(battCapInfo -> battCapInfo.getPerformance().equals(Capperformance.BATTSTATE_3.getStateName()))
|
.sorted(Comparator.comparing(BattCapInfoDto::getRealCap)).collect(Collectors.toList());
|
NameValueIntDto time2BadDto = new NameValueIntDto();
|
time2BadDto.setName("劣化");
|
time2BadDto.setValue(badListOfTime2.size());
|
NameValueIntDto time2DamageDto = new NameValueIntDto();
|
time2DamageDto.setName("损坏");
|
time2DamageDto.setValue(damageListOfTime2.size());
|
time2Dto.setValue(Arrays.asList(time2BadDto,time2DamageDto));
|
|
data.add(time1Dto);
|
data.add(time12Dto);
|
data.add(time2Dto);
|
|
//data2
|
List<NameValueListDto<NameValueObjectDto<BattCapInfoDto>>> data2 = new ArrayList<>();
|
NameValueListDto<NameValueObjectDto<BattCapInfoDto>> time1ObjectDto = new NameValueListDto<>();
|
time1ObjectDto.setName(time1+"年内");
|
NameValueObjectDto<BattCapInfoDto> time1BadObjectDto = new NameValueObjectDto();
|
time1BadObjectDto.setName("劣化");
|
time1BadObjectDto.setValue(badListOfTime1.size()==0?new BattCapInfoDto():badListOfTime1.get(0));
|
|
NameValueObjectDto<BattCapInfoDto> time1DamageObjectDto = new NameValueObjectDto();
|
time1DamageObjectDto.setName("损坏");
|
time1DamageObjectDto.setValue(damageListOfTime1.size()==0?new BattCapInfoDto():damageListOfTime1.get(0));
|
time1ObjectDto.setValue(Arrays.asList(time1BadObjectDto,time1DamageObjectDto));
|
data2.add(time1ObjectDto);
|
|
NameValueListDto<NameValueObjectDto<BattCapInfoDto>> time12ObjectDto = new NameValueListDto<>();
|
time12ObjectDto.setName(time1+"-"+time2+"年");
|
NameValueObjectDto<BattCapInfoDto> time12BadObjectDto = new NameValueObjectDto();
|
time12BadObjectDto.setName("劣化");
|
time12BadObjectDto.setValue(badListOfTime12.size()==0?new BattCapInfoDto():badListOfTime12.get(0));
|
NameValueObjectDto<BattCapInfoDto> time12DamageObjectDto = new NameValueObjectDto();
|
time12DamageObjectDto.setName("损坏");
|
time12DamageObjectDto.setValue(damageListOfTime12.size()==0?new BattCapInfoDto():damageListOfTime12.get(0));
|
time12ObjectDto.setValue(Arrays.asList(time12BadObjectDto,time12DamageObjectDto));
|
data2.add(time12ObjectDto);
|
|
NameValueListDto<NameValueObjectDto<BattCapInfoDto>> time2ObjectDto = new NameValueListDto<>();
|
time2ObjectDto.setName(time2+"年以上");
|
NameValueObjectDto<BattCapInfoDto> time2BadObjectDto = new NameValueObjectDto();
|
time2BadObjectDto.setName("劣化");
|
time2BadObjectDto.setValue(badListOfTime2.size()==0?new BattCapInfoDto():badListOfTime2.get(0));
|
NameValueObjectDto<BattCapInfoDto> time2DamageObjectDto = new NameValueObjectDto();
|
time2DamageObjectDto.setName("损坏");
|
time2DamageObjectDto.setValue(damageListOfTime2.size()==0?new BattCapInfoDto():damageListOfTime2.get(0));
|
time2ObjectDto.setValue(Arrays.asList(time2BadObjectDto,time2DamageObjectDto));
|
data2.add(time2ObjectDto);
|
|
return new Response().setII(1,data,data2,"");
|
|
}
|
|
public List<BattCapInfoDto> getBattCapInfo(List<BattInf> battInfList) {
|
//获取核容优劣,损坏参数
|
List<AppParam> paramList=appParamService.getHrParam();
|
Float badValue=0f;
|
Float damageValue=0f;
|
if(paramList!=null){
|
for (AppParam param:paramList) {
|
if(param.getParamNamePsx().equals("batt_mon_deteriorate_val")){
|
badValue=param.getParamValue();
|
}
|
if(param.getParamNamePsx().equals("batt_mon_damage_val")){
|
damageValue=param.getParamValue();
|
}
|
|
}
|
}
|
//1查询符合条件的电池组
|
if(battInfList==null||battInfList.size()==0){
|
//return new Response().set(1,false,"当前用户未管理满足条件的电池组");
|
}
|
List<BattCapInfoDto> capInfoList = new ArrayList<>();
|
|
for (BattInf battInf:battInfList) {
|
BattCapInfoDto capInfo = new BattCapInfoDto();
|
capInfo.setStationName(battInf.getStationName());
|
capInfo.setBattGroupName(battInf.getBattgroupName());
|
capInfo.setDeviceName(battInf.getDevName());
|
capInfo.setProduct(battInf.getProduct());
|
capInfo.setInuseTime(battInf.getInuseTime());
|
|
//2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电)
|
BatttestdataInf testInf = battTestDataInfService.getLastStandardTestDataByTime(battInf.getBattgroupId(), battInf.getInuseTime(),null);
|
if (testInf == null) {
|
capInfo.setRealCap(0f);
|
capInfo.setCapPercentage("0");
|
capInfo.setPerformance(Capperformance.BATTSTATE_4.getStateName());
|
continue;
|
}
|
//找这次放电的最后一笔数据
|
List<BatttestdataId> idDataList = battTestDataIdService.getLastDataByBattgroupId(testInf.getBattgroupId(), testInf.getTestRecordCount(), testInf.getRecordNum());
|
if (idDataList == null || idDataList.size() == 0) {
|
capInfo.setRealCap(0f);
|
capInfo.setCapPercentage("0");
|
capInfo.setPerformance(Capperformance.BATTSTATE_4.getStateName());
|
continue;
|
}
|
Float moncapStd = battInf.getMoncapstd();
|
int hourRate = BattCapFactory.GetHourRate(testInf.getTestCap(), testInf.getTestCurr());
|
Float groupRealCap = (float) BattCapFactory.GetMonomerCap(testInf.getTestCap(), hourRate, testInf.getTestCap(), testInf.getMaxMonvol(), testInf.getMinMonvol(), testInf.getGroupVol(), BattCapFactory.CapType_Real);
|
capInfo.setRealCap(groupRealCap);
|
if (groupRealCap >= moncapStd * badValue) {
|
capInfo.setPerformance(Capperformance.BATTSTATE_1.getStateName());
|
}
|
if (groupRealCap <= moncapStd * damageValue) {
|
capInfo.setPerformance(Capperformance.BATTSTATE_3.getStateName());
|
}
|
if ((groupRealCap > moncapStd * damageValue) && (groupRealCap < moncapStd * badValue)) {
|
capInfo.setPerformance(Capperformance.BATTSTATE_2.getStateName());
|
}
|
//保留5位小数
|
String capPercentage = String.format("%.5f", (groupRealCap / battInf.getMoncapstd() * 100));
|
capInfo.setCapPercentage(capPercentage);
|
|
capInfoList.add(capInfo);
|
}
|
return capInfoList;
|
}
|
|
}
|