package com.persagy.proxy.adm.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.persagy.dmp.basic.model.QueryCriteria;
import com.persagy.dmp.common.helper.SpringHelper;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.digital.client.DigitalObjectFacade;
import com.persagy.dmp.digital.client.DigitalRelationFacade;
import com.persagy.dmp.digital.entity.ObjectRelation;
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.request.AdmCountResponse;
/**
* 统计接口
*
* @version 1.0.0
* @company persagy
* @author zhangqiankun
* @date 2021年9月8日 下午7:51:56
*/
@RestController
@RequestMapping("/statistics")
public class ComponentStatisticsController {
/**
* 台账中待删除的对象
*
条件:"filters": "taskState = -1"
* @param queryCriteria
* @param request
* @return
*/
@RequestMapping(value = "/object-delete-count")
public AdmCountResponse objectDeleteCount(@RequestBody JSONObject params, HttpServletRequest request) {
return AdmCountResponse.success(0L);
}
/**
* 不能同步到物理世界的关系数据
*
* @param params
* @param request
* @return
*/
@RequestMapping(value = "/unsyn-relation-count")
public AdmCountResponse unsynRelationCount(HttpServletRequest request) {
return AdmCountResponse.success(0L);
}
/**
* 岗位和关联的资产信息点值不一致
*
* @param request
* @return
*/
@RequestMapping(value = "/eq2pe-count")
public AdmCountResponse eq2peCount(HttpServletRequest request) {
return AdmCountResponse.success(0L);
}
/**
* 岗位和关联的资产信息点值不一致的数据
*
* @param request
* @return
*/
@RequestMapping(value = "/eq2pe-different")
public AdmCountResponse eq2peDifferent(HttpServletRequest request) {
return AdmCountResponse.success(0L);
}
/**
* 设备-未关联资产的设备,这里返回所有的设备
*
* @param params
* @param request
* @return
*/
@RequestMapping(value = "/uneq2pe-count")
public AdmCountResponse uneq2peCount(HttpServletRequest request) {
String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
QueryCriteria queryCriteria = new QueryCriteria();
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
ObjectNode objectNode = objectMapper.createObjectNode();
objectNode.put("classCode", AdmObjectType.EQUIPMENT.getIndex());
queryCriteria.setCriteria(objectNode);
queryCriteria.setOnlyCount(true);
CommonResult> result = DigitalObjectFacade.queryPrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
long count = result == null ? 0 : (result.getCount() == null ? 0 : result.getCount());
return AdmCountResponse.success(count);
}
/**
* 业务空间-各分区占比
*
* @param request
* @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);
}
/**
* 业务空间-默认分区功能类型占比
*
* @param request
* @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);
}
/**
* 租户-关联业务空间完成度
*
* @param request
* @return
*/
@RequestMapping(value = "/tenant2sp-count")
public AdmCountResponse tenant2spCount(HttpServletRequest request) {
String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
QueryCriteria queryCriteria = new QueryCriteria();
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
ObjectNode objectNode = objectMapper.createObjectNode();
objectNode.put("graphCode", AdmRelationTypeEnum.TN2SP.getGraphCode());
objectNode.put("relCode", AdmRelationTypeEnum.TN2SP.getRelCode());
queryCriteria.setCriteria(objectNode);
queryCriteria.setOnlyCount(true);
CommonResult> result = DigitalRelationFacade.queryPrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
long count = result == null ? 0 : (result.getCount() == null ? 0 : result.getCount());
return AdmCountResponse.success(count);
}
/**
* 竖井-关联业务空间完成度
*
* @param request
* @return
*/
@RequestMapping(value = "/shaft2sp-count")
public AdmCountResponse shaft2spCount(HttpServletRequest request) {
String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
QueryCriteria queryCriteria = new QueryCriteria();
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
ObjectNode objectNode = objectMapper.createObjectNode();
objectNode.put("graphCode", AdmRelationTypeEnum.SH2SP.getGraphCode());
objectNode.put("relCode", AdmRelationTypeEnum.SH2SP.getRelCode());
queryCriteria.setCriteria(objectNode);
queryCriteria.setOnlyCount(true);
CommonResult> result = DigitalRelationFacade.queryPrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
long count = result == null ? 0 : (result.getCount() == null ? 0 : result.getCount());
return AdmCountResponse.success(count);
}
/**
* 竖井-按功能类型占比
*
* @param request
* @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);
}
}