package com.sw.mes.fb.aio.controller;

import com.sw.mes.core.response.Result;
import com.sw.mes.core.response.ResultGenerator;
import com.sw.mes.fb.aio.entity.AioCheckSectionState;
import com.sw.mes.fb.aio.service.AioCheckSectionStateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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;

@Slf4j
@RestController
@RequestMapping("/mes/aio")
@Api(description = "一体机对外接口")
public class AioController {


    @Autowired
    private AioCheckSectionStateService aioCheckSectionStateService;


    @ApiOperation(value = "检验查询加工履历信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sectionNo", value = "晶段编号", dataType = "String", paramType = "query"),
    })
    @GetMapping(value = "/findCheckStateBySectionNo")
    public Result findCheckStateBySectionNo(String sectionNo) {
        if (StringUtils.isBlank(sectionNo)) {
            return ResultGenerator.fail("晶段编号为空！");
        }
        AioCheckSectionState state = aioCheckSectionStateService.findBySectionNoGroup(sectionNo);
        if (state != null) {
            return ResultGenerator.success(state);
        }
        return ResultGenerator.success();
    }
}
