package org.ts.ddcs.worker;


import com.alibaba.fastjson.JSONObject;
import org.ts.ddcs.log.LogHelper;

import java.util.concurrent.Callable;


public class LogSpliteWorker implements Callable<Integer> {

    private String log;

    LogSpliteWorker(String log) {
        this.log = log;
    }

    @Override
    public Integer call() throws Exception {
        try {
//            JSONObject jsonLog = new JSONObject();
//            String tm = log.substring(0, "yyyy-mm-dd hh:MM:ss.mmm ".length());
//            jsonLog.put("logTime", tm);
//            String log_content = log.substring("yyyy-mm-dd hh:MM:ss.mmm ".length());
//            int offest = log_content.indexOf("success pick datagram") + "success pick datagram".length();
//            String jsonStr = log_content.substring(offest);
//            JSONObject json = JSONObject.parseObject(jsonStr);
//            jsonLog.put("datagram", json.getString("datagram"));
//            if (json.containsKey("version")) {
//                jsonLog.put("agreement", json.getString("version"));
//            } else if (json.containsKey("agreement")) {
//                jsonLog.put("agreement", json.getString("agreement"));
//            } else {
//                jsonLog.put("agreement", json.getString(""));
//            }
//            jsonLog.put("rtu", json.getString("rtuCode"));
//            DataProcessHolder.newInstance().dataProcess.SubmitMapTask(jsonLog);
        } catch (Exception e) {
            LogHelper.error(e);
        }
        return 0;
    }
}
