package cn.estsh.i3plus.ext.mes.apiservice.controller.busi.ems;

import cn.estsh.i3plus.ext.mes.api.busi.ems.IEmsCloudService;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Dominic
 * @description ems微服务提供controller
 * @createDate 2022/7/14 14:25
 */
@RestController
@Api(tags = "ems微服务提供")
@RequestMapping(CommonConstWords.BASE_URL_MES + "/ems-cloud")
public class EmsCloudController {

    @Autowired
    private IEmsCloudService emsCloudService;

    /**
     * 获取上一年月度总产量
     *
     * @param annual  年度
     * @param monthly 月度
     * @return 产量
     */
    @GetMapping(value = "/get-last-monthly-output")
    @ApiOperation(value = "获取上一年月度总产量")
    public ResultBean getLastMonthlyOutput(Integer annual, Integer monthly) {
        try {
            return ResultBean.success("查询成功").setResultObject(emsCloudService.getLastMonthlyOutput(annual, monthly))
                    .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }
}
