CZT
2023-09-06 71c4fa1e27f75ae4b765c95c67a3069c84dc72ba
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
package com.ld.igds.timer.zcl;
 
import com.ld.igds.timer.zcl.dto.InteGrainDto;
import com.ld.igds.timer.zcl.service.InteGrainService;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
 
 
/**
 * 接口业务分发
 * @author chen
 */
@Component
public class InteGrainManager implements ApplicationContextAware {
 
    private static Map<String, InteGrainService> serviceMap;
 
 
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        Map<String, InteGrainService> map = applicationContext
                .getBeansOfType(InteGrainService.class);
        serviceMap = new HashMap<>();
        for (String key : map.keySet()) {
            serviceMap.put(map.get(key).getCompanyId(), map.get(key));
        }
    }
 
    /**
     * 执行保存
     * @param dto
     */
    public void toSaveGrain(InteGrainDto dto){
 
        InteGrainService service = serviceMap.get(dto.getCompanyId());
 
        service.toSaveGrain(dto);
    }
 
}