From 234852704fa6e9528e7be3b079143f9574e75d0d Mon Sep 17 00:00:00 2001 From: guob yuano Date: Tue, 29 Sep 2026 15:30:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=B6=88=E8=B4=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=A4=B1=E8=B4=A5=20=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 + Src/Dlhis.Basic/Dlhis.Basic.csproj | 4 + Src/Dlhis.Canteen/Dlhis.Canteen.csproj | 4 + Src/Dlhis.ScheduledTask/Jobs/CostUploadJob.cs | 78 ++++++++++--------- Src/Dlhis.Sys/Dlhis.Sys.csproj | 4 + 5 files changed, 58 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index f8f1c339..b0e15423 100644 --- a/.gitignore +++ b/.gitignore @@ -212,3 +212,6 @@ ServiceFabricBackup/ *.ldf *.ndf +/Src/Dlhis.Basic/App/App +/Src/Dlhis.Basic/App +/Src/Dlhis.Sys/App diff --git a/Src/Dlhis.Basic/Dlhis.Basic.csproj b/Src/Dlhis.Basic/Dlhis.Basic.csproj index 00d979c2..dd101846 100644 --- a/Src/Dlhis.Basic/Dlhis.Basic.csproj +++ b/Src/Dlhis.Basic/Dlhis.Basic.csproj @@ -14,9 +14,13 @@ + + + + appsettings.json diff --git a/Src/Dlhis.Canteen/Dlhis.Canteen.csproj b/Src/Dlhis.Canteen/Dlhis.Canteen.csproj index 42d85d59..401c1fc5 100644 --- a/Src/Dlhis.Canteen/Dlhis.Canteen.csproj +++ b/Src/Dlhis.Canteen/Dlhis.Canteen.csproj @@ -10,9 +10,13 @@ + + + + diff --git a/Src/Dlhis.ScheduledTask/Jobs/CostUploadJob.cs b/Src/Dlhis.ScheduledTask/Jobs/CostUploadJob.cs index 96511477..cd016f03 100644 --- a/Src/Dlhis.ScheduledTask/Jobs/CostUploadJob.cs +++ b/Src/Dlhis.ScheduledTask/Jobs/CostUploadJob.cs @@ -3,6 +3,7 @@ using Dlhis.Entity.Canteen.Enums; using Dlhis.Jip.Api; using Dlhis.Jip.Api.Requests; using Dlhis.ScheduledTask.Attributes; +using Newtonsoft.Json; using SqlSugar; namespace Dlhis.ScheduledTask.Jobs; @@ -78,49 +79,56 @@ public class CostUploadJob : BaseJob }).ToList() }; - var response = await jipApi.UploadCostAsync(request); - var handleData = response.Data.Where(x => x.Success == "S").ToList(); - Logger.LogInformation("CostUploadJob消费上传成功人员:{count}", handleData.Count); - if (!handleData.Any()) + try { - continue; - } - var workCodes = handleData.Select(x => x.WorkCode).ToList(); - - var records = await DbContext.Queryable() - .Where(x => workCodes.Contains(x.UserCode)) - .Where(x => x.Year == s.Year && x.Month == s.Month) - .ToListAsync(); - - var updatedRecords = new List(); - var newRecords = new List(); - foreach (var item in handleData) - { - var record = records.FirstOrDefault(x => x.UserCode == item.WorkCode); - if (record != null) + var response = await jipApi.UploadCostAsync(request); + var handleData = response.Data.Where(x => x.Success == "S").ToList(); + Logger.LogInformation("CostUploadJob消费上传成功人员:{count}", handleData.Count); + if (!handleData.Any()) { - record.Cost = dict[item.WorkCode]; - updatedRecords.Add(record); + continue; } - else + var workCodes = handleData.Select(x => x.WorkCode).ToList(); + + var records = await DbContext.Queryable() + .Where(x => workCodes.Contains(x.UserCode)) + .Where(x => x.Year == s.Year && x.Month == s.Month) + .ToListAsync(); + + var updatedRecords = new List(); + var newRecords = new List(); + foreach (var item in handleData) { - newRecords.Add(new UserBalanceUploadRecordEntity + var record = records.FirstOrDefault(x => x.UserCode == item.WorkCode); + if (record != null) { - UserCode = item.WorkCode, - Year = s.Year, - Month = s.Month, - Cost = dict[item.WorkCode] - }); + record.Cost = dict[item.WorkCode]; + updatedRecords.Add(record); + } + else + { + newRecords.Add(new UserBalanceUploadRecordEntity + { + UserCode = item.WorkCode, + Year = s.Year, + Month = s.Month, + Cost = dict[item.WorkCode] + }); + } + } + if (updatedRecords.Any()) + { + await DbContext.UpdateAsync(updatedRecords); + } + + if (newRecords.Any()) + { + await DbContext.InsertAsync(newRecords); } } - if (updatedRecords.Any()) + catch (Exception ex) { - await DbContext.UpdateAsync(updatedRecords); - } - - if (newRecords.Any()) - { - await DbContext.InsertAsync(newRecords); + Logger.LogError(ex, "BirthdayCostUploadJob上传消费数据失败-{userCode}:{error}", JsonConvert.SerializeObject(request), ex.Message); } } } diff --git a/Src/Dlhis.Sys/Dlhis.Sys.csproj b/Src/Dlhis.Sys/Dlhis.Sys.csproj index ff5b9084..66a4fe24 100644 --- a/Src/Dlhis.Sys/Dlhis.Sys.csproj +++ b/Src/Dlhis.Sys/Dlhis.Sys.csproj @@ -10,9 +10,13 @@ + + + +