From 20cf421a3c773b7cb077f38055a52c3d6aad0157 Mon Sep 17 00:00:00 2001 From: cheche <717840555@qq.com> Date: Wed, 13 Mar 2024 14:20:52 +0800 Subject: [PATCH 01/23] =?UTF-8?q?feat=20=E8=8F=9C=E5=8D=95=E8=8F=9C?= =?UTF-8?q?=E5=93=81=E5=AE=9E=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Canteen/Entities/CanteenDishesEntity.cs | 91 +++++++++++++ .../Canteen/Entities/CanteenMenuEntity.cs | 67 ++++++++++ .../Entities/MiniProgramOrderEntity.cs | 120 ++++++++++++++++++ .../Canteen/Entities/OrderDetailsEntity.cs | 79 ++++++++++++ .../Canteen/Enums/CanteenDishesEnumType.cs | 35 +++++ .../Canteen/Enums/CanteenPayEnumType.cs | 28 ++++ .../Enums/MiniProgramOrderStatusEnumType.cs | 36 ++++++ .../Enums/OrderDetailsStatusEnumType.cs | 22 ++++ 8 files changed, 478 insertions(+) create mode 100644 Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs create mode 100644 Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs create mode 100644 Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs create mode 100644 Src/Dlhis.Entity/Canteen/Entities/OrderDetailsEntity.cs create mode 100644 Src/Dlhis.Entity/Canteen/Enums/CanteenDishesEnumType.cs create mode 100644 Src/Dlhis.Entity/Canteen/Enums/CanteenPayEnumType.cs create mode 100644 Src/Dlhis.Entity/Canteen/Enums/MiniProgramOrderStatusEnumType.cs create mode 100644 Src/Dlhis.Entity/Canteen/Enums/OrderDetailsStatusEnumType.cs diff --git a/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs new file mode 100644 index 00000000..b1136216 --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs @@ -0,0 +1,91 @@ +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 Guid MenuCode { get; set; } + + /// + /// 大类 + /// + [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 int RestrictedNum { 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/CanteenMenuEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs new file mode 100644 index 00000000..1973fecd --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs @@ -0,0 +1,67 @@ +using Kurisu.SqlSugar; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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(ColumnDescription = "结束日期")] + public DateOnly EndDate { get; set; } + + /// + /// 餐次段 + /// + [SugarColumn(ColumnDescription = "餐次段", IsNullable = true)] + 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..4efab394 --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs @@ -0,0 +1,120 @@ +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 = "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; } + + /// + /// 成本中心 + /// + 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(ColumnDescription = "餐次", IsNullable = true)] + public string 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(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..ecd2ab2a --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Entities/OrderDetailsEntity.cs @@ -0,0 +1,79 @@ +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 = "OrderDetails", TableDescription = "订餐明细表")] + public class OrderDetailsEntity : SugarBaseEntity + { + /// + /// 订单号 + /// + [SugarColumn(ColumnDescription = "订单号")] + public string ThirdNo { get; set; } + + /// + /// 营业日 + /// + [SugarColumn(ColumnDescription = "营业日")] + public DateOnly BusinessDate { get; set; } + + /// + /// 餐别 + /// + [SugarColumn(ColumnDescription = "餐别")] + public string ShiftType { get; set; } + + /// + /// 菜品编码 + /// + [SugarColumn(ColumnDescription = "菜品编码")] + public Guid DishesCode { get; set; } + + /// + /// 菜品名称 + /// + [SugarColumn(ColumnDescription = "菜品名称")] + public Guid 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, + } +} From 53dd000f34cd81ef3602d6c3bdf0deca82895b2c Mon Sep 17 00:00:00 2001 From: cheche <717840555@qq.com> Date: Wed, 13 Mar 2024 18:55:12 +0800 Subject: [PATCH 02/23] =?UTF-8?q?feat=20=E8=8F=9C=E5=8D=95=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=8E=A7=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Order/Controllers/MenuDishesController.cs | 70 ++++++++++++ .../MiniProgramOrderDetailController.cs | 47 ++++++++ .../Order/Request/GetDetailRequest.cs | 8 ++ .../Order/Request/GetDishesRequest.cs | 9 ++ .../Order/Request/GetMenuRequest.cs | 9 ++ .../Request/GetMiniProgramOrderRequest.cs | 8 ++ .../Order/Request/SaveDishesRequest.cs | 69 ++++++++++++ .../Order/Request/SaveMenuRequest.cs | 48 ++++++++ .../Order/Response/GetDetailResponse.cs | 66 +++++++++++ .../Order/Response/GetDishesResponse.cs | 75 +++++++++++++ .../Order/Response/GetMenuResponse.cs | 59 ++++++++++ .../Response/GetMiniProgramOrderResponse.cs | 106 ++++++++++++++++++ .../Order/Services/IMenuDishesService.cs | 18 +++ .../IMiniProgramOrderDetailService.cs | 14 +++ .../Services/Implements/MenuDishesService.cs | 93 +++++++++++++++ .../MiniProgramOrderDetailService.cs | 39 +++++++ .../Canteen/Entities/CanteenMenuEntity.cs | 8 +- .../Entities/MiniProgramOrderEntity.cs | 6 +- .../Canteen/Enums/ShiftEnumType.cs | 41 +++++++ 19 files changed, 785 insertions(+), 8 deletions(-) create mode 100644 Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs create mode 100644 Src/Dlhis.Canteen/Order/Controllers/MiniProgramOrderDetailController.cs create mode 100644 Src/Dlhis.Canteen/Order/Request/GetDetailRequest.cs create mode 100644 Src/Dlhis.Canteen/Order/Request/GetDishesRequest.cs create mode 100644 Src/Dlhis.Canteen/Order/Request/GetMenuRequest.cs create mode 100644 Src/Dlhis.Canteen/Order/Request/GetMiniProgramOrderRequest.cs create mode 100644 Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs create mode 100644 Src/Dlhis.Canteen/Order/Request/SaveMenuRequest.cs create mode 100644 Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs create mode 100644 Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs create mode 100644 Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs create mode 100644 Src/Dlhis.Canteen/Order/Response/GetMiniProgramOrderResponse.cs create mode 100644 Src/Dlhis.Canteen/Order/Services/IMenuDishesService.cs create mode 100644 Src/Dlhis.Canteen/Order/Services/IMiniProgramOrderDetailService.cs create mode 100644 Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs create mode 100644 Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs create mode 100644 Src/Dlhis.Entity/Canteen/Enums/ShiftEnumType.cs diff --git a/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs b/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs new file mode 100644 index 00000000..be35ced4 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs @@ -0,0 +1,70 @@ +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); + } +} + diff --git a/Src/Dlhis.Canteen/Order/Controllers/MiniProgramOrderDetailController.cs b/Src/Dlhis.Canteen/Order/Controllers/MiniProgramOrderDetailController.cs new file mode 100644 index 00000000..93d81ee9 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Controllers/MiniProgramOrderDetailController.cs @@ -0,0 +1,47 @@ +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); + } + + /// + /// 明细分页 + /// + /// + /// + [HttpGet("pageDetail")] + public async Task> GetDetailAsync([FromQuery] GetDetailRequest request) + { + return await _miniProgramOrderDetailService.GetDetailAsync(request); + } +} 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..0d197a5e --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/GetMenuRequest.cs @@ -0,0 +1,9 @@ +using Kurisu.Core.DataAccess.Dto; + +namespace Dlhis.Canteen.Order.Request +{ + public class GetMenuRequest : PageDto + { + public Guid? PlaceCode { 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..dbbbdea8 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/GetMiniProgramOrderRequest.cs @@ -0,0 +1,8 @@ +using Kurisu.Core.DataAccess.Dto; + +namespace Dlhis.Canteen.Order.Request +{ + public class GetMiniProgramOrderRequest : PageDto + { + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs b/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs new file mode 100644 index 00000000..1a05a4ba --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs @@ -0,0 +1,69 @@ +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 Guid MenuCode { 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 int RestrictedNum { 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..d4420c48 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/SaveMenuRequest.cs @@ -0,0 +1,48 @@ +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 DateOnly EndDate { 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..c20c4f00 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs @@ -0,0 +1,66 @@ +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 string 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; } + + /// + /// 订单明细状态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..5b790fd0 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs @@ -0,0 +1,75 @@ +using Dlhis.Entity.Canteen.Enums; +using SqlSugar.DbConvert; +using SqlSugar; +using Kurisu.AspNetCore.Utils.Extensions; + +namespace Dlhis.Canteen.Order.Response +{ + public class GetDishesResponse + { + /// + /// 菜单编码 + /// + public Guid MenuCode { get; set; } + + /// + /// 大类 + /// + 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 int RestrictedNum { 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..06d1d2bc --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs @@ -0,0 +1,59 @@ +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 Factory { get; set; } + + /// + /// 开始日期 + /// + public DateOnly StartDate { get; set; } + + /// + /// 结束日期 + /// + public DateOnly EndDate { 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..d14f4fcb --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Response/GetMiniProgramOrderResponse.cs @@ -0,0 +1,106 @@ +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 CostId { get; set; } + + /// + /// 工作地 + /// + public string Workplace { get; set; } + + /// + /// 厂区 + /// + public string Factory { get; set; } + + /// + /// 营业点 + /// + public Guid PlaceCode { get; set; } + + /// + /// 餐次 + /// + public string ShiftType { get; set; } + + /// + /// 菜品 + /// + public Guid DishesCode { 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 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..63e2a697 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Services/IMenuDishesService.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 IMenuDishesService :IScopeDependency + { + Task> GetMenuAsync(GetMenuRequest request); + + Task SaveMenuAsync(SaveMenuRequest request); + + Task> GetDishesAsync(GetDishesRequest request); + + Task SaveDishesAsync(SaveDishesRequest 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..1fb11cd4 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Services/IMiniProgramOrderDetailService.cs @@ -0,0 +1,14 @@ +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> GetDetailAsync( GetDetailRequest 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..ca06fee2 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs @@ -0,0 +1,93 @@ +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 currentTenantId = _currentUser.GetStringTenantId(); + + var page = await _dbContext.Queryable() + .Where(x => x.Factory == currentTenantId) + .WhereIF(request.PlaceCode.HasValue, x => request.PlaceCode == x.PlaceCode) + .WhereIF(!request.Search.IsEmpty(),x => x.Name.Contains(request.Search)) + .Select(x => new GetMenuResponse + { + ShiftTypesSrt = x.ShiftTypes.ToString(), + },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) + { + var page = await _dbContext.Queryable() + .WhereIF(request.MenuCode.HasValue, x => request.MenuCode == x.MenuCode) + .WhereIF(!request.Search.IsEmpty(),x => x.Name.Contains(request.Search)) + .Select() + .ToPageListAsync(request); + return page; + } + + public async Task SaveDishesAsync(SaveDishesRequest request) + { + var menu = await _dbContext.Queryable() + .FirstAsync(x => x.Code == request.MenuCode); + menu.ThrowIfNull($"{request.MenuCode}:该菜单不存在!"); + + 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); + } + } + } +} 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..1235e705 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs @@ -0,0 +1,39 @@ +using Dlhis.Canteen.Order.Request; +using Dlhis.Canteen.Order.Response; +using Dlhis.Entity.Canteen.Entities; +using Kurisu.AspNetCore.Utils.Extensions; +using Kurisu.Core.DataAccess.Dto; +using Kurisu.SqlSugar.Extensions; +using Kurisu.SqlSugar.Services; +using Microsoft.AspNetCore.Mvc; + +namespace Dlhis.Canteen.Order.Services.Implements; + +public class MiniProgramOrderDetailService : IMiniProgramOrderDetailService +{ + private readonly IDbContext _dbContext; + + public MiniProgramOrderDetailService(IDbContext dbContext) + { + _dbContext = dbContext; + } + + public async Task> GetMiniProgramOrderAsync(GetMiniProgramOrderRequest request) + { + var page = await _dbContext.Queryable() + .WhereIF(!request.Search.IsEmpty(), x => x.Name == request.Search || x.Code == request.Search) + .Select() + .ToPageListAsync(request); + return page; + } + + 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; + } +} diff --git a/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs index 1973fecd..2c8501ba 100644 --- a/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs +++ b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs @@ -1,4 +1,6 @@ -using Kurisu.SqlSugar; +using Dlhis.Entity.Canteen.Enums; +using Dlhis.Entity.Device.Enums; +using Kurisu.SqlSugar; using SqlSugar; using System; using System.Collections.Generic; @@ -54,8 +56,8 @@ public class CanteenMenuEntity : SugarBaseEntity /// /// 餐次段 /// - [SugarColumn(ColumnDescription = "餐次段", IsNullable = true)] - public List ShiftTypes { get; set; } + [SugarColumn(ColumnDataType = "varchar(150)", IsJson = true, ColumnDescription = "餐次段", DefaultValue = "[]")] + public List ShiftTypes { get; set; } /// /// 是否启用 diff --git a/Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs index 4efab394..8a007704 100644 --- a/Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs +++ b/Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs @@ -2,11 +2,6 @@ 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 { @@ -49,6 +44,7 @@ namespace Dlhis.Entity.Canteen.Entities /// /// 成本中心 /// + [SugarColumn(ColumnDescription = "成本中心")] public string CostId { get; set; } /// 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 From d17b20365ab4af293e3c9aff60ceeac7466126ce Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 15:46:08 +0800 Subject: [PATCH 03/23] =?UTF-8?q?fix=20=E6=9F=A5=E8=AF=A2=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=BC=82=E5=B8=B8=E6=8A=9B=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GainfoPermissionsController.cs | 6 +-- .../Services/IGainfoPermissions.cs | 3 +- .../Services/Implements/GainfoPermissions.cs | 50 +++++++++---------- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs index 84ab0fb5..3e5a39b3 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs @@ -1,10 +1,8 @@ -using System.ComponentModel.DataAnnotations; -using Dlhis.Basic.BusinessPlace.Response; +using Dlhis.Basic.BusinessPlace.Response; using Dlhis.Basic.Device.Response; using Dlhis.Basic.Organization.Request; using Dlhis.Basic.Organization.Response; using Dlhis.Basic.Organization.Services; -using Dlhis.Basic.Organization.Services.Implements; using Kurisu.Core.DataAccess.Dto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -42,7 +40,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); } diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoPermissions.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoPermissions.cs index 7b1f6183..0e146416 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,7 @@ public interface IGainfoPermissions : IScopeDependency { Task> GetPlaceByGainfoAsync(DeviceAssRequest request); - Task> GetDevicesUnderGroupByUserNoAsync(string userNo, string deviceGroupCode); + Task> GetDevicesUnderGroupByUserNoAsync(string userNo, Guid deviceGroupCode); Task> GetAssignDeviceCodesAsync(DeviceAssRequest request); } diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs index 2bcc5fe4..bda8b03e 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs @@ -8,12 +8,9 @@ using Dlhis.Entity.Canteen.Entities; using Dlhis.Entity.Canteen.Enums; using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.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 +45,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 +67,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 +96,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 +146,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) From 16be030748e326fee35b382b02493408320906e4 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 16:35:38 +0800 Subject: [PATCH 04/23] =?UTF-8?q?feat=20=E9=A4=90=E8=A1=A5=E6=8E=A5?= =?UTF-8?q?=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dlhis.Jinko.Face.sln | 11 ++- .../Entity/MealSupplementRecordEntity.cs | 60 ++++++++++++++++ .../Enums/MealSupplementStatusEnumtype.cs | 29 ++++++++ Src/Dlhis.External/Dlhis.External.csproj | 24 +++++++ Src/Dlhis.External/Dockerfile | 24 +++++++ .../Channel/MealSupplementHandler.cs | 37 ++++++++++ .../Controller/MealSupplementsController.cs | 27 +++++++ .../Request/MealSupplementReceiveReuqest.cs | 45 ++++++++++++ .../Services/IMealSupplementService.cs | 8 +++ .../Implements/MealSupplementService.cs | 23 ++++++ Src/Dlhis.External/Program.cs | 29 ++++++++ .../Properties/launchSettings.json | 13 ++++ .../appsettings.Development.json | 8 +++ Src/Dlhis.External/appsettings.json | 72 +++++++++++++++++++ .../Request/DeviceTaskAssignmentRequest.cs | 4 +- 15 files changed, 411 insertions(+), 3 deletions(-) create mode 100644 Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs create mode 100644 Src/Dlhis.Entity/Basic/Enums/MealSupplementStatusEnumtype.cs create mode 100644 Src/Dlhis.External/Dlhis.External.csproj create mode 100644 Src/Dlhis.External/Dockerfile create mode 100644 Src/Dlhis.External/MealSupplement/Channel/MealSupplementHandler.cs create mode 100644 Src/Dlhis.External/MealSupplement/Controller/MealSupplementsController.cs create mode 100644 Src/Dlhis.External/MealSupplement/Request/MealSupplementReceiveReuqest.cs create mode 100644 Src/Dlhis.External/MealSupplement/Services/IMealSupplementService.cs create mode 100644 Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs create mode 100644 Src/Dlhis.External/Program.cs create mode 100644 Src/Dlhis.External/Properties/launchSettings.json create mode 100644 Src/Dlhis.External/appsettings.Development.json create mode 100644 Src/Dlhis.External/appsettings.json 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.Entity/Basic/Entity/MealSupplementRecordEntity.cs b/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs new file mode 100644 index 00000000..94e5fa7e --- /dev/null +++ b/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs @@ -0,0 +1,60 @@ +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 : SugarBaseEntity +{ + /// + /// 唯一号 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "唯一号", UniqueGroupNameList = new[] { "idx_MealSupplementRecord_UniqueId" })] + public string UniqueId { get; set; } + + /// + /// 工号 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "工号")] + public string Code { get; set; } + + /// + /// 考勤日期 + /// + [SugarColumn(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; } + + /// + /// 餐补状态 + /// + [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] + public MealSupplementStatusEnumtype Status { 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.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..9f0a22ca --- /dev/null +++ b/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs @@ -0,0 +1,23 @@ +using Dlhis.External.MealSupplement.Channel; +using Dlhis.External.MealSupplement.Request; +using Kurisu.AspNetCore.EventBus.Abstractions; +using Kurisu.SqlSugar.Services; + +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 _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/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs index fee03043..d6c88730 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs @@ -7,7 +7,7 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Request; public class DeviceTaskAssignmentRequest : PageDto { /// - /// 设备类型 + /// 设备类型 DeviceTypeEnumType /// [EnumDataType(typeof(DeviceTypeEnumType))] public DeviceTypeEnumType? Type { get; set; } @@ -20,7 +20,7 @@ public class DeviceTaskAssignmentRequest : PageDto public DeviceTaskEnumType? TaskType { get; set; } /// - /// 任务下发状态 + /// 任务下发状态 DeviceTaskStatusEnumType /// [EnumDataType(typeof(DeviceTaskStatusEnumType))] public DeviceTaskStatusEnumType? Status { get; set; } From 5be226aef21a3a3db5a519bf6c23d7a0060a8850 Mon Sep 17 00:00:00 2001 From: cheche <717840555@qq.com> Date: Thu, 14 Mar 2024 17:19:43 +0800 Subject: [PATCH 05/23] =?UTF-8?q?fix=20=E5=AD=97=E6=AE=B5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GainfoPermissionsController.cs | 13 ++ .../Response/GetAssignGroupResponse.cs | 7 + .../Services/IGainfoPermissions.cs | 3 +- .../Services/Implements/GainfoPermissions.cs | 12 ++ .../Order/Controllers/MenuDishesController.cs | 4 +- .../MiniProgramOrderDetailController.cs | 22 +++ .../Order/Request/GetMenuRequest.cs | 2 + .../Request/GetMiniProgramOrderRequest.cs | 4 + .../Order/Request/OrderRequest.cs | 45 ++++++ .../Order/Request/SaveDetailRequest.cs | 61 ++++++++ .../Order/Response/GetDetailResponse.cs | 9 +- .../Order/Response/GetDishesResponse.cs | 5 + .../Order/Response/GetMenuResponse.cs | 5 + .../Response/GetMiniProgramOrderResponse.cs | 32 ++++- .../IMiniProgramOrderDetailService.cs | 4 + .../Services/Implements/MenuDishesService.cs | 14 +- .../MiniProgramOrderDetailService.cs | 136 +++++++++++++++++- Src/Dlhis.Canteen/appsettings.json | 3 +- .../Entities/MiniProgramOrderEntity.cs | 10 +- .../Canteen/Entities/OrderDetailsEntity.cs | 17 +-- Src/Dlhis.Entity/Common/ApkFileEntity.cs | 2 +- 21 files changed, 379 insertions(+), 31 deletions(-) create mode 100644 Src/Dlhis.Basic/Organization/Response/GetAssignGroupResponse.cs create mode 100644 Src/Dlhis.Canteen/Order/Request/OrderRequest.cs create mode 100644 Src/Dlhis.Canteen/Order/Request/SaveDetailRequest.cs diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs index 84ab0fb5..94b134a4 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs @@ -1,13 +1,16 @@ using System.ComponentModel.DataAnnotations; 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; @@ -57,4 +60,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..72e38ae2 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; @@ -14,4 +13,6 @@ public interface IGainfoPermissions : IScopeDependency Task> GetDevicesUnderGroupByUserNoAsync(string userNo, string deviceGroupCode); Task> GetAssignDeviceCodesAsync(DeviceAssRequest request); + + Task> GetAssignGroupAsync(string userNo); } diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissions.cs index 2bcc5fe4..5fd1e448 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,6 +9,7 @@ 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; @@ -193,6 +195,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 index be35ced4..4c04d817 100644 --- a/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs +++ b/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs @@ -24,7 +24,7 @@ public class MenuDishesController : ControllerBase } /// - /// 获取菜单 + /// 菜单分页 /// /// /// @@ -46,7 +46,7 @@ public class MenuDishesController : ControllerBase } /// - /// 获取菜品 + /// 菜品分页 /// /// /// diff --git a/Src/Dlhis.Canteen/Order/Controllers/MiniProgramOrderDetailController.cs b/Src/Dlhis.Canteen/Order/Controllers/MiniProgramOrderDetailController.cs index 93d81ee9..e26efc4b 100644 --- a/Src/Dlhis.Canteen/Order/Controllers/MiniProgramOrderDetailController.cs +++ b/Src/Dlhis.Canteen/Order/Controllers/MiniProgramOrderDetailController.cs @@ -34,6 +34,18 @@ public class MiniProgramOrderDetailController : ControllerBase return await _miniProgramOrderDetailService.GetMiniProgramOrderAsync(request); } + + /// + /// 明细保存 + /// + /// + /// + [HttpPost("saveDetail")] + public async Task SaveDetailAsync(SaveDetailRequest request) + { + await _miniProgramOrderDetailService.SaveDetailAsync(request); + } + /// /// 明细分页 /// @@ -44,4 +56,14 @@ public class MiniProgramOrderDetailController : ControllerBase { 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/GetMenuRequest.cs b/Src/Dlhis.Canteen/Order/Request/GetMenuRequest.cs index 0d197a5e..8f9c6b55 100644 --- a/Src/Dlhis.Canteen/Order/Request/GetMenuRequest.cs +++ b/Src/Dlhis.Canteen/Order/Request/GetMenuRequest.cs @@ -5,5 +5,7 @@ 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 index dbbbdea8..98bdea14 100644 --- a/Src/Dlhis.Canteen/Order/Request/GetMiniProgramOrderRequest.cs +++ b/Src/Dlhis.Canteen/Order/Request/GetMiniProgramOrderRequest.cs @@ -4,5 +4,9 @@ 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..2369dd07 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/OrderRequest.cs @@ -0,0 +1,45 @@ +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 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/Response/GetDetailResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs index c20c4f00..c99deb60 100644 --- a/Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs +++ b/Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs @@ -18,9 +18,14 @@ namespace Dlhis.Canteen.Order.Response public DateOnly BusinessDate { get; set; } /// - /// 餐别 + /// 餐次 /// - public string ShiftType { get; set; } + public ShiftEnumType ShiftType { get; set; } + + /// + /// 餐次CN + /// + public string ShiftTypeCN => ShiftType.GetDescription(); /// /// 菜品编码 diff --git a/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs index 5b790fd0..aafee2b4 100644 --- a/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs +++ b/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs @@ -12,6 +12,11 @@ namespace Dlhis.Canteen.Order.Response /// public Guid MenuCode { get; set; } + /// + /// 菜单名称 + /// + public string MenuName { get; set; } + /// /// 大类 /// diff --git a/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs index 06d1d2bc..11a864da 100644 --- a/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs +++ b/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs @@ -21,6 +21,11 @@ namespace Dlhis.Canteen.Order.Response /// public Guid PlaceCode { get; set; } + /// + /// 所属营业点名称 + /// + public string PlaceName { get; set; } + /// /// 厂区 /// diff --git a/Src/Dlhis.Canteen/Order/Response/GetMiniProgramOrderResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetMiniProgramOrderResponse.cs index d14f4fcb..5fcd6a2b 100644 --- a/Src/Dlhis.Canteen/Order/Response/GetMiniProgramOrderResponse.cs +++ b/Src/Dlhis.Canteen/Order/Response/GetMiniProgramOrderResponse.cs @@ -32,6 +32,11 @@ namespace Dlhis.Canteen.Order.Response /// public string DepartmentNo { get; set; } + /// + /// 部门名称 + /// + public string DepartmentName { get; set; } + /// /// 成本中心 /// @@ -52,16 +57,31 @@ namespace Dlhis.Canteen.Order.Response /// public Guid PlaceCode { get; set; } + /// + /// 营业名称 + /// + public string PlaceName { get; set; } + /// /// 餐次 /// - public string ShiftType { get; set; } + public ShiftEnumType ShiftType { get; set; } + + /// + /// 餐次CN + /// + public string ShiftTypeCN => ShiftType.GetDescription(); /// /// 菜品 /// public Guid DishesCode { get; set; } + /// + /// 菜品名称 + /// + public string DishesName { get; set; } + /// /// 手机号码 /// @@ -97,6 +117,16 @@ namespace Dlhis.Canteen.Order.Response /// public string OrderStatusCN => OrderStatus.GetDescription(); + /// + /// 订单类型 + /// + public CanteenDishesEnumType OrderType { get; set; } + + /// + /// 订单类型CN + /// + public string OrderTypeCN => OrderType.GetDescription(); + /// /// 总金额 /// diff --git a/Src/Dlhis.Canteen/Order/Services/IMiniProgramOrderDetailService.cs b/Src/Dlhis.Canteen/Order/Services/IMiniProgramOrderDetailService.cs index 1fb11cd4..7bb8394d 100644 --- a/Src/Dlhis.Canteen/Order/Services/IMiniProgramOrderDetailService.cs +++ b/Src/Dlhis.Canteen/Order/Services/IMiniProgramOrderDetailService.cs @@ -9,6 +9,10 @@ namespace Dlhis.Canteen.Order.Services { 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 index ca06fee2..2b1c3443 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs @@ -24,15 +24,15 @@ namespace Dlhis.Canteen.Order.Services.Implements public async Task> GetMenuAsync(GetMenuRequest request) { - var currentTenantId = _currentUser.GetStringTenantId(); - var page = await _dbContext.Queryable() - .Where(x => x.Factory == currentTenantId) + .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 => new GetMenuResponse + .Select((x,place) => new GetMenuResponse { ShiftTypesSrt = x.ShiftTypes.ToString(), + PlaceName = place.Name, },true) .ToPageListAsync(request); return page; @@ -62,9 +62,13 @@ namespace Dlhis.Canteen.Order.Services.Implements public async Task> GetDishesAsync(GetDishesRequest request) { var page = await _dbContext.Queryable() + .LeftJoin((x,menu)=>x.MenuCode == menu.Code) .WhereIF(request.MenuCode.HasValue, x => request.MenuCode == x.MenuCode) .WhereIF(!request.Search.IsEmpty(),x => x.Name.Contains(request.Search)) - .Select() + .Select((x,menu) => new GetDishesResponse + { + MenuName = menu.Name, + },true) .ToPageListAsync(request); return page; } diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs index 1235e705..c322f622 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs @@ -1,32 +1,64 @@ 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 Microsoft.AspNetCore.Mvc; +using Mapster; namespace Dlhis.Canteen.Order.Services.Implements; public class MiniProgramOrderDetailService : IMiniProgramOrderDetailService { private readonly IDbContext _dbContext; - - public MiniProgramOrderDetailService(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() - .WhereIF(!request.Search.IsEmpty(), x => x.Name == request.Search || x.Code == request.Search) - .Select() + .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() @@ -36,4 +68,98 @@ public class MiniProgramOrderDetailService : IMiniProgramOrderDetailService 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 == dishes.MenuCode).FirstAsync(); + menu.Enable.ThrowIfFalse($"{dishes.Name}没启用!"); + + // 获取用餐日期 + DateOnly tomorrow = DateOnly.FromDateTime(DateTime.Today.AddDays(1)); + if (!(tomorrow >= menu.StartDate && tomorrow <= menu.EndDate)) + { + true.ThrowIfTrue($"菜品:{dishes.Name}对应的菜单:{menu.Name}不在营业日!"); + } + if(dishes.RestrictedNum < 0) + { + true.ThrowIfTrue($"菜品:{dishes.Name}已售罄!"); + } + + var gainfo = await _dbContext.Queryable() + .Where(x => x.Code == request.UserCode) + .FirstAsync(); + + //判断是否订过餐 + 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); + dishes.RestrictedNum-=request.DishesNum; + await _dbContext.UpdateAsync(dishes); + } + } 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/Canteen/Entities/MiniProgramOrderEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs index 8a007704..13ba9fed 100644 --- a/Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs +++ b/Src/Dlhis.Entity/Canteen/Entities/MiniProgramOrderEntity.cs @@ -68,8 +68,8 @@ namespace Dlhis.Entity.Canteen.Entities /// /// 餐次 /// - [SugarColumn(ColumnDescription = "餐次", IsNullable = true)] - public string ShiftType { get; set; } + [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "餐次")] + public ShiftEnumType ShiftType { get; set; } /// /// 菜品 @@ -107,6 +107,12 @@ namespace Dlhis.Entity.Canteen.Entities [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; } + /// /// 总金额 /// diff --git a/Src/Dlhis.Entity/Canteen/Entities/OrderDetailsEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/OrderDetailsEntity.cs index ecd2ab2a..7ba082e5 100644 --- a/Src/Dlhis.Entity/Canteen/Entities/OrderDetailsEntity.cs +++ b/Src/Dlhis.Entity/Canteen/Entities/OrderDetailsEntity.cs @@ -2,11 +2,6 @@ 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 { @@ -23,16 +18,16 @@ namespace Dlhis.Entity.Canteen.Entities public string ThirdNo { get; set; } /// - /// 营业日 + /// 营业日(用餐日期) /// [SugarColumn(ColumnDescription = "营业日")] - public DateOnly BusinessDate { get; set; } + public DateOnly SysDate { get; set; } /// - /// 餐别 + /// 餐次 /// - [SugarColumn(ColumnDescription = "餐别")] - public string ShiftType { get; set; } + [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "餐次")] + public ShiftEnumType ShiftType { get; set; } /// /// 菜品编码 @@ -44,7 +39,7 @@ namespace Dlhis.Entity.Canteen.Entities /// 菜品名称 /// [SugarColumn(ColumnDescription = "菜品名称")] - public Guid DishesName { get; set; } + public string DishesName { get; set; } /// /// 单价 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; } } From 944d9c2291b5355da8940268c7a794fc87608203 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 18:30:27 +0800 Subject: [PATCH 06/23] =?UTF-8?q?fix=20=E5=AE=9E=E4=BD=93=E7=BB=A7?= =?UTF-8?q?=E6=89=BF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/MealSupplementRecordEntity.cs | 33 +++++++++++-------- .../Implements/MealSupplementService.cs | 7 ++-- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs b/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs index 94e5fa7e..8a993992 100644 --- a/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs +++ b/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs @@ -9,24 +9,38 @@ namespace Dlhis.Entity.Basic.Entity; /// 餐补记录 /// [SugarTable(TableName = "MealSupplementRecord", TableDescription = "餐补记录")] -public class MealSupplementRecordEntity : SugarBaseEntity +public class MealSupplementRecordEntity : MealSupplementRequestRecordEntity { /// /// 唯一号 /// [SugarColumn(IsNullable = false, ColumnDescription = "唯一号", UniqueGroupNameList = new[] { "idx_MealSupplementRecord_UniqueId" })] - public string UniqueId { get; set; } + public override string UniqueId { get; set; } /// /// 工号 /// - [SugarColumn(IsNullable = false, ColumnDescription = "工号")] - public string Code { 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(IsNullable = false, ColumnDescription = "考勤日期")] + [SugarColumn(ColumnDataType = "date", IsNullable = false, ColumnDescription = "考勤日期")] public DateTime Date { get; set; } /// @@ -41,9 +55,6 @@ public class MealSupplementRecordEntity : SugarBaseEntity [SugarColumn(IsNullable = false, ColumnDescription = "厂区")] public string Factory { get; set; } - /// - /// 备注 - /// public string Remark { get; set; } /// @@ -51,10 +62,4 @@ public class MealSupplementRecordEntity : SugarBaseEntity /// [SugarColumn(IsNullable = false, ColumnDescription = "餐补")] public decimal Amount { get; set; } - - /// - /// 餐补状态 - /// - [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] - public MealSupplementStatusEnumtype Status { get; set; } } diff --git a/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs b/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs index 9f0a22ca..701b9430 100644 --- a/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs +++ b/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs @@ -1,7 +1,9 @@ -using Dlhis.External.MealSupplement.Channel; +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; @@ -10,7 +12,7 @@ public class MealSupplementService : IMealSupplementService private readonly IEventBus _eventBus; private readonly IDbContext _dbContext; - public MealSupplementService(IEventBus eventBus , IDbContext dbContext) + public MealSupplementService(IEventBus eventBus, IDbContext dbContext) { _eventBus = eventBus; _dbContext = dbContext; @@ -18,6 +20,7 @@ public class MealSupplementService : IMealSupplementService public async Task DoSupplementsAsync(List reuqests) { + await _dbContext.InsertAsync(reuqests.Adapt>()); await _eventBus.PublishAsync(new MealSupplementMessage { Items = reuqests }); } } From 6fcb73f7a98ea83a1e9161a2c00ae024772f97fe Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 18:42:46 +0800 Subject: [PATCH 07/23] =?UTF-8?q?fix=20=E8=90=A5=E4=B8=9A=E7=82=B9?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BE=9B=E5=BA=94=E5=95=86(=E6=89=BF?= =?UTF-8?q?=E5=8C=85=E5=95=86)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessPlace/Request/BusinessPlaceSaveRequest.cs | 5 +++++ .../BusinessPlace/Response/BusinessPlaceResponse.cs | 6 ++++++ .../Services/Implements/BusinessPlaceService.cs | 5 +++-- Src/Dlhis.Entity/Basic/Entity/BusinessPlaceEntity.cs | 7 +++++++ 4 files changed, 21 insertions(+), 2 deletions(-) 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.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; } /// /// 营业点名称 From 89a93d2a692b6ddaf6669d814ddfb28feba9d290 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 18:44:04 +0800 Subject: [PATCH 08/23] =?UTF-8?q?fix=20=E5=90=8C=E6=AD=A5=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E6=8E=A7=E5=88=B6=E4=BA=BA=E4=BA=8B=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Entity/Basic/Entity/WerkEntity.cs | 6 ++++++ .../SyncSapInfo/Services/Implements/JinkoSapService.cs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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.ScheduledTask/SyncSapInfo/Services/Implements/JinkoSapService.cs b/Src/Dlhis.ScheduledTask/SyncSapInfo/Services/Implements/JinkoSapService.cs index bfd27a08..26a090a5 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(); From 2cdba175bdc94bf53370d4c3a5204253cf3d435e Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 18:50:59 +0800 Subject: [PATCH 09/23] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E5=94=AF?= =?UTF-8?q?=E4=B8=80=E7=BC=96=E7=A0=81=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/BusinessPlaceShiftService.cs | 14 ++++++-------- .../Device/Services/Implements/DeviceService.cs | 1 + .../Basic/Entity/BusinessShiftEntity.cs | 2 ++ Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs | 2 ++ 4 files changed, 11 insertions(+), 8 deletions(-) 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/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.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; } From efbb72105c60e9fbc13e3bc6d76dec56e6c6b8b7 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 19:29:30 +0800 Subject: [PATCH 10/23] =?UTF-8?q?fix=20=E8=81=9A=E5=90=88swagger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Gateway/Gateway.csproj | 2 ++ Src/Gateway/Program.cs | 31 +++++++++++++++------------ Src/Gateway/Startup.cs | 41 ++++++++++++++++++++++++++++++++++++ Src/Gateway/appsettings.json | 10 ++++++++- Src/Gateway/ocelot.json | 11 ++++++++++ 5 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 Src/Gateway/Startup.cs 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": {} From 7a6bedf3f43db8b4674deaa9842ea4672b5efc0b Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 20:36:14 +0800 Subject: [PATCH 11/23] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CancelDuplicationTaskHandler.cs | 135 ++++++++++++++++++ .../Implements/DevicePermissionService.cs | 7 +- Src/Dlhis.Basic/Dlhis.Basic.csproj | 2 +- Src/Dlhis.Basic/Program.cs | 2 + .../Device/Entities/DeviceTaskEntity.cs | 6 + .../Device/Enums/DeviceTaskStatusEnumType.cs | 7 + 6 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs new file mode 100644 index 00000000..43c096dc --- /dev/null +++ b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs @@ -0,0 +1,135 @@ +using System.Linq.Expressions; +using Dlhis.Entity.Device.Entities; +using Dlhis.Entity.Device.Enums; +using Kurisu.AspNetCore.EventBus.Abstractions; +using Kurisu.AspNetCore.EventBus.Abstractions.Handler; +using Kurisu.AspNetCore.Utils.Extensions; +using Kurisu.Core.DataAccess.Entity; +using Kurisu.SqlSugar.Services; +using SqlSugar; + +namespace Dlhis.Basic.Device.EventBusHandler; + +public class CancelDuplicationTaskHandler : IAsyncChannelHandler +{ + private readonly IServiceProvider _serviceProvider; + private readonly ILogger _logger; + + public CancelDuplicationTaskHandler(IServiceProvider serviceProvider, ILogger logger) + { + _serviceProvider = serviceProvider; + _logger = logger; + } + + public async Task InvokeAsync(CancelDuplicationTaskMessage message) + { + _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) + .Select(x => new IdVersion { Id = x.Id, Version = x.Version }).ToList(); + + ignoreData.ForEach(p => + { + where = where.Or(x => x.Id == p.Id && x.Version == p.Version && x.Status == DeviceTaskStatusEnumType.Wait); + }); + } + else if (item.Type == DeviceTaskEnumType.Delete && item.Status == DeviceTaskStatusEnumType.Wait) + { + ignoreData = data.Where(x => (x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Delete)) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .Where(x => x.Id != item.Id) + .Select(x => new IdVersion { Id = x.Id, Version = x.Version }).ToList(); + + ignoreData.ForEach(p => + { + where = where.Or(x => x.Id == p.Id && x.Version == p.Version && x.Status == DeviceTaskStatusEnumType.Wait); + }); + } + + if (ignoreData.Any()) + { + 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("抵消任务处理完成"); + } +} + +public class CancelDuplicationTaskMessage : IAsyncChannelMessage +{ + +} + +public class IdVersion +{ + public long Id { get; set; } + public int Version { get; set; } +} diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs index f3c56a47..d1b38a8c 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs @@ -1,4 +1,5 @@ using Dlhis.Basic.Device.Dtos; +using Dlhis.Basic.Device.EventBusHandler; using Dlhis.Basic.Device.Request; using Dlhis.Basic.Device.Response; using Dlhis.Entity.Basic.Entity; @@ -6,6 +7,7 @@ using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; using Dlhis.Entity.Sys.Entities; using Dlhis.Entity.Sys.Enums; +using Kurisu.AspNetCore.EventBus.Abstractions; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Core.DataAccess.Dto; using Kurisu.Core.DataAccess.Entity; @@ -18,11 +20,13 @@ public class DevicePermissionService : IDevicePermissionService { private readonly IDbContext _dbContext; private readonly ICurrentUser _currentUser; + private readonly IEventBus _eventBus; - public DevicePermissionService(IDbContext dbContext, ICurrentUser currentUser) + public DevicePermissionService(IDbContext dbContext, ICurrentUser currentUser, IEventBus eventBus) { _dbContext = dbContext; _currentUser = currentUser; + _eventBus = eventBus; } public async Task AssignAsync(DevicePermissionSaveReuqest reuqest) @@ -153,6 +157,7 @@ public class DevicePermissionService : IDevicePermissionService if (waitTasks.Any()) { await _dbContext.InsertAsync(waitTasks); + await _eventBus.PublishAsync(new CancelDuplicationTaskMessage()); } } finally 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/Program.cs b/Src/Dlhis.Basic/Program.cs index 953eea17..8ccfcccb 100644 --- a/Src/Dlhis.Basic/Program.cs +++ b/Src/Dlhis.Basic/Program.cs @@ -1,3 +1,4 @@ +using Kurisu.AspNetCore.EventBus.Extensions; using Kurisu.AspNetCore.Startup; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Startup; @@ -22,5 +23,6 @@ public class Startup : DefaultStartup { base.ConfigureServices(services); services.AddRedis(); + services.AddEventBus(); } } \ No newline at end of file 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, + /// /// 异常 /// From 7da5fdcb2f304a5b7193d294a0b34f5051a55abf Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 20:53:56 +0800 Subject: [PATCH 12/23] =?UTF-8?q?fix=20=E5=88=A0=E9=99=A4=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E8=AE=BE=E7=BD=AE=E6=89=80=E6=9C=89=E4=B8=BA=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CancelDuplicationTaskHandler.cs | 52 ++++++++++++------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs index 43c096dc..3a00b25e 100644 --- a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs +++ b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs @@ -64,34 +64,48 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler x.Status == DeviceTaskStatusEnumType.Wait) .Where(x => x.Id != item.Id) .Select(x => new IdVersion { Id = x.Id, Version = x.Version }).ToList(); - - ignoreData.ForEach(p => - { - where = where.Or(x => x.Id == p.Id && x.Version == p.Version && x.Status == DeviceTaskStatusEnumType.Wait); - }); } + //最新一条删除人员信息 else if (item.Type == DeviceTaskEnumType.Delete && item.Status == DeviceTaskStatusEnumType.Wait) { - ignoreData = data.Where(x => (x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Delete)) - .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) - .Where(x => x.Id != item.Id) - .Select(x => new IdVersion { Id = x.Id, Version = x.Version }).ToList(); - - ignoreData.ForEach(p => + //判断是否成功 + 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()) { - where = where.Or(x => x.Id == p.Id && x.Version == p.Version && x.Status == DeviceTaskStatusEnumType.Wait); - }); + var beforeTask = data.Where(x => x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Update) + .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) + .FirstOrDefault(x => x.Id != item.Id); + + if (beforeTask != null) ignoreData.Add(beforeTask); + + } + else + { + 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) + .Select(x => new IdVersion { Id = x.Id, Version = x.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(); + .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 => { From b763e74c123e40a37be18c6f4c55654833bc5e73 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 20:56:37 +0800 Subject: [PATCH 13/23] =?UTF-8?q?fix=20=E5=88=A4=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=8F=96=E5=8F=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CancelDuplicationTaskHandler.cs | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs index 3a00b25e..485c4296 100644 --- a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs +++ b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs @@ -68,27 +68,26 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler().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) + .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) + ); + } + else { var beforeTask = data.Where(x => x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Update) .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) .FirstOrDefault(x => x.Id != item.Id); if (beforeTask != null) ignoreData.Add(beforeTask); - - } - else - { - 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) - .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) - ); } } From 62d54c1f70562120b5131d4861b3ad8ba7c2a334 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 21:04:45 +0800 Subject: [PATCH 14/23] =?UTF-8?q?fix=20=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CancelDuplicationTaskHandler.cs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs index 485c4296..92158487 100644 --- a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs +++ b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs @@ -83,11 +83,29 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler { item.Id }; var beforeTask = data.Where(x => x.Type == DeviceTaskEnumType.Add || x.Type == DeviceTaskEnumType.Update) - .Select(x => new IdVersion { Id = x.Id, Version = x.Version }) - .FirstOrDefault(x => x.Id != item.Id); + .Where(x => !currentIds.Contains(x.Id)) + .Where(x => x.Status == DeviceTaskStatusEnumType.Wait) + .FirstOrDefault(); - if (beforeTask != null) ignoreData.Add(beforeTask); + //逻辑正确,最终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) + .FirstOrDefault(); + } + + if (beforeTask != null) + { + ignoreData.Add(new IdVersion() { Id = beforeTask.Id, Version = beforeTask.Version }); + ignoreData.Add(new IdVersion() { Id = item.Id, Version = item.Version }); + } } } From f2de9a6526953fc46dd8b362deaacb8c7ac1e114 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 21:08:28 +0800 Subject: [PATCH 15/23] =?UTF-8?q?fix=20=E6=95=B0=E6=8D=AE=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=9C=80=E8=A6=81=E6=AF=94=E8=BE=83=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Device/EventBusHandler/CancelDuplicationTaskHandler.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs index 92158487..e19cf28f 100644 --- a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs +++ b/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs @@ -63,6 +63,7 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler 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(); } //最新一条删除人员信息 @@ -78,6 +79,7 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler 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 }) ); } @@ -87,6 +89,7 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler 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 @@ -98,6 +101,7 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler 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(); } From d3c1b45cf9f057553c7650e6249020272e0969ba Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 21:29:20 +0800 Subject: [PATCH 16/23] =?UTF-8?q?fix=20=E5=8F=96=E6=B6=88=E5=A4=84?= =?UTF-8?q?=E7=90=86=E4=BB=A3=E7=A0=81=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Device/Services/Implements/DevicePermissionService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs index d1b38a8c..c0886441 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs @@ -157,8 +157,9 @@ public class DevicePermissionService : IDevicePermissionService if (waitTasks.Any()) { await _dbContext.InsertAsync(waitTasks); - await _eventBus.PublishAsync(new CancelDuplicationTaskMessage()); } + + await _eventBus.PublishAsync(new CancelDuplicationTaskMessage()); } finally { From 9fdb2b0159b75c86ba1a5068bc2df8cdf67a928b Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 21:44:02 +0800 Subject: [PATCH 17/23] =?UTF-8?q?fix=20=E7=A7=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E6=95=88=E5=AD=97=E6=AE=B5=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Response/DeviceTaskAssignmentResponse.cs | 11 ----------- .../Implements/DeviceTaskAssignmentService.cs | 2 -- 2 files changed, 13 deletions(-) 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..50755267 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs @@ -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); From ccf8a88a9be103b01953f1236dac553f8c96ff88 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 14 Mar 2024 21:59:32 +0800 Subject: [PATCH 18/23] =?UTF-8?q?fix=20=E8=B0=83=E6=95=B4=E4=B8=BA?= =?UTF-8?q?=E8=B0=83=E5=BA=A6=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Device/Controllers/DevicesController.cs | 3 +- .../Implements/DevicePermissionService.cs | 8 +---- Src/Dlhis.Basic/Program.cs | 2 -- .../CommonJobs/CancelDuplicationTaskJob.cs} | 29 ++++++++----------- Src/Dlhis.ScheduledTask/Packs/JobPack.cs | 8 ++++- 5 files changed, 22 insertions(+), 28 deletions(-) rename Src/{Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs => Dlhis.ScheduledTask/CommonJobs/CancelDuplicationTaskJob.cs} (91%) 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/DevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs index c0886441..f3c56a47 100644 --- a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs +++ b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs @@ -1,5 +1,4 @@ using Dlhis.Basic.Device.Dtos; -using Dlhis.Basic.Device.EventBusHandler; using Dlhis.Basic.Device.Request; using Dlhis.Basic.Device.Response; using Dlhis.Entity.Basic.Entity; @@ -7,7 +6,6 @@ using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; using Dlhis.Entity.Sys.Entities; using Dlhis.Entity.Sys.Enums; -using Kurisu.AspNetCore.EventBus.Abstractions; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Core.DataAccess.Dto; using Kurisu.Core.DataAccess.Entity; @@ -20,13 +18,11 @@ public class DevicePermissionService : IDevicePermissionService { private readonly IDbContext _dbContext; private readonly ICurrentUser _currentUser; - private readonly IEventBus _eventBus; - public DevicePermissionService(IDbContext dbContext, ICurrentUser currentUser, IEventBus eventBus) + public DevicePermissionService(IDbContext dbContext, ICurrentUser currentUser) { _dbContext = dbContext; _currentUser = currentUser; - _eventBus = eventBus; } public async Task AssignAsync(DevicePermissionSaveReuqest reuqest) @@ -158,8 +154,6 @@ public class DevicePermissionService : IDevicePermissionService { await _dbContext.InsertAsync(waitTasks); } - - await _eventBus.PublishAsync(new CancelDuplicationTaskMessage()); } finally { diff --git a/Src/Dlhis.Basic/Program.cs b/Src/Dlhis.Basic/Program.cs index 8ccfcccb..953eea17 100644 --- a/Src/Dlhis.Basic/Program.cs +++ b/Src/Dlhis.Basic/Program.cs @@ -1,4 +1,3 @@ -using Kurisu.AspNetCore.EventBus.Extensions; using Kurisu.AspNetCore.Startup; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Startup; @@ -23,6 +22,5 @@ public class Startup : DefaultStartup { base.ConfigureServices(services); services.AddRedis(); - services.AddEventBus(); } } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs b/Src/Dlhis.ScheduledTask/CommonJobs/CancelDuplicationTaskJob.cs similarity index 91% rename from Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs rename to Src/Dlhis.ScheduledTask/CommonJobs/CancelDuplicationTaskJob.cs index e19cf28f..b701c93e 100644 --- a/Src/Dlhis.Basic/Device/EventBusHandler/CancelDuplicationTaskHandler.cs +++ b/Src/Dlhis.ScheduledTask/CommonJobs/CancelDuplicationTaskJob.cs @@ -1,27 +1,25 @@ -using System.Linq.Expressions; -using Dlhis.Entity.Device.Entities; +using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; -using Kurisu.AspNetCore.EventBus.Abstractions; -using Kurisu.AspNetCore.EventBus.Abstractions.Handler; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.Core.DataAccess.Entity; using Kurisu.SqlSugar.Services; using SqlSugar; +using System.Linq.Expressions; -namespace Dlhis.Basic.Device.EventBusHandler; +namespace Dlhis.ScheduledTask.CommonJobs; -public class CancelDuplicationTaskHandler : IAsyncChannelHandler +public class CancelDuplicationTaskJob { private readonly IServiceProvider _serviceProvider; - private readonly ILogger _logger; + private readonly ILogger _logger; - public CancelDuplicationTaskHandler(IServiceProvider serviceProvider, ILogger logger) + public CancelDuplicationTaskJob(IServiceProvider serviceProvider, ILogger logger) { _serviceProvider = serviceProvider; _logger = logger; } - public async Task InvokeAsync(CancelDuplicationTaskMessage message) + public async Task RunAsync() { _logger.LogInformation("抵消任务开始处理"); @@ -156,15 +154,12 @@ public class CancelDuplicationTaskHandler : IAsyncChannelHandler("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 }); - } } From 843662a404177462ae5a2104a57e25e7d4da1509 Mon Sep 17 00:00:00 2001 From: cheche <717840555@qq.com> Date: Fri, 15 Mar 2024 09:28:08 +0800 Subject: [PATCH 19/23] =?UTF-8?q?fix=20=E5=AD=97=E6=AE=B5=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs index c99deb60..1b78423e 100644 --- a/Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs +++ b/Src/Dlhis.Canteen/Order/Response/GetDetailResponse.cs @@ -35,7 +35,7 @@ namespace Dlhis.Canteen.Order.Response /// /// 菜品名称 /// - public Guid DishesName { get; set; } + public string DishesName { get; set; } /// /// 单价 From 9fc0719bad2748388c5fa0f419f937b5bfecd2aa Mon Sep 17 00:00:00 2001 From: cheche <717840555@qq.com> Date: Fri, 15 Mar 2024 10:40:05 +0800 Subject: [PATCH 20/23] =?UTF-8?q?feat=20=E9=85=8D=E7=BD=AE=E8=8F=9C?= =?UTF-8?q?=E5=93=81=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Order/Controllers/MenuDishesController.cs | 11 +++++ .../Order/Request/DispositionDishesRequest.cs | 8 ++++ .../Order/Request/SaveDishesRequest.cs | 5 -- .../Order/Response/GetDishesResponse.cs | 5 -- .../Order/Services/IMenuDishesService.cs | 2 + .../Services/Implements/MenuDishesService.cs | 46 +++++++++++++------ .../MiniProgramOrderDetailService.cs | 12 ++--- .../Canteen/Entities/CanteenDishesEntity.cs | 5 -- .../CanteenMenuDishersRelationshipEntity.cs | 17 +++++++ 9 files changed, 76 insertions(+), 35 deletions(-) create mode 100644 Src/Dlhis.Canteen/Order/Request/DispositionDishesRequest.cs create mode 100644 Src/Dlhis.Entity/Canteen/Entities/CanteenMenuDishersRelationshipEntity.cs diff --git a/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs b/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs index 4c04d817..9001b4f4 100644 --- a/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs +++ b/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs @@ -66,5 +66,16 @@ public class MenuDishesController : ControllerBase { await _menuDishesService.SaveDishesAsync(request); } + + /// + /// 配置菜单菜品 + /// + /// + /// + [HttpPost("disposition")] + public async Task DispositionDishesAsync(DispositionDishesRequest request) + { + await _menuDishesService.DispositionDishesAsync(request); + } } diff --git a/Src/Dlhis.Canteen/Order/Request/DispositionDishesRequest.cs b/Src/Dlhis.Canteen/Order/Request/DispositionDishesRequest.cs new file mode 100644 index 00000000..5beb9f23 --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Request/DispositionDishesRequest.cs @@ -0,0 +1,8 @@ +namespace Dlhis.Canteen.Order.Request +{ + public class DispositionDishesRequest + { + public Guid MenudCode { get; set; } + public List DishersCodes { get; set; } + } +} diff --git a/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs b/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs index 1a05a4ba..11429d96 100644 --- a/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs +++ b/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs @@ -10,11 +10,6 @@ namespace Dlhis.Canteen.Order.Request public long? Id { get; set; } - /// - /// 菜单编码 - /// - public Guid MenuCode { get; set; } - /// /// 大类 /// diff --git a/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs index aafee2b4..3fa98a24 100644 --- a/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs +++ b/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs @@ -7,11 +7,6 @@ namespace Dlhis.Canteen.Order.Response { public class GetDishesResponse { - /// - /// 菜单编码 - /// - public Guid MenuCode { get; set; } - /// /// 菜单名称 /// diff --git a/Src/Dlhis.Canteen/Order/Services/IMenuDishesService.cs b/Src/Dlhis.Canteen/Order/Services/IMenuDishesService.cs index 63e2a697..020b5bed 100644 --- a/Src/Dlhis.Canteen/Order/Services/IMenuDishesService.cs +++ b/Src/Dlhis.Canteen/Order/Services/IMenuDishesService.cs @@ -14,5 +14,7 @@ namespace Dlhis.Canteen.Order.Services Task> GetDishesAsync(GetDishesRequest request); Task SaveDishesAsync(SaveDishesRequest request); + + Task DispositionDishesAsync(DispositionDishesRequest request); } } diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs index 2b1c3443..84b2d4dd 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs @@ -61,24 +61,27 @@ namespace Dlhis.Canteen.Order.Services.Implements public async Task> GetDishesAsync(GetDishesRequest request) { - var page = await _dbContext.Queryable() - .LeftJoin((x,menu)=>x.MenuCode == menu.Code) - .WhereIF(request.MenuCode.HasValue, x => request.MenuCode == x.MenuCode) - .WhereIF(!request.Search.IsEmpty(),x => x.Name.Contains(request.Search)) - .Select((x,menu) => new GetDishesResponse - { - MenuName = menu.Name, - },true) - .ToPageListAsync(request); - return page; + 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) { - var menu = await _dbContext.Queryable() - .FirstAsync(x => x.Code == request.MenuCode); - menu.ThrowIfNull($"{request.MenuCode}:该菜单不存在!"); - if (!request.Id.HasValue) { var dishers = request.Adapt(); @@ -93,5 +96,20 @@ namespace Dlhis.Canteen.Order.Services.Implements await _dbContext.UpdateAsync(entity); } } + + public async Task DispositionDishesAsync(DispositionDishesRequest request) + { + var lst = new List(); + foreach (var dCode in request.DishersCodes) + { + var entity = new CanteenMenuDishersRelationshipEntity + { + MenuCode = request.MenudCode, + DishersCode = dCode, + }; + 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 index c322f622..b30107d1 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs @@ -82,15 +82,15 @@ public class MiniProgramOrderDetailService : IMiniProgramOrderDetailService 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 == dishes.MenuCode).FirstAsync(); - menu.Enable.ThrowIfFalse($"{dishes.Name}没启用!"); + //var menu = await _dbContext.Queryable().Where(x => x.Code == dishes.MenuCode).FirstAsync(); + //menu.Enable.ThrowIfFalse($"{dishes.Name}没启用!"); // 获取用餐日期 DateOnly tomorrow = DateOnly.FromDateTime(DateTime.Today.AddDays(1)); - if (!(tomorrow >= menu.StartDate && tomorrow <= menu.EndDate)) - { - true.ThrowIfTrue($"菜品:{dishes.Name}对应的菜单:{menu.Name}不在营业日!"); - } + //if (!(tomorrow >= menu.StartDate && tomorrow <= menu.EndDate)) + //{ + // true.ThrowIfTrue($"菜品:{dishes.Name}对应的菜单:{menu.Name}不在营业日!"); + //} if(dishes.RestrictedNum < 0) { true.ThrowIfTrue($"菜品:{dishes.Name}已售罄!"); diff --git a/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs index b1136216..7c8a4292 100644 --- a/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs +++ b/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs @@ -16,11 +16,6 @@ namespace Dlhis.Entity.Canteen.Entities [SugarTable(TableName = "CanteenDishes", TableDescription = "菜品表")] public class CanteenDishesEntity : SugarBaseEntity { - /// - /// 菜单编码 - /// - [SugarColumn(ColumnDescription = "菜单编码")] - public Guid MenuCode { 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..28341644 --- /dev/null +++ b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuDishersRelationshipEntity.cs @@ -0,0 +1,17 @@ +using Kurisu.SqlSugar; +using SqlSugar; + +namespace Dlhis.Entity.Canteen.Entities +{ + /// + /// 菜单菜品表 + /// + [SugarTable(TableName = "CanteenMenuDishersRelationship", TableDescription = "菜单菜品表")] + public class CanteenMenuDishersRelationshipEntity : SugarBaseEntity + { + public Guid MenuCode { get; set; } + + + public Guid DishersCode { get; set; } + } +} From 1bddd5c90f52d381065c3ef24260f4a11defa2c9 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 15 Mar 2024 11:59:24 +0800 Subject: [PATCH 21/23] =?UTF-8?q?fix=20=E6=A0=B9=E8=8A=82=E7=82=B9pno?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BAnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Organization/Services/Implements/DepartmentService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 => { From 8a0eb06038056dad9f2eefbc5376d25b33313ee2 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 15 Mar 2024 12:15:50 +0800 Subject: [PATCH 22/23] =?UTF-8?q?fix=20=E6=94=AF=E6=8C=81=E5=A4=9A?= =?UTF-8?q?=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Request/DeviceTaskAssignmentRequest.cs | 7 ++----- .../Implements/DeviceTaskAssignmentService.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs index d6c88730..ed69bfdb 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs @@ -12,16 +12,13 @@ public class DeviceTaskAssignmentRequest : PageDto [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/Services/Implements/DeviceTaskAssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/DeviceTaskAssignmentService.cs index 50755267..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 From 69a80f22634481dd3cac3044ffba5041ca458e49 Mon Sep 17 00:00:00 2001 From: cheche <717840555@qq.com> Date: Fri, 15 Mar 2024 12:39:43 +0800 Subject: [PATCH 23/23] =?UTF-8?q?fix=20=E5=AD=97=E6=AE=B5=E4=BF=AE?= =?UTF-8?q?=E6=94=B91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Order/Controllers/MenuDishesController.cs | 2 +- .../Order/Request/DispositionDishesDto.cs | 10 ++++++ .../Order/Request/DispositionDishesRequest.cs | 4 ++- .../Order/Request/OrderRequest.cs | 7 +++- .../Order/Request/SaveDishesRequest.cs | 5 --- .../Order/Request/SaveMenuRequest.cs | 6 +--- .../Order/Response/GetDishesResponse.cs | 8 ----- .../Order/Response/GetMenuResponse.cs | 6 +--- .../Services/Implements/MenuDishesService.cs | 7 ++-- .../MiniProgramOrderDetailService.cs | 33 ++++++++++++------- .../Canteen/Entities/CanteenDishesEntity.cs | 6 ---- .../CanteenMenuDishersRelationshipEntity.cs | 17 +++++++++- .../Canteen/Entities/CanteenMenuEntity.cs | 15 ++------- 13 files changed, 67 insertions(+), 59 deletions(-) create mode 100644 Src/Dlhis.Canteen/Order/Request/DispositionDishesDto.cs diff --git a/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs b/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs index 9001b4f4..b6ecc0d5 100644 --- a/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs +++ b/Src/Dlhis.Canteen/Order/Controllers/MenuDishesController.cs @@ -68,7 +68,7 @@ public class MenuDishesController : ControllerBase } /// - /// 配置菜单菜品 + /// 配置每日菜单菜品及限售 /// /// /// 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 index 5beb9f23..070e8c42 100644 --- a/Src/Dlhis.Canteen/Order/Request/DispositionDishesRequest.cs +++ b/Src/Dlhis.Canteen/Order/Request/DispositionDishesRequest.cs @@ -3,6 +3,8 @@ public class DispositionDishesRequest { public Guid MenudCode { get; set; } - public List DishersCodes { get; set; } + + public List DishersDtos { get; set; } + } } diff --git a/Src/Dlhis.Canteen/Order/Request/OrderRequest.cs b/Src/Dlhis.Canteen/Order/Request/OrderRequest.cs index 2369dd07..4d8b9cc2 100644 --- a/Src/Dlhis.Canteen/Order/Request/OrderRequest.cs +++ b/Src/Dlhis.Canteen/Order/Request/OrderRequest.cs @@ -18,7 +18,7 @@ namespace Dlhis.Canteen.Order.Request public Guid PlaceCode { get; set; } /// - /// 餐别 + /// 餐次 /// public ShiftEnumType ShiftType { get; set; } @@ -27,6 +27,11 @@ namespace Dlhis.Canteen.Order.Request /// public string Address { get; set; } + /// + /// 菜单 + /// + public Guid MenuCode { get; set; } + /// /// 菜品 /// diff --git a/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs b/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs index 11429d96..f68b41e1 100644 --- a/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs +++ b/Src/Dlhis.Canteen/Order/Request/SaveDishesRequest.cs @@ -46,11 +46,6 @@ namespace Dlhis.Canteen.Order.Request /// public string Unit { get; set; } - /// - /// 限售份数 - /// - public int RestrictedNum { get; set; } - /// /// 图片 /// diff --git a/Src/Dlhis.Canteen/Order/Request/SaveMenuRequest.cs b/Src/Dlhis.Canteen/Order/Request/SaveMenuRequest.cs index d4420c48..76e7d66e 100644 --- a/Src/Dlhis.Canteen/Order/Request/SaveMenuRequest.cs +++ b/Src/Dlhis.Canteen/Order/Request/SaveMenuRequest.cs @@ -26,14 +26,10 @@ namespace Dlhis.Canteen.Order.Request public string Factory { get; set; } /// - /// 开始日期 + /// 营业日期 /// public DateOnly StartDate { get; set; } - /// - /// 结束日期 - /// - public DateOnly EndDate { get; set; } /// /// 餐次段 diff --git a/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs index 3fa98a24..4d149b01 100644 --- a/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs +++ b/Src/Dlhis.Canteen/Order/Response/GetDishesResponse.cs @@ -7,10 +7,6 @@ namespace Dlhis.Canteen.Order.Response { public class GetDishesResponse { - /// - /// 菜单名称 - /// - public string MenuName { get; set; } /// /// 大类 @@ -57,10 +53,6 @@ namespace Dlhis.Canteen.Order.Response /// public string Unit { get; set; } - /// - /// 限售份数 - /// - public int RestrictedNum { get; set; } /// /// 图片 diff --git a/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs b/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs index 11a864da..111e0ecb 100644 --- a/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs +++ b/Src/Dlhis.Canteen/Order/Response/GetMenuResponse.cs @@ -32,14 +32,10 @@ namespace Dlhis.Canteen.Order.Response public string Factory { get; set; } /// - /// 开始日期 + /// 营业日期 /// public DateOnly StartDate { get; set; } - /// - /// 结束日期 - /// - public DateOnly EndDate { get; set; } /// /// 餐次段 diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs index 84b2d4dd..a5965110 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/MenuDishesService.cs @@ -32,6 +32,7 @@ namespace Dlhis.Canteen.Order.Services.Implements .Select((x,place) => new GetMenuResponse { ShiftTypesSrt = x.ShiftTypes.ToString(), + //ShiftTypesSrt = string.Join(", ", x.ShiftTypes.Select(enumValue => enumValue.GetDescription())), PlaceName = place.Name, },true) .ToPageListAsync(request); @@ -100,12 +101,14 @@ namespace Dlhis.Canteen.Order.Services.Implements public async Task DispositionDishesAsync(DispositionDishesRequest request) { var lst = new List(); - foreach (var dCode in request.DishersCodes) + + foreach (var dto in request.DishersDtos) { var entity = new CanteenMenuDishersRelationshipEntity { MenuCode = request.MenudCode, - DishersCode = dCode, + DishersCode = dto.DisherCode, + RestrictedNum = dto.RestrictedNum, }; lst.Add(entity); } diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs index b30107d1..9c31e57e 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/MiniProgramOrderDetailService.cs @@ -10,6 +10,7 @@ using Kurisu.Core.DataAccess.Dto; using Kurisu.SqlSugar.Extensions; using Kurisu.SqlSugar.Services; using Mapster; +using SqlSugar; namespace Dlhis.Canteen.Order.Services.Implements; @@ -82,16 +83,20 @@ public class MiniProgramOrderDetailService : IMiniProgramOrderDetailService 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 == dishes.MenuCode).FirstAsync(); - //menu.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 && tomorrow <= menu.EndDate)) - //{ - // true.ThrowIfTrue($"菜品:{dishes.Name}对应的菜单:{menu.Name}不在营业日!"); - //} - if(dishes.RestrictedNum < 0) + 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}已售罄!"); } @@ -99,6 +104,7 @@ public class MiniProgramOrderDetailService : IMiniProgramOrderDetailService var gainfo = await _dbContext.Queryable() .Where(x => x.Code == request.UserCode) .FirstAsync(); + gainfo.ThrowIfNull($"用户{request.UserCode}无档案信息,无法订餐!"); //判断是否订过餐 var flag = await _dbContext.Queryable() @@ -140,7 +146,7 @@ public class MiniProgramOrderDetailService : IMiniProgramOrderDetailService OrderStatus = MiniProgramOrderStatusEnumType.I, OrderType = dishes.Type, }; - //订单明细 + //生成订单明细 var detail = new OrderDetailsEntity { ThirdNo = order.No, @@ -155,11 +161,16 @@ public class MiniProgramOrderDetailService : IMiniProgramOrderDetailService OrderStatus = OrderDetailsStatusEnumType.I, }; order.TotalAmount = detail.Amount; - await _dbContext.InsertAsync(order); await _dbContext.InsertAsync(detail); - dishes.RestrictedNum-=request.DishesNum; - await _dbContext.UpdateAsync(dishes); + //扣减份数 + 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.Entity/Canteen/Entities/CanteenDishesEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs index 7c8a4292..25dfd418 100644 --- a/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs +++ b/Src/Dlhis.Entity/Canteen/Entities/CanteenDishesEntity.cs @@ -65,12 +65,6 @@ namespace Dlhis.Entity.Canteen.Entities [SugarColumn(ColumnDescription = "单位")] public string Unit { get; set; } - /// - /// 限售份数 - /// - [SugarColumn(ColumnDescription = "限售份数")] - public int RestrictedNum { get; set; } - /// /// 图片 /// diff --git a/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuDishersRelationshipEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuDishersRelationshipEntity.cs index 28341644..da94aa3b 100644 --- a/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuDishersRelationshipEntity.cs +++ b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuDishersRelationshipEntity.cs @@ -9,9 +9,24 @@ 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 index 2c8501ba..03461d3a 100644 --- a/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs +++ b/Src/Dlhis.Entity/Canteen/Entities/CanteenMenuEntity.cs @@ -1,12 +1,6 @@ using Dlhis.Entity.Canteen.Enums; -using Dlhis.Entity.Device.Enums; using Kurisu.SqlSugar; using SqlSugar; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Dlhis.Entity.Canteen.Entities; @@ -42,16 +36,11 @@ public class CanteenMenuEntity : SugarBaseEntity public string Factory { get; set; } /// - /// 开始日期 + /// 营业日期 /// - [SugarColumn(ColumnDescription = "开始日期")] + [SugarColumn(ColumnDescription = "营业日期")] public DateOnly StartDate { get; set; } - /// - /// 结束日期 - /// - [SugarColumn(ColumnDescription = "结束日期")] - public DateOnly EndDate { get; set; } /// /// 餐次段