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.*; import com.whyc.dto.paramter.GroupTestCapPar; import com.whyc.dto.result.GroupTestCapRes; import com.whyc.dto.result.ReportBattTestDTO; import com.whyc.mapper.*; import com.whyc.pojo.*; import com.whyc.util.ActionUtil; import com.whyc.util.MessageUtils; import com.whyc.util.ThreadLocalUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.time.Year; import java.util.*; import java.util.stream.Collectors; @Service public class BatttestdataInfService { @Resource private BatttestdataInfMapper mapper; @Resource private BattTestDataStopMapper stopMapper; @Resource private BattParamLowMapper battParamLowMapper; @Resource AlarmParamMapper alarmParamMapper; @Resource BattInfMapper binfMapper; @Resource BattalarmDataMapper alarmDataMapper; @Autowired private PageParamService pageParamService; @Autowired private SubTablePageInfoService subService; @Resource private BaoJiGroupMapper baoJiGroupMapper; //在线监测-历史监控-获取充放电记录 public Response searchBattTestInfDataById(int battGroupId, int fbsDeviceId) { //查询出 4种类型的过滤时间值 List pageParamList = pageParamService.getList2ByCategoryId(14); String lang = ActionUtil.getLang(); QueryWrapper wrapper = new QueryWrapper(); wrapper.eq("BattGroupId", battGroupId); wrapper.eq("data_available", 1); wrapper.orderByDesc("test_starttime"); int judgeNum = mapper.judge(battGroupId); if (judgeNum > 0) { List list = mapper.selectList(wrapper); //过滤 list = list.stream().filter(data->{ Integer testType = data.getTestType(); Integer testStarttype = data.getTestStarttype(); Integer testDatatype = data.getTestDatatype(); Integer testTimeLong = data.getTestTimelong(); if (testType == 3) { // 测试类型为放电 if (testStarttype == 3) { //核容放电 if(testTimeLong>=pageParamList.get(0).getStatus()*60){ return true; }else{ return false; } } else { if (testDatatype==1) { //停电放电 return true; } else { //监测放电 if(testTimeLong>=pageParamList.get(2).getStatus()*60){ return true; }else{ return false; } } } } else if (testType == 2) { // 测试类型为充电 if (testStarttype == 3) { //核容充电 if(testTimeLong>=pageParamList.get(1).getStatus()*60){ return true; }else{ return false; } } else { //监测充电 if(testTimeLong>=pageParamList.get(3).getStatus()*60){ return true; }else{ return false; } } }else{ return true; } }).collect(Collectors.toList()); list.stream().forEach(tinf -> { //放电终止原因 if (fbsDeviceId / 10000 == 61850) { //61850设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_6185(tinf.getTestStoptype())); }else if(fbsDeviceId / 10000 == 61852) { //61852设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_61852(tinf.getTestStoptype())); } else if (fbsDeviceId / 100000 == 4016) { //6度设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_4016(tinf.getTestStoptype())); } else if (fbsDeviceId / 100000 == 9110) { //假负载设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_9110(tinf.getTestStoptype())); } else if ((fbsDeviceId / 100000 == 9120) || (fbsDeviceId / 100000 == 9140)) { // 逆变设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_9120(tinf.getTestStoptype())); } else if (fbsDeviceId / 100000 == 8059) { //一体机设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_8059(tinf.getTestStoptype())); } else if (fbsDeviceId / 100000 == 6087) { //电操核容设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_6087(tinf.getTestStoptype())); } else if (fbsDeviceId / 100000 == 4830) { //FBO4830设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_4830(tinf.getTestStoptype())); } else if (fbsDeviceId / 100000 == 4831) { //FBO4831设备放电停止原因 tinf.setTestStoptypeReason(MessageUtils.getMessageSocket(BattTestData.getStopType_4831(tinf.getTestStoptype()), lang)); } else if (fbsDeviceId / 100000 == 4815) { //FBO4815设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_4815(tinf.getTestStoptype())); } else if (fbsDeviceId / 100000 == 6001) { //6001设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_6001(tinf.getTestStoptype())); }else if ((fbsDeviceId / 10000 == 61853)||(fbsDeviceId / 100000 == 6186)||(fbsDeviceId / 100000 == 6286)) { //61853设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_61853(tinf.getTestStoptype())); }else if((fbsDeviceId / 100000 == 6183)||(fbsDeviceId / 100000 == 6184)){ tinf.setTestStoptypeReason(BattTestData.getStopType_6183_4(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, int devId, String lang) { 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.last(" and (test_stoptype in (3, 4, 6) or (test_stoptype = 2 and test_timelong >= 7200)) ORDER BY test_starttime DESC "); BatttestdataInf tinf = mapper.selectOne(wrapper); List list = new ArrayList(); if (tinf != null) { //放电终止原因 if (devId / 10000 == 61850) { //61850设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_6185(tinf.getTestStoptype())); }else if(devId / 10000 == 61852) { //61852设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_61852(tinf.getTestStoptype())); } else if (devId / 100000 == 4016) { //6度设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_4016(tinf.getTestStoptype())); } else if (devId / 100000 == 9110) { //假负载设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_9110(tinf.getTestStoptype())); } else if ((devId / 100000 == 9120) || (devId / 100000 == 9140)) { // 逆变设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_9120(tinf.getTestStoptype())); } else if (devId / 100000 == 8059) { //一体机设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_8059(tinf.getTestStoptype())); } else if(devId / 100000 == 6087) { //电操核容设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_6087(tinf.getTestStoptype())); }else if (devId / 100000 == 4830) { // FBO4830设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_4830(tinf.getTestStoptype())); } else if (devId / 100000 == 4831) { // FBO4830设备放电停止原因 tinf.setTestStoptypeReason(MessageUtils.getMessageSocket(BattTestData.getStopType_4831(tinf.getTestStoptype()), lang)); } else if (devId / 100000 == 4815) { //FBO4815设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_4815(tinf.getTestStoptype())); } else if (devId / 100000 == 6001) { //6001设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_6001(tinf.getTestStoptype())); } else if ((devId / 10000 == 61853)|| (devId / 100000 == 6186)|| (devId / 100000 == 6286)) { //61853设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_61853(tinf.getTestStoptype())); } else if (devId / 100000 == 9149) { //FBO9149设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_9149(tinf.getTestStoptype())); }else if (devId / 100000 == 9150) { //山东定制9150设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_9150(tinf.getTestStoptype())); }else if((devId / 100000 == 6183)||(devId / 100000 == 6184)){ tinf.setTestStoptypeReason(BattTestData.getStopType_6183_4(tinf.getTestStoptype())); }else { tinf.setTestStoptypeReason(BattTestData.getStopType(tinf.getTestStarttype(), tinf.getTestStoptype())); } //list = stopMapper.getTestDataStop(tinf.getBattGroupId(), tinf.getTestStarttime()); list = subService.getTestDataStop(tinf.getBattGroupId(), tinf.getTestStarttime()); tinf.setBatttestdataList(list); } return new Response().setII(1, tinf != null ? true : false, tinf, ""); } //最后一次核容放电数据 public Response searchBattLastHrDataByIdDbs(int battGroupId, int devId, String lang) { 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.last(" and (test_stoptype in (3, 4, 6) or (test_stoptype = 2 and test_timelong >= 7200)) ORDER BY test_starttime DESC "); BatttestdataInf tinf = mapper.selectOne(wrapper); List list = new ArrayList(); if (tinf != null) { //放电终止原因 if (devId / 10000 == 61850) {//dbs为多宝山专用 //61850设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_6185DBS(tinf.getTestStoptype())); }else if(devId / 10000 == 61852) { //61852设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_61852(tinf.getTestStoptype())); } else if (devId / 100000 == 4016) { //6度设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_4016(tinf.getTestStoptype())); } else if (devId / 100000 == 9110) { //假负载设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_9110(tinf.getTestStoptype())); } else if ((devId / 100000 == 9120) || (devId / 100000 == 9140)) { // 逆变设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_9120(tinf.getTestStoptype())); } else if (devId / 100000 == 8059) { //一体机设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_8059(tinf.getTestStoptype())); } else if(devId / 100000 == 6087) { //电操核容设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_6087(tinf.getTestStoptype())); }else if (devId / 100000 == 4830) { // FBO4830设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_4830(tinf.getTestStoptype())); } else if (devId / 100000 == 4831) { // FBO4830设备放电停止原因 tinf.setTestStoptypeReason(MessageUtils.getMessageSocket(BattTestData.getStopType_4831(tinf.getTestStoptype()), lang)); } else if (devId / 100000 == 4815) { //FBO4815设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_4815(tinf.getTestStoptype())); } else if (devId / 100000 == 6001) { //6001设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_6001(tinf.getTestStoptype())); } else if ((devId / 10000 == 61853)|| (devId / 100000 == 6186)|| (devId / 100000 == 6286)) { //61853设备放电停止原因和6186 tinf.setTestStoptypeReason(BattTestData.getStopType_61853(tinf.getTestStoptype())); } else if (devId / 100000 == 9149) { //FBO9149设备放电停止原因 tinf.setTestStoptypeReason(BattTestData.getStopType_9149(tinf.getTestStoptype())); } else { tinf.setTestStoptypeReason(BattTestData.getStopType(tinf.getTestStarttype(), tinf.getTestStoptype())); } //list = stopMapper.getTestDataStop(tinf.getBattGroupId(), tinf.getTestStarttime()); list = subService.getTestDataStop(tinf.getBattGroupId(), tinf.getTestStarttime()); tinf.setBatttestdataList(list); } return new Response().setII(1, tinf != null ? true : false, tinf, ""); } //报表分析使用 public List searchByTestType(BatttestdataInf tinf){ List 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 Map searchDischargeTest(Integer battGroupId, float monCapStd, float monVolStd, Date recordStartTime, Date recordEndTime,int wj) { List list = new ArrayList<>(); Map map = new HashMap<>(); if(wj==0){//本年 list=mapper.searchDischargeTest(battGroupId, recordStartTime, recordEndTime); if( list.size()==0){ map.put("wj", "N"); }else{ map.put("wj", "J"); } }else if(wj==1){//往年 list = mapper.searchDischargeTest_WJ(battGroupId, recordStartTime); if( list.size()==0){ map.put("wj", "N"); }else{ map.put("wj", "W"); } }else if(wj==-1){//全部 list=mapper.searchDischargeTest(battGroupId, recordStartTime, recordEndTime); if( list.size()==0){ list = mapper.searchDischargeTest_WJ(battGroupId, recordStartTime); if( list.size()==0){ map.put("wj", "N"); }else{ map.put("wj", "W"); } }else{ map.put("wj", "J"); } } List testList = new LinkedList<>(); 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(monCapStd, binf.getTestCurr()); cap = (float) BattCapFactory.GetMonomerCap(monCapStd, hourRate, binf.getTestCap(), binf.getMaxMonvol(), binf.getMinMonvol(), monVolStd, BattCapFactory.CapType_Real); binf.setRealCap(cap); testList.add(binf); 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; } map.put("battGroupid", battGroupId); map.put("sum", sum); map.put("maxCap", maxCap); map.put("avgCap", avgCap); map.put("minCap", minCap); map.put("lastCap", lastCap); map.put("testList", testList); return map; } public Response searchBattLifeNow(int pageNum,int pageSize,Battinf binf){ PageHelper.startPage(pageNum,pageSize); List list = mapper.searchBattLifeNow(binf); PageInfo pageInfo = new PageInfo<>(list); return new Response().set(1,pageInfo,"查询成功"); } public Response searchBattLife(int pageNum,int pageSize,Battinf binf){ //PageHelper.startPage(pageNum,pageSize); List 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 listC = battParamLowMapper.serchByLow(capLow); if (listC!=null && listC.size()>0){ param = listC.get(listC.size()-1).getLowValue(); } int flag=0;//该次放电是否有效判断 List listE=new ArrayList();//存放放电有效的测试 //当前页记录列表 LinkedList data = new LinkedList<>(); //对结果进行分页 Page page = new Page(); if (list!=null &&list.size()>0){ for(int i=0;i0){ 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; } } page.setPageCurr(pageNum); page.setPageSize(pageSize); //总页数 page.setPageAll(listE.size()); if(listE.size()>pageSize*pageNum) { for (int i = (pageNum-1)*pageSize; i < pageSize*pageNum; i++) { data.add(listE.get(i)); } }else { int a1 = (pageNum - 1) * pageSize; int a2 = (listE.size() - ((pageNum - 1) * pageSize)); for (int i = (pageNum - 1) * pageSize; i < listE.size(); i++) { data.add(listE.get(i)); } } } page.setData(data); return new Response().set(1, page, "查询成功"); } //统计时间段内设备的测试容量 public Response searchGroupTestCap(GroupTestCapPar groupCapPar) { PageHelper.startPage(groupCapPar.getPageCurr(), groupCapPar.getPageSize()); List list = mapper.searchGroupTestCap(groupCapPar); PageInfo pageInfo = new PageInfo(list); return new Response().setII(1, list.size() > 0 ? true : false, pageInfo, "统计时间段内设备的测试容量"); } //管理员首页头部信息加入 public int getYearAnalysis(int userId) { //Map map = new HashMap<>(); //本年已核容放电电池组数 int hrdisNum = mapper.getHrQuarterZC(userId); //本年已停电放电电池组数 //int jcdisNum = mapper.getJcQuarter(userId); //map.put("hrdisNum", hrdisNum); // map.put("jcdisNum", jcdisNum); return hrdisNum; } //获取本年已核容电池组 public Response getHrYeardisBatt() { UserInf uinf = ActionUtil.getUser(); String userId = uinf.getUId().toString(); List list = mapper.getHrYeardisBatt(userId); return new Response().setII(1, list.size() > 0, list, "获取本年已核容电池组"); } //获取实时停电放电电池组 public Response getJcdisBatt() { UserInf uinf = ActionUtil.getUser(); String userId = uinf.getUId().toString(); List list = mapper.getJcdisBatt(userId); for (Battinf binf : list) { int battgroupId = 0; battgroupId = binfMapper.searchBattGroupId(binf.getStationId()); binf.setBattGroupId(battgroupId); } return new Response().setII(1, list.size() > 0, list, "获取本年已核容电池组"); } //测试信息 @Transactional public Response getTestdataInfAnalysis(int userId) { try { Map map = new HashMap<>(); //本月数据 List listMonth = mapper.selectMonth(userId); map.put("month", analysisTestData(listMonth)); //本季度 List listQuarter = mapper.selectQuarter(userId); map.put("quarter", analysisTestData(listQuarter)); //本年 List listYear = mapper.selectYear(userId); map.put("year", analysisTestData(listYear)); return new Response().setII(1, true, map, "测试信息"); } catch (Exception e) { return new Response().set(1, false, "发生异常:" + e.getCause()); } } /*管理员首页统计测试信息 if (testType == 3) { // 测试类型为放电 if (testStarttype == 3) { 核容放电 } else { if (testDatatype==1) { 停电放电 1 } else { 监测放电 0 } } } else if (testType == 2) { // 测试类型为充电 if (testStarttype == 3) { 核容充电 } else { 监测充电 } }*/ public Map analysisTestData(List list) { List pageParamList = pageParamService.getList2ByCategoryId(14); Map map = new HashMap<>(); int hrdisNum = 0;//核容放电 int jcdisNum = 0;//监测放电 int jcchNum = 0;//监测充电 int dddisNum = 0;//停电放电 int hrchNum = 0;//核容充电 if (list != null && list.size() > 0) { for (BatttestdataInf tinf : list) { if (tinf.getTestType() == 3) { // 测试类型为放电 if (tinf.getTestStarttype() == 3) { if ((tinf.getTestStoptype() == 3 || tinf.getTestStoptype() == 4 || tinf.getTestStoptype() == 6) || (tinf.getTestStoptype() == 2 && tinf.getTestTimelong() >= 7200)) { hrdisNum += 1; } } else { if (tinf.getTestDatatype() == 1) { dddisNum += 1; } if (tinf.getTestDatatype() == 0) { if(tinf.getTestTimelong()>=pageParamList.get(2).getStatus()*60) { jcdisNum += 1; } } } } else if (tinf.getTestType() == 2) { // 测试类型为充电 if (tinf.getTestStarttype() == 3) { hrchNum += 1; } else { if(tinf.getTestTimelong()>=pageParamList.get(3).getStatus()*60) { jcchNum += 1; } } } } } map.put("hrdisNum", hrdisNum); map.put("hrchNum", hrchNum); map.put("jcdisNum", jcdisNum); map.put("dddisNum", dddisNum); map.put("jcchNum", jcchNum); return map; } //查询今天所有正在放电的机房总数 public int getPlanStaticToday(int userId) { int num = mapper.getPlanStaticToday(userId); return num; } //本年度核容放电电池组(testdate_inf中test_type=3,test_startType=3) public int getHrQuarter(int userId) { //本年度 int hrQuarter = mapper.getHrQuarter(userId); return hrQuarter; } /*领导层本年度已放数 仅需要统计放电正常停止的 正常停止的条件如下: stop_type: 2-放电时间到终止 3-放电容量到终止 4-单体电压下限到终止 6-组端电压下限到终止 并且放电时间超过2小时*/ public int getHrQuarterZC(int userId) { int hrQuarter = mapper.getHrQuarterZC(userId); return hrQuarter; } //山西晋源特定接口 public int getHrQuarterZCJY() { int hrQuarter = mapper.getHrQuarterZCJY(); return hrQuarter; } //蓄电池组优劣分析(用蓄电池组组后评估的统计) public Response getGroupAnalysis(int userId) { try { //0.查询劣化(告警)和损坏(更换)的阈值 QueryWrapper 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 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; } //小于capAlarm int alarmNum = 0; //小于capChange int changeNum = 0; //放电正常 int goodSum = 0; //未正常 int noHrDisNum = 0; //去年的数据---------------- //小于capAlarm int oldalarmNum = 0; //小于capChange int oldchangeNum = 0; //放电正常 int oldgoodSum = 0; //未正常 int oldnoHrDisNum = 0; //0.查询所有的电池组 List binfList = binfMapper.getBinfList(userId); if (binfList != null && binfList.size() > 0) { for (Battinf binf : binfList) { //实际容量 float cap = 0f; //实际容量去年 float oldcap = 0f; int battgroupId = binf.getBattGroupId(); float monCapStd = binf.getMonCapStd(); float monVolstd = binf.getMonVolStd(); //放电次数 int disNum = 0; int olddisNum = 0; //1.查出符合条件的电池组(核容数据)按照时间倒叙排序的第一个(本年度) BatttestdataInf inf = mapper.getGroupAnalysisQB(battgroupId); //1.查出符合条件的电池组(核容数据)按照时间倒叙排序的第一个(上一年度) BatttestdataInf oldinf = mapper.getGroupAnalysisQBOld(battgroupId); if (inf != null) { disNum = 1; int hourRate = BattCapFactory.GetHourRate(monCapStd, inf.getTestCurr()); cap = (float) BattCapFactory.GetMonomerCap(monCapStd, hourRate, inf.getTestCap(), inf.getMaxMonvol(), inf.getMinMonvol(), monVolstd, BattCapFactory.CapType_Real); } if(oldinf!=null){ olddisNum=1; int oldhourRate = BattCapFactory.GetHourRate(monCapStd, oldinf.getTestCurr()); oldcap = (float) BattCapFactory.GetMonomerCap(monCapStd, oldhourRate, oldinf.getTestCap(), oldinf.getMaxMonvol(), oldinf.getMinMonvol(), monVolstd, BattCapFactory.CapType_Real); } //查询电池告警(劣化:内阻过高重要,电压过低重要;损坏:内阻过高紧急,电压过低紧急) List listALmSH = alarmDataMapper.getAlm(battgroupId, 3); List listALmLH = alarmDataMapper.getAlm(battgroupId, 2); //先判断是否损坏 if ((disNum != 0 && cap < capChange * monCapStd) || (listALmSH != null && listALmSH.size() > 0)) { if (disNum == 0) { noHrDisNum += 1; } changeNum = changeNum + 1; }//在判断是否劣化 else if ( (disNum != 0 && cap <= capAlarm * monCapStd && cap >= capChange * monCapStd ) || (listALmLH != null && listALmLH.size() > 0)) { if (disNum == 0) { noHrDisNum += 1; } alarmNum = alarmNum + 1; }//再判断是否放电正常 else if (disNum != 0 && cap > capAlarm * monCapStd) { if (disNum == 0) { noHrDisNum += 1; } goodSum = goodSum + 1; } else { noHrDisNum += 1; } //去年-----------------的数据 //先判断是否损坏 if ((olddisNum != 0 && oldcap < capChange * monCapStd) || (listALmSH != null && listALmSH.size() > 0)) { if (olddisNum == 0) { oldnoHrDisNum += 1; } oldchangeNum = oldchangeNum + 1; }//在判断是否劣化 else if ( (olddisNum != 0 && oldcap <= capAlarm * monCapStd && oldcap >= capChange * monCapStd ) || (listALmLH != null && listALmLH.size() > 0)) { if (olddisNum == 0) { oldnoHrDisNum += 1; } oldalarmNum = oldalarmNum + 1; }//再判断是否放电正常 else if (olddisNum != 0 && oldcap > capAlarm * monCapStd) { if (olddisNum == 0) { oldnoHrDisNum += 1; } oldgoodSum = oldgoodSum + 1; } else { oldnoHrDisNum += 1; } } } Map numMap = new HashMap<>(); numMap.put("alarmNum", alarmNum); numMap.put("changeNum", changeNum); //总电池组(分类) int groupNum = binfMapper.geGroupCount(userId); numMap.put("groupNum", groupNum); /*//已放电电池组数 int inDischargeNum = binfMapper.searchInDischarge(userId);*/ //蓄电池优良(已经放电数-告警数) numMap.put("goodSum", goodSum); /*本年度已核容放电电池组(testdate_inf中test_type=3,test_startType=3) int hrDisNum = testInfService.getHrQuarter(userId); * 修改为:领导层本年度已放数 仅需要统计放电正常停止的 正常停止的条件如下: stop_type: 2-放电时间到终止并且放电时间超过2小时 3-放电容量到终止 4-单体电压下限到终止 6-组端电压下限到终止*/ //int hrDisNum = mapper.getHrQuarterZC(userId); numMap.put("noHrDisNum", noHrDisNum); //去年----------------------------统计 Map oldnumMap = new HashMap<>(); oldnumMap.put("alarmNum", oldalarmNum); oldnumMap.put("changeNum", oldchangeNum); //总电池组(分类) oldnumMap.put("groupNum", groupNum); //蓄电池优良(已经放电数-告警数) oldnumMap.put("goodSum", oldgoodSum); /*本年度已核容放电电池组(testdate_inf中test_type=3,test_startType=3) int hrDisNum = testInfService.getHrQuarter(userId); * 修改为:领导层本年度已放数 仅需要统计放电正常停止的 正常停止的条件如下: stop_type: 2-放电时间到终止并且放电时间超过2小时 3-放电容量到终止 4-单体电压下限到终止 6-组端电压下限到终止*/ oldnumMap.put("noHrDisNum", oldnoHrDisNum); return new Response().setIII(1, true, numMap,oldnumMap, "蓄电池组优劣分析"); } catch (Exception e) { return new Response<>().set(1, false, "发生异常:" + e.getCause()); } } //蓄电池组优劣分析(用蓄电池组组后评估的统计) public Response getGroupAnalysis2(int userId) { try { //0.查询劣化(告警)和损坏(更换)的阈值 QueryWrapper 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 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; } //获取当前年 int year = Year.now().getValue(); Date nowDateStart=ThreadLocalUtil.parse(year+"-01-01 00:00:00",1); Date nowDateEnd=ThreadLocalUtil.parse(year+"-12-31 23:59:59",1); Date oldDateStart=ThreadLocalUtil.parse((year-1)+"-01-01 00:00:00",1); Date oldDateEnd=ThreadLocalUtil.parse((year-1)+"-12-31 23:59:59",1); //小于capAlarm int alarmNum = 0; //小于capChange int changeNum = 0; //放电正常 int goodSum = 0; //未正常 int noHrDisNum = 0; //去年的数据---------------- //小于capAlarm int oldalarmNum = 0; //小于capChange int oldchangeNum = 0; //放电正常 int oldgoodSum = 0; //未正常 int oldnoHrDisNum = 0; //0.查询所有的电池组 List binfList = binfMapper.getBinfList(userId); if (binfList != null && binfList.size() > 0) { for (Battinf binf : binfList) { //实际容量 float cap = 0f; float oldcap = 0f; //放电次数 int disNum = 0; int olddisNum = 0; int battgroupId = binf.getBattGroupId(); float monCapStd = binf.getMonCapStd(); float monVolstd = binf.getMonVolStd(); //1.查出符合条件的电池组(核容数据)按照时间倒叙排序的第一个(本年度) BatttestdataInf inf = mapper.getGroupAnalysisQB_WJ(battgroupId,nowDateStart,nowDateEnd); //1.查出符合条件的电池组(核容数据)按照时间倒叙排序的第一个(上一年度) BatttestdataInf oldinf = mapper.getGroupAnalysisQB_WJ(battgroupId,oldDateStart,oldDateEnd); if (inf != null) { disNum=1; int hourRate = BattCapFactory.GetHourRate(monCapStd, inf.getTestCurr()); cap = (float) BattCapFactory.GetMonomerCap(monCapStd, hourRate, inf.getTestCap(), inf.getMaxMonvol(), inf.getMinMonvol(), monVolstd, BattCapFactory.CapType_Real); } if(oldinf!=null){ olddisNum=1; int oldhourRate = BattCapFactory.GetHourRate(monCapStd, oldinf.getTestCurr()); oldcap = (float) BattCapFactory.GetMonomerCap(monCapStd, oldhourRate, oldinf.getTestCap(), oldinf.getMaxMonvol(), oldinf.getMinMonvol(), monVolstd, BattCapFactory.CapType_Real); } //查询电池告警内阻告警 List listALmRes = alarmDataMapper.getAlm2(battgroupId); //未放电:本年度未放电,且无内阻告警<13,14>(预告警(重要),告警(紧急))-----本年度 if( (disNum==0) ){ noHrDisNum+=1; } //优秀:本年度已放电,且容量健康,无内阻告警(预告警(重要),告警(紧急)) if( (disNum>0)&&(cap > capAlarm * monCapStd)&&(listALmRes.size()<=0)){ goodSum+=1; } /*劣化:本年度未放电,内阻告警(预告警(重要),告警(紧急)) *容量小于劣化阈值,大于损坏阈值,内阻告警(预告警,告警) * 容量小于劣化阈值,内阻正常 * 容量正常,内阻告警(预告警,告警) */ if (((disNum==0)&&(listALmRes.size()>0)) ||((disNum>0)&&(cap <= capAlarm * monCapStd && cap >= capChange * monCapStd)&&(listALmRes.size()>0)) ||((disNum>0)&&(cap <= capAlarm * monCapStd)&&(listALmRes.size()<=0)) ||(disNum>0)&&(cap > capAlarm * monCapStd)&&(listALmRes.size()>0)){ alarmNum+=1; } //损坏:容量低,内阻告警 if((disNum>0)&&(cap< capChange * monCapStd)&&(listALmRes.size()>0)){ changeNum+=1; } //未放电:本年度未放电,且无内阻告警<13,14>(预告警(重要),告警(紧急))-----其他年度 if( (olddisNum==0) ){ oldnoHrDisNum+=1; } //优秀:本年度已放电,且容量健康,无内阻告警(预告警(重要),告警(紧急)) if( (olddisNum>0)&&(oldcap > capAlarm * monCapStd)&&(listALmRes.size()<=0)){ oldgoodSum+=1; } /*劣化:本年度未放电,内阻告警(预告警(重要),告警(紧急)) *容量小于劣化阈值,大于损坏阈值,内阻告警(预告警,告警) * 容量小于劣化阈值,内阻正常 * 容量正常,内阻告警(预告警,告警) */ if (((olddisNum==0)&&(listALmRes.size()>0)) ||((olddisNum>0)&&(oldcap <= capAlarm * monCapStd && oldcap >= capChange * monCapStd)&&(listALmRes.size()>0)) ||((olddisNum>0)&&(oldcap <= capAlarm * monCapStd)&&(listALmRes.size()<=0)) ||(olddisNum>0)&&(oldcap > capAlarm * monCapStd)&&(listALmRes.size()>0)){ oldalarmNum+=1; } //损坏:容量低,内阻告警 if((olddisNum>0)&&(oldcap< capChange * monCapStd)&&(listALmRes.size()>0)){ oldchangeNum+=1; } } } Map numMap = new HashMap<>(); numMap.put("alarmNum", alarmNum); numMap.put("changeNum", changeNum); //总电池组(分类) int groupNum = binfMapper.geGroupCount(userId); numMap.put("groupNum", groupNum); /*//已放电电池组数 int inDischargeNum = binfMapper.searchInDischarge(userId);*/ //蓄电池优良(已经放电数-告警数) numMap.put("goodSum", goodSum); /*本年度已核容放电电池组(testdate_inf中test_type=3,test_startType=3) int hrDisNum = testInfService.getHrQuarter(userId); * 修改为:领导层本年度已放数 仅需要统计放电正常停止的 正常停止的条件如下: stop_type: 2-放电时间到终止并且放电时间超过2小时 3-放电容量到终止 4-单体电压下限到终止 6-组端电压下限到终止*/ //int hrDisNum = mapper.getHrQuarterZC(userId); numMap.put("noHrDisNum", noHrDisNum); //去年----------------------------统计 Map oldnumMap = new HashMap<>(); oldnumMap.put("alarmNum", oldalarmNum); oldnumMap.put("changeNum", oldchangeNum); //总电池组(分类) oldnumMap.put("groupNum", groupNum); //蓄电池优良(已经放电数-告警数) oldnumMap.put("goodSum", oldgoodSum); /*本年度已核容放电电池组(testdate_inf中test_type=3,test_startType=3) int hrDisNum = testInfService.getHrQuarter(userId); * 修改为:领导层本年度已放数 仅需要统计放电正常停止的 正常停止的条件如下: stop_type: 2-放电时间到终止并且放电时间超过2小时 3-放电容量到终止 4-单体电压下限到终止 6-组端电压下限到终止*/ oldnumMap.put("noHrDisNum", oldnoHrDisNum); return new Response().setIII(1, true, numMap,oldnumMap, "蓄电池组优劣分析"); } catch (Exception e) { return new Response<>().set(1, false, "发生异常:" + e.getCause()); } } //蓄电池组优劣分析(用蓄电池组组后评估的统计) public Response getGroupAnalysis3(int userId) { try { //0.查询劣化(告警)和损坏(更换)的阈值 QueryWrapper 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 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; } //获取当前年 int year = Year.now().getValue(); Date nowDateStart=ThreadLocalUtil.parse(year+"-01-01 00:00:00",1); Date nowDateEnd=ThreadLocalUtil.parse(year+"-12-31 23:59:59",1); Date oldDateStart=ThreadLocalUtil.parse((year-1)+"-01-01 00:00:00",1); Date oldDateEnd=ThreadLocalUtil.parse((year-1)+"-12-31 23:59:59",1); //小于capAlarm int alarmNum = 0; //小于capChange int changeNum = 0; //放电正常 int goodSum = 0; //未正常 int noHrDisNum = 0; //去年的数据---------------- //小于capAlarm int oldalarmNum = 0; //小于capChange int oldchangeNum = 0; //放电正常 int oldgoodSum = 0; //未正常 int oldnoHrDisNum = 0; //0.查询所有的电池组 List binfList = binfMapper.getBinfList(userId); if (binfList != null && binfList.size() > 0) { for (Battinf binf : binfList) { //实际容量 float cap = 0f; float oldcap = 0f; //放电次数 int disNum = 0; int olddisNum = 0; int battgroupId = binf.getBattGroupId(); float monCapStd = binf.getMonCapStd(); float monVolstd = binf.getMonVolStd(); //1.查出符合条件的电池组(核容数据)按照时间倒叙排序的第一个(本年度) BatttestdataInf inf = mapper.getGroupAnalysisQB_WJ(battgroupId,nowDateStart,nowDateEnd); //1.查出符合条件的电池组(核容数据)按照时间倒叙排序的第一个(上一年度) BatttestdataInf oldinf = mapper.getGroupAnalysisQB_WJ(battgroupId,oldDateStart,oldDateEnd); if (inf != null) { disNum=1; int hourRate = BattCapFactory.GetHourRate(monCapStd, inf.getTestCurr()); cap = (float) BattCapFactory.GetMonomerCap(monCapStd, hourRate, inf.getTestCap(), inf.getMaxMonvol(), inf.getMinMonvol(), monVolstd, BattCapFactory.CapType_Real); } if(oldinf!=null){ olddisNum=1; int oldhourRate = BattCapFactory.GetHourRate(monCapStd, oldinf.getTestCurr()); oldcap = (float) BattCapFactory.GetMonomerCap(monCapStd, oldhourRate, oldinf.getTestCap(), oldinf.getMaxMonvol(), oldinf.getMinMonvol(), monVolstd, BattCapFactory.CapType_Real); } //未放电:本年度未放电,且无内阻告警<13,14>(预告警(重要),告警(紧急))-----本年度 if( (disNum==0) ){ noHrDisNum+=1; } //优秀:本年度已放电,且容量健康) if( (disNum>0)&&(cap > capAlarm * monCapStd)){ goodSum+=1; } /*劣化: *容量小于劣化阈值,大于损坏阈值 */ if (((disNum>0)&&(cap <= capAlarm * monCapStd && cap >= capChange * monCapStd))){ alarmNum+=1; } //损坏:容量低 if((disNum>0)&&(cap< capChange * monCapStd)){ changeNum+=1; } //未放电:本年度未放电,且无内阻告警<13,14>(预告警(重要),告警(紧急))-----其他年度 if( (olddisNum==0) ){ oldnoHrDisNum+=1; } //优秀:本年度已放电,且容量健康) if( (olddisNum>0)&&(oldcap > capAlarm * monCapStd)){ oldgoodSum+=1; } /*劣化 *容量小于劣化阈值,大于损坏阈值 * */ if (((olddisNum>0)&&(oldcap <= capAlarm * monCapStd && oldcap >= capChange * monCapStd))){ oldalarmNum+=1; } //损坏:容量低 if((olddisNum>0)&&(oldcap< capChange * monCapStd)){ oldchangeNum+=1; } } } Map numMap = new HashMap<>(); numMap.put("alarmNum", alarmNum); numMap.put("changeNum", changeNum); //总电池组(分类) int groupNum = binfMapper.geGroupCount(userId); numMap.put("groupNum", groupNum); /*//已放电电池组数 int inDischargeNum = binfMapper.searchInDischarge(userId);*/ //蓄电池优良(已经放电数-告警数) numMap.put("goodSum", goodSum); /*本年度已核容放电电池组(testdate_inf中test_type=3,test_startType=3) int hrDisNum = testInfService.getHrQuarter(userId); * 修改为:领导层本年度已放数 仅需要统计放电正常停止的 正常停止的条件如下: stop_type: 2-放电时间到终止并且放电时间超过2小时 3-放电容量到终止 4-单体电压下限到终止 6-组端电压下限到终止*/ //int hrDisNum = mapper.getHrQuarterZC(userId); numMap.put("noHrDisNum", noHrDisNum); //去年----------------------------统计 Map oldnumMap = new HashMap<>(); oldnumMap.put("alarmNum", oldalarmNum); oldnumMap.put("changeNum", oldchangeNum); //总电池组(分类) oldnumMap.put("groupNum", groupNum); //蓄电池优良(已经放电数-告警数) oldnumMap.put("goodSum", oldgoodSum); /*本年度已核容放电电池组(testdate_inf中test_type=3,test_startType=3) int hrDisNum = testInfService.getHrQuarter(userId); * 修改为:领导层本年度已放数 仅需要统计放电正常停止的 正常停止的条件如下: stop_type: 2-放电时间到终止并且放电时间超过2小时 3-放电容量到终止 4-单体电压下限到终止 6-组端电压下限到终止*/ oldnumMap.put("noHrDisNum", oldnoHrDisNum); return new Response().setIII(1, true, numMap,oldnumMap, "蓄电池组优劣分析"); } catch (Exception e) { return new Response<>().set(1, false, "发生异常:" + e.getCause()); } } //获取本年已核容放电电池组最新一次数据详情 public Response getHrYeardisBattInfo() { int userId = Integer.parseInt(ActionUtil.getUser().getUId().toString()); try { //0.查询劣化(告警)和损坏(更换)的阈值 QueryWrapper 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 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; } //1.查出符合条件的电池组(核容数据)按照时间倒叙排序 List list = mapper.getGroupAnalysis(userId); //2.分组取出每个电池组的最新一笔数据(取电池组放电数据的第一个) List infoList = new ArrayList<>(); String battGroupId = "0"; if (list != null && list.size() > 0) { for (BatttestdataInf inf : list) { if (!battGroupId.equals(inf.getBattGroupId().toString())) { int hourRate = BattCapFactory.GetHourRate(inf.getMonCapStd(), inf.getTestCurr()); float cap = (float) BattCapFactory.GetMonomerCap(inf.getMonCapStd(), hourRate, inf.getTestCap(), inf.getMaxMonvol(), inf.getMinMonvol(), inf.getMonVolStd(), BattCapFactory.CapType_Real); inf.setRealCap(cap); infoList.add(inf); battGroupId = inf.getBattGroupId().toString(); } } } return new Response().setII(1, true, infoList, "获取本年已核容放电电池组最新一次数据详情"); } catch (Exception e) { return new Response<>().set(1, false, "发生异常:" + e.getCause()); } } //获取本年已核容放电电池组最新一次数据详情(正常) public Response getHrYeardisBattInfoZC() { int userId = Integer.parseInt(ActionUtil.getUser().getUId().toString()); String lang = ActionUtil.getLang(); try { //0.查询劣化(告警)和损坏(更换)的阈值 QueryWrapper 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 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; } //1.查出符合条件的电池组(核容数据)按照时间倒叙排序 List list = mapper.getGroupAnalysisZC(userId); //2.分组取出每个电池组的最新一笔数据(取电池组放电数据的第一个) List infoList = new ArrayList<>(); String battGroupId = "0"; if (list != null && list.size() > 0) { for (BatttestdataInf inf : list) { if (!battGroupId.equals(inf.getBattGroupId().toString())) { int hourRate = BattCapFactory.GetHourRate(inf.getMonCapStd(), inf.getTestCurr()); float cap = (float) BattCapFactory.GetMonomerCap(inf.getMonCapStd(), hourRate, inf.getTestCap(), inf.getMaxMonvol(), inf.getMinMonvol(), inf.getMonVolStd(), BattCapFactory.CapType_Real); inf.setRealCap(cap); //放电终止原因 if (inf.getFBSDeviceId() / 10000 == 61850) { //61850设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_6185(inf.getTestStoptype())); }else if(inf.getFBSDeviceId() / 10000 == 61852) { //61852设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_61852(inf.getTestStoptype())); } else if (inf.getFBSDeviceId() / 100000 == 4016) { //6度设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_4016(inf.getTestStoptype())); } else if (inf.getFBSDeviceId() / 100000 == 9110) { //假负载设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_9110(inf.getTestStoptype())); } else if ((inf.getFBSDeviceId() / 100000 == 9120) || (inf.getFBSDeviceId() / 100000 == 9140)) { // 逆变设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_9120(inf.getTestStoptype())); } else if (inf.getFBSDeviceId() / 100000 == 8059) { //一体机设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_8059(inf.getTestStoptype())); } else if (inf.getFBSDeviceId() / 100000 == 6087) { //电操核容设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_6087(inf.getTestStoptype())); } else if (inf.getFBSDeviceId() / 100000 == 4830) { //FBO4830设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_4830(inf.getTestStoptype())); } else if (inf.getFBSDeviceId() / 100000 == 4831) { //FBO4831设备放电停止原因 inf.setTestStoptypeReason(MessageUtils.getMessageSocket(BattTestData.getStopType_4831(inf.getTestStoptype()), lang)); } else if (inf.getFBSDeviceId() / 100000 == 4815) { //FBO4815设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_4815(inf.getTestStoptype())); } else if (inf.getFBSDeviceId() / 100000 == 6001) { //6001设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_6001(inf.getTestStoptype())); } else if ((inf.getFBSDeviceId() / 10000 == 61853)||(inf.getFBSDeviceId() / 100000 == 6186)||(inf.getFBSDeviceId() / 100000 == 6286)) { //61853设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_61853(inf.getTestStoptype())); } else if (inf.getFBSDeviceId() / 100000 == 9149) { //FBO4815设备放电停止原因 inf.setTestStoptypeReason(BattTestData.getStopType_9149(inf.getTestStoptype())); } else { inf.setTestStoptypeReason(BattTestData.getStopType(inf.getTestStarttype(), inf.getTestStoptype())); } infoList.add(inf); battGroupId = inf.getBattGroupId().toString(); } } } return new Response().setII(1, true, infoList, "获取本年已核容放电电池组最新一次数据详情正常"); } catch (Exception e) { return new Response<>().set(1, false, "发生异常:" + e.getCause()); } } //本年度上一次正常核容的放电记录编号 public Response searchHrYear(int battGroupId) { BatttestdataInf tinf = mapper.searchHrYear(battGroupId); int testNumber = 0; if (tinf != null) { testNumber = tinf.getNum(); } return new Response().setII(1, true, testNumber, "本年度上一次正常核容的放电记录编号"); } //能效统计 public Response getEnergyStatistics(int year) { Calendar calendar = Calendar.getInstance(); int nowYear= calendar.get(Calendar.YEAR); int lastYear=nowYear-year+1; Date date1 = ThreadLocalUtil.parse(lastYear+"-01-01 00:00:00",1 ); Date date2 = ThreadLocalUtil.parse(nowYear+"-12-31 23:59:59",1 ); List list=mapper.getEnergyStatistics(date1,date2); Map sCountMap=new HashMap<>(); Map sCapMap=new HashMap<>(); for (int i=0;i> yearMap = list.stream().collect(Collectors.groupingBy(GroupTestCapRes::getYearTime)); for (Integer yearTime : yearMap.keySet()) { sCountMap.put(yearTime,yearMap.get(yearTime).size()); List groupList=yearMap.get(yearTime); Double sum = groupList.stream().collect(Collectors.summingDouble(GroupTestCapRes::getTestCap)); sCapMap.put(yearTime,String.format("%.3f",sum)); } return new Response().setIII(1, true, sCountMap,sCapMap, "能效统计"); } //能效统计分班组 public Response getEnergyStatisticsInBaojiGroup(int year) { Calendar calendar = Calendar.getInstance(); int nowYear= calendar.get(Calendar.YEAR); int lastYear=nowYear-year+1; Date date1 = ThreadLocalUtil.parse(lastYear+"-01-01 00:00:00",1 ); Date date2 = ThreadLocalUtil.parse(nowYear+"-12-31 23:59:59",1 ); //1.查询出所有的班组 QueryWrapper wrapper=new QueryWrapper(); wrapper.eq("discharge_plan_flag",1); List listbj=baoJiGroupMapper.selectList(wrapper); List listeg=new ArrayList<>(); if(listbj!=null&&listbj.size()>0){ for (BaoJiGroup bj:listbj) { EnergyStatisticDto egDto=new EnergyStatisticDto(); egDto.setBaoJiGroup(bj); Long bjGroupId=bj.getBaoJiGroupId(); List list=mapper.getEnergyStatisticsInBaojiGroup(date1,date2,bjGroupId); Map sCountMap=new HashMap<>(); Map sCapMap=new HashMap<>(); for (int i=0;i> yearMap = list.stream().collect(Collectors.groupingBy(GroupTestCapRes::getYearTime)); for (Integer yearTime : yearMap.keySet()) { sCountMap.put(yearTime,yearMap.get(yearTime).size()); List groupList=yearMap.get(yearTime); Double sum = groupList.stream().collect(Collectors.summingDouble(GroupTestCapRes::getTestCap)); sCapMap.put(yearTime,String.format("%.3f",sum)); } egDto.setSCapMap(sCapMap); listeg.add(egDto); } } return new Response().setII(1, true, listeg, "能效统计分班组"); } //能效统计分班组 public Response getEnergyStatisticsInBaojiGroupWithOutYear(int year) { Calendar calendar = Calendar.getInstance(); int nowYear= calendar.get(Calendar.YEAR); int lastYear=nowYear-year+1; Date date1 = ThreadLocalUtil.parse(lastYear+"-01-01 00:00:00",1 ); Date date2 = ThreadLocalUtil.parse(nowYear+"-12-31 23:59:59",1 ); //1.查询出所有的班组 QueryWrapper wrapper=new QueryWrapper(); wrapper.eq("discharge_plan_flag",1); List listbj=baoJiGroupMapper.selectList(wrapper); Map sCountMap=new HashMap<>(); Map sCapMap=new HashMap<>(); if(listbj!=null&&listbj.size()>0){ for (BaoJiGroup bj:listbj) { Long bjGroupId=bj.getBaoJiGroupId(); List list=mapper.getEnergyStatisticsInBaojiGroup(date1,date2,bjGroupId); sCountMap.put(bj.getBaoJiGroupName(),list.size()); Double sum = list.stream().collect(Collectors.summingDouble(GroupTestCapRes::getTestCap)); sCapMap.put(bj.getBaoJiGroupName(),String.format("%.3f",sum)); } } return new Response().setIII(1, true, sCountMap,sCapMap, "能效统计"); } //能效统计--南京websocket首页 public Response getEnergyStatistics_nj(int year,int userId) { Calendar calendar = Calendar.getInstance(); int nowYear= calendar.get(Calendar.YEAR); int lastYear=nowYear-year+1; Date date1 = ThreadLocalUtil.parse(lastYear+"-01-01 00:00:00",1 ); Date date2 = ThreadLocalUtil.parse(nowYear+"-12-31 23:59:59",1 ); List list=mapper.getEnergyStatistics_nj(date1,date2,userId); Map sCountMap=new HashMap<>(); Map sCapMap=new HashMap<>(); for (int i=0;i> yearMap = list.stream().collect(Collectors.groupingBy(GroupTestCapRes::getYearTime)); for (Integer yearTime : yearMap.keySet()) { sCountMap.put(yearTime,yearMap.get(yearTime).size()); List groupList=yearMap.get(yearTime); Double sum = groupList.stream().collect(Collectors.summingDouble(GroupTestCapRes::getTestCap)); sCapMap.put(yearTime,String.format("%.3f",sum)); } return new Response().setIII(1, true, sCountMap,sCapMap, "能效统计"); } //1.获取当前最大的放电信息testRecordCount public BatttestdataInf getMaxRecord(int battGroupId) { QueryWrapper wrapper=new QueryWrapper(); wrapper.eq("battGroupId",battGroupId); wrapper.last("limit 1"); wrapper.orderByDesc("test_record_count"); BatttestdataInf tinf=mapper.selectOne(wrapper); return tinf; } //3.将tinf补齐 public void insertTinf(BatttestdataInf tinf) { mapper.insert(tinf); } }