src/main/java/com/whyc/constant/ChargeTypeEnum.java
New file @@ -0,0 +1,45 @@ package com.whyc.constant; import java.util.HashMap; import java.util.Map; public enum ChargeTypeEnum { ChargeType_1(1,"已放电"), ChargeTyp_2(2,"未放电"), ; private Integer stateId; private String stateName; ChargeTypeEnum(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 (ChargeTypeEnum 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 (ChargeTypeEnum logOpEnum : ChargeTypeEnum.values()) { map.put(logOpEnum.getStateId(),logOpEnum.getStateName()); } return map; } } src/main/java/com/whyc/controller/StatisticController.java
@@ -67,6 +67,22 @@ return new Response().setII(1,true,map,"单节数量统计"); } @ApiOperation(value = "本年度已放电数量统计(1.2.5)") @PostMapping("getDischr5Statistic") public Response getDischr5Statistic(@RequestBody DisChargeStic stic){ User uinf= ActionUtil.getUser(); stic.setUid(uinf.getId()); return battTinfService.getDischr5Statistic(stic); } @ApiOperation(value = "本年度未放电数量统计(1.2.6)") @PostMapping("getDischr6Statistic") public Response getDischr6Statistic(@RequestBody DisChargeStic stic){ User uinf= ActionUtil.getUser(); stic.setUid(uinf.getId()); return battTinfService.getDischr6Statistic(stic); } @ApiOperation(value = "站点信息统计(1.2.11)") @PostMapping("getStationStatistic") src/main/java/com/whyc/dto/Statistic/BanZu.java
New file @@ -0,0 +1,11 @@ package com.whyc.dto.Statistic; import lombok.Data; @Data public class BanZu { private Integer baojiGroupId; private String baojiGroupName; private Integer dischargeNum; private Integer nochargeNum; } src/main/java/com/whyc/dto/Statistic/DisChargeStic.java
New file @@ -0,0 +1,22 @@ package com.whyc.dto.Statistic; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.util.Date; @Data public class DisChargeStic { private String provice; private String city; private String country; private String stationName; private Integer disChargeType; //1.已放电 2.未放电 不传全部 private Integer uid; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date testStartTime;//开始时间 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date testEndTime;//结束时间 private Integer pageNum; private Integer pageSize; } src/main/java/com/whyc/dto/Statistic/SticDischarge5Res.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 SticDischarge5Res { private String provice; private String city; private String country; private String stationName; private String battgroupName; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date testStartTime; private Float realCap; //实际容量 private Integer testTimelong; //测试时长 private Float testCap; //测试容量 private String stopReason; //停止原因 private String capperformance; //电池性能 private Integer disChargeType; //1.已放电 2.未放电 不传全部 } 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.Statistic.BattCompareStic; import com.whyc.dto.Statistic.DisChargeStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.StationStic; import com.whyc.pojo.db_station.BattInf; @@ -47,4 +48,6 @@ List<BattInf> getBattCompare16Statistic(@Param("stic") BattCompareStic stic); //蓄电池组对比分析界面 List<BattInf> getBattCompare17Statistic(@Param("stic") BattCompareStic stic); //本年度已放电数量统计(1.2.5) List<BattInf> getDischr5Statistic(@Param("stic") DisChargeStic stic); } src/main/java/com/whyc/mapper/PowerInfMapper.java
@@ -24,4 +24,6 @@ List<String> getProtocolByUid(Integer uid); //电源信息统计 List<PowerInf> getPowerStatistic(@Param("stic") StationStic stic); //查询机房所在的班组 String getGroupName(Integer powerId); } src/main/java/com/whyc/pojo/db_station/BattInf.java
@@ -114,4 +114,8 @@ @TableField(exist = false) @ApiModelProperty(value = "设备下电池组个数") private Integer battCount; @TableField(exist = false) @ApiModelProperty(value = "包机组名称") private String baojiGroupName; } src/main/java/com/whyc/service/BaojigroupService.java
@@ -244,4 +244,16 @@ update.eq("station_id",sid); bjPowermapper.delete(update); } //查询机房所在的班组 public String getGroupName(Integer powerId) { String groupName = powerInfMapper.getGroupName(powerId); return groupName; } //查询所有的包机组名集合 public List<Baojigroup> getGroupList() { QueryWrapper wrapper=new QueryWrapper(); wrapper.eq("team_flag",1); List<Baojigroup> list=mapper.selectList(wrapper); return list; } } src/main/java/com/whyc/service/BattInfService.java
@@ -11,6 +11,7 @@ import com.whyc.dto.Real.QuarterDto; import com.whyc.dto.Response; import com.whyc.dto.Statistic.BattCompareStic; import com.whyc.dto.Statistic.DisChargeStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.StationStic; import com.whyc.factory.InfoFactory; @@ -442,7 +443,7 @@ public List<BattInf> getMonStatistic(MonStic stic) { return mapper.getMonStatistic(stic); } //蓄电池组对比分析界面 //蓄电池组对比分析界面15 public List<BattInf> getBattCompare15Statistic(BattCompareStic stic) { return mapper.getBattCompare15Statistic(stic); } @@ -451,12 +452,16 @@ Map<Integer,String> map= Capperformance.getOpInfo(); return new Response().setII(1,true,map,"获取容量性能(下拉)"); } //蓄电池组对比分析界面 //蓄电池组对比分析界面16 public List<BattInf> getBattCompare16Statistic(BattCompareStic stic) { return mapper.getBattCompare16Statistic(stic); } //蓄电池组对比分析界面 //蓄电池组对比分析界面17 public List<BattInf> getBattCompare17Statistic(BattCompareStic stic) { return mapper.getBattCompare17Statistic(stic); } //本年度已放电数量统计(1.2.5) public List<BattInf> getDischr5Statistic(DisChargeStic stic) { return mapper.getDischr5Statistic(stic); } } src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -16,7 +16,9 @@ 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.pojo.db_user.Baojigroup; import com.whyc.util.PageInfoUtils; import com.whyc.util.ThreadLocalUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -41,6 +43,9 @@ @Autowired(required = false) private AppParamService appParamService; @Autowired(required = false) private BaojigroupService bjService; @@ -437,7 +442,7 @@ } } //1查询符合条件的电池组 List<BattInf> binfList=battInfService.getBattCompare15Statistic(stic); List<BattInf> binfList=battInfService.getBattCompare17Statistic(stic); if(binfList==null||binfList.size()==0){ return new Response().set(1,false,"当前用户未管理满足条件的电池组"); } @@ -604,4 +609,193 @@ } return new Response().setII(1,true,map,"历史测试记录"); } //本年度已放电数量统计(1.2.5) public Response getDischr5Statistic(DisChargeStic stic) { Map<String, Object> map=new HashMap<>(); //查询出所有的班组并赋予初始值 setBanZuDefault(map); //获取核容优劣,损坏参数 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.getDischr5Statistic(stic); if(binfList==null||binfList.size()==0){ return new Response().set(1,false,"当前用户未管理满足条件的电池组"); } List<SticDischarge5Res> reslist=new ArrayList<>(); for (BattInf binf:binfList) { //查询电池组所在的班组 String groupName=bjService.getGroupName(binf.getPowerId()); SticDischarge5Res res=new SticDischarge5Res(); res.setProvice(binf.getProvice()); res.setCity(binf.getCity()); res.setCountry(binf.getCountry()); res.setStationName(binf.getStationName()); res.setBattgroupName(binf.getBattgroupName()); //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); if(tinf==null){ res.setRealCap(0f); res.setTestStartTime(ThreadLocalUtil.parse("1972-01-01 00:00:00",1)); res.setTestTimelong(0); res.setTestCap(0f); res.setStopReason(""); res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId())); res.setDisChargeType(2); if(!groupName.equals("none")){ BanZu bz= (BanZu) map.get(groupName); int nochargeNum=bz.getNochargeNum(); bz.setNochargeNum(nochargeNum+1); map.put(groupName,bz); } continue; } if(!groupName.equals("none")){ BanZu bz= (BanZu) map.get(groupName); int dischargeNum=bz.getDischargeNum(); bz.setDischargeNum(dischargeNum+1); map.put(groupName,bz); } res.setTestStartTime(tinf.getTestStarttime()); res.setTestTimelong(tinf.getTestTimelong()); res.setTestCap(tinf.getTestCap()); res.setStopReason(StopReasonEnum.getValue(tinf.getTestStoptype())); 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); res.setRealCap(grouprealCap); res.setDisChargeType(1); 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())); } if(stic.getDisChargeType()==null){ reslist.add(res); }else{ if(res.getDisChargeType()==stic.getDisChargeType()){ reslist.add(res); } } } PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize()); return new Response().setIII(1,reslist.size()>0,pageInfo,map,"本年度已放电数量统计"); } //查询出所有的班组并赋予初始值 private void setBanZuDefault(Map<String, Object> map) { List<Baojigroup> banZuList=bjService.getGroupList(); for (Baojigroup bj:banZuList) { BanZu bz=new BanZu(); bz.setBaojiGroupId(bj.getBaojiGroupId()); bz.setBaojiGroupName(bj.getBaojiGroupName()); bz.setDischargeNum(0); bz.setNochargeNum(0); map.put(bj.getBaojiGroupName(),bz); } } //本年度未放电数量统计(1.2.6) public Response getDischr6Statistic(DisChargeStic stic) { Map<String, Object> map=new HashMap<>(); //查询出所有的班组并赋予初始值 setBanZuDefault(map); //获取核容优劣,损坏参数 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.getDischr5Statistic(stic); if(binfList==null||binfList.size()==0){ return new Response().set(1,false,"当前用户未管理满足条件的电池组"); } List<SticDischarge5Res> reslist=new ArrayList<>(); for (BattInf binf:binfList) { //查询电池组所在的班组 String groupName=bjService.getGroupName(binf.getPowerId()); SticDischarge5Res res=new SticDischarge5Res(); res.setProvice(binf.getProvice()); res.setCity(binf.getCity()); res.setCountry(binf.getCountry()); res.setStationName(binf.getStationName()); res.setBattgroupName(binf.getBattgroupName()); //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); if(tinf==null){ res.setRealCap(0f); res.setTestStartTime(ThreadLocalUtil.parse("1972-01-01 00:00:00",1)); res.setTestTimelong(0); res.setTestCap(0f); res.setStopReason(""); res.setCapperformance(Capperformance.getValue(Capperformance.BATTSTATE_4.getStateId())); res.setDisChargeType(2); if(!groupName.equals("none")){ BanZu bz= (BanZu) map.get(groupName); int nochargeNum=bz.getNochargeNum(); bz.setNochargeNum(nochargeNum+1); map.put(groupName,bz); } continue; } if(!groupName.equals("none")){ BanZu bz= (BanZu) map.get(groupName); int dischargeNum=bz.getDischargeNum(); bz.setDischargeNum(dischargeNum+1); map.put(groupName,bz); } res.setTestStartTime(tinf.getTestStarttime()); res.setTestTimelong(tinf.getTestTimelong()); res.setTestCap(tinf.getTestCap()); res.setStopReason(StopReasonEnum.getValue(tinf.getTestStoptype())); 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); res.setRealCap(grouprealCap); res.setDisChargeType(1); 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())); } if(stic.getDisChargeType()==null){ reslist.add(res); }else{ if(res.getDisChargeType()==stic.getDisChargeType()){ reslist.add(res); } } } PageInfo pageInfo=PageInfoUtils.list2PageInfo(reslist, stic.getPageNum(), stic.getPageSize()); return new Response().setII(1,reslist.size()>0,pageInfo,"本年度未放电数量统计"); } } src/main/resources/mapper/BattInfMapper.xml
@@ -318,5 +318,33 @@ order by tb_batt_inf.dev_id asc,battgroup_id asc </where> </select> <select id="getDischr5Statistic" 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.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> src/main/resources/mapper/PowerInfMapper.xml
@@ -111,5 +111,15 @@ order by tb_power_inf.power_id asc </where> </select> <select id="getGroupName" resultType="java.lang.String"> select distinct ifnull(baoji_group_name,'none') from db_user.tb_baojigroup,db_user.tb_baojigroup_power <where> tb_baojigroup.baoji_group_id=tb_baojigroup_power.baoji_group_id and tb_baojigroup.team_flag=1 <if test="powerId!=null"> and power_id=#{powerId} </if> </where> </select> </mapper>