diff --git a/Common/Dapper/DapperHelper.cs b/Common/Dapper/DapperHelper.cs index c6ddb5f..c1bc505 100644 --- a/Common/Dapper/DapperHelper.cs +++ b/Common/Dapper/DapperHelper.cs @@ -12,7 +12,8 @@ public class DapperHelper : IDapperHelper DEV, PRO, DataFill, - Canteen + Canteen, + GYAPP } /// @@ -88,6 +89,7 @@ public class DapperHelper : IDapperHelper SysName.PRO => new SqlConnection(AppSettings.GetConnectionString("PRO")), SysName.DataFill => new SqlConnection(AppSettings.GetConnectionString("DataFill")), SysName.Canteen => new SqlConnection(AppSettings.GetConnectionString("Canteen")), + SysName.GYAPP => new SqlConnection(AppSettings.GetConnectionString("GYAPP")), _ => new SqlConnection(AppSettings.GetConnectionString("Default")) }; diff --git a/ExternalAPI_NET8/Controllers/CanteenController.cs b/ExternalAPI_NET8/Controllers/CanteenController.cs index b4468e8..1cc19e4 100644 --- a/ExternalAPI_NET8/Controllers/CanteenController.cs +++ b/ExternalAPI_NET8/Controllers/CanteenController.cs @@ -13,13 +13,11 @@ namespace ExternalAPI_NET8.Controllers; public class CanteenController(ICanteenServices canteenServices) : ApiControllerBase { - private readonly ICanteenServices _canteenServices = canteenServices; - [HttpGet] [AllowAnonymous] public async Task GetMealsAmount(string date) { - var a=await _canteenServices.GetMealsAmountAsync(date); + var a=await canteenServices.GetMealsAmountAsync(date); return RenderOk(a); } } \ No newline at end of file diff --git a/ExternalAPI_NET8/ExternalAPI.xml b/ExternalAPI_NET8/ExternalAPI.xml index 7049f28..0dce6bf 100644 --- a/ExternalAPI_NET8/ExternalAPI.xml +++ b/ExternalAPI_NET8/ExternalAPI.xml @@ -50,7 +50,7 @@ - 接收采购付款审批流程数据1 + 接收采购付款审批流程数据 diff --git a/Model/Entity/Ordermeals.cs b/Model/Entity/Ordermeals.cs index bbd8287..0d02bea 100644 --- a/Model/Entity/Ordermeals.cs +++ b/Model/Entity/Ordermeals.cs @@ -1,9 +1,12 @@ namespace Web.Core.Model.Entity; -public class Ordermeals +public class Ordermeal { + public int lunch { get; set; } + public int dinner { get; set; } public int total => lunch + dinner; + } \ No newline at end of file diff --git a/Model/Web.Core.Model.csproj b/Model/Web.Core.Model.csproj index adacf1b..fe089a8 100644 --- a/Model/Web.Core.Model.csproj +++ b/Model/Web.Core.Model.csproj @@ -10,6 +10,11 @@ none + 1701;1702;1591 + + + + 1701;1702;1591 diff --git a/Web.Core.IServices/Canteen/ICanteenServices.cs b/Web.Core.IServices/Canteen/ICanteenServices.cs index 21485d6..d1b2c57 100644 --- a/Web.Core.IServices/Canteen/ICanteenServices.cs +++ b/Web.Core.IServices/Canteen/ICanteenServices.cs @@ -4,5 +4,5 @@ namespace Web.Core.IServices.Canteen; public interface ICanteenServices { - public Task GetMealsAmountAsync(string date); + public Task GetMealsAmountAsync(string date); } \ No newline at end of file diff --git a/Web.Core.Services/Canteen/CanteenServices.cs b/Web.Core.Services/Canteen/CanteenServices.cs index 1115ef5..09bd063 100644 --- a/Web.Core.Services/Canteen/CanteenServices.cs +++ b/Web.Core.Services/Canteen/CanteenServices.cs @@ -4,18 +4,31 @@ using Web.Core.Model.Entity; namespace Web.Core.Services.Canteen; -public class CanteenServices(IDapperHelper dapperHelper):ICanteenServices +public class CanteenServices(IDapperHelper dapperHelper) : ICanteenServices { - private readonly IDapperHelper _db = dapperHelper; - - public async Task GetMealsAmountAsync(string date) + public async Task GetMealsAmountAsync(string date) { - string sql = """ - WITH temp AS (SELECT Card_id,Dins1,Dins2,Dins1Cancel,Dins2Cancel FROM MealQuery(@date,@date)) - SELECT ISNULL(SUM(CASE WHEN ISNULL(a.Dins1,0)=1 AND ISNULL(a.Dins1Cancel,0)=0 THEN 1 ELSE 0 END),0) AS lunch , - ISNULL(SUM(CASE WHEN ISNULL(a.Dins2,0)=1 AND ISNULL(a.Dins2Cancel,0)=0 THEN 1 ELSE 0 END),0) AS dinner - FROM temp a - """; - return await _db.QueryFirstOrDefaultAsync(DapperHelper.SysName.Canteen, sql, new { date }); + var sql1 = """ + WITH temp AS (SELECT Card_id,Dins1,Dins2,Dins1Cancel,Dins2Cancel FROM MealQuery(@date,@date)) + SELECT ISNULL(SUM(CASE WHEN ISNULL(a.Dins1,0)=1 AND ISNULL(a.Dins1Cancel,0)=0 THEN 1 ELSE 0 END),0) AS lunch , + ISNULL(SUM(CASE WHEN ISNULL(a.Dins2,0)=1 AND ISNULL(a.Dins2Cancel,0)=0 THEN 1 ELSE 0 END),0) AS dinner + FROM temp a + """; + var sql2 = + "SELECT LunchNumber as lunch,DinnerNumber as dinner FROM dbo.MealCommitNumbers WHERE RecodeTime=@date"; + + var ordermeal1 = + await dapperHelper.QueryFirstOrDefaultAsync(DapperHelper.SysName.Canteen, sql1, new { date }); + + + var ordermeal2 = + await dapperHelper.QueryFirstOrDefaultAsync(DapperHelper.SysName.GYAPP, sql2, + new { date }); + + return new Ordermeal + { + lunch = ordermeal1.lunch + (ordermeal2?.lunch ?? 0), + dinner = ordermeal1.dinner + (ordermeal2?.dinner ?? 0) + }; } } \ No newline at end of file