Browse Source

增加statistics/eq2sp接口

yucheng 3 years ago
parent
commit
22ed186d9b

+ 41 - 21
src/main/java/com/persagy/proxy/adm/controller/ComponentStatisticsController.java

@@ -1,15 +1,6 @@
 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;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
+import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
@@ -17,9 +8,23 @@ 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.model.AdmEquipment;
 import com.persagy.proxy.adm.request.AdmCountResponse;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.IAdmEquipmentService;
 import com.persagy.proxy.adm.service.IRelationReportService;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 统计接口
@@ -39,7 +44,6 @@ public class ComponentStatisticsController {
 	/**
 	 * 台账中待删除的对象
 	 * <p>条件:"filters": "taskState = -1"</p>
-	 * @param queryCriteria
 	 * @param request
 	 * @return
 	 */
@@ -50,8 +54,6 @@ public class ComponentStatisticsController {
 	
 	/**
 	 * 不能同步到物理世界的关系数据
-	 * 
-	 * @param params
 	 * @param request
 	 * @return
 	 */
@@ -84,8 +86,6 @@ public class ComponentStatisticsController {
 	
 	/**
 	 * 设备-未关联资产的设备,这里返回所有的设备
-	 * 
-	 * @param params
 	 * @param request
 	 * @return
 	 */
@@ -100,7 +100,6 @@ public class ComponentStatisticsController {
 	
 	/**
 	 * 业务空间-各分区占比
-	 * 
 	 * @param request
 	 * @return
 	 */
@@ -118,7 +117,6 @@ public class ComponentStatisticsController {
 	
 	/**
 	 * 业务空间-默认分区功能类型占比
-	 * 
 	 * @param request
 	 * @return
 	 */
@@ -136,7 +134,6 @@ public class ComponentStatisticsController {
 	
 	/**
 	 * 租户-关联业务空间完成度
-	 * 
 	 * @param request
 	 * @return
 	 */
@@ -152,7 +149,6 @@ public class ComponentStatisticsController {
 	
 	/**
 	 * 竖井-关联业务空间完成度
-	 * 
 	 * @param request
 	 * @return
 	 */
@@ -168,7 +164,6 @@ public class ComponentStatisticsController {
 	
 	/**
 	 * 竖井-按功能类型占比
-	 * 
 	 * @param request
 	 * @return
 	 */
@@ -183,5 +178,30 @@ public class ComponentStatisticsController {
 		}
 		return AdmResponse.success(list);
 	}
-	
+
+	@Autowired
+	private IAdmEquipmentService equipmentService;
+
+	/**
+	 * 设备所在空间占比统计
+	 * @return
+	 */
+	@RequestMapping(value = "/eq2sp")
+	public AdmResponse queryEquip2Space() {
+		InstanceUrlParam context = AdmContextUtil.toDmpContext();
+		// 查询设备数量
+		AdmQueryCriteria criteria = new AdmQueryCriteria();
+		criteria.setName(AdmEquipment.OBJ_TYPE);
+		criteria.setOnlyCount(true);
+		AdmResponse rs = equipmentService.doQuery(context, criteria, AdmEquipment.class);
+		long equipCount = rs.getCount() == null ? 0L : rs.getCount().longValue();
+		// 查询关系数量
+		long relCount = relationReportService.countRelationObject(context.getGroupCode(), context.getProjectId(),
+				AdmRelationTypeEnum.EQ2SP_IN.getGraphCode(),AdmRelationTypeEnum.EQ2SP_IN.getRelCode(), "GeneralZone");
+		// 组装返回结果
+		Map<String, Long> countMap = new HashMap<>(2);
+		countMap.put("equipCount", equipCount);
+		countMap.put("relCount", relCount);
+		return AdmResponse.success(CollUtil.newArrayList(countMap));
+	}
 }