package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.bu.oqc;

import cn.estsh.i3plus.ext.mes.pcn.api.busi.bu.IBuQmsOqcManageService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.bu.SxBuOqcDataModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StopWatch;

import java.util.Map;

/**
 * @Description 出货检验 主数据 组件 实现 静态代理
 * @author wangjie
 * @version 1.0
 * @date 2021/1/13 9:28
 **/
@Slf4j
public class BuQmsOqcByZjManageProxy implements IBuQmsOqcManageService {

    private IBuQmsOqcManageService oqcManageService;

    public BuQmsOqcByZjManageProxy(IBuQmsOqcManageService oqcManageService) {

        this.oqcManageService = oqcManageService;

    }

    @Override
    public SxBuOqcDataModel exec(Map<String, Object> params) {

        String organizeCode = (String) params.get(MesPcnExtConstWords.ORGANIZE_CODE);

        String idStr = (String) params.get(MesPcnExtConstWords.VALUE);

        log.info("BU-QMS出货检验主数据 --- 组件出货检验 --- 参数[{}][{}] --- 线程ID[{}]", organizeCode, idStr, Thread.currentThread().getName());

        SxBuOqcDataModel oqcDataModel = oqcManageService.exec(params);

        log.info("BU-QMS出货检验主数据 --- 组件出货检验 --- result[{}] --- 线程ID[{}]", JSONObject.toJSONString(oqcDataModel), Thread.currentThread().getName());

        return oqcDataModel;
    }

}

@Slf4j
class BuQmsOqcByZjManageWatchProxy implements IBuQmsOqcManageService {

    private IBuQmsOqcManageService oqcManageService;

    public BuQmsOqcByZjManageWatchProxy(IBuQmsOqcManageService oqcManageService) {

        this.oqcManageService = oqcManageService;

    }

    @Override
    public SxBuOqcDataModel exec(Map<String, Object> params) {

        StopWatch stopWatch = new StopWatch();

        stopWatch.start();

        SxBuOqcDataModel oqcDataModel = oqcManageService.exec(params);

        stopWatch.stop();

        log.info("BU-QMS出货检验主数据 --- 组件出货检验 SUCCESS --- 耗时[{}] --- 线程ID[{}]", stopWatch.getTotalTimeMillis(), Thread.currentThread().getName());

        return oqcDataModel;
    }

}
