ProcessService.java
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.viontech.process;
import com.alibaba.fastjson.JSONObject;
import com.viontech.model.BaseModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* .
*
* @author 谢明辉
* @date 2020/8/31
*/
@Service
@Slf4j
public class ProcessService {
@Resource
private Process behaviorProcess;
@Resource
private Process trafficProcess;
@Resource
private Process flowProcess;
/**
* 分类处理繁星发来的数据
*
* @param jsonStr 繁星发来的数据
*
* @return 转换成对接方需要的
*/
public BaseModel process(String jsonStr) throws Exception {
JSONObject jsonObject = JSONObject.parseObject(jsonStr);
String eventCate = jsonObject.getString("event_cate");
String eventType = jsonObject.getString("event_type");
if (eventCate == null) {
return null;
}
switch (eventCate) {
case "traffic":
if ("vehicle".equals(eventType)) {
return trafficProcess.process(jsonObject);
} else if ("tflow".equals(eventType)) {
return flowProcess.process(jsonObject);
}
return null;
case "behavior":
return behaviorProcess.process(jsonObject);
default:
return null;
}
}
}