Process.java 1.05 KB
package com.viontech.process;

import com.alibaba.fastjson.JSONObject;
import com.viontech.model.BaseModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * .
 *
 * @author 谢明辉
 * @date 2020/8/20
 */
public interface Process {
    Logger log = LoggerFactory.getLogger(Process.class);

    /**
     * 分类处理繁星发来的数据
     *
     * @param jsonStr 繁星发来的数据
     *
     * @return 转换成对接方需要的
     */
    static BaseModel process(String jsonStr) throws Exception {
        JSONObject jsonObject = JSONObject.parseObject(jsonStr);
        String eventCate = jsonObject.getString("event_cate");
        if (eventCate == null) {
            return null;
        }
        switch (eventCate) {
            case "traffic":
                return new TrafficProcess().process(jsonObject);
            case "behavior":
                return new BehaviorProcess().process(jsonObject);
            default:
                return null;
        }
    }

    BaseModel process(JSONObject jsonObject) throws Exception;
}