src/main/java/com/whyc/service/BattresdataInfService.java
@@ -2,15 +2,19 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.whyc.dto.Real.QuarterDto;
import com.whyc.dto.Response;
import com.whyc.dto.Statistic.ComPareChangeCurve;
import com.whyc.dto.Statistic.ComPareChart;
import com.whyc.mapper.BattresdataInfMapper;
import com.whyc.mapper.CommonMapper;
import com.whyc.pojo.db_batt_testdata.BattresdataId;
import com.whyc.pojo.db_batt_testdata.BattresdataInf;
import com.whyc.pojo.db_station.BattInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.*;
@Service
public class BattresdataInfService {
@@ -40,7 +44,6 @@
        wrapper.last(" ORDER BY test_record_count asc ");
        BattresdataInf rinf = mapper.selectOne(wrapper);
        if(rinf!=null){
            String tableName ="db_batt_testdata.tb_battresdata_"+battgroupId;
            String existTableName = commonMapper.existTable("db_batt_testdata", "tb_battresdata_"+battgroupId);
            if(existTableName != null){
                List<QuarterDto> list=subTablePageInfoService.getBattResInfData(battgroupId,rinf.getTestRecordCount());
@@ -49,4 +52,60 @@
        }
        return null;
    }
    //蓄电池对比分析右侧最高单体内阻数据(最新一次内阻测试)
    public ComPareChart getMaxResData(BattInf binf) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("battgroup_id", binf.getBattgroupId());
        wrapper.last(" limit 1");
        wrapper.last(" ORDER BY test_starttime desc ");
        BattresdataInf rinf = mapper.selectOne(wrapper);
        ComPareChart chart=new ComPareChart();
        chart.setBattgroupName(binf.getBattgroupName());
        chart.setBattgroupId(binf.getBattgroupId());
        chart.setValue(0f);
        chart.setMonNum(1);
        if(rinf!=null){
            String existTableName = commonMapper.existTable("db_batt_testdata", "tb_battresdata_"+binf.getBattgroupId());
            if(existTableName != null){
                //取内阻测试的最大内阻和单体编号
                List<QuarterDto> list=subTablePageInfoService.getMaxResInInfData(binf.getBattgroupId(),rinf.getTestRecordCount());
                if(list!=null&&list.size()>0){
                    Map<String, Object> map =list.stream()
                            .max(Comparator.comparing(QuarterDto::getNumValue))
                            .map(dto -> {
                                Map<String, Object> result = new HashMap<>();
                                result.put("maxNumValue", dto.getNumValue());
                                result.put("monNum", dto.getMonNum());
                                return result;
                            })
                            .orElse(Collections.emptyMap());
                    chart.setBattgroupId(binf.getBattgroupId());
                    chart.setBattgroupName(binf.getBattgroupName());
                    chart.setValue(Float.parseFloat(map.get("maxNumValue").toString()));
                    chart.setMonNum(Integer.parseInt(map.get("monNum").toString()));
                }
            }
        }
        return chart;
    }
    //点击右侧折线图画出电池组单体的所有内阻测试单体内阻变化图(1.2.15/16/17)
    public Response getMonResChangeByBattgroupId(Integer battgroupId, Integer monNum) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("battgroup_id", battgroupId);
        wrapper.last(" ORDER BY test_starttime asc ");
        List<BattresdataInf> list = mapper.selectList(wrapper);
        List<ComPareChangeCurve> curvelist=new ArrayList<>();
        for (BattresdataInf rinf:list) {
            String existTableName = commonMapper.existTable("db_batt_testdata", "tb_battresdata_"+battgroupId);
            if(existTableName != null){
                //取内阻测试指定单体的单体电压
                ComPareChangeCurve curve=subTablePageInfoService.getMonResChangeByBattgroupId(battgroupId,rinf.getTestRecordCount(),monNum);
                if(curve!=null){
                    curvelist.add(curve);
                }
            }
        }
        return new Response().setII(1,list.size()>0,curvelist,"点击右侧折线图画出电池组单体的所有内阻测试单体内阻变化图(1.2.15/16/17)");
    }
}