Ver código fonte

添加端子自动关联功能

liling 1 ano atrás
pai
commit
ef43fb38ca

+ 85 - 5
service/controllers/busAdminController.go

@@ -369,6 +369,75 @@ func (c *BusAdminController) DeleteSysModelByID() {
 	c.ServeJSON()
 }
 
+// @Summary 更新检测模型指定装置的类型编码
+//	@Description  更新检测模型指定装置的类型编码
+// 	@Tags         业务管理服务
+// 	@Accept       x-www-form-urlencoded
+// 	@Produce      json
+//	@Param 	id 			formData   int  true 	"模型ID"
+//	@Param 	old_iedtype formData   string  true 	"装置原编码"
+//	@Param 	new_iedtype formData   string  true 	"装置新编码"
+// 	@Success     200    {object} ResultOK 成功
+// 	@Failure 	 500 	{object} ResultError  失败
+// @router /admin/sysmodel/update/iedtype [post]
+func (c *BusAdminController) UPdateSysModelIedType() {
+	id, _ := c.GetInt("id")
+	if id == 0 {
+		c.Data["json"] = c.ResultError("模型编号不能为空!")
+		c.ServeJSON()
+		return
+	}
+	oldtype := c.GetString("old_iedtype")
+	newtype := c.GetString("new_iedtype")
+	if oldtype == "" || newtype == "" {
+		c.Data["json"] = c.ResultError("装置类型编码不能为空!")
+		c.ServeJSON()
+		return
+	}
+	obj := new(bo.SysCheckModelMgr)
+	obj.SetUserInfo(c.GetCurrentUserInfo())
+	obj.Model = bo.T_data_model_defualt{Id: id}
+	err := obj.UpdateIedType(oldtype, newtype)
+	if err != nil {
+		c.Data["json"] = c.ResultError(err.Error())
+		c.ServeJSON()
+		return
+	}
+	c.Data["json"] = c.ResultOK("", 0)
+	c.ServeJSON()
+}
+
+// @Summary 获取检测模型指定装置的自定义类型编码
+//	@Description  获取检测模型指定装置的自定义类型编码
+// 	@Tags         业务管理服务
+// 	@Accept       x-www-form-urlencoded
+// 	@Produce      json
+//	@Param 	id 			formData   int  true 	"模型ID"
+//	@Param 	ied_type formData   string  true 	"装置原编码"
+// 	@Success     200    {object} ResultOK 成功
+// 	@Failure 	 500 	{object} ResultError  失败
+// @router /admin/sysmodel/get/iedtype [get]
+func (c *BusAdminController) GetSysModelIedTypeMapping() {
+	id, _ := c.GetInt("id")
+	if id == 0 {
+		c.Data["json"] = c.ResultError("模型编号不能为空!")
+		c.ServeJSON()
+		return
+	}
+	oldtype := c.GetString("ied_type")
+	if oldtype == "" {
+		c.Data["json"] = c.ResultError("装置类型编码不能为空!")
+		c.ServeJSON()
+		return
+	}
+	obj := new(bo.SysCheckModelMgr)
+	obj.SetUserInfo(c.GetCurrentUserInfo())
+	obj.Model = bo.T_data_model_defualt{Id: id}
+	r := obj.GetIedtypeMapping(oldtype)
+	c.Data["json"] = c.ResultOK(r, 0)
+	c.ServeJSON()
+}
+
 // @Summary 查询检测模型列表
 //	@Description  查询检测模型列表。支持名称、电压等级等过滤条件
 // 	@Tags         检测任务服务接口
@@ -621,7 +690,8 @@ func (c *BusAdminController) GetFuncListByIedType() {
 // 	@Accept       x-www-form-urlencoded
 // 	@Produce      json
 //	@Param 	model_id 	formData   int  	true 	"模型ID"
-//	@Param 	ied_type 	formData   string  	true 	"装置类型"
+//	@Param 	ied_type 	formData   string  	true 	"查询的装置类型"
+//	@Param 	ref_ied_type formData   string  true 	"对侧关联装置类型"
 //	@Param 	sv_or_goose formData   string  	true 	"信号类型。仅支持:SV或GOOSE"
 //	@Param 	in_or_out	formData   string  	true 	"信号方向。仅支持:'输出'或'接收'"
 // 	@Success     200    {object} ResultOK 成功
@@ -636,11 +706,16 @@ func (c *BusAdminController) GetFuncFcdaList() {
 	}
 	ied_type := c.GetString("ied_type")
 	if ied_type == "" {
-		c.Data["json"] = c.ResultError("装置类型不能为空!")
+		c.Data["json"] = c.ResultError("查询的装置类型不能为空!")
+		c.ServeJSON()
+		return
+	}
+	ref_ied_type := c.GetString("ref_ied_type")
+	if ied_type == "" {
+		c.Data["json"] = c.ResultError("对侧关联装置类型不能为空!")
 		c.ServeJSON()
 		return
 	}
-
 	obj := new(bo.SysCheckModelIedFuncMgr)
 	obj.SetUserInfo(c.GetCurrentUserInfo())
 	lst, err := obj.GetList(modelid, ied_type)
@@ -649,6 +724,11 @@ func (c *BusAdminController) GetFuncFcdaList() {
 		c.ServeJSON()
 		return
 	}
+	if len(lst) == 0 {
+		c.Data["json"] = c.ResultOK("", 0)
+		c.ServeJSON()
+		return
+	}
 	funcids := []string{}
 	for _, row := range lst {
 		funcids = append(funcids, tools.IsEmpty(row["id"]))
@@ -658,7 +738,7 @@ func (c *BusAdminController) GetFuncFcdaList() {
 	fcdaMgr.Model.ModelId = modelid
 	fcdaMgr.Model.Svorgoose = strings.ToUpper(c.GetString("sv_or_goose"))
 	fcdaMgr.Model.Inorout = c.GetString("in_or_out")
-	fcdaList, err := fcdaMgr.GetList(funcids)
+	fcdaList, err := fcdaMgr.GetList(ref_ied_type, funcids)
 	if err != nil {
 		c.Data["json"] = c.ResultError(err.Error())
 		c.ServeJSON()
@@ -738,7 +818,7 @@ func (c *BusAdminController) SaveFuncFcda() {
 	mgr := new(bo.SysCheckModelIedFuncMgr)
 	mgr.SetUserInfo(c.GetCurrentUserInfo())
 	mgr.Model = mod
-	err := mgr.Save()
+	_, _, err := mgr.Save()
 	if err != nil {
 		c.Data["json"] = c.ResultError(err.Error())
 		c.ServeJSON()

+ 80 - 11
service/models/bo/check_sys_model.go

@@ -110,6 +110,39 @@ func (c *SysCheckModelMgr) Save() (err error) {
 			return errors.New("模型名称已存在")
 		}
 		c.Model.Cr, _ = strconv.Atoi(c.GetUserId())
+		//处理组合装置
+		if c.Model.RelationJson != "" {
+			modelJson := map[string]interface{}{}
+			err = json.Unmarshal([]byte(c.Model.RelationJson), &modelJson)
+			if err != nil {
+				logger.Logger.Error(err)
+				dblog.Description = fmt.Sprintf("保存%s信息失败:%s,操作数据:%+v", sysCheckModelDesc, err.Error(), c.Model)
+				dblog.Fail2()
+				return err
+			}
+			if modelJson["nodes"] != nil {
+				nodes := modelJson["nodes"].([]interface{})
+				iedtypes := []string{}
+				for _, ritem := range nodes {
+					ritem2 := ritem.(map[string]interface{})
+					nodetype := tools.IsEmpty(ritem2["type"])
+					if nodetype == "group" {
+						properties := ritem2["properties"].(map[string]interface{})
+						iedtypes = append(iedtypes, tools.IsEmpty(properties["ied_type"]))
+						continue
+					}
+					properties := ritem2["properties"].(map[string]interface{})
+					tmp := tools.IsEmpty(properties["ied_type"])
+					if arrayex.IndexOf(iedtypes, tmp) > 0 {
+						//装置类型重复了
+						return errors.New("装置类型" + tmp + "不能重复引用")
+					}
+					iedtypes = append(iedtypes, tmp)
+				}
+				c.Model.IedTypes = strings.Join(iedtypes, ",")
+			}
+
+		}
 		newid, err2 := db.Insert(&c.Model)
 		if err2 == nil {
 			//添加接线方式与模型关系
@@ -203,25 +236,19 @@ func (c *SysCheckModelMgr) Save() (err error) {
 			if modelJson["nodes"] != nil {
 				nodes := modelJson["nodes"].([]interface{})
 				iedtypes := []string{}
-				groupIedTypes := map[string]int{}
+				//groupIedTypes := map[string]int{}
 				for _, ritem := range nodes {
 					ritem2 := ritem.(map[string]interface{})
 					nodetype := tools.IsEmpty(ritem2["type"])
 					if nodetype == "group" {
 						//装置分组
-						childrens := ritem2["children"]
-						if childrens != nil {
-							for _, ci := range childrens.([]string) {
-								groupIedTypes[ci] = 1
-							}
-						}
+						properties := ritem2["properties"].(map[string]interface{})
+						tmp := tools.IsEmpty(properties["ied_type"])
+						iedtypes = append(iedtypes, tmp)
+						continue
 					}
 					properties := ritem2["properties"].(map[string]interface{})
 					tmp := tools.IsEmpty(properties["ied_type"])
-					if groupIedTypes[tmp] == 1 {
-						//过滤属于分组中的装置类型
-						continue
-					}
 					if arrayex.IndexOf(iedtypes, tmp) > 0 {
 						//装置类型重复了
 						return errors.New("装置类型" + tmp + "不能重复引用")
@@ -283,6 +310,41 @@ func (c *SysCheckModelMgr) One() (T_data_model_defualt, error) {
 	return tmpMod, err
 }
 
+//更新指定模型中的指定装置类型编码
+func (c *SysCheckModelMgr) UpdateIedType(oldiedtype, newiedtype string) error {
+	dblog := new(SystemLog)
+	dblog.SetUserInfo(c.GetUserInfo())
+	dblog.Audittype = enum.AuditType_check_model
+	dblog.Logtype = enum.LogType_Delete
+	dblog.Eventtype = enum.OptEventType_Bus
+	dblog.Eventlevel = enum.OptEventLevel_Hight
+	mapping := new(SysCheckModelIedtypeMappingMgr)
+	mapping.Model = T_data_model_iedtype_maping{ModelId: c.Model.Id}
+	mapping.Model.IedType = oldiedtype
+	mapping.Model.MappingIedType = newiedtype
+	err := mapping.Save()
+	if err != nil {
+		dblog.Description = fmt.Sprintf("设置%s%s装置类型编码(%s->%s)失败:%s", sysCheckModelDesc, c.Model.ModelName, oldiedtype, newiedtype, err.Error())
+		dblog.Fail2()
+	} else {
+		dblog.Description = fmt.Sprintf("设置%s%s装置类型编码(%s->%s)成功", sysCheckModelDesc, c.Model.ModelName, oldiedtype, newiedtype)
+		dblog.Success2()
+	}
+	return err
+}
+
+//获取指定装置类型的自定义类型编码
+func (c *SysCheckModelMgr) GetIedtypeMapping(iedtype string) string {
+	mapping := new(SysCheckModelIedtypeMappingMgr)
+	mapping.Model = T_data_model_iedtype_maping{ModelId: c.Model.Id}
+	mapping.Model.IedType = iedtype
+	re := mapping.List()
+	if len(re) == 0 {
+		return ""
+	}
+	return re[iedtype]
+}
+
 //根据model中指定的id删除
 func (c *SysCheckModelMgr) Delete() (err error) {
 	dblog := new(SystemLog)
@@ -316,6 +378,9 @@ func (c *SysCheckModelMgr) Delete() (err error) {
 		bgm := new(SysCheckModelIedtypeGroupMgr)
 		bgm.Model = T_data_model_iedtype_group{ModelId: c.Model.Id}
 		bgm.Delete()
+		obj1 := new(SysCheckModelIedtypeMappingMgr)
+		obj1.Model = T_data_model_iedtype_maping{ModelId: c.Model.Id}
+		obj1.Delete()
 		dblog.Description = fmt.Sprintf("删除%s%s成功", sysCheckModelDesc, c.Model.ModelName)
 		dblog.Success2()
 	}
@@ -366,6 +431,10 @@ func (c *SysCheckModelMgr) Copy(modelid int) (error, int) {
 		bgm := new(SysCheckModelIedtypeGroupMgr)
 		bgm.Model = T_data_model_iedtype_group{ModelId: modelid}
 		bgm.Copy(int(newid))
+		//复制装置类型自定义信息
+		obj1 := new(SysCheckModelIedtypeMappingMgr)
+		obj1.Model = T_data_model_iedtype_maping{ModelId: c.Model.Id}
+		obj1.Copy(int(newid))
 		//复制功能及端子信息
 		m3 := new(SysCheckModelIedFuncMgr)
 		m3.SetUserInfo(c.GetUserInfo())

+ 52 - 36
service/models/bo/check_sysmodel_ied_func.go

@@ -14,19 +14,20 @@ import (
 
 //系统内置模型-装置功能管理
 type T_data_model_func_def struct {
-	Id           int    `orm:"pk"`
-	ModelId      int    // '模型ID' ,
-	IedType      string // '装置类型;关联代码:device_type',
-	FuncName     string // '功能名称',
-	FuncFcdaId   int    `orm:"-"`
-	FcdaName     string `orm:"-"` // 端子设计名称
-	FcdaMatchExp string `orm:"-"` // 端子匹配表达式
-	Svorgoose    string `orm:"-"`
-	Inorout      string `orm:"-"`
-	Cr           int    // '创建人' ,
-	Ct           string `orm:"-"` // '创建时间' ,
-	Ur           int    // '更新人' ,
-	Ut           string `orm:"-"` // '更新时间'
+	Id             int    `orm:"pk"`
+	ModelId        int    // '模型ID' ,
+	IedType        string // '装置类型;关联代码:device_type',
+	FuncName       string // '功能名称',
+	FuncFcdaId     int    `orm:"-"`
+	FcdaName       string `orm:"-"` // 端子设计名称
+	FcdaMatchExp   string `orm:"-"` // 端子匹配表达式
+	Svorgoose      string `orm:"-"`
+	Inorout        string `orm:"-"`
+	ReceiveIedType string `orm:"-"`
+	Cr             int    // '创建人' ,
+	Ct             string `orm:"-"` // '创建时间' ,
+	Ur             int    // '更新人' ,
+	Ut             string `orm:"-"` // '更新时间'
 }
 
 //内置检测模型-装置功能管理对象
@@ -42,7 +43,7 @@ func init() {
 }
 
 //保存检测模型装置功能信息
-func (c *SysCheckModelIedFuncMgr) Save() (err error) {
+func (c *SysCheckModelIedFuncMgr) Save() (funcid, fcdaid int, err error) {
 	dblog := new(SystemLog)
 	dblog.SetUserInfo(c.GetUserInfo())
 	dblog.Audittype = enum.AuditType_check_model
@@ -52,59 +53,64 @@ func (c *SysCheckModelIedFuncMgr) Save() (err error) {
 	db := orm.NewOrm()
 	hasName, err := c.Exist()
 	if err != nil {
-		return err
+		return 0, 0, err
 	}
 	if c.Model.Svorgoose != "SV" && c.Model.Svorgoose != "GOOSE" {
-		return errors.New("端子信号类型值无效,仅支持SV或GOOSE")
+		return 0, 0, errors.New("端子信号类型值无效,仅支持SV或GOOSE")
 	}
-	if c.Model.Inorout != "接收" && c.Model.Inorout != "输出" {
-		return errors.New("端子信号方向值无效,仅支持'接收'或'输出'")
+	if !strings.Contains(c.Model.Inorout, "接收") && !strings.Contains(c.Model.Inorout, "输出") {
+		return 0, 0, errors.New("端子信号方向值无效,仅支持'接收'或'输出'")
 	}
+	funcid2 := int64(c.Model.Id)
 	db.Begin()
 	if c.Model.Id > 0 {
 		//编辑
 		if hasName > 0 && c.Model.Id != hasName {
 			db.Rollback()
-			return errors.New("功能名称已存在")
+			return 0, 0, errors.New("功能名称已存在")
 		}
 		_, err = db.Update(&c.Model)
 	} else {
 		//新增
 		if hasName > 0 {
 			db.Rollback()
-			return errors.New("功能名称已存在")
+			return 0, 0, errors.New("功能名称已存在")
 		}
-		newid, err2 := db.Insert(&c.Model)
-		err = err2
-		c.Model.Id = int(newid)
+		funcid2, err = db.Insert(&c.Model)
 	}
 	if err != nil {
 		logger.Logger.Error(err)
 		dblog.Description = fmt.Sprintf("保存%s信息失败:%s,操作数据:%+v", sysCheckModel_iedFuncDesc, err.Error(), c.Model)
 		dblog.Fail2()
+		return 0, 0, err
 	} else {
 		//保存功能-端子定义
 		fcdaMgr := new(SysCheckModelIedFuncFcdaMgr)
 		fcdaMgr.Model = T_data_model_func_fcda{ModelId: c.Model.ModelId}
-		fcdaMgr.Model.Id = c.Model.FuncFcdaId
+		if c.Model.FuncFcdaId > 0 {
+			fcdaMgr.Model.Id = c.Model.FuncFcdaId
+		}
 		fcdaMgr.Model.FcdaMatchExp = c.Model.FcdaMatchExp
 		fcdaMgr.Model.FcdaName = c.Model.FcdaName
-		fcdaMgr.Model.FuncId = c.Model.Id
+		fcdaMgr.Model.FuncId = int(funcid2)
 		fcdaMgr.Model.Svorgoose = c.Model.Svorgoose
 		fcdaMgr.Model.Inorout = c.Model.Inorout
-		err = fcdaMgr.Save()
+		fcdaMgr.Model.ReceiveIedType = c.Model.ReceiveIedType
+		fcdaid, err = fcdaMgr.Save()
 		if err != nil {
 			db.Rollback()
 			logger.Logger.Error(err)
 			dblog.Description = fmt.Sprintf("保存%s信息失败:%s,操作数据:%+v", sysCheckModel_iedFuncDesc, err.Error(), c.Model)
 			dblog.Fail2()
-			return
+			return 0, 0, err
 		}
 		db.Commit()
+		fcdaMgr.Model.Id = fcdaid
 		dblog.Description = fmt.Sprintf("保存%s信息成功,操作数据:%+v", sysCheckModel_iedFuncDesc, c.Model)
 		dblog.Success2()
+		return int(funcid2), fcdaMgr.Model.Id, nil
 	}
-	return err
+
 }
 
 func (c *SysCheckModelIedFuncMgr) Exist() (int, error) {
@@ -264,8 +270,9 @@ func (c *SysCheckModelIedFuncMgr) Imp(param map[string]interface{}) (bool, error
 	bgm := new(SysCheckModelIedtypeGroupMgr)
 	bgm.Model = T_data_model_iedtype_group{ModelId: modelId}
 	groupList := bgm.List()
+	autoRows := []T_data_model_func_def{}
 	for _, row := range datalist {
-		ied_type := strings.ToUpper(tools.IsEmpty(row[2]))
+		ied_type := strings.ToUpper(row[2])
 		if ied_type == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:装置类型编码不能为空", i))
 		}
@@ -277,26 +284,27 @@ func (c *SysCheckModelIedFuncMgr) Imp(param map[string]interface{}) (bool, error
 			//模型中未发现该装置类型
 			continue
 		}
-		func_name := tools.IsEmpty(row[3])
+		func_name := row[3]
 		if func_name == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:功能名称不能为空", i))
 		}
-		fcda_name := strings.ReplaceAll(strings.ReplaceAll(tools.IsEmpty(row[4]), "(", "("), ")", ")")
+		fcda_name := strings.ReplaceAll(strings.ReplaceAll(row[4], "(", "("), ")", ")")
 		if fcda_name == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:端子设计名称不能为空", i))
 		}
-		fcda_match_exp := strings.ReplaceAll(strings.ReplaceAll(tools.IsEmpty(row[5]), "(", "("), ")", ")")
+		fcda_match_exp := strings.ReplaceAll(strings.ReplaceAll(row[5], "(", "("), ")", ")")
 		if fcda_match_exp == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:端子关键词不能为空", i))
 		}
-		svorgoose := tools.IsEmpty(row[6])
+		svorgoose := row[6]
 		if svorgoose == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:信号类型不能为空", i))
 		}
-		inorout := tools.IsEmpty(row[7])
+		inorout := strings.ReplaceAll(row[7], ",", ",")
 		if inorout == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:信号方向不能为空", i))
 		}
+		receive_ied_type := strings.ReplaceAll(row[8], ",", ",") //对侧接收装置类型
 		funckey := fmt.Sprintf("%d%s%s", modelId, ied_type, func_name)
 		func_id = funcMap[funckey]
 		if func_id == 0 {
@@ -315,7 +323,9 @@ func (c *SysCheckModelIedFuncMgr) Imp(param map[string]interface{}) (bool, error
 			}
 		}
 		mod := T_data_model_func_def{}
-		mod.Id = func_id
+		if func_id > 0 {
+			mod.Id = func_id
+		}
 		mod.ModelId = modelId
 		mod.IedType = ied_type
 		mod.FuncFcdaId = fcda_id
@@ -324,12 +334,18 @@ func (c *SysCheckModelIedFuncMgr) Imp(param map[string]interface{}) (bool, error
 		mod.FcdaMatchExp = fcda_match_exp
 		mod.Svorgoose = svorgoose
 		mod.Inorout = inorout
+		mod.ReceiveIedType = receive_ied_type
 		c.Model = mod
-		err := c.Save()
+		funcid, fcdaid, err := c.Save()
 		if err != nil {
 			return false, errors.New(fmt.Sprintf("第%d行:%s", i, err.Error()))
 		}
+		mod.Id = funcid
+		mod.FuncFcdaId = fcdaid
+		autoRows = append(autoRows, mod)
 		i = i + 1
 	}
+	//根据接收装置编码定义,自动建立端子关系
+	fcdaMgr.AutoRelation(modelId, autoRows)
 	return true, nil
 }

+ 121 - 24
service/models/bo/check_sysmodel_ied_func_fcda.go

@@ -14,17 +14,18 @@ import (
 
 //系统内置模型-装置功能点端子管理
 type T_data_model_func_fcda struct {
-	Id           int    `orm:"pk"`
-	ModelId      int    // '模型ID' ,
-	FuncId       int    // '功能ID',
-	FcdaName     string // 端子设计名称
-	FcdaMatchExp string // 端子匹配表达式
-	Svorgoose    string
-	Inorout      string
-	Cr           int    // '创建人' ,
-	Ct           string `orm:"-"` // '创建时间' ,
-	Ur           int    // '更新人' ,
-	Ut           string `orm:"-"` // '更新时间'
+	Id             int    `orm:"pk"`
+	ModelId        int    // '模型ID' ,
+	FuncId         int    // '功能ID',
+	FcdaName       string // 端子设计名称
+	FcdaMatchExp   string // 端子匹配表达式
+	Svorgoose      string
+	Inorout        string
+	ReceiveIedType string
+	Cr             int    // '创建人' ,
+	Ct             string `orm:"-"` // '创建时间' ,
+	Ur             int    // '更新人' ,
+	Ut             string `orm:"-"` // '更新时间'
 }
 
 //内置检测模型-装置功能点端子管理
@@ -40,7 +41,7 @@ func init() {
 }
 
 //保存检测模型装置功能信息
-func (c *SysCheckModelIedFuncFcdaMgr) Save() (err error) {
+func (c *SysCheckModelIedFuncFcdaMgr) Save() (id int, err error) {
 	dblog := new(SystemLog)
 	dblog.SetUserInfo(c.GetUserInfo())
 	dblog.Audittype = enum.AuditType_check_model
@@ -50,27 +51,30 @@ func (c *SysCheckModelIedFuncFcdaMgr) Save() (err error) {
 	db := orm.NewOrm()
 	hasName, _, err := c.Exist()
 	if err != nil {
-		return err
+		return 0, err
 	}
 	if hasName {
-		return errors.New("端子名称[" + c.Model.FcdaName + "]已存在")
+		return 0, errors.New("端子名称[" + c.Model.FcdaName + "]已存在")
 	}
+	newid := int64(0)
 	if c.Model.Id > 0 {
 		//编辑
 		_, err = db.Update(&c.Model)
 	} else {
 		//新增
-		_, err = db.Insert(&c.Model)
+		newid, err = db.Insert(&c.Model)
+		c.Model.Id = int(newid)
 	}
 	if err != nil {
 		logger.Logger.Error(err)
 		dblog.Description = fmt.Sprintf("保存%s信息失败:%s,操作数据:%+v", sysCheckModel_iedFuncFcdaDesc, err.Error(), c.Model)
 		dblog.Fail2()
+		return 0, err
 	} else {
 		dblog.Description = fmt.Sprintf("保存%s信息成功,操作数据:%+v", sysCheckModel_iedFuncFcdaDesc, c.Model)
 		dblog.Success2()
 	}
-	return err
+	return c.Model.Id, nil
 }
 
 func (c *SysCheckModelIedFuncFcdaMgr) Exist() (bool, int, error) {
@@ -118,6 +122,99 @@ func (c *SysCheckModelIedFuncFcdaMgr) Copy(oldFuncId, newModelId, newFuncId int)
 	return nil
 }
 
+//自动建立端子关系
+func (c *SysCheckModelIedFuncFcdaMgr) AutoRelation(modelid int, relationrow []T_data_model_func_def) {
+	if len(relationrow) == 0 {
+		return
+	}
+	fcdaMap := map[string]T_data_model_func_def{}
+	for _, row := range relationrow {
+		key := fmt.Sprintf("%s%s", row.IedType, row.FcdaName)
+		if row.FuncName == "额定延时" {
+			if strings.Index(row.FcdaName, "额定") > -1 || strings.Index(row.FcdaName, "延迟") > -1 || strings.Index(row.FcdaName, "延时") > -1 {
+				key = fmt.Sprintf("%s%s", row.IedType, "额定延时")
+			}
+		}
+		fcdaMap[key] = row
+	}
+	//获取装置分组信息
+	bgm := new(SysCheckModelIedtypeGroupMgr)
+	bgm.Model = T_data_model_iedtype_group{ModelId: modelid}
+	groupList := bgm.List()
+	var getRealIedCode = func(ied_type string, groupList map[string]string) string {
+		if groupList != nil && groupList[ied_type] != "" {
+			ied_type = groupList[ied_type]
+		}
+		return ied_type
+	}
+	fr := new(SysCheckModelFcdaRalationMgr)
+	fr.Model = T_data_model_fcda_ref{ModelId: modelid}
+	noMatchList := map[string][]interface{}{} //未完全匹配的列表
+	for i, row := range relationrow {
+		if row.ReceiveIedType != "" {
+			tmplst := strings.Split(row.ReceiveIedType, ",")
+			for _, item := range tmplst {
+				key := fmt.Sprintf("%s%s", item, row.FcdaName)
+				if row.FuncName == "额定延时" {
+					if strings.Index(row.FcdaName, "额定") > -1 || strings.Index(row.FcdaName, "延迟") > -1 || strings.Index(row.FcdaName, "延时") > -1 {
+						key = fmt.Sprintf("%s%s", item, "额定延时")
+					}
+				}
+				if r, h := fcdaMap[key]; h {
+					fr.Model.FromFcdaId = row.FuncFcdaId
+					fr.Model.ToFcdaId = r.FuncFcdaId
+					fr.Model.FromFuncId = row.Id
+					fr.Model.ToFuncId = r.Id
+					fr.Model.FromIedCode = getRealIedCode(row.IedType, groupList)
+					fr.Model.ToIedCode = getRealIedCode(r.IedType, groupList)
+					fr.Model.Goosesv = row.Svorgoose
+					fr.Save()
+				} else {
+					//未完全匹配到端子时,查找其接收端的对侧装置为当前装置的端子
+					k := row.IedType + "," + item
+					if _, h := noMatchList[k]; !h {
+						tmp := map[string]interface{}{"no": i, "fromrow": row}
+						noMatchList[k] = []interface{}{tmp}
+					} else {
+						noMatchList[k] = append(noMatchList[k], map[string]interface{}{"no": i, "fromrow": row})
+					}
+				}
+			}
+		}
+	}
+	//未完全匹配到端子时,查找其接收端的对侧装置为当前装置的端子
+	for iedtype, obj := range noMatchList {
+		ks := strings.Split(iedtype, ",")
+		subNo := 0 //相差的行数
+		fromrow := T_data_model_func_def{}
+		for i, row := range relationrow {
+			if row.IedType == ks[1] && strings.Index(row.ReceiveIedType, ks[0]) > -1 {
+				tmp := obj[0].(map[string]interface{})
+				no, _ := tmp["no"].(int)
+				subNo = no - i //相差的行数
+				break
+			}
+		}
+		for _, item := range obj {
+			item2 := item.(map[string]interface{})
+			rowno := item2["no"].(int) - subNo
+			if rowno < 0 || rowno > len(relationrow) {
+				return
+			}
+			fromrow = item2["fromrow"].(T_data_model_func_def)
+			r := relationrow[rowno]
+			fr.Model.FromFcdaId = fromrow.FuncFcdaId
+			fr.Model.ToFcdaId = r.FuncFcdaId
+			fr.Model.FromFuncId = fromrow.Id
+			fr.Model.ToFuncId = r.Id
+			fr.Model.FromIedCode = getRealIedCode(fromrow.IedType, groupList)
+			fr.Model.ToIedCode = getRealIedCode(r.IedType, groupList)
+			fr.Model.Goosesv = fromrow.Svorgoose
+			fr.Save()
+		}
+	}
+}
+
 //根据model中指定的id删除
 func (c *SysCheckModelIedFuncFcdaMgr) Delete() (err error) {
 	dblog := new(SystemLog)
@@ -156,7 +253,7 @@ func (c *SysCheckModelIedFuncFcdaMgr) Delete() (err error) {
 			if one.FuncId > 0 {
 				c.Model.ModelId = one.ModelId
 				c.Model.FuncId = one.FuncId
-				r, _ := c.GetList()
+				r, _ := c.GetList("")
 				if len(r) == 0 {
 					//删除功能定义数据
 					funcMgr := new(SysCheckModelIedFuncMgr)
@@ -186,19 +283,19 @@ func (c *SysCheckModelIedFuncFcdaMgr) One(id int) (T_data_model_func_fcda, error
 
 //获取指定模型及装置功能下的端子信息列表
 //funcids:指定的功能编码列表。可不传
-func (c *SysCheckModelIedFuncFcdaMgr) GetList(funcids ...[]string) ([]orm.Params, error) {
+func (c *SysCheckModelIedFuncFcdaMgr) GetList(refIedtype string, funcids ...[]string) ([]orm.Params, error) {
 	o := orm.NewOrm()
 	sqlParamters := []interface{}{c.Model.ModelId}
 	outsql := ""
 	desc := ""
 	if c.Model.Inorout == "接收" {
-		outsql = ",(select from_fcda_id from t_data_model_fcda_ref where model_id=? and to_fcda_id=t.id and from_func_id=t1.id) from_fcda_id"
-		sqlParamters = append(sqlParamters, c.Model.ModelId)
+		outsql = ",(select from_fcda_id from t_data_model_fcda_ref where model_id=? and to_fcda_id=t.id and to_func_id=t1.id and from_ied_code=?) from_fcda_id"
+		sqlParamters = append(sqlParamters, refIedtype, c.Model.ModelId)
 		desc = " from_fcda_id," //已有关联关系的端子排在前面
 	}
 	if c.Model.Inorout == "输出" {
-		outsql = ",(select to_fcda_id from t_data_model_fcda_ref where model_id=? and from_fcda_id=t.id and to_func_id=t1.id) to_fcda_id"
-		sqlParamters = append(sqlParamters, c.Model.ModelId)
+		outsql = ",(select to_fcda_id from t_data_model_fcda_ref where model_id=? and from_fcda_id=t.id and from_func_id=t1.id and to_ied_code=?) to_fcda_id"
+		sqlParamters = append(sqlParamters, refIedtype, c.Model.ModelId)
 	}
 	sql := "select t.*,t1.func_name" + outsql + " from t_data_model_func_fcda t,t_data_model_func_def t1 where t1.id=t.func_id and t.model_id=? "
 	if c.Model.FuncId > 0 {
@@ -213,8 +310,8 @@ func (c *SysCheckModelIedFuncFcdaMgr) GetList(funcids ...[]string) ([]orm.Params
 		sqlParamters = append(sqlParamters, c.Model.Svorgoose)
 	}
 	if c.Model.Inorout != "" {
-		sql = sql + " and t.inorout=?"
-		sqlParamters = append(sqlParamters, c.Model.Inorout)
+		sql = sql + " and t.inorout like ?"
+		sqlParamters = append(sqlParamters, "%"+c.Model.Inorout+"%")
 	}
 	sql = sql + " order by " + desc + " t.id"
 	if c.Model.Inorout == "输出" {

+ 105 - 0
service/models/bo/check_sysmodel_iedtype_mapping.go

@@ -0,0 +1,105 @@
+package bo
+
+import (
+	"fmt"
+	"scd_check_tools/logger"
+	"scd_check_tools/tools"
+	"sync"
+
+	"github.com/astaxie/beego/orm"
+)
+
+var mapps = sync.Map{}
+
+type T_data_model_iedtype_maping struct {
+	Id             int `orm:"pk"`
+	ModelId        int // '模型ID' ,
+	IedType        string
+	MappingIedType string
+}
+
+//内置检测模型-装置分组管理
+type SysCheckModelIedtypeMappingMgr struct {
+	Model T_data_model_iedtype_maping
+	DeviceBaseModel
+}
+
+func init() {
+	orm.RegisterModel(new(T_data_model_iedtype_maping))
+}
+
+func (c *SysCheckModelIedtypeMappingMgr) Delete() {
+	db := orm.NewOrm()
+	if c.Model.Id > 0 {
+		db.Delete(&c.Model)
+		mapps.Delete(tools.IsEmpty(c.Model.ModelId))
+		mapps.Delete(fmt.Sprintf("%d%s", c.Model.ModelId, c.Model.IedType))
+		return
+	}
+	if c.Model.ModelId > 0 {
+		if c.Model.IedType != "" {
+			db.Raw("delete from t_data_model_iedtype_mapping where model_id=? and ied_type=?", c.Model.ModelId, c.Model.IedType).Exec()
+			mapps.Delete(tools.IsEmpty(c.Model.ModelId))
+			mapps.Delete(fmt.Sprintf("%d%s", c.Model.ModelId, c.Model.IedType))
+			return
+		}
+		db.Raw("delete from t_data_model_iedtype_mapping where model_id=?", c.Model.ModelId).Exec()
+		all, h := mapps.Load(tools.IsEmpty(c.Model.ModelId))
+		if h {
+			mapps.Delete(tools.IsEmpty(c.Model.ModelId))
+			allitem := all.(map[string]string)
+			for k, _ := range allitem {
+				mapps.Delete(fmt.Sprintf("%d%s", c.Model.ModelId, k))
+			}
+		}
+	}
+}
+
+func (c *SysCheckModelIedtypeMappingMgr) Copy(new_modelid int) {
+	db := orm.NewOrm()
+	db.Raw("insert into t_data_model_iedtype_mapping(model_id,ied_type,mapping_ied_type)select ?,ied_type,mapping_ied_type from t_data_model_iedtype_mapping where model_id=?", new_modelid, c.Model.Id).Exec()
+}
+
+func (c *SysCheckModelIedtypeMappingMgr) Save() error {
+	db := orm.NewOrm()
+	if c.Model.Id > 0 {
+		_, err := db.Update(&c.Model)
+		return err
+	}
+	if c.Model.MappingIedType == "" {
+		_, err := db.Raw("delete from t_data_model_iedtype_mapping where model_id=? and ied_type=?", c.Model.ModelId, c.Model.IedType).Exec()
+		return err
+	}
+	_, err := db.Insert(&c.Model)
+	return err
+}
+
+func (c *SysCheckModelIedtypeMappingMgr) List() map[string]string {
+	if c.Model.ModelId == 0 {
+		return nil
+	}
+	key := fmt.Sprintf("%d%s", c.Model.ModelId, c.Model.IedType)
+	if v, h := mapps.Load(key); h {
+		return v.(map[string]string)
+	}
+	result := map[string]string{}
+	db := orm.NewOrm()
+	rowset := []orm.Params{}
+	sql := "select * from t_data_model_iedtype_mapping where model_id=?"
+	sqlParams := []interface{}{c.Model.ModelId}
+	if c.Model.IedType != "" {
+		sql = sql + " and ied_type=?"
+		sqlParams = append(sqlParams, c.Model.IedType)
+	}
+	_, err := db.Raw(sql, sqlParams).Values(&rowset)
+	if err != nil {
+		logger.Logger.Error(err)
+		return nil
+	} else {
+		for _, row := range rowset {
+			result[tools.IsEmpty(row["ied_type"])] = tools.IsEmpty(row["mapping_type"])
+		}
+		mapps.Store(key, result)
+	}
+	return result
+}

+ 128 - 62
service/models/bo/checktools_area.go

@@ -414,10 +414,10 @@ func (c *CheckAreaMgr) CheckAreaIedRelation() error {
 		if areaCode == "J" {
 			HasAreaJ = true
 			modelid := tools.IsEmpty(row["model_id"])
-			c.cJ(scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], "PE", area_ruleid)
-			c.cJ(scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], "PJ", area_ruleid)
-			c.cJ(scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], "PK", area_ruleid)
-			c.cJ(scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], "PF", area_ruleid)
+			c.cJ(modelid, scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], "PE", area_ruleid)
+			c.cJ(modelid, scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], "PJ", area_ruleid)
+			c.cJ(modelid, scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], "PK", area_ruleid)
+			c.cJ(modelid, scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], "PF", area_ruleid)
 		}
 	}
 	for _, row := range arealist {
@@ -430,11 +430,11 @@ func (c *CheckAreaMgr) CheckAreaIedRelation() error {
 		}
 		if areaCode == "L" {
 			//线路间隔
-			c.cL(scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], area_ruleid)
+			c.cL(modelid, scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], area_ruleid)
 		}
 		if areaCode == "T" {
 			//变压器齐间隔
-			c.cT(scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], area_ruleid, HasAreaJ)
+			c.cT(modelid, scdXmlObj, scdNode, scdNodeRule, area_name, model_refs[modelid], area_ieds[area_id], area_ruleid, HasAreaJ)
 		}
 	}
 	scdNodeRule.CheckFinish()
@@ -612,11 +612,12 @@ 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)
 		//循环处理关联关系
-		for ied_type, fromrowlist := range funclist {
+		for ied_type2, fromrowlist := range funclist {
+			ied_type := c.getIedTypeCode(modelid, ied_type2)
 			//找出信号输出装置
 			outiedlist := map[string][]orm.Params{}
 			for _, r := range fromrowlist {
-				fromiedcode := tools.IsEmpty(r["from_ied_code"])
+				fromiedcode := c.getIedTypeCode(modelid, tools.IsEmpty(r["from_ied_code"]))
 				ied_type, vol := getIedTypeAndVolCode(fromiedcode)
 				outiedlist2 := filterAreaIeds(ied_type, vol, s1)
 				for _, iedrow := range outiedlist2 {
@@ -879,6 +880,20 @@ func (c *CheckAreaMgr) ParseModelArea() {
 			modelid, _ := strconv.Atoi(tools.IsEmpty(row["id"]))
 			//modelname := tools.IsEmpty(row["model_name"])
 			iedtypes := tools.IsEmpty(row["ied_types"])
+			mapptype := new(SysCheckModelIedtypeMappingMgr)
+			mapptype.Model = T_data_model_iedtype_maping{ModelId: modelid}
+			mappresult := mapptype.List()
+			if len(mappresult) > 0 {
+				tmp := []string{}
+				for _, r := range strings.Split(iedtypes, ",") {
+					if mappresult[r] != "" {
+						tmp = append(tmp, mappresult[r])
+					} else {
+						tmp = append(tmp, r)
+					}
+				}
+				iedtypes = strings.Join(tmp, ",")
+			}
 			volcode := strings.ReplaceAll(tools.IsEmpty(row["vol_code"]), "v_level_", "")
 			c.pJ(modelid, volcode, iedtypes, iedMap, "PE")
 			c.pJ(modelid, volcode, iedtypes, iedMap, "PJ")
@@ -914,6 +929,21 @@ func (c *CheckAreaMgr) ParseModelArea() {
 		if areaCode == "J" {
 			continue
 		}
+		//获取模型中的自定义装置类型编码
+		mapptype := new(SysCheckModelIedtypeMappingMgr)
+		mapptype.Model = T_data_model_iedtype_maping{ModelId: modelid}
+		mappresult := mapptype.List()
+		if len(mappresult) > 0 {
+			tmp := []string{}
+			for _, r := range strings.Split(iedtypes, ",") {
+				if mappresult[r] != "" {
+					tmp = append(tmp, mappresult[r])
+				} else {
+					tmp = append(tmp, r)
+				}
+			}
+			iedtypes = strings.Join(tmp, ",")
+		}
 		//获取模型内中装备关系定义
 		//主变间隔分析:需要查站内该电压等级下的高中低压侧装置或者高低压装置组成一个间隔,以主变保护装置(PT)为起始
 		if areaCode == "T" {
@@ -926,6 +956,19 @@ func (c *CheckAreaMgr) ParseModelArea() {
 	}
 }
 
+//根据默认装置类型获取其类型编码。如果没有自定义编码,则返回默认编码
+func (c *CheckAreaMgr) getIedTypeCode(modelid int, iedtype string) string {
+	mapptype := new(SysCheckModelIedtypeMappingMgr)
+	mapptype.Model = T_data_model_iedtype_maping{ModelId: modelid}
+	mapptype.Model.IedType = iedtype
+	mappresult := mapptype.List()
+	ptCode := iedtype
+	if len(mappresult) > 0 {
+		ptCode = mappresult[iedtype] //自定义主变保护编码
+	}
+	return ptCode
+}
+
 //变压器间隔分析
 func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Params, HasAreaJ bool) {
 	scdParseMgr := new(ScdParse)
@@ -981,9 +1024,9 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 	//判断是否将各电压等级的保护装置合并还是分开的间隔
 	//如果存在高中低压的保护装置,则说明是分开的主变间隔
 	//isMarge := true // 默认为合并的主变间隔
-
+	ptCode := c.getIedTypeCode(modelid, "PT")
 	for _, row := range ieds {
-		if tools.IsEmpty(row["ied_type"]) != "P" || tools.IsEmpty(row["p_type"]) != "T" {
+		if tools.IsEmpty(row["ied_type"]) != ptCode[0:1] || tools.IsEmpty(row["p_type"]) != ptCode[1:] {
 			continue
 		}
 		//判断主变保护是否是按电压等级分开配置的模型
@@ -1015,8 +1058,8 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 		inAreaIedName := pl_iedname
 		insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "P", "T"))
 		//判断间隔是否需要包含差动装置
-		if strings.Contains(iedtypes, "PT#C") {
-			_, iedname := getIedByDesc(ieds, "PT", "差动")
+		if strings.Contains(iedtypes, ptCode+"#C") {
+			_, iedname := getIedByDesc(ieds, ptCode, "差动")
 			if len(iedname) > 0 {
 				for _, in := range iedname {
 					tmpIednameParts := scdParseMgr.ParseIedName(in)
@@ -1028,8 +1071,8 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			}
 		}
 		//判断间隔是否需要包含本体保护装置
-		if strings.Contains(iedtypes, "PT#0") {
-			_, iedname := getIedByDesc(ieds, "PT", "本体")
+		if strings.Contains(iedtypes, ptCode+"#0") {
+			_, iedname := getIedByDesc(ieds, ptCode, "本体")
 			if len(iedname) > 0 {
 				for _, in := range iedname {
 					tmpIednameParts := scdParseMgr.ParseIedName(in)
@@ -1041,7 +1084,8 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			}
 		}
 		//合智一体IMT/MIT,分高中低压
-		h, m, l := c.getIedListByVol("IMT", ieds, volMap)
+		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 {
@@ -1051,7 +1095,8 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 				insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "IM", "T"))
 			}
 		}
-		h, m, l = c.getIedListByVol("MIT", ieds, volMap)
+		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 {
@@ -1063,7 +1108,8 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 		}
 		//母联智能终端IE需要分高中压,无低压侧
 		if HasAreaJ {
-			h, m, l = c.getIedListByVol("IE", ieds, volMap)
+			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"])
@@ -1083,7 +1129,8 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			}
 		}
 		//合并单元MT分高中低压侧;低压侧无关联母线合并单元MM
-		h, m, l = c.getIedListByVol("MT", ieds, volMap)
+		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 {
@@ -1094,8 +1141,8 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			}
 		}
 		//是否包含本体合并单元
-		if strings.Contains(iedtypes, "MT#0") {
-			_, iedname := getIedByDesc(ieds, "MT", "本体")
+		if strings.Contains(iedtypes, imtcode+"#0") {
+			_, iedname := getIedByDesc(ieds, imtcode, "本体")
 			if len(iedname) > 0 {
 				for _, in := range iedname {
 					tmpIednameParts := scdParseMgr.ParseIedName(in)
@@ -1107,7 +1154,8 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			}
 		}
 		//测控装置CT分高中低压侧,且可能是多套合并单元MT共用,既不分AB套
-		h, m, l = c.getIedListByVol("CT", ieds, volMap)
+		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 {
@@ -1121,8 +1169,8 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			}
 		}
 		//是否包含本体测控装置
-		if strings.Contains(iedtypes, "CT#0") {
-			_, iedname := getIedByDesc(ieds, "CT", "本体")
+		if strings.Contains(iedtypes, imtcode+"#0") {
+			_, iedname := getIedByDesc(ieds, imtcode, "本体")
 			if len(iedname) > 0 {
 				for _, in := range iedname {
 					tmpIednameParts := scdParseMgr.ParseIedName(in)
@@ -1134,7 +1182,10 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			}
 		}
 		//智能终端(IB:开关\IT:分支\IF:分段)分高中低压侧
-		h, m, l = c.getIedListByVol("IB", ieds, volMap)
+		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 {
@@ -1148,9 +1199,9 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			}
 		}
 		//是否包含本体测控装置
-		if strings.Contains(iedtypes, "IT#0") {
+		if strings.Contains(iedtypes, imtcodeT+"#0") {
 			for n, row := range ieds {
-				if strings.HasPrefix(n, "IT") || strings.HasPrefix(n, "IB") || strings.HasPrefix(n, "IF") {
+				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)
@@ -1162,7 +1213,7 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 				}
 			}
 		}
-		h, m, l = c.getIedListByVol("IT", ieds, volMap)
+		h, m, l = c.getIedListByVol(imtcodeT, ieds, volMap)
 		h = append(h, m...)
 		h = append(h, l...)
 		for _, r := range h {
@@ -1175,7 +1226,7 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 				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, m, l = c.getIedListByVol(imtcodeF, ieds, volMap)
 		h = append(h, m...)
 		h = append(h, l...)
 		for _, r := range h {
@@ -1189,7 +1240,8 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			}
 		}
 		//母线保护PM及母线合并单元MM,可能是多套合并单元MT共用,既不分AB套;低压侧智能终端无关联母线保护
-		h, m, l = c.getIedListByVol("PM", ieds, volMap)
+		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"])
@@ -1232,8 +1284,9 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
 	db := orm.NewOrm()
 
 	scdXmlObj, _ := scdParseMgr.GetScdXmlObjectBySCDID(tools.IsEmpty(c.ScdId))
+	iedCode := c.getIedTypeCode(modelid, "PL")
 	for _, row := range ieds {
-		if tools.IsEmpty(row["vol"]) != vol || tools.IsEmpty(row["ied_type"]) != "P" || tools.IsEmpty(row["p_type"]) != "L" {
+		if tools.IsEmpty(row["vol"]) != vol || tools.IsEmpty(row["ied_type"]) != iedCode[0:1] || tools.IsEmpty(row["p_type"]) != iedCode[1:] {
 			continue
 		}
 		pmIedName := ""
@@ -1255,9 +1308,13 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
 		}
 		ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values"
 		insvalues := []string{}
+		pmCode := c.getIedTypeCode(modelid, "PM")
+		mmCode := c.getIedTypeCode(modelid, "MM")
+		clCode := c.getIedTypeCode(modelid, "CL")
 		for _, ty := range strings.Split(iedtypes, ",") {
 			inAreaIedName := ""
-			if ty == "PM" {
+			tyCode := c.getIedTypeCode(modelid, ty)
+			if tyCode == pmCode {
 				//母线保护和母线合并单元装置编号跟随变压器
 				//查找变压器编号
 				//1号变压器->2号变压器->3号
@@ -1267,11 +1324,11 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
 					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"
+					tyCode = mmCode
 					inAreaIedName = c.getMMName(iednameParts, ieds, iednameParts[7])
 					mmIedName = inAreaIedName
 				}
-			} else if ty == "MM" {
+			} else if tyCode == mmCode {
 				if pmIedName != "" && mmIedName == "" {
 					//pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
 					//使用PM装置的名称去定义MM的名称
@@ -1280,7 +1337,7 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
 				} else {
 					continue
 				}
-			} else if ty == "PLC" || ty == "PCL" {
+			} else if tyCode == "PLC" || tyCode == "PCL" {
 				//判断是否是保测一体的
 				if strings.Contains(iedtypes, "PLC") || strings.Contains(iedtypes, "PCL") {
 					no := []string{"PLC", "PCL", "PL"}
@@ -1293,8 +1350,8 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
 					}
 				}
 			} else {
-				inAreaIedName = ty + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6] + iednameParts[7]
-				if ty == "IML" {
+				inAreaIedName = tyCode + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6] + iednameParts[7]
+				if tyCode == "IML" {
 					//查找IML装置是否存在,不存在就查找MIL开头装置做中合智一体装置
 					no := []string{"IML", "MIL"}
 					for _, n := range no {
@@ -1307,8 +1364,8 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
 			}
 			if strings.Index("ABCDE", iednameParts[7]) > -1 {
 				//最后一位是字母则说明是AB套
-				switch ty {
-				case "CL":
+				switch tyCode {
+				case clCode:
 					if strings.Contains(iedtypes, "PLC") || strings.Contains(iedtypes, "PCL") {
 						//不处理CL装置
 					} else {
@@ -1325,7 +1382,7 @@ func (c *CheckAreaMgr) pL(modelid int, vol, iedtypes string, ieds map[string]orm
 					break
 				}
 			}
-			insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, ty[0:1], ty[1:2]))
+			insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, tyCode[0:1], tyCode[1:]))
 		}
 		_, err = db.Raw(ins1 + strings.Join(insvalues, ",")).Exec()
 		if err != nil {
@@ -1350,9 +1407,10 @@ func (c *CheckAreaMgr) pJ(modelid int, vol, iedtypes string, ieds map[string]orm
 	scdParseMgr := new(ScdParse)
 	//scdNodeMgr := new(ScdNode)
 	db := orm.NewOrm()
+	pjIed = c.getIedTypeCode(modelid, pjIed)
 	//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] {
+		if tools.IsEmpty(row["vol"]) != vol || tools.IsEmpty(row["ied_type"]) != pjIed[0:1] || tools.IsEmpty(row["p_type"]) != pjIed[1:2] {
 			continue
 		}
 		pmIedName := ""
@@ -1373,23 +1431,26 @@ func (c *CheckAreaMgr) pJ(modelid int, vol, iedtypes string, ieds map[string]orm
 		}
 		ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values"
 		insvalues := []string{}
+		pmCode := c.getIedTypeCode(modelid, "PM")
+		mmCode := c.getIedTypeCode(modelid, "MM")
 		for _, ty := range strings.Split(iedtypes, ",") {
+			tyCode := c.getIedTypeCode(modelid, ty)
 			inAreaIedName := ""
-			if ty == "PM" {
+			if tyCode == pmCode {
 				//母线保护和母线合并单元装置编号跟随变压器
 				//查找变压器编号
 				//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]))
+					insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, tyCode[0:1], tyCode[1:2]))
 					pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
 					//使用PM装置的名称去定义MM的名称
-					ty = "MM"
+					tyCode = "MM"
 					inAreaIedName = c.getMMName(pmIedNameParts, ieds, iednameParts[7])
 					mmIedName = inAreaIedName
 				}
-			} else if ty == "MM" {
+			} else if tyCode == mmCode {
 				if pmIedName != "" && mmIedName == "" {
 					pmIedNameParts := scdParseMgr.ParseIedName(pmIedName)
 					//使用PM装置的名称去定义MM的名称
@@ -1399,15 +1460,15 @@ func (c *CheckAreaMgr) pJ(modelid int, vol, iedtypes string, ieds map[string]orm
 					continue
 				}
 			} else {
-				ty = ty[0:1] + pjIed[1:2]
-				inAreaIedName = ty + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6] + iednameParts[7]
+				tyCode = tyCode[0:1] + pjIed[1:2]
+				inAreaIedName = tyCode + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6] + iednameParts[7]
 				//判断与基准保护装置相同套号的装置是否存在
 				if ieds[inAreaIedName] == nil {
 					//尝试去除套号
-					inAreaIedName = ty + iednameParts[3] + iednameParts[4] + iednameParts[5] + iednameParts[6]
+					inAreaIedName = tyCode + 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]))
+			insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, tyCode[0:1], tyCode[1:2]))
 		}
 		_, err = db.Raw(ins1 + strings.Join(insvalues, ",")).Exec()
 		if err != nil {
@@ -1420,8 +1481,9 @@ func (c *CheckAreaMgr) pJ(modelid int, vol, iedtypes string, ieds map[string]orm
 }
 
 //母联间隔装置关系检查
-func (c *CheckAreaMgr) cJ(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)
+	pjIed = c.getIedTypeCode(modelidInt, pjIed)
 	masterIed := new(node_attr.NIED)
 	findIedName := ""
 	for _, row2 := range area_ieds {
@@ -1436,8 +1498,8 @@ func (c *CheckAreaMgr) cJ(scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNode
 	}
 	dealFromIed := map[string]int{}
 	for _, row := range ied_refs {
-		fromiedtype := tools.IsEmpty(row["from_ied_code"])
-		toiedtype := tools.IsEmpty(row["to_ied_code"])
+		fromiedtype := c.getIedTypeCode(modelidInt, tools.IsEmpty(row["from_ied_code"]))
+		toiedtype := c.getIedTypeCode(modelidInt, tools.IsEmpty(row["to_ied_code"]))
 		reftype := tools.IsEmpty(row["in_type"])
 		tmpFromAreaIeds := []orm.Params{}
 		tmpToAreaIeds := []orm.Params{}
@@ -1514,12 +1576,14 @@ func (c *CheckAreaMgr) cJ(scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNode
 }
 
 //线路间隔装置关系检查
-func (c *CheckAreaMgr) cL(scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNodeRule *ScdNodeRule, area_name string, ied_refs []orm.Params, area_ieds []orm.Params, area_ruleid string) {
+func (c *CheckAreaMgr) cL(modelid string, scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNodeRule *ScdNodeRule, area_name string, ied_refs []orm.Params, area_ieds []orm.Params, area_ruleid string) {
+	modelidInt, _ := strconv.Atoi(modelid)
+	plIed := c.getIedTypeCode(modelidInt, "PL")
 	masterIed := new(node_attr.NIED)
 	findIedName := ""
 	for _, row2 := range area_ieds {
 		findIedName = tools.IsEmpty(row2["ied_name"])
-		if strings.HasPrefix(findIedName, "PL") {
+		if strings.HasPrefix(findIedName, plIed) {
 			masterIed = scdNodeMgr.GetIed(scdXmlObj, "", findIedName)
 			break
 		}
@@ -1529,8 +1593,8 @@ func (c *CheckAreaMgr) cL(scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNode
 	}
 	dealFromIed := map[string]int{}
 	for _, row := range ied_refs {
-		fromiedtype := tools.IsEmpty(row["from_ied_code"])
-		toiedtype := tools.IsEmpty(row["to_ied_code"])
+		fromiedtype := c.getIedTypeCode(modelidInt, tools.IsEmpty(row["from_ied_code"]))
+		toiedtype := c.getIedTypeCode(modelidInt, tools.IsEmpty(row["to_ied_code"]))
 		reftype := tools.IsEmpty(row["in_type"])
 		tmpFromAreaIeds := []orm.Params{}
 		tmpToAreaIeds := []orm.Params{}
@@ -1607,12 +1671,14 @@ func (c *CheckAreaMgr) cL(scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNode
 }
 
 //变压器间隔装置关系检查
-func (c *CheckAreaMgr) cT(scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNodeRule *ScdNodeRule, area_name string, ied_refs []orm.Params, area_ieds []orm.Params, area_ruleid string, HasAreaJ bool) {
+func (c *CheckAreaMgr) cT(modelid string, scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNodeRule *ScdNodeRule, area_name string, ied_refs []orm.Params, area_ieds []orm.Params, area_ruleid string, HasAreaJ bool) {
 	masterIed := new(node_attr.NIED)
 	findIedName := ""
+	modelidInt, _ := strconv.Atoi(modelid)
+	ptIed := c.getIedTypeCode(modelidInt, "PT")
 	for _, row2 := range area_ieds {
 		findIedName = tools.IsEmpty(row2["ied_name"])
-		if strings.HasPrefix(findIedName, "PT") {
+		if strings.HasPrefix(findIedName, ptIed) {
 			masterIed = scdNodeMgr.GetIed(scdXmlObj, "", findIedName)
 			break
 		}
@@ -1623,9 +1689,9 @@ func (c *CheckAreaMgr) cT(scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNode
 	scdParseMgr := new(ScdParse)
 	dealFromIed := map[string]int{}
 	for _, row := range ied_refs {
-		fromiedtype := tools.IsEmpty(row["from_ied_code"])
-		fromiedtype = strings.Split(fromiedtype, "#")[0]                      //去除后面的电压级别标识
-		toiedtype := strings.Split(tools.IsEmpty(row["to_ied_code"]), "#")[0] //去除后面的电压级别标识
+		fromiedtype := c.getIedTypeCode(modelidInt, tools.IsEmpty(row["from_ied_code"]))
+		fromiedtype = strings.Split(fromiedtype, "#")[0]                                                    //去除后面的电压级别标识
+		toiedtype := strings.Split(c.getIedTypeCode(modelidInt, tools.IsEmpty(row["to_ied_code"])), "#")[0] //去除后面的电压级别标识
 		reftype := tools.IsEmpty(row["in_type"])
 		tmpFromAreaIeds := []orm.Params{}
 		tmpToAreaIeds := []orm.Params{}
@@ -1708,7 +1774,7 @@ func (c *CheckAreaMgr) cT(scdXmlObj *node_attr.SCL, scdNodeMgr *ScdNode, scdNode
 					break
 				}
 			}
-			if toiedtype != "PT" {
+			if toiedtype != ptIed {
 				if volLevel != "" && !hasSameVolIed {
 					parse_result := fmt.Sprintf("间隔%s的装置%s缺失同电压等级的关联类型%s装置", area_name, findIedName, toiedtype)
 					r := map[string]interface{}{"scdid": c.ScdId, "lineno": 0, "ruleid": area_ruleid, "nodeid": 0, "parse_result": parse_result}

+ 18 - 0
service/routers/commentsRouter_controllers.go

@@ -702,6 +702,15 @@ func init() {
 
     beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"] = append(beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"],
         beego.ControllerComments{
+            Method: "GetSysModelIedTypeMapping",
+            Router: "/admin/sysmodel/get/iedtype",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"] = append(beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"],
+        beego.ControllerComments{
             Method: "GetSysModelList",
             Router: "/admin/sysmodel/list",
             AllowHTTPMethods: []string{"get"},
@@ -729,6 +738,15 @@ func init() {
 
     beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"] = append(beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"],
         beego.ControllerComments{
+            Method: "UPdateSysModelIedType",
+            Router: "/admin/sysmodel/update/iedtype",
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"] = append(beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"],
+        beego.ControllerComments{
             Method: "SaveCheckAreaIedByAreaID",
             Router: "/admin/update/check_area/ied",
             AllowHTTPMethods: []string{"post"},

+ 89 - 1
service/static/swagger/swagger.json

@@ -621,7 +621,14 @@
                     {
                         "in": "formData",
                         "name": "ied_type",
-                        "description": "装置类型",
+                        "description": "查询的装置类型",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "ref_ied_type",
+                        "description": "对侧关联装置类型",
                         "required": true,
                         "type": "string"
                     },
@@ -836,6 +843,43 @@
                 }
             }
         },
+        "/admin/sysmodel/get/iedtype": {
+            "get": {
+                "tags": [
+                    "scd_check_tools/controllersBusAdminController"
+                ],
+                "summary": "获取检测模型指定装置的自定义类型编码",
+                "description": "获取检测模型指定装置的自定义类型编码",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "id",
+                        "description": "模型ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "ied_type",
+                        "description": "装置原编码",
+                        "required": true,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/admin/sysmodel/list": {
             "get": {
                 "tags": [
@@ -1022,6 +1066,50 @@
                 }
             }
         },
+        "/admin/sysmodel/update/iedtype": {
+            "post": {
+                "tags": [
+                    "scd_check_tools/controllersBusAdminController"
+                ],
+                "summary": "更新检测模型指定装置的类型编码",
+                "description": "更新检测模型指定装置的类型编码",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "id",
+                        "description": "模型ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "old_iedtype",
+                        "description": "装置原编码",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "new_iedtype",
+                        "description": "装置新编码",
+                        "required": true,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/admin/update/check_area/ied": {
             "post": {
                 "tags": [

+ 61 - 1
service/static/swagger/swagger.yml

@@ -428,7 +428,12 @@ paths:
         format: int64
       - in: formData
         name: ied_type
-        description: 装置类型
+        description: 查询的装置类型
+        required: true
+        type: string
+      - in: formData
+        name: ref_ied_type
+        description: 对侧关联装置类型
         required: true
         type: string
       - in: formData
@@ -573,6 +578,31 @@ paths:
             $ref: '#/definitions/ResultOK'
         "500":
           description: '{object} ResultError  失败'
+  /admin/sysmodel/get/iedtype:
+    get:
+      tags:
+      - scd_check_tools/controllersBusAdminController
+      summary: 获取检测模型指定装置的自定义类型编码
+      description: 获取检测模型指定装置的自定义类型编码
+      parameters:
+      - in: formData
+        name: id
+        description: 模型ID
+        required: true
+        type: integer
+        format: int64
+      - in: formData
+        name: ied_type
+        description: 装置原编码
+        required: true
+        type: string
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /admin/sysmodel/list:
     get:
       tags:
@@ -701,6 +731,36 @@ paths:
             $ref: '#/definitions/ResultOK'
         "500":
           description: '{object} ResultError  失败'
+  /admin/sysmodel/update/iedtype:
+    post:
+      tags:
+      - scd_check_tools/controllersBusAdminController
+      summary: 更新检测模型指定装置的类型编码
+      description: 更新检测模型指定装置的类型编码
+      parameters:
+      - in: formData
+        name: id
+        description: 模型ID
+        required: true
+        type: integer
+        format: int64
+      - in: formData
+        name: old_iedtype
+        description: 装置原编码
+        required: true
+        type: string
+      - in: formData
+        name: new_iedtype
+        description: 装置新编码
+        required: true
+        type: string
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /admin/update/check_area/ied:
     post:
       tags:

+ 89 - 1
service/swagger/swagger.json

@@ -621,7 +621,14 @@
                     {
                         "in": "formData",
                         "name": "ied_type",
-                        "description": "装置类型",
+                        "description": "查询的装置类型",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "ref_ied_type",
+                        "description": "对侧关联装置类型",
                         "required": true,
                         "type": "string"
                     },
@@ -836,6 +843,43 @@
                 }
             }
         },
+        "/admin/sysmodel/get/iedtype": {
+            "get": {
+                "tags": [
+                    "scd_check_tools/controllersBusAdminController"
+                ],
+                "summary": "获取检测模型指定装置的自定义类型编码",
+                "description": "获取检测模型指定装置的自定义类型编码",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "id",
+                        "description": "模型ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "ied_type",
+                        "description": "装置原编码",
+                        "required": true,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/admin/sysmodel/list": {
             "get": {
                 "tags": [
@@ -1022,6 +1066,50 @@
                 }
             }
         },
+        "/admin/sysmodel/update/iedtype": {
+            "post": {
+                "tags": [
+                    "scd_check_tools/controllersBusAdminController"
+                ],
+                "summary": "更新检测模型指定装置的类型编码",
+                "description": "更新检测模型指定装置的类型编码",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "id",
+                        "description": "模型ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "old_iedtype",
+                        "description": "装置原编码",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "new_iedtype",
+                        "description": "装置新编码",
+                        "required": true,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/admin/update/check_area/ied": {
             "post": {
                 "tags": [

+ 61 - 1
service/swagger/swagger.yml

@@ -428,7 +428,12 @@ paths:
         format: int64
       - in: formData
         name: ied_type
-        description: 装置类型
+        description: 查询的装置类型
+        required: true
+        type: string
+      - in: formData
+        name: ref_ied_type
+        description: 对侧关联装置类型
         required: true
         type: string
       - in: formData
@@ -573,6 +578,31 @@ paths:
             $ref: '#/definitions/ResultOK'
         "500":
           description: '{object} ResultError  失败'
+  /admin/sysmodel/get/iedtype:
+    get:
+      tags:
+      - scd_check_tools/controllersBusAdminController
+      summary: 获取检测模型指定装置的自定义类型编码
+      description: 获取检测模型指定装置的自定义类型编码
+      parameters:
+      - in: formData
+        name: id
+        description: 模型ID
+        required: true
+        type: integer
+        format: int64
+      - in: formData
+        name: ied_type
+        description: 装置原编码
+        required: true
+        type: string
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /admin/sysmodel/list:
     get:
       tags:
@@ -701,6 +731,36 @@ paths:
             $ref: '#/definitions/ResultOK'
         "500":
           description: '{object} ResultError  失败'
+  /admin/sysmodel/update/iedtype:
+    post:
+      tags:
+      - scd_check_tools/controllersBusAdminController
+      summary: 更新检测模型指定装置的类型编码
+      description: 更新检测模型指定装置的类型编码
+      parameters:
+      - in: formData
+        name: id
+        description: 模型ID
+        required: true
+        type: integer
+        format: int64
+      - in: formData
+        name: old_iedtype
+        description: 装置原编码
+        required: true
+        type: string
+      - in: formData
+        name: new_iedtype
+        description: 装置新编码
+        required: true
+        type: string
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /admin/update/check_area/ied:
     post:
       tags: