java110
2022-07-14 2e998bbd82f580d852292cace5811d46b3c2438c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
package com.java110.boot.smo.assetExport.impl;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.java110.boot.smo.DefaultAbstractComponentSMO;
import com.java110.boot.smo.assetExport.IExportFeeManualCollectionSMO;
import com.java110.core.context.IPageData;
import com.java110.core.log.LoggerFactory;
import com.java110.dto.fee.FeeDto;
import com.java110.entity.component.ComponentValidateResult;
import com.java110.utils.util.Assert;
import com.java110.utils.util.Base64Convert;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.Money2ChineseUtil;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
 
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
 
/**
 * @ClassName AssetImportSmoImpl
 * @Description TODO
 * @Author wuxw
 * @Date 2019/9/23 23:14
 * @Version 1.0
 * add by wuxw 2019/9/23
 **/
@Service("exportFeeManualCollectionSMOImpl")
public class ExportFeeManualCollectionSMOImpl extends DefaultAbstractComponentSMO implements IExportFeeManualCollectionSMO {
    private final static Logger logger = LoggerFactory.getLogger(ExportFeeManualCollectionSMOImpl.class);
 
    @Autowired
    private RestTemplate restTemplate;
 
    @Override
    public ResponseEntity<Object> exportExcelData(IPageData pd) throws Exception {
 
        ComponentValidateResult result = this.validateStoreStaffCommunityRelationship(pd, restTemplate);
 
        Assert.hasKeyAndValue(JSONObject.parseObject(pd.getReqData()), "communityId", "请求中未包含小区");
 
        Workbook workbook = null;  //工作簿
        //工作表
        workbook = new XSSFWorkbook();
        //获取楼信息
        getRoomFees(pd, result, workbook);
 
 
        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("Pargam", "no-cache");
        headers.add("Cache-Control", "no-cache");
        //headers.add("Content-Disposition", "attachment; filename=" + outParam.getString("fileName"));
        headers.add("Accept-Ranges", "bytes");
        byte[] context = null;
        try {
            workbook.write(os);
            context = os.toByteArray();
            os.close();
            workbook.close();
        } catch (IOException e) {
            e.printStackTrace();
            // 保存数据
            return new ResponseEntity<Object>("导出失败", HttpStatus.INTERNAL_SERVER_ERROR);
        }
        // 保存数据
        return new ResponseEntity<Object>(context, headers, HttpStatus.OK);
    }
 
    @Override
    public ResponseEntity<Object> downloadCollectionLetterOrder(IPageData pd) {
        ComponentValidateResult result = this.validateStoreStaffCommunityRelationship(pd, restTemplate);
 
        Assert.hasKeyAndValue(JSONObject.parseObject(pd.getReqData()), "communityId", "请求中未包含小区");
 
        Workbook workbook = null;  //工作簿
        //工作表
        workbook = new XSSFWorkbook();
        //获取楼信息
        getRoomOweFees(pd, result, workbook);
 
 
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        MultiValueMap headers = new HttpHeaders();
        headers.add("content-type", "application/octet-stream;charset=UTF-8");
        headers.add("Content-Disposition", "attachment;filename=downloadCollectionLetterOrder_" + DateUtil.getyyyyMMddhhmmssDateString() + ".xlsx");
        headers.add("Pargam", "no-cache");
        headers.add("Cache-Control", "no-cache");
        //headers.add("Content-Disposition", "attachment; filename=" + outParam.getString("fileName"));
        headers.add("Accept-Ranges", "bytes");
        byte[] context = null;
        try {
            workbook.write(os);
            context = os.toByteArray();
 
        } catch (IOException e) {
            e.printStackTrace();
            // 保存数据
            return new ResponseEntity<Object>("导出失败", HttpStatus.INTERNAL_SERVER_ERROR);
        } finally {
            try {
                os.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                workbook.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        // 保存数据
        return new ResponseEntity<Object>(context, headers, HttpStatus.OK);
    }
 
    /**
     * 查询房屋欠费
     *
     * @param pd
     * @param result
     * @param workbook
     */
    private void getRoomOweFees(IPageData pd, ComponentValidateResult result, Workbook workbook) {
        Sheet sheet = workbook.createSheet("催缴单");
        Drawing patriarch = sheet.createDrawingPatriarch();
        String apiUrl = "";
        ResponseEntity<String> responseEntity = null;
        JSONObject reqJson = JSONObject.parseObject(pd.getReqData());
        apiUrl = "/feeApi/listAllRoomOweFees" + mapToUrlParam(reqJson);
        responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
 
        if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息
            return;
        }
 
        JSONObject savedRoomInfoResults = JSONObject.parseObject(responseEntity.getBody(), Feature.OrderedField);
 
 
        if (!savedRoomInfoResults.containsKey("data")) {
            return;
        }
 
 
        JSONArray rooms = savedRoomInfoResults.getJSONArray("data");
 
        if (rooms == null || rooms.size() < 1) {
            return;
        }
 
        //查询催缴单二维码
        JSONObject feePrint = null;
        apiUrl = "/feePrintSpec/queryFeePrintSpec?page=1&row=1&specCd=1010&communityId=" + result.getCommunityId();
        responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
        if (responseEntity.getStatusCode() == HttpStatus.OK) {
            JSONObject feePrintResults = JSONObject.parseObject(responseEntity.getBody(), Feature.OrderedField);
            if (feePrintResults.containsKey("data")) {
                JSONArray feePrints = feePrintResults.getJSONArray("data");
                if (feePrints != null && feePrints.size() > 0) {
                    feePrint = feePrints.getJSONObject(0);
                }
            }
 
        }
 
 
        int line = 0;
        double totalPageHeight = 0;
        for (int roomIndex = 0; roomIndex < rooms.size(); roomIndex++) {
            Map<String, Object> info = generatorRoomOweFee(sheet, workbook, rooms.getJSONObject(roomIndex), line, totalPageHeight, patriarch, feePrint);
            line = Integer.parseInt(info.get("line").toString()) + 1;
            totalPageHeight = Double.parseDouble(info.get("totalPageHeight").toString());
        }
    }
 
    private Map<String, Object> generatorRoomOweFee(Sheet sheet, Workbook workbook, JSONObject room, int line, double totalPageHeight, Drawing patriarch, JSONObject feePrint) {
        JSONArray fees = room.getJSONArray("fees");
        String[] feePrintRemarks = null;
        if (feePrint != null) {
            feePrintRemarks = feePrint.getString("content").toLowerCase().replace("</br>", "").split("\n");
        } else {
            feePrintRemarks = new String[]{""};
        }
        int defaultRowHeight = 280;
        //计算当前单子的高度
        int titleHeight = defaultRowHeight * 3;
        int subTitleHeight = defaultRowHeight * 5;
        int totalHeight = titleHeight + subTitleHeight + defaultRowHeight * 3 + fees.size() * defaultRowHeight;
        //备注,加上打印配置内容
        if (feePrintRemarks != null && feePrintRemarks.length > 0) {
            totalHeight += (feePrintRemarks.length * defaultRowHeight);
        }
        double A4_lengthways_pageSize = defaultRowHeight * 57;//15960
 
        //当前页 已经占用的高度
        double curPageHeight = totalPageHeight % A4_lengthways_pageSize;
        //当前页空闲高度
        double freePageHeight = A4_lengthways_pageSize - curPageHeight;
        if (freePageHeight < totalHeight && curPageHeight != 0) {
            line += Math.ceil(freePageHeight / defaultRowHeight);
            totalPageHeight += freePageHeight;
        }
 
        totalPageHeight += totalHeight;
 
 
        sheet.setColumnWidth(0, 8 * 256 * 2);
        sheet.setColumnWidth(1, 8 * 256 * 1);
        sheet.setColumnWidth(2, 8 * 256 * 1);
        sheet.setColumnWidth(3, 8 * 256 * 3);
        sheet.setColumnWidth(4, 8 * 256 * 1);
        sheet.setColumnWidth(5, 8 * 256 * 1);
        sheet.setColumnWidth(6, 8 * 256 * 1);
 
        //通用样式
        CellStyle cellStyle = workbook.createCellStyle();
//设置样式对象,这里仅设置了边框属性
        cellStyle.setBorderBottom(BorderStyle.THIN); //下边框
        cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
        cellStyle.setBorderTop(BorderStyle.THIN);//上边框
        cellStyle.setBorderRight(BorderStyle.THIN);//右边框
        cellStyle.setAlignment(HorizontalAlignment.CENTER);
 
        // 标题
        Row row = sheet.createRow(0 + line);
        Cell cell0 = row.createCell(0);
        //cell0.setCellValue("缴费通知单totalHeight:" + totalHeight + "-totalPageHeight:" + totalPageHeight + "-curPageHeight:" + curPageHeight + "-freePageHeight:" + freePageHeight + "-line:" + line);
        if (feePrint != null) {
            cell0.setCellValue(feePrint.getString("printName") + "缴费通知单");
        } else {
            cell0.setCellValue("缴费通知单");
        }
        //标题设置字体
        Font font = workbook.createFont();
        font.setFontName("黑体");
        font.setFontHeightInPoints((short) 26);
        CellStyle titleCellStyle = workbook.createCellStyle();
        titleCellStyle.setFont(font);
        titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
        cell0.setCellStyle(titleCellStyle);
        row.setHeight((short) (titleHeight));
 
        //合并标题
        CellRangeAddress region = new CellRangeAddress(0 + line, 0 + line, 0, 6);
        sheet.addMergedRegion(region);
 
 
        //子标题
        if (feePrint != null) {
            XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) 0, 1 + line, (short) 1, 1 + line + 1);
            anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);//设置图片随单元移动调整大小
            try {
                String qrImg = feePrint.getString("qrImg").replace("data:image/webp;base64,", "")
                        .replace("data:image/png;base64,", "")
                        .replace("data:image/jpeg;base64,", "");
                patriarch.createPicture(anchor, workbook.addPicture(Base64Convert.base64ToByte(qrImg), XSSFWorkbook.PICTURE_TYPE_JPEG));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        CellStyle subTitleCellStyle = workbook.createCellStyle();
        subTitleCellStyle.setAlignment(HorizontalAlignment.CENTER);
        subTitleCellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM);
        row = sheet.createRow(1 + line);
        Cell cell1 = row.createCell(1);
        if (fees != null && fees.size() > 0) {
            cell1.setCellValue("业主:" + fees.getJSONObject(0).getString("ownerName"));
        } else {
            cell1.setCellValue("业主:无");
        }
        cell1.setCellStyle(subTitleCellStyle);
 
        Cell cell2 = row.createCell(2);
        cell2.setCellValue("房号:" + room.getString("floorNum")
                + "-" + room.getString("unitNum")
                + "-" + room.getString("roomNum"));
        cell2.setCellStyle(subTitleCellStyle);
 
        row.createCell(3).setCellValue("");
        row.createCell(4).setCellValue("");
        Cell cell5 = row.createCell(5);
        cell5.setCellValue(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B));
        cell5.setCellStyle(subTitleCellStyle);
        CellStyle rowCellStyle = workbook.createCellStyle();
        rowCellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM);
        row.setRowStyle(rowCellStyle);
 
        //设置表头之上
        region = new CellRangeAddress(1 + line, 1 + line, 2, 3);
        sheet.addMergedRegion(region);
        region = new CellRangeAddress(1 + line, 1 + line, 5, 6);
        sheet.addMergedRegion(region);
        //子标题高度
        row.setHeight((short) (subTitleHeight));
 
 
        row = sheet.createRow(2 + line);
        cell0 = row.createCell(0);
        cell0.setCellValue("收费名称");
        cell0.setCellStyle(cellStyle);
        cell1 = row.createCell(1);
        cell1.setCellValue("收费标准");
        cell1.setCellStyle(cellStyle);
        cell2 = row.createCell(2);
        cell2.setCellValue("数量/面积");
        cell2.setCellStyle(cellStyle);
        Cell cell3 = row.createCell(3);
        cell3.setCellValue("欠费时间");
        cell3.setCellStyle(cellStyle);
        Cell cell4 = row.createCell(4);
        cell4.setCellValue("应缴金额(元)");
        cell4.setCellStyle(cellStyle);
        cell5 = row.createCell(5);
        cell5.setCellValue("违约金(元)");
        cell5.setCellStyle(cellStyle);
        Cell cell6 = row.createCell(6);
        cell6.setCellValue("备注");
        cell6.setCellStyle(cellStyle);
        row.setHeight((short) (defaultRowHeight));
 
 
        BigDecimal totalPrice = new BigDecimal(0);
        String startTime = "";
        String endTime = "";
        String squarePrice = "";
        for (int feeIndex = 0; feeIndex < fees.size(); feeIndex++) {
            JSONObject feeObj = fees.getJSONObject(feeIndex);
            row = sheet.createRow(line + feeIndex + 3);
            startTime = feeObj.getString("endTime").length() > 10 ? feeObj.getString("endTime").substring(0, 10) : feeObj.getString("endTime");
            endTime = feeObj.getString("deadlineTime").length() > 10 ? feeObj.getString("deadlineTime").substring(0, 10) : feeObj.getString("deadlineTime");
            //如果费用是周期性费用 则 结束时间减一天
            try {
                if (feeObj.containsKey("feeFlag") && FeeDto.FEE_FLAG_CYCLE.equals(feeObj.getString("feeFlag"))) {
                    endTime = DateUtil.getFormatTimeString(DateUtil.stepDay(DateUtil.getDateFromString(endTime, DateUtil.DATE_FORMATE_STRING_B), -1),
                            DateUtil.DATE_FORMATE_STRING_B);
                }
            } catch (ParseException e) {
                logger.error("处理结束时间失败", e);
            }
            squarePrice = feeObj.getString("squarePrice");
 
            //动态费用单价就去动态单价
            if(feeObj.containsKey("computingFormula") && "9009".equals(feeObj.getString("computingFormula"))){
                squarePrice = feeObj.getString("mwPrice");
            }
 
            cell0 = row.createCell(0);
            cell0.setCellValue(feeObj.getString("feeName"));
            cell0.setCellStyle(cellStyle);
            cell1 = row.createCell(1);
            cell1.setCellValue(squarePrice);
            cell1.setCellStyle(cellStyle);
            cell2 = row.createCell(2);
            cell2.setCellValue(room.getString("builtUpArea"));
            cell2.setCellStyle(cellStyle);
            cell3 = row.createCell(3);
            if (feeObj.containsKey("curDegrees")) {
                cell3.setCellValue(startTime + "至" + endTime + " " + feeObj.getString("preDegrees") + "至" + feeObj.getString("curDegrees"));
            } else {
                cell3.setCellValue(startTime + "至" + endTime);
            }
            cell3.setCellStyle(cellStyle);
            cell4 = row.createCell(4);
            cell4.setCellValue(feeObj.getString("feePrice"));
            cell4.setCellStyle(cellStyle);
            cell5 = row.createCell(5);
            cell5.setCellValue("0");
            cell5.setCellStyle(cellStyle);
            cell6 = row.createCell(6);
            cell6.setCellValue("");
            cell6.setCellStyle(cellStyle);
            row.setHeight((short) (defaultRowHeight));
            totalPrice = totalPrice.add(new BigDecimal(feeObj.getString("feePrice")));
        }
 
        row = sheet.createRow(line + fees.size() + 3);
 
        cell0 = row.createCell(0);
        cell0.setCellValue("合计(大写)");
        cell0.setCellStyle(cellStyle);
        cell1 = row.createCell(1);
        cell1.setCellValue(Money2ChineseUtil.toChineseChar(totalPrice.doubleValue()));
        cell1.setCellStyle(cellStyle);
        cell2 = row.createCell(2);
        cell2.setCellValue("");
        cell2.setCellStyle(cellStyle);
        cell3 = row.createCell(3);
        cell3.setCellValue("");
        cell3.setCellStyle(cellStyle);
        cell4 = row.createCell(4);
        cell4.setCellValue(totalPrice.doubleValue());
        cell4.setCellStyle(cellStyle);
        cell5 = row.createCell(5);
        cell5.setCellValue("");
        cell5.setCellStyle(cellStyle);
        cell6 = row.createCell(6);
        cell6.setCellValue("");
        cell6.setCellStyle(cellStyle);
        row.setHeight((short) (defaultRowHeight));
 
 
        //合计 合并
        region = new CellRangeAddress(line + fees.size() + 3, line + fees.size() + 3, 1, 3);
        sheet.addMergedRegion(region);
 
        if (feePrintRemarks != null && feePrintRemarks.length > 0) {
            for (int remarkIndex = 0; remarkIndex < feePrintRemarks.length; remarkIndex++) {
                row = sheet.createRow(line + fees.size() + 4 + remarkIndex);
                row.createCell(0).setCellValue(feePrintRemarks[remarkIndex]);
                row.setHeight((short) (defaultRowHeight));
            }
        }
        row = sheet.createRow(line + fees.size() + 4 + feePrintRemarks.length);
        row.createCell(0).setCellValue("");
        row.setHeight((short) (defaultRowHeight));
        Map info = new HashMap();
        info.put("line", line + fees.size() + 4 + feePrintRemarks.length);
        info.put("totalPageHeight", totalPageHeight);
        return info;
    }
 
 
    /**
     * 查询存在的房屋信息
     * room.queryRooms
     *
     * @param pd
     * @param result
     * @return
     */
    private JSONArray getExistsRoomFee(IPageData pd, ComponentValidateResult result) {
        String apiUrl = "";
        ResponseEntity<String> responseEntity = null;
        apiUrl = "/feeManualCollection/queryExportCollections?communityId=" + result.getCommunityId();
        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");
 
    }
 
    /**
     * 获取 房屋信息
     *
     * @param componentValidateResult
     * @param workbook
     */
    private void getRoomFees(IPageData pd, ComponentValidateResult componentValidateResult, Workbook workbook) {
        Sheet sheet = workbook.createSheet("人工托收");
        Row row = sheet.createRow(0);
        Cell cell0 = row.createCell(0);
        cell0.setCellValue("小区名称:         ;办公电话:        ;具体交费地点:        ;\n" +
                "对公信息:开户名:              ;对公账号:               ;开户行:              ;税号:               ;\n" +
                "对接人员姓名(包括项目上的和公司财务对接人员):          ;对接人员电话:          ;\n" +
                "可否上门收:        ;有无业委会:     ;是否属前期物业:       ;物业上班时间:             ;" +
                "物业入驻小区开始服务时间:如:2014年1月1号服务至今   ;有无涨价:     ;有无涨价公告:    ;" +
                "有无提前收取其他费用(如:水电周转金      、装修押金       、土头清运费      )");
        CellStyle cs = workbook.createCellStyle();
        cs.setWrapText(true);  //关键
        cell0.setCellStyle(cs);
        row.setHeight((short) (200 * 10));
        row = sheet.createRow(1);
        row.createCell(0).setCellValue("序号");
 
 
        //查询楼栋信息
        JSONArray rooms = this.getExistsRoomFee(pd, componentValidateResult);
        if (rooms == null || rooms.size() < 1) {
            CellRangeAddress region = new CellRangeAddress(0, 0, 0, 1);
            sheet.addMergedRegion(region);
            return;
        }
        JSONObject dataObj = rooms.getJSONObject(0);
        int dataKeyIndex = 1;
        for (String key : dataObj.keySet()) {
            if (key.contains("_")) {
                row.createCell(dataKeyIndex).setCellValue(key.substring(key.indexOf("_") + 1));
            } else {
                row.createCell(dataKeyIndex).setCellValue(key);
            }
            dataKeyIndex++;
        }
        row.createCell(dataKeyIndex).setCellValue("备注");
 
 
        for (int roomIndex = 0; roomIndex < rooms.size(); roomIndex++) {
            row = sheet.createRow(roomIndex + 2);
            dataObj = rooms.getJSONObject(roomIndex);
            dataKeyIndex = 1;
            row.createCell(0).setCellValue(roomIndex + 1);
            for (String key : dataObj.keySet()) {
                row.createCell(dataKeyIndex).setCellValue(dataObj.getString(key));
                dataKeyIndex++;
            }
            row.createCell(dataKeyIndex + 2).setCellValue("");
        }
 
        row = sheet.createRow(rooms.size() + 2);
        cell0 = row.createCell(0);
        cell0.setCellValue("注:此《欠费统计表》交由厦门维度智临科技有限公司进行催收");
 
        CellRangeAddress region = new CellRangeAddress(0, 0, 0, dataKeyIndex);
        sheet.addMergedRegion(region);
        region = new CellRangeAddress(rooms.size() + 2, rooms.size() + 2, 0, dataKeyIndex);
        sheet.addMergedRegion(region);
    }
 
    public RestTemplate getRestTemplate() {
        return restTemplate;
    }
 
    public void setRestTemplate(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }
 
 
}