diff --git a/Dlhis.Jinko.Face.sln b/Dlhis.Jinko.Face.sln index cf2e3f24..5425d10b 100644 --- a/Dlhis.Jinko.Face.sln +++ b/Dlhis.Jinko.Face.sln @@ -31,7 +31,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Sys.Api", "Src\Dlhis. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Basic.Api", "Src\Dlhis.Basic.Api\Dlhis.Basic.Api.csproj", "{1F337648-8A22-4601-A842-0F634FBA2825}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gateway", "Src\Gateway\Gateway.csproj", "{00DE1D49-8F1F-4EAA-B06F-CDE0EFAA03D3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gateway", "Src\Gateway\Gateway.csproj", "{00DE1D49-8F1F-4EAA-B06F-CDE0EFAA03D3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{489252FB-A44B-46EE-B065-21CDCB724441}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.External", "Src\Dlhis.External\Dlhis.External.csproj", "{8472596E-0DE7-4A17-93D6-F0FC7D44FDF5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -83,6 +87,10 @@ Global {00DE1D49-8F1F-4EAA-B06F-CDE0EFAA03D3}.Debug|Any CPU.Build.0 = Debug|Any CPU {00DE1D49-8F1F-4EAA-B06F-CDE0EFAA03D3}.Release|Any CPU.ActiveCfg = Release|Any CPU {00DE1D49-8F1F-4EAA-B06F-CDE0EFAA03D3}.Release|Any CPU.Build.0 = Release|Any CPU + {8472596E-0DE7-4A17-93D6-F0FC7D44FDF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8472596E-0DE7-4A17-93D6-F0FC7D44FDF5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8472596E-0DE7-4A17-93D6-F0FC7D44FDF5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8472596E-0DE7-4A17-93D6-F0FC7D44FDF5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -97,6 +105,7 @@ Global {8317C526-3523-4195-9B19-2F17CFD71927} = {3D8A98C1-83C9-4375-AEAB-4F72AFAF365B} {85A345C7-913E-4C1B-BE1C-600DE408A02F} = {57074FD8-1A2F-40C7-8476-001778A3F65D} {1F337648-8A22-4601-A842-0F634FBA2825} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} + {8472596E-0DE7-4A17-93D6-F0FC7D44FDF5} = {489252FB-A44B-46EE-B065-21CDCB724441} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7439494A-E2FD-4FEA-8ABF-74AE57A4A5A0} diff --git a/Src/Dlhis.Basic/BusinessPlace/Request/BusinessPlaceSaveRequest.cs b/Src/Dlhis.Basic/BusinessPlace/Request/BusinessPlaceSaveRequest.cs index 15abe478..35c7cb27 100644 --- a/Src/Dlhis.Basic/BusinessPlace/Request/BusinessPlaceSaveRequest.cs +++ b/Src/Dlhis.Basic/BusinessPlace/Request/BusinessPlaceSaveRequest.cs @@ -25,6 +25,11 @@ public class BusinessPlaceSaveRequest [Required(ErrorMessage = "营业点名称不能为空")] public string Name { get; set; } + /// + /// 供应商 + /// + public string Supplier { get; set; } + /// /// 状态 CanteenBusinessPlaceStatusEnumType /// diff --git a/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs b/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs index c954462a..ae186627 100644 --- a/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs +++ b/Src/Dlhis.Basic/BusinessPlace/Response/BusinessPlaceResponse.cs @@ -23,6 +23,12 @@ public class BusinessPlaceResponse /// public string Name { get; set; } + + /// + /// 供应商 + /// + public string Supplier { get; set; } + /// /// 状态,停用/启用 /// diff --git a/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs b/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs index a49ecf44..17e4f88e 100644 --- a/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs +++ b/Src/Dlhis.Basic/BusinessPlace/Services/Implements/BusinessPlaceService.cs @@ -25,7 +25,7 @@ public class BusinessPlaceService : IBusinessPlaceService var page = await _dbContext.Queryable() .LeftJoin((x, ps) => x.Code == ps.PlaceCode) .LeftJoin((x, ps, s) => s.Code == ps.ShiftCode) - .WhereIF(request.Search.IsPresent(), x => x.CustomCode.Contains(request.Search) + .WhereIF(request.Search.IsPresent(), x => x.CustomCode.Contains(request.Search) || x.Code.ToString().Contains(request.Search) || x.Name.Contains(request.Search)) .WhereIF(request.Catalog.HasValue, x => x.Catalog == request.Catalog) .WhereIF(request.Status.HasValue, x => x.Status == request.Status) @@ -39,7 +39,7 @@ public class BusinessPlaceService : IBusinessPlaceService Catalog = x.Catalog, CustomCode = x.CustomCode, Source = x.Source, - + Supplier = x.Supplier, ShiftCode = s.Code, ShiftName = s.Name }) @@ -65,6 +65,7 @@ public class BusinessPlaceService : IBusinessPlaceService if (!request.Id.HasValue) { var entity = request.Adapt(); + entity.CustomCode = request.CustomCode; entity.Code = Guid.NewGuid(); await _dbContext.InsertAsync(entity); } diff --git a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs index 92f5f95e..de3fa555 100644 --- a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs +++ b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs @@ -62,7 +62,8 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService public async Task> GetListAsync() { var result = await _dbContext.Queryable() - .Select().ToListAsync(); + .Select() + .ToListAsync(); return result; } @@ -71,15 +72,14 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService { await CheckExistsAsync(request); - Guid code = Guid.Empty; if (!request.Id.HasValue) { var entity = request.Adapt(); - + entity.CustomCode = request.CustomCode; entity.Code = Guid.NewGuid(); await _dbContext.InsertAsync(entity); - code = entity.Code; + return entity.Code; } else { @@ -89,10 +89,8 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService request.Adapt(entity); await _dbContext.UpdateAsync(entity); - code = entity.Code; + return entity.Code; } - - return code; } public async Task SaveMealShiftsAsync(List requests) @@ -198,7 +196,7 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService .ToListAsync(); var devices = await _dbContext.Queryable().ToListAsync(); - + var list = new List(); if (regiss.Count > 0) { diff --git a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs index 51b5bfaa..3298137a 100644 --- a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs +++ b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs @@ -2,6 +2,8 @@ using Dlhis.Basic.Device.Response; using Dlhis.Basic.Device.Services; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; +using Kurisu.AspNetCore.EventBus.Abstractions; +using Kurisu.AspNetCore.Scope; using Kurisu.Core.DataAccess.Dto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -218,5 +220,4 @@ public class DevicesController : ControllerBase { return await _deviceService.BulkUploadsAsync(request); } - } diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs index a0524c49..c0020c88 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs @@ -82,6 +82,7 @@ public class DeviceService : IDeviceService if (!request.Id.HasValue) { entity = request.Adapt(); + entity.UniqueNo = request.UniqueNo; entity.Code = Guid.NewGuid(); await _dbContext.InsertAsync(entity); //同时保存注册信息 diff --git a/Src/Dlhis.Basic/Dlhis.Basic.csproj b/Src/Dlhis.Basic/Dlhis.Basic.csproj index ffe86e4d..61d37f79 100644 --- a/Src/Dlhis.Basic/Dlhis.Basic.csproj +++ b/Src/Dlhis.Basic/Dlhis.Basic.csproj @@ -17,7 +17,7 @@ - + diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs index 84ab0fb5..a5a9a006 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs @@ -1,13 +1,15 @@ -using System.ComponentModel.DataAnnotations; -using Dlhis.Basic.BusinessPlace.Response; +using Dlhis.Basic.BusinessPlace.Response; using Dlhis.Basic.Device.Response; +using Dlhis.Basic.Device.Services; using Dlhis.Basic.Organization.Request; using Dlhis.Basic.Organization.Response; using Dlhis.Basic.Organization.Services; using Dlhis.Basic.Organization.Services.Implements; +using Dlhis.Entity.Device.Entities; using Kurisu.Core.DataAccess.Dto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Org.BouncyCastle.Asn1.Ocsp; namespace Dlhis.Basic.Organization.Controllers; @@ -42,7 +44,7 @@ public class GainfoPermissionsController : ControllerBase /// /// [HttpGet("devicesUnderGroupByUserNo")] - public async Task> GetDevicesUnderGroupByUserNoAsync(string userNo, string deviceGroupCode) + public async Task> GetDevicesUnderGroupByUserNoAsync(string userNo, Guid deviceGroupCode) { return await _gainfoPermissions.GetDevicesUnderGroupByUserNoAsync(userNo, deviceGroupCode); } @@ -57,4 +59,14 @@ public class GainfoPermissionsController : ControllerBase { return await _gainfoPermissions.GetAssignDeviceCodesAsync(request); } + + /// + /// 当前绑定的设备组信息 + /// + /// + [HttpGet("assignGroups")] + public async Task> GetAssignGroupAsync(string userNo) + { + return await _gainfoPermissions.GetAssignGroupAsync(userNo); + } } diff --git a/Src/Dlhis.Basic/Organization/Response/GetAssignGroupResponse.cs b/Src/Dlhis.Basic/Organization/Response/GetAssignGroupResponse.cs new file mode 100644 index 00000000..eff54888 --- /dev/null +++ b/Src/Dlhis.Basic/Organization/Response/GetAssignGroupResponse.cs @@ -0,0 +1,7 @@ +namespace Dlhis.Basic.Organization.Response +{ + public class GetAssignGroupResponse + { + + } +} diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoPermissions.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoPermissions.cs index 7b1f6183..182926f0 100644 --- a/Src/Dlhis.Basic/Organization/Services/IGainfoPermissions.cs +++ b/Src/Dlhis.Basic/Organization/Services/IGainfoPermissions.cs @@ -2,7 +2,6 @@ using Dlhis.Basic.Device.Response; using Dlhis.Basic.Organization.Request; using Dlhis.Basic.Organization.Response; -using Dlhis.Basic.Organization.Services.Implements; using Kurisu.Core.DataAccess.Dto; namespace Dlhis.Basic.Organization.Services; @@ -11,7 +10,9 @@ public interface IGainfoPermissions : IScopeDependency { Task> GetPlaceByGainfoAsync(DeviceAssRequest request); - Task> GetDevicesUnderGroupByUserNoAsync(string userNo, string deviceGroupCode); + Task> GetDevicesUnderGroupByUserNoAsync(string userNo, Guid deviceGroupCode); Task> GetAssignDeviceCodesAsync(DeviceAssRequest request); + + Task> GetAssignGroupAsync(string userNo); } diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/DepartmentService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/DepartmentService.cs index fd4f8e74..a7cfd72d 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/DepartmentService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/DepartmentService.cs @@ -35,7 +35,7 @@ public class DepartmentService : IDepartmentService { Name = x.Name, No = x.Code, - PNo = x.PCode, + PNo = null, Tenant = x.Code, _Next = tops.Select(item => { diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs index 2bcc5fe4..fd8dbe9d 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs @@ -1,4 +1,5 @@ using Dlhis.Basic.BusinessPlace.Response; +using Dlhis.Basic.Device.Request; using Dlhis.Basic.Device.Response; using Dlhis.Basic.Device.Services; using Dlhis.Basic.Organization.Request; @@ -8,12 +9,11 @@ using Dlhis.Entity.Canteen.Entities; using Dlhis.Entity.Canteen.Enums; using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; +using Dlhis.Entity.Sys.Enums; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Core.DataAccess.Dto; using Kurisu.SqlSugar.Extensions; using Kurisu.SqlSugar.Services; -using Org.BouncyCastle.Asn1.Ocsp; -using Org.BouncyCastle.Crypto; using SqlSugar; namespace Dlhis.Basic.Organization.Services.Implements; @@ -48,8 +48,8 @@ public class GainfoPermissions : IGainfoPermissions return await _dbContext.Queryable() .LeftJoin((x, dr) => x.UniqueNo == dr.DeviceUniqueNo) .LeftJoin((x, dr, place) => dr.BusinessPlaceCode == place.Code) - .LeftJoin((x,dr,place, ps) => x.Code == ps.PlaceCode) - .LeftJoin((x, dr, place, ps,s) => s.Code == ps.ShiftCode) + .LeftJoin((x, dr, place, ps) => x.Code == ps.PlaceCode) + .LeftJoin((x, dr, place, ps, s) => s.Code == ps.ShiftCode) .Where(x => x.Type == DeviceTypeEnumType.Meal) .Where(x => deviceCodes.Contains(x.Code)) .Where((x, dr) => !string.IsNullOrEmpty(dr.BusinessPlaceCustomCode)) @@ -70,11 +70,14 @@ public class GainfoPermissions : IGainfoPermissions .ToPageListAsync(request); } - public async Task> GetDevicesUnderGroupByUserNoAsync(string userNo, string deviceGroupCode) + public async Task> GetDevicesUnderGroupByUserNoAsync(string userNo, Guid deviceGroupCode) { var deviceGroups = await _dbContext.Queryable().ToListAsync(); - var currentGroup = deviceGroups.Where(x => x.Code.ToString() == deviceGroupCode).FirstOrDefault(); - currentGroup.ThrowIfNull($"{deviceGroupCode}在设备组中不存在"); + var currentGroup = deviceGroups.Where(x => x.Code == deviceGroupCode).FirstOrDefault(); + if (currentGroup == null) + { + return new List(); + } var groups = RecursionGetNext(currentGroup, deviceGroups).ToList(); @@ -96,21 +99,21 @@ public class GainfoPermissions : IGainfoPermissions .LeftJoin((d, dt, dr, bp) => dr.BusinessPlaceCode == bp.Code) .Where(d => nos.Contains(d.UniqueNo)) .Select((d, dt, dr, bp) => new DevicePageResponse - { - FuncsStr = d.Funcs.ToString(), - Brand = dt.Brand, - Type = d.Type, - BusinessPlaceCode = bp.Code, - BusinessPlaceName = bp.Name, - LastHeartbeatTime = dr.LastHeartbeatTime, - UniqueNo = d.UniqueNo, - Supplier = d.Supplier, - DeployPlace = d.DeployPlace, - DeployPosition = d.DeployPosition, - DeployDirection = d.DeployDirection, - TemplateCode = dt.Code, - ConnectionInfo = d.ConnectionInfo, - Enable = d.Enable, + { + FuncsStr = d.Funcs.ToString(), + Brand = dt.Brand, + Type = d.Type, + BusinessPlaceCode = bp.Code, + BusinessPlaceName = bp.Name, + LastHeartbeatTime = dr.LastHeartbeatTime, + UniqueNo = d.UniqueNo, + Supplier = d.Supplier, + DeployPlace = d.DeployPlace, + DeployPosition = d.DeployPosition, + DeployDirection = d.DeployDirection, + TemplateCode = dt.Code, + ConnectionInfo = d.ConnectionInfo, + Enable = d.Enable, }) .ToListAsync(); var deviceUniqueNos = page.Select(x => x.UniqueNo).ToList(); @@ -146,9 +149,9 @@ public class GainfoPermissions : IGainfoPermissions return lst; } - public async Task> GetAssignDeviceCodesAsync(DeviceAssRequest request) + public async Task> GetAssignDeviceCodesAsync(DeviceAssRequest request) { - var ids = await _devicePermissionService.GetAssignDeviceCodesAsync(request.UserNo); + var ids = await _devicePermissionService.GetAssignDeviceCodesAsync(request.UserNo); var page = await _dbContext.Queryable() .LeftJoin((d, dt) => d.TemplateCode == dt.Code) @@ -193,6 +196,16 @@ public class GainfoPermissions : IGainfoPermissions } + + public async Task> GetAssignGroupAsync(string userNo) + { + var groups = await _devicePermissionService.GetAssignmentsAsync(DeviceAssignmentTypeEnumType.Group, AssignTypeEnumType.User, userNo); + return await _dbContext.Queryable() + .Where(x => groups.Contains(x.Code)) + .Select() + .ToListAsync(); + } + private IEnumerable RecursionGetNext(DeviceGroupEntity current, List deviceGroups) { var next = deviceGroups.Where(x => x.PCode == current.Code).ToList(); diff --git a/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs b/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs new file mode 100644 index 00000000..b6ecc0d5 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs @@ -0,0 +1,81 @@ +using Dlhis.Canteen.Order.Request; +using Dlhis.Canteen.Order.Response; +using Dlhis.Canteen.Order.Services; +using Kurisu.Core.DataAccess.Dto; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace Dlhis.Canteen.Order.Controllers; + +/// +/// 菜单菜品控制器 +/// +[Authorize] +[Route("api/[controller]")] +[ApiController] +public class MenuDishesController : ControllerBase +{ + private readonly IMenuDishesService _menuDishesService; + + public MenuDishesController(IMenuDishesService menuDishesService) + { + _menuDishesService = menuDishesService; + } + + /// + /// 菜单分页 + /// + /// + /// + [HttpGet("pageMenu")] + public async Task> GetMenuAsync([FromQuery]GetMenuRequest request) + { + return await _menuDishesService.GetMenuAsync(request); + } + + /// + /// 菜单保存/更改 + /// + /// + /// + [HttpPost("saveMenu")] + public async Task SaveMenuAsync(SaveMenuRequest request) + { + await _menuDishesService.SaveMenuAsync(request); + } + + /// + /// 菜品分页 + /// + /// + /// + [HttpGet("pageDishes")] + public async Task> GetDishesAsync([FromQuery] GetDishesRequest request) + { + return await _menuDishesService.GetDishesAsync(request); + } + + /// + /// 菜品保存/更改 + /// + /// + /// + [HttpPost("saveDishes")] + public async Task SaveDishesAsync(SaveDishesRequest request) + { + await _menuDishesService.SaveDishesAsync(request); + } + + /// + /// 配置每日菜单菜品及限售 + /// + /// + /// + [HttpPost("disposition")] + public async Task DispositionDishesAsync(DispositionDishesRequest request) + { + await _menuDishesService.DispositionDishesAsync(request); + } +} + diff --git a/Src/Dlhis.Canteen/Order/Controllers/MiniProgramOrderDetailController.cs b/Src/Dlhis.Canteen/Order/Controllers/MiniProgramOrderDetailController.cs new file mode 100644 index 00000000..e26efc4b --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Controllers/MiniProgramOrderDetailController.cs @@ -0,0 +1,69 @@ +using Dlhis.Canteen.Order.Request; +using Dlhis.Canteen.Order.Response; +using Dlhis.Canteen.Order.Services; +using Kurisu.Core.DataAccess.Dto; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace Dlhis.Canteen.Order.Controllers; + +/// +///订单/明细控制器 +/// +[Authorize] +[Route("api/[controller]")] +[ApiController] +public class MiniProgramOrderDetailController : ControllerBase +{ + private readonly IMiniProgramOrderDetailService _miniProgramOrderDetailService; + + public MiniProgramOrderDetailController(IMiniProgramOrderDetailService miniProgramOrderDetailService) + { + _miniProgramOrderDetailService = miniProgramOrderDetailService; + } + + /// + /// 订单分页 + /// + /// + /// + [HttpGet("pageOrder")] + public async Task> GetMiniProgramOrderAsync([FromQuery]GetMiniProgramOrderRequest request) + { + return await _miniProgramOrderDetailService.GetMiniProgramOrderAsync(request); + } + + + /// + /// 明细保存 + /// + /// + /// + [HttpPost("saveDetail")] + public async Task SaveDetailAsync(SaveDetailRequest request) + { + await _miniProgramOrderDetailService.SaveDetailAsync(request); + } + + /// + /// 明细分页 + /// + /// + /// + [HttpGet("pageDetail")] + public async Task> GetDetailAsync([FromQuery] GetDetailRequest request) + { + return await _miniProgramOrderDetailService.GetDetailAsync(request); + } + + /// + /// 下单 + /// + /// + [HttpPost("order")] + public async Task OrderAsync(OrderRequest request) + { + await _miniProgramOrderDetailService.OrderAsync(request); + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/DispositionDishesDto.cs b/Src/Dlhis.Canteen/Order/Request/DispositionDishesDto.cs new file mode 100644 index 00000000..07863df5 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/DispositionDishesDto.cs @@ -0,0 +1,10 @@ +namespace Dlhis.Canteen.Order.Request +{ + public class DispositionDishesDto + { + public Guid DisherCode { get; set; } + + public int RestrictedNum { get; set; } + + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/DispositionDishesRequest.cs b/Src/Dlhis.Canteen/Order/Request/DispositionDishesRequest.cs new file mode 100644 index 00000000..070e8c42 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/DispositionDishesRequest.cs @@ -0,0 +1,10 @@ +namespace Dlhis.Canteen.Order.Request +{ + public class DispositionDishesRequest + { + public Guid MenudCode { get; set; } + + public List DishersDtos { get; set; } + + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/GetDetailRequest.cs b/Src/Dlhis.Canteen/Order/Request/GetDetailRequest.cs new file mode 100644 index 00000000..797deff3 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/GetDetailRequest.cs @@ -0,0 +1,8 @@ +using Kurisu.Core.DataAccess.Dto; + +namespace Dlhis.Canteen.Order.Request +{ + public class GetDetailRequest : PageDto + { + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/GetDishesRequest.cs b/Src/Dlhis.Canteen/Order/Request/GetDishesRequest.cs new file mode 100644 index 00000000..6f741793 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/GetDishesRequest.cs @@ -0,0 +1,9 @@ +using Kurisu.Core.DataAccess.Dto; + +namespace Dlhis.Canteen.Order.Request +{ + public class GetDishesRequest : PageDto + { + public Guid? MenuCode { get; set; } + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/GetMenuRequest.cs b/Src/Dlhis.Canteen/Order/Request/GetMenuRequest.cs new file mode 100644 index 00000000..8f9c6b55 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/GetMenuRequest.cs @@ -0,0 +1,11 @@ +using Kurisu.Core.DataAccess.Dto; + +namespace Dlhis.Canteen.Order.Request +{ + public class GetMenuRequest : PageDto + { + public Guid? PlaceCode { get; set; } + + public string Factory { get; set; } + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/GetMiniProgramOrderRequest.cs b/Src/Dlhis.Canteen/Order/Request/GetMiniProgramOrderRequest.cs new file mode 100644 index 00000000..98bdea14 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/GetMiniProgramOrderRequest.cs @@ -0,0 +1,12 @@ +using Kurisu.Core.DataAccess.Dto; + +namespace Dlhis.Canteen.Order.Request +{ + public class GetMiniProgramOrderRequest : PageDto + { + /// + /// 用餐日期 + /// + public DateOnly? SysDate { get; set; } + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/OrderRequest.cs b/Src/Dlhis.Canteen/Order/Request/OrderRequest.cs new file mode 100644 index 00000000..4d8b9cc2 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/OrderRequest.cs @@ -0,0 +1,50 @@ +using Dlhis.Entity.Canteen.Enums; +using SqlSugar.DbConvert; +using SqlSugar; + +namespace Dlhis.Canteen.Order.Request +{ + public class OrderRequest + { + + /// + /// 订餐人 + /// + public string UserCode { get; set; } + + /// + /// 食堂 + /// + public Guid PlaceCode { get; set; } + + /// + /// 餐次 + /// + public ShiftEnumType ShiftType { get; set; } + + /// + /// 配送地址 + /// + public string Address { get; set; } + + /// + /// 菜单 + /// + public Guid MenuCode { get; set; } + + /// + /// 菜品 + /// + public Guid DishesCode { get; set; } + + /// + /// 数量 + /// + public int DishesNum { get; set; } = 1; + + /// + /// 支付方式 + /// + public CanteenPayEnumType PayType { get; set; } + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/SaveDetailRequest.cs b/Src/Dlhis.Canteen/Order/Request/SaveDetailRequest.cs new file mode 100644 index 00000000..a7ed3d5d --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/SaveDetailRequest.cs @@ -0,0 +1,61 @@ +using Dlhis.Entity.Canteen.Enums; +using SqlSugar.DbConvert; +using SqlSugar; + +namespace Dlhis.Canteen.Order.Request +{ + public class SaveDetailRequest + { + public long? Id { get; set; } + + /// + /// 订单号 + /// + public string ThirdNo { get; set; } + + /// + /// 营业日 + /// + public DateOnly BusinessDate { get; set; } + + /// + /// 餐次 + /// + public ShiftEnumType ShiftType { get; set; } + + /// + /// 菜品编码 + /// + public Guid DishesCode { get; set; } + + /// + /// 菜品名称 + /// + public Guid DishesName { get; set; } + + /// + /// 单价 + /// + public decimal Price { get; set; } + + /// + /// 单位 + /// + public string Unit { get; set; } + + /// + /// 数量 + /// + public int Num { get; set; } + + /// + /// 金额 + /// + public decimal Amount { get; set; } + + /// + /// 订单明细状态 + /// + public OrderDetailsStatusEnumType OrderStatus { get; set; } + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs b/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs new file mode 100644 index 00000000..f68b41e1 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs @@ -0,0 +1,59 @@ +using Dlhis.Entity.Canteen.Enums; +using SqlSugar.DbConvert; +using SqlSugar; +using System.ComponentModel.DataAnnotations; + +namespace Dlhis.Canteen.Order.Request +{ + public class SaveDishesRequest + { + + public long? Id { get; set; } + + /// + /// 大类 + /// + public string Categories { get; set; } + + /// + /// 小类 + /// + public string SubCategories { get; set; } + + /// + /// 菜品名称 + /// + public string Name { get; set; } + + /// + /// 类型 + /// + [EnumDataType(typeof(CanteenDishesEnumType))] + public CanteenDishesEnumType Type { get; set; } + + /// + /// 描述 + /// + public string Description { get; set; } + + /// + /// 单价 + /// + public decimal Amount { get; set; } + + /// + /// 单位 + /// + public string Unit { get; set; } + + /// + /// 图片 + /// + public string Image { get; set; } + + /// + /// 是否启用 + /// + public bool Enable { get; set; } + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/SaveMenuRequest.cs b/Src/Dlhis.Canteen/Order/Request/SaveMenuRequest.cs new file mode 100644 index 00000000..76e7d66e --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/SaveMenuRequest.cs @@ -0,0 +1,44 @@ +using Dlhis.Entity.Canteen.Enums; +using Dlhis.Entity.Device.Enums; +using SqlSugar; +using System.ComponentModel.DataAnnotations; + +namespace Dlhis.Canteen.Order.Request +{ + public class SaveMenuRequest + { + public long? Id { get; set; } + + /// + /// 菜单名称 + /// + public string Name { get; set; } + + /// + /// 所属营业点 + /// + [Required] + public Guid PlaceCode { get; set; } + + /// + /// 厂区 + /// + public string Factory { get; set; } + + /// + /// 营业日期 + /// + public DateOnly StartDate { get; set; } + + + /// + /// 餐次段 + /// + public List ShiftTypes { get; set; } + + /// + /// 是否启用 + /// + public bool Enable { get; set; } + } +} diff --git a/Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs new file mode 100644 index 00000000..1b78423e --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs @@ -0,0 +1,71 @@ +using Dlhis.Entity.Canteen.Enums; +using SqlSugar.DbConvert; +using SqlSugar; +using Kurisu.AspNetCore.Utils.Extensions; + +namespace Dlhis.Canteen.Order.Response +{ + public class GetDetailResponse + { + /// + /// 订单号 + /// + public string ThirdNo { get; set; } + + /// + /// 营业日 + /// + public DateOnly BusinessDate { get; set; } + + /// + /// 餐次 + /// + public ShiftEnumType ShiftType { get; set; } + + /// + /// 餐次CN + /// + public string ShiftTypeCN => ShiftType.GetDescription(); + + /// + /// 菜品编码 + /// + public Guid DishesCode { get; set; } + + /// + /// 菜品名称 + /// + public string DishesName { get; set; } + + /// + /// 单价 + /// + public decimal Price { get; set; } + + /// + /// 单位 + /// + public string Unit { get; set; } + + /// + /// 数量 + /// + public int Num { get; set; } + + /// + /// 金额 + /// + public decimal Amount { get; set; } + + /// + /// 订单明细状态 + /// + public OrderDetailsStatusEnumType OrderStatus { get; set; } + + /// + /// 订单明细状态CN + /// + public string OrderStatusCN => OrderStatus.GetDescription(); + } + +} \ No newline at end of file diff --git a/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs new file mode 100644 index 00000000..4d149b01 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs @@ -0,0 +1,67 @@ +using Dlhis.Entity.Canteen.Enums; +using SqlSugar.DbConvert; +using SqlSugar; +using Kurisu.AspNetCore.Utils.Extensions; + +namespace Dlhis.Canteen.Order.Response +{ + public class GetDishesResponse + { + + /// + /// 大类 + /// + public string Categories { get; set; } + + /// + /// 小类 + /// + public string SubCategories { get; set; } + + /// + /// 菜品编码 + /// + public Guid Code { get; set; } + + /// + /// 菜品名称 + /// + public string Name { get; set; } + + /// + /// 菜品类型 + /// + public CanteenDishesEnumType Type { get; set; } + + /// + /// 菜品类型描述 + /// + public string TypeDescription => Type.GetDescription(); + + /// + /// 描述 + /// + public string Description { get; set; } + + /// + /// 单价 + /// + public decimal Amount { get; set; } + + /// + /// 单位 + /// + public string Unit { get; set; } + + + /// + /// 图片 + /// + public string Image { get; set; } + + /// + /// 是否启用 + /// + public bool Enable { get; set; } + } +} diff --git a/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs new file mode 100644 index 00000000..111e0ecb --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs @@ -0,0 +1,60 @@ +using Dlhis.Entity.Canteen.Enums; +using Kurisu.AspNetCore.Utils.Extensions; + +namespace Dlhis.Canteen.Order.Response +{ + public class GetMenuResponse + { + + /// + /// 菜单编码 + /// + public Guid Code { get; set; } + + /// + /// 菜单名称 + /// + public string Name { get; set; } + + /// + /// 所属营业点 + /// + public Guid PlaceCode { get; set; } + + /// + /// 所属营业点名称 + /// + public string PlaceName { get; set; } + + /// + /// 厂区 + /// + public string Factory { get; set; } + + /// + /// 营业日期 + /// + public DateOnly StartDate { get; set; } + + + /// + /// 餐次段 + /// + public List ShiftTypes + { + get + { + if (ShiftTypesSrt.IsEmpty()) ShiftTypesSrt = "[]"; + + return ShiftTypesSrt.ToObject>(); + } + } + + public string ShiftTypesSrt { get; set; } + + /// + /// 是否启用 + /// + public bool Enable { get; set; } + } +} diff --git a/Src/Dlhis.Canteen/Order/Response/GetMiniProgramOrderResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetMiniProgramOrderResponse.cs new file mode 100644 index 00000000..5fcd6a2b --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Response/GetMiniProgramOrderResponse.cs @@ -0,0 +1,136 @@ +using Dlhis.Entity.Canteen.Enums; +using SqlSugar.DbConvert; +using SqlSugar; +using Kurisu.AspNetCore.Utils.Extensions; + +namespace Dlhis.Canteen.Order.Response +{ + public class GetMiniProgramOrderResponse + { + /// + /// 订单号 + /// + public string No { get; set; } + + /// + /// 姓名 + /// + public string Name { get; set; } + + /// + /// 工号 + /// + public string Code { get; set; } + + /// + /// 人事范围 + /// + public string Werks { get; set; } + + /// + /// 部门编码 + /// + public string DepartmentNo { get; set; } + + /// + /// 部门名称 + /// + public string DepartmentName { get; set; } + + /// + /// 成本中心 + /// + public string CostId { get; set; } + + /// + /// 工作地 + /// + public string Workplace { get; set; } + + /// + /// 厂区 + /// + public string Factory { get; set; } + + /// + /// 营业点 + /// + public Guid PlaceCode { get; set; } + + /// + /// 营业名称 + /// + public string PlaceName { get; set; } + + /// + /// 餐次 + /// + public ShiftEnumType ShiftType { get; set; } + + /// + /// 餐次CN + /// + public string ShiftTypeCN => ShiftType.GetDescription(); + + /// + /// 菜品 + /// + public Guid DishesCode { get; set; } + + /// + /// 菜品名称 + /// + public string DishesName { get; set; } + + /// + /// 手机号码 + /// + public string Phone { get; set; } + + /// + /// 用餐日期 + /// + public DateOnly SysDate { get; set; } + + /// + /// 下单时间 + /// + public DateTime CostDate { get; set; } + + /// + /// 支付方式 + /// + public CanteenPayEnumType PayType { get; set; } + + /// + /// 支付方式CN + /// + public string PayTypeCN => PayType.GetDescription(); + + /// + /// 订单状态 + /// + public MiniProgramOrderStatusEnumType OrderStatus { get; set; } + + /// + /// 订单状态CN + /// + public string OrderStatusCN => OrderStatus.GetDescription(); + + /// + /// 订单类型 + /// + public CanteenDishesEnumType OrderType { get; set; } + + /// + /// 订单类型CN + /// + public string OrderTypeCN => OrderType.GetDescription(); + + /// + /// 总金额 + /// + public decimal TotalAmount { get; set; } + +} +} diff --git a/Src/Dlhis.Canteen/Order/Services/IMenuDishesService.cs b/Src/Dlhis.Canteen/Order/Services/IMenuDishesService.cs new file mode 100644 index 00000000..020b5bed --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Services/IMenuDishesService.cs @@ -0,0 +1,20 @@ +using Dlhis.Canteen.Order.Request; +using Dlhis.Canteen.Order.Response; +using Kurisu.Core.DataAccess.Dto; +using Microsoft.AspNetCore.Mvc; + +namespace Dlhis.Canteen.Order.Services +{ + public interface IMenuDishesService :IScopeDependency + { + Task> GetMenuAsync(GetMenuRequest request); + + Task SaveMenuAsync(SaveMenuRequest request); + + Task> GetDishesAsync(GetDishesRequest request); + + Task SaveDishesAsync(SaveDishesRequest request); + + Task DispositionDishesAsync(DispositionDishesRequest request); + } +} diff --git a/Src/Dlhis.Canteen/Order/Services/IMiniProgramOrderDetailService.cs b/Src/Dlhis.Canteen/Order/Services/IMiniProgramOrderDetailService.cs new file mode 100644 index 00000000..7bb8394d --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Services/IMiniProgramOrderDetailService.cs @@ -0,0 +1,18 @@ +using Dlhis.Canteen.Order.Request; +using Dlhis.Canteen.Order.Response; +using Kurisu.Core.DataAccess.Dto; +using Microsoft.AspNetCore.Mvc; + +namespace Dlhis.Canteen.Order.Services +{ + public interface IMiniProgramOrderDetailService : IScopeDependency + { + Task> GetMiniProgramOrderAsync(GetMiniProgramOrderRequest request); + + Task SaveDetailAsync(SaveDetailRequest request); + + Task> GetDetailAsync( GetDetailRequest request); + + Task OrderAsync(OrderRequest request); + } +} diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs new file mode 100644 index 00000000..a5965110 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs @@ -0,0 +1,118 @@ +using Dlhis.Canteen.Order.Request; +using Dlhis.Canteen.Order.Response; +using Dlhis.Entity.Basic.Entity; +using Dlhis.Entity.Canteen.Entities; +using Kurisu.AspNetCore.Utils.Extensions; +using Kurisu.Core.DataAccess.Dto; +using Kurisu.Core.User.Abstractions; +using Kurisu.SqlSugar.Extensions; +using Kurisu.SqlSugar.Services; +using Mapster; + +namespace Dlhis.Canteen.Order.Services.Implements +{ + public class MenuDishesService : IMenuDishesService + { + private readonly IDbContext _dbContext; + private readonly ICurrentUser _currentUser; + + public MenuDishesService(IDbContext dbContext, ICurrentUser currentUser) + { + _dbContext = dbContext; + _currentUser = currentUser; + } + + public async Task> GetMenuAsync(GetMenuRequest request) + { + var page = await _dbContext.Queryable() + .LeftJoin((x,place) => x.PlaceCode == place.Code) + .WhereIF(!request.Factory.IsEmpty(),x => x.Factory == request.Factory) + .WhereIF(request.PlaceCode.HasValue, x => request.PlaceCode == x.PlaceCode) + .WhereIF(!request.Search.IsEmpty(),x => x.Name.Contains(request.Search)) + .Select((x,place) => new GetMenuResponse + { + ShiftTypesSrt = x.ShiftTypes.ToString(), + //ShiftTypesSrt = string.Join(", ", x.ShiftTypes.Select(enumValue => enumValue.GetDescription())), + PlaceName = place.Name, + },true) + .ToPageListAsync(request); + return page; + } + + public async Task SaveMenuAsync(SaveMenuRequest request) + { + var place = await _dbContext.Queryable() + .FirstAsync(x => x.Code == request.PlaceCode); + place.ThrowIfNull($"{request.PlaceCode}:该营业点不存在!"); + + if (!request.Id.HasValue) + { + var entity = request.Adapt(); + entity.Code = Guid.NewGuid(); + await _dbContext.InsertAsync(entity); + } + else + { + var entity = await _dbContext.Queryable() + .Where(x => x.Id == request.Id).FirstAsync(); + request.Adapt(entity); + await _dbContext.UpdateAsync(entity); + } + } + + public async Task> GetDishesAsync(GetDishesRequest request) + { + if (!request.MenuCode.HasValue) + { + return await _dbContext.Queryable() + .Select() + .ToPageListAsync(request); + } + else + { + var disCodes = await _dbContext.Queryable() + .Where(x => x.MenuCode == request.MenuCode) + .Select(x => x.DishersCode) + .ToListAsync(); + return await _dbContext.Queryable() + .Where(x => disCodes.Contains(x.Code)) + .Select() + .ToPageListAsync(request); + } + } + + public async Task SaveDishesAsync(SaveDishesRequest request) + { + if (!request.Id.HasValue) + { + var dishers = request.Adapt(); + dishers.Code = Guid.NewGuid(); + await _dbContext.InsertAsync(dishers); + } + else + { + var entity = await _dbContext.Queryable() + .Where(x => x.Id == request.Id).FirstAsync(); + request.Adapt(entity); + await _dbContext.UpdateAsync(entity); + } + } + + public async Task DispositionDishesAsync(DispositionDishesRequest request) + { + var lst = new List(); + + foreach (var dto in request.DishersDtos) + { + var entity = new CanteenMenuDishersRelationshipEntity + { + MenuCode = request.MenudCode, + DishersCode = dto.DisherCode, + RestrictedNum = dto.RestrictedNum, + }; + lst.Add(entity); + } + await _dbContext.InsertAsync(lst); + } + } +} diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs new file mode 100644 index 00000000..9c31e57e --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs @@ -0,0 +1,176 @@ +using Dlhis.Canteen.Order.Request; +using Dlhis.Canteen.Order.Response; +using Dlhis.Entity.Basic.Entity; +using Dlhis.Entity.Canteen.Entities; +using Dlhis.Entity.Canteen.Enums; +using Dlhis.Sys.Api; +using Kurisu.AspNetCore.Utils; +using Kurisu.AspNetCore.Utils.Extensions; +using Kurisu.Core.DataAccess.Dto; +using Kurisu.SqlSugar.Extensions; +using Kurisu.SqlSugar.Services; +using Mapster; +using SqlSugar; + +namespace Dlhis.Canteen.Order.Services.Implements; + +public class MiniProgramOrderDetailService : IMiniProgramOrderDetailService +{ + private readonly IDbContext _dbContext; + private readonly ITenantApi _tenantApi; + public MiniProgramOrderDetailService(IDbContext dbContext, ITenantApi tenantApi) + { + _dbContext = dbContext; + _tenantApi = tenantApi; + } + + public async Task> GetMiniProgramOrderAsync(GetMiniProgramOrderRequest request) + { + var page = await _dbContext.Queryable() + .LeftJoin((order,place) => order.PlaceCode == place.Code) + .LeftJoin((order, place,dishers) => order.DishesCode == dishers.Code) + .LeftJoin((order, place, dishers,depart) => order.DepartmentNo == depart.No) + .WhereIF(!request.Search.IsEmpty(), order => order.Name == request.Search || order.Code == request.Search) + .WhereIF(request.SysDate.HasValue,order=>order.SysDate == request.SysDate) + .OrderBy(order => order.CostDate,SqlSugar.OrderByType.Desc) + .Select((order, place, dishers, depart) => new GetMiniProgramOrderResponse + { + PlaceName = place.Name, + DepartmentName = depart.Name, + DishesName = dishers.Name, + },true) + .ToPageListAsync(request); + return page; + } + + public async Task SaveDetailAsync(SaveDetailRequest request) + { + if (!request.Id.HasValue) + { + var entity = request.Adapt(); + await _dbContext.InsertAsync(entity); + } + else + { + var entity = await _dbContext.Queryable() + .Where(x => x.Id == request.Id) + .FirstAsync(); + request.Adapt(entity); + await _dbContext.UpdateAsync(entity); + } + } + + public async Task> GetDetailAsync(GetDetailRequest request) + { + var page = await _dbContext.Queryable() + .WhereIF(!request.Search.IsEmpty(),x => x.ThirdNo == request.Search) + .Select() + .ToPageListAsync(request); + + return page; + } + + public async Task OrderAsync(OrderRequest request) + { + //判断时间 + DateTime currentTime = DateTime.Now; + TimeSpan ninePM = new TimeSpan(20, 30, 0); + if (currentTime.TimeOfDay > ninePM) + { + true.ThrowIfTrue("20:30之后无法订餐!"); + } + //判断营业日 + var dishes = await _dbContext.Queryable().Where(x => x.Code == request.DishesCode).FirstAsync(); + dishes.Enable.ThrowIfFalse($"{dishes.Name}没启用!"); + + var menu = await _dbContext.Queryable().Where(x => x.Code == request.MenuCode).FirstAsync(); + menu.Enable.ThrowIfFalse($"{dishes.Name}没启用!"); + + // 获取用餐日期 + DateOnly tomorrow = DateOnly.FromDateTime(DateTime.Today.AddDays(1)); + if (tomorrow != menu.StartDate) + { + true.ThrowIfTrue($"菜品:{dishes.Name}对应的菜单:{menu.Name}不在营业日!"); + } + + var restricted= await _dbContext.Queryable< CanteenMenuDishersRelationshipEntity>() + .Where(x => x.MenuCode == request.MenuCode && x.DishersCode == request.DishesCode).FirstAsync(); + restricted.ThrowIfNull($"每日菜单:{menu.Name} 还没有配置菜品:{dishes.Name} 的限售数量!"); + if (restricted.RestrictedNum < 0) + { + true.ThrowIfTrue($"菜品:{dishes.Name}已售罄!"); + } + + var gainfo = await _dbContext.Queryable() + .Where(x => x.Code == request.UserCode) + .FirstAsync(); + gainfo.ThrowIfNull($"用户{request.UserCode}无档案信息,无法订餐!"); + + //判断是否订过餐 + var flag = await _dbContext.Queryable() + .Where(x => x.SysDate == tomorrow && x.ShiftType == request.ShiftType && x.Code == request.UserCode && x.OrderStatus == MiniProgramOrderStatusEnumType.I) + .AnyAsync(); + flag.ThrowIfTrue($"工号:{request.UserCode} 姓名:{gainfo.Name} 已经定过{tomorrow}的{request.ShiftType.GetDescription()}!"); + + //支付方式 + /* var result = await _tenantApi.GetTenantTreeAsync(); + var tree = result.Data; + var shanxi = tree.Where(x => x.Name == "山西基地").FirstOrDefault(); + var codes = shanxi.Next.Select(x => x.Code).ToList(); + if (!codes.Contains(gainfo.Factory)) + { + if (request.PayType == CanteenPayEnumType.Repair) + { + true.ThrowIfTrue($"非山西,支付方式不能为{request.PayType.GetDescription()}"); + } + }*/ + + //生成订单 + var order = new MiniProgramOrderEntity + { + No = "O" + SnowFlakeHelper.Instance.NextId(), + Name = gainfo.Name, + Code = gainfo.Code, + Werks = gainfo.Werks, + DepartmentNo = gainfo.DepartmentNo, + CostId = gainfo.CostId, + Workplace = gainfo.Workplace, + Factory = gainfo.Factory, + PlaceCode = request.PlaceCode, + ShiftType = request.ShiftType, + DishesCode = request.DishesCode, + Phone = gainfo.Phone, + SysDate = tomorrow, + CostDate = DateTime.Now, + PayType = request.PayType, + OrderStatus = MiniProgramOrderStatusEnumType.I, + OrderType = dishes.Type, + }; + //生成订单明细 + var detail = new OrderDetailsEntity + { + ThirdNo = order.No, + SysDate = tomorrow, + ShiftType= request.ShiftType, + DishesCode= request.DishesCode, + DishesName = dishes.Name, + Price = dishes.Amount, + Unit = dishes.Unit, + Num = request.DishesNum, + Amount = request.DishesNum * dishes.Amount, + OrderStatus = OrderDetailsStatusEnumType.I, + }; + order.TotalAmount = detail.Amount; + await _dbContext.InsertAsync(order); + await _dbContext.InsertAsync(detail); + //扣减份数 + var effect = await _dbContext.Updateable() + .SetColumns(x => x.RestrictedNum == restricted.RestrictedNum - request.DishesNum) + .SetColumns(x => x.Version == x.Version + 1) + .Where(x => x.MenuCode == request.MenuCode && x.DishersCode == request.DishesCode && x.Version == restricted.Version) + .ExecuteCommandAsync(); + + if (effect <= 0) throw new VersionExceptions("更新版本冲突"); + } + +} diff --git a/Src/Dlhis.Canteen/appsettings.json b/Src/Dlhis.Canteen/appsettings.json index e8f2179e..75f2d95b 100644 --- a/Src/Dlhis.Canteen/appsettings.json +++ b/Src/Dlhis.Canteen/appsettings.json @@ -8,7 +8,8 @@ "AllowedHosts": "*", "InternalRequest": { "CommonRequestUrl": "http://common", - "BasicRequestUrl": "http://basic" + "BasicRequestUrl": "http://basic", + "SysRequestUrl": "http://sys" }, "FilterOptions": { "EnableApiRequestLog": true diff --git a/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceEntity.cs b/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceEntity.cs index 866f030a..429930a1 100644 --- a/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceEntity.cs @@ -1,6 +1,7 @@ using Dlhis.Entity.Canteen.Enums; using Kurisu.Core.DataAccess.Entity; using Kurisu.SqlSugar; +using Mapster; using SqlSugar; using SqlSugar.DbConvert; @@ -21,9 +22,15 @@ public class BusinessPlaceEntity : SugarBaseEntity, ITenantId /// /// 自定义代号 /// + [AdaptIgnore(MemberSide.Destination)] [SugarColumn(ColumnDescription = "自定义手工号")] public string CustomCode { get; set; } + /// + /// 供应商 + /// + [SugarColumn(ColumnDescription = "供应商")] + public string Supplier { get; set; } /// /// 营业点名称 diff --git a/Src/Dlhis.Entity/Basic/Entity/BusinessShiftEntity.cs b/Src/Dlhis.Entity/Basic/Entity/BusinessShiftEntity.cs index 9893a6c6..8964221f 100644 --- a/Src/Dlhis.Entity/Basic/Entity/BusinessShiftEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/BusinessShiftEntity.cs @@ -1,5 +1,6 @@ using Kurisu.Core.DataAccess.Entity; using Kurisu.SqlSugar; +using Mapster; using SqlSugar; namespace Dlhis.Entity.Basic.Entity; @@ -19,6 +20,7 @@ public class BusinessShiftEntity : SugarBaseEntity, ITenantId /// /// 自定义代号 /// + [AdaptIgnore(MemberSide.Destination)] [SugarColumn(ColumnDescription = "自定义手工号")] public string CustomCode { get; set; } diff --git a/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs b/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs index ddedd0ec..ed046e71 100644 --- a/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs @@ -1,6 +1,7 @@ using Dlhis.Entity.Device.Enums; using Kurisu.Core.DataAccess.Entity; using Kurisu.SqlSugar; +using Mapster; using SqlSugar; using SqlSugar.DbConvert; @@ -21,6 +22,7 @@ public class DeviceEntity : SugarBaseEntity, ITenantId /// /// 设备唯一码,IP/MAC/SNO /// + [AdaptIgnore(MemberSide.Destination)] [SugarColumn(ColumnDescription = "设备唯一码", IsNullable = false, UniqueGroupNameList = new[] { "Idx_Device_UniqueNo" })] public string UniqueNo { get; set; } diff --git a/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs b/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs new file mode 100644 index 00000000..8a993992 --- /dev/null +++ b/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs @@ -0,0 +1,65 @@ +using Dlhis.Entity.Basic.Enums; +using Kurisu.SqlSugar; +using SqlSugar; +using SqlSugar.DbConvert; + +namespace Dlhis.Entity.Basic.Entity; + +/// +/// 餐补记录 +/// +[SugarTable(TableName = "MealSupplementRecord", TableDescription = "餐补记录")] +public class MealSupplementRecordEntity : MealSupplementRequestRecordEntity +{ + /// + /// 唯一号 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "唯一号", UniqueGroupNameList = new[] { "idx_MealSupplementRecord_UniqueId" })] + public override string UniqueId { get; set; } + + /// + /// 工号 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "工号", IndexGroupNameList = new[] { "idx_MealSupplementRecord_Code" })] + public override string Code { get; set; } + + /// + /// 餐补状态 + /// + [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] + public MealSupplementStatusEnumtype Status { get; set; } +} + +[SugarTable(TableName = "MealSupplementRequestRecord", TableDescription = "餐补请求记录")] +public class MealSupplementRequestRecordEntity : SugarBaseEntity +{ + public virtual string UniqueId { get; set; } + + public virtual string Code { get; set; } + + /// + /// 考勤日期 + /// + [SugarColumn(ColumnDataType = "date", IsNullable = false, ColumnDescription = "考勤日期")] + public DateTime Date { get; set; } + + /// + /// 工作地 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "工作地")] + public string Workplace { get; set; } + + /// + /// 厂区 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "厂区")] + public string Factory { get; set; } + + public string Remark { get; set; } + + /// + /// 餐补 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "餐补")] + public decimal Amount { get; set; } +} diff --git a/Src/Dlhis.Entity/Basic/Entity/WerkEntity.cs b/Src/Dlhis.Entity/Basic/Entity/WerkEntity.cs index d3142388..845dc6bf 100644 --- a/Src/Dlhis.Entity/Basic/Entity/WerkEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/WerkEntity.cs @@ -16,4 +16,10 @@ public class WerkEntity : SugarBaseEntity /// 名称 /// public string Name { get; set; } + + /// + /// 是否启用 + /// + [SugarColumn(ColumnDataType = "bit", DefaultValue = "1")] + public bool Enable { get; set; } } diff --git a/Src/Dlhis.Entity/Basic/Enums/MealSupplementStatusEnumtype.cs b/Src/Dlhis.Entity/Basic/Enums/MealSupplementStatusEnumtype.cs new file mode 100644 index 00000000..6de28a57 --- /dev/null +++ b/Src/Dlhis.Entity/Basic/Enums/MealSupplementStatusEnumtype.cs @@ -0,0 +1,29 @@ +using System.ComponentModel; + +namespace Dlhis.Entity.Basic.Enums; + +/// +/// 餐补状态 +/// +[Description("餐补状态")] +public enum MealSupplementStatusEnumtype +{ + /// + /// 待核算 + /// + [Description("待核算")] + Wait = 0, + + + /// + /// 成功 + /// + [Description("成功")] + Sucess = 1, + + /// + /// 处理异常 + /// + [Description("处理异常")] + Error = 99 +} diff --git a/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs new file mode 100644 index 00000000..25dfd418 --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs @@ -0,0 +1,80 @@ +using Dlhis.Entity.Canteen.Enums; +using Kurisu.SqlSugar; +using SqlSugar; +using SqlSugar.DbConvert; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Dlhis.Entity.Canteen.Entities +{ + /// + /// 菜品表 + /// + [SugarTable(TableName = "CanteenDishes", TableDescription = "菜品表")] + public class CanteenDishesEntity : SugarBaseEntity + { + + /// + /// 大类 + /// + [SugarColumn(ColumnDescription = "大类")] + public string Categories { get; set; } + + /// + /// 小类 + /// + [SugarColumn(ColumnDescription = "小类")] + public string SubCategories { get; set; } + + /// + /// 菜品编码 + /// + [SugarColumn(ColumnDescription = "菜品编码")] + public Guid Code { get; set; } + + /// + /// 菜品名称 + /// + [SugarColumn(ColumnDescription = "菜品名称")] + public string Name { get; set; } + + /// + /// 类型 + /// + [SugarColumn(ColumnDescription = "类型", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] + public CanteenDishesEnumType Type { get; set; } + + /// + /// 描述 + /// + [SugarColumn(ColumnDescription = "描述")] + public string Description { get; set; } + + /// + /// 单价 + /// + [SugarColumn(ColumnDescription = "单价")] + public decimal Amount { get; set; } + + /// + /// 单位 + /// + [SugarColumn(ColumnDescription = "单位")] + public string Unit { get; set; } + + /// + /// 图片 + /// + [SugarColumn(ColumnDescription = "图片")] + public string Image { get; set; } + + /// + /// 是否启用 + /// + [SugarColumn(ColumnDataType = "bit", ColumnDescription = "是否启用")] + public bool Enable { get; set; } + } +} diff --git a/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuDishersRelationshipEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuDishersRelationshipEntity.cs new file mode 100644 index 00000000..da94aa3b --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuDishersRelationshipEntity.cs @@ -0,0 +1,32 @@ +using Kurisu.SqlSugar; +using SqlSugar; + +namespace Dlhis.Entity.Canteen.Entities +{ + /// + /// 菜单菜品表 + /// + [SugarTable(TableName = "CanteenMenuDishersRelationship", TableDescription = "菜单菜品表")] + public class CanteenMenuDishersRelationshipEntity : SugarBaseEntity + { + /// + /// 菜单code + /// + public Guid MenuCode { get; set; } + + /// + /// 菜品code + /// + public Guid DishersCode { get; set; } + + /// + /// 限售份数 + /// + public int RestrictedNum { get; set; } + + /// + /// 版本 + /// + public int Version { get; set; } + } +} diff --git a/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs new file mode 100644 index 00000000..03461d3a --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs @@ -0,0 +1,58 @@ +using Dlhis.Entity.Canteen.Enums; +using Kurisu.SqlSugar; +using SqlSugar; + +namespace Dlhis.Entity.Canteen.Entities; + +/// +/// 菜单表 +/// +[SugarTable(TableName = "CanteenMenu", TableDescription = "菜单表")] +public class CanteenMenuEntity : SugarBaseEntity +{ + + /// + /// 菜单编码 + /// + [SugarColumn(ColumnDescription = "菜单编码")] + public Guid Code { get; set; } + + /// + /// 菜单名称 + /// + [SugarColumn(ColumnDescription = "菜单名称")] + public string Name { get; set; } + + /// + /// 所属营业点 + /// + [SugarColumn(ColumnDescription = "所属营业点")] + public Guid PlaceCode { get; set; } + + /// + /// 厂区 + /// + [SugarColumn(ColumnDescription = "厂区")] + public string Factory { get; set; } + + /// + /// 营业日期 + /// + [SugarColumn(ColumnDescription = "营业日期")] + public DateOnly StartDate { get; set; } + + + /// + /// 餐次段 + /// + [SugarColumn(ColumnDataType = "varchar(150)", IsJson = true, ColumnDescription = "餐次段", DefaultValue = "[]")] + public List ShiftTypes { get; set; } + + /// + /// 是否启用 + /// + [SugarColumn(ColumnDataType = "bit", ColumnDescription = "是否启用")] + public bool Enable { get; set; } +} + + diff --git a/Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs new file mode 100644 index 00000000..13ba9fed --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs @@ -0,0 +1,122 @@ +using Dlhis.Entity.Canteen.Enums; +using Kurisu.SqlSugar; +using SqlSugar; +using SqlSugar.DbConvert; + +namespace Dlhis.Entity.Canteen.Entities +{ + /// + /// 小程序订单表 + /// + [SugarTable(TableName = "MiniProgramOrder", TableDescription = "小程序订单表")] + public class MiniProgramOrderEntity : SugarBaseEntity + { + /// + /// 订单号 + /// + [SugarColumn(ColumnDescription = "订单号")] + public string No { get; set; } + + /// + /// 姓名 + /// + [SugarColumn(ColumnDescription = "姓名")] + public string Name { get; set; } + + /// + /// 工号 + /// + [SugarColumn(ColumnDescription = "工号")] + public string Code { get; set; } + + /// + /// 人事范围 + /// + [SugarColumn(ColumnDescription = "人事范围")] + public string Werks { get; set; } + + /// + /// 部门编码 + /// + [SugarColumn(ColumnDescription = "部门编码")] + public string DepartmentNo { get; set; } + + /// + /// 成本中心 + /// + [SugarColumn(ColumnDescription = "成本中心")] + public string CostId { get; set; } + + /// + /// 工作地 + /// + [SugarColumn(ColumnDescription = "工作地")] + public string Workplace { get; set; } + + /// + /// 厂区 + /// + [SugarColumn(ColumnDescription = "厂区")] + public string Factory { get; set; } + + /// + /// 营业点 + /// + [SugarColumn(ColumnDescription = "营业点")] + public Guid PlaceCode { get; set; } + + /// + /// 餐次 + /// + [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "餐次")] + public ShiftEnumType ShiftType { get; set; } + + /// + /// 菜品 + /// + [SugarColumn(ColumnDescription = "菜品")] + public Guid DishesCode { get; set; } + + /// + /// 手机号码 + /// + [SugarColumn(ColumnDescription = "手机号码")] + public string Phone { get; set; } + + /// + /// 用餐日期 + /// + [SugarColumn(ColumnDescription = "用餐日期")] + public DateOnly SysDate { get; set; } + + /// + /// 下单时间 + /// + [SugarColumn(ColumnDescription = "下单时间")] + public DateTime CostDate { get; set; } + + /// + /// 支付方式 + /// + [SugarColumn(ColumnDescription = "支付方式", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] + public CanteenPayEnumType PayType { get; set; } + + /// + /// 订单状态 + /// + [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "订单状态")] + public MiniProgramOrderStatusEnumType OrderStatus { get; set; } + + /// + /// 订单类型 + /// + [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "订单类型")] + public CanteenDishesEnumType OrderType { get; set; } + + /// + /// 总金额 + /// + [SugarColumn(ColumnDescription = "总金额")] + public decimal TotalAmount { get; set; } + } +} diff --git a/Src/Dlhis.Entity/Canteen/Entities/OrderDetailsEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/OrderDetailsEntity.cs new file mode 100644 index 00000000..7ba082e5 --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Entities/OrderDetailsEntity.cs @@ -0,0 +1,74 @@ +using Dlhis.Entity.Canteen.Enums; +using Kurisu.SqlSugar; +using SqlSugar; +using SqlSugar.DbConvert; + +namespace Dlhis.Entity.Canteen.Entities +{ + /// + /// 订餐明细表 + /// + [SugarTable(TableName = "OrderDetails", TableDescription = "订餐明细表")] + public class OrderDetailsEntity : SugarBaseEntity + { + /// + /// 订单号 + /// + [SugarColumn(ColumnDescription = "订单号")] + public string ThirdNo { get; set; } + + /// + /// 营业日(用餐日期) + /// + [SugarColumn(ColumnDescription = "营业日")] + public DateOnly SysDate { get; set; } + + /// + /// 餐次 + /// + [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "餐次")] + public ShiftEnumType ShiftType { get; set; } + + /// + /// 菜品编码 + /// + [SugarColumn(ColumnDescription = "菜品编码")] + public Guid DishesCode { get; set; } + + /// + /// 菜品名称 + /// + [SugarColumn(ColumnDescription = "菜品名称")] + public string DishesName { get; set; } + + /// + /// 单价 + /// + [SugarColumn(ColumnDescription = "单价")] + public decimal Price { get; set; } + + /// + /// 单位 + /// + [SugarColumn(ColumnDescription = "单位")] + public string Unit { get; set; } + + /// + /// 数量 + /// + [SugarColumn(ColumnDescription = "数量")] + public int Num { get; set; } + + /// + /// 金额 + /// + [SugarColumn(ColumnDescription = "金额")] + public decimal Amount { get; set; } + + /// + /// 订单明细状态 + /// + [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "订单明细状态")] + public OrderDetailsStatusEnumType OrderStatus { get; set; } + } +} diff --git a/Src/Dlhis.Entity/Canteen/Enums/CanteenDishesEnumType.cs b/Src/Dlhis.Entity/Canteen/Enums/CanteenDishesEnumType.cs new file mode 100644 index 00000000..dc3ba103 --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Enums/CanteenDishesEnumType.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Dlhis.Entity.Canteen.Enums +{ + /// + /// 菜品类型 + /// + [Description("菜品类型")] + public enum CanteenDishesEnumType + { + + /// + /// 订餐 + /// + [Description("订餐")] + Order = 1, + + /// + /// 扫码点餐 + /// + [Description("扫码点餐")] + QrCode=2, + + /// + /// 通用 + /// + [Description("通用")] + General = 3, + } +} diff --git a/Src/Dlhis.Entity/Canteen/Enums/CanteenPayEnumType.cs b/Src/Dlhis.Entity/Canteen/Enums/CanteenPayEnumType.cs new file mode 100644 index 00000000..72218726 --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Enums/CanteenPayEnumType.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Dlhis.Entity.Canteen.Enums +{ + /// + /// 支付方式 + /// + [Description("支付方式")] + public enum CanteenPayEnumType + { + /// + /// 餐补 + /// + [Description("餐补")] + Repair = 1, + + /// + /// 现场 + /// + [Description("现场")] + Scene = 2, + } +} diff --git a/Src/Dlhis.Entity/Canteen/Enums/MiniProgramOrderStatusEnumType.cs b/Src/Dlhis.Entity/Canteen/Enums/MiniProgramOrderStatusEnumType.cs new file mode 100644 index 00000000..56eb9ba1 --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Enums/MiniProgramOrderStatusEnumType.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Dlhis.Entity.Canteen.Enums +{ + public enum MiniProgramOrderStatusEnumType + { + /// + /// 有效 + /// + [Description("有效")] + I = 1, + + /// + /// 取消 + /// + [Description("取消")] + C = 2, + + /// + /// 退单 + /// + [Description("退单")] + X = 3, + + /// + /// 免单 + /// + [Description("免单")] + Z = 4, + } +} diff --git a/Src/Dlhis.Entity/Canteen/Enums/OrderDetailsStatusEnumType.cs b/Src/Dlhis.Entity/Canteen/Enums/OrderDetailsStatusEnumType.cs new file mode 100644 index 00000000..0012812e --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Enums/OrderDetailsStatusEnumType.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Dlhis.Entity.Canteen.Enums +{ + /// + /// 订单明细状态 + /// + [Description("订单明细状态")] + public enum OrderDetailsStatusEnumType + { + /// + /// 有效 + /// + [Description("有效")] + I = 1, + } +} diff --git a/Src/Dlhis.Entity/Canteen/Enums/ShiftEnumType.cs b/Src/Dlhis.Entity/Canteen/Enums/ShiftEnumType.cs new file mode 100644 index 00000000..d760412a --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Enums/ShiftEnumType.cs @@ -0,0 +1,41 @@ +using System.ComponentModel; + +namespace Dlhis.Entity.Canteen.Enums +{ + /// + /// 餐次 + /// + [Description("餐次")] + public enum ShiftEnumType + { + /// + /// 早餐 + /// + [Description("早餐")] + Breakfast = 1, + + /// + /// 午餐 + /// + [Description("午餐")] + Lunch = 2, + + /// + /// 晚餐 + /// + [Description("晚餐")] + Dinner = 3, + + /// + /// 宵夜 + /// + [Description("宵夜")] + Nightsnack = 4, + + /// + /// 凌晨餐 + /// + [Description("凌晨餐")] + Midnightsnack = 5, + } +} \ No newline at end of file diff --git a/Src/Dlhis.Entity/Common/ApkFileEntity.cs b/Src/Dlhis.Entity/Common/ApkFileEntity.cs index 2c15bf57..e32c5bf9 100644 --- a/Src/Dlhis.Entity/Common/ApkFileEntity.cs +++ b/Src/Dlhis.Entity/Common/ApkFileEntity.cs @@ -42,7 +42,7 @@ public class ApkFileEntity : SugarBaseEntity /// 产品代码 /// [SugarColumn(ColumnDescription = "产品代码")] - public string? ProductCode { get; set; } + public string ProductCode { get; set; } } diff --git a/Src/Dlhis.Entity/Device/Entities/DeviceTaskEntity.cs b/Src/Dlhis.Entity/Device/Entities/DeviceTaskEntity.cs index 22d404b6..93ba3b54 100644 --- a/Src/Dlhis.Entity/Device/Entities/DeviceTaskEntity.cs +++ b/Src/Dlhis.Entity/Device/Entities/DeviceTaskEntity.cs @@ -47,5 +47,11 @@ public class DeviceTaskEntity : SugarBaseEntity, ITenantId, IVersion [SugarColumn(ColumnDataType = "longtext")] public string ResultMessage { get; set; } + /// + /// 取消id + /// + public long CancellationId { get; set; } + + public string TenantId { get; set; } } diff --git a/Src/Dlhis.Entity/Device/Enums/DeviceTaskStatusEnumType.cs b/Src/Dlhis.Entity/Device/Enums/DeviceTaskStatusEnumType.cs index 3c2009af..9b9cc18c 100644 --- a/Src/Dlhis.Entity/Device/Enums/DeviceTaskStatusEnumType.cs +++ b/Src/Dlhis.Entity/Device/Enums/DeviceTaskStatusEnumType.cs @@ -26,6 +26,13 @@ public enum DeviceTaskStatusEnumType [Description("下发完成")] Success = 10, + + /// + /// 取消 + /// + [Description("取消")] + Cancel = 95, + /// /// 异常 /// diff --git a/Src/Dlhis.External/Dlhis.External.csproj b/Src/Dlhis.External/Dlhis.External.csproj new file mode 100644 index 00000000..e89418db --- /dev/null +++ b/Src/Dlhis.External/Dlhis.External.csproj @@ -0,0 +1,24 @@ + + + + net6.0 + disable + enable + Linux + ..\.. + + + + + + + + + + + + + + + + diff --git a/Src/Dlhis.External/Dockerfile b/Src/Dlhis.External/Dockerfile new file mode 100644 index 00000000..8a640cee --- /dev/null +++ b/Src/Dlhis.External/Dockerfile @@ -0,0 +1,24 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +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/"] +RUN dotnet restore "./Src/Dlhis.External/./Dlhis.External.csproj" +COPY . . +WORKDIR "/src/Src/Dlhis.External" +RUN dotnet build "./Dlhis.External.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./Dlhis.External.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Dlhis.External.dll"] \ No newline at end of file diff --git a/Src/Dlhis.External/MealSupplement/Channel/MealSupplementHandler.cs b/Src/Dlhis.External/MealSupplement/Channel/MealSupplementHandler.cs new file mode 100644 index 00000000..25622039 --- /dev/null +++ b/Src/Dlhis.External/MealSupplement/Channel/MealSupplementHandler.cs @@ -0,0 +1,37 @@ +using Dlhis.Entity.Basic.Entity; +using Dlhis.External.MealSupplement.Request; +using Kurisu.AspNetCore.EventBus.Abstractions; +using Kurisu.AspNetCore.EventBus.Abstractions.Handler; +using Kurisu.SqlSugar.Services; +using Mapster; + +namespace Dlhis.External.MealSupplement.Channel; + +public class MealSupplementHandler : IAsyncChannelHandler +{ + private readonly IServiceProvider _serviceProvider; + + public MealSupplementHandler(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + public async Task InvokeAsync(MealSupplementMessage message) + { + using (var scope = _serviceProvider.CreateScope()) + { + var db = scope.ServiceProvider.GetService(); + + var existsIds = await db.Queryable().Select(x => x.UniqueId).ToListAsync(); + var items = message.Items.Where(x => !existsIds.Contains(x.UniqueId)).ToList(); + + var entities = items.Adapt>(); + await db.InsertAsync(entities); + } + } +} + +public class MealSupplementMessage : IAsyncChannelMessage +{ + public List Items { get; set; } +} diff --git a/Src/Dlhis.External/MealSupplement/Controller/MealSupplementsController.cs b/Src/Dlhis.External/MealSupplement/Controller/MealSupplementsController.cs new file mode 100644 index 00000000..5f0d9b6c --- /dev/null +++ b/Src/Dlhis.External/MealSupplement/Controller/MealSupplementsController.cs @@ -0,0 +1,27 @@ +using Dlhis.External.MealSupplement.Request; +using Dlhis.External.MealSupplement.Services; +using Microsoft.AspNetCore.Mvc; + +namespace Dlhis.External.MealSupplement.Controller; + +[Route("api/[controller]")] +[ApiController] +public class MealSupplementsController : ControllerBase +{ + private readonly IMealSupplementService _mealSupplementService; + + public MealSupplementsController(IMealSupplementService mealSupplementService) + { + _mealSupplementService = mealSupplementService; + } + + /// + /// 接受餐补 + /// + /// + [HttpPost("receive")] + public async Task DoSupplements(List reuqests) + { + await _mealSupplementService.DoSupplementsAsync(reuqests); + } +} diff --git a/Src/Dlhis.External/MealSupplement/Request/MealSupplementReceiveReuqest.cs b/Src/Dlhis.External/MealSupplement/Request/MealSupplementReceiveReuqest.cs new file mode 100644 index 00000000..c9bdc4de --- /dev/null +++ b/Src/Dlhis.External/MealSupplement/Request/MealSupplementReceiveReuqest.cs @@ -0,0 +1,45 @@ +using System.ComponentModel.DataAnnotations; + +namespace Dlhis.External.MealSupplement.Request; + +public class MealSupplementReceiveReuqest +{ + /// + /// 唯一号 + /// + [Required(ErrorMessage = "唯一号必填")] + public string UniqueId { get; set; } + + /// + /// 工号 + /// + [Required(ErrorMessage = "工号必填")] + public string Code { get; set; } + + /// + /// 考勤日期 + /// + public DateTime Date { get; set; } + + /// + /// 工作地 + /// + [Required(ErrorMessage = "工作地")] + public string Workplace { get; set; } + + /// + /// 厂区 + /// + [Required(ErrorMessage = "厂区")] + public string Factory { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 餐补 + /// + public decimal Amount { get; set; } +} diff --git a/Src/Dlhis.External/MealSupplement/Services/IMealSupplementService.cs b/Src/Dlhis.External/MealSupplement/Services/IMealSupplementService.cs new file mode 100644 index 00000000..9c186dca --- /dev/null +++ b/Src/Dlhis.External/MealSupplement/Services/IMealSupplementService.cs @@ -0,0 +1,8 @@ +using Dlhis.External.MealSupplement.Request; + +namespace Dlhis.External.MealSupplement.Services; + +public interface IMealSupplementService : IScopeDependency +{ + Task DoSupplementsAsync(List reuqests); +} diff --git a/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs b/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs new file mode 100644 index 00000000..701b9430 --- /dev/null +++ b/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs @@ -0,0 +1,26 @@ +using Dlhis.Entity.Basic.Entity; +using Dlhis.External.MealSupplement.Channel; +using Dlhis.External.MealSupplement.Request; +using Kurisu.AspNetCore.EventBus.Abstractions; +using Kurisu.SqlSugar.Services; +using Mapster; + +namespace Dlhis.External.MealSupplement.Services.Implements; + +public class MealSupplementService : IMealSupplementService +{ + private readonly IEventBus _eventBus; + private readonly IDbContext _dbContext; + + public MealSupplementService(IEventBus eventBus, IDbContext dbContext) + { + _eventBus = eventBus; + _dbContext = dbContext; + } + + public async Task DoSupplementsAsync(List reuqests) + { + await _dbContext.InsertAsync(reuqests.Adapt>()); + await _eventBus.PublishAsync(new MealSupplementMessage { Items = reuqests }); + } +} diff --git a/Src/Dlhis.External/Program.cs b/Src/Dlhis.External/Program.cs new file mode 100644 index 00000000..8ed604e2 --- /dev/null +++ b/Src/Dlhis.External/Program.cs @@ -0,0 +1,29 @@ +using Kurisu.AspNetCore.EventBus.Extensions; +using Kurisu.AspNetCore.Startup; +using Kurisu.SqlSugar.Extensions; +using Kurisu.Startup; +using Microsoft.IdentityModel.Logging; + +class Program +{ + static void Main(string[] args) + { + KurisuHost.Run(true, args); + } +} + +public class Startup : DefaultStartup +{ + public Startup(IConfiguration configuration) : base(configuration) + { + IdentityModelEventSource.ShowPII = true; + } + + public override void ConfigureServices(IServiceCollection services) + { + base.ConfigureServices(services); + + services.AddSqlSugar(); + services.AddEventBus(); + } +} \ No newline at end of file diff --git a/Src/Dlhis.External/Properties/launchSettings.json b/Src/Dlhis.External/Properties/launchSettings.json new file mode 100644 index 00000000..a31280e1 --- /dev/null +++ b/Src/Dlhis.External/Properties/launchSettings.json @@ -0,0 +1,13 @@ +{ + "profiles": { + "Dlhis.External": { + "commandName": "Project", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5020" + } + }, + "$schema": "https://json.schemastore.org/launchsettings.json" +} \ No newline at end of file diff --git a/Src/Dlhis.External/appsettings.Development.json b/Src/Dlhis.External/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/Src/Dlhis.External/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Src/Dlhis.External/appsettings.json b/Src/Dlhis.External/appsettings.json new file mode 100644 index 00000000..1b75d34f --- /dev/null +++ b/Src/Dlhis.External/appsettings.json @@ -0,0 +1,72 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "SqlSugarOptions": { + "DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;", + "SlaveConnectionString": [], + "Timeout": 30, + "SlowSqlTime": 1, + "EnableSqlLog": false + }, + "SwaggerOptions": { + "Enable": true, + "Authority": "http://identity.oauth.svc.cluster.local", + "ClientId": "4fb184324eac4180", + "ClientSecret": "8ac8f235152f1524", + "Scopes": { + "openid": "openid", + "profile": "profile", + "yikatong": "yikatong" + } + }, + "IdentityServerOptions": { + "Authority": "http://identity.oauth.svc.cluster.local", + "RequireHttpsMetadata": false, + "Issuer": "identity.isawesome.cn", + "Audience": "", + "Pat": { + "Enable": false, + "Scheme": "token", + "ClientId": "reference", + "ClientSecret": "123456" + } + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "WriteTo": [ + { + "Name": "Async", + "Args": { + "configure": [ + { + "Name": "Console", + "Args": { + "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "MySQL", + "Args": { + "connectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=log;charset=utf8mb4;", + "tableName": "Logs", + "autoCreateSqlTable": true + } + } + ] + } + } + ] + } +} diff --git a/Src/Dlhis.ScheduledTask/CommonJobs/CancelDuplicationTaskJob.cs b/Src/Dlhis.ScheduledTask/CommonJobs/CancelDuplicationTaskJob.cs new file mode 100644 index 00000000..b701c93e --- /dev/null +++ b/Src/Dlhis.ScheduledTask/CommonJobs/CancelDuplicationTaskJob.cs @@ -0,0 +1,165 @@ +using Dlhis.Entity.Device.Entities; +using Dlhis.Entity.Device.Enums; +using Kurisu.AspNetCore.Utils.Extensions; +using Kurisu.Core.DataAccess.Entity; +using Kurisu.SqlSugar.Services; +using SqlSugar; +using System.Linq.Expressions; + +namespace Dlhis.ScheduledTask.CommonJobs; + +public class CancelDuplicationTaskJob +{ + private readonly IServiceProvider _serviceProvider; + private readonly ILogger _logger; + + public CancelDuplicationTaskJob(IServiceProvider serviceProvider, ILogger logger) + { + _serviceProvider = serviceProvider; + _logger = logger; + } + + public async Task RunAsync() + { + _logger.LogInformation("抵消任务开始处理"); + + using (var scope = _serviceProvider.CreateScope()) + { + var optionService = scope.ServiceProvider.GetService(); + var db = scope.ServiceProvider.GetService(); + + db.Client.QueryFilter.ClearAndBackup(); + optionService.IgnoreTenant = true; + try + { + //人员下发任务相关 + var taskTypes = new List() { DeviceTaskEnumType.Add, DeviceTaskEnumType.Delete, DeviceTaskEnumType.Update }; + + var deviceTasks = await db.Queryable() + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait)//没有被获取 + .Where(x => taskTypes.Contains(x.Type)) + .OrderBy(x => x.CreateTime, OrderByType.Desc) + .ToListAsync(); + + var groupData = deviceTasks.GroupBy(x => new { x.TenantId, x.UserNo, x.DeviceUniqueNo }); + foreach (var deviceTaskPack in groupData) + { + var uniqueInfo = deviceTaskPack.Key; + var data = deviceTaskPack.ToList(); + + + foreach (var item in data) + { + try + { + Expression> where = LinqExpressionExtension.False(); + var ignoreData = new List(); + //最新一条更新人员信息 + if (item.Type == DeviceTaskEnumType.Update && item.Status == DeviceTaskStatusEnumType.Wait) + { + //获取过往的更新人员任务 + ignoreData = data.Where(x => x.Type == DeviceTaskEnumType.Update) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .Where(x => x.Id != item.Id) + .Where(x => item.CreateTime > x.CreateTime) + .Select(x => new IdVersion { Id = x.Id, Version = x.Version }).ToList(); + } + //最新一条删除人员信息 + else if (item.Type == DeviceTaskEnumType.Delete && item.Status == DeviceTaskStatusEnumType.Wait) + { + //存在成功下发的任务,此处可以直接把其他任务取消 + if (await db.Queryable().Where(x => x.UserNo == item.UserNo) + .Where(x => x.DeviceUniqueNo == item.DeviceUniqueNo) + .Where(x => x.TenantId == item.TenantId).Where(x => x.Status == DeviceTaskStatusEnumType.Success).AnyAsync()) + { + ignoreData.AddRange(data.Where(x => x.Type == DeviceTaskEnumType.Add + || x.Type == DeviceTaskEnumType.Delete + || x.Type == DeviceTaskEnumType.Update) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .Where(x => x.Id != item.Id) + .Where(x => item.CreateTime > x.CreateTime) + .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) + ); + } + else + { + var currentIds = new List { item.Id }; + var beforeTask = data.Where(x => x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Update) + .Where(x => !currentIds.Contains(x.Id)) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .Where(x => item.CreateTime > x.CreateTime) + .FirstOrDefault(); + + //逻辑正确,最终beforeTask.type == DeviceTaskEnumType.Add + while (beforeTask != null && beforeTask.Type == DeviceTaskEnumType.Update) + { + ignoreData.Add(new IdVersion() { Id = beforeTask.Id, Version = beforeTask.Version }); + currentIds.Add(beforeTask.Id); + + beforeTask = data.Where(x => x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Update) + .Where(x => !currentIds.Contains(x.Id)) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .Where(x => item.CreateTime > x.CreateTime) + .FirstOrDefault(); + } + + if (beforeTask != null) + { + ignoreData.Add(new IdVersion() { Id = beforeTask.Id, Version = beforeTask.Version }); + ignoreData.Add(new IdVersion() { Id = item.Id, Version = item.Version }); + } + } + } + + if (ignoreData.Any()) + { + ignoreData.ForEach(p => + { + where = where.Or(x => x.Id == p.Id && x.Version == p.Version && x.Status == DeviceTaskStatusEnumType.Wait); + }); + + await db.Updateable() + .SetColumns(x => x.Version == x.Version + 1) + .SetColumns(x => x.Status == DeviceTaskStatusEnumType.Cancel) + .SetColumns(x => x.CancellationId == item.Id) + .SetColumns(x => x.ModifiedTime == DateTime.Now) + .Where(where) + .ExecuteCommandAsync(); + + data.ForEach(x => + { + if (ignoreData.Any(p => p.Id == x.Id)) + x.Status = DeviceTaskStatusEnumType.Cancel; + }); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "抵消处理异常:{message}", ex.Message); + } + } + } + } + catch (Exception ex) + { + _logger.LogError(ex, "抵消处理异常:{message}", ex.Message); + } + finally + { + db.Client.QueryFilter.Restore(); + optionService.IgnoreTenant = false; + } + } + + + _logger.LogInformation("抵消任务处理完成"); + } + + class IdVersion + { + public long Id { get; set; } + public int Version { get; set; } + } + +} + diff --git a/Src/Dlhis.ScheduledTask/Packs/JobPack.cs b/Src/Dlhis.ScheduledTask/Packs/JobPack.cs index d7391825..bacad69f 100644 --- a/Src/Dlhis.ScheduledTask/Packs/JobPack.cs +++ b/Src/Dlhis.ScheduledTask/Packs/JobPack.cs @@ -53,10 +53,16 @@ public class JobPack : BaseAppPack TimeZone = TimeZoneInfo.Local }); + //处理重复下发任务 + RecurringJob.AddOrUpdate("CancelDuplicationTask", s => s.RunAsync(), "0/15 * * * * ?", new RecurringJobOptions + { + TimeZone = TimeZoneInfo.Local + }); + + RecurringJob.AddOrUpdate("TempCreateUser", s => s.RunAsync(), "0 0 5 * * ?", new RecurringJobOptions { TimeZone = TimeZoneInfo.Local }); - } } diff --git a/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoSapService.cs b/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoSapService.cs index 1b893898..9d25a50b 100644 --- a/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoSapService.cs +++ b/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoSapService.cs @@ -65,7 +65,7 @@ public class JinkoSapService : IJinkoSapService { var apiUrl = "/RESTAdapter/Rest/EHR_PERSONNEL/"; - var werks = await _dbContext.Queryable().ToListAsync(); + var werks = await _dbContext.Queryable().Where(x => x.Enable).ToListAsync(); List persons = new(); List jobInfos = new(); diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs index fee03043..ed69bfdb 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs @@ -7,21 +7,18 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Request; public class DeviceTaskAssignmentRequest : PageDto { /// - /// 设备类型 + /// 设备类型 DeviceTypeEnumType /// [EnumDataType(typeof(DeviceTypeEnumType))] public DeviceTypeEnumType? Type { get; set; } - /// /// 任务类型 /// - [EnumDataType(typeof(DeviceTaskEnumType))] - public DeviceTaskEnumType? TaskType { get; set; } + public List TaskTypes { get; set; } /// - /// 任务下发状态 + /// 任务下发状态 DeviceTaskStatusEnumType /// - [EnumDataType(typeof(DeviceTaskStatusEnumType))] - public DeviceTaskStatusEnumType? Status { get; set; } + public List Status { get; set; } } diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs index fc9e74d2..d594c37d 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskAssignmentResponse.cs @@ -1,6 +1,5 @@ using Dlhis.Entity.Device.Enums; using Kurisu.AspNetCore.Utils.Extensions; -using SqlSugar; namespace Dlhis.ScheduledTask.TaskAssignment.Response; @@ -83,14 +82,4 @@ public class DeviceTaskAssignmentResponse /// 部署点 /// public string DeployPlace { get; set; } - - /// - /// 连接信息 - /// - public string ConnectionInfo { get; set; } - - /// - /// 设备名称 - /// - public string DeviceName { get; set; } } diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs index 0138667d..cec44059 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs @@ -28,15 +28,15 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService var page = await _dbContext.Queryable() .LeftJoin((deviceTask, ga) => deviceTask.UserNo == ga.No) .LeftJoin((deviceTask, ga, device) => deviceTask.DeviceUniqueNo == device.UniqueNo) - .WhereIF(!request.Search.IsEmpty(), (deviceTask, ga, device) => - deviceTask.UserNo == request.Search - || ga.Name.Contains(request.Search) - || ga.Code == request.Search + .WhereIF(!request.Search.IsEmpty(), (deviceTask, ga, device) => + deviceTask.UserNo == request.Search + || ga.Name.Contains(request.Search) + || ga.Code == request.Search || deviceTask.DeviceUniqueNo == request.Search ) - .WhereIF(request.TaskType.HasValue, deviceTask => deviceTask.Type == request.TaskType) + .WhereIF(request.TaskTypes.IsPresent(), deviceTask => request.TaskTypes.Contains(deviceTask.Type)) .WhereIF(request.Type.HasValue, (deviceTask, ga, device) => device.Type == request.Type) - .WhereIF(request.Status.HasValue, deviceTask => deviceTask.Status == request.Status) + .WhereIF(request.Status.IsPresent(), deviceTask => request.Status.Contains(deviceTask.Status)) .Where(deviceTask => 1 == 1) .OrderBy(deviceTask => deviceTask.CreateTime, OrderByType.Desc) .Select((deviceTask, ga, device) => new DeviceTaskAssignmentResponse @@ -54,8 +54,6 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService LastUpdateTime = deviceTask.ModifiedTime, TenantId = deviceTask.TenantId, DeployPlace = device.DeployPlace, - ConnectionInfo = device.ConnectionInfo, - DeviceName = device.Supplier }) .ToPageListAsync(request); diff --git a/Src/Gateway/Gateway.csproj b/Src/Gateway/Gateway.csproj index 82f8dae2..4dc2203d 100644 --- a/Src/Gateway/Gateway.csproj +++ b/Src/Gateway/Gateway.csproj @@ -10,6 +10,8 @@ + + diff --git a/Src/Gateway/Program.cs b/Src/Gateway/Program.cs index b3ba8e28..5e1e7a63 100644 --- a/Src/Gateway/Program.cs +++ b/Src/Gateway/Program.cs @@ -1,16 +1,19 @@ -using Ocelot.DependencyInjection; -using Ocelot.Middleware; -var builder = WebApplication.CreateBuilder(args); -builder.Configuration.AddJsonFile("ocelot.json", true, true); -// Add services to the container. +using Gateway; -builder.Services.AddOcelot(); - -var app = builder.Build(); - -// Configure the HTTP request pipeline. - -app.UseOcelot().Wait(); - -app.Run(); +public class Program +{ + public static void Main(string[] args) + { + Host.CreateDefaultBuilder(args) + .ConfigureAppConfiguration(builder => + { + builder.AddJsonFile("ocelot.json", true, true); + }) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .Build().Run(); + } +} diff --git a/Src/Gateway/Startup.cs b/Src/Gateway/Startup.cs new file mode 100644 index 00000000..87d10f71 --- /dev/null +++ b/Src/Gateway/Startup.cs @@ -0,0 +1,41 @@ +using Microsoft.OpenApi.Models; +using Ocelot.DependencyInjection; +using Ocelot.Middleware; + +namespace Gateway; + +public class Startup +{ + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + public void ConfigureServices(IServiceCollection services) + { + services.AddEndpointsApiExplorer(); + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "Gateway API", Version = "v1", Description = "# gateway api..." }); + }); + + services.AddOcelot(); + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.UseSwagger(); + app.UseSwaggerUI(c => + { + var services = Configuration.GetSection("Services").Get>(); + foreach (var s in services) + { + c.SwaggerEndpoint($"/{s.ToLower()}/swagger/v1/swagger.json", s); + } + }); + app.UseOcelot().Wait(); + } + +} diff --git a/Src/Gateway/appsettings.json b/Src/Gateway/appsettings.json index 10f68b8c..68b1359a 100644 --- a/Src/Gateway/appsettings.json +++ b/Src/Gateway/appsettings.json @@ -5,5 +5,13 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "Services": [ + "Basic", + "Common", + "Canteen", + "Scheduled", + "User", + "Sys" + ] } diff --git a/Src/Gateway/ocelot.json b/Src/Gateway/ocelot.json index 46e3b225..52cdcdf4 100644 --- a/Src/Gateway/ocelot.json +++ b/Src/Gateway/ocelot.json @@ -84,6 +84,17 @@ "Port": 31007 } ] + }, + { + "UpstreamPathTemplate": "/{url}/swagger/v1/swagger.json", + "DownstreamPathTemplate": "/{url}/swagger/v1/swagger.json", + "DownstreamScheme": "https", + "DownstreamHostAndPorts": [ + { + "Host": "yikatong.isawesome.cn", + "Port": 443 + } + ] } ], "GlobalConfiguration": {}