...
|
...
|
@@ -6,6 +6,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -24,10 +25,23 @@ func (userService *UserService) SyncToAttendanceMachine(cmd *command.SyncToAtten |
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
userRepository, _, _ := factory.FastPgUser(transactionContext, 0)
|
|
|
|
|
|
_, users, err := userRepository.Find(map[string]interface{}{"companyId": cmd.OperateInfo.CompanyId, "inUserIds": cmd.Users})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
orgRepository, _, _ := factory.FastPgOrg(transactionContext, 0)
|
|
|
var users []*domain.User
|
|
|
// 指定用户进行同步
|
|
|
if len(cmd.Users) > 0 {
|
|
|
_, users, err = userRepository.Find(map[string]interface{}{"companyId": cmd.OperateInfo.CompanyId, "inUserIds": utils.ToArrayInt64(cmd.Users)})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
} else {
|
|
|
org, _ := orgRepository.FindOne(map[string]interface{}{"companyId": cmd.OperateInfo.CompanyId, "orgName": "制造中心"})
|
|
|
if org == nil {
|
|
|
return nil, nil
|
|
|
}
|
|
|
_, users, err = userRepository.Find(map[string]interface{}{"companyId": cmd.OperateInfo.CompanyId, "inDepartmentIds": []int64{org.OrgId}})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for i := range users {
|
...
|
...
|
|