Browse Source

mxg:sys_direction添加is_source约束

mengxiangge 5 years ago
parent
commit
3d1de70b4b
1 changed files with 10 additions and 8 deletions
  1. 10 8
      datacenter/docs/sys_calc/sys_direction.md

+ 10 - 8
datacenter/docs/sys_calc/sys_direction.md

@@ -14,7 +14,7 @@
 
 # 函数
 ```
-create or replace function public.sys_direction(project_id character varying,building_id character varying,block_id character varying, system_name character varying,domain character varying) returns boolean
+create or replace function public.sys_direction(project_id character varying,building_id character varying,block_id character varying, system_name character varying,domain character varying,is_source boolean default true) returns boolean
 as
 $$
 from relations.src.system_relation import calc_flowdirection, systemdatautils,systemutils
@@ -32,15 +32,16 @@ def get_connected_block_data(project_id,building_id,block_id,system_name,domain)
   objs=systemutils.sqldata2objlist(data)
   return objs
 
-def get_connected_block_source_data(project_id,building_id,block_id,system_name,domain):
+def get_connected_block_source_data(project_id,building_id,block_id,system_name,domain,is_source):
   sql = "select * from revit_calc.connected_block_source " \
 		  "where project_id=$1" \
 		  "and block_id=$2" \
 		  "and mep_system_type=$3" \
 		  "and domain=$4" \
-		  "and ($5 is null or building_id=$5)"
-  join_plan=plpy.prepare(sql,["text","text","text","text","text"])
-  data=join_plan.execute([project_id,block_id,system_name,domain,building_id])
+		  "and ($5 is null or building_id=$5)" \
+		  "and is_source=$6"
+  join_plan=plpy.prepare(sql,["text","text","text","text","text","boolean"])
+  data=join_plan.execute([project_id,block_id,system_name,domain,building_id,is_source])
   objs=systemutils.sqldata2objlist(data)
   return objs
 
@@ -56,7 +57,7 @@ try:
   # 将下面对数据库的操作作为一个事务, 出异常则自动rollback
   with plpy.subtransaction():
     block_datas=get_connected_block_data(project_id,building_id, block_id,system_name,domain)
-    source_datas=get_connected_block_source_data(project_id,building_id, block_id,system_name,domain)
+    source_datas=get_connected_block_source_data(project_id,building_id, block_id,system_name,domain,is_source)
     block_datas= calc_flowdirection.calc(block_datas, source_datas)
     for block_data in block_datas:
       update_connected_block_data(block_data)
@@ -68,7 +69,7 @@ else:
 $$
 LANGUAGE 'plpython3u' VOLATILE;
 
-select public.sys_direction('Pj1101010015','Bd11010100153c05821ed8fd11e9b8f2d79d0a5b4bf6','0','冷冻水供水管','DomainPiping')
+select public.sys_direction('Pj1101010015','Bd11010100153c05821ed8fd11e9b8f2d79d0a5b4bf6','0','冷冻水供水管','DomainPiping',true)
 ```
 
 ## 输入
@@ -76,7 +77,8 @@ select public.sys_direction('Pj1101010015','Bd11010100153c05821ed8fd11e9b8f2d79d
     2. 需要计算的building_id,如果没有提供时请传入null,不能传""
     3. 需要计算的块id    
     4. 需要计算的系统名称
-    5. 需要计算的管道系统类型,枚举(水管或风管):DomainPiping,DomainHvac
+    5. 需要计算的管道系统类型,枚举(水管或风管):DomainPiping,DomainHvac    
+    6. 跟据源或端计算:bool。true表示源,false表示端
 ## 返回结果
     True    成功
     False   失败