From 9e428b3f4a90df003848d28aca5f358c7b6ef969 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期三, 25 六月 2025 14:43:58 +0800 Subject: [PATCH] 蓄电池对比分析中弹窗根据设置的权重表格评分 --- src/main/java/com/whyc/service/BatttestdataInfService.java | 79 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 79 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/whyc/service/BatttestdataInfService.java b/src/main/java/com/whyc/service/BatttestdataInfService.java index 6811e8c..865d92f 100644 --- a/src/main/java/com/whyc/service/BatttestdataInfService.java +++ b/src/main/java/com/whyc/service/BatttestdataInfService.java @@ -7,7 +7,9 @@ import com.whyc.constant.PwrCapperformanceEnum; import com.whyc.constant.StopReasonEnum; import com.whyc.dto.Real.TestDataDto; +import com.whyc.dto.ResSocreHehavior; import com.whyc.dto.Response; +import com.whyc.dto.SocreHehaviorDto; import com.whyc.dto.Statistic.*; import com.whyc.factory.BattCapFactory; import com.whyc.mapper.BatttestdataInfMapper; @@ -27,6 +29,7 @@ import java.time.LocalDateTime; import java.util.*; +import java.util.stream.Collectors; @Service public class BatttestdataInfService { @@ -1090,4 +1093,80 @@ } return new Response().setII(1,list.size()>0,curvelist,"鐐瑰嚮鍙充晶鎶樼嚎鍥剧敾鍑虹數姹犵粍鎵�鏈夊畬鏁村懆鏈熺殑娴厖鐢靛帇鍙樺寲鍥�(1.2.15/16/17)"); } + //寮圭獥鏍规嵁璁剧疆鐨勬潈閲嶈〃鏍艰瘎鍒� + public Response getScoreByHehavior(SocreHehaviorDto dto) { + //鑾峰彇鏍稿浼樺姡锛屾崯鍧忓弬鏁� + List<AppParam> paramList=appParamService.getHrParam(); + Float badValue=0f; + Float damageValue=0f; + if(paramList!=null){ + for (AppParam param:paramList) { + if(param.getParamNamePsx().equals("batt_mon_deteriorate_val")){ + badValue=param.getParamValue(); + } + if(param.getParamNamePsx().equals("batt_mon_damage_val")){ + damageValue=param.getParamValue(); + } + } + } + List<ResSocreHehavior> reslist=new ArrayList<>(); + //璇㈢鍚堟潯浠剁殑鐢垫睜缁勬潈閲嶈〃鏍艰瘎鍒� + List<BattInf> binfList=battInfService.getScoreByHehavior(dto); + if(binfList==null||binfList.size()==0){ + return new Response().set(1,false,"褰撳墠鐢ㄦ埛鏈鐞嗘弧瓒虫潯浠剁殑鐢垫睜缁�"); + }else{ + Map<String, List<BattInf>> map=binfList.stream().collect(Collectors.groupingBy(item -> item.getMonvolstd().toString() + '-' + item.getMoncapstd())); + for (String volcap : map.keySet()) { + List<BattInf> list=map.get(volcap); + ResSocreHehavior res=new ResSocreHehavior(); + res.setProduct(dto.getProduct()); + res.setInuseYear(dto.getInuserYear()+"骞村唴"); + Integer goodBatt=0; + Integer badBatt=0; + Integer damageBatt=0; + Integer nodisBatt=0; + Integer sumBatt=list.size(); + res.setSumBatt(sumBatt); + String[] parts = volcap.split("-"); // 浣跨敤split鏂规硶鍒嗗壊瀛楃涓� + res.setMonvolstd(Float.valueOf(parts[0])); + res.setMoncapstd(Float.valueOf(parts[1])); + for (BattInf binf:list) { + //2.鑾峰彇鐢垫睜缁勫湪缁欏畾鏃堕棿娈电殑鏀剧數璁板綍(鎸囧畾鏃堕棿娈电殑鏍囧噯鏍稿鏀剧數) + BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),null,null); + if(tinf==null){ + nodisBatt++; + }else{ + Float moncapStd=binf.getMoncapstd(); + int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); + Float grouprealCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real); + if(grouprealCap>=moncapStd*badValue){ + goodBatt++; + } + if(grouprealCap<=moncapStd*damageValue){ + damageBatt++; + } + if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){ + badBatt++; + } + } + } + //淇濈暀5浣嶅皬鏁� + String goodPercent = String.format("%.5f",(goodBatt/sumBatt*100.0)); + res.setGoodBatt(goodBatt); + res.setGoodPercent(goodPercent); + String badPercent = String.format("%.5f",(badBatt/sumBatt*100.0)); + res.setBadBatt(badBatt); + res.setBadPercent(badPercent); + String damagePercent = String.format("%.5f",(damageBatt/sumBatt*100.0)); + res.setDamagebatt(damageBatt); + res.setDamagePercent(damagePercent); + String nodisPercent = String.format("%.5f",(nodisBatt/sumBatt*100.0)); + res.setNodisbatt(nodisBatt); + res.setNodisPercent(nodisPercent); + res.setScore(0f); + reslist.add(res); + } + } + return new Response().setII(1,reslist.size()>0,reslist,"寮圭獥鏍规嵁璁剧疆鐨勬潈閲嶈〃鏍艰瘎鍒�"); + } } \ No newline at end of file -- Gitblit v1.9.1