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

import com.hdkj.hussar.ApiResponse;
import com.hdkj.lt.bf.entity.vo.AlarmFeederVO;
import com.hdkj.lt.bf.service.AlarmEventService;
import com.hdkj.lt.core.mvc.BaseController;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * 告警 Controller
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/alarm")
public class AlarmController extends BaseController {

    private final AlarmEventService alarmEventService;

    /**
     * 查询馈线告警列表（联表 t_psr 获取馈线名称，返回中文 VO）
     *
     * @param params 请求参数，含 date（yyyy-MM-dd）
     * @return 告警 VO 列表
     */
    @PostMapping("/feeders")
    public ApiResponse<List<AlarmFeederVO>> feeders(@RequestBody Map<String, String> params) {
        String date = params.get("date");
        LocalDate alarmDate = LocalDate.parse(date);
        List<AlarmFeederVO> list = alarmEventService.getAlarmFeederList(alarmDate);
        return ApiResponse.success(list);
    }
}
