todolist.go 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  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. )
  17. type TodoListController struct {
  18. BaseController
  19. }
  20. // @Title 获取列表
  21. // @Description get user by token
  22. // @Success 200 {object} []supplier.OilSupplierView
  23. // @router /gettodolist [get]
  24. func (this *TodoListController) GetMyTaskEntityList() {
  25. var todolists []todolist.TodoList
  26. page := this.GetPageInfoForm()
  27. stype := this.GetString("Type")
  28. supplierTypeCode := this.GetString("SupplierTypeCode")
  29. supplierName := this.GetString("SupplierName")
  30. actisvc := workflow.GetActivitiService(utils.DBE)
  31. svc := supplier.GetOilSupplierService(utils.DBE)
  32. var myTasksRetWithTimes []workflow.ActiMyTasksRetWithTimeVM
  33. if stype == "1" || stype == "" {
  34. where := " 1=1 "
  35. if supplierTypeCode != "" {
  36. where = where + " and b.SupplierTypeCode = '" + supplierTypeCode + "'"
  37. }
  38. if supplierName != "" {
  39. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  40. }
  41. where = where + " and b.Id = "
  42. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_SUPPLIER_APPLY, this.User.Id)
  43. for _,item := range myTasksRetWithTimes {
  44. //var entity []supplier.OilSupplierView
  45. var todo todolist.TodoList
  46. idx := strings.Index(item.BusinessKey, "-")
  47. if idx >= 0 {
  48. id := strings.Split(item.BusinessKey, "-")[0]
  49. whereadd := where + id
  50. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  51. if has {
  52. todo.UserName = this.User.Realname
  53. todo.CreateTime = item.CreateTime
  54. todolists = append(todolists, todo)
  55. }
  56. fmt.Println("1")
  57. }
  58. }
  59. //一级物资供方准入流程图
  60. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_FIRST_SUPPLIER_APPLY, this.User.Id)
  61. for _,item := range myTasksRetWithTimes {
  62. var todo todolist.TodoList
  63. idx := strings.Index(item.BusinessKey, "-")
  64. if idx >= 0 {
  65. id := strings.Split(item.BusinessKey, "-")[0]
  66. whereadd := where + id
  67. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  68. if has {
  69. todo.UserName = this.User.Realname
  70. todo.CreateTime = item.CreateTime
  71. todolists = append(todolists, todo)
  72. }
  73. }
  74. }
  75. //二级物资供方准入流程图
  76. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_SECOND_SUPPLIER_APPLY, this.User.Id)
  77. for _,item := range myTasksRetWithTimes {
  78. //var entity []supplier.OilSupplierView
  79. var todo todolist.TodoList
  80. idx := strings.Index(item.BusinessKey, "-")
  81. if idx >= 0 {
  82. id := strings.Split(item.BusinessKey, "-")[0]
  83. whereadd := where + id
  84. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  85. fmt.Println("2")
  86. if has {
  87. todo.UserName = this.User.Realname
  88. todo.CreateTime = item.CreateTime
  89. todolists = append(todolists, todo)
  90. }
  91. }
  92. }
  93. //企业用户准入流程图
  94. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
  95. for _,item := range myTasksRetWithTimes {
  96. var todo todolist.TodoList
  97. idx := strings.Index(item.BusinessKey, "-")
  98. if idx >= 0 {
  99. id := strings.Split(item.BusinessKey, "-")[0]
  100. whereadd := where + id
  101. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  102. fmt.Println("3")
  103. if has {
  104. todo.UserName = this.User.Realname
  105. todo.CreateTime = item.CreateTime
  106. todolists = append(todolists, todo)
  107. }
  108. }
  109. }
  110. // 企业用户一级物资准入流程图
  111. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id)
  112. for _,item := range myTasksRetWithTimes {
  113. var todo todolist.TodoList
  114. idx := strings.Index(item.BusinessKey, "-")
  115. if idx >= 0 {
  116. id := strings.Split(item.BusinessKey, "-")[0]
  117. whereadd := where + id
  118. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  119. fmt.Println("4")
  120. if has {
  121. todo.UserName = this.User.Realname
  122. todo.CreateTime = item.CreateTime
  123. todolists = append(todolists, todo)
  124. }
  125. }
  126. }
  127. //企业用户二级物资准入流程图
  128. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
  129. for _,item := range myTasksRetWithTimes {
  130. var todo todolist.TodoList
  131. idx := strings.Index(item.BusinessKey, "-")
  132. if idx >= 0 {
  133. id := strings.Split(item.BusinessKey, "-")[0]
  134. whereadd := where + id
  135. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  136. fmt.Println("5")
  137. if has {
  138. todo.UserName = this.User.Realname
  139. todo.CreateTime = item.CreateTime
  140. todolists = append(todolists, todo)
  141. }
  142. }
  143. }
  144. }
  145. if stype == "2" || stype == "" {
  146. //待办任务 -- 增项
  147. where := "1=1"
  148. if supplierTypeCode != "" {
  149. where = where + " and b.AppendType = '" + supplierTypeCode + "'"
  150. }
  151. if supplierName != "" {
  152. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  153. }
  154. where += " and b.Id ="
  155. svcapp := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  156. //供方增项流程图
  157. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_APPEND_APPLY, this.User.Id)
  158. for _,item := range myTasksRetWithTimes {
  159. var todo todolist.TodoList
  160. idx := strings.Index(item.BusinessKey, "-")
  161. if idx >= 0 {
  162. id := strings.Split(item.BusinessKey, "-")[0]
  163. whereapp := where + id
  164. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  165. if has {
  166. todo.Type = todolist.CERTAPPEND
  167. todo.UserName = this.User.Realname
  168. todo.CreateTime = item.CreateTime
  169. todolists = append(todolists, todo)
  170. }
  171. }
  172. }
  173. //一级物资供方增项流程图
  174. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_FIRST_APPEND_APPLY, this.User.Id)
  175. for _,item := range myTasksRetWithTimes {
  176. var todo todolist.TodoList
  177. idx := strings.Index(item.BusinessKey, "-")
  178. if idx >= 0 {
  179. id := strings.Split(item.BusinessKey, "-")[0]
  180. whereapp := where + id
  181. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  182. if has {
  183. todo.Type = todolist.CERTAPPEND
  184. todo.UserName = this.User.Realname
  185. todo.CreateTime = item.CreateTime
  186. todolists = append(todolists, todo)
  187. }
  188. }
  189. }
  190. //二级物资供方准入流程图
  191. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_SECOND_APPEND_APPLY, this.User.Id)
  192. for _,item := range myTasksRetWithTimes {
  193. var todo todolist.TodoList
  194. idx := strings.Index(item.BusinessKey, "-")
  195. if idx >= 0 {
  196. id := strings.Split(item.BusinessKey, "-")[0]
  197. whereapp := where + id
  198. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  199. if has {
  200. todo.Type = todolist.CERTAPPEND
  201. todo.UserName = this.User.Realname
  202. todo.CreateTime = item.CreateTime
  203. todolists = append(todolists, todo)
  204. }
  205. }
  206. }
  207. //企业用户增项流程图
  208. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_ENUSER_APPEND_APPLY, this.User.Id)
  209. for _,item := range myTasksRetWithTimes {
  210. var todo todolist.TodoList
  211. idx := strings.Index(item.BusinessKey, "-")
  212. if idx >= 0 {
  213. id := strings.Split(item.BusinessKey, "-")[0]
  214. whereapp := where + id
  215. has :=svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  216. if has {
  217. todo.Type = todolist.CERTAPPEND
  218. todo.UserName = this.User.Realname
  219. todo.CreateTime = item.CreateTime
  220. todolists = append(todolists, todo)
  221. }
  222. }
  223. }
  224. //企业用户一级物资增项流程图
  225. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_FIRST_ENUSER_APPEND_APPLY, this.User.Id)
  226. for _,item := range myTasksRetWithTimes {
  227. var todo todolist.TodoList
  228. idx := strings.Index(item.BusinessKey, "-")
  229. if idx >= 0 {
  230. id := strings.Split(item.BusinessKey, "-")[0]
  231. whereapp := where + id
  232. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  233. if has {
  234. todo.Type = todolist.CERTAPPEND
  235. todo.UserName = this.User.Realname
  236. todo.CreateTime = item.CreateTime
  237. todolists = append(todolists, todo)
  238. }
  239. }
  240. }
  241. //企业用户二级物资增项流程图
  242. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_SECOND_ENUSER_APPEND_APPLY, this.User.Id)
  243. for _,item := range myTasksRetWithTimes {
  244. var todo todolist.TodoList
  245. idx := strings.Index(item.BusinessKey, "-")
  246. if idx >= 0 {
  247. id := strings.Split(item.BusinessKey, "-")[0]
  248. whereapp := where + id
  249. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  250. if has {
  251. todo.Type = todolist.CERTAPPEND
  252. todo.UserName = this.User.Realname
  253. todo.CreateTime = item.CreateTime
  254. todolists = append(todolists, todo)
  255. }
  256. }
  257. }
  258. }
  259. if stype == "3" || stype == "" {
  260. // 待办--年审
  261. where := "1=1"
  262. if supplierTypeCode != "" {
  263. where = where + " and SupplierTypeName = '" + supplierTypeCode + "'"
  264. }
  265. if supplierName != "" {
  266. where = where + " and SupplierName like '%" + supplierName + "%'"
  267. }
  268. where += " and Id ="
  269. //年审流程图
  270. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_AUDIT_APPLY, this.User.Id)
  271. for _,item := range myTasksRetWithTimes {
  272. var todo todolist.TodoList
  273. var listannu annualaudit.OilAnnualAudit
  274. idx := strings.Index(item.BusinessKey, "-")
  275. if idx >= 0 {
  276. id := strings.Split(item.BusinessKey, "-")[0]
  277. whereannu := where + id
  278. has := svc.GetEntity(&listannu, whereannu)
  279. if has {
  280. todo.Id = listannu.Id
  281. todo.SupplierId = strconv.Itoa(listannu.SupplierId)
  282. todo.Type = todolist.ANNUALAUDIT
  283. todo.SupplierName = listannu.SupplierName
  284. todo.UserName = this.User.Realname
  285. todo.SupplierTypeCode = listannu.SupplierTypeName
  286. todo.Step = strconv.Itoa(listannu.Step)
  287. todo.Status = listannu.Status
  288. todo.CertId = strconv.Itoa(listannu.CerId)
  289. todo.CreateTime = item.CreateTime
  290. todolists = append(todolists, todo)
  291. }
  292. }
  293. }
  294. }
  295. if stype == "4" || stype == "" {
  296. // 待办 ----- 信息变更
  297. where := "1=1"
  298. if supplierName != "" {
  299. where = where + " and SupplierName like '%" + supplierName + "%'"
  300. }
  301. where += " and Id ="
  302. //信息变更流程图
  303. myTasksRetWithTimes = actisvc.GetMyTasksWithTime(workflow.OIL_INFO_CHANGE, this.User.Id)
  304. for _,item := range myTasksRetWithTimes {
  305. var todo todolist.TodoList
  306. var listInfo infochange.OilInfoChange
  307. idx := strings.Index(item.BusinessKey, "-")
  308. if idx >= 0 {
  309. id := strings.Split(item.BusinessKey, "-")[0]
  310. whereinfo := where + id
  311. has := svc.GetEntity(&listInfo, whereinfo)
  312. if has {
  313. todo.Id = listInfo.Id
  314. todo.SupplierId = strconv.Itoa(listInfo.SupplierId)
  315. todo.Type = todolist.INFOCHANGE
  316. todo.SupplierName = listInfo.SupplierName
  317. todo.UserName = this.User.Realname
  318. todo.SupplierTypeCode = listInfo.SupplierTypeName
  319. todo.Status = listInfo.Status
  320. todo.CreateTime = item.CreateTime
  321. todolists = append(todolists, todo)
  322. }
  323. }
  324. }
  325. }
  326. //if stype == "5" || stype == "" {
  327. // // 资质变更
  328. // arr := actisvc.GetMyTasksWithTime(workflow.OIL_QUAL_CHANGE, this.User.Id)
  329. // for _,s := range arr {
  330. // myTasksRetWithTimes = append(myTasksRetWithTimes, s)
  331. // }
  332. // var listqual []qualchange.OilQualChangeMain
  333. // qualList := actisvc.GetMyTasks(workflow.OIL_QUAL_CHANGE, this.User.Id)
  334. // qualIdarr := strings.Split(qualList, ",")
  335. // for i, item := range qualIdarr {
  336. // idx := strings.Index(item, "-")
  337. // if idx >= 0 {
  338. // qualIdarr[i] = strings.Split(item, "-")[0]
  339. // }
  340. // }
  341. // qualList = strings.Join(qualIdarr, ",")
  342. // wherequal := "1=1 "
  343. //
  344. // if supplierName != "" {
  345. // wherequal = wherequal + " and SupplierName like '%" + supplierName + "%'"
  346. // }
  347. // if qualList != "" {
  348. // wherequal += " and Id in (" + qualList + ")"
  349. // wherequal += " and Status > 0 "
  350. // svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &listqual, wherequal)
  351. // var todo todolist.TodoList
  352. // for _, item := range listqual {
  353. // todo.Id = item.Id
  354. // todo.CertId = strconv.Itoa(item.SupplierCertId)
  355. // todo.SupplierId = strconv.Itoa(item.SupplierId)
  356. // todo.Type = todolist.QUALCHANGE
  357. // todo.SupplierName = item.SupplierName
  358. // todo.UserName = this.User.Realname
  359. // todo.SupplierTypeCode = "0"
  360. // todo.Status = item.Status
  361. // todo.BusinessKey = strconv.Itoa(item.Id) + "-"+ strconv.Itoa(item.AuditIndex)
  362. // todolists = append(todolists, todo)
  363. // }
  364. // }
  365. //}
  366. if stype == "6" || stype == "" {
  367. where := " CheckStatus=0 "
  368. if supplierName != "" {
  369. where = where + " and SupplierName like '%" + supplierName + "%' "
  370. }
  371. where = where + " and CheckUserId like '%" + this.User.Id + "%' "
  372. svc := register.GetOilCorporateInfoService(utils.DBE)
  373. var list []register.OilCorporateInfo
  374. _, list = svc.GetCompanyListByWhere(page.CurrentPage, page.Size, "Id desc", "OilCorporateInfo", where)
  375. var todo todolist.TodoList
  376. for _, item := range list {
  377. todo.Id = item.Id
  378. todo.Type = todolist.REGISTER
  379. todo.SupplierName = item.SupplierName
  380. todo.UserName = this.User.Realname
  381. todo.Status = strconv.Itoa(item.CheckStatus)
  382. todo.CreateTime = item.CreateOn.Unix() * 1000
  383. todolists = append(todolists, todo)
  384. }
  385. }
  386. //for i,todo := range todolists {
  387. // for _,myTasksRetWithTime := range myTasksRetWithTimes {
  388. // if todo.BusinessKey == myTasksRetWithTime.BusinessKey && todo.WorkflowId == myTasksRetWithTime.WorkflowId {
  389. // todolists[i].CreateTime = myTasksRetWithTime.CreateTime
  390. // }
  391. // }
  392. //}
  393. sort.Slice(todolists, func(i, j int) bool {
  394. return todolists[i].CreateTime > todolists[j].CreateTime
  395. })
  396. var datainfo DataInfo
  397. datainfo.Items = todolists
  398. this.Data["json"] = &datainfo
  399. this.ServeJSON()
  400. //this.SetUserDeptId()
  401. }
  402. // @Title 获取已办列表
  403. // @Description get user by token
  404. // @Success 200 {object} []supplier.OilSupplierView
  405. // @router /getmytaskfinishedlist [get]
  406. func (this *TodoListController) GetMyTaskFinishedList() {
  407. var todolists []todolist.TodoList
  408. page := this.GetPageInfoForm()
  409. stype := this.GetString("Type")
  410. supplierTypeCode := this.GetString("SupplierTypeCode")
  411. supplierName := this.GetString("SupplierName")
  412. actisvc := workflow.GetActivitiService(utils.DBE)
  413. svc := supplier.GetOilSupplierService(utils.DBE)
  414. var myTasksRetWithTimes []workflow.ActiMyTasksRetWithTimeVM
  415. if stype == "1" || stype == "" {
  416. where := " 1=1 "
  417. if supplierTypeCode != "" {
  418. where = where + " and b.SupplierTypeCode = '" + supplierTypeCode + "'"
  419. }
  420. if supplierName != "" {
  421. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  422. }
  423. where = where + " and b.Id = "
  424. //已办任务===准入
  425. //供方准入流程图
  426. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_SUPPLIER_APPLY, this.User.Id)
  427. for _,item := range myTasksRetWithTimes {
  428. //var entity []supplier.OilSupplierView
  429. var todo todolist.TodoList
  430. idx := strings.Index(item.BusinessKey, "-")
  431. if idx >= 0 {
  432. id := strings.Split(item.BusinessKey, "-")[0]
  433. whereadd := where + id
  434. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  435. if has {
  436. todo.UserName = this.User.Realname
  437. todo.CreateTime = item.CreateTime
  438. todolists = append(todolists, todo)
  439. }
  440. fmt.Println("1")
  441. }
  442. }
  443. //一级物资供方准入流程图
  444. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_FIRST_SUPPLIER_APPLY, this.User.Id)
  445. for _,item := range myTasksRetWithTimes {
  446. //var entity []supplier.OilSupplierView
  447. var todo todolist.TodoList
  448. idx := strings.Index(item.BusinessKey, "-")
  449. if idx >= 0 {
  450. id := strings.Split(item.BusinessKey, "-")[0]
  451. whereadd := where + id
  452. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  453. if has {
  454. todo.UserName = this.User.Realname
  455. todo.CreateTime = item.CreateTime
  456. todolists = append(todolists, todo)
  457. }
  458. }
  459. }
  460. //二级物资供方准入流程图
  461. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_SECOND_SUPPLIER_APPLY, this.User.Id)
  462. for _,item := range myTasksRetWithTimes {
  463. //var entity []supplier.OilSupplierView
  464. var todo todolist.TodoList
  465. idx := strings.Index(item.BusinessKey, "-")
  466. if idx >= 0 {
  467. id := strings.Split(item.BusinessKey, "-")[0]
  468. whereadd := where + id
  469. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  470. fmt.Println("2")
  471. if has {
  472. todo.UserName = this.User.Realname
  473. todo.CreateTime = item.CreateTime
  474. todolists = append(todolists, todo)
  475. }
  476. }
  477. }
  478. //企业用户准入流程图
  479. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
  480. for _,item := range myTasksRetWithTimes {
  481. //var entity []supplier.OilSupplierView
  482. var todo todolist.TodoList
  483. idx := strings.Index(item.BusinessKey, "-")
  484. if idx >= 0 {
  485. id := strings.Split(item.BusinessKey, "-")[0]
  486. whereadd := where + id
  487. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  488. fmt.Println("3")
  489. if has {
  490. todo.UserName = this.User.Realname
  491. todo.CreateTime = item.CreateTime
  492. todolists = append(todolists, todo)
  493. }
  494. }
  495. }
  496. // 企业用户一级物资准入流程图
  497. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id)
  498. for _,item := range myTasksRetWithTimes {
  499. //var entity []supplier.OilSupplierView
  500. var todo todolist.TodoList
  501. idx := strings.Index(item.BusinessKey, "-")
  502. if idx >= 0 {
  503. id := strings.Split(item.BusinessKey, "-")[0]
  504. whereadd := where + id
  505. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  506. fmt.Println("4")
  507. if has {
  508. todo.UserName = this.User.Realname
  509. todo.CreateTime = item.CreateTime
  510. todolists = append(todolists, todo)
  511. }
  512. }
  513. }
  514. //企业用户二级物资准入流程图
  515. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
  516. for _,item := range myTasksRetWithTimes {
  517. //var entity []supplier.OilSupplierView
  518. var todo todolist.TodoList
  519. idx := strings.Index(item.BusinessKey, "-")
  520. if idx >= 0 {
  521. id := strings.Split(item.BusinessKey, "-")[0]
  522. whereadd := where + id
  523. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  524. fmt.Println("5")
  525. if has {
  526. todo.UserName = this.User.Realname
  527. todo.CreateTime = item.CreateTime
  528. todolists = append(todolists, todo)
  529. }
  530. }
  531. }
  532. }
  533. if stype == "2" || stype == "" {
  534. //已办任务 -- 增项
  535. where := "1=1"
  536. if supplierTypeCode != "" {
  537. where = where + " and b.AppendType = '" + supplierTypeCode + "'"
  538. }
  539. if supplierName != "" {
  540. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  541. }
  542. where += " and b.Id ="
  543. svcapp := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  544. //供方增项流程图
  545. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_APPEND_APPLY, this.User.Id)
  546. for _,item := range myTasksRetWithTimes {
  547. //var entity []supplier.OilSupplierView
  548. var todo todolist.TodoList
  549. idx := strings.Index(item.BusinessKey, "-")
  550. if idx >= 0 {
  551. id := strings.Split(item.BusinessKey, "-")[0]
  552. whereapp := where + id
  553. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  554. if has {
  555. todo.Type = todolist.CERTAPPEND
  556. todo.UserName = this.User.Realname
  557. todo.CreateTime = item.CreateTime
  558. todolists = append(todolists, todo)
  559. }
  560. }
  561. }
  562. //一级物资供方增项流程图
  563. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_FIRST_APPEND_APPLY, this.User.Id)
  564. for _,item := range myTasksRetWithTimes {
  565. //var entity []supplier.OilSupplierView
  566. var todo todolist.TodoList
  567. idx := strings.Index(item.BusinessKey, "-")
  568. if idx >= 0 {
  569. id := strings.Split(item.BusinessKey, "-")[0]
  570. whereapp := where + id
  571. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  572. if has {
  573. todo.Type = todolist.CERTAPPEND
  574. todo.UserName = this.User.Realname
  575. todo.CreateTime = item.CreateTime
  576. todolists = append(todolists, todo)
  577. }
  578. }
  579. }
  580. //二级物资供方准入流程图
  581. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_SECOND_APPEND_APPLY, this.User.Id)
  582. for _,item := range myTasksRetWithTimes {
  583. //var entity []supplier.OilSupplierView
  584. var todo todolist.TodoList
  585. idx := strings.Index(item.BusinessKey, "-")
  586. if idx >= 0 {
  587. id := strings.Split(item.BusinessKey, "-")[0]
  588. whereapp := where + id
  589. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  590. if has {
  591. todo.Type = todolist.CERTAPPEND
  592. todo.UserName = this.User.Realname
  593. todo.CreateTime = item.CreateTime
  594. todolists = append(todolists, todo)
  595. }
  596. }
  597. }
  598. //企业用户增项流程图
  599. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_ENUSER_APPEND_APPLY, this.User.Id)
  600. for _,item := range myTasksRetWithTimes {
  601. //var entity []supplier.OilSupplierView
  602. var todo todolist.TodoList
  603. idx := strings.Index(item.BusinessKey, "-")
  604. if idx >= 0 {
  605. id := strings.Split(item.BusinessKey, "-")[0]
  606. whereapp := where + id
  607. has :=svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  608. if has {
  609. todo.Type = todolist.CERTAPPEND
  610. todo.UserName = this.User.Realname
  611. todo.CreateTime = item.CreateTime
  612. todolists = append(todolists, todo)
  613. }
  614. }
  615. }
  616. //企业用户一级物资增项流程图
  617. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_FIRST_ENUSER_APPEND_APPLY, this.User.Id)
  618. for _,item := range myTasksRetWithTimes {
  619. //var entity []supplier.OilSupplierView
  620. var todo todolist.TodoList
  621. idx := strings.Index(item.BusinessKey, "-")
  622. if idx >= 0 {
  623. id := strings.Split(item.BusinessKey, "-")[0]
  624. whereapp := where + id
  625. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  626. if has {
  627. todo.Type = todolist.CERTAPPEND
  628. todo.UserName = this.User.Realname
  629. todo.CreateTime = item.CreateTime
  630. todolists = append(todolists, todo)
  631. }
  632. }
  633. }
  634. //企业用户二级物资增项流程图
  635. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_SECOND_ENUSER_APPEND_APPLY, this.User.Id)
  636. for _,item := range myTasksRetWithTimes {
  637. //var entity []supplier.OilSupplierView
  638. var todo todolist.TodoList
  639. idx := strings.Index(item.BusinessKey, "-")
  640. if idx >= 0 {
  641. id := strings.Split(item.BusinessKey, "-")[0]
  642. whereapp := where + id
  643. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  644. if has {
  645. todo.Type = todolist.CERTAPPEND
  646. todo.UserName = this.User.Realname
  647. todo.CreateTime = item.CreateTime
  648. todolists = append(todolists, todo)
  649. }
  650. }
  651. }
  652. }
  653. if stype == "3" || stype == "" {
  654. // 已办--年审
  655. where := "1=1"
  656. if supplierTypeCode != "" {
  657. where = where + " and SupplierTypeName = '" + supplierTypeCode + "'"
  658. }
  659. if supplierName != "" {
  660. where = where + " and SupplierName like '%" + supplierName + "%'"
  661. }
  662. where += " and Id ="
  663. //年审流程图
  664. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_AUDIT_APPLY, this.User.Id)
  665. for _,item := range myTasksRetWithTimes {
  666. //var entity []supplier.OilSupplierView
  667. var todo todolist.TodoList
  668. var listannu annualaudit.OilAnnualAudit
  669. idx := strings.Index(item.BusinessKey, "-")
  670. if idx >= 0 {
  671. id := strings.Split(item.BusinessKey, "-")[0]
  672. whereannu := where + id
  673. has := svc.GetEntity(&listannu, whereannu)
  674. if has {
  675. todo.SupplierId = strconv.Itoa(listannu.SupplierId)
  676. todo.Type = todolist.ANNUALAUDIT
  677. todo.SupplierName = listannu.SupplierName
  678. todo.UserName = this.User.Realname
  679. todo.SupplierTypeCode = listannu.SupplierTypeName
  680. todo.Step = strconv.Itoa(listannu.Step)
  681. todo.Status = listannu.Status
  682. todo.CertId = strconv.Itoa(listannu.CerId)
  683. todo.CreateTime = item.CreateTime
  684. todolists = append(todolists, todo)
  685. }
  686. }
  687. }
  688. }
  689. if stype == "4" || stype == "" {
  690. // 已办 ----- 信息变更
  691. where := "1=1"
  692. if supplierName != "" {
  693. where = where + " and SupplierName like '%" + supplierName + "%'"
  694. }
  695. where += " and Id ="
  696. //信息变更流程图
  697. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_INFO_CHANGE, this.User.Id)
  698. for _,item := range myTasksRetWithTimes {
  699. //var entity []supplier.OilSupplierView
  700. var todo todolist.TodoList
  701. var listInfo infochange.OilInfoChange
  702. idx := strings.Index(item.BusinessKey, "-")
  703. if idx >= 0 {
  704. id := strings.Split(item.BusinessKey, "-")[0]
  705. whereinfo := where + id
  706. has := svc.GetEntity(&listInfo, whereinfo)
  707. if has {
  708. todo.Id = listInfo.Id
  709. todo.Type = todolist.INFOCHANGE
  710. todo.SupplierName = listInfo.SupplierName
  711. todo.UserName = this.User.Realname
  712. todo.SupplierTypeCode = listInfo.SupplierTypeName
  713. todo.Status = listInfo.Status
  714. todo.CreateTime = item.CreateTime
  715. todolists = append(todolists, todo)
  716. }
  717. }
  718. }
  719. }
  720. ////if stype == "5" || stype == "" {
  721. //// // 资质变更
  722. //// var listqual []qualchange.OilQualChangeMain
  723. //// arr := actisvc.GetMyFinishedTasksWithTime(workflow.OIL_QUAL_CHANGE, this.User.Id)
  724. //// for _,s := range arr {
  725. //// myTasksRetWithTimes = append(myTasksRetWithTimes, s)
  726. //// }
  727. //// qualList := actisvc.GetHistoryMyTasks(workflow.OIL_QUAL_CHANGE, this.User.Id)
  728. //// qualIdarr := strings.Split(qualList, ",")
  729. //// for i, item := range qualIdarr {
  730. //// idx := strings.Index(item, "-")
  731. //// if idx >= 0 {
  732. //// qualIdarr[i] = strings.Split(item, "-")[0]
  733. //// }
  734. //// }
  735. //// qualList = strings.Join(qualIdarr, ",")
  736. //// wherequal := "1=1 "
  737. ////
  738. //// if supplierName != "" {
  739. //// wherequal = wherequal + " and SupplierName like '%" + supplierName + "%'"
  740. //// }
  741. //// if qualList != "" {
  742. //// wherequal += " and Id in (" + qualList + ")"
  743. //// wherequal += " and Status != -2 "
  744. //// svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &listqual, wherequal)
  745. //// for _, item := range listqual {
  746. //// todo.Id = item.Id
  747. //// todo.CertId = strconv.Itoa(item.SupplierCertId)
  748. //// todo.SupplierId = strconv.Itoa(item.SupplierId)
  749. //// todo.Type = todolist.QUALCHANGE
  750. //// todo.SupplierName = item.SupplierName
  751. //// todo.UserName = this.User.Realname
  752. //// todo.SupplierTypeCode = "0"
  753. //// todo.Status = item.Status
  754. //// todo.BusinessKey = strconv.Itoa(item.Id) + "-"+ strconv.Itoa(item.AuditIndex)
  755. //// todolists = append(todolists, todo)
  756. //// }
  757. //// }
  758. ////}
  759. if stype == "6" || stype == "" {
  760. where := " CheckStatus in (1,2) "
  761. if supplierName != "" {
  762. where = where + " and SupplierName like '%" + supplierName + "%' "
  763. }
  764. where = where + " and CheckUserId like '%" + this.User.Id + "%' "
  765. svc := register.GetOilCorporateInfoService(utils.DBE)
  766. var todo todolist.TodoList
  767. var list []register.OilCorporateInfo
  768. _, list = svc.GetCompanyListByWhere(page.CurrentPage, page.Size, "Id desc", "OilCorporateInfo", where)
  769. for _, item := range list {
  770. todo.Id = item.Id
  771. todo.Type = todolist.REGISTER
  772. todo.SupplierName = item.SupplierName
  773. todo.UserName = this.User.Realname
  774. todo.Status = strconv.Itoa(item.CheckStatus)
  775. todo.CreateTime = item.CreateOn.Unix() * 1000
  776. todolists = append(todolists, todo)
  777. }
  778. }
  779. sort.Slice(todolists, func(i, j int) bool {
  780. return todolists[i].CreateTime > todolists[j].CreateTime
  781. })
  782. var datainfo DataInfo
  783. datainfo.Items = todolists
  784. this.Data["json"] = &datainfo
  785. this.ServeJSON()
  786. }