flowController.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. /*
  2. * @Author: lilig
  3. * @Date: 2022-09-17 10:07:52
  4. * @LastEditors: lilifor
  5. * @LastEditTime: 2022-09-17 14:44:58
  6. * @FilePath: \SCD\controllers\wsController.go
  7. * @Description:
  8. *
  9. * Copyright (c) 2022 by lilig/jujutong, All Rights Reserved.
  10. */
  11. package controllers
  12. import (
  13. "scd_check_tools/models/bo"
  14. )
  15. type FlowController struct {
  16. BaseController
  17. }
  18. func init() {
  19. }
  20. /**
  21. * @description: 获取流程配置信息
  22. * @Author: liling
  23. * @method: get
  24. * @parameter: station_id,flow_type
  25. * @url: /cnf/getinfo
  26. * @content-type: application/json
  27. * @return json格式
  28. */
  29. // @Summary 获取流程配置信息
  30. // @Description 获取流程配置信息
  31. // @Tags 签入签出流程服务接口
  32. // @Accept x-www-form-urlencoded
  33. // @Produce json
  34. // @Param station_id query string true "变电站ID"
  35. // @Param flow_type query string false "流程类型。值为:3(SCD签入)、4(SCD签出)之一"
  36. // @Param userfilter query string false "是否需要根据当前登录人员进行节点过滤,为1表示需要,主要用于流转时获取节点列表;否则为获取全节点,主要用于后台配置"
  37. // @Success 200 {object} ResultOK 成功
  38. // @Failure 500 {object} ResultError 失败
  39. // @router /flow/cnf/getinfo [get]
  40. func (c *FlowController) GetFlowCnf() {
  41. //变电站ID
  42. station_id, _ := c.GetInt64("station_id")
  43. //流程类型。同一流程类型只能启用一个流程配置
  44. flow_type := c.GetString("flow_type")
  45. userfilter := c.GetString("userfilter") //是否需要根据当前登录人员进行节点过滤
  46. if station_id == 0 {
  47. c.Data["json"] = c.ResultError("变电站ID不能为空!")
  48. c.ServeJSON()
  49. return
  50. }
  51. if flow_type == "" {
  52. c.Data["json"] = c.ResultError("流程类型不能为空!")
  53. c.ServeJSON()
  54. return
  55. }
  56. flowObj := new(bo.Flow)
  57. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  58. rowset, err := flowObj.FlowConfigList(station_id, flow_type, userfilter)
  59. if err != nil {
  60. c.Data["json"] = c.ResultError(err.Error())
  61. c.ServeJSON()
  62. return
  63. }
  64. c.Data["json"] = c.ResultOK(rowset, len(rowset))
  65. c.ServeJSON()
  66. }
  67. /**
  68. * @description: 保存流程配置信息
  69. * @Author: liling
  70. * @method: post
  71. * @parameter: station_id,node_id,user_ids,node_inst_id
  72. * @url: /node/refuser
  73. * @content-type: application/json
  74. * @return json格式
  75. */
  76. // @Summary 保存流程配置信息
  77. // @Description 保存流程配置信息
  78. // @Tags 签入签出流程服务接口
  79. // @Accept x-www-form-urlencoded
  80. // @Produce json
  81. // @Param station_id formData string true "变电站ID"
  82. // @Param node_id formData string true "节点编号ID"
  83. // @Param user_ids formData string true "有该节点权限的人员ID列表,多个ID之间用逗号分隔"
  84. // @Param node_inst_id formData string false "节点与人员的分配记录ID"
  85. // @Success 200 {object} ResultOK 成功
  86. // @Failure 500 {object} ResultError 失败
  87. // @router /flow/node/refuser [post]
  88. func (c *FlowController) SaveFlowCnf_NodeUser() {
  89. //变电站ID
  90. station_id := c.GetString("station_id")
  91. user_ids := c.GetString("user_ids")
  92. node_id := c.GetString("node_id")
  93. if station_id == "" {
  94. c.Data["json"] = c.ResultError("变电站ID不能为空!")
  95. c.ServeJSON()
  96. return
  97. }
  98. if node_id == "" {
  99. c.Data["json"] = c.ResultError("节点编号不能为空!")
  100. c.ServeJSON()
  101. return
  102. }
  103. if user_ids == "" {
  104. c.Data["json"] = c.ResultError("人员编号不能为空!")
  105. c.ServeJSON()
  106. return
  107. }
  108. flowObj := new(bo.Flow)
  109. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  110. err := flowObj.SaveNodeUserRelation(station_id, node_id, c.GetString("node_inst_id"), user_ids)
  111. if err != nil {
  112. c.Data["json"] = c.ResultError(err.Error())
  113. c.ServeJSON()
  114. return
  115. }
  116. c.Data["json"] = c.ResultOK("", 0)
  117. c.ServeJSON()
  118. }
  119. /**
  120. * @description: 删除指定流程的节点人员配置信息
  121. * @Author: liling
  122. * @method: post
  123. * @parameter: user_id,node_inst_id
  124. * @url: /cnf/deleteuser
  125. * @content-type: application/json
  126. * @return json格式
  127. */
  128. // @Summary 删除指定流程的节点人员配置信息
  129. // @Description 删除指定流程的节点人员配置信息
  130. // @Tags 签入签出流程服务接口
  131. // @Accept x-www-form-urlencoded
  132. // @Produce json
  133. // @Param user_id formData string true "节点已分配的人员ID"
  134. // @Param node_inst_id formData string true "节点与人员的分配记录ID"
  135. // @Success 200 {object} ResultOK 成功
  136. // @Failure 500 {object} ResultError 失败
  137. // @router /flow/cnf/deleteuser [post]
  138. func (c *FlowController) DeleteFlowCnf_NodeUser() {
  139. user_id := c.GetString("user_id")
  140. node_inst_id := c.GetString("node_inst_id")
  141. if node_inst_id == "" {
  142. c.Data["json"] = c.ResultError("节点编号不能为空!")
  143. c.ServeJSON()
  144. return
  145. }
  146. if user_id == "" {
  147. c.Data["json"] = c.ResultError("人员编号不能为空!")
  148. c.ServeJSON()
  149. return
  150. }
  151. flowObj := new(bo.Flow)
  152. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  153. err := flowObj.DeletNodeUser(node_inst_id, user_id)
  154. if err != nil {
  155. c.Data["json"] = c.ResultError(err.Error())
  156. c.ServeJSON()
  157. return
  158. }
  159. c.Data["json"] = c.ResultOK("", 0)
  160. c.ServeJSON()
  161. }
  162. /**
  163. * @description: 获取指定站的锁定签入签出流程记录列表
  164. * @Author: liling
  165. * @method: get
  166. * @parameter: stationid
  167. * @url: /lock/list
  168. * @content-type: application/json
  169. * @return json格式
  170. */
  171. // @Summary 获取指定站的锁定流程记录列表
  172. // @Description 获取指定站的锁定流程记录列表
  173. // @Tags 签入签出流程服务接口
  174. // @Accept x-www-form-urlencoded
  175. // @Produce json
  176. // @Param station_id query string true "变电站ID"
  177. // @Success 200 {object} ResultOK 成功
  178. // @Failure 500 {object} ResultError 失败
  179. // @router /flow/lock/list [get]
  180. func (c *FlowController) GetFlowLockList() {
  181. stationid := c.GetString("station_id")
  182. if stationid == "" {
  183. c.Data["json"] = c.ResultError("变电站编号不能为空!")
  184. c.ServeJSON()
  185. return
  186. }
  187. flowObj := new(bo.ScdMgr)
  188. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  189. list, err := flowObj.GetCheckoutLockScd(stationid)
  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, len(list))
  196. c.ServeJSON()
  197. }
  198. // @Summary 获取指定站最新签出流程详细信息
  199. // @Description 获取指定站最新签出流程详细信息
  200. // @Tags 签入签出流程服务接口
  201. // @Accept x-www-form-urlencoded
  202. // @Produce json
  203. // @Param station_id query string true "变电站ID"
  204. // @Success 200 {object} ResultOK 成功
  205. // @Failure 500 {object} ResultError 失败
  206. // @router /flow/getlastoutworkbook [get]
  207. func (c *FlowController) GetLastCheckoutWorkbook() {
  208. stationid := c.GetString("station_id")
  209. if stationid == "" {
  210. c.Data["json"] = c.ResultError("变电站编号不能为空!")
  211. c.ServeJSON()
  212. return
  213. }
  214. flowObj := new(bo.Flow)
  215. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  216. list, err := flowObj.GetLastCheckoutWorkbook(stationid)
  217. if err != nil {
  218. c.Data["json"] = c.ResultError(err.Error())
  219. c.ServeJSON()
  220. return
  221. }
  222. c.Data["json"] = c.ResultOK(list, len(list))
  223. c.ServeJSON()
  224. }
  225. /**
  226. * @description: 获取指定站的签入签出流程记录列表
  227. * @Author: liling
  228. * @method: get
  229. * @parameter: stationid,pageno,pagesize
  230. * @url: /cnf/deleteuser
  231. * @content-type: application/json
  232. * @return json格式
  233. */
  234. // @Summary 获取指定站的签入签出流程记录列表
  235. // @Description 获取指定站的签入签出流程记录列表
  236. // @Tags 签入签出流程服务接口
  237. // @Accept x-www-form-urlencoded
  238. // @Produce json
  239. // @Param station_id query string true "变电站ID"
  240. // @Param pageno query int true "当前页码,默认为1"
  241. // @Param pagesize query int true "每页记录条数,默认为20"
  242. // @Param dt1 query string false "查询条件:开始日期"
  243. // @Param dt2 query string false "查询条件:结束日期"
  244. // @Param name query string false "查询条件:SCD名称。模糊匹配"
  245. // @Param flowtype query string false "查询条件:流程类型,值为:3(SCD签入)、4(SCD签出)之一"
  246. // @Param flowstate query string false "查询条件:流程状态,值为:0 处理中 1 结束 2 驳回之一"
  247. // @Success 200 {object} ResultOK 成功
  248. // @Failure 500 {object} ResultError 失败
  249. // @router /flow/run/list [get]
  250. func (c *FlowController) GetFlowRunList() {
  251. stationid := c.GetString("station_id")
  252. pageno, _ := c.GetInt("pageno", 1)
  253. pagesize, _ := c.GetInt("pagesize", 20)
  254. if stationid == "" {
  255. c.Data["json"] = c.ResultError("变电站编号不能为空!")
  256. c.ServeJSON()
  257. return
  258. }
  259. param := map[string]interface{}{}
  260. param["stationid"] = stationid
  261. param["dt1"] = c.GetString("dt1")
  262. param["dt2"] = c.GetString("dt2")
  263. param["name"] = c.GetString("name")
  264. param["flowtype"] = c.GetString("flowtype")
  265. param["flowstate"] = c.GetString("flowstate")
  266. param["pageno"] = pageno
  267. param["pagesize"] = pagesize
  268. flowObj := new(bo.Flow)
  269. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  270. list, num, err := flowObj.GetInoutRecordList(param)
  271. if err != nil {
  272. c.Data["json"] = c.ResultError(err.Error())
  273. c.ServeJSON()
  274. return
  275. }
  276. c.Data["json"] = c.ResultOK(list, num)
  277. c.ServeJSON()
  278. }
  279. /**
  280. * @description: 保存指定站的签入签出数据
  281. * @Author: liling
  282. * @method: post
  283. * @parameter: flow_run_id,station_id,flow_type,node_code,content
  284. * @url: /cnf/deleteuser
  285. * @content-type: application/json
  286. * @return json格式
  287. */
  288. // @Summary 保存指定站的签入签出节点信息
  289. // @Description 保存指定站的签入签出节点信息
  290. // @Tags 签入签出流程服务接口
  291. // @Accept x-www-form-urlencoded
  292. // @Produce json
  293. // @Param station_id formData string true "变电站ID"
  294. // @Param node_code formData string true "节点编号。值为:checkinstart 编制,checkincheck 校验,checkinaudit 审核,checkinend 发布,checkoutstart 签出,checkoutcheck 校核,checkoutend 审核之一"
  295. // @Param content formData string true "节点填录的所有信息,为JSON对象序列化后的字符串。"
  296. // @Param flow_run_id formData int true "流程ID"
  297. // @Param opt formData string false "操作类型。1 通过 0 驳回"
  298. // @Param flow_type formData string false "流程类型,值为:3(SCD签入)、4(SCD签出)之一"
  299. // @Success 200 {object} ResultOK 成功
  300. // @Failure 500 {object} ResultError 失败
  301. // @router /flow/run/nodedeal/save [post]
  302. func (c *FlowController) SaveNodeDealInfo() {
  303. stationid := c.GetString("station_id")
  304. node_code := c.GetString("node_code")
  305. content := c.GetString("content")
  306. flow_run_id := c.GetString("flow_run_id")
  307. flow_type := c.GetString("flow_type")
  308. if stationid == "" {
  309. c.Data["json"] = c.ResultError("变电站编号不能为空!")
  310. c.ServeJSON()
  311. return
  312. }
  313. if node_code == "" {
  314. c.Data["json"] = c.ResultError("节点编号不能为空!")
  315. c.ServeJSON()
  316. return
  317. }
  318. opt, _ := c.GetInt("opt", 1) //节点操作:1 通过 0 驳回
  319. flowObj := new(bo.Flow)
  320. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  321. err := flowObj.SaveNodeDealInfo(flow_type, flow_run_id, stationid, node_code, content, opt)
  322. if err != nil {
  323. c.Data["json"] = c.ResultError(err.Error())
  324. c.ServeJSON()
  325. return
  326. }
  327. c.Data["json"] = c.ResultOK("", 0)
  328. c.ServeJSON()
  329. }
  330. /**
  331. * @description: 获取指定站的签入签出节点数据
  332. * @Author: liling
  333. * @method: post
  334. * @parameter: flow_run_id,station_id,flow_type,node_code
  335. * @url: /cnf/deleteuser
  336. * @content-type: application/json
  337. * @return json格式
  338. */
  339. // @Summary 获取指节点的详细数据
  340. // @Description 获取指节点的详细数据
  341. // @Tags 签入签出流程服务接口
  342. // @Accept x-www-form-urlencoded
  343. // @Produce json
  344. // @Param station_id query string true "变电站ID"
  345. // @Param node_code query string true "节点编号。值为:checkinstart 编制,checkincheck 校验,checkinaudit 审核,checkinend 发布,checkoutstart 签出,checkoutcheck 校核,checkoutend 审核之一"
  346. // @Param flow_run_id query int true "流程ID"
  347. // @Param flow_type query string false "流程类型,值为:3(SCD签入)、4(SCD签出)之一"
  348. // @Success 200 {object} ResultOK 成功
  349. // @Failure 500 {object} ResultError 失败
  350. // @router /flow/node/getdata [get]
  351. func (c *FlowController) GetNodeDealInfo() {
  352. stationid := c.GetString("station_id")
  353. node_code := c.GetString("node_code")
  354. flow_run_id := c.GetString("flow_run_id")
  355. flow_type := c.GetString("flow_type")
  356. if stationid == "" {
  357. c.Data["json"] = c.ResultError("变电站编号不能为空!")
  358. c.ServeJSON()
  359. return
  360. }
  361. if node_code == "" {
  362. c.Data["json"] = c.ResultError("节点编号不能为空!")
  363. c.ServeJSON()
  364. return
  365. }
  366. flowObj := new(bo.Flow)
  367. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  368. lst, err := flowObj.GetNodeDealInfo(flow_type, flow_run_id, stationid, node_code)
  369. if err != nil {
  370. c.Data["json"] = c.ResultError(err.Error())
  371. c.ServeJSON()
  372. return
  373. }
  374. c.Data["json"] = c.ResultOK(lst, 1)
  375. c.ServeJSON()
  376. }
  377. /**
  378. * @description: 获取指定站的指定scd的签入详情
  379. * @Author: liling
  380. * @method: get
  381. * @parameter: station_id,scd_name,scd_path
  382. * @url: /scd_check_tools/checkin/detail
  383. * @content-type: application/json
  384. * @return json格式
  385. */
  386. // @Summary 获取指定站的指定scd的签入详情
  387. // @Description 获取指定站的指定scd的签入详情
  388. // @Tags 签入签出流程服务接口
  389. // @Accept x-www-form-urlencoded
  390. // @Produce json
  391. // @Param station_id query string true "变电站ID"
  392. // @Param scd_name query string false "SCD名称"
  393. // @Param scd_path query string false "SCD文件路径"
  394. // @Param scd_id query string false "SCD文件ID。为空时scd_name和scd_path必填"
  395. // @Success 200 {object} ResultOK 成功
  396. // @Failure 500 {object} ResultError 失败
  397. // @router /scd_check_tools/checkin/detail [get]
  398. func (c *FlowController) GetScdInDetailInfo() {
  399. stationid := c.GetString("station_id")
  400. scd_name := c.GetString("scd_name")
  401. scd_path := c.GetString("scd_path")
  402. scd_id := c.GetString("scd_id")
  403. if stationid == "" {
  404. c.Data["json"] = c.ResultError("变电站编号不能为空!")
  405. c.ServeJSON()
  406. return
  407. }
  408. if scd_id == "" {
  409. if scd_name == "" || scd_path == "" {
  410. c.Data["json"] = c.ResultError("SCD名称和路径不能为空!")
  411. c.ServeJSON()
  412. return
  413. }
  414. }
  415. flowObj := new(bo.Flow)
  416. flowObj.SetUserInfo(c.GetCurrentUserInfo())
  417. lst, err := flowObj.GetCheckinWorkbook(stationid, scd_id, scd_name, scd_path)
  418. if err != nil {
  419. c.Data["json"] = c.ResultError(err.Error())
  420. c.ServeJSON()
  421. return
  422. }
  423. c.Data["json"] = c.ResultOK(lst, 1)
  424. c.ServeJSON()
  425. }