|
|
@@ -683,13 +683,30 @@ select
|
|
|
{
|
|
|
redisExample.DeleteData(value);
|
|
|
}
|
|
|
- return Task.CompletedTask; ;
|
|
|
+ return Task.CompletedTask;
|
|
|
+ }
|
|
|
+ public async Task AddCarRedisAsync()
|
|
|
+ {
|
|
|
+ DateTime now = DateTime.Now;
|
|
|
+
|
|
|
+ DateTime firstDayOfPreviousMonth = now.AddMonths(-1).Date.AddDays(-(now.Day - 1));
|
|
|
+
|
|
|
+ string date = firstDayOfPreviousMonth.ToString("yyyy-MM-dd");
|
|
|
+ List<KeyValuePair<string, string>> hashValues = redisExample.GetListValues("business_unit_info");
|
|
|
+ if (hashValues.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var kvp in hashValues)
|
|
|
+ {
|
|
|
+ await AddEmployeeCardMonthlySummaryToRedisAsync(kvp.Key, date, "0");
|
|
|
+ await AddEmployeeCardMonthlySummaryToRedisAsync(kvp.Key, date, "1");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
public void Getdate(string buid, string date, string Car)
|
|
|
{
|
|
|
redisExample.AddToHash(buid, date, "1");
|
|
|
}
|
|
|
- public void addredis(string buid)
|
|
|
+ public async Task addredis(string buid)
|
|
|
{
|
|
|
List<KeyValuePair<string, string>> hashValues = redisExample.GetListValues(buid);
|
|
|
if (hashValues.Count > 0)
|
|
|
@@ -705,8 +722,8 @@ select
|
|
|
string value = hashValues.FirstOrDefault(x => x.Key == date).Value;
|
|
|
|
|
|
|
|
|
- AddEmployeeCardMonthlySummaryToRedisAsync(buid, date, "0");
|
|
|
- AddEmployeeCardMonthlySummaryToRedisAsync(buid, date, "1");
|
|
|
+ await AddEmployeeCardMonthlySummaryToRedisAsync(buid, date, "0");
|
|
|
+ await AddEmployeeCardMonthlySummaryToRedisAsync(buid, date, "1");
|
|
|
redisExample.AddToHash(buid, dates.Max().AddMonths(1).ToString("yyyy-MM-dd"), "2");
|
|
|
}
|
|
|
}
|
|
|
@@ -766,17 +783,13 @@ select
|
|
|
int totalChunks = (account_ids.Count + chunkSize - 1) / chunkSize;
|
|
|
for (int i = 0; i < totalChunks; i++)
|
|
|
{
|
|
|
- // 计算当前块的起始和结束索引
|
|
|
int startIndex = i * chunkSize;
|
|
|
int endIndex = Math.Min(startIndex + chunkSize, account_ids.Count);
|
|
|
|
|
|
- // 获取当前块的account_ids
|
|
|
List<string> chunkAccountIds = account_ids.GetRange(startIndex, endIndex - startIndex);
|
|
|
|
|
|
- // 构建SQL的IN子句部分
|
|
|
string sqlJoin = string.Join(",", chunkAccountIds.Select(id => string.Format("'{0}'", id)));
|
|
|
|
|
|
- // 构建完整的SQL查询(注意:这里省略了日期等变量的插入)
|
|
|
sql = string.Format(@"
|
|
|
SELECT ci.account_id, sum(trx.amount) as amount FROM public.offline_transaction_info trx
|
|
|
LEFT JOIN public.card_info ci ON trx.card_info_id = ci.id
|
|
|
@@ -790,15 +803,12 @@ select
|
|
|
", buid, sqljoin, date, enddate);
|
|
|
|
|
|
|
|
|
- // 插入变量到SQL查询中(这里简化了,你可能需要更复杂的逻辑来处理buid, date, enddate等)
|
|
|
- sql = string.Format(sql, buid, sqlJoin); // 假设buid是之前定义的变量
|
|
|
+ sql = string.Format(sql, buid, sqlJoin);
|
|
|
|
|
|
- // 执行查询并获取结果
|
|
|
var chunkAccountRecharges = _AccountingContext.DbContext.accountRechargeTotals
|
|
|
.FromSqlRaw(sql)
|
|
|
.ToList();
|
|
|
|
|
|
- // 将结果添加到总列表中
|
|
|
allAccountRecharges.AddRange(chunkAccountRecharges);
|
|
|
}
|
|
|
#region
|
|
|
@@ -880,7 +890,6 @@ select
|
|
|
GROUP BY trx.card_no;
|
|
|
";
|
|
|
|
|
|
- // 使用参数化查询来避免SQL注入攻击
|
|
|
var parameters = new SqlParameter[]
|
|
|
{
|
|
|
new SqlParameter("@BuId", buid),
|
|
|
@@ -888,7 +897,6 @@ select
|
|
|
new SqlParameter("@EndDate", enddate)
|
|
|
};
|
|
|
|
|
|
- // 使用Entity Framework Core的FromSqlRaw重载来包含参数
|
|
|
var chunkCarRecharges = _AccountingContext.DbContext.accountRechargeTotals
|
|
|
.FromSqlRaw(sql)
|
|
|
.ToList();
|