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

import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkCenterService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
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 lombok.extern.slf4j.Slf4j;
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;

/**
 * @Description :
 * @Reference :
 * @Author :
 * @CreateDate : 2024-05-30 13:46
 * @Modify:
 **/
@RestController
@Api(tags = "工单")
@RequestMapping(MesCommonConstant.MES_YANFEN + "/work-center")
@Slf4j
public class MesWorkCenterController {

    @Autowired
    private IMesWorkCenterService workCenterService;


    @GetMapping("/query")
    @ApiOperation(value = "查询工单")
    public ResultBean queryWorkOrder(MesWorkCenter workCenter) {

        try {

            return ResultBean.success("查询DefectActionService成功").setResultList(workCenterService.queryMesWorkCenterList(workCenter));
        } catch (ImppBusiException imppException) {
            return ResultBean.fail(imppException);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }

    @GetMapping("/query-pager")
    @ApiOperation(value = "查询产线")
    public ResultBean queryWorkOrderByPager(MesWorkCenter workCenter, Pager pager) {

        try {

            return ResultBean.success("查询成功").setListPager(workCenterService.queryMesWorkCenterByPager(workCenter, pager));
        } catch (ImppBusiException imppException) {
            return ResultBean.fail(imppException);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }



}
