Merge remote-tracking branch 'origin/test' into dev
正在显示
5 个修改的文件
包含
37 行增加
和
5 行删除
@@ -262,11 +262,17 @@ func (handler ZKClockHandler) BioData(entity BIODATAEntity) (DownEntity, error) | @@ -262,11 +262,17 @@ func (handler ZKClockHandler) BioData(entity BIODATAEntity) (DownEntity, error) | ||
262 | if len(userBase.UserInfo.FacePortrait) == 0 && len(entity.Tmp) > 0 && entity.Type == "9" { | 262 | if len(userBase.UserInfo.FacePortrait) == 0 && len(entity.Tmp) > 0 && entity.Type == "9" { |
263 | userBase.UserInfo.FacePortrait = entity.Tmp | 263 | userBase.UserInfo.FacePortrait = entity.Tmp |
264 | updateFlag = true | 264 | updateFlag = true |
265 | + if len(GlobalTerminalManager.TerminalDeviceList) >= 1 { //TODO:后期移除掉,多台设备时才进行广播 | ||
266 | + event.Fire(DownEntityEvent, map[string]interface{}{"entity": NewUpdateUserFacePortraitDownEntity(generateSn(), entity.Pin, entity.Tmp)}) | ||
267 | + } | ||
265 | } | 268 | } |
266 | // 请求 人脸识别-指纹 | 269 | // 请求 人脸识别-指纹 |
267 | if len(userBase.UserInfo.FingerprintPortrait) == 0 && len(entity.Tmp) > 0 && entity.Type == "1" { | 270 | if len(userBase.UserInfo.FingerprintPortrait) == 0 && len(entity.Tmp) > 0 && entity.Type == "1" { |
268 | userBase.UserInfo.FingerprintPortrait = entity.Tmp | 271 | userBase.UserInfo.FingerprintPortrait = entity.Tmp |
269 | updateFlag = true | 272 | updateFlag = true |
273 | + if len(GlobalTerminalManager.TerminalDeviceList) >= 1 { | ||
274 | + event.Fire(DownEntityEvent, map[string]interface{}{"entity": NewUpdateUserFingerprintPortraitDownEntity(generateSn(), entity.Pin, entity.Tmp)}) | ||
275 | + } | ||
270 | } | 276 | } |
271 | if updateFlag { | 277 | if updateFlag { |
272 | _, err = userBaseRepository.Save(userBase) | 278 | _, err = userBaseRepository.Save(userBase) |
@@ -11,7 +11,7 @@ import ( | @@ -11,7 +11,7 @@ import ( | ||
11 | type SyncToAttendanceMachineCommand struct { | 11 | type SyncToAttendanceMachineCommand struct { |
12 | OperateInfo *domain.OperateInfo `json:"-"` | 12 | OperateInfo *domain.OperateInfo `json:"-"` |
13 | // 用户关联的角色 | 13 | // 用户关联的角色 |
14 | - Users []int64 `cname:"用户关联的角色" json:"userIds" valid:"Required"` | 14 | + Users []string `cname:"用户关联的角色" json:"userIds"` |
15 | } | 15 | } |
16 | 16 | ||
17 | func (syncToAttendance *SyncToAttendanceMachineCommand) Valid(validation *validation.Validation) { | 17 | func (syncToAttendance *SyncToAttendanceMachineCommand) Valid(validation *validation.Validation) { |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/factory" |
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/command" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/user/command" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils" | ||
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log" |
10 | ) | 11 | ) |
11 | 12 | ||
@@ -24,10 +25,23 @@ func (userService *UserService) SyncToAttendanceMachine(cmd *command.SyncToAtten | @@ -24,10 +25,23 @@ func (userService *UserService) SyncToAttendanceMachine(cmd *command.SyncToAtten | ||
24 | transactionContext.RollbackTransaction() | 25 | transactionContext.RollbackTransaction() |
25 | }() | 26 | }() |
26 | userRepository, _, _ := factory.FastPgUser(transactionContext, 0) | 27 | userRepository, _, _ := factory.FastPgUser(transactionContext, 0) |
27 | - | ||
28 | - _, users, err := userRepository.Find(map[string]interface{}{"companyId": cmd.OperateInfo.CompanyId, "inUserIds": cmd.Users}) | ||
29 | - if err != nil { | ||
30 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 28 | + orgRepository, _, _ := factory.FastPgOrg(transactionContext, 0) |
29 | + var users []*domain.User | ||
30 | + // 指定用户进行同步 | ||
31 | + if len(cmd.Users) > 0 { | ||
32 | + _, users, err = userRepository.Find(map[string]interface{}{"companyId": cmd.OperateInfo.CompanyId, "inUserIds": utils.ToArrayInt64(cmd.Users)}) | ||
33 | + if err != nil { | ||
34 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
35 | + } | ||
36 | + } else { | ||
37 | + org, _ := orgRepository.FindOne(map[string]interface{}{"companyId": cmd.OperateInfo.CompanyId, "orgName": "制造中心"}) | ||
38 | + if org == nil { | ||
39 | + return nil, nil | ||
40 | + } | ||
41 | + _, users, err = userRepository.Find(map[string]interface{}{"companyId": cmd.OperateInfo.CompanyId, "inDepartmentIds": []int64{org.OrgId}}) | ||
42 | + if err != nil { | ||
43 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
44 | + } | ||
31 | } | 45 | } |
32 | 46 | ||
33 | for i := range users { | 47 | for i := range users { |
@@ -213,6 +213,9 @@ func (repository *UserRepository) Find(queryOptions map[string]interface{}) (int | @@ -213,6 +213,9 @@ func (repository *UserRepository) Find(queryOptions map[string]interface{}) (int | ||
213 | if v, ok := queryOptions["inCompanyIds"]; ok && len(v.([]int64)) > 0 { | 213 | if v, ok := queryOptions["inCompanyIds"]; ok && len(v.([]int64)) > 0 { |
214 | query.Where(`company_id in (?)`, pg.In(v)) | 214 | query.Where(`company_id in (?)`, pg.In(v)) |
215 | } | 215 | } |
216 | + if v, ok := queryOptions["inDepartmentIds"]; ok && len(v.([]int64)) > 0 { | ||
217 | + query.Where(`department_id in (?)`, pg.In(v)) | ||
218 | + } | ||
216 | query.SetWhereByQueryOption("user_code = ?", "userCode") | 219 | query.SetWhereByQueryOption("user_code = ?", "userCode") |
217 | query.SetWhereByQueryOption("ext->>'icCardNumber' = ?", "icCardNumber") | 220 | query.SetWhereByQueryOption("ext->>'icCardNumber' = ?", "icCardNumber") |
218 | query.SetWhereByQueryOption("user_base_id=?", "userBaseId") | 221 | query.SetWhereByQueryOption("user_base_id=?", "userBaseId") |
@@ -262,3 +262,12 @@ func CopyObject(src, dst interface{}) { | @@ -262,3 +262,12 @@ func CopyObject(src, dst interface{}) { | ||
262 | } | 262 | } |
263 | } | 263 | } |
264 | } | 264 | } |
265 | + | ||
266 | +func ToArrayInt64(inputs []string) []int64 { | ||
267 | + result := make([]int64, 0) | ||
268 | + for i := range inputs { | ||
269 | + v, _ := strconv.ParseInt(inputs[i], 10, 64) | ||
270 | + result = append(result, v) | ||
271 | + } | ||
272 | + return result | ||
273 | +} |
-
请 注册 或 登录 后发表评论