From 249174c416f53c2d6ed597fea9ffb2f1fad0f890 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期四, 06 八月 2020 16:48:30 +0800
Subject: [PATCH] 优化费用导入 模板

---
 service-front/src/main/java/com/java110/front/smo/assetExport/impl/ExportRoomSMOImpl.java |   78 +++++++++------------------------------
 1 files changed, 18 insertions(+), 60 deletions(-)

diff --git a/service-front/src/main/java/com/java110/front/smo/assetExport/impl/ExportRoomSMOImpl.java b/service-front/src/main/java/com/java110/front/smo/assetExport/impl/ExportRoomSMOImpl.java
index 23ac851..30a002b 100644
--- a/service-front/src/main/java/com/java110/front/smo/assetExport/impl/ExportRoomSMOImpl.java
+++ b/service-front/src/main/java/com/java110/front/smo/assetExport/impl/ExportRoomSMOImpl.java
@@ -10,9 +10,8 @@
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.DateUtil;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -59,7 +58,7 @@
         ByteArrayOutputStream os = new ByteArrayOutputStream();
         MultiValueMap headers = new HttpHeaders();
         headers.add("content-type", "application/octet-stream;charset=UTF-8");
-        headers.add("Content-Disposition", "attachment;filename=" + DateUtil.getyyyyMMddhhmmssDateString() + ".xls");
+        headers.add("Content-Disposition", "attachment;filename=feeImport_" + DateUtil.getyyyyMMddhhmmssDateString() + ".xls");
         headers.add("Pargam", "no-cache");
         headers.add("Cache-Control", "no-cache");
         //headers.add("Content-Disposition", "attachment; filename=" + outParam.getString("fileName"));
@@ -127,27 +126,6 @@
         return savedFloorInfoResults;
     }
 
-    private JSONArray getExistsFloor(IPageData pd, ComponentValidateResult result) {
-        String apiUrl = "";
-        ResponseEntity<String> responseEntity = null;
-        apiUrl = ServiceConstant.SERVICE_API_URL + "/api/floor.queryFloors?page=1&row=100&communityId=" + result.getCommunityId();
-
-        responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
-
-        if (responseEntity.getStatusCode() != HttpStatus.OK) { //璺宠繃 淇濆瓨鍗曞厓淇℃伅
-            return null;
-        }
-
-        JSONObject savedFloorInfoResult = JSONObject.parseObject(responseEntity.getBody());
-
-        if (!savedFloorInfoResult.containsKey("apiFloorDataVoList")) {
-            return null;
-        }
-
-        return savedFloorInfoResult.getJSONArray("apiFloorDataVoList");
-
-    }
-
 
     /**
      * 鑾峰彇 鎴垮眿淇℃伅
@@ -156,8 +134,17 @@
      * @param workbook
      */
     private void getRooms(IPageData pd, ComponentValidateResult componentValidateResult, Workbook workbook) {
-        Sheet sheet = workbook.createSheet("鎴垮眿淇℃伅");
+        Sheet sheet = workbook.createSheet("鎴垮眿璐圭敤淇℃伅");
         Row row = sheet.createRow(0);
+        Cell cell0 = row.createCell(0);
+        cell0.setCellValue("璐圭敤鍚嶇О: 璇峰~鍐欑郴缁熶腑璐圭敤绫诲瀷锛屽鐗╀笟璐癸紝鎶奸噾绛� 锛沑n寮�濮嬫椂闂�: " +
+                "鏀惰垂寮�濮嬫椂闂达紝鏍煎紡涓篩YYY-MM-DD锛沑n缁撴潫鏃堕棿: 璐圭敤缁撴潫鏃堕棿锛屾牸寮忎负YYYY-MM-DD锛� \n鏀惰垂閲戦: 鏈鏀跺彇閲戦 鍗曚綅鍏冿紱 " +
+                "\n娉ㄦ剰锛氭墍鏈夊崟鍏冩牸寮忎负鏂囨湰");
+        CellStyle cs = workbook.createCellStyle();
+        cs.setWrapText(true);  //鍏抽敭
+        cell0.setCellStyle(cs);
+        row.setHeight((short) (200 * 10));
+        row = sheet.createRow(1);
         row.createCell(0).setCellValue("妤兼爧缂栧彿");
         row.createCell(1).setCellValue("鍗曞厓缂栧彿");
         row.createCell(2).setCellValue("鎴垮眿缂栫爜");
@@ -169,10 +156,12 @@
         //鏌ヨ妤兼爧淇℃伅
         JSONArray rooms = this.getExistsRoom(pd, componentValidateResult);
         if (rooms == null) {
+            CellRangeAddress region = new CellRangeAddress(0, 0, 0, 6);
+            sheet.addMergedRegion(region);
             return;
         }
         for (int roomIndex = 0; roomIndex < rooms.size(); roomIndex++) {
-            row = sheet.createRow(roomIndex + 1);
+            row = sheet.createRow(roomIndex + 2);
             row.createCell(0).setCellValue(rooms.getJSONObject(roomIndex).getString("floorNum"));
             row.createCell(1).setCellValue(rooms.getJSONObject(roomIndex).getString("unitNum"));
             row.createCell(2).setCellValue(rooms.getJSONObject(roomIndex).getString("roomNum"));
@@ -181,40 +170,9 @@
             row.createCell(5).setCellValue("");
             row.createCell(6).setCellValue("");
         }
-    }
 
-
-    /**
-     * 鑾峰彇灏忓尯
-     *
-     * @param workbook
-     */
-    private void getFloors(IPageData pd, ComponentValidateResult componentValidateResult, Workbook workbook) {
-        Sheet sheet = workbook.createSheet("妤兼爧鍗曞厓");
-        Row row = sheet.createRow(0);
-        row.createCell(0).setCellValue("妤兼爧鍙�");
-        row.createCell(1).setCellValue("鍗曞厓缂栧彿");
-        row.createCell(2).setCellValue("鎬诲眰鏁�");
-        row.createCell(3).setCellValue("鏄惁鏈夌數姊�");
-
-        //鏌ヨ妤兼爧淇℃伅
-        JSONArray floors = this.getExistsFloor(pd, componentValidateResult);
-
-        if (floors == null) {
-            return;
-        }
-        for (int floorIndex = 0; floorIndex < floors.size(); floorIndex++) {
-            JSONArray units = this.getExistsUnit(pd, componentValidateResult, floors.getJSONObject(floorIndex).getString("floorId"));
-            for (int unitIndex = 0; unitIndex < units.size(); unitIndex++) {
-                row = sheet.createRow(floorIndex + 1);
-                row.createCell(0).setCellValue(floors.getJSONObject(floorIndex).getString("floorNum"));
-                row.createCell(1).setCellValue(units.getJSONObject(unitIndex).getString("unitNum"));
-                row.createCell(2).setCellValue(units.getJSONObject(unitIndex).getString("layerCount"));
-                row.createCell(3).setCellValue("1010".equals(units.getJSONObject(unitIndex).getString("lift")) ? "鏈�" : "鏃�");
-            }
-        }
-
-
+        CellRangeAddress region = new CellRangeAddress(0, 0, 0, 6);
+        sheet.addMergedRegion(region);
     }
 
     public RestTemplate getRestTemplate() {

--
Gitblit v1.8.0