| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- package oilsupplier
- import (
- "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
- "dashoo.cn/backend/api/business/oilsupplier/infochange"
- "dashoo.cn/backend/api/business/oilsupplier/supplier"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
- "dashoo.cn/backend/api/business/register"
- "dashoo.cn/backend/api/business/todolist"
- "dashoo.cn/backend/api/business/workflow"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/utils"
- "fmt"
- "sort"
- "strconv"
- "strings"
- "time"
- )
- type TodoListController struct {
- BaseController
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []supplier.OilSupplierView
- // @router /gettodolist [get]
- func (this *TodoListController) GetMyTaskEntityList() {
- page := this.GetPageInfoForm()
- stype := this.GetString("Type") // 1 准入 2 增项 3 年审 4 信息变更 5 注册 6 待入库
- supplierTypeCode := this.GetString("SupplierTypeCode")
- supplierName := this.GetString("SupplierName")
- wfNames := ""
- if stype == "1" {
- wfNames = workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_SUPPLIER_INSTORE + "," + workflow.OIL_SECOND_OTHER_SUPPLIER_APPLY
- } else if stype == "2" {
- wfNames = workflow.OIL_ENUSER_APPEND_APPLY + "," + workflow.OIL_FIRST_ENUSER_APPEND_APPLY + "," + workflow.OIL_SECOND_ENUSER_APPEND_APPLY + "," + workflow.OIL_SECOND_OTHER_APPEND_APPLY
- } else if stype == "3" {
- wfNames = workflow.OIL_AUDIT_APPLY
- } else if stype == "4" {
- wfNames = workflow.OIL_INFO_CHANGE
- } else if stype == "5" {
- wfNames = workflow.OIL_REGISTER_APPLY
- } else if stype == "6" {
- wfNames = workflow.OIL_SUPPLIER_INSTORE
- }
- var todoliststemp []todolist.TodoList
- var pagingResult workflow.ActiMyPagingResultVM
- var myTasksRetWithTimes []workflow.ActiMyTasksRetWithTimeVM
- actisvc := workflow.GetActivitiService(utils.DBE)
- pagingResult = actisvc.GetMyAllTypePagingTasksWithTime(this.User.Id, page.CurrentPage, page.Size, wfNames, supplierTypeCode, supplierName)
- myTasksRetWithTimes = pagingResult.TaskList
- //取出各种类型的ID
- for _,item := range myTasksRetWithTimes {
- idx := strings.Index(item.BusinessKey, "-")
- id := item.BusinessKey
- if idx >= 0 {
- id = strings.Split(item.BusinessKey, "-")[0]
- }
- //工作流名称
- has := false
- wfName := strings.Split(item.ProcessDefinitionId, ":")[0] //如:oil_enuser_supplier_apply:2:2543
- if (item.TaskName != "集中评审") && (wfName == workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY || wfName == workflow.OIL_ENUSER_SUPPLIER_APPLY ||
- wfName == workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY || wfName == workflow.OIL_SUPPLIER_INSTORE || wfName == workflow.OIL_SECOND_OTHER_SUPPLIER_APPLY) {
- //准入
- where := " 1=1 "
- where = where + " and b.Id = '" + id + "'"
- var todo todolist.TodoList
- svc := supplier.GetOilSupplierService(utils.DBE)
- has = svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, where)
- if has {
- todo.Type = todolist.SUPPLIER
- todo.UserName = this.User.Realname
- todo.CreateTime = item.CreateTime
- todo.TaskName = item.TaskName
- if wfName == workflow.OIL_SUPPLIER_INSTORE {
- todo.Type = todolist.STORAGE
- }
- todoliststemp = append(todoliststemp, todo)
- }
- } else if (item.TaskName != "增项-集中评审") && (wfName == workflow.OIL_ENUSER_APPEND_APPLY || wfName == workflow.OIL_FIRST_ENUSER_APPEND_APPLY ||
- wfName == workflow.OIL_SECOND_ENUSER_APPEND_APPLY || wfName == workflow.OIL_SECOND_OTHER_APPEND_APPLY) {
- //增项
- where := " 1=1 "
- where = where + " and b.Id = '" + id + "'"
- var todo todolist.TodoList
- svcapp := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
- has :=svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, where)
- if has {
- todo.Type = todolist.CERTAPPEND
- todo.TaskName = item.TaskName
- todo.UserName = this.User.Realname
- todo.CreateTime = item.CreateTime
- todoliststemp = append(todoliststemp, todo)
- }
- } else if wfName == workflow.OIL_AUDIT_APPLY {
- //年审
- var todo todolist.TodoList
- var listannu annualaudit.OilAnnualAudit
- svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
- has = svc.GetEntityById(id, &listannu)
- if has {
- todo.Id = listannu.Id
- todo.SupplierId = strconv.Itoa(listannu.SupplierId)
- todo.Type = todolist.ANNUALAUDIT
- todo.SupplierName = listannu.SupplierName
- todo.UserName = this.User.Realname
- todo.TaskName = item.TaskName
- todo.SupplierTypeCode = listannu.SupplierTypeName
- todo.Step = strconv.Itoa(listannu.Step)
- todo.Status = listannu.Status
- todo.CertId = strconv.Itoa(listannu.CerId)
- todo.CreateTime = item.CreateTime
- todoliststemp = append(todoliststemp, todo)
- }
- } else if wfName == workflow.OIL_INFO_CHANGE {
- //资质变更
- var todo todolist.TodoList
- var listInfo infochange.OilInfoChange
- svc := infochange.GetInfoChangeService(utils.DBE)
- has = svc.GetEntityById(id, &listInfo)
- if has {
- todo.Id = listInfo.Id
- todo.Type = todolist.INFOCHANGE
- todo.SupplierId = strconv.Itoa(listInfo.SupplierId)
- todo.SupplierName = listInfo.SupplierName
- todo.UserName = this.User.Realname
- todo.TaskName = item.TaskName
- todo.SupplierTypeCode = listInfo.SupplierTypeName
- todo.Status = listInfo.Status
- todo.CreateTime = item.CreateTime
- todoliststemp = append(todoliststemp, todo)
- }
- } else if wfName == workflow.OIL_REGISTER_APPLY {
- //企业用户注册
- var todo todolist.TodoList
- regsvc := register.GetOilCorporateInfoService(utils.DBE)
- var listinfo register.OilCorporateInfo
- has = regsvc.GetEntityById(id, &listinfo)
- if has {
- todo.Id = listinfo.Id
- todo.Type = todolist.REGISTER
- todo.SupplierName = listinfo.SupplierName
- todo.UserName = this.User.Realname
- todo.TaskName = item.TaskName
- todo.Status = strconv.Itoa(listinfo.CheckStatus)
- todo.CreateTime = item.CreateTime
- todoliststemp = append(todoliststemp, todo)
- }
- }
- }
- var todolists []todolist.TodoList
- CreateOn := this.GetString("CreateOn")
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- var minDate time.Time
- var maxDate time.Time
- if len(dates) == 2 {
- minDate,_ = utils.TimeParse(dates[0], "2006-01-02 15:04")
- maxDate,_ = utils.TimeParse(dates[1], "2006-01-02 15:04")
- }
- for i := 0; i < len(todoliststemp); i++ {
- fmt.Println(minDate.Unix()*1000, "==",maxDate.Unix()*1000)
- fmt.Println(todoliststemp[i].CreateTime, "==",todoliststemp[i].CreateTime)
- if todoliststemp[i].CreateTime > minDate.Unix()*1000 && todoliststemp[i].CreateTime < maxDate.Unix()*1000 {
- todolists = append(todolists, todoliststemp[i])
- }
- }
- } else {
- todolists = todoliststemp
- }
- sort.Slice(todolists, func(i, j int) bool {
- return todolists[i].CreateTime > todolists[j].CreateTime
- })
- var datainfo DataInfo
- datainfo.Items = todolists
- datainfo.CurrentItemCount = pagingResult.Total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取已办列表
- // @Description get user by token
- // @Success 200 {object} []supplier.OilSupplierView
- // @router /getmytaskfinishedlist [get]
- func (this *TodoListController) GetMyTaskFinishedList() {
- page := this.GetPageInfoForm()
- stype := this.GetString("Type")
- supplierTypeCode := this.GetString("SupplierTypeCode")
- supplierName := this.GetString("SupplierName")
- wfNames := ""
- if stype == "1" {
- wfNames = workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY + "," + workflow.OIL_SUPPLIER_INSTORE
- } else if stype == "2" {
- wfNames = workflow.OIL_ENUSER_APPEND_APPLY + "," + workflow.OIL_FIRST_ENUSER_APPEND_APPLY + "," + workflow.OIL_SECOND_ENUSER_APPEND_APPLY
- } else if stype == "3" {
- wfNames = workflow.OIL_AUDIT_APPLY
- } else if stype == "4" {
- wfNames = workflow.OIL_INFO_CHANGE
- } else if stype == "5" {
- wfNames = workflow.OIL_REGISTER_APPLY
- } else if stype == "6" {
- wfNames = workflow.OIL_SUPPLIER_INSTORE
- }
- var todoliststemp []todolist.TodoList
- var pagingResult workflow.ActiMyPagingResultVM
- var myTasksRetWithTimes []workflow.ActiMyTasksRetWithTimeVM
- actisvc := workflow.GetActivitiService(utils.DBE)
- pagingResult = actisvc.GetMyAllTypePagingFinishedTasksWithTime(this.User.Id, page.CurrentPage, page.Size, wfNames, supplierTypeCode, supplierName)
- myTasksRetWithTimes = pagingResult.TaskList
- //取出各种类型的ID
- for _,item := range myTasksRetWithTimes {
- idx := strings.Index(item.BusinessKey, "-")
- id := item.BusinessKey
- if idx >= 0 {
- id = strings.Split(item.BusinessKey, "-")[0]
- }
- //工作流名称
- has := false
- wfName := strings.Split(item.ProcessDefinitionId, ":")[0] //如:oil_enuser_supplier_apply:2:2543
- if wfName == workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY || wfName == workflow.OIL_ENUSER_SUPPLIER_APPLY || wfName == workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY || wfName == workflow.OIL_SUPPLIER_INSTORE {
- //准入
- where := " 1=1 "
- where = where + " and b.Id = '" + id + "'"
- var todo todolist.TodoList
- svc := supplier.GetOilSupplierService(utils.DBE)
- has = svc.GetMyTodoEntitie(OilSupplierName, OilSupplierCertName, &todo, where)
- if has {
- todo.Type = todolist.SUPPLIER
- todo.UserName = this.User.Realname
- todo.CreateTime = item.CreateTime
- todo.TaskName = item.TaskName
- todoliststemp = append(todoliststemp, todo)
- }
- } else if wfName == workflow.OIL_ENUSER_APPEND_APPLY || wfName == workflow.OIL_FIRST_ENUSER_APPEND_APPLY || wfName == workflow.OIL_SECOND_ENUSER_APPEND_APPLY {
- //增项
- where := " 1=1 "
- where = where + " and b.Id = '" + id + "'"
- var todo todolist.TodoList
- svcapp := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
- has :=svcapp.GetTodoEntitie(OilSupplierName, OilSupplierCertAppendName, &todo, where)
- if has {
- todo.TaskName = item.TaskName
- todo.Type = todolist.CERTAPPEND
- todo.UserName = this.User.Realname
- todo.CreateTime = item.CreateTime
- todoliststemp = append(todoliststemp, todo)
- }
- } else if wfName == workflow.OIL_AUDIT_APPLY {
- //年审
- where := " 1=1 "
- where = where + " and Id = '" + id + "'"
- var todo todolist.TodoList
- var listannu annualaudit.OilAnnualAudit
- svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
- has = svc.GetEntity(&listannu, where)
- if has {
- todo.Id = listannu.Id
- todo.SupplierId = strconv.Itoa(listannu.SupplierId)
- todo.Type = todolist.ANNUALAUDIT
- todo.SupplierName = listannu.SupplierName
- todo.UserName = this.User.Realname
- todo.TaskName = item.TaskName
- todo.SupplierTypeCode = listannu.SupplierTypeName
- todo.Step = strconv.Itoa(listannu.Step)
- todo.Status = listannu.Status
- todo.CertId = strconv.Itoa(listannu.CerId)
- todo.CreateTime = item.CreateTime
- todoliststemp = append(todoliststemp, todo)
- }
- } else if wfName == workflow.OIL_INFO_CHANGE {
- //资质变更
- where := " 1=1 "
- where = where + " and Id = '" + id + "'"
- var todo todolist.TodoList
- var listInfo infochange.OilInfoChange
- svc := infochange.GetInfoChangeService(utils.DBE)
- has = svc.GetEntity(&listInfo, where)
- if has {
- todo.Id = listInfo.Id
- todo.Type = todolist.INFOCHANGE
- todo.SupplierId = strconv.Itoa(listInfo.SupplierId)
- todo.SupplierName = listInfo.SupplierName
- todo.UserName = this.User.Realname
- todo.TaskName = item.TaskName
- todo.SupplierTypeCode = listInfo.SupplierTypeName
- todo.Status = listInfo.Status
- todo.CreateTime = item.CreateTime
- todoliststemp = append(todoliststemp, todo)
- }
- } else if wfName == workflow.OIL_REGISTER_APPLY {
- //企业用户注册
- var todo todolist.TodoList
- regsvc := register.GetOilCorporateInfoService(utils.DBE)
- var listinfo register.OilCorporateInfo
- has = regsvc.GetEntityById(id, &listinfo)
- if has {
- todo.Id = listinfo.Id
- todo.Type = todolist.REGISTER
- todo.SupplierName = listinfo.SupplierName
- todo.UserName = this.User.Realname
- todo.TaskName = item.TaskName
- todo.Status = strconv.Itoa(listinfo.CheckStatus)
- todo.CreateTime = item.CreateTime
- todoliststemp = append(todoliststemp, todo)
- }
- }
- }
- var todolists []todolist.TodoList
- CreateOn := this.GetString("CreateOn")
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- var minDate time.Time
- var maxDate time.Time
- if len(dates) == 2 {
- minDate,_ = utils.TimeParse(dates[0], "2006-01-02 15:04")
- maxDate,_ = utils.TimeParse(dates[1], "2006-01-02 15:04")
- }
- for i := 0; i < len(todoliststemp); i++ {
- if todoliststemp[i].CreateTime > minDate.Unix()*1000 && todoliststemp[i].CreateTime < maxDate.Unix()*1000 {
- todolists = append(todolists, todoliststemp[i])
- }
- }
- } else {
- todolists = todoliststemp
- }
- sort.Slice(todolists, func(i, j int) bool {
- return todolists[i].CreateTime > todolists[j].CreateTime
- })
- var datainfo DataInfo
- datainfo.Items = todolists
- datainfo.CurrentItemCount = pagingResult.Total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
|