|
@@ -133,17 +133,25 @@ func (c *CheckAreaMgr) Init(scdid int64) {
|
|
}
|
|
}
|
|
|
|
|
|
//保存间隔
|
|
//保存间隔
|
|
-func (c *CheckAreaMgr) Save(model_id int, area_type, area_name string) (int, error) {
|
|
|
|
|
|
+func (c *CheckAreaMgr) Save(model_id int, area_name string) (int, error) {
|
|
//判断间隔名称是否重复
|
|
//判断间隔名称是否重复
|
|
db := orm.NewOrm()
|
|
db := orm.NewOrm()
|
|
rowset := []orm.Params{}
|
|
rowset := []orm.Params{}
|
|
- db.Raw("select id from t_data_check_area where scd_id=?", c.ScdId).Values(&rowset)
|
|
|
|
|
|
+ db.Raw("select id from t_data_check_area where scd_id=? and area_name=?", c.ScdId, area_name).Values(&rowset)
|
|
if len(rowset) > 0 {
|
|
if len(rowset) > 0 {
|
|
return 0, errors.New("间隔名称" + area_name + "已存在")
|
|
return 0, errors.New("间隔名称" + area_name + "已存在")
|
|
}
|
|
}
|
|
|
|
+ modelMgr := new(SysCheckModelMgr)
|
|
|
|
+ modelMgr.Model.Id = model_id
|
|
|
|
+ modelInfo, err := modelMgr.One()
|
|
|
|
+ if err != nil {
|
|
|
|
+ return 0, err
|
|
|
|
+ }
|
|
|
|
+ areatype_codeinfo := new(Global).GetCodeInfoByID(tools.IsEmpty(modelInfo.AreaType))
|
|
|
|
+ area_type := tools.IsEmpty(areatype_codeinfo["code"])
|
|
cr := c.GetUserId()
|
|
cr := c.GetUserId()
|
|
paras := []interface{}{c.ScdId, area_name, area_type, model_id, cr}
|
|
paras := []interface{}{c.ScdId, area_name, area_type, model_id, cr}
|
|
- r, err := db.Raw("insert into t_data_check_area(scd_id,area_name,area_type,model_id,cr)values(?,?,?,?,?)", paras).Exec()
|
|
|
|
|
|
+ r, err := db.Raw("insert into t_data_check_area(scd_id,area_name,area_type,model_id,cr,voltage_level)values(?,?,?,?,?,0)", paras).Exec()
|
|
sqllog := fmt.Sprintf("添加新间隔%s", area_name)
|
|
sqllog := fmt.Sprintf("添加新间隔%s", area_name)
|
|
if err != nil {
|
|
if err != nil {
|
|
logger.Logger.Error(err)
|
|
logger.Logger.Error(err)
|
|
@@ -1549,11 +1557,16 @@ func (c *CheckAreaMgr) pT(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
for _, in := range iedname {
|
|
for _, in := range iedname {
|
|
tmpIednameParts := scdParseMgr.ParseIedName(in)
|
|
tmpIednameParts := scdParseMgr.ParseIedName(in)
|
|
if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] {
|
|
if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] {
|
|
|
|
+ if hasIedNameMap[in] == 1 {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ hasIedNameMap[in] = 1
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, in, ptype[0:1], ptype[1:]))
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, in, ptype[0:1], ptype[1:]))
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ continue
|
|
}
|
|
}
|
|
//判断间隔是否需要包含本体保护装置
|
|
//判断间隔是否需要包含本体保护装置
|
|
if strings.Contains(tyCode, "#0") {
|
|
if strings.Contains(tyCode, "#0") {
|
|
@@ -1562,11 +1575,16 @@ func (c *CheckAreaMgr) pT(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
for _, in := range iedname {
|
|
for _, in := range iedname {
|
|
tmpIednameParts := scdParseMgr.ParseIedName(in)
|
|
tmpIednameParts := scdParseMgr.ParseIedName(in)
|
|
if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] {
|
|
if tmpIednameParts[6] == iednameParts[6] && tmpIednameParts[7] == iednameParts[7] {
|
|
|
|
+ if hasIedNameMap[in] == 1 {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ hasIedNameMap[in] = 1
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, in, ptype[0:1], ptype[1:]))
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, in, ptype[0:1], ptype[1:]))
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ continue
|
|
}
|
|
}
|
|
dlIeds := []orm.Params{}
|
|
dlIeds := []orm.Params{}
|
|
imtcode := c.getIedTypeCode(modelid, tyCode)
|
|
imtcode := c.getIedTypeCode(modelid, tyCode)
|
|
@@ -1639,7 +1657,6 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
if tools.IsEmpty(row["vol"]) != vol || tools.IsEmpty(row["ied_type"]) != iedCode[0:1] || tools.IsEmpty(row["p_type"]) != iedCode[1:] {
|
|
if tools.IsEmpty(row["vol"]) != vol || tools.IsEmpty(row["ied_type"]) != iedCode[0:1] || tools.IsEmpty(row["p_type"]) != iedCode[1:] {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- pmIedName := ""
|
|
|
|
mmIedName := ""
|
|
mmIedName := ""
|
|
pl_iedname := tools.IsEmpty(row["ied_name"])
|
|
pl_iedname := tools.IsEmpty(row["ied_name"])
|
|
if _, h := groupList[pl_iedname]; h {
|
|
if _, h := groupList[pl_iedname]; h {
|
|
@@ -1669,6 +1686,7 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
logger.Logger.Error(err)
|
|
logger.Logger.Error(err)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ hasIedNameMap := map[string]int{}
|
|
ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values"
|
|
ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values"
|
|
insvalues := []string{}
|
|
insvalues := []string{}
|
|
pmCode := c.getIedTypeCode(modelid, "PM")
|
|
pmCode := c.getIedTypeCode(modelid, "PM")
|
|
@@ -1690,29 +1708,20 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
ptype := strings.Split(tyCode, "#")[0]
|
|
ptype := strings.Split(tyCode, "#")[0]
|
|
- if tyCode == pmCode {
|
|
|
|
|
|
+ if ptype == pmCode {
|
|
//母线保护和母线合并单元装置编号跟随变压器
|
|
//母线保护和母线合并单元装置编号跟随变压器
|
|
//查找变压器编号
|
|
//查找变压器编号
|
|
//1号变压器->2号变压器->3号
|
|
//1号变压器->2号变压器->3号
|
|
inAreaIedName = c.getPMName(iednameParts, ieds)
|
|
inAreaIedName = c.getPMName(iednameParts, ieds)
|
|
- pmIedName = inAreaIedName
|
|
|
|
- if mmIedName == "" {
|
|
|
|
- insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:2]))
|
|
|
|
- //pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
|
|
|
|
- //使用PM装置的名称去定义MM的名称
|
|
|
|
- tyCode = mmCode
|
|
|
|
- inAreaIedName = c.getMMName(iednameParts, ieds, iednameParts[7])
|
|
|
|
- mmIedName = inAreaIedName
|
|
|
|
- }
|
|
|
|
- } else if tyCode == mmCode {
|
|
|
|
- if pmIedName != "" && mmIedName == "" {
|
|
|
|
- //pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
|
|
|
|
- //使用PM装置的名称去定义MM的名称
|
|
|
|
- inAreaIedName = c.getMMName(iednameParts, ieds, iednameParts[7])
|
|
|
|
- mmIedName = inAreaIedName
|
|
|
|
- } else {
|
|
|
|
|
|
+ if hasIedNameMap[inAreaIedName] == 1 {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
+ hasIedNameMap[inAreaIedName] = 1
|
|
|
|
+ insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:2]))
|
|
|
|
+ continue
|
|
|
|
+ } else if ptype == mmCode {
|
|
|
|
+ //最后处理
|
|
|
|
+ continue
|
|
} else {
|
|
} else {
|
|
inAreaIedName = ptype + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6] + iednameParts[7]
|
|
inAreaIedName = ptype + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6] + iednameParts[7]
|
|
}
|
|
}
|
|
@@ -1734,6 +1743,10 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if hasIedNameMap[inAreaIedName] == 1 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ hasIedNameMap[inAreaIedName] = 1
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
}
|
|
}
|
|
_, err = db.Raw(ins1 + strings.Join(insvalues, ",")).Exec()
|
|
_, err = db.Raw(ins1 + strings.Join(insvalues, ",")).Exec()
|
|
@@ -1791,6 +1804,7 @@ func (c *CheckAreaMgr) pJ(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
logger.Logger.Error(err)
|
|
logger.Logger.Error(err)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ hasIedNameMap := map[string]int{}
|
|
ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values"
|
|
ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values"
|
|
insvalues := []string{}
|
|
insvalues := []string{}
|
|
pmCode := c.getIedTypeCode(modelid, "PM")
|
|
pmCode := c.getIedTypeCode(modelid, "PM")
|
|
@@ -1803,13 +1817,17 @@ func (c *CheckAreaMgr) pJ(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
tyCode := c.getIedTypeCode(modelid, ty)
|
|
tyCode := c.getIedTypeCode(modelid, ty)
|
|
ptype := strings.Split(tyCode, "#")[0]
|
|
ptype := strings.Split(tyCode, "#")[0]
|
|
inAreaIedName := ""
|
|
inAreaIedName := ""
|
|
- if tyCode == pmCode {
|
|
|
|
|
|
+ if ptype == pmCode {
|
|
//母线保护和母线合并单元装置编号跟随变压器
|
|
//母线保护和母线合并单元装置编号跟随变压器
|
|
//查找变压器编号
|
|
//查找变压器编号
|
|
//1号变压器->2号变压器->3号
|
|
//1号变压器->2号变压器->3号
|
|
inAreaIedName = c.getPMName(iednameParts, ieds)
|
|
inAreaIedName = c.getPMName(iednameParts, ieds)
|
|
pmIedName = inAreaIedName
|
|
pmIedName = inAreaIedName
|
|
if mmIedName == "" {
|
|
if mmIedName == "" {
|
|
|
|
+ if hasIedNameMap[inAreaIedName] == 1 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ hasIedNameMap[inAreaIedName] = 1
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
|
|
pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
|
|
//使用PM装置的名称去定义MM的名称
|
|
//使用PM装置的名称去定义MM的名称
|
|
@@ -1817,7 +1835,7 @@ func (c *CheckAreaMgr) pJ(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
inAreaIedName = c.getMMName(pmIedNameParts, ieds, iednameParts[7])
|
|
inAreaIedName = c.getMMName(pmIedNameParts, ieds, iednameParts[7])
|
|
mmIedName = inAreaIedName
|
|
mmIedName = inAreaIedName
|
|
}
|
|
}
|
|
- } else if tyCode == mmCode {
|
|
|
|
|
|
+ } else if ptype == mmCode {
|
|
if pmIedName != "" && mmIedName == "" {
|
|
if pmIedName != "" && mmIedName == "" {
|
|
pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
|
|
pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
|
|
//使用PM装置的名称去定义MM的名称
|
|
//使用PM装置的名称去定义MM的名称
|
|
@@ -1834,6 +1852,10 @@ func (c *CheckAreaMgr) pJ(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
inAreaIedName = ptype + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6]
|
|
inAreaIedName = ptype + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if hasIedNameMap[inAreaIedName] == 1 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ hasIedNameMap[inAreaIedName] = 1
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
}
|
|
}
|
|
_, err = db.Raw(ins1 + strings.Join(insvalues, ",")).Exec()
|
|
_, err = db.Raw(ins1 + strings.Join(insvalues, ",")).Exec()
|
|
@@ -1912,6 +1934,7 @@ func (c *CheckAreaMgr) pM(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ hasIedNameMap := map[string]int{}
|
|
ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values"
|
|
ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values"
|
|
insvalues := []string{}
|
|
insvalues := []string{}
|
|
mmCode := c.getIedTypeCode(modelid, "MM")
|
|
mmCode := c.getIedTypeCode(modelid, "MM")
|
|
@@ -1936,6 +1959,10 @@ func (c *CheckAreaMgr) pM(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
//MM:母线合并单元
|
|
//MM:母线合并单元
|
|
inAreaIedName = c.getMMName(iednameParts, ieds, abCode)
|
|
inAreaIedName = c.getMMName(iednameParts, ieds, abCode)
|
|
if inAreaIedName != "" {
|
|
if inAreaIedName != "" {
|
|
|
|
+ if hasIedNameMap[inAreaIedName] == 1 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ hasIedNameMap[inAreaIedName] = 1
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -1946,18 +1973,30 @@ func (c *CheckAreaMgr) pM(modelid int, vol, iedtypes string, ieds map[string]orm
|
|
case "hight":
|
|
case "hight":
|
|
for _, item := range h {
|
|
for _, item := range h {
|
|
inAreaIedName = tools.IsEmpty(item["ied_name"])
|
|
inAreaIedName = tools.IsEmpty(item["ied_name"])
|
|
|
|
+ if hasIedNameMap[inAreaIedName] == 1 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ hasIedNameMap[inAreaIedName] = 1
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
}
|
|
}
|
|
break
|
|
break
|
|
case "middle":
|
|
case "middle":
|
|
for _, item := range m {
|
|
for _, item := range m {
|
|
inAreaIedName = tools.IsEmpty(item["ied_name"])
|
|
inAreaIedName = tools.IsEmpty(item["ied_name"])
|
|
|
|
+ if hasIedNameMap[inAreaIedName] == 1 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ hasIedNameMap[inAreaIedName] = 1
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
}
|
|
}
|
|
break
|
|
break
|
|
case "low":
|
|
case "low":
|
|
for _, item := range l {
|
|
for _, item := range l {
|
|
inAreaIedName = tools.IsEmpty(item["ied_name"])
|
|
inAreaIedName = tools.IsEmpty(item["ied_name"])
|
|
|
|
+ if hasIedNameMap[inAreaIedName] == 1 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ hasIedNameMap[inAreaIedName] = 1
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ptype[0:1], ptype[1:]))
|
|
}
|
|
}
|
|
break
|
|
break
|
|
@@ -2429,7 +2468,8 @@ func (c *CheckAreaMgr) getMMName(iednameParts []string, ieds map[string]orm.Para
|
|
return n
|
|
return n
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return ""
|
|
|
|
|
|
+ //理论上的装置名称
|
|
|
|
+ return "MM" + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6] + ab
|
|
}
|
|
}
|
|
|
|
|
|
//获取装置编码中的套别代码(A、B..)
|
|
//获取装置编码中的套别代码(A、B..)
|