/* * @Author: liling * @Date: 2022-10-29 * @LastEditors: liling * @LastEditTime: 2022-10-29 * @FilePath: \SCD\controllers\statController.go * @Description:统计分析相关对外API * * Copyright (c) 2022 by liling/jujutong, All Rights Reserved. */ package controllers import ( "scd_check_tools/models/bo" "scd_check_tools/tools" ) //统计分析服务 type StatController struct { BaseController } func init() { } //scd正确性分析 // @Summary scd正确性分析 // @Description scd正确性分析 // @Tags 统计分析服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param station_id query int true "变电站ID" // @Success 200 {object} ResultOK 成功 // @Success 200 {object} ResultError 错误 // @Failure 500 status 失败 // @router /scd/stat/right [get] func (c *StatController) ScdRightStat() { stationidLst := []string{} stationid := c.GetString("station_id") if stationid == "" { enableOrgCode, _ := bo.GetSysParamValue("xrootcode", "") us := c.GetCurrentUserInfo() areaObject := new(bo.BasicArea) areaObject.SetUserInfo(us) pageIndex, _ := c.GetInt("pageindex", 1) pageSize, _ := c.GetInt("pagesize", 1000) areaObject.Model.Pid, _ = c.GetInt("pid", -1) areaObject.Model.AreaName = c.GetString("name", "") areaObject.Model.AreaKind = c.GetString("area_kind", "") areaObject.Model.AreaType = c.GetString("area_type", enableOrgCode) //只查询变电站类型的区域 areaObject.Model.AreaLevel, _ = c.GetInt("area_level", 0) areaObject.Model.Id, _ = c.GetInt("id", 0) tableData, _, err := areaObject.SearchArea(pageIndex, pageSize) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } for _, stationRow := range tableData { stationidLst = append(stationidLst, tools.IsEmpty(stationRow["id"])) } } else { stationidLst = append(stationidLst, stationid) } scdRuleObj := new(bo.ScdNodeRule) scdRuleObj.SetUserInfo(c.GetCurrentUserInfo()) result := map[string]interface{}{} for _, sid := range stationidLst { rightReate, err := scdRuleObj.RightRateStat(sid) if err != nil { continue } result[sid] = rightReate } c.Data["json"] = c.ResultOK(result, 0) c.ServeJSON() } //资料完整度统计 // @Summary 资料完整度统计 // @Description 资料完整度统计 // @Tags 统计分析服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param id query int false "区域ID" // @Success 200 {object} ResultOK 成功 // @Success 200 {object} ResultError 错误 // @Failure 500 status 失败 // @router /doc/stat/1 [get] func (c *StatController) DocTypeStat0001() { enableOrgCode, _ := bo.GetSysParamValue("xrootcode", "") us := c.GetCurrentUserInfo() areaObject := new(bo.BasicArea) areaObject.SetUserInfo(us) pageIndex, _ := c.GetInt("pageindex", 1) pageSize, _ := c.GetInt("pagesize", 1000) areaObject.Model.Pid, _ = c.GetInt("pid", -1) areaObject.Model.AreaName = c.GetString("name", "") areaObject.Model.AreaKind = c.GetString("area_kind", "") areaObject.Model.AreaType = c.GetString("area_type", enableOrgCode+"01") areaObject.Model.AreaLevel, _ = c.GetInt("area_level", 0) areaObject.Model.Id, _ = c.GetInt("id", 0) tableData, _, err := areaObject.SearchArea(pageIndex, pageSize) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } scdObj := new(bo.ScdMgr) docObj := new(bo.AttachmentMgr) scdObj.SetUserInfo(us) docObj.SetUserInfo(us) for _, stationRow := range tableData { stationid := tools.IsEmpty(stationRow["id"]) //获取当前站的iED总数 iedCnt, err2 := scdObj.IedTotal(stationid) if err2 != nil { err = err2 break } stationRow["ied_cnt"] = iedCnt //统计当前站的文档分类情况 param := map[string]interface{}{} param["stationid"] = stationid list, err2 := docObj.TypeStat(param) if err2 != nil { err = err2 break } stationRow["doc"] = list } if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK(tableData, 0) c.ServeJSON() } //文档 分类统计 // @Summary SCD文档分类统计 // @Description SCD文档分类统计 // @Tags 统计分析服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param station_id query int false "变电站ID" // @Success 200 {object} ResultOK 成功 // @Success 200 {object} ResultError 错误 // @Failure 500 status 失败 // @router /attachment/stat [get] func (c *StatController) DocTypeStat() { stationid := c.GetString("station_id") pageno, _ := c.GetInt("pageno", 1) pagesize, _ := c.GetInt("pagesize", 20) lastid, _ := c.GetInt("lastid", 0) param := map[string]interface{}{} param["station_id"] = stationid param["pageno"] = pageno param["pagesize"] = pagesize param["lastid"] = lastid flowObj := new(bo.AttachmentMgr) flowObj.SetUserInfo(c.GetCurrentUserInfo()) list, err := flowObj.TypeStat(param) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK(list, 0) c.ServeJSON() } //装置分类统计 // @Summary SCD装置分类统计 // @Description SCD装置分类统计 // @Tags 统计分析服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param station_id query int false "变电站ID" // @Success 200 {object} ResultOK 成功 // @Success 200 {object} ResultError 错误 // @Failure 500 status 失败 // @router /ied/stat [get] func (c *StatController) IedTypeStat() { stationid := c.GetString("station_id") pageno, _ := c.GetInt("pageno", 1) pagesize, _ := c.GetInt("pagesize", 20) lastid, _ := c.GetInt("lastid", 0) param := map[string]interface{}{} param["station_id"] = stationid param["pageno"] = pageno param["pagesize"] = pagesize param["lastid"] = lastid flowObj := new(bo.ScdMgr) flowObj.SetUserInfo(c.GetCurrentUserInfo()) list, err := flowObj.IedStat(param) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK(list, 0) c.ServeJSON() } /** * @description: 获取所有站的签入签出完成列表 * @Author: liling * @method: get * @parameter: stationid,pageno,pagesize * @url: /flow/stat/list * @content-type: application/json * @return json格式 */ // @Summary SCD签入签出统计 // @Description SCD签入签出统计 // @Tags 统计分析服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param station_id query int false "变电站ID" // @Success 200 {object} ResultOK 成功 // @Success 200 {object} ResultError 错误 // @Failure 500 status 失败 // @router /flow/stat/list [get] func (c *StatController) GetFlowFinsihList() { stationid := c.GetString("station_id") pageno, _ := c.GetInt("pageno", 1) pagesize, _ := c.GetInt("pagesize", 20) lastid, _ := c.GetInt("lastid", 0) param := map[string]interface{}{} param["stationid"] = stationid param["pageno"] = pageno param["pagesize"] = pagesize param["lastid"] = lastid flowObj := new(bo.Flow) flowObj.SetUserInfo(c.GetCurrentUserInfo()) list, err := flowObj.GetFinishedRecordList(param) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK(list, 0) c.ServeJSON() }