Bläddra i källkod

完善统计接口功能

zhangqiankun 3 år sedan
förälder
incheckning
5f9f1a0b58

+ 34 - 12
src/main/java/com/persagy/proxy/adm/controller/ComponentStatisticsController.java

@@ -1,5 +1,8 @@
 package com.persagy.proxy.adm.controller;
 
+import java.util.List;
+import java.util.Map;
+
 import javax.servlet.http.HttpServletRequest;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -8,10 +11,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.constant.AdmObjectType;
 import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
+import com.persagy.proxy.adm.constant.SpaceTypeEnum;
 import com.persagy.proxy.adm.request.AdmCountResponse;
+import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IRelationReportService;
 
 /**
@@ -98,10 +105,15 @@ public class ComponentStatisticsController {
 	 * @return
 	 */
 	@RequestMapping(value = "/sp-objecttype-count")
-	public AdmCountResponse spObjectTypeCount(HttpServletRequest request) {
-		//String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
-		//String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
-		return AdmCountResponse.success(0L);
+	public AdmResponse spObjectTypeCount(HttpServletRequest request) {
+		String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
+		
+		List<Map<String,Object>> list = this.relationReportService.queryObjectCountByObjInfos(groupCode, null, 
+				Sets.newHashSet(AdmObjectType.SPACE.getIndex()), Lists.newArrayList("classCode"));
+		for (Map<String, Object> map : list) {
+			map.put("name", map.get("classCode"));
+		}
+		return AdmResponse.success(list);
 	}
 	
 	/**
@@ -111,10 +123,15 @@ public class ComponentStatisticsController {
 	 * @return
 	 */
 	@RequestMapping(value = "/general-sp-functype-count")
-	public AdmCountResponse generalSpFunctypeCount(HttpServletRequest request) {
-		//String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
-		//String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
-		return AdmCountResponse.success(0L);
+	public AdmResponse generalSpFunctypeCount(HttpServletRequest request) {
+		String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
+		
+		List<Map<String,Object>> list = this.relationReportService.queryObjectCountByObjInfos(groupCode, Sets.newHashSet(SpaceTypeEnum.GeneralZone.getCode()), 
+				Sets.newHashSet(AdmObjectType.SPACE.getIndex()), Lists.newArrayList("roomFuncType"));
+		for (Map<String, Object> map : list) {
+			map.put("name", map.get("roomFuncType"));
+		}
+		return AdmResponse.success(list);
 	}
 	
 	/**
@@ -156,10 +173,15 @@ public class ComponentStatisticsController {
 	 * @return
 	 */
 	@RequestMapping(value = "/shaft-functype-count")
-	public AdmCountResponse shaftFunctypeCount(HttpServletRequest request) {
-		//String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
-		//String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
-		return AdmCountResponse.success(0L);
+	public AdmResponse shaftFunctypeCount(HttpServletRequest request) {
+		String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
+		
+		List<Map<String,Object>> list = this.relationReportService.queryObjectCountByObjInfos(groupCode, null, 
+				Sets.newHashSet(AdmObjectType.SHAFT.getIndex()), Lists.newArrayList("shaftFuncType"));
+		for (Map<String, Object> map : list) {
+			map.put("name", map.get("shaftFuncType"));
+		}
+		return AdmResponse.success(list);
 	}
 	
 }

+ 13 - 0
src/main/java/com/persagy/proxy/adm/service/IRelationReportService.java

@@ -1,6 +1,8 @@
 package com.persagy.proxy.adm.service;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.define.entity.GraphDefine;
@@ -19,6 +21,17 @@ import com.persagy.proxy.adm.model.AdmRelationObject;
 public interface IRelationReportService {
 
 	/**
+	 * 根据信息点统计对象个数
+	 * 
+	 * @param groupCode
+	 * @param classCodes
+	 * @param objTypes
+	 * @param groups
+	 * @return
+	 */
+	List<Map<String,Object>> queryObjectCountByObjInfos(String groupCode, Set<String> classCodes, Set<String> objTypes, List<String> groups);
+	
+	/**
 	 * 根据条件查询对应的边类型数据
 	 * 
 	 * @param groupCode

+ 32 - 0
src/main/java/com/persagy/proxy/adm/service/impl/RelationReportService.java

@@ -1,6 +1,8 @@
 package com.persagy.proxy.adm.service.impl;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -9,6 +11,7 @@ import org.springframework.stereotype.Service;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.Lists;
+import com.persagy.dmp.basic.dto.RequestData;
 import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.common.helper.SpringHelper;
 import com.persagy.dmp.common.model.response.CommonResult;
@@ -17,6 +20,7 @@ import com.persagy.dmp.define.client.DigitalRelationDefineFacade;
 import com.persagy.dmp.define.entity.GraphDefine;
 import com.persagy.dmp.define.entity.RelationDefine;
 import com.persagy.dmp.digital.client.DigitalObjectFacade;
+import com.persagy.dmp.digital.client.DigitalObjectSimpleFacade;
 import com.persagy.dmp.digital.client.DigitalRelationFacade;
 import com.persagy.dmp.digital.client.DigitalRelationProjectCalFacade;
 import com.persagy.dmp.digital.entity.ObjectRelation;
@@ -52,7 +56,21 @@ public class RelationReportService implements IRelationReportService {
 	private RelationObjectContext relationObjectContext;
 
 	@Override
+	public List<Map<String, Object>> queryObjectCountByObjInfos(String groupCode, Set<String> classCodes, Set<String> objTypes, List<String> groups) {
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
+		
+		RequestData requestData = new RequestData();
+		requestData.setClassCodes(classCodes);
+		requestData.setObjTypes(objTypes);
+		requestData.setGroups(groups);
+		List<Map<String,Object>> list = DigitalObjectSimpleFacade.queryObjectCountByObjInfos(groupCode, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, requestData);
+		return CollectionUtil.isEmpty(list) ? Lists.newArrayList() : list;
+	}
+	
+	@Override
 	public List<GraphDefine> getGraphDefine(String groupCode, String projectId, String graphCode) {
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
+		
 		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
 		QueryCriteria queryCriteria = new QueryCriteria();
 		ObjectNode criteria = objectMapper.createObjectNode();
@@ -66,6 +84,8 @@ public class RelationReportService implements IRelationReportService {
 	
 	@Override
 	public List<RelationDefine> getRelationDefine(String groupCode, String projectId, String graphCode, String relCode) {
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
+		
 		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
 		QueryCriteria queryCriteria = new QueryCriteria();
 		ObjectNode criteria = objectMapper.createObjectNode();
@@ -82,6 +102,8 @@ public class RelationReportService implements IRelationReportService {
 	
 	@Override
 	public ObjectNode getRelationProjectCal(String groupCode, String projectId, String relType) {
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
+		
 		AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
 		if (relationTypeEnum == null) {
 			return null;
@@ -116,6 +138,8 @@ public class RelationReportService implements IRelationReportService {
 	
 	@Override
 	public ObjectNode getRelationProjectCal(String groupCode, String projectId, String graphCode, String relCode, String zoneType) {
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
+		
 		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
 		QueryCriteria queryCriteria = new QueryCriteria();
 		ObjectNode criteria = objectMapper.createObjectNode();
@@ -134,6 +158,8 @@ public class RelationReportService implements IRelationReportService {
 	
 	@Override
 	public long countRelationObject(String groupCode, String projectId, String graphCode, String relCode, String zoneType) {
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
+		
 		QueryCriteria queryCriteria = new QueryCriteria();
 		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
 		ObjectNode criteria = objectMapper.createObjectNode();
@@ -150,6 +176,8 @@ public class RelationReportService implements IRelationReportService {
 	
 	@Override
 	public long countObject(String groupCode, String projectId, String classCode, String objType) {
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
+		
 		QueryCriteria queryCriteria = new QueryCriteria();
 		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
 		ObjectNode criteria = objectMapper.createObjectNode();
@@ -165,6 +193,8 @@ public class RelationReportService implements IRelationReportService {
 	
 	@Override
 	public ObjectNode getObjectNode(String groupCode, String projectId, String id) {
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
+		
 		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
 		QueryCriteria queryCriteria = new QueryCriteria();
 		ObjectNode criteria = objectMapper.createObjectNode();
@@ -176,6 +206,8 @@ public class RelationReportService implements IRelationReportService {
 	
 	@Override
 	public List<ObjectNode> findObjectNodes(String groupCode, String projectId, String objType, String code, String value) {
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
+		
 		if (StrUtil.isBlank(code)) {
 			return null;
 		}