package com.zehong.web.controller.track;

import java.util.List;

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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.track.TProductPlan;
import com.zehong.system.service.track.ITProductPlanService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 生产计划Controller
 * 
 * @author zehong
 * @date 2024-08-24
 */
@RestController
@RequestMapping("/track/plan")
public class TProductPlanController extends BaseController
{
    @Autowired
    private ITProductPlanService tProductPlanService;

    /**
     * 查询生产计划列表
     */
   // @PreAuthorize("@ss.hasPermi('system:plan:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProductPlan tProductPlan)
    {
        startPage();
        List<TProductPlan> list = tProductPlanService.selectTProductPlanList(tProductPlan);
        return getDataTable(list);
    }

    @GetMapping("/planInfoList")
    public AjaxResult planInfoList(TProductPlan tProductPlan)
    {
        List<TProductPlan> list = tProductPlanService.selectTProductPlanList(tProductPlan);
        return AjaxResult.success(list);
    }

    /**
     * 导出生产计划列表
     */
    //@PreAuthorize("@ss.hasPermi('system:plan:export')")
    @Log(title = "生产计划", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProductPlan tProductPlan)
    {
        List<TProductPlan> list = tProductPlanService.selectTProductPlanList(tProductPlan);
        ExcelUtil<TProductPlan> util = new ExcelUtil<TProductPlan>(TProductPlan.class);
        return util.exportExcel(list, "生产计划数据");
    }

    /**
     * 获取生产计划详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:plan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tProductPlanService.selectTProductPlanById(id));
    }

    /**
     * 新增生产计划
     */
    //@PreAuthorize("@ss.hasPermi('system:plan:add')")
    @Log(title = "生产计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProductPlan tProductPlan)
    {
        return toAjax(tProductPlanService.insertTProductPlan(tProductPlan));
    }

    /**
     * 修改生产计划
     */
    //@PreAuthorize("@ss.hasPermi('system:plan:edit')")
    @Log(title = "生产计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProductPlan tProductPlan)
    {
        return toAjax(tProductPlanService.updateTProductPlan(tProductPlan));
    }

    /**
     * 删除生产计划
     */
    //@PreAuthorize("@ss.hasPermi('system:plan:remove')")
    @Log(title = "生产计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProductPlanService.deleteTProductPlanByIds(ids));
    }
}
