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 BuQmsOqcBySnManualProxy implements IBuQmsOqcManageService {

    private IBuQmsOqcManageService oqcManageService;

    public BuQmsOqcBySnManualProxy(IBuQmsOqcManageService qmsOqcManageService) {

        this.oqcManageService = qmsOqcManageService;

    }

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

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

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

        String dataType = (String) params.get(MesPcnExtConstWords.DATA_TYPE);

        log.info("BU-QMS出货检验手动检验查询 --- 成品出货检验 START --- 参数[{}][{}][{}] --- 线程ID[{}]", organizeCode, idStr, dataType, Thread.currentThread().getName());

        SxBuOqcDataModel oqcDataModel = oqcManageService.exec(params);

        log.info("BU-QMS出货检验手动检验查询 --- 成品出货检验 SUCCESS --- result[{}] --- 线程ID[{}]", JSONObject.toJSONString(oqcDataModel), Thread.currentThread().getName());

        return oqcDataModel;
    }

}

@Slf4j
class BuQmsOqcBySnManualWatchProxy implements IBuQmsOqcManageService {

    private IBuQmsOqcManageService oqcManageService;

    public BuQmsOqcBySnManualWatchProxy(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;
    }

}