作者 yangfu

refactor: 优化数据同步

... ... @@ -61,7 +61,7 @@ func terminalReport(cmd *command.TerminalReportCommand, transactionContext appli
var (
response string = "OK"
)
log.Logger.Debug(fmt.Sprintf("【TerminalManager】 收到上行命令 command:%v table:%v content:%v", cmd.Command, cmd.Table, cmd.Content))
switch cmd.Command {
case "getrequest":
device, ok := GlobalTerminalManager.GetDevice(cmd.TerminalId)
... ... @@ -103,7 +103,6 @@ func terminalReport(cmd *command.TerminalReportCommand, transactionContext appli
break
}
case "devicecmd":
log.Logger.Debug("【TerminalManager】 收到命令应答 cmd : " + cmd.Content)
}
return map[string]interface{}{
... ...
... ... @@ -98,13 +98,13 @@ func (term *TerminalManager) SyncUser(e event.Event) error {
if len(assertUser.Ext.IcCardNumber) == 0 {
return nil
}
term.BroadcastDownEntity(NewUpdateUserDownEntity(generateSn(), assertUser.Ext.IcCardNumber, assertUserBase.UserInfo.UserName))
if len(assertUserBase.UserInfo.FacePortrait) > 0 {
term.BroadcastDownEntity(NewUpdateUserFacePortraitDownEntity(generateSn(), assertUser.Ext.IcCardNumber, assertUserBase.UserInfo.FacePortrait))
}
if len(assertUserBase.UserInfo.FingerprintPortrait) > 0 {
term.BroadcastDownEntity(NewUpdateUserFingerprintPortraitDownEntity(generateSn(), assertUser.Ext.IcCardNumber, assertUserBase.UserInfo.FingerprintPortrait))
}
term.BroadcastDownEntity(NewUpdateUserDownEntity(generateSn(), assertUser.Ext.IcCardNumber, assertUserBase.UserInfo.UserName))
}
return nil
}
... ...
... ... @@ -102,18 +102,25 @@ func (userService *UserService) BatchEnable(batchEnableCommand *command.BatchEna
}
for i := 0; i < len(batchEnableCommand.UserIds); i++ {
if user, err := userRepository.FindOne(map[string]interface{}{"userId": batchEnableCommand.UserIds[i]}); err != nil {
var (
user *domain.User
userBase *domain.UserBase
)
user, err = userRepository.FindOne(map[string]interface{}{"userId": batchEnableCommand.UserIds[i]})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
}
if err := user.SetEnableStatus(batchEnableCommand.EnableStatus); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if _, err := userRepository.Save(user); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err, _ := event.Fire(domain.UserEnableEvent, map[string]interface{}{"user": user}); err != nil {
if _, userBase, err = factory.FastPgUserBase(transactionContext, user.UserBaseId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err, _ := event.Fire(domain.UserEnableEvent, map[string]interface{}{"user": user, "userBase": userBase}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
... ...