screenController.go 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. package controllers
  2. import (
  3. "fmt"
  4. "scd_check_tools/global"
  5. "scd_check_tools/models/bo"
  6. "scd_check_tools/tools"
  7. "strconv"
  8. "strings"
  9. )
  10. //SCD服务
  11. type ScreenController struct {
  12. BaseController
  13. }
  14. func init() {
  15. }
  16. //获取当前登录人的token
  17. //返回结果:string
  18. func (c *ScreenController) GetUserToken() string {
  19. Authorization := c.Ctx.Request.Header.Get("Authorization")
  20. if Authorization == "" {
  21. return ""
  22. }
  23. return strings.TrimLeft(Authorization, "Bearer ")
  24. }
  25. //强制解除scd文件锁定状态
  26. // @Summary 强制解除scd文件锁定状态
  27. // @Description 强制解除scd文件锁定状态
  28. // @Tags SCD服务接口
  29. // @Accept x-www-form-urlencoded
  30. // @Produce json
  31. // @Param scd_id formData int true "SCD文件ID"
  32. // @Param flow_run_id formData int true "签入流程ID"
  33. // @Success 200 {object} ResultOK 成功
  34. // @Failure 500 {object} ResultError 失败
  35. // @router /screen/scd/unlock [post]
  36. func (c *ScreenController) UnlockScd() {
  37. scdObj := new(bo.ScdMgr)
  38. scdObj.SetUserInfo(c.GetCurrentUserInfo())
  39. scdid := c.GetString("scd_id")
  40. if scdid == "" {
  41. c.Data["json"] = c.ResultError("SCD文件编号不能为空")
  42. c.ServeJSON()
  43. return
  44. }
  45. flow_run_id := c.GetString("flow_run_id")
  46. if flow_run_id == "" {
  47. c.Data["json"] = c.ResultError("流程流转编号不能为空")
  48. c.ServeJSON()
  49. return
  50. }
  51. err := scdObj.IsDispose(scdid)
  52. if err == nil {
  53. err = (new(bo.Flow)).IsDispose(flow_run_id, c.GetString("reason"))
  54. c.Data["json"] = c.ResultOK("", 0)
  55. } else {
  56. c.Data["json"] = c.ResultError(err.Error())
  57. }
  58. c.ServeJSON()
  59. }
  60. //获取scd列表
  61. // @Summary 获取scd列表
  62. // @Description 获取scd列表
  63. // @Tags SCD服务接口
  64. // @Accept x-www-form-urlencoded
  65. // @Produce json
  66. // @Param stationid query int true "变电站ID"
  67. // @Param pageno query int true "当前页码。默认为1"
  68. // @Param pagesize query int true "每页显示数据数。默认为50"
  69. // @Param name query string false "SCD名称"
  70. // @Param enable query int false "是否在运版SCD"
  71. // @Param ischeckinscd query int false "是否管控scd"
  72. // @Success 200 {object} ResultOK 成功
  73. // @Failure 500 {object} ResultError 失败
  74. // @router /screen/scd/list [get]
  75. func (c *ScreenController) GetScdList() {
  76. scd := new(bo.ScdMgr)
  77. scd.SetUserInfo(c.GetCurrentUserInfo())
  78. stationid := c.GetString("stationid")
  79. para := map[string]interface{}{"stationid": stationid}
  80. para["pagesize"], _ = c.GetInt("pagesize", 100)
  81. para["pageno"], _ = c.GetInt("pageno", 0)
  82. if para["pageno"] == 0 {
  83. para["pageno"], _ = c.GetInt("pageindex", 0)
  84. }
  85. if para["pageno"] == 0 {
  86. para["pageno"] = 1
  87. }
  88. para["id"] = c.GetString("id")
  89. para["name"] = c.GetString("name")
  90. para["enable"] = c.GetString("enable")
  91. para["ischeckinscd"] = c.GetString("ischeckinscd", "") //默认查询管控scd
  92. data, cnt, err := scd.List(para)
  93. if err == nil {
  94. c.Data["json"] = c.ResultOK(data, cnt)
  95. } else {
  96. c.Data["json"] = c.ResultError(err.Error())
  97. }
  98. c.ServeJSON()
  99. }
  100. // @Summary 获取scd详细信息
  101. // @Description 获取scd详细信息
  102. // @Tags SCD服务接口
  103. // @Accept x-www-form-urlencoded
  104. // @Produce json
  105. // @Param scd_id query int true "SCD文件ID"
  106. // @Param scdname query string false "SCD名称"
  107. // @Param scdpath query string false "SCD路径"
  108. // @Success 200 {object} ResultOK 成功
  109. // @Failure 500 {object} ResultError 失败
  110. // @router /screen/scd/info [get]
  111. func (c *ScreenController) GetScdInfoByname() {
  112. scd := new(bo.ScdMgr)
  113. scd.SetUserInfo(c.GetCurrentUserInfo())
  114. scdid := c.GetString("scd_id")
  115. if scdid != "" {
  116. info, err := scd.One(scdid)
  117. if err == nil {
  118. c.Data["json"] = c.ResultOK(info, 0)
  119. } else {
  120. c.Data["json"] = c.ResultError(err.Error())
  121. }
  122. c.ServeJSON()
  123. return
  124. }
  125. data, err := scd.OneByName(c.GetString("scdname"), c.GetString("scdpath"))
  126. if err == nil {
  127. c.Data["json"] = c.ResultOK(data, 0)
  128. } else {
  129. c.Data["json"] = c.ResultError(err.Error())
  130. }
  131. c.ServeJSON()
  132. }
  133. // @Summary 删除指定scd数据
  134. // @Description 删除指定scd数据
  135. // @Tags SCD服务接口
  136. // @Accept x-www-form-urlencoded
  137. // @Produce json
  138. // @Param id formData int true "SCD文件ID"
  139. // @Success 200 {object} ResultOK 成功
  140. // @Failure 500 {object} ResultError 失败
  141. // @router /screen/scd/delete [post]
  142. func (c *ScreenController) RemoveScdInfo() {
  143. scd := new(bo.ScdMgr)
  144. scd.SetUserInfo(c.GetCurrentUserInfo())
  145. err := scd.DeleteScd(c.GetString("id"))
  146. if err == nil {
  147. c.Data["json"] = c.ResultOK("", 0)
  148. } else {
  149. c.Data["json"] = c.ResultError(err.Error())
  150. }
  151. c.ServeJSON()
  152. }
  153. // 该接口一般用于临时scd的解析
  154. // @Summary 临时scd解析
  155. // @Description 临时scd解析
  156. // @Tags SCD服务接口
  157. // @Accept x-www-form-urlencoded
  158. // @Produce json
  159. // @Param station_id formData int true "变电站ID"
  160. // @Param scd_name formData string false "SCD名称"
  161. // @Param scd_path formData string false "SCD路径"
  162. // @Success 200 {object} ResultOK 成功
  163. // @Failure 500 {object} ResultError 失败
  164. // @router /screen/scd/tmp_parse [post]
  165. func (c *ScreenController) TempParseScdInfo() {
  166. userInfo := c.GetCurrentUserInfo()
  167. scd := bo.GetScdParseInstance(userInfo)
  168. stationid := c.GetString("station_id")
  169. if stationid == "" {
  170. c.Data["json"] = c.ResultError("无效的变电站编号")
  171. c.ServeJSON()
  172. return
  173. }
  174. scdpath := c.GetString("scd_path")
  175. scdName := c.GetString("scd_name")
  176. if scdpath == "" || scdName == "" {
  177. c.Data["json"] = c.ResultError("无效的SCD名称")
  178. c.ServeJSON()
  179. return
  180. }
  181. //go scd.Parse(stationid, scdpath, scdName, 0)
  182. scd.IsCheckinScd = 0
  183. go scd.XmlParse(stationid, scdpath, scdName, 0)
  184. c.Data["json"] = c.ResultOK("", 0)
  185. c.ServeJSON()
  186. }
  187. // @Summary 重新解析指定scd
  188. // @Description 重新解析指定scd
  189. // @Tags SCD服务接口
  190. // @Accept x-www-form-urlencoded
  191. // @Produce json
  192. // @Param scd_id formData int true "SCD ID"
  193. // @Success 200 {object} ResultOK 成功
  194. // @Failure 500 {object} ResultError 失败
  195. // @router /screen/scd/agin_parse [post]
  196. func (c *ScreenController) AginParseScdInfo() {
  197. scd := new(bo.ScdMgr)
  198. scd.SetUserInfo(c.GetCurrentUserInfo())
  199. err := scd.AginParse(c.GetString("scd_id"))
  200. if err == nil {
  201. c.Data["json"] = c.ResultOK("", 0)
  202. } else {
  203. c.Data["json"] = c.ResultError(err.Error())
  204. }
  205. c.ServeJSON()
  206. }
  207. // @Summary 解析指定scd的间隔及装置
  208. // @Description 解析指定scd的间隔及装置,该接口不会进行校验及其他分析
  209. // @Tags SCD服务接口
  210. // @Accept x-www-form-urlencoded
  211. // @Produce json
  212. // @Param station_id formData int true "变电站ID"
  213. // @Param scd_path formData string true "SCD文件路径"
  214. // @Param scd_name formData string true "SCD文件名称"
  215. // @Success 200 {object} ResultOK 成功
  216. // @Failure 500 {object} ResultError 失败
  217. // @router /screen/scd/parse/step1 [post]
  218. func (c *ScreenController) ScdParseStep1() {
  219. scd := bo.GetScdParseInstance(c.GetCurrentUserInfo())
  220. stationid := c.GetString("station_id")
  221. if stationid == "" {
  222. c.Data["json"] = c.ResultError("无效的变电站编号")
  223. c.ServeJSON()
  224. return
  225. }
  226. scdpath := c.GetString("scd_path")
  227. scdName := c.GetString("scd_name")
  228. if scdpath == "" || scdName == "" {
  229. c.Data["json"] = c.ResultError("无效的SCD名称")
  230. c.ServeJSON()
  231. return
  232. }
  233. scdid, err := scd.XmlIEDParse(stationid, scdpath, scdName)
  234. if err != nil {
  235. c.Data["json"] = c.ResultError(err.Error())
  236. } else {
  237. checkArea := new(bo.CheckAreaMgr)
  238. checkArea.ScdId, _ = strconv.ParseInt(scdid, 10, 64)
  239. checkArea.ParseModelArea()
  240. c.Data["json"] = c.ResultOK(scdid, 0)
  241. }
  242. c.ServeJSON()
  243. }
  244. // @Summary 对指定scd进行校验及分析
  245. // @Description 对指定scd进行校验及分析
  246. // @Tags SCD服务接口
  247. // @Accept x-www-form-urlencoded
  248. // @Produce json
  249. // @Param scd_id formData int true "SCD ID"
  250. // @Success 200 {object} ResultOK 成功
  251. // @Failure 500 {object} ResultError 失败
  252. // @router /screen/scd/parse/step2 [post]
  253. func (c *ScreenController) ScdParseStep2() {
  254. scd := bo.GetScdParseInstance(c.GetCurrentUserInfo())
  255. scdid, _ := c.GetInt64("scd_id")
  256. if scdid == 0 {
  257. c.Data["json"] = c.ResultError("无效的SCD编号")
  258. c.ServeJSON()
  259. return
  260. }
  261. err := scd.XmlCheckParse(scdid)
  262. if err != nil {
  263. c.Data["json"] = c.ResultError(err.Error())
  264. } else {
  265. c.Data["json"] = c.ResultOK("", 0)
  266. }
  267. c.ServeJSON()
  268. }
  269. // @Summary 获取指定scd校验类型树
  270. // @Description 获取指定scd校验类型树
  271. // @Tags SCD服务接口
  272. // @Accept x-www-form-urlencoded
  273. // @Produce json
  274. // @Param scd_id query int true "SCD文件ID"
  275. // @Param id query int true "节点ID"
  276. // @Param pid query int true "父节点ID"
  277. // @Param datatype query string true "节点类型"
  278. // @Success 200 {object} ResultOK 成功
  279. // @Failure 500 {object} ResultError 失败
  280. // @router /screen/scd/checktools/tree [get]
  281. func (c *ScreenController) GetCheckToolsTreeRoot() {
  282. scdnode := new(bo.ScdNode)
  283. scdnode.SetUserInfo(c.GetCurrentUserInfo())
  284. scd_id, _ := c.GetInt64("scd_id")
  285. scdnode.RootID = scd_id
  286. id, _ := c.GetInt64("id")
  287. pid, _ := c.GetInt64("pid")
  288. data, err := scdnode.GetCheckToolsTreeRoot(id, pid, c.GetString("datatype"))
  289. if err == nil {
  290. c.Data["json"] = c.ResultOK(data, 0)
  291. } else {
  292. c.Data["json"] = c.ResultError(err.Error())
  293. }
  294. c.ServeJSON()
  295. }
  296. // @Summary 获取scd节点列表
  297. // @Description 获取scd节点列表
  298. // @Tags SCD服务接口
  299. // @Accept x-www-form-urlencoded
  300. // @Produce json
  301. // @Param scd_id query int true "SCD文件ID"
  302. // @Param pageno query int true "当前页码。默认为1"
  303. // @Param pagesize query int true "每页的数据条数。默认为20"
  304. // @Param parent_node_id query int false "父节点ID"
  305. // @Param name query string false "节点Name"
  306. // @Param ied_name query string false "装置Name"
  307. // @router /screen/scd/node/list [get]
  308. func (c *ScreenController) GetScdNodeList() {
  309. scdnode := new(bo.ScdNode)
  310. scdnode.SetUserInfo(c.GetCurrentUserInfo())
  311. para := map[string]interface{}{}
  312. para["pagesize"], _ = c.GetInt("pagesize", 20)
  313. para["pageno"], _ = c.GetInt("pageno", 1)
  314. para["scd_id"] = c.GetString("scd_id")
  315. para["parent_node_id"] = c.GetString("parent_node_id")
  316. para["name"] = c.GetString("name")
  317. para["ied_name"] = c.GetString("ied_name")
  318. data, rowcount, err := scdnode.List(para)
  319. if err == nil {
  320. c.Data["json"] = c.ResultOK(data, rowcount)
  321. } else {
  322. c.Data["json"] = c.ResultError(err.Error())
  323. }
  324. c.ServeJSON()
  325. }
  326. // @Summary 统计指定节点的下级节点类型及数量
  327. // @Description 统计指定节点的下级节点类型及数量
  328. // @Tags SCD服务接口
  329. // @Accept x-www-form-urlencoded
  330. // @Produce json
  331. // @Param scd_id query int true "SCD文件ID"
  332. // @Param node_id query int true "SCD节点ID"
  333. // @router /screen/scd/node/children/stat [get]
  334. func (c *ScreenController) StatChildrenNodeList() {
  335. scdnode := new(bo.ScdNode)
  336. scdnode.SetUserInfo(c.GetCurrentUserInfo())
  337. data, rowcount, err := scdnode.GetChildrenStat(c.GetString("scd_id"), c.GetString("node_id"))
  338. if err == nil {
  339. c.Data["json"] = c.ResultOK(data, rowcount)
  340. } else {
  341. c.Data["json"] = c.ResultError(err.Error())
  342. }
  343. c.ServeJSON()
  344. }
  345. // @Summary 获取scd节点属性
  346. // @Description 获取scd节点属性
  347. // @Tags SCD服务接口
  348. // @Accept x-www-form-urlencoded
  349. // @Produce json
  350. // @Param scd_id query int true "SCD文件ID"
  351. // @Param node_id query int true "SCD节点ID"
  352. // @Param ied_name query string false "SCD装置名称"
  353. // @router /screen/scd/node/attrs [get]
  354. func (c *ScreenController) GetScdNodeAttrsList() {
  355. scdnode := new(bo.ScdNode)
  356. scdnode.SetUserInfo(c.GetCurrentUserInfo())
  357. para := map[string]interface{}{}
  358. para["scd_id"] = c.GetString("scd_id")
  359. para["node_id"] = c.GetString("node_id")
  360. para["ied_name"] = c.GetString("ied_name")
  361. data, err := scdnode.GetAttrValues(para)
  362. if err == nil {
  363. c.Data["json"] = c.ResultOK(data, 1)
  364. } else {
  365. c.Data["json"] = c.ResultError(err.Error())
  366. }
  367. c.ServeJSON()
  368. }
  369. // @Summary 获取指定accessPoint下的Ldevice节点列表
  370. // @Description 获取指定accessPoint下的Ldevice节点列表
  371. // @Tags SCD服务接口
  372. // @Accept x-www-form-urlencoded
  373. // @Produce json
  374. // @Param scd_id query int true "SCD文件ID"
  375. // @Param accessPointId query int true "访问点ID"
  376. // @router /screen/scd/ldevice/list [get]
  377. func (c *ScreenController) GetScdLdeviceList() {
  378. scdnode := new(bo.ScdNode)
  379. scdnode.SetUserInfo(c.GetCurrentUserInfo())
  380. data, _, err := scdnode.GetLdeviceList(c.GetString("scd_id"), c.GetString("accessPointId"))
  381. if err == nil {
  382. c.Data["json"] = c.ResultOK(data, len(data))
  383. } else {
  384. c.Data["json"] = c.ResultError(err.Error())
  385. }
  386. c.ServeJSON()
  387. }
  388. // @Summary 获取IED网络配置信息
  389. // @Description 获取IED网络配置信息
  390. // @Tags SCD服务接口
  391. // @Accept x-www-form-urlencoded
  392. // @Produce json
  393. // @Param scd_id query int true "SCD文件ID"
  394. // @Param ied_name query string true "装置名称"
  395. // @router /screen/scd/ied/network/info [get]
  396. func (c *ScreenController) GetScdIedNetworkList() {
  397. scdnode := new(bo.ScdNode)
  398. scdnode.SetUserInfo(c.GetCurrentUserInfo())
  399. scdid, _ := c.GetInt64("scd_id")
  400. data, err := scdnode.GetIedNetworkInfo(scdid, c.GetString("ied_name"))
  401. if err == nil {
  402. c.Data["json"] = c.ResultOK(data, len(data))
  403. } else {
  404. c.Data["json"] = c.ResultError(err.Error())
  405. }
  406. c.ServeJSON()
  407. }
  408. // @Summary 获取IED关联关系
  409. // @Description 获取IED关联关系
  410. // @Tags SCD服务接口
  411. // @Accept x-www-form-urlencoded
  412. // @Produce json
  413. // @Param scd_id query int true "SCD文件ID"
  414. // @Param ied_name query string true "装置名称"
  415. // @router /screen/scd/ied/relation [get]
  416. func (c *ScreenController) GetScdIedRelationList() {
  417. scdnode := new(bo.ScdNode)
  418. scdnode.SetUserInfo(c.GetCurrentUserInfo())
  419. para := map[string]interface{}{}
  420. para["scd_id"] = c.GetString("scd_id")
  421. //是否重新分析.需要时传1
  422. para["reset"] = c.GetString("reset")
  423. para["ied_name"] = c.GetString("ied_name")
  424. data, err := scdnode.GetIedRelations(para)
  425. if err == nil {
  426. c.Data["json"] = c.ResultOK(data, len(data))
  427. } else {
  428. c.Data["json"] = c.ResultError(err.Error())
  429. }
  430. c.ServeJSON()
  431. }
  432. // @Summary 获取IED的虚端子关系
  433. // @Description 获取IED的虚端子关系
  434. // @Tags SCD服务接口
  435. // @Accept x-www-form-urlencoded
  436. // @Produce json
  437. // @Param scd_id query int true "SCD文件ID"
  438. // @Param ied_name query string true "主装置名称"
  439. // @Param m_ied_name query string true "输出IED装置名称"
  440. // @Param s_ied_name query string true "输入IED装置名称"
  441. // @Param m_ctrlid query string true "输出控制块ID"
  442. // @Param s_ctrlid query string true "输入控制块ID"
  443. // @router /screen/scd/ied/inputs [get]
  444. func (c *ScreenController) GetScdIedInputsRelationList() {
  445. scdnode := new(bo.ScdNode)
  446. scdnode.SetUserInfo(c.GetCurrentUserInfo())
  447. para := map[string]interface{}{}
  448. para["scd_id"] = c.GetString("scd_id")
  449. para["ied_id"] = c.GetString("ied_id")
  450. para["ied_name"] = c.GetString("ied_name")
  451. para["m_ied_name"] = c.GetString("m_ied_name") //输出IED
  452. para["s_ied_name"] = c.GetString("s_ied_name") //输入IED
  453. para["m_ctrlid"] = c.GetString("m_ctrlid") //输出控制块ID
  454. para["s_ctrlid"] = c.GetString("s_ctrlid") //输入控制块ID
  455. if para["m_ctrlid"] != "" || para["s_ctrlid"] != "" {
  456. //获取指定IED节点及控制块ID的虚端子关系
  457. data, err := scdnode.GetIedCtrlInputsRelations(para)
  458. if err == nil {
  459. c.Data["json"] = c.ResultOK(data, len(data))
  460. } else {
  461. c.Data["json"] = c.ResultError(err.Error())
  462. }
  463. } else {
  464. data, err := scdnode.GetIedInputsRelations(para)
  465. if err == nil {
  466. c.Data["json"] = c.ResultOK(data, len(data))
  467. } else {
  468. c.Data["json"] = c.ResultError(err.Error())
  469. }
  470. }
  471. c.ServeJSON()
  472. }
  473. // @Summary 获取SCD中配置的所有设备网络地址
  474. // @Description 获取SCD中配置的所有设备网络地址
  475. // @Tags SCD服务接口
  476. // @Accept x-www-form-urlencoded
  477. // @Produce json
  478. // @Param scd_id query int true "SCD文件ID"
  479. // @router /screen/scd/ied/netaddr [get]
  480. func (c *ScreenController) GetScdIedNetaddrList() {
  481. scd := new(bo.ScdMgr)
  482. scd.SetUserInfo(c.GetCurrentUserInfo())
  483. data, err := scd.GetIedNetAddr(c.GetString("scd_id"))
  484. if err == nil {
  485. c.Data["json"] = c.ResultOK(data, len(data))
  486. } else {
  487. c.Data["json"] = c.ResultError(err.Error())
  488. }
  489. c.ServeJSON()
  490. }
  491. // @Summary 获取指定IED的控制块信息
  492. // @Description 获取指定IED的控制块信息
  493. // @Tags SCD服务接口
  494. // @Accept x-www-form-urlencoded
  495. // @Produce json
  496. // @Param scd_id query int true "SCD文件ID"
  497. // @Param ied_name query string true "装置名称"
  498. // @router /screen/scd/ied/ctrlblock [get]
  499. func (c *ScreenController) GetScdIedCtrlBlockList() {
  500. scd := new(bo.ScdNode)
  501. scd.SetUserInfo(c.GetCurrentUserInfo())
  502. scdid, _ := c.GetInt64("scd_id")
  503. iedname := c.GetString("ied_name")
  504. data, err := scd.GetIedCtrlBlock(scdid, iedname)
  505. if err == nil {
  506. c.Data["json"] = c.ResultOK(data, len(data))
  507. } else {
  508. c.Data["json"] = c.ResultError(err.Error())
  509. }
  510. c.ServeJSON()
  511. }
  512. // @Summary 获取指定IED的指定SMV控制块端子列表
  513. // @Description 获取指定IED的指定SMV控制块端子列表
  514. // @Tags SCD服务接口
  515. // @Accept x-www-form-urlencoded
  516. // @Produce json
  517. // @Param scd_id query int true "SCD文件ID"
  518. // @Param ied_name query string true "装置名称"
  519. // @Param ctrlid query int true "SMV控制块ID"
  520. // @router /screen/scd/ied/smv_ctrlblock/sendfcdalist [get]
  521. func (c *ScreenController) GetScdIedSMVCtrlBlockSendFcdaList() {
  522. scd := new(bo.ScdNode)
  523. scd.SetUserInfo(c.GetCurrentUserInfo())
  524. scdid, _ := c.GetInt64("scd_id")
  525. iedname := c.GetString("ied_name")
  526. ctrlid, _ := c.GetInt64("ctrlid")
  527. data, err := scd.GetIedSMVCtrlBlockSendFcdaList(scdid, iedname, ctrlid)
  528. if err == nil {
  529. c.Data["json"] = c.ResultOK(data, len(data))
  530. } else {
  531. c.Data["json"] = c.ResultError(err.Error())
  532. }
  533. c.ServeJSON()
  534. }
  535. // @Summary 获取指定IED的指定GOOSE控制块端子列表
  536. // @Description 获取指定IED的指定GOOSE控制块端子列表
  537. // @Tags SCD服务接口
  538. // @Accept x-www-form-urlencoded
  539. // @Produce json
  540. // @Param scd_id query int true "SCD文件ID"
  541. // @Param ied_name query string true "装置名称"
  542. // @Param ctrlid query int true "GOOSE控制块ID"
  543. // @router /screen/scd/ied/goose_ctrlblock/sendfcdalist [get]
  544. func (c *ScreenController) GetScdIedGOOSECtrlBlockSendFcdaList() {
  545. scd := new(bo.ScdNode)
  546. scd.SetUserInfo(c.GetCurrentUserInfo())
  547. scdid, _ := c.GetInt64("scd_id")
  548. iedname := c.GetString("ied_name")
  549. ctrlid, _ := c.GetInt64("ctrlid")
  550. data, err := scd.GetIedGooseCtrlBlockSendFcdaList(scdid, iedname, ctrlid)
  551. if err == nil {
  552. c.Data["json"] = c.ResultOK(data, len(data))
  553. } else {
  554. c.Data["json"] = c.ResultError(err.Error())
  555. }
  556. c.ServeJSON()
  557. }
  558. // @Summary 获取指定IED的接收SMV控制块端子列表
  559. // @Description 获取指定IED的接收SMV控制块端子列表
  560. // @Tags SCD服务接口
  561. // @Accept x-www-form-urlencoded
  562. // @Produce json
  563. // @Param scd_id query int true "SCD文件ID"
  564. // @Param ied_name query string true "装置名称"
  565. // @router /screen/scd/ied/smv_ctrlblock/receive [get]
  566. func (c *ScreenController) GetScdIedSMVCtrlBlockRevFcdaList() {
  567. scd := new(bo.ScdNode)
  568. scd.SetUserInfo(c.GetCurrentUserInfo())
  569. scdid, _ := c.GetInt64("scd_id")
  570. iedname := c.GetString("ied_name")
  571. data, err := scd.GetIedSMVCtrlBlockRevList(scdid, iedname)
  572. if err == nil {
  573. c.Data["json"] = c.ResultOK(data, len(data))
  574. } else {
  575. c.Data["json"] = c.ResultError(err.Error())
  576. }
  577. c.ServeJSON()
  578. }
  579. // @Summary 获取指定IED的接收GOOSE控制块端子列表
  580. // @Description 获取指定IED的接收GOOSE控制块端子列表
  581. // @Tags SCD服务接口
  582. // @Accept x-www-form-urlencoded
  583. // @Produce json
  584. // @Param scd_id query int true "SCD文件ID"
  585. // @Param ied_name query string true "装置名称"
  586. // @router /screen/scd/ied/goose_ctrlblock/receive [get]
  587. func (c *ScreenController) GetScdIedGOOSECtrlBlockRevFcdaList() {
  588. scd := new(bo.ScdNode)
  589. scd.SetUserInfo(c.GetCurrentUserInfo())
  590. scdid, _ := c.GetInt64("scd_id")
  591. iedname := c.GetString("ied_name")
  592. data, err := scd.GetIedGooseCtrlBlockRevList(scdid, iedname)
  593. if err == nil {
  594. c.Data["json"] = c.ResultOK(data, len(data))
  595. } else {
  596. c.Data["json"] = c.ResultError(err.Error())
  597. }
  598. c.ServeJSON()
  599. }
  600. // @Summary 获取指定IED的关联IED控制块信息
  601. // @Description 获取指定IED的关联IED控制块信息
  602. // @Tags SCD服务接口
  603. // @Accept x-www-form-urlencoded
  604. // @Produce json
  605. // @Param scd_id query int true "SCD文件ID"
  606. // @Param ied_name query string true "装置名称"
  607. // @router /screen/scd/ied/ref/ctrlblock [get]
  608. func (c *ScreenController) GetScdIedRefCtrlBlockList() {
  609. scd := new(bo.ScdNode)
  610. scd.SetUserInfo(c.GetCurrentUserInfo())
  611. scdid, _ := c.GetInt64("scd_id")
  612. iedname := c.GetString("ied_name")
  613. isforce := c.GetString("forcerefresh")
  614. isforceBool := false
  615. if isforce == "1" {
  616. isforceBool = true
  617. }
  618. data, err := scd.GetIedBlockRelations(scdid, iedname, isforceBool)
  619. if err == nil {
  620. c.Data["json"] = c.ResultOK(data, len(data))
  621. } else {
  622. c.Data["json"] = c.ResultError(err.Error())
  623. }
  624. c.ServeJSON()
  625. }
  626. // @Summary 获取指定SCD的汇总统计结果
  627. // @Description 获取指定SCD的汇总统计结果
  628. // @Tags SCD服务接口
  629. // @Accept x-www-form-urlencoded
  630. // @Produce json
  631. // @Param scd_id query int true "SCD文件ID"
  632. // @router /scd/check/sum/result [get]
  633. func (c *ScreenController) GetScdCheckSumResult() {
  634. scd := new(bo.ScdNodeRule)
  635. scd.SetUserInfo(c.GetCurrentUserInfo())
  636. scdid, _ := c.GetInt("scd_id")
  637. scd.ScdID = int64(scdid)
  638. data, err := scd.SumCheckResult()
  639. if err == nil {
  640. c.Data["json"] = c.ResultOK(data, 0)
  641. } else {
  642. c.Data["json"] = c.ResultError(err.Error())
  643. }
  644. c.ServeJSON()
  645. }
  646. // @Summary 获取指定SCD的校验结果
  647. // @Description 获取指定SCD的校验结果
  648. // @Tags SCD服务接口
  649. // @Accept x-www-form-urlencoded
  650. // @Produce json
  651. // @Param scd_id query int true "SCD文件ID"
  652. // @Param pageno query int true "当前页码。默认为1"
  653. // @Param pagesize query int true "每页数据记录条数。默认为20"
  654. // @Param scd_name query string false "SCD文件名称"
  655. // @Param scd_path query string false "SCD文件名称"
  656. // @Param level query string false "校验错误级别"
  657. // @Param ied_name query string false "IED装置名称"
  658. // @Param node_name query string false "节点名称"
  659. // @Param node_id query string false "节点ID"
  660. // @router /scd/check/resultlist [get]
  661. func (c *ScreenController) GetScdCheckResultList() {
  662. scd := new(bo.ScdNodeRule)
  663. scd.SetUserInfo(c.GetCurrentUserInfo())
  664. scdid, _ := c.GetInt("scd_id")
  665. pno, _ := c.GetInt("pageno", 1)
  666. psize, _ := c.GetInt("pagesize", 20)
  667. scd.ScdID = int64(scdid)
  668. data, cnt, err := scd.ResultList(c.GetString("scd_name"),
  669. c.GetString("scd_path"),
  670. c.GetString("level"),
  671. c.GetString("ied_name"),
  672. c.GetString("node_name"),
  673. c.GetString("node_id"), pno, psize)
  674. if err == nil {
  675. c.Data["json"] = c.ResultOK(data, cnt)
  676. } else {
  677. c.Data["json"] = c.ResultError(err.Error())
  678. }
  679. c.ServeJSON()
  680. }
  681. // @Summary 按校验错误等级统计校验结果
  682. // @Description 按校验错误等级统计校验结果
  683. // @Tags SCD服务接口
  684. // @Accept x-www-form-urlencoded
  685. // @Produce json
  686. // @Param scd_id query int true "SCD文件ID"
  687. // @Param scd_name query string false "SCD文件名称"
  688. // @Param scd_path query string false "SCD文件名称"
  689. // @Param ied_name query string false "IED装置名称"
  690. // @Param node_name query string false "节点名称"
  691. // @Param node_id query string false "节点ID"
  692. // @router /scd/check/stat/level [get]
  693. func (c *ScreenController) StatScdCheckResultCnt() {
  694. scd := new(bo.ScdNodeRule)
  695. scd.SetUserInfo(c.GetCurrentUserInfo())
  696. scdid, _ := c.GetInt("scd_id")
  697. scd.ScdID = int64(scdid)
  698. data, err := scd.ResultStatByLevel(
  699. c.GetString("scd_name"),
  700. c.GetString("scd_path"),
  701. c.GetString("ied_name"),
  702. c.GetString("node_name"),
  703. c.GetString("node_id"),
  704. )
  705. if err == nil {
  706. c.Data["json"] = c.ResultOK(data, 0)
  707. } else {
  708. c.Data["json"] = c.ResultError(err.Error())
  709. }
  710. c.ServeJSON()
  711. }
  712. // @Summary 获取指定scd下的间隔信息
  713. // @Description 获取指定scd下的间隔信息
  714. // @Tags SCD服务接口
  715. // @Accept x-www-form-urlencoded
  716. // @Produce json
  717. // @Param scd_id query int true "SCD文件ID"
  718. // @Param voltage_level_id query int false "电压等级ID"
  719. // @router /scd/area/list [get]
  720. func (c *ScreenController) GetScdAreaList() {
  721. scd := new(bo.ScdAreaMgr)
  722. scd.SetUserInfo(c.GetCurrentUserInfo())
  723. scdid, _ := c.GetInt64("scd_id")
  724. vol, _ := c.GetInt32("voltage_level_id")
  725. if vol > 0 {
  726. data, err := scd.GetAreaListByVol(scdid, vol)
  727. if err == nil {
  728. c.Data["json"] = c.ResultOK(data, len(data))
  729. } else {
  730. c.Data["json"] = c.ResultError(err.Error())
  731. }
  732. c.ServeJSON()
  733. return
  734. }
  735. data, err := scd.GetAreaList(scdid)
  736. if err == nil {
  737. c.Data["json"] = c.ResultOK(data, len(data))
  738. } else {
  739. c.Data["json"] = c.ResultError(err.Error())
  740. }
  741. c.ServeJSON()
  742. }
  743. // @Summary 修改指定间隔的名称信息
  744. // @Description 修改指定间隔的名称信息
  745. // @Tags SCD服务接口
  746. // @Accept x-www-form-urlencoded
  747. // @Produce json
  748. // @Param scd_id query int true "SCD文件ID"
  749. // @Param area_id query int true "间隔ID"
  750. // @Param name query string true "间隔名称"
  751. // @router /scd/area/editname [post]
  752. func (c *ScreenController) EditScdAreaName() {
  753. scd := new(bo.ScdAreaMgr)
  754. scd.SetUserInfo(c.GetCurrentUserInfo())
  755. scdid, _ := c.GetInt64("scd_id")
  756. area_id, _ := c.GetInt("area_id")
  757. name := tools.IsEmpty(c.GetString("name"))
  758. if area_id == 0 {
  759. c.Data["json"] = c.ResultError("间隔ID不能为空")
  760. return
  761. }
  762. if name == "" {
  763. c.Data["json"] = c.ResultError("间隔名称不能为空")
  764. return
  765. }
  766. err := scd.UpdateName(scdid, area_id, name)
  767. if err == nil {
  768. c.Data["json"] = c.ResultOK("", 0)
  769. } else {
  770. c.Data["json"] = c.ResultError(err.Error())
  771. }
  772. c.ServeJSON()
  773. }
  774. // @Summary 修改指定间隔的所属电压等级
  775. // @Description 修改指定间隔的所属电压等级
  776. // @Tags SCD服务接口
  777. // @Accept x-www-form-urlencoded
  778. // @Produce json
  779. // @Param voltagelevel query int true "电压等级ID"
  780. // @Param area_id query int true "间隔ID"
  781. // @router /scd/area/edit_voltage_level [post]
  782. func (c *ScreenController) EditScdAreaVolLevel() {
  783. scd := new(bo.ScdAreaMgr)
  784. scd.SetUserInfo(c.GetCurrentUserInfo())
  785. volid, _ := c.GetInt("voltagelevel")
  786. area_id := c.GetString("area_id")
  787. if area_id == "" {
  788. c.Data["json"] = c.ResultError("间隔ID不能为空")
  789. return
  790. }
  791. if volid == 0 {
  792. c.Data["json"] = c.ResultError("电压等级ID不能为空")
  793. return
  794. }
  795. err := scd.SetVoltageLevel(area_id, volid)
  796. if err == nil {
  797. c.Data["json"] = c.ResultOK("", 0)
  798. } else {
  799. c.Data["json"] = c.ResultError(err.Error())
  800. }
  801. c.ServeJSON()
  802. }
  803. // @Summary 修改指定装置的所属间隔
  804. // @Description 修改指定装置的所属间隔
  805. // @Tags SCD服务接口
  806. // @Accept x-www-form-urlencoded
  807. // @Produce json
  808. // @Param scd_id query int true "SCD文件ID"
  809. // @Param ied_name query string true "装置名称"
  810. // @Param area_id query int true "间隔ID"
  811. // @router /scd/ied/editarea [post]
  812. func (c *ScreenController) EditScdIedArea() {
  813. scd := new(bo.ScdAreaMgr)
  814. scd.SetUserInfo(c.GetCurrentUserInfo())
  815. scd_id, _ := c.GetInt64("scd_id")
  816. area_id, _ := c.GetInt("area_id")
  817. if area_id == 0 {
  818. c.Data["json"] = c.ResultError("间隔ID不能为空")
  819. return
  820. }
  821. iedname := c.GetString("ied_name")
  822. if iedname == "" {
  823. c.Data["json"] = c.ResultError("IED装置名称不能为空")
  824. return
  825. }
  826. err := scd.UpdateIedArea(scd_id, iedname, area_id)
  827. if err == nil {
  828. c.Data["json"] = c.ResultOK("", 0)
  829. } else {
  830. c.Data["json"] = c.ResultError(err.Error())
  831. }
  832. c.ServeJSON()
  833. }
  834. // @Summary 获取指定间隔下的IED信息
  835. // @Description 获取指定间隔下的IED信息
  836. // @Tags SCD服务接口
  837. // @Accept x-www-form-urlencoded
  838. // @Produce json
  839. // @Param scd_id query int true "SCD文件ID"
  840. // @Param voltage_level_id query int false "电压等级ID"
  841. // @Param area_id query int false "间隔ID"
  842. // @Param device_type_id query string false "装置类型ID。关联系统字典:device_type"
  843. // @router /scd/area/ied/list [get]
  844. func (c *ScreenController) GetScdAreaIedList() {
  845. scdid, _ := c.GetInt64("scd_id")
  846. areaid, _ := c.GetInt32("area_id")
  847. voltage_level_id, _ := c.GetInt32("voltage_level_id")
  848. device_type := c.GetString("device_type_id")
  849. scd := new(bo.ScdAreaMgr)
  850. scd.SetUserInfo(c.GetCurrentUserInfo())
  851. data, err := scd.GetIedList(scdid, voltage_level_id, areaid, device_type)
  852. if err == nil {
  853. c.Data["json"] = c.ResultOK(data, 0)
  854. } else {
  855. c.Data["json"] = c.ResultError(err.Error())
  856. }
  857. c.ServeJSON()
  858. }
  859. // @Summary 获取指定SCD下的IED类型信息
  860. // @Description 获取指定SCD下的IED类型信息
  861. // @Tags SCD服务接口
  862. // @Accept x-www-form-urlencoded
  863. // @Produce json
  864. // @Param scd_id query int true "SCD文件ID"
  865. // @router /scd/ied/typelist [get]
  866. func (c *ScreenController) GetScdIedTypeList() {
  867. scdid, _ := c.GetInt64("scd_id")
  868. scd := new(bo.ScdAreaMgr)
  869. scd.SetUserInfo(c.GetCurrentUserInfo())
  870. data, err := scd.GetIedTypeList(scdid)
  871. if err == nil {
  872. c.Data["json"] = c.ResultOK(data, 0)
  873. } else {
  874. c.Data["json"] = c.ResultError(err.Error())
  875. }
  876. c.ServeJSON()
  877. }
  878. // @Summary 获取指定IED的定值条目
  879. // @Description 获取指定IED的定值条目
  880. // @Tags SCD服务接口
  881. // @Accept x-www-form-urlencoded
  882. // @Produce json
  883. // @Param scd_id query int true "SCD文件ID"
  884. // @Param ied_name query string true "IED装置名称"
  885. // @router /screen/scd/ied/dingzhi [get]
  886. func (c *ScreenController) GetScdIedDingzhiList() {
  887. scdid, _ := c.GetInt64("scd_id")
  888. ied_name := c.GetString("ied_name")
  889. scd := new(bo.ScdNode)
  890. scd.SetUserInfo(c.GetCurrentUserInfo())
  891. data, err := scd.GetScdIedDingzhiList(scdid, ied_name)
  892. if err == nil {
  893. c.Data["json"] = c.ResultOK(data, 0)
  894. } else {
  895. c.Data["json"] = c.ResultError(err.Error())
  896. }
  897. c.ServeJSON()
  898. }
  899. // @Summary 获取指定IED的信息点表
  900. // @Description 获取指定IED的定值条目
  901. // @Tags SCD服务接口
  902. // @Accept x-www-form-urlencoded
  903. // @Produce json
  904. // @Param scd_id query int true "SCD文件ID"
  905. // @Param ied_name query string true "IED装置名称"
  906. // @router /screen/scd/ied/pointtable [get]
  907. func (c *ScreenController) GetScdIedPointTableList() {
  908. scdid, _ := c.GetInt64("scd_id")
  909. ied_name := c.GetString("ied_name")
  910. scd := new(bo.ScdNode)
  911. scd.SetUserInfo(c.GetCurrentUserInfo())
  912. data, err := scd.GetScdIedPointTableList(scdid, ied_name)
  913. if err == nil {
  914. c.Data["json"] = c.ResultOK(data, 0)
  915. } else {
  916. c.Data["json"] = c.ResultError(err.Error())
  917. }
  918. c.ServeJSON()
  919. }
  920. // @Summary 获取指定IED的源XML
  921. // @Description 获取指定IED的源XML
  922. // @Tags SCD服务接口
  923. // @Accept x-www-form-urlencoded
  924. // @Produce json
  925. // @Param scd_id query int true "SCD文件ID"
  926. // @Param ied_name query string true "IED装置名称"
  927. // @router /screen/scd/ied/sourcexml [get]
  928. func (c *ScreenController) GetScdIedSourceXML() {
  929. scdid, _ := c.GetInt64("scd_id")
  930. ied_name := c.GetString("ied_name")
  931. scd := new(bo.ScdNode)
  932. scd.SetUserInfo(c.GetCurrentUserInfo())
  933. data, err := scd.GetScdIedSourceXML(scdid, ied_name)
  934. if err == nil {
  935. c.Data["json"] = c.ResultOK(data, 0)
  936. } else {
  937. c.Data["json"] = c.ResultError(err.Error())
  938. }
  939. c.ServeJSON()
  940. }
  941. // @Summary 获取指定行号的源XML
  942. // @Description 获取指定行号的源XML,每次获取指定行的前后各100行源数据
  943. // @Tags SCD服务接口
  944. // @Accept x-www-form-urlencoded
  945. // @Produce json
  946. // @Param scd_id query int true "SCD文件ID"
  947. // @Param lineno query int true "行号"
  948. // @router /screen/scd/line/sourcexml [get]
  949. func (c *ScreenController) GetScdLineSourceXML() {
  950. scdid, _ := c.GetInt64("scd_id")
  951. lineno, _ := c.GetInt64("lineno")
  952. scd := new(bo.ScdNode)
  953. scd.SetUserInfo(c.GetCurrentUserInfo())
  954. data, err := scd.GetScdLineSourceXML(scdid, lineno)
  955. if err == nil {
  956. c.Data["json"] = c.ResultOK(data, 0)
  957. } else {
  958. c.Data["json"] = c.ResultError(err.Error())
  959. }
  960. c.ServeJSON()
  961. }
  962. // @Summary 获取指定scd的crc校验结果
  963. // @Description 获取指定scd的crc校验结果
  964. // @Tags SCD服务接口
  965. // @Accept x-www-form-urlencoded
  966. // @Produce json
  967. // @Param scd_id query int true "SCD文件ID"
  968. // @router /screen/scd/crc [get]
  969. func (c *ScreenController) GetScdIedCrc() {
  970. scdid := c.GetString("scd_id")
  971. if scdid == "" {
  972. c.Data["json"] = c.ResultError("无效的SCD编号")
  973. c.ServeJSON()
  974. return
  975. }
  976. scdXmlObj, _ := new(bo.ScdParse).GetScdXmlObjectBySCDID(scdid)
  977. if scdXmlObj == nil {
  978. c.Data["json"] = c.ResultError("无效的SCD")
  979. c.ServeJSON()
  980. return
  981. }
  982. scdmgr := new(bo.ScdMgr)
  983. _, err := scdmgr.CrcCheck(scdid)
  984. if err != nil {
  985. c.Data["json"] = c.ResultError(err.Error())
  986. c.ServeJSON()
  987. return
  988. }
  989. crclist, _ := global.CachedScdCrc.Load(fmt.Sprintf("crc_%s", scdid))
  990. crclist2 := crclist.(map[string]string)
  991. crcresult := map[string]interface{}{}
  992. itemobj := map[string]string{
  993. "checkcrc": crclist2["scdcrc"],
  994. "scdcrc": "",
  995. }
  996. //获取scd文件的校验码
  997. for _, pri := range scdXmlObj.Private {
  998. if pri.Type == "Substation virtual terminal conection CRC" {
  999. itemobj["scdcrc"] = pri.InnerText
  1000. break
  1001. }
  1002. }
  1003. crcresult["scdcrc"] = itemobj
  1004. itemlist := []map[string]interface{}{}
  1005. for _, iedobj := range scdXmlObj.IED {
  1006. itemobj := map[string]interface{}{}
  1007. itemobj["iedname"] = iedobj.Name
  1008. itemobj["ieddesc"] = iedobj.Desc
  1009. itemobj["manufacturer"] = iedobj.Manufacturer
  1010. itemobj["iedversion"] = iedobj.ConfigVersion
  1011. itemobj["type"] = iedobj.Type
  1012. if v, h := crclist2[iedobj.Name]; h {
  1013. itemobj["checkcrc"] = v
  1014. }
  1015. for _, pri := range iedobj.Priavate {
  1016. if pri.Type == "IED virtual terminal conection CRC" {
  1017. itemobj["scdcrc"] = pri.InnerText
  1018. break
  1019. }
  1020. }
  1021. itemlist = append(itemlist, itemobj)
  1022. }
  1023. crcresult["list"] = itemlist
  1024. c.Data["json"] = c.ResultOK(crcresult, 0)
  1025. c.ServeJSON()
  1026. }