소스 검색

修改bug

liling 1 년 전
부모
커밋
3ee07d1ab5

+ 76 - 0
service/controllers/busAdminController.go

@@ -550,6 +550,82 @@ func (c *BusAdminController) ResetCheckAreaByID() {
 	c.ServeJSON()
 }
 
+// @Summary 添加一个新间隔
+//	@Description  添加一个新间隔
+// 	@Tags         业务管理服务
+// 	@Accept       x-www-form-urlencoded
+// 	@Produce      json
+//	@Param 	scd_id 			formData   int  true 	"SCD文件ID"
+//	@Param 	model_id 		formData   int  true 	"间隔所属模型ID。从当前任务已选择模型中选择"
+//	@Param 	area_type 		formData   string  true 	"检测间隔类型。关联系统代码:area_type"
+//	@Param 	area_name 		formData   string  true 	"检测间隔名称"
+// 	@Success     200    {object} ResultOK 成功
+// 	@Failure 	 500 	{object} ResultError  失败
+// @router /admin/new/check_area [post]
+func (c *BusAdminController) AddCheckArea() {
+	id, _ := c.GetInt64("scd_id")
+	if id == 0 {
+		c.Data["json"] = c.ResultError("SCD文件ID不能为空!")
+		c.ServeJSON()
+		return
+	}
+	model_id, _ := c.GetInt("model_id")
+	area_type := c.GetString("area_type")
+	area_name := c.GetString("area_name")
+	if model_id == 0 || area_type == "" || area_name == "" {
+		c.Data["json"] = c.ResultError("参数不能为空!")
+		c.ServeJSON()
+		return
+	}
+	obj := new(bo.CheckAreaMgr)
+	obj.SetUserInfo(c.GetCurrentUserInfo())
+	obj.ScdId = id
+	lst, err := obj.Save(model_id, area_type, area_name)
+	if err != nil {
+		c.Data["json"] = c.ResultError(err.Error())
+		c.ServeJSON()
+		return
+	}
+	c.Data["json"] = c.ResultOK(lst, 0)
+	c.ServeJSON()
+}
+
+// @Summary 删除指定的间隔
+//	@Description  删除指定的间隔
+// 	@Tags         业务管理服务
+// 	@Accept       x-www-form-urlencoded
+// 	@Produce      json
+//	@Param 	scd_id 			formData   int  true 	"SCD文件ID"
+//	@Param 	area_id 		formData   int  true 	"间隔ID"
+// 	@Success     200    {object} ResultOK 成功
+// 	@Failure 	 500 	{object} ResultError  失败
+// @router /admin/del/check_area [post]
+func (c *BusAdminController) DelCheckArea() {
+	id, _ := c.GetInt64("scd_id")
+	if id == 0 {
+		c.Data["json"] = c.ResultError("SCD文件ID不能为空!")
+		c.ServeJSON()
+		return
+	}
+	area_id, _ := c.GetInt("area_id")
+	if area_id == 0 {
+		c.Data["json"] = c.ResultError("参数不能为空!")
+		c.ServeJSON()
+		return
+	}
+	obj := new(bo.CheckAreaMgr)
+	obj.SetUserInfo(c.GetCurrentUserInfo())
+	obj.ScdId = id
+	err := obj.Del(area_id)
+	if err != nil {
+		c.Data["json"] = c.ResultError(err.Error())
+		c.ServeJSON()
+		return
+	}
+	c.Data["json"] = c.ResultOK("", 0)
+	c.ServeJSON()
+}
+
 // @Summary 查询指定电压等级及接线方式下的检测间隔分析结果
 //	@Description  查询指定电压等级及接线方式下的检测间隔分析结果
 // 	@Tags         业务管理服务

+ 3 - 0
service/controllers/scdCompController.go

@@ -64,13 +64,16 @@ func (c *ScdCompController) GetCheckToolsTreeRoot() {
 // @Accept       x-www-form-urlencoded
 // @Produce      json
 // @Param        station_id query     int   true  "变电站ID"
+// @Param        scd_id query     int   false  "SCD文件ID"
 // @Success      200    {object} ResultOK   成功
 // @Failure 	 500 	status  失败
 // @router /scd/comp/list [get]
 func (c *ScdCompController) GetCompList() {
 	stationid, _ := c.GetInt("station_id")
+	scdid, _ := c.GetInt64("scd_id")
 	flowObj := new(bo.ScdCompare)
 	flowObj.StationId = stationid
+	flowObj.Sourceid = scdid
 	flowObj.Userinfo = c.GetCurrentUserInfo()
 	list, err := flowObj.List()
 	if err != nil {

+ 12 - 3
service/models/bo/check_sys_model.go

@@ -131,12 +131,17 @@ func (c *SysCheckModelMgr) Save() (model T_data_model_defualt, err error) {
 					nodetype := tools.IsEmpty(ritem2["type"])
 					if nodetype == "my-group" {
 						properties := ritem2["properties"].(map[string]interface{})
-						iedtypes = append(iedtypes, tools.IsEmpty(properties["ied_type"]))
+						tmp := tools.IsEmpty(properties["ied_type"])
+						if arrayex.IndexOf(iedtypes, tmp) > -1 {
+							//装置类型重复了
+							return c.Model, errors.New("装置类型" + tmp + "不能重复引用")
+						}
+						iedtypes = append(iedtypes, tmp)
 						continue
 					}
 					properties := ritem2["properties"].(map[string]interface{})
 					tmp := tools.IsEmpty(properties["ied_type"])
-					if arrayex.IndexOf(iedtypes, tmp) > 0 {
+					if arrayex.IndexOf(iedtypes, tmp) > -1 {
 						//装置类型重复了
 						return c.Model, errors.New("装置类型" + tmp + "不能重复引用")
 					}
@@ -241,12 +246,16 @@ func (c *SysCheckModelMgr) Save() (model T_data_model_defualt, err error) {
 						//装置分组
 						properties := ritem2["properties"].(map[string]interface{})
 						tmp := tools.IsEmpty(properties["ied_type"])
+						if arrayex.IndexOf(iedtypes, tmp) > -1 {
+							//装置类型重复了
+							return c.Model, errors.New("装置类型" + tmp + "不能重复引用")
+						}
 						iedtypes = append(iedtypes, tmp)
 						continue
 					}
 					properties := ritem2["properties"].(map[string]interface{})
 					tmp := tools.IsEmpty(properties["ied_type"])
-					if arrayex.IndexOf(iedtypes, tmp) > 0 {
+					if arrayex.IndexOf(iedtypes, tmp) > -1 {
 						//装置类型重复了
 						return c.Model, errors.New("装置类型" + tmp + "不能重复引用")
 					}

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

@@ -280,7 +280,15 @@ func (c *SysCheckModelIedFuncMgr) Imp(param map[string]interface{}) (bool, error
 	if modelInfo.Id == 0 || dberr != nil {
 		return false, errors.New(fmt.Sprintf("无效的模型编号:%d", modelId))
 	}
-	modelInfoIedTypes := "," + tools.IsEmpty(modelInfo.IedTypes) + ","
+	modelInfoIedTypes := map[string][]string{} //"," + tools.IsEmpty(modelInfo.IedTypes) + ","
+	for _, t := range strings.Split(tools.IsEmpty(modelInfo.IedTypes), ",") {
+		t1 := strings.Split(t, "-")[0] //装置编码是否有套别
+		if modelInfoIedTypes[t1] == nil {
+			modelInfoIedTypes[t1] = []string{t}
+		} else {
+			modelInfoIedTypes[t1] = append(modelInfoIedTypes[t1], t)
+		}
+	}
 	i := 2
 	func_id := 0
 	fcda_id := 0
@@ -288,26 +296,18 @@ func (c *SysCheckModelIedFuncMgr) Imp(param map[string]interface{}) (bool, error
 	fcdaMap := map[string]int{}
 	fcdaMgr := new(SysCheckModelIedFuncFcdaMgr)
 	fcdaMgr.Model.ModelId = modelId
-	//获取装置分组信息
-	//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(row[2])
 		if ied_type == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:装置类型编码不能为空", i))
 		}
-		/*
-			//判断装置类型是否是合并分组类型,如PLC由PL+CL合并
-			if groupList != nil && groupList[ied_type] != "" {
-				ied_type = groupList[ied_type]
-			}
-		*/
-		if !strings.Contains(modelInfoIedTypes, ","+ied_type+",") {
+		ttt := modelInfoIedTypes[ied_type]
+		if ttt == nil {
 			//模型中未发现该装置类型
 			continue
 		}
+
 		func_name := row[3]
 		if func_name == "" {
 			return false, errors.New(fmt.Sprintf("第%d行:功能名称不能为空", i))
@@ -329,53 +329,53 @@ func (c *SysCheckModelIedFuncMgr) Imp(param map[string]interface{}) (bool, error
 			return false, errors.New(fmt.Sprintf("第%d行:信号方向不能为空", i))
 		}
 		receive_ied_type := strings.ReplaceAll(strings.ReplaceAll(row[8], "&", ","), ",", ",") //对侧接收装置类型
-		/*
-			tmpAry := strings.Split(receive_ied_type, ",")
-			for i, item := range tmpAry {
-				if groupList != nil && groupList[item] != "" {
-					tmpAry[i] = groupList[item]
+		for tj, t := range ttt {
+			funckey := fmt.Sprintf("%d%s%s", modelId, t, func_name)
+			func_id = funcMap[funckey]
+			if func_id == 0 {
+				//获取功能id
+				func_id, _ = c.GetFuncId(modelId, t, func_name)
+				funcMap[funckey] = func_id
+			}
+			if func_id > 0 {
+				fcdaKey := fmt.Sprintf("%d%s", func_id, fcda_name)
+				fcda_id = fcdaMap[fcdaKey]
+				if fcda_id == 0 {
+					fcdaMgr.Model.FuncId = func_id
+					fcdaMgr.Model.FcdaName = fcda_name
+					_, fcda_id, _ := fcdaMgr.Exist()
+					fcdaMap[fcdaKey] = fcda_id
 				}
 			}
-			receive_ied_type = strings.Join(tmpAry, ",")
-		*/
-		funckey := fmt.Sprintf("%d%s%s", modelId, ied_type, func_name)
-		func_id = funcMap[funckey]
-		if func_id == 0 {
-			//获取功能id
-			func_id, _ = c.GetFuncId(modelId, ied_type, func_name)
-			funcMap[funckey] = func_id
-		}
-		if func_id > 0 {
-			fcdaKey := fmt.Sprintf("%d%s", func_id, fcda_name)
-			fcda_id = fcdaMap[fcdaKey]
-			if fcda_id == 0 {
-				fcdaMgr.Model.FuncId = func_id
-				fcdaMgr.Model.FcdaName = fcda_name
-				_, fcda_id, _ := fcdaMgr.Exist()
-				fcdaMap[fcdaKey] = fcda_id
+			mod := T_data_model_func_def{}
+			if func_id > 0 {
+				mod.Id = func_id
+			}
+			mod.ModelId = modelId
+			mod.IedType = t
+			mod.FuncFcdaId = fcda_id
+			mod.FuncName = func_name
+			mod.FcdaName = fcda_name
+			mod.FcdaMatchExp = fcda_match_exp
+			mod.Svorgoose = svorgoose
+			mod.Inorout = inorout
+			if modelInfoIedTypes[receive_ied_type] != nil {
+				mod.ReceiveIedType = modelInfoIedTypes[receive_ied_type][0]
+			} else {
+				mod.ReceiveIedType = receive_ied_type
+			}
+			c.Model = mod
+			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
+			if tj == 0 {
+				//模型中存在多个同类装置时,仅第一个类型装置才自动建立关联,其他的均通过手动关联
+				autoRows = append(autoRows, mod)
 			}
 		}
-		mod := T_data_model_func_def{}
-		if func_id > 0 {
-			mod.Id = func_id
-		}
-		mod.ModelId = modelId
-		mod.IedType = ied_type
-		mod.FuncFcdaId = fcda_id
-		mod.FuncName = func_name
-		mod.FcdaName = fcda_name
-		mod.FcdaMatchExp = fcda_match_exp
-		mod.Svorgoose = svorgoose
-		mod.Inorout = inorout
-		mod.ReceiveIedType = receive_ied_type
-		c.Model = mod
-		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
 	}
 	//根据接收装置编码定义,自动建立端子关系

+ 63 - 15
service/models/bo/checktools_area.go

@@ -132,6 +132,45 @@ func (c *CheckAreaMgr) Init(scdid int64) {
 	tmplist = nil
 }
 
+//保存间隔
+func (c *CheckAreaMgr) Save(model_id int, area_type, area_name string) (int, error) {
+	//判断间隔名称是否重复
+	db := orm.NewOrm()
+	rowset := []orm.Params{}
+	db.Raw("select id from t_data_check_area where scd_id=?", c.ScdId).Values(&rowset)
+	if len(rowset) > 0 {
+		return 0, errors.New("间隔名称" + area_name + "已存在")
+	}
+	cr := c.GetUserId()
+	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()
+	sqllog := fmt.Sprintf("添加新间隔%s", area_name)
+	if err != nil {
+		logger.Logger.Error(err)
+		new(SystemLog).Fail(enum.AuditType_check_area, enum.LogType_Insert, enum.OptEventType_Bus, enum.OptEventLevel_Hight, sqllog, c.GetUserInfo())
+		return 0, err
+	}
+	new(SystemLog).Success(enum.AuditType_check_area, enum.LogType_Insert, enum.OptEventType_Bus, enum.OptEventLevel_Hight, sqllog, c.GetUserInfo())
+
+	id, _ := r.LastInsertId()
+	return int(id), nil
+}
+
+//删除指定间隔
+func (c *CheckAreaMgr) Del(area_id int) error {
+	db := orm.NewOrm()
+	_, err := db.Raw("delete from t_data_check_area where scd_id=? and id=?", c.ScdId, area_id).Exec()
+	_, err = db.Raw("delete from t_data_check_area_ied where scd_id=? and area_id=?", c.ScdId, area_id).Exec()
+	sqllog := fmt.Sprintf("删除间隔%d", area_id)
+	if err != nil {
+		logger.Logger.Error(err)
+		new(SystemLog).Fail(enum.AuditType_check_area, enum.LogType_Delete, enum.OptEventType_Bus, enum.OptEventLevel_Hight, sqllog, c.GetUserInfo())
+	} else {
+		new(SystemLog).Success(enum.AuditType_check_area, enum.LogType_Delete, enum.OptEventType_Bus, enum.OptEventLevel_Hight, sqllog, c.GetUserInfo())
+	}
+	return err
+}
+
 //保存指定间隔所属的电压等级
 func (c *CheckAreaMgr) SetVoltageLevel(id string, voltagelevel int) error {
 	db := orm.NewOrm()
@@ -150,8 +189,12 @@ func (c *CheckAreaMgr) UpdateName(scdid int64, area_id int, name string) error {
 	}
 	areaM.AreaName = name
 	_, err = db.Update(&areaM)
+	sqllog := fmt.Sprintf("修改指定间隔%d的名称为%s", area_id, name)
 	if err != nil {
 		logger.Logger.Error(err)
+		new(SystemLog).Fail(enum.AuditType_check_area, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Hight, sqllog, c.GetUserInfo())
+	} else {
+		new(SystemLog).Success(enum.AuditType_check_area, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Hight, sqllog, c.GetUserInfo())
 	}
 	return err
 }
@@ -172,9 +215,9 @@ func (c *CheckAreaMgr) GetAreaList(scdid int64) ([]orm.Params, error) {
 	sqllog := fmt.Sprintf("SQL:%s 参数:%+v", sql, []interface{}{scdid})
 	if err != nil {
 		logger.Logger.Error(err, sqllog)
-		new(SystemLog).Fail(enum.AuditType_scd_show, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
+		new(SystemLog).Fail(enum.AuditType_check_area, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
 	} else {
-		new(SystemLog).Success(enum.AuditType_scd_show, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
+		new(SystemLog).Success(enum.AuditType_check_area, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
 	}
 	return rowset, nil
 }
@@ -197,9 +240,9 @@ func (c *CheckAreaMgr) GetAreaListByVol(scdid int64, vl, linkstyleid int) ([]orm
 	sqllog := fmt.Sprintf("SQL:%s 参数:%+v", sql, []interface{}{scdid, vl})
 	if err != nil {
 		logger.Logger.Error(err, sqllog)
-		new(SystemLog).Fail(enum.AuditType_scd_show, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
+		new(SystemLog).Fail(enum.AuditType_check_area, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
 	} else {
-		new(SystemLog).Success(enum.AuditType_scd_show, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
+		new(SystemLog).Success(enum.AuditType_check_area, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
 	}
 	return rowset, nil
 }
@@ -226,7 +269,7 @@ func (c *CheckAreaMgr) GetIedList(scdid int64, areaid int) ([]orm.Params, error)
 	sqllog := fmt.Sprintf("SQL:%s 参数:%+v", sql, sqlParamters)
 	if err != nil {
 		logger.Logger.Error(err, sqllog)
-		new(SystemLog).Fail(enum.AuditType_scd_show, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
+		new(SystemLog).Fail(enum.AuditType_check_area, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
 	} else {
 		scdNode := new(ScdNode)
 
@@ -242,7 +285,7 @@ func (c *CheckAreaMgr) GetIedList(scdid int64, areaid int) ([]orm.Params, error)
 			rowset[i]["attr_manufacturer"] = iedObj.Manufacturer
 			rowset[i]["ied_id"] = iedObj.NodeId
 		}
-		//new(SystemLog).Success(enum.AuditType_scd_show, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
+		//new(SystemLog).Success(enum.AuditType_check_area, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
 	}
 	return rowset, nil
 }
@@ -298,7 +341,7 @@ func (c *CheckAreaMgr) GetIedTypeList(scdid int64) ([]orm.Params, error) {
 	sqllog := fmt.Sprintf("SQL:%s 参数:%+v", sql, sqlParamters)
 	if err != nil {
 		logger.Logger.Error(err, sqllog)
-		new(SystemLog).Fail(enum.AuditType_scd_show, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
+		new(SystemLog).Fail(enum.AuditType_check_area, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.GetUserInfo())
 	}
 	return rowset, nil
 }
@@ -1332,7 +1375,7 @@ func (c *CheckAreaMgr) ParseModelArea() {
 		//获取模型内中装备关系定义
 		//主变间隔分析:需要查站内该电压等级下的高中低压侧装置或者高低压装置组成一个间隔,以主变保护装置(PT)为起始
 		if areaCode == "T" {
-			c.pT(modelid, iedtypes, iedMap, HasAreaJ)
+			c.pT(modelid, volcode, iedtypes, iedMap, HasAreaJ)
 		}
 		//线路保护间隔分析:以线路保护测控装置(PL)为开始分析
 		if areaCode == "L" {
@@ -1357,7 +1400,7 @@ func (c *CheckAreaMgr) getIedTypeCode(modelid int, iedtype string) string {
 }
 
 //变压器间隔分析
-func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Params, HasAreaJ bool) {
+func (c *CheckAreaMgr) pT(modelid int, vol, iedtypes string, ieds map[string]orm.Params, HasAreaJ bool) {
 	scdParseMgr := new(ScdParse)
 	scdNodeMgr := new(ScdNode)
 	db := orm.NewOrm()
@@ -1436,7 +1479,7 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 	delPm := false
 	delMm := false
 	for _, row := range ieds {
-		if tools.IsEmpty(row["ied_type"]) != ptCode[0:1] || tools.IsEmpty(row["p_type"]) != ptCode[1:] {
+		if tools.IsEmpty(row["vol"]) != vol || tools.IsEmpty(row["ied_type"]) != ptCode[0:1] || tools.IsEmpty(row["p_type"]) != ptCode[1:] {
 			continue
 		}
 		if _, h := groupList[ptCode]; h {
@@ -1470,6 +1513,7 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 		ins1 := "insert into t_data_check_area_ied(scd_id,area_id,ied_name,ied_type,p_type)values"
 		insvalues := []string{}
 		inAreaIedName := ""
+		hasIedNameMap := map[string]int{}
 		//insvalues = append(insvalues, fmt.Sprintf("(%d,%d,'%s','%s','%s')", c.ScdId, newid, inAreaIedName, "P", "T"))
 		for _, ty := range strings.Split(iedtypes, ",") {
 			inAreaIedName = ""
@@ -1500,7 +1544,7 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			ptype := strings.Split(tyCode, "#")[0]
 			//判断间隔是否需要包含差动装置
 			if strings.Contains(tyCode, "#C") {
-				_, iedname := getIedByDesc(ieds, tyCode, "差动")
+				_, iedname := getIedByDesc(ieds, ptype, "差动")
 				if len(iedname) > 0 {
 					for _, in := range iedname {
 						tmpIednameParts := scdParseMgr.ParseIedName(in)
@@ -1513,7 +1557,7 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			}
 			//判断间隔是否需要包含本体保护装置
 			if strings.Contains(tyCode, "#0") {
-				_, iedname := getIedByDesc(ieds, tyCode, "本体")
+				_, iedname := getIedByDesc(ieds, ptype, "本体")
 				if len(iedname) > 0 {
 					for _, in := range iedname {
 						tmpIednameParts := scdParseMgr.ParseIedName(in)
@@ -1528,17 +1572,21 @@ func (c *CheckAreaMgr) pT(modelid int, iedtypes string, ieds map[string]orm.Para
 			imtcode := c.getIedTypeCode(modelid, tyCode)
 			h, m, l := c.getIedListByVol(imtcode, ieds, volMap, abCode)
 			//logger.Logger.Debug(fmt.Sprintf("tyCode:%s H:%+v,M:%+v,L:%+v", tyCode, h, m, l))
-			if volValue == "" || volValue == "H" {
+			if volValue == "" || volValue == "H" || strings.Contains(tyCode, "#H") {
 				dlIeds = append(dlIeds, h...)
 			}
-			if volValue == "" || volValue == "M" {
+			if volValue == "" || volValue == "M" || strings.Contains(tyCode, "#M") {
 				dlIeds = append(dlIeds, m...)
 			}
-			if volValue == "" || volValue == "L" {
+			if volValue == "" || volValue == "L" || strings.Contains(tyCode, "#L") {
 				dlIeds = append(dlIeds, l...)
 			}
 			for _, r := range dlIeds {
 				inAreaIedName = tools.IsEmpty(r["ied_name"])
+				if hasIedNameMap[inAreaIedName] == 1 {
+					continue
+				}
+				hasIedNameMap[inAreaIedName] = 1
 				tmpIednameParts := scdParseMgr.ParseIedName(inAreaIedName)
 				if tyCode[0:len(ctCode)] == ctCode {
 					//CT单独处理。它可能不分AB套

+ 25 - 0
service/models/bo/link_style.go

@@ -36,6 +36,26 @@ func init() {
 	orm.RegisterModel(new(T_data_link_style))
 }
 
+func (c *LinkStyleMgr) Exist() (int, bool) {
+	db := orm.NewOrm()
+	rowset := []orm.Params{}
+	_, err := db.Raw("select id from t_data_link_style where vol_level_id=? and name=?", c.Model.VolLevelId, c.Model.Name).Values(&rowset)
+	if err != nil {
+		logger.Logger.Error(err)
+		return 0, true
+	}
+	if len(rowset) > 0 {
+		id, _ := strconv.Atoi(tools.IsEmpty(rowset[0]["id"]))
+		if c.Model.Id > 0 && c.Model.Id == id {
+			//发现名称与当前数据记录的相同,判定为不重复
+			return id, false
+		}
+		return id, true
+	} else {
+		return 0, false
+	}
+}
+
 //保存接线方式信息
 func (c *LinkStyleMgr) Save() (err error) {
 	dblog := new(SystemLog)
@@ -44,6 +64,11 @@ func (c *LinkStyleMgr) Save() (err error) {
 	dblog.Logtype = enum.LogType_Insert
 	dblog.Eventtype = enum.OptEventType_Bus
 	dblog.Eventlevel = enum.OptEventLevel_Hight
+	_, same := c.Exist()
+	if same {
+		//发现名称有相同 的
+		return errors.New(fmt.Sprintf("在所选电压等级下接线方式[%s]已存在", c.Model.Name))
+	}
 	db := orm.NewOrm()
 	c.Model.Cr, _ = strconv.Atoi(c.GetUserId())
 	if c.Model.Id == 0 {

+ 9 - 3
service/models/bo/scd_diff_compare.go

@@ -138,10 +138,16 @@ func (c *ScdCompare) GetCheckToolsTreeRoot(scdid, id, pid int64, datatype string
 
 func (c *ScdCompare) List() ([]orm.Params, error) {
 	db := orm.NewOrm()
-	sql := "select t.*,t1.scd_name source_name,case when t1.enable=0 then '签入中' else t1.version end source_version ,t2.scd_name target_name,case when t2.enable=0 then '签入中' else t2.version end target_version from t_scd_diff_compare t left JOIN t_scd_scl t1 on t.source_id=t1.id left JOIN t_scd_scl t2  on t.target_id=t2.id where  t.station_id=? order by CREATED_TIME desc"
+	sql := "select t.*,t1.scd_name source_name,case when t1.enable=0 then '签入中' else t1.version end source_version ,t2.scd_name target_name,case when t2.enable=0 then '签入中' else t2.version end target_version from t_scd_diff_compare t left JOIN t_scd_scl t1 on t.source_id=t1.id left JOIN t_scd_scl t2  on t.target_id=t2.id where  t.station_id=? "
 	rowset := []orm.Params{}
-	_, err := db.Raw(sql, c.StationId).Values(&rowset)
-	sqllog := fmt.Sprintf("SQL:%s,参数:%+v", sql, c.StationId)
+	ps := []interface{}{c.StationId}
+	if c.Sourceid > 0 {
+		sql += " and t.source_id=? "
+		ps = append(ps, c.Sourceid)
+	}
+	sql += " order by CREATED_TIME desc"
+	_, err := db.Raw(sql, ps).Values(&rowset)
+	sqllog := fmt.Sprintf("SQL:%s,参数:%+v", sql, ps)
 	if err != nil {
 		logger.Logger.Error(err, sqllog)
 		new(SystemLog).Fail(enum.AuditType_scd_diffcompare, enum.LogType_Query, enum.OptEventType_Bus, enum.OptEventLevel_Low, sqllog, c.Userinfo)

+ 4 - 0
service/models/bo/scd_node_mgr.go

@@ -1582,6 +1582,10 @@ func (c *ScdNode) GetIedBlockRelations(scdid int64, ied_name string, forcerefres
 		//daName := tools.IsEmpty(row["attr_da_name"])
 		inout := tools.IsEmpty(row["inout_type"]) //in:输入当前IED out:输出到其他IED
 		inIed := c.GetIed(scdXmlObj, tools.IsEmpty(scdid), tmpIedName)
+		if inIed == nil {
+			logger.Logger.Error(errors.New(fmt.Sprintf("在scd:中未找到装置%s", scdid, tmpIedName)))
+			continue
+		}
 		if inIed.AccessPoint == nil {
 			continue
 		}

+ 2 - 0
service/models/bo/task.go

@@ -256,6 +256,8 @@ func (c *TaskMgr) Save() (id int, err error) {
 		if oldinfo.State == 1 {
 			return 0, errors.New("任务正在检测中,不允许编辑")
 		}
+		c.Model.Cr = oldinfo.Cr
+		c.Model.Ct = oldinfo.Ct
 		c.Model.StartTime = oldinfo.StartTime
 		c.Model.EndTime = oldinfo.EndTime
 		c.Model.State = oldinfo.State

+ 4 - 0
service/models/enum/enum_audittype.go

@@ -115,6 +115,8 @@ const (
 	AuditType_admin_dbbackorrecorvey
 	//检测任务
 	AuditType_check_task
+	//检测间隔
+	AuditType_check_area
 	//检测模型管理
 	AuditType_check_model
 	//检测报告管理
@@ -211,6 +213,8 @@ func (t AuditType) String() string {
 		return "检测报告"
 	case AuditType_link_style:
 		return "接线方式管理"
+	case AuditType_check_area:
+		return "检测间隔管理"
 	default:
 		return "未知类型"
 	}

+ 18 - 0
service/routers/commentsRouter_controllers.go

@@ -540,6 +540,15 @@ func init() {
 
     beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"] = append(beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"],
         beego.ControllerComments{
+            Method: "DelCheckArea",
+            Router: "/admin/del/check_area",
+            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: "GetCheckAreaByVolID",
             Router: "/admin/get/check_area",
             AllowHTTPMethods: []string{"get"},
@@ -684,6 +693,15 @@ func init() {
 
     beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"] = append(beego.GlobalControllerRouter["scd_check_tools/controllers:BusAdminController"],
         beego.ControllerComments{
+            Method: "AddCheckArea",
+            Router: "/admin/new/check_area",
+            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: "ResetCheckAreaByID",
             Router: "/admin/parse/check_area",
             AllowHTTPMethods: []string{"post"},

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

@@ -10,6 +10,44 @@
     },
     "basePath": "api",
     "paths": {
+        "/admin/del/check_area": {
+            "post": {
+                "tags": [
+                    "scd_check_tools/controllersBusAdminController"
+                ],
+                "summary": "删除指定的间隔",
+                "description": "删除指定的间隔",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "scd_id",
+                        "description": "SCD文件ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "area_id",
+                        "description": "间隔ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/admin/get/check_area": {
             "get": {
                 "tags": [
@@ -783,6 +821,58 @@
                 }
             }
         },
+        "/admin/new/check_area": {
+            "post": {
+                "tags": [
+                    "scd_check_tools/controllersBusAdminController"
+                ],
+                "summary": "添加一个新间隔",
+                "description": "添加一个新间隔",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "scd_id",
+                        "description": "SCD文件ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "model_id",
+                        "description": "间隔所属模型ID。从当前任务已选择模型中选择",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "area_type",
+                        "description": "检测间隔类型。关联系统代码:area_type",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "area_name",
+                        "description": "检测间隔名称",
+                        "required": true,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/admin/parse/check_area": {
             "post": {
                 "tags": [
@@ -4604,6 +4694,13 @@
                         "required": true,
                         "type": "integer",
                         "format": "int64"
+                    },
+                    {
+                        "in": "query",
+                        "name": "scd_id",
+                        "description": "SCD文件ID",
+                        "type": "integer",
+                        "format": "int64"
                     }
                 ],
                 "responses": {

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

@@ -8,6 +8,32 @@ info:
     email: 3116246@qq.com
 basePath: api
 paths:
+  /admin/del/check_area:
+    post:
+      tags:
+      - scd_check_tools/controllersBusAdminController
+      summary: 删除指定的间隔
+      description: 删除指定的间隔
+      parameters:
+      - in: formData
+        name: scd_id
+        description: SCD文件ID
+        required: true
+        type: integer
+        format: int64
+      - in: formData
+        name: area_id
+        description: 间隔ID
+        required: true
+        type: integer
+        format: int64
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /admin/get/check_area:
     get:
       tags:
@@ -538,6 +564,42 @@ paths:
             $ref: '#/definitions/ResultOK'
         "500":
           description: '{object} ResultError  失败'
+  /admin/new/check_area:
+    post:
+      tags:
+      - scd_check_tools/controllersBusAdminController
+      summary: 添加一个新间隔
+      description: 添加一个新间隔
+      parameters:
+      - in: formData
+        name: scd_id
+        description: SCD文件ID
+        required: true
+        type: integer
+        format: int64
+      - in: formData
+        name: model_id
+        description: 间隔所属模型ID。从当前任务已选择模型中选择
+        required: true
+        type: integer
+        format: int64
+      - in: formData
+        name: area_type
+        description: 检测间隔类型。关联系统代码:area_type
+        required: true
+        type: string
+      - in: formData
+        name: area_name
+        description: 检测间隔名称
+        required: true
+        type: string
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /admin/parse/check_area:
     post:
       tags:
@@ -3118,6 +3180,11 @@ paths:
         required: true
         type: integer
         format: int64
+      - in: query
+        name: scd_id
+        description: SCD文件ID
+        type: integer
+        format: int64
       responses:
         "200":
           description: 成功

+ 97 - 0
service/swagger/swagger.json

@@ -10,6 +10,44 @@
     },
     "basePath": "api",
     "paths": {
+        "/admin/del/check_area": {
+            "post": {
+                "tags": [
+                    "scd_check_tools/controllersBusAdminController"
+                ],
+                "summary": "删除指定的间隔",
+                "description": "删除指定的间隔",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "scd_id",
+                        "description": "SCD文件ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "area_id",
+                        "description": "间隔ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/admin/get/check_area": {
             "get": {
                 "tags": [
@@ -783,6 +821,58 @@
                 }
             }
         },
+        "/admin/new/check_area": {
+            "post": {
+                "tags": [
+                    "scd_check_tools/controllersBusAdminController"
+                ],
+                "summary": "添加一个新间隔",
+                "description": "添加一个新间隔",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "scd_id",
+                        "description": "SCD文件ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "model_id",
+                        "description": "间隔所属模型ID。从当前任务已选择模型中选择",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "area_type",
+                        "description": "检测间隔类型。关联系统代码:area_type",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "area_name",
+                        "description": "检测间隔名称",
+                        "required": true,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/admin/parse/check_area": {
             "post": {
                 "tags": [
@@ -4604,6 +4694,13 @@
                         "required": true,
                         "type": "integer",
                         "format": "int64"
+                    },
+                    {
+                        "in": "query",
+                        "name": "scd_id",
+                        "description": "SCD文件ID",
+                        "type": "integer",
+                        "format": "int64"
                     }
                 ],
                 "responses": {

+ 67 - 0
service/swagger/swagger.yml

@@ -8,6 +8,32 @@ info:
     email: 3116246@qq.com
 basePath: api
 paths:
+  /admin/del/check_area:
+    post:
+      tags:
+      - scd_check_tools/controllersBusAdminController
+      summary: 删除指定的间隔
+      description: 删除指定的间隔
+      parameters:
+      - in: formData
+        name: scd_id
+        description: SCD文件ID
+        required: true
+        type: integer
+        format: int64
+      - in: formData
+        name: area_id
+        description: 间隔ID
+        required: true
+        type: integer
+        format: int64
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /admin/get/check_area:
     get:
       tags:
@@ -538,6 +564,42 @@ paths:
             $ref: '#/definitions/ResultOK'
         "500":
           description: '{object} ResultError  失败'
+  /admin/new/check_area:
+    post:
+      tags:
+      - scd_check_tools/controllersBusAdminController
+      summary: 添加一个新间隔
+      description: 添加一个新间隔
+      parameters:
+      - in: formData
+        name: scd_id
+        description: SCD文件ID
+        required: true
+        type: integer
+        format: int64
+      - in: formData
+        name: model_id
+        description: 间隔所属模型ID。从当前任务已选择模型中选择
+        required: true
+        type: integer
+        format: int64
+      - in: formData
+        name: area_type
+        description: 检测间隔类型。关联系统代码:area_type
+        required: true
+        type: string
+      - in: formData
+        name: area_name
+        description: 检测间隔名称
+        required: true
+        type: string
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /admin/parse/check_area:
     post:
       tags:
@@ -3118,6 +3180,11 @@ paths:
         required: true
         type: integer
         format: int64
+      - in: query
+        name: scd_id
+        description: SCD文件ID
+        type: integer
+        format: int64
       responses:
         "200":
           description: 成功