statController.go 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * @Author: liling
  3. * @Date: 2022-10-29
  4. * @LastEditors: liling
  5. * @LastEditTime: 2022-10-29
  6. * @FilePath: \SCD\controllers\statController.go
  7. * @Description:统计分析相关对外API
  8. *
  9. * Copyright (c) 2022 by liling/jujutong, All Rights Reserved.
  10. */
  11. package controllers
  12. import (
  13. "scd_check_tools/models/bo"
  14. "scd_check_tools/tools"
  15. )
  16. type StatController struct {
  17. BaseController
  18. }
  19. func init() {
  20. }
  21. //scd正确性分析
  22. // @Summary scd正确性分析
  23. // @Description scd正确性分析
  24. // @Tags 统计分析服务接口
  25. // @Accept x-www-form-urlencoded
  26. // @Produce json
  27. // @Param station_id query int true "变电站ID"
  28. // @Success 200 {object} ResultOK 成功
  29. // @Success 200 {object} ResultError 错误
  30. // @Failure 500 status 失败
  31. // @router /scd_check_tools/stat/right [get]
  32. func (c *StatController) ScdRightStat() {
  33. stationidLst := []string{}
  34. stationid := c.GetString("station_id")
  35. if stationid == "" {
  36. enableOrgCode, _ := bo.GetSysParamValue("xrootcode", "")
  37. us := c.GetCurrentUserInfo()
  38. areaObject := new(bo.BasicArea)
  39. areaObject.SetUserInfo(us)
  40. pageIndex, _ := c.GetInt("pageindex", 1)
  41. pageSize, _ := c.GetInt("pagesize", 1000)
  42. areaObject.Model.Pid, _ = c.GetInt("pid", -1)
  43. areaObject.Model.AreaName = c.GetString("name", "")
  44. areaObject.Model.AreaKind = c.GetString("area_kind", "")
  45. areaObject.Model.AreaType = c.GetString("area_type", enableOrgCode) //只查询变电站类型的区域
  46. areaObject.Model.AreaLevel, _ = c.GetInt("area_level", 0)
  47. areaObject.Model.Id, _ = c.GetInt("id", 0)
  48. tableData, _, err := areaObject.SearchArea(pageIndex, pageSize)
  49. if err != nil {
  50. c.Data["json"] = c.ResultError(err.Error())
  51. c.ServeJSON()
  52. return
  53. }
  54. for _, stationRow := range tableData {
  55. stationidLst = append(stationidLst, tools.IsEmpty(stationRow["id"]))
  56. }
  57. } else {
  58. stationidLst = append(stationidLst, stationid)
  59. }
  60. scdRuleObj := new(bo.ScdNodeRule)
  61. scdRuleObj.SetUserInfo(c.GetCurrentUserInfo())
  62. result := map[string]interface{}{}
  63. for _, sid := range stationidLst {
  64. rightReate, err := scdRuleObj.RightRateStat(sid)
  65. if err != nil {
  66. continue
  67. }
  68. result[sid] = rightReate
  69. }
  70. c.Data["json"] = c.ResultOK(result, 0)
  71. c.ServeJSON()
  72. }
  73. //资料完整度统计
  74. // @Summary 资料完整度统计
  75. // @Description 资料完整度统计
  76. // @Tags 统计分析服务接口
  77. // @Accept x-www-form-urlencoded
  78. // @Produce json
  79. // @Param id query int false "区域ID"
  80. // @Success 200 {object} ResultOK 成功
  81. // @Success 200 {object} ResultError 错误
  82. // @Failure 500 status 失败
  83. // @router /doc/stat/1 [get]
  84. func (c *StatController) DocTypeStat0001() {
  85. enableOrgCode, _ := bo.GetSysParamValue("xrootcode", "")
  86. us := c.GetCurrentUserInfo()
  87. areaObject := new(bo.BasicArea)
  88. areaObject.SetUserInfo(us)
  89. pageIndex, _ := c.GetInt("pageindex", 1)
  90. pageSize, _ := c.GetInt("pagesize", 1000)
  91. areaObject.Model.Pid, _ = c.GetInt("pid", -1)
  92. areaObject.Model.AreaName = c.GetString("name", "")
  93. areaObject.Model.AreaKind = c.GetString("area_kind", "")
  94. areaObject.Model.AreaType = c.GetString("area_type", enableOrgCode+"01")
  95. areaObject.Model.AreaLevel, _ = c.GetInt("area_level", 0)
  96. areaObject.Model.Id, _ = c.GetInt("id", 0)
  97. tableData, _, err := areaObject.SearchArea(pageIndex, pageSize)
  98. if err != nil {
  99. c.Data["json"] = c.ResultError(err.Error())
  100. c.ServeJSON()
  101. return
  102. }
  103. scdObj := new(bo.ScdMgr)
  104. docObj := new(bo.AttachmentMgr)
  105. scdObj.SetUserInfo(us)
  106. docObj.SetUserInfo(us)
  107. for _, stationRow := range tableData {
  108. stationid := tools.IsEmpty(stationRow["id"])
  109. //获取当前站的iED总数
  110. iedCnt, err2 := scdObj.IedTotal(stationid)
  111. if err2 != nil {
  112. err = err2
  113. break
  114. }
  115. stationRow["ied_cnt"] = iedCnt
  116. //统计当前站的文档分类情况
  117. param := map[string]interface{}{}
  118. param["stationid"] = stationid
  119. list, err2 := docObj.TypeStat(param)
  120. if err2 != nil {
  121. err = err2
  122. break
  123. }
  124. stationRow["doc"] = list
  125. }
  126. if err != nil {
  127. c.Data["json"] = c.ResultError(err.Error())
  128. c.ServeJSON()
  129. return
  130. }
  131. c.Data["json"] = c.ResultOK(tableData, 0)
  132. c.ServeJSON()
  133. }
  134. //文档 分类统计
  135. // @Summary SCD文档分类统计
  136. // @Description SCD文档分类统计
  137. // @Tags 统计分析服务接口
  138. // @Accept x-www-form-urlencoded
  139. // @Produce json
  140. // @Param station_id query int false "变电站ID"
  141. // @Success 200 {object} ResultOK 成功
  142. // @Success 200 {object} ResultError 错误
  143. // @Failure 500 status 失败
  144. // @router /attachment/stat [get]
  145. func (c *StatController) DocTypeStat() {
  146. stationid := c.GetString("station_id")
  147. pageno, _ := c.GetInt("pageno", 1)
  148. pagesize, _ := c.GetInt("pagesize", 20)
  149. lastid, _ := c.GetInt("lastid", 0)
  150. param := map[string]interface{}{}
  151. param["station_id"] = stationid
  152. param["pageno"] = pageno
  153. param["pagesize"] = pagesize
  154. param["lastid"] = lastid
  155. flowObj := new(bo.AttachmentMgr)
  156. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  157. list, err := flowObj.TypeStat(param)
  158. if err != nil {
  159. c.Data["json"] = c.ResultError(err.Error())
  160. c.ServeJSON()
  161. return
  162. }
  163. c.Data["json"] = c.ResultOK(list, 0)
  164. c.ServeJSON()
  165. }
  166. //装置分类统计
  167. // @Summary SCD装置分类统计
  168. // @Description SCD装置分类统计
  169. // @Tags 统计分析服务接口
  170. // @Accept x-www-form-urlencoded
  171. // @Produce json
  172. // @Param station_id query int false "变电站ID"
  173. // @Success 200 {object} ResultOK 成功
  174. // @Success 200 {object} ResultError 错误
  175. // @Failure 500 status 失败
  176. // @router /ied/stat [get]
  177. func (c *StatController) IedTypeStat() {
  178. stationid := c.GetString("station_id")
  179. pageno, _ := c.GetInt("pageno", 1)
  180. pagesize, _ := c.GetInt("pagesize", 20)
  181. lastid, _ := c.GetInt("lastid", 0)
  182. param := map[string]interface{}{}
  183. param["station_id"] = stationid
  184. param["pageno"] = pageno
  185. param["pagesize"] = pagesize
  186. param["lastid"] = lastid
  187. flowObj := new(bo.ScdMgr)
  188. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  189. list, err := flowObj.IedStat(param)
  190. if err != nil {
  191. c.Data["json"] = c.ResultError(err.Error())
  192. c.ServeJSON()
  193. return
  194. }
  195. c.Data["json"] = c.ResultOK(list, 0)
  196. c.ServeJSON()
  197. }
  198. /**
  199. * @description: 获取所有站的签入签出完成列表
  200. * @Author: liling
  201. * @method: get
  202. * @parameter: stationid,pageno,pagesize
  203. * @url: /flow/stat/list
  204. * @content-type: application/json
  205. * @return json格式
  206. */
  207. // @Summary SCD签入签出统计
  208. // @Description SCD签入签出统计
  209. // @Tags 统计分析服务接口
  210. // @Accept x-www-form-urlencoded
  211. // @Produce json
  212. // @Param station_id query int false "变电站ID"
  213. // @Success 200 {object} ResultOK 成功
  214. // @Success 200 {object} ResultError 错误
  215. // @Failure 500 status 失败
  216. // @router /flow/stat/list [get]
  217. func (c *StatController) GetFlowFinsihList() {
  218. stationid := c.GetString("station_id")
  219. pageno, _ := c.GetInt("pageno", 1)
  220. pagesize, _ := c.GetInt("pagesize", 20)
  221. lastid, _ := c.GetInt("lastid", 0)
  222. param := map[string]interface{}{}
  223. param["stationid"] = stationid
  224. param["pageno"] = pageno
  225. param["pagesize"] = pagesize
  226. param["lastid"] = lastid
  227. flowObj := new(bo.Flow)
  228. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  229. list, err := flowObj.GetFinishedRecordList(param)
  230. if err != nil {
  231. c.Data["json"] = c.ResultError(err.Error())
  232. c.ServeJSON()
  233. return
  234. }
  235. c.Data["json"] = c.ResultOK(list, 0)
  236. c.ServeJSON()
  237. }