package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi.jx;

import cn.estsh.i3plus.ext.mes.api.busi.jx.IJxCenterWorkingBoardService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StopWatch;

import java.util.Map;

/**
 * @Author : wangjie
 * @CreateDate : 2022-02-15
 * @Modify:
 **/
@Slf4j
public class JxCenterWorkingBoardWatchService implements IJxCenterWorkingBoardService {

    private IJxCenterWorkingBoardService proxyService;

    public JxCenterWorkingBoardWatchService(IJxCenterWorkingBoardService proxyService) {
        this.proxyService = proxyService;
    }

    @Override
    public Map<String, Object> queryCenterWorkingBoardData(Map<String, Object> dataMap) {

        log.info("嘉兴产线运行看板 --- WATCH START --- DATA:{} --- THREAD:{}", JSONObject.toJSONString(dataMap), Thread.currentThread().getName());

        StopWatch stopWatch = new StopWatch();

        stopWatch.start();

        try {

            dataMap = proxyService.queryCenterWorkingBoardData(dataMap);

        } catch (Exception e) {

            log.info("嘉兴产线运行看板 --- WATCH EXCEPTION --- {} --- THREAD:{} --- {} ---", e.toString(), Thread.currentThread().getName(), "\r\n" + JSONObject.toJSONString(e));

        } finally {

            stopWatch.stop();

            log.info("嘉兴产线运行看板 --- WATCH END --- 耗时:{}ms --- DATA:{} --- THREAD:{}", stopWatch.getTotalTimeMillis(), JSONObject.toJSONString(dataMap), Thread.currentThread().getName());

        }

        return dataMap;

    }

}
