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.TProductInspect;
import com.zehong.system.service.track.ITProductInspectService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 生产执行Controller
 * 
 * @author zehong
 * @date 2024-08-26
 */
@RestController
@RequestMapping("/track/execute")
public class TProductInspectController extends BaseController
{
    @Autowired
    private ITProductInspectService tProductInspectService;

    /**
     * 查询生产执行列表
     */
   // @PreAuthorize("@ss.hasPermi('system:inspect:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProductInspect tProductInspect)
    {
        startPage();
        List<TProductInspect> list = tProductInspectService.selectTProductInspectList(tProductInspect);
        return getDataTable(list);
    }

    @GetMapping("/executeInfoList")
    public AjaxResult executeInfoList(TProductInspect tProductInspect)
    {
        List<TProductInspect> list = tProductInspectService.selectTProductInspectList(tProductInspect);
        return AjaxResult.success(list);
    }

    /**
     * 导出生产执行列表
     */
    //@PreAuthorize("@ss.hasPermi('system:inspect:export')")
    @Log(title = "生产执行", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProductInspect tProductInspect)
    {
        List<TProductInspect> list = tProductInspectService.selectTProductInspectList(tProductInspect);
        ExcelUtil<TProductInspect> util = new ExcelUtil<TProductInspect>(TProductInspect.class);
        return util.exportExcel(list, "生产执行数据");
    }

    /**
     * 获取生产执行详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:inspect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tProductInspectService.selectTProductInspectById(id));
    }

    /**
     * 新增生产执行
     */
    //@PreAuthorize("@ss.hasPermi('system:inspect:add')")
    @Log(title = "生产执行", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProductInspect tProductInspect)
    {
        return toAjax(tProductInspectService.insertTProductInspect(tProductInspect));
    }

    /**
     * 修改生产执行
     */
    //@PreAuthorize("@ss.hasPermi('system:inspect:edit')")
    @Log(title = "生产执行", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProductInspect tProductInspect)
    {
        return toAjax(tProductInspectService.updateTProductInspect(tProductInspect));
    }

    /**
     * 删除生产执行
     */
    //@PreAuthorize("@ss.hasPermi('system:inspect:remove')")
    @Log(title = "生产执行", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProductInspectService.deleteTProductInspectByIds(ids));
    }
}
