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

import cn.estsh.i3plus.ext.mes.api.busi.bu3.ISxShiftProdCenterRecordService;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
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.*;

import java.util.List;

/**
 * @PROJECT_NAME: i3plus-mes-panasonic-dev
 * @DESCRIPTION:
 * @USER: xinwang.yi
 * @DATE: 2023-05-15 11:24
 */
@RestController
@RequestMapping(CommonConstWords.BASE_URL_MES)
@Api(tags = "获取停开机记录控制层")
public class SxShiftProdCenterController {

    @Autowired
    private ISxShiftProdCenterRecordService sxShiftProdCenterRecordService;

    @GetMapping(value = "/sx/ext/shift-prod-center-record/query-by-andon-order-no")
    @ApiOperation(value = "根据andon编号获取停开机记录")
    public ResultBean queryLossTimeMonthly(@RequestParam("andonQueueNo") List<String> andonQueueNoList, @RequestParam("organizeCode") String organizeCode) {
        try {
            ValidatorBean.checkNotNull(andonQueueNoList, "安灯编号不能为空");
            ValidatorBean.checkNotNull(organizeCode, "工厂代码不能为空");
            return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
                    .setResultList(sxShiftProdCenterRecordService.queryShiftProdCenterRecordListByAndonOrderNo(andonQueueNoList, organizeCode));
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }
}
