Эх сурвалжийг харах

检查时增加装置连接关系判断

liling 1 жил өмнө
parent
commit
2bbca7e0d1

+ 17 - 0
service/models/bo/check_sysmodel_ied_fcda_relation.go

@@ -127,6 +127,17 @@ func (c *SysCheckModelFcdaRalationMgr) GetList() ([]orm.Params, error) {
 }
 
 func (c *SysCheckModelFcdaRalationMgr) GetModelAllFcdaRef() (map[string][]orm.Params, error) {
+	//获取当前模型的装置类型关联
+	refmgr := new(SysCheckModelIedRelationMgr)
+	refLst, _ := refmgr.GetListByModelid(c.Model.ModelId)
+	if refLst == nil || len(refLst) == 0 {
+		return map[string][]orm.Params{}, nil
+	}
+	refMap := map[string]string{}
+	for _, r := range refLst {
+		key := fmt.Sprintf("%s,%s", tools.IsEmpty(r["to_ied_code"]), tools.IsEmpty(r["from_ied_code"]))
+		refMap[key] = tools.IsEmpty(r["in_type"])
+	}
 	db := orm.NewOrm()
 	sql := "select r1.*,(select func_name from t_data_model_func_def where id=f1.func_id) from_func_name,(select func_name from t_data_model_func_def where id=f2.func_id) to_func_name,f1.fcda_name from_fcda_name,f1.fcda_match_exp from_fcda_match_exp,f2.fcda_name to_fcda_name,f2.fcda_match_exp to_fcda_match_exp from t_data_model_fcda_ref r1 left join t_data_model_func_fcda f1 on r1.from_fcda_id=f1.id left join t_data_model_func_fcda f2 on r1.to_fcda_id=f2.id where r1.model_id=? "
 	rowset := []orm.Params{}
@@ -136,6 +147,7 @@ func (c *SysCheckModelFcdaRalationMgr) GetModelAllFcdaRef() (map[string][]orm.Pa
 		logger.Logger.Error(err)
 		return nil, err
 	}
+
 	//获取装置分组信息
 	bgm := new(SysCheckModelIedtypeGroupMgr)
 	bgm.Model = T_data_model_iedtype_group{ModelId: c.Model.ModelId}
@@ -144,6 +156,7 @@ func (c *SysCheckModelFcdaRalationMgr) GetModelAllFcdaRef() (map[string][]orm.Pa
 	for _, row := range rowset {
 		tc := tools.IsEmpty(row["to_ied_code"])
 		fc := tools.IsEmpty(row["from_ied_code"])
+		goosesv := tools.IsEmpty(row["goosesv"])
 		if v, h := groupList[tc]; h {
 			tc = v
 		}
@@ -151,6 +164,10 @@ func (c *SysCheckModelFcdaRalationMgr) GetModelAllFcdaRef() (map[string][]orm.Pa
 			fc = v
 		}
 		key := fmt.Sprintf("%s,%s", tc, fc)
+		if v, h := refMap[key]; !h || v != goosesv {
+			//装置类型之间没有建立连接关系
+			continue
+		}
 		extref_name_exp := tools.IsEmpty(row["to_fcda_match_exp"])
 		if extref_name_exp == "" {
 			extref_name_exp = tools.IsEmpty(row["to_fcda_name"])