|
|
@@ -1,7 +1,12 @@
|
|
|
package oilsupplier
|
|
|
|
|
|
import (
|
|
|
+ "dashoo.cn/backend/api/business/auditsetting"
|
|
|
+ "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
|
|
|
+ "dashoo.cn/backend/api/business/workflow"
|
|
|
+ "dashoo.cn/business2/userRole"
|
|
|
"encoding/json"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
|
@@ -286,3 +291,83 @@ func (this *OilSupplierCertAppendController) DeleteEntity() {
|
|
|
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("firstAudit")
|
|
|
+
|
|
|
+ //取出审批列表
|
|
|
+ certSrv := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
|
|
|
+ var supplierCertAppendEntity suppliercertappend.OilSupplierCertAppend
|
|
|
+ certSrv.GetEntityById(certappendId, &supplierCertAppendEntity)
|
|
|
+
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ svcActiviti := workflow.GetActivitiService(utils.DBE)
|
|
|
+ //获得有审核权限的人员
|
|
|
+ var users []userRole.Base_RoleList
|
|
|
+ var userIds string
|
|
|
+ var auditWorkflow auditsetting.Base_OilAuditSetting
|
|
|
+ rsvc := auditsetting.GetOilAuditSettingService(utils.DBE)
|
|
|
+ rsvc.GetAuditStepRoleEntity(OilAuditSettingName, firstAudit, workflow.FIRST_TRIAL, &auditWorkflow)
|
|
|
+ users = rsvc.GetUserByRole(strconv.Itoa(auditWorkflow.RoleId), this.User.AccCode) //
|
|
|
+
|
|
|
+ processInstanceId := ""
|
|
|
+ if supplierCertAppendEntity.WorkFlowId == "0" || len(supplierCertAppendEntity.WorkFlowId) <= 0 {
|
|
|
+ //启动工作流
|
|
|
+ processInstanceId = svcActiviti.StartProcess(workflow.OIL_APPEND_APPLY, certappendId, this.User.Id)
|
|
|
+ }
|
|
|
+ for _, tmpUser := range users {
|
|
|
+ userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
|
|
|
+ }
|
|
|
+ userIds = strings.Trim(userIds, ",")
|
|
|
+ var ActiComplete workflow.ActiCompleteVM
|
|
|
+ ActiComplete.ProcessKey = workflow.OIL_APPEND_APPLY
|
|
|
+ ActiComplete.BusinessKey = certappendId
|
|
|
+ ActiComplete.UserNames = userIds
|
|
|
+ ActiComplete.UserId = this.User.Id
|
|
|
+ ActiComplete.Result = "1"
|
|
|
+ ActiComplete.Remarks = ""
|
|
|
+ ActiComplete.CallbackUrl = ""
|
|
|
+ receiveVal := svcActiviti.TaskComplete(ActiComplete)
|
|
|
+
|
|
|
+ if receiveVal == "true" {
|
|
|
+ errinfo.Message = "提交成功!"
|
|
|
+ errinfo.Code = 0
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ } else {
|
|
|
+ errinfo.Message = "工作流异常,请联系管理员!"
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
|
|
|
+ var model suppliercertappend.OilSupplierCertAppend
|
|
|
+ model.WorkFlowId = processInstanceId
|
|
|
+ model.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
|
|
|
+ cols := []string{
|
|
|
+ "Id",
|
|
|
+ "WorkFlowId",
|
|
|
+ "Status",
|
|
|
+ }
|
|
|
+ certSrv.UpdateEntityByIdCols(certappendId, model, cols)
|
|
|
+}
|