scdCompController.go 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. * @Author: lilig
  3. * @Date: 2022-09-17 10:07:52
  4. * @LastEditors: lilifor
  5. * @LastEditTime: 2022-09-17 14:44:58
  6. * @FilePath: \SCD\controllers\scdCompController.go
  7. * @Description:
  8. *
  9. * Copyright (c) 2022 by lilig/jujutong, All Rights Reserved.
  10. */
  11. package controllers
  12. import (
  13. "scd_check_tools/models/bo"
  14. "strings"
  15. )
  16. //一致性校验服务
  17. type ScdCompController struct {
  18. BaseController
  19. }
  20. func init() {
  21. }
  22. // @Summary 获取SCD校验对象树
  23. // @Description 获取SCD校验对象树
  24. // @Tags 一致性校验服务接口
  25. // @Accept x-www-form-urlencoded
  26. // @Produce json
  27. // @Param scd_id query int true "SCD文件ID"
  28. // @Param id query int false "对象ID"
  29. // @Param pid query int false "上级对象ID"
  30. // @Success 200 {object} ResultOK 成功
  31. // @Failure 500 status 失败
  32. // @router /scd/comp/tree [get]
  33. func (c *ScdCompController) GetCheckToolsTreeRoot() {
  34. scdnode := new(bo.ScdCompare)
  35. scdnode.Userinfo = c.GetCurrentUserInfo()
  36. scd_id, _ := c.GetInt64("scd_id")
  37. id, _ := c.GetInt64("id")
  38. pid, _ := c.GetInt64("pid")
  39. data, err := scdnode.GetCheckToolsTreeRoot(scd_id, id, pid, c.GetString("datatype"))
  40. if err == nil {
  41. c.Data["json"] = c.ResultOK(data, 0)
  42. } else {
  43. c.Data["json"] = c.ResultError(err.Error())
  44. }
  45. c.ServeJSON()
  46. }
  47. /**
  48. * @description: 获取指定站的差异对比记录列表
  49. * @Author: liling
  50. * @method: get
  51. * @parameter: stationid
  52. * @url: /api/notice/list
  53. * @content-type: application/json
  54. * @return json格式
  55. */
  56. // @Summary 获取指定变电站的差异对比记录列表
  57. // @Description 获取指定变电站的差异对比记录列表
  58. // @Tags 一致性校验服务接口
  59. // @Accept x-www-form-urlencoded
  60. // @Produce json
  61. // @Param station_id query int true "变电站ID"
  62. // @Param scd_id query int false "SCD文件ID"
  63. // @Success 200 {object} ResultOK 成功
  64. // @Failure 500 status 失败
  65. // @router /scd/comp/list [get]
  66. func (c *ScdCompController) GetCompList() {
  67. stationid, _ := c.GetInt("station_id")
  68. scdid, _ := c.GetInt64("scd_id")
  69. flowObj := new(bo.ScdCompare)
  70. flowObj.StationId = stationid
  71. flowObj.Sourceid = scdid
  72. flowObj.Userinfo = c.GetCurrentUserInfo()
  73. list, err := flowObj.List()
  74. if err != nil {
  75. c.Data["json"] = c.ResultError(err.Error())
  76. c.ServeJSON()
  77. return
  78. }
  79. c.Data["json"] = c.ResultOK(list, len(list))
  80. c.ServeJSON()
  81. }
  82. // @Summary 获取指定差异对比的详细结果列表
  83. // @Description 获取指定差异对比的详细结果列表
  84. // @Tags 一致性校验服务接口
  85. // @Accept x-www-form-urlencoded
  86. // @Produce json
  87. // @Param comp_id query int true "差异比对记录ID"
  88. // @Param ied_name query string false "装置名称"
  89. // @Param itemcode query string false "差异对象类型代码"
  90. // @Success 200 {object} ResultOK 成功
  91. // @Failure 500 status 失败
  92. // @router /scd/comp/result [get]
  93. func (c *ScdCompController) GetResult() {
  94. compid, _ := c.GetInt("comp_id")
  95. iedname := c.GetString("ied_name")
  96. comptype := c.GetString("comptype")
  97. item := c.GetString("itemcode")
  98. if compid == 0 {
  99. c.Data["json"] = c.ResultError("差异校验记录编号不能为空!")
  100. c.ServeJSON()
  101. return
  102. }
  103. flowObj := new(bo.ScdCompare)
  104. flowObj.Userinfo = c.GetCurrentUserInfo()
  105. list, err := flowObj.GetCompItemDetailInfo(compid, iedname, comptype, item)
  106. if err != nil {
  107. c.Data["json"] = c.ResultError(err.Error())
  108. c.ServeJSON()
  109. return
  110. }
  111. c.Data["json"] = c.ResultOK(list, 0)
  112. c.ServeJSON()
  113. }
  114. // @Summary 指定装置差异对比结果分类统计
  115. // @Description 指定装置差异对比结果分类统计
  116. // @Tags 一致性校验服务接口
  117. // @Accept x-www-form-urlencoded
  118. // @Produce json
  119. // @Param comp_id query int true "差异比对记录ID"
  120. // @Param ied_name query string false "装置名称"
  121. // @Param comptype query string false "差异类别。值为:i|d|u之一"
  122. // @Success 200 {object} ResultOK 成功
  123. // @Failure 500 status 失败
  124. // @router /scd/comp/iedstat/type [get]
  125. func (c *ScdCompController) GetCompIedStatTypeResult() {
  126. comp := new(bo.ScdCompare)
  127. comp.Userinfo = c.GetCurrentUserInfo()
  128. compid, _ := c.GetInt("comp_id")
  129. ied_name := c.GetString("ied_name")
  130. if compid == 0 {
  131. c.Data["json"] = c.ResultError("差异校验记录编号不能为空!")
  132. c.ServeJSON()
  133. return
  134. }
  135. if ied_name == "" {
  136. c.Data["json"] = c.ResultError("装置name不能为空!")
  137. c.ServeJSON()
  138. return
  139. }
  140. comptype := c.GetString("comptype")
  141. lst, err := comp.SumCompareTypeResult(compid, ied_name, comptype)
  142. if err != nil {
  143. c.Data["json"] = c.ResultError(err.Error())
  144. c.ServeJSON()
  145. return
  146. }
  147. c.Data["json"] = c.ResultOK(lst, len(lst))
  148. c.ServeJSON()
  149. }
  150. //scd差异对比结果概览统计
  151. // @Summary 获取scd差异对比结果概览统计
  152. // @Description 获取scd差异对比结果概览统计
  153. // @Tags 一致性校验服务接口
  154. // @Accept x-www-form-urlencoded
  155. // @Produce json
  156. // @Param comp_id query int true "差异比对记录ID"
  157. // @Success 200 {object} ResultOK 成功
  158. // @Failure 500 status 失败
  159. // @router /scd/comp/stat/result [get]
  160. func (c *ScdCompController) GetCompStatResult() {
  161. comp := new(bo.ScdCompare)
  162. comp.Userinfo = c.GetCurrentUserInfo()
  163. compid, _ := c.GetInt("comp_id")
  164. lst, err := comp.SumCompareResult(compid)
  165. if err != nil {
  166. c.Data["json"] = c.ResultError(err.Error())
  167. c.ServeJSON()
  168. return
  169. }
  170. c.Data["json"] = c.ResultOK(lst, len(lst))
  171. c.ServeJSON()
  172. }
  173. // @Summary 开始scd差异对比
  174. // @Description 开始scd差异对比
  175. // @Tags 一致性校验服务接口
  176. // @Accept x-www-form-urlencoded
  177. // @Produce json
  178. // @Param type query string true "对比的文件类型。值为scd\ccd\cid\ccd_cid_scd\icd_scd之一。"
  179. // @Param comp_id query int false "差异比对记录ID。不为空或0时表示重新比对差异"
  180. // @Param station_id query int true "变电站ID"
  181. // @Param source_scd_id query int true "对比的基准SCD文件ID。type为scd时必填。"
  182. // @Param target_scd_id query int false "对比的参照SCD文件ID。type为scd时必填。"
  183. // @Param ids query string false "非SCD对比对象列表,默认2个元素,第一个为装置name(基准对象),第二个为文件id(对比文件)。如果是2个非SCD对比文件时,需要对比的装置name或文件ID列表,使用逗号分隔。仅当type为ccd\cid\ccd_cid_scd\icd_scd时有效"
  184. // @Success 200 {object} ResultOK 成功
  185. // @Failure 500 status 失败
  186. // @router /scd/comp/start [post]
  187. func (c *ScdCompController) Compare() {
  188. comp := new(bo.ScdCompare)
  189. comp.Userinfo = c.GetCurrentUserInfo()
  190. comp.CompareType = strings.ToUpper(c.GetString("type", "SCD"))
  191. comp.Sourceid, _ = c.GetInt64("source_scd_id")
  192. comp.Targetid, _ = c.GetInt64("target_scd_id")
  193. comp.StationId, _ = c.GetInt("station_id")
  194. ids := c.GetString("ids")
  195. if comp.CompareType != "SCD" && ids == "" {
  196. c.Data["json"] = c.ResultError("无效的校验参数:ids")
  197. c.ServeJSON()
  198. return
  199. }
  200. if comp.Sourceid == 0 {
  201. c.Data["json"] = c.ResultError("无效的校验参数:source_scd_id")
  202. c.ServeJSON()
  203. return
  204. }
  205. if ids != "" {
  206. comp.CompFileIds = strings.Split(ids, ",")
  207. }
  208. compid, _ := c.GetInt("comp_id")
  209. err := comp.Compare(compid)
  210. if err != nil {
  211. c.Data["json"] = c.ResultError(err.Error())
  212. c.ServeJSON()
  213. return
  214. }
  215. if comp.CompareBaseInfo == nil || len(comp.CompareBaseInfo) == 0 {
  216. c.Data["json"] = c.ResultOK(comp.CompareResultList, len(comp.CompareResultList))
  217. } else {
  218. c.Data["json"] = c.ResultOK(map[string]interface{}{"list": comp.CompareResultList, "info": comp.CompareBaseInfo}, len(comp.CompareResultList))
  219. }
  220. c.ServeJSON()
  221. }