package com.hdkj.lt.bf.controller.optimization;

import com.hdkj.hussar.ApiResponse;
import com.hdkj.lt.bf.entity.vo.StaticGridDashboardVO;
import com.hdkj.lt.bf.service.staticgrid.StaticGridDashboardService;
import com.hdkj.lt.core.mvc.BaseController;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 静态网架评估仪表盘 Controller
 *
 * @author lsl
 * @since 2026-07-19
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/static-grid")
public class StaticGridController extends BaseController {

    private final StaticGridDashboardService staticGridDashboardService;

    /**
     * 查询静态网架评估仪表盘
     * <p>
     * 入参可选：
     * <ul>
     *   <li>batchId — 查指定批次，为空则查最新一次</li>
     * </ul>
     *
     * @param params 请求参数
     * @return 仪表盘 VO
     */
    @PostMapping("/dashboard")
    public ApiResponse<StaticGridDashboardVO> dashboard(@RequestBody Map<String, String> params) {
        String id = params.get("id");
        String type = params.get("type");
        StaticGridDashboardVO vo = staticGridDashboardService.queryLatestDashboard(id, type);
        return ApiResponse.success(vo);
    }
}
