饭餐查询接口增加饭票数量统计
This commit is contained in:
parent
3f5dc410e3
commit
aa2cf39f17
@ -12,7 +12,8 @@ public class DapperHelper : IDapperHelper
|
||||
DEV,
|
||||
PRO,
|
||||
DataFill,
|
||||
Canteen
|
||||
Canteen,
|
||||
GYAPP
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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"))
|
||||
};
|
||||
|
||||
|
||||
@ -13,13 +13,11 @@ namespace ExternalAPI_NET8.Controllers;
|
||||
|
||||
public class CanteenController(ICanteenServices canteenServices) : ApiControllerBase
|
||||
{
|
||||
private readonly ICanteenServices _canteenServices = canteenServices;
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> GetMealsAmount(string date)
|
||||
{
|
||||
var a=await _canteenServices.GetMealsAmountAsync(date);
|
||||
var a=await canteenServices.GetMealsAmountAsync(date);
|
||||
return RenderOk(a);
|
||||
}
|
||||
}
|
||||
@ -50,7 +50,7 @@
|
||||
</member>
|
||||
<member name="M:ExternalAPI_NET8.Controllers.OAPushController.ReveivePMInvoiceFromOA(Web.Core.Model.Entity.OAPush_PMInvoice)">
|
||||
<summary>
|
||||
接收采购付款审批流程数据1
|
||||
接收采购付款审批流程数据
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
|
||||
@ -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;
|
||||
|
||||
}
|
||||
@ -10,6 +10,11 @@
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DebugType>none</DebugType>
|
||||
<NoWarn>1701;1702;1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<NoWarn>1701;1702;1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -4,5 +4,5 @@ namespace Web.Core.IServices.Canteen;
|
||||
|
||||
public interface ICanteenServices
|
||||
{
|
||||
public Task<Ordermeals> GetMealsAmountAsync(string date);
|
||||
public Task<Ordermeal> GetMealsAmountAsync(string date);
|
||||
}
|
||||
@ -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<Ordermeals> GetMealsAmountAsync(string date)
|
||||
public async Task<Ordermeal> 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<Ordermeals>(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<Ordermeal>(DapperHelper.SysName.Canteen, sql1, new { date });
|
||||
|
||||
|
||||
var ordermeal2 =
|
||||
await dapperHelper.QueryFirstOrDefaultAsync<Ordermeal>(DapperHelper.SysName.GYAPP, sql2,
|
||||
new { date });
|
||||
|
||||
return new Ordermeal
|
||||
{
|
||||
lunch = ordermeal1.lunch + (ordermeal2?.lunch ?? 0),
|
||||
dinner = ordermeal1.dinner + (ordermeal2?.dinner ?? 0)
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user