scdCompController.go 7.5 KB

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