【调度系统】广东民航医疗快线调度系统源代码
克樊道人
2024-12-02 61ce8cc6883e5f94e6470141df3484167caf31ed
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
 
namespace Aliyun\Core\Profile;
 
use Aliyun\Core\Auth\Credential;
use Aliyun\Core\Auth\ShaHmac1Signer;
use Aliyun\Core\Regions\ProductDomain;
use Aliyun\Core\Regions\Endpoint;
use Aliyun\Core\Regions\EndpointProvider;
 
class DefaultProfile implements IClientProfile
{
    private static $profile;
    private static $endpoints;
    private static $credential;
    private static $regionId;
    private static $acceptFormat;
    
    private static $isigner;
    private static $iCredential;
    
    private function  __construct($regionId,$credential)
    {
        self::$regionId = $regionId;
        self::$credential = $credential;
    }
    
    public static function getProfile($regionId, $accessKeyId, $accessSecret)
    {
        $credential =new Credential($accessKeyId, $accessSecret);
        self::$profile = new DefaultProfile($regionId, $credential);
        return self::$profile;
    }
    
    public function getSigner()
    {
        if(null == self::$isigner)
        {
            self::$isigner = new ShaHmac1Signer(); 
        }
        return self::$isigner;
    }
    
    public function getRegionId()
    {
        return self::$regionId;
    }
    
    public function getFormat()
    {
        return self::$acceptFormat;
    }
    
    public function getCredential()
    {
        if(null == self::$credential && null != self::$iCredential)
        {
            self::$credential = self::$iCredential;
        }
        return self::$credential;
    }
    
    public static function getEndpoints()
    {
        if(null == self::$endpoints)
        {
            self::$endpoints = EndpointProvider::getEndpoints();
        }
        return self::$endpoints;
    }
    
    public static function addEndpoint($endpointName, $regionId, $product, $domain)
    {
        if(null == self::$endpoints)
        {
            self::$endpoints = self::getEndpoints();
        }
        $endpoint = self::findEndpointByName($endpointName);
        if(null == $endpoint)
        {
            self::addEndpoint_($endpointName, $regionId, $product, $domain);
        }
        else 
        {
            self::updateEndpoint($regionId, $product, $domain, $endpoint);
        }
    }
    
    public static function findEndpointByName($endpointName)
    {
        foreach (self::$endpoints as $key => $endpoint)
        {
            if($endpoint->getName() == $endpointName)
            {
                return $endpoint;
            }
        }
    }
    
    private static function addEndpoint_($endpointName,$regionId, $product, $domain)
    {
        $regionIds = array($regionId);
        $productDomains = array(new ProductDomain($product, $domain));
        $endpoint = new Endpoint($endpointName, $regionIds, $productDomains);
        array_push(self::$endpoints, $endpoint);
    }
    
    private static function updateEndpoint($regionId, $product, $domain, $endpoint)
    {
        $regionIds = $endpoint->getRegionIds();
        if(!in_array($regionId,$regionIds))
        {
            array_push($regionIds, $regionId);
            $endpoint->setRegionIds($regionIds);
        }
 
        $productDomains = $endpoint->getProductDomains();
        if(null == self::findProductDomain($productDomains, $product, $domain))
        {
             array_push($productDomains, new ProductDomain($product, $domain));    
        }
        $endpoint->setProductDomains($productDomains);
    }
    
    private static function findProductDomain($productDomains, $product, $domain)
    {
        foreach ($productDomains as $key => $productDomain)
        {
            if($productDomain->getProductName() == $product && $productDomain->getDomainName() == $domain)
            {
                return $productDomain;
            }
        }
        return null;
    }
 
}