|
@@ -1,12 +1,18 @@
|
|
|
package com.persagy.dmp.middleware.controller;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
+import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
+import com.persagy.dmp.digital.entity.ObjectDigital;
|
|
|
import com.persagy.dmp.middleware.constant.CommonConsant;
|
|
|
import com.persagy.dmp.middleware.constant.enums.RelationTypeEnum;
|
|
|
import com.persagy.dmp.middleware.entity.dto.CommonRequestDTO;
|
|
|
+import com.persagy.dmp.middleware.entity.dto.FloorDTO;
|
|
|
import com.persagy.dmp.middleware.entity.dto.InstanceUrlParam;
|
|
|
import com.persagy.dmp.middleware.entity.response.CommonResult;
|
|
|
import com.persagy.dmp.middleware.service.IBaseService;
|
|
@@ -21,7 +27,9 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.management.ObjectInstance;
|
|
|
import javax.ws.rs.QueryParam;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -66,9 +74,53 @@ public class FloorController {
|
|
|
RelationTypeEnum.ARCHSUBSET_BD2FL.getRelCode(), request.getBuildId(), 0);
|
|
|
// 查询建筑下的楼层列表
|
|
|
CommonResult response = baseService.doQuery(context,queryCriteria ,null);
|
|
|
+ List<JSONObject> content = (List<JSONObject>) response.getContent();
|
|
|
+ //结果集处理
|
|
|
+ handleResultList(content);
|
|
|
+ response.setContent(content);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 编辑楼层信息
|
|
|
+ * @param projectId
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/save")
|
|
|
+ public CommonResult update(@QueryParam("groupCode") String groupCode,@QueryParam("projectId") String projectId,
|
|
|
+ @RequestBody List<FloorDTO> list) throws Exception {
|
|
|
+ // 组装上下文条件
|
|
|
+ InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, null);
|
|
|
+ CommonResult<Object> response = new CommonResult<>();
|
|
|
+ //保存楼层信息
|
|
|
+ baseService.doUpdate(context,null,list);
|
|
|
+ response.setContent(list);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 结果集处理
|
|
|
+ * @param content
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void handleResultList(List<JSONObject> content){
|
|
|
+ if(CollUtil.isEmpty(content)){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ for (JSONObject node : content) {
|
|
|
+ Double area = node.getDouble("area");
|
|
|
+ if(area == null){
|
|
|
+ node.put("area",0);
|
|
|
+ }
|
|
|
+ Double height = node.getDouble("height");
|
|
|
+ if(height == null){
|
|
|
+ node.put("height",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 统计楼层下各信息
|
|
@@ -121,4 +173,42 @@ public class FloorController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询楼层下的空间列表
|
|
|
+ * @param projectId
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/queryFloorSpaceList")
|
|
|
+ public CommonResult queryFloorUnSpaceList(@QueryParam("groupCode") String groupCode,@QueryParam("projectId") String projectId,
|
|
|
+ @RequestBody List<CommonRequestDTO> list) throws Exception {
|
|
|
+ // 组装上下文条件
|
|
|
+ InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, null);
|
|
|
+ if(CollUtil.isEmpty(list)){
|
|
|
+ return new CommonResult();
|
|
|
+ }
|
|
|
+ List<JSONObject> result = new ArrayList<>();
|
|
|
+ for (CommonRequestDTO commonRequestDTO : list) {
|
|
|
+ if(StringUtils.isEmpty(commonRequestDTO.getFloorId())){
|
|
|
+ throw new Exception("楼层ID不能为空");
|
|
|
+ }
|
|
|
+ List<JSONObject> content = floorService.queryFloorUnSpaceList(context, commonRequestDTO);
|
|
|
+ JSONObject floorSpace = new JSONObject();
|
|
|
+ floorSpace.put("floorId",commonRequestDTO.getFloorId());
|
|
|
+ if(CollUtil.isNotEmpty(content)){
|
|
|
+ //类型名称相同的合并处理
|
|
|
+ content = EntityTransferUtil.combineData(content);
|
|
|
+ //按首字母,对象数量为0放后的规则进行排序
|
|
|
+ content = SortUtil.sortByCharacter(content, CommonConsant.OBJ_TYPE, CommonConsant.CLASS_NAME);
|
|
|
+ }
|
|
|
+ floorSpace.put("spaceInfos",content);
|
|
|
+ result.add(floorSpace);
|
|
|
+ }
|
|
|
+ //设置返回值
|
|
|
+ CommonResult<List<JSONObject>> response = CommonResult.success(result);
|
|
|
+ response.setCount(result == null ? 0 : Long.valueOf(result.size()));
|
|
|
+ return response;
|
|
|
+ }
|
|
|
}
|