czt
2025-06-11 283da741b2429cf5a53786e5ee1b5528b757fdf6
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
package com.fzzy.igds.dzhwk.v1;
 
import com.fzzy.igds.dzhwk.v1.dto.ApiV1ReqDto;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
 
/**
 * @Description 解析数据接口分发
 * @Author CZT
 * @Date 2025/6/04 16:10
 */
@Component
public class ApiV1Manager implements ApplicationContextAware {
 
    private static Map<String, ApiV1Service> serviceMap;
 
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        Map<String, ApiV1Service> map = applicationContext
                .getBeansOfType(ApiV1Service.class);
        serviceMap = new HashMap<>();
        for (String key : map.keySet()) {
            serviceMap.put(map.get(key).getInterfaceId(), map.get(key));
        }
    }
 
    /**
     * 业务执行入口
     * @param
     * @return
     * @throws Exception
     */
    @Async
    public void analysis(String interfaceId, String dataStr, ApiV1ReqDto reqDto){
 
        ApiV1Service service = serviceMap.get(interfaceId);
        if(null == service){
            return;
        }
        service.analysis(dataStr, reqDto);
    }
 
}