| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915 |
- package oilsupplier
- import (
- "dashoo.cn/backend/api/business/paymentinfo"
- "encoding/json"
- "fmt"
- "strconv"
- "strings"
- "time"
- "dashoo.cn/backend/api/business/auditsetting"
- "dashoo.cn/backend/api/business/workflow"
- "dashoo.cn/backend/api/business/baseUser"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
- "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/business2/userRole"
- "dashoo.cn/utils"
- )
- type OilSupplierCertController struct {
- BaseController
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []suppliercert.OilSupplierCert
- // @router /list [get]
- func (this *OilSupplierCertController) GetEntityList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Id"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- Id := this.GetString("Id")
- SupplierId := this.GetString("SupplierId")
- AccessCardNo := this.GetString("AccessCardNo")
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- SupplierTypeName := this.GetString("SupplierTypeName")
- RecUnitReason := this.GetString("RecUnitReason")
- RecUnitPerson := this.GetString("RecUnitPerson")
- RecDate := this.GetString("RecDate")
- RecUnitId := this.GetString("RecUnitId")
- RecUnitName := this.GetString("RecUnitName")
- StatusA := this.GetString("StatusA")
- BackReason := this.GetString("BackReason")
- InFlag := this.GetString("InFlag")
- EffectStartTime := this.GetString("EffectStartTime")
- EffectEndTime := this.GetString("EffectEndTime")
- AuditProcessNote := this.GetString("AuditProcessNote")
- AuditDate := this.GetString("AuditDate")
- PayNotice := this.GetString("PayNotice")
- SupplierStatus := this.GetString("SupplierStatus")
- MgrType := this.GetString("MgrType")
- Type := this.GetString("Type")
- MgrUnit := this.GetString("MgrUnit")
- AddinTime := this.GetString("AddinTime")
- EffectTime := this.GetString("EffectTime")
- ApplyTime := this.GetString("ApplyTime")
- SupplierNo := this.GetString("SupplierNo")
- MDMFlag := this.GetString("MDMFlag")
- InternalFlag := this.GetString("InternalFlag")
- ImportFlag := this.GetString("ImportFlag")
- OutsideFlog := this.GetString("OutsideFlog")
- Remark := this.GetString("Remark")
- IsDelete := this.GetString("IsDelete")
- CreateOn := this.GetString("CreateOn")
- CreateUserId := this.GetString("CreateUserId")
- CreateBy := this.GetString("CreateBy")
- ModifiedOn := this.GetString("ModifiedOn")
- ModifiedUserId := this.GetString("ModifiedUserId")
- ModifiedBy := this.GetString("ModifiedBy")
- if Id != "" {
- where = where + " and Id like '%" + Id + "%'"
- }
- if SupplierId != "" {
- where = where + " and SupplierId like '%" + SupplierId + "%'"
- }
- if AccessCardNo != "" {
- where = where + " and AccessCardNo like '%" + AccessCardNo + "%'"
- }
- if SupplierTypeCode != "" {
- where = where + " and SupplierTypeCode like '%" + SupplierTypeCode + "%'"
- }
- if SupplierTypeName != "" {
- where = where + " and SupplierTypeName like '%" + SupplierTypeName + "%'"
- }
- if RecUnitReason != "" {
- where = where + " and RecUnitReason like '%" + RecUnitReason + "%'"
- }
- if RecUnitPerson != "" {
- where = where + " and RecUnitPerson like '%" + RecUnitPerson + "%'"
- }
- if RecDate != "" {
- where = where + " and RecDate like '%" + RecDate + "%'"
- }
- if RecUnitId != "" {
- where = where + " and RecUnitId like '%" + RecUnitId + "%'"
- }
- if RecUnitName != "" {
- where = where + " and RecUnitName like '%" + RecUnitName + "%'"
- }
- if StatusA != "" {
- where = where + " and StatusA like '%" + StatusA + "%'"
- }
- if BackReason != "" {
- where = where + " and BackReason like '%" + BackReason + "%'"
- }
- if InFlag != "" {
- where = where + " and InFlag like '%" + InFlag + "%'"
- }
- if EffectStartTime != "" {
- where = where + " and EffectStartTime like '%" + EffectStartTime + "%'"
- }
- if EffectEndTime != "" {
- where = where + " and EffectEndTime like '%" + EffectEndTime + "%'"
- }
- if AuditProcessNote != "" {
- where = where + " and AuditProcessNote like '%" + AuditProcessNote + "%'"
- }
- if AuditDate != "" {
- where = where + " and AuditDate like '%" + AuditDate + "%'"
- }
- if PayNotice != "" {
- where = where + " and PayNotice like '%" + PayNotice + "%'"
- }
- if SupplierStatus != "" {
- where = where + " and SupplierStatus like '%" + SupplierStatus + "%'"
- }
- if MgrType != "" {
- where = where + " and MgrType like '%" + MgrType + "%'"
- }
- if Type != "" {
- where = where + " and Type like '%" + Type + "%'"
- }
- if MgrUnit != "" {
- where = where + " and MgrUnit like '%" + MgrUnit + "%'"
- }
- if AddinTime != "" {
- where = where + " and AddinTime like '%" + AddinTime + "%'"
- }
- if EffectTime != "" {
- where = where + " and EffectTime like '%" + EffectTime + "%'"
- }
- if ApplyTime != "" {
- where = where + " and ApplyTime like '%" + ApplyTime + "%'"
- }
- if SupplierNo != "" {
- where = where + " and SupplierNo like '%" + SupplierNo + "%'"
- }
- if MDMFlag != "" {
- where = where + " and MDMFlag like '%" + MDMFlag + "%'"
- }
- if InternalFlag != "" {
- where = where + " and InternalFlag like '%" + InternalFlag + "%'"
- }
- if ImportFlag != "" {
- where = where + " and ImportFlag like '%" + ImportFlag + "%'"
- }
- if OutsideFlog != "" {
- where = where + " and OutsideFlog like '%" + OutsideFlog + "%'"
- }
- if Remark != "" {
- where = where + " and Remark like '%" + Remark + "%'"
- }
- if IsDelete != "" {
- where = where + " and IsDelete like '%" + IsDelete + "%'"
- }
- if CreateOn != "" {
- where = where + " and CreateOn like '%" + CreateOn + "%'"
- }
- if CreateUserId != "" {
- where = where + " and CreateUserId like '%" + CreateUserId + "%'"
- }
- if CreateBy != "" {
- where = where + " and CreateBy like '%" + CreateBy + "%'"
- }
- if ModifiedOn != "" {
- where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
- }
- if ModifiedUserId != "" {
- where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
- }
- if ModifiedBy != "" {
- where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- svc := suppliercert.GetOilSupplierCertService(utils.DBE)
- var list []suppliercert.OilSupplierCert
- total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取字典列表
- // @Description get user by token
- // @Success 200 {object} map[string]interface{}
- // @router /dictlist [get]
- func (this *OilSupplierCertController) GetDictList() {
- dictList := make(map[string]interface{})
- //dictSvc := items.GetItemsService(utils.DBE)
- userSvc := baseUser.GetBaseUserService(utils.DBE)
- //customerSvc := svccustomer.GetCustomerService(utils.DBE)
- //dictList["WellNo"] = dictSvc.GetKeyValueItems("WellNo", this.User.AccCode)
- var userEntity userRole.Base_User
- userSvc.GetEntityById(this.User.Id, &userEntity)
- dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
- //var dictCustomer []svccustomer.Customer
- //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
- //dictList["EntrustCorp"] = &dictCustomer
- var datainfo DataInfo
- datainfo.Items = dictList
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} suppliercert.OilSupplierCert
- // @router /get/:id [get]
- func (this *OilSupplierCertController) GetEntity() {
- Id := this.Ctx.Input.Param(":id")
- var model suppliercert.OilSupplierCert
- svc := suppliercert.GetOilSupplierCertService(utils.DBE)
- svc.GetEntityByIdBytbl(OilSupplierCertName, Id, &model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} suppliercert.OilSupplierCert
- // @router /getbycreatorandtype/:typecode [get]
- func (this *OilSupplierCertController) GetEntityByCreatorId() {
- creatorId := this.User.Id
- typeCode := this.Ctx.Input.Param(":typecode")
- var model suppliercert.OilSupplierCert
- svc := suppliercert.GetOilSupplierCertService(utils.DBE)
- where := " CreateUserId = '" + creatorId + "'"
- where += " and SupplierTypeCode = '" + typeCode + "'"
- svc.GetEntityByWhere(OilSupplierCertName, where, &model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 添加
- // @Description 新增
- // @Success 200 {object} controllers.Request
- // @router /add [post]
- func (this *OilSupplierCertController) AddEntity() {
- var model suppliercert.OilSupplierCert
- var jsonBlob = this.Ctx.Input.RequestBody
- svc := suppliercert.GetOilSupplierCertService(utils.DBE)
- json.Unmarshal(jsonBlob, &model)
- model.CreateOn = time.Now()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- //model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
- _, err := svc.InsertEntityBytbl(OilSupplierCertName, &model)
- var errinfo ErrorDataInfo
- if err == nil {
- //新增
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- errinfo.Item = model.Id
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 修改实体
- // @Description 修改实体
- // @Success 200 {object} controllers.Request
- // @router /update/:id [post]
- func (this *OilSupplierCertController) UpdateEntity() {
- id := this.Ctx.Input.Param(":id")
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model suppliercert.OilSupplierCert
- svc := suppliercert.GetOilSupplierCertService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &model)
- model.ModifiedOn = time.Now()
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- cols := []string{
- "Id",
- "SupplierId",
- "AccessCardNo",
- "SupplierTypeCode",
- "SupplierTypeName",
- "RecUnitReason",
- "RecUnitPerson",
- "RecDate",
- "RecUnitId",
- "RecUnitName",
- "Status",
- "BackReason",
- "InFlag",
- "EffectStartTime",
- "EffectEndTime",
- "AuditProcessNote",
- "AuditDate",
- "PayNotice",
- "SupplierStatus",
- "MgrType",
- "Type",
- "MgrUnit",
- "AddinTime",
- "EffectTime",
- "ApplyTime",
- "SupplierNo",
- "MDMFlag",
- "InternalFlag",
- "ImportFlag",
- "OutsideFlog",
- "Remark",
- "IsDelete",
- "CreateOn",
- "CreateUserId",
- "CreateBy",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- }
- err := svc.UpdateEntityBytbl(OilSupplierCertName, id, &model, cols)
- if err == nil {
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 删除单条信息
- // @Description
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /delete/:Id [delete]
- func (this *OilSupplierCertController) DeleteEntity() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model suppliercert.OilSupplierCert
- var entityempty suppliercert.OilSupplierCert
- svc := suppliercert.GetOilSupplierCertService(utils.DBE)
- opdesc := "删除-" + Id
- err := svc.DeleteOperationAndWriteLogBytbl(OilSupplierCertName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
- if err == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 提交审批
- // @Description 提交审批
- // @Success 200 {object} controllers.Request
- // @router /audit/:id [post]
- func (this *OilSupplierCertController) AuditEntity() {
- certId := this.Ctx.Input.Param(":id")
- firstAudit := this.GetString("FirstAuditName")
- AuditRemark := this.GetString("AuditRemark")
- //取出审批列表
- certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
- var supplierCertEntity suppliercert.OilSupplierCert
- certSrv.GetEntityById(certId, &supplierCertEntity)
- var errinfo ErrorDataInfo
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = "提交失败," + err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- errinfo.Message = "审核提交成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- ////判断当前部门是否企业用户
- //result := "1"
- //if this.User.IsCompanyUser == 1 {
- // result = "0"
- //}
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- ////获得有审核权限的人员
- //var users []userRole.Base_RoleList
- //var userIds string
- //var auditWorkflow auditsetting.Base_OilAuditSetting
- //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
- //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, firstAudit, workflow.FIRST_TRIAL, &auditWorkflow)
- //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
- processInstanceId := ""
- if supplierCertEntity.WorkflowId == "0" || len(supplierCertEntity.WorkflowId) <= 0 {
- //启动工作流
- processInstanceId = svcActiviti.StartProcess(workflow.OIL_SUPPLIER_APPLY, certId, this.User.Id)
- } else {
- processInstanceId = supplierCertEntity.WorkflowId
- }
- //processInstanceId,_ := certSrv.SubmitOrgAudit(certId, workflow.OIL_SUPPLIER_APPLY, workflow.FIRST_TRIAL, this.User.Id, result, "提交给二级单位初审", OilSupplierCertSubName, OilClassOrgSettingName, "", "")
- //for _, tmpUser := range users {
- // userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
- //}
- //userIds = strings.Trim(userIds, ",")
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_APPLY
- ActiComplete.BusinessKey = certId
- ActiComplete.UserNames = firstAudit
- ActiComplete.UserId = this.User.Id
- ActiComplete.Result = "1"
- ActiComplete.Remarks = AuditRemark
- ActiComplete.CallbackUrl = ""
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal == "true" {
- errinfo.Message = "提交成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "工作流异常,请联系管理员!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- fmt.Println("-----------processInstanceId------------")
- //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
- supplierCertEntity.WorkflowId = processInstanceId
- supplierCertEntity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
- supplierCertEntity.Step = 2
- supplierCertEntity.FirstAudit, _ = strconv.Atoi(firstAudit)
- cols := []string{
- "Id",
- "WorkflowId",
- "Status",
- "Step",
- "FirstAudit",
- }
- certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
- //var model classorgsetting.OilClassOrgSetting
- //var jsonBlob = this.Ctx.Input.RequestBody
- //svc := suppliercert.GetOilSupplierCertService(utils.DBE)
- //
- //json.Unmarshal(jsonBlob, &model)
- //model.CreateOn = time.Now()
- //model.CreateBy = this.User.Realname
- //model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- ////model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
- //
- //svc.InsertEntityBytbl(OilSupplierCertName, &model)
- //fmt.Println(model)
- }
- // @Title 专业审批
- // @Description 准入初审提交审批
- // @Success 200 {object} controllers.Request
- // @router /admission/:id [post]
- func (this *OilSupplierCertController) AuditEntityadmission() {
- certId := this.Ctx.Input.Param(":id")
- var errinfo ErrorDataInfo
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = "提交失败," + err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- errinfo.Message = "审核提交成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- //取出审批列表
- certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
- certSrv.SubmitOrgAudit(certId, workflow.OIL_SUPPLIER_APPLY, workflow.PROF_AUDIT, this.User.Id, "1", "提交给专业科室审核", OilSupplierCertSubName, OilClassOrgSettingName, "", "")
- //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
- var supplierCertEntity suppliercert.OilSupplierCert
- certSrv.GetEntityById(certId, supplierCertEntity)
- supplierCertEntity.Status = suppliercert.PROF_AUDIT_STATUS //二级单位初审
- cols := []string{
- "Id",
- "Status",
- }
- certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
- }
- // @Title 增项审批
- // @Description 提交审批
- // @Success 200 {object} controllers.Request
- // @router /auditappend/:id [post]
- func (this *OilSupplierCertController) AuditEntityappend() {
- certId := this.Ctx.Input.Param(":id")
- var errinfo ErrorDataInfo
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = "提交失败," + err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- errinfo.Message = "审核提交成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- var IsCompanyU string
- if this.User.IsCompanyUser == 1 {
- IsCompanyU = "0"
- } else if this.User.IsCompanyUser == 0 {
- IsCompanyU = "1"
- }
- //取出审批列表
- certSrv := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
- processInstanceId := certSrv.SubmitOrgAudit(certId, workflow.OIL_SUPPLIER_APPEND, workflow.FIRST_TRIAL, this.User.Id, IsCompanyU, "提交增项初审", OilSupplierCertAppendSubName, OilClassOrgSettingName)
- fmt.Println("--------processInstanceId--------", processInstanceId)
- //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
- var supplierCertAppendEntity suppliercertappend.OilSupplierCertAppend
- certSrv.GetEntityById(certId, supplierCertAppendEntity)
- supplierCertAppendEntity.WorkFlowId = processInstanceId + ""
- supplierCertAppendEntity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
- cols := []string{
- "Id",
- "WorkflowId",
- "Status",
- }
- certSrv.UpdateEntityByIdCols(certId, supplierCertAppendEntity, cols)
- }
- // @Title 审批
- // @Description 审批
- // @Param body body suppliercert.OilSupplierCert
- // @Success 200 {object} controllers.Request
- // @router /auditEntityFir/:id [post]
- func (this *OilSupplierCertController) AuditEntityFir() {
- certId := this.Ctx.Input.Param(":id")
- auditer := this.GetString("auditer")
- majorDept := this.GetString("majorDept")
- //取出审批列表
- certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
- var supplierCertEntity suppliercert.OilSupplierCert
- certSrv.GetEntityById(certId, &supplierCertEntity)
- var jsonblob = this.Ctx.Input.RequestBody
- var dataother ShenHeModel
- json.Unmarshal(jsonblob, &dataother)
- var errinfo ErrorDataInfo
- defer func() { //finally处理失败的异常
- if err := recover(); err != nil {
- errinfo.Message = "提交失败," + err.(string)
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- //返回正确结果
- errinfo.Message = "审核提交成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }()
- //remarks := ""
- step := 2
- status := ""
- var userIds string
- if supplierCertEntity.Status == "1" {
- userIds = auditer
- status = suppliercert.SECOND_TRIAL_STATUS
- step = 2
- supplierCertEntity.ThirdAudit,_ = strconv.Atoi(majorDept)
- cols := []string{
- "ThirdAudit",
- }
- certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
- } else if supplierCertEntity.Status == "2" {
- status = suppliercert.THIRD_TRIAL_STATUS
- step = 2
- //获得有专业审核接收权限的人员
- //var users1 []userRole.Base_RoleList
- //var auditWorkflow1 auditsetting.Base_OilAuditSetting
- //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
- //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, strconv.Itoa(supplierCertEntity.ThirdAudit), workflow.PROF_RECE, &auditWorkflow1)
- //users1 = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow1.RoleId), this.User.AccCode)
- //var auditset []auditsetting.Base_OilAuditSetting
- //where := "OrganizeId=" + strconv.Itoa(supplierCertEntity.ThirdAudit) + " and AuditStepCode='" + workflow.PROF_RECE + "'"
- //certSrv.GetEntitysByWhere(OilAuditSettingName,where, &users)
- var users []userRole.Base_RoleList
- certSrv.GetAuditUser(strconv.Itoa(supplierCertEntity.ThirdAudit), workflow.PROF_RECE, &users)
- for _, tmpUser := range users {
- userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
- }
- userIds = strings.Trim(userIds, ",")
- } else if supplierCertEntity.Status == "3" {
- userIds = auditer
- status = suppliercert.PROF_AUDIT_STATUS
- step = 2
- } else if supplierCertEntity.Status == "4" {
- status = suppliercert.CENT_AUDIT_STATUS
- step = 2
- ////获得有专业审核接收权限的人员
- //var users1 []userRole.Base_RoleList
- //rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
- //users1 = rsvc.GetUserByRole("10000204", this.User.AccCode)
- //var users []suppliercert.UserList
- //where := "OrganizeId=100000178 and AuditStepCode='" + workflow.PROF_REGULATION + "'"
- //certSrv.GetEntitysByWhere(OilAuditSettingName,where, &users)
- var users []userRole.Base_RoleList
- certSrv.GetAuditUser("100000178", workflow.PROF_REGULATION, &users)
- for _, tmpUser := range users {
- userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
- }
- userIds = strings.Trim(userIds, ",")
- } else if supplierCertEntity.Status == "5" {
- userIds = auditer
- status = suppliercert.PAYING_AUDIT_STATUS
- step = 3
- }
- svcActiviti := workflow.GetActivitiService(utils.DBE)
- var ActiComplete workflow.ActiCompleteVM
- ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_APPLY
- ActiComplete.BusinessKey = certId
- ActiComplete.UserNames = userIds
- ActiComplete.UserId = this.User.Id
- ActiComplete.Remarks = dataother.AuditorRemark
- ActiComplete.CallbackUrl = ""
- if dataother.SuccessStatus == 1 {
- ActiComplete.Result = "1"
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal == "true" {
- supplierCertEntity.Status = status
- supplierCertEntity.Step = step
- cols := []string{
- "Status",
- "Step",
- }
- certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
- if supplierCertEntity.Status == "5" {
- paysvc := paymentinfo.GetPaymentService(utils.DBE)
- var Amount float64
- if supplierCertEntity.SupplierTypeCode == "01" {
- Amount = 6000
- }else if supplierCertEntity.SupplierTypeCode == "02"{
- Amount = 7000
- }else if supplierCertEntity.SupplierTypeCode == "03" {
- Amount = 8000
- }
- paysvc.AddPaymentinfo(supplierCertEntity.SupplierId, supplierCertEntity.Id, Amount,"1")
- }
- errinfo.Message = "提交成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "工作流异常,请联系管理员!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- } else {
- ActiComplete.Result = "0"
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
- if receiveVal == "true" {
- supplierCertEntity.Status = "0"
- supplierCertEntity.Step = 1
- cols := []string{
- "Status",
- "Step",
- }
- certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
- errinfo.Message = "提交成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "工作流异常,请联系管理员!"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- }
- }
- // @Title 审核
- // @Description 审核
- // @Success 200 {object} controllers.Request
- // @router /auditcallback [get]
- func (this *OilSupplierCertController) AuditCallback() {
- id := this.GetString("Id")
- status := this.GetString("status")
- step := this.GetString("step")
- var supplierCertEntity suppliercert.OilSupplierCert
- svc := suppliercert.GetOilSupplierCertService(utils.DBE)
- supplierCertEntity.Status = status
- supplierCertEntity.Step, _ = strconv.Atoi(step)
- cols := []string{
- "Id",
- "Status",
- "step",
- }
- svc.UpdateEntityByIdCols(id, supplierCertEntity, cols)
- fmt.Println(id, status, step)
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} controllers.Request
- // @router /isaccess [get]
- func (this *OilSupplierCertController) IsAccess() {
- auditstepcode := this.GetString("auditstepcode")
- var users []userRole.Base_RoleList
- var auditWorkflow auditsetting.Base_OilAuditSetting
- rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
- res := false
- if auditstepcode == workflow.PROF_CONCENT { // 集中审批
- rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, workflow.PROF_AUDIT, &auditWorkflow)
- users = rsvc.GetUserByRole("10000204", this.User.AccCode)
- for _, user := range users {
- if this.User.Id == strconv.Itoa(int(user.Id)) {
- res = true
- break
- }
- }
- } else {
- //var users []suppliercert.UserList
- //where := "OrganizeId=" + this.User.DepartmentId + " and AuditStepCode='" + auditstepcode + "'"
- //rsvc.GetEntitysByWhere(OilAuditSettingName,where, &users)
- //rsvc.GetAuditStepRoleEntity(OilAuditSettingName, this.User.DepartmentId, auditstepcode, &auditWorkflow)
- //users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode)
- var users []userRole.Base_RoleList
- certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
- certSrv.GetAuditUser(this.User.DepartmentId, auditstepcode, &users)
- for _, user := range users {
- if this.User.Id == strconv.Itoa(int(user.Id)) {
- res = true
- break
- }
- }
- }
- this.Data["json"] = res
- this.ServeJSON()
- }
|