|
@@ -51,18 +51,20 @@ func NewSafeAuditService() SafeAuditService {
|
|
|
|
|
|
// 关闭审批流程
|
|
// 关闭审批流程
|
|
func (s *safeAuditService) CloseAudit(id int, opinion string, curUid int, saveId int) error {
|
|
func (s *safeAuditService) CloseAudit(id int, opinion string, curUid int, saveId int) error {
|
|
- auditor, err := s.daoApprover.FindApproverById(id)
|
|
|
|
- if auditor.AuditId != curUid {
|
|
|
|
- return errors.New("该用户没有审批权限!")
|
|
|
|
- }
|
|
|
|
- safe := s.daoSafe.FindById(auditor.DataId)
|
|
|
|
- // 增加审批日志记录
|
|
|
|
- err = s.daoSafeAudit.AddAuditRecord(auditor.DataId, auditor.BidsectionId, auditor.AuditId, safe.Times, 2, auditor.Progress, opinion, "")
|
|
|
|
- // 更改cm_safe的记录
|
|
|
|
- err = s.daoSafe.ChangeStatus(saveId, 5)
|
|
|
|
- // 更改cm_approver的记录
|
|
|
|
- err = s.daoApprover.ChangeStatus(id, 3)
|
|
|
|
|
|
+ err := s.daoApprover.CloseHandler(id, opinion, curUid, saveId)
|
|
return err
|
|
return err
|
|
|
|
+ // auditor, err := s.daoApprover.FindApproverById(id)
|
|
|
|
+ // if auditor.AuditId != curUid {
|
|
|
|
+ // return errors.New("该用户没有审批权限!")
|
|
|
|
+ // }
|
|
|
|
+ // safe := s.daoSafe.FindById(auditor.DataId)
|
|
|
|
+ // // 增加审批日志记录
|
|
|
|
+ // err = s.daoSafeAudit.AddAuditRecord(auditor.DataId, auditor.BidsectionId, auditor.AuditId, safe.Times, 2, auditor.Progress, opinion, "")
|
|
|
|
+ // // 更改cm_safe的记录
|
|
|
|
+ // err = s.daoSafe.ChangeStatus(saveId, 5)
|
|
|
|
+ // // 更改cm_approver的记录
|
|
|
|
+ // err = s.daoApprover.ChangeStatus(id, 3)
|
|
|
|
+ // return err
|
|
}
|
|
}
|
|
|
|
|
|
// 审批退回
|
|
// 审批退回
|
|
@@ -72,11 +74,6 @@ func (s *safeAuditService) BackAudit(id int, opinion string, curUid int, saveId
|
|
return errors.New("该用户没有审批权限!")
|
|
return errors.New("该用户没有审批权限!")
|
|
}
|
|
}
|
|
safe := s.daoSafe.FindById(saveId)
|
|
safe := s.daoSafe.FindById(saveId)
|
|
- // 增加审批日志
|
|
|
|
- // err = s.daoSafeAudit.AddAuditRecord(auditor.DataId, auditor.BidsectionId, auditor.AuditId, safe.Times, 1, auditor.Progress, opinion, "")
|
|
|
|
- // if err != nil {
|
|
|
|
- // return err
|
|
|
|
- // }
|
|
|
|
|
|
|
|
// 退回到了检查人
|
|
// 退回到了检查人
|
|
if auditId == 0 {
|
|
if auditId == 0 {
|
|
@@ -84,7 +81,7 @@ func (s *safeAuditService) BackAudit(id int, opinion string, curUid int, saveId
|
|
err = s.daoApprover.InitStatus(auditor.BidsectionId, auditor.DataType, auditor.DataId, auditor.AuditId, safe.Times, auditor.Progress+1, opinion)
|
|
err = s.daoApprover.InitStatus(auditor.BidsectionId, auditor.DataType, auditor.DataId, auditor.AuditId, safe.Times, auditor.Progress+1, opinion)
|
|
} else {
|
|
} else {
|
|
// 退回到审批流程中的某一个人
|
|
// 退回到审批流程中的某一个人
|
|
- err = s.daoApprover.BackHandlerWithId(auditId, id, safe.Times, auditor.Progress+1, opinion)
|
|
|
|
|
|
+ err = s.daoApprover.BackHandlerWithId(auditId, auditor.AuditId, safe.Times, auditor.Progress+1, opinion)
|
|
}
|
|
}
|
|
return err
|
|
return err
|
|
|
|
|
|
@@ -92,45 +89,48 @@ func (s *safeAuditService) BackAudit(id int, opinion string, curUid int, saveId
|
|
|
|
|
|
// 审批通过
|
|
// 审批通过
|
|
func (s *safeAuditService) PassAudit(id int, uid int, auditId int, opinion string, rectifiedInfo string) error {
|
|
func (s *safeAuditService) PassAudit(id int, uid int, auditId int, opinion string, rectifiedInfo string) error {
|
|
- auditor, err := s.daoApprover.FindApproverById(id)
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- // 获取安全巡检记录
|
|
|
|
- safe := s.daoSafe.FindById(auditor.DataId)
|
|
|
|
- if auditor.AuditId != uid {
|
|
|
|
- return errors.New("该用户没有审批权限!")
|
|
|
|
- }
|
|
|
|
- // 增加审批日志
|
|
|
|
- err = s.daoSafeAudit.AddAuditRecord(auditor.DataId, auditor.BidsectionId, auditor.AuditId, safe.Times, 0, auditor.Progress+1, opinion, rectifiedInfo)
|
|
|
|
- // 改变审批流程中当前审批人以及下一个审批人的审批流程状态
|
|
|
|
- err = s.daoApprover.ChangeStatus(id, 2)
|
|
|
|
- err = s.daoApprover.ChangeNextStatus(id, 1)
|
|
|
|
- // 审批人选择了整改人
|
|
|
|
- if auditId != 0 {
|
|
|
|
- // 修改cm_safe表的status状态为待整改
|
|
|
|
- err = s.daoSafe.ChangeStatus(auditor.DataId, 2)
|
|
|
|
- // 改变审批流程中的整改人id
|
|
|
|
- err = s.daoApprover.ChangeAuditId(auditor.BidsectionId, auditor.DataType, auditor.DataId, auditor.AuditOrder+1, auditId)
|
|
|
|
- } else {
|
|
|
|
- if auditor.Progress == 1 {
|
|
|
|
- // 整改人审批流程
|
|
|
|
- // 修改cm_safe表的status状态为待复查
|
|
|
|
- err = s.daoSafe.ChangeStatus(auditor.DataId, 3)
|
|
|
|
- } else {
|
|
|
|
- // 复查流程
|
|
|
|
- // 查找最后一个审批人
|
|
|
|
- lastAuditor, err := s.daoApprover.GetLastAuditor(auditor.BidsectionId, auditor.DataType, auditor.DataId)
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- if lastAuditor.AuditId == auditor.AuditId {
|
|
|
|
- // 说明审批流程已经走完
|
|
|
|
- err = s.daoSafe.ChangeStatus(auditor.DataId, 4)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ err := s.daoApprover.PassHandler(id, uid, auditId, opinion, rectifiedInfo)
|
|
return err
|
|
return err
|
|
|
|
+ // auditor, err := s.daoApprover.FindApproverById(id)
|
|
|
|
+ // if err != nil {
|
|
|
|
+ // return err
|
|
|
|
+ // }
|
|
|
|
+ // // 获取安全巡检记录
|
|
|
|
+ // safe := s.daoSafe.FindById(auditor.DataId)
|
|
|
|
+ // if auditor.AuditId != uid {
|
|
|
|
+ // return errors.New("该用户没有审批权限!")
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // err = s.daoSafeAudit.AddAuditRecord(auditor.DataId, auditor.BidsectionId, auditor.AuditId, safe.Times, 0, auditor.Progress+1, opinion, rectifiedInfo)
|
|
|
|
+
|
|
|
|
+ // err = s.daoApprover.ChangeStatus(id, 2)
|
|
|
|
+ // err = s.daoApprover.ChangeNextStatus(id, 1)
|
|
|
|
+ // // 审批人选择了整改人
|
|
|
|
+ // if auditId != 0 {
|
|
|
|
+ // // 修改cm_safe表的status状态为待整改
|
|
|
|
+ // err = s.daoSafe.ChangeStatus(auditor.DataId, 2)
|
|
|
|
+ // // 改变审批流程中的整改人id
|
|
|
|
+ // err = s.daoApprover.ChangeAuditId(auditor.BidsectionId, auditor.DataType, auditor.DataId, auditor.AuditOrder+1, auditId)
|
|
|
|
+ // } else {
|
|
|
|
+ // if auditor.Progress == 1 {
|
|
|
|
+ // // 整改人审批流程
|
|
|
|
+ // // 修改cm_safe表的status状态为待复查
|
|
|
|
+ // err = s.daoSafe.ChangeStatus(auditor.DataId, 3)
|
|
|
|
+ // } else {
|
|
|
|
+ // // 复查流程
|
|
|
|
+ // // 查找最后一个审批人
|
|
|
|
+ // lastAuditor, err := s.daoApprover.GetLastAuditor(auditor.BidsectionId, auditor.DataType, auditor.DataId)
|
|
|
|
+ // if err != nil {
|
|
|
|
+ // return err
|
|
|
|
+ // }
|
|
|
|
+ // if lastAuditor.AuditId == auditor.AuditId {
|
|
|
|
+ // // 说明审批流程已经走完
|
|
|
|
+ // err = s.daoSafe.ChangeStatus(auditor.DataId, 4)
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // return err
|
|
}
|
|
}
|
|
|
|
|
|
func (s *safeAuditService) StartAudit(safeId int, bidsectionId int, auditors []int, reAuditors []int, uid int, pid int) error {
|
|
func (s *safeAuditService) StartAudit(safeId int, bidsectionId int, auditors []int, reAuditors []int, uid int, pid int) error {
|