Browse Source

feat: 房屋空置1000平米增加局址编号、局址别名字段

weijianghai 11 months ago
parent
commit
566f24afc2
1 changed files with 111 additions and 105 deletions
  1. 111 105
      src/main/java/com/example/service/house/HouseWzBuildManageDetailsService.java

+ 111 - 105
src/main/java/com/example/service/house/HouseWzBuildManageDetailsService.java

@@ -18,7 +18,6 @@ import org.apache.poi.ss.usermodel.DataFormat;
 import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.VerticalAlignment;
-import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.xssf.streaming.SXSSFSheet;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.springframework.stereotype.Service;
@@ -116,11 +115,11 @@ public class HouseWzBuildManageDetailsService {
         percentCellStyle.setDataFormat(dataFormat.getFormat("0.00%"));
         percentCellStyle.setAlignment(HorizontalAlignment.RIGHT);
         SXSSFSheet sheet = wb.createSheet();
-        AtomicInteger columnIndex = new AtomicInteger(0);
+        AtomicInteger rowIndex = new AtomicInteger(0);
         // 表头
-        Row headerRow = sheet.createRow(columnIndex.getAndIncrement());
-        List<String> headers = Stream.of("资产所属单位(一级)", "资产所属单位(二级)", "资产所属单位(三级)", "建筑别名",
-                "地段", "建筑面积(㎡)","建筑面积-出租(㎡)", "建筑面积-闲置(㎡)", "上级局址名称", "建筑面积-自用(㎡)",
+        Row headerRow = sheet.createRow(rowIndex.getAndIncrement());
+        List<String> headers = Stream.of("资产所属单位(一级)", "资产所属单位(二级)", "资产所属单位(三级)", "局址编号",
+                "局址别名", "建筑别名", "地段", "建筑面积(㎡)","建筑面积-出租(㎡)", "建筑面积-闲置(㎡)", "建筑面积-自用(㎡)",
                 "建筑面积-不可使用(㎡)", "上级土地名称", "得房率", "房屋来源", "取得日期", "房龄开始年份", "投资主体", "管理层级",
                 "房屋结构", "楼层总数", "是否临街", "是否有院落", "整栋是否独有", "是否有房产证", "无房产证原因", "未关联资产",
                 "资产编号", "资产标签号", "使用状态", "建筑用途", "权属状态", "建筑占地面积(㎡)", "使用面积(㎡)",
@@ -137,228 +136,235 @@ public class HouseWzBuildManageDetailsService {
         }
         // 数据
         for (HouseBuildingPo houseBuildingPo : list) {
-            Row row = sheet.createRow(columnIndex.getAndIncrement());
+            AtomicInteger columnIndex = new AtomicInteger(0);
+            Row row = sheet.createRow(rowIndex.getAndIncrement());
             // 资产所属单位(一级)
-            Cell a = row.createCell(CellReference.convertColStringToIndex("a"));
+            Cell firstUnitCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getFirstUnit() != null) {
-                a.setCellValue(houseBuildingPo.getFirstUnit());
+                firstUnitCell.setCellValue(houseBuildingPo.getFirstUnit());
             }
             // 二级单位
-            Cell b = row.createCell(CellReference.convertColStringToIndex("b"));
+            Cell areaNameCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getAreaName() != null) {
-                b.setCellValue(houseBuildingPo.getAreaName());
+                areaNameCell.setCellValue(houseBuildingPo.getAreaName());
             }
             // 三级单位
-            Cell c = row.createCell(CellReference.convertColStringToIndex("c"));
+            Cell cityNameCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getCityName() != null) {
-                c.setCellValue(houseBuildingPo.getCityName());
+                cityNameCell.setCellValue(houseBuildingPo.getCityName());
+            }
+            // 局址编号
+            Cell siteNumCell = row.createCell(columnIndex.getAndIncrement());
+            if (houseBuildingPo.getSiteName() != null) {
+                siteNumCell.setCellValue(houseBuildingPo.getSiteNum());
+            }
+            // 局址别名
+            Cell siteNameCell = row.createCell(columnIndex.getAndIncrement());
+            if (houseBuildingPo.getSiteName() != null) {
+                siteNameCell.setCellValue(houseBuildingPo.getSiteName());
             }
             // 建筑别名
-            Cell d = row.createCell(CellReference.convertColStringToIndex("d"));
+            Cell buildingNameCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getBuildingName() != null) {
-                d.setCellValue(houseBuildingPo.getBuildingName());
+                buildingNameCell.setCellValue(houseBuildingPo.getBuildingName());
             }
             // 地段
-            Cell e = row.createCell(CellReference.convertColStringToIndex("e"));
+            Cell areaSectorCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getAreaSector() != null) {
-                e.setCellValue(houseBuildingPo.getAreaSector());
+                areaSectorCell.setCellValue(houseBuildingPo.getAreaSector());
             }
             // 建筑面积(㎡)
-            Cell f = row.createCell(CellReference.convertColStringToIndex("f"));
+            Cell buildingAreaCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getBuildingArea() != null) {
-                f.setCellValue(houseBuildingPo.getBuildingArea().doubleValue());
+                buildingAreaCell.setCellValue(houseBuildingPo.getBuildingArea().doubleValue());
             }
-            f.setCellStyle(numberCellStyle);
+            buildingAreaCell.setCellStyle(numberCellStyle);
             // 建筑面积-出租(㎡)
-            Cell g = row.createCell(CellReference.convertColStringToIndex("g"));
+            Cell buildingAreaRentCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getBuildingAreaRent() != null) {
-                g.setCellValue(houseBuildingPo.getBuildingAreaRent().doubleValue());
+                buildingAreaRentCell.setCellValue(houseBuildingPo.getBuildingAreaRent().doubleValue());
             }
-            g.setCellStyle(numberCellStyle);
+            buildingAreaRentCell.setCellStyle(numberCellStyle);
             // 建筑面积-闲置(㎡)
-            Cell h = row.createCell(CellReference.convertColStringToIndex("h"));
+            Cell buildingAreaIdleCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getBuildingAreaIdle() != null) {
-                h.setCellValue(houseBuildingPo.getBuildingAreaIdle().doubleValue());
-            }
-            h.setCellStyle(numberCellStyle);
-            // 上级局址名称
-            Cell i = row.createCell(CellReference.convertColStringToIndex("i"));
-            if (houseBuildingPo.getSiteName() != null) {
-                i.setCellValue(houseBuildingPo.getSiteName());
+                buildingAreaIdleCell.setCellValue(houseBuildingPo.getBuildingAreaIdle().doubleValue());
             }
+            buildingAreaIdleCell.setCellStyle(numberCellStyle);
             // 建筑面积-自用(㎡)
-            Cell j = row.createCell(CellReference.convertColStringToIndex("j"));
+            Cell buildingAreaSelfUseCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getBuildingAreaSelfUse() != null) {
-                j.setCellValue(houseBuildingPo.getBuildingAreaSelfUse().doubleValue());
+                buildingAreaSelfUseCell.setCellValue(houseBuildingPo.getBuildingAreaSelfUse().doubleValue());
             }
-            j.setCellStyle(numberCellStyle);
+            buildingAreaSelfUseCell.setCellStyle(numberCellStyle);
             // 建筑面积-不可使用(㎡)
-            Cell k = row.createCell(CellReference.convertColStringToIndex("k"));
+            Cell buildingAreaUnusableCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getBuildingAreaUnusable() != null) {
-                k.setCellValue(houseBuildingPo.getBuildingAreaUnusable().doubleValue());
+                buildingAreaUnusableCell.setCellValue(houseBuildingPo.getBuildingAreaUnusable().doubleValue());
             }
-            k.setCellStyle(numberCellStyle);
+            buildingAreaUnusableCell.setCellStyle(numberCellStyle);
             // 上级土地名称
-            Cell l = row.createCell(CellReference.convertColStringToIndex("l"));
+            Cell landNameCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getLandName() != null) {
-                l.setCellValue(houseBuildingPo.getLandName());
+                landNameCell.setCellValue(houseBuildingPo.getLandName());
             }
             // 得房率
-            Cell m = row.createCell(CellReference.convertColStringToIndex("m"));
+            Cell housingAcquisitionRateCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getHousingAcquisitionRate() != null) {
-                m.setCellValue(houseBuildingPo.getHousingAcquisitionRate().doubleValue());
+                housingAcquisitionRateCell.setCellValue(houseBuildingPo.getHousingAcquisitionRate().doubleValue());
             }
-            m.setCellStyle(percentCellStyle);
+            housingAcquisitionRateCell.setCellStyle(percentCellStyle);
             // 房屋来源
-            Cell n = row.createCell(CellReference.convertColStringToIndex("n"));
+            Cell housingSourceCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getHousingSource() != null) {
-                n.setCellValue(houseBuildingPo.getHousingSource());
+                housingSourceCell.setCellValue(houseBuildingPo.getHousingSource());
             }
             // 取得日期
-            Cell o = row.createCell(CellReference.convertColStringToIndex("o"));
+            Cell acquisitionDateCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getAcquisitionDate() != null) {
-                o.setCellValue(houseBuildingPo.getAcquisitionDate());
+                acquisitionDateCell.setCellValue(houseBuildingPo.getAcquisitionDate());
             }
             // 房龄开始年份
-            Cell p = row.createCell(CellReference.convertColStringToIndex("p"));
+            Cell houseYearBeganCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getHouseYearBegan() != null) {
-                p.setCellValue(houseBuildingPo.getHouseYearBegan());
+                houseYearBeganCell.setCellValue(houseBuildingPo.getHouseYearBegan());
             }
             // 投资主体
-            Cell q = row.createCell(CellReference.convertColStringToIndex("q"));
+            Cell investorCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getInvestor() != null) {
-                q.setCellValue(houseBuildingPo.getInvestor());
+                investorCell.setCellValue(houseBuildingPo.getInvestor());
             }
             // 管理层级
-            Cell r = row.createCell(CellReference.convertColStringToIndex("r"));
+            Cell managementLevelCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getManagementLevel() != null) {
-                r.setCellValue(houseBuildingPo.getManagementLevel());
+                managementLevelCell.setCellValue(houseBuildingPo.getManagementLevel());
             }
             // 房屋结构
-            Cell s = row.createCell(CellReference.convertColStringToIndex("s"));
+            Cell buildingStructureCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getBuildingStructure() != null) {
-                s.setCellValue(houseBuildingPo.getBuildingStructure());
+                buildingStructureCell.setCellValue(houseBuildingPo.getBuildingStructure());
             }
             // 楼层总数
-            Cell t = row.createCell(CellReference.convertColStringToIndex("t"));
+            Cell totalFloorsCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getTotalFloors() != null) {
-                t.setCellValue(houseBuildingPo.getTotalFloors());
+                totalFloorsCell.setCellValue(houseBuildingPo.getTotalFloors());
             }
             // 是否临街
-            Cell u = row.createCell(CellReference.convertColStringToIndex("u"));
+            Cell frontageCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getFrontage() != null) {
-                u.setCellValue(houseBuildingPo.getFrontage());
+                frontageCell.setCellValue(houseBuildingPo.getFrontage());
             }
             // 是否有院落
-            Cell v = row.createCell(CellReference.convertColStringToIndex("v"));
+            Cell courtyardCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getCourtyard() != null) {
-                v.setCellValue(houseBuildingPo.getCourtyard());
+                courtyardCell.setCellValue(houseBuildingPo.getCourtyard());
             }
             // 整栋是否独有
-            Cell w = row.createCell(CellReference.convertColStringToIndex("w"));
+            Cell wholeBuildingCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getWholeBuilding() != null) {
-                w.setCellValue(houseBuildingPo.getWholeBuilding());
+                wholeBuildingCell.setCellValue(houseBuildingPo.getWholeBuilding());
             }
             // 是否有房产证
-            Cell x = row.createCell(CellReference.convertColStringToIndex("x"));
+            Cell propertyOwnershipCertificateCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getPropertyOwnershipCertificate() != null) {
-                x.setCellValue(houseBuildingPo.getPropertyOwnershipCertificate());
+                propertyOwnershipCertificateCell.setCellValue(houseBuildingPo.getPropertyOwnershipCertificate());
             }
             // 无房产证原因
-            Cell y = row.createCell(CellReference.convertColStringToIndex("y"));
+            Cell noPropertyOwnershipCertificateReasonCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getNoPropertyOwnershipCertificateReason() != null) {
-                y.setCellValue(houseBuildingPo.getNoPropertyOwnershipCertificateReason());
+                noPropertyOwnershipCertificateReasonCell.setCellValue(
+                        houseBuildingPo.getNoPropertyOwnershipCertificateReason());
             }
             // 未关联资产
-            Cell z = row.createCell(CellReference.convertColStringToIndex("z"));
+            Cell unrelatedAssetsCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getUnrelatedAssets() != null) {
-                z.setCellValue(houseBuildingPo.getUnrelatedAssets());
+                unrelatedAssetsCell.setCellValue(houseBuildingPo.getUnrelatedAssets());
             }
             // 资产编号
-            Cell aa = row.createCell(CellReference.convertColStringToIndex("aa"));
+            Cell assetsNumCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getAssetsNum() != null) {
-                aa.setCellValue(houseBuildingPo.getAssetsNum());
+                assetsNumCell.setCellValue(houseBuildingPo.getAssetsNum());
             }
             // 资产标签号
-            Cell ab = row.createCell(CellReference.convertColStringToIndex("ab"));
+            Cell assetsTagNumCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getAssetsTagNum() != null) {
-                ab.setCellValue(houseBuildingPo.getAssetsTagNum());
+                assetsTagNumCell.setCellValue(houseBuildingPo.getAssetsTagNum());
             }
             // 使用状态
-            Cell ac = row.createCell(CellReference.convertColStringToIndex("ac"));
+            Cell usageStatusCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getUsageStatus() != null) {
-                ac.setCellValue(houseBuildingPo.getUsageStatus());
+                usageStatusCell.setCellValue(houseBuildingPo.getUsageStatus());
             }
             // 建筑用途
-            Cell ad = row.createCell(CellReference.convertColStringToIndex("ad"));
+            Cell buildingUseCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getBuildingUse() != null) {
-                ad.setCellValue(houseBuildingPo.getBuildingUse());
+                buildingUseCell.setCellValue(houseBuildingPo.getBuildingUse());
             }
             // 权属状态
-            Cell ae = row.createCell(CellReference.convertColStringToIndex("ae"));
+            Cell ownershipStatusCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getOwnershipStatus() != null) {
-                ae.setCellValue(houseBuildingPo.getOwnershipStatus());
+                ownershipStatusCell.setCellValue(houseBuildingPo.getOwnershipStatus());
             }
             // 建筑占地面积(㎡)
-            Cell af = row.createCell(CellReference.convertColStringToIndex("af"));
+            Cell floorAreaCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getFloorArea() != null) {
-                af.setCellValue(houseBuildingPo.getFloorArea().doubleValue());
+                floorAreaCell.setCellValue(houseBuildingPo.getFloorArea().doubleValue());
             }
-            af.setCellStyle(numberCellStyle);
+            floorAreaCell.setCellStyle(numberCellStyle);
             // 使用面积(㎡)
-            Cell ag = row.createCell(CellReference.convertColStringToIndex("ag"));
+            Cell usableAreaCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getUsableArea() != null) {
-                ag.setCellValue(houseBuildingPo.getUsableArea().doubleValue());
+                usableAreaCell.setCellValue(houseBuildingPo.getUsableArea().doubleValue());
             }
-            ag.setCellStyle(numberCellStyle);
+            usableAreaCell.setCellStyle(numberCellStyle);
             // 使用面积-自用(㎡)
-            Cell ah = row.createCell(CellReference.convertColStringToIndex("ah"));
+            Cell usableAreaSelfUseCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getUsableAreaSelfUse() != null) {
-                ah.setCellValue(houseBuildingPo.getUsableAreaSelfUse().doubleValue());
+                usableAreaSelfUseCell.setCellValue(houseBuildingPo.getUsableAreaSelfUse().doubleValue());
             }
-            ah.setCellStyle(numberCellStyle);
+            usableAreaSelfUseCell.setCellStyle(numberCellStyle);
             // 使用面积-出租(㎡)
-            Cell ai = row.createCell(CellReference.convertColStringToIndex("ai"));
+            Cell usableAreaRentCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getUsableAreaRent() != null) {
-                ai.setCellValue(houseBuildingPo.getUsableAreaRent().doubleValue());
+                usableAreaRentCell.setCellValue(houseBuildingPo.getUsableAreaRent().doubleValue());
             }
-            ai.setCellStyle(numberCellStyle);
+            usableAreaRentCell.setCellStyle(numberCellStyle);
             // 使用面积-闲置(㎡)
-            Cell aj = row.createCell(CellReference.convertColStringToIndex("aj"));
+            Cell usableAreaIdleCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getUsableAreaIdle() != null) {
-                aj.setCellValue(houseBuildingPo.getUsableAreaIdle().doubleValue());
+                usableAreaIdleCell.setCellValue(houseBuildingPo.getUsableAreaIdle().doubleValue());
             }
-            aj.setCellStyle(numberCellStyle);
+            usableAreaIdleCell.setCellStyle(numberCellStyle);
             // 使用面积-不可使用(㎡)
-            Cell ak = row.createCell(CellReference.convertColStringToIndex("ak"));
+            Cell usableAreaUnusableCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getUsableAreaUnusable() != null) {
-                ak.setCellValue(houseBuildingPo.getUsableAreaUnusable().doubleValue());
+                usableAreaUnusableCell.setCellValue(houseBuildingPo.getUsableAreaUnusable().doubleValue());
             }
-            ak.setCellStyle(numberCellStyle);
+            usableAreaUnusableCell.setCellStyle(numberCellStyle);
             // 楼长姓名
-            Cell al = row.createCell(CellReference.convertColStringToIndex("al"));
+            Cell communityAssistantNameCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getCommunityAssistantName() != null) {
-                al.setCellValue(houseBuildingPo.getCommunityAssistantName());
+                communityAssistantNameCell.setCellValue(houseBuildingPo.getCommunityAssistantName());
             }
             // 楼长所在单位
-            Cell am = row.createCell(CellReference.convertColStringToIndex("am"));
+            Cell communityAssistantUnitCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getCommunityAssistantUnit() != null) {
-                am.setCellValue(houseBuildingPo.getCommunityAssistantUnit());
+                communityAssistantUnitCell.setCellValue(houseBuildingPo.getCommunityAssistantUnit());
             }
             // 经度
-            Cell an = row.createCell(CellReference.convertColStringToIndex("an"));
+            Cell lngJtCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getLngJt() != null) {
-                an.setCellValue(houseBuildingPo.getLngJt().toString());
+                lngJtCell.setCellValue(houseBuildingPo.getLngJt().toString());
             }
             // 纬度
-            Cell ao = row.createCell(CellReference.convertColStringToIndex("ao"));
+            Cell latJtCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getLatJt() != null) {
-                ao.setCellValue(houseBuildingPo.getLatJt().toString());
+                latJtCell.setCellValue(houseBuildingPo.getLatJt().toString());
             }
             // 实际产权人
-            Cell ap = row.createCell(CellReference.convertColStringToIndex("ap"));
+            Cell propertyOwnerCell = row.createCell(columnIndex.getAndIncrement());
             if (houseBuildingPo.getPropertyOwner() != null) {
-                ap.setCellValue(houseBuildingPo.getPropertyOwner());
+                propertyOwnerCell.setCellValue(houseBuildingPo.getPropertyOwner());
             }
         }
     }