| | |
| | | import com.whyc.pojo.BattgroupData; |
| | | import com.whyc.pojo.FileParam; |
| | | import com.whyc.pojo.StationInfo; |
| | | import com.whyc.pojo.TestParam; |
| | | import com.whyc.util.MathUtil; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.text.NumberFormat; |
| | | import java.text.ParseException; |
| | | import java.text.ParsePosition; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | @Autowired |
| | | private StationInfoService stationInfoService; |
| | | |
| | | @Autowired |
| | | private TestParamService testParamService; |
| | | |
| | | public void resTestReport(BattGroupStationInfoWithFileParam info, HttpServletResponse response) throws IOException { |
| | | HashMap<String, Object> map = Maps.newHashMap(); |
| | | //总体评价:内阻/电压/连接条/?容量 |
| | | int resGoodCount = 0; |
| | | int volGoodCount = 0; |
| | | int chainResGoodCount = 0; |
| | | FileParam fileParam = info.getFileParam(); |
| | | //总体评价:有效的电阻/电压/连接条 数 |
| | | int battVolTestCount = 0; |
| | | int battResTestCount = 0; |
| | | int battChainResTestCount = 0; |
| | | FileParam param = info.getFileParam(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | fileParam.setTestTimeStr(format.format(fileParam.getTestTime())); |
| | | param.setTestTimeStr(format.format(param.getTestTime())); |
| | | //查询全局的测试系数和参数 |
| | | TestParam param2 = testParamService.getFactorsAndThreshold(); |
| | | //判断测试数据告警范围 |
| | | Float stdRes = param.getBattRes(); |
| | | Float volLowCoeK1 = null; |
| | | Float volHighCoeK2 = null; |
| | | //电压不同,电压阈值不同 |
| | | if(param.getBattVol() == 2){ |
| | | volLowCoeK1 = param2.getVol2LowCoeK1(); |
| | | volHighCoeK2 = param2.getVol2HighCoeK2(); |
| | | } |
| | | else if(param.getBattVol() == 1.2){ |
| | | volLowCoeK1 = param2.getVol1d2LowCoeK1(); |
| | | volHighCoeK2 = param2.getVol1d2HighCoeK2(); |
| | | } |
| | | else if(param.getBattVol() == 6){ |
| | | volLowCoeK1 = param2.getVol6LowCoeK1(); |
| | | volHighCoeK2 = param2.getVol6HighCoeK2(); |
| | | } |
| | | else if(param.getBattVol() == 12){ |
| | | volLowCoeK1 = param2.getVol12LowCoeK1(); |
| | | volHighCoeK2 = param2.getVol12HighCoeK2(); |
| | | }else{ //电压非常规值,则默认设置为2v的电压阈值 |
| | | volLowCoeK1 = param2.getVol2LowCoeK1(); |
| | | volHighCoeK2 = param2.getVol2HighCoeK2(); |
| | | } |
| | | Float resGoodCoeK3 = param2.getResGoodCoeK3(); |
| | | Float resBadCoeK4 = param2.getResBadCoeK4(); |
| | | Float chainRes = param.getVersion().toUpperCase().contains("V2.0")?param.getChainRes():param.getConnRes(); |
| | | Float finalVolLowCoeK = volLowCoeK1; |
| | | Float finalVolHighCoeK = volHighCoeK2; |
| | | List<BattgroupData> dataList = info.getDataList(); |
| | | for(BattgroupData data : dataList){ |
| | | //计算电压,内阻,连接条数值是否有效,被测试过 |
| | | float bv = Float.parseFloat(data.getBv()); |
| | | float br = Float.parseFloat(data.getBr()); |
| | | float cr = Float.parseFloat(data.getCr()); |
| | | if (bv!=0.0){ |
| | | battVolTestCount++; |
| | | } |
| | | if(br!=0.0){ |
| | | battResTestCount++; |
| | | } |
| | | if (cr!=0.0){ |
| | | battChainResTestCount++; |
| | | } |
| | | |
| | | data.setMonNumStr("#"+data.getMonNum()); |
| | | if(!data.isHighResFlag1() && !data.isHighResFlag2()){ |
| | | if(br==0.0){ |
| | | data.setResEvaluation("—"); |
| | | } |
| | | /*else if(!data.isHighResFlag1() && !data.isHighResFlag2()){ |
| | | resGoodCount +=1; |
| | | data.setResEvaluation("优"); |
| | | }else if(data.isHighResFlag1()){ |
| | | data.setResEvaluation("差"); |
| | | data.setResEvaluation("良"); |
| | | }else{ |
| | | data.setResEvaluation("很差"); |
| | | data.setResEvaluation("差"); |
| | | }*/ |
| | | else if(br >= stdRes*resGoodCoeK3/100){ |
| | | if(br >= stdRes*resBadCoeK4/100){ |
| | | // data.setHighResFlag2(true); |
| | | data.setResEvaluation("差"); |
| | | }else{ |
| | | // data.setHighResFlag1(true); |
| | | data.setResEvaluation("良"); |
| | | } |
| | | }else{ |
| | | resGoodCount +=1; |
| | | data.setResEvaluation("优"); |
| | | } |
| | | if(!data.isLowVolFlag() && !data.isHighVolFlag()){ |
| | | /*if(bv!=0.0 && !data.isLowVolFlag() && !data.isHighVolFlag()){ |
| | | volGoodCount +=1; |
| | | }*/ |
| | | if(bv!=0.0 && bv > finalVolLowCoeK && bv < finalVolHighCoeK){ |
| | | volGoodCount +=1; |
| | | } |
| | | if(!data.isHighChainResFlag()){ |
| | | /*if(cr!=0.0 && !data.isHighChainResFlag1() && !data.isHighChainResFlag2()){ |
| | | chainResGoodCount +=1; |
| | | }*/ |
| | | if(cr!=0.0 && cr < chainRes*param2.getChainResCoeK5()/100){ |
| | | chainResGoodCount +=1; |
| | | } |
| | | }; |
| | |
| | | info.setVolGoodCount(volGoodCount); |
| | | info.setChainResGoodCount(chainResGoodCount); |
| | | |
| | | info.setBattVolTestCount(battVolTestCount); |
| | | info.setBattResTestCount(battResTestCount); |
| | | info.setBattChainResTestCount(battChainResTestCount); |
| | | |
| | | StationInfo stationInfo = info.getStationInfo(); |
| | | if(stationInfo!=null) { |
| | | if (stationInfo.getStationName2().equals("-")) { |
| | | stationInfo.setStationName(stationInfo.getStationName1()); |
| | | } else { |
| | | stationInfo.setStationName(stationInfo.getStationName1() + "-" + stationInfo.getStationName2()); |
| | | } |
| | | } |
| | | map.put("dto", info); |
| | | //图片 |
| | | BASE64Decoder decoder = new BASE64Decoder(); |
| | |
| | | List<String> resBalanceRateList = data3.get("resBalanceRate"); |
| | | List<String> volBalanceRateList = data3.get("volBalanceRate"); |
| | | //均一性:chainRes/?容量/bs(电导) |
| | | List<Float> chainResList = dataList2.stream().map(BattgroupData::getCr).collect(Collectors.toList()); |
| | | List<Float> bsList = dataList2.stream().map(BattgroupData::getBs).collect(Collectors.toList()); |
| | | String chainResBalanceRate = MathUtil.getStandardDeviation(chainResList) * 10000 / 100 + "%"; |
| | | String bsBalanceRate = MathUtil.getStandardDeviation(bsList) * 10000 / 100 + "%"; |
| | | NumberFormat percentInstance = NumberFormat.getPercentInstance(); |
| | | percentInstance.setMinimumFractionDigits(2); |
| | | |
| | | List<Float> chainResList = dataList2.stream().map(BattgroupData::getCr).map(Float::parseFloat).collect(Collectors.toList()); |
| | | List<Float> bsList = dataList2.stream().map(BattgroupData::getBs).map(Float::parseFloat).collect(Collectors.toList()); |
| | | String chainResBalanceRate = percentInstance.format(MathUtil.getStandardDeviation(chainResList)); |
| | | String bsBalanceRate = percentInstance.format(MathUtil.getStandardDeviation(bsList)); |
| | | //获取FileParam和StationInfo |
| | | StationInfo stationInfo = stationInfoService.getByFileId(fileId2); |
| | | FileParam param = fileParamService.getByFileId(fileId2); |
| | |
| | | map.put("resImage",resImage); |
| | | } |
| | | |
| | | if(stationInfo.getStationName2().equals("-")){ |
| | | stationInfo.setStationName(stationInfo.getStationName1()); |
| | | }else{ |
| | | stationInfo.setStationName(stationInfo.getStationName1()+"-"+stationInfo.getStationName2()); |
| | | } |
| | | |
| | | map.put("fileParam",param); |
| | | map.put("stationInfo",stationInfo); |
| | | //总体评价:内阻/电压/连接条/?容量 |
| | | int resGoodCount = 0; |
| | | int volGoodCount = 0; |
| | | int chainResGoodCount = 0; |
| | | |
| | | //总体评价:有效的电阻/电压/连接条 数 |
| | | int battVolTestCount = 0; |
| | | int battResTestCount = 0; |
| | | int battChainResTestCount = 0; |
| | | |
| | | for(BattgroupData data : dataList2){ |
| | | //计算电压,内阻,连接条数值是否有效,被测试过 |
| | | float bv = Float.parseFloat(data.getBv()); |
| | | float br = Float.parseFloat(data.getBr()); |
| | | float cr = Float.parseFloat(data.getCr()); |
| | | if (bv!=0.0){ |
| | | battVolTestCount++; |
| | | } |
| | | if(br!=0.0){ |
| | | battResTestCount++; |
| | | } |
| | | if (cr!=0.0){ |
| | | battChainResTestCount++; |
| | | } |
| | | |
| | | data.setMonNumStr("#"+data.getMonNum()); |
| | | if(!data.isHighResFlag1() && !data.isHighResFlag2()){ |
| | | if(br==0.0){ |
| | | data.setResEvaluation("—"); |
| | | } |
| | | else if(!data.isHighResFlag1() && !data.isHighResFlag2() ){ |
| | | resGoodCount +=1; |
| | | data.setResEvaluation("优"); |
| | | }else if(data.isHighResFlag1()){ |
| | | data.setResEvaluation("差"); |
| | | data.setResEvaluation("良"); |
| | | }else{ |
| | | data.setResEvaluation("很差"); |
| | | data.setResEvaluation("差"); |
| | | } |
| | | if(!data.isLowVolFlag() && !data.isHighVolFlag()){ |
| | | if(bv!=0.0 && !data.isLowVolFlag() && !data.isHighVolFlag()){ |
| | | volGoodCount +=1; |
| | | } |
| | | if(!data.isHighChainResFlag()){ |
| | | if(cr!=0.0 && !data.isHighChainResFlag1() && !data.isHighChainResFlag2()){ |
| | | chainResGoodCount +=1; |
| | | } |
| | | }; |
| | |
| | | map.put("volGoodCount",volGoodCount); |
| | | map.put("chainResGoodCount",chainResGoodCount); |
| | | |
| | | map.put("battVolTestCount",battVolTestCount); |
| | | map.put("battResTestCount",battResTestCount); |
| | | map.put("battChainResTestCount",battChainResTestCount); |
| | | |
| | | map.put("dataList",dataList); |
| | | map.put("dataList2",dataList2); |
| | | |