2
3

todolist.go 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  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.Type = todolist.INFOCHANGE
  315. todo.SupplierName = listInfo.SupplierName
  316. todo.UserName = this.User.Realname
  317. todo.SupplierTypeCode = listInfo.SupplierTypeName
  318. todo.Status = listInfo.Status
  319. todo.CreateTime = item.CreateTime
  320. todolists = append(todolists, todo)
  321. }
  322. }
  323. }
  324. }
  325. //if stype == "5" || stype == "" {
  326. // // 资质变更
  327. // arr := actisvc.GetMyTasksWithTime(workflow.OIL_QUAL_CHANGE, this.User.Id)
  328. // for _,s := range arr {
  329. // myTasksRetWithTimes = append(myTasksRetWithTimes, s)
  330. // }
  331. // var listqual []qualchange.OilQualChangeMain
  332. // qualList := actisvc.GetMyTasks(workflow.OIL_QUAL_CHANGE, this.User.Id)
  333. // qualIdarr := strings.Split(qualList, ",")
  334. // for i, item := range qualIdarr {
  335. // idx := strings.Index(item, "-")
  336. // if idx >= 0 {
  337. // qualIdarr[i] = strings.Split(item, "-")[0]
  338. // }
  339. // }
  340. // qualList = strings.Join(qualIdarr, ",")
  341. // wherequal := "1=1 "
  342. //
  343. // if supplierName != "" {
  344. // wherequal = wherequal + " and SupplierName like '%" + supplierName + "%'"
  345. // }
  346. // if qualList != "" {
  347. // wherequal += " and Id in (" + qualList + ")"
  348. // wherequal += " and Status > 0 "
  349. // svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &listqual, wherequal)
  350. // var todo todolist.TodoList
  351. // for _, item := range listqual {
  352. // todo.Id = item.Id
  353. // todo.CertId = strconv.Itoa(item.SupplierCertId)
  354. // todo.SupplierId = strconv.Itoa(item.SupplierId)
  355. // todo.Type = todolist.QUALCHANGE
  356. // todo.SupplierName = item.SupplierName
  357. // todo.UserName = this.User.Realname
  358. // todo.SupplierTypeCode = "0"
  359. // todo.Status = item.Status
  360. // todo.BusinessKey = strconv.Itoa(item.Id) + "-"+ strconv.Itoa(item.AuditIndex)
  361. // todolists = append(todolists, todo)
  362. // }
  363. // }
  364. //}
  365. if stype == "6" || stype == "" {
  366. where := " CheckStatus=0 "
  367. if supplierName != "" {
  368. where = where + " and SupplierName like '%" + supplierName + "%' "
  369. }
  370. where = where + " and CheckUserId like '%" + this.User.Id + "%' "
  371. svc := register.GetOilCorporateInfoService(utils.DBE)
  372. var list []register.OilCorporateInfo
  373. _, list = svc.GetCompanyListByWhere(page.CurrentPage, page.Size, "Id desc", "OilCorporateInfo", where)
  374. var todo todolist.TodoList
  375. for _, item := range list {
  376. todo.Id = item.Id
  377. todo.Type = todolist.REGISTER
  378. todo.SupplierName = item.SupplierName
  379. todo.UserName = this.User.Realname
  380. todo.Status = strconv.Itoa(item.CheckStatus)
  381. todo.CreateTime = item.CreateOn.Unix() * 1000
  382. todolists = append(todolists, todo)
  383. }
  384. }
  385. //for i,todo := range todolists {
  386. // for _,myTasksRetWithTime := range myTasksRetWithTimes {
  387. // if todo.BusinessKey == myTasksRetWithTime.BusinessKey && todo.WorkflowId == myTasksRetWithTime.WorkflowId {
  388. // todolists[i].CreateTime = myTasksRetWithTime.CreateTime
  389. // }
  390. // }
  391. //}
  392. sort.Slice(todolists, func(i, j int) bool {
  393. return todolists[i].CreateTime > todolists[j].CreateTime
  394. })
  395. var datainfo DataInfo
  396. datainfo.Items = todolists
  397. this.Data["json"] = &datainfo
  398. this.ServeJSON()
  399. //this.SetUserDeptId()
  400. }
  401. // @Title 获取已办列表
  402. // @Description get user by token
  403. // @Success 200 {object} []supplier.OilSupplierView
  404. // @router /getmytaskfinishedlist [get]
  405. func (this *TodoListController) GetMyTaskFinishedList() {
  406. var todolists []todolist.TodoList
  407. page := this.GetPageInfoForm()
  408. stype := this.GetString("Type")
  409. supplierTypeCode := this.GetString("SupplierTypeCode")
  410. supplierName := this.GetString("SupplierName")
  411. actisvc := workflow.GetActivitiService(utils.DBE)
  412. svc := supplier.GetOilSupplierService(utils.DBE)
  413. var myTasksRetWithTimes []workflow.ActiMyTasksRetWithTimeVM
  414. if stype == "1" || stype == "" {
  415. where := " 1=1 "
  416. if supplierTypeCode != "" {
  417. where = where + " and b.SupplierTypeCode = '" + supplierTypeCode + "'"
  418. }
  419. if supplierName != "" {
  420. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  421. }
  422. where = where + " and b.Id = "
  423. //已办任务===准入
  424. //供方准入流程图
  425. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_SUPPLIER_APPLY, this.User.Id)
  426. for _,item := range myTasksRetWithTimes {
  427. //var entity []supplier.OilSupplierView
  428. var todo todolist.TodoList
  429. idx := strings.Index(item.BusinessKey, "-")
  430. if idx >= 0 {
  431. id := strings.Split(item.BusinessKey, "-")[0]
  432. whereadd := where + id
  433. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  434. if has {
  435. todo.UserName = this.User.Realname
  436. todo.CreateTime = item.CreateTime
  437. todolists = append(todolists, todo)
  438. }
  439. fmt.Println("1")
  440. }
  441. }
  442. //一级物资供方准入流程图
  443. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_FIRST_SUPPLIER_APPLY, this.User.Id)
  444. for _,item := range myTasksRetWithTimes {
  445. //var entity []supplier.OilSupplierView
  446. var todo todolist.TodoList
  447. idx := strings.Index(item.BusinessKey, "-")
  448. if idx >= 0 {
  449. id := strings.Split(item.BusinessKey, "-")[0]
  450. whereadd := where + id
  451. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  452. if has {
  453. todo.UserName = this.User.Realname
  454. todo.CreateTime = item.CreateTime
  455. todolists = append(todolists, todo)
  456. }
  457. }
  458. }
  459. //二级物资供方准入流程图
  460. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_SECOND_SUPPLIER_APPLY, this.User.Id)
  461. for _,item := range myTasksRetWithTimes {
  462. //var entity []supplier.OilSupplierView
  463. var todo todolist.TodoList
  464. idx := strings.Index(item.BusinessKey, "-")
  465. if idx >= 0 {
  466. id := strings.Split(item.BusinessKey, "-")[0]
  467. whereadd := where + id
  468. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  469. fmt.Println("2")
  470. if has {
  471. todo.UserName = this.User.Realname
  472. todo.CreateTime = item.CreateTime
  473. todolists = append(todolists, todo)
  474. }
  475. }
  476. }
  477. //企业用户准入流程图
  478. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_ENUSER_SUPPLIER_APPLY, this.User.Id)
  479. for _,item := range myTasksRetWithTimes {
  480. //var entity []supplier.OilSupplierView
  481. var todo todolist.TodoList
  482. idx := strings.Index(item.BusinessKey, "-")
  483. if idx >= 0 {
  484. id := strings.Split(item.BusinessKey, "-")[0]
  485. whereadd := where + id
  486. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  487. fmt.Println("3")
  488. if has {
  489. todo.UserName = this.User.Realname
  490. todo.CreateTime = item.CreateTime
  491. todolists = append(todolists, todo)
  492. }
  493. }
  494. }
  495. // 企业用户一级物资准入流程图
  496. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, this.User.Id)
  497. for _,item := range myTasksRetWithTimes {
  498. //var entity []supplier.OilSupplierView
  499. var todo todolist.TodoList
  500. idx := strings.Index(item.BusinessKey, "-")
  501. if idx >= 0 {
  502. id := strings.Split(item.BusinessKey, "-")[0]
  503. whereadd := where + id
  504. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  505. fmt.Println("4")
  506. if has {
  507. todo.UserName = this.User.Realname
  508. todo.CreateTime = item.CreateTime
  509. todolists = append(todolists, todo)
  510. }
  511. }
  512. }
  513. //企业用户二级物资准入流程图
  514. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, this.User.Id)
  515. for _,item := range myTasksRetWithTimes {
  516. //var entity []supplier.OilSupplierView
  517. var todo todolist.TodoList
  518. idx := strings.Index(item.BusinessKey, "-")
  519. if idx >= 0 {
  520. id := strings.Split(item.BusinessKey, "-")[0]
  521. whereadd := where + id
  522. has := svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, whereadd)
  523. fmt.Println("5")
  524. if has {
  525. todo.UserName = this.User.Realname
  526. todo.CreateTime = item.CreateTime
  527. todolists = append(todolists, todo)
  528. }
  529. }
  530. }
  531. }
  532. if stype == "2" || stype == "" {
  533. //已办任务 -- 增项
  534. where := "1=1"
  535. if supplierTypeCode != "" {
  536. where = where + " and b.AppendType = '" + supplierTypeCode + "'"
  537. }
  538. if supplierName != "" {
  539. where = where + " and a.SupplierName like '%" + supplierName + "%'"
  540. }
  541. where += " and b.Id ="
  542. svcapp := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  543. //供方增项流程图
  544. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_APPEND_APPLY, this.User.Id)
  545. for _,item := range myTasksRetWithTimes {
  546. //var entity []supplier.OilSupplierView
  547. var todo todolist.TodoList
  548. idx := strings.Index(item.BusinessKey, "-")
  549. if idx >= 0 {
  550. id := strings.Split(item.BusinessKey, "-")[0]
  551. whereapp := where + id
  552. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  553. if has {
  554. todo.Type = todolist.CERTAPPEND
  555. todo.UserName = this.User.Realname
  556. todo.CreateTime = item.CreateTime
  557. todolists = append(todolists, todo)
  558. }
  559. }
  560. }
  561. //一级物资供方增项流程图
  562. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_FIRST_APPEND_APPLY, this.User.Id)
  563. for _,item := range myTasksRetWithTimes {
  564. //var entity []supplier.OilSupplierView
  565. var todo todolist.TodoList
  566. idx := strings.Index(item.BusinessKey, "-")
  567. if idx >= 0 {
  568. id := strings.Split(item.BusinessKey, "-")[0]
  569. whereapp := where + id
  570. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  571. if has {
  572. todo.Type = todolist.CERTAPPEND
  573. todo.UserName = this.User.Realname
  574. todo.CreateTime = item.CreateTime
  575. todolists = append(todolists, todo)
  576. }
  577. }
  578. }
  579. //二级物资供方准入流程图
  580. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_SECOND_APPEND_APPLY, this.User.Id)
  581. for _,item := range myTasksRetWithTimes {
  582. //var entity []supplier.OilSupplierView
  583. var todo todolist.TodoList
  584. idx := strings.Index(item.BusinessKey, "-")
  585. if idx >= 0 {
  586. id := strings.Split(item.BusinessKey, "-")[0]
  587. whereapp := where + id
  588. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  589. if has {
  590. todo.Type = todolist.CERTAPPEND
  591. todo.UserName = this.User.Realname
  592. todo.CreateTime = item.CreateTime
  593. todolists = append(todolists, todo)
  594. }
  595. }
  596. }
  597. //企业用户增项流程图
  598. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_ENUSER_APPEND_APPLY, this.User.Id)
  599. for _,item := range myTasksRetWithTimes {
  600. //var entity []supplier.OilSupplierView
  601. var todo todolist.TodoList
  602. idx := strings.Index(item.BusinessKey, "-")
  603. if idx >= 0 {
  604. id := strings.Split(item.BusinessKey, "-")[0]
  605. whereapp := where + id
  606. has :=svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  607. if has {
  608. todo.Type = todolist.CERTAPPEND
  609. todo.UserName = this.User.Realname
  610. todo.CreateTime = item.CreateTime
  611. todolists = append(todolists, todo)
  612. }
  613. }
  614. }
  615. //企业用户一级物资增项流程图
  616. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_FIRST_ENUSER_APPEND_APPLY, this.User.Id)
  617. for _,item := range myTasksRetWithTimes {
  618. //var entity []supplier.OilSupplierView
  619. var todo todolist.TodoList
  620. idx := strings.Index(item.BusinessKey, "-")
  621. if idx >= 0 {
  622. id := strings.Split(item.BusinessKey, "-")[0]
  623. whereapp := where + id
  624. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  625. if has {
  626. todo.Type = todolist.CERTAPPEND
  627. todo.UserName = this.User.Realname
  628. todo.CreateTime = item.CreateTime
  629. todolists = append(todolists, todo)
  630. }
  631. }
  632. }
  633. //企业用户二级物资增项流程图
  634. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_SECOND_ENUSER_APPEND_APPLY, this.User.Id)
  635. for _,item := range myTasksRetWithTimes {
  636. //var entity []supplier.OilSupplierView
  637. var todo todolist.TodoList
  638. idx := strings.Index(item.BusinessKey, "-")
  639. if idx >= 0 {
  640. id := strings.Split(item.BusinessKey, "-")[0]
  641. whereapp := where + id
  642. has := svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, whereapp)
  643. if has {
  644. todo.Type = todolist.CERTAPPEND
  645. todo.UserName = this.User.Realname
  646. todo.CreateTime = item.CreateTime
  647. todolists = append(todolists, todo)
  648. }
  649. }
  650. }
  651. }
  652. if stype == "3" || stype == "" {
  653. // 已办--年审
  654. where := "1=1"
  655. if supplierTypeCode != "" {
  656. where = where + " and SupplierTypeName = '" + supplierTypeCode + "'"
  657. }
  658. if supplierName != "" {
  659. where = where + " and SupplierName like '%" + supplierName + "%'"
  660. }
  661. where += " and Id ="
  662. //年审流程图
  663. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_AUDIT_APPLY, this.User.Id)
  664. for _,item := range myTasksRetWithTimes {
  665. //var entity []supplier.OilSupplierView
  666. var todo todolist.TodoList
  667. var listannu annualaudit.OilAnnualAudit
  668. idx := strings.Index(item.BusinessKey, "-")
  669. if idx >= 0 {
  670. id := strings.Split(item.BusinessKey, "-")[0]
  671. whereannu := where + id
  672. has := svc.GetEntity(&listannu, whereannu)
  673. if has {
  674. todo.SupplierId = strconv.Itoa(listannu.SupplierId)
  675. todo.Type = todolist.ANNUALAUDIT
  676. todo.SupplierName = listannu.SupplierName
  677. todo.UserName = this.User.Realname
  678. todo.SupplierTypeCode = listannu.SupplierTypeName
  679. todo.Step = strconv.Itoa(listannu.Step)
  680. todo.Status = listannu.Status
  681. todo.CertId = strconv.Itoa(listannu.CerId)
  682. todo.CreateTime = item.CreateTime
  683. todolists = append(todolists, todo)
  684. }
  685. }
  686. }
  687. }
  688. if stype == "4" || stype == "" {
  689. // 已办 ----- 信息变更
  690. where := "1=1"
  691. if supplierName != "" {
  692. where = where + " and SupplierName like '%" + supplierName + "%'"
  693. }
  694. where += " and Id ="
  695. //信息变更流程图
  696. myTasksRetWithTimes = actisvc.GetMyFinishedTasksWithTime(workflow.OIL_INFO_CHANGE, this.User.Id)
  697. for _,item := range myTasksRetWithTimes {
  698. //var entity []supplier.OilSupplierView
  699. var todo todolist.TodoList
  700. var listInfo infochange.OilInfoChange
  701. idx := strings.Index(item.BusinessKey, "-")
  702. if idx >= 0 {
  703. id := strings.Split(item.BusinessKey, "-")[0]
  704. whereinfo := where + id
  705. has := svc.GetEntity(&listInfo, whereinfo)
  706. if has {
  707. todo.Id = listInfo.Id
  708. todo.Type = todolist.INFOCHANGE
  709. todo.SupplierName = listInfo.SupplierName
  710. todo.UserName = this.User.Realname
  711. todo.SupplierTypeCode = listInfo.SupplierTypeName
  712. todo.Status = listInfo.Status
  713. todo.CreateTime = item.CreateTime
  714. todolists = append(todolists, todo)
  715. }
  716. }
  717. }
  718. }
  719. ////if stype == "5" || stype == "" {
  720. //// // 资质变更
  721. //// var listqual []qualchange.OilQualChangeMain
  722. //// arr := actisvc.GetMyFinishedTasksWithTime(workflow.OIL_QUAL_CHANGE, this.User.Id)
  723. //// for _,s := range arr {
  724. //// myTasksRetWithTimes = append(myTasksRetWithTimes, s)
  725. //// }
  726. //// qualList := actisvc.GetHistoryMyTasks(workflow.OIL_QUAL_CHANGE, this.User.Id)
  727. //// qualIdarr := strings.Split(qualList, ",")
  728. //// for i, item := range qualIdarr {
  729. //// idx := strings.Index(item, "-")
  730. //// if idx >= 0 {
  731. //// qualIdarr[i] = strings.Split(item, "-")[0]
  732. //// }
  733. //// }
  734. //// qualList = strings.Join(qualIdarr, ",")
  735. //// wherequal := "1=1 "
  736. ////
  737. //// if supplierName != "" {
  738. //// wherequal = wherequal + " and SupplierName like '%" + supplierName + "%'"
  739. //// }
  740. //// if qualList != "" {
  741. //// wherequal += " and Id in (" + qualList + ")"
  742. //// wherequal += " and Status != -2 "
  743. //// svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &listqual, wherequal)
  744. //// for _, item := range listqual {
  745. //// todo.Id = item.Id
  746. //// todo.CertId = strconv.Itoa(item.SupplierCertId)
  747. //// todo.SupplierId = strconv.Itoa(item.SupplierId)
  748. //// todo.Type = todolist.QUALCHANGE
  749. //// todo.SupplierName = item.SupplierName
  750. //// todo.UserName = this.User.Realname
  751. //// todo.SupplierTypeCode = "0"
  752. //// todo.Status = item.Status
  753. //// todo.BusinessKey = strconv.Itoa(item.Id) + "-"+ strconv.Itoa(item.AuditIndex)
  754. //// todolists = append(todolists, todo)
  755. //// }
  756. //// }
  757. ////}
  758. if stype == "6" || stype == "" {
  759. where := " CheckStatus in (1,2) "
  760. if supplierName != "" {
  761. where = where + " and SupplierName like '%" + supplierName + "%' "
  762. }
  763. where = where + " and CheckUserId like '%" + this.User.Id + "%' "
  764. svc := register.GetOilCorporateInfoService(utils.DBE)
  765. var todo todolist.TodoList
  766. var list []register.OilCorporateInfo
  767. _, list = svc.GetCompanyListByWhere(page.CurrentPage, page.Size, "Id desc", "OilCorporateInfo", where)
  768. for _, item := range list {
  769. todo.Id = item.Id
  770. todo.Type = todolist.REGISTER
  771. todo.SupplierName = item.SupplierName
  772. todo.UserName = this.User.Realname
  773. todo.Status = strconv.Itoa(item.CheckStatus)
  774. todo.CreateTime = item.CreateOn.Unix() * 1000
  775. todolists = append(todolists, todo)
  776. }
  777. }
  778. sort.Slice(todolists, func(i, j int) bool {
  779. return todolists[i].CreateTime > todolists[j].CreateTime
  780. })
  781. var datainfo DataInfo
  782. datainfo.Items = todolists
  783. this.Data["json"] = &datainfo
  784. this.ServeJSON()
  785. }