| 
					
				 | 
			
			
				@@ -622,6 +622,7 @@ func (c *CheckAreaMgr) CheckIedFcda() error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		//获取该间隔下该类型的装置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		s1 := []orm.Params{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		_, err = db.Raw("select ied_name from t_data_check_area_ied where area_id=?", area_id).Values(&s1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		typeMappingMgr := new(SysCheckModelIedtypeMappingMgr) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		//循环处理关联关系 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		for to_ied_type2, refrow := range funclist { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			ts := strings.Split(to_ied_type2, ",") 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -630,6 +631,10 @@ func (c *CheckAreaMgr) CheckIedFcda() error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if v, h := groupList[ied_type]; h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				ied_type = v 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			mappresult := typeMappingMgr.GetMappingType(modelid, ied_type) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if mappresult != "" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				ied_type = mappresult 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			ied_type, vol := getIedTypeAndVolCode(ied_type) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			iedlst := filterAreaIeds(ied_type, vol, s1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			logger.Logger.Debug(fmt.Sprintf("正在检查装置类型:%s的装置(%+v)端子关系", ied_type, iedlst)) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -639,6 +644,10 @@ func (c *CheckAreaMgr) CheckIedFcda() error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if v, h := groupList[fromiedcode]; h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				fromiedcode = v 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			mappresult = typeMappingMgr.GetMappingType(modelid, fromiedcode) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if mappresult != "" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				fromiedcode = mappresult 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			from_ied_type, vol2 := getIedTypeAndVolCode(fromiedcode) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			outiedlist2 := filterAreaIeds(from_ied_type, vol2, s1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			for _, iedrow := range outiedlist2 { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -668,11 +677,11 @@ func (c *CheckAreaMgr) CheckIedFcda() error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					logger.Logger.Debug(fmt.Sprintf("正在匹配装置%s与%s的端子关联关系", iedname, outiedname)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					outIedObj := scdNodeMgr.GetIed(scdXmlObj, fmt.Sprintf("%d", c.ScdId), outiedname) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					outIedObjDesc := "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					//outIedObjDesc := "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					if outIedObj == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						logger.Logger.Error(fmt.Sprintf("信号输出装置%s未找到!", outiedname)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						outIedObjDesc = outIedObj.Desc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						//outIedObjDesc = outIedObj.Desc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					if iedObj == nil && outIedObj == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						continue 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -730,23 +739,24 @@ func (c *CheckAreaMgr) CheckIedFcda() error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 								//检查未通过 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 								scdNodeRule.AppendFcdaCheckResult(re) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							if !fcda2Exist { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								parse_result := fmt.Sprintf("间隔%s的装置%s缺失端子%s", area_name, outiedname, fcda_name) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								re := map[string]interface{}{"scdid": c.ScdId, "lineno": 0, "ruleid": area_ruleid, "nodeid": 0, "parse_result": parse_result, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									"ied_name":      "", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									"ied_desc":      "", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									"out_ied_name":  outiedname, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									"out_ied_desc":  outIedObjDesc, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									"fcda_desc":     "", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									"fcda_addr":     "", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									"out_fcda_desc": fcda_name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									"out_fcda_addr": "", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									"error_type":    "3", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							/* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								if !fcda2Exist { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									parse_result := fmt.Sprintf("间隔%s的装置%s缺失端子%s", area_name, outiedname, fcda_name) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									re := map[string]interface{}{"scdid": c.ScdId, "lineno": 0, "ruleid": area_ruleid, "nodeid": 0, "parse_result": parse_result, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										"ied_name":      "", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										"ied_desc":      "", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										"out_ied_name":  outiedname, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										"out_ied_desc":  outIedObjDesc, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										"fcda_desc":     "", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										"fcda_addr":     "", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										"out_fcda_desc": fcda_name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										"out_fcda_addr": "", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										"error_type":    "3", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									//检查未通过 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									scdNodeRule.AppendFcdaCheckResult(re) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								//检查未通过 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								scdNodeRule.AppendFcdaCheckResult(re) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							//检查端子是否关联正确 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							if fcda2Exist && (extrefObj.LdInst != fcdaObj.LdInst || 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -993,12 +1003,10 @@ func (c *CheckAreaMgr) ParseModelArea() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //根据默认装置类型获取其类型编码。如果没有自定义编码,则返回默认编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func (c *CheckAreaMgr) getIedTypeCode(modelid int, iedtype string) string { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	mapptype := new(SysCheckModelIedtypeMappingMgr) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	mapptype.Model = T_data_model_iedtype_mapping{ModelId: modelid} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	mapptype.Model.IedType = iedtype 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	mappresult := mapptype.List() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	mappresult := mapptype.GetMappingType(modelid, iedtype) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	ptCode := iedtype 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if len(mappresult) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ptCode = mappresult[iedtype] //自定义主变保护编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if mappresult != "" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		ptCode = mappresult //自定义主变保护编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return ptCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1063,8 +1071,25 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//判断是否将各电压等级的保护装置合并还是分开的间隔 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//如果存在高中低压的保护装置,则说明是分开的主变间隔 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	//isMarge := true // 默认为合并的主变间隔 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	ptCode := c.getIedTypeCode(modelid, "PT") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	volValue := "" //电压等级值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if strings.Index(","+iedtypes+",", ","+ptCode+",") == -1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//判断主变保护是否是按电压等级分开配置的模型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		h, m, l := c.getIedListByVol(ptCode, ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if strings.Contains(iedtypes, ptCode+"#H") && len(h) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//高压侧装置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			volValue = "H" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} else if strings.Contains(iedtypes, ptCode+"#M") && len(m) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			volValue = "M" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} else if strings.Contains(iedtypes, ptCode+"#L") && len(l) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			volValue = "L" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	pmCode := c.getIedTypeCode(modelid, "PM") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	mmCode := c.getIedTypeCode(modelid, "MM") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	ctCode := c.getIedTypeCode(modelid, "CT") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	delPm := false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	delMm := false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	for _, row := range ieds { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if tools.IsEmpty(row["ied_type"]) != ptCode[0:1] || tools.IsEmpty(row["p_type"]) != ptCode[1:] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			continue 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1073,16 +1098,6 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			//装置如果是分组成员装置,则不用检测 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			continue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//判断主变保护是否是按电压等级分开配置的模型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		/* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if strings.Contains(iedtypes, "PT#H") || strings.Contains(iedtypes, "PT#M") || strings.Contains(iedtypes, "PT#L") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				h, m, l := c.getIedListByVol("PT", ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				pl_iedname := tools.IsEmpty(row["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//pmIedName := "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//mmIedName := "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		pl_iedname := tools.IsEmpty(row["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		iednameParts := scdParseMgr.ParseIedName(pl_iedname) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		areadesc := tools.IsEmpty(row["ied_desc"]) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1109,220 +1124,99 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		insvalues := []string{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		inAreaIedName := pl_iedname 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "P", "T")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//判断间隔是否需要包含差动装置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if strings.Contains(iedtypes, ptCode+"#C") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			_, iedname := getIedByDesc(ieds, ptCode, "差动") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if len(iedname) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				for _, in := range iedname { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					tmpIednameParts := scdParseMgr.ParseIedName(in) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, in, "P", "TC")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		inAreaIedName := "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "P", "T")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		for _, ty := range strings.Split(iedtypes, ",") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			inAreaIedName = "" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if _, h := groupList[ty]; h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				//装置如果是分组成员装置,则不用检测 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				continue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			tyCode := c.getIedTypeCode(modelid, ty) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if _, h := groupList[tyCode]; h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				//装置如果是分组成员装置,则不用检测 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				continue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if tyCode[0:len(pmCode)] == pmCode { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				//PM和MM最后处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				delPm = true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				continue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if tyCode[0:len(mmCode)] == mmCode { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				//PM和MM最后处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				delMm = true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				continue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//判断间隔是否需要包含差动装置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if strings.Contains(tyCode, "#C") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				_, iedname := getIedByDesc(ieds, tyCode, "差动") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if len(iedname) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					for _, in := range iedname { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						tmpIednameParts := scdParseMgr.ParseIedName(in) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, in, tyCode[0:1], tyCode[1:])) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//判断间隔是否需要包含本体保护装置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if strings.Contains(iedtypes, ptCode+"#0") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			_, iedname := getIedByDesc(ieds, ptCode, "本体") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if len(iedname) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				for _, in := range iedname { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					tmpIednameParts := scdParseMgr.ParseIedName(in) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, in, "P", "T0")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//判断间隔是否需要包含本体保护装置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if strings.Contains(tyCode, "#0") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				_, iedname := getIedByDesc(ieds, tyCode, "本体") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if len(iedname) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					for _, in := range iedname { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						tmpIednameParts := scdParseMgr.ParseIedName(in) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, in, tyCode[0:1], tyCode[1:])) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//合智一体IMT/MIT,分高中低压 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		imtcode := c.getIedTypeCode(modelid, "IMT") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h, m, l := c.getIedListByVol(imtcode, ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, m...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, l...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for _, r := range h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			inAreaIedName = tools.IsEmpty(r["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "IM", "T")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			dlIeds := []orm.Params{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			imtcode := c.getIedTypeCode(modelid, tyCode) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			h, m, l := c.getIedListByVol(imtcode, ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//logger.Logger.Debug(fmt.Sprintf("tyCode:%s H:%+v,M:%+v,L:%+v", tyCode, h, m, l)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if volValue == "" || volValue == "H" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				dlIeds = append(dlIeds, h...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		imtcode = c.getIedTypeCode(modelid, "MIT") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h, m, l = c.getIedListByVol(imtcode, ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, m...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, l...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for _, r := range h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			inAreaIedName = tools.IsEmpty(r["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "MI", "T")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if volValue == "" || volValue == "M" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				dlIeds = append(dlIeds, m...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//母联智能终端IE需要分高中压,无低压侧 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if HasAreaJ { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			imtcode = c.getIedTypeCode(modelid, "IE") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			h, m, l = c.getIedListByVol(imtcode, ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			for _, r := range h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				//高压侧,AB套必须与PT装置相同 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				inAreaIedName = tools.IsEmpty(r["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "I", "E")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if volValue == "" || volValue == "L" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				dlIeds = append(dlIeds, l...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			for _, r := range m { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				//中压侧 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			for _, r := range dlIeds { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				inAreaIedName = tools.IsEmpty(r["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				lastChar := tmpIednameParts[7] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if tmpIednameParts[6] == iednameParts[6] && (lastChar == "" || tmpIednameParts[7] == iednameParts[7]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "I", "E")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//合并单元MT分高中低压侧;低压侧无关联母线合并单元MM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		imtcode = c.getIedTypeCode(modelid, "MT") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h, m, l = c.getIedListByVol(imtcode, ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, m...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, l...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for _, r := range h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			inAreaIedName = tools.IsEmpty(r["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "M", "T")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//是否包含本体合并单元 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if strings.Contains(iedtypes, imtcode+"#0") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			_, iedname := getIedByDesc(ieds, imtcode, "本体") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if len(iedname) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				for _, in := range iedname { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					tmpIednameParts := scdParseMgr.ParseIedName(in) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, in, "M", "T")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if tyCode[0:len(ctCode)] == ctCode { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					//CT单独处理。它可能不分AB套 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					lastChar := tmpIednameParts[7] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if tmpIednameParts[6] == iednameParts[6] && (lastChar == "" || lastChar == iednameParts[7]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, tyCode[0:1], tyCode[1:])) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//测控装置CT分高中低压侧,且可能是多套合并单元MT共用,既不分AB套 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		imtcode = c.getIedTypeCode(modelid, "CT") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h, m, l = c.getIedListByVol(imtcode, ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, m...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, l...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for _, r := range h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			inAreaIedName = tools.IsEmpty(r["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			lastChar := tmpIednameParts[7] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpVol := tmpIednameParts[3] + tmpIednameParts[4] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			//高中低压电压等级相同的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (tmpVol == volMap["low"] || tmpVol == volMap["middle"] || tmpVol == volMap["hight"]) && tmpIednameParts[6] == iednameParts[6] && (lastChar == "" || lastChar == iednameParts[7]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "C", "T")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//是否包含本体测控装置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if strings.Contains(iedtypes, imtcode+"#0") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			_, iedname := getIedByDesc(ieds, imtcode, "本体") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if len(iedname) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				for _, in := range iedname { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					tmpIednameParts := scdParseMgr.ParseIedName(in) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, in, "C", "T")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, tyCode[0:1], tyCode[1:])) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//智能终端(IB:开关\IT:分支\IF:分段)分高中低压侧 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		imtcodeB := c.getIedTypeCode(modelid, "IB") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		imtcodeT := c.getIedTypeCode(modelid, "IT") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		imtcodeF := c.getIedTypeCode(modelid, "IF") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h, m, l = c.getIedListByVol(imtcodeB, ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, m...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, l...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for _, r := range h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			inAreaIedName = tools.IsEmpty(r["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			lastChar := tmpIednameParts[7] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpVol := tmpIednameParts[3] + tmpIednameParts[4] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			//高中低压电压等级相同的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (tmpVol == volMap["low"] || tmpVol == volMap["middle"] || tmpVol == volMap["hight"]) && tmpIednameParts[6] == iednameParts[6] && (lastChar == "" || lastChar == iednameParts[7]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "I", "B")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//是否包含本体测控装置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if strings.Contains(iedtypes, imtcodeT+"#0") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			for n, row := range ieds { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if strings.HasPrefix(n, imtcodeT) || strings.HasPrefix(n, imtcodeB) || strings.HasPrefix(n, imtcodeF) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					ieddesc := tools.IsEmpty(row["ied_desc"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if strings.Contains(ieddesc, "本体") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						tmpIednameParts := scdParseMgr.ParseIedName(n) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, n, "I", "T")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h, m, l = c.getIedListByVol(imtcodeT, ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, m...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, l...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for _, r := range h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			inAreaIedName = tools.IsEmpty(r["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			lastChar := tmpIednameParts[7] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpVol := tmpIednameParts[3] + tmpIednameParts[4] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			//高中低压电压等级相同的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (tmpVol == volMap["low"] || tmpVol == volMap["middle"] || tmpVol == volMap["hight"]) && tmpIednameParts[6] == iednameParts[6] && (lastChar == "" || lastChar == iednameParts[7]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "I", "T")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h, m, l = c.getIedListByVol(imtcodeF, ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, m...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h = append(h, l...) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for _, r := range h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			inAreaIedName = tools.IsEmpty(r["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			lastChar := tmpIednameParts[7] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpVol := tmpIednameParts[3] + tmpIednameParts[4] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			//高中低压电压等级相同的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (tmpVol == volMap["low"] || tmpVol == volMap["middle"] || tmpVol == volMap["hight"]) && tmpIednameParts[6] == iednameParts[6] && (lastChar == "" || lastChar == iednameParts[7]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "I", "F")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//母线保护PM及母线合并单元MM,可能是多套合并单元MT共用,既不分AB套;低压侧智能终端无关联母线保护 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		imtcode = c.getIedTypeCode(modelid, "PM") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		h, m, l = c.getIedListByVol(imtcode, ieds, volMap) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for _, r := range h { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			//高压侧,AB套必须与PT装置相同 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			inAreaIedName = tools.IsEmpty(r["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			lastChar := tmpIednameParts[7] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if tmpIednameParts[6] == iednameParts[6] && lastChar == iednameParts[7] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "P", "M")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				//MM装置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				mmIedName := c.getMMName(tmpIednameParts, ieds, iednameParts[7]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, mmIedName, "M", "M")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//最后处理PM和MM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		inAreaIedName = c.getPMName(iednameParts, ieds) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if delPm && inAreaIedName != "" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "P", "M")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//pmIedNameParts := scdParseMgr.ParseIedName(pmIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//使用PM装置的名称去定义MM的名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			inAreaIedName = c.getMMName(iednameParts, ieds, iednameParts[7]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if delMm && inAreaIedName != "" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "M", "M")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for _, r := range m { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			//中压侧 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			inAreaIedName = tools.IsEmpty(r["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			lastChar := tmpIednameParts[7] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if tmpIednameParts[6] == iednameParts[6] && (lastChar == "" || lastChar == iednameParts[7]) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "P", "M")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				//MM装置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				mmIedName := c.getMMName(tmpIednameParts, ieds, iednameParts[7]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, mmIedName, "M", "M")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//写数据库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if len(insvalues) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			_, err = db.Raw(ins1 + strings.Join(insvalues, ",")).Exec() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		_, err = db.Raw(ins1 + strings.Join(insvalues, ",")).Exec() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			logger.Logger.Error(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			return 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1995,10 +1889,11 @@ func (c *CheckAreaMgr) getIedListByVol(iedtype string, ieds map[string]orm.Param 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	for _, v := range vollevel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		tmpLst[v] = []orm.Params{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	it := strings.Split(iedtype, "#") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	scdParseMgr := new(ScdParse) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	for _, row := range ieds { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		pl_iedname := tools.IsEmpty(row["ied_name"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if pl_iedname[0:len(iedtype)] != iedtype { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if pl_iedname[0:len(it[0])] != it[0] { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			continue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		iednameParts := scdParseMgr.ParseIedName(pl_iedname) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2009,13 +1904,24 @@ func (c *CheckAreaMgr) getIedListByVol(iedtype string, ieds map[string]orm.Param 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			tmpLst[volvalue] = append(tmpLst[volvalue], row) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if len(it) > 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if it[1] == "H" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return tmpLst[vollevel["hight"]], []orm.Params{}, []orm.Params{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if it[1] == "M" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return []orm.Params{}, tmpLst[vollevel["middle"]], []orm.Params{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if it[1] == "L" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return []orm.Params{}, []orm.Params{}, tmpLst[vollevel["low"]] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return tmpLst[vollevel["hight"]], tmpLst[vollevel["middle"]], tmpLst[vollevel["low"]] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func (c *CheckAreaMgr) GetCheckResult(scdid int64) ([]orm.Params, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	db := orm.NewOrm() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	rowset := []orm.Params{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	sql := "select *,case error_type when 1 then '多余' when 2 then '错误' when 3 then '缺失' else '其他' end error_type_desc from t_scd_fcda_check_result where scd_id=? order by ied_name" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	sql := "select *,case error_type when 1 then '多余' when 2 then '错误' when 3 then '缺失' else '其他' end error_type_desc from t_scd_fcda_check_result where scd_id=? order by ied_name,out_ied_name,error_type" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	_, err := db.Raw(sql, scdid).Values(&rowset) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return rowset, err 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |