src/main/java/com/whyc/constant/Capperformance.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/controller/ConditionController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/controller/StatisticController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/dto/Statistic/BattCompareStic.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/dto/Statistic/SticCompareRes.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/mapper/BattInfMapper.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/constant/Capperformance.java
New file @@ -0,0 +1,46 @@ package com.whyc.constant; import java.util.HashMap; import java.util.Map; public enum Capperformance { BATTSTATE_1(1,"优秀"), BATTSTATE_2(2,"劣化"), BATTSTATE_3(3,"损坏"), ; private Integer stateId; private String stateName; Capperformance(Integer stateId, String stateName) { this.stateId = stateId; this.stateName = stateName; } public Integer getStateId() { return stateId; } public String getStateName() { return stateName; } public static String getValue(Integer stateId) { if(stateId==null){ return ""; } for (Capperformance ele : values()) { if(ele.getStateId().equals(stateId)) { return ele.getStateName(); } } return null; } public static Map<Integer,String> getOpInfo() { Map<Integer,String> map=new HashMap<>(); for (Capperformance logOpEnum : Capperformance.values()) { map.put(logOpEnum.getStateId(),logOpEnum.getStateName()); } return map; } } src/main/java/com/whyc/controller/ConditionController.java
@@ -163,6 +163,12 @@ return pwrAlmService.getPwrAlmIdType(); } @ApiOperation(value = "获取容量性能(下拉)") @GetMapping("getCapperformance") public Response getCapperformance(){ return binfService.getCapperformance(); } @ApiOperation(value = "获取设备工作类型(下拉)") @GetMapping("getDevState") public Response getDevState(){ src/main/java/com/whyc/controller/StatisticController.java
@@ -1,10 +1,7 @@ package com.whyc.controller; import com.whyc.dto.Response; import com.whyc.dto.Statistic.BattTinfStic; import com.whyc.dto.Statistic.DeviceStateStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.StationStic; import com.whyc.dto.Statistic.*; import com.whyc.pojo.db_user.User; import com.whyc.service.*; import com.whyc.util.ActionUtil; @@ -82,6 +79,13 @@ stic.setUid(uinf.getId()); return battTinfService.getBattTinfStatistic(stic); } @ApiOperation(value = "蓄电池组对比分析界面(同一品牌同一时间)(1.2.15)") @PostMapping("getBattCompare15Statistic") public Response getBattCompare15Statistic(@RequestBody BattCompareStic stic){ User uinf= ActionUtil.getUser(); stic.setUid(uinf.getId()); return battTinfService.getBattCompare15Statistic(stic); } @ApiOperation(value = "设备工作状态统计(1.2.21)") @PostMapping("getDeviceStateStatistic") @@ -90,4 +94,6 @@ stic.setUid(uinf.getId()); return deviceStateService.getDeviceStateStatistic(stic); } } src/main/java/com/whyc/dto/Statistic/BattCompareStic.java
New file @@ -0,0 +1,23 @@ package com.whyc.dto.Statistic; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.util.Date; @Data public class BattCompareStic { private String provice; private String city; private String country; private String stationName; private Integer uid; private Integer pageNum; private Integer pageSize; private Integer performance;//电池性能:1优秀,2劣化,3损坏 private String product; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date testStartTime;//开始时间 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date testEndTime;//结束时间 } src/main/java/com/whyc/dto/Statistic/SticCompareRes.java
New file @@ -0,0 +1,24 @@ package com.whyc.dto.Statistic; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.util.Date; import java.util.List; @Data public class SticCompareRes { private String provice; private String city; private String country; private String stationName; private String battgroupName; private String product; @JsonFormat(pattern = "yyyy-MM-dd") private Date inuseTime; private Float monvolstd; private List<Integer> monNums; //损坏单体编号 private Float realCap; //实际容量 private String precentCap; //容量百分比 private String capperformance; //性能 } src/main/java/com/whyc/mapper/BattInfMapper.java
@@ -2,6 +2,7 @@ import com.whyc.dto.BattDto; import com.whyc.dto.InfoDto; import com.whyc.dto.Statistic.BattCompareStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.StationStic; import com.whyc.pojo.db_station.BattInf; @@ -40,4 +41,6 @@ List<BattInf> getBattStatistic(@Param("stic") StationStic stic); //单体统计查询符合条件的电池组 List<BattInf> getMonStatistic(@Param("stic") MonStic stic); //蓄电池组对比分析界面 List<BattInf> getBattCompare15Statistic(@Param("stic") BattCompareStic stic); } src/main/java/com/whyc/service/BattInfService.java
@@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.whyc.constant.Capperformance; import com.whyc.constant.PowerAlarmEnum; import com.whyc.dto.BattDto; import com.whyc.dto.InfoDto; import com.whyc.dto.Real.QuarterDto; import com.whyc.dto.Response; import com.whyc.dto.Statistic.BattCompareStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.StationStic; import com.whyc.factory.InfoFactory; @@ -26,6 +29,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; @Service public class BattInfService { @@ -435,4 +439,13 @@ public List<BattInf> getMonStatistic(MonStic stic) { return mapper.getMonStatistic(stic); } //蓄电池组对比分析界面 public List<BattInf> getBattCompare15Statistic(BattCompareStic stic) { return mapper.getBattCompare15Statistic(stic); } //获取容量性能(下拉) public Response getCapperformance() { Map<Integer,String> map= Capperformance.getOpInfo(); return new Response().setII(1,true,map,"获取容量性能(下拉)"); } } src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -3,11 +3,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.whyc.constant.Capperformance; import com.whyc.dto.Response; import com.whyc.dto.Statistic.BattTinfStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.StationStic; import com.whyc.dto.Statistic.SticMonRes; import com.whyc.dto.Statistic.*; import com.whyc.factory.BattCapFactory; import com.whyc.mapper.BattInfMapper; import com.whyc.mapper.BatttestdataInfMapper; @@ -17,13 +15,11 @@ import com.whyc.pojo.db_ram_db.BattRtdata; import com.whyc.pojo.db_ram_db.BattRtstate; import com.whyc.pojo.db_station.BattInf; import com.whyc.util.PageInfoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.*; @Service public class BatttestdataInfService { @@ -219,4 +215,108 @@ } } } /*蓄电池组对比分析界面(同一品牌同一时间) *1.查询出符合条件的电池组信息 * 2.计算电池组的预估剩余容量 *3.判断性能和百分比 * 4.分页 */ public Response getBattCompare15Statistic(BattCompareStic stic) { //获取核容优劣,损坏参数 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(); } } } //1查询符合条件的电池组 List<BattInf> binfList=battInfService.getBattCompare15Statistic(stic); if(binfList==null||binfList.size()==0){ return new Response().set(1,false,"当前用户未管理满足条件的电池组"); } List<SticCompareRes> reslist=new ArrayList<>(); for (BattInf binf:binfList) { SticCompareRes res=new SticCompareRes(); res.setProvice(binf.getProvice()); res.setCity(binf.getCity()); res.setCountry(binf.getCountry()); res.setStationName(binf.getStationName()); res.setBattgroupName(binf.getBattgroupName()); res.setProduct(binf.getProduct()); res.setInuseTime(binf.getInuseTime()); res.setMonvolstd(binf.getMonvolstd()); //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); if(tinf==null){ res.setRealCap(0f); res.setPrecentCap("0"); res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); continue; } //找这次放电的最后一笔数据 List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum()); if(idDataList==null||idDataList.size()==0){ res.setRealCap(0f); res.setPrecentCap("0"); res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); continue; } Float moncapStd=binf.getMoncapstd(); int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); Float grouprealCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real); //Float restCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest); res.setRealCap(grouprealCap); if(grouprealCap>=moncapStd*badValue){ res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_1.getStateId())); } if(grouprealCap<=moncapStd*damageValue){ res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_3.getStateId())); } if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){ res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_2.getStateId())); } //保留5位小数 String precentCap = String.format("%.5f",(grouprealCap/binf.getMoncapstd()*100)); res.setPrecentCap(precentCap); List<Integer> monNums=new ArrayList<>(); for (BatttestdataId data:idDataList) {//求单体的 实际容量,最小值就是单体的单体电压 Float monrealCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), data.getMonVol(), tinf.getGroupVol(), BattCapFactory.CapType_Real); if (monrealCap <= moncapStd * damageValue) {//损坏的 monNums.add(data.getMonNum()); } } res.setMonNums(monNums); if(stic.getPerformance()==0){ reslist.add(res); }else{ if(res.getCapperformance().equals(Capperformance.getValue(stic.getPerformance()))){ reslist.add(res); } } } PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize()); return new Response().setII(1,reslist.size()>0,pageInfo,"蓄电池组对比分析界面(同一品牌同一时间)"); } //获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) private BatttestdataInf getLastStandardTestDataByTime(Integer battgroupId, Date testStartTime, Date testEndTime) { QueryWrapper wrapper = new QueryWrapper(); wrapper.eq("battgroup_id", battgroupId); wrapper.eq("test_type", 3); wrapper.eq("test_starttype", 3); wrapper.gt("test_starttime",testStartTime); wrapper.lt("test_starttime",testEndTime); wrapper.last(" and test_timelong >= 7200 ORDER BY test_starttime DESC "); wrapper.last("limit 1"); BatttestdataInf tinf = mapper.selectOne(wrapper); return tinf; } } src/main/resources/mapper/BattInfMapper.xml
@@ -209,5 +209,36 @@ </if> </where> </select> <select id="getBattCompare15Statistic" resultType="com.whyc.pojo.db_station.BattInf"> select distinct tb_batt_inf.* ,tb_station_inf.station_type,tb_station_inf.station_name,tb_station_inf.provice,tb_station_inf.city,tb_station_inf.country,tb_station_inf.full_name from db_station.tb_batt_inf,db_station.tb_station_inf <where> tb_batt_inf.station_id=tb_station_inf.station_id <if test="stic.provice!=null"> and tb_station_inf.provice=#{stic.provice} </if> <if test="stic.city!=null"> and tb_station_inf.city=#{stic.city} </if> <if test="stic.country!=null"> and tb_station_inf.country=#{stic.country} </if> <if test="stic.stationName!=null"> and tb_station_inf.station_name=#{stic.stationName} </if> <if test="stic.product!=null"> and tb_batt_inf.product=#{stic.product} </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>