|
@@ -164,11 +164,20 @@ func (c *CheckAreaMgr) GetAreaList(scdid int64) ([]orm.Params, error) {
|
|
|
}
|
|
|
|
|
|
//获取指定scd和电压等级的间隔信息
|
|
|
-func (c *CheckAreaMgr) GetAreaListByVol(scdid int64, vl int32) ([]orm.Params, error) {
|
|
|
+func (c *CheckAreaMgr) GetAreaListByVol(scdid int64, vl, linkstyleid int) ([]orm.Params, error) {
|
|
|
db := orm.NewOrm()
|
|
|
- sql := "select * from t_data_check_area where scd_id=? and voltage_level=? order by name"
|
|
|
+ sql := "select t1.id model_id, t1.model_name,t1.vol_id,g1.name vol_name,t1.line_link_style,ls.name,t.id area_id, t.area_name,t.ut,t.ur from t_data_check_area t right join t_data_model_defualt t1 on t.model_id=t1.id left join t_data_link_style ls on t1.line_link_style=ls.id left join global_const_code g1 on t1.vol_id=g1.id and g1.parentcode='voltage_level' where t.scd_id=? "
|
|
|
+ params := []interface{}{scdid}
|
|
|
+ if vl > 0 {
|
|
|
+ sql = sql + " and t1.vol_id=? "
|
|
|
+ params = append(params, vl)
|
|
|
+ }
|
|
|
+ if linkstyleid > 0 {
|
|
|
+ sql = sql + " and t1.line_link_style=? "
|
|
|
+ params = append(params, linkstyleid)
|
|
|
+ }
|
|
|
rowset := []orm.Params{}
|
|
|
- _, err := db.Raw(sql, scdid, vl).Values(&rowset)
|
|
|
+ _, err := db.Raw(sql, params).Values(&rowset)
|
|
|
sqllog := fmt.Sprintf("SQL:%s 参数:%+v", sql, []interface{}{scdid, vl})
|
|
|
if err != nil {
|
|
|
logger.Logger.Error(err, sqllog)
|
|
@@ -290,6 +299,22 @@ func (c *CheckAreaMgr) ParseModelArea() {
|
|
|
for _, r := range iedlst {
|
|
|
iedMap[tools.IsEmpty(r["ied_name"])] = r
|
|
|
}
|
|
|
+ //先分析母联间隔,如果没有选择母联间隔时,主变间隔中不包含母联终端装置
|
|
|
+ HasAreaJ := false
|
|
|
+ for _, row := range c.CheckModelList {
|
|
|
+ areaCode := tools.IsEmpty(row["area_type_code"])
|
|
|
+ if areaCode == "J" {
|
|
|
+ HasAreaJ = true
|
|
|
+ modelid, _ := strconv.Atoi(tools.IsEmpty(row["id"]))
|
|
|
+ //modelname := tools.IsEmpty(row["model_name"])
|
|
|
+ iedtypes := tools.IsEmpty(row["ied_types"])
|
|
|
+ volcode := strings.ReplaceAll(tools.IsEmpty(row["vol_code"]), "v_level_", "")
|
|
|
+ c.pJ(modelid, volcode, iedtypes, iedMap, "PE")
|
|
|
+ c.pJ(modelid, volcode, iedtypes, iedMap, "PJ")
|
|
|
+ c.pJ(modelid, volcode, iedtypes, iedMap, "PK")
|
|
|
+ c.pJ(modelid, volcode, iedtypes, iedMap, "PF")
|
|
|
+ }
|
|
|
+ }
|
|
|
for _, row := range c.CheckModelList {
|
|
|
//逐一分析模型定义
|
|
|
modelid, _ := strconv.Atoi(tools.IsEmpty(row["id"]))
|
|
@@ -314,10 +339,14 @@ func (c *CheckAreaMgr) ParseModelArea() {
|
|
|
if modelname == "" || iedtypes == "" {
|
|
|
continue
|
|
|
}
|
|
|
+ //母联间隔已经提前分析,如果没有母联间隔时,主变间隔中不包含母联终端装置
|
|
|
+ if areaCode == "J" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
//获取模型内中装备关系定义
|
|
|
//主变间隔分析:需要查站内该电压等级下的高中低压侧装置或者高低压装置组成一个间隔,以主变保护装置(PT)为起始
|
|
|
if areaCode == "T" {
|
|
|
- go c.pT(modelid, iedtypes, iedMap)
|
|
|
+ go c.pT(modelid, iedtypes, iedMap, HasAreaJ)
|
|
|
}
|
|
|
//线路保护间隔分析:以线路保护测控装置(PL)为开始分析
|
|
|
if areaCode == "L" {
|
|
@@ -327,8 +356,198 @@ func (c *CheckAreaMgr) ParseModelArea() {
|
|
|
}
|
|
|
|
|
|
//变压器间隔分析
|
|
|
-func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Params) {
|
|
|
-
|
|
|
+func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Params, HasAreaJ bool) {
|
|
|
+ scdParseMgr := new(ScdParse)
|
|
|
+ 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) //低压电压等级
|
|
|
+ }
|
|
|
+ for _, row := range ieds {
|
|
|
+ if tools.IsEmpty(row["ied_type"]) != "P" || tools.IsEmpty(row["p_type"]) != "T" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //pmIedName := ""
|
|
|
+ //mmIedName := ""
|
|
|
+ pl_iedname := tools.IsEmpty(row["ied_name"])
|
|
|
+ iednameParts := scdParseMgr.ParseIedName(pl_iedname)
|
|
|
+ //添加间隔数据
|
|
|
+ dbdata := T_data_check_area{
|
|
|
+ ModelId: modelid,
|
|
|
+ ScdId: c.ScdId,
|
|
|
+ AreaType: "T",
|
|
|
+ AreaName: tools.IsEmpty(row["area_name"]) + iednameParts[7],
|
|
|
+ }
|
|
|
+ newid, err := db.Insert(&dbdata)
|
|
|
+ if err != nil {
|
|
|
+ logger.Logger.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ 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"))
|
|
|
+ //合智一体IMT/MIT,分高中低压
|
|
|
+ h, m, l := c.getIedListByVol("IMT", 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]
|
|
|
+ if lastChar == iednameParts[7] {
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "IM", "T"))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ h, m, l = c.getIedListByVol("MIT", 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]
|
|
|
+ if lastChar == iednameParts[7] {
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "MI", "T"))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //母联智能终端IE需要分高中压,无低压侧
|
|
|
+ if HasAreaJ {
|
|
|
+ h, m, l = c.getIedListByVol("IE", ieds, volMap)
|
|
|
+ for _, r := range h {
|
|
|
+ //高压侧,AB套必须与PT装置相同
|
|
|
+ inAreaIedName = tools.IsEmpty(r["ied_name"])
|
|
|
+ tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName)
|
|
|
+ lastChar := tmpIednameParts[7]
|
|
|
+ if lastChar == iednameParts[7] {
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "I", "E"))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, r := range m {
|
|
|
+ //中压侧
|
|
|
+ inAreaIedName = tools.IsEmpty(r["ied_name"])
|
|
|
+ tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName)
|
|
|
+ lastChar := tmpIednameParts[7]
|
|
|
+ if lastChar == "" || lastChar == iednameParts[7] {
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "I", "E"))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //合并单元MT分高中低压侧;低压侧无关联母线合并单元MM
|
|
|
+ h, m, l = c.getIedListByVol("MT", 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]
|
|
|
+ if lastChar == iednameParts[7] {
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "M", "T"))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //测控装置CT分高中低压侧,且可能是多套合并单元MT共用,既不分AB套
|
|
|
+ h, m, l = c.getIedListByVol("CT", 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"]) && (lastChar == "" || lastChar == iednameParts[7]) {
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "C", "T"))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //智能终端(IB:开关\IT:分支\IF:分段)分高中低压侧
|
|
|
+ h, m, l = c.getIedListByVol("IB", 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"]) && (lastChar == "" || lastChar == iednameParts[7]) {
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "I", "B"))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ h, m, l = c.getIedListByVol("IT", 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"]) && (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("IF", 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"]) && (lastChar == "" || lastChar == iednameParts[7]) {
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "I", "F"))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //母线保护PM及母线合并单元MM,可能是多套合并单元MT共用,既不分AB套;低压侧智能终端无关联母线保护
|
|
|
+ h, m, l = c.getIedListByVol("PM", ieds, volMap)
|
|
|
+ for _, r := range h {
|
|
|
+ //高压侧,AB套必须与PT装置相同
|
|
|
+ inAreaIedName = tools.IsEmpty(r["ied_name"])
|
|
|
+ tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName)
|
|
|
+ lastChar := tmpIednameParts[7]
|
|
|
+ if 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, r := range m {
|
|
|
+ //中压侧
|
|
|
+ inAreaIedName = tools.IsEmpty(r["ied_name"])
|
|
|
+ tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName)
|
|
|
+ lastChar := tmpIednameParts[7]
|
|
|
+ if 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _, err = db.Raw(ins1 + strings.Join(insvalues, ",")).Exec()
|
|
|
+ if err != nil {
|
|
|
+ logger.Logger.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//线路间隔分析
|
|
@@ -337,17 +556,21 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
|
scdParseMgr := new(ScdParse)
|
|
|
//scdNodeMgr := new(ScdNode)
|
|
|
db := orm.NewOrm()
|
|
|
+
|
|
|
//scdXmlObject, _ := scdParseMgr.GetScdXmlObjectBySCDID(tools.IsEmpty(c.ScdId))
|
|
|
for _, row := range ieds {
|
|
|
if tools.IsEmpty(row["vol"]) != vol || tools.IsEmpty(row["ied_type"]) != "P" || tools.IsEmpty(row["p_type"]) != "L" {
|
|
|
continue
|
|
|
}
|
|
|
+ pmIedName := ""
|
|
|
+ mmIedName := ""
|
|
|
pl_iedname := tools.IsEmpty(row["ied_name"])
|
|
|
iednameParts := scdParseMgr.ParseIedName(pl_iedname)
|
|
|
//添加间隔数据
|
|
|
dbdata := T_data_check_area{
|
|
|
ModelId: modelid,
|
|
|
ScdId: c.ScdId,
|
|
|
+ AreaType: "L",
|
|
|
AreaName: tools.IsEmpty(row["area_name"]) + iednameParts[7],
|
|
|
}
|
|
|
newid, err := db.Insert(&dbdata)
|
|
@@ -364,8 +587,24 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
|
//查找变压器编号
|
|
|
//1号变压器->2号变压器->3号
|
|
|
inAreaIedName = c.getPMName(iednameParts, ieds)
|
|
|
+ pmIedName = inAreaIedName
|
|
|
+ if mmIedName == "" {
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ty[0:1], ty[1:2]))
|
|
|
+ pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
|
|
|
+ //使用PM装置的名称去定义MM的名称
|
|
|
+ ty = "MM"
|
|
|
+ inAreaIedName = c.getMMName(pmIedNameParts, ieds, iednameParts[7])
|
|
|
+ mmIedName = inAreaIedName
|
|
|
+ }
|
|
|
} else if ty == "MM" {
|
|
|
- inAreaIedName = c.getMMName(iednameParts, ieds)
|
|
|
+ if pmIedName != "" && mmIedName == "" {
|
|
|
+ pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
|
|
|
+ //使用PM装置的名称去定义MM的名称
|
|
|
+ inAreaIedName = c.getMMName(pmIedNameParts, ieds, iednameParts[7])
|
|
|
+ mmIedName = inAreaIedName
|
|
|
+ } else {
|
|
|
+ continue
|
|
|
+ }
|
|
|
} else {
|
|
|
inAreaIedName = ty + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6] + iednameParts[7]
|
|
|
}
|
|
@@ -392,7 +631,91 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
|
logger.Logger.Error(err)
|
|
|
return
|
|
|
}
|
|
|
+ //如果mm装置还未确定
|
|
|
+ if mmIedName == "" {
|
|
|
+ pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
|
|
|
+ inAreaIedName := c.getMMName(pmIedNameParts, ieds, iednameParts[7])
|
|
|
+ _, err = db.Raw(ins1 + fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "M", "M")).Exec()
|
|
|
+ if err != nil {
|
|
|
+ logger.Logger.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//母联间隔分析
|
|
|
+func (c *CheckAreaMgr) pJ(modelid int, vol, iedtypes string, ieds map[string]orm.Params, pjIed string) {
|
|
|
+ scdParseMgr := new(ScdParse)
|
|
|
+ //scdNodeMgr := new(ScdNode)
|
|
|
+ db := orm.NewOrm()
|
|
|
+ //scdXmlObject, _ := scdParseMgr.GetScdXmlObjectBySCDID(tools.IsEmpty(c.ScdId))
|
|
|
+ for _, row := range ieds {
|
|
|
+ if tools.IsEmpty(row["vol"]) != vol || tools.IsEmpty(row["ied_type"]) != "P" || tools.IsEmpty(row["p_type"]) != pjIed[1:2] {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ pmIedName := ""
|
|
|
+ mmIedName := ""
|
|
|
+ pl_iedname := tools.IsEmpty(row["ied_name"])
|
|
|
+ iednameParts := scdParseMgr.ParseIedName(pl_iedname)
|
|
|
+ //添加间隔数据
|
|
|
+ dbdata := T_data_check_area{
|
|
|
+ ModelId: modelid,
|
|
|
+ ScdId: c.ScdId,
|
|
|
+ AreaType: "J",
|
|
|
+ AreaName: tools.IsEmpty(row["area_name"]) + iednameParts[7],
|
|
|
+ }
|
|
|
+ newid, err := db.Insert(&dbdata)
|
|
|
+ if err != nil {
|
|
|
+ logger.Logger.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values"
|
|
|
+ insvalues := []string{}
|
|
|
+ for _, ty := range strings.Split(iedtypes, ",") {
|
|
|
+ inAreaIedName := ""
|
|
|
+ if ty == "PM" {
|
|
|
+ //母线保护和母线合并单元装置编号跟随变压器
|
|
|
+ //查找变压器编号
|
|
|
+ //1号变压器->2号变压器->3号
|
|
|
+ inAreaIedName = c.getPMName(iednameParts, ieds)
|
|
|
+ pmIedName = inAreaIedName
|
|
|
+ if mmIedName == "" {
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ty[0:1], ty[1:2]))
|
|
|
+ pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
|
|
|
+ //使用PM装置的名称去定义MM的名称
|
|
|
+ ty = "MM"
|
|
|
+ inAreaIedName = c.getMMName(pmIedNameParts, ieds, iednameParts[7])
|
|
|
+ mmIedName = inAreaIedName
|
|
|
+ }
|
|
|
+ } else if ty == "MM" {
|
|
|
+ if pmIedName != "" && mmIedName == "" {
|
|
|
+ pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
|
|
|
+ //使用PM装置的名称去定义MM的名称
|
|
|
+ inAreaIedName = c.getMMName(pmIedNameParts, ieds, iednameParts[7])
|
|
|
+ mmIedName = inAreaIedName
|
|
|
+ } else {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ty = ty[0:1] + pjIed[1:2]
|
|
|
+ inAreaIedName = ty + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6] + iednameParts[7]
|
|
|
+ //判断与基准保护装置相同套号的装置是否存在
|
|
|
+ if ieds[inAreaIedName] == nil {
|
|
|
+ //尝试去除套号
|
|
|
+ inAreaIedName = ty + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ty[0:1], ty[1:2]))
|
|
|
+ }
|
|
|
+ _, err = db.Raw(ins1 + strings.Join(insvalues, ",")).Exec()
|
|
|
+ if err != nil {
|
|
|
+ logger.Logger.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//根据参考ied name找出应该关联PM装置
|
|
@@ -411,20 +734,38 @@ func (c *CheckAreaMgr) getPMName(iednameParts []string, ieds map[string]orm.Para
|
|
|
}
|
|
|
|
|
|
//根据参考ied name找出应该关联MM装置
|
|
|
-func (c *CheckAreaMgr) getMMName(iednameParts []string, ieds map[string]orm.Params) string {
|
|
|
- tmpIedName := "MM" + iednameParts[3] + iednameParts[4] + iednameParts[5] + "1" + iednameParts[7]
|
|
|
- iedObj := ieds[tmpIedName]
|
|
|
- if iedObj != nil {
|
|
|
- } else {
|
|
|
- tmpIedName = "MM" + iednameParts[3] + iednameParts[4] + iednameParts[5] + "2" + iednameParts[7]
|
|
|
- iedObj = ieds[tmpIedName]
|
|
|
- if iedObj != nil {
|
|
|
- return tmpIedName
|
|
|
- }
|
|
|
+func (c *CheckAreaMgr) getMMName(iednameParts []string, ieds map[string]orm.Params, ab string) string {
|
|
|
+ tmpIedName := "MM" + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6] + ab
|
|
|
+ if ieds[tmpIedName] == nil {
|
|
|
+ tmpIedName = "MM" + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6] + iednameParts[7]
|
|
|
}
|
|
|
return tmpIedName
|
|
|
}
|
|
|
|
|
|
+//根据当前设备列表,分析出电压等级(高、中、低)的设备列表
|
|
|
+// CT测控、IT智能终端、MT合并单元需要判断是否是本体装置,是则将其归为主变高压侧
|
|
|
+func (c *CheckAreaMgr) getIedListByVol(iedtype string, ieds map[string]orm.Params, vollevel map[string]string) (hightLst, middleLst, lowLst []orm.Params) {
|
|
|
+ tmpLst := map[string][]orm.Params{}
|
|
|
+ for _, v := range vollevel {
|
|
|
+ tmpLst[v] = []orm.Params{}
|
|
|
+ }
|
|
|
+ scdParseMgr := new(ScdParse)
|
|
|
+ for _, row := range ieds {
|
|
|
+ pl_iedname := tools.IsEmpty(row["ied_name"])
|
|
|
+ if pl_iedname[0:len(iedtype)] != iedtype {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ iednameParts := scdParseMgr.ParseIedName(pl_iedname)
|
|
|
+ volvalue := iednameParts[3] + iednameParts[4]
|
|
|
+ if tmpLst[volvalue] == nil {
|
|
|
+ tmpLst[volvalue] = []orm.Params{row}
|
|
|
+ } else {
|
|
|
+ tmpLst[volvalue] = append(tmpLst[volvalue], row)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return tmpLst[vollevel["hight"]], tmpLst[vollevel["middle"]], tmpLst[vollevel["low"]]
|
|
|
+}
|
|
|
+
|
|
|
//测试
|
|
|
func (c *CheckAreaMgr) TestAppendNode(iedname string) {
|
|
|
//t := t_scd_node_scl{NodeName: iedname}
|