cloudpss 3.2.0a2__py3-none-any.whl → 4.0.0a5__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 +6 -4
- cloudpss/dslab/DSLabFinancialResult.py +96 -0
- cloudpss/dslab/__init__.py +2 -0
- cloudpss/dslab/dataManageModel.py +267 -0
- cloudpss/dslab/dslab.py +145 -0
- cloudpss/dslab/files/__init__.py +2 -0
- cloudpss/dslab/files/curveData.py +140205 -0
- cloudpss/dslab/files/files.py +19 -0
- cloudpss/dslab/financialAnalysisModel.py +137 -0
- cloudpss/function/functionExecution.py +0 -2
- cloudpss/ieslab/DataManageModel.py +415 -0
- cloudpss/ieslab/EvaluationModel.py +189 -0
- cloudpss/ieslab/IESLabPlan.py +132 -0
- cloudpss/ieslab/IESLabSimulation.py +54 -0
- cloudpss/ieslab/PlanModel.py +143 -0
- cloudpss/ieslab/__init__.py +4 -0
- cloudpss/model/jobDefinitions.py +34 -0
- cloudpss/model/model.py +202 -15
- cloudpss/model/revision.py +2 -2
- cloudpss/project/project.py +4 -3
- cloudpss/runner/DSLabResult.py +92 -0
- cloudpss/runner/IESLabEvaluationResult.py +143 -0
- cloudpss/runner/IESLabPlanResult.py +195 -0
- cloudpss/runner/IESLabTypicalDayResult.py +142 -0
- cloudpss/runner/MessageStreamReceiver.py +193 -0
- cloudpss/runner/receiver.py +3 -3
- cloudpss/runner/result.py +38 -4
- cloudpss/runner/runner.py +61 -18
- cloudpss/utils/IO.py +153 -0
- cloudpss/utils/httprequests.py +14 -11
- cloudpss/verify.py +27 -14
- cloudpss/version.py +1 -0
- {cloudpss-3.2.0a2.dist-info → cloudpss-4.0.0a5.dist-info}/METADATA +2 -4
- cloudpss-4.0.0a5.dist-info/RECORD +54 -0
- {cloudpss-3.2.0a2.dist-info → cloudpss-4.0.0a5.dist-info}/WHEEL +1 -1
- cloudpss-3.2.0a2.dist-info/RECORD +0 -33
- {cloudpss-3.2.0a2.dist-info → cloudpss-4.0.0a5.dist-info}/top_level.txt +0 -0
cloudpss/model/model.py
CHANGED
@@ -5,9 +5,14 @@ import json
|
|
5
5
|
import yaml
|
6
6
|
import gzip
|
7
7
|
from copy import deepcopy
|
8
|
+
|
8
9
|
from .revision import ModelRevision
|
9
10
|
from .jobDefinitions import JOB_DEFINITIONS
|
10
11
|
from ..utils import request, fileLoad, graphql_request
|
12
|
+
from ..verify import userName
|
13
|
+
|
14
|
+
from cloudpss.runner.result import PowerFlowResult, EMTResult, Result, IESResult
|
15
|
+
from cloudpss.runner.runner import Runner
|
11
16
|
|
12
17
|
|
13
18
|
class Model(object):
|
@@ -31,18 +36,17 @@ class Model(object):
|
|
31
36
|
context 当前项目的上下文相关信息
|
32
37
|
|
33
38
|
"""
|
39
|
+
context: dict
|
40
|
+
jobs: list
|
41
|
+
configs: list
|
42
|
+
|
34
43
|
def __init__(self, model: dict = {}):
|
35
44
|
"""
|
36
45
|
项目初始化
|
37
46
|
"""
|
38
47
|
for k, v in model.items():
|
39
48
|
if k == 'revision':
|
40
|
-
|
41
|
-
self.__dict__[k] = ModelRevision(v)
|
42
|
-
else:
|
43
|
-
raise Exception(
|
44
|
-
'当前SDK版本(ver 3.X.X)不兼容该项目文件,请先升级项目文件。具体方法:将该项目文件导入至XStudio 3.X.X平台后重新保存至本地后即可。'
|
45
|
-
)
|
49
|
+
self.revision = ModelRevision(v)
|
46
50
|
|
47
51
|
else:
|
48
52
|
self.__dict__[k] = v
|
@@ -96,9 +100,7 @@ class Model(object):
|
|
96
100
|
cells = {}
|
97
101
|
for key, val in v.items():
|
98
102
|
|
99
|
-
if val.shape.
|
100
|
-
continue
|
101
|
-
if val.shape != 'diagram-component':
|
103
|
+
if not val.shape.startswith('diagram-component'):
|
102
104
|
continue
|
103
105
|
if val.definition == rid:
|
104
106
|
cells[key] = val
|
@@ -311,9 +313,11 @@ class Model(object):
|
|
311
313
|
if config is None:
|
312
314
|
currentConfig = self.context['currentConfig']
|
313
315
|
config = self.configs[currentConfig]
|
314
|
-
|
315
316
|
return self.revision.run(job, config, name, self.rid, **kwargs)
|
316
317
|
|
318
|
+
def iesSimulationRun(self, job=None, config=None, name=None, **kwargs):
|
319
|
+
return self.run(job=job, config=config, name=name, kwargs=kwargs)
|
320
|
+
|
317
321
|
@staticmethod
|
318
322
|
def load(filePath):
|
319
323
|
"""
|
@@ -369,7 +373,7 @@ class Model(object):
|
|
369
373
|
model.save(model,'newKey') # 另存为新的项目
|
370
374
|
|
371
375
|
"""
|
372
|
-
username =
|
376
|
+
username = userName()
|
373
377
|
|
374
378
|
if key is not None:
|
375
379
|
matchObj = re.match(r'^[-_A-Za-z0-9]+$', key, re.I | re.S)
|
@@ -411,7 +415,7 @@ class Model(object):
|
|
411
415
|
"""
|
412
416
|
# Model.update(model)
|
413
417
|
t = '(?<=/)\\S+(?=/)'
|
414
|
-
username =
|
418
|
+
username = userName()
|
415
419
|
owner = re.search(t, model.rid)
|
416
420
|
|
417
421
|
if owner is None:
|
@@ -462,7 +466,7 @@ class Model(object):
|
|
462
466
|
"""
|
463
467
|
|
464
468
|
t = '(?<=/)\\S+(?=/)'
|
465
|
-
username =
|
469
|
+
username = userName()
|
466
470
|
owner = re.search(t, model.rid)
|
467
471
|
|
468
472
|
if owner is None:
|
@@ -481,6 +485,13 @@ class Model(object):
|
|
481
485
|
auth = (65539 if publicRead else 65537) if isPublic else 0
|
482
486
|
revision = ModelRevision.create(model.revision, model.revision.hash)
|
483
487
|
|
488
|
+
xVersion = int(os.environ.get('X_CLOUDPSS_VERSION', 4))
|
489
|
+
tags= {
|
490
|
+
"replace":model.tags
|
491
|
+
}
|
492
|
+
if xVersion==3:
|
493
|
+
tags=model.tags
|
494
|
+
|
484
495
|
return graphql_request(
|
485
496
|
modelQuery, {
|
486
497
|
'a': {
|
@@ -491,7 +502,7 @@ class Model(object):
|
|
491
502
|
'jobs': model.jobs,
|
492
503
|
'name': model.name,
|
493
504
|
'description': model.description,
|
494
|
-
'tags':
|
505
|
+
'tags': tags,
|
495
506
|
"permissions": {
|
496
507
|
"moderator": 1,
|
497
508
|
"member": 1,
|
@@ -527,5 +538,181 @@ class Model(object):
|
|
527
538
|
currentConfig = self.context['currentConfig']
|
528
539
|
config = self.configs[currentConfig]
|
529
540
|
return self.revision.fetchTopology(implementType, config,
|
530
|
-
|
541
|
+
maximumDepth)
|
531
542
|
return None
|
543
|
+
|
544
|
+
def runEMT(self,job=None,config=None)->Runner[EMTResult]:
|
545
|
+
'''
|
546
|
+
运行 emtp 内核,如果当前 model 没有创建 Job 时报错,默认使用第一个计算方案,进行仿真。
|
547
|
+
|
548
|
+
:param: job 计算方案名称,可选,字符串类型或者字典类型,默认使用第一个计算方案,如果同名使用最靠前一个
|
549
|
+
:param: config 参数方案,可选,字符串类型或者字典类型,默认使用保存时选中的参数方案
|
550
|
+
|
551
|
+
:return: runner Runner[EMTResult]
|
552
|
+
'''
|
553
|
+
if job is None:
|
554
|
+
currentJob = self.context['currentJob']
|
555
|
+
job = self.jobs[currentJob]
|
556
|
+
if job['rid'] != 'job-definition/cloudpss/emtp':
|
557
|
+
for j in self.jobs:
|
558
|
+
if j['rid'] == 'job-definition/cloudpss/emtp':
|
559
|
+
job = j
|
560
|
+
if job is None:
|
561
|
+
raise Exception("找不到电磁暂态运行的计算方案")
|
562
|
+
if job['rid'] != 'job-definition/cloudpss/emtp':
|
563
|
+
raise Exception("不是电磁暂态运行生成算法的计算方案")
|
564
|
+
if config is None:
|
565
|
+
currentConfig = self.context['currentConfig']
|
566
|
+
config = self.configs[currentConfig]
|
567
|
+
return self.run(job=job, config=config)
|
568
|
+
|
569
|
+
def runSFEMT(self,job=None,config=None)->Runner[EMTResult]:
|
570
|
+
'''
|
571
|
+
运行 移频电磁暂态 内核,如果当前 model 没有创建 Job 时报错,默认使用第一个计算方案,进行仿真。
|
572
|
+
|
573
|
+
:param: job 计算方案名称,可选,字符串类型或者字典类型,默认使用第一个计算方案,如果同名使用最靠前一个
|
574
|
+
:param: config 参数方案,可选,字符串类型或者字典类型,默认使用保存时选中的参数方案
|
575
|
+
|
576
|
+
:return: runner Runner[EMTResult]
|
577
|
+
'''
|
578
|
+
if job is None:
|
579
|
+
currentJob = self.context['currentJob']
|
580
|
+
job = self.jobs[currentJob]
|
581
|
+
if job['rid'] != 'job-definition/cloudpss/sfemt':
|
582
|
+
for j in self.jobs:
|
583
|
+
if j['rid'] == 'job-definition/cloudpss/sfemt':
|
584
|
+
job = j
|
585
|
+
if job is None:
|
586
|
+
raise Exception("找不到移频电磁暂态运行的计算方案")
|
587
|
+
if job['rid'] != 'job-definition/cloudpss/sfemt':
|
588
|
+
raise Exception("不是移频电磁暂态运行生成算法的计算方案")
|
589
|
+
if config is None:
|
590
|
+
currentConfig = self.context['currentConfig']
|
591
|
+
config = self.configs[currentConfig]
|
592
|
+
return self.run(job=job, config=config)
|
593
|
+
|
594
|
+
def runPowerFlow(self,job=None,config=None)->Runner[PowerFlowResult]:
|
595
|
+
'''
|
596
|
+
运行 潮流 内核,如果当前 model 没有创建 Job 时报错,默认使用第一个计算方案,进行仿真。
|
597
|
+
|
598
|
+
:param: job 计算方案名称,可选,字符串类型或者字典类型,默认使用第一个计算方案,如果同名使用最靠前一个
|
599
|
+
:param: config 参数方案,可选,字符串类型或者字典类型,默认使用保存时选中的参数方案
|
600
|
+
|
601
|
+
:return: runner Runner[PowerFlowResult]
|
602
|
+
'''
|
603
|
+
if job is None:
|
604
|
+
currentJob = self.context['currentJob']
|
605
|
+
job = self.jobs[currentJob]
|
606
|
+
if job['rid'] != 'job-definition/cloudpss/power-flow':
|
607
|
+
for j in self.jobs:
|
608
|
+
if j['rid'] == 'job-definition/cloudpss/power-flow':
|
609
|
+
job = j
|
610
|
+
if job is None:
|
611
|
+
raise Exception("找不到潮流内核运行的计算方案")
|
612
|
+
if job['rid'] != 'job-definition/cloudpss/power-flow':
|
613
|
+
raise Exception("不是潮流内核运行生成算法的计算方案")
|
614
|
+
if config is None:
|
615
|
+
currentConfig = self.context['currentConfig']
|
616
|
+
config = self.configs[currentConfig]
|
617
|
+
return self.run(job=job, config=config)
|
618
|
+
|
619
|
+
def runThreePhasePowerFlow(self,job=None,config=None)->Runner[PowerFlowResult]:
|
620
|
+
'''
|
621
|
+
运行 三相不平衡潮流 内核,如果当前 model 没有创建 Job 时报错,默认使用第一个计算方案,进行仿真。
|
622
|
+
|
623
|
+
:param: job 计算方案名称,可选,字符串类型或者字典类型,默认使用第一个计算方案,如果同名使用最靠前一个
|
624
|
+
:param: config 参数方案,可选,字符串类型或者字典类型,默认使用保存时选中的参数方案
|
625
|
+
|
626
|
+
:return: runner Runner[PowerFlowResult]
|
627
|
+
'''
|
628
|
+
if job is None:
|
629
|
+
currentJob = self.context['currentJob']
|
630
|
+
job = self.jobs[currentJob]
|
631
|
+
if job['rid'] != 'job-definition/cloudpss/three-phase-powerFlow':
|
632
|
+
for j in self.jobs:
|
633
|
+
if j['rid'] == 'job-definition/cloudpss/three-phase-powerFlow':
|
634
|
+
job = j
|
635
|
+
if job is None:
|
636
|
+
raise Exception("找不到三相不平衡潮流内核运行的计算方案")
|
637
|
+
if job['rid'] != 'job-definition/cloudpss/three-phase-powerFlow':
|
638
|
+
raise Exception("不是三相不平衡潮流内核运行生成算法的计算方案")
|
639
|
+
if config is None:
|
640
|
+
currentConfig = self.context['currentConfig']
|
641
|
+
config = self.configs[currentConfig]
|
642
|
+
return self.run(job=job, config=config)
|
643
|
+
|
644
|
+
def runIESLoadPrediction(self,job=None,config=None)->Runner[IESResult]:
|
645
|
+
'''
|
646
|
+
运行 负荷预测方案 内核,如果当前 model 没有创建 Job 时报错,默认使用第一个计算方案,进行仿真。
|
647
|
+
|
648
|
+
:param: job 计算方案名称,可选,字符串类型或者字典类型,默认使用第一个计算方案,如果同名使用最靠前一个
|
649
|
+
:param: config 参数方案,可选,字符串类型或者字典类型,默认使用保存时选中的参数方案
|
650
|
+
|
651
|
+
:return: runner Runner[IESResult]
|
652
|
+
'''
|
653
|
+
if job is None:
|
654
|
+
currentJob = self.context['currentJob']
|
655
|
+
job = self.jobs[currentJob]
|
656
|
+
if job['rid'] != 'job-definition/ies/ies-load-prediction':
|
657
|
+
for j in self.jobs:
|
658
|
+
if j['rid'] == 'job-definition/ies/ies-load-prediction':
|
659
|
+
job = j
|
660
|
+
if job is None:
|
661
|
+
raise Exception("找不到负荷预测方案内核运行的计算方案")
|
662
|
+
if job['rid'] != 'job-definition/ies/ies-load-prediction':
|
663
|
+
raise Exception("不是负荷预测方案内核运行生成算法的计算方案")
|
664
|
+
if config is None:
|
665
|
+
currentConfig = self.context['currentConfig']
|
666
|
+
config = self.configs[currentConfig]
|
667
|
+
return self.run(job=job, config=config)
|
668
|
+
|
669
|
+
def runIESPowerFlow(self,job=None,config=None)->Runner[IESResult]:
|
670
|
+
'''
|
671
|
+
运行 时序潮流方案 内核,如果当前 model 没有创建 Job 时报错,默认使用第一个计算方案,进行仿真。
|
672
|
+
|
673
|
+
:param: job 计算方案名称,可选,字符串类型或者字典类型,默认使用第一个计算方案,如果同名使用最靠前一个
|
674
|
+
:param: config 参数方案,可选,字符串类型或者字典类型,默认使用保存时选中的参数方案
|
675
|
+
|
676
|
+
:return: runner Runner[IESResult]
|
677
|
+
'''
|
678
|
+
if job is None:
|
679
|
+
currentJob = self.context['currentJob']
|
680
|
+
job = self.jobs[currentJob]
|
681
|
+
if job['rid'] != 'job-definition/ies/ies-power-flow':
|
682
|
+
for j in self.jobs:
|
683
|
+
if j['rid'] == 'job-definition/ies/ies-power-flow':
|
684
|
+
job = j
|
685
|
+
if job is None:
|
686
|
+
raise Exception("找不到时序潮流方案内核运行的计算方案")
|
687
|
+
if job['rid'] != 'job-definition/ies/ies-power-flow':
|
688
|
+
raise Exception("不是时序潮流方案内核运行生成算法的计算方案")
|
689
|
+
if config is None:
|
690
|
+
currentConfig = self.context['currentConfig']
|
691
|
+
config = self.configs[currentConfig]
|
692
|
+
return self.run(job=job, config=config)
|
693
|
+
|
694
|
+
def runIESEnergyStoragePlan(self,job=None,config=None)->Runner[IESResult]:
|
695
|
+
'''
|
696
|
+
运行 储能规划方案 内核,如果当前 model 没有创建 Job 时报错,默认使用第一个计算方案,进行仿真。
|
697
|
+
|
698
|
+
:param: job 计算方案名称,可选,字符串类型或者字典类型,默认使用第一个计算方案,如果同名使用最靠前一个
|
699
|
+
:param: config 参数方案,可选,字符串类型或者字典类型,默认使用保存时选中的参数方案
|
700
|
+
|
701
|
+
:return: runner Runner[IESResult]
|
702
|
+
'''
|
703
|
+
if job is None:
|
704
|
+
currentJob = self.context['currentJob']
|
705
|
+
job = self.jobs[currentJob]
|
706
|
+
if job['rid'] != 'job-definition/ies/ies-energy-storage-plan':
|
707
|
+
for j in self.jobs:
|
708
|
+
if j['rid'] == 'job-definition/ies/ies-energy-storage-plan':
|
709
|
+
job = j
|
710
|
+
if job is None:
|
711
|
+
raise Exception("找不到储能规划方案内核运行的计算方案")
|
712
|
+
if job['rid'] != 'job-definition/ies/ies-energy-storage-plan':
|
713
|
+
raise Exception("不是储能规划方案内核运行生成算法的计算方案")
|
714
|
+
if config is None:
|
715
|
+
currentConfig = self.context['currentConfig']
|
716
|
+
config = self.configs[currentConfig]
|
717
|
+
return self.run(job=job, config=config)
|
718
|
+
|
cloudpss/model/revision.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import json
|
2
1
|
from .topology import ModelTopology
|
3
2
|
from .implements import ModelImplement
|
4
3
|
from ..utils import request, graphql_request
|
@@ -68,7 +67,6 @@ class ModelRevision(object):
|
|
68
67
|
|
69
68
|
>>> revision.run(revision,job,config,'')
|
70
69
|
"""
|
71
|
-
|
72
70
|
revision = ModelRevision.create(self)
|
73
71
|
return Runner.create(revision['hash'], job, config, name, rid,
|
74
72
|
**kwargs)
|
@@ -96,6 +94,8 @@ class ModelRevision(object):
|
|
96
94
|
variables = {'a': {**r, 'parent': parentHash}}
|
97
95
|
|
98
96
|
r = graphql_request(query, variables)
|
97
|
+
if 'errors' in r:
|
98
|
+
raise Exception(r['errors'])
|
99
99
|
return r['data']['createModelRevision']
|
100
100
|
|
101
101
|
def fetchTopology(self, implementType, config, maximumDepth):
|
cloudpss/project/project.py
CHANGED
@@ -10,6 +10,7 @@ from ..model.jobDefinitions import JOB_DEFINITIONS
|
|
10
10
|
from ..utils import request, fileLoad, graphql_request
|
11
11
|
from ..model import Model
|
12
12
|
from deprecated import deprecated
|
13
|
+
from ..verify import userName
|
13
14
|
|
14
15
|
|
15
16
|
@deprecated(version='3.0', reason="该类将在 5.0 版本移除,请使用 Model 类代替")
|
@@ -388,7 +389,7 @@ class Project(Model):
|
|
388
389
|
project.save(project,'newKey') # 另存为新的项目
|
389
390
|
|
390
391
|
"""
|
391
|
-
username =
|
392
|
+
username = userName()
|
392
393
|
|
393
394
|
if key is not None:
|
394
395
|
matchObj = re.match(r'^[-_A-Za-z0-9]+$', key, re.I | re.S)
|
@@ -431,7 +432,7 @@ class Project(Model):
|
|
431
432
|
"""
|
432
433
|
# Project.update(project)
|
433
434
|
t = '(?<=/)\\S+(?=/)'
|
434
|
-
username =
|
435
|
+
username = userName()
|
435
436
|
owner = re.search(t, model.rid)
|
436
437
|
|
437
438
|
if owner is None:
|
@@ -483,7 +484,7 @@ class Project(Model):
|
|
483
484
|
"""
|
484
485
|
|
485
486
|
t = '(?<=/)\\S+(?=/)'
|
486
|
-
username =
|
487
|
+
username = userName()
|
487
488
|
owner = re.search(t, project.rid)
|
488
489
|
|
489
490
|
if owner is None:
|
@@ -0,0 +1,92 @@
|
|
1
|
+
import json
|
2
|
+
from ..utils.httprequests import request
|
3
|
+
|
4
|
+
class DSLabResult(object):
|
5
|
+
_baseUri = "api/ies/rest/"
|
6
|
+
_kindNameMap = {
|
7
|
+
"利润与利润分配": "getEconomyResult",
|
8
|
+
"财务计划现金": "getFinancialPlanCashFlowResult",
|
9
|
+
"资产负债": "getLiabilityAssetsResult",
|
10
|
+
"投资使用计划与资金筹措": "getInvestPlanDataResult",
|
11
|
+
"借款还本付息计划": "getLoanRepaymentPlanResult",
|
12
|
+
"流动资金估算": "getFlowCashEvaluteResult",
|
13
|
+
"资产折旧与摊销估算": "getFlowCashEvaluteResult",
|
14
|
+
"总成本费用估算表": "getSumCostResult",
|
15
|
+
"项目总投资现金流量": "getSumInvestFlowCashResult",
|
16
|
+
"项目资本金现金流量": "getProjectCashFlowResult",
|
17
|
+
"营业收入、税金、附加和增值税估算": "getIncomeTaxResult",
|
18
|
+
}
|
19
|
+
|
20
|
+
def __init__(self, simulationId, taskId=None, **keywords) -> None:
|
21
|
+
"""
|
22
|
+
初始化
|
23
|
+
"""
|
24
|
+
self.simulationId = simulationId
|
25
|
+
self.timeId = keywords.get("timeId", 0)
|
26
|
+
self.planId = keywords.get("planId", 0)
|
27
|
+
self.cmdType = keywords.get("cmdType", None)
|
28
|
+
|
29
|
+
def _fetchItemData(self, url, planID):
|
30
|
+
"""
|
31
|
+
获取planID对应的优化方案下resultType财务评估结果
|
32
|
+
|
33
|
+
:param planID int 类型,表示优化方案的ID,数值位于0~优化方案数量之间
|
34
|
+
:param resultType enum 类型,表示财务评价结果表格的类型
|
35
|
+
|
36
|
+
:return: dict 类型,为源数据的引用,代表方案对应的财务评价基础参数信息
|
37
|
+
"""
|
38
|
+
r = request(
|
39
|
+
"GET", url, params={"simu": self.simulationId, "planId": planID, "time": 0}
|
40
|
+
)
|
41
|
+
data = json.loads(r.text)
|
42
|
+
return data
|
43
|
+
|
44
|
+
def status(self):
|
45
|
+
"""
|
46
|
+
获取运行状态
|
47
|
+
|
48
|
+
:return: boolean 类型
|
49
|
+
"""
|
50
|
+
result = self.GetOverviewResult()
|
51
|
+
if result is None or type(result) is list:
|
52
|
+
return False
|
53
|
+
return True
|
54
|
+
|
55
|
+
def GetFinancialResult(self, resultType):
|
56
|
+
"""
|
57
|
+
获取planID对应的优化方案下resultType财务评估结果
|
58
|
+
:param planID int 类型,表示优化方案的ID,数值位于0~优化方案数量之间
|
59
|
+
:param resultType enum 类型,表示财务评价结果表格的类型
|
60
|
+
|
61
|
+
:return: dict 类型,为源数据的引用,代表方案对应的财务评价基础参数信息
|
62
|
+
|
63
|
+
"""
|
64
|
+
assert resultType in self._kindNameMap, "数据类型不存在"
|
65
|
+
kind = self._kindNameMap.get(resultType, resultType)
|
66
|
+
url = f"{self._baseUri}{kind}"
|
67
|
+
list = self._fetchItemData(url, self.planId)
|
68
|
+
dict_result = dict()
|
69
|
+
for val in list:
|
70
|
+
for k, v in val.items():
|
71
|
+
dict_result[k] = v
|
72
|
+
return dict_result["data"]
|
73
|
+
|
74
|
+
def GetOverviewResult(self):
|
75
|
+
"""
|
76
|
+
获取当前结果类对应的概览结果
|
77
|
+
|
78
|
+
:return: array类型,代表该方案对应的概览结果
|
79
|
+
"""
|
80
|
+
r = request(
|
81
|
+
"GET",
|
82
|
+
"api/ies/rest/getOverviewResult",
|
83
|
+
params={
|
84
|
+
"simu": self.simulationId,
|
85
|
+
"planId": self.planId,
|
86
|
+
"time": self.timeId,
|
87
|
+
},
|
88
|
+
)
|
89
|
+
result = json.loads(r.text)
|
90
|
+
if len(result) > 0:
|
91
|
+
return result[0]["data"]
|
92
|
+
return None
|
@@ -0,0 +1,143 @@
|
|
1
|
+
import json
|
2
|
+
from ..utils.httprequests import request
|
3
|
+
|
4
|
+
|
5
|
+
class IESLabEvaluationResult(object):
|
6
|
+
_baseUri = 'api/ieslab-plan/taskmanager/'
|
7
|
+
_kindNameMap = {
|
8
|
+
"利润与利润分配": "getEconomyResult",
|
9
|
+
"财务计划现金": "getFinancialPlanCashFlowResult",
|
10
|
+
"资产负债": "getLiabilityAssetsResult",
|
11
|
+
"投资使用计划与资金筹措": "getInvestPlanDataResult",
|
12
|
+
"借款还本付息计划": "getLoanRepaymentPlanResult",
|
13
|
+
"流动资金估算": "getFlowCashEvaluteResult",
|
14
|
+
"资产折旧与摊销估算": "getFlowCashEvaluteResult",
|
15
|
+
"总成本费用估算表": "getSumCostResult",
|
16
|
+
"项目总投资现金流量": "getSumInvestFlowCashResult",
|
17
|
+
"项目资本金现金流量": "getProjectCashFlowResult",
|
18
|
+
"营业收入、税金、附加和增值税估算": "getIncomeTaxResult",
|
19
|
+
}
|
20
|
+
|
21
|
+
def __init__(self, simulationId, taskId=None, **keywords) -> None:
|
22
|
+
"""
|
23
|
+
初始化
|
24
|
+
"""
|
25
|
+
self.simulationId = simulationId
|
26
|
+
self.timeId = keywords.get('timeId', 0)
|
27
|
+
self.planId = keywords.get('planId', 0)
|
28
|
+
self.cmdType = keywords.get('cmdType', None)
|
29
|
+
|
30
|
+
def _fetchItemData(self, url, planID):
|
31
|
+
'''
|
32
|
+
获取planID对应的优化方案下resultType财务评估结果
|
33
|
+
|
34
|
+
:param planID int 类型,表示优化方案的ID,数值位于0~优化方案数量之间
|
35
|
+
:param resultType enum 类型,表示财务评价结果表格的类型
|
36
|
+
|
37
|
+
:return: dict 类型,为源数据的引用,代表方案对应的财务评价基础参数信息
|
38
|
+
'''
|
39
|
+
r = request('GET',
|
40
|
+
url,
|
41
|
+
params={
|
42
|
+
"simu_id": self.simulationId,
|
43
|
+
"planId": planID,
|
44
|
+
"time": 0
|
45
|
+
})
|
46
|
+
data = json.loads(r.text)
|
47
|
+
return data
|
48
|
+
|
49
|
+
def status(self):
|
50
|
+
'''
|
51
|
+
获取运行状态
|
52
|
+
|
53
|
+
:return: boolean 类型
|
54
|
+
'''
|
55
|
+
# 定义一个字典,把命令类型映射到相应的方法
|
56
|
+
cmd_dict = {
|
57
|
+
None: self.GetOverviewResult,
|
58
|
+
'energyEvaluation': self.GetEnergyEvaluationResult,
|
59
|
+
'environmentalEvaluation': self.GetEnvironmentalEvaluationResult
|
60
|
+
}
|
61
|
+
# 从字典中获取对应的方法,如果没有找到,就抛出一个异常或返回False
|
62
|
+
result = cmd_dict.get(self.cmdType, lambda x: None)(self.planId)
|
63
|
+
if result is None or type(result) is list:
|
64
|
+
return False
|
65
|
+
return True
|
66
|
+
|
67
|
+
|
68
|
+
def GetFinancialResult(self, resultType, planID):
|
69
|
+
'''
|
70
|
+
获取planID对应的优化方案下resultType财务评估结果
|
71
|
+
|
72
|
+
:param planID int 类型,表示优化方案的ID,数值位于0~优化方案数量之间
|
73
|
+
:param resultType enum 类型,表示财务评价结果表格的类型
|
74
|
+
|
75
|
+
:return: dict 类型,为源数据的引用,代表方案对应的财务评价基础参数信息
|
76
|
+
|
77
|
+
'''
|
78
|
+
assert (resultType in self._kindNameMap), "数据类型不存在"
|
79
|
+
kind = self._kindNameMap.get(resultType, resultType)
|
80
|
+
url = self._baseUri + kind
|
81
|
+
list = self._fetchItemData(url, planID)
|
82
|
+
dict_result = dict()
|
83
|
+
for val in list['results']:
|
84
|
+
for k, v in val.items():
|
85
|
+
dict_result[k] = v
|
86
|
+
return dict_result['data']
|
87
|
+
|
88
|
+
def GetOverviewResult(self, planID):
|
89
|
+
'''
|
90
|
+
获取当前结果类对应的优化方案下的概览结果
|
91
|
+
:param planID int 类型,表示优化方案的ID,数值位于0~优化方案数量之间
|
92
|
+
|
93
|
+
:return: array类型,代表该方案对应的概览结果
|
94
|
+
'''
|
95
|
+
r = request('GET',
|
96
|
+
"api/ieslab-plan/taskmanager/getOverviewResult",
|
97
|
+
params={
|
98
|
+
"simu_id": self.simulationId,
|
99
|
+
"planId": planID,
|
100
|
+
"time": self.timeId
|
101
|
+
})
|
102
|
+
result = json.loads(r.text)
|
103
|
+
if len(result['results']) > 0 and len(result['results'][0]['data']) > 0:
|
104
|
+
return result['results'][0]['data']
|
105
|
+
return []
|
106
|
+
|
107
|
+
def GetEnergyEvaluationResult(self, planID):
|
108
|
+
'''
|
109
|
+
获取当前结果类对应的优化方案下的能效评价
|
110
|
+
:param planID int 类型,表示优化方案的ID,数值位于0~优化方案数量之间
|
111
|
+
|
112
|
+
:return: array类型,代表该方案对应的能效评价结果
|
113
|
+
'''
|
114
|
+
r = request('GET',
|
115
|
+
"api/ieslab-plan/taskmanager/getEnergyEvaluation",
|
116
|
+
params={
|
117
|
+
"simu_id": self.simulationId,
|
118
|
+
"planId": planID,
|
119
|
+
"time": self.timeId
|
120
|
+
})
|
121
|
+
result = json.loads(r.text)
|
122
|
+
if len(result['results']) > 0 and len(result['results'][0]['data']) > 0:
|
123
|
+
return result['results'][0]['data']
|
124
|
+
return []
|
125
|
+
|
126
|
+
def GetEnvironmentalEvaluationResult(self, planID):
|
127
|
+
'''
|
128
|
+
获取当前结果类对应的优化方案下的环保评价
|
129
|
+
:param planID int 类型,表示优化方案的ID,数值位于0~优化方案数量之间
|
130
|
+
|
131
|
+
:return: array类型,代表该方案对应的环保评价结果
|
132
|
+
'''
|
133
|
+
r = request('GET',
|
134
|
+
"api/ieslab-plan/taskmanager/getEnvironmentalEvaluation",
|
135
|
+
params={
|
136
|
+
"simu_id": self.simulationId,
|
137
|
+
"planId": planID,
|
138
|
+
"time": self.timeId
|
139
|
+
})
|
140
|
+
result = json.loads(r.text)
|
141
|
+
if len(result['results']) > 0 and len(result['results'][0]['data']) > 0:
|
142
|
+
return result['results'][0]['data']
|
143
|
+
return []
|