whyczh
2022-01-14 1d8c0e669733c0815451618769acad03e3705765
src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -4,11 +4,16 @@
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.BattCapFactory;
import com.whyc.dto.BattState;
import com.whyc.dto.BattTestData;
import com.whyc.dto.Response;
import com.whyc.dto.result.ReportBattTestDTO;
import com.whyc.mapper.BattParamLowMapper;
import com.whyc.mapper.BattTestDataStopMapper;
import com.whyc.mapper.BatttestdataInfMapper;
import com.whyc.pojo.BattParamLow;
import com.whyc.pojo.BattTestDataStop;
import com.whyc.pojo.Battinf;
import com.whyc.pojo.BatttestdataInf;
import org.springframework.stereotype.Service;
@@ -24,6 +29,9 @@
    @Resource
    private BattTestDataStopMapper stopMapper;
    @Resource
    private BattParamLowMapper battParamLowMapper;
    //在线监测-历史监控-获取充放电记录
    public Response searchBattTestInfDataById(int battGroupId) {
@@ -135,9 +143,52 @@
        return list1;
    }
    public Response searchBattLifeNow(){
    public Response searchBattLifeNow(int pageNum,int pageSize,Battinf binf){
        PageHelper.startPage(pageNum,pageSize);
        List<BattState> list = mapper.searchBattLifeNow(binf);
        PageInfo<BattState> pageInfo = new PageInfo<>(list);
        return new Response().set(1,pageInfo,"查询成功");
    }
        return null;
    public Response searchBattLife(int pageNum,int pageSize,Battinf binf){
        PageHelper.startPage(pageNum,pageSize);
        List<ReportBattTestDTO> 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<BattParamLow> listC = battParamLowMapper.serchByLow(capLow);
        if (listC!=null && listC.size()>0){
            param = listC.get(listC.size()-1).getLowValue();
        }
        int flag=0;//该次放电是否有效判断
        List<ReportBattTestDTO> listE=new ArrayList();//存放放电有效的测试
        if (list!=null &&list.size()>0){
            for(int i=0;i<list.size();i++){
                STDAH=list.get(i).getBinf().getMonCapStd();
                float testCap=list.get(i).getTdata().getTestCap();//此次放电量统计
                //System.out.println(list.get(i).getTdata().getBattGroupId()+"  "+list.get(i).getTdata().getTest_record_count()+"   "+testCap+"  "+param+"  "+STDAH);
                flag=BattCapFactory.Judge(testCap, param, STDAH);
                if(flag==1){
                    if(listE.size()>0){
                        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;
                }
            }
        }
        PageInfo<ReportBattTestDTO> pageInfo = new PageInfo<>(list);
        return new Response().set(1,pageInfo,"查询成功");
    }