whyclxw
2025-06-06 c34c224406217a2523d68fdcecaf2bb4fb732389
src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -5,6 +5,7 @@
import com.github.pagehelper.PageInfo;
import com.whyc.constant.Capperformance;
import com.whyc.constant.StopReasonEnum;
import com.whyc.dto.Real.TestDataDto;
import com.whyc.dto.Response;
import com.whyc.dto.Statistic.*;
import com.whyc.factory.BattCapFactory;
@@ -40,6 +41,7 @@
    @Autowired(required = false)
    private AppParamService appParamService;
@@ -529,4 +531,75 @@
            }
        }
    }
    //历史测试记录
    public Response getBattTinf(Integer battgroupId) {
        Map<String,  Object> map=new HashMap<>();
        List<TestDataDto> List1=new ArrayList<>();
        List<TestDataDto> List2=new ArrayList<>();
        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);   //停电放电
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("battgroup_id",battgroupId);
        wrapper.orderByDesc("test_starttime");
        List<BatttestdataInf> list=mapper.selectList(wrapper);
        for (BatttestdataInf tinf:list) {
            TestDataDto dto=new TestDataDto();
            dto.setTestStarttime(tinf.getTestStarttime());
            dto.setBattgroupId(tinf.getBattgroupId());
            dto.setTestRecordCount(tinf.getTestRecordCount());
            dto.setRecordNum(tinf.getRecordNum());
            dto.setTestCap(tinf.getTestCap());
            dto.setTestTimeLong(tinf.getTestTimelong());
            int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr());
            Float realCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real);
            dto.setRealCap(realCap);
            //实时获取电池组信息
            BattRtstate battRtstate = rtstateService.getBattRealInfo(tinf.getBattgroupId());
            //获取电池组信息
            BattInf binf = battInfService.getBinfByBattgroupId(tinf.getBattgroupId());
            dto.setMoncapstd(binf.getMoncapstd());
            dto.setMonCount(binf.getMoncount());
            dto.setMonvolstd(binf.getMonvolstd());
            if(battRtstate!=null){
                Float restTime= BattCapFactory.getTheoryTime(battRtstate.getGroupCurr(), realCap, binf.getMoncapstd());
                dto.setRestTime(restTime);
                dto.setFloatchartVol(battRtstate.getGroupVol());
            }else{
                dto.setRestTime(0f);
                dto.setFloatchartVol(0f);
            }
            //找这次放电的指定一笔数据
            List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),1);
            if(idDataList!=null&&idDataList.size()>=0){
                BatttestdataId idData=idDataList.get(0);
                dto.setOnlineVol(idData.getOnlineVol());
                dto.setGroupCurr(idData.getTestCurr());
            }else {
                dto.setOnlineVol(0f);
                dto.setGroupCurr(0f);
            }
            if (tinf.getTestType() == 3) {
                // 测试类型为放电
                if (tinf.getTestStarttype() == 3) {
                    List1.add(dto);
                } else {
                    List3.add(dto);
                }
            } else if (tinf.getTestType() == 2) {
                // 测试类型为充电
                if (tinf.getTestStarttype() == 3) {
                    List2.add(dto);
                } else {
                    List4.add(dto);
                }
            }
        }
        return new Response().setII(1,true,map,"历史测试记录");
    }
}