From b3fe957a1bec7be787191020a47eb92fbfd12297 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Mon, 9 Sep 2024 11:15:17 +0800 Subject: [PATCH 01/18] =?UTF-8?q?fix=20=E6=95=B0=E6=8D=AE=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Implements/BalanceService.cs | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs index ba37ddfd..de93f8b6 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs @@ -49,12 +49,9 @@ public class BalanceService : IBalanceService public async Task> GetPageAsync(BalanceRecordPageRequest request) { var page = await _dbContext.Queryable() - .LeftJoin((record, ga) => record.UserNo == ga.No) - //.LeftJoinIF(request.GainfoStatus == GainfoStatusEnumType.Working, (record, ga) => record.UserNo == ga.No) - //.LeftJoinIF(request.GainfoStatus == GainfoStatusEnumType.Leave, (record, ga) => record.UserNo == ga.No) - .LeftJoin((record, ga, department) => ga.DepartmentNo == department.No) - .LeftJoin((record, ga, department, bPlace) => record.BusinessPlaceCode == bPlace.Code) - .LeftJoin((record, ga, department, bPlace, order) => record.No == order.No) + .LeftJoin((record, department) => record.DepartmentNo == department.No) + .LeftJoin((record, department, bPlace) => record.BusinessPlaceCode == bPlace.Code) + .LeftJoin((record, department, bPlace, order) => record.No == order.No) .WhereIF(request.Factory.IsPresent(), record => record.TenantId == request.Factory) .WhereIF(request.SearchDateTimePeriod.HasValue(), record => record.CostDate >= request.SearchDateTimePeriod.Start && record.CostDate <= request.SearchDateTimePeriod.End) .WhereIF(request.Type.HasValue, record => record.Type == request.Type) @@ -62,7 +59,7 @@ public class BalanceService : IBalanceService .WhereIF(request.UserCode.IsPresent(), record => record.UserCode == request.UserCode) .WhereIF(request.UserName.IsPresent(), record => record.Name == request.UserName) .OrderBy(record => record.CreateTime, OrderByType.Desc) - .Select((record, ga, department, bPlace, order) => new BalanceRecordResponse + .Select((record, department, bPlace, order) => new BalanceRecordResponse { Id = record.Id, No = record.No, @@ -182,17 +179,16 @@ public class BalanceService : IBalanceService } var page = await _dbContext.Queryable() - .LeftJoin((record, ga) => record.UserNo == ga.No) - .LeftJoin((record, ga, department) => ga.DepartmentNo == department.No) - .LeftJoin((record, ga, department, bPlace) => record.BusinessPlaceCode == bPlace.Code) - .LeftJoin((record, ga, department, bPlace, imageRecord) => imageRecord.No == record.No) + .LeftJoin((record, department) => record.DepartmentNo == department.No) + .LeftJoin((record, department, bPlace) => record.BusinessPlaceCode == bPlace.Code) + .LeftJoin((record, department, bPlace, imageRecord) => imageRecord.No == record.No) .Where(record => record.DeviceUniqueNo == device.UniqueNo) .Where(record => record.CostDate >= request.Start && record.CostDate <= request.End) .Where(record => record.Type == BalanceRecordTypeEnumType.Out && (record.Status == BalanceRecordStatusEnumType.Valid || (record.Status == BalanceRecordStatusEnumType.Obsolute && record.Remark == "退款"))) .WhereIF(request.UserCode.IsPresent(), record => record.UserCode == request.UserCode) .OrderBy(record => record.CostDateTime, OrderByType.Desc) - .Select((record, ga, department, bPlace, imageRecord) => new BalanceRecordDeviceResponse + .Select((record, department, bPlace, imageRecord) => new BalanceRecordDeviceResponse { Id = record.Id, Amount = SqlFunc.Abs(record.Amount), @@ -238,7 +234,6 @@ public class BalanceService : IBalanceService var queryable = _dbContext.Queryable() .LeftJoin((record, department) => record.DepartmentNo == department.No) .LeftJoin((record, department, bPlace) => record.BusinessPlaceCode == bPlace.Code) - .LeftJoin((record, department, bPlace, gainfo) => record.UserNo == gainfo.No) .Where(record => record.Type == BalanceRecordTypeEnumType.Out && record.Status == BalanceRecordStatusEnumType.Valid) .Where(record => myCodes.Contains(record.BusinessPlaceCode)) .WhereIF(request.SearchDateTimePeriod.HasValue(), record => record.CostDate >= request.SearchDateTimePeriod.Start && record.CostDate <= request.SearchDateTimePeriod.End) @@ -247,7 +242,7 @@ public class BalanceService : IBalanceService var page = await queryable .OrderBy(record => record.CostDateTime, OrderByType.Desc) - .Select((record, department, bPlace, gainfo) => new BalanceRecordDetailPageResponse + .Select((record, department, bPlace) => new BalanceRecordDetailPageResponse { Id = record.Id, No = record.No, From 7f77a6339b3200f536f5dc29478d1f7d0b45b8b8 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 18 Sep 2024 17:22:20 +0800 Subject: [PATCH 02/18] fix dockerfile --- Src/Dlhis.External/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Src/Dlhis.External/Dockerfile b/Src/Dlhis.External/Dockerfile index 8a640cee..ae159968 100644 --- a/Src/Dlhis.External/Dockerfile +++ b/Src/Dlhis.External/Dockerfile @@ -9,6 +9,7 @@ ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["Src/Dlhis.External/Dlhis.External.csproj", "Src/Dlhis.External/"] COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"] +COPY ["Src/Dlhis.DataPermission.Model/Dlhis.DataPermission.Model.csproj", "Src/Dlhis.DataPermission.Model/"] RUN dotnet restore "./Src/Dlhis.External/./Dlhis.External.csproj" COPY . . WORKDIR "/src/Src/Dlhis.External" From 8e6eb516ad3bd724dd3ba0917a936ab5019e16f5 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 19 Sep 2024 10:40:08 +0800 Subject: [PATCH 03/18] =?UTF-8?q?fix=20=E7=A7=BB=E9=99=A4=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EMealVoucher/Services/Implements/EMealVoucherService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Src/Dlhis.Canteen/EMealVoucher/Services/Implements/EMealVoucherService.cs b/Src/Dlhis.Canteen/EMealVoucher/Services/Implements/EMealVoucherService.cs index fb689658..4b562870 100644 --- a/Src/Dlhis.Canteen/EMealVoucher/Services/Implements/EMealVoucherService.cs +++ b/Src/Dlhis.Canteen/EMealVoucher/Services/Implements/EMealVoucherService.cs @@ -31,7 +31,6 @@ public class EMealVoucherService : IEMealVoucherService public async Task> GetMyEMealVoucherPageAsync(EMealVoucherPageRequest request) { var code = _currentUser.GetUserClaim("jinko-code"); - code = "0123456"; return await _dbContext.Queryable() .Where(x => x.Code == code) .OrderBy(x => x.Id, OrderByType.Desc) From 17365b81e0a89ee81b987adaae22c46b4282d747 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 19 Sep 2024 11:23:20 +0800 Subject: [PATCH 04/18] fix log --- .../Order/Services/Implements/OrderService.cs | 7 ++++++- Src/Dlhis.Entity/Basic/Entity/OutsourceEntity.cs | 8 ++++---- .../Services/Implements/CanteenSettingService.cs | 4 +--- .../Services/Implements/HealthcheckService.cs | 12 +++++++----- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs index c12467a4..9f8363b5 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs @@ -58,6 +58,7 @@ public class OrderService : BaseOrderService, IOrderService { if (_httpContextAccessor.HttpContext!.Request.Headers.TryGetValue("X-Requested-DeviceIp", out var ip)) { + Logger.LogInformation("设备:{deviceNo} Ip:{ip}", request.DeviceUniqueNo, ip); var device = await DbContext.Queryable().Where(x => x.UniqueNo == request.DeviceUniqueNo).SingleAsync(); device.ConnectionInfo = new { @@ -137,7 +138,7 @@ public class OrderService : BaseOrderService, IOrderService { //尝试匹配userId var s = long.TryParse(request.UserUniqueNo, out var userId); - GainfoEntity gainfo = null; + GainfoEntity gainfo; if (request.Source == BalanceRecordSourceEnumType.QrCode) { @@ -153,6 +154,10 @@ public class OrderService : BaseOrderService, IOrderService var code = eMealVoucherQrCode.OriginData.Split(':')[2]; gainfo = await DbContext.Queryable().Where(x => x.Code == code).SingleAsync(); } + else + { + throw new UserFriendlyException($"无法识别{request.UserUniqueNo}"); + } } else { diff --git a/Src/Dlhis.Entity/Basic/Entity/OutsourceEntity.cs b/Src/Dlhis.Entity/Basic/Entity/OutsourceEntity.cs index 6a32abc5..d06b2506 100644 --- a/Src/Dlhis.Entity/Basic/Entity/OutsourceEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/OutsourceEntity.cs @@ -10,25 +10,25 @@ namespace Dlhis.Entity.Basic.Entity; public class OutsourceEntity : SugarBaseEntity { /// - /// 外包人员工号 LS开头 + /// 外包人员工号 LS开头 /// [SugarColumn(IsNullable = false, ColumnDescription = "工号")] public string Code { get; set; } /// - /// 供应商 + /// 供应商 /// [SugarColumn(IsNullable = false, ColumnDescription = "供应商")] public string Supplier { get; set; } /// - /// 对接人员工号 + /// 对接人员工号 /// [SugarColumn(IsNullable = false, ColumnDescription = "对接人工号")] public string SapCode { get; set; } /// - /// 对接人员手机号 + /// 对接人员手机号 /// [SugarColumn(IsNullable = false, ColumnDescription = "对接人手机号")] public string SapPhone { get; set; } diff --git a/Src/Dlhis.Middle/Services/Implements/CanteenSettingService.cs b/Src/Dlhis.Middle/Services/Implements/CanteenSettingService.cs index 79239dda..2c2ffe74 100644 --- a/Src/Dlhis.Middle/Services/Implements/CanteenSettingService.cs +++ b/Src/Dlhis.Middle/Services/Implements/CanteenSettingService.cs @@ -1,8 +1,6 @@ -using Dlhis.Entity.Basic.Entity; -using Dlhis.Entity.Canteen.Enums; +using Dlhis.Entity.Canteen.Enums; using Dlhis.Middle.Entities; using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; -using Mapster; namespace Dlhis.Middle.Services.Implements; diff --git a/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs b/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs index 07fc0946..7e4e22b6 100644 --- a/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs +++ b/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs @@ -4,7 +4,7 @@ namespace Dlhis.Middle.Services.Implements; public class HealthCheckService : IHealthCheckService { - private bool _isOffline = false; + private bool _isOffline; private readonly string _hostName; private readonly ILogger _logger; private int _successRetry; @@ -23,11 +23,13 @@ public class HealthCheckService : IHealthCheckService public async Task DoHealthCheckAsync() { + var cancellationTokenSource = new CancellationTokenSource(1000); var tcpClient = new TcpClient(); + try { _logger.LogDebug("tcp connecting {host} {port}", _hostName, 443); - await tcpClient.ConnectAsync(_hostName, 443); + await tcpClient.ConnectAsync(_hostName, 443, cancellationTokenSource.Token); _retry++; _logger.LogDebug("retry {retry}", _retry); if (tcpClient.Connected) @@ -44,7 +46,7 @@ public class HealthCheckService : IHealthCheckService else { _logger.LogDebug("wait next check in {waitTime}", _successRetry * 1000); - await Task.Delay(_successRetry * 1000); + await Task.Delay(_successRetry * 1000, cancellationTokenSource.Token); } } else @@ -52,14 +54,14 @@ public class HealthCheckService : IHealthCheckService _successRetry = 0; _isOffline = true; _logger.LogDebug("current is {status}", "unavailable"); - await Task.Delay(500); + await Task.Delay(500, cancellationTokenSource.Token); } } catch (Exception ex) { _logger.LogError("fail cause :{reason}", ex.Message); _isOffline = true; - await Task.Delay(5000); + await Task.Delay(5000, cancellationTokenSource.Token); } } } \ No newline at end of file From 3c921ef1c9f64fbc79ce333a75aab916d369287f Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 19 Sep 2024 11:26:04 +0800 Subject: [PATCH 05/18] fix . --- Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs index 9f8363b5..c9786d3e 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs @@ -58,7 +58,6 @@ public class OrderService : BaseOrderService, IOrderService { if (_httpContextAccessor.HttpContext!.Request.Headers.TryGetValue("X-Requested-DeviceIp", out var ip)) { - Logger.LogInformation("设备:{deviceNo} Ip:{ip}", request.DeviceUniqueNo, ip); var device = await DbContext.Queryable().Where(x => x.UniqueNo == request.DeviceUniqueNo).SingleAsync(); device.ConnectionInfo = new { @@ -67,6 +66,8 @@ public class OrderService : BaseOrderService, IOrderService await DbContext.UpdateAsync(device); } + + Logger.LogInformation("设备IP获取:{deviceNo} {ip}", request.DeviceUniqueNo, ip); } catch (Exception) { From 33e2db33982e549df8c7eb00744c62b9ac5502fd Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 19 Sep 2024 13:55:12 +0800 Subject: [PATCH 06/18] =?UTF-8?q?fix=20=E7=94=B5=E5=AD=90=E9=A4=90?= =?UTF-8?q?=E5=88=B8=E8=B6=85=E5=B8=82=E7=A6=81=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Order/Services/Implements/OrderService.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs index c9786d3e..93a78c8f 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs @@ -66,7 +66,7 @@ public class OrderService : BaseOrderService, IOrderService await DbContext.UpdateAsync(device); } - + Logger.LogInformation("设备IP获取:{deviceNo} {ip}", request.DeviceUniqueNo, ip); } catch (Exception) @@ -680,6 +680,11 @@ public class OrderService : BaseOrderService, IOrderService var eMealVoucher = await DbContext.Queryable().Where(x => x.No == no).SingleAsync(); var checkData = await PreCheckAsync(request.DeviceUniqueNo, request.CostDateTime); + var isSupermarket = await DbContext.Queryable().Where(x => x.Code == checkData.BusinessPlaceCode) + .Select(x => x.Catalog == CanteenBusinessPlaceCatalogEnumType.Supermarket) + .SingleAsync(); + isSupermarket.ThrowIfTrue("禁止在超市消费"); + eMealVoucher.Factories.Contains(checkData.BusinessPlaceTenantId).ThrowIfFalse("禁止在当前厂区消费"); var order = new CanteenOrderEntity From 17e494f5c8f1fb5bc1d5cfabbe46ba442124d0a4 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 20 Sep 2024 19:45:24 +0800 Subject: [PATCH 07/18] =?UTF-8?q?fix=20=E7=A7=BB=E9=99=A4=E7=94=B5?= =?UTF-8?q?=E5=AD=90=E9=A4=90=E5=88=B8=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=97=B6?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs index 93a78c8f..6f38ad02 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs @@ -674,8 +674,9 @@ public class OrderService : BaseOrderService, IOrderService .Where(x => x.No == no && x.IdNo == idNo).SingleAsync(); (nowDate >= current.Start && nowDate <= current.End).ThrowIfFalse("餐券已过期"); - var time = DateTimeOffset.FromUnixTimeMilliseconds(Convert.ToInt64(ts.Reverse().Join(string.Empty))).ToLocalTime().DateTime; - (time.AddMinutes(60) >= DateTime.Now).ThrowIfFalse("餐券二维码已过期"); + //todo 临时注释 + // var time = DateTimeOffset.FromUnixTimeMilliseconds(Convert.ToInt64(ts.Reverse().Join(string.Empty))).ToLocalTime().DateTime; + // (time.AddMinutes(60) >= DateTime.Now).ThrowIfFalse("餐券二维码已过期"); var eMealVoucher = await DbContext.Queryable().Where(x => x.No == no).SingleAsync(); From 9775052ab21cf73451e2554365e6d48ec876d3a0 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Tue, 24 Sep 2024 22:53:25 +0800 Subject: [PATCH 08/18] =?UTF-8?q?fix=20=E6=B6=88=E8=B4=B9=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E6=94=AF=E6=8C=81=E5=A4=9A=E9=80=89=E8=90=A5=E4=B8=9A?= =?UTF-8?q?=E7=82=B9/=E9=A4=90=E8=A1=A5=E9=83=A8=E9=97=A8=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Response/MealSupplementRecordResponse.cs | 6 ++++ .../Implements/MealSupplementRecordService.cs | 30 +++++++++++-------- .../Request/BalanceRecordAnalysisRequest.cs | 4 --- .../Implements/BalanceSummaryService.cs | 5 ---- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Src/Dlhis.Canteen/MealSupplementRecord/Response/MealSupplementRecordResponse.cs b/Src/Dlhis.Canteen/MealSupplementRecord/Response/MealSupplementRecordResponse.cs index 86e0d236..6ebce013 100644 --- a/Src/Dlhis.Canteen/MealSupplementRecord/Response/MealSupplementRecordResponse.cs +++ b/Src/Dlhis.Canteen/MealSupplementRecord/Response/MealSupplementRecordResponse.cs @@ -78,6 +78,12 @@ public class MealSupplementRecordResponse /// public DateTime CreateTime { get; set; } + + /// + /// 部门号 + /// + public string DepartmentNo { get; set; } + /// /// 部门名称 /// diff --git a/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs b/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs index 254b6c06..21c4835c 100644 --- a/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs +++ b/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs @@ -4,6 +4,7 @@ using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Canteen.Entities; using Dlhis.Entity.Canteen.Enums; using Dlhis.Sys.Api; +using Dlhis.Sys.Api.Response; using Kurisu.AspNetCore.Authentication.Abstractions; using Kurisu.AspNetCore.CustomClass; using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; @@ -31,18 +32,18 @@ public class MealSupplementRecordService : IMealSupplementRecordService { var queryable = _dbContext.Queryable() .LeftJoin((x, ga) => x.Code == ga.Code) - .LeftJoin((x, ga, department) => ga.DepartmentNo == department.No) + .LeftJoin((x, ga, gaLeave) => gaLeave.Code == x.Code) .WhereIF(request.Status.HasValue, x => x.Status == request.Status) .WhereIF(request.Sync.HasValue, x => x.Sync == request.Sync) .WhereIF(request.Workplace.IsPresent(), x => x.Workplace == request.Workplace) .WhereIF(request.Factory.IsPresent(), x => x.Factory == request.Factory) - .WhereIF(request.DepartmentNo.IsPresent(), (x, ga) => ga.DepartmentNo == request.DepartmentNo) + .WhereIF(request.DepartmentNo.IsPresent(), (x, ga, gaLeave) => ga.DepartmentNo == request.DepartmentNo || gaLeave.DepartmentNo == request.DepartmentNo) .WhereIF(request.Werks.IsPresent(), (x, ga) => ga.Werks == request.Werks) .WhereIF(request.DateTimePeriod.HasValue(), x => x.Date >= request.DateTimePeriod.Start && x.Date <= request.DateTimePeriod.End) .WhereIF(request.Search.IsPresent(), (x, ga) => x.Code == request.Search || ga.Name == request.Search); var page = await queryable - .Select((x, ga, department) => new MealSupplementRecordResponse + .Select((x, ga, gaLeave) => new MealSupplementRecordResponse { Amount = x.Amount, Code = x.Code, @@ -52,32 +53,37 @@ public class MealSupplementRecordService : IMealSupplementRecordService Status = x.Status, Sync = x.Sync, UniqueId = x.UniqueId, - UserName = ga.Name, + UserName = SqlFunc.IIF(SqlFunc.IsNullOrEmpty(ga.Name), gaLeave.Name, ga.Name), Workplace = x.Workplace, + DepartmentNo = SqlFunc.IIF(SqlFunc.IsNullOrEmpty(ga.DepartmentNo), gaLeave.DepartmentNo, ga.DepartmentNo), Factory = x.Factory, CreateTime = x.CreateTime, - DepartmentName = department.Name, Werks = ga.Werks }) .ToPageListAsync(request); + var departmentNos = page.Data.Select(x => x.DepartmentNo).Distinct().ToList(); + var departmentInfos = await _dbContext.Queryable().Where(x => departmentNos.Contains(x.No)).Select(x => new { x.No, x.Name }).ToListAsync(); + + var tenants = new List(); try { var tenantsResult = await _tenantApi.GetTenantsInternalAsync(); - var tenants = tenantsResult.Data; - - page.Data.ForEach(item => - { - item.Workplace = tenants.FirstOrDefault(x => x.Code == item.Workplace)?.Name; - item.Factory = tenants.FirstOrDefault(x => x.Code == item.Factory)?.Name; - }); + tenants = tenantsResult.Data; } catch (Exception) { //ignore } + page.Data.ForEach(item => + { + item.Workplace = tenants.FirstOrDefault(x => x.Code == item.Workplace)?.Name; + item.Factory = tenants.FirstOrDefault(x => x.Code == item.Factory)?.Name; + item.DepartmentName = departmentInfos.FirstOrDefault(x => x.No == item.DepartmentNo)?.Name; + }); + return new MealSupplementRecordSummaryResponse { diff --git a/Src/Dlhis.Canteen/Order/Request/BalanceRecordAnalysisRequest.cs b/Src/Dlhis.Canteen/Order/Request/BalanceRecordAnalysisRequest.cs index 8b02b7a6..cd5dd4b5 100644 --- a/Src/Dlhis.Canteen/Order/Request/BalanceRecordAnalysisRequest.cs +++ b/Src/Dlhis.Canteen/Order/Request/BalanceRecordAnalysisRequest.cs @@ -4,8 +4,4 @@ namespace Dlhis.Canteen.Order.Request; public class BalanceRecordAnalysisRequest : SummaryCommonDto { - /// - /// 营业点 - /// - public Guid? BusinessPlaceCode { get; set; } } \ No newline at end of file diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs index f22fb99a..cc85035e 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs @@ -26,11 +26,6 @@ public class BalanceSummaryService : IBalanceSummaryService public async Task BalanceRecordAnalysisAsync(BalanceRecordAnalysisRequest request) { - if (request.BusinessPlaceCode.HasValue) - { - request.BusinessPlaceCodes = new List { request.BusinessPlaceCode.Value }; - } - var queryable = GetQueryable(request); var list = await queryable.ToListAsync(); From 57c1fd5a76d7771a6db3b9a8d1e30136957d0ff7 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Tue, 24 Sep 2024 22:54:12 +0800 Subject: [PATCH 09/18] =?UTF-8?q?fix=20=E5=87=BA=E5=B7=AE=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E5=8F=AA=E5=85=81=E8=AE=B8=E5=AF=B9=E6=8E=A5=E4=BA=BA?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Implements/GainfoService.cs | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index b6a0719c..6c82dc5f 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -1,5 +1,4 @@ using Dlhis.Basic.Device.Services; -using Dlhis.Basic.Organization.Api; using Dlhis.Basic.Organization.Request; using Dlhis.Basic.Organization.Response; using Dlhis.Entity.Basic.Entity; @@ -28,7 +27,6 @@ public class GainfoService : IGainfoService private readonly ICurrentUser _currentUser; private readonly ITenantApi _tenantApi; private readonly IHangfireApi _hangfireApi; - private readonly IHainingApi _hainingApi; private readonly IDevicePermissionService _devicePermissionService; private readonly IGainfoPermissionService _gainfoPermissionService; private readonly ILogger _logger; @@ -39,7 +37,6 @@ public class GainfoService : IGainfoService ICurrentUser currentUser, ITenantApi tenantApi, IHangfireApi hangfireApi, - IHainingApi hainingApi, IDevicePermissionService devicePermissionService, IGainfoPermissionService gainfoPermissionService, ILogger logger) @@ -50,7 +47,6 @@ public class GainfoService : IGainfoService _currentUser = currentUser; _tenantApi = tenantApi; _hangfireApi = hangfireApi; - _hainingApi = hainingApi; _devicePermissionService = devicePermissionService; _gainfoPermissionService = gainfoPermissionService; _logger = logger; @@ -68,6 +64,11 @@ public class GainfoService : IGainfoService //根据组织架构搜索档案 var where = LinqExpressionExtensions.False(); var factories = _currentUser.GetUserClaim("tenants").Split(",").ToList(); + + var role = _currentUser.GetRole(); + var jinkoCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty; + var isAll = role is "admin" or "tenant-admin"; + if (request.DepartmentSelections.Any()) { foreach (var item in request.DepartmentSelections) @@ -91,11 +92,15 @@ public class GainfoService : IGainfoService where = Expressionable.Create() .And(where) .Or(gainfo => SqlFunc.Subqueryable() - .Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today)) - .Any()) + .Where(p => p.Code == gainfo.Code + && factories.Contains(p.Destination) + && SqlFunc.DateIsSame(p.BeginDate, today)) + .Any() + ) .ToExpression(); } + ISugarQueryable queryable = request.IsSearchAll ? _dbContext.Queryable().AS("GainfoEntity", "gainfo") .Where(where) @@ -117,7 +122,12 @@ public class GainfoService : IGainfoService .LeftJoin((gainfo, department, type) => type.Code == SqlFunc.ToString(gainfo.CardType) && type.Type == "timeperiod") .WhereIF(request.SearchType != GainfoSearchEnumType.BusinessTrip && request.DepartmentSelections?.Any() == false, gainfo => factories.Contains(gainfo.Factory)) .WhereIF(request.SearchType == GainfoSearchEnumType.Internal, gainfo => SqlFunc.Subqueryable().Where(p => p.Code == gainfo.Code).NotAny()) - .WhereIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => SqlFunc.Subqueryable().Where(p => p.Code == gainfo.Code).Any()) //&& today >= gainfo.EntryDate && today <= gainfo.ResignationDate + .WhereIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => + SqlFunc.Subqueryable() + .Where(p => p.Code == gainfo.Code) + .WhereIF(!isAll, p => p.SapCode == jinkoCode) + .Any() + ) .WhereIF(request.SearchType == GainfoSearchEnumType.BusinessTrip, gainfo => SqlFunc.Subqueryable().Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today)).Any()) .WhereIF(request.Search.IsPresent(), gainfo => @@ -132,14 +142,16 @@ public class GainfoService : IGainfoService CardTypeName = type.Display }, true); - _logger.LogInformation(queryable.ToSqlString()); var page = await queryable.ToPageListAsync(request); //外包人员部门号处理 if (request.SearchType == GainfoSearchEnumType.Outsource) { var codes = page.Data.Select(x => x.Code).ToList(); - var outsourceInfos = await _dbContext.Queryable().Where(x => codes.Contains(x.Code)).Select(x => new { x.Code, x.Supplier }).ToListAsync(); + var outsourceInfos = await _dbContext.Queryable() + .Where(x => codes.Contains(x.Code)) + .Select(x => new { x.Code, x.Supplier }) + .ToListAsync(); page.Data.ForEach(item => { item.DepartmentName = outsourceInfos.FirstOrDefault(x => x.Code == item.Code)?.Supplier; }); } From 1c2b19225ce1358f78f4ae4ca3cd2a523feb2797 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 25 Sep 2024 21:36:52 +0800 Subject: [PATCH 10/18] =?UTF-8?q?fix=20werk=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/MealSupplementRecordService.cs | 2 +- .../Response/AppointmentPageResponse.cs | 22 --- .../Services/Implements/AppointmentService.cs | 129 ------------------ 3 files changed, 1 insertion(+), 152 deletions(-) delete mode 100644 Src/Dlhis.Visitor/Appointment/Response/AppointmentPageResponse.cs delete mode 100644 Src/Dlhis.Visitor/Appointment/Services/Implements/AppointmentService.cs diff --git a/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs b/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs index 21c4835c..c334c0cc 100644 --- a/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs +++ b/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs @@ -58,7 +58,7 @@ public class MealSupplementRecordService : IMealSupplementRecordService DepartmentNo = SqlFunc.IIF(SqlFunc.IsNullOrEmpty(ga.DepartmentNo), gaLeave.DepartmentNo, ga.DepartmentNo), Factory = x.Factory, CreateTime = x.CreateTime, - Werks = ga.Werks + Werks = SqlFunc.IIF(SqlFunc.IsNullOrEmpty(ga.Werks), gaLeave.Werks, ga.Werks) }) .ToPageListAsync(request); diff --git a/Src/Dlhis.Visitor/Appointment/Response/AppointmentPageResponse.cs b/Src/Dlhis.Visitor/Appointment/Response/AppointmentPageResponse.cs deleted file mode 100644 index 8a0de429..00000000 --- a/Src/Dlhis.Visitor/Appointment/Response/AppointmentPageResponse.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Dlhis.Visitor.Appointment.Response; - -public class AppointmentPageResponse -{ - public string FlowId { get; set; } - - public string Title { get; set; } - - public string Code { get; set; } - - public string Name { get; set; } - - public string Description { get; set; } - - public string DepartmentNo { get; set; } - - public string DepartmentName { get; set; } - - public string Company { get; set; } - - public DateTime ApplyTime { get; set; } -} diff --git a/Src/Dlhis.Visitor/Appointment/Services/Implements/AppointmentService.cs b/Src/Dlhis.Visitor/Appointment/Services/Implements/AppointmentService.cs deleted file mode 100644 index 2522ebb1..00000000 --- a/Src/Dlhis.Visitor/Appointment/Services/Implements/AppointmentService.cs +++ /dev/null @@ -1,129 +0,0 @@ -// using Dlhis.Entity.Basic.Entity; -// using Dlhis.Entity.Device.Entities; -// using Dlhis.Entity.Device.Enums; -// using Dlhis.Entity.Visitor.Entity; -// using Dlhis.Entity.Visitor.Enums; -// using Dlhis.Visitor.Appointment.Request; -// using Dlhis.Visitor.Appointment.Response; -// using Kurisu.AspNetCore.CustomClass; -// using Kurisu.AspNetCore.DataAccess.Dto; -// using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; -// using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; -// using Kurisu.AspNetCore.Utils.Extensions; -// using Microsoft.AspNetCore.DataProtection; -// using Microsoft.AspNetCore.Mvc; -// using SqlSugar; -// -// namespace Dlhis.Visitor.Appointment.Services.Implements; -// -// public class AppointmentService : IAppointmentService -// { -// private readonly IDbContext _dbContext; -// private readonly IDataProtectionProvider _dataProtectionProvider; -// -// public AppointmentService(IDbContext dbContext, IDataProtectionProvider dataProtectionProvider) -// { -// _dbContext = dbContext; -// _dataProtectionProvider = dataProtectionProvider; -// } -// -// public async Task> GetPageAsync(AppointmentPageRequest request) -// { -// return await _dbContext.Queryable() -// .WhereIF(request.SearchDateTimePeriod?.Start.HasValue == true && request.SearchDateTimePeriod?.End.HasValue == true, -// x => x.ApplyTime >= request.SearchDateTimePeriod.Start && x.ApplyTime <= request.SearchDateTimePeriod.End) -// .WhereIF(request.Search.IsPresent(), x => x.Code == request.Search || x.Name == request.Search) -// .Select() -// .ToPageListAsync(request); -// } -// -// public async Task> GetAppointmentDetailsByIdAsync(long id) -// { -// return await _dbContext.Queryable() -// .Where(x => x.AppointmentId == id) -// .Select() -// .ToListAsync(); -// } -// -// public async Task ConfirmAsync(AppointmentConfirmRequest request) -// { -// var detail = await _dbContext.Queryable().Where(x => x.Id == request.Id).SingleAsync(); -// detail.ThrowIfNull("预约信息不存在"); -// -// var mst = await _dbContext.Queryable().Where(x => x.Id == detail.AppointmentId).SingleAsync(); -// -// //当前分配的设备codes -// var deviceCodes = await _dbContext.Queryable() -// .Where(x => x.CustomCode == mst.AreaCustomCode) -// .Select(x => x.DeviceCode) -// .ToListAsync(); -// -// var deviceUniqueNos = await _dbContext.Queryable().Where(x => deviceCodes.Contains(x.Code)).Select(x => x.UniqueNo).ToListAsync(); -// -// var userNo = detail.IsExternal -// ? await _dbContext.Queryable().Where(x => x.IdNo == detail.IdNo).Select(x => x.No).FirstAsync() -// : await _dbContext.Queryable().Where(x => x.IdNo == detail.IdNo).Select(x => x.No).FirstAsync(); -// -// await _dbContext.InsertAsync(deviceUniqueNos.Select(x => new DeviceTaskEntity -// { -// CancellationId = 0, -// DeviceType = DeviceTypeEnumType.Door, -// DeviceUniqueNo = x, -// Status = DeviceTaskStatusEnumType.Wait, -// UserNo = userNo, -// Type = DeviceTaskEnumType.Add, -// Priority = 100, -// Source = DeviceTaskSourceEnumType.Appointment, -// Version = 0 -// }).ToList()); -// -// detail.Status = AppointmentDetailEnumType.Arrived; -// await _dbContext.UpdateAsync(detail); -// } -// -// -// //********************************************************** 用户操作 ******************************************************************* -// -// public async Task GetTodayByIdNoAsync(string idNo) -// { -// var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno"); -// try -// { -// idNo = protector.Unprotect(idNo); -// } -// catch (Exception) -// { -// throw new UserFriendlyException("凭证有误"); -// } -// -// var detail = await _dbContext.Queryable() -// .Where(x => x.IdNo == idNo) -// .Where(x => SqlFunc.DateIsSame(x.Start, DateTime.Today, DateType.Day)) -// .OrderBy(x => x.Start) -// .Select() -// .FirstAsync(); -// -// return detail; -// } -// -// public async Task> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request) -// { -// var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno"); -// try -// { -// request.IdNo = protector.Unprotect(request.IdNo); -// } -// catch (Exception) -// { -// throw new UserFriendlyException("凭证有误"); -// } -// -// var page = await _dbContext.Queryable() -// .Where(x => x.IdNo == request.IdNo) -// .OrderBy(x => x.Start) -// .Select() -// .ToPageListAsync(request); -// -// return page; -// } -// } \ No newline at end of file From 5ca68188b705251761d043113f692b1aa9d1d438 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 27 Sep 2024 14:57:35 +0800 Subject: [PATCH 11/18] =?UTF-8?q?fix=20=E7=A7=BB=E9=99=A4tokensource?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs b/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs index 7e4e22b6..20071903 100644 --- a/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs +++ b/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs @@ -54,14 +54,15 @@ public class HealthCheckService : IHealthCheckService _successRetry = 0; _isOffline = true; _logger.LogDebug("current is {status}", "unavailable"); - await Task.Delay(500, cancellationTokenSource.Token); + await Task.Delay(500); } } catch (Exception ex) { _logger.LogError("fail cause :{reason}", ex.Message); _isOffline = true; - await Task.Delay(5000, cancellationTokenSource.Token); + + await Task.Delay(5000); } } } \ No newline at end of file From 540ac8a759d891b04b35ad5fa012c3be49feca53 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 27 Sep 2024 15:09:40 +0800 Subject: [PATCH 12/18] =?UTF-8?q?fix=20=E8=B0=83=E6=95=B4=E5=88=B03?= =?UTF-8?q?=E7=A7=92=E6=97=B6=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs b/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs index 20071903..4a5bc00c 100644 --- a/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs +++ b/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs @@ -23,7 +23,7 @@ public class HealthCheckService : IHealthCheckService public async Task DoHealthCheckAsync() { - var cancellationTokenSource = new CancellationTokenSource(1000); + var cancellationTokenSource = new CancellationTokenSource(3000); var tcpClient = new TcpClient(); try @@ -61,8 +61,6 @@ public class HealthCheckService : IHealthCheckService { _logger.LogError("fail cause :{reason}", ex.Message); _isOffline = true; - - await Task.Delay(5000); } } } \ No newline at end of file From 03a5c80e792f339fa58eb49ff3c8786d1db09d83 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 27 Sep 2024 15:14:00 +0800 Subject: [PATCH 13/18] =?UTF-8?q?fix=20=E8=B0=83=E6=95=B4=E5=88=B05?= =?UTF-8?q?=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs b/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs index 4a5bc00c..2c01192a 100644 --- a/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs +++ b/Src/Dlhis.Middle/Services/Implements/HealthcheckService.cs @@ -23,7 +23,7 @@ public class HealthCheckService : IHealthCheckService public async Task DoHealthCheckAsync() { - var cancellationTokenSource = new CancellationTokenSource(3000); + var cancellationTokenSource = new CancellationTokenSource(5000); var tcpClient = new TcpClient(); try From 4497027feed1588cf96819625e36b59d4d816c24 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Sun, 29 Sep 2024 17:02:54 +0800 Subject: [PATCH 14/18] =?UTF-8?q?fix=20=E6=81=A2=E5=A4=8D=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Order/Request/BalanceRecordAnalysisRequest.cs | 1 + .../Order/Services/Implements/BalanceSummaryService.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Src/Dlhis.Canteen/Order/Request/BalanceRecordAnalysisRequest.cs b/Src/Dlhis.Canteen/Order/Request/BalanceRecordAnalysisRequest.cs index cd5dd4b5..6c28285a 100644 --- a/Src/Dlhis.Canteen/Order/Request/BalanceRecordAnalysisRequest.cs +++ b/Src/Dlhis.Canteen/Order/Request/BalanceRecordAnalysisRequest.cs @@ -4,4 +4,5 @@ namespace Dlhis.Canteen.Order.Request; public class BalanceRecordAnalysisRequest : SummaryCommonDto { + public Guid? BusinessPlaceCode { get; set; } } \ No newline at end of file diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs index cc85035e..f22fb99a 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs @@ -26,6 +26,11 @@ public class BalanceSummaryService : IBalanceSummaryService public async Task BalanceRecordAnalysisAsync(BalanceRecordAnalysisRequest request) { + if (request.BusinessPlaceCode.HasValue) + { + request.BusinessPlaceCodes = new List { request.BusinessPlaceCode.Value }; + } + var queryable = GetQueryable(request); var list = await queryable.ToListAsync(); From 981bcc38e2ce7f6d3f574bd8e174d3523f0998a8 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 9 Oct 2024 11:10:37 +0800 Subject: [PATCH 15/18] =?UTF-8?q?fix=20=E7=94=B5=E5=AD=90=E9=A4=90?= =?UTF-8?q?=E5=88=B8=E4=BD=99=E9=A2=9D=E6=9F=A5=E8=AF=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs index 6f38ad02..2fc753f1 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs @@ -553,7 +553,7 @@ public class OrderService : BaseOrderService, IOrderService //获取餐券余额 var data = await DbContext.Queryable() .LeftJoin((x, d) => x.No == d.No) - .Where((x, d) => d.IdNo == idNo) + .Where((x, d) => x.No == no && d.IdNo == idNo) .Select((x, d) => new OrderResultResponse { CurrentBalance = d.Balance From 4af590209f9a53cf3d49fbfdd068dcca8366da68 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 10 Oct 2024 12:27:37 +0800 Subject: [PATCH 16/18] =?UTF-8?q?add=20=E8=AE=BF=E5=AE=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/AppointmentAreaAssignmentEntity.cs | 3 +- .../Visitor/Entity/AppointmentAreaEntity.cs | 7 +-- .../Entity/VisitorAppointmentEntity.cs | 8 +-- .../Visitor/Enums/ApponintmentAreaEnumType.cs | 19 ------- .../Enums/VisitorAppointmentStatusEnumType.cs | 22 -------- .../Response/AppointmentDetailResponse.cs | 56 ------------------- .../Services/IAppointmentAreaService.cs | 13 ----- 7 files changed, 7 insertions(+), 121 deletions(-) delete mode 100644 Src/Dlhis.Entity/Visitor/Enums/ApponintmentAreaEnumType.cs delete mode 100644 Src/Dlhis.Entity/Visitor/Enums/VisitorAppointmentStatusEnumType.cs delete mode 100644 Src/Dlhis.Visitor/Appointment/Response/AppointmentDetailResponse.cs delete mode 100644 Src/Dlhis.Visitor/Appointment/Services/IAppointmentAreaService.cs diff --git a/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaAssignmentEntity.cs b/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaAssignmentEntity.cs index 02c0eead..82dc7a05 100644 --- a/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaAssignmentEntity.cs +++ b/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaAssignmentEntity.cs @@ -22,6 +22,7 @@ public class AppointmentAreaAssignmentEntity : SugarBaseEntity, ITenantId [SugarColumn(IsNullable = false, ColumnDescription = "设备code")] public Guid DeviceCode { get; set; } + [SugarColumn] public string TenantId { get; set; } -} +} \ No newline at end of file diff --git a/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaEntity.cs b/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaEntity.cs index c0f3d960..adb576aa 100644 --- a/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaEntity.cs +++ b/Src/Dlhis.Entity/Visitor/Entity/AppointmentAreaEntity.cs @@ -11,7 +11,7 @@ namespace Dlhis.Entity.Visitor.Entity; /// 预约区域 /// [SugarTable(TableName = "AppointmentArea", TableDescription = "预约区域")] -public class AppointmentAreaEntity : SugarBaseEntity, ITenantId, ISoftDeleted +public class AppointmentAreaEntity : SugarBaseEntity, ITenantId { /// /// 区域类型 @@ -48,7 +48,4 @@ public class AppointmentAreaEntity : SugarBaseEntity, ITenantId, ISoftDeleted [SugarColumn(IsNullable = false, ColumnDescription = " 基地/租户", UniqueGroupNameList = new[] { "idx_AppointmentArea_t_cc_tid" })] public string TenantId { get; set; } - - - public bool IsDeleted { get; set; } -} +} \ No newline at end of file diff --git a/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentEntity.cs b/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentEntity.cs index 9cc68b92..0718b525 100644 --- a/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentEntity.cs +++ b/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentEntity.cs @@ -1,7 +1,5 @@ -using Dlhis.Entity.Visitor.Enums; -using Kurisu.AspNetCore.DataAccess.SqlSugar; +using Kurisu.AspNetCore.DataAccess.SqlSugar; using SqlSugar; -using SqlSugar.DbConvert; namespace Dlhis.Entity.Visitor.Entity; @@ -36,7 +34,7 @@ public class VisitorAppointmentEntity : SugarBaseEntity /// 申请时间 /// public DateTime Date { get; set; } - + /// /// 备注 /// @@ -51,4 +49,4 @@ public class VisitorAppointmentEntity : SugarBaseEntity /// 申请事由 /// public string Reason { get; set; } -} \ No newline at end of file +} diff --git a/Src/Dlhis.Entity/Visitor/Enums/ApponintmentAreaEnumType.cs b/Src/Dlhis.Entity/Visitor/Enums/ApponintmentAreaEnumType.cs deleted file mode 100644 index f7972f2e..00000000 --- a/Src/Dlhis.Entity/Visitor/Enums/ApponintmentAreaEnumType.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.ComponentModel; - -namespace Dlhis.Entity.Visitor.Enums; - -[Description("预约区域")] -public enum ApponintmentAreaEnumType -{ - /// - /// 门岗 - /// - [Description("门岗")] - Door = 1, - - /// - /// 车间 - /// - [Description("车间")] - Workshop = 2, -} diff --git a/Src/Dlhis.Entity/Visitor/Enums/VisitorAppointmentStatusEnumType.cs b/Src/Dlhis.Entity/Visitor/Enums/VisitorAppointmentStatusEnumType.cs deleted file mode 100644 index e8659094..00000000 --- a/Src/Dlhis.Entity/Visitor/Enums/VisitorAppointmentStatusEnumType.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.ComponentModel; - -namespace Dlhis.Entity.Visitor.Enums; - -/// -/// 访客预约明细状态 -/// -[Description("访客预约状态")] -public enum VisitorAppointmentStatusEnumType -{ - /// - /// 到达 - /// - [Description("到达")] - Valid = 1, - - /// - /// 作废 - /// - [Description("作废")] - Obsolete = 99 -} diff --git a/Src/Dlhis.Visitor/Appointment/Response/AppointmentDetailResponse.cs b/Src/Dlhis.Visitor/Appointment/Response/AppointmentDetailResponse.cs deleted file mode 100644 index 322e396b..00000000 --- a/Src/Dlhis.Visitor/Appointment/Response/AppointmentDetailResponse.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Dlhis.Entity.Visitor.Enums; -using Kurisu.AspNetCore.Utils.Extensions; - -namespace Dlhis.Visitor.Appointment.Response; - -public class AppointmentDetailResponse -{ - public long Id { get; set; } - - public long AppointmentId { get; set; } - - /// - /// 流水号 - /// - public string FlowId { get; set; } - - /// - /// 访客名称 - /// - public string Name { get; set; } - - /// - /// 手机号 - /// - public string Phone { get; set; } - - /// - /// 身份证 - /// - public string IdNo { get; set; } - - /// - /// 预计到达 - /// - public DateTime Start { get; set; } - - /// - /// 预计离开 - /// - public DateTime End { get; set; } - - /// - /// 状态 - /// - public AppointmentDetailEnumType Status { get; set; } - - /// - /// 状态 - /// - public string StatusDesc => Status.GetDescription(); - - /// - /// 备注 - /// - public string Remark { get; set; } -} diff --git a/Src/Dlhis.Visitor/Appointment/Services/IAppointmentAreaService.cs b/Src/Dlhis.Visitor/Appointment/Services/IAppointmentAreaService.cs deleted file mode 100644 index 0a384e36..00000000 --- a/Src/Dlhis.Visitor/Appointment/Services/IAppointmentAreaService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Dlhis.Visitor.Appointment.Request; -using Dlhis.Visitor.Appointment.Response; -using Kurisu.AspNetCore.DataAccess.Dto; - -namespace Dlhis.Visitor.Appointment.Services; - -public interface IAppointmentAreaService : IScopeDependency -{ - Task> GetPageAsync(PageDto request); - Task SaveAsync(AppointmentAreaSaveRequest request); - Task DeleteAsync(long id); - Task AssignAsync(AppointmentAreaAssignRequest request); -} \ No newline at end of file From cce6785863b3e86f048692e64a71cd5d33ffb590 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 10 Oct 2024 12:28:20 +0800 Subject: [PATCH 17/18] =?UTF-8?q?fix=20=E5=B7=B2=E7=9F=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/DeviceConnectService.cs | 36 ++++++++++--------- .../Request/GainfoMealPageRequest.cs | 2 +- .../Services/Implements/GainfoGroupService.cs | 8 +++-- .../Implements/GainfoOutsourceService.cs | 16 +++++---- .../Services/Implements/GainfoService.cs | 3 +- 5 files changed, 36 insertions(+), 29 deletions(-) diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs index 72d4a785..7cf1612e 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs @@ -30,12 +30,6 @@ public class DeviceConnectService : IDeviceConnectService businessPlace.ThrowIfNull("营业点不存在"); var device = await GetEnableDeviceAsync(request.UniqueNo, false, request.DeployPlace, businessPlace.TenantId); - if (device.DeployPlace.Equals("AUTO", StringComparison.OrdinalIgnoreCase)) - { - device.DeployPlace = businessPlace.Name; - await _dbContext.UpdateAsync(device); - } - var registry = await _dbContext.Queryable().Where(x => x.DeviceUniqueNo == request.UniqueNo).SingleAsync(); if (registry != null) @@ -45,20 +39,28 @@ public class DeviceConnectService : IDeviceConnectService registry.BusinessPlaceCode = businessPlace.Code; await _dbContext.UpdateAsync(registry); - - return "请勿重复注册设备"; + } + else + { + registry = new DeviceRegistryEntity + { + DeviceUniqueNo = request.UniqueNo, + LastHeartbeatTime = DateTime.Now, + RegisterTime = DateTime.Now, + BusinessPlaceCode = businessPlace.Code, + TenantId = device.TenantId + }; + + await _dbContext.InsertAsync(registry); } - registry = new DeviceRegistryEntity - { - DeviceUniqueNo = request.UniqueNo, - LastHeartbeatTime = DateTime.Now, - RegisterTime = DateTime.Now, - BusinessPlaceCode = businessPlace.Code, - TenantId = device.TenantId - }; + if (request.DeployPlace.Equals("AUTO", StringComparison.OrdinalIgnoreCase)) + device.DeployPlace = businessPlace.Name; + else + device.DeployPlace = request.DeployPlace.IsPresent() ? request.DeployPlace : businessPlace.Name; + + await _dbContext.UpdateAsync(device); - await _dbContext.InsertAsync(registry); return "设备注册成功"; } diff --git a/Src/Dlhis.Basic/Organization/Request/GainfoMealPageRequest.cs b/Src/Dlhis.Basic/Organization/Request/GainfoMealPageRequest.cs index 7dab11fd..41ece6c7 100644 --- a/Src/Dlhis.Basic/Organization/Request/GainfoMealPageRequest.cs +++ b/Src/Dlhis.Basic/Organization/Request/GainfoMealPageRequest.cs @@ -11,7 +11,7 @@ public class GainfoMealPageRequest : PageDto public DateTimePeriod SearchDateTimePeriod { get; set; } /// - /// 是否离职 + /// 是否查询离职 /// public bool IsLeave { get; set; } } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs index 27fee37d..d4291220 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs @@ -89,12 +89,14 @@ public class GainfoGroupService : IGainfoGroupService .ToListAsync(); await _dbContext.DeleteAsync(relations); - request.UserNos = await _dbContext.Queryable() - .Where(x => request.UserNos.Contains(x.No) || request.UserNos.Contains(x.Code)) + var userNos = await _dbContext.Queryable() + .Where(x => request.UserNos.Contains(x.No) || request.UserNos.Contains(x.Code)) //NO和工号匹配 .Select(x => x.No) .ToListAsync(); - var entities = request.UserNos.Select(x => new GainfoGroupRelationshipEntity + (userNos.Count != request.UserNos.Count).ThrowIfTrue("存在权限外人员,无法添加"); + + var entities = userNos.Select(x => new GainfoGroupRelationshipEntity { GroupCode = request.GroupCode, UserNo = x diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs index 170ea3b9..db1866e6 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs @@ -43,13 +43,17 @@ public class GainfoOutsourceService : IGainfoOutsourceService : await GetOutSourceCodeAsync(); await _dbContext.InsertAsync(entity); - await _dbContext.InsertAsync(new OutsourceEntity + + if (!await _dbContext.Queryable().Where(x => x.Code == entity.Code).AnyAsync()) { - Code = entity.Code, - Supplier = request.ExternalInfo.Supplier, - SapCode = request.ExternalInfo.SapCode, - SapPhone = request.ExternalInfo.SapPhone - }); + await _dbContext.InsertAsync(new OutsourceEntity + { + Code = entity.Code, + Supplier = request.ExternalInfo.Supplier, + SapCode = request.ExternalInfo.SapCode, + SapPhone = request.ExternalInfo.SapPhone + }); + } } else { diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index 6c82dc5f..63317086 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -239,8 +239,7 @@ public class GainfoService : IGainfoService public async Task CheckIdNoAndNameMatchAsync(GainfoCheckIdNoAndNameRequest request) { - var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).FirstAsync(x => x.IdNo == request.IdNo && x.Name == request.Name); - + var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).SingleAsync(x => x.IdNo == request.IdNo && x.Name == request.Name); gainfo.ThrowIfNull("验证失败!"); var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno"); From 33dbc33836a43b5a226ded2bd7a781be64c955f8 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 10 Oct 2024 18:02:10 +0800 Subject: [PATCH 18/18] =?UTF-8?q?fix=20=E8=AE=BF=E5=AE=A2=E9=A2=84?= =?UTF-8?q?=E7=BA=A6=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AppointmentAreasController.cs | 42 ++-- .../Controllers/AppointmentsController.cs | 18 +- .../Dto/AppointmentReceiveItemDto.cs | 2 +- .../Request/AppointmentAreaAssignRequest.cs | 4 +- .../Request/AppointmentAreaPageRequest.cs | 14 ++ .../Request/AppointmentAreaSaveRequest.cs | 10 +- .../Request/AppointmentConfirmRequest.cs | 2 +- .../Request/AppointmentIdNoPageRequest.cs | 2 +- .../Request/AppointmentPageRequest.cs | 20 ++ .../Request/AppointmentReceiveRequest.cs | 4 +- .../Response/AppointmentAreaPageResponse.cs} | 12 +- .../Response/AppointmentDetailResponse.cs | 102 ++++++++++ .../Response/AppointmentPageResponse.cs | 41 ++++ .../Services/IAppointmentAreaService.cs | 29 +++ .../Services/IAppointmentService.cs | 10 +- .../Implements/AppointmentAreaService.cs | 180 ++++++++++++++++++ .../Services/Implements/AppointmentService.cs | 145 ++++++++++++++ .../Services/Implements/DeviceService.cs | 2 +- .../Entity/VisitorAppointmentDetailEntity.cs | 7 +- .../Request/AppointmentPageRequest.cs | 9 - 20 files changed, 585 insertions(+), 70 deletions(-) rename Src/{Dlhis.Visitor => Dlhis.Basic}/Appointment/Controllers/AppointmentAreasController.cs (58%) rename Src/{Dlhis.Visitor => Dlhis.Basic}/Appointment/Controllers/AppointmentsController.cs (84%) rename Src/{Dlhis.Visitor => Dlhis.Basic}/Appointment/Dto/AppointmentReceiveItemDto.cs (94%) rename Src/{Dlhis.Visitor => Dlhis.Basic}/Appointment/Request/AppointmentAreaAssignRequest.cs (87%) create mode 100644 Src/Dlhis.Basic/Appointment/Request/AppointmentAreaPageRequest.cs rename Src/{Dlhis.Visitor => Dlhis.Basic}/Appointment/Request/AppointmentAreaSaveRequest.cs (83%) rename Src/{Dlhis.Visitor => Dlhis.Basic}/Appointment/Request/AppointmentConfirmRequest.cs (74%) rename Src/{Dlhis.Visitor => Dlhis.Basic}/Appointment/Request/AppointmentIdNoPageRequest.cs (89%) create mode 100644 Src/Dlhis.Basic/Appointment/Request/AppointmentPageRequest.cs rename Src/{Dlhis.Visitor => Dlhis.Basic}/Appointment/Request/AppointmentReceiveRequest.cs (96%) rename Src/{Dlhis.Visitor/Appointment/Response/ApponintmentAreaPageResponse.cs => Dlhis.Basic/Appointment/Response/AppointmentAreaPageResponse.cs} (86%) create mode 100644 Src/Dlhis.Basic/Appointment/Response/AppointmentDetailResponse.cs create mode 100644 Src/Dlhis.Basic/Appointment/Response/AppointmentPageResponse.cs create mode 100644 Src/Dlhis.Basic/Appointment/Services/IAppointmentAreaService.cs rename Src/{Dlhis.Visitor => Dlhis.Basic}/Appointment/Services/IAppointmentService.cs (84%) create mode 100644 Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentAreaService.cs create mode 100644 Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs delete mode 100644 Src/Dlhis.Visitor/Appointment/Request/AppointmentPageRequest.cs diff --git a/Src/Dlhis.Visitor/Appointment/Controllers/AppointmentAreasController.cs b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentAreasController.cs similarity index 58% rename from Src/Dlhis.Visitor/Appointment/Controllers/AppointmentAreasController.cs rename to Src/Dlhis.Basic/Appointment/Controllers/AppointmentAreasController.cs index 984da794..a286e912 100644 --- a/Src/Dlhis.Visitor/Appointment/Controllers/AppointmentAreasController.cs +++ b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentAreasController.cs @@ -1,12 +1,12 @@ -using Dlhis.Visitor.Appointment.Request; -using Dlhis.Visitor.Appointment.Response; -using Dlhis.Visitor.Appointment.Services; +using Dlhis.Basic.Appointment.Request; +using Dlhis.Basic.Appointment.Response; +using Dlhis.Basic.Appointment.Services; using Kurisu.AspNetCore.DataAccess.Dto; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -namespace Dlhis.Visitor.Appointment.Controllers; +namespace Dlhis.Basic.Appointment.Controllers; /// /// 预约区域 @@ -16,24 +16,13 @@ namespace Dlhis.Visitor.Appointment.Controllers; [ApiController] public class AppointmentAreasController : ControllerBase { - private readonly IAppointmentAreaService _apponintmentAreaService; + private readonly IAppointmentAreaService _appointmentAreaService; - public AppointmentAreasController(IAppointmentAreaService apponintmentAreaService) + public AppointmentAreasController(IAppointmentAreaService appointmentAreaService ) { - _apponintmentAreaService = apponintmentAreaService; + _appointmentAreaService = appointmentAreaService; } - - /// - /// 预约区域 - /// - /// - /// - [HttpGet("page")] - public async Task> GetPageAsync([FromQuery] PageDto request) - { - return await _apponintmentAreaService.GetPageAsync(request); - } - + /// /// 保存 /// @@ -42,19 +31,18 @@ public class AppointmentAreasController : ControllerBase [HttpPost("save")] public async Task SaveAsync(AppointmentAreaSaveRequest request) { - await _apponintmentAreaService.SaveAsync(request); + await _appointmentAreaService.SaveAsync(request); } - /// - /// 删除 + /// 预约区域分页 /// - /// + /// /// - [HttpDelete("{id}")] - public async Task DeleteAsync(long id) + [HttpGet("page")] + public async Task> GetPageAsync([FromQuery] AppointmentAreaPageRequest request) { - await _apponintmentAreaService.DeleteAsync(id); + return await _appointmentAreaService.GetPageAsync(request); } /// @@ -65,6 +53,6 @@ public class AppointmentAreasController : ControllerBase [Transactional] public async Task AssignAsync(AppointmentAreaAssignRequest request) { - await _apponintmentAreaService.AssignAsync(request); + await _appointmentAreaService.AssignAsync(request); } } diff --git a/Src/Dlhis.Visitor/Appointment/Controllers/AppointmentsController.cs b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentsController.cs similarity index 84% rename from Src/Dlhis.Visitor/Appointment/Controllers/AppointmentsController.cs rename to Src/Dlhis.Basic/Appointment/Controllers/AppointmentsController.cs index b8d63ac1..11b988ef 100644 --- a/Src/Dlhis.Visitor/Appointment/Controllers/AppointmentsController.cs +++ b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentsController.cs @@ -1,13 +1,13 @@ using System.ComponentModel.DataAnnotations; -using Dlhis.Visitor.Appointment.Request; -using Dlhis.Visitor.Appointment.Response; -using Dlhis.Visitor.Appointment.Services; +using Dlhis.Basic.Appointment.Request; +using Dlhis.Basic.Appointment.Response; +using Dlhis.Basic.Appointment.Services; using Kurisu.AspNetCore.DataAccess.Dto; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -namespace Dlhis.Visitor.Appointment.Controllers; +namespace Dlhis.Basic.Appointment.Controllers; /// /// 预约 @@ -23,7 +23,7 @@ public class AppointmentsController : ControllerBase { _appointmentService = appointmentService; } - + /// /// 预约申请分页 /// @@ -41,6 +41,7 @@ public class AppointmentsController : ControllerBase /// /// [HttpPost("confirm")] + [Transactional] public async Task ConfirmAsync(AppointmentConfirmRequest request) { await _appointmentService.ConfirmAsync(request); @@ -54,9 +55,8 @@ public class AppointmentsController : ControllerBase [AllowAnonymous] [HttpGet("today")] public async Task GetTodayByIdNoAsync( - [FromQuery] - [StringLength(18, MinimumLength = 18, ErrorMessage = "身份证有误")] - [Required(ErrorMessage = "身份证有误")]string idNo) + [FromQuery] [StringLength(18, MinimumLength = 18, ErrorMessage = "身份证有误")] [Required(ErrorMessage = "身份证有误")] + string idNo) { return await _appointmentService.GetTodayByIdNoAsync(idNo); } @@ -72,4 +72,4 @@ public class AppointmentsController : ControllerBase { return await _appointmentService.GetRecordPageByIdNoAsync(request); } -} +} \ No newline at end of file diff --git a/Src/Dlhis.Visitor/Appointment/Dto/AppointmentReceiveItemDto.cs b/Src/Dlhis.Basic/Appointment/Dto/AppointmentReceiveItemDto.cs similarity index 94% rename from Src/Dlhis.Visitor/Appointment/Dto/AppointmentReceiveItemDto.cs rename to Src/Dlhis.Basic/Appointment/Dto/AppointmentReceiveItemDto.cs index 57cf552c..2071e4c0 100644 --- a/Src/Dlhis.Visitor/Appointment/Dto/AppointmentReceiveItemDto.cs +++ b/Src/Dlhis.Basic/Appointment/Dto/AppointmentReceiveItemDto.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace Dlhis.Visitor.Appointment.Dto; +namespace Dlhis.Basic.Appointment.Dto; public class AppointmentReceiveItemDto { diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaAssignRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaAssignRequest.cs similarity index 87% rename from Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaAssignRequest.cs rename to Src/Dlhis.Basic/Appointment/Request/AppointmentAreaAssignRequest.cs index 755a14a8..aec22aaf 100644 --- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaAssignRequest.cs +++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaAssignRequest.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace Dlhis.Visitor.Appointment.Request; +namespace Dlhis.Basic.Appointment.Request; public class AppointmentAreaAssignRequest { @@ -14,4 +14,4 @@ public class AppointmentAreaAssignRequest /// 分组 /// public List DeviceCodes { get; set; } -} +} \ No newline at end of file diff --git a/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaPageRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaPageRequest.cs new file mode 100644 index 00000000..20a43294 --- /dev/null +++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaPageRequest.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations; +using Dlhis.Entity.Visitor.Enums; +using Kurisu.AspNetCore.DataAccess.Dto; + +namespace Dlhis.Basic.Appointment.Request; + +public class AppointmentAreaPageRequest : PageDto +{ + /// + /// 区域类型 + /// + [EnumDataType(typeof(AppointmentAreaEnumType))] + public AppointmentAreaEnumType? Type { get; set; } +} \ No newline at end of file diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaSaveRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaSaveRequest.cs similarity index 83% rename from Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaSaveRequest.cs rename to Src/Dlhis.Basic/Appointment/Request/AppointmentAreaSaveRequest.cs index 7a0ba649..f7d5b03e 100644 --- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaSaveRequest.cs +++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaSaveRequest.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using Dlhis.Entity.Visitor.Enums; -namespace Dlhis.Visitor.Appointment.Request; +namespace Dlhis.Basic.Appointment.Request; public class AppointmentAreaSaveRequest { @@ -17,13 +17,13 @@ public class AppointmentAreaSaveRequest public AppointmentAreaEnumType Type { get; set; } /// - /// 预期编码 + /// 编码 /// - [Required] + [Required(ErrorMessage = "编码不能为空")] public string CustomCode { get; set; } /// - /// 姓名 + /// 名称 /// [Required] public string Name { get; set; } @@ -32,4 +32,4 @@ public class AppointmentAreaSaveRequest /// 备注 /// public string Remark { get; set; } -} +} \ No newline at end of file diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentConfirmRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentConfirmRequest.cs similarity index 74% rename from Src/Dlhis.Visitor/Appointment/Request/AppointmentConfirmRequest.cs rename to Src/Dlhis.Basic/Appointment/Request/AppointmentConfirmRequest.cs index c3cf17e5..c544bb98 100644 --- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentConfirmRequest.cs +++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentConfirmRequest.cs @@ -1,4 +1,4 @@ -namespace Dlhis.Visitor.Appointment.Request; +namespace Dlhis.Basic.Appointment.Request; public class AppointmentConfirmRequest { diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentIdNoPageRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentIdNoPageRequest.cs similarity index 89% rename from Src/Dlhis.Visitor/Appointment/Request/AppointmentIdNoPageRequest.cs rename to Src/Dlhis.Basic/Appointment/Request/AppointmentIdNoPageRequest.cs index bc8682e0..e620a087 100644 --- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentIdNoPageRequest.cs +++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentIdNoPageRequest.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using Kurisu.AspNetCore.DataAccess.Dto; -namespace Dlhis.Visitor.Appointment.Request; +namespace Dlhis.Basic.Appointment.Request; public class AppointmentIdNoPageRequest : PageDto { diff --git a/Src/Dlhis.Basic/Appointment/Request/AppointmentPageRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentPageRequest.cs new file mode 100644 index 00000000..5ac43759 --- /dev/null +++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentPageRequest.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; +using Kurisu.AspNetCore.CustomClass; +using Kurisu.AspNetCore.DataAccess.Dto; + +namespace Dlhis.Basic.Appointment.Request; + +public class AppointmentPageRequest : PageDto , IValidatableObject +{ + public DateTimePeriod SearchDateTimePeriod { get; set; } + + /// + public IEnumerable Validate(ValidationContext validationContext) + { + if (SearchDateTimePeriod.HasValue()) + { + SearchDateTimePeriod.End = SearchDateTimePeriod.End!.Value.AddDays(1).AddSeconds(-1); + } + yield break; + } +} diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentReceiveRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentReceiveRequest.cs similarity index 96% rename from Src/Dlhis.Visitor/Appointment/Request/AppointmentReceiveRequest.cs rename to Src/Dlhis.Basic/Appointment/Request/AppointmentReceiveRequest.cs index 3028e970..25565f62 100644 --- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentReceiveRequest.cs +++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentReceiveRequest.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; -using Dlhis.Visitor.Appointment.Dto; +using Dlhis.Basic.Appointment.Dto; -namespace Dlhis.Visitor.Appointment.Request; +namespace Dlhis.Basic.Appointment.Request; public class AppointmentReceiveRequest : IValidatableObject { diff --git a/Src/Dlhis.Visitor/Appointment/Response/ApponintmentAreaPageResponse.cs b/Src/Dlhis.Basic/Appointment/Response/AppointmentAreaPageResponse.cs similarity index 86% rename from Src/Dlhis.Visitor/Appointment/Response/ApponintmentAreaPageResponse.cs rename to Src/Dlhis.Basic/Appointment/Response/AppointmentAreaPageResponse.cs index 6197d54f..f6c27e7d 100644 --- a/Src/Dlhis.Visitor/Appointment/Response/ApponintmentAreaPageResponse.cs +++ b/Src/Dlhis.Basic/Appointment/Response/AppointmentAreaPageResponse.cs @@ -1,17 +1,17 @@ using Dlhis.Entity.Visitor.Enums; using Kurisu.AspNetCore.Utils.Extensions; -namespace Dlhis.Visitor.Appointment.Response; +namespace Dlhis.Basic.Appointment.Response; -public class ApponintmentAreaPageResponse +public class AppointmentAreaPageResponse { public long Id { get; set; } - + /// /// 区域类型 /// public AppointmentAreaEnumType Type { get; set; } - + /// /// 区域类型 /// @@ -21,7 +21,7 @@ public class ApponintmentAreaPageResponse /// 自定义编码 /// public string CustomCode { get; set; } - + /// /// 名称 /// @@ -31,4 +31,4 @@ public class ApponintmentAreaPageResponse /// 备注 /// public string Remark { get; set; } -} +} \ No newline at end of file diff --git a/Src/Dlhis.Basic/Appointment/Response/AppointmentDetailResponse.cs b/Src/Dlhis.Basic/Appointment/Response/AppointmentDetailResponse.cs new file mode 100644 index 00000000..9a0cd25c --- /dev/null +++ b/Src/Dlhis.Basic/Appointment/Response/AppointmentDetailResponse.cs @@ -0,0 +1,102 @@ +using Dlhis.Entity.Visitor.Enums; + +namespace Dlhis.Basic.Appointment.Response; + +public class AppointmentDetailResponse +{ + /// + /// 流水号 + /// + public string No { get; set; } + + /// + /// no + /// + public string UserNo { get; set; } + + /// + /// 证件类型 + /// + public string IdType { get; set; } + + /// + /// 证件号 + /// + public string IdNo { get; set; } + + /// + /// 访客名称 + /// + public string Name { get; set; } + + /// + /// 手机号 + /// + public string Phone { get; set; } + + /// + /// 车牌 + /// + public string LicensePlate { get; set; } + + /// + /// 进入门岗 + /// + public bool IsEnterDoorArea { get; set; } + + /// + /// 预约门禁区域 + /// + public string ApplyDoorArea { get; set; } + + /// + /// 访客开始 + /// + public DateTime DoorStart { get; set; } + + /// + /// 访问结束 + /// + public DateTime DoorEnd { get; set; } + + /// + /// 是否进入车间 + /// + public bool IsEnterWorkplace { get; set; } + + /// + /// 申请车间区域 + /// + public List ApplyWorkplaceAreas { get; set; } + + /// + /// 车间访问开始 + /// + public DateTime? WorkplaceStart { get; set; } + + /// + /// 车间访问结束 + /// + public DateTime? WorkplaceEnd { get; set; } + + /// + /// 社保照片url + /// + public string ImageUrl { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + + /// + /// 门禁状态 + /// + public VisitorAppointmentDetailStatusEnumType DoorStatus { get; set; } + + /// + /// 车间状态 + /// + public VisitorAppointmentDetailStatusEnumType WorkplaceStatus { get; set; } +} \ No newline at end of file diff --git a/Src/Dlhis.Basic/Appointment/Response/AppointmentPageResponse.cs b/Src/Dlhis.Basic/Appointment/Response/AppointmentPageResponse.cs new file mode 100644 index 00000000..90315d30 --- /dev/null +++ b/Src/Dlhis.Basic/Appointment/Response/AppointmentPageResponse.cs @@ -0,0 +1,41 @@ +namespace Dlhis.Basic.Appointment.Response; + +public class AppointmentPageResponse +{ + public string No { get; set; } + + /// + /// 标题 + /// + public string Title { get; set; } + + /// + /// 对接人工号 + /// + public string Code { get; set; } + + /// + /// 来访人来源/公司 + /// + public string Source { get; set; } + + /// + /// 申请时间 + /// + public DateTime Date { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 预约厂区 + /// + public string Factory { get; set; } + + /// + /// 申请事由 + /// + public string Reason { get; set; } +} diff --git a/Src/Dlhis.Basic/Appointment/Services/IAppointmentAreaService.cs b/Src/Dlhis.Basic/Appointment/Services/IAppointmentAreaService.cs new file mode 100644 index 00000000..90fb0727 --- /dev/null +++ b/Src/Dlhis.Basic/Appointment/Services/IAppointmentAreaService.cs @@ -0,0 +1,29 @@ +using Dlhis.Basic.Appointment.Request; +using Dlhis.Basic.Appointment.Response; +using Kurisu.AspNetCore.DataAccess.Dto; + +namespace Dlhis.Basic.Appointment.Services; + +public interface IAppointmentAreaService : IScopeDependency +{ + /// + /// 区域分页 + /// + /// + /// + Task> GetPageAsync(AppointmentAreaPageRequest request); + + /// + /// 保存区域 + /// + /// + /// + Task SaveAsync(AppointmentAreaSaveRequest request); + + /// + /// 分配设备组到区域 + /// + /// + /// + Task AssignAsync(AppointmentAreaAssignRequest request); +} \ No newline at end of file diff --git a/Src/Dlhis.Visitor/Appointment/Services/IAppointmentService.cs b/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs similarity index 84% rename from Src/Dlhis.Visitor/Appointment/Services/IAppointmentService.cs rename to Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs index e601d02f..1480c464 100644 --- a/Src/Dlhis.Visitor/Appointment/Services/IAppointmentService.cs +++ b/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs @@ -1,9 +1,9 @@ -using Dlhis.Visitor.Appointment.Request; -using Dlhis.Visitor.Appointment.Response; +using Dlhis.Basic.Appointment.Request; +using Dlhis.Basic.Appointment.Response; using Kurisu.AspNetCore.DataAccess.Dto; using Microsoft.AspNetCore.Mvc; -namespace Dlhis.Visitor.Appointment.Services; +namespace Dlhis.Basic.Appointment.Services; public interface IAppointmentService : IScopeDependency { @@ -17,9 +17,9 @@ public interface IAppointmentService : IScopeDependency /// /// 查看明细 /// - /// + /// /// - Task> GetAppointmentDetailsByIdAsync(long id); + Task> GetAppointmentDetailsByIdAsync(string no); /// /// 确认到达 diff --git a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentAreaService.cs b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentAreaService.cs new file mode 100644 index 00000000..74e36c98 --- /dev/null +++ b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentAreaService.cs @@ -0,0 +1,180 @@ +using Dlhis.Basic.Appointment.Request; +using Dlhis.Basic.Appointment.Response; +using Dlhis.Entity.Basic.Entity; +using Dlhis.Entity.Device.Entities; +using Dlhis.Entity.Device.Enums; +using Dlhis.Entity.Visitor.Entity; +using Dlhis.Entity.Visitor.Enums; +using Kurisu.AspNetCore.DataAccess.Dto; +using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; +using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; +using Kurisu.AspNetCore.Utils.Extensions; +using Mapster; + +namespace Dlhis.Basic.Appointment.Services.Implements; + +public class AppointmentAreaService : IAppointmentAreaService +{ + private readonly IDbContext _dbContext; + + public AppointmentAreaService(IDbContext dbContext) + { + _dbContext = dbContext; + } + + public async Task SaveAsync(AppointmentAreaSaveRequest request) + { + if (!request.Id.HasValue) + { + var entity = request.Adapt(); + entity.CustomCode = request.CustomCode; + entity.Type = request.Type; + await _dbContext.InsertAsync(entity); + } + else + { + var entity = await _dbContext.Queryable().Where(x => x.Id == request.Id).SingleAsync(); + entity.ThrowIfNull("预约区域不存在"); + request.Adapt(entity); + await _dbContext.UpdateAsync(entity); + } + } + + public async Task> GetPageAsync(AppointmentAreaPageRequest request) + { + return await _dbContext.Queryable() + .WhereIF(request.Type.HasValue, x => x.Type == request.Type) + .WhereIF(request.Search.IsPresent(), x => x.CustomCode == request.Search || x.Name.Contains(request.Search)) + .Select() + .ToPageListAsync(request); + } + + public async Task AssignAsync(AppointmentAreaAssignRequest request) + { + (await _dbContext.Queryable().Where(x => x.CustomCode == request.CustomCode).AnyAsync()) + .ThrowIfFalse("区域不存在"); + + var userBeforePermissions = await GetMyPermissionsAsync(request.CustomCode); + var userNos = userBeforePermissions.Select(x => x.Key).ToList(); + + //删除原来的配置 + await _dbContext.Client.Deleteable() + .Where(x => x.CustomCode == request.CustomCode) + .ExecuteCommandAsync(); + + //添加当前区域的设置 + var data = request.DeviceCodes.Select(x => new AppointmentAreaAssignmentEntity + { + CustomCode = request.CustomCode, + DeviceCode = x + }).ToList(); + + await _dbContext.InsertAsync(data); + + var userCurrentPermissions = await GetMyPermissionsAsync(request.CustomCode); + + var allDeviceCodes = userCurrentPermissions.SelectMany(x => x.Value); + var devices = await _dbContext.Queryable().Where(x => allDeviceCodes.Contains(x.Code)).ToListAsync(); + + var tasks = new List(); + foreach (var userNo in userNos) + { + var before = userBeforePermissions[userNo]; + var current = userCurrentPermissions[userNo]; + + //被删除 + var deletedItems = before.Where(x => !current.Contains(x)).ToList(); + //新增 + var addItems = current.Where(x => !before.Contains(x)).ToList(); + + if (!deletedItems.Any() && !addItems.Any()) + { + continue; + } + + tasks.AddRange(deletedItems.Select(x => new DeviceTaskEntity + { + Type = DeviceTaskEnumType.Delete, + DeviceType = DeviceTypeEnumType.Door, + UserNo = userNo, + DeviceUniqueNo = devices.First(item => item.Code == x).UniqueNo, + Status = DeviceTaskStatusEnumType.Wait, + Version = 0, + CancellationId = 0, + Source = DeviceTaskSourceEnumType.Appointment, + Priority = 99 + })); + + tasks.AddRange(addItems.Select(x => new DeviceTaskEntity + { + Type = DeviceTaskEnumType.Add, + DeviceType = DeviceTypeEnumType.Door, + UserNo = userNo, + DeviceUniqueNo = devices.First(item => item.Code == x).UniqueNo, + Status = DeviceTaskStatusEnumType.Wait, + Version = 0, + CancellationId = 0, + Source = DeviceTaskSourceEnumType.Appointment, + Priority = 99 + })); + } + + await _dbContext.InsertAsync(tasks); + } + + + //********************************************************* help methods *************************************************************** + + + private async Task>> GetMyPermissionsAsync(string areaCode) + { + //获取已经到达的数据 + var arrivedInfos = await _dbContext.Queryable() + .Where(x => x.DoorStatus == VisitorAppointmentDetailStatusEnumType.Arrived || x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Arrived) + .Select(x => new + { + x.UserNo, + x.DoorStatus, + x.WorkplaceStatus, + x.IsEnterDoorArea, + x.ApplyDoorArea, + x.IsEnterWorkplace, + x.ApplyWorkplaceAreas + }) + .ToListAsync(); + + var userAreaCodes = arrivedInfos.GroupBy(x => x.UserNo).ToDictionary(p => p.Key, ls => + { + return ls.SelectMany(x => + { + var list = new List(); + if (x.DoorStatus == VisitorAppointmentDetailStatusEnumType.Arrived) + { + list.Add(x.ApplyDoorArea); + } + + if (x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Arrived) + { + list.AddRange(x.ApplyWorkplaceAreas); + } + + return list; + }); + }); + + userAreaCodes = userAreaCodes.Where(x => x.Value.Contains(areaCode)).ToDictionary(x => x.Key, x => x.Value); + + var userBeforePermissions = new Dictionary>(userAreaCodes.Count); + foreach ((string currentUserNo, IEnumerable currentUseAreaCode) in userAreaCodes) + { + var deviceCodes = await _dbContext.Queryable() + .Where(x => currentUseAreaCode.Contains(x.CustomCode)) + .Select(x => x.DeviceCode) + .ToListAsync(); + + userBeforePermissions.Add(currentUserNo, deviceCodes); + } + + return userBeforePermissions; + } +} \ No newline at end of file diff --git a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs new file mode 100644 index 00000000..ab32b99e --- /dev/null +++ b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs @@ -0,0 +1,145 @@ +using Dlhis.Basic.Appointment.Request; +using Dlhis.Basic.Appointment.Response; +using Dlhis.Entity.Basic.Entity; +using Dlhis.Entity.Device.Entities; +using Dlhis.Entity.Device.Enums; +using Dlhis.Entity.Visitor.Entity; +using Dlhis.Entity.Visitor.Enums; +using Kurisu.AspNetCore.CustomClass; +using Kurisu.AspNetCore.DataAccess.Dto; +using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; +using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; +using Kurisu.AspNetCore.Utils.Extensions; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; + +namespace Dlhis.Basic.Appointment.Services.Implements; + +public class AppointmentService : IAppointmentService +{ + private readonly IDbContext _dbContext; + private readonly IDataProtectionProvider _dataProtectionProvider; + + public AppointmentService(IDbContext dbContext, IDataProtectionProvider dataProtectionProvider) + { + _dbContext = dbContext; + _dataProtectionProvider = dataProtectionProvider; + } + + public async Task> GetPageAsync(AppointmentPageRequest request) + { + return await _dbContext.Queryable() + .WhereIF(request.SearchDateTimePeriod.HasValue(), + x => x.Date >= request.SearchDateTimePeriod.Start && x.Date <= request.SearchDateTimePeriod.End) + .WhereIF(request.Search.IsPresent(), x => x.Code == request.Search) + .Select() + .ToPageListAsync(request); + } + + public async Task> GetAppointmentDetailsByIdAsync(string no) + { + return await _dbContext.Queryable() + .Where(x => x.No == no) + .Select() + .ToListAsync(); + } + + public async Task ConfirmAsync(AppointmentConfirmRequest request) + { + var detail = await _dbContext.Queryable().Where(x => x.Id == request.Id).SingleAsync(); + detail.ThrowIfNull("预约信息不存在"); + + var areaCodes = GetValidAreaCodes(detail); + var existsAreaCodes = await _dbContext.Queryable().Where(x => areaCodes.Contains(x.CustomCode)).Select(x => x.CustomCode).ToListAsync(); + + //当前分配的设备codes + var deviceCodes = await _dbContext.Queryable() + .Where(x => existsAreaCodes.Contains(x.CustomCode)) + .Select(x => x.DeviceCode) + .ToListAsync(); + + var deviceUniqueNos = await _dbContext.Queryable().Where(x => deviceCodes.Contains(x.Code)).Select(x => new { x.UniqueNo, x.TenantId }).ToListAsync(); + + await _dbContext.InsertAsync(deviceUniqueNos.Select(x => new DeviceTaskEntity + { + DeviceType = DeviceTypeEnumType.Door, + DeviceUniqueNo = x.UniqueNo, + Status = DeviceTaskStatusEnumType.Wait, + UserNo = detail.UserNo, + Type = DeviceTaskEnumType.Add, + Priority = 100, + TenantId = x.TenantId, + Source = DeviceTaskSourceEnumType.Appointment, + Version = 0, + }).ToList()); + + detail.DoorStatus = VisitorAppointmentDetailStatusEnumType.Arrived; + detail.WorkplaceStatus = VisitorAppointmentDetailStatusEnumType.Arrived; + detail.ArrivedTime = DateTime.Now; + await _dbContext.UpdateAsync(detail); + } + + + private static IEnumerable GetValidAreaCodes(VisitorAppointmentDetailEntity detail) + { + if (detail.IsEnterDoorArea) + { + yield return detail.ApplyDoorArea; + } + + if (detail.IsEnterWorkplace) + { + foreach (var item in detail.ApplyWorkplaceAreas) + { + yield return item; + } + } + } + + //********************************************************** 用户操作 ******************************************************************* + + + public async Task GetTodayByIdNoAsync(string idNo) + { + var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno"); + try + { + idNo = protector.Unprotect(idNo); + } + catch (Exception) + { + throw new UserFriendlyException("凭证有误"); + } + + var now = DateTime.Now; + return await _dbContext.Queryable() + .LeftJoin((x, ga) => ga.IdNo == idNo) + .Where((x, ga) => ga.IdNo == idNo) + .Where(x => (x.IsEnterDoorArea && SqlFunc.DateIsSame(x.DoorStart, now)) || (x.IsEnterWorkplace && SqlFunc.DateIsSame(x.WorkplaceStart, now))) + .Select() + .SingleAsync(); + } + + public async Task> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request) + { + var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno"); + try + { + request.IdNo = protector.Unprotect(request.IdNo); + } + catch (Exception) + { + throw new UserFriendlyException("凭证有误"); + } + + var page = await _dbContext.Queryable() + .LeftJoin((x, ga) => x.UserNo == ga.No) + .Where((x, ga) => ga.IdNo == request.IdNo) + .OrderBy(x => x.CreateTime) + .Select() + .ToPageListAsync(request); + + return page; + } +} \ No newline at end of file diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs index 1e3f678b..332d1fcf 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs @@ -101,7 +101,7 @@ public class DeviceService : IDeviceService .Where((dgr, dg) => dgr.DeviceCode == entity.Code) .AnyAsync(); - existsG.ThrowIfTrue("存在设备分组,不可修改设备分类"); + existsG.ThrowIfTrue("存在设备分组,不可修改设备类型"); } request.Adapt(entity); diff --git a/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentDetailEntity.cs b/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentDetailEntity.cs index a73e98aa..c7b01aaa 100644 --- a/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentDetailEntity.cs +++ b/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentDetailEntity.cs @@ -104,13 +104,18 @@ public class VisitorAppointmentDetailEntity : SugarBaseEntity [SugarColumn(ColumnDescription = "备注")] public string Remark { get; set; } - /// /// 门禁状态 /// [SugarColumn(IsNullable = false, ColumnDescription = "门禁状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] public VisitorAppointmentDetailStatusEnumType DoorStatus { get; set; } + /// + /// 到达时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? ArrivedTime { get; set; } + /// /// 车间状态 /// diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentPageRequest.cs b/Src/Dlhis.Visitor/Appointment/Request/AppointmentPageRequest.cs deleted file mode 100644 index cec11f6d..00000000 --- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentPageRequest.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Kurisu.AspNetCore.CustomClass; -using Kurisu.AspNetCore.DataAccess.Dto; - -namespace Dlhis.Visitor.Appointment.Request; - -public class AppointmentPageRequest : PageDto -{ - public DateTimePeriod SearchDateTimePeriod { get; set; } -}