package com.hdkj.lt.bf.controller;

import com.hdkj.lt.bf.entity.dto.SwitchInfoListRequest;
import com.hdkj.lt.bf.service.ExportDataService;
import com.hdkj.lt.bf.service.FhzgFaultTransferSchemeFinalSegmentCurrentDetailService;
import com.hdkj.lt.bf.service.FhzgPlanProcessStateCheckService;
import com.hdkj.hussar.ApiResponse;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author luorui
 * @date 2025/8/22 15:18
 * @discription  导出excel
 *
 **/
@RestController
@RequestMapping("/export")
@RequiredArgsConstructor
public class ExportDataController {

    private final ExportDataService exportDataService;

    private final FhzgFaultTransferSchemeFinalSegmentCurrentDetailService fhzgFaultTransferSchemeFinalSegmentCurrentDetailService;

    private final FhzgPlanProcessStateCheckService fhzgPlanProcessStateCheckService;




    /**
     * 导出终导线段电流校验不通过数据
     * 导出类型 :
     * "plan_loop";//计划合环校验导线段
     * "plan_final";//计划终态校验导线段
     * "fault_final";//故障终态校验导线段
     * @author luorui
     * @date 2025/8/22 10:18
     *
     **/
    @GetMapping("/export-segment-current")
    @ApiOperation(value = "导出导线段电流校验数据")
    public void exportSegmentCurrentList(HttpServletResponse response, @RequestParam("switchingId") Long switchingId, @RequestParam("exportType") String exportType) {
        exportDataService.exportSegmentCurrentList(response, switchingId, exportType);
    }


    /**
     *
     * 导出开关保护定值配置
     * @author luorui
     * @date 2025/9/15 9:17
     **/
    @PostMapping("/export-switch-setting")
    @ApiOperation(value = "导出开关保护定值配置")
    public void exportSwitchSettingList(HttpServletResponse response, @RequestBody SwitchInfoListRequest request ) {
        exportDataService.exportSwitchSetting(response, request);
    }

    /**
     *
     * 导出开关保护定值模板
     * @author luorui
     * @date 2025/9/15 9:17
     *
     **/
    @PostMapping("/export-switch-setting-temp")
    @ApiOperation(value = "导出开关保护定值配置")
    public void exportSwitchSettingTemp(HttpServletResponse response) {
        exportDataService.exportSwitchSettingTemp(response);
    }

    /**
     * 开关保护定值导入
     * @author luorui
     * @date 2025/6/16 14:31
     *
     **/
    @PostMapping("/import-switch-setting")
    @ApiOperation(value = "开关保护定值导入")
    public ApiResponse<String> importSwitchSetting(@RequestParam("file") MultipartFile file) {
        int importCount = exportDataService.importSwitchSetting(file);
        if (importCount > 0) {
            return ApiResponse.success("导入成功");
        } else {
            return ApiResponse.success("导入失败");
        }
    }
}
