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

import cn.estsh.i3plus.ext.mes.api.base.bu3.ISxEquipmentCheckService;
import cn.estsh.i3plus.ext.mes.pojo.bean.MesEquipmentCheck;
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.impp.framework.base.controller.MesBaseController;
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 cn.estsh.impp.framework.boot.util.ValidatorBean;
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: wangjie
 * @CreateDate: 2021/01/19 15:37
 * @Description:
 **/
@RestController
@RequestMapping(CommonConstWords.BASE_URL_MES)
@Api(tags = "产品类别计划比例控制层")
public class SxEquipmentCheckController extends MesBaseController {

    @Autowired
    private ISxEquipmentCheckService equipmentCheckService;

    @GetMapping(value = "/sx-ext/equipment-check/equ-info-map/query")
    @ApiOperation(value = "根据生产线查询设备点检设备信息去重信息")
    public ResultBean queryEquipmentCheckEquInfoMap(MesEquipmentCheck equipmentCheck) {
        try {
            ValidatorBean.beginValid(equipmentCheck)
                    .notNull(MesExtConstWords.WORK_CENTER_CODE, equipmentCheck.getWorkCenterCode());
            equipmentCheck.setOrganizeCode(AuthUtil.getOrganize().getOrganizeCode());
            return ResultBean.success("查询成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
                    .setResultMap(equipmentCheckService.queryEquipmentCheckEquInfoMap(equipmentCheck));
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }

}
