flowController.go 15 KB

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