package com.persagy.dmp.simple.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.persagy.dmp.basic.config.DigitalFeignConfig;
import com.persagy.dmp.basic.dto.RequestData;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.digital.entity.ObjectRelation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * 数字孪生 简洁API Client
 * @author Charlie Yu
 * @date 2021-09-02
 */
@FeignClient(name = "dmp-rwd", configuration = DigitalFeignConfig.class,
        url = "${persagy.bdtp.rwd.service:}",path = "/api/")
public interface DigitalObjectSimpleClient {

    /**
     * 根据项目ID查询设备数量和待报废设备数量统计
     * @param groupCode: 集团编码
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param projectIds: 项目ID - 为空查所有
     * @return
     */
    @PostMapping("report/equipment/queryExpectScrapCountByProjects")
    CommonResult<List<Map<String, Object>>> queryExpectScrapCountByProjects(@RequestParam("groupCode") String groupCode,
                                                                            @RequestParam("appId") String appId,
                                                                            @RequestParam("userId") String userId,
                                                                            @RequestBody(required = false) List<String> projectIds);

    /**
     * 根据对象信息点统计数量
     * @param groupCode: 集团编码
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param requestData: 请求参数
     * @return
     */
    @PostMapping("report/equipment/queryObjectCountByObjInfos")
    CommonResult<List<Map<String, Object>>> queryObjectCountByObjInfos(@RequestParam("groupCode") String groupCode,
                                                                       @RequestParam("appId") String appId,
                                                                       @RequestParam("userId") String userId,
                                                                       @RequestBody RequestData requestData);

    /**
     * 查询当前设备类型下的部件分类以及数量
     * @param groupCode: 集团编码
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param requestData: 请求参数
     * @return
     */
    @PostMapping("report/equipment/queryComponentsCountByEquipId")
    CommonResult<List<Map<String, Object>>> queryComponentsCountByEquipId(@RequestParam("groupCode") String groupCode, @RequestParam("projectId") String projectId,
                                                                       @RequestParam("appId") String appId,
                                                                       @RequestParam("userId") String userId, @RequestBody RequestData requestData);
    /**
     * 统计项目下允许创建的部件类型，以及项目下创建的部件数量
     * @param groupCode: 集团编码
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param requestData: 请求参数
     * @return
     */
    @PostMapping("report/equipment/queryEquipComponentsByProjectId")
    CommonResult<List<Map<String, Object>>> queryEquipComponentsByProjectId(@RequestParam("groupCode") String groupCode, @RequestParam("projectId") String projectId,
                                                                          @RequestParam("appId") String appId,
                                                                          @RequestParam("userId") String userId, @RequestBody RequestData requestData);
    /**
     * 项目下所有实例(system/space/equipment..)类型以及名称
     * @param groupCode: 集团编码
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param requestData: 请求参数
     * @return
     */
    @PostMapping("report/equipment/queryDefineInfoByObjType")
    CommonResult<List<Map<String, Object>>> queryDefineInfoByObjType(@RequestParam("groupCode") String groupCode, @RequestParam("projectId") String projectId,
                                                                            @RequestParam("appId") String appId,
                                                                            @RequestParam("userId") String userId, @RequestBody RequestData requestData);

    /**
     * 查询不确定楼层/不确定建筑 的系统
     * @param groupCode: 集团编码
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param requestData: 请求参数
     * @return
     */
    @PostMapping("custom/system/queryNotSureSystem")
    Page<Map<String,Object>> queryNotSureSystem(@RequestParam("groupCode") String groupCode, @RequestParam("projectId") String projectId,
                                                @RequestParam("appId") String appId,
                                                @RequestParam("userId") String userId, @RequestBody RequestData requestData);
    /**
     * 根据条件查询系统 针对查询条件中有distinct 和 projectiond 的情况
     * {
     *     "distinct": true,
     *     "pageNumber": 1,
     *     "pageSize": 1000,
     *     "projection": [
     *         "classCode",
     *         "CategoryName"
     *     ]
     * }
     * @param groupCode: 集团编码
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param requestData: 请求参数
     * @return
     */
    @PostMapping("custom/system/queryObjListByConditions")
    CommonResult<List<ObjectNode>> queryObjListByConditions(@RequestParam("groupCode") String groupCode, @RequestParam("projectId") String projectId,
                                                               @RequestParam("appId") String appId,
                                                               @RequestParam("userId") String userId, @RequestBody RequestData requestData);
    /***
     * Description: 根据对象id统计关系数量
     * @param groupCode: 集团编码
     * @param appId: 应用ID
     * @param userId: 用户ID
     * @param projectId: 项目id
     * @param requestData : 请求参数
     * @author : lijie
     * @date :2021/10/28 10:16
     * Update By lijie 2021/10/28 10:16
     */
    @PostMapping("report/relation/queryRelationCountByObjIds")
    CommonResult<List<ObjectRelation>> queryRelationCountByObjIds(@RequestParam("groupCode") String groupCode,
                                                                  @RequestParam("projectId") String projectId,
                                                                  @RequestParam("appId") String appId,
                                                                  @RequestParam("userId") String userId,
                                                                  @RequestBody Object requestData);
}
