HouseWzBuildManageDetailsService.java 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344
  1. package com.example.service.house;
  2. import cn.hutool.core.net.URLEncodeUtil;
  3. import com.baomidou.mybatisplus.core.metadata.OrderItem;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.example.common.PageVo;
  6. import com.example.common.Rsp;
  7. import com.example.dao.WzOtnAreaDao;
  8. import com.example.dao.house.HouseBuildingDao;
  9. import com.example.entity.house.BuildingIdleStatPo;
  10. import com.example.entity.house.HouseAgeStatPo;
  11. import com.example.entity.house.HouseBuildingPo;
  12. import com.example.entity.house.HouseSitePo;
  13. import com.example.enums.ListBuildingIdleOrderEnum;
  14. import com.example.enums.ListBuildingOrderEnum;
  15. import com.example.enums.OrderEnum;
  16. import com.example.pojo.bo.BuildingIdleStatBo;
  17. import com.example.pojo.bo.HouseAgeStatBo;
  18. import com.example.pojo.bo.ListBuildingBo;
  19. import com.example.pojo.bo.ListBuildingIdleBo;
  20. import com.example.pojo.bo.ListHouseSiteBo;
  21. import com.example.pojo.dto.BuildingIdleStatDto;
  22. import com.example.pojo.dto.HouseAgeStatDto;
  23. import com.example.pojo.dto.ListBuildingDto;
  24. import com.example.pojo.dto.ListBuildingIdleDto;
  25. import com.example.pojo.dto.ListSiteNameDto;
  26. import com.example.pojo.dto.ListSiteNumDto;
  27. import com.example.pojo.vo.BuildingIdleStatVo;
  28. import com.example.pojo.vo.HouseAgeStatVo;
  29. import com.example.pojo.vo.ListBuildingIdleVo;
  30. import com.example.pojo.vo.ListBuildingVo;
  31. import lombok.extern.slf4j.Slf4j;
  32. import org.apache.poi.ss.usermodel.Cell;
  33. import org.apache.poi.ss.usermodel.CellStyle;
  34. import org.apache.poi.ss.usermodel.DataFormat;
  35. import org.apache.poi.ss.usermodel.HorizontalAlignment;
  36. import org.apache.poi.ss.usermodel.Row;
  37. import org.apache.poi.ss.usermodel.VerticalAlignment;
  38. import org.apache.poi.xssf.streaming.SXSSFSheet;
  39. import org.apache.poi.xssf.streaming.SXSSFWorkbook;
  40. import org.springframework.stereotype.Service;
  41. import org.springframework.util.CollectionUtils;
  42. import org.springframework.util.StringUtils;
  43. import org.springframework.web.context.request.RequestContextHolder;
  44. import org.springframework.web.context.request.ServletRequestAttributes;
  45. import javax.servlet.http.HttpServletResponse;
  46. import java.time.LocalDateTime;
  47. import java.time.format.DateTimeFormatter;
  48. import java.util.ArrayList;
  49. import java.util.Collections;
  50. import java.util.LinkedHashMap;
  51. import java.util.List;
  52. import java.util.concurrent.atomic.AtomicInteger;
  53. import java.util.stream.Stream;
  54. @Slf4j
  55. @Service
  56. public class HouseWzBuildManageDetailsService {
  57. private final HouseBuildingDao houseBuildingDao;
  58. private final WzOtnAreaDao wzOtnAreaDao;
  59. public HouseWzBuildManageDetailsService(HouseBuildingDao houseBuildingDao, WzOtnAreaDao wzOtnAreaDao) {
  60. this.houseBuildingDao = houseBuildingDao;
  61. this.wzOtnAreaDao = wzOtnAreaDao;
  62. }
  63. public Rsp<PageVo<ListBuildingIdleVo>> ideList(ListBuildingIdleDto dto) {
  64. Page<HouseBuildingPo> page = new Page<>(dto.getPage().getPageNum(), dto.getPage().getPageSize());
  65. List<HouseBuildingPo> list = getBuildingIdle(dto, page);
  66. List<ListBuildingIdleVo> vos = new ArrayList<>();
  67. for (HouseBuildingPo po : list) {
  68. vos.add(new ListBuildingIdleVo(po));
  69. }
  70. PageVo<ListBuildingIdleVo> pageVo = new PageVo<>(vos, page);
  71. return Rsp.ok(pageVo);
  72. }
  73. public void ideListExport(ListBuildingIdleDto.ListBuildingIdleMapDTO dto) {
  74. ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder
  75. .getRequestAttributes();
  76. if (servletRequestAttributes == null) {
  77. return;
  78. }
  79. HttpServletResponse response = servletRequestAttributes.getResponse();
  80. if (response == null) {
  81. return;
  82. }
  83. String filename = "房屋空置_空置1000平方米以上"
  84. + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
  85. response.setHeader("Content-Disposition", "attachment;filename=" + URLEncodeUtil.encode(filename));
  86. response.setContentType("application/octet-stream");
  87. try (SXSSFWorkbook wb = new SXSSFWorkbook()) {
  88. writeIdleList(new ListBuildingIdleDto(dto), wb);
  89. wb.write(response.getOutputStream());
  90. } catch (Exception e) {
  91. log.error(e.getMessage(), e);
  92. }
  93. }
  94. /**
  95. * 查询房屋空置
  96. */
  97. private List<HouseBuildingPo> getBuildingIdle(ListBuildingIdleDto dto, Page<HouseBuildingPo> page) {
  98. ListBuildingIdleBo bo = new ListBuildingIdleBo();
  99. if (dto.getMap() != null && dto.getMap().getStatisticalMonth() != null) {
  100. bo.setYearMonth(dto.getMap().getStatisticalMonth());
  101. }
  102. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCity()) && !"全省".equals(dto.getMap().getCity())) {
  103. bo.setAreaNo(dto.getMap().getCity());
  104. }
  105. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCounty())) {
  106. bo.setCityNo(dto.getMap().getCounty());
  107. }
  108. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getBuildingAddressNumber())) {
  109. bo.setSiteNum(dto.getMap().getBuildingAddressNumber());
  110. }
  111. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getBuildingNameAlias())) {
  112. bo.setSiteName(dto.getMap().getBuildingNameAlias());
  113. }
  114. if (dto.getMap() != null && dto.getMap().getOrder() != null && dto.getMap().getSidx() != null) {
  115. if (OrderEnum.asc.equals(dto.getMap().getOrder())) {
  116. page.addOrder(OrderItem.asc(dto.getMap().getSidx().getColumnName()));
  117. } else {
  118. page.addOrder(OrderItem.desc(dto.getMap().getSidx().getColumnName()));
  119. }
  120. } else {
  121. page.addOrder(OrderItem.desc(ListBuildingIdleOrderEnum.buildingAreaIdelArea.getColumnName()));
  122. }
  123. return houseBuildingDao.listBuildingIdle(page, bo);
  124. }
  125. /**
  126. * 写空置1000平米以上建筑文件
  127. */
  128. private void writeIdleList(ListBuildingIdleDto dto, SXSSFWorkbook wb) {
  129. Page<HouseBuildingPo> page = new Page<>(1, Long.MAX_VALUE);
  130. List<HouseBuildingPo> list = getBuildingIdle(dto, page);
  131. DataFormat dataFormat = wb.createDataFormat();
  132. // 数字样式
  133. CellStyle numberCellStyle = wb.createCellStyle();
  134. numberCellStyle.setDataFormat(dataFormat.getFormat("#,##0.00"));
  135. numberCellStyle.setAlignment(HorizontalAlignment.RIGHT);
  136. // 默认样式
  137. CellStyle baseCellStyle = wb.createCellStyle();
  138. baseCellStyle.setAlignment(HorizontalAlignment.CENTER);
  139. baseCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  140. CellStyle percentCellStyle = wb.createCellStyle();
  141. percentCellStyle.setDataFormat(dataFormat.getFormat("0.00%"));
  142. percentCellStyle.setAlignment(HorizontalAlignment.RIGHT);
  143. SXSSFSheet sheet = wb.createSheet();
  144. AtomicInteger rowIndex = new AtomicInteger(0);
  145. // 表头
  146. Row headerRow = sheet.createRow(rowIndex.getAndIncrement());
  147. List<String> headers = Stream.of("资产所属单位(一级)", "资产所属单位(二级)", "资产所属单位(三级)", "局址编号",
  148. "局址别名", "建筑别名", "地段", "建筑面积(㎡)","建筑面积-出租(㎡)", "建筑面积-闲置(㎡)", "建筑面积-自用(㎡)",
  149. "建筑面积-不可使用(㎡)", "上级土地名称", "得房率", "房屋来源", "取得日期", "房龄开始年份", "投资主体", "管理层级",
  150. "房屋结构", "楼层总数", "是否临街", "是否有院落", "整栋是否独有", "是否有房产证", "无房产证原因", "未关联资产",
  151. "资产编号", "资产标签号", "使用状态", "建筑用途", "权属状态", "建筑占地面积(㎡)", "使用面积(㎡)",
  152. "使用面积-自用(㎡)", "使用面积-出租(㎡)", "使用面积-闲置(㎡)", "使用面积-不可使用(㎡)", "楼长姓名",
  153. "楼长所在单位", "经度", "纬度", "实际产权人").toList();
  154. int headerLength = headers.size();
  155. for (int i = 0; i < headerLength; i++) {
  156. Cell cell = headerRow.createCell(i);
  157. cell.setCellValue(headers.get(i));
  158. cell.setCellStyle(baseCellStyle);
  159. // 根据内容长度设置列宽
  160. int columnWidth = headers.get(i).length() * 256 * 2 + 256;
  161. sheet.setColumnWidth(i, columnWidth);
  162. }
  163. // 数据
  164. for (HouseBuildingPo po : list) {
  165. AtomicInteger columnIndex = new AtomicInteger(0);
  166. Row row = sheet.createRow(rowIndex.getAndIncrement());
  167. // 资产所属单位(一级)
  168. Cell firstUnitCell = row.createCell(columnIndex.getAndIncrement());
  169. if (po.getFirstUnit() != null) {
  170. firstUnitCell.setCellValue(po.getFirstUnit());
  171. }
  172. // 二级单位
  173. Cell areaNameCell = row.createCell(columnIndex.getAndIncrement());
  174. if (po.getAreaName() != null) {
  175. areaNameCell.setCellValue(po.getAreaName());
  176. }
  177. // 三级单位
  178. Cell cityNameCell = row.createCell(columnIndex.getAndIncrement());
  179. if (po.getCityName() != null) {
  180. cityNameCell.setCellValue(po.getCityName());
  181. }
  182. // 局址编号
  183. Cell siteNumCell = row.createCell(columnIndex.getAndIncrement());
  184. if (po.getSiteName() != null) {
  185. siteNumCell.setCellValue(po.getSiteNum());
  186. }
  187. // 局址别名
  188. Cell siteNameCell = row.createCell(columnIndex.getAndIncrement());
  189. if (po.getSiteName() != null) {
  190. siteNameCell.setCellValue(po.getSiteName());
  191. }
  192. // 建筑别名
  193. Cell buildingNameCell = row.createCell(columnIndex.getAndIncrement());
  194. if (po.getBuildingName() != null) {
  195. buildingNameCell.setCellValue(po.getBuildingName());
  196. }
  197. // 地段
  198. Cell areaSectorCell = row.createCell(columnIndex.getAndIncrement());
  199. if (po.getAreaSector() != null) {
  200. areaSectorCell.setCellValue(po.getAreaSector());
  201. }
  202. // 建筑面积(㎡)
  203. Cell buildingAreaCell = row.createCell(columnIndex.getAndIncrement());
  204. if (po.getBuildingArea() != null) {
  205. buildingAreaCell.setCellValue(po.getBuildingArea().doubleValue());
  206. }
  207. buildingAreaCell.setCellStyle(numberCellStyle);
  208. // 建筑面积-出租(㎡)
  209. Cell buildingAreaRentCell = row.createCell(columnIndex.getAndIncrement());
  210. if (po.getBuildingAreaRent() != null) {
  211. buildingAreaRentCell.setCellValue(po.getBuildingAreaRent().doubleValue());
  212. }
  213. buildingAreaRentCell.setCellStyle(numberCellStyle);
  214. // 建筑面积-闲置(㎡)
  215. Cell buildingAreaIdleCell = row.createCell(columnIndex.getAndIncrement());
  216. if (po.getBuildingAreaIdle() != null) {
  217. buildingAreaIdleCell.setCellValue(po.getBuildingAreaIdle().doubleValue());
  218. }
  219. buildingAreaIdleCell.setCellStyle(numberCellStyle);
  220. // 建筑面积-自用(㎡)
  221. Cell buildingAreaSelfUseCell = row.createCell(columnIndex.getAndIncrement());
  222. if (po.getBuildingAreaSelfUse() != null) {
  223. buildingAreaSelfUseCell.setCellValue(po.getBuildingAreaSelfUse().doubleValue());
  224. }
  225. buildingAreaSelfUseCell.setCellStyle(numberCellStyle);
  226. // 建筑面积-不可使用(㎡)
  227. Cell buildingAreaUnusableCell = row.createCell(columnIndex.getAndIncrement());
  228. if (po.getBuildingAreaUnusable() != null) {
  229. buildingAreaUnusableCell.setCellValue(po.getBuildingAreaUnusable().doubleValue());
  230. }
  231. buildingAreaUnusableCell.setCellStyle(numberCellStyle);
  232. // 上级土地名称
  233. Cell landNameCell = row.createCell(columnIndex.getAndIncrement());
  234. if (po.getLandName() != null) {
  235. landNameCell.setCellValue(po.getLandName());
  236. }
  237. // 得房率
  238. Cell housingAcquisitionRateCell = row.createCell(columnIndex.getAndIncrement());
  239. if (po.getHousingAcquisitionRate() != null) {
  240. housingAcquisitionRateCell.setCellValue(po.getHousingAcquisitionRate().doubleValue());
  241. }
  242. housingAcquisitionRateCell.setCellStyle(percentCellStyle);
  243. // 房屋来源
  244. Cell housingSourceCell = row.createCell(columnIndex.getAndIncrement());
  245. if (po.getHousingSource() != null) {
  246. housingSourceCell.setCellValue(po.getHousingSource());
  247. }
  248. // 取得日期
  249. Cell acquisitionDateCell = row.createCell(columnIndex.getAndIncrement());
  250. if (po.getAcquisitionDate() != null) {
  251. acquisitionDateCell.setCellValue(po.getAcquisitionDate());
  252. }
  253. // 房龄开始年份
  254. Cell houseYearBeganCell = row.createCell(columnIndex.getAndIncrement());
  255. if (po.getHouseYearBegan() != null) {
  256. houseYearBeganCell.setCellValue(po.getHouseYearBegan());
  257. }
  258. // 投资主体
  259. Cell investorCell = row.createCell(columnIndex.getAndIncrement());
  260. if (po.getInvestor() != null) {
  261. investorCell.setCellValue(po.getInvestor());
  262. }
  263. // 管理层级
  264. Cell managementLevelCell = row.createCell(columnIndex.getAndIncrement());
  265. if (po.getManagementLevel() != null) {
  266. managementLevelCell.setCellValue(po.getManagementLevel());
  267. }
  268. // 房屋结构
  269. Cell buildingStructureCell = row.createCell(columnIndex.getAndIncrement());
  270. if (po.getBuildingStructure() != null) {
  271. buildingStructureCell.setCellValue(po.getBuildingStructure());
  272. }
  273. // 楼层总数
  274. Cell totalFloorsCell = row.createCell(columnIndex.getAndIncrement());
  275. if (po.getTotalFloors() != null) {
  276. totalFloorsCell.setCellValue(po.getTotalFloors());
  277. }
  278. // 是否临街
  279. Cell frontageCell = row.createCell(columnIndex.getAndIncrement());
  280. if (po.getFrontage() != null) {
  281. frontageCell.setCellValue(po.getFrontage());
  282. }
  283. // 是否有院落
  284. Cell courtyardCell = row.createCell(columnIndex.getAndIncrement());
  285. if (po.getCourtyard() != null) {
  286. courtyardCell.setCellValue(po.getCourtyard());
  287. }
  288. // 整栋是否独有
  289. Cell wholeBuildingCell = row.createCell(columnIndex.getAndIncrement());
  290. if (po.getWholeBuilding() != null) {
  291. wholeBuildingCell.setCellValue(po.getWholeBuilding());
  292. }
  293. // 是否有房产证
  294. Cell propertyOwnershipCertificateCell = row.createCell(columnIndex.getAndIncrement());
  295. if (po.getPropertyOwnershipCertificate() != null) {
  296. propertyOwnershipCertificateCell.setCellValue(po.getPropertyOwnershipCertificate());
  297. }
  298. // 无房产证原因
  299. Cell noPropertyOwnershipCertificateReasonCell = row.createCell(columnIndex.getAndIncrement());
  300. if (po.getNoPropertyOwnershipCertificateReason() != null) {
  301. noPropertyOwnershipCertificateReasonCell.setCellValue(
  302. po.getNoPropertyOwnershipCertificateReason());
  303. }
  304. // 未关联资产
  305. Cell unrelatedAssetsCell = row.createCell(columnIndex.getAndIncrement());
  306. if (po.getUnrelatedAssets() != null) {
  307. unrelatedAssetsCell.setCellValue(po.getUnrelatedAssets());
  308. }
  309. // 资产编号
  310. Cell assetsNumCell = row.createCell(columnIndex.getAndIncrement());
  311. if (po.getAssetsNum() != null) {
  312. assetsNumCell.setCellValue(po.getAssetsNum());
  313. }
  314. // 资产标签号
  315. Cell assetsTagNumCell = row.createCell(columnIndex.getAndIncrement());
  316. if (po.getAssetsTagNum() != null) {
  317. assetsTagNumCell.setCellValue(po.getAssetsTagNum());
  318. }
  319. // 使用状态
  320. Cell usageStatusCell = row.createCell(columnIndex.getAndIncrement());
  321. if (po.getUsageStatus() != null) {
  322. usageStatusCell.setCellValue(po.getUsageStatus());
  323. }
  324. // 建筑用途
  325. Cell buildingUseCell = row.createCell(columnIndex.getAndIncrement());
  326. if (po.getBuildingUse() != null) {
  327. buildingUseCell.setCellValue(po.getBuildingUse());
  328. }
  329. // 权属状态
  330. Cell ownershipStatusCell = row.createCell(columnIndex.getAndIncrement());
  331. if (po.getOwnershipStatus() != null) {
  332. ownershipStatusCell.setCellValue(po.getOwnershipStatus());
  333. }
  334. // 建筑占地面积(㎡)
  335. Cell floorAreaCell = row.createCell(columnIndex.getAndIncrement());
  336. if (po.getFloorArea() != null) {
  337. floorAreaCell.setCellValue(po.getFloorArea().doubleValue());
  338. }
  339. floorAreaCell.setCellStyle(numberCellStyle);
  340. // 使用面积(㎡)
  341. Cell usableAreaCell = row.createCell(columnIndex.getAndIncrement());
  342. if (po.getUsableArea() != null) {
  343. usableAreaCell.setCellValue(po.getUsableArea().doubleValue());
  344. }
  345. usableAreaCell.setCellStyle(numberCellStyle);
  346. // 使用面积-自用(㎡)
  347. Cell usableAreaSelfUseCell = row.createCell(columnIndex.getAndIncrement());
  348. if (po.getUsableAreaSelfUse() != null) {
  349. usableAreaSelfUseCell.setCellValue(po.getUsableAreaSelfUse().doubleValue());
  350. }
  351. usableAreaSelfUseCell.setCellStyle(numberCellStyle);
  352. // 使用面积-出租(㎡)
  353. Cell usableAreaRentCell = row.createCell(columnIndex.getAndIncrement());
  354. if (po.getUsableAreaRent() != null) {
  355. usableAreaRentCell.setCellValue(po.getUsableAreaRent().doubleValue());
  356. }
  357. usableAreaRentCell.setCellStyle(numberCellStyle);
  358. // 使用面积-闲置(㎡)
  359. Cell usableAreaIdleCell = row.createCell(columnIndex.getAndIncrement());
  360. if (po.getUsableAreaIdle() != null) {
  361. usableAreaIdleCell.setCellValue(po.getUsableAreaIdle().doubleValue());
  362. }
  363. usableAreaIdleCell.setCellStyle(numberCellStyle);
  364. // 使用面积-不可使用(㎡)
  365. Cell usableAreaUnusableCell = row.createCell(columnIndex.getAndIncrement());
  366. if (po.getUsableAreaUnusable() != null) {
  367. usableAreaUnusableCell.setCellValue(po.getUsableAreaUnusable().doubleValue());
  368. }
  369. usableAreaUnusableCell.setCellStyle(numberCellStyle);
  370. // 楼长姓名
  371. Cell communityAssistantNameCell = row.createCell(columnIndex.getAndIncrement());
  372. if (po.getCommunityAssistantName() != null) {
  373. communityAssistantNameCell.setCellValue(po.getCommunityAssistantName());
  374. }
  375. // 楼长所在单位
  376. Cell communityAssistantUnitCell = row.createCell(columnIndex.getAndIncrement());
  377. if (po.getCommunityAssistantUnit() != null) {
  378. communityAssistantUnitCell.setCellValue(po.getCommunityAssistantUnit());
  379. }
  380. // 经度
  381. Cell lngJtCell = row.createCell(columnIndex.getAndIncrement());
  382. if (po.getLngJt() != null) {
  383. lngJtCell.setCellValue(po.getLngJt().toString());
  384. }
  385. // 纬度
  386. Cell latJtCell = row.createCell(columnIndex.getAndIncrement());
  387. if (po.getLatJt() != null) {
  388. latJtCell.setCellValue(po.getLatJt().toString());
  389. }
  390. // 实际产权人
  391. Cell propertyOwnerCell = row.createCell(columnIndex.getAndIncrement());
  392. if (po.getPropertyOwner() != null) {
  393. propertyOwnerCell.setCellValue(po.getPropertyOwner());
  394. }
  395. }
  396. }
  397. public Rsp<PageVo<String>> listSiteName(ListSiteNameDto dto) {
  398. if ("全省".equals(dto.getMap().getCity())) {
  399. dto.getMap().setCity(null);
  400. dto.getMap().setCounty(null);
  401. }
  402. ListHouseSiteBo bo = new ListHouseSiteBo();
  403. bo.setAreaNo(dto.getMap().getCity());
  404. bo.setCityNo(dto.getMap().getCounty());
  405. bo.setSiteName(dto.getMap().getAlias());
  406. Page<HouseSitePo> page = new Page<>(dto.getPage().getPageNum(), dto.getPage().getPageSize());
  407. List<HouseSitePo> list = wzOtnAreaDao.listHouseSite(page, bo);
  408. List<String> vos = list.stream().map(HouseSitePo::getSiteName).toList();
  409. PageVo<String> pageVo = new PageVo<>(vos, page);
  410. return Rsp.ok(pageVo);
  411. }
  412. public Rsp<PageVo<String>> listSiteNum(ListSiteNumDto dto) {
  413. if ("全省".equals(dto.getMap().getCity())) {
  414. dto.getMap().setCity(null);
  415. dto.getMap().setCounty(null);
  416. }
  417. ListHouseSiteBo bo = new ListHouseSiteBo();
  418. bo.setAreaNo(dto.getMap().getCity());
  419. bo.setCityNo(dto.getMap().getCounty());
  420. bo.setSiteNum(dto.getMap().getCode());
  421. Page<HouseSitePo> page = new Page<>(dto.getPage().getPageNum(), dto.getPage().getPageSize());
  422. List<HouseSitePo> list = wzOtnAreaDao.listHouseSite(page, bo);
  423. List<String> vos = list.stream().map(HouseSitePo::getSiteNum).toList();
  424. PageVo<String> pageVo = new PageVo<>(vos, page);
  425. return Rsp.ok(pageVo);
  426. }
  427. public Rsp<PageVo<ListBuildingVo>> listBuilding(ListBuildingDto dto) {
  428. Page<HouseBuildingPo> page = new Page<>(dto.getPage().getPageNum(), dto.getPage().getPageSize());
  429. List<HouseBuildingPo> list = getBuildingList(dto, page);
  430. List<ListBuildingVo> vos = new ArrayList<>();
  431. for (HouseBuildingPo po : list) {
  432. vos.add(new ListBuildingVo(po));
  433. }
  434. PageVo<ListBuildingVo> pageVo = new PageVo<>(vos, page);
  435. return Rsp.ok(pageVo);
  436. }
  437. /**
  438. * 查询不动产建筑
  439. */
  440. private List<HouseBuildingPo> getBuildingList(ListBuildingDto dto, Page<HouseBuildingPo> page) {
  441. ListBuildingBo bo = new ListBuildingBo();
  442. if (dto.getMap() != null && dto.getMap().getStatisticalMonth() != null) {
  443. bo.setYearMonth(dto.getMap().getStatisticalMonth());
  444. }
  445. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCity()) && !"全省".equals(dto.getMap().getCity())) {
  446. bo.setAreaNo(dto.getMap().getCity());
  447. }
  448. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCounty())) {
  449. bo.setCityNo(dto.getMap().getCounty());
  450. }
  451. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getBuildingAddressNumber())) {
  452. bo.setSiteNum(dto.getMap().getBuildingAddressNumber());
  453. }
  454. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getBuildingNameAlias())) {
  455. bo.setSiteName(dto.getMap().getBuildingNameAlias());
  456. }
  457. if (dto.getMap() != null && dto.getMap().getOrder() != null && dto.getMap().getSidx() != null) {
  458. if (OrderEnum.asc.equals(dto.getMap().getOrder())) {
  459. page.addOrder(OrderItem.asc(dto.getMap().getSidx().getColumnName()));
  460. } else {
  461. page.addOrder(OrderItem.desc(dto.getMap().getSidx().getColumnName()));
  462. }
  463. } else {
  464. page.addOrder(OrderItem.desc(ListBuildingOrderEnum.buildingArea.getColumnName()));
  465. }
  466. return houseBuildingDao.listBuilding(page, bo);
  467. }
  468. public void listBuildingExport(ListBuildingDto.ListBuildingMapDTO dto) {
  469. ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder
  470. .getRequestAttributes();
  471. if (servletRequestAttributes == null) {
  472. return;
  473. }
  474. HttpServletResponse response = servletRequestAttributes.getResponse();
  475. if (response == null) {
  476. return;
  477. }
  478. String filename = "房屋管理_房产记录"
  479. + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
  480. response.setHeader("Content-Disposition", "attachment;filename=" + URLEncodeUtil.encode(filename));
  481. response.setContentType("application/octet-stream");
  482. try (SXSSFWorkbook wb = new SXSSFWorkbook()) {
  483. writeListBuilding(new ListBuildingDto(dto), wb);
  484. wb.write(response.getOutputStream());
  485. } catch (Exception e) {
  486. log.error(e.getMessage(), e);
  487. }
  488. }
  489. /**
  490. * 写不动产建筑文件
  491. */
  492. private void writeListBuilding(ListBuildingDto dto, SXSSFWorkbook wb) {
  493. Page<HouseBuildingPo> page = new Page<>(1, Long.MAX_VALUE);
  494. List<HouseBuildingPo> list = getBuildingList(dto, page);
  495. DataFormat dataFormat = wb.createDataFormat();
  496. // 数字样式
  497. CellStyle numberCellStyle = wb.createCellStyle();
  498. numberCellStyle.setDataFormat(dataFormat.getFormat("#,##0.00"));
  499. numberCellStyle.setAlignment(HorizontalAlignment.RIGHT);
  500. // 默认样式
  501. CellStyle baseCellStyle = wb.createCellStyle();
  502. baseCellStyle.setAlignment(HorizontalAlignment.CENTER);
  503. baseCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  504. // 百分比样式
  505. CellStyle percentCellStyle = wb.createCellStyle();
  506. percentCellStyle.setDataFormat(dataFormat.getFormat("0.00%"));
  507. percentCellStyle.setAlignment(HorizontalAlignment.RIGHT);
  508. SXSSFSheet sheet = wb.createSheet();
  509. AtomicInteger rowIndex = new AtomicInteger(0);
  510. // 表头
  511. Row headerRow = sheet.createRow(rowIndex.getAndIncrement());
  512. List<String> headers = Stream.of("资产所属单位(一级)", "资产所属单位(二级)", "资产所属单位(三级)", "局址编号",
  513. "局址别名", "建筑别名", "地段", "建筑面积(㎡)","建筑面积-出租(㎡)", "建筑面积-闲置(㎡)", "建筑面积-自用(㎡)",
  514. "建筑面积-不可使用(㎡)", "上级土地名称", "得房率", "房屋来源", "取得日期", "房龄开始年份", "投资主体", "管理层级",
  515. "房屋结构", "楼层总数", "是否临街", "是否有院落", "整栋是否独有", "是否有房产证", "无房产证原因", "未关联资产",
  516. "资产编号", "资产标签号", "使用状态", "建筑用途", "权属状态", "建筑占地面积(㎡)", "使用面积(㎡)",
  517. "使用面积-自用(㎡)", "使用面积-出租(㎡)", "使用面积-闲置(㎡)", "使用面积-不可使用(㎡)", "楼长姓名",
  518. "楼长所在单位", "经度", "纬度", "实际产权人").toList();
  519. int headerLength = headers.size();
  520. for (int i = 0; i < headerLength; i++) {
  521. Cell cell = headerRow.createCell(i);
  522. cell.setCellValue(headers.get(i));
  523. cell.setCellStyle(baseCellStyle);
  524. // 根据内容长度设置列宽
  525. int columnWidth = headers.get(i).length() * 256 * 2 + 256;
  526. sheet.setColumnWidth(i, columnWidth);
  527. }
  528. // 数据
  529. for (HouseBuildingPo po : list) {
  530. AtomicInteger columnIndex = new AtomicInteger(0);
  531. Row row = sheet.createRow(rowIndex.getAndIncrement());
  532. // 资产所属单位(一级)
  533. Cell firstUnitCell = row.createCell(columnIndex.getAndIncrement());
  534. if (po.getFirstUnit() != null) {
  535. firstUnitCell.setCellValue(po.getFirstUnit());
  536. }
  537. // 二级单位
  538. Cell areaNameCell = row.createCell(columnIndex.getAndIncrement());
  539. if (po.getAreaName() != null) {
  540. areaNameCell.setCellValue(po.getAreaName());
  541. }
  542. // 三级单位
  543. Cell cityNameCell = row.createCell(columnIndex.getAndIncrement());
  544. if (po.getCityName() != null) {
  545. cityNameCell.setCellValue(po.getCityName());
  546. }
  547. // 局址编号
  548. Cell siteNumCell = row.createCell(columnIndex.getAndIncrement());
  549. if (po.getSiteName() != null) {
  550. siteNumCell.setCellValue(po.getSiteNum());
  551. }
  552. // 局址别名
  553. Cell siteNameCell = row.createCell(columnIndex.getAndIncrement());
  554. if (po.getSiteName() != null) {
  555. siteNameCell.setCellValue(po.getSiteName());
  556. }
  557. // 建筑别名
  558. Cell buildingNameCell = row.createCell(columnIndex.getAndIncrement());
  559. if (po.getBuildingName() != null) {
  560. buildingNameCell.setCellValue(po.getBuildingName());
  561. }
  562. // 地段
  563. Cell areaSectorCell = row.createCell(columnIndex.getAndIncrement());
  564. if (po.getAreaSector() != null) {
  565. areaSectorCell.setCellValue(po.getAreaSector());
  566. }
  567. // 建筑面积(㎡)
  568. Cell buildingAreaCell = row.createCell(columnIndex.getAndIncrement());
  569. if (po.getBuildingArea() != null) {
  570. buildingAreaCell.setCellValue(po.getBuildingArea().doubleValue());
  571. }
  572. buildingAreaCell.setCellStyle(numberCellStyle);
  573. // 建筑面积-出租(㎡)
  574. Cell buildingAreaRentCell = row.createCell(columnIndex.getAndIncrement());
  575. if (po.getBuildingAreaRent() != null) {
  576. buildingAreaRentCell.setCellValue(po.getBuildingAreaRent().doubleValue());
  577. }
  578. buildingAreaRentCell.setCellStyle(numberCellStyle);
  579. // 建筑面积-闲置(㎡)
  580. Cell buildingAreaIdleCell = row.createCell(columnIndex.getAndIncrement());
  581. if (po.getBuildingAreaIdle() != null) {
  582. buildingAreaIdleCell.setCellValue(po.getBuildingAreaIdle().doubleValue());
  583. }
  584. buildingAreaIdleCell.setCellStyle(numberCellStyle);
  585. // 建筑面积-自用(㎡)
  586. Cell buildingAreaSelfUseCell = row.createCell(columnIndex.getAndIncrement());
  587. if (po.getBuildingAreaSelfUse() != null) {
  588. buildingAreaSelfUseCell.setCellValue(po.getBuildingAreaSelfUse().doubleValue());
  589. }
  590. buildingAreaSelfUseCell.setCellStyle(numberCellStyle);
  591. // 建筑面积-不可使用(㎡)
  592. Cell buildingAreaUnusableCell = row.createCell(columnIndex.getAndIncrement());
  593. if (po.getBuildingAreaUnusable() != null) {
  594. buildingAreaUnusableCell.setCellValue(po.getBuildingAreaUnusable().doubleValue());
  595. }
  596. buildingAreaUnusableCell.setCellStyle(numberCellStyle);
  597. // 上级土地名称
  598. Cell landNameCell = row.createCell(columnIndex.getAndIncrement());
  599. if (po.getLandName() != null) {
  600. landNameCell.setCellValue(po.getLandName());
  601. }
  602. // 得房率
  603. Cell housingAcquisitionRateCell = row.createCell(columnIndex.getAndIncrement());
  604. if (po.getHousingAcquisitionRate() != null) {
  605. housingAcquisitionRateCell.setCellValue(po.getHousingAcquisitionRate().doubleValue());
  606. }
  607. housingAcquisitionRateCell.setCellStyle(percentCellStyle);
  608. // 房屋来源
  609. Cell housingSourceCell = row.createCell(columnIndex.getAndIncrement());
  610. if (po.getHousingSource() != null) {
  611. housingSourceCell.setCellValue(po.getHousingSource());
  612. }
  613. // 取得日期
  614. Cell acquisitionDateCell = row.createCell(columnIndex.getAndIncrement());
  615. if (po.getAcquisitionDate() != null) {
  616. acquisitionDateCell.setCellValue(po.getAcquisitionDate());
  617. }
  618. // 房龄开始年份
  619. Cell houseYearBeganCell = row.createCell(columnIndex.getAndIncrement());
  620. if (po.getHouseYearBegan() != null) {
  621. houseYearBeganCell.setCellValue(po.getHouseYearBegan());
  622. }
  623. // 投资主体
  624. Cell investorCell = row.createCell(columnIndex.getAndIncrement());
  625. if (po.getInvestor() != null) {
  626. investorCell.setCellValue(po.getInvestor());
  627. }
  628. // 管理层级
  629. Cell managementLevelCell = row.createCell(columnIndex.getAndIncrement());
  630. if (po.getManagementLevel() != null) {
  631. managementLevelCell.setCellValue(po.getManagementLevel());
  632. }
  633. // 房屋结构
  634. Cell buildingStructureCell = row.createCell(columnIndex.getAndIncrement());
  635. if (po.getBuildingStructure() != null) {
  636. buildingStructureCell.setCellValue(po.getBuildingStructure());
  637. }
  638. // 楼层总数
  639. Cell totalFloorsCell = row.createCell(columnIndex.getAndIncrement());
  640. if (po.getTotalFloors() != null) {
  641. totalFloorsCell.setCellValue(po.getTotalFloors());
  642. }
  643. // 是否临街
  644. Cell frontageCell = row.createCell(columnIndex.getAndIncrement());
  645. if (po.getFrontage() != null) {
  646. frontageCell.setCellValue(po.getFrontage());
  647. }
  648. // 是否有院落
  649. Cell courtyardCell = row.createCell(columnIndex.getAndIncrement());
  650. if (po.getCourtyard() != null) {
  651. courtyardCell.setCellValue(po.getCourtyard());
  652. }
  653. // 整栋是否独有
  654. Cell wholeBuildingCell = row.createCell(columnIndex.getAndIncrement());
  655. if (po.getWholeBuilding() != null) {
  656. wholeBuildingCell.setCellValue(po.getWholeBuilding());
  657. }
  658. // 是否有房产证
  659. Cell propertyOwnershipCertificateCell = row.createCell(columnIndex.getAndIncrement());
  660. if (po.getPropertyOwnershipCertificate() != null) {
  661. propertyOwnershipCertificateCell.setCellValue(po.getPropertyOwnershipCertificate());
  662. }
  663. // 无房产证原因
  664. Cell noPropertyOwnershipCertificateReasonCell = row.createCell(columnIndex.getAndIncrement());
  665. if (po.getNoPropertyOwnershipCertificateReason() != null) {
  666. noPropertyOwnershipCertificateReasonCell.setCellValue(
  667. po.getNoPropertyOwnershipCertificateReason());
  668. }
  669. // 未关联资产
  670. Cell unrelatedAssetsCell = row.createCell(columnIndex.getAndIncrement());
  671. if (po.getUnrelatedAssets() != null) {
  672. unrelatedAssetsCell.setCellValue(po.getUnrelatedAssets());
  673. }
  674. // 资产编号
  675. Cell assetsNumCell = row.createCell(columnIndex.getAndIncrement());
  676. if (po.getAssetsNum() != null) {
  677. assetsNumCell.setCellValue(po.getAssetsNum());
  678. }
  679. // 资产标签号
  680. Cell assetsTagNumCell = row.createCell(columnIndex.getAndIncrement());
  681. if (po.getAssetsTagNum() != null) {
  682. assetsTagNumCell.setCellValue(po.getAssetsTagNum());
  683. }
  684. // 使用状态
  685. Cell usageStatusCell = row.createCell(columnIndex.getAndIncrement());
  686. if (po.getUsageStatus() != null) {
  687. usageStatusCell.setCellValue(po.getUsageStatus());
  688. }
  689. // 建筑用途
  690. Cell buildingUseCell = row.createCell(columnIndex.getAndIncrement());
  691. if (po.getBuildingUse() != null) {
  692. buildingUseCell.setCellValue(po.getBuildingUse());
  693. }
  694. // 权属状态
  695. Cell ownershipStatusCell = row.createCell(columnIndex.getAndIncrement());
  696. if (po.getOwnershipStatus() != null) {
  697. ownershipStatusCell.setCellValue(po.getOwnershipStatus());
  698. }
  699. // 建筑占地面积(㎡)
  700. Cell floorAreaCell = row.createCell(columnIndex.getAndIncrement());
  701. if (po.getFloorArea() != null) {
  702. floorAreaCell.setCellValue(po.getFloorArea().doubleValue());
  703. }
  704. floorAreaCell.setCellStyle(numberCellStyle);
  705. // 使用面积(㎡)
  706. Cell usableAreaCell = row.createCell(columnIndex.getAndIncrement());
  707. if (po.getUsableArea() != null) {
  708. usableAreaCell.setCellValue(po.getUsableArea().doubleValue());
  709. }
  710. usableAreaCell.setCellStyle(numberCellStyle);
  711. // 使用面积-自用(㎡)
  712. Cell usableAreaSelfUseCell = row.createCell(columnIndex.getAndIncrement());
  713. if (po.getUsableAreaSelfUse() != null) {
  714. usableAreaSelfUseCell.setCellValue(po.getUsableAreaSelfUse().doubleValue());
  715. }
  716. usableAreaSelfUseCell.setCellStyle(numberCellStyle);
  717. // 使用面积-出租(㎡)
  718. Cell usableAreaRentCell = row.createCell(columnIndex.getAndIncrement());
  719. if (po.getUsableAreaRent() != null) {
  720. usableAreaRentCell.setCellValue(po.getUsableAreaRent().doubleValue());
  721. }
  722. usableAreaRentCell.setCellStyle(numberCellStyle);
  723. // 使用面积-闲置(㎡)
  724. Cell usableAreaIdleCell = row.createCell(columnIndex.getAndIncrement());
  725. if (po.getUsableAreaIdle() != null) {
  726. usableAreaIdleCell.setCellValue(po.getUsableAreaIdle().doubleValue());
  727. }
  728. usableAreaIdleCell.setCellStyle(numberCellStyle);
  729. // 使用面积-不可使用(㎡)
  730. Cell usableAreaUnusableCell = row.createCell(columnIndex.getAndIncrement());
  731. if (po.getUsableAreaUnusable() != null) {
  732. usableAreaUnusableCell.setCellValue(po.getUsableAreaUnusable().doubleValue());
  733. }
  734. usableAreaUnusableCell.setCellStyle(numberCellStyle);
  735. // 楼长姓名
  736. Cell communityAssistantNameCell = row.createCell(columnIndex.getAndIncrement());
  737. if (po.getCommunityAssistantName() != null) {
  738. communityAssistantNameCell.setCellValue(po.getCommunityAssistantName());
  739. }
  740. // 楼长所在单位
  741. Cell communityAssistantUnitCell = row.createCell(columnIndex.getAndIncrement());
  742. if (po.getCommunityAssistantUnit() != null) {
  743. communityAssistantUnitCell.setCellValue(po.getCommunityAssistantUnit());
  744. }
  745. // 经度
  746. Cell lngJtCell = row.createCell(columnIndex.getAndIncrement());
  747. if (po.getLngJt() != null) {
  748. lngJtCell.setCellValue(po.getLngJt().toString());
  749. }
  750. // 纬度
  751. Cell latJtCell = row.createCell(columnIndex.getAndIncrement());
  752. if (po.getLatJt() != null) {
  753. latJtCell.setCellValue(po.getLatJt().toString());
  754. }
  755. // 实际产权人
  756. Cell propertyOwnerCell = row.createCell(columnIndex.getAndIncrement());
  757. if (po.getPropertyOwner() != null) {
  758. propertyOwnerCell.setCellValue(po.getPropertyOwner());
  759. }
  760. }
  761. }
  762. public Rsp<PageVo<HouseAgeStatVo>> houseAgeStat(HouseAgeStatDto dto) {
  763. HouseAgeStatPo houseAgeStatPos = getHouseAgeStatPos(dto);
  764. if (houseAgeStatPos == null) {
  765. return Rsp.ok();
  766. }
  767. HouseAgeStatVo vo = new HouseAgeStatVo(houseAgeStatPos, false);
  768. PageVo<HouseAgeStatVo> pageVo = new PageVo<>(Collections.singletonList(vo));
  769. return Rsp.ok(pageVo);
  770. }
  771. /**
  772. * 不动产自有房产房龄统计
  773. */
  774. public HouseAgeStatPo getHouseAgeStatPos(HouseAgeStatDto dto) {
  775. HouseAgeStatBo bo = new HouseAgeStatBo();
  776. if (dto.getMap() != null && dto.getMap().getStatisticalMonth() != null) {
  777. bo.setYearMonth(dto.getMap().getStatisticalMonth());
  778. }
  779. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCity()) && !"全省".equals(dto.getMap().getCity())) {
  780. bo.setAreaNo(dto.getMap().getCity());
  781. }
  782. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCounty())) {
  783. bo.setCityNo(dto.getMap().getCounty());
  784. }
  785. // 查询三级单位统计
  786. List<HouseAgeStatPo> houseAgeStatPos = houseBuildingDao.houseAgeStat(bo);
  787. if (CollectionUtils.isEmpty(houseAgeStatPos)) {
  788. return null;
  789. }
  790. // 一级单位统计
  791. HouseAgeStatPo firstUnitPo = new HouseAgeStatPo();
  792. firstUnitPo.setAreaName("全省");
  793. firstUnitPo.setCityName("全省");
  794. LinkedHashMap<String, HouseAgeStatPo> secondUnitPoMap = new LinkedHashMap<>();
  795. // 二级单位统计
  796. for (HouseAgeStatPo houseAgeStatPo : houseAgeStatPos) {
  797. secondUnitPoMap.putIfAbsent(houseAgeStatPo.getAreaNo(),
  798. new HouseAgeStatPo(houseAgeStatPo.getAreaNo(), houseAgeStatPo.getAreaName()));
  799. HouseAgeStatPo secondUnitPo = secondUnitPoMap.get(houseAgeStatPo.getAreaNo());
  800. secondUnitPo.update(houseAgeStatPo);
  801. }
  802. for (HouseAgeStatPo value : secondUnitPoMap.values()) {
  803. firstUnitPo.update(value);
  804. }
  805. return firstUnitPo;
  806. }
  807. public void queryHouseYearExport(HouseAgeStatDto.HouseAgeStatMapDTO dto) {
  808. ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder
  809. .getRequestAttributes();
  810. if (servletRequestAttributes == null) {
  811. return;
  812. }
  813. HttpServletResponse response = servletRequestAttributes.getResponse();
  814. if (response == null) {
  815. return;
  816. }
  817. String filename = "房屋管理_房龄统计"
  818. + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
  819. response.setHeader("Content-Disposition", "attachment;filename=" + URLEncodeUtil.encode(filename));
  820. response.setContentType("application/octet-stream");
  821. try (SXSSFWorkbook wb = new SXSSFWorkbook()) {
  822. writeQueryHouseYear(new HouseAgeStatDto(dto), wb);
  823. wb.write(response.getOutputStream());
  824. } catch (Exception e) {
  825. log.error(e.getMessage(), e);
  826. }
  827. }
  828. /**
  829. * 写房龄统计文件
  830. */
  831. private void writeQueryHouseYear(HouseAgeStatDto dto, SXSSFWorkbook wb) {
  832. HouseAgeStatPo firstPo = getHouseAgeStatPos(dto);
  833. DataFormat dataFormat = wb.createDataFormat();
  834. // 整数样式
  835. CellStyle integerCellStyle = wb.createCellStyle();
  836. integerCellStyle.setDataFormat(dataFormat.getFormat("#,##0"));
  837. integerCellStyle.setAlignment(HorizontalAlignment.RIGHT);
  838. // 数字样式
  839. CellStyle numberCellStyle = wb.createCellStyle();
  840. numberCellStyle.setDataFormat(dataFormat.getFormat("#,##0.00"));
  841. numberCellStyle.setAlignment(HorizontalAlignment.RIGHT);
  842. // 默认样式
  843. CellStyle baseCellStyle = wb.createCellStyle();
  844. baseCellStyle.setAlignment(HorizontalAlignment.CENTER);
  845. baseCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  846. SXSSFSheet sheet = wb.createSheet();
  847. AtomicInteger rowIndex = new AtomicInteger(0);
  848. // 表头
  849. Row headerRow = sheet.createRow(rowIndex.getAndIncrement());
  850. List<String> headers = Stream.of("资产所属单位(一级)", "资产所属单位(二级)", "资产所属单位(三级)",
  851. "1-10年", "11-20年", "21-30年", "31-40年", "41-50年", "50年以上", "平均房龄").toList();
  852. int headerLength = headers.size();
  853. for (int i = 0; i < headerLength; i++) {
  854. Cell cell = headerRow.createCell(i);
  855. cell.setCellValue(headers.get(i));
  856. cell.setCellStyle(baseCellStyle);
  857. // 根据内容长度设置列宽
  858. int columnWidth = headers.get(i).length() * 256 * 2 + 256;
  859. sheet.setColumnWidth(i, columnWidth);
  860. }
  861. if (firstPo == null) {
  862. return;
  863. }
  864. // 数据
  865. AtomicInteger columnIndex1 = new AtomicInteger(0);
  866. // 一级单位统计
  867. Row row1 = sheet.createRow(rowIndex.getAndIncrement());
  868. // 资产所属单位(一级)
  869. Cell firstUnitCell1 = row1.createCell(columnIndex1.getAndIncrement());
  870. if (firstPo.getAreaName() != null) {
  871. firstUnitCell1.setCellValue(firstPo.getAreaName());
  872. }
  873. // 二级单位
  874. Cell areaNameCell1 = row1.createCell(columnIndex1.getAndIncrement());
  875. // if (firstPo.getAreaName() != null) {
  876. // areaNameCell1.setCellValue(firstPo.getAreaName());
  877. // }
  878. // 三级单位
  879. Cell cityNameCell1 = row1.createCell(columnIndex1.getAndIncrement());
  880. // if (firstPo.getCityName() != null) {
  881. // cityNameCell1.setCellValue(firstPo.getCityName());
  882. // }
  883. // 1-10年
  884. Cell a1Cell1 = row1.createCell(columnIndex1.getAndIncrement());
  885. if (firstPo.getA1() != null) {
  886. a1Cell1.setCellValue(firstPo.getA1());
  887. }
  888. a1Cell1.setCellStyle(integerCellStyle);
  889. // 11-20年
  890. Cell a2Cell1 = row1.createCell(columnIndex1.getAndIncrement());
  891. if (firstPo.getA2() != null) {
  892. a2Cell1.setCellValue(firstPo.getA2());
  893. }
  894. a2Cell1.setCellStyle(integerCellStyle);
  895. // 21-30年
  896. Cell a3Cell1 = row1.createCell(columnIndex1.getAndIncrement());
  897. if (firstPo.getA3() != null) {
  898. a3Cell1.setCellValue(firstPo.getA3());
  899. }
  900. a3Cell1.setCellStyle(integerCellStyle);
  901. // 31-40年
  902. Cell a4Cell1 = row1.createCell(columnIndex1.getAndIncrement());
  903. if (firstPo.getA4() != null) {
  904. a4Cell1.setCellValue(firstPo.getA4());
  905. }
  906. a4Cell1.setCellStyle(integerCellStyle);
  907. // 41-50年
  908. Cell a5Cell1 = row1.createCell(columnIndex1.getAndIncrement());
  909. if (firstPo.getA5() != null) {
  910. a5Cell1.setCellValue(firstPo.getA5());
  911. }
  912. a5Cell1.setCellStyle(integerCellStyle);
  913. // 50年以上
  914. Cell a6Cell1 = row1.createCell(columnIndex1.getAndIncrement());
  915. if (firstPo.getA6() != null) {
  916. a6Cell1.setCellValue(firstPo.getA6());
  917. }
  918. a6Cell1.setCellStyle(integerCellStyle);
  919. // 平均房龄
  920. Cell houseAgeAvgCell1 = row1.createCell(columnIndex1.getAndIncrement());
  921. if (firstPo.getHouseAgeAvg() != null) {
  922. houseAgeAvgCell1.setCellValue(firstPo.getHouseAgeAvg().doubleValue());
  923. }
  924. houseAgeAvgCell1.setCellStyle(numberCellStyle);
  925. // 二级单位统计
  926. for (HouseAgeStatPo secondPo : firstPo.getChildren()) {
  927. AtomicInteger columnIndex2 = new AtomicInteger(0);
  928. Row row2 = sheet.createRow(rowIndex.getAndIncrement());
  929. // 资产所属单位(一级)
  930. Cell firstUnitCell2 = row2.createCell(columnIndex2.getAndIncrement());
  931. // if (secondPo.getAreaName() != null) {
  932. // firstUnitCell2.setCellValue(secondPo.getAreaName());
  933. // }
  934. // 二级单位
  935. Cell areaNameCell2 = row2.createCell(columnIndex2.getAndIncrement());
  936. if (secondPo.getAreaName() != null) {
  937. areaNameCell2.setCellValue(secondPo.getAreaName());
  938. }
  939. // 三级单位
  940. Cell cityNameCell2 = row2.createCell(columnIndex2.getAndIncrement());
  941. // if (secondPo.getCityName() != null) {
  942. // cityNameCell2.setCellValue(secondPo.getCityName());
  943. // }
  944. // 1-10年
  945. Cell a1Cell2 = row2.createCell(columnIndex2.getAndIncrement());
  946. if (secondPo.getA1() != null) {
  947. a1Cell2.setCellValue(secondPo.getA1());
  948. }
  949. a1Cell2.setCellStyle(integerCellStyle);
  950. // 11-20年
  951. Cell a2Cell2 = row2.createCell(columnIndex2.getAndIncrement());
  952. if (secondPo.getA2() != null) {
  953. a2Cell2.setCellValue(secondPo.getA2());
  954. }
  955. a2Cell2.setCellStyle(integerCellStyle);
  956. // 21-30年
  957. Cell a3Cell2 = row2.createCell(columnIndex2.getAndIncrement());
  958. if (secondPo.getA3() != null) {
  959. a3Cell2.setCellValue(secondPo.getA3());
  960. }
  961. a3Cell2.setCellStyle(integerCellStyle);
  962. // 31-40年
  963. Cell a4Cell2 = row2.createCell(columnIndex2.getAndIncrement());
  964. if (secondPo.getA4() != null) {
  965. a4Cell2.setCellValue(secondPo.getA4());
  966. }
  967. a4Cell2.setCellStyle(integerCellStyle);
  968. // 41-50年
  969. Cell a5Cell2 = row2.createCell(columnIndex2.getAndIncrement());
  970. if (secondPo.getA5() != null) {
  971. a5Cell2.setCellValue(secondPo.getA5());
  972. }
  973. a5Cell2.setCellStyle(integerCellStyle);
  974. // 50年以上
  975. Cell a6Cell2 = row2.createCell(columnIndex2.getAndIncrement());
  976. if (secondPo.getA6() != null) {
  977. a6Cell2.setCellValue(secondPo.getA6());
  978. }
  979. a6Cell2.setCellStyle(integerCellStyle);
  980. // 平均房龄
  981. Cell houseAgeAvgCell2 = row2.createCell(columnIndex2.getAndIncrement());
  982. if (secondPo.getHouseAgeAvg() != null) {
  983. houseAgeAvgCell2.setCellValue(secondPo.getHouseAgeAvg().doubleValue());
  984. }
  985. houseAgeAvgCell2.setCellStyle(numberCellStyle);
  986. // 三级单位统计
  987. for (HouseAgeStatPo thirdPo : secondPo.getChildren()) {
  988. AtomicInteger columnIndex3 = new AtomicInteger(0);
  989. Row row3 = sheet.createRow(rowIndex.getAndIncrement());
  990. // 资产所属单位(一级)
  991. Cell firstUnitCell3 = row3.createCell(columnIndex3.getAndIncrement());
  992. // if (thirdPo.getAreaName() != null) {
  993. // firstUnitCell3.setCellValue(thirdPo.getAreaName());
  994. // }
  995. // 二级单位
  996. Cell areaNameCell3 = row3.createCell(columnIndex3.getAndIncrement());
  997. // if (thirdPo.getAreaName() != null) {
  998. // areaNameCell3.setCellValue(thirdPo.getAreaName());
  999. // }
  1000. // 三级单位
  1001. Cell cityNameCell3 = row3.createCell(columnIndex3.getAndIncrement());
  1002. if (thirdPo.getCityName() != null) {
  1003. cityNameCell3.setCellValue(thirdPo.getCityName());
  1004. }
  1005. // 1-10年
  1006. Cell a1Cell3 = row3.createCell(columnIndex3.getAndIncrement());
  1007. if (thirdPo.getA1() != null) {
  1008. a1Cell3.setCellValue(thirdPo.getA1());
  1009. }
  1010. a1Cell3.setCellStyle(integerCellStyle);
  1011. // 11-20年
  1012. Cell a2Cell3 = row3.createCell(columnIndex3.getAndIncrement());
  1013. if (thirdPo.getA2() != null) {
  1014. a2Cell3.setCellValue(thirdPo.getA2());
  1015. }
  1016. a2Cell3.setCellStyle(integerCellStyle);
  1017. // 21-30年
  1018. Cell a3Cell3 = row3.createCell(columnIndex3.getAndIncrement());
  1019. if (thirdPo.getA3() != null) {
  1020. a3Cell3.setCellValue(thirdPo.getA3());
  1021. }
  1022. a3Cell3.setCellStyle(integerCellStyle);
  1023. // 31-40年
  1024. Cell a4Cell3 = row3.createCell(columnIndex3.getAndIncrement());
  1025. if (thirdPo.getA4() != null) {
  1026. a4Cell3.setCellValue(thirdPo.getA4());
  1027. }
  1028. a4Cell3.setCellStyle(integerCellStyle);
  1029. // 41-50年
  1030. Cell a5Cell3 = row3.createCell(columnIndex3.getAndIncrement());
  1031. if (thirdPo.getA5() != null) {
  1032. a5Cell3.setCellValue(thirdPo.getA5());
  1033. }
  1034. a5Cell3.setCellStyle(integerCellStyle);
  1035. // 50年以上
  1036. Cell a6Cell3 = row3.createCell(columnIndex3.getAndIncrement());
  1037. if (thirdPo.getA6() != null) {
  1038. a6Cell3.setCellValue(thirdPo.getA6());
  1039. }
  1040. a6Cell3.setCellStyle(integerCellStyle);
  1041. // 平均房龄
  1042. Cell houseAgeAvgCell3 = row3.createCell(columnIndex3.getAndIncrement());
  1043. if (thirdPo.getHouseAgeAvg() != null) {
  1044. houseAgeAvgCell3.setCellValue(thirdPo.getHouseAgeAvg().doubleValue());
  1045. }
  1046. houseAgeAvgCell3.setCellStyle(numberCellStyle);
  1047. }
  1048. }
  1049. }
  1050. public Rsp<PageVo<BuildingIdleStatVo>> buildingIdleStat(BuildingIdleStatDto dto) {
  1051. BuildingIdleStatPo buildingIdleStatPos = getBuildingIdleStatPos(dto);
  1052. if (buildingIdleStatPos == null) {
  1053. return Rsp.ok();
  1054. }
  1055. BuildingIdleStatVo vo = new BuildingIdleStatVo(buildingIdleStatPos, false);
  1056. PageVo<BuildingIdleStatVo> pageVo = new PageVo<>(Collections.singletonList(vo));
  1057. return Rsp.ok(pageVo);
  1058. }
  1059. private BuildingIdleStatPo getBuildingIdleStatPos(BuildingIdleStatDto dto) {
  1060. BuildingIdleStatBo bo = new BuildingIdleStatBo();
  1061. if (dto.getMap() != null && dto.getMap().getStatisticalMonth() != null) {
  1062. bo.setYearMonth(dto.getMap().getStatisticalMonth());
  1063. }
  1064. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCity()) && !"全省".equals(dto.getMap().getCity())) {
  1065. bo.setAreaNo(dto.getMap().getCity());
  1066. }
  1067. if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCounty())) {
  1068. bo.setCityNo(dto.getMap().getCounty());
  1069. }
  1070. // 查询三级单位统计
  1071. List<BuildingIdleStatPo> buildingIdleStatPos = houseBuildingDao.buildingIdleStat(bo);
  1072. if (CollectionUtils.isEmpty(buildingIdleStatPos)) {
  1073. return null;
  1074. }
  1075. // 一级单位统计
  1076. BuildingIdleStatPo firstUnitPo = new BuildingIdleStatPo();
  1077. firstUnitPo.setAreaName("全省");
  1078. firstUnitPo.setCityName("全省");
  1079. LinkedHashMap<String, BuildingIdleStatPo> secondUnitPoMap = new LinkedHashMap<>();
  1080. // 二级单位统计
  1081. for (BuildingIdleStatPo houseAgeStatPo : buildingIdleStatPos) {
  1082. secondUnitPoMap.putIfAbsent(houseAgeStatPo.getAreaNo(),
  1083. new BuildingIdleStatPo(houseAgeStatPo.getAreaNo(), houseAgeStatPo.getAreaName()));
  1084. BuildingIdleStatPo secondUnitPo = secondUnitPoMap.get(houseAgeStatPo.getAreaNo());
  1085. secondUnitPo.update(houseAgeStatPo);
  1086. }
  1087. for (BuildingIdleStatPo value : secondUnitPoMap.values()) {
  1088. firstUnitPo.update(value);
  1089. }
  1090. return firstUnitPo;
  1091. }
  1092. public void buildingIdleStatExport(BuildingIdleStatDto.BuildingIdleStatMapDTO dto) {
  1093. ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder
  1094. .getRequestAttributes();
  1095. if (servletRequestAttributes == null) {
  1096. return;
  1097. }
  1098. HttpServletResponse response = servletRequestAttributes.getResponse();
  1099. if (response == null) {
  1100. return;
  1101. }
  1102. String filename = "房屋管理_闲置管理"
  1103. + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
  1104. response.setHeader("Content-Disposition", "attachment;filename=" + URLEncodeUtil.encode(filename));
  1105. response.setContentType("application/octet-stream");
  1106. try (SXSSFWorkbook wb = new SXSSFWorkbook()) {
  1107. writeBuildingIdleStat(new BuildingIdleStatDto(dto), wb);
  1108. wb.write(response.getOutputStream());
  1109. } catch (Exception e) {
  1110. log.error(e.getMessage(), e);
  1111. }
  1112. }
  1113. /**
  1114. * 写闲置管理文件
  1115. */
  1116. private void writeBuildingIdleStat(BuildingIdleStatDto dto, SXSSFWorkbook wb) {
  1117. BuildingIdleStatPo firstPo = getBuildingIdleStatPos(dto);
  1118. DataFormat dataFormat = wb.createDataFormat();
  1119. // 整数样式
  1120. CellStyle integerCellStyle = wb.createCellStyle();
  1121. integerCellStyle.setDataFormat(dataFormat.getFormat("#,##0"));
  1122. integerCellStyle.setAlignment(HorizontalAlignment.RIGHT);
  1123. // 数字样式
  1124. CellStyle numberCellStyle = wb.createCellStyle();
  1125. numberCellStyle.setDataFormat(dataFormat.getFormat("#,##0.00"));
  1126. numberCellStyle.setAlignment(HorizontalAlignment.RIGHT);
  1127. // 默认样式
  1128. CellStyle baseCellStyle = wb.createCellStyle();
  1129. baseCellStyle.setAlignment(HorizontalAlignment.CENTER);
  1130. baseCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  1131. // 百分比样式
  1132. CellStyle percentCellStyle = wb.createCellStyle();
  1133. percentCellStyle.setDataFormat(dataFormat.getFormat("0.00%"));
  1134. percentCellStyle.setAlignment(HorizontalAlignment.RIGHT);
  1135. SXSSFSheet sheet = wb.createSheet();
  1136. AtomicInteger rowIndex = new AtomicInteger(0);
  1137. // 表头
  1138. Row headerRow = sheet.createRow(rowIndex.getAndIncrement());
  1139. List<String> headers = Stream.of("资产所属单位(一级)", "资产所属单位(二级)", "资产所属单位(三级)",
  1140. "建筑面积(㎡)", "闲置建筑数量", "建筑面积-自用(㎡)","建筑面积-出租(㎡)", "建筑面积-闲置(㎡)", "闲置率(%)").toList();
  1141. int headerLength = headers.size();
  1142. for (int i = 0; i < headerLength; i++) {
  1143. Cell cell = headerRow.createCell(i);
  1144. cell.setCellValue(headers.get(i));
  1145. cell.setCellStyle(baseCellStyle);
  1146. // 根据内容长度设置列宽
  1147. int columnWidth = headers.get(i).length() * 256 * 2 + 256;
  1148. sheet.setColumnWidth(i, columnWidth);
  1149. }
  1150. if (firstPo == null) {
  1151. return;
  1152. }
  1153. // 数据
  1154. AtomicInteger columnIndex1 = new AtomicInteger(0);
  1155. // 一级单位统计
  1156. Row row1 = sheet.createRow(rowIndex.getAndIncrement());
  1157. // 资产所属单位(一级)
  1158. Cell firstUnitCell1 = row1.createCell(columnIndex1.getAndIncrement());
  1159. if (firstPo.getAreaName() != null) {
  1160. firstUnitCell1.setCellValue(firstPo.getAreaName());
  1161. }
  1162. // 二级单位
  1163. Cell areaNameCell1 = row1.createCell(columnIndex1.getAndIncrement());
  1164. // if (firstPo.getAreaName() != null) {
  1165. // areaNameCell1.setCellValue(firstPo.getAreaName());
  1166. // }
  1167. // 三级单位
  1168. Cell cityNameCell1 = row1.createCell(columnIndex1.getAndIncrement());
  1169. // if (firstPo.getCityName() != null) {
  1170. // cityNameCell1.setCellValue(firstPo.getCityName());
  1171. // }
  1172. // 建筑面积(㎡)
  1173. Cell buildingAreaSumCell1 = row1.createCell(columnIndex1.getAndIncrement());
  1174. if (firstPo.getBuildingAreaSum() != null) {
  1175. buildingAreaSumCell1.setCellValue(firstPo.getBuildingAreaSum().doubleValue());
  1176. }
  1177. buildingAreaSumCell1.setCellStyle(numberCellStyle);
  1178. // 闲置建筑数量
  1179. Cell idleCountCell1 = row1.createCell(columnIndex1.getAndIncrement());
  1180. if (firstPo.getIdleCount() != null) {
  1181. idleCountCell1.setCellValue(firstPo.getIdleCount());
  1182. }
  1183. idleCountCell1.setCellStyle(integerCellStyle);
  1184. // 建筑面积-自用(㎡)
  1185. Cell buildingAreaSelfUseSumCell1 = row1.createCell(columnIndex1.getAndIncrement());
  1186. if (firstPo.getBuildingAreaSelfUseSum() != null) {
  1187. buildingAreaSelfUseSumCell1.setCellValue(firstPo.getBuildingAreaSelfUseSum().doubleValue());
  1188. }
  1189. buildingAreaSelfUseSumCell1.setCellStyle(numberCellStyle);
  1190. // 建筑面积-出租(㎡)
  1191. Cell buildingAreaRentSumCell1 = row1.createCell(columnIndex1.getAndIncrement());
  1192. if (firstPo.getBuildingAreaRentSum() != null) {
  1193. buildingAreaRentSumCell1.setCellValue(firstPo.getBuildingAreaRentSum().doubleValue());
  1194. }
  1195. buildingAreaRentSumCell1.setCellStyle(numberCellStyle);
  1196. // 建筑面积-闲置(㎡)
  1197. Cell buildingAreaIdleSumCell1 = row1.createCell(columnIndex1.getAndIncrement());
  1198. if (firstPo.getBuildingAreaIdleSum() != null) {
  1199. buildingAreaIdleSumCell1.setCellValue(firstPo.getBuildingAreaIdleSum().doubleValue());
  1200. }
  1201. buildingAreaIdleSumCell1.setCellStyle(numberCellStyle);
  1202. // 闲置率
  1203. Cell idlePercentCell1 = row1.createCell(columnIndex1.getAndIncrement());
  1204. if (firstPo.getIdlePercent() != null) {
  1205. idlePercentCell1.setCellValue(firstPo.getIdlePercent().doubleValue());
  1206. }
  1207. idlePercentCell1.setCellStyle(percentCellStyle);
  1208. // 二级单位统计
  1209. for (BuildingIdleStatPo secondPo : firstPo.getChildren()) {
  1210. AtomicInteger columnIndex2 = new AtomicInteger(0);
  1211. // 一级单位统计
  1212. Row row2 = sheet.createRow(rowIndex.getAndIncrement());
  1213. // 资产所属单位(一级)
  1214. Cell firstUnitCell2 = row2.createCell(columnIndex2.getAndIncrement());
  1215. // if (secondPo.getAreaName() != null) {
  1216. // firstUnitCell2.setCellValue(secondPo.getAreaName());
  1217. // }
  1218. // 二级单位
  1219. Cell areaNameCell2 = row2.createCell(columnIndex2.getAndIncrement());
  1220. if (secondPo.getAreaName() != null) {
  1221. areaNameCell2.setCellValue(secondPo.getAreaName());
  1222. }
  1223. // 三级单位
  1224. Cell cityNameCell2 = row2.createCell(columnIndex2.getAndIncrement());
  1225. // if (secondPo.getCityName() != null) {
  1226. // cityNameCell2.setCellValue(secondPo.getCityName());
  1227. // }
  1228. // 建筑面积(㎡)
  1229. Cell buildingAreaSumCell2 = row2.createCell(columnIndex2.getAndIncrement());
  1230. if (secondPo.getBuildingAreaSum() != null) {
  1231. buildingAreaSumCell2.setCellValue(secondPo.getBuildingAreaSum().doubleValue());
  1232. }
  1233. buildingAreaSumCell2.setCellStyle(numberCellStyle);
  1234. // 闲置建筑数量
  1235. Cell idleCountCell2 = row2.createCell(columnIndex2.getAndIncrement());
  1236. if (secondPo.getIdleCount() != null) {
  1237. idleCountCell2.setCellValue(secondPo.getIdleCount());
  1238. }
  1239. idleCountCell2.setCellStyle(integerCellStyle);
  1240. // 建筑面积-自用(㎡)
  1241. Cell buildingAreaSelfUseSumCell2 = row2.createCell(columnIndex2.getAndIncrement());
  1242. if (secondPo.getBuildingAreaSelfUseSum() != null) {
  1243. buildingAreaSelfUseSumCell2.setCellValue(secondPo.getBuildingAreaSelfUseSum().doubleValue());
  1244. }
  1245. buildingAreaSelfUseSumCell2.setCellStyle(numberCellStyle);
  1246. // 建筑面积-出租(㎡)
  1247. Cell buildingAreaRentSumCell2 = row2.createCell(columnIndex2.getAndIncrement());
  1248. if (secondPo.getBuildingAreaRentSum() != null) {
  1249. buildingAreaRentSumCell2.setCellValue(secondPo.getBuildingAreaRentSum().doubleValue());
  1250. }
  1251. buildingAreaRentSumCell2.setCellStyle(numberCellStyle);
  1252. // 建筑面积-闲置(㎡)
  1253. Cell buildingAreaIdleSumCell2 = row2.createCell(columnIndex2.getAndIncrement());
  1254. if (secondPo.getBuildingAreaIdleSum() != null) {
  1255. buildingAreaIdleSumCell2.setCellValue(secondPo.getBuildingAreaIdleSum().doubleValue());
  1256. }
  1257. buildingAreaIdleSumCell2.setCellStyle(numberCellStyle);
  1258. // 闲置率
  1259. Cell idlePercentCell2 = row2.createCell(columnIndex2.getAndIncrement());
  1260. if (secondPo.getIdlePercent() != null) {
  1261. idlePercentCell2.setCellValue(secondPo.getIdlePercent().doubleValue());
  1262. }
  1263. idlePercentCell2.setCellStyle(percentCellStyle);
  1264. // 三级单位统计
  1265. for (BuildingIdleStatPo thirdPo : secondPo.getChildren()) {
  1266. AtomicInteger columnIndex3 = new AtomicInteger(0);
  1267. Row row3 = sheet.createRow(rowIndex.getAndIncrement());
  1268. // 资产所属单位(一级)
  1269. Cell firstUnitCell3 = row3.createCell(columnIndex3.getAndIncrement());
  1270. // if (thirdPo.getAreaName() != null) {
  1271. // firstUnitCell3.setCellValue(thirdPo.getAreaName());
  1272. // }
  1273. // 二级单位
  1274. Cell areaNameCell3 = row3.createCell(columnIndex3.getAndIncrement());
  1275. // if (thirdPo.getAreaName() != null) {
  1276. // areaNameCell3.setCellValue(thirdPo.getAreaName());
  1277. // }
  1278. // 三级单位
  1279. Cell cityNameCell3 = row3.createCell(columnIndex3.getAndIncrement());
  1280. if (thirdPo.getCityName() != null) {
  1281. cityNameCell3.setCellValue(thirdPo.getCityName());
  1282. }
  1283. // 建筑面积(㎡)
  1284. Cell buildingAreaSumCell3 = row3.createCell(columnIndex3.getAndIncrement());
  1285. if (thirdPo.getBuildingAreaSum() != null) {
  1286. buildingAreaSumCell3.setCellValue(thirdPo.getBuildingAreaSum().doubleValue());
  1287. }
  1288. buildingAreaSumCell3.setCellStyle(numberCellStyle);
  1289. // 闲置建筑数量
  1290. Cell idleCountCell3 = row3.createCell(columnIndex3.getAndIncrement());
  1291. if (thirdPo.getIdleCount() != null) {
  1292. idleCountCell3.setCellValue(thirdPo.getIdleCount());
  1293. }
  1294. idleCountCell3.setCellStyle(integerCellStyle);
  1295. // 建筑面积-自用(㎡)
  1296. Cell buildingAreaSelfUseSumCell3 = row3.createCell(columnIndex3.getAndIncrement());
  1297. if (thirdPo.getBuildingAreaSelfUseSum() != null) {
  1298. buildingAreaSelfUseSumCell3.setCellValue(thirdPo.getBuildingAreaSelfUseSum().doubleValue());
  1299. }
  1300. buildingAreaSelfUseSumCell3.setCellStyle(numberCellStyle);
  1301. // 建筑面积-出租(㎡)
  1302. Cell buildingAreaRentSumCell3 = row3.createCell(columnIndex3.getAndIncrement());
  1303. if (thirdPo.getBuildingAreaRentSum() != null) {
  1304. buildingAreaRentSumCell3.setCellValue(thirdPo.getBuildingAreaRentSum().doubleValue());
  1305. }
  1306. buildingAreaRentSumCell3.setCellStyle(numberCellStyle);
  1307. // 建筑面积-闲置(㎡)
  1308. Cell buildingAreaIdleSumCell3 = row3.createCell(columnIndex3.getAndIncrement());
  1309. if (thirdPo.getBuildingAreaIdleSum() != null) {
  1310. buildingAreaIdleSumCell3.setCellValue(thirdPo.getBuildingAreaIdleSum().doubleValue());
  1311. }
  1312. buildingAreaIdleSumCell3.setCellStyle(numberCellStyle);
  1313. // 闲置率
  1314. Cell idlePercentCell3 = row3.createCell(columnIndex3.getAndIncrement());
  1315. if (thirdPo.getIdlePercent() != null) {
  1316. idlePercentCell3.setCellValue(thirdPo.getIdlePercent().doubleValue());
  1317. }
  1318. idlePercentCell3.setCellStyle(percentCellStyle);
  1319. }
  1320. }
  1321. }
  1322. }