浏览代码

优化导出

java110 6 年之前
父节点
当前提交
3c425aa194

+ 55 - 3
service-front/src/main/java/com/java110/front/smo/assetExport/impl/ExportReportFeeSMOImpl.java

@@ -41,6 +41,7 @@ public class ExportReportFeeSMOImpl extends BaseComponentSMO implements IExportR
     private final static Logger logger = LoggerFactory.getLogger(ExportReportFeeSMOImpl.class);
 
     public static final String REPORT_FEE_SUMMARY = "reportFeeSummary";
+    public static final String REPORT_FLOOR_UNIT_FEE_SUMMARY = "reportFloorUnitFeeSummary";
 
     @Autowired
     private RestTemplate restTemplate;
@@ -63,13 +64,16 @@ public class ExportReportFeeSMOImpl extends BaseComponentSMO implements IExportR
             case REPORT_FEE_SUMMARY:
                 reportFeeSummary(pd, result, workbook);
                 break;
+            case REPORT_FLOOR_UNIT_FEE_SUMMARY:
+                reportFloorUnitFeeSummary(pd, result, workbook);
+                break;
         }
 
 
         ByteArrayOutputStream os = new ByteArrayOutputStream();
         MultiValueMap headers = new HttpHeaders();
         headers.add("content-type", "application/octet-stream;charset=UTF-8");
-        headers.add("Content-Disposition", "attachment;filename=feeManualCollection_" + DateUtil.getyyyyMMddhhmmssDateString() + ".xlsx");
+        headers.add("Content-Disposition", "attachment;filename=" + pagePath + DateUtil.getyyyyMMddhhmmssDateString() + ".xlsx");
         headers.add("Pargam", "no-cache");
         headers.add("Cache-Control", "no-cache");
         //headers.add("Content-Disposition", "attachment; filename=" + outParam.getString("fileName"));
@@ -89,6 +93,56 @@ public class ExportReportFeeSMOImpl extends BaseComponentSMO implements IExportR
         return new ResponseEntity<Object>(context, headers, HttpStatus.OK);
     }
 
+    private void reportFloorUnitFeeSummary(IPageData pd, ComponentValidateResult result, 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("应收金额");
+        row.createCell(4).setCellValue("实收金额");
+        row.createCell(5).setCellValue("欠费金额");
+
+
+        //查询楼栋信息
+        JSONArray rooms = this.getReportFloorUnitFeeSummary(pd, result);
+        JSONObject dataObj = null;
+        for (int roomIndex = 0; roomIndex < rooms.size(); roomIndex++) {
+            row = sheet.createRow(roomIndex + 2);
+            dataObj = rooms.getJSONObject(roomIndex);
+
+            row.createCell(0).setCellValue(dataObj.getString("feeYear") + "年" + dataObj.getString("feeMonth") + "月");
+            row.createCell(1).setCellValue(dataObj.getString("receivableAmount"));
+            row.createCell(2).setCellValue(dataObj.getString("floorNum") + "号楼");
+            row.createCell(3).setCellValue(dataObj.getString("unitNum") + "单元");
+            row.createCell(4).setCellValue(dataObj.getString("receivedAmount"));
+            row.createCell(5).setCellValue(dataObj.getString("oweAmount"));
+
+        }
+    }
+
+    private JSONArray getReportFloorUnitFeeSummary(IPageData pd, ComponentValidateResult result) {
+        String apiUrl = "";
+        ResponseEntity<String> responseEntity = null;
+        apiUrl = ServiceConstant.SERVICE_API_URL + "/api/reportFeeMonthStatistics/queryFloorUnitFeeSummary?communityId=" + result.getCommunityId() + "&page=1&row=10000";
+        responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息
+            return null;
+        }
+
+        JSONObject savedRoomInfoResults = JSONObject.parseObject(responseEntity.getBody(), Feature.OrderedField);
+
+
+        if (!savedRoomInfoResults.containsKey("data")) {
+            return null;
+        }
+
+
+        return savedRoomInfoResults.getJSONArray("data");
+
+    }
+
 
     /**
      * 查询存在的房屋信息
@@ -133,8 +187,6 @@ public class ExportReportFeeSMOImpl extends BaseComponentSMO implements IExportR
         row.createCell(1).setCellValue("应收金额");
         row.createCell(2).setCellValue("实收金额");
         row.createCell(3).setCellValue("欠费金额");
-        row = sheet.createRow(1);
-        row.createCell(0).setCellValue("序号");
 
 
         //查询楼栋信息