fix 根据权限查询

This commit is contained in:
2024-03-07 00:31:27 +08:00
parent 20aa1b0815
commit a0505a1a93
9 changed files with 78 additions and 13 deletions

View File

@@ -18,8 +18,8 @@
<ItemGroup>
<ProjectReference Include="..\Dlhis.Basic.Api\Dlhis.Basic.Api.csproj" />
<ProjectReference Include="..\Dlhis.Common.Api\Dlhis.Common.Api.csproj" />
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
<ProjectReference Include="..\Dlhis.Sys.Api\Dlhis.Sys.Api.csproj" />
</ItemGroup>
<ItemGroup>
@@ -37,6 +37,7 @@
<ItemGroup>
<PackageReference Include="Kurisu.AspNetCore" Version="0.7.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
</ItemGroup>
</Project>

View File

@@ -8,8 +8,8 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Src/Dlhis.Canteen/Dlhis.Canteen.csproj", "Src/Dlhis.Canteen/"]
COPY ["Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj", "Src/Dlhis.Basic.Api/"]
COPY ["Src/Dlhis.Common.Api/Dlhis.Common.Api.csproj", "Src/Dlhis.Common.Api/"]
COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"]
COPY ["Src/Dlhis.Sys.Api/Dlhis.Sys.Api.csproj", "Src/Dlhis.Sys.Api/"]
RUN dotnet restore "Src/Dlhis.Canteen/Dlhis.Canteen.csproj"
COPY . .
WORKDIR "/src/Src/Dlhis.Canteen"

View File

@@ -1,6 +1,7 @@
using Dlhis.Canteen.Order.Request;
using Dlhis.Canteen.Order.Response;
using Dlhis.Canteen.Order.Services;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -28,6 +29,7 @@ public class BalancesController : ControllerBase
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[DataPermission]
[HttpGet]
public async Task<Pagination<BalanceRecordResponse>> GetPageAsync([FromQuery] BalanceRecordPageRequest request)
{
@@ -89,7 +91,7 @@ public class BalancesController : ControllerBase
[HttpGet("recordByCostId")]
public async Task<Pagination<BalanceRecordCostIdResponse>> RecordByCostIdAsync([FromQuery] BalanceRecordPageByCostIdRequest request)
{
return await _balanceService.RecordByCostIdAsync(request);
return await _balanceService.RecordByCostIdAsync(request);
}
/// <summary>
@@ -166,9 +168,9 @@ public class BalancesController : ControllerBase
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("disposition")]
public async Task DispositionDeviceAsync([FromQuery]DispositionDeviceRequest request)
public async Task DispositionDeviceAsync([FromQuery] DispositionDeviceRequest request)
{
await _balanceService.DispositionDeviceAsync(request);
await _balanceService.DispositionDeviceAsync(request);
}

View File

@@ -119,4 +119,14 @@ public class BalanceRecordResponse
/// 汇总金额
/// </summary>
public decimal Sum { get; set; }
/// <summary>
/// 厂区id
/// </summary>
public string TenantId { get; set; }
/// <summary>
/// 厂区名称
/// </summary>
public string TenantName { get; set; }
}

View File

@@ -5,6 +5,7 @@ using Dlhis.Entity.Canteen.Entities;
using Dlhis.Entity.Canteen.Enums;
using Dlhis.Entity.Device.Entities;
using Dlhis.Entity.Device.Enums;
using Dlhis.Sys.Api;
using Kurisu.AspNetCore.UnifyResultAndValidation;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.DataAccess.Dto;
@@ -12,7 +13,6 @@ using Kurisu.Core.DataAccess.Entity;
using Kurisu.Core.User.Abstractions;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
namespace Dlhis.Canteen.Order.Services.Implements;
@@ -22,12 +22,14 @@ public class BalanceService : IBalanceService
private readonly IDbContext _dbContext;
private readonly ICurrentUser _currentUser;
private readonly ILogger<BalanceService> _logger;
private readonly ITenantApi _tenantApi;
public BalanceService(IDbContext dbContext, ICurrentUser currentUser, ILogger<BalanceService> logger)
public BalanceService(IDbContext dbContext, ICurrentUser currentUser, ILogger<BalanceService> logger ,ITenantApi tenantApi)
{
_dbContext = dbContext;
_currentUser = currentUser;
_logger = logger;
_tenantApi = tenantApi;
}
public async Task<Pagination<BalanceRecordResponse>> GetPageAsync(BalanceRecordPageRequest request)
@@ -71,10 +73,26 @@ public class BalanceService : IBalanceService
DepartmentName = department.Name,
BusinessPlaceName = bplace.Name,
BusinessShiftName = type.Display,
CostDateTime = record.CostDateTime
CostDateTime = record.CostDateTime,
TenantId = record.TenantId,
})
.ToPageListAsync(request);
try
{
var tenantResult = await _tenantApi.GetTenantsInternalAsync();
var tenants = tenantResult.Data;
page.Data.ForEach(item =>
{
item.TenantName = tenants.FirstOrDefault(x => x.Code == item.TenantId)?.Name;
});
}
catch (Exception)
{
}
return page;
}
/// <summary>
@@ -562,7 +580,7 @@ public class BalanceService : IBalanceService
var offCount = await GetOfflineDevicesCount(devices);
var places = await _dbContext.Queryable<BusinessPlaceEntity>()
.Where(x =>x.Status == CanteenBusinessPlaceStatusEnumType.Opened)
.Where(x => x.Status == CanteenBusinessPlaceStatusEnumType.Opened)
.ToListAsync();
var time = DateTime.Now.ToString("yyyy-MM-dd");
@@ -747,7 +765,7 @@ public class BalanceService : IBalanceService
var devices = await _dbContext.Queryable<DeviceEntity>().ToListAsync();
if (request.UniqueNos!=null && request.UniqueNos.Count > 0)
if (request.UniqueNos != null && request.UniqueNos.Count > 0)
{
foreach (var no in request.UniqueNos)
{

View File

@@ -20,7 +20,7 @@
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.7" />
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.9.3" />
<PackageReference Include="Kurisu.AspNetCore" Version="0.6.0" />
<PackageReference Include="Kurisu.AspNetCore" Version="0.7.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,6 +1,7 @@
using Dlhis.ScheduledTask.TaskAssignment.Request;
using Dlhis.ScheduledTask.TaskAssignment.Response;
using Dlhis.ScheduledTask.TaskAssignment.Services;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -28,6 +29,7 @@ public class DeviceTaskAssignmentsController : ControllerBase
/// <param name="request"></param>
/// <returns></returns>
[HttpGet("page")]
[DataPermission]
public async Task<Pagination<DeviceTaskAssignmentResponse>> GetPageAsync([FromQuery] DeviceTaskAssignmentRequest request)
{
return await _deviceTaskAssignmentService.GetPageAsync(request);

View File

@@ -66,4 +66,15 @@ public class DeviceTaskAssignmentResponse
/// 数据状态最新修改时间
/// </summary>
public DateTime LastUpdateTime { get; set; }
/// <summary>
/// 厂区id
/// </summary>
public string TenantId { get; set; }
/// <summary>
/// 厂区名称
/// </summary>
public string TenantName { get; set; }
}

View File

@@ -3,6 +3,7 @@ using Dlhis.Entity.Device.Entities;
using Dlhis.Entity.Device.Enums;
using Dlhis.ScheduledTask.TaskAssignment.Request;
using Dlhis.ScheduledTask.TaskAssignment.Response;
using Dlhis.Sys.Api;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.DataAccess.Dto;
using Kurisu.SqlSugar.Extensions;
@@ -14,10 +15,12 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Services.Implements;
public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService
{
private readonly IDbContext _dbContext;
private readonly ITenantApi _tenantApi;
public DeviceTaskAssignmentService(IDbContext dbContext)
public DeviceTaskAssignmentService(IDbContext dbContext, ITenantApi tenantApi)
{
_dbContext = dbContext;
_tenantApi = tenantApi;
}
public async Task<Pagination<DeviceTaskAssignmentResponse>> GetPageAsync(DeviceTaskAssignmentRequest request)
@@ -27,6 +30,7 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService
.WhereIF(!request.Search.IsEmpty(), (deviceTask, ga) => deviceTask.UserNo == request.Search || ga.Name.Contains(request.Search))
.WhereIF(request.Type.HasValue, deviceTask => deviceTask.Type == request.Type)
.WhereIF(request.Status.HasValue, deviceTask => deviceTask.Status == request.Status)
.Where(deviceTask => 1 == 1)
.OrderBy(deviceTask => deviceTask.CreateTime, OrderByType.Desc)
.Select((deviceTask, ga) => new DeviceTaskAssignmentResponse
{
@@ -40,10 +44,27 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService
UserCode = ga.Code,
Type = deviceTask.Type,
CreateTime = deviceTask.CreateTime,
LastUpdateTime = deviceTask.ModifiedTime
LastUpdateTime = deviceTask.ModifiedTime,
TenantId = deviceTask.TenantId,
})
.ToPageListAsync(request);
try
{
var tenantResult = await _tenantApi.GetTenantsInternalAsync();
var tenants = tenantResult.Data;
page.Data.ForEach(item =>
{
item.TenantName = tenants.FirstOrDefault(x => x.Code == item.TenantId)?.Name;
});
}
catch (Exception)
{
}
return page;
}