|
@@ -1,25 +1,60 @@
|
|
package com.example.service.house;
|
|
package com.example.service.house;
|
|
|
|
|
|
|
|
+import cn.hutool.core.net.URLEncodeUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.example.common.PageVo;
|
|
import com.example.common.PageVo;
|
|
import com.example.common.Rsp;
|
|
import com.example.common.Rsp;
|
|
import com.example.dao.WzOtnAreaDao;
|
|
import com.example.dao.WzOtnAreaDao;
|
|
|
|
+import com.example.dao.house.HouseLandDao;
|
|
|
|
+import com.example.entity.house.HouseLandPo;
|
|
import com.example.entity.house.HouseSitePo;
|
|
import com.example.entity.house.HouseSitePo;
|
|
|
|
+import com.example.entity.house.LandIdleStatPo;
|
|
|
|
+import com.example.enums.ListLandOrderEnum;
|
|
|
|
+import com.example.enums.OrderEnum;
|
|
|
|
+import com.example.pojo.bo.LandIdleStatBo;
|
|
import com.example.pojo.bo.ListHouseSiteBo;
|
|
import com.example.pojo.bo.ListHouseSiteBo;
|
|
|
|
+import com.example.pojo.bo.ListLandBo;
|
|
|
|
+import com.example.pojo.dto.LandIdleStatDto;
|
|
|
|
+import com.example.pojo.dto.ListLandDto;
|
|
import com.example.pojo.dto.ListSiteNameDto;
|
|
import com.example.pojo.dto.ListSiteNameDto;
|
|
import com.example.pojo.dto.ListSiteNumDto;
|
|
import com.example.pojo.dto.ListSiteNumDto;
|
|
|
|
+import com.example.pojo.vo.LandIdleStatVo;
|
|
|
|
+import com.example.pojo.vo.ListLandVo;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
+import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
+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.xssf.streaming.SXSSFSheet;
|
|
|
|
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
+import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
+import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.LinkedHashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
public class HouseWzLandManageDetailsService {
|
|
public class HouseWzLandManageDetailsService {
|
|
private final WzOtnAreaDao wzOtnAreaDao;
|
|
private final WzOtnAreaDao wzOtnAreaDao;
|
|
|
|
+ private final HouseLandDao houseLandDao;
|
|
|
|
|
|
- public HouseWzLandManageDetailsService(WzOtnAreaDao wzOtnAreaDao) {
|
|
|
|
|
|
+ public HouseWzLandManageDetailsService(WzOtnAreaDao wzOtnAreaDao, HouseLandDao houseLandDao) {
|
|
this.wzOtnAreaDao = wzOtnAreaDao;
|
|
this.wzOtnAreaDao = wzOtnAreaDao;
|
|
|
|
+ this.houseLandDao = houseLandDao;
|
|
}
|
|
}
|
|
|
|
|
|
public Rsp<PageVo<String>> listSiteName(ListSiteNameDto dto) {
|
|
public Rsp<PageVo<String>> listSiteName(ListSiteNameDto dto) {
|
|
@@ -53,4 +88,554 @@ public class HouseWzLandManageDetailsService {
|
|
PageVo<String> pageVo = new PageVo<>(vos, page);
|
|
PageVo<String> pageVo = new PageVo<>(vos, page);
|
|
return Rsp.ok(pageVo);
|
|
return Rsp.ok(pageVo);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public Rsp<PageVo<LandIdleStatVo>> landIdleStat(LandIdleStatDto dto) {
|
|
|
|
+ LandIdleStatPo pos = getLandIdleStatPos(dto);
|
|
|
|
+ if (pos == null) {
|
|
|
|
+ return Rsp.ok();
|
|
|
|
+ }
|
|
|
|
+ LandIdleStatVo vo = new LandIdleStatVo(pos, false);
|
|
|
|
+ PageVo<LandIdleStatVo> pageVo = new PageVo<>(Collections.singletonList(vo));
|
|
|
|
+ return Rsp.ok(pageVo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private LandIdleStatPo getLandIdleStatPos(LandIdleStatDto dto) {
|
|
|
|
+ LandIdleStatBo bo = new LandIdleStatBo();
|
|
|
|
+ if (dto.getMap() != null && dto.getMap().getStatisticalMonth() != null) {
|
|
|
|
+ bo.setYearMonth(dto.getMap().getStatisticalMonth());
|
|
|
|
+ }
|
|
|
|
+ if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCity()) && !"全省".equals(dto.getMap().getCity())) {
|
|
|
|
+ bo.setAreaNo(dto.getMap().getCity());
|
|
|
|
+ }
|
|
|
|
+ if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCounty())) {
|
|
|
|
+ bo.setCityNo(dto.getMap().getCounty());
|
|
|
|
+ }
|
|
|
|
+ // 查询三级单位统计
|
|
|
|
+ List<LandIdleStatPo> landIdleStatPos = houseLandDao.landIdleStat(bo);
|
|
|
|
+ if (CollectionUtils.isEmpty(landIdleStatPos)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ // 一级单位统计
|
|
|
|
+ LandIdleStatPo firstUnitPo = new LandIdleStatPo();
|
|
|
|
+ firstUnitPo.setAreaName("全省");
|
|
|
|
+ firstUnitPo.setCityName("全省");
|
|
|
|
+ LinkedHashMap<String, LandIdleStatPo> secondUnitPoMap = new LinkedHashMap<>();
|
|
|
|
+ // 二级单位统计
|
|
|
|
+ for (LandIdleStatPo houseAgeStatPo : landIdleStatPos) {
|
|
|
|
+ secondUnitPoMap.putIfAbsent(houseAgeStatPo.getAreaNo(),
|
|
|
|
+ new LandIdleStatPo(houseAgeStatPo.getAreaNo(), houseAgeStatPo.getAreaName()));
|
|
|
|
+ LandIdleStatPo secondUnitPo = secondUnitPoMap.get(houseAgeStatPo.getAreaNo());
|
|
|
|
+ secondUnitPo.update(houseAgeStatPo);
|
|
|
|
+ }
|
|
|
|
+ for (LandIdleStatPo value : secondUnitPoMap.values()) {
|
|
|
|
+ firstUnitPo.update(value);
|
|
|
|
+ }
|
|
|
|
+ return firstUnitPo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void landIdleStatExport(LandIdleStatDto.LandIdleStatMapDTO dto) {
|
|
|
|
+ ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder
|
|
|
|
+ .getRequestAttributes();
|
|
|
|
+ if (servletRequestAttributes == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ HttpServletResponse response = servletRequestAttributes.getResponse();
|
|
|
|
+ if (response == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String filename = "土地管理_闲置管理"
|
|
|
|
+ + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncodeUtil.encode(filename));
|
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
|
+ try (SXSSFWorkbook wb = new SXSSFWorkbook()) {
|
|
|
|
+ writeLandIdleStat(new LandIdleStatDto(dto), wb);
|
|
|
|
+ wb.write(response.getOutputStream());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void writeLandIdleStat(LandIdleStatDto dto, SXSSFWorkbook wb) {
|
|
|
|
+ LandIdleStatPo firstPo = getLandIdleStatPos(dto);
|
|
|
|
+ DataFormat dataFormat = wb.createDataFormat();
|
|
|
|
+ // 数字样式
|
|
|
|
+ CellStyle numberCellStyle = wb.createCellStyle();
|
|
|
|
+ numberCellStyle.setDataFormat(dataFormat.getFormat("#,##0.00"));
|
|
|
|
+ numberCellStyle.setAlignment(HorizontalAlignment.RIGHT);
|
|
|
|
+ // 默认样式
|
|
|
|
+ CellStyle baseCellStyle = wb.createCellStyle();
|
|
|
|
+ baseCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ baseCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
+ // 百分比样式
|
|
|
|
+ CellStyle percentCellStyle = wb.createCellStyle();
|
|
|
|
+ percentCellStyle.setDataFormat(dataFormat.getFormat("0.00%"));
|
|
|
|
+ percentCellStyle.setAlignment(HorizontalAlignment.RIGHT);
|
|
|
|
+ SXSSFSheet sheet = wb.createSheet();
|
|
|
|
+ AtomicInteger rowIndex = new AtomicInteger(0);
|
|
|
|
+ // 表头
|
|
|
|
+ Row headerRow = sheet.createRow(rowIndex.getAndIncrement());
|
|
|
|
+ List<String> headers = Stream.of("资产所属单位(一级)", "资产所属单位(二级)", "资产所属单位(三级)",
|
|
|
|
+ "土地总面积(㎡)", "土地自用面积(㎡)", "土地不可使用面积(㎡)","土地出租面积(㎡)", "土地闲置面积(㎡)", "闲置率(%)")
|
|
|
|
+ .toList();
|
|
|
|
+ int headerLength = headers.size();
|
|
|
|
+ for (int i = 0; i < headerLength; i++) {
|
|
|
|
+ Cell cell = headerRow.createCell(i);
|
|
|
|
+ cell.setCellValue(headers.get(i));
|
|
|
|
+ cell.setCellStyle(baseCellStyle);
|
|
|
|
+ // 根据内容长度设置列宽
|
|
|
|
+ int columnWidth = headers.get(i).length() * 256 * 2 + 256;
|
|
|
|
+ sheet.setColumnWidth(i, columnWidth);
|
|
|
|
+ }
|
|
|
|
+ if (firstPo == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 数据
|
|
|
|
+ AtomicInteger columnIndex1 = new AtomicInteger(0);
|
|
|
|
+ // 一级单位统计
|
|
|
|
+ Row row1 = sheet.createRow(rowIndex.getAndIncrement());
|
|
|
|
+ // 资产所属单位(一级)
|
|
|
|
+ Cell firstUnitCell1 = row1.createCell(columnIndex1.getAndIncrement());
|
|
|
|
+ if (firstPo.getAreaName() != null) {
|
|
|
|
+ firstUnitCell1.setCellValue(firstPo.getAreaName());
|
|
|
|
+ }
|
|
|
|
+ // 二级单位
|
|
|
|
+ Cell areaNameCell1 = row1.createCell(columnIndex1.getAndIncrement());
|
|
|
|
+// if (firstPo.getAreaName() != null) {
|
|
|
|
+// areaNameCell1.setCellValue(firstPo.getAreaName());
|
|
|
|
+// }
|
|
|
|
+ // 三级单位
|
|
|
|
+ Cell cityNameCell1 = row1.createCell(columnIndex1.getAndIncrement());
|
|
|
|
+// if (firstPo.getCityName() != null) {
|
|
|
|
+// cityNameCell1.setCellValue(firstPo.getCityName());
|
|
|
|
+// }
|
|
|
|
+ // 土地总面积(㎡)
|
|
|
|
+ Cell totalLandAreaSumCell1 = row1.createCell(columnIndex1.getAndIncrement());
|
|
|
|
+ if (firstPo.getTotalLandAreaSum() != null) {
|
|
|
|
+ totalLandAreaSumCell1.setCellValue(firstPo.getTotalLandAreaSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ totalLandAreaSumCell1.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地自用面积(㎡)
|
|
|
|
+ Cell landAreaSelfUseSumCell1 = row1.createCell(columnIndex1.getAndIncrement());
|
|
|
|
+ if (firstPo.getLandAreaSelfUseSum() != null) {
|
|
|
|
+ landAreaSelfUseSumCell1.setCellValue(firstPo.getLandAreaSelfUseSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaSelfUseSumCell1.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地不可使用面积(㎡)
|
|
|
|
+ Cell landAreaUnusableSumCell1 = row1.createCell(columnIndex1.getAndIncrement());
|
|
|
|
+ if (firstPo.getLandAreaUnusableSum() != null) {
|
|
|
|
+ landAreaUnusableSumCell1.setCellValue(firstPo.getLandAreaUnusableSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaUnusableSumCell1.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地出租面积(㎡)
|
|
|
|
+ Cell landAreaRentSumCell1 = row1.createCell(columnIndex1.getAndIncrement());
|
|
|
|
+ if (firstPo.getLandAreaRentSum() != null) {
|
|
|
|
+ landAreaRentSumCell1.setCellValue(firstPo.getLandAreaRentSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaRentSumCell1.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地闲置面积(㎡)
|
|
|
|
+ Cell landAreaIdleSumCell1 = row1.createCell(columnIndex1.getAndIncrement());
|
|
|
|
+ if (firstPo.getLandAreaIdleSum() != null) {
|
|
|
|
+ landAreaIdleSumCell1.setCellValue(firstPo.getLandAreaIdleSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaIdleSumCell1.setCellStyle(numberCellStyle);
|
|
|
|
+ // 闲置率
|
|
|
|
+ Cell idlePercentCell1 = row1.createCell(columnIndex1.getAndIncrement());
|
|
|
|
+ if (firstPo.getIdlePercent() != null) {
|
|
|
|
+ idlePercentCell1.setCellValue(firstPo.getIdlePercent().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ idlePercentCell1.setCellStyle(percentCellStyle);
|
|
|
|
+ // 二级单位统计
|
|
|
|
+ for (LandIdleStatPo secondPo : firstPo.getChildren()) {
|
|
|
|
+ AtomicInteger columnIndex2 = new AtomicInteger(0);
|
|
|
|
+ // 一级单位统计
|
|
|
|
+ Row row2 = sheet.createRow(rowIndex.getAndIncrement());
|
|
|
|
+ // 资产所属单位(一级)
|
|
|
|
+ Cell firstUnitCell2 = row2.createCell(columnIndex2.getAndIncrement());
|
|
|
|
+// if (secondPo.getAreaName() != null) {
|
|
|
|
+// firstUnitCell2.setCellValue(secondPo.getAreaName());
|
|
|
|
+// }
|
|
|
|
+ // 二级单位
|
|
|
|
+ Cell areaNameCell2 = row2.createCell(columnIndex2.getAndIncrement());
|
|
|
|
+ if (secondPo.getAreaName() != null) {
|
|
|
|
+ areaNameCell2.setCellValue(secondPo.getAreaName());
|
|
|
|
+ }
|
|
|
|
+ // 三级单位
|
|
|
|
+ Cell cityNameCell2 = row2.createCell(columnIndex2.getAndIncrement());
|
|
|
|
+// if (secondPo.getCityName() != null) {
|
|
|
|
+// cityNameCell2.setCellValue(secondPo.getCityName());
|
|
|
|
+// }
|
|
|
|
+ // 土地总面积(㎡)
|
|
|
|
+ Cell totalLandAreaSumCell2 = row2.createCell(columnIndex2.getAndIncrement());
|
|
|
|
+ if (secondPo.getTotalLandAreaSum() != null) {
|
|
|
|
+ totalLandAreaSumCell2.setCellValue(secondPo.getTotalLandAreaSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ totalLandAreaSumCell2.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地自用面积(㎡)
|
|
|
|
+ Cell landAreaSelfUseSumCell2 = row2.createCell(columnIndex2.getAndIncrement());
|
|
|
|
+ if (secondPo.getLandAreaSelfUseSum() != null) {
|
|
|
|
+ landAreaSelfUseSumCell2.setCellValue(secondPo.getLandAreaSelfUseSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaSelfUseSumCell2.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地不可使用面积(㎡)
|
|
|
|
+ Cell landAreaUnusableSumCell2 = row2.createCell(columnIndex2.getAndIncrement());
|
|
|
|
+ if (secondPo.getLandAreaUnusableSum() != null) {
|
|
|
|
+ landAreaUnusableSumCell2.setCellValue(secondPo.getLandAreaUnusableSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaUnusableSumCell2.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地出租面积(㎡)
|
|
|
|
+ Cell landAreaRentSumCell2 = row2.createCell(columnIndex2.getAndIncrement());
|
|
|
|
+ if (secondPo.getLandAreaRentSum() != null) {
|
|
|
|
+ landAreaRentSumCell2.setCellValue(secondPo.getLandAreaRentSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaRentSumCell2.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地闲置面积(㎡)
|
|
|
|
+ Cell landAreaIdleSumCell2 = row2.createCell(columnIndex2.getAndIncrement());
|
|
|
|
+ if (secondPo.getLandAreaIdleSum() != null) {
|
|
|
|
+ landAreaIdleSumCell2.setCellValue(secondPo.getLandAreaIdleSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaIdleSumCell2.setCellStyle(numberCellStyle);
|
|
|
|
+ // 闲置率
|
|
|
|
+ Cell idlePercentCell2 = row2.createCell(columnIndex2.getAndIncrement());
|
|
|
|
+ if (secondPo.getIdlePercent() != null) {
|
|
|
|
+ idlePercentCell2.setCellValue(secondPo.getIdlePercent().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ idlePercentCell2.setCellStyle(percentCellStyle);
|
|
|
|
+ // 三级单位统计
|
|
|
|
+ for (LandIdleStatPo thirdPo : secondPo.getChildren()) {
|
|
|
|
+ AtomicInteger columnIndex3 = new AtomicInteger(0);
|
|
|
|
+ Row row3 = sheet.createRow(rowIndex.getAndIncrement());
|
|
|
|
+ // 资产所属单位(一级)
|
|
|
|
+ Cell firstUnitCell3 = row3.createCell(columnIndex3.getAndIncrement());
|
|
|
|
+// if (thirdPo.getAreaName() != null) {
|
|
|
|
+// firstUnitCell3.setCellValue(thirdPo.getAreaName());
|
|
|
|
+// }
|
|
|
|
+ // 二级单位
|
|
|
|
+ Cell areaNameCell3 = row3.createCell(columnIndex3.getAndIncrement());
|
|
|
|
+// if (thirdPo.getAreaName() != null) {
|
|
|
|
+// areaNameCell3.setCellValue(thirdPo.getAreaName());
|
|
|
|
+// }
|
|
|
|
+ // 三级单位
|
|
|
|
+ Cell cityNameCell3 = row3.createCell(columnIndex3.getAndIncrement());
|
|
|
|
+ if (thirdPo.getCityName() != null) {
|
|
|
|
+ cityNameCell3.setCellValue(thirdPo.getCityName());
|
|
|
|
+ }
|
|
|
|
+ // 土地总面积(㎡)
|
|
|
|
+ Cell totalLandAreaSumCell3 = row3.createCell(columnIndex3.getAndIncrement());
|
|
|
|
+ if (thirdPo.getTotalLandAreaSum() != null) {
|
|
|
|
+ totalLandAreaSumCell3.setCellValue(thirdPo.getTotalLandAreaSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ totalLandAreaSumCell3.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地自用面积(㎡)
|
|
|
|
+ Cell landAreaSelfUseSumCell3 = row3.createCell(columnIndex3.getAndIncrement());
|
|
|
|
+ if (thirdPo.getLandAreaSelfUseSum() != null) {
|
|
|
|
+ landAreaSelfUseSumCell3.setCellValue(thirdPo.getLandAreaSelfUseSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaSelfUseSumCell3.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地不可使用面积(㎡)
|
|
|
|
+ Cell landAreaUnusableSumCell3 = row3.createCell(columnIndex3.getAndIncrement());
|
|
|
|
+ if (thirdPo.getLandAreaUnusableSum() != null) {
|
|
|
|
+ landAreaUnusableSumCell3.setCellValue(thirdPo.getLandAreaUnusableSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaUnusableSumCell3.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地出租面积(㎡)
|
|
|
|
+ Cell landAreaRentSumCell3 = row3.createCell(columnIndex3.getAndIncrement());
|
|
|
|
+ if (thirdPo.getLandAreaRentSum() != null) {
|
|
|
|
+ landAreaRentSumCell3.setCellValue(thirdPo.getLandAreaRentSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaRentSumCell3.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地闲置面积(㎡)
|
|
|
|
+ Cell landAreaIdleSumCell3 = row3.createCell(columnIndex3.getAndIncrement());
|
|
|
|
+ if (thirdPo.getLandAreaIdleSum() != null) {
|
|
|
|
+ landAreaIdleSumCell3.setCellValue(thirdPo.getLandAreaIdleSum().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaIdleSumCell3.setCellStyle(numberCellStyle);
|
|
|
|
+ // 闲置率
|
|
|
|
+ Cell idlePercentCell3 = row3.createCell(columnIndex3.getAndIncrement());
|
|
|
|
+ if (thirdPo.getIdlePercent() != null) {
|
|
|
|
+ idlePercentCell3.setCellValue(thirdPo.getIdlePercent().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ idlePercentCell3.setCellStyle(percentCellStyle);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Rsp<PageVo<ListLandVo>> queryLandDetail(ListLandDto dto) {
|
|
|
|
+ Page<HouseLandPo> page = new Page<>(dto.getPage().getPageNum(), dto.getPage().getPageSize());
|
|
|
|
+ List<HouseLandPo> list = getLandList(dto, page);
|
|
|
|
+ List<ListLandVo> vos = new ArrayList<>();
|
|
|
|
+ for (HouseLandPo po : list) {
|
|
|
|
+ vos.add(new ListLandVo(po));
|
|
|
|
+ }
|
|
|
|
+ PageVo<ListLandVo> pageVo = new PageVo<>(vos, page);
|
|
|
|
+ return Rsp.ok(pageVo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<HouseLandPo> getLandList(ListLandDto dto, Page<HouseLandPo> page) {
|
|
|
|
+ ListLandBo bo = new ListLandBo();
|
|
|
|
+ if (dto.getMap() != null && dto.getMap().getStatisticalMonth() != null) {
|
|
|
|
+ bo.setYearMonth(dto.getMap().getStatisticalMonth());
|
|
|
|
+ }
|
|
|
|
+ if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCity()) && !"全省".equals(dto.getMap().getCity())) {
|
|
|
|
+ bo.setAreaNo(dto.getMap().getCity());
|
|
|
|
+ }
|
|
|
|
+ if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCounty())) {
|
|
|
|
+ bo.setCityNo(dto.getMap().getCounty());
|
|
|
|
+ }
|
|
|
|
+ if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getCode())) {
|
|
|
|
+ bo.setSiteNum(dto.getMap().getCode());
|
|
|
|
+ }
|
|
|
|
+ if (dto.getMap() != null && StringUtils.hasText(dto.getMap().getBuildingNameAlias())) {
|
|
|
|
+ bo.setSiteName(dto.getMap().getBuildingNameAlias());
|
|
|
|
+ }
|
|
|
|
+ if (dto.getMap() != null && dto.getMap().getOrder() != null && dto.getMap().getSidx() != null) {
|
|
|
|
+ if (OrderEnum.asc.equals(dto.getMap().getOrder())) {
|
|
|
|
+ page.addOrder(OrderItem.asc(dto.getMap().getSidx().getColumnName()));
|
|
|
|
+ } else {
|
|
|
|
+ page.addOrder(OrderItem.desc(dto.getMap().getSidx().getColumnName()));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ page.addOrder(OrderItem.desc(ListLandOrderEnum.totalLandArea.getColumnName()));
|
|
|
|
+ }
|
|
|
|
+ return houseLandDao.listLand(page, bo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void queryLandDetailExport(ListLandDto.ListLandMapDTO dto) {
|
|
|
|
+ ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder
|
|
|
|
+ .getRequestAttributes();
|
|
|
|
+ if (servletRequestAttributes == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ HttpServletResponse response = servletRequestAttributes.getResponse();
|
|
|
|
+ if (response == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String filename = "土地管理_土地记录"
|
|
|
|
+ + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncodeUtil.encode(filename));
|
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
|
+ try (SXSSFWorkbook wb = new SXSSFWorkbook()) {
|
|
|
|
+ writeListLand(new ListLandDto(dto), wb);
|
|
|
|
+ wb.write(response.getOutputStream());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void writeListLand(ListLandDto dto, SXSSFWorkbook wb) {
|
|
|
|
+ Page<HouseLandPo> page = new Page<>(1, Long.MAX_VALUE);
|
|
|
|
+ List<HouseLandPo> list = getLandList(dto, page);
|
|
|
|
+ DataFormat dataFormat = wb.createDataFormat();
|
|
|
|
+ // 数字样式
|
|
|
|
+ CellStyle numberCellStyle = wb.createCellStyle();
|
|
|
|
+ numberCellStyle.setDataFormat(dataFormat.getFormat("#,##0.00"));
|
|
|
|
+ numberCellStyle.setAlignment(HorizontalAlignment.RIGHT);
|
|
|
|
+ // 默认样式
|
|
|
|
+ CellStyle baseCellStyle = wb.createCellStyle();
|
|
|
|
+ baseCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ baseCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
+ SXSSFSheet sheet = wb.createSheet();
|
|
|
|
+ AtomicInteger rowIndex = new AtomicInteger(0);
|
|
|
|
+ // 表头
|
|
|
|
+ Row headerRow = sheet.createRow(rowIndex.getAndIncrement());
|
|
|
|
+ List<String> headers = Stream.of("资产所属单位(一级)", "资产所属单位(二级)", "资产所属单位(三级)", "局址编号",
|
|
|
|
+ "局址别名", "土地别名", "土地性质", "使用权类型", "地类用途", "取得日期", "闲置开始时间", "标准地址",
|
|
|
|
+ "投资主体", "管理层级", "权属状态", "使用状态", "土地总面积(㎡)","土地自用面积(㎡)", "土地闲置面积(㎡)",
|
|
|
|
+ "土地出租面积(㎡)", "土地不可使用面积(㎡)", "是否有土地证", "无土地证原因", "是否有保地风险", "是否空地",
|
|
|
|
+ "是否有院落", "未关联资产", "资产编号", "资产标签号", "责任部门", "责任人", "经度", "纬度", "实际产权人",
|
|
|
|
+ "特殊说明").toList();
|
|
|
|
+ int headerLength = headers.size();
|
|
|
|
+ for (int i = 0; i < headerLength; i++) {
|
|
|
|
+ Cell cell = headerRow.createCell(i);
|
|
|
|
+ cell.setCellValue(headers.get(i));
|
|
|
|
+ cell.setCellStyle(baseCellStyle);
|
|
|
|
+ // 根据内容长度设置列宽
|
|
|
|
+ int columnWidth = headers.get(i).length() * 256 * 2 + 256;
|
|
|
|
+ sheet.setColumnWidth(i, columnWidth);
|
|
|
|
+ }
|
|
|
|
+ // 数据
|
|
|
|
+ for (HouseLandPo po : list) {
|
|
|
|
+ AtomicInteger columnIndex = new AtomicInteger(0);
|
|
|
|
+ Row row = sheet.createRow(rowIndex.getAndIncrement());
|
|
|
|
+ // 资产所属单位(一级)
|
|
|
|
+ Cell firstUnitCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getFirstUnit() != null) {
|
|
|
|
+ firstUnitCell.setCellValue(po.getFirstUnit());
|
|
|
|
+ }
|
|
|
|
+ // 二级单位
|
|
|
|
+ Cell areaNameCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getAreaName() != null) {
|
|
|
|
+ areaNameCell.setCellValue(po.getAreaName());
|
|
|
|
+ }
|
|
|
|
+ // 三级单位
|
|
|
|
+ Cell cityNameCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getCityName() != null) {
|
|
|
|
+ cityNameCell.setCellValue(po.getCityName());
|
|
|
|
+ }
|
|
|
|
+ // 局址编号
|
|
|
|
+ Cell siteNumCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getSiteName() != null) {
|
|
|
|
+ siteNumCell.setCellValue(po.getSiteNum());
|
|
|
|
+ }
|
|
|
|
+ // 局址别名
|
|
|
|
+ Cell siteNameCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getSiteName() != null) {
|
|
|
|
+ siteNameCell.setCellValue(po.getSiteName());
|
|
|
|
+ }
|
|
|
|
+ // 土地别名
|
|
|
|
+ Cell landNameCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getLandName() != null) {
|
|
|
|
+ landNameCell.setCellValue(po.getLandName());
|
|
|
|
+ }
|
|
|
|
+ // 土地性质
|
|
|
|
+ Cell landOwnershipCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getLandOwnership() != null) {
|
|
|
|
+ landOwnershipCell.setCellValue(po.getLandOwnership());
|
|
|
|
+ }
|
|
|
|
+ // 使用权类型
|
|
|
|
+ Cell useRightTypeCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getUseRightType() != null) {
|
|
|
|
+ useRightTypeCell.setCellValue(po.getUseRightType());
|
|
|
|
+ }
|
|
|
|
+ // 地类用途
|
|
|
|
+ Cell landUseCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getLandUse() != null) {
|
|
|
|
+ landUseCell.setCellValue(po.getLandUse());
|
|
|
|
+ }
|
|
|
|
+ // 取得日期
|
|
|
|
+ Cell acquisitionDateCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getAcquisitionDate() != null) {
|
|
|
|
+ acquisitionDateCell.setCellValue(po.getAcquisitionDate());
|
|
|
|
+ }
|
|
|
|
+ // 闲置开始时间
|
|
|
|
+ Cell idleStartDateCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getIdleStartDate() != null) {
|
|
|
|
+ idleStartDateCell.setCellValue(po.getIdleStartDate());
|
|
|
|
+ }
|
|
|
|
+ // 标准地址
|
|
|
|
+ Cell addressCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getAddress() != null) {
|
|
|
|
+ addressCell.setCellValue(po.getAddress());
|
|
|
|
+ }
|
|
|
|
+ // 投资主体
|
|
|
|
+ Cell investorCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getInvestor() != null) {
|
|
|
|
+ investorCell.setCellValue(po.getInvestor());
|
|
|
|
+ }
|
|
|
|
+ // 管理层级
|
|
|
|
+ Cell managementLevelCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getManagementLevel() != null) {
|
|
|
|
+ managementLevelCell.setCellValue(po.getManagementLevel());
|
|
|
|
+ }
|
|
|
|
+ // 权属状态
|
|
|
|
+ Cell ownershipStatusCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getOwnershipStatus() != null) {
|
|
|
|
+ ownershipStatusCell.setCellValue(po.getOwnershipStatus());
|
|
|
|
+ }
|
|
|
|
+ // 使用状态
|
|
|
|
+ Cell usageStatusCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getUsageStatus() != null) {
|
|
|
|
+ usageStatusCell.setCellValue(po.getUsageStatus());
|
|
|
|
+ }
|
|
|
|
+ // 土地总面积(㎡)
|
|
|
|
+ Cell totalLandAreaCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getTotalLandArea() != null) {
|
|
|
|
+ totalLandAreaCell.setCellValue(po.getTotalLandArea().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ totalLandAreaCell.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地自用面积(㎡)
|
|
|
|
+ Cell landAreaSelfUseCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getLandAreaSelfUse() != null) {
|
|
|
|
+ landAreaSelfUseCell.setCellValue(po.getLandAreaSelfUse().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaSelfUseCell.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地闲置面积(㎡)
|
|
|
|
+ Cell landAreaIdleCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getLandAreaIdle() != null) {
|
|
|
|
+ landAreaIdleCell.setCellValue(po.getLandAreaIdle().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaIdleCell.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地出租面积(㎡)
|
|
|
|
+ Cell landAreaRentCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getLandAreaRent() != null) {
|
|
|
|
+ landAreaRentCell.setCellValue(po.getLandAreaRent().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaRentCell.setCellStyle(numberCellStyle);
|
|
|
|
+ // 土地不可使用面积(㎡)
|
|
|
|
+ Cell landAreaUnusableCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getLandAreaUnusable() != null) {
|
|
|
|
+ landAreaUnusableCell.setCellValue(po.getLandAreaUnusable().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ landAreaUnusableCell.setCellStyle(numberCellStyle);
|
|
|
|
+ // 是否有土地证
|
|
|
|
+ Cell hasLandDeedCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getHasLandDeed() != null) {
|
|
|
|
+ hasLandDeedCell.setCellValue(po.getHasLandDeed());
|
|
|
|
+ }
|
|
|
|
+ // 无土地证原因
|
|
|
|
+ Cell noLandDeedReasonCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getNoLandDeedReason() != null) {
|
|
|
|
+ noLandDeedReasonCell.setCellValue(po.getNoLandDeedReason());
|
|
|
|
+ }
|
|
|
|
+ // 是否有保地风险
|
|
|
|
+ Cell landPreservationRiskCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getLandPreservationRisk() != null) {
|
|
|
|
+ landPreservationRiskCell.setCellValue(po.getLandPreservationRisk());
|
|
|
|
+ }
|
|
|
|
+ // 是否空地
|
|
|
|
+ Cell openSpaceCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getOpenSpace() != null) {
|
|
|
|
+ openSpaceCell.setCellValue(po.getOpenSpace());
|
|
|
|
+ }
|
|
|
|
+ // 是否有院落
|
|
|
|
+ Cell courtyardCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getCourtyard() != null) {
|
|
|
|
+ courtyardCell.setCellValue(po.getCourtyard());
|
|
|
|
+ }
|
|
|
|
+ // 未关联资产
|
|
|
|
+ Cell unrelatedAssetsCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getUnrelatedAssets() != null) {
|
|
|
|
+ unrelatedAssetsCell.setCellValue(po.getUnrelatedAssets());
|
|
|
|
+ }
|
|
|
|
+ // 资产编号
|
|
|
|
+ Cell assetsNumCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getAssetsNum() != null) {
|
|
|
|
+ assetsNumCell.setCellValue(po.getAssetsNum());
|
|
|
|
+ }
|
|
|
|
+ // 资产标签号
|
|
|
|
+ Cell assetsTagNumCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getAssetsTagNum() != null) {
|
|
|
|
+ assetsTagNumCell.setCellValue(po.getAssetsTagNum());
|
|
|
|
+ }
|
|
|
|
+ // 责任部门
|
|
|
|
+ Cell responsibleDepartmentCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getResponsibleDepartment() != null) {
|
|
|
|
+ responsibleDepartmentCell.setCellValue(po.getResponsibleDepartment());
|
|
|
|
+ }
|
|
|
|
+ // 责任人
|
|
|
|
+ Cell personInChargeCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getPersonInCharge() != null) {
|
|
|
|
+ personInChargeCell.setCellValue(po.getPersonInCharge());
|
|
|
|
+ }
|
|
|
|
+ // 经度
|
|
|
|
+ Cell lngJtCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getLngJt() != null) {
|
|
|
|
+ lngJtCell.setCellValue(po.getLngJt().toString());
|
|
|
|
+ }
|
|
|
|
+ // 纬度
|
|
|
|
+ Cell latJtCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getLatJt() != null) {
|
|
|
|
+ latJtCell.setCellValue(po.getLatJt().toString());
|
|
|
|
+ }
|
|
|
|
+ // 实际产权人
|
|
|
|
+ Cell propertyOwnerCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getPropertyOwner() != null) {
|
|
|
|
+ propertyOwnerCell.setCellValue(po.getPropertyOwner());
|
|
|
|
+ }
|
|
|
|
+ // 特殊说明
|
|
|
|
+ Cell specialSpecificationCell = row.createCell(columnIndex.getAndIncrement());
|
|
|
|
+ if (po.getSpecialSpecification() != null) {
|
|
|
|
+ specialSpecificationCell.setCellValue(po.getSpecialSpecification());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|