|
@@ -25,11 +25,12 @@ import com.google.common.collect.Lists;
|
25
|
25
|
import com.google.common.collect.Maps;
|
26
|
26
|
import org.apache.commons.collections.CollectionUtils;
|
27
|
27
|
|
|
28
|
+import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
29
|
+import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
30
|
+import org.apache.poi.hssf.usermodel.HSSFSheet;
|
28
|
31
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
29
|
|
-import org.apache.poi.ss.usermodel.Row;
|
30
|
|
-import org.apache.poi.ss.usermodel.Sheet;
|
31
|
|
-import org.apache.poi.ss.usermodel.Workbook;
|
32
|
|
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
32
|
+import org.apache.poi.ss.usermodel.*;
|
|
33
|
+import org.apache.poi.xssf.usermodel.*;
|
33
|
34
|
import org.slf4j.Logger;
|
34
|
35
|
import org.slf4j.LoggerFactory;
|
35
|
36
|
|
|
@@ -39,6 +40,8 @@ import org.springframework.stereotype.Service;
|
39
|
40
|
import org.springframework.transaction.annotation.Transactional;
|
40
|
41
|
import org.springframework.web.multipart.MultipartFile;
|
41
|
42
|
|
|
43
|
+import java.io.IOException;
|
|
44
|
+import java.io.InputStream;
|
42
|
45
|
import java.time.LocalDateTime;
|
43
|
46
|
import java.util.*;
|
44
|
47
|
import java.util.regex.Pattern;
|
|
@@ -845,4 +848,87 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
845
|
848
|
|
846
|
849
|
return selectBuild;
|
847
|
850
|
}
|
|
851
|
+
|
|
852
|
+ @Override
|
|
853
|
+ public ResponseBean downloadExcel(UserElement userElement) {
|
|
854
|
+ ResponseBean responseBean = new ResponseBean();
|
|
855
|
+
|
|
856
|
+ InputStream inputStream = null;
|
|
857
|
+ inputStream = this.getClass().getResourceAsStream("/业主资料库.xlsx");
|
|
858
|
+
|
|
859
|
+ XSSFWorkbook workbook = null;
|
|
860
|
+ try {
|
|
861
|
+ workbook = new XSSFWorkbook(inputStream);
|
|
862
|
+ } catch (IOException e) {
|
|
863
|
+ e.printStackTrace();
|
|
864
|
+ }
|
|
865
|
+
|
|
866
|
+ XSSFSheet sheet = workbook.getSheetAt(0);
|
|
867
|
+ // 创建行
|
|
868
|
+ XSSFRow row = null;
|
|
869
|
+ // 创建列
|
|
870
|
+ XSSFCell cell = null;
|
|
871
|
+
|
|
872
|
+ Integer pageNum = 1;
|
|
873
|
+ Integer pageSize = 10;
|
|
874
|
+ Page<TpBuildingOwnerInfo> page = new Page(pageNum,pageSize);
|
|
875
|
+ // 分页查询
|
|
876
|
+ QueryWrapper<TpBuildingOwnerInfo> buildingOwnerInfoQueryWrapper = new QueryWrapper<>();
|
|
877
|
+ buildingOwnerInfoQueryWrapper.eq("community_id", userElement.getCommunityId());
|
|
878
|
+ IPage<TpBuildingOwnerInfo> infoIPage = tpBuildingOwnerInfoMapper.selectPage(page, buildingOwnerInfoQueryWrapper);
|
|
879
|
+ List<TpBuildingOwnerInfo> records = infoIPage.getRecords();
|
|
880
|
+ // 总页数
|
|
881
|
+ Long pages = infoIPage.getPages();
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+ // 行数 默认从 第 5 行开始
|
|
885
|
+ int currentRow = 5;
|
|
886
|
+ // 记录坐标
|
|
887
|
+ int index = 0;
|
|
888
|
+
|
|
889
|
+ // 样式
|
|
890
|
+ XSSFCellStyle cellStyle = workbook.createCellStyle();
|
|
891
|
+ cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN); //下边框
|
|
892
|
+ cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);//左边框
|
|
893
|
+ cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);//上边框
|
|
894
|
+ cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);//右边框
|
|
895
|
+ cellStyle.setAlignment(HorizontalAlignment.LEFT);
|
|
896
|
+
|
|
897
|
+ if (records.size() > 0) {
|
|
898
|
+ do {
|
|
899
|
+ TpBuildingOwnerInfo buildingOwnerInfo = records.get(index);
|
|
900
|
+ row = sheet.createRow(currentRow);
|
|
901
|
+ String address = buildingOwnerInfo.getPhaseName() +
|
|
902
|
+ buildingOwnerInfo.getBuildingName() +
|
|
903
|
+ buildingOwnerInfo.getUnitName() +
|
|
904
|
+ buildingOwnerInfo.getLevelName() +
|
|
905
|
+ buildingOwnerInfo.getName();
|
|
906
|
+
|
|
907
|
+ cell = row.createCell(0);
|
|
908
|
+ cell.setCellValue(address);
|
|
909
|
+ cell.setCellStyle(cellStyle);
|
|
910
|
+ cell = row.createCell(1);
|
|
911
|
+ cell.setCellValue(buildingOwnerInfo.getId());
|
|
912
|
+ cell.setCellStyle(cellStyle);
|
|
913
|
+ cell = row.createCell(2);
|
|
914
|
+ cell.setCellStyle(cellStyle);
|
|
915
|
+ cell = row.createCell(3);
|
|
916
|
+ cell.setCellStyle(cellStyle);
|
|
917
|
+ cell = row.createCell(4);
|
|
918
|
+ cell.setCellStyle(cellStyle);
|
|
919
|
+
|
|
920
|
+ currentRow ++;
|
|
921
|
+ index ++;
|
|
922
|
+ if (index == records.size()) {
|
|
923
|
+ index = 0;
|
|
924
|
+ page = new Page(infoIPage.getCurrent() + 1,pageSize);
|
|
925
|
+ infoIPage = tpBuildingOwnerInfoMapper.selectPage(page, buildingOwnerInfoQueryWrapper);
|
|
926
|
+ records = infoIPage.getRecords();
|
|
927
|
+ }
|
|
928
|
+ } while (infoIPage.getCurrent() <= pages);
|
|
929
|
+ }
|
|
930
|
+
|
|
931
|
+ responseBean.addSuccess(workbook);
|
|
932
|
+ return responseBean;
|
|
933
|
+ }
|
848
|
934
|
}
|