package com.op.wms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.wms.domain.OdsProcureOutOrder;
import com.op.wms.service.IOdsProcureOutOrderService;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.utils.poi.ExcelUtil;
import com.op.common.core.web.page.TableDataInfo;

/**
 * 包材出库单Controller
 * 
 * @author Open Platform
 * @date 2023-07-06
 */
@RestController
@RequestMapping("/outorder")
public class OdsProcureOutOrderController extends BaseController {
	@Autowired
	private IOdsProcureOutOrderService odsProcureOutOrderService;

	/**
	 * 查询包材出库单列表
	 */
	@RequiresPermissions("wms:outorder:list")
	@GetMapping("/list")
	public TableDataInfo list(OdsProcureOutOrder odsProcureOutOrder) {
		startPage();
		List<OdsProcureOutOrder> list = odsProcureOutOrderService.selectOdsProcureOutOrderList(odsProcureOutOrder);
		return getDataTable(list);
	}

	/**
	 * 导出包材出库单列表
	 */
	@RequiresPermissions("wms:outorder:export")
	@Log(title = "包材出库单", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	public void export(HttpServletResponse response, OdsProcureOutOrder odsProcureOutOrder) {
		List<OdsProcureOutOrder> list = odsProcureOutOrderService.selectOdsProcureOutOrderList(odsProcureOutOrder);
		ExcelUtil<OdsProcureOutOrder> util = new ExcelUtil<OdsProcureOutOrder>(OdsProcureOutOrder.class);
		util.exportExcel(response, list, "包材出库单数据");
	}

	/**
	 * 获取包材出库单详细信息
	 */
	@RequiresPermissions("wms:outorder:query")
	@GetMapping(value = "/{ID}")
	public AjaxResult getInfo(@PathVariable("ID") String ID) {
		return success(odsProcureOutOrderService.selectOdsProcureOutOrderByID(ID));
	}

	/**
	 * 新增包材出库单
	 */
	@RequiresPermissions("wms:outorder:add")
	@Log(title = "包材出库单", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody OdsProcureOutOrder odsProcureOutOrder) {
		return toAjax(odsProcureOutOrderService.insertOdsProcureOutOrder(odsProcureOutOrder));
	}

	/**
	 * 修改包材出库单
	 */
	@RequiresPermissions("wms:outorder:edit")
	@Log(title = "包材出库单", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody OdsProcureOutOrder odsProcureOutOrder) {
		return toAjax(odsProcureOutOrderService.updateOdsProcureOutOrder(odsProcureOutOrder));
	}

	/**
	 * 删除包材出库单
	 */
	@RequiresPermissions("wms:outorder:remove")
	@Log(title = "包材出库单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
	public AjaxResult remove(@PathVariable String[] IDs) {
		return toAjax(odsProcureOutOrderService.deleteOdsProcureOutOrderByIDs(IDs));
	}
}
