package com.zbf.web.controller.system;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import com.zbf.web.controller.section.EnhanceDataList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zbf.common.annotation.Log;
import com.zbf.common.core.controller.BaseController;
import com.zbf.common.core.domain.AjaxResult;
import com.zbf.common.core.page.TableDataInfo;
import com.zbf.common.enums.BusinessType;
import com.zbf.common.utils.OrderCodeFactory;
import com.zbf.common.utils.poi.ExcelUtil;
import com.zbf.system.domain.TOngoodsshelfBak;
import com.zbf.system.service.ITOngoodsshelfBakService;

/**
 * 入库任务历史Controller
 *
 * @author tony
 * @date 2024-06-18
 */
@RestController
@RequestMapping("/system/tOnGoodsShelfbak")
public class TOngoodsshelfBakController extends BaseController
{
    @Autowired
    private ITOngoodsshelfBakService tOngoodsshelfBakService;

/**
 * 查询入库任务历史列表
 */
//@PreAuthorize("@ss.hasPermi('system:tOnGoodsShelfbak:list')")
@GetMapping("/list")
@EnhanceDataList(entityType = TOngoodsshelfBak.class)
    public TableDataInfo list(TOngoodsshelfBak tOngoodsshelfBak)
    {
        startPage();
        tOngoodsshelfBak.setDeptId(getDeptId());
        if (tOngoodsshelfBak.getDate()!=null){
            String[] date = tOngoodsshelfBak.getDate();
            tOngoodsshelfBak.setStartTime(date[0]);
            tOngoodsshelfBak.setEndTime(date[1]);
        }
        List<TOngoodsshelfBak> list = tOngoodsshelfBakService.selectTOngoodsshelfBakList(tOngoodsshelfBak);
        return getDataTable(list);
    }

    /**
     * 导出入库任务历史列表
     */
    @PreAuthorize("@ss.hasPermi('system:tOnGoodsShelfbak:export')")
    @Log(title = "入库任务历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TOngoodsshelfBak tOngoodsshelfBak)
    {
        tOngoodsshelfBak.setDeptId(getDeptId());
        List<TOngoodsshelfBak> list = tOngoodsshelfBakService.selectTOngoodsshelfBakList(tOngoodsshelfBak);
        ExcelUtil<TOngoodsshelfBak> util = new ExcelUtil<TOngoodsshelfBak>(TOngoodsshelfBak.class);
        util.exportExcel(response, list, "入库任务历史数据");
    }

    /**
     * 获取入库任务历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tOnGoodsShelfbak:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tOngoodsshelfBakService.selectTOngoodsshelfBakById(id));
    }

    /**
     * 新增入库任务历史
     */
    @PreAuthorize("@ss.hasPermi('system:tOnGoodsShelfbak:add')")
    @Log(title = "入库任务历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TOngoodsshelfBak tOngoodsshelfBak)
    {
        tOngoodsshelfBak.setId(OrderCodeFactory.getOrderCode("SHELF", ""));
        return toAjax(tOngoodsshelfBakService.insertTOngoodsshelfBak(tOngoodsshelfBak));
    }

    /**
     * 修改入库任务历史
     */
    @PreAuthorize("@ss.hasPermi('system:tOnGoodsShelfbak:edit')")
    @Log(title = "入库任务历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TOngoodsshelfBak tOngoodsshelfBak)
    {
        return toAjax(tOngoodsshelfBakService.updateTOngoodsshelfBak(tOngoodsshelfBak));
    }

    /**
     * 删除入库任务历史
     */
    @PreAuthorize("@ss.hasPermi('system:tOnGoodsShelfbak:remove')")
    @Log(title = "入库任务历史", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tOngoodsshelfBakService.deleteTOngoodsshelfBakByIds(ids));
    }

    /**
     * 启用
     */
    @PreAuthorize("@ss.hasPermi('system:tOnGoodsShelfbak:remove')")
    @Log(title = "入库任务历史", businessType = BusinessType.UPDATE)
    @DeleteMapping("/disable/{ids}")
    public AjaxResult disable(@PathVariable String[] ids)
    {
        return toAjax(tOngoodsshelfBakService.disabledTOngoodsshelfBakByIds(ids));
    }

    /**
     * 禁用
     */
    @PreAuthorize("@ss.hasPermi('system:tOnGoodsShelfbak:edit')")
    @Log(title = "入库任务历史", businessType = BusinessType.UPDATE)
    @DeleteMapping("/enable/{ids}")
    public AjaxResult enable(@PathVariable String[] ids)
    {
        return toAjax(tOngoodsshelfBakService.enableTOngoodsshelfBakByIds(ids));
    }

    /**
     * 修改状态
     */
    @PreAuthorize("@ss.hasPermi('system:tOnGoodsShelfbak:edit')")
    @Log(title = "入库任务历史", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody TOngoodsshelfBak tOngoodsshelfBak) {
        return toAjax(tOngoodsshelfBakService.updateStatus(tOngoodsshelfBak));
    }

}

