package oilsupplier import ( "dashoo.cn/backend/api/business/audithistory" "dashoo.cn/backend/api/business/codecsequence" msg2 "dashoo.cn/backend/api/business/msg" "dashoo.cn/backend/api/business/oilsupplier/annualaudit" "dashoo.cn/backend/api/business/oilsupplier/infochange" "dashoo.cn/backend/api/business/oilsupplier/oilactivity" "dashoo.cn/backend/api/business/oilsupplier/oilcostmanage" "dashoo.cn/backend/api/business/oilsupplier/supplier" "dashoo.cn/backend/api/business/oilsupplier/supplierapplytime" "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend" "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub" "dashoo.cn/backend/api/business/oilsupplier/supplierfile" "dashoo.cn/backend/api/business/organize" "dashoo.cn/backend/api/business/paymentinfo" "dashoo.cn/business2/parameter" "encoding/json" "fmt" "strconv" "strings" "time" "unicode/utf8" "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/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} controllers.Request // @router /updatestorage/:id [post] func (this *OilSupplierCertController) UpdateStorage() { id := this.Ctx.Input.Param(":id") status := this.GetString("Status") PACNumber := this.GetString("PACNumber") SupplierId := this.GetString("SupplierId") 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) var err error if status == suppliercert.NO_CENT_AUDIT_STATUS { model.Status = suppliercert.DRAFT_STATUS cols := []string{ "Status", } err = svc.UpdateEntityBytbl(OilSupplierCertName, id, &model, cols) } else { var activity oilactivity.OilActivity where := "EntityId=" + id + " and ActType='" + oilactivity.STORAGE + "'" svc.GetEntity(&activity, where) svcActiviti := workflow.GetActivitiService(utils.DBE) var ActiComplete workflow.ActiCompleteVM ActiComplete.ProcessKey = activity.ProcessKey ActiComplete.BusinessKey = activity.BusinessKey ActiComplete.UserId = this.User.Id ActiComplete.Remarks = "" ActiComplete.Result = "1" receiveVal := svcActiviti.TaskComplete(ActiComplete) fmt.Println(receiveVal) model.Status = suppliercert.STORE_STATUS model.Step = 7 model.StorageOn = time.Now() model.ApplyTime = time.Now().AddDate(1, 0, 0) model.InFlag = "1" model.ModifiedOn = time.Now() model.ModifiedBy = this.User.Realname model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int() cols := []string{ "Step", "Status", "ApplyTime", "InFlag", "StorageOn", "ModifiedOn", "ModifiedUserId", "ModifiedBy", } err = svc.UpdateEntityBytbl(OilSupplierCertName, id, &model, cols) var model2 suppliercertsub.OilSupplierCertSub model2.CertSubStatus = "1" whereid := " SupplierCertId = " + id svc.UpdateEntityBywheretbl(OilSupplierCertSubName, &model2, []string{"CertSubStatus"}, whereid) var model3 supplier.OilSupplier model3.PACNumber = PACNumber cols3 := []string{"PACNumber"} svc.UpdateEntityByIdCols(SupplierId, &model3, cols3) } 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") secondAudit := this.GetString("SecondAudit") thirdAudit := this.GetString("ThirdAudit") typeCode := this.GetString("TypeCode") var setting auditsetting.Base_OilAuditSetting var userlist []userRole.Base_User usvc := userRole.GetUserService(utils.DBE) where := "" if this.User.IsCompanyUser == 1 { if typeCode == "01" { where = "AuditStepCode='" + workflow.SUB_OFFICE_WZ + "'" } else if typeCode == "02" { where = "AuditStepCode='" + workflow.SUB_OFFICE_JS + "'" } else if typeCode == "03" { where = "AuditStepCode='" + workflow.SUB_OFFICE_JF + "'" } 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=" + firstAudit usvc.GetEntities(&userlist, where) } userIds := "" for _, tmpUser := range userlist { userIds += strconv.Itoa(tmpUser.Id) + "," } firstAudit = strings.Trim(userIds, ",") } //取出审批列表 certSrv := suppliercert.GetOilSupplierCertService(utils.DBE) var supplierCertEntity suppliercert.OilSupplierCert certSrv.GetEntityById(certId, &supplierCertEntity) //取出企业主表 supplierSvc := supplier.GetOilSupplierService(utils.DBE) var supplierEntity supplier.OilSupplier supplierSvc.GetEntityById(supplierCertEntity.SupplierId, &supplierEntity) svc := organize.GetOrganizeService(utils.DBE) unitId := svc.GetMyUnitDepartmentId(this.User.DepartmentId) 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 := "" businessKey := "" result := strconv.Itoa(this.User.IsCompanyUser) status, _ := strconv.Atoi(supplierCertEntity.Status) if status <= 0 { //启动工作流 businessKey = certId + "-" + strconv.Itoa(supplierCertEntity.AuditIndex) // 1 评审准入 2 一级物资备案准入 3 二级物资备案准入 4 战略合作准入 5 内部多元准入 6 外部市场准入 if supplierCertEntity.InStyle == "2" || supplierCertEntity.InStyle == "4" || supplierCertEntity.InStyle == "6" { processInstanceId = svcActiviti.StartProcess2(workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY, businessKey, this.User.Id, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName) } else if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit == supplier.MGRUNIT { processInstanceId = svcActiviti.StartProcess2(workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY, businessKey, this.User.Id, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName) } else if supplierCertEntity.InStyle == "1" || supplierCertEntity.InStyle == "5" { processInstanceId = svcActiviti.StartProcess2(workflow.OIL_ENUSER_SUPPLIER_APPLY, businessKey, this.User.Id, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName) } else if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit != supplier.MGRUNIT { // 二级物资准入(除大港油田外的其他公司) processInstanceId = svcActiviti.StartProcess2(workflow.OIL_SECOND_OTHER_SUPPLIER_APPLY, businessKey, this.User.Id, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName) } } 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 if supplierCertEntity.InStyle == "2" || supplierCertEntity.InStyle == "4" || supplierCertEntity.InStyle == "6" { ActiComplete.ProcessKey = workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY } else if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit == supplier.MGRUNIT { ActiComplete.ProcessKey = workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY } else if supplierCertEntity.InStyle == "1" || supplierCertEntity.InStyle == "5" { ActiComplete.ProcessKey = workflow.OIL_ENUSER_SUPPLIER_APPLY } else if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit != supplier.MGRUNIT { ActiComplete.ProcessKey = workflow.OIL_SECOND_OTHER_SUPPLIER_APPLY } //if this.User.IsCompanyUser == 1 { // if supplierCertEntity.InStyle == "2" || supplierCertEntity.InStyle == "4" || supplierCertEntity.InStyle == "6" { // ActiComplete.ProcessKey = workflow.OIL_FIRST_ENUSER_SUPPLIER_APPLY // } else if supplierCertEntity.InStyle == "3" { // ActiComplete.ProcessKey = workflow.OIL_SECOND_ENUSER_SUPPLIER_APPLY // } else if supplierCertEntity.InStyle == "1" || supplierCertEntity.InStyle == "5" { // ActiComplete.ProcessKey = workflow.OIL_ENUSER_SUPPLIER_APPLY // } //}else if this.User.IsCompanyUser == 0 { // if supplierCertEntity.InStyle == "2" || supplierCertEntity.InStyle == "4" || supplierCertEntity.InStyle == "6" { // ActiComplete.ProcessKey = workflow.OIL_FIRST_SUPPLIER_APPLY // } else if supplierCertEntity.InStyle == "3" { // ActiComplete.ProcessKey = workflow.OIL_SECOND_SUPPLIER_APPLY // } else if supplierCertEntity.InStyle == "1" || supplierCertEntity.InStyle == "5" { // ActiComplete.ProcessKey = workflow.OIL_ENUSER_SUPPLIER_APPLY // } //} ActiComplete.BusinessKey = businessKey ActiComplete.UserNames = firstAudit ActiComplete.UserId = this.User.Id ActiComplete.Result = result ActiComplete.Remarks = AuditRemark ActiComplete.CallbackUrl = "" receiveVal := svcActiviti.TaskComplete(ActiComplete) var audithistoryentity audithistory.Base_AuditHistory audithistoryentity.EntityId = supplierCertEntity.Id audithistoryentity.WorkflowId = supplierCertEntity.WorkflowId audithistoryentity.Process = ActiComplete.ProcessKey audithistoryentity.BusinessKey = ActiComplete.BusinessKey audithistoryentity.Type = supplierCertEntity.SupplierTypeCode audithistoryentity.BackStep = supplierCertEntity.Status audithistoryentity.Index = supplierCertEntity.AuditIndex audithistoryentity.CreateOn = time.Now() audithistoryentity.CreateBy = this.User.Realname audithistoryentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int() certSrv.InsertEntity(audithistoryentity) 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 if this.User.IsCompanyUser == 1 { supplierCertEntity.Status = suppliercert.FEN_TRIAL_STATUS //分办 } else if this.User.IsCompanyUser == 0 { supplierCertEntity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审 } supplierCertEntity.Step = 2 supplierCertEntity.FirstAudit, _ = strconv.Atoi(firstAudit) supplierCertEntity.AuditIndex = supplierCertEntity.AuditIndex + 1 supplierCertEntity.BusinessKey = ActiComplete.BusinessKey supplierCertEntity.SecondAudit, _ = strconv.Atoi(secondAudit) supplierCertEntity.ThirdAudit, _ = strconv.Atoi(thirdAudit) supplierCertEntity.ProcessKey = ActiComplete.ProcessKey supplierCertEntity.CommitComId = unitId cols := []string{ "Id", "WorkflowId", "Status", "Step", "FirstAudit", "AuditIndex", "BusinessKey", "SecondAudit", "ThirdAudit", "ProcessKey", "CommitComId", } 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_ENUSER_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 审批 // @Param body body suppliercert.OilSupplierCert // @Success 200 {object} controllers.Request // @router /auditEntityFir/:id [post] func (this *OilSupplierCertController) AuditEntityFir() { var dataother ShenHeModel certId := this.Ctx.Input.Param(":id") auditer := this.GetString("auditer") firstAudit := this.GetString("FirstAuditName") AuditRemark := this.GetString("AuditRemark") secondAudit := this.GetString("SecondAudit") thirdAudit := this.GetString("ThirdAudit") //majorDept := this.GetString("majorDept") //取出审批列表 certSrv := suppliercert.GetOilSupplierCertService(utils.DBE) var supplierCertEntity suppliercert.OilSupplierCert var supplierEntity supplier.OilSupplier certSrv.GetEntityById(certId, &supplierCertEntity) wheresup := "Id=" + strconv.Itoa(supplierCertEntity.SupplierId) certSrv.GetEntity(&supplierEntity, wheresup) var jsonblob = this.Ctx.Input.RequestBody json.Unmarshal(jsonblob, &dataother) if AuditRemark != "" { dataother.AuditorRemark = AuditRemark } 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 := "" backstatus := "0" var userIds string if supplierCertEntity.Status == suppliercert.FEN_TRIAL_STATUS { userIds = firstAudit status = suppliercert.FIRST_TRIAL_STATUS backstatus = suppliercert.NO_FEN_TRIAL_STATUS step = 2 if dataother.SuccessStatus == 1 { supplierCertEntity.Step = 2 supplierCertEntity.FirstAudit, _ = strconv.Atoi(firstAudit) supplierCertEntity.SecondAudit, _ = strconv.Atoi(secondAudit) supplierCertEntity.ThirdAudit, _ = strconv.Atoi(thirdAudit) cols := []string{ "Id", "Step", "FirstAudit", "SecondAudit", "ThirdAudit", } certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols) } } if supplierCertEntity.Status == suppliercert.FIRST_TRIAL_STATUS { userIds = utils.ToStr(supplierCertEntity.SecondAudit) status = suppliercert.SECOND_TRIAL_STATUS backstatus = suppliercert.NOPASS_STATUS step = 2 //supplierCertEntity.ThirdAudit,_ = strconv.Atoi(majorDept) //cols := []string{ // "ThirdAudit", //} //certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols) } else if supplierCertEntity.Status == suppliercert.SECOND_TRIAL_STATUS { step = 2 backstatus = suppliercert.NO_SECOND_TRIAL_STATUS svc := organize.GetOrganizeService(utils.DBE) unitId := svc.GetMyUnitDepartmentId(strconv.Itoa(supplierCertEntity.ThirdAudit)) var userlist []userRole.Base_User var setting auditsetting.Base_OilAuditSetting usvc := userRole.GetUserService(utils.DBE) if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit == supplier.MGRUNIT { status = suppliercert.THIRD_TRIAL_STATUS where := "AuditStepCode='" + workflow.PROF_RECE + "'" 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=" + strconv.Itoa(supplierCertEntity.ThirdAudit) usvc.GetEntities(&userlist, where) } } else if supplierCertEntity.InStyle == "3" && supplierEntity.MgrUnit != supplier.MGRUNIT { 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 supplierCertEntity.InStyle == "2" || supplierCertEntity.InStyle == "4" || supplierCertEntity.InStyle == "6" { svcActiviti := workflow.GetActivitiService(utils.DBE) businessKey := strconv.Itoa(supplierCertEntity.Id) result := "1" userIds := "" var userlist []userRole.Base_User var setting auditsetting.Base_OilAuditSetting usvc := userRole.GetUserService(utils.DBE) where := "AuditStepCode='" + workflow.PROF_REGULATION + "'" certSrv.GetEntity(&setting, where) ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId)) tempstr := strings.Join(ids, ",") uids := strings.Replace(tempstr, "uid_", "", -1) uids = strings.Trim(uids, ",") paramSvc := baseparameter.GetBaseparameterService(utils.DBE) topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT") if uids != "" { where := "Id in (" + uids + ")" + " and UnitId=" + topid paramSvc.GetEntities(&userlist, where) } for _, tmpUser := range userlist { userIds += strconv.Itoa(tmpUser.Id) + "," //strconv.FormatInt(tmpUser.Id, 10) + "," } userIds = strings.Trim(userIds, ",") processInstanceId := svcActiviti.StartProcess2(workflow.OIL_SUPPLIER_INSTORE, businessKey, userIds, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName) //var ActiComplete workflow.ActiCompleteVM //ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_INSTORE //ActiComplete.BusinessKey = businessKey //ActiComplete.UserNames = userIds //ActiComplete.UserId = this.User.Id //ActiComplete.Result = "1" //ActiComplete.Remarks = "" //ActiComplete.CallbackUrl = "" // //res := svcActiviti.TaskComplete(ActiComplete) //fmt.Println(res) var activity oilactivity.OilActivity activity.EntityId = supplierCertEntity.Id activity.ActType = oilactivity.STORAGE activity.WorkflowId = processInstanceId activity.BusinessKey = businessKey activity.ProcessKey = workflow.OIL_SUPPLIER_INSTORE activity.CreateOn = time.Now() certSrv.InsertEntityBytbl(OilActivityName, &activity) status = suppliercert.STOREING_STATUS step = 3 } 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) } } //var users []userRole.Base_RoleList //certSrv.GetAuditUser(strconv.Itoa(supplierCertEntity.ThirdAudit), workflow.PROF_RECE, &users) 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 supplierCertEntity.Status == suppliercert.THIRD_TRIAL_STATUS { userIds = auditer status = suppliercert.PROF_AUDIT_STATUS step = 2 backstatus = suppliercert.NO_THIRD_TRIAL_STATUS } else if supplierCertEntity.Status == suppliercert.PROF_AUDIT_STATUS { if supplierCertEntity.InStyle == "3" { userIds = auditer 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 supplierCertEntity.Status == suppliercert.CENT_AUDIT_STATUS { userIds = 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 = supplierCertEntity.ProcessKey ActiComplete.BusinessKey = supplierCertEntity.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" { if supplierCertEntity.Status == suppliercert.CENT_AUDIT_STATUS { if supplierCertEntity.InStyle == "1" && supplierCertEntity.IsPay == 0{ paysvc := paymentinfo.GetPaymentService(utils.DBE) var Amount float64 asvc := oilcostmanage.GetOilCostManageService(utils.DBE) Amount = asvc.GetAmount("ZHUNRU", supplierCertEntity.SupplierTypeCode) var payinfo paymentinfo.OilPaymentInfo payinfo.SupplierId = supplierCertEntity.SupplierId payinfo.SrcId = supplierCertEntity.Id payinfo.SupplierCertId = supplierCertEntity.Id payinfo.USCCode = supplierEntity.CommercialNo payinfo.SupplierName = supplierEntity.SupplierName payinfo.PayType = "1" payinfo.Amount = strconv.FormatFloat(Amount, 'E', -1, 64) payinfo.IsPay = "0" payinfo.IsInvoice = "0" payinfo.CreateUserId = supplierCertEntity.CreateUserId payinfo.CreateBy = supplierCertEntity.CreateBy payinfo.CreateOn = time.Now() //wheresup := " SupplierCertId=" + strconv.Itoa(supplierCertEntity.Id) //var sup []suppliercertsub.OilSupplierCertSub //total := paysvc.GetPagingEntitiesWithOrder(1, 10, "Id", true, &sup, wheresup) //if supplierCertEntity.SupplierTypeCode == "01" && total <= 50 { // status = suppliercert.STOREING_STATUS // // svcActiviti := workflow.GetActivitiService(utils.DBE) // businessKey := strconv.Itoa(supplierCertEntity.Id) // result := "1" // // userIds := "" // var userlist []userRole.Base_User // var setting auditsetting.Base_OilAuditSetting // usvc := userRole.GetUserService(utils.DBE) // where := "AuditStepCode='" + workflow.PROF_REGULATION + "'" // paysvc.GetEntity(&setting, where) // ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId)) // tempstr := strings.Join(ids, ",") // uids := strings.Replace(tempstr, "uid_", "", -1) // uids = strings.Trim(uids, ",") // paramSvc := baseparameter.GetBaseparameterService(utils.DBE) // topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT") // if uids != "" { // where := "Id in (" + uids + ")" + " and UnitId=" + topid // paramSvc.GetEntities(&userlist, where) // } // // for _, tmpUser := range userlist { // userIds += strconv.Itoa(tmpUser.Id) + "," //strconv.FormatInt(tmpUser.Id, 10) + "," // } // userIds = strings.Trim(userIds, ",") // // processInstanceId := svcActiviti.StartProcess2(workflow.OIL_SUPPLIER_INSTORE, businessKey, userIds, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName) // // //var ActiComplete workflow.ActiCompleteVM // //ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_INSTORE // //ActiComplete.BusinessKey = businessKey // //ActiComplete.UserNames = userIds // //ActiComplete.UserId = this.User.Id // //ActiComplete.Result = "1" // //ActiComplete.Remarks = "" // //ActiComplete.CallbackUrl = "" // // // //res := svcActiviti.TaskComplete(ActiComplete) // //fmt.Println(res) // // var activity oilactivity.OilActivity // activity.EntityId = supplierCertEntity.Id // activity.ActType = oilactivity.STORAGE // activity.WorkflowId = processInstanceId // activity.BusinessKey = businessKey // activity.ProcessKey = workflow.OIL_SUPPLIER_INSTORE // activity.CreateOn = time.Now() // // paysvc.InsertEntityBytbl(OilActivityName, &activity) // //} else { // paysvc.InsertEntity(&payinfo) // //发短信 // toMobile := supplierEntity.Mobile // msg := "您的" + supplierCertEntity.SupplierTypeName + "准入审核通过,请及时确认交费信息!" // msgService := msg2.GetMsgService(utils.DBE) // msgService.HandleMsg(toMobile, msg, "3-1", supplierCertEntity.CreateBy, supplierEntity.ContactName, strconv.Itoa(supplierCertEntity.CreateUserId), this.User.Username) //} paysvc.InsertEntity(&payinfo) //发短信 toMobile := supplierEntity.Mobile msg := "您的" + supplierCertEntity.SupplierTypeName + "准入审核通过,请及时确认信息并交费!" msgService := msg2.GetMsgService(utils.DBE) msgService.HandleMsg(toMobile, msg, "3-1", supplierCertEntity.CreateBy, supplierEntity.ContactName, strconv.Itoa(supplierCertEntity.CreateUserId), this.User.Username) //paysvc.AddPaymentinfo(supplierCertEntity.SupplierId, supplierCertEntity.Id, Amount, "1") supplierCertEntity.Status = status supplierCertEntity.Step = step cols := []string{ "Status", "Step", } certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols) } else { svcActiviti := workflow.GetActivitiService(utils.DBE) businessKey := strconv.Itoa(supplierCertEntity.Id) result := "1" userIds := "" var userlist []userRole.Base_User var setting auditsetting.Base_OilAuditSetting usvc := userRole.GetUserService(utils.DBE) where := "AuditStepCode='" + workflow.PROF_REGULATION + "'" certSrv.GetEntity(&setting, where) ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId)) tempstr := strings.Join(ids, ",") uids := strings.Replace(tempstr, "uid_", "", -1) uids = strings.Trim(uids, ",") paramSvc := baseparameter.GetBaseparameterService(utils.DBE) topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT") if uids != "" { where := "Id in (" + uids + ")" + " and UnitId=" + topid paramSvc.GetEntities(&userlist, where) } for _, tmpUser := range userlist { userIds += strconv.Itoa(tmpUser.Id) + "," //strconv.FormatInt(tmpUser.Id, 10) + "," } userIds = strings.Trim(userIds, ",") processInstanceId := svcActiviti.StartProcess2(workflow.OIL_SUPPLIER_INSTORE, businessKey, userIds, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName) //var ActiComplete workflow.ActiCompleteVM //ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_INSTORE //ActiComplete.BusinessKey = businessKey //ActiComplete.UserNames = userIds //ActiComplete.UserId = this.User.Id //ActiComplete.Result = "1" //ActiComplete.Remarks = "" //ActiComplete.CallbackUrl = "" // //res := svcActiviti.TaskComplete(ActiComplete) //fmt.Println(res) var activity oilactivity.OilActivity activity.EntityId = supplierCertEntity.Id activity.ActType = oilactivity.STORAGE activity.WorkflowId = processInstanceId activity.BusinessKey = businessKey activity.ProcessKey = workflow.OIL_SUPPLIER_INSTORE activity.CreateOn = time.Now() certSrv.InsertEntityBytbl(OilActivityName, &activity) supplierCertEntity.Status = suppliercert.STOREING_STATUS supplierCertEntity.Step = step cols := []string{ "Status", "Step", } certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols) } } else if supplierCertEntity.Status == suppliercert.PROF_AUDIT_STATUS && supplierCertEntity.InStyle == "3" { //if supplierCertEntity.InStyle == "3" { svcActiviti := workflow.GetActivitiService(utils.DBE) businessKey := strconv.Itoa(supplierCertEntity.Id) result := "1" userIds := "" var userlist []userRole.Base_User var setting auditsetting.Base_OilAuditSetting usvc := userRole.GetUserService(utils.DBE) where := "AuditStepCode='" + workflow.PROF_REGULATION + "'" certSrv.GetEntity(&setting, where) ids := usvc.GetUserIdsByRoleId(strconv.Itoa(setting.RoleId)) tempstr := strings.Join(ids, ",") uids := strings.Replace(tempstr, "uid_", "", -1) uids = strings.Trim(uids, ",") paramSvc := baseparameter.GetBaseparameterService(utils.DBE) topid := paramSvc.GetBaseparameterMessage("", "paramset", "CENT_AUDIT") if uids != "" { where := "Id in (" + uids + ")" + " and UnitId=" + topid paramSvc.GetEntities(&userlist, where) } for _, tmpUser := range userlist { userIds += strconv.Itoa(tmpUser.Id) + "," //strconv.FormatInt(tmpUser.Id, 10) + "," } userIds = strings.Trim(userIds, ",") processInstanceId := svcActiviti.StartProcess2(workflow.OIL_SUPPLIER_INSTORE, businessKey, userIds, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName) //var ActiComplete workflow.ActiCompleteVM //ActiComplete.ProcessKey = workflow.OIL_SUPPLIER_INSTORE //ActiComplete.BusinessKey = businessKey //ActiComplete.UserNames = userIds //ActiComplete.UserId = this.User.Id //ActiComplete.Result = "1" //ActiComplete.Remarks = "" //ActiComplete.CallbackUrl = "" // //res := svcActiviti.TaskComplete(ActiComplete) //fmt.Println(res) var activity oilactivity.OilActivity activity.EntityId = supplierCertEntity.Id activity.ActType = oilactivity.STORAGE activity.WorkflowId = processInstanceId activity.BusinessKey = businessKey activity.ProcessKey = workflow.OIL_SUPPLIER_INSTORE activity.CreateOn = time.Now() certSrv.InsertEntityBytbl(OilActivityName, &activity) supplierCertEntity.Status = suppliercert.STOREING_STATUS supplierCertEntity.Step = 3 cols := []string{ "Status", "Step", } certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols) } else { supplierCertEntity.Status = status supplierCertEntity.Step = step 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 } } else { ActiComplete.Result = "0" receiveVal := svcActiviti.TaskComplete(ActiComplete) if receiveVal == "true" { // 审批历史 //var audithistoryentity audithistory.Base_AuditHistory //audithistoryentity.EntityId = supplierCertEntity.Id //audithistoryentity.WorkflowId = supplierCertEntity.WorkflowId //audithistoryentity.Process = ActiComplete.ProcessKey //audithistoryentity.BusinessKey = ActiComplete.BusinessKey //audithistoryentity.Type = supplierCertEntity.SupplierTypeCode //audithistoryentity.BackStep = supplierCertEntity.Status //audithistoryentity.Index = supplierCertEntity.AuditIndex //audithistoryentity.CreateOn = time.Now() //audithistoryentity.CreateBy = this.User.Realname //audithistoryentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int() //certSrv.InsertEntity(audithistoryentity) if supplierCertEntity.Status == suppliercert.CENT_AUDIT_STATUS { supplierCertEntity.Status = suppliercert.NO_CENT_AUDIT_STATUS supplierCertEntity.BackReason = dataother.AuditorRemark cols := []string{ "BackReason", } certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols) } else { supplierCertEntity.Status = backstatus } supplierCertEntity.Step = 1 //supplierCertEntity.WorkflowId = "" cols := []string{ "Status", "Step", //"WorkflowId", } certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols) toMobile := supplierEntity.Mobile msg := "您的" + supplierCertEntity.SupplierTypeName + "准入审核未通过,请及时查看!" msgService := msg2.GetMsgService(utils.DBE) msgService.HandleMsg(toMobile, msg, "4-1", supplierCertEntity.CreateBy, supplierEntity.ContactName, strconv.Itoa(supplierCertEntity.CreateUserId), this.User.Username) 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") processkey := this.GetString("processkey") id := this.GetString("id") //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 // } //} var setting auditsetting.Base_OilAuditSetting svc := organize.GetOrganizeService(utils.DBE) where := "AuditStepCode='" + auditstepcode + "'" svc.GetEntity(&setting, where) res = svc.UserInRoleById(this.User.Id, strconv.Itoa(setting.RoleId)) } 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) var setting auditsetting.Base_OilAuditSetting svc := organize.GetOrganizeService(utils.DBE) where := "AuditStepCode='" + auditstepcode + "'" svc.GetEntity(&setting, where) res = svc.UserInRoleById(this.User.Id, strconv.Itoa(setting.RoleId)) if res { actisvc := workflow.GetActivitiService(utils.DBE) ids := actisvc.GetMyTasks(processkey, this.User.Id) res = strings.Contains(ids, id) } //for _, user := range users { // if this.User.Id == strconv.Itoa(int(user.Id)) { // res = true // break // } //} } this.Data["json"] = res this.ServeJSON() } // @Title 获取准入编码 // @Description 获取准入编码 // @Success 200 {object} controllers.Request // @router /createaccesscardno/:type [get] func (this *OilSupplierCertController) CreateAccessCardNo() { Id := this.GetString("Id") certId := this.GetString(("SupplierCertId")) typeCode := this.Ctx.Input.Param(":type") codecSvc := codecsequence.GetCodecSequenceService(utils.DBE) var entitycert suppliercert.OilSupplierCert var entity supplier.OilSupplier //where := "Id = " + Id //codecSvc.GetEntities(&model, "") seqStr := "" cols := []string{} if (typeCode == "01") { // 物质 has := true for has { seqStr = codecSvc.GetWZAccessCardNo(this.User.AccCode) where := "SupplierTypeCode='" + typeCode + "' and AccessCardNo='" + seqStr + "'" has = codecSvc.GetEntity(&entitycert, where) } cols = []string{"WZAccessCardNo"} entity.WZAccessCardNo = seqStr } else if typeCode == "03" { //技术服务 has := true for has { seqStr = codecSvc.GetJFAccessCardNo(this.User.AccCode) where := "SupplierTypeCode='" + typeCode + "' and AccessCardNo='" + seqStr + "'" has = codecSvc.GetEntity(&entitycert, where) } cols = []string{"JFAccessCardNo"} entity.JFAccessCardNo = seqStr } else if typeCode == "02" { // 基建 has := true for has { seqStr = codecSvc.GetJSAccessCardNo(this.User.AccCode) where := "SupplierTypeCode='" + typeCode + "' and AccessCardNo='" + seqStr + "'" has = codecSvc.GetEntity(&entitycert, where) } cols = []string{"JSAccessCardNo"} entity.JSAccessCardNo = seqStr } codecSvc.UpdateEntityByIdCols(Id, &entity, cols) var cert suppliercert.OilSupplierCert certcols := []string{"AccessCardNo"} cert.AccessCardNo = seqStr codecSvc.UpdateEntityByIdCols(certId, &cert, certcols) this.Data["json"] = seqStr this.ServeJSON() } // @Title 修改准入标识 // @Description 修改准入标识 // @Success 200 {object} controllers.Request // @router /updatainflag/ [get] func (this *OilSupplierCertController) UpdataInFlag() { t := time.Now() session := utils.DBE.NewSession() var certentitys []suppliercert.OilSupplierCert svc := suppliercert.GetOilSupplierCertSession(session) defer func() { session.Close() }() err := session.Begin() svc.GetEntities(&certentitys, "InFlag!='3'") currenttime := time.Now() //.Format("2006-01-02") for i := 0; i < len(certentitys); i++ { if currenttime.After(certentitys[i].ApplyTime) && !currenttime.After(certentitys[i].ApplyTime.AddDate(1, 0, 0)) && certentitys[i].InFlag != "2" { var certentity suppliercert.OilSupplierCert certentity.InFlag = "2" cols := []string{"InFlag"} _, err = svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols) if err != nil { session.Rollback() } } if currenttime.After(certentitys[i].ApplyTime.AddDate(1, 0, 0)) { fmt.Println(time.Now().Format("2006-01-02"), certentitys[i].ApplyTime.AddDate(1, 0, 0).Format("2006-01-02")) var certentity suppliercert.OilSupplierCert certentity.InFlag = "3" cols := []string{"InFlag"} _, err = svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols) if err != nil { session.Rollback() } } } err = session.Commit() fmt.Println(err) elapsed := time.Since(t) fmt.Println(elapsed, "更新准入标识") } // @Title 退回 // @Description // @Success 200 {object} controllers.Request // @router /backstatus/:Id [post] func (this *OilSupplierCertController) BackStatus() { id := this.Ctx.Input.Param(":Id") status := this.GetString("Status") backRemark := this.GetString("BackRemark") var entity suppliercert.OilSupplierCert svc := suppliercert.GetOilSupplierCertService(utils.DBE) cols := []string{"Status", "BackRemark"} entity.Status = status entity.BackRemark = backRemark _, err := svc.UpdateEntityByIdCols(id, &entity, cols) var errinfo ErrorDataInfo if err == nil { var activity oilactivity.OilActivity where := "EntityId=" + id + " and ActType='" + oilactivity.STORAGE + "'" svc.GetEntity(&activity, where) svcActiviti := workflow.GetActivitiService(utils.DBE) var ActiComplete workflow.ActiCompleteVM ActiComplete.ProcessKey = activity.ProcessKey ActiComplete.BusinessKey = activity.BusinessKey ActiComplete.UserId = this.User.Id ActiComplete.Remarks = "" ActiComplete.Result = "1" svcActiviti.TaskComplete(ActiComplete) errinfo.Message = "操作成功!" errinfo.Code = 00 this.Data["json"] = &errinfo this.ServeJSON() } else { errinfo.Message = "操作失败!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() } } // @Title 保存准入编码 // @Description 保存准入编码 // @Success 200 {object} controllers.Request // @router /saveaccesscardno/:Id [get] func (this *OilSupplierCertController) SaveAccessCardNo() { id := this.Ctx.Input.Param(":Id") certId := this.GetString(("SupplierCertId")) typeCode := this.GetString("typeCode") accessCardNo := this.GetString("AccessCardNo") var model []suppliercert.OilSupplierCert var supplier supplier.OilSupplier svc := suppliercert.GetOilSupplierCertService(utils.DBE) where := "AccessCardNo='" + accessCardNo + "'" svc.GetEntities(&model, where) supcols := []string{} if model == nil || len(model) == 0 { if (typeCode == "01") { // 物质 supplier.WZAccessCardNo = accessCardNo supcols = []string{"WZAccessCardNo"} } else if typeCode == "03" { //技术服务 supplier.JFAccessCardNo = accessCardNo supcols = []string{"JFAccessCardNo"} } else if typeCode == "02" { // 基建 supplier.JSAccessCardNo = accessCardNo supcols = []string{"JSAccessCardNo"} } svc.UpdateEntityByIdCols(id, &supplier, supcols) var cert suppliercert.OilSupplierCert certcols := []string{"AccessCardNo"} cert.AccessCardNo = accessCardNo svc.UpdateEntityByIdCols(certId, &cert, certcols) var errinfo ErrorDataInfo errinfo.Message = "保存成功!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() } else { var errinfo ErrorDataInfo errinfo.Message = "准入编码已经存在!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() } } // @Title 快到期短信通知 // @Description 修改准入标识 // @Success 200 {object} controllers.Request // @router /sendingSMS/ [get] func (this *OilSupplierCertController) SendingSMS() { t := time.Now() svcsupp := supplier.GetOilSupplierService(utils.DBE) var list []supplier.OilSupplierView where := "b.InFlag = '1'" svcsupp.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 0, 0, "Id", true, &list, where) currenttime := time.Now() loginName := "TimingTask" if this.User != nil { loginName = this.User.Username } for _, item := range list { if currenttime.AddDate(0, 3, 0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) { toMobile := item.Mobile msg := "您的" + item.SupplierTypeName + "准入还有3个月到期" msgService := msg2.GetMsgService(utils.DBE) msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName) } if currenttime.AddDate(0, 2, 0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) { toMobile := item.Mobile msg := "您的" + item.SupplierTypeName + "准入还有2个月到期" msgService := msg2.GetMsgService(utils.DBE) msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName) } if currenttime.AddDate(0, 1, 0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) { toMobile := item.Mobile msg := "您的" + item.SupplierTypeName + "准入还有1个月到期" msgService := msg2.GetMsgService(utils.DBE) msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName) } } elapsed := time.Since(t) fmt.Println(elapsed, "快到期提醒") } // @Title 资质快到期短信通知 // @Description // @Success 200 {object} controllers.Request // @router /sendingSMSSupplierFile/ [get] func (this *OilSupplierCertController) SendingSMSSupplierFile() { t := time.Now() svcsupp := supplier.GetOilSupplierService(utils.DBE) var expireFile []supplier.ExpireFile where := " b.EffectDate LIKE '%" + time.Now().AddDate(0, 1, 0).Format("2006-01-02") + "%'" err := svcsupp.GetExpireFile(OilSupplierName, OilSupplierFileName, &expireFile, where) if err == nil { for _, item := range expireFile { fileName := "" if utf8.RuneCountInString(item.NeedAllFile) > 50 { fileName = string([]rune(item.NeedAllFile)[0: 50]) fileName = fileName[0: strings.LastIndex(fileName, ";")] + "等资质" } else { fileName = item.NeedAllFile } toMobile := item.Mobile msg := "您的" + fileName + "还有1个月到期" msgService := msg2.GetMsgService(utils.DBE) loginName := "TimingTask" if this.User != nil { loginName = this.User.Username } msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName) } } elapsed := time.Since(t) fmt.Println(elapsed, "资质到期提醒") } // @Title 资质 // @Description // @Success 200 {object} controllers.Request // @router /changeSupplierStatus/ [get] func (this *OilSupplierCertController) ChangeSupplierStatus() { svcsupp := supplier.GetOilSupplierService(utils.DBE) var fileData []supplier.ExpireFileList where := " b.EffectDate LIKE '%" + time.Now().AddDate(0, 0, -1).Format("2006-01-02") + "%'" svcsupp.GetExpireFileList(OilSupplierName, OilSupplierFileName, &fileData, where) for _, item := range fileData { var sert suppliercert.OilSupplierCert cols := []string{ "InFlag", } sert.InFlag = "2" where := "SupplierId=" + strconv.Itoa(item.Id) + " AND InFlag = '1'" if item.SupplierTypeCode != "000" { where = where + " and SupplierTypeCode='" + item.SupplierTypeCode +"'" } svcsupp.UpdateEntityBywheretbl(OilSupplierCertName, &sert, cols, where) } } // @Title 更新Inflag状态 // @Description 企业入库 // @Success 200 {object} controllers.Request // @router /reinput/:id [post] func (this *OilSupplierCertController) ReInput() { id := this.Ctx.Input.Param(":id") var errinfo ErrorInfo if id == "" { errinfo.Message = "操作失败!请求信息不完整" errinfo.Code = -2 this.Data["json"] = &errinfo this.ServeJSON() return } session := utils.DBE.NewSession() svc := suppliercert.GetOilSupplierCertSession(session) defer func() { session.Close() }() err := session.Begin() var model []suppliercert.Del_OilSupplierCert where := "SupplierId=" + id var sql string sql = "select * from " + OilSupplierCertName + " where " + where utils.DBE.SQL(sql).Find(&model) isdelsupplier := false if model != nil && len(model) > 0 { isdelsupplier = true } for _, item := range model { if item.InFlag == "3" { where := "Id=" + strconv.Itoa(item.Id) err = svc.DeleteEntityBytbl(OilSupplierCertName, where) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } item.DeleteDate = time.Now() _, err = svc.InsertEntityBytbl(DelOilSupplierCertName, &item) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } // 交费信息 var delpay []paymentinfo.Del_OilPaymentInfo wherepay := "SupplierCertId=" + strconv.Itoa(model[0].Id) var sqlpay string sqlpay = "select * from " + OilPaymentInfoName + " where " + wherepay utils.DBE.SQL(sqlpay).Find(&delpay) err = svc.DeleteEntityBytbl(OilPaymentInfoName, wherepay) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } for idx, _ := range delpay { delpay[idx].DeleteDate = time.Now() } _, err = svc.InsertEntityBytbl(DelOilPaymentInfoName, &delpay) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } // 删除增项记录 var modelapp []suppliercertappend.Del_OilSupplierCertAppend whereapp := "SupplierCertId=" + strconv.Itoa(model[0].Id) var sqlapp string sqlapp = "select * from " + OilSupplierCertAppendName + " where " + whereapp utils.DBE.SQL(sqlapp).Find(&modelapp) err = svc.DeleteEntityBytbl(OilSupplierCertAppendName, whereapp) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } for idx, _ := range modelapp { modelapp[idx].DeleteDate = time.Now() } _, err = svc.InsertEntityBytbl(DelOilSupplierCertAppendName, &modelapp) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } // 删除年审记录 var modelann []annualaudit.Del_OilAnnualAudit whereann := "CerId=" + strconv.Itoa(model[0].Id) var sqlann string sqlann = "select * from " + OilAnnualAuditName + " where " + whereann utils.DBE.SQL(sqlann).Find(&modelann) err = svc.DeleteEntityBytbl(OilAnnualAuditName, whereann) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } for idx, _ := range modelann { modelann[idx].DeleteDate = time.Now() } _, err = svc.InsertEntityBytbl(DelOilAnnualAuditName, &modelann) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } // 删除准入范围 var certsup []suppliercertsub.Del_OilSupplierCertSub wheresup := "SupplierCertId=" + strconv.Itoa(model[0].Id) var sqlsup string sqlsup = "select * from " + OilSupplierCertSubName + " where " + wheresup utils.DBE.SQL(sqlsup).Find(&certsup) err = svc.DeleteEntityBytbl(OilSupplierCertSubName, wheresup) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } for idx, _ := range certsup { certsup[idx].DeleteDate = time.Now() } _, err = svc.InsertEntityBytbl(DelOilSupplierCertSubName, &certsup) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } } else { isdelsupplier = false } } if isdelsupplier { // 删除企业信息 var modelsupp supplier.Del_OilSupplier where := "Id=" + strconv.Itoa(model[0].SupplierId) var sql string sql = "select * from " + OilSupplierName + " where " + where utils.DBE.SQL(sql).Get(&modelsupp) err = svc.DeleteEntityBytbl(OilSupplierName, where) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } modelsupp.DeleteDate = time.Now() _, err = svc.InsertEntityBytbl(DelOilSupplierName, &modelsupp) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } // 删除企业资质 var delfile []supplierfile.Del_OilSupplierFile wheref := "SupplierId=" + strconv.Itoa(model[0].SupplierId) var sqlw string sqlw = "select * from " + OilSupplierFileName + " where " + wheref utils.DBE.SQL(sqlw).Find(&delfile) err = svc.DeleteEntityBytbl(OilSupplierFileName, wheref) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } for idx, _ := range delfile { delfile[idx].DeleteDate = time.Now() } _, err = svc.InsertEntityBytbl(DelOilSupplierFileName, &delfile) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } // 删除信息变更 var delinfo []infochange.Del_OilInfoChange whereinfo := "SupplierId=" + strconv.Itoa(model[0].SupplierId) var sqlinfo string sqlinfo = "select * from " + OilInfoChangeName + " where " + whereinfo utils.DBE.SQL(sqlinfo).Find(&delinfo) err = svc.DeleteEntityBytbl(OilInfoChangeName, whereinfo) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } for idx, _ := range delinfo { delinfo[idx].DeleteDate = time.Now() } _, err = svc.InsertEntityBytbl(DelOilInfoChangeName, &delinfo) if err != nil { session.Rollback() errinfo.Message = "提交失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } } 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 修改年审到期时间 // @Success 200 {object} controllers.Request // @router /updataapplytime/:id [post] func (this *OilSupplierCertController) UpdataApplyTime() { session := utils.DBE.NewSession() defer func() { session.Close() }() 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 supplierapplytime.OilSupplierApplyTime svc := suppliercert.GetOilSupplierCertSession(session) var jsonBlob = this.Ctx.Input.RequestBody 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(SupplierApplyTimeName, &model) if err != nil { session.Rollback() errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } var modelcert suppliercert.OilSupplierCert modelcert.ApplyTime = model.AfterDate if model.AfterDate.Unix() < time.Now().Unix() { modelcert.InFlag = "2" } else { modelcert.InFlag = "1" } var cols = []string{ "ApplyTime", "InFlag", } err = svc.UpdateEntityBytbl(OilSupplierCertName, id, &modelcert, cols) if err != nil { session.Rollback() errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } 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} []suppliercert.OilSupplierCert // @router /getapplytimelist [get] func (this *OilSupplierCertController) GetApplyTimeList() { SupplierCertId := this.GetString("SupplierCertId") var model []supplierapplytime.OilSupplierApplyTime svc := suppliercert.GetOilSupplierCertService(utils.DBE) where := "SupplierCertId = " + SupplierCertId svc.GetEntities(&model, where) var errinfo ErrorDataInfo errinfo.Message = "修改成功!" errinfo.Code = 0 errinfo.Item = model this.Data["json"] = &model this.ServeJSON() }