screenController.go 34 KB

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