package com.aucma.dms.controller;

import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.core.page.TableDataInfo;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.dms.domain.DmsBaseLubeStandard;
import com.aucma.dms.domain.DmsBaseLubeStation;
import com.aucma.dms.domain.DmsPlanLubeDetail;
import com.aucma.dms.service.IDmsBaseLubeStandardService;
import com.aucma.dms.service.IDmsBaseLubeStationService;
import com.aucma.dms.service.IDmsPlanLubeDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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




/**
 * 润滑计划明细Controller
 *
 * @author xins
 * @date 2024-03-21
 */
@RestController
@RequestMapping("/dms/dmsPlanLubeDetail")
public class DmsPlanLubeDetailController extends BaseController
{

    @Autowired
    private IDmsPlanLubeDetailService dmsPlanLubeDetailService;

    @Autowired
    private IDmsBaseLubeStandardService dmsBaseLubeStandardService;

    @Autowired
    private IDmsBaseLubeStationService dmsBaseLubeStationService;


    /**
     * 查询润滑计划明细列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanLubeDetail:list')" )
    @GetMapping("/list")
    public TableDataInfo list(DmsPlanLubeDetail dmsPlanLubeDetail)
    {
        startPage();
        List<DmsPlanLubeDetail> list = dmsPlanLubeDetailService.selectDmsPlanLubeDetailList(dmsPlanLubeDetail);
        return getDataTable(list);
    }

    /**
     * 导出润滑计划明细列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanLubeDetail:export')" )
    ////@Log(title = "润滑计划明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsPlanLubeDetail dmsPlanLubeDetail)
    {
        List<DmsPlanLubeDetail> list = dmsPlanLubeDetailService.selectDmsPlanLubeDetailList(dmsPlanLubeDetail);
        ExcelUtil<DmsPlanLubeDetail> util = new ExcelUtil<DmsPlanLubeDetail>(DmsPlanLubeDetail.class);
        util.exportExcel(response, list, "润滑计划明细数据");
    }

    /**
     * 获取润滑计划明细详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanLubeDetail:query')" )
    @GetMapping(value = "/{planLubeDetailId}")
    public AjaxResult getInfo(@PathVariable("planLubeDetailId") Long planLubeDetailId)
    {
        return success(dmsPlanLubeDetailService.selectDmsPlanLubeDetailByPlanLubeDetailId(planLubeDetailId));
    }
    /**
     * 根据计划id查询明细
     * */
    @GetMapping("/getDmsPlanDetailByPlanLubeId/{planLubeId}")
    public TableDataInfo selectPlanLubeDetailByPlanLubeId(@PathVariable("planLubeId") Long planLubeId){

        List<DmsPlanLubeDetail> dmsPlanLubeDetails = dmsPlanLubeDetailService.selectPlanLubeDetailByPlanLubeId(planLubeId);
        return getDataTable(dmsPlanLubeDetails);
    }

    /**
     * 新增润滑计划明细
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanLubeDetail:add')" )
    ////@Log(title = "润滑计划明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsPlanLubeDetail dmsPlanLubeDetail)
    {
        return toAjax(dmsPlanLubeDetailService.insertDmsPlanLubeDetail(dmsPlanLubeDetail));
    }

    /**
     * 修改润滑计划明细
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanLubeDetail:edit')" )
    ////@Log(title = "润滑计划明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsPlanLubeDetail dmsPlanLubeDetail)
    {
        return toAjax(dmsPlanLubeDetailService.updateDmsPlanLubeDetail(dmsPlanLubeDetail));
    }

    /**
     * 删除润滑计划明细
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanLubeDetail:remove')" )
    ////@Log(title = "润滑计划明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{planLubeDetailIds}")
    public AjaxResult remove(@PathVariable Long[] planLubeDetailIds)
    {
        return toAjax(dmsPlanLubeDetailService.deleteDmsPlanLubeDetailByPlanLubeDetailIds(planLubeDetailIds));
    }





    /**
     * 获取润滑标准列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanLubeDetail:query')" )
    @GetMapping(value = "/getLubeStations")
    public AjaxResult getLubeStations(DmsBaseLubeStation dmsBaseLubeStation)
    {
        return success(dmsBaseLubeStationService.selectDmsBaseLubeStationList(dmsBaseLubeStation));
    }


    /**
     * 获取润滑部位列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsPlanLubeDetail:query')" )
    @GetMapping(value = "/getLubeStandards")
    public AjaxResult getLubeStandards(DmsBaseLubeStandard dmsBaseLubeStandard)
    {
        return success(dmsBaseLubeStandardService.selectDmsBaseLubeStandardList(dmsBaseLubeStandard));
    }


}
