|
@@ -5,10 +5,14 @@ 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.dao.house.HouseRepairExceptionDao;
|
|
import com.example.dao.house.HouseRepairExceptionDao;
|
|
import com.example.entity.house.HouseBuildingHighRepairPo;
|
|
import com.example.entity.house.HouseBuildingHighRepairPo;
|
|
|
|
+import com.example.entity.house.HouseBuildingSameRepairFrequencyPo;
|
|
import com.example.enums.OrderEnum;
|
|
import com.example.enums.OrderEnum;
|
|
-import com.example.pojo.dto.ListBuildingHighRepairDto;
|
|
|
|
import com.example.pojo.bo.ListBuildingHighRepairBo;
|
|
import com.example.pojo.bo.ListBuildingHighRepairBo;
|
|
|
|
+import com.example.pojo.bo.ListBuildingSameRepairFrequencyBo;
|
|
|
|
+import com.example.pojo.dto.ListBuildingHighRepairDto;
|
|
|
|
+import com.example.pojo.dto.ListBuildingSameRepairFrequencyDto;
|
|
import com.example.pojo.vo.ListBuildingHighRepairVo;
|
|
import com.example.pojo.vo.ListBuildingHighRepairVo;
|
|
|
|
+import com.example.pojo.vo.ListBuildingSameRepairFrequencyVo;
|
|
import com.example.utils.PageUtils;
|
|
import com.example.utils.PageUtils;
|
|
import com.example.utils.R;
|
|
import com.example.utils.R;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -76,6 +80,9 @@ public class HouseWzHouseMaintenaCostService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询不动产自有房产高总价统计
|
|
|
|
+ */
|
|
private List<HouseBuildingHighRepairPo> getHouseBuildingHighRepairPos(ListBuildingHighRepairDto dto,
|
|
private List<HouseBuildingHighRepairPo> getHouseBuildingHighRepairPos(ListBuildingHighRepairDto dto,
|
|
Page<HouseBuildingHighRepairPo> page) {
|
|
Page<HouseBuildingHighRepairPo> page) {
|
|
ListBuildingHighRepairBo bo = new ListBuildingHighRepairBo();
|
|
ListBuildingHighRepairBo bo = new ListBuildingHighRepairBo();
|
|
@@ -99,7 +106,7 @@ public class HouseWzHouseMaintenaCostService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 写高总价统计文件
|
|
|
|
|
|
+ * 写不动产自有房产高总价统计文件
|
|
*/
|
|
*/
|
|
private void writeQueryHighPrice(ListBuildingHighRepairDto dto, SXSSFWorkbook wb) {
|
|
private void writeQueryHighPrice(ListBuildingHighRepairDto dto, SXSSFWorkbook wb) {
|
|
Page<HouseBuildingHighRepairPo> page = new Page<>(1, Long.MAX_VALUE);
|
|
Page<HouseBuildingHighRepairPo> page = new Page<>(1, Long.MAX_VALUE);
|
|
@@ -210,4 +217,146 @@ public class HouseWzHouseMaintenaCostService {
|
|
n.setCellStyle(numberCellStyle);
|
|
n.setCellStyle(numberCellStyle);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public R queryHighFrequency(ListBuildingSameRepairFrequencyDto dto) {
|
|
|
|
+ Page<HouseBuildingSameRepairFrequencyPo> page = new Page<>(dto.getPage().getPageNum(), dto.getPage().getPageSize());
|
|
|
|
+ List<HouseBuildingSameRepairFrequencyPo> list = getHouseBuildingSameRepairFrequencyPos(dto, page);
|
|
|
|
+ List<ListBuildingSameRepairFrequencyVo> vos = new ArrayList<>();
|
|
|
|
+ for (HouseBuildingSameRepairFrequencyPo po : list) {
|
|
|
|
+ vos.add(new ListBuildingSameRepairFrequencyVo(po));
|
|
|
|
+ }
|
|
|
|
+ PageUtils pageUtil = new PageUtils(vos, page);
|
|
|
|
+ return R.ok().put("page", pageUtil);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询不动产自有房产相同维修频次统计
|
|
|
|
+ */
|
|
|
|
+ private List<HouseBuildingSameRepairFrequencyPo> getHouseBuildingSameRepairFrequencyPos(
|
|
|
|
+ ListBuildingSameRepairFrequencyDto dto,
|
|
|
|
+ Page<HouseBuildingSameRepairFrequencyPo> page) {
|
|
|
|
+ ListBuildingSameRepairFrequencyBo bo = new ListBuildingSameRepairFrequencyBo();
|
|
|
|
+ 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 && 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()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return houseRepairExceptionDao.listBuildingSameRepairFrequency(page, bo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void queryHighFrequencyExport(ListBuildingSameRepairFrequencyDto 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()) {
|
|
|
|
+ writeQueryHighFrequency(dto, wb);
|
|
|
|
+ wb.write(response.getOutputStream());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 写不动产自有房产相同维修频次统计文件
|
|
|
|
+ */
|
|
|
|
+ private void writeQueryHighFrequency(ListBuildingSameRepairFrequencyDto dto, SXSSFWorkbook wb) {
|
|
|
|
+ Page<HouseBuildingSameRepairFrequencyPo> page = new Page<>(1, Long.MAX_VALUE);
|
|
|
|
+ List<HouseBuildingSameRepairFrequencyPo> list = getHouseBuildingSameRepairFrequencyPos(dto, page);
|
|
|
|
+ DataFormat dataFormat = wb.createDataFormat();
|
|
|
|
+ // 数字样式
|
|
|
|
+ CellStyle numberCellStyle = wb.createCellStyle();
|
|
|
|
+ numberCellStyle.setDataFormat(dataFormat.getFormat("#,##0"));
|
|
|
|
+ numberCellStyle.setAlignment(HorizontalAlignment.RIGHT);
|
|
|
|
+ // 默认样式
|
|
|
|
+ CellStyle baseCellStyle = wb.createCellStyle();
|
|
|
|
+ baseCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ baseCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
+ SXSSFSheet sheet = wb.createSheet();
|
|
|
|
+ AtomicInteger columnIndex = new AtomicInteger(0);
|
|
|
|
+ // 表头
|
|
|
|
+ Row headerRow = sheet.createRow(columnIndex.getAndIncrement());
|
|
|
|
+ List<String> headers = Stream.of("建筑id", "单位", "维修建筑", "维修类别", "维修内容", "账期时间",
|
|
|
|
+ "本年累计发生频率", "排名", "202301至今累计发生频率").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 (HouseBuildingSameRepairFrequencyPo houseBuildingSameRepairFrequencyPo : list) {
|
|
|
|
+ Row row = sheet.createRow(columnIndex.getAndIncrement());
|
|
|
|
+ // 建筑id
|
|
|
|
+ Cell a = row.createCell(CellReference.convertColStringToIndex("a"));
|
|
|
|
+ if (houseBuildingSameRepairFrequencyPo.getBuildingId() != null) {
|
|
|
|
+ a.setCellValue(houseBuildingSameRepairFrequencyPo.getBuildingId());
|
|
|
|
+ }
|
|
|
|
+ // 二级单位
|
|
|
|
+ Cell b = row.createCell(CellReference.convertColStringToIndex("b"));
|
|
|
|
+ if (houseBuildingSameRepairFrequencyPo.getAreaName() != null) {
|
|
|
|
+ b.setCellValue(houseBuildingSameRepairFrequencyPo.getAreaName());
|
|
|
|
+ }
|
|
|
|
+ // 维修建筑
|
|
|
|
+ Cell c = row.createCell(CellReference.convertColStringToIndex("c"));
|
|
|
|
+ if (houseBuildingSameRepairFrequencyPo.getBuildingName() != null) {
|
|
|
|
+ c.setCellValue(houseBuildingSameRepairFrequencyPo.getBuildingName());
|
|
|
|
+ }
|
|
|
|
+ // 维修类别
|
|
|
|
+ Cell d = row.createCell(CellReference.convertColStringToIndex("d"));
|
|
|
|
+ if (houseBuildingSameRepairFrequencyPo.getRepairType() != null) {
|
|
|
|
+ d.setCellValue(houseBuildingSameRepairFrequencyPo.getRepairType());
|
|
|
|
+ }
|
|
|
|
+ // 维修内容
|
|
|
|
+ Cell e = row.createCell(CellReference.convertColStringToIndex("e"));
|
|
|
|
+ if (houseBuildingSameRepairFrequencyPo.getContentCategory() != null) {
|
|
|
|
+ e.setCellValue(houseBuildingSameRepairFrequencyPo.getContentCategory());
|
|
|
|
+ }
|
|
|
|
+ // 账期时间
|
|
|
|
+ Cell f = row.createCell(CellReference.convertColStringToIndex("f"));
|
|
|
|
+ if (houseBuildingSameRepairFrequencyPo.getYearMonth() != null) {
|
|
|
|
+ f.setCellValue(houseBuildingSameRepairFrequencyPo.getYearMonth());
|
|
|
|
+ }
|
|
|
|
+ // 本年累计发生频率
|
|
|
|
+ Cell g = row.createCell(CellReference.convertColStringToIndex("g"));
|
|
|
|
+ if (houseBuildingSameRepairFrequencyPo.getTyTotal() != null) {
|
|
|
|
+ g.setCellValue(houseBuildingSameRepairFrequencyPo.getTyTotal());
|
|
|
|
+ }
|
|
|
|
+ g.setCellStyle(numberCellStyle);
|
|
|
|
+ // 排名
|
|
|
|
+ Cell h = row.createCell(CellReference.convertColStringToIndex("h"));
|
|
|
|
+ if (houseBuildingSameRepairFrequencyPo.getTyTotalRank() != null) {
|
|
|
|
+ h.setCellValue(houseBuildingSameRepairFrequencyPo.getTyTotalRank());
|
|
|
|
+ }
|
|
|
|
+ // 202301至今累计发生频率
|
|
|
|
+ Cell i = row.createCell(CellReference.convertColStringToIndex("i"));
|
|
|
|
+ if (houseBuildingSameRepairFrequencyPo.getHistoryTotal() != null) {
|
|
|
|
+ i.setCellValue(houseBuildingSameRepairFrequencyPo.getHistoryTotal());
|
|
|
|
+ }
|
|
|
|
+ i.setCellStyle(numberCellStyle);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|