cloudpss 4.1.1b8__py3-none-any.whl → 4.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cloudpss/__init__.py +2 -3
- cloudpss/asyncio/__init__.py +8 -0
- cloudpss/asyncio/job/__init__.py +5 -0
- cloudpss/asyncio/job/job.py +116 -0
- cloudpss/asyncio/job/messageStreamReceiver.py +121 -0
- cloudpss/asyncio/job/messageStreamSender.py +45 -0
- cloudpss/asyncio/model/__init__.py +5 -0
- cloudpss/asyncio/model/model.py +257 -0
- cloudpss/asyncio/model/revision.py +41 -0
- cloudpss/asyncio/model/topology.py +34 -0
- cloudpss/asyncio/utils/__init__.py +6 -0
- cloudpss/{utils → asyncio/utils}/httpAsyncRequest.py +2 -2
- cloudpss/function/functionExecution.py +36 -3
- cloudpss/ieslab/DataManageModel.py +131 -9
- cloudpss/ieslab/EvaluationModel.py +80 -9
- cloudpss/ieslab/IESLabOpt.py +235 -0
- cloudpss/ieslab/IESLabPlan.py +82 -4
- cloudpss/ieslab/IESLabSimulation.py +59 -32
- cloudpss/ieslab/PlanModel.py +276 -33
- cloudpss/ieslab/__init__.py +2 -1
- cloudpss/job/job.py +136 -141
- cloudpss/job/jobReceiver.py +8 -2
- cloudpss/job/messageStreamReceiver.py +42 -99
- cloudpss/job/messageStreamSender.py +5 -42
- cloudpss/job/{view/EMTView.py → result/EMTResult.py} +11 -13
- cloudpss/job/result/IESLabSimulationResult.py +5 -0
- cloudpss/job/result/IESLabTypicalDayResult.py +136 -0
- cloudpss/job/{view/IESView.py → result/IESResult.py} +2 -2
- cloudpss/job/{view/PowerFlowView.py → result/PowerFlowResult.py} +2 -2
- cloudpss/job/result/__init__.py +39 -0
- cloudpss/job/{view/view.py → result/result.py} +37 -8
- cloudpss/model/implements/diagram.py +113 -0
- cloudpss/model/jobDefinitions.py +6 -6
- cloudpss/model/model.py +232 -209
- cloudpss/model/revision.py +30 -35
- cloudpss/model/topology.py +13 -15
- cloudpss/runner/IESLabEvaluationResult.py +14 -6
- cloudpss/runner/IESLabPlanResult.py +91 -35
- cloudpss/runner/IESLabTypicalDayResult.py +62 -50
- cloudpss/runner/MessageStreamReceiver.py +5 -100
- cloudpss/runner/result.py +6 -1
- cloudpss/runner/runner.py +77 -48
- cloudpss/utils/IO.py +1 -1
- cloudpss/utils/graphqlUtil.py +3 -2
- cloudpss/utils/httprequests.py +16 -8
- cloudpss/version.py +1 -1
- {cloudpss-4.1.1b8.dist-info → cloudpss-4.5.0.dist-info}/METADATA +2 -2
- cloudpss-4.5.0.dist-info/RECORD +70 -0
- cloudpss/dslab/__init__.py +0 -2
- cloudpss/dslab/dataManageModel.py +0 -275
- cloudpss/dslab/dslab.py +0 -210
- cloudpss/dslab/files/__init__.py +0 -2
- cloudpss/dslab/files/curveData.py +0 -140229
- cloudpss/dslab/files/files.py +0 -27
- cloudpss/dslab/financialAnalysisModel.py +0 -137
- cloudpss/job/jobMachine.py +0 -11
- cloudpss/job/jobPolicy.py +0 -129
- cloudpss/job/jobQueue.py +0 -14
- cloudpss/job/jobTres.py +0 -6
- cloudpss/job/view/IESLabSimulationView.py +0 -5
- cloudpss/job/view/IESLabTypicalDayView.py +0 -27
- cloudpss/job/view/__init__.py +0 -42
- cloudpss/runner/DSLabResult.py +0 -92
- cloudpss-4.1.1b8.dist-info/RECORD +0 -71
- /cloudpss/{utils → asyncio/utils}/AsyncIterable.py +0 -0
- {cloudpss-4.1.1b8.dist-info → cloudpss-4.5.0.dist-info}/WHEEL +0 -0
- {cloudpss-4.1.1b8.dist-info → cloudpss-4.5.0.dist-info}/top_level.txt +0 -0
    
        cloudpss/model/revision.py
    CHANGED
    
    | @@ -1,12 +1,11 @@ | |
| 1 | 
            -
            import  | 
| 2 | 
            -
            from cloudpss.utils.httpAsyncRequest import graphql_fetch
         | 
| 1 | 
            +
            from cloudpss.job.job import Job
         | 
| 3 2 | 
             
            from .topology import ModelTopology
         | 
| 4 3 | 
             
            from .implements import ModelImplement
         | 
| 5 | 
            -
            from ..utils import | 
| 6 | 
            -
            from ..runner import Runner
         | 
| 4 | 
            +
            from ..utils import  graphql_request
         | 
| 7 5 |  | 
| 8 6 |  | 
| 9 7 | 
             
            class ModelRevision(object):
         | 
| 8 | 
            +
                
         | 
| 10 9 | 
             
                """
         | 
| 11 10 | 
             
                    表示一个项目的版本数据
         | 
| 12 11 |  | 
| @@ -23,6 +22,12 @@ class ModelRevision(object): | |
| 23 22 |  | 
| 24 23 |  | 
| 25 24 | 
             
                """
         | 
| 25 | 
            +
                
         | 
| 26 | 
            +
                __createModelRevisionQuery = """
         | 
| 27 | 
            +
                                mutation($a:CreateModelRevisionInput!){createModelRevision(input:$a){
         | 
| 28 | 
            +
                                        hash
         | 
| 29 | 
            +
                                }}
         | 
| 30 | 
            +
                            """
         | 
| 26 31 |  | 
| 27 32 | 
             
                def __init__(self, revision: dict = {}):
         | 
| 28 33 | 
             
                    """
         | 
| @@ -56,21 +61,27 @@ class ModelRevision(object): | |
| 56 61 | 
             
                    """
         | 
| 57 62 |  | 
| 58 63 | 
             
                    return self.implements
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                 | 
| 64 | 
            +
                
         | 
| 65 | 
            +
                def run(self, job, config, name=None, policy=None,stop_on_entry=None,rid=None, **kwargs):
         | 
| 61 66 | 
             
                    """
         | 
| 62 | 
            -
                         | 
| 67 | 
            +
                        运行当前版本
         | 
| 63 68 |  | 
| 64 69 | 
             
                        :params job:  调用仿真时使用的计算方案,为空时使用项目的第一个计算方案
         | 
| 65 70 | 
             
                        :params config:  调用仿真时使用的参数方案,为空时使用项目的第一个参数方案
         | 
| 66 71 | 
             
                        :params name:  任务名称,为空时使用项目的参数方案名称和计算方案名称
         | 
| 67 72 | 
             
                        :params rid:  项目rid,可为空
         | 
| 68 73 |  | 
| 69 | 
            -
                        :return:  | 
| 74 | 
            +
                        :return: 返回一个运行实例
         | 
| 70 75 |  | 
| 71 76 | 
             
                        >>> revision.run(revision,job,config,'')
         | 
| 72 77 | 
             
                    """
         | 
| 73 | 
            -
                     | 
| 78 | 
            +
                    revision= ModelRevision.create(self)
         | 
| 79 | 
            +
                    if stop_on_entry is not None:
         | 
| 80 | 
            +
                        job['args']['stop_on_entry'] = stop_on_entry
         | 
| 81 | 
            +
                    return Job.create(
         | 
| 82 | 
            +
                        revision["hash"], job, config, name=name, rid=rid, policy=policy, **kwargs
         | 
| 83 | 
            +
                    )
         | 
| 84 | 
            +
                
         | 
| 74 85 |  | 
| 75 86 | 
             
                @staticmethod
         | 
| 76 87 | 
             
                def create(revision, parentHash=None):
         | 
| @@ -85,36 +96,19 @@ class ModelRevision(object): | |
| 85 96 | 
             
                        {hash:'4043acbddb9ce0c6174be65573c0380415bc48186c74a459f88865313743230c'}
         | 
| 86 97 | 
             
                    """
         | 
| 87 98 |  | 
| 88 | 
            -
                    return  asyncio.run(ModelRevision.createAsync(revision, parentHash))
         | 
| 89 | 
            -
                    
         | 
| 90 | 
            -
                @staticmethod
         | 
| 91 | 
            -
                async def createAsync(revision, parentHash=None):
         | 
| 92 | 
            -
                    """
         | 
| 93 | 
            -
                        创建一个新版本
         | 
| 94 | 
            -
             | 
| 95 | 
            -
                        :params: revision 版本数据
         | 
| 96 | 
            -
             | 
| 97 | 
            -
                        :return: 项目版本hash
         | 
| 98 | 
            -
             | 
| 99 | 
            -
                        >>> ModelRevision.create(model.revision)
         | 
| 100 | 
            -
                        {hash:'4043acbddb9ce0c6174be65573c0380415bc48186c74a459f88865313743230c'}
         | 
| 101 | 
            -
                    """
         | 
| 102 | 
            -
             | 
| 103 | 
            -
                    query = """
         | 
| 104 | 
            -
                                mutation($a:CreateModelRevisionInput!){createModelRevision(input:$a){
         | 
| 105 | 
            -
                                        hash
         | 
| 106 | 
            -
                                }}
         | 
| 107 | 
            -
                            """
         | 
| 108 99 | 
             
                    r = revision.toJSON()
         | 
| 109 | 
            -
                     | 
| 100 | 
            +
                    if 'hash' in r:
         | 
| 101 | 
            +
                        del r['hash']
         | 
| 110 102 | 
             
                    variables = {'a': {**r, 'parent': parentHash}}
         | 
| 111 | 
            -
             | 
| 112 | 
            -
                    r = await graphql_fetch(query, variables)
         | 
| 103 | 
            +
                    r = graphql_request(ModelRevision.__createModelRevisionQuery, variables)
         | 
| 113 104 | 
             
                    if 'errors' in r:
         | 
| 114 105 | 
             
                        raise Exception(r['errors'])
         | 
| 106 | 
            +
                    
         | 
| 115 107 | 
             
                    return r['data']['createModelRevision']
         | 
| 108 | 
            +
                    
         | 
| 109 | 
            +
                
         | 
| 116 110 |  | 
| 117 | 
            -
                 | 
| 111 | 
            +
                def fetchTopology(self, implementType, config, maximumDepth, **kwargs):
         | 
| 118 112 | 
             
                    """
         | 
| 119 113 | 
             
                        获取当前项目版本的拓扑数据
         | 
| 120 114 |  | 
| @@ -131,6 +125,7 @@ class ModelRevision(object): | |
| 131 125 | 
             
                    """
         | 
| 132 126 |  | 
| 133 127 | 
             
                    if self.hash is not None:
         | 
| 134 | 
            -
                        return  | 
| 135 | 
            -
                                                   maximumDepth)
         | 
| 128 | 
            +
                        return ModelTopology.fetch(self.hash, implementType, config,
         | 
| 129 | 
            +
                                                   maximumDepth, **kwargs)
         | 
| 136 130 | 
             
                    return None
         | 
| 131 | 
            +
             | 
    
        cloudpss/model/topology.py
    CHANGED
    
    | @@ -1,7 +1,6 @@ | |
| 1 1 | 
             
            import asyncio
         | 
| 2 2 | 
             
            import json
         | 
| 3 3 |  | 
| 4 | 
            -
            from cloudpss.utils.httpAsyncRequest import graphql_fetch
         | 
| 5 4 | 
             
            from ..utils import request, graphql_request
         | 
| 6 5 |  | 
| 7 6 |  | 
| @@ -19,6 +18,13 @@ class ModelTopology(): | |
| 19 18 |  | 
| 20 19 |  | 
| 21 20 | 
             
                """
         | 
| 21 | 
            +
                __modelTopologyQuery = """
         | 
| 22 | 
            +
                        query($a:ModelTopologyInput!){
         | 
| 23 | 
            +
                        modelTopology(input:$a){
         | 
| 24 | 
            +
                            components
         | 
| 25 | 
            +
                            mappings
         | 
| 26 | 
            +
                        }}
         | 
| 27 | 
            +
                    """
         | 
| 22 28 | 
             
                __All__ = ['ModelTopology']
         | 
| 23 29 |  | 
| 24 30 | 
             
                def __init__(self, topology: dict = {}):
         | 
| @@ -47,11 +53,7 @@ class ModelTopology(): | |
| 47 53 | 
             
                    f.close()
         | 
| 48 54 |  | 
| 49 55 | 
             
                @staticmethod
         | 
| 50 | 
            -
                def fetch(hash, implementType, config, maximumDepth=None):
         | 
| 51 | 
            -
                   return asyncio.run(ModelTopology.fetchAsync(hash, implementType, config, maximumDepth))
         | 
| 52 | 
            -
                    
         | 
| 53 | 
            -
                @staticmethod
         | 
| 54 | 
            -
                async def fetchAsync(hash, implementType, config, maximumDepth=None):
         | 
| 56 | 
            +
                def fetch(hash, implementType, config, maximumDepth=None, **kwargs):
         | 
| 55 57 | 
             
                    """
         | 
| 56 58 | 
             
                        获取拓扑
         | 
| 57 59 |  | 
| @@ -66,14 +68,6 @@ class ModelTopology(): | |
| 66 68 |  | 
| 67 69 | 
             
                    """
         | 
| 68 70 | 
             
                    args = {} if config is None else config['args']
         | 
| 69 | 
            -
                    query = """
         | 
| 70 | 
            -
                        query($a:ModelTopologyInput!){
         | 
| 71 | 
            -
                        modelTopology(input:$a){
         | 
| 72 | 
            -
                            components
         | 
| 73 | 
            -
                            mappings
         | 
| 74 | 
            -
                        }}
         | 
| 75 | 
            -
                    """
         | 
| 76 | 
            -
             | 
| 77 71 | 
             
                    variables = {
         | 
| 78 72 | 
             
                        "a": {
         | 
| 79 73 | 
             
                            'hash': hash,
         | 
| @@ -82,8 +76,12 @@ class ModelTopology(): | |
| 82 76 | 
             
                            'maximumDepth': maximumDepth
         | 
| 83 77 | 
             
                        }
         | 
| 84 78 | 
             
                    }
         | 
| 85 | 
            -
                    data =  | 
| 79 | 
            +
                    data = graphql_request(ModelTopology.__modelTopologyQuery, variables, **kwargs)
         | 
| 86 80 | 
             
                    if 'errors' in data:
         | 
| 87 81 | 
             
                        raise Exception(data['errors'][0]['message'])
         | 
| 88 82 |  | 
| 89 83 | 
             
                    return ModelTopology(data['data']['modelTopology'])
         | 
| 84 | 
            +
                    
         | 
| 85 | 
            +
                
         | 
| 86 | 
            +
             | 
| 87 | 
            +
             | 
| @@ -3,7 +3,7 @@ from ..utils.httprequests import request | |
| 3 3 |  | 
| 4 4 |  | 
| 5 5 | 
             
            class IESLabEvaluationResult(object):
         | 
| 6 | 
            -
                _baseUri = ' | 
| 6 | 
            +
                _baseUri = ''
         | 
| 7 7 | 
             
                _kindNameMap = {
         | 
| 8 8 | 
             
                    "利润与利润分配": "getEconomyResult",
         | 
| 9 9 | 
             
                    "财务计划现金": "getFinancialPlanCashFlowResult",
         | 
| @@ -77,7 +77,7 @@ class IESLabEvaluationResult(object): | |
| 77 77 | 
             
                    '''
         | 
| 78 78 | 
             
                    assert (resultType in self._kindNameMap), "数据类型不存在"
         | 
| 79 79 | 
             
                    kind = self._kindNameMap.get(resultType, resultType)
         | 
| 80 | 
            -
                    url = self._baseUri + kind
         | 
| 80 | 
            +
                    url = self._baseUri + '/' + kind
         | 
| 81 81 | 
             
                    list = self._fetchItemData(url, planID)
         | 
| 82 82 | 
             
                    dict_result = dict()
         | 
| 83 83 | 
             
                    for val in list['results']:
         | 
| @@ -93,7 +93,7 @@ class IESLabEvaluationResult(object): | |
| 93 93 | 
             
                        :return: array类型,代表该方案对应的概览结果
         | 
| 94 94 | 
             
                    '''
         | 
| 95 95 | 
             
                    r = request('GET',
         | 
| 96 | 
            -
                                " | 
| 96 | 
            +
                                f"{self._baseUri}/getOverviewResult",
         | 
| 97 97 | 
             
                                params={
         | 
| 98 98 | 
             
                                    "simu_id": self.simulationId,
         | 
| 99 99 | 
             
                                    "planId": planID,
         | 
| @@ -112,7 +112,7 @@ class IESLabEvaluationResult(object): | |
| 112 112 | 
             
                        :return: array类型,代表该方案对应的能效评价结果
         | 
| 113 113 | 
             
                    '''
         | 
| 114 114 | 
             
                    r = request('GET',
         | 
| 115 | 
            -
                                " | 
| 115 | 
            +
                                f"{self._baseUri}/getEnergyEvaluation",
         | 
| 116 116 | 
             
                                params={
         | 
| 117 117 | 
             
                                    "simu_id": self.simulationId,
         | 
| 118 118 | 
             
                                    "planId": planID,
         | 
| @@ -131,7 +131,7 @@ class IESLabEvaluationResult(object): | |
| 131 131 | 
             
                        :return: array类型,代表该方案对应的环保评价结果
         | 
| 132 132 | 
             
                    '''
         | 
| 133 133 | 
             
                    r = request('GET',
         | 
| 134 | 
            -
                                " | 
| 134 | 
            +
                                f"{self._baseUri}/getEnvironmentalEvaluation",
         | 
| 135 135 | 
             
                                params={
         | 
| 136 136 | 
             
                                    "simu_id": self.simulationId,
         | 
| 137 137 | 
             
                                    "planId": planID,
         | 
| @@ -140,4 +140,12 @@ class IESLabEvaluationResult(object): | |
| 140 140 | 
             
                    result = json.loads(r.text)
         | 
| 141 141 | 
             
                    if len(result['results']) > 0 and len(result['results'][0]['data']) > 0:
         | 
| 142 142 | 
             
                        return result['results'][0]['data']
         | 
| 143 | 
            -
                    return []
         | 
| 143 | 
            +
                    return []
         | 
| 144 | 
            +
                
         | 
| 145 | 
            +
             | 
| 146 | 
            +
            class IESLabPlanEvaluationResult(IESLabEvaluationResult):
         | 
| 147 | 
            +
                _baseUri = 'api/ieslab-plan/taskmanager'
         | 
| 148 | 
            +
             | 
| 149 | 
            +
             | 
| 150 | 
            +
            class IESLabOptEvaluationResult(IESLabEvaluationResult):
         | 
| 151 | 
            +
                _baseUri = 'api/ieslab-opt/taskmanager'
         | 
| @@ -1,22 +1,24 @@ | |
| 1 1 | 
             
            import json
         | 
| 2 2 | 
             
            from math import fabs
         | 
| 3 3 | 
             
            from ..utils.httprequests import request
         | 
| 4 | 
            +
            # from .result import IESResult
         | 
| 4 5 |  | 
| 5 6 |  | 
| 6 | 
            -
            class  | 
| 7 | 
            +
            class IESLabResult(object):
         | 
| 8 | 
            +
                _baseUri = ''
         | 
| 7 9 | 
             
                taskId = None
         | 
| 8 10 |  | 
| 9 | 
            -
                def __init__(self, simulationId, taskId=None | 
| 11 | 
            +
                def __init__(self, simulationId, taskId=None) -> None:
         | 
| 10 12 | 
             
                    """
         | 
| 11 13 | 
             
                        初始化
         | 
| 12 14 | 
             
                        获得taskId
         | 
| 13 15 | 
             
                    """
         | 
| 16 | 
            +
             | 
| 14 17 | 
             
                    self.simulationId = simulationId
         | 
| 15 18 | 
             
                    if taskId is not None:
         | 
| 16 19 | 
             
                        self.taskId = taskId
         | 
| 17 20 | 
             
                    else:
         | 
| 18 21 | 
             
                        self.taskId = self.__getLastTask()
         | 
| 19 | 
            -
                    pass
         | 
| 20 22 |  | 
| 21 23 | 
             
                def __getLastTask(self):
         | 
| 22 24 | 
             
                    '''
         | 
| @@ -25,7 +27,7 @@ class IESLabPlanResult(object): | |
| 25 27 | 
             
                        :return: string 类型
         | 
| 26 28 | 
             
                    '''
         | 
| 27 29 | 
             
                    try:
         | 
| 28 | 
            -
                        r=request('GET',' | 
| 30 | 
            +
                        r=request('GET',f'{self._baseUri}/getSimuLastTasks',params={
         | 
| 29 31 | 
             
                            'simuid':self.simulationId
         | 
| 30 32 | 
             
                        })
         | 
| 31 33 | 
             
                        result= json.loads(r.text)
         | 
| @@ -54,7 +56,7 @@ class IESLabPlanResult(object): | |
| 54 56 | 
             
                    if self.taskId is None:
         | 
| 55 57 | 
             
                        raise Exception('未开始运行')
         | 
| 56 58 | 
             
                    r = request('GET',
         | 
| 57 | 
            -
                                ' | 
| 59 | 
            +
                                f'{self._baseUri}/getOptimizationLog',
         | 
| 58 60 | 
             
                                params={
         | 
| 59 61 | 
             
                                    'simuid': self.simulationId,
         | 
| 60 62 | 
             
                                    'taskid': self.taskId
         | 
| @@ -64,14 +66,14 @@ class IESLabPlanResult(object): | |
| 64 66 |  | 
| 65 67 | 
             
                def GetPlanNum(self):
         | 
| 66 68 | 
             
                    '''
         | 
| 67 | 
            -
                        获取当前result实例对应的优化方案数量
         | 
| 69 | 
            +
                        获取当前 result 实例对应的优化方案数量
         | 
| 68 70 |  | 
| 69 71 | 
             
                        :return: int类型,代表优化方案的数量
         | 
| 70 72 | 
             
                    '''
         | 
| 71 73 | 
             
                    if self.taskId is None:
         | 
| 72 74 | 
             
                        raise Exception('未开始运行')
         | 
| 73 75 | 
             
                    r = request('GET',
         | 
| 74 | 
            -
                                ' | 
| 76 | 
            +
                                f'{self._baseUri}/getOptimizationResult',
         | 
| 75 77 | 
             
                                params={
         | 
| 76 78 | 
             
                                    'simuid': self.simulationId,
         | 
| 77 79 | 
             
                                    'taskid': self.taskId,
         | 
| @@ -84,39 +86,46 @@ class IESLabPlanResult(object): | |
| 84 86 | 
             
                    '''
         | 
| 85 87 | 
             
                        获取planID对应的优化方案的基础信息
         | 
| 86 88 |  | 
| 87 | 
            -
                        :param: planID int类型,表示优化方案的ID,数值位于 0~优化方案数量 之间
         | 
| 89 | 
            +
                        :param: planID int 类型,表示优化方案的 ID,数值位于 0~优化方案数量 之间
         | 
| 88 90 |  | 
| 89 | 
            -
                        :return: dict类型,代表该方案的基础信息,包括投资、运行成本、负荷总量等信息
         | 
| 91 | 
            +
                        :return: dict 类型,代表该方案的基础信息,包括投资、运行成本、负荷总量等信息
         | 
| 90 92 | 
             
                    '''
         | 
| 91 93 | 
             
                    if self.taskId is None:
         | 
| 92 94 | 
             
                        raise Exception('未开始运行')
         | 
| 95 | 
            +
                    length = self.GetPlanNum()
         | 
| 96 | 
            +
                    if int(planID) > length:
         | 
| 97 | 
            +
                        raise Exception('计算方案id未产生')
         | 
| 93 98 | 
             
                    r = request('GET',
         | 
| 94 | 
            -
                            ' | 
| 99 | 
            +
                            f'{self._baseUri}/getOptimizationResult',
         | 
| 95 100 | 
             
                            params={
         | 
| 96 101 | 
             
                                'simuid': self.simulationId,
         | 
| 97 102 | 
             
                                'taskid': self.taskId,
         | 
| 98 103 | 
             
                                'resultType': 0
         | 
| 99 104 | 
             
                            })
         | 
| 100 105 | 
             
                    data = json.loads(r.text).get('data', [])
         | 
| 101 | 
            -
                     | 
| 102 | 
            -
                     | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 106 | 
            +
                    filtered_data = [item for item in data if item['id'] == planID]
         | 
| 107 | 
            +
                    if filtered_data:
         | 
| 108 | 
            +
                        result = filtered_data[0].get('data', {}).get('data', [])[0]
         | 
| 109 | 
            +
                        header = filtered_data[0].get('data', {}).get('headerDesc', [])
         | 
| 110 | 
            +
                        dict_result = {val.get('hearderName', ''): result.get(val.get('key', ''), '') for val in header}
         | 
| 111 | 
            +
                        return dict_result
         | 
| 112 | 
            +
                    else:
         | 
| 113 | 
            +
                        raise Exception('未查询到该方案id数据')
         | 
| 105 114 |  | 
| 106 115 |  | 
| 107 116 | 
             
                def GetPlanConfiguration(self, planID):
         | 
| 108 117 | 
             
                    '''
         | 
| 109 118 | 
             
                        获取planID对应的优化方案的配置信息
         | 
| 110 119 |  | 
| 111 | 
            -
                        :param: planID int类型,表示优化方案的ID,数值位于 0~优化方案数量 之间
         | 
| 120 | 
            +
                        :param: planID int 类型,表示优化方案的ID,数值位于 0~优化方案数量 之间
         | 
| 112 121 |  | 
| 113 | 
            -
                        :return: dict类型,代表该方案的配置信息,包括每种设备的选型配置、容量配置、成本等相关信息
         | 
| 122 | 
            +
                        :return: dict 类型,代表该方案的配置信息,包括每种设备的选型配置、容量配置、成本等相关信息
         | 
| 114 123 | 
             
                    '''
         | 
| 115 | 
            -
                     | 
| 116 | 
            -
                    if int(planID) >  | 
| 124 | 
            +
                    length = self.GetPlanNum()
         | 
| 125 | 
            +
                    if int(planID) > length:
         | 
| 117 126 | 
             
                        raise Exception('计算方案id未产生')
         | 
| 118 127 | 
             
                    r = request('GET',
         | 
| 119 | 
            -
                                ' | 
| 128 | 
            +
                                f'{self._baseUri}/getOptimizationResult',
         | 
| 120 129 | 
             
                                params={
         | 
| 121 130 | 
             
                                    'simuid': self.simulationId,
         | 
| 122 131 | 
             
                                    'taskid': self.taskId,
         | 
| @@ -124,10 +133,13 @@ class IESLabPlanResult(object): | |
| 124 133 | 
             
                                    'resultType': 1
         | 
| 125 134 | 
             
                                })
         | 
| 126 135 | 
             
                    d = json.loads(r.text)
         | 
| 127 | 
            -
                     | 
| 128 | 
            -
             | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 136 | 
            +
                    if len(d['data']) == 0:
         | 
| 137 | 
            +
                        raise Exception('未查询到该方案id数据')
         | 
| 138 | 
            +
                    else: 
         | 
| 139 | 
            +
                        result = {}
         | 
| 140 | 
            +
                        for val in d['data']:
         | 
| 141 | 
            +
                            result[val['u_name']] = val['data']['data']
         | 
| 142 | 
            +
                        return result
         | 
| 131 143 |  | 
| 132 144 | 
             
                def GetComponentResult(self, planID, componentID, typicalDayName=''):
         | 
| 133 145 | 
             
                    '''
         | 
| @@ -139,11 +151,11 @@ class IESLabPlanResult(object): | |
| 139 151 |  | 
| 140 152 | 
             
                        :return: dict类型,代表该元件在不同典型日下的运行信息
         | 
| 141 153 | 
             
                    '''
         | 
| 142 | 
            -
                     | 
| 143 | 
            -
                    if int(planID) >  | 
| 154 | 
            +
                    length = self.GetPlanNum()
         | 
| 155 | 
            +
                    if int(planID) > length:
         | 
| 144 156 | 
             
                        raise Exception('计算方案id未产生')
         | 
| 145 157 | 
             
                    r = request('GET',
         | 
| 146 | 
            -
                                ' | 
| 158 | 
            +
                                f'{self._baseUri}/getOptimizationResult',
         | 
| 147 159 | 
             
                                params={
         | 
| 148 160 | 
             
                                    'simuid': self.simulationId,
         | 
| 149 161 | 
             
                                    'taskid': self.taskId,
         | 
| @@ -153,13 +165,45 @@ class IESLabPlanResult(object): | |
| 153 165 | 
             
                                    'u_name': componentID
         | 
| 154 166 | 
             
                                })
         | 
| 155 167 | 
             
                    d = json.loads(r.text)
         | 
| 156 | 
            -
                     | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 159 | 
            -
             | 
| 160 | 
            -
             | 
| 168 | 
            +
                    if len(d['data']) == 0:
         | 
| 169 | 
            +
                        raise Exception('未查询到该方案id对应的优化方案下componentID对应元件数据')
         | 
| 170 | 
            +
                    else:
         | 
| 171 | 
            +
                        dict_result = dict()
         | 
| 172 | 
            +
                        for val in d['data']:
         | 
| 173 | 
            +
                            for k, v in val.items():
         | 
| 174 | 
            +
                                dict_result[k] = v
         | 
| 175 | 
            +
                        return dict_result
         | 
| 176 | 
            +
                
         | 
| 177 | 
            +
                def GetEnergyBalanceResult(self, planID, typicalDayName=''):
         | 
| 178 | 
            +
                    '''
         | 
| 179 | 
            +
                        获取planID对应的优化方案下能量平衡图数据
         | 
| 180 | 
            +
                        
         | 
| 181 | 
            +
                        :param: planID int 类型,表示优化方案的ID,数值位于 0~优化方案数量 之间
         | 
| 182 | 
            +
                        :param typicalDayName str 类型,代表典型日的名称
         | 
| 183 | 
            +
             | 
| 184 | 
            +
                        :return: dict类型,代表该元件在不同典型日下的运行信息
         | 
| 185 | 
            +
             | 
| 186 | 
            +
                    '''
         | 
| 187 | 
            +
                    length = self.GetPlanNum()
         | 
| 188 | 
            +
                    if int(planID) > length:
         | 
| 189 | 
            +
                        raise Exception('计算方案id未产生')
         | 
| 190 | 
            +
                    try:
         | 
| 191 | 
            +
                        r = request('GET',
         | 
| 192 | 
            +
                                    f'{self._baseUri}/getOptimizationResult',
         | 
| 193 | 
            +
                                    params={
         | 
| 194 | 
            +
                                        'simuid': self.simulationId,
         | 
| 195 | 
            +
                                        'taskid': self.taskId,
         | 
| 196 | 
            +
                                        'resultType': 4,
         | 
| 197 | 
            +
                                        'typicalDay': typicalDayName,
         | 
| 198 | 
            +
                                        "planId": planID,
         | 
| 199 | 
            +
                                        "u_name": "systemData"
         | 
| 200 | 
            +
                                    })
         | 
| 201 | 
            +
                        return json.loads(r.text)
         | 
| 202 | 
            +
                    except:
         | 
| 203 | 
            +
                        raise Exception('运行失败')
         | 
| 204 | 
            +
             | 
| 161 205 |  | 
| 162 | 
            -
                def GetComponentTypiDays(self,  | 
| 206 | 
            +
                def GetComponentTypiDays(self, planID, componentID):
         | 
| 163 207 | 
             
                    '''
         | 
| 164 208 | 
             
                        获取当前result实例对应的优化方案数量
         | 
| 165 209 |  | 
| @@ -170,12 +214,15 @@ class IESLabPlanResult(object): | |
| 170 214 | 
             
                    '''
         | 
| 171 215 | 
             
                    if self.taskId is None:
         | 
| 172 216 | 
             
                        raise Exception('未开始运行')
         | 
| 217 | 
            +
                    length = self.GetPlanNum()
         | 
| 218 | 
            +
                    if int(planID) > length:
         | 
| 219 | 
            +
                        raise Exception('计算方案id未产生')
         | 
| 173 220 | 
             
                    r = request('GET',
         | 
| 174 | 
            -
                                ' | 
| 221 | 
            +
                                f'{self._baseUri}/getOptimizationResult',
         | 
| 175 222 | 
             
                                params={
         | 
| 176 223 | 
             
                                    'simuid': self.simulationId,
         | 
| 177 224 | 
             
                                    'taskid': self.taskId,
         | 
| 178 | 
            -
                                    "planId":  | 
| 225 | 
            +
                                    "planId": planID,
         | 
| 179 226 | 
             
                                    'u_name': componentID,
         | 
| 180 227 | 
             
                                    'resultType': 2
         | 
| 181 228 | 
             
                                })
         | 
| @@ -188,8 +235,17 @@ class IESLabPlanResult(object): | |
| 188 235 |  | 
| 189 236 | 
             
                        :return: dict 类型
         | 
| 190 237 | 
             
                    '''
         | 
| 191 | 
            -
                    r=request('GET',' | 
| 238 | 
            +
                    r=request('GET',f'{self._baseUri}/getSimuLastTasks',params={
         | 
| 192 239 | 
             
                        'simuid':self.simulationId
         | 
| 193 240 | 
             
                    })
         | 
| 194 241 | 
             
                    result= json.loads(r.text)
         | 
| 195 242 | 
             
                    return result
         | 
| 243 | 
            +
             | 
| 244 | 
            +
             | 
| 245 | 
            +
            class IESLabPlanResult(IESLabResult):
         | 
| 246 | 
            +
                _baseUri = 'api/ieslab-plan/taskmanager'
         | 
| 247 | 
            +
             | 
| 248 | 
            +
             | 
| 249 | 
            +
            class IESLabOptResult(IESLabResult):
         | 
| 250 | 
            +
                _baseUri = 'api/ieslab-opt/taskmanager'
         | 
| 251 | 
            +
                
         |