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

/**
 * 生产执行中间Controller
 * 
 * @author zehong
 * @date 2024-08-26
 */
@RestController
@RequestMapping("/track/executeDetail")
public class TProductInspectDetailController extends BaseController
{
    @Autowired
    private ITProductInspectDetailService tProductInspectDetailService;

    /**
     * 查询生产执行中间列表
     */
   // @PreAuthorize("@ss.hasPermi('system:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProductInspectDetail tProductInspectDetail)
    {
        startPage();
        List<TProductInspectDetail> list = tProductInspectDetailService.selectTProductInspectDetailList(tProductInspectDetail);
        return getDataTable(list);
    }

    /**
     * 导出生产执行中间列表
     */
    //@PreAuthorize("@ss.hasPermi('system:detail:export')")
    @Log(title = "生产执行中间", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProductInspectDetail tProductInspectDetail)
    {
        List<TProductInspectDetail> list = tProductInspectDetailService.selectTProductInspectDetailList(tProductInspectDetail);
        ExcelUtil<TProductInspectDetail> util = new ExcelUtil<TProductInspectDetail>(TProductInspectDetail.class);
        return util.exportExcel(list, "生产执行中间数据");
    }

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

    /**
     * 新增生产执行中间
     */
    //@PreAuthorize("@ss.hasPermi('system:detail:add')")
    @Log(title = "生产执行中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProductInspectDetail tProductInspectDetail)
    {
        return toAjax(tProductInspectDetailService.insertTProductInspectDetail(tProductInspectDetail));
    }

    /**
     * 修改生产执行中间
     */
    //@PreAuthorize("@ss.hasPermi('system:detail:edit')")
    @Log(title = "生产执行中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProductInspectDetail tProductInspectDetail)
    {
        return toAjax(tProductInspectDetailService.updateTProductInspectDetail(tProductInspectDetail));
    }

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

    @PostMapping("/batchAddDetailInfo")
    public AjaxResult batchAddDetailInfo(@RequestBody List<TProductInspectDetail> productInspectDetailList) {
        return toAjax(tProductInspectDetailService.batchAddDetailInfo(productInspectDetailList));
    }
}
