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

import cn.estsh.i3plus.ext.mes.pcn.api.base.ISxOrganizeExtService;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
import cn.estsh.impp.framework.base.controller.MesPcnBaseController;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
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;

import java.util.List;

/**
 * @Author: wangjie
 * @CreateDate: 2021/01/19 15:37
 * @Description:
 **/
@RestController
@RequestMapping(CommonConstWords.BASE_URL_MES_PCN + "/ext")
@Api(tags = "SX_组织")
public class SxOrganizeExtController extends MesPcnBaseController {

    @Autowired
    private ISxOrganizeExtService organizeService;

    @GetMapping({"/query-work-cell-by-center"})
    @ApiOperation(
            value = "查询工作单元",
            notes = "查询工作单元"
    )
    public ResultBean queryWorkCell(String workCenterCode) {
        try {
            List<MesWorkCell> areaList = this.organizeService.findWorkCell(AuthUtil.getOrganize().getOrganizeCode(), workCenterCode);
            return ResultBean.success("操作成功").setResultList(areaList).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
        } catch (ImppBusiException var3) {
            return ResultBean.fail(var3);
        } catch (Exception var4) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(var4);
        }
    }

}
