whyclxw
2025-06-10 84403b5ebe123b200f4bfba5848dd8307d99e8d2
src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -4,6 +4,7 @@
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.constant.Capperformance;
import com.whyc.constant.PowerAlarmEnum;
import com.whyc.constant.StopReasonEnum;
import com.whyc.dto.Real.TestDataDto;
import com.whyc.dto.Response;
@@ -86,7 +87,7 @@
                BattInf binf=battInfService.getBinfByBattgroupId(tinf.getBattgroupId());
                //实时组端电流,剩余容量,标称容量
                if(battRtstate!=null){
                    Float restTime= BattCapFactory.getTheoryTime(battRtstate.getGroupCurr(), restCap, binf.getMoncapstd());
                    Float restTime= BattCapFactory.getTheoryTime(battRtstate.getLoadCurr(), restCap, binf.getMoncapstd());
                    tinf.setRestTime(restTime);
                }
                //保留5位小数
@@ -107,6 +108,7 @@
        wrapper.last("  and test_timelong >= 7200 ORDER BY test_starttime DESC ");
        wrapper.last("limit 1");
        BatttestdataInf tinf = mapper.selectOne(wrapper);
        tinf.setTestStoptypeReason(StopReasonEnum.getValue(tinf.getTestStoptype()));
        return tinf;
    }
@@ -572,7 +574,7 @@
            dto.setMonCount(binf.getMoncount());
            dto.setMonvolstd(binf.getMonvolstd());
            if(battRtstate!=null){
                Float restTime= BattCapFactory.getTheoryTime(battRtstate.getGroupCurr(), realCap, binf.getMoncapstd());
                Float restTime= BattCapFactory.getTheoryTime(battRtstate.getLoadCurr(), realCap, binf.getMoncapstd());
                dto.setRestTime(restTime);
                dto.setFloatchartVol(battRtstate.getGroupVol());
            }else{
@@ -715,7 +717,83 @@
        Map<String,  Object> map=new HashMap<>();
        //查询出所有的班组并赋予初始值
        setBanZuDefault(map);
        //获取核容优劣,损坏参数
        //1查询符合条件的电池组
        List<BattInf> binfList=battInfService.getDischr6Statistic(stic);
        if(binfList==null||binfList.size()==0){
            return new Response().set(1,false,"当前用户未管理满足条件的电池组");
        }
        List<SticDischarge6Res> reslist=new ArrayList<>();
        for (BattInf binf:binfList) {
            //查询电池组所在的班组
            String  groupName=bjService.getGroupName(binf.getPowerId());
            SticDischarge6Res res=new SticDischarge6Res();
            res.setProvice(binf.getProvice());
            res.setCity(binf.getCity());
            res.setCountry(binf.getCountry());
            res.setStationName(binf.getStationName());
            res.setBattgroupName(binf.getBattgroupName());
            res.setMoncapstd(binf.getMoncapstd());
            res.setMonvolstd(binf.getMonvolstd());
            res.setMoncount(binf.getMoncount());
            res.setProduct(binf.getProduct());
            //获取电池组未放电记录(指定时间段的标准核容放电)
            getNoDischargeData(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime(),stic.getTypeList(),res);
            //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电)
            BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime());
            res.setTinf(tinf);
            if(stic.getStopReasonType()==0){
                reslist.add(res);
            }else {
                if(res.getStopReasonType()==stic.getStopReasonType()){
                    reslist.add(res);
                }
            }
            if(tinf==null){
                if(!groupName.equals("none")){
                    BanZu bz= (BanZu) map.get(groupName);
                    int nochargeNum=bz.getNochargeNum();
                    bz.setNochargeNum(nochargeNum+1);
                    map.put(groupName,bz);
                }
                continue;
            }
            if(!groupName.equals("none")){
                BanZu bz= (BanZu) map.get(groupName);
                int dischargeNum=bz.getDischargeNum();
                bz.setDischargeNum(dischargeNum+1);
                map.put(groupName,bz);
            }
        }
        PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize());
        return new Response().setIII(1,reslist.size()>0,pageInfo,map,"本年度未放电数量统计");
    }
    //2.获取电池组未放电记录(指定时间段的标准核容放电)
    private void getNoDischargeData(Integer battgroupId, Date testStartTime, Date testEndTime, List<Integer> typeList, SticDischarge6Res res) {
        List<BatttestdataInf> tinfList=mapper.getNoDischargeData(battgroupId,testStartTime,testEndTime,typeList);
        List<String> stopList=new ArrayList<>();
        if(tinfList!=null&&tinfList.size()>0){
            res.setErrorNum(tinfList.size());
            res.setStopReasonType(1);
            for (BatttestdataInf tinf:tinfList) {
                String stopReason=StopReasonEnum.getValue(tinf.getTestStoptype());
                stopList.add(stopReason);
            }
            res.setStopList(stopList);
        }else {
            res.setErrorNum(0);
            res.setStopList(new ArrayList<>());
            res.setStopReasonType(0);
        }
    }
    //获取核容停止原因类型(下拉)
    public Response getStopReasonType() {
        Map<String,Map<Integer,String>> map= StopReasonEnum.getOpInfo();
        return new Response().setII(1,true,map,"获取核容停止原因类型(下拉)");
    }
    //电池组电池性能统计(未放电,优秀,劣化,损坏)统计(1.2.8/9/10)
    public Response getPerformanceStatistic(PerformanceStic stic) {
        /*//获取核容优劣,损坏参数
        List<AppParam> paramList=appParamService.getHrParam();
        Float badValue=0f;
        Float damageValue=0f;
@@ -731,53 +809,47 @@
            }
        }
        //1查询符合条件的电池组
        List<BattInf> binfList=battInfService.getDischr5Statistic(stic);
        List<BattInf> binfList=battInfService.getBattCompare15Statistic(stic);
        if(binfList==null||binfList.size()==0){
            return new Response().set(1,false,"当前用户未管理满足条件的电池组");
        }
        List<SticDischarge5Res> reslist=new ArrayList<>();
        List<SticCompare15Res> reslist=new ArrayList<>();
        for (BattInf binf:binfList) {
            //查询电池组所在的班组
            String  groupName=bjService.getGroupName(binf.getPowerId());
            SticDischarge5Res res=new SticDischarge5Res();
            SticCompare15Res res=new SticCompare15Res();
            res.setProvice(binf.getProvice());
            res.setCity(binf.getCity());
            res.setCountry(binf.getCountry());
            res.setStationName(binf.getStationName());
            res.setBattgroupName(binf.getBattgroupName());
            res.setDevName(binf.getDevName());
            res.setProduct(binf.getProduct());
            res.setInuseTime(binf.getInuseTime());
            res.setMonvolstd(binf.getMonvolstd());
            res.setStationId(binf.getStationId());
            res.setPowerId(binf.getPowerId());
            res.setDevId(binf.getDevId());
            res.setBattgroupId(binf.getBattgroupId());
            //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电)
            BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime());
            if(tinf==null){
                res.setRealCap(0f);
                res.setTestStartTime(ThreadLocalUtil.parse("1972-01-01 00:00:00",1));
                res.setTestTimelong(0);
                res.setTestCap(0f);
                res.setStopReason("");
                res.setPrecentCap("0");
                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId()));
                res.setDisChargeType(2);
                if(!groupName.equals("none")){
                    BanZu bz= (BanZu) map.get(groupName);
                    int nochargeNum=bz.getNochargeNum();
                    bz.setNochargeNum(nochargeNum+1);
                    map.put(groupName,bz);
                }
                continue;
            }
            if(!groupName.equals("none")){
                BanZu bz= (BanZu) map.get(groupName);
                int dischargeNum=bz.getDischargeNum();
                bz.setDischargeNum(dischargeNum+1);
                map.put(groupName,bz);
            //找这次放电的最后一笔数据
            List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum());
            if(idDataList==null||idDataList.size()==0){
                res.setRealCap(0f);
                res.setPrecentCap("0");
                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId()));
                continue;
            }
            res.setTestStartTime(tinf.getTestStarttime());
            res.setTestTimelong(tinf.getTestTimelong());
            res.setTestCap(tinf.getTestCap());
            res.setStopReason(StopReasonEnum.getValue(tinf.getTestStoptype()));
            Float moncapStd=binf.getMoncapstd();
            int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
            Float grouprealCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
            //Float restCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest);
            res.setRealCap(grouprealCap);
            res.setDisChargeType(1);
            if(grouprealCap>=moncapStd*badValue){
                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_1.getStateId()));
            }
@@ -787,15 +859,28 @@
            if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){
                res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId()));
            }
            if(stic.getDisChargeType()==null){
            //保留5位小数
            String precentCap = String.format("%.5f",(grouprealCap/binf.getMoncapstd()*100));
            res.setPrecentCap(precentCap);
            List<Integer> monNums=new ArrayList<>();
            for (BatttestdataId data:idDataList) {//求单体的 实际容量,最小值就是单体的单体电压
                Float monrealCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), data.getMonVol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
                if (monrealCap <= moncapStd * damageValue) {//损坏的
                    monNums.add(data.getMonNum());
                }
            }
            res.setMonNums(monNums);
            if(stic.getPerformance()==null){
                reslist.add(res);
            }else{
                if(res.getDisChargeType()==stic.getDisChargeType()){
                if(res.getCapperformance().equals(Capperformance.getValue(stic.getPerformance()))){
                    reslist.add(res);
                }
            }
        }
        PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize());
        return new Response().setII(1,reslist.size()>0,pageInfo,"本年度未放电数量统计");
        return new Response().setII(1,reslist.size()>0,pageInfo,"蓄电池组对比分析界面(同一品牌同一时间)");*/
        return null;
    }
}