package com.hdkj.lt.si.controller.estimation;


import com.hdkj.lt.core.bizms.modle.dto.StateEstimation;
import com.hdkj.lt.core.bizms.modle.po.FhzgFeederAutoSwitchMapping;
import com.hdkj.lt.core.bizms.modle.request.StateEstimationEquipRequest;
import com.hdkj.lt.core.bizms.modle.request.StateEstimationRequest;
import com.hdkj.lt.core.mvc.BaseController;
import com.hdkj.lt.si.service.estimation.StateEstimationService;
import com.hdkj.hussar.ApiResponse;
import lombok.AllArgsConstructor;
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 javax.validation.Valid;
import java.util.List;

/**
 * @Description:
 * @Author: wenhao
 * @Create: 2024/04/19 9:56
 * @Version: 1.0
 */
@RestController
@AllArgsConstructor
@RequestMapping("/stateEstimation")
public class StateEstimationController extends BaseController {

    private final StateEstimationService stateEstimationService;

    @PostMapping(value = "/queryPeriodByFeeder")
//    @AuditLog(moduleName = "分时段查询中压线路下设备节点状估数据", eventDesc = "分时段查询中压线路下设备节点状估数据", eventGrade = AuditEventGrade.SYSTEM_LOG_TYPE, evnetType = AuditEventType.QUERY)
    public ApiResponse<StateEstimation> queryPeriodByFeeder(@Valid @RequestBody StateEstimationRequest request) {
        return data(stateEstimationService.queryByFeeder(request));
    }

    @PostMapping(value = "/queryPeriodByEquip")
//    @AuditLog(moduleName = "分时段查询设备状估数据", eventDesc = "分时段查询设备状估数据", eventGrade = AuditEventGrade.SYSTEM_LOG_TYPE, evnetType = AuditEventType.QUERY)
    public ApiResponse<StateEstimation> queryPeriodByEquip(@Valid @RequestBody StateEstimationEquipRequest request) {
        return data(stateEstimationService.queryPeriodByEquip(request));
    }

    @PostMapping(value = "/queryByFeederSave")
//    @AuditLog(moduleName = "保存前一天线路状估数据", eventDesc = "保存前一天线路状估数据", eventGrade = AuditEventGrade.SYSTEM_LOG_TYPE, evnetType = AuditEventType.QUERY)
    public ApiResponse<StateEstimation> queryByFeederSave(@Valid @RequestBody StateEstimationRequest request) {
        return data(stateEstimationService.queryByFeederSave(request));
    }

    @PostMapping(value = "/querySave")
//    @AuditLog(moduleName = "保存前线路状估数据", eventDesc = "保存前一天线路状估数据", eventGrade = AuditEventGrade.SYSTEM_LOG_TYPE, evnetType = AuditEventType.QUERY)
    public ApiResponse<StateEstimation> querySave(@Valid @RequestBody StateEstimationRequest request) {
        return data(stateEstimationService.querySave(request, request.getStateEstimation()));
    }

    @PostMapping(value = "/saveAutoSwitch")
//    @AuditLog(moduleName = "获取线路自动化开关数据", eventDesc = "获取线路自动化开关数据", eventGrade = AuditEventGrade.SYSTEM_LOG_TYPE, evnetType = AuditEventType.QUERY)
    public ApiResponse<List<FhzgFeederAutoSwitchMapping>> saveAutoSwitch(@Valid @RequestBody StateEstimationRequest request) {
        return data(stateEstimationService.saveAutoSwitch(request));
    }
}
