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

import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesOrgService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesOrg;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: 责任人库区关系
 * @Author: gsz
 * @Date: 2024/6/5 10:16
 * @Modify:
 */
@RestController
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mesOrg")
public class MesOrgController {
    @Autowired
    private IMesOrgService mesOrgService;


    @GetMapping(value = "/query")
    @ApiOperation(value = "查询责任人区域关系")
   public ResultBean queryMesProdShiftRecord(MesOrg mesOrg) {
        try {

            List<MesOrg> mesOrgList= mesOrgService.queryMesOrg(mesOrg);
            return ResultBean.success("查询成功")
                    .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(mesOrgList);
        } catch (ImppBusiException e) {
            return ResultBean.fail(e).build();
        } catch (Exception e) {
            return ResultBean.fail(e);
        }
    }

    @GetMapping(value = "/query-split")
    @ApiOperation(value = "查询责任人区域关系（拆分责任人）")
    public ResultBean queryMesOrgSplit(MesOrg mesOrg) {
        try {
            List<MesOrg> mesOrgList= mesOrgService.queryMesOrgSplit(mesOrg);
            return ResultBean.success("查询成功")
                    .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(mesOrgList);
        } catch (ImppBusiException e) {
            return ResultBean.fail(e).build();
        } catch (Exception e) {
            return ResultBean.fail(e);
        }
    }

}
