statController.go 7.3 KB

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