src/main/java/com/whyc/controller/BattCompareController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/controller/StatisticController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/dto/ResSocreHehavior.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/dto/SocreHehaviorDto.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/mapper/BattInfMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/db_station/BattInf.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/BattInfService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/BatttestdataInfService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/BattInfMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/BattCompareController.java
@@ -1,8 +1,11 @@ package com.whyc.controller; import com.whyc.dto.Response; import com.whyc.dto.SocreHehaviorDto; import com.whyc.dto.Statistic.BattCompareStic; import com.whyc.pojo.db_param.AppParam; import com.whyc.pojo.db_user.User; import com.whyc.service.AppParamService; import com.whyc.service.BattresdataInfService; import com.whyc.service.BatttestdataInfService; import com.whyc.util.ActionUtil; @@ -12,6 +15,7 @@ import org.springframework.web.bind.annotation.*; import java.text.ParseException; import java.util.List; import java.util.Map; @RestController @@ -25,6 +29,8 @@ @Autowired private BattresdataInfService battRinfService; @Autowired private AppParamService appParamService; @ApiOperation(value = "蓄电池组对比分析界面(同一时间同一品牌/同一时间不同一品牌/不同一时间同一品牌)(1.2.15/16/17)") @PostMapping("getBattCompare15Statistic") @@ -56,4 +62,29 @@ public Response getMonResChangeByBattgroupId(@RequestParam Integer battgroupId,@RequestParam Integer monNum){ return battRinfService.getMonResChangeByBattgroupId(battgroupId,monNum); } @ApiOperation(value = "弹窗根据设置的权重表格评分") @PostMapping("getScoreByHehavior") public Response getScoreByHehavior(@RequestBody SocreHehaviorDto dto) throws ParseException { User uinf= ActionUtil.getUser(); dto.setUid(uinf.getId()); if(dto.getInuserYear()!=null){ int year=ActionUtil.getNowYear(); dto.setInuseStartTime(ActionUtil.sdfwithday.parse(ActionUtil.getDayTime(year+1-dto.getInuserYear(),0,1,5))); dto.setInuseEndTime(ActionUtil.sdfwithday.parse(ActionUtil.getDayTime(year,11,31,5))); } return battTinfService.getScoreByHehavior(dto); } @ApiOperation(value = "设置权重(1.2.16)") @PostMapping("setHehavior") public Response setHehavior(@RequestBody List<AppParam> List){ return appParamService.setHehavior(List); } @ApiOperation(value = "读取权重(1.2.16)") @GetMapping("getHehavior") public Response getHehavior(){ return appParamService.getHehavior(); } } src/main/java/com/whyc/controller/StatisticController.java
@@ -33,8 +33,6 @@ @Autowired private DeviceStateService deviceStateService; @Autowired private AppParamService appParamService; @ApiOperation(value = "电源信息统计(1.2.1/1.2.13)") @PostMapping("getPowerStatistic") @@ -158,18 +156,6 @@ User uinf= ActionUtil.getUser(); stic.setUid(uinf.getId()); return deviceStateService.getDeviceStateStatistic(stic); } @ApiOperation(value = "设置权重(1.2.16)") @PostMapping("setHehavior") public Response setHehavior(@RequestBody List<AppParam> List){ return appParamService.setHehavior(List); } @ApiOperation(value = "读取权重(1.2.16)") @GetMapping("getHehavior") public Response getHehavior(){ return appParamService.getHehavior(); } src/main/java/com/whyc/dto/ResSocreHehavior.java
New file @@ -0,0 +1,22 @@ package com.whyc.dto; import lombok.Data; @Data public class ResSocreHehavior { private String product; private Float monvolstd; private Float moncapstd; private String inuseYear; private Integer sumBatt; private Integer goodBatt; private String goodPercent; private Integer badBatt; private String badPercent; //恶化 private Integer damagebatt; private String damagePercent;//损坏 private Integer nodisbatt; private String nodisPercent;//未放电 private Float score;//最终得分 } src/main/java/com/whyc/dto/SocreHehaviorDto.java
New file @@ -0,0 +1,20 @@ package com.whyc.dto; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.util.Date; @Data public class SocreHehaviorDto { private String product; private Float moncapstd; private Float monvolstd;//标称电压 @JsonFormat(pattern = "yyyy-MM-dd") private Date inuseStartTime;//开始时间 @JsonFormat(pattern = "yyyy-MM-dd") private Date inuseEndTime;//结束时间 private Integer inuserYear;//投运时间1~15年 private Integer uid; } src/main/java/com/whyc/mapper/BattInfMapper.java
@@ -3,6 +3,7 @@ import com.whyc.dto.BattDto; import com.whyc.dto.InfoDto; import com.whyc.dto.Param.ParamAlmDto; import com.whyc.dto.SocreHehaviorDto; import com.whyc.dto.Statistic.*; import com.whyc.pojo.db_station.BattInf; import org.apache.ibatis.annotations.Param; @@ -67,4 +68,6 @@ List<BattInf> getBattgroupIdListByPowerId(@Param("powerId") Integer powerId); //查询设备下所有的电池组id List<BattInf> getBattgroupIdListByDevId(@Param("devId") Integer devId); //询符合条件的电池组权重表格评分 List<BattInf> getScoreByHehavior(@Param("stic") SocreHehaviorDto dto); } src/main/java/com/whyc/pojo/db_station/BattInf.java
@@ -88,6 +88,9 @@ private Date inuseTime; @TableField(exist = false) private Integer inuseYear; @TableField(exist = false) private String stationName; @TableField(exist = false) src/main/java/com/whyc/service/BattInfService.java
@@ -10,6 +10,7 @@ import com.whyc.dto.Param.ParamAlmDto; import com.whyc.dto.Real.QuarterDto; import com.whyc.dto.Response; import com.whyc.dto.SocreHehaviorDto; import com.whyc.dto.Statistic.*; import com.whyc.factory.InfoFactory; import com.whyc.mapper.BattInfMapper; @@ -510,4 +511,8 @@ public List<BattInf> getBattgroupIdListByDevId(Integer devId) { return mapper.getBattgroupIdListByDevId(devId); } //询符合条件的电池组权重表格评分 public List<BattInf> getScoreByHehavior(SocreHehaviorDto dto) { return mapper.getScoreByHehavior(dto); } } 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,"弹窗根据设置的权重表格评分"); } } src/main/resources/mapper/BattInfMapper.xml
@@ -278,7 +278,7 @@ and tb_batt_inf.inuse_time>=#{stic.inuseStartTime} </if> <if test="stic.inuseEndTime!=null"> and tb_batt_inf.inuse_time<=#{stic.inuseEndTimee} and tb_batt_inf.inuse_time<=#{stic.inuseEndTime} </if> <if test="stic.uid>100"> and tb_batt_inf.station_id in( @@ -315,7 +315,7 @@ and tb_batt_inf.inuse_time>=#{stic.inuseStartTime} </if> <if test="stic.inuseEndTime!=null"> and tb_batt_inf.inuse_time<=#{stic.inuseEndTimee} and tb_batt_inf.inuse_time<=#{stic.inuseEndTime} </if> <if test="stic.uid>100"> and tb_batt_inf.station_id in( @@ -501,4 +501,33 @@ </where> order by battgroup_num asc </select> <select id="getScoreByHehavior" resultType="com.whyc.pojo.db_station.BattInf"> select distinct tb_batt_inf.*,#{stic.inuserYear} as inuse_year from db_station.tb_batt_inf <where> <if test="stic.product!=null"> and tb_batt_inf.product=#{stic.product} </if> <if test="stic.moncapstd!=null"> and tb_batt_inf.moncapstd=#{stic.moncapstd} </if> <if test="stic.monvolstd!=null"> and tb_batt_inf.monvolstd=#{stic.monvolstd} </if> <if test="stic.inuseStartTime!=null"> and tb_batt_inf.inuse_time>=#{stic.inuseStartTime} </if> <if test="stic.inuseEndTime!=null"> and tb_batt_inf.inuse_time<=#{stic.inuseEndTime} </if> <if test="stic.uid>100"> and tb_batt_inf.station_id in( select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr where tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id and tb_baojigroup_usr.uid=#{stic.uid} ) </if> order by tb_batt_inf.dev_id asc,battgroup_id asc </where> </select> </mapper>