scdCompController.go 7.6 KB

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