package com.yeejoin.amos.boot.module.statistcs.biz.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.statistcs.biz.service.impl.ComprehensiveStatisticalAnalysisServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;

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

/**
 * 综合统计分析API
 *
 * @author system_generator
 * @date 2025-06-24
 */
@RestController
@Api(tags = "综合统计分析API")
@RequestMapping(value = "/comprehensiveStatisticalAnalysis")
public class ComprehensiveStatisticalAnalysisController extends BaseController {

    @Autowired
    private ComprehensiveStatisticalAnalysisServiceImpl statisticalAnalysisService;

    /**
     * 查询设备分类
     *
     * @param category
     * @return
     */
    @TycloudOperation(ApiLevel = UserType.AGENCY)
    @PostMapping(value = "/select/equipmentCategory")
    @ApiOperation(httpMethod = "POST", value = "查询设备分类", notes = "查询设备分类")
    public ResponseModel<List<Map<String, Object>>> queryEquipmentCategory(@RequestBody JSONObject category) {
        String key = category.getString("key") == null ? null : category.getString("key");
        return ResponseHelper.buildResponse(statisticalAnalysisService.queryEquipmentCategory(key));
    }

    /**
     * @param jsonObject
     * @return
     */
    @TycloudOperation(ApiLevel = UserType.AGENCY)
    @PostMapping(value = "/select/queryEquipmentSearchData")
    @ApiOperation(httpMethod = "POST", value = "查询设备查询条件", notes = "查询设备查询条件")
    public ResponseModel<JSONObject> queryEquipmentSearchData(@RequestBody JSONObject jsonObject) {
        return ResponseHelper.buildResponse(statisticalAnalysisService.queryEquipmentSearchData(jsonObject.getString("value")));
    }

    /**
     * @param
     * @return
     */
    @TycloudOperation(ApiLevel = UserType.AGENCY)
    @GetMapping(value = "/select/queryAdvancedSearch")
    @ApiOperation(httpMethod = "GET", value = "查询高级筛选", notes = "查询高级筛选")
    public ResponseModel<JSONArray> query() {
        return ResponseHelper.buildResponse(statisticalAnalysisService.queryAdvancedSearch());
    }

    /**
     * 综合统计分析接口分页查询
     *
     * @param map
     * @return
     */
    @TycloudOperation(ApiLevel = UserType.AGENCY)
    @PostMapping(value = "/page")
    @ApiOperation(httpMethod = "POST", value = "综合统计分析接口分页查询", notes = "综合统计分析接口分页查询")
    public ResponseModel<JSONObject> queryForPage(@RequestBody Map<String, Object> map) {
        JSONObject jsonObject = new JSONObject(map);
        return ResponseHelper.buildResponse(statisticalAnalysisService.queryForPage(jsonObject));
    }


}
