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.ReportBattDTO;
|
import com.whyc.dto.Response;
|
import com.whyc.mapper.*;
|
import com.whyc.pojo.AlarmParam;
|
import com.whyc.pojo.BattParamLow;
|
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.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
@Service
|
public class BattMaintDealarmService {
|
@Resource
|
private BattMaintDealarmMapper mapper;
|
@Resource
|
private BattInfMapper battInfMapper;
|
@Resource
|
private BattParamLowMapper battParamLowMapper;
|
@Resource
|
private BattResDataMapper BattResDataMapper;
|
@Resource
|
AlarmParamMapper alarmParamMapper;
|
|
@Resource
|
private BatttestdataInfService batttestdataInfService;
|
|
public Response searchLow(ReportBattDTO tinf, int userId) {
|
Response res = new Response();
|
List<Battinf> battinfList = battInfMapper.searchByTestType(tinf, userId);
|
List<Map> result = new ArrayList<>();
|
if (battinfList != null && battinfList.size() > 0) {
|
BatttestdataInf btdinf = new BatttestdataInf();
|
btdinf.setRecordTime(tinf.getRecordStartTime());
|
btdinf.setRecordTime1(tinf.getRecordEndTime());
|
btdinf.setTestType(tinf.getTestType());
|
btdinf.setTestStarttype(tinf.getTestStartType());
|
for (Battinf binf : battinfList) {
|
btdinf.setBattGroupId(binf.getBattGroupId());
|
btdinf.setGroupVol(binf.getMonVolStd());
|
btdinf.setTestCap(binf.getMonCapStd());
|
btdinf.setTestRecordCount(binf.getTestRecordCount());
|
Map map = new HashMap();
|
map.put("battinf", binf);
|
//该电池组的放电结果
|
List<BatttestdataInf> batttestdataInfList = batttestdataInfService.searchByTestType(btdinf);
|
map.put("battTestDataInf", batttestdataInfList);
|
result.add(map);
|
}
|
}
|
return res.set(1,result,"查询成功");
|
}
|
|
//1.4电池性能评估
|
public Response searchGroupAssess(int pageNum,int pageSize,ReportBattDTO tinf, int userId){
|
PageHelper.startPage(pageNum,pageSize);
|
List<Battinf> battinfList = battInfMapper.searchGroupAssess(tinf, userId);
|
List<Map> result = new ArrayList<>();
|
Integer assess = tinf.getAssess();//性能筛选
|
if (battinfList!=null && battinfList.size()>0){
|
BatttestdataInf btdinf = new BatttestdataInf();
|
btdinf.setRecordTime(tinf.getRecordStartTime());
|
btdinf.setRecordTime1(tinf.getRecordEndTime());
|
btdinf.setTestType(tinf.getTestType());
|
btdinf.setTestStarttype(tinf.getTestStartType());
|
for (Battinf binf:battinfList) {
|
btdinf.setBattGroupId(binf.getBattGroupId());
|
btdinf.setGroupVol(binf.getMonVolStd());
|
btdinf.setTestCap(binf.getMonCapStd());
|
List batttestdataInfList = batttestdataInfService.searchDischargeTest(btdinf);
|
int flag = getAssess(batttestdataInfList, assess, binf.getMonCapStd());
|
if (flag == 1) {
|
Map map = new HashMap();
|
map.put("battinf", binf);
|
map.put("battTestDataInf", batttestdataInfList);
|
result.add(map);
|
}
|
}
|
}
|
PageInfo pageInfo = new PageInfo(result);
|
//pageInfo.setList(result);
|
return new Response().set(1, pageInfo, "查询成功");
|
}
|
|
//筛选蓄电池组后评性能
|
public int getAssess(List list, Integer assess, Float monCapStd) {
|
int flag = 0;
|
if (assess == null) {
|
assess = -1;
|
}
|
//直接去集合第2个数(放电次数),第6个数(实际预估容量:最近一次核容的实际容量)
|
int disNum = (int) list.get(1);
|
float realCap = (float) list.get(5);
|
//0.查询劣化(告警)和损坏(更换)的阈值
|
QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper();
|
alarmWrapper.and(wrapper -> {
|
return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange");
|
});
|
alarmWrapper.orderByAsc("alm_id");
|
List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
|
float capAlarm = 0f;
|
float capChange = 0f;
|
if (paramList != null && paramList.size() > 0) {
|
capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
|
capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
|
} else {
|
capAlarm = 0.8f;
|
capChange = 0.6f;
|
}
|
//获取评估参数
|
switch (assess) {
|
case -1:
|
flag = 1;
|
break;
|
case 0:
|
if (disNum == 0) {
|
flag = 1;
|
}
|
break;
|
case 1:
|
if (realCap > capAlarm * monCapStd) {
|
flag = 1;
|
}
|
break;
|
case 2:
|
if ((realCap <= capAlarm * monCapStd) && (realCap >= capChange * monCapStd)) {
|
flag = 1;
|
}
|
break;
|
case 3:
|
if (realCap < capChange * monCapStd) {
|
flag = 1;
|
}
|
break;
|
}
|
return flag;
|
}
|
|
public Response searchMonNum(ReportBattDTO dto) {
|
List list = new ArrayList();
|
if (dto.getTestType() == 3) {
|
list = mapper.searchByBattGroupId(dto);
|
}
|
if (dto.getTestType() == 5) {
|
list = mapper.searchByBattGroupId5(dto);
|
}
|
//添加内阻测试设置为标准值的那一笔,如果没有则拿最新的一笔
|
List listRes = new ArrayList();
|
listRes = BattResDataMapper.serchisStandard(dto.getBattGroupId().intValue());
|
if (listRes == null || listRes.size() <= 0) {
|
listRes = BattResDataMapper.serchCurrent(dto.getBattGroupId().intValue());
|
}
|
BattParamLow lowCA = new BattParamLow();
|
lowCA.setLowType(2);
|
lowCA.setLowNametype(2);//电容告警
|
BattParamLow lowCH = new BattParamLow();
|
lowCH.setLowType(2);
|
lowCH.setLowNametype(3);//电容更换
|
List<BattParamLow> listCA = battParamLowMapper.serchByLow(lowCA);
|
List<BattParamLow> listCH = battParamLowMapper.serchByLow(lowCH);
|
Float percentCA = listCA.get(0).getLowValue();
|
Float percentCH = listCH.get(0).getLowValue();
|
//电导基准/维护建议/电导分析值
|
BattParamLow lowRA=new BattParamLow();
|
lowRA.setLowType(3);
|
lowRA.setLowNametype(2);//电导告警
|
BattParamLow lowRH=new BattParamLow();
|
lowRH.setLowType(3);
|
lowRH.setLowNametype(3);//电导更换
|
|
//电导
|
List<BattParamLow> listRA = battParamLowMapper.serchByLow(lowRA);
|
List<BattParamLow> listRH = battParamLowMapper.serchByLow(lowRH);
|
Float percentRA = listRA.get(0).getLowValue();
|
Float percentRH = listRH.get(0).getLowValue();
|
int methodRM = listRA.get(0).getLowMethod(); //分析方式
|
|
Map<String, Object> map = new HashMap<>();
|
map.put("Data", list);
|
map.put("Data2", listRes);
|
map.put("LowCA", percentCA);
|
map.put("LowCH", percentCH);
|
map.put("LowRA", percentRA);
|
map.put("LowRH", percentRH);
|
map.put("newSum", methodRM);
|
|
return new Response().set(1, map, "查询成功");
|
}
|
|
|
}
|