package com.ruoyi.powerdistribution.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.powerdistribution.domain.vo.PdmLineComplete;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.powerdistribution.domain.PdmLine;
import com.ruoyi.powerdistribution.service.IPdmLineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 可靠性馈线Controller
 *
 * @author ruoyi
 * @date 2024-12-24
 */
@Api(value = "PdmLineController", tags = "线路查询")
@RestController
@RequestMapping("/power/line")
public class PdmLineController extends BaseController
{
    @Autowired
    private IPdmLineService pdmLineService;

    /**
     * 查询可靠性馈线列表
     */
    @PreAuthorize("@ss.hasPermi('system:line:list')")
    @GetMapping("/list")
    public TableDataInfo list(PdmLine pdmLine)
    {
        startPage();
        List<PdmLine> list = pdmLineService.selectPdmLineList(pdmLine);
        return getDataTable(list);
    }

    /**
     * 导出可靠性馈线列表
     */
    @PreAuthorize("@ss.hasPermi('system:line:export')")
    @Log(title = "可靠性馈线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PdmLine pdmLine)
    {
        List<PdmLine> list = pdmLineService.selectPdmLineList(pdmLine);
        ExcelUtil<PdmLine> util = new ExcelUtil<PdmLine>(PdmLine.class);
        util.exportExcel(response, list, "可靠性馈线数据");
    }

    /**
     * 获取可靠性馈线详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:line:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pdmLineService.selectPdmLineById(id));
    }

    /**
     * 新增可靠性馈线
     */
    @PreAuthorize("@ss.hasPermi('system:line:add')")
    @Log(title = "可靠性馈线", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody PdmLine pdmLine)
    {
        return toAjax(pdmLineService.insertPdmLine(pdmLine));
    }

    /**
     * 修改可靠性馈线
     */
    @PreAuthorize("@ss.hasPermi('system:line:edit')")
    @Log(title = "可靠性馈线", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody PdmLine pdmLine)
    {
        return toAjax(pdmLineService.updatePdmLine(pdmLine));
    }

    /**
     * 删除可靠性馈线
     */
    @PreAuthorize("@ss.hasPermi('system:line:remove')")
    @Log(title = "可靠性馈线", businessType = BusinessType.DELETE)
	@GetMapping("delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pdmLineService.deletePdmLineByIds(ids));
    }

    /**
     * 查询线路完成情况列表
     */
    @ApiOperation(value = "查询线路完成情况列表")
    @GetMapping("/selectCompleteList")
    public TableDataInfo selectCompleteList(PdmLineComplete complete)
    {
        startPage();
        List<PdmLineComplete> list = pdmLineService.selectCompleteList(complete);
        return getDataTable(list);
    }

}
