Преглед изворни кода

[性能验证][task-1390] 各个指标中数据公式的计算和结论推导,线性范围

liyuan пре 2 година
родитељ
комит
5c4ec64469

+ 30 - 5
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/controller/PerformanceVerificationController.java

@@ -13,10 +13,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.ByteArrayOutputStream;
@@ -61,7 +58,7 @@ public class PerformanceVerificationController extends GenericProvider{
     }
 
     @PostMapping("/exportExcelTemplate")
-    @ApiOperation(value = "导出数据模板", notes = "导出数据")
+    @ApiOperation(value = "导出数据模板", notes = "导出数据模板")
     public void exportExcelTemplate(@RequestParam(value = "name") String name,
                                     @RequestParam(value = "id") String id) {
         ByteArrayOutputStream bos = null;
@@ -88,4 +85,32 @@ public class PerformanceVerificationController extends GenericProvider{
             }
         }
     }
+    @PostMapping("/exportExcelReport")
+    @ApiOperation(value = "导出数据报告", notes = "导出数据报告")
+    public void exportExcelReport(@RequestParam(value = "name") String name,
+                               @RequestParam(value = "id") String id) {
+        ByteArrayOutputStream bos = null;
+        try {
+
+            Workbook workbook = performanceVerificationService.exportExcelReport(name, id);
+//			String rootRealPath = AppFileUtil.getRealPath("/" + AppFileUtil.TEMP_PATH); // 操作的根目录
+            String fileName = "dataTemplate_" + name + (workbook instanceof HSSFWorkbook ? ".xls" : ".xlsx");
+//			FileUtil.writeFile(rootRealPath + File.separator + fileName + (workbook instanceof HSSFWorkbook ? ".xls" : ".xlsx"), workbook);
+            bos = new ByteArrayOutputStream();
+            workbook.write(bos);
+            byte[] barray = bos.toByteArray();
+            com.lc.ibps.base.web.util.RequestUtil.downLoadFileByByte(this.getRequest(), this.getResponse(), barray, fileName);// 导出
+
+        } catch (Exception e) {
+            logger.error("/pv/exportExcelReport", e);
+        } finally {
+            if (bos != null) {
+                try {
+                    bos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
 }

+ 7 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVTest.java

@@ -1,5 +1,8 @@
 package com.lc.ibps.components.verification.excel;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.lc.ibps.components.verification.model.FunctionEnum;
 import com.lc.ibps.components.verification.model.InspectionConfigVO;
 import com.lc.ibps.components.verification.model.InspectionItemVO;
@@ -102,8 +105,11 @@ public class PVTest {
 //        vo.getItem().add(item2);
 //        vo.getItem().add(item3);
         vo.getItem().add(item4);
+//        final String s = JSONObject.toJSONString(vo,SerializerFeature.PrettyFormat,SerializerFeature.DisableCircularReferenceDetect);
+//        InspectionVO voJson = JSON.parseObject(s, InspectionVO.class);
 
-        final Workbook workbook = vo.exportExcelReport();
+        System.out.println(vo);
+        final Workbook workbook = vo.exportExcelReport(false);
         FileOutputStream fos = new FileOutputStream(String.format("C:/tmp/%s.xlsx", vo.getName()));
         workbook.write(fos);
         fos.close();

+ 1 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model/InspectionVO.java

@@ -13,7 +13,7 @@ public class InspectionVO {
     private String name;
     private List<InspectionItemVO> item = new ArrayList<>();
 
-    public Workbook exportExcelReport() {
+    public Workbook exportExcelReport(boolean isSummary) {
         List<Map<String, Object>> list = new ArrayList<>();
         for (InspectionItemVO item : item) {
             list.add(item.buildExportReportParams());

+ 2 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/service/PerformanceVerificationService.java

@@ -13,4 +13,6 @@ public interface PerformanceVerificationService {
                                        MultipartFile applyFiles) throws IOException;
 
     Workbook exportExcelTemplateExport(String name, String id);
+
+    Workbook exportExcelReport(String name, String id);
 }

+ 12 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/service/impl/PerformanceVerificationServiceImpl.java

@@ -2,7 +2,9 @@ package com.lc.ibps.components.verification.service.impl;
 
 import com.lc.ibps.components.verification.model.InspectionConfigVO;
 import com.lc.ibps.components.verification.model.InspectionItemVO;
+import com.lc.ibps.components.verification.model.InspectionVO;
 import com.lc.ibps.components.verification.service.PerformanceVerificationService;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
@@ -29,6 +31,16 @@ public class PerformanceVerificationServiceImpl implements PerformanceVerificati
         return workbook;
     }
 
+    @Override
+    public Workbook exportExcelReport(String name, String id) {
+        InspectionConfigVO config = getInspectionConfig(name, id);
+        InspectionVO inspectionVO = new InspectionVO();
+        InspectionItemVO item = new InspectionItemVO(config);
+        inspectionVO.getItem().add(item);
+        Workbook workbook = inspectionVO.exportExcelReport(StringUtils.isNotBlank(name));
+        return workbook;
+    }
+
     private InspectionConfigVO getInspectionConfig(String name, String id) {
 
         InspectionConfigVO configVO = new InspectionConfigVO("批内精密度", 1, 2,