2
3

todolist.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
  4. "dashoo.cn/backend/api/business/oilsupplier/infochange"
  5. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  6. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
  7. "dashoo.cn/backend/api/business/register"
  8. "dashoo.cn/backend/api/business/todolist"
  9. "dashoo.cn/backend/api/business/workflow"
  10. . "dashoo.cn/backend/api/controllers"
  11. "dashoo.cn/utils"
  12. "fmt"
  13. "sort"
  14. "strconv"
  15. "strings"
  16. "time"
  17. )
  18. type TodoListController struct {
  19. BaseController
  20. }
  21. // @Title 获取列表
  22. // @Description get user by token
  23. // @Success 200 {object} []supplier.OilSupplierView
  24. // @router /gettodolist [get]
  25. func (this *TodoListController) GetMyTaskEntityList() {
  26. page := this.GetPageInfoForm()
  27. stype := this.GetString("Type") // 1 准入 2 增项 3 年审 4 信息变更 5 注册 6 待入库
  28. supplierTypeCode := this.GetString("SupplierTypeCode")
  29. supplierName := this.GetString("SupplierName")
  30. wfNames := ""
  31. if stype == "1" {
  32. wfNames = workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_SUPPLIER_INSTORE + "," + workflow.OIL_SECOND_OTHER_SUPPLIER_APPLY
  33. } else if stype == "2" {
  34. wfNames = workflow.OIL_ENUSER_APPEND_APPLY + "," + workflow.OIL_FIRST_ENUSER_APPEND_APPLY + "," + workflow.OIL_SECOND_ENUSER_APPEND_APPLY + "," + workflow.OIL_SECOND_OTHER_APPEND_APPLY
  35. } else if stype == "3" {
  36. wfNames = workflow.OIL_AUDIT_APPLY
  37. } else if stype == "4" {
  38. wfNames = workflow.OIL_INFO_CHANGE
  39. } else if stype == "5" {
  40. wfNames = workflow.OIL_REGISTER_APPLY
  41. } else if stype == "6" {
  42. wfNames = workflow.OIL_SUPPLIER_INSTORE
  43. }
  44. var todoliststemp []todolist.TodoList
  45. var pagingResult workflow.ActiMyPagingResultVM
  46. var myTasksRetWithTimes []workflow.ActiMyTasksRetWithTimeVM
  47. actisvc := workflow.GetActivitiService(utils.DBE)
  48. pagingResult = actisvc.GetMyAllTypePagingTasksWithTime(this.User.Id, page.CurrentPage, page.Size, wfNames, supplierTypeCode, supplierName)
  49. myTasksRetWithTimes = pagingResult.TaskList
  50. //取出各种类型的ID
  51. for _,item := range myTasksRetWithTimes {
  52. idx := strings.Index(item.BusinessKey, "-")
  53. id := item.BusinessKey
  54. if idx >= 0 {
  55. id = strings.Split(item.BusinessKey, "-")[0]
  56. }
  57. //工作流名称
  58. has := false
  59. wfName := strings.Split(item.ProcessDefinitionId, ":")[0] //如:oil_enuser_supplier_apply:2:2543
  60. if (item.TaskName != "集中评审") && (wfName == workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY || wfName == workflow.OIL_ENUSER_SUPPLIER_APPLY ||
  61. wfName == workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY || wfName == workflow.OIL_SUPPLIER_INSTORE || wfName == workflow.OIL_SECOND_OTHER_SUPPLIER_APPLY) {
  62. //准入
  63. where := " 1=1 "
  64. where = where + " and b.Id = '" + id + "'"
  65. var todo todolist.TodoList
  66. svc := supplier.GetOilSupplierService(utils.DBE)
  67. has = svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, where)
  68. if has {
  69. todo.Type = todolist.SUPPLIER
  70. todo.UserName = this.User.Realname
  71. todo.CreateTime = item.CreateTime
  72. todo.TaskName = item.TaskName
  73. if wfName == workflow.OIL_SUPPLIER_INSTORE {
  74. todo.Type = todolist.STORAGE
  75. }
  76. todoliststemp = append(todoliststemp, todo)
  77. }
  78. } else if (item.TaskName != "增项-集中评审") && (wfName == workflow.OIL_ENUSER_APPEND_APPLY || wfName == workflow.OIL_FIRST_ENUSER_APPEND_APPLY ||
  79. wfName == workflow.OIL_SECOND_ENUSER_APPEND_APPLY || wfName == workflow.OIL_SECOND_OTHER_APPEND_APPLY) {
  80. //增项
  81. where := " 1=1 "
  82. where = where + " and b.Id = '" + id + "'"
  83. var todo todolist.TodoList
  84. svcapp := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  85. has :=svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, where)
  86. if has {
  87. todo.Type = todolist.CERTAPPEND
  88. todo.TaskName = item.TaskName
  89. todo.UserName = this.User.Realname
  90. todo.CreateTime = item.CreateTime
  91. todoliststemp = append(todoliststemp, todo)
  92. }
  93. } else if wfName == workflow.OIL_AUDIT_APPLY {
  94. //年审
  95. var todo todolist.TodoList
  96. var listannu annualaudit.OilAnnualAudit
  97. svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  98. has = svc.GetEntityById(id, &listannu)
  99. if has {
  100. todo.Id = listannu.Id
  101. todo.SupplierId = strconv.Itoa(listannu.SupplierId)
  102. todo.Type = todolist.ANNUALAUDIT
  103. todo.SupplierName = listannu.SupplierName
  104. todo.UserName = this.User.Realname
  105. todo.TaskName = item.TaskName
  106. todo.SupplierTypeCode = listannu.SupplierTypeName
  107. todo.Step = strconv.Itoa(listannu.Step)
  108. todo.Status = listannu.Status
  109. todo.CertId = strconv.Itoa(listannu.CerId)
  110. todo.CreateTime = item.CreateTime
  111. todoliststemp = append(todoliststemp, todo)
  112. }
  113. } else if wfName == workflow.OIL_INFO_CHANGE {
  114. //资质变更
  115. var todo todolist.TodoList
  116. var listInfo infochange.OilInfoChange
  117. svc := infochange.GetInfoChangeService(utils.DBE)
  118. has = svc.GetEntityById(id, &listInfo)
  119. if has {
  120. todo.Id = listInfo.Id
  121. todo.Type = todolist.INFOCHANGE
  122. todo.SupplierId = strconv.Itoa(listInfo.SupplierId)
  123. todo.SupplierName = listInfo.SupplierName
  124. todo.UserName = this.User.Realname
  125. todo.TaskName = item.TaskName
  126. todo.SupplierTypeCode = listInfo.SupplierTypeName
  127. todo.Status = listInfo.Status
  128. todo.CreateTime = item.CreateTime
  129. todoliststemp = append(todoliststemp, todo)
  130. }
  131. } else if wfName == workflow.OIL_REGISTER_APPLY {
  132. //企业用户注册
  133. var todo todolist.TodoList
  134. regsvc := register.GetOilCorporateInfoService(utils.DBE)
  135. var listinfo register.OilCorporateInfo
  136. has = regsvc.GetEntityById(id, &listinfo)
  137. if has {
  138. todo.Id = listinfo.Id
  139. todo.Type = todolist.REGISTER
  140. todo.SupplierName = listinfo.SupplierName
  141. todo.UserName = this.User.Realname
  142. todo.TaskName = item.TaskName
  143. todo.Status = strconv.Itoa(listinfo.CheckStatus)
  144. todo.CreateTime = item.CreateTime
  145. todoliststemp = append(todoliststemp, todo)
  146. }
  147. }
  148. }
  149. var todolists []todolist.TodoList
  150. CreateOn := this.GetString("CreateOn")
  151. if CreateOn != "" {
  152. dates := strings.Split(CreateOn, ",")
  153. var minDate time.Time
  154. var maxDate time.Time
  155. if len(dates) == 2 {
  156. minDate,_ = utils.TimeParse(dates[0], "2006-01-02 15:04")
  157. maxDate,_ = utils.TimeParse(dates[1], "2006-01-02 15:04")
  158. }
  159. for i := 0; i < len(todoliststemp); i++ {
  160. fmt.Println(minDate.Unix()*1000, "==",maxDate.Unix()*1000)
  161. fmt.Println(todoliststemp[i].CreateTime, "==",todoliststemp[i].CreateTime)
  162. if todoliststemp[i].CreateTime > minDate.Unix()*1000 && todoliststemp[i].CreateTime < maxDate.Unix()*1000 {
  163. todolists = append(todolists, todoliststemp[i])
  164. }
  165. }
  166. } else {
  167. todolists = todoliststemp
  168. }
  169. sort.Slice(todolists, func(i, j int) bool {
  170. return todolists[i].CreateTime > todolists[j].CreateTime
  171. })
  172. var datainfo DataInfo
  173. datainfo.Items = todolists
  174. datainfo.CurrentItemCount = pagingResult.Total
  175. datainfo.PageIndex = page.CurrentPage
  176. datainfo.ItemsPerPage = page.Size
  177. this.Data["json"] = &datainfo
  178. this.ServeJSON()
  179. }
  180. // @Title 获取已办列表
  181. // @Description get user by token
  182. // @Success 200 {object} []supplier.OilSupplierView
  183. // @router /getmytaskfinishedlist [get]
  184. func (this *TodoListController) GetMyTaskFinishedList() {
  185. page := this.GetPageInfoForm()
  186. stype := this.GetString("Type")
  187. supplierTypeCode := this.GetString("SupplierTypeCode")
  188. supplierName := this.GetString("SupplierName")
  189. wfNames := ""
  190. if stype == "1" {
  191. wfNames = workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_SUPPLIER_INSTORE
  192. } else if stype == "2" {
  193. wfNames = workflow.OIL_ENUSER_APPEND_APPLY + "," + workflow.OIL_FIRST_ENUSER_APPEND_APPLY + "," + workflow.OIL_SECOND_ENUSER_APPEND_APPLY
  194. } else if stype == "3" {
  195. wfNames = workflow.OIL_AUDIT_APPLY
  196. } else if stype == "4" {
  197. wfNames = workflow.OIL_INFO_CHANGE
  198. } else if stype == "5" {
  199. wfNames = workflow.OIL_REGISTER_APPLY
  200. } else if stype == "6" {
  201. wfNames = workflow.OIL_SUPPLIER_INSTORE
  202. }
  203. var todoliststemp []todolist.TodoList
  204. var pagingResult workflow.ActiMyPagingResultVM
  205. var myTasksRetWithTimes []workflow.ActiMyTasksRetWithTimeVM
  206. actisvc := workflow.GetActivitiService(utils.DBE)
  207. pagingResult = actisvc.GetMyAllTypePagingFinishedTasksWithTime(this.User.Id, page.CurrentPage, page.Size, wfNames, supplierTypeCode, supplierName)
  208. myTasksRetWithTimes = pagingResult.TaskList
  209. //取出各种类型的ID
  210. for _,item := range myTasksRetWithTimes {
  211. idx := strings.Index(item.BusinessKey, "-")
  212. id := item.BusinessKey
  213. if idx >= 0 {
  214. id = strings.Split(item.BusinessKey, "-")[0]
  215. }
  216. //工作流名称
  217. has := false
  218. wfName := strings.Split(item.ProcessDefinitionId, ":")[0] //如:oil_enuser_supplier_apply:2:2543
  219. if wfName == workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY || wfName == workflow.OIL_ENUSER_SUPPLIER_APPLY || wfName == workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY || wfName == workflow.OIL_SUPPLIER_INSTORE {
  220. //准入
  221. where := " 1=1 "
  222. where = where + " and b.Id = '" + id + "'"
  223. var todo todolist.TodoList
  224. svc := supplier.GetOilSupplierService(utils.DBE)
  225. has = svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, where)
  226. if has {
  227. todo.Type = todolist.SUPPLIER
  228. todo.UserName = this.User.Realname
  229. todo.CreateTime = item.CreateTime
  230. todo.TaskName = item.TaskName
  231. todoliststemp = append(todoliststemp, todo)
  232. }
  233. } else if wfName == workflow.OIL_ENUSER_APPEND_APPLY || wfName == workflow.OIL_FIRST_ENUSER_APPEND_APPLY || wfName == workflow.OIL_SECOND_ENUSER_APPEND_APPLY {
  234. //增项
  235. where := " 1=1 "
  236. where = where + " and b.Id = '" + id + "'"
  237. var todo todolist.TodoList
  238. svcapp := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  239. has :=svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, where)
  240. if has {
  241. todo.TaskName = item.TaskName
  242. todo.Type = todolist.CERTAPPEND
  243. todo.UserName = this.User.Realname
  244. todo.CreateTime = item.CreateTime
  245. todoliststemp = append(todoliststemp, todo)
  246. }
  247. } else if wfName == workflow.OIL_AUDIT_APPLY {
  248. //年审
  249. where := " 1=1 "
  250. where = where + " and Id = '" + id + "'"
  251. var todo todolist.TodoList
  252. var listannu annualaudit.OilAnnualAudit
  253. svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  254. has = svc.GetEntity(&listannu, where)
  255. if has {
  256. todo.Id = listannu.Id
  257. todo.SupplierId = strconv.Itoa(listannu.SupplierId)
  258. todo.Type = todolist.ANNUALAUDIT
  259. todo.SupplierName = listannu.SupplierName
  260. todo.UserName = this.User.Realname
  261. todo.TaskName = item.TaskName
  262. todo.SupplierTypeCode = listannu.SupplierTypeName
  263. todo.Step = strconv.Itoa(listannu.Step)
  264. todo.Status = listannu.Status
  265. todo.CertId = strconv.Itoa(listannu.CerId)
  266. todo.CreateTime = item.CreateTime
  267. todoliststemp = append(todoliststemp, todo)
  268. }
  269. } else if wfName == workflow.OIL_INFO_CHANGE {
  270. //资质变更
  271. where := " 1=1 "
  272. where = where + " and Id = '" + id + "'"
  273. var todo todolist.TodoList
  274. var listInfo infochange.OilInfoChange
  275. svc := infochange.GetInfoChangeService(utils.DBE)
  276. has = svc.GetEntity(&listInfo, where)
  277. if has {
  278. todo.Id = listInfo.Id
  279. todo.Type = todolist.INFOCHANGE
  280. todo.SupplierId = strconv.Itoa(listInfo.SupplierId)
  281. todo.SupplierName = listInfo.SupplierName
  282. todo.UserName = this.User.Realname
  283. todo.TaskName = item.TaskName
  284. todo.SupplierTypeCode = listInfo.SupplierTypeName
  285. todo.Status = listInfo.Status
  286. todo.CreateTime = item.CreateTime
  287. todoliststemp = append(todoliststemp, todo)
  288. }
  289. } else if wfName == workflow.OIL_REGISTER_APPLY {
  290. //企业用户注册
  291. var todo todolist.TodoList
  292. regsvc := register.GetOilCorporateInfoService(utils.DBE)
  293. var listinfo register.OilCorporateInfo
  294. has = regsvc.GetEntityById(id, &listinfo)
  295. if has {
  296. todo.Id = listinfo.Id
  297. todo.Type = todolist.REGISTER
  298. todo.SupplierName = listinfo.SupplierName
  299. todo.UserName = this.User.Realname
  300. todo.TaskName = item.TaskName
  301. todo.Status = strconv.Itoa(listinfo.CheckStatus)
  302. todo.CreateTime = item.CreateTime
  303. todoliststemp = append(todoliststemp, todo)
  304. }
  305. }
  306. }
  307. var todolists []todolist.TodoList
  308. CreateOn := this.GetString("CreateOn")
  309. if CreateOn != "" {
  310. dates := strings.Split(CreateOn, ",")
  311. var minDate time.Time
  312. var maxDate time.Time
  313. if len(dates) == 2 {
  314. minDate,_ = utils.TimeParse(dates[0], "2006-01-02 15:04")
  315. maxDate,_ = utils.TimeParse(dates[1], "2006-01-02 15:04")
  316. }
  317. for i := 0; i < len(todoliststemp); i++ {
  318. if todoliststemp[i].CreateTime > minDate.Unix()*1000 && todoliststemp[i].CreateTime < maxDate.Unix()*1000 {
  319. todolists = append(todolists, todoliststemp[i])
  320. }
  321. }
  322. } else {
  323. todolists = todoliststemp
  324. }
  325. sort.Slice(todolists, func(i, j int) bool {
  326. return todolists[i].CreateTime > todolists[j].CreateTime
  327. })
  328. var datainfo DataInfo
  329. datainfo.Items = todolists
  330. datainfo.CurrentItemCount = pagingResult.Total
  331. datainfo.PageIndex = page.CurrentPage
  332. datainfo.ItemsPerPage = page.Size
  333. this.Data["json"] = &datainfo
  334. this.ServeJSON()
  335. }