package com.steerinfo.ems.ifmesemsproductorder.controller;

import java.util.Arrays;
import java.util.HashMap;

import com.steerinfo.ems.ifmesemsproductorder.model.IfMesEmsProductorder;
import com.steerinfo.ems.ifmesemsproductorder.service.IIfMesEmsProductorderService;
import com.steerinfo.framework.controller.BaseRESTfulController;
import com.steerinfo.framework.controller.RESTfulResult;
import com.steerinfo.framework.service.pagehelper.PageList;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/${api.version}/ifmesemsproductorder")
public class IfMesEmsProductorderController extends BaseRESTfulController {

    @Autowired
    IIfMesEmsProductorderService ifMesEmsProductorderService;

    @ApiOperation(value="获取列表", notes="分页查询")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
        @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("trmunit:view")
    @GetMapping(value = "/")
    public RESTfulResult list(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
        PageList<IfMesEmsProductorder> list = ifMesEmsProductorderService.queryForPage(parmas, pageNum, pageSize);
        return success(list);
    }
    
    @ApiOperation(value="获取列表", notes="分页模糊查询")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
        @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("tpmcaseact:view")
    @GetMapping(value = "/like/")
    public RESTfulResult listLike(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
        PageList<IfMesEmsProductorder> list = ifMesEmsProductorderService.queryLikeForPage(parmas, pageNum, pageSize);
        return success(list);
    }
    
    // @ApiOperation(value="创建", notes="根据IfMesEmsProductorder对象创建")
    // @ApiImplicitParam(name = "IfMesEmsProductorder", value = "详细实体IfMesEmsProductorder", required = true, dataType = "IfMesEmsProductorder")
    // //@RequiresPermissions("trmunit:create")
    // @PostMapping(value = "/")
    // public RESTfulResult add(@ModelAttribute IfMesEmsProductorder model){
    //     IfMesEmsProductorder IfMesEmsProductorder = ifMesEmsProductorderService.add(model);
    //     return success(IfMesEmsProductorder);
    // }

    @ApiOperation(value="立即从MES同步数据", notes="从MES同步生产计划数据")
    @PostMapping(value = "/synchronousMesAnEmsData")
    public RESTfulResult synchronousMesAnEmsData(@ModelAttribute IfMesEmsProductorder model){
        String s = ifMesEmsProductorderService.synchronousMesAnEmsData();
        return success(s);
    }


}
