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.PowderChargeOrder;
import com.op.wms.service.IPowderChargeOrderService;
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-10
 */
@RestController
@RequestMapping("/chargeorder")
public class PowderChargeOrderController extends BaseController {
	@Autowired
	private IPowderChargeOrderService powderChargeOrderService;

	/**
	 * 查询粉料配料列表
	 */
	@RequiresPermissions("wms:chargeorder:list")
	@GetMapping("/list")
	public TableDataInfo list(PowderChargeOrder powderChargeOrder) {
		startPage();
		List<PowderChargeOrder> list = powderChargeOrderService.selectPowderChargeOrderList(powderChargeOrder);
		return getDataTable(list);
	}

	/**
	 * 导出粉料配料列表
	 */
	@RequiresPermissions("wms:chargeorder:export")
	@Log(title = "粉料配料", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	public void export(HttpServletResponse response, PowderChargeOrder powderChargeOrder) {
		List<PowderChargeOrder> list = powderChargeOrderService.selectPowderChargeOrderList(powderChargeOrder);
		ExcelUtil<PowderChargeOrder> util = new ExcelUtil<PowderChargeOrder>(PowderChargeOrder.class);
		util.exportExcel(response, list, "粉料配料数据");
	}

	/**
	 * 获取粉料配料详细信息
	 */
	@RequiresPermissions("wms:chargeorder:query")
	@GetMapping(value = "/{ID}")
	public AjaxResult getInfo(@PathVariable("ID") String ID) {
		return success(powderChargeOrderService.selectPowderChargeOrderByID(ID));
	}

	/**
	 * 新增粉料配料
	 */
	@RequiresPermissions("wms:chargeorder:add")
	@Log(title = "粉料配料", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody PowderChargeOrder powderChargeOrder) {
		return toAjax(powderChargeOrderService.insertPowderChargeOrder(powderChargeOrder));
	}

	/**
	 * 修改粉料配料
	 */
	@RequiresPermissions("wms:chargeorder:edit")
	@Log(title = "粉料配料", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody PowderChargeOrder powderChargeOrder) {
		return toAjax(powderChargeOrderService.updatePowderChargeOrder(powderChargeOrder));
	}

	/**
	 * 删除粉料配料
	 */
	@RequiresPermissions("wms:chargeorder:remove")
	@Log(title = "粉料配料", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
	public AjaxResult remove(@PathVariable String[] IDs) {
		return toAjax(powderChargeOrderService.deletePowderChargeOrderByIDs(IDs));
	}
}
