/* * @Author: lilig * @Date: 2022-09-17 10:07:52 * @LastEditors: lilifor * @LastEditTime: 2022-09-17 14:44:58 * @FilePath: \SCD\controllers\wsController.go * @Description: * * Copyright (c) 2022 by lilig/jujutong, All Rights Reserved. */ package controllers import ( "scd_check_tools/models/bo" ) //签入签出流程服务 type FlowController struct { BaseController } func init() { } /** * @description: 获取流程配置信息 * @Author: liling * @method: get * @parameter: station_id,flow_type * @url: /cnf/getinfo * @content-type: application/json * @return json格式 */ // @Summary 获取流程配置信息 // @Description 获取流程配置信息 // @Tags 签入签出流程服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param station_id query string true "变电站ID" // @Param flow_type query string false "流程类型。值为:3(SCD签入)、4(SCD签出)之一" // @Param userfilter query string false "是否需要根据当前登录人员进行节点过滤,为1表示需要,主要用于流转时获取节点列表;否则为获取全节点,主要用于后台配置" // @Success 200 {object} ResultOK 成功 // @Failure 500 {object} ResultError 失败 // @router /flow/cnf/getinfo [get] func (c *FlowController) GetFlowCnf() { //变电站ID station_id, _ := c.GetInt64("station_id") //流程类型。同一流程类型只能启用一个流程配置 flow_type := c.GetString("flow_type") userfilter := c.GetString("userfilter") //是否需要根据当前登录人员进行节点过滤 if station_id == 0 { c.Data["json"] = c.ResultError("变电站ID不能为空!") c.ServeJSON() return } if flow_type == "" { c.Data["json"] = c.ResultError("流程类型不能为空!") c.ServeJSON() return } flowObj := new(bo.Flow) flowObj.SetUserInfo(c.GetCurrentUserInfo()) rowset, err := flowObj.FlowConfigList(station_id, flow_type, userfilter) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK(rowset, len(rowset)) c.ServeJSON() } /** * @description: 保存流程配置信息 * @Author: liling * @method: post * @parameter: station_id,node_id,user_ids,node_inst_id * @url: /node/refuser * @content-type: application/json * @return json格式 */ // @Summary 保存流程配置信息 // @Description 保存流程配置信息 // @Tags 签入签出流程服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param station_id formData string true "变电站ID" // @Param node_id formData string true "节点编号ID" // @Param user_ids formData string true "有该节点权限的人员ID列表,多个ID之间用逗号分隔" // @Param node_inst_id formData string false "节点与人员的分配记录ID" // @Success 200 {object} ResultOK 成功 // @Failure 500 {object} ResultError 失败 // @router /flow/node/refuser [post] func (c *FlowController) SaveFlowCnf_NodeUser() { //变电站ID station_id := c.GetString("station_id") user_ids := c.GetString("user_ids") node_id := c.GetString("node_id") if station_id == "" { c.Data["json"] = c.ResultError("变电站ID不能为空!") c.ServeJSON() return } if node_id == "" { c.Data["json"] = c.ResultError("节点编号不能为空!") c.ServeJSON() return } if user_ids == "" { c.Data["json"] = c.ResultError("人员编号不能为空!") c.ServeJSON() return } flowObj := new(bo.Flow) flowObj.SetUserInfo(c.GetCurrentUserInfo()) err := flowObj.SaveNodeUserRelation(station_id, node_id, c.GetString("node_inst_id"), user_ids) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK("", 0) c.ServeJSON() } /** * @description: 删除指定流程的节点人员配置信息 * @Author: liling * @method: post * @parameter: user_id,node_inst_id * @url: /cnf/deleteuser * @content-type: application/json * @return json格式 */ // @Summary 删除指定流程的节点人员配置信息 // @Description 删除指定流程的节点人员配置信息 // @Tags 签入签出流程服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param user_id formData string true "节点已分配的人员ID" // @Param node_inst_id formData string true "节点与人员的分配记录ID" // @Success 200 {object} ResultOK 成功 // @Failure 500 {object} ResultError 失败 // @router /flow/cnf/deleteuser [post] func (c *FlowController) DeleteFlowCnf_NodeUser() { user_id := c.GetString("user_id") node_inst_id := c.GetString("node_inst_id") if node_inst_id == "" { c.Data["json"] = c.ResultError("节点编号不能为空!") c.ServeJSON() return } if user_id == "" { c.Data["json"] = c.ResultError("人员编号不能为空!") c.ServeJSON() return } flowObj := new(bo.Flow) flowObj.SetUserInfo(c.GetCurrentUserInfo()) err := flowObj.DeletNodeUser(node_inst_id, user_id) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK("", 0) c.ServeJSON() } /** * @description: 获取指定站的锁定签入签出流程记录列表 * @Author: liling * @method: get * @parameter: stationid * @url: /lock/list * @content-type: application/json * @return json格式 */ // @Summary 获取指定站的锁定流程记录列表 // @Description 获取指定站的锁定流程记录列表 // @Tags 签入签出流程服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param station_id query string true "变电站ID" // @Success 200 {object} ResultOK 成功 // @Failure 500 {object} ResultError 失败 // @router /flow/lock/list [get] func (c *FlowController) GetFlowLockList() { stationid := c.GetString("station_id") if stationid == "" { c.Data["json"] = c.ResultError("变电站编号不能为空!") c.ServeJSON() return } flowObj := new(bo.ScdMgr) flowObj.SetUserInfo(c.GetCurrentUserInfo()) list, err := flowObj.GetCheckoutLockScd(stationid) 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 station_id query string true "变电站ID" // @Success 200 {object} ResultOK 成功 // @Failure 500 {object} ResultError 失败 // @router /flow/getlastoutworkbook [get] func (c *FlowController) GetLastCheckoutWorkbook() { stationid := c.GetString("station_id") if stationid == "" { c.Data["json"] = c.ResultError("变电站编号不能为空!") c.ServeJSON() return } flowObj := new(bo.Flow) flowObj.SetUserInfo(c.GetCurrentUserInfo()) list, err := flowObj.GetLastCheckoutWorkbook(stationid) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK(list, len(list)) c.ServeJSON() } /** * @description: 获取指定站的签入签出流程记录列表 * @Author: liling * @method: get * @parameter: stationid,pageno,pagesize * @url: /cnf/deleteuser * @content-type: application/json * @return json格式 */ // @Summary 获取指定站的签入签出流程记录列表 // @Description 获取指定站的签入签出流程记录列表 // @Tags 签入签出流程服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param station_id query string true "变电站ID" // @Param pageno query int true "当前页码,默认为1" // @Param pagesize query int true "每页记录条数,默认为20" // @Param dt1 query string false "查询条件:开始日期" // @Param dt2 query string false "查询条件:结束日期" // @Param name query string false "查询条件:SCD名称。模糊匹配" // @Param flowtype query string false "查询条件:流程类型,值为:3(SCD签入)、4(SCD签出)之一" // @Param flowstate query string false "查询条件:流程状态,值为:0 处理中 1 结束 2 驳回之一" // @Success 200 {object} ResultOK 成功 // @Failure 500 {object} ResultError 失败 // @router /flow/run/list [get] func (c *FlowController) GetFlowRunList() { stationid := c.GetString("station_id") pageno, _ := c.GetInt("pageno", 1) pagesize, _ := c.GetInt("pagesize", 20) if stationid == "" { c.Data["json"] = c.ResultError("变电站编号不能为空!") c.ServeJSON() return } param := map[string]interface{}{} param["stationid"] = stationid param["dt1"] = c.GetString("dt1") param["dt2"] = c.GetString("dt2") param["name"] = c.GetString("name") param["flowtype"] = c.GetString("flowtype") param["flowstate"] = c.GetString("flowstate") param["pageno"] = pageno param["pagesize"] = pagesize flowObj := new(bo.Flow) flowObj.SetUserInfo(c.GetCurrentUserInfo()) list, num, err := flowObj.GetInoutRecordList(param) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK(list, num) c.ServeJSON() } /** * @description: 保存指定站的签入签出数据 * @Author: liling * @method: post * @parameter: flow_run_id,station_id,flow_type,node_code,content * @url: /cnf/deleteuser * @content-type: application/json * @return json格式 */ // @Summary 保存指定站的签入签出节点信息 // @Description 保存指定站的签入签出节点信息 // @Tags 签入签出流程服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param station_id formData string true "变电站ID" // @Param node_code formData string true "节点编号。值为:checkinstart 编制,checkincheck 校验,checkinaudit 审核,checkinend 发布,checkoutstart 签出,checkoutcheck 校核,checkoutend 审核之一" // @Param content formData string true "节点填录的所有信息,为JSON对象序列化后的字符串。" // @Param flow_run_id formData int true "流程ID" // @Param opt formData string false "操作类型。1 通过 0 驳回" // @Param flow_type formData string false "流程类型,值为:3(SCD签入)、4(SCD签出)之一" // @Success 200 {object} ResultOK 成功 // @Failure 500 {object} ResultError 失败 // @router /flow/run/nodedeal/save [post] func (c *FlowController) SaveNodeDealInfo() { stationid := c.GetString("station_id") node_code := c.GetString("node_code") content := c.GetString("content") flow_run_id := c.GetString("flow_run_id") flow_type := c.GetString("flow_type") if stationid == "" { c.Data["json"] = c.ResultError("变电站编号不能为空!") c.ServeJSON() return } if node_code == "" { c.Data["json"] = c.ResultError("节点编号不能为空!") c.ServeJSON() return } opt, _ := c.GetInt("opt", 1) //节点操作:1 通过 0 驳回 flowObj := new(bo.Flow) flowObj.SetUserInfo(c.GetCurrentUserInfo()) err := flowObj.SaveNodeDealInfo(flow_type, flow_run_id, stationid, node_code, content, opt) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK("", 0) c.ServeJSON() } /** * @description: 获取指定站的签入签出节点数据 * @Author: liling * @method: post * @parameter: flow_run_id,station_id,flow_type,node_code * @url: /cnf/deleteuser * @content-type: application/json * @return json格式 */ // @Summary 获取指节点的详细数据 // @Description 获取指节点的详细数据 // @Tags 签入签出流程服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param station_id query string true "变电站ID" // @Param node_code query string true "节点编号。值为:checkinstart 编制,checkincheck 校验,checkinaudit 审核,checkinend 发布,checkoutstart 签出,checkoutcheck 校核,checkoutend 审核之一" // @Param flow_run_id query int true "流程ID" // @Param flow_type query string false "流程类型,值为:3(SCD签入)、4(SCD签出)之一" // @Success 200 {object} ResultOK 成功 // @Failure 500 {object} ResultError 失败 // @router /flow/node/getdata [get] func (c *FlowController) GetNodeDealInfo() { stationid := c.GetString("station_id") node_code := c.GetString("node_code") flow_run_id := c.GetString("flow_run_id") flow_type := c.GetString("flow_type") if stationid == "" { c.Data["json"] = c.ResultError("变电站编号不能为空!") c.ServeJSON() return } if node_code == "" { c.Data["json"] = c.ResultError("节点编号不能为空!") c.ServeJSON() return } flowObj := new(bo.Flow) flowObj.SetUserInfo(c.GetCurrentUserInfo()) lst, err := flowObj.GetNodeDealInfo(flow_type, flow_run_id, stationid, node_code) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK(lst, 1) c.ServeJSON() } /** * @description: 获取指定站的指定scd的签入详情 * @Author: liling * @method: get * @parameter: station_id,scd_name,scd_path * @url: /scd_check_tools/checkin/detail * @content-type: application/json * @return json格式 */ // @Summary 获取指定站的指定scd的签入详情 // @Description 获取指定站的指定scd的签入详情 // @Tags 签入签出流程服务接口 // @Accept x-www-form-urlencoded // @Produce json // @Param station_id query string true "变电站ID" // @Param scd_name query string false "SCD名称" // @Param scd_path query string false "SCD文件路径" // @Param scd_id query string false "SCD文件ID。为空时scd_name和scd_path必填" // @Success 200 {object} ResultOK 成功 // @Failure 500 {object} ResultError 失败 // @router /scd_check_tools/checkin/detail [get] func (c *FlowController) GetScdInDetailInfo() { stationid := c.GetString("station_id") scd_name := c.GetString("scd_name") scd_path := c.GetString("scd_path") scd_id := c.GetString("scd_id") if stationid == "" { c.Data["json"] = c.ResultError("变电站编号不能为空!") c.ServeJSON() return } if scd_id == "" { if scd_name == "" || scd_path == "" { c.Data["json"] = c.ResultError("SCD名称和路径不能为空!") c.ServeJSON() return } } flowObj := new(bo.Flow) flowObj.SetUserInfo(c.GetCurrentUserInfo()) lst, err := flowObj.GetCheckinWorkbook(stationid, scd_id, scd_name, scd_path) if err != nil { c.Data["json"] = c.ResultError(err.Error()) c.ServeJSON() return } c.Data["json"] = c.ResultOK(lst, 1) c.ServeJSON() }