todolist.go 26 KB

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