Browse Source

修复完善端子导入功能

liling 1 năm trước cách đây
mục cha
commit
296d59a2e4

+ 35 - 0
service/controllers/busAdminController.go

@@ -620,6 +620,8 @@ func (c *BusAdminController) GetFuncListByIedType() {
 // 	@Produce      json
 //	@Param 	model_id 	formData   int  	true 	"模型ID"
 //	@Param 	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 成功
 // 	@Failure 	 500 	{object} ResultError  失败
 // @router /admin/model/function/fcda/list [get]
@@ -648,6 +650,8 @@ func (c *BusAdminController) GetFuncFcdaList() {
 	fcdaMgr := new(bo.SysCheckModelIedFuncFcdaMgr)
 	fcdaMgr.Model = bo.T_data_model_func_fcda{}
 	fcdaMgr.Model.ModelId = modelid
+	fcdaMgr.Model.Svorgoose = strings.ToUpper(c.GetString("sv_or_goose"))
+	fcdaMgr.Model.Inorout = c.GetString("in_or_out")
 	for _, row := range lst {
 		fcdaMgr.Model.FuncId, _ = strconv.Atoi(tools.IsEmpty(row["id"]))
 		tmpLst, err := fcdaMgr.GetList()
@@ -744,6 +748,37 @@ func (c *BusAdminController) SaveFuncFcda() {
 	c.ServeJSON()
 }
 
+// @Summary 删除指定模型所有的装置端子
+//	@Description  删除指定模型所有的装置端子
+// 	@Tags         业务管理服务
+// 	@Accept       x-www-form-urlencoded
+// 	@Produce      json
+//	@Param 	model_id 	formData   int  	true 	"模型ID"
+// 	@Success     200    {object} ResultOK 成功
+// 	@Failure 	 500 	{object} ResultError  失败
+// @router /admin/model/fcda/delall [post]
+func (c *BusAdminController) DelAllFuncFcda() {
+	modelid, _ := c.GetInt("model_id")
+	if modelid == 0 {
+		c.Data["json"] = c.ResultError("模型ID不能为空!")
+		c.ServeJSON()
+		return
+	}
+
+	fcdaMgr := new(bo.SysCheckModelIedFuncFcdaMgr)
+	fcdaMgr.SetUserInfo(c.GetCurrentUserInfo())
+	fcdaMgr.Model = bo.T_data_model_func_fcda{}
+	fcdaMgr.Model.ModelId = modelid
+	err := fcdaMgr.Delete()
+	if err != nil {
+		c.Data["json"] = c.ResultError(err.Error())
+		c.ServeJSON()
+		return
+	}
+	c.Data["json"] = c.ResultOK("", 0)
+	c.ServeJSON()
+}
+
 // @Summary 删除装置端子
 //	@Description  删除装置端子
 // 	@Tags         业务管理服务

+ 17 - 4
service/models/bo/check_sysmodel_ied_func.go

@@ -7,6 +7,7 @@ import (
 	"scd_check_tools/models/enum"
 	"scd_check_tools/tools"
 	"strconv"
+	"strings"
 
 	"github.com/astaxie/beego/orm"
 )
@@ -53,10 +54,10 @@ func (c *SysCheckModelIedFuncMgr) Save() (err error) {
 	if err != nil {
 		return err
 	}
-	if c.Model.Svorgoose != "SV" || c.Model.Svorgoose != "GOOSE" {
+	if c.Model.Svorgoose != "SV" && c.Model.Svorgoose != "GOOSE" {
 		return errors.New("端子信号类型值无效,仅支持SV或GOOSE")
 	}
-	if c.Model.Inorout != "接收" || c.Model.Inorout != "输出" {
+	if c.Model.Inorout != "接收" && c.Model.Inorout != "输出" {
 		return errors.New("端子信号方向值无效,仅支持'接收'或'输出'")
 	}
 	db.Begin()
@@ -237,6 +238,14 @@ func (c *SysCheckModelIedFuncMgr) Imp(param map[string]interface{}) (bool, error
 	logObj.Eventlevel = enum.OptEventLevel_Hight
 	logObj.Logtype = enum.LogType_imp
 	logObj.Description = "装置功能及端子导入"
+	//模型信息
+	modelObj := new(SysCheckModelMgr)
+	modelObj.Model.Id = modelId
+	modelInfo, dberr := modelObj.One()
+	if modelInfo.Id == 0 || dberr != nil {
+		return false, errors.New(fmt.Sprintf("无效的模型编号:%d", modelId))
+	}
+	modelInfoIedTypes := "," + tools.IsEmpty(modelInfo.IedTypes) + ","
 	i := 2
 	func_id := 0
 	fcda_id := 0
@@ -249,15 +258,19 @@ func (c *SysCheckModelIedFuncMgr) Imp(param map[string]interface{}) (bool, error
 		if ied_type == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:装置类型编码不能为空", i))
 		}
+		if !strings.Contains(modelInfoIedTypes, ","+ied_type+",") {
+			//模型中未发现该装置类型
+			continue
+		}
 		func_name := tools.IsEmpty(row[3])
 		if func_name == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:功能名称不能为空", i))
 		}
-		fcda_name := tools.IsEmpty(row[4])
+		fcda_name := strings.ReplaceAll(strings.ReplaceAll(tools.IsEmpty(row[4]), "(", "("), ")", ")")
 		if fcda_name == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:端子设计名称不能为空", i))
 		}
-		fcda_match_exp := tools.IsEmpty(row[5])
+		fcda_match_exp := strings.ReplaceAll(strings.ReplaceAll(tools.IsEmpty(row[5]), "(", "("), ")", ")")
 		if fcda_match_exp == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:端子关键词不能为空", i))
 		}

+ 28 - 2
service/models/bo/check_sysmodel_ied_func_fcda.go

@@ -163,6 +163,14 @@ func (c *SysCheckModelIedFuncFcdaMgr) Delete() (err error) {
 					funcMgr.Delete()
 				}
 			}
+		} else if c.Model.FuncId > 0 {
+			funcMgr := new(SysCheckModelIedFuncMgr)
+			funcMgr.Model.Id = c.Model.FuncId
+			funcMgr.Delete()
+		} else {
+			funcMgr := new(SysCheckModelIedFuncMgr)
+			funcMgr.Model.ModelId = c.Model.ModelId
+			funcMgr.Delete()
 		}
 	}
 	return err
@@ -177,8 +185,26 @@ func (c *SysCheckModelIedFuncFcdaMgr) One(id int) (T_data_model_func_fcda, error
 
 func (c *SysCheckModelIedFuncFcdaMgr) GetList() ([]orm.Params, error) {
 	o := orm.NewOrm()
-	sqlParamters := []interface{}{c.Model.ModelId, c.Model.FuncId}
-	sql := "select t.*,t1.func_name from t_data_model_func_fcda t,t_data_model_func_def t1 where t1.id=t.func_id and t.model_id=? and t.func_id=?"
+	sqlParamters := []interface{}{c.Model.ModelId}
+	outsql := ""
+	if c.Model.Inorout == "接收" {
+		outsql = ",(select id from t_data_model_fcda_ref where model_id=? and to_fcda_id=t.id) from_fcda_id"
+		sqlParamters = append(sqlParamters, 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 {
+		sql = sql + " and t.func_id=?"
+		sqlParamters = append(sqlParamters, c.Model.FuncId)
+	}
+	if c.Model.Svorgoose != "" {
+		sql = sql + " and t.svorgoose=?"
+		sqlParamters = append(sqlParamters, c.Model.Svorgoose)
+	}
+	if c.Model.Inorout != "" {
+		sql = sql + " and t.inorout=?"
+		sqlParamters = append(sqlParamters, c.Model.Inorout)
+	}
+	sql = sql + " order by t.id"
 	rowset := []orm.Params{}
 	_, err := o.Raw(sql, sqlParamters).Values(&rowset)
 	if err != nil {

+ 9 - 0
service/routers/commentsRouter_____________ME_GoProject_src_scd_check_tools_controllers.go

@@ -612,6 +612,15 @@ func init() {
 
     beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"] = append(beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"],
         beego.ControllerComments{
+            Method: "DelAllFuncFcda",
+            Router: "/admin/model/fcda/delall",
+            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: "GetFuncFcdaRef",
             Router: "/admin/model/function/fcda-ref/list",
             AllowHTTPMethods: []string{"get"},

+ 9 - 0
service/routers/commentsRouter_controllers.go

@@ -718,6 +718,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["scd_check_tools/controllers:ExcelController"] = append(beego.GlobalControllerRouter["scd_check_tools/controllers:ExcelController"],
+        beego.ControllerComments{
+            Method: "UploadExcelFile",
+            Router: "impData",
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["scd_check_tools/controllers:FlowController"] = append(beego.GlobalControllerRouter["scd_check_tools/controllers:FlowController"],
         beego.ControllerComments{
             Method: "DeleteFlowCnf_NodeUser",

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

@@ -365,6 +365,36 @@
                 }
             }
         },
+        "/admin/model/fcda/delall": {
+            "post": {
+                "tags": [
+                    "scd_check_tools/controllersBusAdminController"
+                ],
+                "summary": "删除指定模型所有的装置端子",
+                "description": "删除指定模型所有的装置端子",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "model_id",
+                        "description": "模型ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/admin/model/function/fcda-ref/list": {
             "get": {
                 "tags": [
@@ -541,6 +571,20 @@
                         "description": "装置类型",
                         "required": true,
                         "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "sv_or_goose",
+                        "description": "信号类型。仅支持:SV或GOOSE",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "in_or_out",
+                        "description": "信号方向。仅支持:'输出'或'接收'",
+                        "required": true,
+                        "type": "string"
                     }
                 ],
                 "responses": {

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

@@ -251,6 +251,26 @@ paths:
             $ref: '#/definitions/ResultOK'
         "500":
           description: '{object} ResultError  失败'
+  /admin/model/fcda/delall:
+    post:
+      tags:
+      - scd_check_tools/controllersBusAdminController
+      summary: 删除指定模型所有的装置端子
+      description: 删除指定模型所有的装置端子
+      parameters:
+      - in: formData
+        name: model_id
+        description: 模型ID
+        required: true
+        type: integer
+        format: int64
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /admin/model/function/fcda-ref/list:
     get:
       tags:
@@ -375,6 +395,16 @@ paths:
         description: 装置类型
         required: true
         type: string
+      - in: formData
+        name: sv_or_goose
+        description: 信号类型。仅支持:SV或GOOSE
+        required: true
+        type: string
+      - in: formData
+        name: in_or_out
+        description: 信号方向。仅支持:'输出'或'接收'
+        required: true
+        type: string
       responses:
         "200":
           description: 成功

+ 44 - 0
service/swagger/swagger.json

@@ -365,6 +365,36 @@
                 }
             }
         },
+        "/admin/model/fcda/delall": {
+            "post": {
+                "tags": [
+                    "scd_check_tools/controllersBusAdminController"
+                ],
+                "summary": "删除指定模型所有的装置端子",
+                "description": "删除指定模型所有的装置端子",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "model_id",
+                        "description": "模型ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/admin/model/function/fcda-ref/list": {
             "get": {
                 "tags": [
@@ -541,6 +571,20 @@
                         "description": "装置类型",
                         "required": true,
                         "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "sv_or_goose",
+                        "description": "信号类型。仅支持:SV或GOOSE",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "in_or_out",
+                        "description": "信号方向。仅支持:'输出'或'接收'",
+                        "required": true,
+                        "type": "string"
                     }
                 ],
                 "responses": {

+ 30 - 0
service/swagger/swagger.yml

@@ -251,6 +251,26 @@ paths:
             $ref: '#/definitions/ResultOK'
         "500":
           description: '{object} ResultError  失败'
+  /admin/model/fcda/delall:
+    post:
+      tags:
+      - scd_check_tools/controllersBusAdminController
+      summary: 删除指定模型所有的装置端子
+      description: 删除指定模型所有的装置端子
+      parameters:
+      - in: formData
+        name: model_id
+        description: 模型ID
+        required: true
+        type: integer
+        format: int64
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /admin/model/function/fcda-ref/list:
     get:
       tags:
@@ -375,6 +395,16 @@ paths:
         description: 装置类型
         required: true
         type: string
+      - in: formData
+        name: sv_or_goose
+        description: 信号类型。仅支持:SV或GOOSE
+        required: true
+        type: string
+      - in: formData
+        name: in_or_out
+        description: 信号方向。仅支持:'输出'或'接收'
+        required: true
+        type: string
       responses:
         "200":
           description: 成功