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.Response; import com.whyc.dto.Statistic.BattTinfStic; import com.whyc.factory.BattCapFactory; import com.whyc.mapper.BattInfMapper; import com.whyc.mapper.BatttestdataInfMapper; import com.whyc.pojo.db_batt_testdata.BatttestdataInf; import com.whyc.pojo.db_station.BattInf; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service public class BatttestdataInfService { @Autowired(required = false) private BatttestdataInfMapper mapper; //获取最后一次测试数据并计算剩余容量 public Float getLastTestDataRestCap(Integer battgroupId) { //获取放电记录 QueryWrapper wrapper=new QueryWrapper(); wrapper.eq("battgroup_id",battgroupId); wrapper.orderByDesc("test_starttime"); wrapper.last("limit 1"); BatttestdataInf tinf=mapper.selectOne(wrapper); if(tinf!=null){ int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); Float restcap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest); return restcap; }else{ return 0f; } } //蓄电池核容信息统计 public Response getBattTinfStatistic(BattTinfStic stic) { PageHelper.startPage(stic.getPageNum(), stic.getPageSize()); List list=mapper.getBattTinfStatistic(stic); PageInfo pageInfo=new PageInfo(list); return new Response().setII(1,list.size()>0,pageInfo,"蓄电池核容信息统计"); } }