| | |
| | | <artifactId>jaxen</artifactId> |
| | | <version>1.1.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-base</artifactId> |
| | | <!-- <version>3.0.3</version>--> |
| | | <version>4.1.2</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>com.google.guava</groupId> |
| | | <artifactId>guava</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-web</artifactId> |
| | | <!-- <version>3.0.3</version>--> |
| | | <version>4.1.2</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-annotation</artifactId> |
| | | <version>4.1.2</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Api(tags = "电池组数据") |
| | | @RestController |
| | |
| | | |
| | | @ApiOperation("单数据分析-单体数据列表") |
| | | @GetMapping("list") |
| | | public Response getListWithTestTime(@RequestParam String fieldId){ |
| | | List<BattgroupData> monList = service.getListWithTestTime(fieldId); |
| | | return new Response().set(1,monList); |
| | | public Response getListWithTestTime(@RequestParam String fileId){ |
| | | List<BattgroupData> monList = service.getListWithTestTime(fileId); |
| | | Map<String,String> map = service.getStandardDeviation(monList); |
| | | return new Response().setII(1,monList,map,null); |
| | | } |
| | | |
| | | @ApiOperation(value = "对比分析-两组数据列表",notes = "data:第一行的基础数据,data2:第二行的基础数据," + |
New file |
| | |
| | | package com.whyc.controller; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
| | | import com.google.common.collect.Maps; |
| | | import com.whyc.dto.ResTestReportDTO; |
| | | import com.whyc.service.ExcelExportService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | @Api(tags = "excel导出") |
| | | @RestController |
| | | @RequestMapping("excelExport") |
| | | public class ExcelExportController { |
| | | |
| | | @Autowired |
| | | private ExcelExportService service; |
| | | |
| | | @ApiOperation("内阻计测试") |
| | | @GetMapping("resTestReport") |
| | | public void resTestReport(@RequestParam String fileId, HttpServletResponse response){ |
| | | service.resTestReport(fileId,response); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | @ApiOperation("分级评价-系数及阈值查询") |
| | | @GetMapping("factorsAndThreshold") |
| | | public Response getFactorsAndThreshold(@RequestParam String fieldId){ |
| | | FileParam param = service.getFactorsAndThreshold(fieldId); |
| | | public Response getFactorsAndThreshold(@RequestParam String fileId){ |
| | | FileParam param = service.getFactorsAndThreshold(fileId); |
| | | return new Response().set(1,param); |
| | | } |
| | | |
New file |
| | |
| | | package com.whyc.dto; |
| | | |
| | | public class ResTestReportDTO { |
| | | |
| | | private String p1; |
| | | |
| | | public String getP1() { |
| | | return p1; |
| | | } |
| | | |
| | | public void setP1(String p1) { |
| | | this.p1 = p1; |
| | | } |
| | | } |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | @Service |
| | | public class BattGroupDataService { |
| | |
| | | @Autowired |
| | | private BattGroupInfoService battGroupInfoService; |
| | | |
| | | public List<BattgroupData> getListWithTestTime(String fieldId) { |
| | | String battGroupId = battGroupInfoService.getByFileId(fieldId).getBattgroupId(); |
| | | public List<BattgroupData> getListWithTestTime(String fileId) { |
| | | String battGroupId = battGroupInfoService.getByFileId(fileId).getBattgroupId(); |
| | | List<BattgroupData> dataList = mapper.getListWithTestTime(battGroupId); |
| | | //查询系数和阈值是否禁用 |
| | | BattgroupInfo info = battGroupInfoService.getByBattGroupId(fieldId); |
| | | BattgroupInfo info = battGroupInfoService.getByBattGroupId(fileId); |
| | | FileParam param = fileParamService.getFactorsAndThreshold(info.getFileId()); |
| | | if(param.getFactorDisabled() == 1){ //系数和阈值禁用,不需要判断处理阈值 |
| | | return dataList; |
| | |
| | | return dataList; |
| | | } |
| | | |
| | | public Map<String, String> getStandardDeviation(List<BattgroupData> monList) { |
| | | Map<String,String> map = new HashMap<>(); |
| | | Stream<BattgroupData> stream = monList.stream(); |
| | | List<Float> bvList = stream.map(BattgroupData::getBv).collect(Collectors.toList()); |
| | | List<Float> brList = stream.map(BattgroupData::getBr).collect(Collectors.toList()); |
| | | List<Float> crList = stream.map(BattgroupData::getCr).collect(Collectors.toList()); |
| | | List<Float> bsList = stream.map(BattgroupData::getBs).collect(Collectors.toList()); |
| | | float stdDevBv = MathUtil.getStandardDeviation(bvList); |
| | | float stdDevBr = MathUtil.getStandardDeviation(brList); |
| | | float stdDevCr = MathUtil.getStandardDeviation(crList); |
| | | float stdDevBs = MathUtil.getStandardDeviation(bsList); |
| | | map.put("stdDevBv",stdDevBv*100+"%"); |
| | | map.put("stdDevBr",stdDevBr*100+"%"); |
| | | map.put("stdDevCr",stdDevCr*100+"%"); |
| | | map.put("stdDevBs",stdDevBs*100+"%"); |
| | | return map; |
| | | } |
| | | |
| | | public Response getComparedList(String baseFileId, String fileId) { |
| | | String baseBattGroupId = battGroupInfoService.getByFileId(baseFileId).getBattgroupId(); |
| | | String battGroupId = battGroupInfoService.getByFileId(fileId).getBattgroupId(); |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
| | | import com.google.common.collect.Maps; |
| | | import com.whyc.dto.ResTestReportDTO; |
| | | import com.whyc.pojo.FileParam; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class ExcelExportService { |
| | | |
| | | @Autowired |
| | | private FileParamService fileParamService; |
| | | |
| | | @Autowired |
| | | private BattGroupDataService battGroupDataService; |
| | | |
| | | public void resTestReport(String fileId, HttpServletResponse response) { |
| | | HashMap<String, Object> map = Maps.newHashMap(); |
| | | List list = new LinkedList<>(); |
| | | ResTestReportDTO dto = new ResTestReportDTO(); |
| | | dto.setP1("excel模板"); |
| | | list.add(dto); |
| | | //基础测试数据 |
| | | //battGroupDataService.getListWithTestTime(fileId); |
| | | //文件所属的电池组信息 |
| | | FileParam fileParam = fileParamService.getByFileId(fileId); |
| | | |
| | | map.put("dto", list); |
| | | //获取导出模板地址 |
| | | ClassPathResource classPathResource = new ClassPathResource("excel_templates/rest_test_report_single_template.xls"); |
| | | String path = classPathResource.getPath(); |
| | | TemplateExportParams templateExportParams1 = new TemplateExportParams(path); |
| | | Workbook wb = ExcelExportUtil.exportExcel(templateExportParams1, map); |
| | | String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy_MM_dd_HH_mm_ss")); |
| | | String fileName = "内阻计测试"+time+".xls"; |
| | | try { |
| | | response.setContentType("application/octet-stream;charset=utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8")); |
| | | response.flushBuffer(); |
| | | wb.write(response.getOutputStream()); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | |
| | | return new Response().setII(1,list.size()>0,list,"筛选数据库信息"); |
| | | } |
| | | |
| | | public FileParam getFactorsAndThreshold(String fieldId) { |
| | | public FileParam getFactorsAndThreshold(String fileId) { |
| | | QueryWrapper<FileParam> query = Wrappers.query(); |
| | | query.select("num","field_id","batt_vol","batt_res","volLowCoeK1","volHighCoeK2","resGoodCoeK3","resBadCoeK4","chainRes","factor_disabled").eq("field_id",fieldId).last(" limit 1"); |
| | | query.select("num","file_id","batt_vol","batt_res","volLowCoeK1","volHighCoeK2","resGoodCoeK3","resBadCoeK4","chainRes","factor_disabled").eq("file_id",fileId).last(" limit 1"); |
| | | return mapper.selectOne(query); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public FileParam getByFileId(String fileId) { |
| | | QueryWrapper<FileParam> query = Wrappers.query(); |
| | | query.eq("file_id",fileId).last(" limit 1"); |
| | | return mapper.selectOne(query); |
| | | } |
| | | } |