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,15 +29,17 @@ @Autowired private BattresdataInfService battRinfService; @Autowired private AppParamService appParamService; @ApiOperation(value = "蓄电池组对比分析界面(同一时间同一品牌/同一时间不同一品牌/不同一时间同一品牌)(1.2.15/16/17)") @ApiOperation(value = "蓄电池组对比分析界面(同一时间同一品牌/同一时间不同一品牌/不同一时间同一品牌)(2.5.1/2/3)") @PostMapping("getBattCompare15Statistic") public Response getBattCompare15Statistic(@RequestBody BattCompareStic stic) throws ParseException { User uinf= ActionUtil.getUser(); stic.setUid(uinf.getId()); if(stic.getInuserYear()!=null){ if(stic.getInuseYear()!=null){ int year=ActionUtil.getNowYear(); stic.setInuseStartTime(ActionUtil.sdfwithday.parse(ActionUtil.getDayTime(year+1-stic.getInuserYear(),0,1,5))); stic.setInuseStartTime(ActionUtil.sdfwithday.parse(ActionUtil.getDayTime(year+1-stic.getInuseYear(),0,1,5))); stic.setInuseEndTime(ActionUtil.sdfwithday.parse(ActionUtil.getDayTime(year,11,31,5))); } return battTinfService.getBattCompare15Statistic(stic); @@ -56,4 +62,42 @@ 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.getInuseYear()!=null){ int year=ActionUtil.getNowYear(); dto.setInuseStartTime(ActionUtil.sdfwithday.parse(ActionUtil.getDayTime(year+1-dto.getInuseYear(),0,1,5))); dto.setInuseEndTime(ActionUtil.sdfwithday.parse(ActionUtil.getDayTime(year,11,31,5))); } if (dto.getProduct()!=null) { if(dto.getInuseYear()!=null){ dto.setSelectType(1); }else{ dto.setSelectType(2); } }else{ if(dto.getInuseYear()!=null){ dto.setSelectType(3); }else{ dto.setSelectType(4); } } 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/ExportFileController.java
@@ -1,6 +1,7 @@ package com.whyc.controller; import com.whyc.dto.Real.ExportTinfDataDto; import com.whyc.dto.Statistic.BattCompareStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.service.ExportService; import io.swagger.annotations.Api; @@ -31,4 +32,10 @@ public void exportTinfDataByTestRecordCount(HttpServletRequest req, HttpServletResponse resp ,@RequestBody ExportTinfDataDto dto) throws ParseException, IOException { service.exportTinfDataByTestRecordCount(req,resp,dto); } @PostMapping("exportBattCompare") @ApiOperation(value = "蓄电池组对比分析导出(2.5.1/2/3)") public void exportBattCompare(HttpServletRequest req, HttpServletResponse resp ,@RequestBody BattCompareStic stic) throws ParseException, IOException { service.exportBattCompare(req,resp,stic); } } 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/InfoDto.java
@@ -79,6 +79,14 @@ @ApiModelProperty(value = "整流器使能[bit0-模块1 bit15-模块16]【1-可用 0-不可以】") private Long modelCfg; @ApiModelProperty(value = "交流上限阈值") private Float acvolHighLimit; @ApiModelProperty(value = "交流下限阈值") private Float acvolLowLimit; @ApiModelProperty(value = "直流输出电压下限阈值") private Float dcoutvolLowLimit; @ApiModelProperty(value = "设备id") @@ -129,6 +137,30 @@ @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") private Date inuseTime; @ApiModelProperty(value = "浮充电压阈值") private Float floatVolLevel; @ApiModelProperty(value = "离线电压阈值") private Float offlinelineVolLevel; @ApiModelProperty(value = "浮充电流阈值") private Float floatCurrLevel; @ApiModelProperty(value = "最大核容电流(0~300)") private Float maxDisCurr; @ApiModelProperty(value = "验签格式0-常规 1-正常1拖2[61850设备有效]") private Integer signType; @ApiModelProperty(value = "通信端口号【0-使用设备默认端口号】") private Integer commPort; @ApiModelProperty(value = "负载电流") private Float loadCurr; @ApiModelProperty(value = "视频监控序列号") private String videoUrl; @ApiModelProperty(value = "标识是否加入电池组1:添加,0不添加") private Integer addBinfFlag; 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,26 @@ 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 inuseYear;//投运时间1~15年 private Integer uid; /*1:选品牌,选投运时间 2:选品牌,不选投运时间 3:不选品牌,选投运时间 4:不选品牌,不选投运时间 */ private Integer selectType; } src/main/java/com/whyc/dto/Statistic/BattCompareStic.java
@@ -27,5 +27,12 @@ @JsonFormat(pattern = "yyyy-MM-dd") private Date inuseEndTime;//结束时间 private Integer inuserYear;//投运时间1~15年 private Integer inuseYear;//投运时间1~15年 //导出时使用 private Float avgCap;//导出时平均容量 private Float standCapDiff;//导出时容量标准差 private String picCap;//容量折线图 private String picRes;//最高内阻折线图 private String picFlotVol;//电池组浮充电压折线图 } src/main/java/com/whyc/dto/Statistic/SticCompare15Res.java
@@ -13,12 +13,16 @@ private String city; private String country; private String stationName; private String fullName; private String battgroupName; private String devName; private String product; @JsonFormat(pattern = "yyyy-MM-dd") private Date inuseTime; @JsonFormat(pattern = "yyyy-MM-dd") private String inuseTimeStr; private Float monvolstd; private Float moncapstd; //private List<Integer> monNums; //损坏单体编号 private Float realCap; //实际容量 private String precentCap; //容量百分比 src/main/java/com/whyc/factory/InfoFactory.java
@@ -15,7 +15,10 @@ .setProtocol(info.getProtocol()) .setPowerIp(info.getPowerIp()) .setModelCfg(info.getModelCfg()) .setPowerInuseTime(info.getPowerInuseTime()); .setPowerInuseTime(info.getPowerInuseTime()) .setAcvolHighLimit(info.getAcvolHighLimit()) .setAcvolLowLimit(info.getAcvolLowLimit()) .setDcoutvolLowLimit(info.getDcoutvolLowLimit()); if(info.getPowerId()!=null){ pinf.setPowerId(info.getPowerId()); } @@ -91,6 +94,30 @@ if(info.getInuseTime()!=null){ binf.setInuseTime(info.getInuseTime()); } if(info.getFloatVolLevel()!=null){ binf.setFloatVolLevel(info.getFloatVolLevel()); } if(info.getOfflinelineVolLevel()!=null){ binf.setOfflinelineVolLevel(info.getOfflinelineVolLevel()); } if(info.getFloatCurrLevel()!=null){ binf.setFloatCurrLevel(info.getFloatCurrLevel()); } if(info.getMaxDisCurr()!=null){ binf.setMaxDisCurr(info.getMaxDisCurr()); } if(info.getSignType()!=null){ binf.setSignType(info.getSignType()); } if(info.getCommPort()!=null){ binf.setCommPort(info.getCommPort()); } if(info.getLoadCurr()!=null){ binf.setLoadCurr(info.getLoadCurr()); } if(info.getVideoUrl()!=null){ binf.setVideoUrl(info.getVideoUrl()); } return binf; } } 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
@@ -87,6 +87,37 @@ @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") private Date inuseTime; @ApiModelProperty(value = "浮充电压阈值") private Float floatVolLevel; @ApiModelProperty(value = "离线电压阈值") private Float offlinelineVolLevel; @ApiModelProperty(value = "浮充电流阈值") private Float floatCurrLevel; @ApiModelProperty(value = "最大核容电流(0~300)") private Float maxDisCurr; @ApiModelProperty(value = "验签格式0-常规 1-正常1拖2[61850设备有效]") private Integer signType; @ApiModelProperty(value = "通信端口号【0-使用设备默认端口号】") private Integer commPort; @ApiModelProperty(value = "负载电流") private Float loadCurr; @ApiModelProperty(value = "视频监控序列号") private String videoUrl; @TableField(exist = false) private Integer inuseYear; @TableField(exist = false) private Integer battYear; @TableField(exist = false) private String stationName; src/main/java/com/whyc/pojo/db_station/PowerInf.java
@@ -69,6 +69,15 @@ @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") private Date powerInuseTime; @ApiModelProperty(value = "交流上限阈值") private Float acvolHighLimit; @ApiModelProperty(value = "交流下限阈值") private Float acvolLowLimit; @ApiModelProperty(value = "直流输出电压下限阈值") private Float dcoutvolLowLimit; @TableField(exist = false) private StationInf sinf; 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; @@ -232,6 +233,15 @@ if(pinf.getModelCfg()!=null){ wrapper2.set("model_cfg",pinf.getModelCfg()); } if(pinf.getAcvolHighLimit()!=null){ wrapper2.set("acvol_high_limit",pinf.getAcvolHighLimit()); } if(pinf.getAcvolLowLimit()!=null){ wrapper2.set("acvol_low_limit",pinf.getAcvolLowLimit()); } if(pinf.getDcoutvolLowLimit()!=null){ wrapper2.set("dcoutvol_low_limit",pinf.getDcoutvolLowLimit()); } /*if(pinf.getPowerName()!=null){ //检测该机房下要修改的电源名是否存在 QueryWrapper queryWrapper1=new QueryWrapper(); @@ -304,6 +314,30 @@ } if (binf.getInuseTime() != null) { wrapper4.set("inuse_time", binf.getInuseTime()); } if (binf.getFloatVolLevel() != null) { wrapper4.set("float_vol_level", binf.getFloatVolLevel()); } if (binf.getOfflinelineVolLevel() != null) { wrapper4.set("offlineline_vol_level", binf.getOfflinelineVolLevel()); } if (binf.getFloatCurrLevel() != null) { wrapper4.set("float_curr_level", binf.getFloatCurrLevel()); } if (binf.getMaxDisCurr() != null) { wrapper4.set("max_dis_curr", binf.getMaxDisCurr()); } if (binf.getSignType()!= null) { wrapper4.set("sign_type", binf.getSignType()); } if (binf.getCommPort()!= null) { wrapper4.set("comm_port", binf.getCommPort()); } if (binf.getLoadCurr()!= null) { wrapper4.set("load_curr", binf.getLoadCurr()); } if (binf.getVideoUrl()!= null) { wrapper4.set("video_url", binf.getVideoUrl()); } wrapper4.eq("battgroup_id", binf.getBattgroupId()); mapper.update((BattInf) ActionUtil.objeNull,wrapper3); @@ -510,4 +544,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 { @@ -313,11 +316,14 @@ res.setDevName(binf.getDevName()); res.setProduct(binf.getProduct()); res.setInuseTime(binf.getInuseTime()); res.setInuseTimeStr(ActionUtil.sdfwithday.format(binf.getInuseTime())); res.setMonvolstd(binf.getMonvolstd()); res.setMoncapstd(binf.getMoncapstd()); res.setStationId(binf.getStationId()); res.setPowerId(binf.getPowerId()); res.setDevId(binf.getDevId()); res.setBattgroupId(binf.getBattgroupId()); res.setFullName(binf.getFullName()); //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); if(tinf==null){ @@ -386,11 +392,97 @@ } map.put("avgCap",sumCap/binfList.size()); map.put("standCapDiff",maxCap-minCap); PageInfo pageInfo=PageInfoUtils.list2PageInfo(comparelist, stic.getPageNum(), stic.getPageSize()); return new Response().setIII(1,comparelist.size()>0,pageInfo,map,"蓄电池组对比分析界面(同一品牌同一时间)"); } /*蓄电池组对比分析导出使用 */ public List<SticCompare15Res> exportBattCompare(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); List<SticCompare15Res> comparelist=new ArrayList<>(); if(binfList!=null&&binfList.size()>=0){ for (BattInf binf:binfList) { SticCompare15Res res=new SticCompare15Res(); res.setProvice(binf.getProvice()); res.setCity(binf.getCity()); res.setCountry(binf.getCountry()); res.setStationName(binf.getStationName()); res.setBattgroupName(binf.getBattgroupName()); res.setDevName(binf.getDevName()); res.setProduct(binf.getProduct()); res.setInuseTime(binf.getInuseTime()); res.setInuseTimeStr(ActionUtil.sdfwithday.format(binf.getInuseTime())); res.setMonvolstd(binf.getMonvolstd()); res.setMoncapstd(binf.getMoncapstd()); res.setStationId(binf.getStationId()); res.setPowerId(binf.getPowerId()); res.setDevId(binf.getDevId()); res.setBattgroupId(binf.getBattgroupId()); res.setFullName(binf.getFullName()); //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),stic.getTestStartTime(),stic.getTestEndTime()); if(tinf==null){ res.setRealCap(0f); res.setPrecentCap("0.00000"); res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId())); res.setStopReason("--"); res.setFloatGroupVol(0f); }else{ res.setStopReason(StopReasonEnum.getValue(tinf.getTestStoptype())); res.setFloatGroupVol(tinf.getFloatGroupVol()); //找这次放电的最后一笔数据 List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum()); if(idDataList==null||idDataList.size()==0){ res.setRealCap(0f); res.setPrecentCap("0.00000"); res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_4.getStateId())); res.setFloatGroupVol(0f); }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); //Float restCap = (float) BattCapFactory.GetMonomerCap(binf.getMoncapstd(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest); res.setRealCap(grouprealCap); if(grouprealCap>=moncapStd*badValue){ res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_1.getStateId())); } if(grouprealCap<=moncapStd*damageValue){ res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_3.getStateId())); } if((grouprealCap>moncapStd*damageValue)&&(grouprealCap<moncapStd*badValue)){ res.setCapperformance(BattCapperformanceEnum.getValue(BattCapperformanceEnum.BATTSTATE_2.getStateId())); } //保留5位小数 String precentCap = String.format("%.5f",(grouprealCap/binf.getMoncapstd()*100)); res.setPrecentCap(precentCap); } } if(stic.getPerformance()==null){ comparelist.add(res); }else{ if(res.getCapperformance().equals(BattCapperformanceEnum.getValue(stic.getPerformance()))){ comparelist.add(res); } } } } return comparelist; } //蓄电池组对比分析界面(不同品牌同一时间)(1.2.16) public Response getBattCompare16Statistic(BattCompareStic stic) { //获取核容优劣,损坏参数 @@ -1090,4 +1182,314 @@ } return new Response().setII(1,list.size()>0,curvelist,"点击右侧折线图画出电池组所有完整周期的浮充电压变化图(1.2.15/16/17)"); } //弹窗根据设置的权重表格评分 public Response getScoreByHehavior(SocreHehaviorDto dto) { 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=new HashMap<>(); if(dto.getSelectType()==1){//选品牌,选时间 map=binfList.stream().collect(Collectors.groupingBy(item -> item.getProduct() + '-' + item.getInuseYear())); groupby1(dto,reslist,map); } if(dto.getSelectType()==2){//选品牌,不选时间 map=binfList.stream().collect(Collectors.groupingBy(item -> item.getProduct())); groupby2(dto,reslist,map); } if(dto.getSelectType()==3){//不选品牌,选时间 map=binfList.stream().collect(Collectors.groupingBy(item -> ""+item.getInuseYear())); groupby3(dto,reslist,map); } if(dto.getSelectType()==4){//不选品牌不选时间 map=binfList.stream().collect(Collectors.groupingBy(item -> item.getMonvolstd().toString() + '-' + item.getMoncapstd())); groupby4(dto,reslist,map); } } return new Response().setII(1,reslist.size()>0,reslist,"弹窗根据设置的权重表格评分"); } //不选品牌不选时间 private void groupby4(SocreHehaviorDto dto,List<ResSocreHehavior> reslist, Map<String, List<BattInf>> 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(); } } } for (String groupType : map.keySet()) { List<BattInf> list=map.get(groupType); Map<String,List<BattInf>> groupMap=list.stream().collect(Collectors.groupingBy(item -> item.getProduct()+"-"+item.getBattYear())); for (String group : groupMap.keySet()) { List<BattInf> grouplist=groupMap.get(group); ResSocreHehavior res=new ResSocreHehavior(); Integer goodBatt=0; Integer badBatt=0; Integer damageBatt=0; Integer nodisBatt=0; Integer sumBatt=grouplist.size(); res.setSumBatt(sumBatt); String[] productYearparts = group.split("-"); // 使用split方法分割字符串 res.setProduct(productYearparts[0]); res.setInuseYear(productYearparts[1]+"年内"); res.setMonvolstd(dto.getMonvolstd()); res.setMoncapstd(dto.getMoncapstd()); for (BattInf binf:grouplist) { Float moncapStd=binf.getMoncapstd(); //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),null,null); if(tinf==null){ nodisBatt++; }else{ int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); Float grouprealCap = (float) BattCapFactory.GetMonomerCap(moncapStd, 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); } } } //不选品牌,选时间 private void groupby3(SocreHehaviorDto dto,List<ResSocreHehavior> reslist, Map<String, List<BattInf>> 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(); } } } for (String groupType : map.keySet()) { List<BattInf> list=map.get(groupType); Map<String,List<BattInf>> productMap=list.stream().collect(Collectors.groupingBy(item -> item.getProduct())); for (String product : productMap.keySet()) { List<BattInf> productList=productMap.get(product); ResSocreHehavior res=new ResSocreHehavior(); res.setInuseYear(dto.getInuseYear()+"年内"); res.setProduct(product); Integer goodBatt=0; Integer badBatt=0; Integer damageBatt=0; Integer nodisBatt=0; Integer sumBatt=productList.size(); res.setSumBatt(sumBatt); res.setMonvolstd(dto.getMonvolstd()); res.setMoncapstd(dto.getMoncapstd()); for (BattInf binf:productList) { Float moncapStd=binf.getMoncapstd(); //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),null,null); if(tinf==null){ nodisBatt++; }else{ int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); Float grouprealCap = (float) BattCapFactory.GetMonomerCap(moncapStd, 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); } } } //选品牌,不选时间 private void groupby2(SocreHehaviorDto dto,List<ResSocreHehavior> reslist, Map<String, List<BattInf>> 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(); } } } for (String groupType : map.keySet()) { List<BattInf> list=map.get(groupType); Map<String,List<BattInf>> timeMap=list.stream().collect(Collectors.groupingBy(item -> item.getBattYear().toString())); for (String time : timeMap.keySet()) { List<BattInf> timeList=timeMap.get(time); ResSocreHehavior res=new ResSocreHehavior(); res.setProduct(dto.getProduct()); res.setInuseYear(time+"年内"); Integer goodBatt=0; Integer badBatt=0; Integer damageBatt=0; Integer nodisBatt=0; Integer sumBatt=timeList.size(); res.setSumBatt(sumBatt); res.setMonvolstd(dto.getMonvolstd()); res.setMoncapstd(dto.getMoncapstd()); for (BattInf binf:timeList) { Float moncapStd=binf.getMoncapstd(); //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),null,null); if(tinf==null){ nodisBatt++; }else{ int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); Float grouprealCap = (float) BattCapFactory.GetMonomerCap(moncapStd, 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); } } } //选品牌,选时间 private void groupby1(SocreHehaviorDto dto,List<ResSocreHehavior> reslist, Map<String, List<BattInf>> 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(); } } } for (String groupType : map.keySet()) { List<BattInf> list=map.get(groupType); ResSocreHehavior res=new ResSocreHehavior(); res.setProduct(dto.getProduct()); res.setInuseYear(dto.getInuseYear()+"年内"); Integer goodBatt=0; Integer badBatt=0; Integer damageBatt=0; Integer nodisBatt=0; Integer sumBatt=list.size(); res.setSumBatt(sumBatt); res.setMonvolstd(dto.getMonvolstd()); res.setMoncapstd(dto.getMoncapstd()); for (BattInf binf:list) { Float moncapStd=binf.getMoncapstd(); //2.获取电池组在给定时间段的放电记录(指定时间段的标准核容放电) BatttestdataInf tinf =getLastStandardTestDataByTime(binf.getBattgroupId(),null,null); if(tinf==null){ nodisBatt++; }else{ int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); Float grouprealCap = (float) BattCapFactory.GetMonomerCap(moncapStd, 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); } } } src/main/java/com/whyc/service/ExportService.java
@@ -5,7 +5,9 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import com.whyc.dto.Real.ExportTinfDataDto; import com.whyc.dto.Response; import com.whyc.dto.Statistic.BattCompareStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.SticCompare15Res; import com.whyc.dto.Statistic.SticMonRes; import com.whyc.mapper.CommonMapper; import com.whyc.pojo.db_batt_testdata.BatttestdataId; @@ -229,4 +231,49 @@ e.printStackTrace(); } } //蓄电池组对比分析导出(2.5.1/2/3) public void exportBattCompare(HttpServletRequest req, HttpServletResponse resp, BattCompareStic stic) throws IOException { Map<String,Object> map=new HashMap<>(); map.put("avgCap",stic.getAvgCap()); map.put("standCapDiff",stic.getStandCapDiff()); //表格数据 List<SticCompare15Res> dataList= battTinfService.exportBattCompare(stic); map.put("dataList",dataList); BASE64Decoder decoder = new BASE64Decoder(); if(!stic.getPicCap().equals("")) { ImageEntity volImage = new ImageEntity(); volImage.setData(decoder.decodeBuffer(stic.getPicCap().substring(stic.getPicCap().indexOf(",") + 1))); volImage.setColspan(6); volImage.setRowspan(17); map.put("picCap",volImage); } if(!stic.getPicRes().equals("")) { ImageEntity volImage = new ImageEntity(); volImage.setData(decoder.decodeBuffer(stic.getPicRes().substring(stic.getPicRes().indexOf(",") + 1))); volImage.setColspan(6); volImage.setRowspan(17); map.put("picRes",volImage); } if(!stic.getPicFlotVol().equals("")) { ImageEntity volImage = new ImageEntity(); volImage.setData(decoder.decodeBuffer(stic.getPicFlotVol().substring(stic.getPicFlotVol().indexOf(",") + 1))); volImage.setColspan(6); volImage.setRowspan(17); map.put("picFlotVol",volImage); } //获取导出模板地址 ClassPathResource classPathResource = new ClassPathResource("excel_templates/batt_compare_template.xlsx"); String path = classPathResource.getPath(); TemplateExportParams templateExportParams1 = new TemplateExportParams(path,true); Workbook wb = ExcelExportUtil.exportExcel(templateExportParams1, map); try { String fileName = "蓄电池组对比数据.xls"; resp.setContentType("application/vnd.ms-excel"); resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8")); resp.flushBuffer(); wb.write(resp.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } } } src/main/resources/excel_templates/batt_compare_template.xlsxBinary files differ
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.*,(TIMESTAMPDIFF(YEAR, tb_batt_inf.inuse_time,CURDATE())+1) as batt_year,#{stic.inuseYear} 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>