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

import cn.estsh.i3plus.ext.mes.pcn.api.busi.yf.IYfManyCellMonitorService;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.impp.framework.base.controller.MesPcnBaseController;
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;

/**
 * @Author: wangjie
 * @CreateDate: 2021/01/19 15:37
 * @Description:
 **/
@RestController
@RequestMapping(CommonConstWords.BASE_URL_MES_PCN)
@Api(tags = "延峰多工位监控生产")
public class YfManyCellMonitorController extends MesPcnBaseController {

    @Autowired
    private IYfManyCellMonitorService manyCellMonitorService;

    @GetMapping(value = "/many-cell-monitor/plc-write")
    @ApiOperation(value = "模拟PLC写值")
    public ResultBean doWritePlc(String organizeCode, String plcCode, String value) {
        try {
            manyCellMonitorService.doWritePlc(organizeCode, plcCode, value);
            return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
        } catch (ImppBusiException busExcep) {
            return ResultBean.fail(busExcep);
        } catch (Exception e) {
            return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
        }
    }

}
