sync: 同步 v1.0.4 并脱敏配置与镜像
This commit is contained in:
@@ -91,7 +91,7 @@ func (s MessageCenterSender) sendPlatform(ctx context.Context, batch Batch) erro
|
||||
len(batch.Items),
|
||||
err,
|
||||
)
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -205,9 +205,12 @@ func (s MessageCenterSender) writePlatform(ctx context.Context, batch Batch) err
|
||||
}
|
||||
|
||||
func resolvePlatformDeliveries(ctx context.Context, batch Batch) ([]platformDelivery, error) {
|
||||
if batch.prepared != nil {
|
||||
return []platformDelivery{{Group: *batch.prepared, Batch: batch}}, nil
|
||||
}
|
||||
deliveries := make([]platformDelivery, 0, 2)
|
||||
|
||||
agentUserIDs, err := queryAgentUserIDs(ctx, batch.TenantID, batch.DeptID, batch.CreatedBy)
|
||||
agentUserIDs, err := queryAgentUserIDs(ctx, batch.TenantID, batch.DeptID, batch.CreatedBy, batch.Business)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -219,6 +222,8 @@ func resolvePlatformDeliveries(ctx context.Context, batch Batch) ([]platformDeli
|
||||
},
|
||||
Batch: batch,
|
||||
})
|
||||
} else if batch.Business == BusinessTrafficCutoff {
|
||||
g.Log().Warningf(ctx, "WarningNotify traffic cutoff skipped department recipients, tenantId:%s, deptId:%d, category:%s, stage:%d, count:%d", batch.TenantID, batch.DeptID, batch.Category, batch.WarnStage, len(batch.Items))
|
||||
}
|
||||
|
||||
if hasCardWarningItems(batch.Items) {
|
||||
@@ -228,11 +233,11 @@ func resolvePlatformDeliveries(ctx context.Context, batch Batch) ([]platformDeli
|
||||
return deliveries, nil
|
||||
}
|
||||
|
||||
func queryAgentUserIDs(ctx context.Context, tenantID string, deptID int64, createdBy int64) ([]int64, error) {
|
||||
userIDs := make([]int64, 0)
|
||||
seen := make(map[int64]struct{})
|
||||
func queryAgentUserIDs(ctx context.Context, tenantID string, deptID int64, createdBy int64, business string) ([]int64, error) {
|
||||
deptUserIDs := make([]int64, 0)
|
||||
creatorUserID := int64(0)
|
||||
if strings.TrimSpace(tenantID) == "" {
|
||||
return userIDs, nil
|
||||
return deptUserIDs, nil
|
||||
}
|
||||
|
||||
columns := dao.SysUser.Columns()
|
||||
@@ -248,11 +253,11 @@ func queryAgentUserIDs(ctx context.Context, tenantID string, deptID int64, creat
|
||||
return nil, err
|
||||
}
|
||||
for _, user := range users {
|
||||
userIDs = appendUniqueInt64(userIDs, seen, user.UserId)
|
||||
deptUserIDs = append(deptUserIDs, user.UserId)
|
||||
}
|
||||
}
|
||||
|
||||
if createdBy > 0 {
|
||||
if business != BusinessTrafficCutoff && createdBy > 0 {
|
||||
var creator *entity.SysUser
|
||||
if err := dao.SysUser.Ctx(ctx).
|
||||
Fields(columns.UserId).
|
||||
@@ -264,11 +269,23 @@ func queryAgentUserIDs(ctx context.Context, tenantID string, deptID int64, creat
|
||||
return nil, err
|
||||
}
|
||||
if creator != nil {
|
||||
userIDs = appendUniqueInt64(userIDs, seen, creator.UserId)
|
||||
creatorUserID = creator.UserId
|
||||
}
|
||||
}
|
||||
|
||||
return userIDs, nil
|
||||
return platformAgentRecipientIDs(business, deptUserIDs, creatorUserID), nil
|
||||
}
|
||||
|
||||
func platformAgentRecipientIDs(business string, deptUserIDs []int64, createdBy int64) []int64 {
|
||||
userIDs := make([]int64, 0, len(deptUserIDs)+1)
|
||||
seen := make(map[int64]struct{})
|
||||
for _, userID := range deptUserIDs {
|
||||
userIDs = appendUniqueInt64(userIDs, seen, userID)
|
||||
}
|
||||
if business != BusinessTrafficCutoff {
|
||||
userIDs = appendUniqueInt64(userIDs, seen, createdBy)
|
||||
}
|
||||
return userIDs
|
||||
}
|
||||
|
||||
func queryCreatedTerminalUserIDs(ctx context.Context, tenantID string, createdBy int64) ([]int64, error) {
|
||||
@@ -295,6 +312,9 @@ func queryCreatedTerminalUserIDs(ctx context.Context, tenantID string, createdBy
|
||||
}
|
||||
|
||||
func resolveTerminalPlatformDeliveries(ctx context.Context, batch Batch) []platformDelivery {
|
||||
if batch.prepared != nil {
|
||||
return []platformDelivery{{Group: *batch.prepared, Batch: batch}}
|
||||
}
|
||||
itemsByUser := make(map[int64][]Event)
|
||||
seenByUser := make(map[int64]map[int]struct{})
|
||||
|
||||
@@ -408,16 +428,26 @@ func queryTerminalUserCardRowsByColumn(ctx context.Context, tenantID string, col
|
||||
if strings.TrimSpace(tenantID) == "" || len(values) == 0 {
|
||||
return rows, nil
|
||||
}
|
||||
err := g.DB().Model(simTerminalTable+" st").Ctx(ctx).Safe().
|
||||
LeftJoin(terminalTable+" t", "t.terminal_id = st.terminal_id AND t.tenant_id = st.tenant_id").
|
||||
LeftJoin(dao.SysUser.Table()+" u", "(u.user_id = t.leader OR u.user_id = st.terminal_id) AND u.tenant_id = st.tenant_id").
|
||||
Fields("DISTINCT u.user_id, st.iccid, st.msisdn").
|
||||
Where("st.tenant_id", tenantID).
|
||||
Where("u.user_type", consts.SysUserTypeAPP).
|
||||
Where("u.status", consts.SysDeptStatusNormal).
|
||||
WhereIn(column, values).
|
||||
Scan(&rows)
|
||||
return rows, err
|
||||
for offset := 0; offset < len(values); offset += 500 {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
end := min(offset+500, len(values))
|
||||
var page []terminalUserCardRow
|
||||
if err := g.DB().Model(simTerminalTable+" st").Ctx(ctx).Safe().
|
||||
LeftJoin(terminalTable+" t", "t.terminal_id = st.terminal_id AND t.tenant_id = st.tenant_id").
|
||||
LeftJoin(dao.SysUser.Table()+" u", "(u.user_id = t.leader OR u.user_id = st.terminal_id) AND u.tenant_id = st.tenant_id").
|
||||
Fields("DISTINCT u.user_id, st.iccid, st.msisdn").
|
||||
Where("st.tenant_id", tenantID).
|
||||
Where("u.user_type", consts.SysUserTypeAPP).
|
||||
Where("u.status", consts.SysDeptStatusNormal).
|
||||
WhereIn(column, values[offset:end]).
|
||||
Scan(&page); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rows = append(rows, page...)
|
||||
}
|
||||
return rows, nil
|
||||
}
|
||||
|
||||
func hasCardWarningItems(items []Event) bool {
|
||||
|
||||
Reference in New Issue
Block a user