whyclxw
2025-06-12 10574a67b78e2578fc10e8fbe83965bf4832c36a
src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -17,6 +17,7 @@
import com.whyc.pojo.db_ram_db.BattRtdata;
import com.whyc.pojo.db_ram_db.BattRtstate;
import com.whyc.pojo.db_station.BattInf;
import com.whyc.pojo.db_station.PowerInf;
import com.whyc.pojo.db_user.Baojigroup;
import com.whyc.util.ActionUtil;
import com.whyc.util.PageInfoUtils;
@@ -49,8 +50,11 @@
    @Autowired(required = false)
    private BaojigroupService bjService;
    @Autowired(required = false)
    private PowerInfService powerInfService;
    @Autowired(required = false)
    private PwrdevHistorydataIdService pwrHisdataIdService;
    //获取最后一次测试数据并计算剩余容量
@@ -547,11 +551,11 @@
        List<TestDataDto> List3=new ArrayList<>();
        List<TestDataDto> List4=new ArrayList<>();
        List<TestDataDto> List5=new ArrayList<>();
        map.put("1",List1);   //核容放电
        map.put("2",List2);   //核容充电
        map.put("3",List3);   //监测放电
        map.put("4",List4);   //监测充电
        map.put("5",List5);   //停电放电
        map.put("核容放电",List1);   //核容放电
        map.put("核容充电",List2);   //核容充电
        map.put("监测放电",List3);   //监测放电
        map.put("监测充电",List4);   //监测充电
        map.put("停电放电",List5);   //停电放电
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("battgroup_id",battgroupId);
        wrapper.orderByDesc("test_starttime");
@@ -657,13 +661,6 @@
            //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.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId()));
                res.setDisChargeType(2);*/
                continue;
            }
            if(!groupName.equals("none")){
@@ -676,6 +673,17 @@
            res.setTestTimelong(tinf.getTestTimelong());
            res.setTestCap(tinf.getTestCap());
            res.setStopReason(StopReasonEnum.getValue(tinf.getTestStoptype()));
            if (tinf.getTestType() == 3) {
                // 测试类型为放电
                if (tinf.getTestStarttype() == 3) {
                    res.setDischargeName("核容放电");
                } else if(tinf.getTestStarttype() == 4){
                    res.setDischargeName("停电放电");
                }else {
                    res.setDischargeName("监测放电");
                }
            }
            res.setTestRecordCount(tinf.getTestRecordCount());
            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);
@@ -700,78 +708,6 @@
        }
        PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize());
        return new Response().setIIII(1,reslist.size()>0,pageInfo,bzmap,xnmap,"本年度已放电数量统计");
    }//本年度已放电数量统计右侧图表(1.2.5/6)
    public Response getDischr5Chart(Integer uid) {
        //班组
        Map<String,  Object> bzmap=new HashMap<>();
        //性能
        Map<String,  Integer> xnmap=new HashMap<>();
        xnmap.put("优秀",0);
        xnmap.put("劣化",0);
        xnmap.put("损坏",0);
        xnmap.put("未放电",0);
        //查询出所有的班组并赋予初始值
        setBanZuDefault(bzmap);
        //获取核容优劣,损坏参数
        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查询符合条件的电池组
        List<BattInf> binfList=battInfService.getDischrChart(uid);
        if(binfList==null||binfList.size()==0){
            return new Response().set(1,false,"当前用户未管理满足条件的电池组");
        }
        for (BattInf binf:binfList) {
            //查询电池组所在的班组
            String  groupName=bjService.getGroupName(binf.getPowerId());
            //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电)
            BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),null,null);
            if(tinf==null){
                int value=xnmap.get(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId()));
                xnmap.put(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId()),value+1);
                if(!groupName.equals("none")){
                    BanZu bz= (BanZu) bzmap.get(groupName);
                    int nochargeNum=bz.getNochargeNum();
                    bz.setNochargeNum(nochargeNum+1);
                    bzmap.put(groupName,bz);
                }
                continue;
            }
            if(!groupName.equals("none")){
                BanZu bz= (BanZu) bzmap.get(groupName);
                int dischargeNum=bz.getDischargeNum();
                bz.setDischargeNum(dischargeNum+1);
                bzmap.put(groupName,bz);
            }
            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);
            if(grouprealCap>=moncapStd*badValue){
                int value=xnmap.get(Capperformance.getValue(Capperformance.BATTSTATE_1.getStateId()));
                xnmap.put(Capperformance.getValue(Capperformance.BATTSTATE_1.getStateId()),value+1);
            }
            if(grouprealCap<=moncapStd*damageValue){
                int value=xnmap.get(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId()));
                xnmap.put(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId()),value+1);
            }
            if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){
                int value=xnmap.get(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId()));
                xnmap.put(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId()),value+1);
            }
        }
        return new Response().setIII(1,true,bzmap,xnmap,"本年度已放电数量统计");
    }
    //查询出所有的班组并赋予初始值
@@ -814,9 +750,6 @@
            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 {
@@ -824,16 +757,12 @@
                    reslist.add(res);
                }
            }
            if(tinf==null){
                if(!groupName.equals("none")){
                    BanZu bz= (BanZu) bzmap.get(groupName);
                    int nochargeNum=bz.getNochargeNum();
                    bz.setNochargeNum(nochargeNum+1);
                    bzmap.put(groupName,bz);
                }
                continue;
            if(!groupName.equals("none")){
                BanZu bz= (BanZu) bzmap.get(groupName);
                int nochargeNum=bz.getNochargeNum();
                bz.setNochargeNum(nochargeNum+1);
                bzmap.put(groupName,bz);
            }
        }
        PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize());
        return new Response().setIII(1,reslist.size()>0,pageInfo,bzmap,"本年度未放电数量统计");
@@ -845,7 +774,21 @@
        if(tinfList!=null&&tinfList.size()>0){
            res.setErrorNum(tinfList.size());
            res.setStopReasonType(1);
            for (BatttestdataInf tinf:tinfList) {
            for (int i=0;i<tinfList.size();i++) {
                BatttestdataInf tinf=tinfList.get(i);
                if(i==0){
                   res.setTestRecordCount(tinf.getTestRecordCount());
                   if (tinf.getTestType() == 3) {
                        // 测试类型为放电
                        if (tinf.getTestStarttype() == 3) {
                            res.setDischargeName("核容放电");
                        } else if(tinf.getTestStarttype() == 4){
                            res.setDischargeName("停电放电");
                        }else {
                            res.setDischargeName("监测放电");
                        }
                   }
                }
                String stopReason=StopReasonEnum.getValue(tinf.getTestStoptype());
                stopList.add(stopReason);
            }
@@ -936,24 +879,35 @@
    }
   //优良电源数量统计(1.2.7)
    public Response getPwr7Statistic(Pwr7Stic stic) {
        //获取核容优劣,损坏参数
        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();
        //1查询符合条件的电池组
        List<PowerInf> pinfList=powerInfService.getPwr7Statistic(stic);
        if(pinfList==null||pinfList.size()==0){
            return new Response().set(1,false,"当前用户未管理满足条件的电池组");
        }
        List<SticPwr7Res> reslist=new ArrayList<>();
        for (PowerInf pinf:pinfList) {
            SticPwr7Res res=new SticPwr7Res();
            //查询电池组所在的班组
            String groupName = bjService.getGroupName(pinf.getPowerId());
            if(groupName.equals("none")){
                continue;
            }else{
                if(stic.getGroupName()==null||res.getGroupName()==stic.getGroupName()){
                    res.setProvice(pinf.getProvice());
                    res.setCity(pinf.getCity());
                    res.setCountry(pinf.getCountry());
                    res.setStationName(pinf.getStationName());
                    res.setPowerName(pinf.getPowerName());
                    res.setCompany(pinf.getCompany());
                    res.setStationType(pinf.getStationType());
                    res.setGroupName(groupName);
                    res.setInuseTime(pinf.getPowerInuseTime());
                    Map<String,Integer> map=pwrHisdataIdService.getPwrQuarter7(pinf.getPowerId(),null);
                    reslist.add(res);
                }
                if(param.getParamNamePsx().equals("batt_mon_damage_val")){
                    damageValue=param.getParamValue();
                }
            }
        }
        //1查询符合条件的电池组
        List<BattInf> binfList=battInfService.getPwr7Statistic(stic);
        List<PerformanceRes> reslist=new ArrayList<>();
        PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize());
        return new Response().setII(1,reslist.size()>0,pageInfo,"优良电源数量统计(1.2.7)");
    }