123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- /*
- * @Author: lilig
- * @Date: 2022-09-17 10:07:52
- * @LastEditors: lilifor
- * @LastEditTime: 2022-09-17 14:44:58
- * @FilePath: \SCD\controllers\scdCompController.go
- * @Description:
- *
- * Copyright (c) 2022 by lilig/jujutong, All Rights Reserved.
- */
- package controllers
- import (
- "scd_check_tools/models/bo"
- "strings"
- )
- //一致性校验服务
- type ScdCompController struct {
- BaseController
- }
- func init() {
- }
- // @Summary 获取SCD校验对象树
- // @Description 获取SCD校验对象树
- // @Tags 一致性校验服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param scd_id query int true "SCD文件ID"
- // @Param id query int false "对象ID"
- // @Param pid query int false "上级对象ID"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 status 失败
- // @router /scd/comp/tree [get]
- func (c *ScdCompController) GetCheckToolsTreeRoot() {
- scdnode := new(bo.ScdCompare)
- scdnode.Userinfo = c.GetCurrentUserInfo()
- scd_id, _ := c.GetInt64("scd_id")
- id, _ := c.GetInt64("id")
- pid, _ := c.GetInt64("pid")
- data, err := scdnode.GetCheckToolsTreeRoot(scd_id, id, pid, c.GetString("datatype"))
- if err == nil {
- c.Data["json"] = c.ResultOK(data, 0)
- } else {
- c.Data["json"] = c.ResultError(err.Error())
- }
- c.ServeJSON()
- }
- /**
- * @description: 获取指定站的差异对比记录列表
- * @Author: liling
- * @method: get
- * @parameter: stationid
- * @url: /api/notice/list
- * @content-type: application/json
- * @return json格式
- */
- // @Summary 获取指定变电站的差异对比记录列表
- // @Description 获取指定变电站的差异对比记录列表
- // @Tags 一致性校验服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param station_id query int true "变电站ID"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 status 失败
- // @router /scd/comp/list [get]
- func (c *ScdCompController) GetCompList() {
- stationid, _ := c.GetInt("station_id")
- flowObj := new(bo.ScdCompare)
- flowObj.StationId = stationid
- flowObj.Userinfo = c.GetCurrentUserInfo()
- list, err := flowObj.List()
- if err != nil {
- c.Data["json"] = c.ResultError(err.Error())
- c.ServeJSON()
- return
- }
- c.Data["json"] = c.ResultOK(list, len(list))
- c.ServeJSON()
- }
- // @Summary 获取指定差异对比的详细结果列表
- // @Description 获取指定差异对比的详细结果列表
- // @Tags 一致性校验服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param comp_id query int true "差异比对记录ID"
- // @Param ied_name query string false "装置名称"
- // @Param itemcode query string false "差异对象类型代码"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 status 失败
- // @router /scd/comp/result [get]
- func (c *ScdCompController) GetResult() {
- compid, _ := c.GetInt("comp_id")
- iedname := c.GetString("ied_name")
- comptype := c.GetString("comptype")
- item := c.GetString("itemcode")
- if compid == 0 {
- c.Data["json"] = c.ResultError("差异校验记录编号不能为空!")
- c.ServeJSON()
- return
- }
- flowObj := new(bo.ScdCompare)
- flowObj.Userinfo = c.GetCurrentUserInfo()
- list, err := flowObj.GetCompItemDetailInfo(compid, iedname, comptype, item)
- if err != nil {
- c.Data["json"] = c.ResultError(err.Error())
- c.ServeJSON()
- return
- }
- c.Data["json"] = c.ResultOK(list, 0)
- c.ServeJSON()
- }
- // @Summary 指定装置差异对比结果分类统计
- // @Description 指定装置差异对比结果分类统计
- // @Tags 一致性校验服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param comp_id query int true "差异比对记录ID"
- // @Param ied_name query string false "装置名称"
- // @Param comptype query string false "差异类别。值为:i|d|u之一"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 status 失败
- // @router /scd/comp/iedstat/type [get]
- func (c *ScdCompController) GetCompIedStatTypeResult() {
- comp := new(bo.ScdCompare)
- comp.Userinfo = c.GetCurrentUserInfo()
- compid, _ := c.GetInt("comp_id")
- ied_name := c.GetString("ied_name")
- if compid == 0 {
- c.Data["json"] = c.ResultError("差异校验记录编号不能为空!")
- c.ServeJSON()
- return
- }
- if ied_name == "" {
- c.Data["json"] = c.ResultError("装置name不能为空!")
- c.ServeJSON()
- return
- }
- comptype := c.GetString("comptype")
- lst, err := comp.SumCompareTypeResult(compid, ied_name, comptype)
- if err != nil {
- c.Data["json"] = c.ResultError(err.Error())
- c.ServeJSON()
- return
- }
- c.Data["json"] = c.ResultOK(lst, len(lst))
- c.ServeJSON()
- }
- //scd差异对比结果概览统计
- // @Summary 获取scd差异对比结果概览统计
- // @Description 获取scd差异对比结果概览统计
- // @Tags 一致性校验服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param comp_id query int true "差异比对记录ID"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 status 失败
- // @router /scd/comp/stat/result [get]
- func (c *ScdCompController) GetCompStatResult() {
- comp := new(bo.ScdCompare)
- comp.Userinfo = c.GetCurrentUserInfo()
- compid, _ := c.GetInt("comp_id")
- lst, err := comp.SumCompareResult(compid)
- if err != nil {
- c.Data["json"] = c.ResultError(err.Error())
- c.ServeJSON()
- return
- }
- c.Data["json"] = c.ResultOK(lst, len(lst))
- c.ServeJSON()
- }
- // @Summary 开始scd差异对比
- // @Description 开始scd差异对比
- // @Tags 一致性校验服务接口
- // @Accept x-www-form-urlencoded
- // @Produce json
- // @Param type query string true "对比的文件类型。值为scd\ccd\cid\ccd_cid_scd\icd_scd之一。"
- // @Param comp_id query int false "差异比对记录ID。不为空或0时表示重新比对差异"
- // @Param station_id query int true "变电站ID"
- // @Param source_scd_id query int false "对比的基准SCD文件ID。type为scd时必填。"
- // @Param target_scd_id query int false "对比的参照SCD文件ID。type为scd时必填。"
- // @Param ids query string false "如果是2个非SCD对比文件时,需要对比的文件ID列表,使用逗号分隔。仅当type为ccd\cid\ccd_cid_scd\icd_scd时有效"
- // @Success 200 {object} ResultOK 成功
- // @Failure 500 status 失败
- // @router /scd/comp/start [post]
- func (c *ScdCompController) Compare() {
- comp := new(bo.ScdCompare)
- comp.Userinfo = c.GetCurrentUserInfo()
- comp.CompareType = strings.ToUpper(c.GetString("type", "SCD"))
- comp.Sourceid, _ = c.GetInt64("source_scd_id")
- comp.Targetid, _ = c.GetInt64("target_scd_id")
- comp.StationId, _ = c.GetInt("station_id")
- ids := c.GetString("ids")
- if comp.CompareType != "SCD" && ids == "" {
- c.Data["json"] = c.ResultError("无效的校验参数:ids")
- c.ServeJSON()
- return
- }
- if comp.Sourceid == 0 {
- c.Data["json"] = c.ResultError("无效的校验参数:source_scd_id")
- c.ServeJSON()
- return
- }
- if ids != "" {
- comp.CompFileIds = strings.Split(ids, ",")
- }
- compid, _ := c.GetInt("comp_id")
- err := comp.Compare(compid)
- if err != nil {
- c.Data["json"] = c.ResultError(err.Error())
- c.ServeJSON()
- return
- }
- if comp.CompareBaseInfo == nil || len(comp.CompareBaseInfo) == 0 {
- c.Data["json"] = c.ResultOK(comp.CompareResultList, len(comp.CompareResultList))
- } else {
- c.Data["json"] = c.ResultOK(map[string]interface{}{"list": comp.CompareResultList, "info": comp.CompareBaseInfo}, len(comp.CompareResultList))
- }
- c.ServeJSON()
- }
|