todolist.go 26 KB

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