|
@@ -2,10 +2,13 @@ package com.persagy.proxy.adm.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import com.persagy.proxy.adm.constant.AdmCommonConstant;
|
|
import com.persagy.proxy.adm.constant.AdmCommonConstant;
|
|
|
|
+import com.persagy.proxy.adm.model.AdmBuilding;
|
|
|
|
+import com.persagy.proxy.adm.model.AdmFloor;
|
|
import com.persagy.proxy.adm.model.AdmSpace;
|
|
import com.persagy.proxy.adm.model.AdmSpace;
|
|
import com.persagy.proxy.adm.request.AdmCreateRequest;
|
|
import com.persagy.proxy.adm.request.AdmCreateRequest;
|
|
import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
import com.persagy.proxy.adm.request.AdmResponse;
|
|
import com.persagy.proxy.adm.request.AdmResponse;
|
|
|
|
+import com.persagy.proxy.adm.service.IAdmBuildingService;
|
|
import com.persagy.proxy.adm.service.IAdmSpaceService;
|
|
import com.persagy.proxy.adm.service.IAdmSpaceService;
|
|
import com.persagy.proxy.common.entity.InstanceUrlParam;
|
|
import com.persagy.proxy.common.entity.InstanceUrlParam;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -16,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.ws.rs.QueryParam;
|
|
import javax.ws.rs.QueryParam;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -29,6 +33,8 @@ import java.util.List;
|
|
public class AdmSpaceController {
|
|
public class AdmSpaceController {
|
|
@Autowired
|
|
@Autowired
|
|
private IAdmSpaceService service;
|
|
private IAdmSpaceService service;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IAdmBuildingService buildingService;
|
|
@Value("${middleware.group.code}")
|
|
@Value("${middleware.group.code}")
|
|
private String groupCode;
|
|
private String groupCode;
|
|
|
|
|
|
@@ -116,12 +122,37 @@ public class AdmSpaceController {
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
@PostMapping("/building-floor")
|
|
@PostMapping("/building-floor")
|
|
- public AdmResponse queryFloor(@QueryParam("projectId") String projectId,
|
|
|
|
|
|
+ public AdmResponse queryBuildingFloor(@QueryParam("projectId") String projectId,
|
|
@RequestBody AdmQueryCriteria request) throws Exception {
|
|
@RequestBody AdmQueryCriteria request) throws Exception {
|
|
// 组装上下文条件
|
|
// 组装上下文条件
|
|
InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
- request.setName("space");
|
|
|
|
- return service.doQuery(context, request, AdmSpace.class);
|
|
|
|
|
|
+ request.setName("building");
|
|
|
|
+ AdmQueryCriteria criteriaFloor = new AdmQueryCriteria();
|
|
|
|
+ criteriaFloor.setName("floor");
|
|
|
|
+
|
|
|
|
+ AdmQueryCriteria criteriaSpace = new AdmQueryCriteria();
|
|
|
|
+ criteriaSpace.setName("spaceList");
|
|
|
|
+ criteriaSpace.setFilters("state = 1");
|
|
|
|
+
|
|
|
|
+ criteriaFloor.setCascade(CollUtil.newArrayList(criteriaSpace));
|
|
|
|
+ request.setCascade(CollUtil.newArrayList(criteriaFloor));
|
|
|
|
+ AdmResponse response = buildingService.doQueryBuildingFloor(context, request);
|
|
|
|
+ List<AdmBuilding> buildings = (List<AdmBuilding>) response.getContent();
|
|
|
|
+ buildings.stream().forEach(building -> {
|
|
|
|
+ if(CollUtil.isNotEmpty(building.getFloor())){
|
|
|
|
+ List<AdmFloor> floors = building.getFloor();
|
|
|
|
+ floors.stream().forEach(floor -> {
|
|
|
|
+ if(CollUtil.isNotEmpty(floor.getSpaceList())){
|
|
|
|
+ floor.setCount(String.valueOf(floor.getSpaceList().size()));
|
|
|
|
+ floor.setSpaceList(null);
|
|
|
|
+ }else{
|
|
|
|
+ floor.setCount("0");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return response;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|