123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068 |
- package controllers
- import (
- "fmt"
- "scd_check_tools/global"
- "scd_check_tools/models/bo"
- "scd_check_tools/tools"
- "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 scdname formData string false "SCD名称"
- // @Param scdpath 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 {
- 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()
- }
|