|
@@ -9,6 +9,7 @@ package services
|
|
|
import (
|
|
|
"errors"
|
|
|
"log"
|
|
|
+ "time"
|
|
|
|
|
|
"github.com/kataras/iris/v12"
|
|
|
"go.mod/dao"
|
|
@@ -23,7 +24,7 @@ type SafeAuditService interface {
|
|
|
CloseAudit(id int, opinion string, curUid int, saveId int) error
|
|
|
BackAudit(id int, opinion string, curUid int, saveId int, auditId int) error
|
|
|
PassAudit(id int, uid int, auditId int, opinion string, rectifiedInfo string) error
|
|
|
- StartAudit(safeId int, bidsectionId int, auditors []int, reAuditors []int, uid int, pid int) error
|
|
|
+ StartAudit(safeId int, bidsectionId int, auditors []int, reAuditors []int, uid int, pid int, inspection string, inspectionDetail string, demand string, createTime time.Time) error
|
|
|
}
|
|
|
|
|
|
type safeAuditService struct {
|
|
@@ -53,18 +54,6 @@ func NewSafeAuditService() SafeAuditService {
|
|
|
func (s *safeAuditService) CloseAudit(id int, opinion string, curUid int, saveId int) error {
|
|
|
err := s.daoApprover.CloseHandler(id, opinion, curUid, saveId)
|
|
|
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
|
|
|
}
|
|
|
|
|
|
// 审批退回
|
|
@@ -91,49 +80,9 @@ 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 {
|
|
|
err := s.daoApprover.PassHandler(id, uid, auditId, opinion, rectifiedInfo)
|
|
|
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, inspection string, inspectionDetail string, demand string, createTime time.Time) error {
|
|
|
safe := s.daoSafe.FindById(safeId)
|
|
|
if safe.Uid != uid {
|
|
|
return errors.New("该用户没有操作权限!")
|
|
@@ -143,7 +92,7 @@ func (s *safeAuditService) StartAudit(safeId int, bidsectionId int, auditors []i
|
|
|
// 增加审批日志
|
|
|
err = s.daoSafeAudit.AddAuditRecord(safeId, bidsectionId, uid, safe.Times, 0, 0, "", "")
|
|
|
// 改变安全巡检表的状态
|
|
|
- err = s.daoSafe.ChangeStatus(safeId, 1)
|
|
|
+ err = s.daoSafe.ChangeStatus(safeId, 1, inspection, inspectionDetail, demand, createTime)
|
|
|
// 创建审批流程
|
|
|
err = s.daoApprover.InsertData(bidsectionId, pid, 1, safeId, auditors, reAuditors)
|
|
|
return err
|