whyclxw
3 天以前 a4e25fc0cd113518980305af3c061892b1b24b14
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.BattCapperformanceEnum;
import com.whyc.constant.PwrCapperformanceEnum;
import com.whyc.constant.StopReasonEnum;
import com.whyc.dto.Real.TestDataDto;
import com.whyc.dto.Response;
@@ -19,10 +20,12 @@
import com.whyc.pojo.db_station.PowerInf;
import com.whyc.pojo.db_user.Baojigroup;
import com.whyc.util.ActionUtil;
import com.whyc.util.DateUtil;
import com.whyc.util.PageInfoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.*;
@Service
@@ -110,7 +113,8 @@
        wrapper.eq("battgroup_id", battgroupId);
        wrapper.eq("test_type", 3);
        wrapper.eq("test_starttype", 3);
        wrapper.last("  and test_timelong >= 7200 ORDER BY test_starttime DESC ");
        wrapper.eq("data_available", 1);//一次有效的记录
        wrapper.last(" ORDER BY test_starttime DESC ");
        wrapper.last("limit 1");
        BatttestdataInf tinf = mapper.selectOne(wrapper);
        tinf.setTestStoptypeReason(StopReasonEnum.getValue(tinf.getTestStoptype()));
@@ -129,8 +133,9 @@
        if(testEndTime!=null){
            wrapper.lt("test_starttime",testEndTime);
        }
        wrapper.last("  and test_timelong >= 7200 ORDER BY test_starttime DESC ");
        wrapper.last("limit 1");
        wrapper.eq("data_available", 1);//一次有效的记录
        wrapper.last("  ORDER BY test_starttime DESC ");
        wrapper.last(" limit  1 ");
        BatttestdataInf tinf = mapper.selectOne(wrapper);
        return tinf;
    }
@@ -273,7 +278,6 @@
                if(param.getParamNamePsx().equals("batt_mon_damage_val")){
                    damageValue=param.getParamValue();
                }
            }
        }
        //1查询符合条件的电池组
@@ -578,13 +582,12 @@
            dto.setMoncapstd(binf.getMoncapstd());
            dto.setMonCount(binf.getMoncount());
            dto.setMonvolstd(binf.getMonvolstd());
            dto.setFloatchartVol(tinf.getFloatGroupVol());
            if(battRtstate!=null){
                Float restTime= BattCapFactory.getTheoryTime(battRtstate.getLoadCurr(), 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);
@@ -936,36 +939,51 @@
        return new Response().setII(1,reslist.size()>0,pageInfo,"电池组电池性能统计(未放电,优秀,劣化,损坏)统计(1.2.8/9/10)");
    }
   //优良电源数量统计(1.2.7)
    public Response getPwr7Statistic(Pwr7Stic stic) {
    public Response getPwr7Statistic(Pwr7Stic stic) throws NoSuchFieldException, IllegalAccessException {
        Date inuseTimeStart =new Date();
        if(stic.getInuseYear()!=null){
            if(stic.getInuseYear()==1){
                //投入使用时间条件筛选
                LocalDateTime startTime = LocalDateTime.now().minusYears(5);
                inuseTimeStart = DateUtil.convertToDate(startTime);
            }else{
                //投入使用时间条件筛选
                LocalDateTime startTime = LocalDateTime.now().minusYears(stic.getInuseYear());
                inuseTimeStart = DateUtil.convertToDate(startTime);
            }
            stic.setPwrInUseTime(inuseTimeStart);
        }
        //1查询符合条件的电池组
        List<PowerInf> pinfList=powerInfService.getPwr7Statistic(stic);
        if(pinfList==null||pinfList.size()==0){
            return new Response().set(1,false,"当前用户未管理满足条件的电池组");
            return new Response().set(1,false,"当前用户未管理满足条件的电源");
        }
        List<SticPwr7Res> reslist=new ArrayList<>();
        for (PowerInf pinf:pinfList) {
            SticPwr7Res res=new SticPwr7Res();
            //查询电池组所在的班组
            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);
            if (stic.getGroupName() == null || groupName == 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());
                Integer performance= pwrHisdataIdService.getPwrQuarter7(pinf.getPowerId(),pinf.getPowerType());
                res.setPerformanceName(PwrCapperformanceEnum.getValue(performance));
                if(stic.getPerformance()==null){
                    reslist.add(res);
                }else{
                    if(performance==stic.getPerformance()){
                        reslist.add(res);
                    }
                }
            }
        }
        PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize());
        return new Response().setII(1,reslist.size()>0,pageInfo,"优良电源数量统计(1.2.7)");
    }
@@ -978,4 +996,20 @@
    public int getHrDisCount(Integer userId, Date startTime, Date endTime) {
        return mapper.getHrDisCount(userId, startTime, endTime);
    }
    //获取这一次的放电信息
    public BatttestdataInf getTinfByTestRecordCount(Integer battgroupId, Integer testRecordCount) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("battgroup_id",battgroupId);
        wrapper.eq("test_record_count",testRecordCount);
        wrapper.last(" limit 1");
        return mapper.selectOne(wrapper);
    }
    //历史测试数据导出
    public BatttestdataInf exportTinfDataByTestRecordCount(Integer battgroupId, Integer testRecordCount) {
        QueryWrapper wrapper =new QueryWrapper();
        wrapper.eq("battgroup_id",battgroupId);
        wrapper.eq("test_record_count",testRecordCount);
        wrapper.last(" limit 1");
        return mapper.selectOne(wrapper);
    }
}