package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.base.jx;

import cn.estsh.i3plus.ext.mes.pcn.api.base.jx.IJxBadnessClassifyDetailService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.jx.IJxBadnessClassifyService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.jx.IJxBadnessTypeService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesBadnessClassify;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesBadnessClassifyDetail;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesBadnessType;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.impp.framework.base.controller.MesPcnBaseController;
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;

/**
 * @PROJECT_NAME: i3plus-mes-panasonic-jx
 * @DESCRIPTION:
 * @USER: xinwang.yi
 * @DATE: 2023-11-06 16:23
 */
@RestController
@RequestMapping(MesPcnExtConstWords.BASE_URL_MES_PCN_JX)
@Api(tags = "班次信息")
public class JxBadnessTypeController extends MesPcnBaseController {

    @Autowired
    private IJxBadnessTypeService badnessTypeService;

    @Autowired
    private IJxBadnessClassifyService badnessClassifyService;

    @Autowired
    private IJxBadnessClassifyDetailService badnessClassifyDetailService;

    @GetMapping(value = "/badness-type/query")
    @ApiOperation(value = "分页查询不良类型")
    public ResultBean queryBuBadnessTypePager(MesBadnessType badnessType, Pager pager) {
        try {
            return ResultBean.success("查询成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
                    .setListPager(badnessTypeService.queryBadnessTypePager(badnessType, pager));
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }

    @GetMapping(value = "/badness-classify/query")
    @ApiOperation(value = "分页查询不良分类")
    public ResultBean queryBadnessClassifyPager(MesBadnessClassify badnessClassify, Pager pager) {
        try {
            return ResultBean.success("查询成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
                    .setListPager(badnessClassifyService.queryBuBadnessClassifyPager(badnessClassify, pager));
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }

    @GetMapping(value = "/badness-classify-detail/query")
    @ApiOperation(value = "分页查询不良分类明细")
    public ResultBean queryBadnessClassifyDetailPager(MesBadnessClassifyDetail badnessClassifyDetail, Pager pager) {
        try {
            return ResultBean.success("查询成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
                    .setListPager(badnessClassifyDetailService.queryBadnessClassifyDetailPager(badnessClassifyDetail, pager));
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }

}
