Commit ef1f7ff0 authored by 周昊's avatar 周昊

1、修改楼宇id获取楼层列表

parent eb4fe7e5
......@@ -282,7 +282,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerFloor>>}
*/
@GetMapping("/floor/list/{buildingId}")
public R<List<LedgerFloor>> getFloorListByBuildingId(@PathVariable("buildingId") Long buildingId) {
public R<List<LedgerFloorDto>> getFloorListByBuildingId(@PathVariable("buildingId") Long buildingId) {
return R.ok(ledgerFloorService.getFloorListByBuildingId(buildingId));
}
......
package com.censoft.censoftrongtong.domain.dto;
import com.censoft.censoftrongtong.domain.LedgerFloor;
import lombok.Data;
import java.util.List;
/**
* 基础数据-楼层对象 ledger_floor
*
* @author ruoyi
* @date 2023-06-26
*/
@Data
public class LedgerFloorDto {
/**
* 名称 地上地下
*/
private String name;
/**
* 楼层
*/
private List<LedgerFloor> children;
}
package com.censoft.censoftrongtong.service;
import com.censoft.censoftrongtong.domain.LedgerFloor;
import com.censoft.censoftrongtong.domain.dto.LedgerFloorDto;
import java.util.List;
......@@ -60,5 +61,5 @@ public interface ILedgerFloorService
*/
public int deleteLedgerFloorById(Long id);
List<LedgerFloor> getFloorListByBuildingId(Long buildingId);
List<LedgerFloorDto> getFloorListByBuildingId(Long buildingId);
}
package com.censoft.censoftrongtong.service.impl;
import java.util.List;
import java.util.stream.Collectors;
import com.censoft.censoftrongtong.domain.LedgerFloor;
import com.censoft.censoftrongtong.domain.dto.LedgerFloorDto;
import com.censoft.censoftrongtong.mapper.LedgerFloorMapper;
import com.censoft.censoftrongtong.service.ILedgerFloorService;
import com.ruoyi.common.utils.DateUtils;
......@@ -96,10 +98,27 @@ public class LedgerFloorServiceImpl implements ILedgerFloorService
}
@Override
public List<LedgerFloor> getFloorListByBuildingId(Long buildingId) {
public List<LedgerFloorDto> getFloorListByBuildingId(Long buildingId) {
LedgerFloor query = new LedgerFloor();
query.setBuildingId(buildingId);
query.setStatus("0");
return selectLedgerFloorList(query);
List<LedgerFloor> ledgerFloors = selectLedgerFloorList(query);
return getLedgerFloorDtoListByLedgerFloor(ledgerFloors);
}
private List<LedgerFloorDto> getLedgerFloorDtoListByLedgerFloor(List<LedgerFloor> ledgerFloors) {
return ledgerFloors.stream()
.map(LedgerFloor::getType)
.distinct()
.map(type->{
List<LedgerFloor> children = ledgerFloors
.stream()
.filter(ledgerFloor -> type.equals(ledgerFloor.getType()))
.collect(Collectors.toList());
LedgerFloorDto ledgerFloorDto = new LedgerFloorDto();
ledgerFloorDto.setName(type);
ledgerFloorDto.setChildren(children);
return ledgerFloorDto;
}).collect(Collectors.toList());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment