package com.steerinfo.ems.ifmesemswatermonitor.controller;

import com.steerinfo.ems.ifmesemswatermonitor.model.IfMesEmsWatermonitor;
import com.steerinfo.ems.ifmesemswatermonitor.service.IIfMesEmsWatermonitorService;
import com.steerinfo.framework.controller.BaseRESTfulController;
import com.steerinfo.framework.controller.RESTfulResult;
import com.steerinfo.framework.service.pagehelper.PageList;
import com.steerinfo.framework.utils.collection.ListUtils;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * IfMesEmsWatermonitor RESTful接口：
 * @author generator
 * @version 1.0-SNAPSHORT 2019-12-02 02:52
 * 类描述
 * 修订历史：
 * 日期：2019-12-02
 * 作者：generator
 * 参考：
 * 描述：IfMesEmsWatermonitor RESTful接口
 * @see null
 * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
 */
@RestController
@RequestMapping("/${api.version}/ifmesemswatermonitors")
public class IfMesEmsWatermonitorController extends BaseRESTfulController {

    @Autowired
    IIfMesEmsWatermonitorService ifMesEmsWatermonitorService;

    @ApiOperation(value="获取列表", notes="分页查询")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
        @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("ifmesemswatermonitor:view")
    @GetMapping(value = "/")
    public RESTfulResult list(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
        PageList<IfMesEmsWatermonitor> list = ifMesEmsWatermonitorService.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("ifmesemswatermonitor:view")
    @GetMapping(value = "/like/")
    public RESTfulResult listLike(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
        PageList<IfMesEmsWatermonitor> list = ifMesEmsWatermonitorService.queryLikeForPage(parmas, pageNum, pageSize);
        return success(list);
    }

    @ApiOperation(value="立即从MES同步数据", notes="从MES同步生产计划数据")
    @GetMapping(value = "/synchronousMesAnEmsData/")
    public RESTfulResult synchronousMesAnEmsData(){
        int getnum = ifMesEmsWatermonitorService.synchronousMesAnEmsData();
        if (getnum == -1){
            return failed(null, "本次未获取到数据！");
        }
        return success();
    }
}
