|
@@ -656,6 +656,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
@@ -656,6 +656,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
656
|
company *models.Company
|
656
|
company *models.Company
|
657
|
roleName string
|
657
|
roleName string
|
658
|
approver *models.User
|
658
|
approver *models.User
|
|
|
659
|
+ roleId []int
|
659
|
)
|
660
|
)
|
660
|
if configs, err = models.GetAuditFlowConfigsLevel(templateId, 1); err != nil {
|
661
|
if configs, err = models.GetAuditFlowConfigsLevel(templateId, 1); err != nil {
|
661
|
if err == orm.ErrNoRows {
|
662
|
if err == orm.ErrNoRows {
|
|
@@ -678,6 +679,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
@@ -678,6 +679,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
678
|
groupId = config.AuditGroupId
|
679
|
groupId = config.AuditGroupId
|
679
|
continue
|
680
|
continue
|
680
|
}
|
681
|
}
|
|
|
682
|
+ if config.FlowType == protocol.FlowTypeSpecail {
|
681
|
if len(config.FromSpecialUser) > 0 {
|
683
|
if len(config.FromSpecialUser) > 0 {
|
682
|
if err = json.Unmarshal([]byte(config.FromSpecialUser), &ids); err != nil {
|
684
|
if err = json.Unmarshal([]byte(config.FromSpecialUser), &ids); err != nil {
|
683
|
log.Error(err)
|
685
|
log.Error(err)
|
|
@@ -691,6 +693,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
@@ -691,6 +693,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
691
|
}
|
693
|
}
|
692
|
}
|
694
|
}
|
693
|
}
|
695
|
}
|
|
|
696
|
+ }
|
694
|
if IsSpecailAuditFlow {
|
697
|
if IsSpecailAuditFlow {
|
695
|
break
|
698
|
break
|
696
|
}
|
699
|
}
|
|
@@ -727,15 +730,25 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
@@ -727,15 +730,25 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
727
|
log.Error(err)
|
730
|
log.Error(err)
|
728
|
return
|
731
|
return
|
729
|
}
|
732
|
}
|
|
|
733
|
+ break
|
730
|
case protocol.AuditByUser:
|
734
|
case protocol.AuditByUser:
|
731
|
if err = json.Unmarshal([]byte(config.ToUser), &userIds); err != nil {
|
735
|
if err = json.Unmarshal([]byte(config.ToUser), &userIds); err != nil {
|
732
|
log.Error(err)
|
736
|
log.Error(err)
|
733
|
return
|
737
|
return
|
734
|
}
|
738
|
}
|
|
|
739
|
+ break
|
735
|
case protocol.AuditByRole:
|
740
|
case protocol.AuditByRole:
|
736
|
//roleName="" //TODO:角色
|
741
|
//roleName="" //TODO:角色
|
|
|
742
|
+ if e := json.Unmarshal([]byte(config.ToRole), &roleId); e == nil {
|
|
|
743
|
+ if userIds, err = getRoleUsers(header, roleId[0]); err != nil {
|
|
|
744
|
+ log.Error(err)
|
737
|
return
|
745
|
return
|
738
|
}
|
746
|
}
|
|
|
747
|
+ } else {
|
|
|
748
|
+ log.Error(config.ToRole, e)
|
|
|
749
|
+ }
|
|
|
750
|
+ break
|
|
|
751
|
+ }
|
739
|
if len(userIds) == 0 { //当前步骤没有用户 默认一个空审核人
|
752
|
if len(userIds) == 0 { //当前步骤没有用户 默认一个空审核人
|
740
|
userIds = append(userIds, 0)
|
753
|
userIds = append(userIds, 0)
|
741
|
}
|
754
|
}
|
|
@@ -744,7 +757,10 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
|
@@ -744,7 +757,10 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related |
744
|
if uid == 0 && auditConfig.NoApprover == protocol.NoApproverToAdmin { //审批人为空 转交给管理员
|
757
|
if uid == 0 && auditConfig.NoApprover == protocol.NoApproverToAdmin { //审批人为空 转交给管理员
|
745
|
uid = company.AdminId
|
758
|
uid = company.AdminId
|
746
|
}
|
759
|
}
|
747
|
- if uid == header.Uid { //审核人自己 转交给管理员
|
760
|
+ if uid == 0 {
|
|
|
761
|
+ uid = company.AdminId
|
|
|
762
|
+ }
|
|
|
763
|
+ if uid == header.UserId { //审核人自己 转交给管理员
|
748
|
log.Info(fmt.Sprintf("生成机会审批流-转给管理员:chance_id:%v audit_level:%v audit_user:%v -> admin:%v", chanceId, config.Level, uid, company.AdminId))
|
764
|
log.Info(fmt.Sprintf("生成机会审批流-转给管理员:chance_id:%v audit_level:%v audit_user:%v -> admin:%v", chanceId, config.Level, uid, company.AdminId))
|
749
|
uid = company.AdminId
|
765
|
uid = company.AdminId
|
750
|
}
|
766
|
}
|
|
@@ -802,14 +818,38 @@ func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) |
|
@@ -802,14 +818,38 @@ func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) |
802
|
}
|
818
|
}
|
803
|
if len(departments.Managers) > 0 {
|
819
|
if len(departments.Managers) > 0 {
|
804
|
var tmpIds []int64
|
820
|
var tmpIds []int64
|
805
|
- if err = json.Unmarshal([]byte(departments.Managers), &tmpIds); err == nil && len(ids) > 0 {
|
821
|
+ if err = json.Unmarshal([]byte(departments.Managers), &tmpIds); err == nil {
|
|
|
822
|
+ if len(tmpIds) > 0 {
|
806
|
ids = append(ids, tmpIds...)
|
823
|
ids = append(ids, tmpIds...)
|
807
|
}
|
824
|
}
|
808
|
}
|
825
|
}
|
|
|
826
|
+ }
|
809
|
//部门长不存在
|
827
|
//部门长不存在
|
810
|
if len(ids) == 0 {
|
828
|
if len(ids) == 0 {
|
811
|
ids = append(ids, 0)
|
829
|
ids = append(ids, 0)
|
812
|
}
|
830
|
}
|
|
|
831
|
+ log.Info(fmt.Sprintf("生成机会审批流-部门:department_id:%v managers:%v ids:%v", relatedDeparmentId, departments.Managers, ids))
|
|
|
832
|
+ return
|
|
|
833
|
+}
|
|
|
834
|
+
|
|
|
835
|
+//获取角色ids
|
|
|
836
|
+func getRoleUsers(header *protocol.RequestHeader, roleId int) (ids []int64, err error) {
|
|
|
837
|
+ var (
|
|
|
838
|
+ userRole []*models.UserRole
|
|
|
839
|
+ )
|
|
|
840
|
+ if userRole, err = models.GetUserRolesById(roleId); err != nil {
|
|
|
841
|
+ log.Error(roleId, err)
|
|
|
842
|
+ if err == orm.ErrNoRows {
|
|
|
843
|
+ err = nil
|
|
|
844
|
+ }
|
|
|
845
|
+ }
|
|
|
846
|
+ for i := range userRole {
|
|
|
847
|
+ ids = append(ids, userRole[i].UserCompanyId)
|
|
|
848
|
+ }
|
|
|
849
|
+ if len(ids) == 0 {
|
|
|
850
|
+ ids = append(ids, 0)
|
|
|
851
|
+ }
|
|
|
852
|
+ log.Info(fmt.Sprintf("生成机会审批流-角色:role_id:%v ids:%v", roleId, ids))
|
813
|
return
|
853
|
return
|
814
|
}
|
854
|
}
|
815
|
|
855
|
|