|
|
@@ -2,6 +2,7 @@ package oilsupplier
|
|
|
|
|
|
import (
|
|
|
"dashoo.cn/backend/api/business/audithistory"
|
|
|
+ "dashoo.cn/business2/items"
|
|
|
"encoding/json"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
@@ -30,7 +31,6 @@ type QualShenHeModel struct {
|
|
|
QualId int
|
|
|
SuccessStatus int
|
|
|
AuditorRemark string
|
|
|
- Auditer int
|
|
|
SuppId int
|
|
|
}
|
|
|
|
|
|
@@ -512,15 +512,14 @@ func (this *QualChangeController) EditQualChange() {
|
|
|
mainentirt.Status = "0"
|
|
|
mainentirt.Step = 1
|
|
|
err = svc.UpdateEntityBywheretbl(OilQualChangeMainName, &mainentirt, []string{"SupplierCertId", "Status", "Step"}, qmwhere)
|
|
|
- qualmainId := mainentirt.Id
|
|
|
|
|
|
- qdwhere := " SupplierId = " + utils.ToStr(model.SupplierId) + " and FileId = "+ id
|
|
|
+ qdwhere := " SupplierId = " + utils.ToStr(model.SupplierId) + " and FileId = "+ utils.ToStr(model.Id)
|
|
|
svc.GetEntitysByWhere(OilQualChangeDetailName, qdwhere, &qualdetaimodel)
|
|
|
entity = model
|
|
|
entity.Id = 0
|
|
|
- entity.ParentId = qualmainId
|
|
|
+ entity.ParentId, _ = strconv.Atoi(id)
|
|
|
entity.SupplierCertId = model.SupplierCertId
|
|
|
- entity.FileId, _ = utils.StrTo(id).Int()
|
|
|
+ entity.FileId = model.Id
|
|
|
if len(qualdetaimodel) == 0 {
|
|
|
entity.CreateOn = time.Now()
|
|
|
entity.CreateBy = this.User.Realname
|
|
|
@@ -550,6 +549,7 @@ func (this *QualChangeController) EditQualChange() {
|
|
|
func (this *QualChangeController) AuditEntity() {
|
|
|
suppId := this.Ctx.Input.Param(":id")
|
|
|
firstAudit := this.GetString("auditer")
|
|
|
+ fushenauditer := this.GetString("fushenauditer")
|
|
|
Remark := this.GetString("Remark")
|
|
|
//取出审批列表
|
|
|
svc := qualchange.GetQualChangeService(utils.DBE)
|
|
|
@@ -599,6 +599,8 @@ func (this *QualChangeController) AuditEntity() {
|
|
|
qualmainmodel.WorkFlowId = processInstanceId
|
|
|
qualmainmodel.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
|
|
|
qualmainmodel.AuditIndex = qualmain.AuditIndex + 1
|
|
|
+ qualmainmodel.FirstAudit, _ = strconv.Atoi(firstAudit)
|
|
|
+ qualmainmodel.SecondAudit, _ = strconv.Atoi(fushenauditer)
|
|
|
qualmainmodel.BusinessKey = ActiComplete.BusinessKey
|
|
|
qualmainmodel.CreateOn = time.Now()
|
|
|
qualmainmodel.CreateBy = this.User.Realname
|
|
|
@@ -611,6 +613,8 @@ func (this *QualChangeController) AuditEntity() {
|
|
|
"Status",
|
|
|
"Step",
|
|
|
"AuditIndex",
|
|
|
+ "FirstAudit",
|
|
|
+ "SecondAudit",
|
|
|
"BusinessKey",
|
|
|
"CreateOn",
|
|
|
"CreateBy",
|
|
|
@@ -645,17 +649,16 @@ func (this *QualChangeController) AuditEntity() {
|
|
|
// @router /qualaudit [post]
|
|
|
func (this *QualChangeController) QualAudit() {
|
|
|
svc := qualchange.GetQualChangeService(utils.DBE)
|
|
|
- var jsonblob = this.Ctx.Input.RequestBody
|
|
|
+ var jsonblob= this.Ctx.Input.RequestBody
|
|
|
var dataother QualShenHeModel
|
|
|
json.Unmarshal(jsonblob, &dataother)
|
|
|
//取出审批列表
|
|
|
- var qualid = dataother.QualId
|
|
|
+ var qualid= dataother.QualId
|
|
|
var qualmodel qualchange.OilQualChangeMain
|
|
|
svc.GetEntityById(utils.ToStr(dataother.QualId), &qualmodel)
|
|
|
var qualdetail []qualchange.OilQualChangeDetail
|
|
|
where := "ParentId = " + utils.ToStr(qualid)
|
|
|
svc.GetEntities(&qualdetail, where)
|
|
|
- var qualchanentity qualchange.OilQualChangeMain
|
|
|
var errinfo ErrorDataInfo
|
|
|
defer func() { //finally处理失败的异常
|
|
|
if err := recover(); err != nil {
|
|
|
@@ -671,16 +674,37 @@ func (this *QualChangeController) QualAudit() {
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
}()
|
|
|
- var userIds string
|
|
|
- certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
- var users []userRole.Base_RoleList
|
|
|
- certSrv.GetAuditUser("100000178", workflow.PROF_REGULATION, &users)
|
|
|
|
|
|
- for _, tmpUser := range users {
|
|
|
- userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
|
|
|
- }
|
|
|
- userIds = strings.Trim(userIds, ",")
|
|
|
+ //审核状态判断进行的操作
|
|
|
step := 2
|
|
|
+ status := ""
|
|
|
+ backstatus := "0"
|
|
|
+ var userIds string
|
|
|
+ if qualmodel.Status == suppliercert.FIRST_TRIAL_STATUS {
|
|
|
+ userIds = utils.ToStr(qualmodel.SecondAudit)
|
|
|
+ status = suppliercert.SECOND_TRIAL_STATUS
|
|
|
+ step = 2
|
|
|
+ backstatus = suppliercert.NOPASS_STATUS
|
|
|
+ } else if qualmodel.Status == suppliercert.SECOND_TRIAL_STATUS {
|
|
|
+ status = suppliercert.CENT_AUDIT_STATUS
|
|
|
+ backstatus = suppliercert.NO_SECOND_TRIAL_STATUS
|
|
|
+ step = 2
|
|
|
+ dictSvc := items.GetItemsService(utils.DBE)
|
|
|
+ deptIds := dictSvc.GetKeyValueItems("CENT_AUDIT")
|
|
|
+ var users []userRole.Base_RoleList
|
|
|
+ certSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
+ for _, dept := range deptIds {
|
|
|
+ certSrv.GetAuditUser(dept.Value, workflow.PROF_REGULATION, &users)
|
|
|
+ for _, tmpUser := range users {
|
|
|
+ userIds += strconv.FormatInt(tmpUser.Id, 10) + ","
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userIds = strings.Trim(userIds, ",")
|
|
|
+ } else if qualmodel.Status == suppliercert.CENT_AUDIT_STATUS {
|
|
|
+ status = suppliercert.ALL_PASE_STATUS
|
|
|
+ step = 3
|
|
|
+ backstatus = suppliercert.NO_THIRD_TRIAL_STATUS
|
|
|
+ }
|
|
|
svcActiviti := workflow.GetActivitiService(utils.DBE)
|
|
|
var ActiComplete workflow.ActiCompleteVM
|
|
|
ActiComplete.ProcessKey = workflow.OIL_QUAL_CHANGE
|
|
|
@@ -689,25 +713,22 @@ func (this *QualChangeController) QualAudit() {
|
|
|
ActiComplete.UserId = this.User.Id
|
|
|
ActiComplete.Remarks = dataother.AuditorRemark
|
|
|
ActiComplete.CallbackUrl = ""
|
|
|
+ var myerr error
|
|
|
if dataother.SuccessStatus == 1 {
|
|
|
ActiComplete.Result = "1"
|
|
|
- if qualmodel.Status == "1" {
|
|
|
- qualchanentity.Status = "2" //二级单位初审
|
|
|
- } else if qualmodel.Status == "2" {
|
|
|
- qualchanentity.Status = "3" //企业法规处审批
|
|
|
- step = 3
|
|
|
- }
|
|
|
receiveVal := svcActiviti.TaskComplete(ActiComplete)
|
|
|
+ qualmodel.Status = status
|
|
|
+ qualmodel.Step = step
|
|
|
if receiveVal == "true" {
|
|
|
cols := []string{
|
|
|
"Id",
|
|
|
"Status",
|
|
|
"Step",
|
|
|
}
|
|
|
- _, err := svc.UpdateEntityByIdCols(qualid, qualchanentity, cols)
|
|
|
+ _, err := svc.UpdateEntityByIdCols(qualid, qualmodel, cols)
|
|
|
if err == nil {
|
|
|
//原信息表更新
|
|
|
- if qualmodel.Status == "2" {
|
|
|
+ if qualmodel.Status == suppliercert.CENT_AUDIT_STATUS {
|
|
|
if len(qualdetail) > 0 {
|
|
|
for i := 0; i < len(qualdetail); i++ {
|
|
|
var supfilemodel supplierfile.OilSupplierFile
|
|
|
@@ -718,74 +739,73 @@ func (this *QualChangeController) QualAudit() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- errinfo.Message = "提交成功!"
|
|
|
- errinfo.Code = 0
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
+ if myerr == 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.Message = "工作流异常,请联系管理员!"
|
|
|
errinfo.Code = -1
|
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
|
+ return
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
- errinfo.Message = "工作流异常,请联系管理员!"
|
|
|
- errinfo.Code = -1
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
- } else {
|
|
|
- ActiComplete.Result = "0"
|
|
|
- if qualmodel.Status == "1" {
|
|
|
- qualchanentity.Status = "-2" //二级单位初审
|
|
|
- } else if qualmodel.Status == "2" {
|
|
|
- qualchanentity.Status = "-3" //企业法规处审批
|
|
|
- }
|
|
|
- receiveVal := svcActiviti.TaskComplete(ActiComplete)
|
|
|
- if qualchanentity.Status == "-2" {
|
|
|
- // 审批历史
|
|
|
- var audithistoryentity audithistory.Base_AuditHistory
|
|
|
- audithistoryentity.EntityId = qualid
|
|
|
- audithistoryentity.WorkflowId = qualmodel.WorkFlowId
|
|
|
- audithistoryentity.Process = ActiComplete.ProcessKey
|
|
|
- audithistoryentity.BusinessKey = ActiComplete.BusinessKey
|
|
|
- audithistoryentity.Type = "05"
|
|
|
- audithistoryentity.BackStep = qualmodel.Status
|
|
|
- audithistoryentity.Index = qualmodel.AuditIndex
|
|
|
- audithistoryentity.CreateOn = time.Now()
|
|
|
- audithistoryentity.CreateBy = this.User.Realname
|
|
|
- audithistoryentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
- certSrv.InsertEntity(audithistoryentity)
|
|
|
- qualchanentity.WorkFlowId = ""
|
|
|
- }
|
|
|
- if receiveVal == "true" {
|
|
|
- qualchanentity.Step = step
|
|
|
- cols := []string{
|
|
|
- "Id",
|
|
|
- "Status",
|
|
|
- "Step",
|
|
|
- "WorkFlowId",
|
|
|
- }
|
|
|
- _, err := svc.UpdateEntityByIdCols(qualid, qualchanentity, cols)
|
|
|
- if err == nil {
|
|
|
- errinfo.Message = "提交成功!"
|
|
|
- errinfo.Code = 0
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
+ ActiComplete.Result = "0"
|
|
|
+ receiveVal := svcActiviti.TaskComplete(ActiComplete)
|
|
|
+ if receiveVal == "true" {
|
|
|
+ if qualmodel.Status == suppliercert.CENT_AUDIT_STATUS {
|
|
|
+ qualmodel.Status = backstatus
|
|
|
+ } else {
|
|
|
+ qualmodel.Status = backstatus
|
|
|
+ // 审批历史
|
|
|
+ var audithistoryentity audithistory.Base_AuditHistory
|
|
|
+ audithistoryentity.EntityId = qualid
|
|
|
+ audithistoryentity.WorkflowId = qualmodel.WorkFlowId
|
|
|
+ audithistoryentity.Process = ActiComplete.ProcessKey
|
|
|
+ audithistoryentity.BusinessKey = ActiComplete.BusinessKey
|
|
|
+ audithistoryentity.Type = "04"
|
|
|
+ audithistoryentity.BackStep = qualmodel.Status
|
|
|
+ audithistoryentity.Index = qualmodel.AuditIndex
|
|
|
+ audithistoryentity.CreateOn = time.Now()
|
|
|
+ audithistoryentity.CreateBy = this.User.Realname
|
|
|
+ audithistoryentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ _, myerr = svc.InsertEntity(audithistoryentity)
|
|
|
+ qualmodel.WorkFlowId = ""
|
|
|
+ }
|
|
|
+ qualmodel.Step = 1
|
|
|
+ cols := []string{
|
|
|
+ "Status",
|
|
|
+ "Step",
|
|
|
+ }
|
|
|
+ _, myerr := svc.UpdateEntityByIdCols(qualid, qualmodel, cols)
|
|
|
+
|
|
|
+ if myerr == 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.Message = "工作流异常,请联系管理员!"
|
|
|
errinfo.Code = -1
|
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
|
+ return
|
|
|
}
|
|
|
- } else {
|
|
|
- errinfo.Message = "工作流异常,请联系管理员!"
|
|
|
- errinfo.Code = -1
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|