From b980f61f219abef08894aa79fb2610788bbc2999 Mon Sep 17 00:00:00 2001 From: "wanling040@gmail.com" Date: Thu, 28 Jul 2022 09:33:53 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=8B=E7=B6=AD=E5=84=B2=E5=AD=98=E5=BA=AB-?= =?UTF-8?q?=E5=AF=AB=E5=85=A5=E9=80=9A=E7=9F=A5=E8=A1=8C=E7=A8=8B=E7=9A=84?= =?UTF-8?q?=E5=87=BD=E5=BC=8F=E8=AA=BF=E6=95=B4=E7=82=BA=E5=8F=AF=E6=9B=B4?= =?UTF-8?q?=E6=94=B9emailType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Quartz/Jobs/OperationScheduleJob.cs | 2 +- .../Implement/OperationRepository.cs | 25 +++++++++++++++++-- .../Interface/IOperationRepository.cs | 8 +++++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs index 10a1d73..e97cdde 100644 --- a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs +++ b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs @@ -176,7 +176,7 @@ namespace SolarPower.Quartz.Jobs var personal = await operationRepository.GetOperationPersonnel(a.PowerStationId); var Title = $@"電站:{a.PowerStationName} - {WorkType}單 - 編號:{a.PlanId}"; var content = $@" {noticeName} {Environment.NewLine} 內容描述:{a.Description}"; - await operationRepository.InsertNoticeSchedule(personal, Title, content); + await operationRepository.InsertNoticeSchedule(personal, Title, content, 3); var OperationPlans = new OperationCreatePlan() { diff --git a/SolarPower/Repository/Implement/OperationRepository.cs b/SolarPower/Repository/Implement/OperationRepository.cs index 6ade5ac..2f1a88c 100644 --- a/SolarPower/Repository/Implement/OperationRepository.cs +++ b/SolarPower/Repository/Implement/OperationRepository.cs @@ -636,7 +636,7 @@ namespace SolarPower.Repository.Implement } } - public async Task InsertNoticeSchedule(List personal, string Title, string content) + public async Task InsertNoticeSchedule(List personal, string Title, string content, int emailType) { using (IDbConnection conn = this._databaseHelper.GetConnection()) { @@ -648,7 +648,7 @@ namespace SolarPower.Repository.Implement List value = new List(); foreach (MyUser a in personal) { - value.Add($@"(1,'{a.Name}','{a.Email}','{Title}','{content}',{a.Id},3)"); + value.Add($@"(1,'{a.Name}','{a.Email}','{Title}','{content}',{a.Id}, {emailType})"); } string values = string.Join(",", value.ToArray()); @@ -776,5 +776,26 @@ namespace SolarPower.Repository.Implement } } + public async Task> GetAllOperations() + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = @$"SELECT DISTINCT us.* + FROM power_station_operation_personnel ps + LEFT JOIN user us ON ps.UserId = us.Id + WHERE ps.Deleted = 0 AND us.Deleted = 0"; + result = (await conn.QueryAsync(sql)).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + } } diff --git a/SolarPower/Repository/Interface/IOperationRepository.cs b/SolarPower/Repository/Interface/IOperationRepository.cs index 9630b39..3c1d8e0 100644 --- a/SolarPower/Repository/Interface/IOperationRepository.cs +++ b/SolarPower/Repository/Interface/IOperationRepository.cs @@ -74,7 +74,7 @@ namespace SolarPower.Repository.Interface Task> GetOperationPersonnel(int PowerStationId); - Task InsertNoticeSchedule(List personal, string Title, string content); + Task InsertNoticeSchedule(List personal, string Title, string content, int emailType); Task AddOperationRecordPersonnelAsync(List entity, List properties); @@ -83,6 +83,12 @@ namespace SolarPower.Repository.Interface Task DeleteOperationRecordPersonnel(List operationRecordPersonnels); Task DeleteRecord(List operations); + + /// + /// 取所有維運人員 + /// + /// + Task> GetAllOperations(); } }