|
@@ -1040,6 +1040,10 @@ func (c *CheckAreaMgr) ParseModelArea() {
|
|
if areaCode == "L" {
|
|
if areaCode == "L" {
|
|
c.pL(modelid, volcode, iedtypes, iedMap)
|
|
c.pL(modelid, volcode, iedtypes, iedMap)
|
|
}
|
|
}
|
|
|
|
+ //母线间隔分析:PM
|
|
|
|
+ if areaCode == "M" {
|
|
|
|
+ c.pM(modelid, volcode, iedtypes, iedMap)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1175,6 +1179,11 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
|
|
//装置如果是分组成员装置,则不用检测
|
|
//装置如果是分组成员装置,则不用检测
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
+ //判断是否指定的套别标识
|
|
|
|
+ abCode := c.getIedTypeABCode(ty)
|
|
|
|
+ if abCode != "" {
|
|
|
|
+ iednameParts[7] = abCode
|
|
|
|
+ }
|
|
tyCode := c.getIedTypeCode(modelid, ty)
|
|
tyCode := c.getIedTypeCode(modelid, ty)
|
|
if _, h := groupList[tyCode]; h {
|
|
if _, h := groupList[tyCode]; h {
|
|
//装置如果是分组成员装置,则不用检测
|
|
//装置如果是分组成员装置,则不用检测
|
|
@@ -1190,11 +1199,6 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
|
|
delMm = true
|
|
delMm = true
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- //判断是否指定的套别标识
|
|
|
|
- abCode := c.getIedTypeABCode(tyCode)
|
|
|
|
- if abCode != "" {
|
|
|
|
- iednameParts[7] = abCode
|
|
|
|
- }
|
|
|
|
//判断间隔是否需要包含差动装置
|
|
//判断间隔是否需要包含差动装置
|
|
if strings.Contains(tyCode, "#C") {
|
|
if strings.Contains(tyCode, "#C") {
|
|
_, iedname := getIedByDesc(ieds, tyCode, "差动")
|
|
_, iedname := getIedByDesc(ieds, tyCode, "差动")
|
|
@@ -1329,15 +1333,15 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
//装置如果是分组成员装置,则不用检测
|
|
//装置如果是分组成员装置,则不用检测
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
+ abCode := c.getIedTypeABCode(ty)
|
|
|
|
+ if abCode != "" {
|
|
|
|
+ iednameParts[7] = abCode
|
|
|
|
+ }
|
|
tyCode := c.getIedTypeCode(modelid, ty)
|
|
tyCode := c.getIedTypeCode(modelid, ty)
|
|
if _, h := groupList[tyCode]; h {
|
|
if _, h := groupList[tyCode]; h {
|
|
//装置如果是分组成员装置,则不用检测
|
|
//装置如果是分组成员装置,则不用检测
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- abCode := c.getIedTypeABCode(tyCode)
|
|
|
|
- if abCode != "" {
|
|
|
|
- iednameParts[7] = abCode
|
|
|
|
- }
|
|
|
|
if tyCode == pmCode {
|
|
if tyCode == pmCode {
|
|
//母线保护和母线合并单元装置编号跟随变压器
|
|
//母线保护和母线合并单元装置编号跟随变压器
|
|
//查找变压器编号
|
|
//查找变压器编号
|
|
@@ -1446,6 +1450,10 @@ func (c *CheckAreaMgr) pJ(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
pmCode := c.getIedTypeCode(modelid, "PM")
|
|
pmCode := c.getIedTypeCode(modelid, "PM")
|
|
mmCode := c.getIedTypeCode(modelid, "MM")
|
|
mmCode := c.getIedTypeCode(modelid, "MM")
|
|
for _, ty := range strings.Split(iedtypes, ",") {
|
|
for _, ty := range strings.Split(iedtypes, ",") {
|
|
|
|
+ abCode := c.getIedTypeABCode(ty)
|
|
|
|
+ if abCode != "" {
|
|
|
|
+ iednameParts[7] = abCode
|
|
|
|
+ }
|
|
tyCode := c.getIedTypeCode(modelid, ty)
|
|
tyCode := c.getIedTypeCode(modelid, ty)
|
|
inAreaIedName := ""
|
|
inAreaIedName := ""
|
|
if tyCode == pmCode {
|
|
if tyCode == pmCode {
|
|
@@ -1492,6 +1500,134 @@ func (c *CheckAreaMgr) pJ(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//母线间隔装置提取
|
|
|
|
+func (c *CheckAreaMgr) pM(modelid int, vol, iedtypes string, ieds map[string]orm.Params) {
|
|
|
|
+ scdParseMgr := new(ScdParse)
|
|
|
|
+ scdNodeMgr := new(ScdNode)
|
|
|
|
+ db := orm.NewOrm()
|
|
|
|
+ //获取当前站的各电压等级
|
|
|
|
+ volRows := []orm.Params{}
|
|
|
|
+ _, err := db.Raw("select t.vol, CAST(REPLACE(UPPER(g.name),'KV','') as SIGNED) volname from t_area_ied_relation t,global_const_code g where g.code=CONCAT('v_level_',t.vol) and g.parentcode='voltage_level' and t.vol!=999 and t.scd_id=? GROUP BY t.vol ORDER BY volname desc", c.ScdId).Values(&volRows)
|
|
|
|
+ if err != nil {
|
|
|
|
+ logger.Logger.Error(err)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if len(volRows) == 0 {
|
|
|
|
+ logger.Logger.Error(errors.New("该scd未发现任何电压等级的装置"))
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ volMap := map[string]string{}
|
|
|
|
+ volMap["hight"] = tools.IsEmpty(volRows[0]["vol"]) //高压电压
|
|
|
|
+ if len(volRows) == 2 {
|
|
|
|
+ volMap["middle"] = ""
|
|
|
|
+ volMap["low"] = volRows[1]["vol"].(string) //低压电压等级
|
|
|
|
+ } else {
|
|
|
|
+ volMap["middle"] = volRows[1]["vol"].(string) //中压电压等级
|
|
|
|
+ volMap["low"] = volRows[len(volRows)-1]["vol"].(string) //低压电压等级
|
|
|
|
+ }
|
|
|
|
+ //获取装置分组信息
|
|
|
|
+ bgm := new(SysCheckModelIedtypeGroupMgr)
|
|
|
|
+ bgm.Model = T_data_model_iedtype_group{ModelId: modelid}
|
|
|
|
+ groupList := bgm.List()
|
|
|
|
+ scdXmlObj, _ := scdParseMgr.GetScdXmlObjectBySCDID(tools.IsEmpty(c.ScdId))
|
|
|
|
+ iedCode := c.getIedTypeCode(modelid, "PM")
|
|
|
|
+ for _, row := range ieds {
|
|
|
|
+ if tools.IsEmpty(row["vol"]) != vol || tools.IsEmpty(row["ied_type"]) != iedCode[0:1] || tools.IsEmpty(row["p_type"]) != iedCode[1:] {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ pl_iedname := tools.IsEmpty(row["ied_name"])
|
|
|
|
+ iednameParts := scdParseMgr.ParseIedName(pl_iedname)
|
|
|
|
+ areadesc := tools.IsEmpty(row["ied_desc"])
|
|
|
|
+ if areadesc == "" {
|
|
|
|
+ iedobj := scdNodeMgr.GetIed(scdXmlObj, "", pl_iedname)
|
|
|
|
+ if iedobj != nil {
|
|
|
|
+ areadesc = iedobj.Desc
|
|
|
|
+ } else {
|
|
|
|
+ areadesc = tools.IsEmpty(row["area_name"])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ areadesc = strings.ReplaceAll(areadesc, "装置", "")
|
|
|
|
+ //添加间隔数据
|
|
|
|
+ dbdata := T_data_check_area{
|
|
|
|
+ ModelId: modelid,
|
|
|
|
+ ScdId: c.ScdId,
|
|
|
|
+ AreaType: "M",
|
|
|
|
+ AreaName: areadesc,
|
|
|
|
+ }
|
|
|
|
+ newid, err := db.Insert(&dbdata)
|
|
|
|
+ if err != nil {
|
|
|
|
+ logger.Logger.Error(err)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ pmVol := "" //当前PM装置的电压等级
|
|
|
|
+ for volLevel, volValue := range volMap {
|
|
|
|
+ if volValue == iednameParts[3]+iednameParts[4] {
|
|
|
|
+ pmVol = volLevel
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values"
|
|
|
|
+ insvalues := []string{}
|
|
|
|
+ mmCode := c.getIedTypeCode(modelid, "MM")
|
|
|
|
+ for _, ty := range strings.Split(iedtypes, ",") {
|
|
|
|
+ inAreaIedName := ""
|
|
|
|
+ if _, h := groupList[ty]; h {
|
|
|
|
+ //装置如果是分组成员装置,则不用检测
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ abCode := c.getIedTypeABCode(ty)
|
|
|
|
+ if abCode == "" {
|
|
|
|
+ //未特别指定套别时,采用主IED装置的套别
|
|
|
|
+ abCode = iednameParts[7]
|
|
|
|
+ }
|
|
|
|
+ tyCode := c.getIedTypeCode(modelid, ty)
|
|
|
|
+ if _, h := groupList[tyCode]; h {
|
|
|
|
+ //装置如果是分组成员装置,则不用检测
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ if tyCode == mmCode {
|
|
|
|
+ //MM:母线合并单元
|
|
|
|
+ inAreaIedName = c.getMMName(iednameParts, ieds, abCode)
|
|
|
|
+ if inAreaIedName != "" {
|
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, tyCode[0:1], tyCode[1:]))
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //需要查找同电压等级的所有同类同套装置
|
|
|
|
+ h, m, l := c.getIedListByVol(tyCode, ieds, volMap, abCode)
|
|
|
|
+ logger.Logger.Debug(fmt.Sprintf("当前PM装置:%s 电压等级:%s 提取类型:%s 套别:%s h:%+v,m:%+v,l:%+v", pl_iedname, pmVol, tyCode, abCode, h, m, l))
|
|
|
|
+ switch pmVol {
|
|
|
|
+ case "hight":
|
|
|
|
+ for _, item := range h {
|
|
|
|
+ inAreaIedName = tools.IsEmpty(item["ied_name"])
|
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, tyCode[0:1], tyCode[1:]))
|
|
|
|
+ }
|
|
|
|
+ break
|
|
|
|
+ case "middle":
|
|
|
|
+ for _, item := range m {
|
|
|
|
+ inAreaIedName = tools.IsEmpty(item["ied_name"])
|
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, tyCode[0:1], tyCode[1:]))
|
|
|
|
+ }
|
|
|
|
+ break
|
|
|
|
+ case "low":
|
|
|
|
+ for _, item := range l {
|
|
|
|
+ inAreaIedName = tools.IsEmpty(item["ied_name"])
|
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, tyCode[0:1], tyCode[1:]))
|
|
|
|
+ }
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if len(insvalues) == 0 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ _, err = db.Raw(ins1 + strings.Join(insvalues, ",")).Exec()
|
|
|
|
+ if err != nil {
|
|
|
|
+ logger.Logger.Error(err)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
//母联间隔装置关系检查
|
|
//母联间隔装置关系检查
|
|
func (c *CheckAreaMgr) cJ(modelid string, scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNodeRule *ScdNodeRule, area_name string, ied_refs []orm.Params, area_ieds []orm.Params, pjIed, area_ruleid string) {
|
|
func (c *CheckAreaMgr) cJ(modelid string, scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNodeRule *ScdNodeRule, area_name string, ied_refs []orm.Params, area_ieds []orm.Params, pjIed, area_ruleid string) {
|
|
modelidInt, _ := strconv.Atoi(modelid)
|
|
modelidInt, _ := strconv.Atoi(modelid)
|
|
@@ -1939,7 +2075,10 @@ func (c *CheckAreaMgr) getMMName(iednameParts []string, ieds map[string]orm.Para
|
|
return mmLst[0]
|
|
return mmLst[0]
|
|
}
|
|
}
|
|
for _, n := range mmLst {
|
|
for _, n := range mmLst {
|
|
- if strings.HasSuffix(n, ab) {
|
|
|
|
|
|
+ if ab != "" && strings.HasSuffix(n, ab) {
|
|
|
|
+ return n
|
|
|
|
+ }
|
|
|
|
+ if ab == "" && strings.HasSuffix(n, iednameParts[5]+iednameParts[6]) {
|
|
return n
|
|
return n
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1951,7 +2090,7 @@ func (c *CheckAreaMgr) getIedTypeABCode(iedtype string) string {
|
|
if strings.Index(iedtype, "-") > 0 {
|
|
if strings.Index(iedtype, "-") > 0 {
|
|
return strings.Split(iedtype, "-")[1]
|
|
return strings.Split(iedtype, "-")[1]
|
|
}
|
|
}
|
|
- return iedtype
|
|
|
|
|
|
+ return ""
|
|
}
|
|
}
|
|
|
|
|
|
//根据当前设备列表,分析出电压等级(高、中、低)的设备列表
|
|
//根据当前设备列表,分析出电压等级(高、中、低)的设备列表
|