todolist.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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/qualchange"
  6. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  7. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
  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. "strconv"
  14. "strings"
  15. )
  16. type TodoListController struct {
  17. BaseController
  18. }
  19. // @Title 获取列表
  20. // @Description get user by token
  21. // @Success 200 {object} []supplier.OilSupplierView
  22. // @router /gettodolist [get]
  23. func (this *TodoListController) GetMyTaskEntityList() {
  24. var todolists []todolist.TodoList
  25. var todo todolist.TodoList
  26. page := this.GetPageInfoForm()
  27. where := " 1=1 "
  28. orderby := "Id"
  29. asc := false
  30. Order := this.GetString("Order")
  31. where = where + " and b.Status>0"
  32. Prop := this.GetString("Prop")
  33. if Order != "" && Prop != "" {
  34. orderby = Prop
  35. if Order == "asc" {
  36. asc = true
  37. }
  38. }
  39. stype := this.GetString("Type")
  40. supplierTypeCode := this.GetString("SupplierTypeCode")
  41. supplierName := this.GetString("SupplierName")
  42. if supplierTypeCode != "" {
  43. where = where + " and b.SupplierTypeCode = '" + supplierTypeCode + "'"
  44. }
  45. if supplierName != "" {
  46. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  47. }
  48. actisvc := workflow.GetActivitiService(utils.DBE)
  49. svc := supplier.GetOilSupplierService(utils.DBE)
  50. if stype == "1" || stype == "" {
  51. //找出待办任务===准入
  52. var certIdList string
  53. if actisvc.GetMyTasks(workflow.OIL_SUPPLIER_APPLY, this.User.Id) != "" {
  54. certIdList = actisvc.GetMyTasks(workflow.OIL_SUPPLIER_APPLY, this.User.Id)
  55. certIdList = certIdList + ","
  56. }
  57. if actisvc.GetMyTasks(workflow.OIL_FIRST_SUPPLIER_APPLY, this.User.Id) != "" {
  58. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_FIRST_SUPPLIER_APPLY, this.User.Id))
  59. certIdList = certIdList + ","
  60. }
  61. if actisvc.GetMyTasks(workflow.OIL_SECOND_SUPPLIER_APPLY, this.User.Id) != "" {
  62. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_SECOND_SUPPLIER_APPLY, this.User.Id))
  63. certIdList = certIdList + ","
  64. }
  65. if actisvc.GetMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  66. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id))
  67. certIdList = certIdList + ","
  68. }
  69. if actisvc.GetMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  70. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id))
  71. certIdList = certIdList + ","
  72. }
  73. if actisvc.GetMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  74. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id))
  75. certIdList = certIdList + ","
  76. }
  77. certIdList = strings.Trim(certIdList, ",")
  78. certIdarr := strings.Split(certIdList, ",")
  79. for i, item := range certIdarr {
  80. idx := strings.Index(item, "-")
  81. if idx >= 0 {
  82. certIdarr[i] = strings.Split(item, "-")[0]
  83. }
  84. }
  85. certIdList = strings.Join(certIdarr, ",")
  86. var list []supplier.OilSupplierView
  87. if certIdList != "" {
  88. where += " and b.Id in (" + certIdList + ")"
  89. svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  90. for _, item := range list {
  91. todo.Id = item.Id
  92. todo.CertId = item.CertId
  93. todo.SupplierTypeCode = item.SupplierTypeCode
  94. todo.Type = todolist.SUPPLIER
  95. todo.SupplierName = item.SupplierName
  96. todo.UserName = this.User.Realname
  97. todo.Status = item.Status
  98. todolists = append(todolists, todo)
  99. }
  100. }
  101. }
  102. if stype == "2" || stype == "" {
  103. //找出待办任务 -- 增项
  104. whereapp := "1=1"
  105. whereapp = whereapp + " and b.Status>0"
  106. appendIdList := actisvc.GetMyTasks(workflow.OIL_APPEND_APPLY, this.User.Id)
  107. appendIdarr := strings.Split(appendIdList, ",")
  108. for i, item := range appendIdarr {
  109. idx := strings.Index(item, "-")
  110. if (idx >= 0) {
  111. appendIdarr[i] = strings.Split(item, "-")[0]
  112. }
  113. }
  114. appendIdList = strings.Join(appendIdarr, ",")
  115. var listapp []suppliercertappend.OilSupplierCertAppendTodo
  116. svcapp := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  117. if appendIdList != "" {
  118. whereapp += " and b.Id in (" + appendIdList + ")"
  119. svcapp.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertAppendName, page.CurrentPage, page.Size, orderby, asc, &listapp, whereapp)
  120. for _, item := range listapp {
  121. todo.Id = item.Id
  122. todo.Type = todolist.CERTAPPEND
  123. todo.SupplierName = item.SupplierName
  124. todo.UserName = this.User.Realname
  125. todo.SupplierTypeCode = item.AppendType
  126. todo.Status = item.Status
  127. todolists = append(todolists, todo)
  128. }
  129. }
  130. }
  131. if stype == "3" || stype == "" {
  132. // 待办--年审
  133. whereannu := "1=1"
  134. if supplierName != "" {
  135. whereannu = whereannu + " and SupplierName like '%" + supplierName + "%'"
  136. }
  137. var listannu []annualaudit.OilAnnualAudit
  138. annuIdList := actisvc.GetMyTasks(workflow.OIL_AUDIT_APPLY, this.User.Id)
  139. annuIdarr := strings.Split(annuIdList, ",")
  140. for i, item := range annuIdarr {
  141. idx := strings.Index(item, "-")
  142. if idx >= 0 {
  143. annuIdarr[i] = strings.Split(item, "-")[0]
  144. }
  145. }
  146. annuIdList = strings.Join(annuIdarr, ",")
  147. if annuIdList != "" {
  148. whereannu += " and Id in (" + annuIdList + ")"
  149. //根据部门查询待办任务
  150. whereannu += " and Status != 2 "
  151. svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &listannu, whereannu)
  152. for _, item := range listannu {
  153. todo.Id = item.Id
  154. todo.SupplierId = strconv.Itoa(item.SupplierId)
  155. todo.Type = todolist.ANNUALAUDIT
  156. todo.SupplierName = item.SupplierName
  157. todo.UserName = this.User.Realname
  158. todo.SupplierTypeCode = item.SupplierTypeName
  159. todo.Step = strconv.Itoa(item.Step)
  160. todo.WorkflowId = item.WorkflowId
  161. todo.Status = item.Status
  162. todo.CertId = strconv.Itoa(item.CerId)
  163. todolists = append(todolists, todo)
  164. }
  165. }
  166. }
  167. if stype == "4" || stype == "" {
  168. // 待办 ----- 信息变更
  169. var listInfo []infochange.OilInfoChange
  170. whereInfo := "1=1"
  171. if supplierName != "" {
  172. whereInfo = where + " and SupplierName like '%" + supplierName + "%'"
  173. }
  174. infoList := actisvc.GetMyTasks(workflow.OIL_INFO_CHANGE, this.User.Id)
  175. infoIdarr := strings.Split(infoList, ",")
  176. for i, item := range infoIdarr {
  177. idx := strings.Index(item, "-")
  178. if (idx >= 0) {
  179. infoIdarr[i] = strings.Split(item, "-")[0]
  180. }
  181. }
  182. infoList = strings.Join(infoIdarr, ",")
  183. if infoList != "" {
  184. whereInfo += " and Id in (" + infoList + ")"
  185. svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &listInfo, whereInfo)
  186. for _, item := range listInfo {
  187. todo.Id = item.Id
  188. todo.Type = todolist.INFOCHANGE
  189. todo.SupplierId = strconv.Itoa(item.SupplierId)
  190. todo.SupplierName = item.OldSupplierName
  191. todo.UserName = this.User.Realname
  192. todo.SupplierTypeCode = item.SupplierTypeName
  193. todo.Status = item.Status
  194. todolists = append(todolists, todo)
  195. }
  196. }
  197. }
  198. if stype == "5" || stype == "" {
  199. // 资质变更
  200. var listqual []qualchange.OilQualChangeMain
  201. qualList := actisvc.GetMyTasks(workflow.OIL_QUAL_CHANGE, this.User.Id)
  202. qualIdarr := strings.Split(qualList, ",")
  203. for i, item := range qualIdarr {
  204. idx := strings.Index(item, "-")
  205. if idx >= 0 {
  206. qualIdarr[i] = strings.Split(item, "-")[0]
  207. }
  208. }
  209. qualList = strings.Join(qualIdarr, ",")
  210. wherequal := "1=1 "
  211. if supplierName != "" {
  212. wherequal = wherequal + " and SupplierName like '%" + supplierName + "%'"
  213. }
  214. if qualList != "" {
  215. wherequal += " and Id in (" + qualList + ")"
  216. wherequal += " and Status != -2 "
  217. svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &listqual, wherequal)
  218. for _, item := range listqual {
  219. todo.Id = item.Id
  220. todo.CertId = strconv.Itoa(item.SupplierCertId)
  221. todo.SupplierId = strconv.Itoa(item.SupplierId)
  222. todo.Type = todolist.QUALCHANGE
  223. todo.SupplierName = item.SupplierName
  224. todo.UserName = this.User.Realname
  225. todo.SupplierTypeCode = "0"
  226. todo.Status = item.Status
  227. todolists = append(todolists, todo)
  228. }
  229. }
  230. }
  231. var datainfo DataInfo
  232. datainfo.Items = todolists
  233. this.Data["json"] = &datainfo
  234. this.ServeJSON()
  235. //this.SetUserDeptId()
  236. }
  237. // @Title 获取已办列表
  238. // @Description get user by token
  239. // @Success 200 {object} []supplier.OilSupplierView
  240. // @router /getmytaskfinishedlist [get]
  241. func (this *TodoListController) GetMyTaskFinishedList() {
  242. var todolists []todolist.TodoList
  243. var todo todolist.TodoList
  244. page := this.GetPageInfoForm()
  245. where := " 1=1 "
  246. orderby := "Id"
  247. asc := false
  248. Order := this.GetString("Order")
  249. where = where + " and b.Status>0"
  250. Prop := this.GetString("Prop")
  251. if Order != "" && Prop != "" {
  252. orderby = Prop
  253. if Order == "asc" {
  254. asc = true
  255. }
  256. }
  257. stype := this.GetString("Type")
  258. supplierTypeCode := this.GetString("SupplierTypeCode")
  259. supplierName := this.GetString("SupplierName")
  260. if supplierTypeCode != "" {
  261. where = where + " and b.SupplierTypeCode = '" + supplierTypeCode + "'"
  262. }
  263. if supplierName != "" {
  264. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  265. }
  266. actisvc := workflow.GetActivitiService(utils.DBE)
  267. svc := supplier.GetOilSupplierService(utils.DBE)
  268. if stype == "1" || stype == "" {
  269. //已办任务===准入
  270. var certIdList string
  271. if actisvc.GetHistoryMyTasks(workflow.OIL_SUPPLIER_APPLY, this.User.Id) != "" {
  272. certIdList = actisvc.GetHistoryMyTasks(workflow.OIL_SUPPLIER_APPLY, this.User.Id)
  273. certIdList = certIdList + ","
  274. }
  275. if actisvc.GetHistoryMyTasks(workflow.OIL_FIRST_SUPPLIER_APPLY, this.User.Id) != "" {
  276. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetHistoryMyTasks(workflow.OIL_FIRST_SUPPLIER_APPLY, this.User.Id))
  277. certIdList = certIdList + ","
  278. }
  279. if actisvc.GetHistoryMyTasks(workflow.OIL_SECOND_SUPPLIER_APPLY, this.User.Id) != "" {
  280. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetHistoryMyTasks(workflow.OIL_SECOND_SUPPLIER_APPLY, this.User.Id))
  281. certIdList = certIdList + ","
  282. }
  283. if actisvc.GetHistoryMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  284. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetHistoryMyTasks(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id))
  285. certIdList = certIdList + ","
  286. }
  287. if actisvc.GetHistoryMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  288. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetHistoryMyTasks(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id))
  289. certIdList = certIdList + ","
  290. }
  291. if actisvc.GetHistoryMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id) != "" {
  292. certIdList = fmt.Sprintf("%s %s", certIdList, actisvc.GetHistoryMyTasks(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id))
  293. certIdList = certIdList + ","
  294. }
  295. certIdList = strings.Trim(certIdList, ",")
  296. certIdarr := strings.Split(certIdList, ",")
  297. for i, item := range certIdarr {
  298. idx := strings.Index(item, "-")
  299. if idx >= 0 {
  300. certIdarr[i] = strings.Split(item, "-")[0]
  301. }
  302. }
  303. certIdList = strings.Join(certIdarr, ",")
  304. var list []supplier.OilSupplierView
  305. if certIdList != "" {
  306. where += " and b.Id in (" + certIdList + ")"
  307. svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, page.CurrentPage, page.Size, orderby, asc, &list, where)
  308. for _, item := range list {
  309. todo.Id = item.Id
  310. todo.CertId = item.CertId
  311. todo.SupplierTypeCode = item.SupplierTypeCode
  312. todo.Type = todolist.SUPPLIER
  313. todo.SupplierName = item.SupplierName
  314. todo.UserName = this.User.Realname
  315. todo.Status = item.Status
  316. todolists = append(todolists, todo)
  317. }
  318. }
  319. }
  320. if stype == "2" || stype == "" {
  321. //已办任务 -- 增项
  322. whereapp := "1=1"
  323. whereapp = whereapp + " and b.Status>0"
  324. appendIdList := actisvc.GetHistoryMyTasks(workflow.OIL_APPEND_APPLY, this.User.Id)
  325. appendIdarr := strings.Split(appendIdList, ",")
  326. for i, item := range appendIdarr {
  327. idx := strings.Index(item, "-")
  328. if (idx >= 0) {
  329. appendIdarr[i] = strings.Split(item, "-")[0]
  330. }
  331. }
  332. appendIdList = strings.Join(appendIdarr, ",")
  333. var listapp []suppliercertappend.OilSupplierCertAppendTodo
  334. svcapp := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  335. if appendIdList != "" {
  336. whereapp += " and b.Id in (" + appendIdList + ")"
  337. svcapp.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertAppendName, page.CurrentPage, page.Size, orderby, asc, &listapp, whereapp)
  338. for _, item := range listapp {
  339. todo.Id = item.Id
  340. todo.Type = todolist.CERTAPPEND
  341. todo.SupplierName = item.SupplierName
  342. todo.UserName = this.User.Realname
  343. todo.SupplierTypeCode = item.AppendType
  344. todo.Status = item.Status
  345. todolists = append(todolists, todo)
  346. }
  347. }
  348. }
  349. if stype == "3" || stype == "" {
  350. // 已办--年审
  351. whereannu := "1=1"
  352. if supplierName != "" {
  353. whereannu = whereannu + " and SupplierName like '%" + supplierName + "%'"
  354. }
  355. var listannu []annualaudit.OilAnnualAudit
  356. annuIdList := actisvc.GetHistoryMyTasks(workflow.OIL_AUDIT_APPLY, this.User.Id)
  357. annuIdarr := strings.Split(annuIdList, ",")
  358. for i, item := range annuIdarr {
  359. idx := strings.Index(item, "-")
  360. if idx >= 0 {
  361. annuIdarr[i] = strings.Split(item, "-")[0]
  362. }
  363. }
  364. annuIdList = strings.Join(annuIdarr, ",")
  365. if annuIdList != "" {
  366. whereannu += " and Id in (" + annuIdList + ")"
  367. //根据部门查询待办任务
  368. whereannu += " and Status != 2 "
  369. svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &listannu, whereannu)
  370. for _, item := range listannu {
  371. todo.Id = item.Id
  372. todo.SupplierId = strconv.Itoa(item.SupplierId)
  373. todo.Type = todolist.ANNUALAUDIT
  374. todo.SupplierName = item.SupplierName
  375. todo.UserName = this.User.Realname
  376. todo.SupplierTypeCode = item.SupplierTypeName
  377. todo.Step = strconv.Itoa(item.Step)
  378. todo.WorkflowId = item.WorkflowId
  379. todo.Status = item.Status
  380. todo.CertId = strconv.Itoa(item.CerId)
  381. todolists = append(todolists, todo)
  382. }
  383. }
  384. }
  385. if stype == "4" || stype == "" {
  386. // 已办 ----- 信息变更
  387. var listInfo []infochange.OilInfoChange
  388. whereInfo := "1=1"
  389. if supplierName != "" {
  390. whereInfo = where + " and SupplierName like '%" + supplierName + "%'"
  391. }
  392. infoList := actisvc.GetHistoryMyTasks(workflow.OIL_INFO_CHANGE, this.User.Id)
  393. infoIdarr := strings.Split(infoList, ",")
  394. for i, item := range infoIdarr {
  395. idx := strings.Index(item, "-")
  396. if (idx >= 0) {
  397. infoIdarr[i] = strings.Split(item, "-")[0]
  398. }
  399. }
  400. infoList = strings.Join(infoIdarr, ",")
  401. if infoList != "" {
  402. whereInfo += " and Id in (" + infoList + ")"
  403. svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &listInfo, whereInfo)
  404. for _, item := range listInfo {
  405. todo.Id = item.Id
  406. todo.Type = todolist.INFOCHANGE
  407. todo.SupplierName = item.SupplierName
  408. todo.UserName = this.User.Realname
  409. todo.SupplierTypeCode = item.SupplierTypeName
  410. todo.Status = item.Status
  411. todolists = append(todolists, todo)
  412. }
  413. }
  414. }
  415. if stype == "5" || stype == "" {
  416. // 资质变更
  417. var listqual []qualchange.OilQualChangeMain
  418. qualList := actisvc.GetHistoryMyTasks(workflow.OIL_QUAL_CHANGE, this.User.Id)
  419. qualIdarr := strings.Split(qualList, ",")
  420. for i, item := range qualIdarr {
  421. idx := strings.Index(item, "-")
  422. if idx >= 0 {
  423. qualIdarr[i] = strings.Split(item, "-")[0]
  424. }
  425. }
  426. qualList = strings.Join(qualIdarr, ",")
  427. wherequal := "1=1 "
  428. if supplierName != "" {
  429. wherequal = wherequal + " and SupplierName like '%" + supplierName + "%'"
  430. }
  431. if qualList != "" {
  432. wherequal += " and Id in (" + qualList + ")"
  433. wherequal += " and Status != -2 "
  434. svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &listqual, wherequal)
  435. for _, item := range listqual {
  436. todo.Id = item.Id
  437. todo.CertId = strconv.Itoa(item.SupplierCertId)
  438. todo.SupplierId = strconv.Itoa(item.SupplierId)
  439. todo.Type = todolist.QUALCHANGE
  440. todo.SupplierName = item.SupplierName
  441. todo.UserName = this.User.Realname
  442. todo.SupplierTypeCode = "0"
  443. todo.Status = item.Status
  444. todolists = append(todolists, todo)
  445. }
  446. }
  447. }
  448. var datainfo DataInfo
  449. datainfo.Items = todolists
  450. this.Data["json"] = &datainfo
  451. this.ServeJSON()
  452. }