package com.zg.project.Inventory.Visualization.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
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.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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.zg.framework.aspectj.lang.annotation.Log;
import com.zg.framework.aspectj.lang.enums.BusinessType;
import com.zg.project.Inventory.Visualization.domain.Pln;
import com.zg.project.Inventory.Visualization.service.IPlnService;
import com.zg.framework.web.controller.BaseController;
import com.zg.framework.web.domain.AjaxResult;
import com.zg.common.utils.poi.ExcelUtil;
import com.zg.framework.web.page.TableDataInfo;

/**
 * 计划履约Controller
 * 
 * @author zg
 * @date 2025-05-09
 */
@RestController
@RequestMapping("/Visual/pln")
public class PlnController extends BaseController
{
    @Autowired
    private IPlnService plnService;

    /**
     * 查询计划履约列表
     */
    @PreAuthorize("@ss.hasPermi('Visualization:pln:list')")
    @GetMapping("/list")
    public TableDataInfo list(Pln pln)
    {
        startPage();
        List<Pln> list = plnService.selectPlnList(pln);
        return getDataTable(list);
    }

    /**
     * 查询所有供应计划
     */
    @GetMapping("/plnQueryAll")
    public AjaxResult queryAll() {

        Map<String, Object> resultMap = plnService.getAll();

        return AjaxResult.success(resultMap);
    }

    /**
     * 导出计划履约列表
     */
    @PreAuthorize("@ss.hasPermi('Visualization:pln:export')")
    @Log(title = "计划履约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Pln pln)
    {
        List<Pln> list = plnService.selectPlnList(pln);
        ExcelUtil<Pln> util = new ExcelUtil<Pln>(Pln.class);
        util.exportExcel(response, list, "计划履约数据");
    }

    /**
     * 获取计划履约详细信息
     */
    @PreAuthorize("@ss.hasPermi('Visualization:pln:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(plnService.selectPlnById(id));
    }

    /**
     * 新增计划履约
     */
    @PreAuthorize("@ss.hasPermi('Visualization:pln:add')")
    @Log(title = "计划履约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Pln pln)
    {
        return toAjax(plnService.insertPln(pln));
    }

    /**
     * 修改计划履约
     */
    @PreAuthorize("@ss.hasPermi('Visualization:pln:edit')")
    @Log(title = "计划履约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Pln pln)
    {
        return toAjax(plnService.updatePln(pln));
    }

    /**
     * 删除计划履约
     */
    @PreAuthorize("@ss.hasPermi('Visualization:pln:remove')")
    @Log(title = "计划履约", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(plnService.deletePlnByIds(ids));
    }
}
