screenController.go 30 KB

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