1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072 |
- package controllers
- import (
- "fmt"
- "scd_check_tools/global"
- "scd_check_tools/models/bo"
- "scd_check_tools/tools"
- "strconv"
- "strings"
- )
- //SCD服务
- type ScreenController struct {
- BaseController
- }
- func init() {
- }
- //获取当前登录人的token
- //返回结果:string
- func (c *ScreenController) GetUserToken() string {
- Authorization := c.Ctx.Request.Header.Get("Authorization")
- if Authorization == "" {
- return ""
- }
- return strings.TrimLeft(Authorization, "Bearer ")
- }
- //强制解除scd文件锁定状态
- // @Summary 强制解除scd文件锁定状态
- // @Description 强制解除scd文件锁定状态
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id formData int true "SCD文件ID"
- // @Param flow_run_id formData int true "签入流程ID"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /screen/scd/unlock [post]
- func (c *ScreenController) UnlockScd() {
- scdObj := new(bo.ScdMgr)
- scdObj.SetUserInfo(c.GetCurrentUserInfo())
- scdid := c.GetString("scd_id")
- if scdid == "" {
- c.Data["json"] = c.ResultError("SCD文件编号不能为空")
- c.ServeJSON()
- return
- }
- flow_run_id := c.GetString("flow_run_id")
- if flow_run_id == "" {
- c.Data["json"] = c.ResultError("流程流转编号不能为空")
- c.ServeJSON()
- return
- }
- err := scdObj.IsDispose(scdid)
- if err == nil {
- err = (new(bo.Flow)).IsDispose(flow_run_id, c.GetString("reason"))
- c.Data["json"] = c.ResultOK("", 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- //获取scd列表
- // @Summary 获取scd列表
- // @Description 获取scd列表
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param stationid query int true "变电站ID"
- // @Param pageno query int true "当前页码。默认为1"
- // @Param pagesize query int true "每页显示数据数。默认为50"
- // @Param name query string false "SCD名称"
- // @Param enable query int false "是否在运版SCD"
- // @Param ischeckinscd query int false "是否管控scd"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /screen/scd/list [get]
- func (c *ScreenController) GetScdList() {
- scd := new(bo.ScdMgr)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- stationid := c.GetString("stationid")
- para := map[string]interface{}{"stationid": stationid}
- para["pagesize"], _ = c.GetInt("pagesize", 100)
- para["pageno"], _ = c.GetInt("pageno", 0)
- if para["pageno"] == 0 {
- para["pageno"], _ = c.GetInt("pageindex", 0)
- }
- if para["pageno"] == 0 {
- para["pageno"] = 1
- }
- para["id"] = c.GetString("id")
- para["name"] = c.GetString("name")
- para["enable"] = c.GetString("enable")
- para["ischeckinscd"] = c.GetString("ischeckinscd", "") //默认查询管控scd
- data, cnt, err := scd.List(para)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, cnt)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取scd详细信息
- // @Description 获取scd详细信息
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param scdname query string false "SCD名称"
- // @Param scdpath query string false "SCD路径"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /screen/scd/info [get]
- func (c *ScreenController) GetScdInfoByname() {
- scd := new(bo.ScdMgr)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid := c.GetString("scd_id")
- if scdid != "" {
- info, err := scd.One(scdid)
- if err == nil {
- c.Data["json"] = c.ResultOK(info, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- return
- }
- data, err := scd.OneByName(c.GetString("scdname"), c.GetString("scdpath"))
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 删除指定scd数据
- // @Description 删除指定scd数据
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param id formData int true "SCD文件ID"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /screen/scd/delete [post]
- func (c *ScreenController) RemoveScdInfo() {
- scd := new(bo.ScdMgr)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- err := scd.DeleteScd(c.GetString("id"))
- if err == nil {
- c.Data["json"] = c.ResultOK("", 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // 该接口一般用于临时scd的解析
- // @Summary 临时scd解析
- // @Description 临时scd解析
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param station_id formData int true "变电站ID"
- // @Param scd_name formData string false "SCD名称"
- // @Param scd_path formData string false "SCD路径"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /screen/scd/tmp_parse [post]
- func (c *ScreenController) TempParseScdInfo() {
- userInfo := c.GetCurrentUserInfo()
- scd := bo.GetScdParseInstance(userInfo)
- stationid := c.GetString("station_id")
- if stationid == "" {
- c.Data["json"] = c.ResultError("无效的变电站编号")
- c.ServeJSON()
- return
- }
- scdpath := c.GetString("scd_path")
- scdName := c.GetString("scd_name")
- if scdpath == "" || scdName == "" {
- c.Data["json"] = c.ResultError("无效的SCD名称")
- c.ServeJSON()
- return
- }
- //go scd.Parse(stationid, scdpath, scdName, 0)
- scd.IsCheckinScd = 0
- go scd.XmlParse(stationid, scdpath, scdName, 0)
- c.Data["json"] = c.ResultOK("", 0)
- c.ServeJSON()
- }
- // @Summary 重新解析指定scd
- // @Description 重新解析指定scd
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id formData int true "SCD ID"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /screen/scd/agin_parse [post]
- func (c *ScreenController) AginParseScdInfo() {
- scd := new(bo.ScdMgr)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- err := scd.AginParse(c.GetString("scd_id"))
- if err == nil {
- c.Data["json"] = c.ResultOK("", 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 解析指定scd的间隔及装置
- // @Description 解析指定scd的间隔及装置,该接口不会进行校验及其他分析
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param station_id formData int true "变电站ID"
- // @Param scd_path formData string true "SCD文件路径"
- // @Param scd_name formData string true "SCD文件名称"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /screen/scd/parse/step1 [post]
- func (c *ScreenController) ScdParseStep1() {
- scd := bo.GetScdParseInstance(c.GetCurrentUserInfo())
- stationid := c.GetString("station_id")
- if stationid == "" {
- c.Data["json"] = c.ResultError("无效的变电站编号")
- c.ServeJSON()
- return
- }
- scdpath := c.GetString("scd_path")
- scdName := c.GetString("scd_name")
- if scdpath == "" || scdName == "" {
- c.Data["json"] = c.ResultError("无效的SCD名称")
- c.ServeJSON()
- return
- }
- scdid, err := scd.XmlIEDParse(stationid, scdpath, scdName)
- if err != nil {
- c.Data["json"] = c.ResultError(err.Error())
- } else {
- checkArea := new(bo.CheckAreaMgr)
- checkArea.ScdId, _ = strconv.ParseInt(scdid, 10, 64)
- checkArea.ParseModelArea()
- c.Data["json"] = c.ResultOK(scdid, 0)
- }
- c.ServeJSON()
- }
- // @Summary 对指定scd进行校验及分析
- // @Description 对指定scd进行校验及分析
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id formData int true "SCD ID"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /screen/scd/parse/step2 [post]
- func (c *ScreenController) ScdParseStep2() {
- scd := bo.GetScdParseInstance(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt64("scd_id")
- if scdid == 0 {
- c.Data["json"] = c.ResultError("无效的SCD编号")
- c.ServeJSON()
- return
- }
- err := scd.XmlCheckParse(scdid)
- if err != nil {
- c.Data["json"] = c.ResultError(err.Error())
- } else {
- c.Data["json"] = c.ResultOK("", 0)
- }
- c.ServeJSON()
- }
- // @Summary 获取指定scd校验类型树
- // @Description 获取指定scd校验类型树
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param id query int true "节点ID"
- // @Param pid query int true "父节点ID"
- // @Param datatype query string true "节点类型"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 {object} ResultError 失败
- // @router /screen/scd/checktools/tree [get]
- func (c *ScreenController) GetCheckToolsTreeRoot() {
- scdnode := new(bo.ScdNode)
- scdnode.SetUserInfo(c.GetCurrentUserInfo())
- scd_id, _ := c.GetInt64("scd_id")
- scdnode.RootID = scd_id
- id, _ := c.GetInt64("id")
- pid, _ := c.GetInt64("pid")
- data, err := scdnode.GetCheckToolsTreeRoot(id, pid, c.GetString("datatype"))
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取scd节点列表
- // @Description 获取scd节点列表
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param pageno query int true "当前页码。默认为1"
- // @Param pagesize query int true "每页的数据条数。默认为20"
- // @Param parent_node_id query int false "父节点ID"
- // @Param name query string false "节点Name"
- // @Param ied_name query string false "装置Name"
- // @router /screen/scd/node/list [get]
- func (c *ScreenController) GetScdNodeList() {
- scdnode := new(bo.ScdNode)
- scdnode.SetUserInfo(c.GetCurrentUserInfo())
- para := map[string]interface{}{}
- para["pagesize"], _ = c.GetInt("pagesize", 20)
- para["pageno"], _ = c.GetInt("pageno", 1)
- para["scd_id"] = c.GetString("scd_id")
- para["parent_node_id"] = c.GetString("parent_node_id")
- para["name"] = c.GetString("name")
- para["ied_name"] = c.GetString("ied_name")
- data, rowcount, err := scdnode.List(para)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, rowcount)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 统计指定节点的下级节点类型及数量
- // @Description 统计指定节点的下级节点类型及数量
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param node_id query int true "SCD节点ID"
- // @router /screen/scd/node/children/stat [get]
- func (c *ScreenController) StatChildrenNodeList() {
- scdnode := new(bo.ScdNode)
- scdnode.SetUserInfo(c.GetCurrentUserInfo())
- data, rowcount, err := scdnode.GetChildrenStat(c.GetString("scd_id"), c.GetString("node_id"))
- if err == nil {
- c.Data["json"] = c.ResultOK(data, rowcount)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取scd节点属性
- // @Description 获取scd节点属性
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param node_id query int true "SCD节点ID"
- // @Param ied_name query string false "SCD装置名称"
- // @router /screen/scd/node/attrs [get]
- func (c *ScreenController) GetScdNodeAttrsList() {
- scdnode := new(bo.ScdNode)
- scdnode.SetUserInfo(c.GetCurrentUserInfo())
- para := map[string]interface{}{}
- para["scd_id"] = c.GetString("scd_id")
- para["node_id"] = c.GetString("node_id")
- para["ied_name"] = c.GetString("ied_name")
- data, err := scdnode.GetAttrValues(para)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 1)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定accessPoint下的Ldevice节点列表
- // @Description 获取指定accessPoint下的Ldevice节点列表
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param accessPointId query int true "访问点ID"
- // @router /screen/scd/ldevice/list [get]
- func (c *ScreenController) GetScdLdeviceList() {
- scdnode := new(bo.ScdNode)
- scdnode.SetUserInfo(c.GetCurrentUserInfo())
- data, _, err := scdnode.GetLdeviceList(c.GetString("scd_id"), c.GetString("accessPointId"))
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取IED网络配置信息
- // @Description 获取IED网络配置信息
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "装置名称"
- // @router /screen/scd/ied/network/info [get]
- func (c *ScreenController) GetScdIedNetworkList() {
- scdnode := new(bo.ScdNode)
- scdnode.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt64("scd_id")
- data, err := scdnode.GetIedNetworkInfo(scdid, c.GetString("ied_name"))
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取IED关联关系
- // @Description 获取IED关联关系
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "装置名称"
- // @router /screen/scd/ied/relation [get]
- func (c *ScreenController) GetScdIedRelationList() {
- scdnode := new(bo.ScdNode)
- scdnode.SetUserInfo(c.GetCurrentUserInfo())
- para := map[string]interface{}{}
- para["scd_id"] = c.GetString("scd_id")
- //是否重新分析.需要时传1
- para["reset"] = c.GetString("reset")
- para["ied_name"] = c.GetString("ied_name")
- data, err := scdnode.GetIedRelations(para)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取IED的虚端子关系
- // @Description 获取IED的虚端子关系
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "主装置名称"
- // @Param m_ied_name query string true "输出IED装置名称"
- // @Param s_ied_name query string true "输入IED装置名称"
- // @Param m_ctrlid query string true "输出控制块ID"
- // @Param s_ctrlid query string true "输入控制块ID"
- // @router /screen/scd/ied/inputs [get]
- func (c *ScreenController) GetScdIedInputsRelationList() {
- scdnode := new(bo.ScdNode)
- scdnode.SetUserInfo(c.GetCurrentUserInfo())
- para := map[string]interface{}{}
- para["scd_id"] = c.GetString("scd_id")
- para["ied_id"] = c.GetString("ied_id")
- para["ied_name"] = c.GetString("ied_name")
- para["m_ied_name"] = c.GetString("m_ied_name") //输出IED
- para["s_ied_name"] = c.GetString("s_ied_name") //输入IED
- para["m_ctrlid"] = c.GetString("m_ctrlid") //输出控制块ID
- para["s_ctrlid"] = c.GetString("s_ctrlid") //输入控制块ID
- if para["m_ctrlid"] != "" || para["s_ctrlid"] != "" {
- //获取指定IED节点及控制块ID的虚端子关系
- data, err := scdnode.GetIedCtrlInputsRelations(para)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- } else {
- data, err := scdnode.GetIedInputsRelations(para)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- }
- c.ServeJSON()
- }
- // @Summary 获取SCD中配置的所有设备网络地址
- // @Description 获取SCD中配置的所有设备网络地址
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @router /screen/scd/ied/netaddr [get]
- func (c *ScreenController) GetScdIedNetaddrList() {
- scd := new(bo.ScdMgr)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- data, err := scd.GetIedNetAddr(c.GetString("scd_id"))
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定IED的控制块信息
- // @Description 获取指定IED的控制块信息
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "装置名称"
- // @router /screen/scd/ied/ctrlblock [get]
- func (c *ScreenController) GetScdIedCtrlBlockList() {
- scd := new(bo.ScdNode)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt64("scd_id")
- iedname := c.GetString("ied_name")
- data, err := scd.GetIedCtrlBlock(scdid, iedname)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定IED的指定SMV控制块端子列表
- // @Description 获取指定IED的指定SMV控制块端子列表
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "装置名称"
- // @Param ctrlid query int true "SMV控制块ID"
- // @router /screen/scd/ied/smv_ctrlblock/sendfcdalist [get]
- func (c *ScreenController) GetScdIedSMVCtrlBlockSendFcdaList() {
- scd := new(bo.ScdNode)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt64("scd_id")
- iedname := c.GetString("ied_name")
- ctrlid, _ := c.GetInt64("ctrlid")
- data, err := scd.GetIedSMVCtrlBlockSendFcdaList(scdid, iedname, ctrlid)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定IED的指定GOOSE控制块端子列表
- // @Description 获取指定IED的指定GOOSE控制块端子列表
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "装置名称"
- // @Param ctrlid query int true "GOOSE控制块ID"
- // @router /screen/scd/ied/goose_ctrlblock/sendfcdalist [get]
- func (c *ScreenController) GetScdIedGOOSECtrlBlockSendFcdaList() {
- scd := new(bo.ScdNode)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt64("scd_id")
- iedname := c.GetString("ied_name")
- ctrlid, _ := c.GetInt64("ctrlid")
- data, err := scd.GetIedGooseCtrlBlockSendFcdaList(scdid, iedname, ctrlid)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定IED的接收SMV控制块端子列表
- // @Description 获取指定IED的接收SMV控制块端子列表
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "装置名称"
- // @router /screen/scd/ied/smv_ctrlblock/receive [get]
- func (c *ScreenController) GetScdIedSMVCtrlBlockRevFcdaList() {
- scd := new(bo.ScdNode)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt64("scd_id")
- iedname := c.GetString("ied_name")
- data, err := scd.GetIedSMVCtrlBlockRevList(scdid, iedname)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定IED的接收GOOSE控制块端子列表
- // @Description 获取指定IED的接收GOOSE控制块端子列表
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "装置名称"
- // @router /screen/scd/ied/goose_ctrlblock/receive [get]
- func (c *ScreenController) GetScdIedGOOSECtrlBlockRevFcdaList() {
- scd := new(bo.ScdNode)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt64("scd_id")
- iedname := c.GetString("ied_name")
- data, err := scd.GetIedGooseCtrlBlockRevList(scdid, iedname)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定IED的关联IED控制块信息
- // @Description 获取指定IED的关联IED控制块信息
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "装置名称"
- // @router /screen/scd/ied/ref/ctrlblock [get]
- func (c *ScreenController) GetScdIedRefCtrlBlockList() {
- scd := new(bo.ScdNode)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt64("scd_id")
- iedname := c.GetString("ied_name")
- isforce := c.GetString("forcerefresh")
- isforceBool := false
- if isforce == "1" {
- isforceBool = true
- }
- data, err := scd.GetIedBlockRelations(scdid, iedname, isforceBool)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定SCD的汇总统计结果
- // @Description 获取指定SCD的汇总统计结果
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @router /scd/check/sum/result [get]
- func (c *ScreenController) GetScdCheckSumResult() {
- scd := new(bo.ScdNodeRule)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt("scd_id")
- scd.ScdID = int64(scdid)
- data, err := scd.SumCheckResult()
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定SCD的校验结果
- // @Description 获取指定SCD的校验结果
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param pageno query int true "当前页码。默认为1"
- // @Param pagesize query int true "每页数据记录条数。默认为20"
- // @Param scd_name query string false "SCD文件名称"
- // @Param scd_path query string false "SCD文件名称"
- // @Param level query string false "校验错误级别"
- // @Param ied_name query string false "IED装置名称"
- // @Param node_name query string false "节点名称"
- // @Param node_id query string false "节点ID"
- // @router /scd/check/resultlist [get]
- func (c *ScreenController) GetScdCheckResultList() {
- scd := new(bo.ScdNodeRule)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt("scd_id")
- pno, _ := c.GetInt("pageno", 1)
- psize, _ := c.GetInt("pagesize", 20)
- scd.ScdID = int64(scdid)
- data, cnt, err := scd.ResultList(c.GetString("scd_name"),
- c.GetString("scd_path"),
- c.GetString("level"),
- c.GetString("ied_name"),
- c.GetString("node_name"),
- c.GetString("node_id"), pno, psize)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, cnt)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 按校验错误等级统计校验结果
- // @Description 按校验错误等级统计校验结果
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param scd_name query string false "SCD文件名称"
- // @Param scd_path query string false "SCD文件名称"
- // @Param ied_name query string false "IED装置名称"
- // @Param node_name query string false "节点名称"
- // @Param node_id query string false "节点ID"
- // @router /scd/check/stat/level [get]
- func (c *ScreenController) StatScdCheckResultCnt() {
- scd := new(bo.ScdNodeRule)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt("scd_id")
- scd.ScdID = int64(scdid)
- data, err := scd.ResultStatByLevel(
- c.GetString("scd_name"),
- c.GetString("scd_path"),
- c.GetString("ied_name"),
- c.GetString("node_name"),
- c.GetString("node_id"),
- )
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定scd下的间隔信息
- // @Description 获取指定scd下的间隔信息
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param voltage_level_id query int false "电压等级ID"
- // @router /scd/area/list [get]
- func (c *ScreenController) GetScdAreaList() {
- scd := new(bo.ScdAreaMgr)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt64("scd_id")
- vol, _ := c.GetInt32("voltage_level_id")
- if vol > 0 {
- data, err := scd.GetAreaListByVol(scdid, vol)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- return
- }
- data, err := scd.GetAreaList(scdid)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, len(data))
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 修改指定间隔的名称信息
- // @Description 修改指定间隔的名称信息
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param area_id query int true "间隔ID"
- // @Param name query string true "间隔名称"
- // @router /scd/area/editname [post]
- func (c *ScreenController) EditScdAreaName() {
- scd := new(bo.ScdAreaMgr)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scdid, _ := c.GetInt64("scd_id")
- area_id, _ := c.GetInt("area_id")
- name := tools.IsEmpty(c.GetString("name"))
- if area_id == 0 {
- c.Data["json"] = c.ResultError("间隔ID不能为空")
- return
- }
- if name == "" {
- c.Data["json"] = c.ResultError("间隔名称不能为空")
- return
- }
- err := scd.UpdateName(scdid, area_id, name)
- if err == nil {
- c.Data["json"] = c.ResultOK("", 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 修改指定间隔的所属电压等级
- // @Description 修改指定间隔的所属电压等级
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param voltagelevel query int true "电压等级ID"
- // @Param area_id query int true "间隔ID"
- // @router /scd/area/edit_voltage_level [post]
- func (c *ScreenController) EditScdAreaVolLevel() {
- scd := new(bo.ScdAreaMgr)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- volid, _ := c.GetInt("voltagelevel")
- area_id := c.GetString("area_id")
- if area_id == "" {
- c.Data["json"] = c.ResultError("间隔ID不能为空")
- return
- }
- if volid == 0 {
- c.Data["json"] = c.ResultError("电压等级ID不能为空")
- return
- }
- err := scd.SetVoltageLevel(area_id, volid)
- if err == nil {
- c.Data["json"] = c.ResultOK("", 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 修改指定装置的所属间隔
- // @Description 修改指定装置的所属间隔
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "装置名称"
- // @Param area_id query int true "间隔ID"
- // @router /scd/ied/editarea [post]
- func (c *ScreenController) EditScdIedArea() {
- scd := new(bo.ScdAreaMgr)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- scd_id, _ := c.GetInt64("scd_id")
- area_id, _ := c.GetInt("area_id")
- if area_id == 0 {
- c.Data["json"] = c.ResultError("间隔ID不能为空")
- return
- }
- iedname := c.GetString("ied_name")
- if iedname == "" {
- c.Data["json"] = c.ResultError("IED装置名称不能为空")
- return
- }
- err := scd.UpdateIedArea(scd_id, iedname, area_id)
- if err == nil {
- c.Data["json"] = c.ResultOK("", 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定间隔下的IED信息
- // @Description 获取指定间隔下的IED信息
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param voltage_level_id query int false "电压等级ID"
- // @Param area_id query int false "间隔ID"
- // @Param device_type_id query string false "装置类型ID。关联系统字典:device_type"
- // @router /scd/area/ied/list [get]
- func (c *ScreenController) GetScdAreaIedList() {
- scdid, _ := c.GetInt64("scd_id")
- areaid, _ := c.GetInt32("area_id")
- voltage_level_id, _ := c.GetInt32("voltage_level_id")
- device_type := c.GetString("device_type_id")
- scd := new(bo.ScdAreaMgr)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- data, err := scd.GetIedList(scdid, voltage_level_id, areaid, device_type)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定SCD下的IED类型信息
- // @Description 获取指定SCD下的IED类型信息
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @router /scd/ied/typelist [get]
- func (c *ScreenController) GetScdIedTypeList() {
- scdid, _ := c.GetInt64("scd_id")
- scd := new(bo.ScdAreaMgr)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- data, err := scd.GetIedTypeList(scdid)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定IED的定值条目
- // @Description 获取指定IED的定值条目
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "IED装置名称"
- // @router /screen/scd/ied/dingzhi [get]
- func (c *ScreenController) GetScdIedDingzhiList() {
- scdid, _ := c.GetInt64("scd_id")
- ied_name := c.GetString("ied_name")
- scd := new(bo.ScdNode)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- data, err := scd.GetScdIedDingzhiList(scdid, ied_name)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定IED的信息点表
- // @Description 获取指定IED的定值条目
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "IED装置名称"
- // @router /screen/scd/ied/pointtable [get]
- func (c *ScreenController) GetScdIedPointTableList() {
- scdid, _ := c.GetInt64("scd_id")
- ied_name := c.GetString("ied_name")
- scd := new(bo.ScdNode)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- data, err := scd.GetScdIedPointTableList(scdid, ied_name)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定IED的源XML
- // @Description 获取指定IED的源XML
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param ied_name query string true "IED装置名称"
- // @router /screen/scd/ied/sourcexml [get]
- func (c *ScreenController) GetScdIedSourceXML() {
- scdid, _ := c.GetInt64("scd_id")
- ied_name := c.GetString("ied_name")
- scd := new(bo.ScdNode)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- data, err := scd.GetScdIedSourceXML(scdid, ied_name)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定行号的源XML
- // @Description 获取指定行号的源XML,每次获取指定行的前后各100行源数据
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param lineno query int true "行号"
- // @router /screen/scd/line/sourcexml [get]
- func (c *ScreenController) GetScdLineSourceXML() {
- scdid, _ := c.GetInt64("scd_id")
- lineno, _ := c.GetInt64("lineno")
- scd := new(bo.ScdNode)
- scd.SetUserInfo(c.GetCurrentUserInfo())
- data, err := scd.GetScdLineSourceXML(scdid, lineno)
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- // @Summary 获取指定scd的crc校验结果
- // @Description 获取指定scd的crc校验结果
- // @Tags SCD服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @router /screen/scd/crc [get]
- func (c *ScreenController) GetScdIedCrc() {
- scdid := c.GetString("scd_id")
- if scdid == "" {
- c.Data["json"] = c.ResultError("无效的SCD编号")
- c.ServeJSON()
- return
- }
- scdXmlObj, _ := new(bo.ScdParse).GetScdXmlObjectBySCDID(scdid)
- if scdXmlObj == nil {
- c.Data["json"] = c.ResultError("无效的SCD")
- c.ServeJSON()
- return
- }
- scdmgr := new(bo.ScdMgr)
- _, err := scdmgr.CrcCheck(scdid)
- if err != nil {
- c.Data["json"] = c.ResultError(err.Error())
- c.ServeJSON()
- return
- }
- crclist, _ := global.CachedScdCrc.Load(fmt.Sprintf("crc_%s", scdid))
- crclist2 := crclist.(map[string]string)
- crcresult := map[string]interface{}{}
- itemobj := map[string]string{
- "checkcrc": crclist2["scdcrc"],
- "scdcrc": "",
- }
- //获取scd文件的校验码
- for _, pri := range scdXmlObj.Private {
- if pri.Type == "Substation virtual terminal conection CRC" {
- itemobj["scdcrc"] = pri.InnerText
- break
- }
- }
- crcresult["scdcrc"] = itemobj
- itemlist := []map[string]interface{}{}
- for _, iedobj := range scdXmlObj.IED {
- itemobj := map[string]interface{}{}
- itemobj["iedname"] = iedobj.Name
- itemobj["ieddesc"] = iedobj.Desc
- itemobj["manufacturer"] = iedobj.Manufacturer
- itemobj["iedversion"] = iedobj.ConfigVersion
- itemobj["type"] = iedobj.Type
- if v, h := crclist2[iedobj.Name]; h {
- itemobj["checkcrc"] = v
- }
- for _, pri := range iedobj.Priavate {
- if pri.Type == "IED virtual terminal conection CRC" {
- itemobj["scdcrc"] = pri.InnerText
- break
- }
- }
- itemlist = append(itemlist, itemobj)
- }
- crcresult["list"] = itemlist
- c.Data["json"] = c.ResultOK(crcresult, 0)
- c.ServeJSON()
- }
|