ソースを参照

工作流启动

yuedefeng 5 年 前
コミット
b58f8b5042

+ 2 - 1
src/dashoo.cn/backend/api/business/workflow/ActivitiService.go

@@ -132,7 +132,8 @@ func (this *ActivitiService) StartProcess2(processKey, formEntityId, userNames,
 
 	json, err := json.Marshal(ActiProcess)
 	if err != nil {
-		fmt.Println(err, "生成json字符串错误")
+		// panic(err., "生成json字符串错误")
+		panic("生成json字符串错误")
 	}
 	params := string(json)
 	fmt.Println(params)

+ 103 - 74
src/dashoo.cn/backend/api/controllers/oilsupplier/suppliercert.go

@@ -1,7 +1,6 @@
 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"
@@ -606,16 +605,114 @@ func (this *OilSupplierCertController) DeleteEntity() {
 // @Title 提交审批
 // @Description 提交审批
 // @Success	200	{object} controllers.Request
-// @router /audit/:id [post]
+// @router /first-audit/:id [post]
 func (this *OilSupplierCertController) AuditEntity() {
+	certId := this.Ctx.Input.Param(":id")
+	unitId := this.GetString("UnitId")
+	AuditRemark := this.GetString("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()
+		}
+	}()
+
+	//取出审批列表
+	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)
+	result := strconv.Itoa(this.User.IsCompanyUser)
+	status, _ := strconv.Atoi(supplierCertEntity.Status)
+	if status > 0 {
+		panic("工作流已经启动,请刷新重试!")
+	}
+
+	svcActiviti := workflow.GetActivitiService(utils.DBE)
+	//启动工作流
+	businessKey := certId + "-" + strconv.Itoa(supplierCertEntity.AuditIndex)
+	processInstanceId := svcActiviti.StartProcess2(workflow.OIL_ENUSER_SUPPLIER_APPLY, businessKey, this.User.Id, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName)
+	//同时完成此步骤
+	var ActiComplete workflow.ActiCompleteVM
+	ActiComplete.ProcessKey = workflow.OIL_ENUSER_SUPPLIER_APPLY
+	ActiComplete.BusinessKey = businessKey
+	// ActiComplete.UserNames =
+	ActiComplete.UserId = this.User.Id
+	ActiComplete.Result = result
+	ActiComplete.Remarks = AuditRemark
+	ActiComplete.CallbackUrl = ""
+	receiveVal := svcActiviti.TaskComplete(ActiComplete)
+	if receiveVal != "true" {
+		panic("工作流异常,请联系管理员!")
+	}
+
+	//记下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 = 1
+	supplierCertEntity.FirstAudit, _ = strconv.Atoi(this.User.Id)
+	supplierCertEntity.AuditIndex = supplierCertEntity.AuditIndex + 1
+	supplierCertEntity.BusinessKey = ActiComplete.BusinessKey
+	supplierCertEntity.ProcessKey = ActiComplete.ProcessKey
+	supplierCertEntity.CommitComId = unitId
+	cols := []string{
+		"Id",
+		"WorkflowId",
+		"Status",
+		"Step",
+		"FirstAudit",
+		"AuditIndex",
+		"BusinessKey",
+		"ProcessKey",
+		"CommitComId",
+	}
+	certSrv.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
+}
+
+// @Title 分办审批
+// @Description 分办审批
+// @Success	200	{object} controllers.Request
+// @router /audit/:id [post]
+func (this *OilSupplierCertController) SeparateAuditEntity() {
 	certId := this.Ctx.Input.Param(":id")
 	firstAudit := this.GetString("FirstAuditName")
-	unitId := this.GetString("FirstAuditName")
 	AuditRemark := this.GetString("AuditRemark")
 	secondAudit := this.GetString("SecondAudit")
 	thirdAudit := this.GetString("ThirdAudit")
 	typeCode := this.GetString("TypeCode")
 
+	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 setting auditsetting.Base_OilAuditSetting
 	var userlist []userRole.Base_User
 	usvc := userRole.GetUserService(utils.DBE)
@@ -653,55 +750,13 @@ func (this *OilSupplierCertController) AuditEntity() {
 	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)
-		processInstanceId = svcActiviti.StartProcess2(workflow.OIL_ENUSER_SUPPLIER_APPLY, businessKey, this.User.Id, result, supplierCertEntity.SupplierTypeCode, supplierEntity.SupplierName)
-	} else {
-		processInstanceId = supplierCertEntity.WorkflowId
-	}
+	processInstanceId := supplierCertEntity.WorkflowId
+	businessKey := supplierCertEntity.BusinessKey
+	result := "1" //分办默认向前走
 
 	var ActiComplete workflow.ActiCompleteVM
 	ActiComplete.ProcessKey = workflow.OIL_ENUSER_SUPPLIER_APPLY
-
 	ActiComplete.BusinessKey = businessKey
 	ActiComplete.UserNames = firstAudit
 	ActiComplete.UserId = this.User.Id
@@ -709,20 +764,6 @@ func (this *OilSupplierCertController) AuditEntity() {
 	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
@@ -736,36 +777,24 @@ func (this *OilSupplierCertController) AuditEntity() {
 		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)
 }

+ 7 - 0
src/dashoo.cn/frontend_web/src/api/oilsupplier/suppliercert.js

@@ -51,6 +51,13 @@ export default {
       method: 'delete'
     })
   },
+  firstAuditEntity (entityId, params, myAxios) {
+    return myAxios({
+      url: '/suppliercert/first-audit/' + entityId,
+      method: 'post',
+      params: params
+    })
+  },
   auditEntity (entityId, params, myAxios) {
     return myAxios({
       url: '/suppliercert/audit/' + entityId,

+ 3 - 2
src/dashoo.cn/frontend_web/src/pages/oilsupplier/supplier/_opera/goodsedit.vue

@@ -1785,6 +1785,7 @@ export default {
         }
       }
       this.applyLoading = true
+      this.auditform.UnitId = this.auditer
       this.auditform.FirstAuditName = this.auditer
       this.auditform.CertId = this.certId
       this.auditform.SecondAudit = this.fushenauditer
@@ -1830,10 +1831,10 @@ export default {
       //   return
       // }
       this.applyLoading = true
-      this.auditform.FirstAuditName = this.UnitOrg
+      this.auditform.UnitId = this.UnitOrg
       this.auditform.CertId = this.certId
       this.loading = true
-      apiCert.auditEntity(this.certId, this.auditform, this.$axios)
+      apiCert.firstAuditEntity(this.certId, this.auditform, this.$axios)
         .then(res => {
           if (res.data.code === 0) {
             // 保存成功后,初始化数据,变成修改