liling před 1 rokem
rodič
revize
b7cc479f45

+ 27 - 9
service/controllers/busAdminController.go

@@ -754,6 +754,8 @@ func (c *BusAdminController) DelFuncFcda() {
 // 	@Produce      json
 //	@Param 	model_id 	formData   int  	true 	"模型ID"
 //	@Param 	from_fcda_id 	formData   int  	true 	"输出装置端子ID"
+//	@Param 	to_ied_type 	formData   string  	false 	"输入装置类型"
+//	@Param 	goosesv 		formData   string  	false 	"信号类型。GOOSE|SV"
 // 	@Success     200    {object} ResultOK 成功
 // 	@Failure 	 500 	{object} ResultError  失败
 // @router /admin/model/function/fcda-ref/list [get]
@@ -775,6 +777,8 @@ func (c *BusAdminController) GetFuncFcdaRef() {
 	fcdaMgr.Model = bo.T_data_model_fcda_ref{}
 	fcdaMgr.Model.ModelId = modelid
 	fcdaMgr.Model.FromFcdaId = fcda_id
+	fcdaMgr.Model.ToIedCode = c.GetString("to_ied_type")
+	fcdaMgr.Model.Goosesv = c.GetString("goosesv")
 	lst, err := fcdaMgr.GetList()
 	if err != nil {
 		c.Data["json"] = c.ResultError(err.Error())
@@ -812,6 +816,7 @@ func (c *BusAdminController) SaveFuncFcdaRef() {
 		c.ServeJSON()
 		return
 	}
+	fcda_in_ids := c.GetString("to_fcda_ids")
 	fcdaMgr := new(bo.SysCheckModelFcdaRalationMgr)
 	fcdaMgr.SetUserInfo(c.GetCurrentUserInfo())
 	fcdaMgr.Model = bo.T_data_model_fcda_ref{}
@@ -838,24 +843,37 @@ func (c *BusAdminController) SaveFuncFcdaRef() {
 	obj := new(bo.SysCheckModelIedFuncFcdaMgr)
 	fcdainf, er := obj.One(fcdaMgr.Model.FromFcdaId)
 	if er != nil {
-		c.Data["json"] = c.ResultError(er.Error())
+		c.Data["json"] = c.ResultError("无效的输出端子ID")
 		c.ServeJSON()
 		return
 	}
 	fcdaMgr.Model.FromFuncId = fcdainf.FuncId
-	fcdainf, er = obj.One(fcdaMgr.Model.ToFcdaId)
-	if er != nil {
-		c.Data["json"] = c.ResultError(er.Error())
-		c.ServeJSON()
-		return
-	}
-	fcdaMgr.Model.ToFuncId = fcdainf.FuncId
-	err := fcdaMgr.Save()
+	//清除原关系
+	err := fcdaMgr.Delete()
 	if err != nil {
 		c.Data["json"] = c.ResultError(err.Error())
 		c.ServeJSON()
 		return
 	}
+	if fcda_in_ids != "" {
+		fcda_in_ids_1 := strings.Split(fcda_in_ids, ",")
+		for _, k := range fcda_in_ids_1 {
+			fcdaMgr.Model.ToFcdaId, _ = strconv.Atoi(k)
+			fcdainf, er = obj.One(fcdaMgr.Model.ToFcdaId)
+			if er != nil {
+				c.Data["json"] = c.ResultError("无效的输入端子ID")
+				c.ServeJSON()
+				return
+			}
+			fcdaMgr.Model.ToFuncId = fcdainf.FuncId
+			err := fcdaMgr.Save()
+			if err != nil {
+				c.Data["json"] = c.ResultError(err.Error())
+				c.ServeJSON()
+				return
+			}
+		}
+	}
 	c.Data["json"] = c.ResultOK("", 0)
 	c.ServeJSON()
 }

+ 13 - 5
service/models/bo/check_sysmodel_ied_fcda_relation.go

@@ -74,7 +74,11 @@ func (c *SysCheckModelFcdaRalationMgr) Delete() (err error) {
 	dblog.Eventtype = enum.OptEventType_Bus
 	dblog.Eventlevel = enum.OptEventLevel_Hight
 	db := orm.NewOrm()
-	if c.Model.FromFuncId > 0 {
+	if c.Model.FromFcdaId > 0 {
+		_, err = db.Raw("delete from t_data_model_fcda_ref where model_id=? and (from_fcda_id=? or to_fcda_id=?) and to_ied_code=? and goosesv=?", c.Model.ModelId, c.Model.FromFcdaId, c.Model.FromFcdaId, c.Model.ToIedCode, c.Model.Goosesv).Exec()
+	} else if c.Model.ToFcdaId > 0 {
+		_, err = db.Raw("delete from t_data_model_fcda_ref where model_id=? and (from_fcda_id=? or to_fcda_id=?)", c.Model.ModelId, c.Model.ToFcdaId, c.Model.ToFcdaId).Exec()
+	} else if c.Model.FromFuncId > 0 {
 		_, err = db.Raw("delete from t_data_model_fcda_ref where model_id=? and from_func_id=?", c.Model.ModelId, c.Model.FromFuncId).Exec()
 	} else if c.Model.FromIedCode != "" {
 		_, err = db.Raw("delete from t_data_model_fcda_ref where model_id=? and (from_ied_code=? or to_ied_code=?)", c.Model.ModelId, c.Model.FromIedCode, c.Model.FromIedCode).Exec()
@@ -84,10 +88,6 @@ func (c *SysCheckModelFcdaRalationMgr) Delete() (err error) {
 		_, err = db.Raw("delete from t_data_model_fcda_ref where model_id=? and (from_func_id=? or to_func_id=?)", c.Model.ModelId, c.Model.FromFuncId, c.Model.FromFuncId).Exec()
 	} else if c.Model.ToFuncId > 0 {
 		_, err = db.Raw("delete from t_data_model_fcda_ref where model_id=? and (from_func_id=? or to_func_id=?)", c.Model.ModelId, c.Model.ToFuncId, c.Model.ToFuncId).Exec()
-	} else if c.Model.FromFcdaId > 0 {
-		_, err = db.Raw("delete from t_data_model_fcda_ref where model_id=? and (from_fcda_id=? or to_fcda_id=?)", c.Model.ModelId, c.Model.FromFcdaId, c.Model.FromFcdaId).Exec()
-	} else if c.Model.ToFcdaId > 0 {
-		_, err = db.Raw("delete from t_data_model_fcda_ref where model_id=? and (from_fcda_id=? or to_fcda_id=?)", c.Model.ModelId, c.Model.ToFcdaId, c.Model.ToFcdaId).Exec()
 	} else {
 		_, err = db.Raw("delete from t_data_model_fcda_ref where model_id=? ", c.Model.ModelId).Exec()
 	}
@@ -106,6 +106,14 @@ func (c *SysCheckModelFcdaRalationMgr) GetList() ([]orm.Params, error) {
 	o := orm.NewOrm()
 	sqlParamters := []interface{}{c.Model.ModelId, c.Model.FromFcdaId}
 	sql := "select t.* from t_data_model_fcda_ref t where t.model_id=? and t.from_fcda_id=?"
+	if c.Model.ToIedCode != "" {
+		sql = sql + " and t.to_ied_code=?"
+		sqlParamters = append(sqlParamters, c.Model.ToIedCode)
+	}
+	if c.Model.Goosesv != "" {
+		sql = sql + " and t.goosesv=?"
+		sqlParamters = append(sqlParamters, c.Model.Goosesv)
+	}
 	rowset := []orm.Params{}
 	_, err := o.Raw(sql, sqlParamters).Values(&rowset)
 	if err != nil {

+ 3 - 3
service/models/bo/check_sysmodel_ied_func.go

@@ -99,10 +99,10 @@ func (c *SysCheckModelIedFuncMgr) Exist() (bool, error) {
 	rowset := []orm.Params{}
 	_, err := db.Raw("select id from t_data_model_func_def where model_id=? and ied_type=? and func_name=?", c.Model.ModelId, c.Model.IedType, c.Model.FuncName).Values(&rowset)
 	if len(rowset) > 0 {
-		if tools.IsEmpty(c.Model.Id) != tools.IsEmpty(rowset[0]["id"]) {
-			return false, nil
-		} else {
+		if c.Model.Id > 0 && tools.IsEmpty(c.Model.Id) != tools.IsEmpty(rowset[0]["id"]) {
 			return true, nil
+		} else {
+			return false, nil
 		}
 	}
 	return false, err

+ 12 - 0
service/static/swagger/swagger.json

@@ -388,6 +388,18 @@
                         "required": true,
                         "type": "integer",
                         "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "to_ied_type",
+                        "description": "输入装置类型",
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "goosesv",
+                        "description": "信号类型。GOOSE|SV",
+                        "type": "string"
                     }
                 ],
                 "responses": {

+ 8 - 0
service/static/swagger/swagger.yml

@@ -270,6 +270,14 @@ paths:
         required: true
         type: integer
         format: int64
+      - in: formData
+        name: to_ied_type
+        description: 输入装置类型
+        type: string
+      - in: formData
+        name: goosesv
+        description: 信号类型。GOOSE|SV
+        type: string
       responses:
         "200":
           description: 成功

+ 12 - 0
service/swagger/swagger.json

@@ -388,6 +388,18 @@
                         "required": true,
                         "type": "integer",
                         "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "to_ied_type",
+                        "description": "输入装置类型",
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "goosesv",
+                        "description": "信号类型。GOOSE|SV",
+                        "type": "string"
                     }
                 ],
                 "responses": {

+ 8 - 0
service/swagger/swagger.yml

@@ -270,6 +270,14 @@ paths:
         required: true
         type: integer
         format: int64
+      - in: formData
+        name: to_ied_type
+        description: 输入装置类型
+        type: string
+      - in: formData
+        name: goosesv
+        description: 信号类型。GOOSE|SV
+        type: string
       responses:
         "200":
           description: 成功