package oilsupplier import ( "dashoo.cn/backend/api/business/audithistory" "dashoo.cn/backend/api/business/auditsetting" "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub" "dashoo.cn/backend/api/business/organize" "dashoo.cn/backend/api/business/register" "dashoo.cn/business2/parameter" "dashoo.cn/business2/userRole" "encoding/json" "fmt" "strconv" "strings" "time" "dashoo.cn/backend/api/business/oilsupplier/suppliercert" "dashoo.cn/backend/api/business/paymentinfo" "dashoo.cn/backend/api/business/workflow" "dashoo.cn/business2/permission" "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend" "dashoo.cn/backend/api/business/oilsupplier/suppliercertappendsub" . "dashoo.cn/backend/api/controllers" "dashoo.cn/utils" "github.com/go-xorm/xorm" ) type OilSupplierCertAppendController struct { BaseController } type AppShenHeModel struct { AnnualId int SuccessStatus int AuditorRemark string Auditer int MajorDept int } // @Title 获取列表 // @Description 获取列表 // @Success 200 {object} []suppliercertappend.OilSupplierCertAppend // @router /list [get] func (this *OilSupplierCertAppendController) GetList() { //获取分页信息 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 } } ApplyDate := this.GetString("ApplyDate") RecUnitId := this.GetString("RecUnitId") RecUnitName := this.GetString("RecUnitName") AppendType := this.GetString("AppendType") DenyReason := this.GetString("DenyReason") AuditDate := this.GetString("AuditDate") Remark := this.GetString("Remark") CreateOn := this.GetString("CreateOn") if ApplyDate != "" { where = where + " and ApplyDate like '%" + ApplyDate + "%'" } if RecUnitId != "" { where = where + " and RecUnitId like '%" + RecUnitId + "%'" } if RecUnitName != "" { where = where + " and RecUnitName like '%" + RecUnitName + "%'" } if AppendType != "" { where = where + " and AppendType like '%" + AppendType + "%'" } if DenyReason != "" { where = where + " and DenyReason like '%" + DenyReason + "%'" } if AuditDate != "" { where = where + " and AuditDate like '%" + AuditDate + "%'" } if Remark != "" { where = where + " and Remark like '%" + Remark + "%'" } if CreateOn != "" { dates := strings.Split(CreateOn, ",") if len(dates) == 2 { minDate := dates[0] maxDate := dates[1] where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'" } } //企业用户必须加创建人条件 if this.User.IsCompanyUser == 1 { where = where + " and CreateUserId = '" + this.User.Id + "'" } else { //超级管理员和有查看所有数据权限的用户不加条件 svcPerm := permission.GetPermissionService(utils.DBE) isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord") if !svcPerm.IsAdmin(this.User.Id) && !isauth { where = where + " and CreateUserId = '" + this.User.Id + "'" } } svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE) var list []suppliercertappend.OilSupplierCertAppend total := svc.GetPagingEntitiesWithOrderBytbl("", 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 通过Id获取信息 // @Description get user by token // @Success 200 {object} []suppliercertappend.OilSupplierCertAppend // @router /getEntityById/:id [get] func (this *OilSupplierCertAppendController) GetEntityById() { Id := this.Ctx.Input.Param(":id") var model suppliercertappend.OilSupplierCertAppend svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE) svc.GetEntityByIdBytbl(OilSupplierCertAppendName, Id, &model) this.Data["json"] = &model this.ServeJSON() } // @Title 获取公司信息 // @Description 根据创建用户Id和增项类别号获取公司信息 // @Success 200 {object} []suppliercertappend.OilSupplierCertAppend // @router /getsupplier [get] func (this *OilSupplierCertAppendController) GetSupplier() { SuppTypeCode := this.GetString("SuppTypeCode") svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE) where := "1=1 " if SuppTypeCode != "" { where = " WHERE b.Id is NOT NULL AND a.SupplierTypeCode = '" + SuppTypeCode + "' and a.InFlag='1'" }else { where = " WHERE b.Id is NOT NULL AND a.InFlag='1'" } var registerUser register.OilCorporateInfo sql := " UserName='" + this.User.Username + "'" svc.GetEntity(®isterUser,sql) //企业用户必须加创建人条件 if this.User.IsCompanyUser == 1 { where = where + " and (b.CreateUserId = '" + this.User.Id + "' or b.CommercialNo='"+registerUser.CommercialNo+"')" //if this.User.IsCompanyUser == 1 { // where = where + " and b.CreateUserId = '" + this.User.Id + "'" } sqlStr := "SELECT b.Id AS SupplierId, a.Id AS SupplierCertId, b.SupplierName AS SupplierName FROM OilSupplierCert AS a LEFT JOIN OilSupplier AS b ON a.SupplierId = b.Id " sqlStr = sqlStr + where model, _ := svc.DBE.QueryString(sqlStr) this.Data["json"] = &model this.ServeJSON() } // @Title 添加 // @Description 添加增项信息 // @Success 200 {object} controllers.Request // @router /addappend [post] func (this *OilSupplierCertAppendController) AddAppend() { var errinfo DataEntryInfo var jsonblob = this.Ctx.Input.RequestBody var cermodel suppliercert.OilSupplierCert var model suppliercertappend.OilSupplierCertAppend json.Unmarshal(jsonblob, &model) where := " Id = "+ utils.ToStr(model.SupplierCertId)+ " and SupplierTypeCode = '"+ model.AppendType +"'" svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE) where_app := " SupplierCertId = "+ utils.ToStr(model.SupplierCertId)+ " and SupplierId = "+ utils.ToStr(model.SupplierId)+ " and AppendType = '"+ model.AppendType +"'" where_app += " and Status < 6" has := svc.GetEntityByWhere(OilSupplierCertAppendName, where_app, &model) if has { errinfo.Message = "已提交增项申请,审批通过后才可再提交申请!" errinfo.Code = -1 errinfo.Info = model.Id this.Data["json"] = &errinfo this.ServeJSON() } svc.GetEntityByWhere(OilSupplierCertName, where, &cermodel) //if cermodel.Status != "8" { // errinfo.Message = "入库后才能提交增项!" // errinfo.Code = -1 // this.Data["json"] = &errinfo // this.ServeJSON() // return //} //添加增项信息 model.InStyle = cermodel.InStyle model.ApplyDate = time.Now() //申请日期 model.CreateOn = time.Now() model.CreateBy = this.User.Realname model.CreateUserId, _ = utils.StrTo(this.User.Id).Int() _, err := svc.InsertEntityBytbl(OilSupplierCertAppendName, &model) //查询准入范围 var certsublist []suppliercertsub.OilSupplierCertSub suwhere := " SupplierCertId = "+ utils.ToStr(model.SupplierCertId)+ " and SupplierTypeCode = "+ model.AppendType svc.GetEntitysByWhere(OilSupplierCertSubName, suwhere, &certsublist) if err == nil { errinfo.Message = "操作成功!" errinfo.Code = 0 errinfo.Item = certsublist errinfo.Info = 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 *OilSupplierCertAppendController) UpdateEntity() { var errinfo ErrorInfo var model suppliercertappend.OilSupplierCertAppend id := this.Ctx.Input.Param(":id") if id == "" { errinfo.Message = "操作失败!请求信息不完整" errinfo.Code = -2 this.Data["json"] = &errinfo this.ServeJSON() return } svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE) var jsonBlob = this.Ctx.Input.RequestBody json.Unmarshal(jsonBlob, &model) model.ApplyDate = time.Now() //更新申请日期 model.ModifiedOn = time.Now() model.ModifiedBy = this.User.Realname model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int() cols := []string{ "Id", "ApplyDate", "RecUnitFlag", "RecUnitId", "RecUnitName", "WorkRange", "Remark", "ModifiedOn", "ModifiedUserId", "ModifiedBy", } err := svc.UpdateEntityBytbl(OilSupplierCertAppendName, 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 *OilSupplierCertAppendController) DeleteEntity() { Id := this.Ctx.Input.Param(":Id") var errinfo ErrorInfo if Id == "" { errinfo.Message = "操作失败!请求信息不完整" errinfo.Code = -2 this.Data["json"] = &errinfo this.ServeJSON() return } //定义session var session *xorm.Session session = utils.DBE.NewSession() svc := suppliercertappend.GetOilSupplierCertAppendSession(session) svcSub := suppliercertappendsub.GetOilSupplierCertAppendSubSession(session) //"session开始" 之前,首先定义 "session关闭" defer session.Close() err := session.Begin() where := "SupplierCertAppendId = " + Id //删除资质表信息 var submodel []suppliercertsub.OilSupplierCertSub svc.GetEntitysByWhere(OilSupplierCertSubName,where,&submodel) if len(submodel) > 0 { filewhere := " SupplierId = "+ utils.ToStr(submodel[0].SupplierId) + " and SupType = 2 and SupplierTypeCode = '"+ submodel[0].SupplierTypeCode +"'" err = svcSub.DeleteEntityBytbl(OilSupplierFileName, filewhere) if err != nil { //回滚操作 session.Rollback() } } //删除准入范围表信息 err = svcSub.DeleteEntityBytbl(OilSupplierCertSubName, where) if err != nil { //回滚操作 session.Rollback() } //最后删除主表信息 var model suppliercertappend.OilSupplierCertAppend var entityempty suppliercertappend.OilSupplierCertAppend opdesc := "删除-" + Id err = svc.DeleteOperationAndWriteLogBytbl(OilSupplierCertAppendName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "增项信息") if err != nil { session.Rollback() } //提交操作 err = session.Commit() 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 get user by token // @Success 200 {object} []supplier.OilSupplierView // @router /mytasks [get] func (this *OilSupplierCertAppendController) GetMyTaskEntityList() { //获取分页信息 page := this.GetPageInfoForm() where := " 1=1 " orderby := "Id" asc := false Order := this.GetString("Order") where = where + " and Status>0" Prop := this.GetString("Prop") if Order != "" && Prop != "" { orderby = Prop if Order == "asc" { asc = true } } ApplyDate := this.GetString("ApplyDate") RecUnitId := this.GetString("RecUnitId") RecUnitName := this.GetString("RecUnitName") AppendType := this.GetString("AppendType") DenyReason := this.GetString("DenyReason") AuditDate := this.GetString("AuditDate") Remark := this.GetString("Remark") CreateOn := this.GetString("CreateOn") if ApplyDate != "" { where = where + " and ApplyDate like '%" + ApplyDate + "%'" } if RecUnitId != "" { where = where + " and RecUnitId like '%" + RecUnitId + "%'" } if RecUnitName != "" { where = where + " and RecUnitName like '%" + RecUnitName + "%'" } if AppendType != "" { where = where + " and AppendType like '" + AppendType + "'" } if DenyReason != "" { where = where + " and DenyReason like '%" + DenyReason + "%'" } if AuditDate != "" { where = where + " and AuditDate like '%" + AuditDate + "%'" } if Remark != "" { where = where + " and Remark like '%" + Remark + "%'" } if CreateOn != "" { dates := strings.Split(CreateOn, ",") if len(dates) == 2 { minDate := dates[0] maxDate := dates[1] where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'" } } //找出待办任务 actisvc := workflow.GetActivitiService(utils.DBE) var appendIdList string if actisvc.GetMyTasks(workflow.OIL_APPEND_APPLY, this.User.Id) != "" { appendIdList = actisvc.GetMyTasks(workflow.OIL_APPEND_APPLY, this.User.Id) appendIdList = appendIdList + "," } if actisvc.GetMyTasks(workflow.OIL_FIRST_APPEND_APPLY, this.User.Id) != "" { appendIdList = fmt.Sprintf("%s %s", appendIdList, actisvc.GetMyTasks(workflow.OIL_FIRST_APPEND_APPLY, this.User.Id)) appendIdList = appendIdList + "," } if actisvc.GetMyTasks(workflow.OIL_SECOND_APPEND_APPLY, this.User.Id) != "" { appendIdList = fmt.Sprintf("%s %s", appendIdList, actisvc.GetMyTasks(workflow.OIL_SECOND_APPEND_APPLY, this.User.Id)) appendIdList = appendIdList + "," } appendIdList = strings.Trim(appendIdList, ",") appendIdarr := strings.Split(appendIdList, ",") for i, item := range appendIdarr { idx := strings.Index(item,"-") if (idx >= 0 ) { appendIdarr[i] = strings.Split(item, "-")[0] } } appendIdList = strings.Join(appendIdarr, ",") var list []suppliercertappend.OilSupplierCertAppend var total int64 = 0 if (appendIdList != "") { where += " and Id in (" + appendIdList + ")" svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE) total = svc.GetPagingEntitiesWithOrderBytbl("", 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 提交审批 // @Success 200 {object} controllers.Request // @router /audit/:id [post] func (this *OilSupplierCertAppendController) AuditEntity() { certappendId := this.Ctx.Input.Param(":id") firstAudit := this.GetString("FirstAuditName") SecondAudit := this.GetString("SecondAudit") ThirdAudit := this.GetString("ThirdAudit") AuditRemark := this.GetString("AuditRemark") //取出审批列表 certSrv := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE) var supplierCertAppendEntity suppliercertappend.OilSupplierCertAppend certSrv.GetEntityById(certappendId, &supplierCertAppendEntity) var historworkflowid string historworkflowid = supplierCertAppendEntity.WorkFlowId 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 suppappend suppliercertappend.OilSupplierCertAppend //第二次提交先清空工作流 if supplierCertAppendEntity.AuditIndex > 0 { suppappend.WorkFlowId = "" cols := []string{ "WorkflowId", } certSrv.UpdateEntityByIdCols(certappendId, suppappend, cols) supplierCertAppendEntity.WorkFlowId = "" } svcActiviti := workflow.GetActivitiService(utils.DBE) processInstanceId := "" businessKey := "" if supplierCertAppendEntity.WorkFlowId == "0" || len(supplierCertAppendEntity.WorkFlowId) <= 0 { //启动工作流 businessKey = certappendId + "-" + strconv.Itoa(supplierCertAppendEntity.AuditIndex) if this.User.IsCompanyUser == 1 { if supplierCertAppendEntity.InStyle == "2" { processInstanceId = svcActiviti.StartProcess(workflow.OIL_FIRST_ENUSER_APPEND_APPLY, businessKey, this.User.Id) } else if supplierCertAppendEntity.InStyle == "3" { processInstanceId = svcActiviti.StartProcess(workflow.OIL_SECOND_ENUSER_APPEND_APPLY, businessKey, this.User.Id) } else { processInstanceId = svcActiviti.StartProcess(workflow.OIL_ENUSER_APPEND_APPLY, businessKey, this.User.Id) } }else if this.User.IsCompanyUser == 0 { if supplierCertAppendEntity.InStyle == "2" { processInstanceId = svcActiviti.StartProcess(workflow.OIL_FIRST_APPEND_APPLY, businessKey, this.User.Id) }else if supplierCertAppendEntity.InStyle == "3" { processInstanceId = svcActiviti.StartProcess(workflow.OIL_SECOND_APPEND_APPLY, businessKey, this.User.Id) }else { processInstanceId = svcActiviti.StartProcess(workflow.OIL_APPEND_APPLY, businessKey, this.User.Id) } } } var ActiComplete workflow.ActiCompleteVM if this.User.IsCompanyUser == 1 { if supplierCertAppendEntity.InStyle == "2" { ActiComplete.ProcessKey = workflow.OIL_FIRST_ENUSER_APPEND_APPLY } else if supplierCertAppendEntity.InStyle == "3" { ActiComplete.ProcessKey = workflow.OIL_SECOND_ENUSER_APPEND_APPLY } else { ActiComplete.ProcessKey = workflow.OIL_ENUSER_APPEND_APPLY } }else if this.User.IsCompanyUser == 0 { if supplierCertAppendEntity.InStyle == "2" { ActiComplete.ProcessKey = workflow.OIL_FIRST_APPEND_APPLY }else if supplierCertAppendEntity.InStyle == "3" { ActiComplete.ProcessKey = workflow.OIL_SECOND_APPEND_APPLY }else{ ActiComplete.ProcessKey = workflow.OIL_APPEND_APPLY } } ActiComplete.BusinessKey = businessKey ActiComplete.UserNames = firstAudit ActiComplete.UserId = this.User.Id ActiComplete.Result = "1" ActiComplete.Remarks = AuditRemark ActiComplete.CallbackUrl = "" receiveVal := svcActiviti.TaskComplete(ActiComplete) if receiveVal == "true" { if supplierCertAppendEntity.AuditIndex > 0 { // 审批历史 var audithistoryentity audithistory.Base_AuditHistory audithistoryentity.EntityId, _ = strconv.Atoi(certappendId) audithistoryentity.WorkflowId = historworkflowid audithistoryentity.Process = workflow.OIL_APPEND_APPLY audithistoryentity.BusinessKey = businessKey audithistoryentity.Type = supplierCertAppendEntity.AppendType audithistoryentity.BackStep = supplierCertAppendEntity.Status audithistoryentity.Index = supplierCertAppendEntity.AuditIndex audithistoryentity.CreateOn = time.Now() audithistoryentity.CreateBy = this.User.Realname audithistoryentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int() certSrv.InsertEntity(audithistoryentity) } errinfo.Message = "提交成功!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() } else { errinfo.Message = "工作流异常,请联系管理员!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态 var model suppliercertappend.OilSupplierCertAppend model.WorkFlowId = processInstanceId if this.User.IsCompanyUser == 1 { model.Status = suppliercert.FEN_TRIAL_STATUS //分办 }else if this.User.IsCompanyUser == 0 { model.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审 } model.FirstAudit, _ = strconv.Atoi(firstAudit) model.SecondAudit, _ = strconv.Atoi(SecondAudit) model.ThirdAudit, _ = strconv.Atoi(ThirdAudit) model.AuditIndex = supplierCertAppendEntity.AuditIndex model.BusinessKey = businessKey model.ProcessKey = ActiComplete.ProcessKey cols := []string{ "Id", "WorkFlowId", "Status", "FirstAudit", "SecondAudit", "ThirdAudit", "AuditIndex", "BusinessKey", "ProcessKey", } certSrv.UpdateEntityByIdCols(certappendId, model, cols) } // @Title 审批 // @Description 审批 // @Param body body suppliercert.OilSupplierCert // @Success 200 {object} controllers.Request // @router /auditEntityFir/:id [post] func (this *OilSupplierCertAppendController) AuditEntityFir() { appendId := this.Ctx.Input.Param(":id") firstAudit := this.GetString("FirstAuditName") secondAudit := this.GetString("SecondAudit") thirdAudit := this.GetString("ThirdAudit") //取出审批列表 //certSrv := suppliercert.GetOilSupplierCertService(utils.DBE) svc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE) var supplierCertAppendEntity suppliercertappend.OilSupplierCertAppend svc.GetEntityById(appendId, &supplierCertAppendEntity) var jsonblob = this.Ctx.Input.RequestBody var dataother AppShenHeModel 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() } }() step := 2 status := "" backstatus := "0" var userIds string if supplierCertAppendEntity.Status == suppliercert.FEN_TRIAL_STATUS { userIds = firstAudit status = suppliercert.FIRST_TRIAL_STATUS step = 2 supplierCertAppendEntity.FirstAudit, _ = strconv.Atoi(firstAudit) supplierCertAppendEntity.SecondAudit,_ = strconv.Atoi(secondAudit) supplierCertAppendEntity.ThirdAudit,_ = strconv.Atoi(thirdAudit) cols := []string{ "Id", "FirstAudit", "SecondAudit", "ThirdAudit", } svc.UpdateEntityByIdCols(appendId, supplierCertAppendEntity, cols) } if supplierCertAppendEntity.Status == suppliercert.FIRST_TRIAL_STATUS { userIds = utils.ToStr(supplierCertAppendEntity.SecondAudit) status = suppliercert.SECOND_TRIAL_STATUS step = 2 backstatus = suppliercert.NOPASS_STATUS } else if supplierCertAppendEntity.Status == suppliercert.SECOND_TRIAL_STATUS { svc := organize.GetOrganizeService(utils.DBE) unitId := svc.GetMyUnitDepartmentId(strconv.Itoa(supplierCertAppendEntity.ThirdAudit)) var userlist []userRole.Base_User var setting auditsetting.Base_OilAuditSetting usvc := userRole.GetUserService(utils.DBE) if supplierCertAppendEntity.InStyle == "2" { status = suppliercert.CENT_AUDIT_STATUS where := "AuditStepCode='" + workflow.PROF_REGULATION + "'" usvc.GetEntity(&setting, where) paramSvc := baseparameter.GetBaseparameterService(utils.DBE) topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT") ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId)) tempstr := strings.Join(ids, ",") uids := strings.Replace(tempstr, "uid_", "", -1) uids = strings.Trim(uids, ",") if uids != "" { where := "Id in (" + uids + ")" + " and UnitId=" + topid usvc.GetEntities(&userlist, where) } } else { status = suppliercert.THIRD_TRIAL_STATUS where := "AuditStepCode='" + workflow.PROF_RECE + "'" svc.GetEntity(&setting, where) ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId)) tempstr := strings.Join(ids, ",") uids := strings.Replace(tempstr, "uid_", "", -1) uids = strings.Trim(uids, ",") if uids != "" { where := "Id in (" + uids + ")" + " and UnitId=" + unitId svc.GetEntities(&userlist, where) } } for _, tmpUser := range userlist { userIds += strconv.Itoa(tmpUser.Id) + "," //strconv.FormatInt(tmpUser.Id, 10) + "," } userIds = strings.Trim(userIds, ",") step = 2 backstatus = suppliercert.NO_SECOND_TRIAL_STATUS } else if supplierCertAppendEntity.Status == suppliercert.THIRD_TRIAL_STATUS { userIds = utils.ToStr(dataother.Auditer) status = suppliercert.PROF_AUDIT_STATUS step = 2 backstatus = suppliercert.NO_THIRD_TRIAL_STATUS } else if supplierCertAppendEntity.Status == suppliercert.PROF_AUDIT_STATUS { if supplierCertAppendEntity.InStyle == "3" { status = suppliercert.PAYING_AUDIT_STATUS step = 3 backstatus = suppliercert.NO_CENT_AUDIT_STATUS } else { status = suppliercert.CENT_AUDIT_STATUS step = 2 backstatus = suppliercert.NO_PROF_AUDIT_STATUS paramSvc := baseparameter.GetBaseparameterService(utils.DBE) topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT") var userlist []userRole.Base_User var setting auditsetting.Base_OilAuditSetting usvc := userRole.GetUserService(utils.DBE) where := "AuditStepCode='" + workflow.PROF_REGULATION + "'" usvc.GetEntity(&setting, where) ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId)) tempstr := strings.Join(ids, ",") uids := strings.Replace(tempstr, "uid_", "", -1) uids = strings.Trim(uids, ",") if uids != "" { where := "Id in (" + uids + ")" + " and UnitId=" + topid usvc.GetEntities(&userlist, where) } for _, tmpUser := range userlist { userIds += strconv.Itoa(tmpUser.Id) + "," } userIds = strings.Trim(userIds, ",") } } else if supplierCertAppendEntity.Status == suppliercert.CENT_AUDIT_STATUS { userIds = utils.ToStr(dataother.Auditer) status = suppliercert.PAYING_AUDIT_STATUS step = 3 backstatus = suppliercert.NO_CENT_AUDIT_STATUS } svcActiviti := workflow.GetActivitiService(utils.DBE) var ActiComplete workflow.ActiCompleteVM ActiComplete.ProcessKey = supplierCertAppendEntity.ProcessKey ActiComplete.BusinessKey = supplierCertAppendEntity.BusinessKey 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" { supplierCertAppendEntity.Status = status supplierCertAppendEntity.Step = step cols := []string{ "Status", "Step", } svc.UpdateEntityByIdCols(appendId, supplierCertAppendEntity, cols) if supplierCertAppendEntity.Status == "5" { if supplierCertAppendEntity.InStyle == "1" { paysvc := paymentinfo.GetPaymentService(utils.DBE) var Amount float64 if supplierCertAppendEntity.AppendType == "01" { Amount = 6000 } else if supplierCertAppendEntity.AppendType == "02" { Amount = 7000 } else if supplierCertAppendEntity.AppendType == "03" { Amount = 8000 } var payinfo paymentinfo.OilPaymentInfo payinfo.SupplierId = supplierCertAppendEntity.SupplierId payinfo.SupplierCertId = supplierCertAppendEntity.SupplierCertId payinfo.PayType = "3" payinfo.IsPay = "1" payinfo.Amount = strconv.FormatFloat(Amount,'E',-1,64) payinfo.CreateUserId = supplierCertAppendEntity.CreateUserId payinfo.CreateBy = supplierCertAppendEntity.CreateBy payinfo.CreateOn = time.Now() paysvc.InsertEntity(&payinfo) //paysvc.AddPaymentinfo(supplierCertAppendEntity.SupplierId, supplierCertAppendEntity.Id, Amount, "3") } } 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" { if supplierCertAppendEntity.Status == "5" { supplierCertAppendEntity.Status = backstatus supplierCertAppendEntity.Step = step supplierCertAppendEntity.AuditIndex = supplierCertAppendEntity.AuditIndex + 1 }else { supplierCertAppendEntity.Status = "-1" supplierCertAppendEntity.Status = "0" supplierCertAppendEntity.Step = 1 supplierCertAppendEntity.AuditIndex = supplierCertAppendEntity.AuditIndex + 1 } cols := []string{ "Status", "Step", "AuditIndex", } _,err := svc.UpdateEntityByIdCols(appendId, supplierCertAppendEntity, cols) if err == nil { errinfo.Message = "提交成功!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() }else { errinfo.Message = "提交失败!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() } } else { errinfo.Message = "工作流异常,请联系管理员!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } } }