From 1ac822e8a0053a3222e353e4ee17252bf1dde27c Mon Sep 17 00:00:00 2001 From: zhaoy <137053305@qq.com> Date: Sat, 6 Jan 2024 17:42:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=96=99=E7=AE=A1=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=92=8C=E5=95=86=E5=93=81=E5=A4=9A=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Auth/AuthService.cs | 2 +- .../DataBase/BatchingServices.cs | 133 +++++++ .../Dtos/Batching/BatchingDetailedDto.cs | 32 ++ .../DataBase/Dtos/Batching/BatchingInfoDto.cs | 82 ++++ .../Dtos/Batching/BatchingListQuery.cs | 93 +++++ .../Dtos/Batching/BatchingStatusDto.cs | 14 + .../DataBase/Dtos/Batching/BatchingTypeDto.cs | 14 + .../DataBase/Dtos/Batching/BatchingUintDto.cs | 13 + .../Dtos/GoodsAttribute/GoodsAttributeDto.cs | 19 + .../Dtos/GoodsAttribute/GoodsAttributeList.cs | 36 ++ .../GoodsAttribute/GoodsAttributeQueryDto.cs | 15 + .../GoodsAttribute/GoodsAttributeValueDto.cs | 23 ++ .../Dtos/GoodsAttribute/GoodsAttributeView.cs | 23 ++ .../GoodsAttribute/GoodsBomAttributeDto.cs | 23 ++ .../DataBase/GoodsAttributeServices.cs | 102 +++++ .../DataBase/Interface/IBatchingService.cs | 26 ++ .../Interface/IGoodsAttributeService.cs | 59 +++ .../DataBase/Services/BatchingService.cs | 364 ++++++++++++++++++ .../Services/GoodsAttributeService.cs | 328 ++++++++++++++++ .../Org/Dtos/Users/UserDtoOutput.cs | 42 ++ .../Org/Dtos/Users/UserDtoPageInput.cs | 22 ++ .../Org/Dtos/Users/UserPwdDtoInput.cs | 24 ++ .../Org/Dtos/Users/UserRoleDtoInput.cs | 21 + .../Org/Interface/IOrganizeService.cs | 1 + .../Org/Interface/IRoleService.cs | 1 + .../Org/Interface/IUserService.cs | 10 + .../Org/OrganizeServices.cs | 5 + .../Org/RolesServices.cs | 11 +- .../Org/Services/OrganizeService.cs | 6 + .../Org/Services/RoleService.cs | 6 + .../Org/Services/UserService.cs | 179 +++++++++ .../Org/UserServices.cs | 108 ++++++ .../System/Dtos/DictDataQueryDto.cs | 2 +- .../System/Services/DictDataService.cs | 2 +- BPA.SAAS.Manage.Core/Base/IBaseEntity.cs | 4 +- BPA.SAAS.Manage.Core/Base/IDeleted.cs | 16 + BPA.SAAS.Manage.Core/Base/IGroupId.cs | 13 + BPA.SAAS.Manage.Core/DataBase/BPA_Batching.cs | 95 +++++ .../DataBase/BPA_BatchingType.cs | 31 ++ .../DataBase/BPA_BatchingUint.cs | 30 ++ BPA.SAAS.Manage.Core/DataBase/BPA_Bom.cs | 45 +++ .../DataBase/BPA_BomAttributeValueRe.cs | 27 ++ BPA.SAAS.Manage.Core/DataBase/BPA_BomEntry.cs | 43 +++ .../DataBase/BPA_BomTypeInfo.cs | 30 ++ .../DataBase/BPA_GoodsAttribute.cs | 28 ++ .../DataBase/BPA_GoodsAttributeValue.cs | 29 ++ BPA.SAAS.Manage.Core/DataBase/BPA_GoodsBom.cs | 29 ++ .../DataBase/BPA_GoodsInfo.cs | 17 + .../DataBase/BPA_GoodsType.cs | 26 ++ BPA.SAAS.Manage.Core/DbContext.cs | 41 +- BPA.SAAS.Manage.Core/Org/BPA_Organize.cs | 2 +- BPA.SAAS.Manage.Core/Org/BPA_Roles.cs | 2 +- BPA.SAAS.Manage.Core/Org/BPA_Users.cs | 10 +- 53 files changed, 2346 insertions(+), 13 deletions(-) create mode 100644 BPA.SAAS.Manage.Application/DataBase/BatchingServices.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingDetailedDto.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingInfoDto.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingListQuery.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingStatusDto.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingTypeDto.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingUintDto.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeDto.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeList.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeQueryDto.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeValueDto.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeView.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsBomAttributeDto.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/GoodsAttributeServices.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Interface/IBatchingService.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsAttributeService.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs create mode 100644 BPA.SAAS.Manage.Application/DataBase/Services/GoodsAttributeService.cs create mode 100644 BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoOutput.cs create mode 100644 BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoPageInput.cs create mode 100644 BPA.SAAS.Manage.Application/Org/Dtos/Users/UserPwdDtoInput.cs create mode 100644 BPA.SAAS.Manage.Application/Org/Dtos/Users/UserRoleDtoInput.cs create mode 100644 BPA.SAAS.Manage.Application/Org/UserServices.cs create mode 100644 BPA.SAAS.Manage.Core/Base/IDeleted.cs create mode 100644 BPA.SAAS.Manage.Core/Base/IGroupId.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_Batching.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_BatchingType.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_BatchingUint.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_Bom.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_BomAttributeValueRe.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_BomEntry.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_BomTypeInfo.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttribute.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttributeValue.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_GoodsBom.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_GoodsInfo.cs create mode 100644 BPA.SAAS.Manage.Core/DataBase/BPA_GoodsType.cs diff --git a/BPA.SAAS.Manage.Application/Auth/AuthService.cs b/BPA.SAAS.Manage.Application/Auth/AuthService.cs index b4c599b..4dc24be 100644 --- a/BPA.SAAS.Manage.Application/Auth/AuthService.cs +++ b/BPA.SAAS.Manage.Application/Auth/AuthService.cs @@ -44,7 +44,7 @@ namespace BPA.SAAS.Manage.Application.Auth //获取权限 var company = _db.Queryable().First(x => x.Id == user.GroupId && x.Status == CommonStatus.ENABLE && x.IsDeleted == 0); string CLAINM_SUPERADMIN = "Customer"; - if (user.AdminType == 0) + if (user.AdminType == 1) { CLAINM_SUPERADMIN = "1"; } diff --git a/BPA.SAAS.Manage.Application/DataBase/BatchingServices.cs b/BPA.SAAS.Manage.Application/DataBase/BatchingServices.cs new file mode 100644 index 0000000..f4ec6ca --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/BatchingServices.cs @@ -0,0 +1,133 @@ +using BPA.SAAS.Manage.Application.DataBase.Dtos.Batching; +using BPA.SAAS.Manage.Application.DataBase.Interface; +using BPA.SAAS.Manage.Core.Base; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase +{ + [ApiDescriptionSettings("DataBase", Tag = "物料基础信息")] + public class BatchingServices: IDynamicApiController + { + IBatchingService _batchingService; + public BatchingServices(IBatchingService batchingService) + { + _batchingService= batchingService; + } + /// + /// 分页查询 + /// + /// + /// + [HttpPost("/api/batching/getpage")] + public async Task GetBatchingList(BatchingListQuery dto) + { + return await _batchingService.GetBatchingList(dto); + } + /// + /// 添加 + /// + /// + /// + [HttpPost("/api/batching/add")] + public async Task AddBatching(BatchingInfoDto dto) + { + return await _batchingService.AddBatching(dto); + } + /// + /// 修改 + /// + /// + /// + [HttpPost("/api/batching/update")] + public async Task UpdateBatching(BatchingInfoDto dto) + { + return await _batchingService.UpdateBatching(dto); + } + /// + /// 删除 + /// + /// + /// + [HttpPost("/api/batching/delete")] + public async Task BatchDelBatching(List Ids) + { + return await _batchingService.BatchDelBatching(Ids); + } + /// + /// 物料列表 + /// + /// + [HttpGet("/api/batching/getbatchinglist")] + public async Task> GetBatchingList() + { + return await _batchingService.GetBatchingList(); + } + [HttpPost("/api/batching/updatebatchingstatus")] + public async Task UpdateBatchingStatus(BatchingStatusDto dto) + { + return await _batchingService.UpdateBatchingStatus(dto); + } + /// + /// 物料类型列表 + /// + /// + [HttpGet("/api/batching/getbatchingtypelist")] + public async Task> GetBatchingTypeList() + { + return await _batchingService.GetBatchingTypeList(); + } + /// + /// 添加物料类型 + /// + /// + /// + [HttpPost("/api/batching/addbatchingtype")] + public async Task AddBatchingType(BatchingTypeDto dto) + { + return await _batchingService.AddBatchingType(dto); + } + /// + /// 删除物料类型 + /// + /// + /// + [HttpGet("/api/batching/batchtypedel")] + public async Task BatchTypeDel(string id) + { + return await _batchingService.BatchTypeDel(id); + } + /// + /// 物料单位列表 + /// + /// + [HttpGet("/api/batching/getbatchinguintList")] + public async Task> GetBatchingUintList() + { + return await _batchingService.GetBatchingUintList(); + } + /// + /// 添加物料物料单位 + /// + /// + /// + [HttpPost("/api/batching/addbatchinguint")] + public async Task AddBatchingUint(BatchingUintDto dto) + { + return await _batchingService.AddBatchingUint(dto); + } + /// + /// 删除物料单位 + /// + /// + /// + [HttpGet("/api/batching/batchinguintdel")] + public async Task BatchingUintDel(string id) + { + return await _batchingService.BatchingUintDel(id); + } + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingDetailedDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingDetailedDto.cs new file mode 100644 index 0000000..737c068 --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingDetailedDto.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Batching +{ + public class BatchingDetailedDto + { + + /// + /// 物料id + /// + public string Id { get; set; } + /// + /// 单位 + /// + public string PackUnit { get; set; } + /// + /// 物料编码 + /// + public string PackCode { get; set; } + + public string Code { get; set; } + /// + /// 换算比例 + /// + public decimal Proportion { get; set; } + + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingInfoDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingInfoDto.cs new file mode 100644 index 0000000..28fa61e --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingInfoDto.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Batching +{ + public class BatchingInfoDto + { + /// + /// 物料id + /// + public string Id { get; set; } + /// + /// 物料名称 + /// + public string Name { get; set; } + /// + /// 物料编码 + /// + public string code { get; set; } + /// + /// 物料规格 + /// + public string specs { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } + /// + /// 单位 + /// + public string StockUint { get; set; } + /// + /// 类型 + /// + public string TypeID { get; set; } + /// + /// itemName + /// + public string itemName { get; set; } + /// + /// 状态 + /// + public string Status { get; set; } + /// + /// 原料属性 + /// + public string Aittribute { get; set; } + /// + /// 配料类型 + /// + public string batchingType { get; set; } + + /// + /// 成本价 + /// + public decimal Price { get; set; } + + + /// + /// 出库单位 + /// + public string outstockUint { get; set; } + + + /// + /// 换算比例 + /// + public decimal proportion { get; set; } + /// + /// 净料率 + /// + public decimal netrecovery { get; set; } + /// + /// + /// + public List membersList { get; set; } + public string ForeignKeyRe { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingListQuery.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingListQuery.cs new file mode 100644 index 0000000..6cfeef0 --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingListQuery.cs @@ -0,0 +1,93 @@ +using BPA.SAAS.Manage.Core.Base; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Batching +{ + public class BatchingListQuery : PageInputBase + { + /// + /// 编号 + /// + public string Id { get; set; } + /// + /// 原料编码 + /// + public string Code { get; set; } + /// + /// 商品属性 (0成品,1半成品,2,易耗品) + /// + public string Aittribute { get; set; } + /// + /// 原料名称 + /// + public string Name { get; set; } + /// + /// 原料类型 + /// + public string TypeID { get; set; } + /// + /// 原料类型名称 + /// + public string TypeName { get; set; } + /// + /// 创建时间 + /// + public DateTime? CreateAt { get; set; } + /// + /// 修改时间 + /// + public DateTime? UpdateAt { get; set; } + /// + /// 库存单位 + /// + public string StockUint { get; set; } + /// + /// 库存单位名称 + /// + public string StockUintName { get; set; } + + /// + /// 规格属性 + /// + public string Specs { get; set; } + /// + /// 状态 + /// + public string Status { get; set; } + /// + /// + /// + public string batchingType { get; set; } + /// + /// 成本价 + /// + public decimal? Price { get; set; } + /// + /// 净料率 + /// + public decimal? netrecovery { get; set; } + + /// + /// 出库单位 + /// + public string outstockUint { get; set; } + + + /// + /// 换算比例 + /// + public decimal proportion { get; set; } + /// + /// + /// + public List MembersList { get; set; } + public DateTime? DeleteAt { get; set; } + public string DeleteBy { get; set; } + public string ForeignKeyRe { get; set; } + + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingStatusDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingStatusDto.cs new file mode 100644 index 0000000..e6745b4 --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingStatusDto.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Batching +{ + public class BatchingStatusDto + { + public string Id { get; set; } + public int Status { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingTypeDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingTypeDto.cs new file mode 100644 index 0000000..f426977 --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingTypeDto.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Batching +{ + public class BatchingTypeDto + { + public string Name { get; set; } + + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingUintDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingUintDto.cs new file mode 100644 index 0000000..1a4d405 --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingUintDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Batching +{ + public class BatchingUintDto + { + public string Name { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeDto.cs new file mode 100644 index 0000000..aa9923e --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeDto.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute +{ + public class GoodsAttributeDto + { + public string Id { get; set; } + public string AttributeName { get; set; } + /// + /// 商品小类id + /// + public string[] GoodsTypeId { get; set; } + public int Sort { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeList.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeList.cs new file mode 100644 index 0000000..286ff5f --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeList.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute +{ + public class GoodsAttributeList + { + public string GoodsAttributeId { get; set; } + /// + /// 属性名称 + /// + public string AttributeName { get; set; } + /// + /// 商品小类id + /// + public string GoodsTypeId { get; set; } + public int Sort { get; set; } + public List GoodsAttributeValueList { get; set; } + } + public class GoodsAttributeValueList + { + public string GoodsAttributeValuId { get; set; } + /// + ///商品属性id + /// + public string GoodsAttributeId { get; set; } + /// + /// 属性值 + /// + public string AttributeValue { get; set; } + public int Sort { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeQueryDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeQueryDto.cs new file mode 100644 index 0000000..93e2e00 --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeQueryDto.cs @@ -0,0 +1,15 @@ +using BPA.SAAS.Manage.Core.Base; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute +{ + public class GoodsAttributeQueryDto : PageInputBase + { + public string AttributeName { get; set; } + public string GoodsTypeName { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeValueDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeValueDto.cs new file mode 100644 index 0000000..fa7ea52 --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeValueDto.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute +{ + public class GoodsAttributeValueDto + { + public string Id { get; set; } + /// + ///商品属性id + /// + public string GoodsAttributeId { get; set; } + /// + /// 属性值 + /// + public string AttributeValue { get; set; } + public int Sort { get; set; } + public string WaiKey { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeView.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeView.cs new file mode 100644 index 0000000..f619184 --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeView.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute +{ + public class GoodsAttributeView + { + public string Id { get; set; } + /// + /// 属性名称 + /// + public string AttributeName { get; set; } + /// + /// 商品小类id + /// + public string GoodsTypeId { get; set; } + public string GoodsTypeName { get; set; } + public int Sort { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsBomAttributeDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsBomAttributeDto.cs new file mode 100644 index 0000000..dac6ab2 --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsBomAttributeDto.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute +{ + public class GoodsBomAttributeDto + { + public string GoodsId { get; set; } + public string BomName { get; set; } + public string BomType { get; set; } + public string[] BomtypeList { get; set; } + public List Mate { get; set; } + public string[] Shuxing { get; set; } + } + public class Mate + { + public string batchingId { get; set; } + public int dosage { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/GoodsAttributeServices.cs b/BPA.SAAS.Manage.Application/DataBase/GoodsAttributeServices.cs new file mode 100644 index 0000000..7baa45c --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/GoodsAttributeServices.cs @@ -0,0 +1,102 @@ +using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute; +using BPA.SAAS.Manage.Application.DataBase.Interface; +using BPA.SAAS.Manage.Core.Base; +using BPA.SAAS.Manage.Core.DataBase; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase +{ + [ApiDescriptionSettings("GoodsAttribute", Tag = "商品属性管理")] + public class GoodsAttributeServices: IDynamicApiController, ITransient + { + IGoodsAttributeService _goodsAttributeServices; + public GoodsAttributeServices(IGoodsAttributeService goodsAttributeServices) + { + _goodsAttributeServices = goodsAttributeServices; + } + /// + /// 分页查询 + /// + /// + /// + [HttpPost("/api/goodsattribute/getgoodsattributepage")] + public PageUtil GetGoodsAttributePageAsync(GoodsAttributeQueryDto dto) + { + return _goodsAttributeServices.GetGoodsAttributePageAsync(dto); + } + /// + /// 添加/修改 + /// + /// + /// + [HttpPost("/api/goodsattribute/addgoodsattribute")] + public async Task AddGoodsAttribute(GoodsAttributeDto dto) + { + return await _goodsAttributeServices.AddGoodsAttribute(dto); + } + /// + /// 删除 + /// + /// + /// + [HttpPost("/api/goodsattribute/deletegoodsattribute")] + public async Task DeleteGoodsAttribute([FromBody] string[] Ids) + { + return await _goodsAttributeServices.DeleteGoodsAttribute(Ids); + } + /// + /// 查询商品属性值列表 + /// + /// + /// + [HttpGet("/api/goodsattribute/getgoodsattributevalue")] + public async Task> GetGoodsAttributeValueAsync(string goodsAttributeId) + { + return await _goodsAttributeServices.GetGoodsAttributeValueAsync(goodsAttributeId); + } + /// + /// 添加/修改 + /// + /// + /// + [HttpPost("/api/goodsattribute/addgoodsattributevalue")] + public async Task AddGoodsAttributeValue(List dto) + { + return await _goodsAttributeServices.AddGoodsAttributeValue(dto); + } + /// + /// 删除 + /// + /// + /// + [HttpGet("/api/goodsattribute/deletegoodsattributevalue")] + public async Task DeleteGoodsAttributeValue(string id) + { + return await _goodsAttributeServices.DeleteGoodsAttributeValue(id); + } + /// + /// 根据商品id查询商品属性 + /// + /// + /// + [HttpGet("/api/goodsattribute/getbygoodsidattribute")] + public async Task> GetByGoodsIdAttribute(string id) + { + return await _goodsAttributeServices.GetByGoodsIdAttribute(id); + } + /// + /// 添加商品配方 + /// + /// + /// + [HttpPost("/api/goodsattribute/addgoodsbomattribute")] + public async Task AddGoodsBomAttribute(GoodsBomAttributeDto dto) + { + return await _goodsAttributeServices.AddGoodsBomAttribute(dto); + } + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Interface/IBatchingService.cs b/BPA.SAAS.Manage.Application/DataBase/Interface/IBatchingService.cs new file mode 100644 index 0000000..172b5f1 --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Interface/IBatchingService.cs @@ -0,0 +1,26 @@ +using BPA.SAAS.Manage.Application.DataBase.Dtos.Batching; +using BPA.SAAS.Manage.Core.Base; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Interface +{ + public interface IBatchingService + { + Task GetBatchingList(BatchingListQuery dto); + Task AddBatching(BatchingInfoDto dto); + Task UpdateBatching(BatchingInfoDto dto); + Task BatchDelBatching(List Ids); + Task> GetBatchingList(); + Task UpdateBatchingStatus(BatchingStatusDto dto); + Task> GetBatchingTypeList(); + Task AddBatchingType(BatchingTypeDto dto); + Task BatchTypeDel(string id); + Task> GetBatchingUintList(); + Task AddBatchingUint(BatchingUintDto dto); + Task BatchingUintDel(string id); + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsAttributeService.cs b/BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsAttributeService.cs new file mode 100644 index 0000000..8024c9f --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsAttributeService.cs @@ -0,0 +1,59 @@ +using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute; +using BPA.SAAS.Manage.Core.Base; +using BPA.SAAS.Manage.Core.DataBase; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Interface +{ + public interface IGoodsAttributeService + { + /// + /// 分页查询 + /// + /// + /// + PageUtil GetGoodsAttributePageAsync(GoodsAttributeQueryDto dto); + /// + /// 添加/修改 + /// + /// + /// + Task AddGoodsAttribute(GoodsAttributeDto dto); + /// + /// 删除 + /// + /// + /// + Task DeleteGoodsAttribute(string[] Ids); + /// + /// 查询商品属性值列表 + /// + /// + /// + Task> GetGoodsAttributeValueAsync(string goodsAttributeId); + /// + /// 添加/修改 + /// + /// + /// + Task AddGoodsAttributeValue(List dto); + /// + /// 删除 + /// + /// + /// + Task DeleteGoodsAttributeValue(string id); + /// + /// 根据商品id查询商品属性 + /// + /// + /// + Task> GetByGoodsIdAttribute(string id); + Task AddGoodsBomAttribute(GoodsBomAttributeDto dto); + Task> GetByNameAttribute(string name); + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs new file mode 100644 index 0000000..b59e9fb --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs @@ -0,0 +1,364 @@ +using BPA.SAAS.Manage.Application.DataBase.Dtos.Batching; +using BPA.SAAS.Manage.Application.DataBase.Interface; +using BPA.SAAS.Manage.Comm.Const; +using BPA.SAAS.Manage.Comm.Enum; +using BPA.SAAS.Manage.Core.Base; +using BPA.SAAS.Manage.Core.DataBase; +using Swashbuckle.AspNetCore.SwaggerGen; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.DataBase.Services +{ + public class BatchingService: IBatchingService ,ITransient + { + private readonly ISqlSugarClient _db; + public BatchingService(ISqlSugarClient db) + { + _db=db; + } + #region 物料 + /// + /// 分页 + /// + /// + /// + public async Task GetBatchingList(BatchingListQuery dto) + { + string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; + #region 查询条件 + List conModels = new List(); + if (!string.IsNullOrEmpty(dto.Name))//物料名称 + { + conModels.Add(new ConditionalModel() { FieldName = "a.Batching_Name", ConditionalType = ConditionalType.Like, FieldValue = dto.Name }); + } + if (!string.IsNullOrEmpty(dto.Code))//物料编码 + { + conModels.Add(new ConditionalModel() { FieldName = "a.Code", ConditionalType = ConditionalType.Like, FieldValue = dto.Code }); + } + if (!string.IsNullOrEmpty(dto.StockUint))//物料单位 + { + conModels.Add(new ConditionalModel() { FieldName = "c.Id", ConditionalType = ConditionalType.Equal, FieldValue = dto.StockUint }); + } + if (!string.IsNullOrEmpty(dto.Specs))//物料规格 + { + conModels.Add(new ConditionalModel() { FieldName = "a.Specs", ConditionalType = ConditionalType.Equal, FieldValue = dto.Specs }); + } + if (!string.IsNullOrEmpty(dto.Aittribute))//物料属性 + { + conModels.Add(new ConditionalModel() { FieldName = "a.Aittribute", ConditionalType = ConditionalType.Equal, FieldValue = dto.Aittribute.ToString() }); + } + if (!string.IsNullOrEmpty(dto.TypeID))//物料类别 + { + conModels.Add(new ConditionalModel() { FieldName = "b.Id", ConditionalType = ConditionalType.Equal, FieldValue = dto.TypeID }); + } + if (!string.IsNullOrEmpty(dto.Status)) + { + conModels.Add(new ConditionalModel() { FieldName = "a.Status", ConditionalType = ConditionalType.Equal, FieldValue = dto.Status }); + } + if (!string.IsNullOrEmpty(groupId)) + { + conModels.Add(new ConditionalModel() { FieldName = "a.GroupId", ConditionalType = ConditionalType.Equal, FieldValue = groupId }); + } + if (dto.Price != null) + { + conModels.Add(new ConditionalModel() { FieldName = "a.Price", ConditionalType = ConditionalType.Equal, FieldValue = dto.Price.ToString() }); + } + if (dto.netrecovery != null) + { + conModels.Add(new ConditionalModel() { FieldName = "a.netrecovery", ConditionalType = ConditionalType.Equal, FieldValue = dto.netrecovery.ToString() }); + } + #endregion + RefAsync total = 0; + var res =await _db.Queryable((a, b, c) => + new JoinQueryInfos(JoinType.Inner, a.TypeID == b.Id, JoinType.Inner, a.StockUint == c.Id)) + .Where((a, b, c) => a.IsDeleted == 0 && b.IsDeleted == 0 && c.IsDeleted == 0) + .Where(conModels) + .WhereIF(dto.CreateAt.HasValue, a => SqlFunc.DateIsSame(a.CreateAt, Convert.ToDateTime(dto.CreateAt), DateType.Day)) + .OrderBy((a, b, c) => a.CreateAt, OrderByType.Desc) + .Select((a, b, c) => new BatchingListQuery() + { + Id = a.Id, + Name = a.Batching_Name, + Code = a.Code, + StockUint = a.StockUint, + StockUintName = c.Name, + Specs = a.Specs, + Aittribute = a.Aittribute.ToString(), + TypeID = b.Id, + TypeName = b.Name, + CreateAt = a.CreateAt, + Status = a.Status.ToString(), + batchingType = a.Batching_Type, + Price = a.Price, + netrecovery = a.netrecovery, + outstockUint = a.outstockUint, + proportion = a.proportion, + ForeignKeyRe = a.ForeignKeyRe + }) + .ToPageListAsync(dto.Current, dto.PageSize, total); + res.ForEach(list => + { + int total1 = 0; + //var res1 = _db.Queryable() + // .Where(a => a.IsDeleted == 0 && a.ProductID == list.Id) + // .OrderBy(a => a.CreateAt, OrderByType.Asc) + // .Select(a => new ProductDetailedDto + // { + // Id = a.Id, + // Code = a.Code, + // PackUnit = a.PackUnit, + // Proportion = a.Proportion + // }) + + // .ToPageList(dto.Current, dto.PageSize, ref total1); + list.MembersList = null; + + }); + PageUtil util = new PageUtil() + { + Total = total, + Data = res + + }; + return util; + } + + /// + /// 添加 + /// + /// + /// + public async Task AddBatching(BatchingInfoDto dto) + { + var productCode = _db.Queryable().Where(x => x.IsDeleted == 0 && x.Code == dto.code).ToList(); + if (productCode.Count() > 0) + { + throw Oops.Oh("编码已存在"); + } + try + { + BPA_Batching bPA_Product = new BPA_Batching(); + bPA_Product.StockUint = dto.StockUint; + bPA_Product.TypeID = dto.TypeID; + bPA_Product.Code = dto.code; + bPA_Product.Batching_Name = dto.Name; + bPA_Product.Specs = dto.specs; + bPA_Product.Status = CommonStatus.ENABLE; + bPA_Product.Aittribute = Convert.ToInt32(dto.Aittribute); + bPA_Product.Batching_Type = dto.batchingType; + bPA_Product.Price = dto.Price; + bPA_Product.netrecovery = dto.netrecovery; + bPA_Product.outstockUint = dto.outstockUint; + bPA_Product.proportion = dto.proportion; + bPA_Product.ForeignKeyRe = dto.ForeignKeyRe; + var res=await _db.Insertable(bPA_Product).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); + return res>0; + } + catch (Exception ex) + { + throw Oops.Oh("添加失败"); + } + } + /// + /// 修改物料信息 + /// + /// + /// + public async Task UpdateBatching(BatchingInfoDto dto) + { + var Code = _db.Queryable().Where(x => x.Id == dto.Id).First(); + if (Code.Code != dto.code) + { + throw Oops.Oh("编码已存在"); + } + try + { + BPA_Batching bPA_Product = new BPA_Batching(); + bPA_Product.StockUint = dto.StockUint; + bPA_Product.TypeID = dto.TypeID; + bPA_Product.Code = dto.code; + bPA_Product.Batching_Name = dto.Name; + bPA_Product.Specs = dto.specs; + bPA_Product.Id = dto.Id; + bPA_Product.Aittribute = Convert.ToInt32(dto.Aittribute); + bPA_Product.Batching_Type = dto.batchingType; + bPA_Product.Price = dto.Price; + bPA_Product.netrecovery = dto.netrecovery; + bPA_Product.outstockUint = dto.outstockUint; + bPA_Product.proportion = dto.proportion; + bPA_Product.ForeignKeyRe = dto.ForeignKeyRe; + if (!string.IsNullOrEmpty(dto.Status)) + { + bPA_Product.Status = (CommonStatus)Enum.ToObject(typeof(CommonStatus), int.Parse(dto.Status)); + } + var res=await _db.Updateable(bPA_Product).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + + return res>0; + } + catch (Exception) + { + throw Oops.Oh("更新失败"); + } + } + + /// + /// 删除物料信息 + /// + /// + /// + public async Task BatchDelBatching(List Ids) + { + try + { + // 查询数据库中是否存在未删除的活动信息 + var resEntitites = _db.Queryable().In(Ids).ToList(); + resEntitites.ForEach(x => + { + x.IsDeleted = 1; + }); + var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); + + return res>0; + } + catch (Exception) + { + throw Oops.Oh("删除失败"); + } + } + /// + /// 查询所有物料信息 + /// + /// + public async Task> GetBatchingList() + { + var res = await _db.Queryable() + .ToDictionaryAsync(x => x.Id, x => x.Batching_Name); + return res; + } + /// + /// 更新物料状态 + /// + /// + /// + public async Task UpdateBatchingStatus(BatchingStatusDto dto) + { + try + { + // 查询数据库中是否存在未删除的活动信息 + var resEntitites = _db.Queryable().Where(x => x.IsDeleted == 0 && x.Id == dto.Id).First(); + if (resEntitites != null) + { + + resEntitites.Status = (CommonStatus)Enum.ToObject(typeof(CommonStatus), dto.Status); + + } + var res =await _db.Updateable(resEntitites).UpdateColumns(x => new { x.Status }).ExecuteCommandAsync(); + + return res>0; + } + catch (Exception) + { + return false; + } + + } + #endregion + #region 物料类型 + public async Task> GetBatchingTypeList() + { + var res = await _db.Queryable().Select(x => new + + { + id = x.Id, + name=x.Name + }) .ToListAsync(); + return res; + } + public async Task AddBatchingType(BatchingTypeDto dto) + { + var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; + var productCode = _db.Queryable().Where(x => x.IsDeleted == 0 && x.GroupId == groupId && x.Name== dto.Name).ToList(); + if (productCode.Count() > 0) + { + throw Oops.Oh("物料类型已存在"); + } + try + { + BPA_BatchingType bPA_Product = new BPA_BatchingType(); + bPA_Product.Name = dto.Name; + var res = await _db.Insertable(bPA_Product).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); + return res > 0; + } + catch (Exception ex) + { + throw Oops.Oh("添加失败"); + } + } + public async Task BatchTypeDel(string id) + { + try + { + // 查询数据库中是否存在未删除的活动信息 + var resEntitites =await _db.Queryable().Where(x=>x.Id== id).FirstAsync(); + resEntitites.IsDeleted= 1; + var res = await _db.Updateable(resEntitites).ExecuteCommandAsync(); + return res > 0; + } + catch (Exception) + { + throw Oops.Oh("删除失败"); + } + } + #endregion + #region 物料单位 + public async Task> GetBatchingUintList() + { + var res = await _db.Queryable().Select(x => new + { + id = x.Id, + name = x.Name + }).ToListAsync(); + return res; + } + public async Task AddBatchingUint(BatchingUintDto dto) + { + var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; + var productCode = _db.Queryable().Where(x => x.IsDeleted == 0 && x.GroupId == groupId && x.Name == dto.Name).ToList(); + if (productCode.Count() > 0) + { + throw Oops.Oh("物料单位已存在"); + } + try + { + BPA_BatchingUint bPA_Product = new BPA_BatchingUint(); + bPA_Product.Name = dto.Name; + var res = await _db.Insertable(bPA_Product).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); + return res > 0; + } + catch (Exception ex) + { + throw Oops.Oh("添加失败"); + } + } + public async Task BatchingUintDel(string id) + { + try + { + // 查询数据库中是否存在未删除的活动信息 + var resEntitites = await _db.Queryable().Where(x => x.Id == id).FirstAsync(); + resEntitites.IsDeleted = 1; + var res = await _db.Updateable(resEntitites).ExecuteCommandAsync(); + return res > 0; + } + catch (Exception) + { + throw Oops.Oh("删除失败"); + } + } + #endregion + } +} diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsAttributeService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsAttributeService.cs new file mode 100644 index 0000000..b40dce9 --- /dev/null +++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsAttributeService.cs @@ -0,0 +1,328 @@ +using BPA.SAAS.Manage.Application.DataBase.Interface; +using BPA.SAAS.Manage.Core.Base; +using BPA.SAAS.Manage.Comm.Const; +using BPA.SAAS.Manage.Core.DataBase; +using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute; +using StackExchange.Profiling.Internal; + +namespace BPA.Franchisee.Application.FranchiseeCenter.GoodsServices +{ + public class GoodsAttributeService: IGoodsAttributeService, ITransient + { + private readonly ISqlSugarClient _db; + public GoodsAttributeService(ISqlSugarClient _db) + { + _db = _db; // 推荐操作 + } + /// + /// 分页查询 + /// + /// m + /// + public PageUtil GetGoodsAttributePageAsync(GoodsAttributeQueryDto dto) + { + List conModels = new List(); + string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; + + int total = new RefAsync(); + + var res = _db.Queryable() + .Where(a=> a.IsDeleted == 0) + .WhereIF(!dto.AttributeName.IsNullOrWhiteSpace(),x=>x.AttributeName.Contains(dto.AttributeName)) + .WhereIF(!dto.GoodsTypeName.IsNullOrWhiteSpace(), x => x.GoodsTypeId.Contains(dto.GoodsTypeName)) + .OrderBy(a => a.CreateAt, OrderByType.Desc) + .Select(a => new GoodsAttributeView + { + Id = a.Id, + AttributeName=a.AttributeName, + GoodsTypeId= a.GoodsTypeId, + Sort =a.Sort, + }) + .Mapper(x => + { + var tyname=_db.Queryable().Where(p=> x.GoodsTypeId.Contains(p.Id)).Select(x=>x.Name).ToArray(); + x.GoodsTypeName = string.Join(",", tyname); + }) + .ToPageList(dto.Current, dto.PageSize, ref total); + PageUtil util = new PageUtil() + { + Total = total, + Data = res + }; + return util; + } + /// + /// 添加/修改 + /// + /// + /// + public async Task AddGoodsAttribute(GoodsAttributeDto dto) + { + if (!string.IsNullOrWhiteSpace(dto.Id)) + { + var resEntity = _db.Queryable().Where(it => it.IsDeleted == 0).First(it => it.Id == dto.Id); + if (null == resEntity) + { + return false; + } + resEntity.AttributeName = dto.AttributeName; + resEntity.GoodsTypeId = string.Join(',', dto.GoodsTypeId) ; + resEntity.Sort = dto.Sort; + var res =await _db.Updateable(resEntity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + return res > 0; + } + else + { + var newGoods = new BPA_GoodsAttribute + { + AttributeName = dto.AttributeName, + GoodsTypeId = string.Join(',', dto.GoodsTypeId), + Sort = dto.Sort, + }; + var res =await _db.Insertable(newGoods).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); + return res > 0; + } + + } + /// + /// 删除 + /// + /// + /// + public async Task DeleteGoodsAttribute(string[] Ids) + { + + // 查询数据库中是否存在未删除的商品 + var resEntitites = _db.Queryable().In(Ids).ToList(); + + resEntitites.ForEach(x => + { + x.IsDeleted = 1; + }); + var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); + if (res > 0) + { + var resEntititesattr = _db.Queryable().In("GoodsAttributeId", Ids).ToList(); + if (resEntititesattr != null) + { + resEntititesattr.ForEach(x => + { + x.IsDeleted = 1; + }); + await _db.Updateable(resEntititesattr).ExecuteCommandAsync(); + } + } + return res > 0; + + } + /// + /// 查询商品属性值列表 + /// + /// + /// + public async Task> GetGoodsAttributeValueAsync(string goodsAttributeId) + { + string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; + + var res =await _db.Queryable().Where(x=>x.GoodsAttributeId== goodsAttributeId && x.IsDeleted==0) + + .OrderBy(a => a.CreateAt, OrderByType.Desc) + .Select(a => new BPA_GoodsAttributeValue + { + Id = a.Id.SelectAll(), + }) + .ToListAsync(); + return res; + } + /// + /// 添加/修改 + /// + /// + /// + public async Task AddGoodsAttributeValue(List dto) + { + List editlist = new(); + List addlist = new(); + var res = 0; + for (int i = 0; i < dto.Count; i++) + { + Guid newGuid = Guid.Empty; + if (Guid.TryParse(dto[i].Id, out newGuid)) + { + var resEntity = _db.Queryable().Where(it => it.IsDeleted == 0).First(it => it.Id == dto[i].Id); + resEntity.AttributeValue = dto[i].AttributeValue; + resEntity.Sort = dto[i].Sort; + resEntity.WaiKey= dto[i].WaiKey; + editlist.Add(resEntity); + } + else + { + var newGoods = new BPA_GoodsAttributeValue + { + GoodsAttributeId = dto[i].GoodsAttributeId, + AttributeValue = dto[i].AttributeValue, + Sort = dto[i].Sort, + WaiKey = dto[i].WaiKey + }; + addlist.Add(newGoods); + } + } + if (editlist.Count > 0) + { + res = await _db.Updateable(editlist).ExecuteCommandAsync(); + } + if (addlist.Count > 0) + { + res = await _db.Insertable(addlist).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); + } + return res > 0; + } + /// + /// 删除 + /// + /// + /// + public async Task DeleteGoodsAttributeValue(string id) + { + + // 查询数据库中是否存在未删除的商品 + var resEntitites = _db.Queryable().In(id).ToList(); + + resEntitites.ForEach(x => + { + x.IsDeleted = 1; + }); + var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); + if (res > 0) + { + + //1.查询上架商品 + //2.删除上架商品 + } + return res > 0; + + } + /// + /// 根据商品id查询商品属性 + /// + /// + /// + public async Task> GetByGoodsIdAttribute(string id) + { + var goods=await _db.Queryable().Where(x => x.Id == id).FirstAsync(); + if (goods == null) throw Oops.Oh("商品不存在"); + var goodsAttributeList = await _db.Queryable().Where(x => x.GoodsTypeId.Contains( goods.GoodsTypeId) && x.IsDeleted == 0) + .Select(x=>new GoodsAttributeList() + { + GoodsAttributeId=x.Id, + AttributeName=x.AttributeName, + GoodsTypeId=goods.GoodsTypeId, + Sort=x.Sort, + }).Mapper(p => + { + p.GoodsAttributeValueList = _db.Queryable().Where(x => x.GoodsAttributeId == p.GoodsAttributeId && x.IsDeleted==0).Select(x => new GoodsAttributeValueList() + { + GoodsAttributeValuId = x.Id, + GoodsAttributeId = p.GoodsAttributeId, + AttributeValue = x.AttributeValue, + Sort = x.Sort + }).ToList(); + }) + .OrderBy(x=>x.Sort,OrderByType.Asc) + .ToListAsync(); + return goodsAttributeList; + } + public async Task> GetByNameAttribute(string name) + { + //var goods = await _db.Queryable().Where(x => x.Id == id).FirstAsync(); + //if (goods == null) throw Oops.Oh("商品不存在"); + var goodsAttributeList = await _db.Queryable().Where(x => x.AttributeName== name && x.IsDeleted == 0) + .Select(x => new GoodsAttributeList() + { + GoodsAttributeId = x.Id, + AttributeName = x.AttributeName, + //GoodsTypeId = goods.Goods_TypeID, + Sort = x.Sort, + }).Mapper(p => + { + p.GoodsAttributeValueList = _db.Queryable().Where(x => x.GoodsAttributeId == p.GoodsAttributeId && x.IsDeleted == 0).Select(x => new GoodsAttributeValueList() + { + GoodsAttributeValuId = x.Id, + GoodsAttributeId = p.GoodsAttributeId, + AttributeValue = x.AttributeValue, + Sort = x.Sort + }).ToList(); + }) + .OrderBy(x => x.Sort, OrderByType.Asc) + .ToListAsync(); + return goodsAttributeList; + } + /// + /// 添加商品配方 + /// + /// + /// + public async Task AddGoodsBomAttribute(GoodsBomAttributeDto dto) + { + _db.Ado.BeginTran(); + try + { + string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; + var sortMax = _db.Queryable().Max(x => x.Sort); + BPA_Bom newbPA_BOM = new BPA_Bom + { + Name = dto.BomName, + Code = DateTime.Now.ToString("yyyyMMddhhmmsss"), + IsMain = dto.BomType == "1" ? true : false, + Sort = sortMax + 1, + Id = Guid.NewGuid().ToString(), + CreateAt = DateTime.Now, + GroupId = groupId + }; + //添加配方 + var res = _db.Insertable(newbPA_BOM).ExecuteCommand(); + //添加配方分类 + var list = dto.BomtypeList.Select(item => new BPA_BomTypeInfo() { BomId = newbPA_BOM.Id, BomTypeId = item }).ToList(); + _db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommand(); + + BPA_GoodsBom bom = new BPA_GoodsBom(); + bom.Goods_Id = dto.GoodsId; + bom.BomId = newbPA_BOM.Id; + //添加商品配方关系 + _db.Insertable(bom).CallEntityMethod(m => m.Create()).ExecuteCommand(); + List BOMEntryList = new(); + if (dto.Mate.Count > 0) + { + for (int i = 0; i < dto.Mate.Count; i++) + { + BPA_BomEntry newbPA_BOMEnty = new BPA_BomEntry + { + BatchingId = dto.Mate[i].batchingId, + //BatchingKey = dto.Mate[i].AutoKey, + BomQty = dto.Mate[i].dosage, + BomId = newbPA_BOM.Id, + IsReplace = false, + }; + BOMEntryList.Add(newbPA_BOMEnty); + } + } + //添加配方物料关系 + _db.Insertable(BOMEntryList).CallEntityMethod(m => m.Create()).ExecuteCommand(); + BPA_BomAttributeValueRe bPA_BomAttributeValueRe = new(); + bPA_BomAttributeValueRe.Id = Guid.NewGuid().ToString(); + bPA_BomAttributeValueRe.GoodsId = dto.GoodsId; + bPA_BomAttributeValueRe.BoomId = newbPA_BOM.Id; + bPA_BomAttributeValueRe.GoodsAttributeValueId = string.Join(",", dto.Shuxing); + //添加商品配方属性关系 + _db.Insertable(bPA_BomAttributeValueRe).ExecuteCommand(); + _db.Ado.CommitTran(); + return true; + } + catch (Exception e) + { + _db.Ado.RollbackTran(); + throw Oops.Oh("添加失败,失败信息:" + e.Message); + } + } + } +} diff --git a/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoOutput.cs b/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoOutput.cs new file mode 100644 index 0000000..13026c2 --- /dev/null +++ b/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoOutput.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.Org.Dtos.Users +{ + public class UserDtoOutput + { + public string Id { get; set; } + /// + /// 用户名称 + /// + public string Name { get; set; } + /// + /// 登录账号 + /// + public string Account { get; set; } + /// + /// 登录密码 + /// + public string Password { get; set; } + /// + /// 手机号码 + /// + public string Phone { get; set; } + /// + /// 管理员类型-超级管理员_1、管理员_2、普通账号_3 + /// + public int AdminType { get; set; } + /// + /// 归属组织 + /// + public string SysOrgId { get; set; } + /// + /// 企业名称 + /// + public string CompanyName { get; set; } + public DateTime? CreateAt { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoPageInput.cs b/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoPageInput.cs new file mode 100644 index 0000000..fe2584c --- /dev/null +++ b/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoPageInput.cs @@ -0,0 +1,22 @@ +using BPA.SAAS.Manage.Core.Base; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.Org.Dtos.Users +{ + public class UserDtoPageInput : PageInputBase + { + /// + /// 昵称 + /// + public string Account { get; set; } + + /// + /// 姓名 + /// + public string Name { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserPwdDtoInput.cs b/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserPwdDtoInput.cs new file mode 100644 index 0000000..d941921 --- /dev/null +++ b/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserPwdDtoInput.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.Org.Dtos.Users +{ + public class UserPwdDtoInput + { + /// + /// 账户 + /// + public string Account { get; set; } + /// + /// 旧密码 + /// + public string OPwd { get; set; } + /// + /// 新密码 + /// + public string NPwd { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserRoleDtoInput.cs b/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserRoleDtoInput.cs new file mode 100644 index 0000000..bfc08de --- /dev/null +++ b/BPA.SAAS.Manage.Application/Org/Dtos/Users/UserRoleDtoInput.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.Org.Dtos.Users +{ + public class UserRoleDtoInput + { + public string Id { get; set; } + /// + /// 用户Id + /// + public string SysUserId { get; set; } + /// + /// 角色Id + /// + public string[] SysRoleId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs b/BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs index 178cb72..a4d89ca 100644 --- a/BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs +++ b/BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs @@ -16,5 +16,6 @@ namespace BPA.SAAS.Manage.Application.Org.Interface Task DeleteOrg(DeleteOrgInput input); Task UpdateOrg(UpdateOrgInput input); Task GetOrgTree(); + Task> GetOrgList(); } } diff --git a/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs b/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs index 54bdeab..8f3a997 100644 --- a/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs +++ b/BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs @@ -18,5 +18,6 @@ namespace BPA.SAAS.Manage.Application.Org.Interface Task AddOrUpdateMenuRole(RoleMenuDtoInput input); Task Disable(string Id); Task Enable(string Id); + Task> GetRole(); } } diff --git a/BPA.SAAS.Manage.Application/Org/Interface/IUserService.cs b/BPA.SAAS.Manage.Application/Org/Interface/IUserService.cs index aeee1b3..0c541c9 100644 --- a/BPA.SAAS.Manage.Application/Org/Interface/IUserService.cs +++ b/BPA.SAAS.Manage.Application/Org/Interface/IUserService.cs @@ -1,4 +1,5 @@ using BPA.SAAS.Manage.Application.Org.Dtos.Users; +using BPA.SAAS.Manage.Core.Base; using System; using System.Collections.Generic; using System.Linq; @@ -9,6 +10,15 @@ namespace BPA.SAAS.Manage.Application.Org.Interface { public interface IUserService { + Task UserPage(UserDtoPageInput input); Task AddUser(UserDtoInput input); + Task UpdateUser(UserDtoInput input); + Task DeleteUser(List input); + Task Enable(string Id); + Task Disable(string Id); + Task ResetPwd(string Id); + Task UpdatePwd(UserPwdDtoInput input); + Task GetUserRole(string UserId); + Task AddUserRole(UserRoleDtoInput input); } } diff --git a/BPA.SAAS.Manage.Application/Org/OrganizeServices.cs b/BPA.SAAS.Manage.Application/Org/OrganizeServices.cs index 8c570e6..45c43bd 100644 --- a/BPA.SAAS.Manage.Application/Org/OrganizeServices.cs +++ b/BPA.SAAS.Manage.Application/Org/OrganizeServices.cs @@ -76,5 +76,10 @@ namespace BPA.SAAS.Manage.Application.Org { return await _organizeService.GetOrgTree(); } + [HttpGet("/api/organize/getorglist")] + public async Task> GetOrgList() + { + return await _organizeService.GetOrgList(); + } } } diff --git a/BPA.SAAS.Manage.Application/Org/RolesServices.cs b/BPA.SAAS.Manage.Application/Org/RolesServices.cs index e3c1edf..c558fd7 100644 --- a/BPA.SAAS.Manage.Application/Org/RolesServices.cs +++ b/BPA.SAAS.Manage.Application/Org/RolesServices.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace BPA.SAAS.Manage.Application.Org { - [ApiDescriptionSettings("SYS", Tag = "角色信息")] + [ApiDescriptionSettings("Org", Tag = "角色信息")] public class RolesServices: IDynamicApiController { IRoleService _roleService; @@ -97,5 +97,14 @@ namespace BPA.SAAS.Manage.Application.Org { return await _roleService.Disable(Id); } + /// + /// 获取所有角色 + /// + /// + [HttpGet("/api/roles/getrole")] + public async Task> GetRole() + { + return await _roleService.GetRole(); + } } } diff --git a/BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs b/BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs index 3c765ab..c35cde5 100644 --- a/BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs +++ b/BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs @@ -181,5 +181,11 @@ namespace BPA.SAAS.Manage.Application.Org.Services childIdList.Add(id); return childIdList; } + public async Task> GetOrgList() + { + var data =await _db.Queryable() + .ToDictionaryAsync(x => x.Id, x => x.Name); + return data; + } } } diff --git a/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs b/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs index f73eb3a..4f8183e 100644 --- a/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs +++ b/BPA.SAAS.Manage.Application/Org/Services/RoleService.cs @@ -215,5 +215,11 @@ namespace BPA.SAAS.Manage.Application.Org.Services var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); return res>0; } + public async Task> GetRole() + { + var res =await _db.Queryable().Where(t => t.IsDeleted == 0 && t.Status == CommonStatus.ENABLE).ToDictionaryAsync(t => t.Id, t => t.Name); + + return res; + } } } diff --git a/BPA.SAAS.Manage.Application/Org/Services/UserService.cs b/BPA.SAAS.Manage.Application/Org/Services/UserService.cs index 7995d28..637e2ce 100644 --- a/BPA.SAAS.Manage.Application/Org/Services/UserService.cs +++ b/BPA.SAAS.Manage.Application/Org/Services/UserService.cs @@ -2,12 +2,16 @@ using BPA.SAAS.Manage.Application.Org.Interface; using BPA.SAAS.Manage.Application.Org.Interface; using BPA.SAAS.Manage.Comm.Const; +using BPA.SAAS.Manage.Comm.Enum; +using BPA.SAAS.Manage.Core.Base; using BPA.SAAS.Manage.Core.Org; +using Furion.LinqBuilder; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; namespace BPA.SAAS.Manage.Application.Org.Services { @@ -18,6 +22,42 @@ namespace BPA.SAAS.Manage.Application.Org.Services { _db=db; } + /// + /// 分页 + /// + /// + /// + public async Task UserPage(UserDtoPageInput input) + { + RefAsync total = 0; + var data =await _db.Queryable().LeftJoin((t, x) => t.GroupId == x.Id) + .WhereIF(!input.Name.IsNullOrEmpty(), t => t.Name.Contains(input.Name)) + .WhereIF(!input.Account.IsNullOrEmpty(), t => t.Account.Contains(input.Account)) + .Where(t => t.IsDeleted != 1) + .OrderBy(t => t.CreateAt, OrderByType.Desc) + .Select((t, x) => new UserDtoOutput + { + Id = t.Id, + Account = t.Account, + AdminType = t.AdminType, + CompanyName = x.Name, + Name = t.Name, + Phone = t.Phone, + SysOrgId = t.SysOrgId, + CreateAt=t.CreateAt + }).ToPageListAsync(input.Current, input.PageSize, total); + PageUtil util = new PageUtil() + { + Total = total, + Data = data + }; + return util; + } + /// + /// 新增 + /// + /// + /// public async Task AddUser(UserDtoInput input) { var user = input.Adapt(); @@ -27,5 +67,144 @@ namespace BPA.SAAS.Manage.Application.Org.Services return false; return await _db.Insertable(user).CallEntityMethod(t => t.Create()).ExecuteCommandAsync()> 0; } + /// + /// 修改用户 + /// + /// + /// + public async Task UpdateUser(UserDtoInput input) + { + var user = _db.Queryable().First(t => t.Account == input.Account); + + if (user == null) + return false; + user.Name = input.Name; + user.Account = input.Account; + user.Phone = input.Phone; + user.SysOrgId = input.SysOrgId; + var res =await _db.Updateable(user) + .IgnoreColumns(t => t.Password) + .IgnoreColumns(t => t.AdminType) + .ExecuteCommandHasChangeAsync(); + return res; + } + + /// + /// 删除 + /// + /// + /// + public async Task DeleteUser(List input) + { + var resEntitites = _db.Queryable().In(input).ToList(); + resEntitites.ForEach(x => + { + x.IsDeleted = 1; + }); + var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); + return res > 0; + } + + /// + /// 启用 + /// + /// + /// + public async Task Enable(string Id) + { + var resEntitites = _db.Queryable().In(Id).ToList(); + resEntitites.ForEach(x => + { + x.Status = CommonStatus.ENABLE; + }); + var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); + return res>0; + } + + /// + /// 禁用 + /// + /// + /// + public async Task Disable(string Id) + { + var resEntitites = _db.Queryable().In(Id).ToList(); + resEntitites.ForEach(x => + { + x.Status = CommonStatus.DISABLE; + }); + var res = await _db.Updateable(resEntitites).ExecuteCommandAsync(); + return res > 0; + } + + /// + /// 重置密码 + /// + /// + /// + public async Task ResetPwd(string Id) + { + var user = _db.Queryable().First(t => t.Id == Id); + + if (user == null) + return false; + string pwd = MD5Encryption.Encrypt("123456").ToLower(); + + return await _db.Updateable(t => t.Password == pwd).Where(t => t.Id == Id).ExecuteCommandHasChangeAsync(); + + } + + /// + /// 变更密码 + /// + /// + /// + public async Task UpdatePwd(UserPwdDtoInput input) + { + input.NPwd = MD5Encryption.Encrypt(input.NPwd).ToLower(); + input.OPwd = MD5Encryption.Encrypt(input.OPwd).ToLower(); + + return await _db.Updateable() + .SetColumns(t => t.Password == input.NPwd) + .Where(t => t.Password == input.OPwd) + .Where(t => t.Account == input.Account) + .ExecuteCommandHasChangeAsync(); + } + /// + /// 获取当前用户的角色 + /// + /// + /// + public async Task GetUserRole(string UserId) + { + string[] sysRoles =await _db.Queryable().Where(t => t.SysUserId == UserId).Select(t => t.SysRoleId).ToArrayAsync(); + UserRoleDtoInput userRoleDtoInput = new UserRoleDtoInput(); + userRoleDtoInput.SysUserId = UserId; + userRoleDtoInput.SysRoleId = sysRoles; + return userRoleDtoInput; + } + /// + /// 新增用户角色 + /// + /// + /// + public async Task AddUserRole(UserRoleDtoInput input) + { + List roles = new List(); + + var dara = _db.Queryable().Where(x => x.SysUserId == input.SysUserId).ToList(); + + _db.Deleteable(dara).ExecuteCommand(); //批量删除 + foreach (string SysRoleId in input.SysRoleId) + { + BPA_UserRole role = new BPA_UserRole(); + role.Id = Guid.NewGuid().ToString(); + role.SysUserId = input.SysUserId; + role.SysRoleId = SysRoleId; + roles.Add(role); + } + return await _db.Insertable(roles).ExecuteCommandAsync() > 0; + + } } } diff --git a/BPA.SAAS.Manage.Application/Org/UserServices.cs b/BPA.SAAS.Manage.Application/Org/UserServices.cs new file mode 100644 index 0000000..ce9fcc9 --- /dev/null +++ b/BPA.SAAS.Manage.Application/Org/UserServices.cs @@ -0,0 +1,108 @@ +using BPA.SAAS.Manage.Application.Org.Dtos.Users; +using BPA.SAAS.Manage.Application.Org.Interface; +using BPA.SAAS.Manage.Core.Base; +using BPA.SAAS.Manage.Core.Org; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application.Org +{ + [ApiDescriptionSettings("Org", Tag = "用户账号信息")] + public class UserServices: IDynamicApiController + { + IUserService _userService; + public UserServices(IUserService userService) + { + _userService=userService; + } + [HttpPost("/api/user/userpage")] + public async Task UserPage(UserDtoPageInput input) + { + return await _userService.UserPage(input); + } + [HttpPost("/api/user/add")] + public async Task AddUser(UserDtoInput input) + { + return await _userService.AddUser(input); + } + [HttpPost("/api/user/update")] + public async Task UpdateUser(UserDtoInput input) + { + return await _userService.UpdateUser(input); + } + /// + /// 删除 + /// + /// + /// + [HttpPost("/api/user/delete")] + public async Task DeleteUser(List input) + { + return await _userService.DeleteUser(input); + } + /// + /// 启用 + /// + /// + /// + [HttpGet("/api/user/enable")] + public async Task Enable(string Id) + { + return await _userService.Enable(Id); + } + /// + /// 禁用 + /// + /// + /// + [HttpGet("/api/user/disable")] + public async Task Disable(string Id) + { + return await _userService.Disable(Id); + } + /// + /// 重置密码 + /// + /// + /// + [HttpGet("/api/user/resetuserpwd")] + public async Task ResetPwd(string Id) + { + return await _userService.ResetPwd(Id); + } + /// + /// 变更密码 + /// + /// + /// + [HttpPost("/api/user/updatepwd")] + public async Task UpdatePwd(UserPwdDtoInput input) + { + return await _userService.UpdatePwd(input); + } + /// + /// 获取当前用户的角色 + /// + /// + /// + [HttpGet("/api/user/getuserrole")] + public async Task GetUserRole(string UserId) + { + return await _userService.GetUserRole(UserId); + } + /// + /// 新增用户角色 + /// + /// + /// + [HttpPost("/api/user/adduserrole")] + public async Task AddUserRole(UserRoleDtoInput input) + { + return await _userService.AddUserRole(input); + + } + } +} diff --git a/BPA.SAAS.Manage.Application/System/Dtos/DictDataQueryDto.cs b/BPA.SAAS.Manage.Application/System/Dtos/DictDataQueryDto.cs index ea46393..44ef7e0 100644 --- a/BPA.SAAS.Manage.Application/System/Dtos/DictDataQueryDto.cs +++ b/BPA.SAAS.Manage.Application/System/Dtos/DictDataQueryDto.cs @@ -14,7 +14,7 @@ namespace BPA.SAAS.Manage.Application.System.Dtos /// public string Id { get; set; } /// - /// 字典类型编号 + /// 字典类型 /// public string TypeId { get; set; } /// diff --git a/BPA.SAAS.Manage.Application/System/Services/DictDataService.cs b/BPA.SAAS.Manage.Application/System/Services/DictDataService.cs index 8fbfda6..2601098 100644 --- a/BPA.SAAS.Manage.Application/System/Services/DictDataService.cs +++ b/BPA.SAAS.Manage.Application/System/Services/DictDataService.cs @@ -68,7 +68,7 @@ namespace BPA.SAAS.Manage.Application var res =await _db.Queryable((a, b) => new JoinQueryInfos(JoinType.Inner, a.TypeId.ToString() == b.Id)) .Where((a, b) => a.IsDeleted == 0 && b.IsDeleted == 0) .Where(conModels) - .WhereIF(dto.CreateAt.HasValue, x => x.CreateAt.Value.Date == dto.CreateAt.Value.Date) + .WhereIF(dto.CreateAt.HasValue, x => x.CreateAt.Date == dto.CreateAt.Value.Date) .Select((a, b) => new DictDataQueryDto { Id = a.Id.SelectAll(), diff --git a/BPA.SAAS.Manage.Core/Base/IBaseEntity.cs b/BPA.SAAS.Manage.Core/Base/IBaseEntity.cs index 88c8671..368d59b 100644 --- a/BPA.SAAS.Manage.Core/Base/IBaseEntity.cs +++ b/BPA.SAAS.Manage.Core/Base/IBaseEntity.cs @@ -9,14 +9,14 @@ using System.Threading.Tasks; namespace BPA.SAAS.Manage.Core.Base { - public abstract class IBaseEntity + public abstract class IBaseEntity: IDeleted { /// /// 主键 Guid /// [SugarColumn(IsPrimaryKey = true, ColumnDataType = "Nvarchar(64)", IsNullable = false)] public string Id { get; set; } - public DateTime? CreateAt { get; set; } = DateTime.Now; + public DateTime CreateAt { get; set; } = DateTime.Now; public string CreateBy { get; set; } /// /// 是否删除 diff --git a/BPA.SAAS.Manage.Core/Base/IDeleted.cs b/BPA.SAAS.Manage.Core/Base/IDeleted.cs new file mode 100644 index 0000000..fec488a --- /dev/null +++ b/BPA.SAAS.Manage.Core/Base/IDeleted.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.Base +{ + public interface IDeleted + { + /// + /// 是否删除 + /// + public int IsDeleted { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/Base/IGroupId.cs b/BPA.SAAS.Manage.Core/Base/IGroupId.cs new file mode 100644 index 0000000..7626b90 --- /dev/null +++ b/BPA.SAAS.Manage.Core/Base/IGroupId.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.Base +{ + public interface IGroupId + { + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_Batching.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_Batching.cs new file mode 100644 index 0000000..56f56dd --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_Batching.cs @@ -0,0 +1,95 @@ +using BPA.SAAS.Manage.Comm.Enum; +using BPA.SAAS.Manage.Core.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Principal; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + [SugarTable("bpa_batching")] + public class BPA_Batching: IBaseEntity, IGroupId + { + /// + /// 原料编码 + /// + [SugarColumn(ColumnDataType = "Nvarchar(50)", IsNullable = false)] + public string Code { get; set; } + /// + /// 商品属性 (0成品,1半成品,2,易耗品) + /// + [SugarColumn(IsNullable = false)] + public int Aittribute { get; set; } = 0; + /// + /// 原料名称 + /// + [SugarColumn(ColumnDataType = "Nvarchar(200)", IsNullable = false)] + public string Batching_Name { get; set; } + /// + /// 配料类型 + /// + [SugarColumn(ColumnDataType = "Nvarchar(200)", IsNullable = false)] + public string Batching_Type { get; set; } + /// + /// 原料类型 + /// + [SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] + public string TypeID { get; set; } + + /// + /// 库存单位 + /// + [SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] + public string StockUint { get; set; } + + /// + /// 规格属性 + /// + [SugarColumn(ColumnDataType = "Nvarchar(500)", IsNullable = false)] + public string Specs { get; set; } + + + /// + /// 成本价 + /// + [SugarColumn(ColumnDataType = "decimal(10,2)", IsNullable = false)] + public decimal Price { get; set; } + + /// + /// 状态 【正常 停用】默认 正常 + /// + [SugarColumn(ColumnDataType = "int", ColumnDescription = "状态", IsNullable = false)] + public CommonStatus Status { get; set; } = CommonStatus.ENABLE; + /// + /// 净料率 + /// + [SugarColumn(ColumnDataType = "decimal(10,2)", IsNullable = false)] + public decimal netrecovery { get; set; } + + /// + /// 出库单位 + /// + [SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] + public string outstockUint { get; set; } + + + /// + /// 换算比例 + /// + [SugarColumn(ColumnDataType = "decimal(10,2)", IsNullable = false)] + public decimal proportion { get; set; } + + + [SugarColumn(IsOnlyIgnoreInsert = true, IsOnlyIgnoreUpdate = true, IsIdentity = true)] + public int AutoKey { get; set; } + [SugarColumn(ColumnDataType = "Nvarchar(255)", IsNullable = true)] + public string ForeignKeyRe { get; set; } + /// + /// 加盟商id + /// + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_BatchingType.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_BatchingType.cs new file mode 100644 index 0000000..8cb1333 --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_BatchingType.cs @@ -0,0 +1,31 @@ +using BPA.SAAS.Manage.Core.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + [SugarTable("bpa_batchingtype")] + public class BPA_BatchingType: IBaseEntity, IGroupId + { + /// + /// 名称 + /// + + [SugarColumn(ColumnDataType = "Nvarchar(200)", IsNullable = false)] + public string Name { get; set; } + + /// + /// 备注 + /// + [SugarColumn(ColumnDataType = "Nvarchar(500)", IsNullable = true)] + public string Remark { get; set; } + /// + /// 加盟商id + /// + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_BatchingUint.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_BatchingUint.cs new file mode 100644 index 0000000..3811715 --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_BatchingUint.cs @@ -0,0 +1,30 @@ +using BPA.SAAS.Manage.Core.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + [SugarTable("BPA_batchinguint")] + public class BPA_BatchingUint : IBaseEntity, IGroupId + { + /// + /// 单位名称 + /// + + [SugarColumn(ColumnDataType = "Nvarchar(200)", IsNullable = false)] + public string Name { get; set; } + /// + /// 备注 + /// + [SugarColumn(ColumnDataType = "Nvarchar(500)", IsNullable = true)] + public string Remark { get; set; } + /// + /// 加盟商id + /// + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_Bom.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_Bom.cs new file mode 100644 index 0000000..91f013b --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_Bom.cs @@ -0,0 +1,45 @@ +using BPA.SAAS.Manage.Core.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + [SugarTable("bpa_bom")] + public class BPA_Bom : IBaseEntity, IGroupId + { + /// + /// 配方名称 + /// + + [SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] + public string Name { get; set; } + + /// + /// 配方编码 + /// + + [SugarColumn(ColumnDataType = "Nvarchar(50)", IsNullable = false)] + public string Code { get; set; } + /// + /// 1主料配方0 辅料配方 + /// + public bool IsMain { get; set; } + + + [SugarColumn(IsOnlyIgnoreInsert = true, IsOnlyIgnoreUpdate = true)] + public int AutoKey { get; set; } + /// + /// 配方数据 + /// + public string BOMInfo { get; set; } + /// + /// 排序 + /// + public int Sort { get; set; } = 1; + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_BomAttributeValueRe.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_BomAttributeValueRe.cs new file mode 100644 index 0000000..a7184f1 --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_BomAttributeValueRe.cs @@ -0,0 +1,27 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + /// + /// 配方商品属性关系 + /// + [SugarTable("bpa_bomattributevaluere")] + public class BPA_BomAttributeValueRe + { + public string Id { get; set; } + public string GoodsId { get; set; } + /// + /// 配方id + /// + public string BoomId { get; set; } + /// + /// 商品属性值id + /// + public string GoodsAttributeValueId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_BomEntry.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_BomEntry.cs new file mode 100644 index 0000000..8c5ea81 --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_BomEntry.cs @@ -0,0 +1,43 @@ +using BPA.SAAS.Manage.Core.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + [SugarTable("bpa_bomentry")] + public class BPA_BomEntry: IBaseEntity, IGroupId + { + /// + /// 物料id + /// + + [SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] + public string BatchingId { get; set; } + /// + /// 物料intid + /// + public long BatchingKey { get; set; } + /// + /// 配方用量 + /// + public decimal BomQty { get; set; } + + /// + /// 配方id + /// + public string BomId { get; set; } + /// + /// 是否可替换 + /// + public bool IsReplace { get; set; } + /// + /// 排序,小炒abc料获取 + /// + public int sort { get; set; } + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_BomTypeInfo.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_BomTypeInfo.cs new file mode 100644 index 0000000..bc4b8b8 --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_BomTypeInfo.cs @@ -0,0 +1,30 @@ +using BPA.SAAS.Manage.Comm.Enum; +using BPA.SAAS.Manage.Core.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + [SugarTable("bpa_bomtypeinfo")] + public class BPA_BomTypeInfo: IBaseEntity, IGroupId + { + /// + /// + /// + public string BomId { get; set; } + /// + /// + /// + public string BomTypeId { get; set; } + /// + /// 状态 【正常 停用】默认 正常 + /// + [SugarColumn(ColumnDataType = "int", ColumnDescription = "状态", IsNullable = false)] + public CommonStatus Status { get; set; } = CommonStatus.ENABLE; + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttribute.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttribute.cs new file mode 100644 index 0000000..03854c9 --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttribute.cs @@ -0,0 +1,28 @@ +using BPA.SAAS.Manage.Comm.Const; +using BPA.SAAS.Manage.Core.Base; +using Furion; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + [SugarTable("bpa_goodsattribute")] + public class BPA_GoodsAttribute: IBaseEntity, IGroupId + { + /// + /// 属性名称 + /// + public string AttributeName { get; set; } + /// + /// 商品小类id + /// + public string GoodsTypeId { get; set; } + public int Sort { get; set; } + [SugarColumn(ColumnDataType = "nvarchar(64)", ColumnDescription = "GroupId", IsNullable = true)] + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttributeValue.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttributeValue.cs new file mode 100644 index 0000000..df83c00 --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttributeValue.cs @@ -0,0 +1,29 @@ +using BPA.SAAS.Manage.Comm.Const; +using BPA.SAAS.Manage.Core.Base; +using Furion; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + [SugarTable("bpa_goodsattributevalue")] + public class BPA_GoodsAttributeValue: IBaseEntity, IGroupId + { + /// + ///商品属性id + /// + public string GoodsAttributeId { get; set; } + /// + /// 属性值 + /// + public string AttributeValue { get; set; } + public int Sort { get; set; } + public string WaiKey { get; set; } + [SugarColumn(ColumnDataType = "nvarchar(64)", ColumnDescription = "GroupId", IsNullable = true)] + public string GroupId { get; set; } = App.User?.FindFirst(ClaimConst.GroupId)?.Value; + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsBom.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsBom.cs new file mode 100644 index 0000000..38ba909 --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsBom.cs @@ -0,0 +1,29 @@ +using BPA.SAAS.Manage.Core.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + [SugarTable("bpa_goodsbom")] + public class BPA_GoodsBom : IBaseEntity, IGroupId + { + /// + /// 商品id + /// + + [SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] + public string Goods_Id { get; set; } + + /// + /// 配方id + /// + + [SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)] + public string BomId { get; set; } + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsInfo.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsInfo.cs new file mode 100644 index 0000000..25e88a4 --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsInfo.cs @@ -0,0 +1,17 @@ +using BPA.SAAS.Manage.Core.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + [SugarTable("bpa_goodsInfo")] + public class BPA_GoodsInfo : IBaseEntity, IGroupId + { + public string GoodsTypeId { get; set; } + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsType.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsType.cs new file mode 100644 index 0000000..0988650 --- /dev/null +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsType.cs @@ -0,0 +1,26 @@ +using BPA.SAAS.Manage.Comm.Enum; +using BPA.SAAS.Manage.Core.Base; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Core.DataBase +{ + [SugarTable("bpa_goodstype")] + public class BPA_GoodsType: IBaseEntity, IGroupId + { + public string Pid { get; set; } + public string Name { get; set; } + public int Sort { get; set; } + public string Remark { get; set; } + /// + /// 状态 【正常 停用】默认 正常 + /// + [SugarColumn(ColumnDataType = "int", ColumnDescription = "状态", IsNullable = false)] + public CommonStatus Status { get; set; } = CommonStatus.ENABLE; + public string GroupId { get; set; } + } +} diff --git a/BPA.SAAS.Manage.Core/DbContext.cs b/BPA.SAAS.Manage.Core/DbContext.cs index 42e5783..96422db 100644 --- a/BPA.SAAS.Manage.Core/DbContext.cs +++ b/BPA.SAAS.Manage.Core/DbContext.cs @@ -1,9 +1,13 @@ -using Furion; +using BPA.SAAS.Manage.Comm.Const; +using BPA.SAAS.Manage.Core.Base; +using Furion; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using SqlSugar; using System; using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; namespace BPA.SAAS.Manage.Core { @@ -31,15 +35,46 @@ namespace BPA.SAAS.Manage.Core SqlSugarScope sqlSugar = new SqlSugarScope(configConnection, db => { + db.Aop.DataExecuting = (oldValue, entityInfo) => + { + //新增添加加盟商id赋值 + var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; + if (entityInfo.PropertyName == "GroupId" && entityInfo.OperationType == DataFilterType.InsertByObject) + { + if (oldValue == null || oldValue == Convert.DBNull) + { + entityInfo.SetValue(groupId); + } + } + }; + //单例参数配置,所有上下文生效 db.Aop.OnLogExecuting = (sql, pars) => { - Console.WriteLine(sql);//输出sql - //Console.WriteLine($"当前SQL语句:【{sql}】,参数:【{string.Join(",", pars.Select(t => t.Value))}】"); + //过滤已删除数据 + db.QueryFilter.AddTableFilter(it => it.IsDeleted == 0); + if (!IsSuperAdmin()) + { + //非管理员账户过滤加盟商数据 + var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; + db.QueryFilter.AddTableFilter(it => it.GroupId == groupId); + } + + //Console.WriteLine(sql);//输出sql + Console.WriteLine($"当前SQL语句:【{sql}】,参数:【{string.Join(",", pars.Select(t => t.Value))}】"); }; }); services.AddSingleton(sqlSugar);//这边是SqlSugarScope用AddSingleton } + // + /// 判断是不是超级管理员 + /// + /// + private static bool IsSuperAdmin() + { + if (App.User == null) return false; + return App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value == "1"; + } } } \ No newline at end of file diff --git a/BPA.SAAS.Manage.Core/Org/BPA_Organize.cs b/BPA.SAAS.Manage.Core/Org/BPA_Organize.cs index d11609e..df59e30 100644 --- a/BPA.SAAS.Manage.Core/Org/BPA_Organize.cs +++ b/BPA.SAAS.Manage.Core/Org/BPA_Organize.cs @@ -13,7 +13,7 @@ namespace BPA.SAAS.Manage.Core.Org /// 组织机构 /// [SugarTable("bpa_organize")] - public class BPA_Organize: IBaseEntity + public class BPA_Organize: IBaseEntity, IGroupId { /// /// 机构名称 diff --git a/BPA.SAAS.Manage.Core/Org/BPA_Roles.cs b/BPA.SAAS.Manage.Core/Org/BPA_Roles.cs index da3a928..db52b28 100644 --- a/BPA.SAAS.Manage.Core/Org/BPA_Roles.cs +++ b/BPA.SAAS.Manage.Core/Org/BPA_Roles.cs @@ -13,7 +13,7 @@ namespace BPA.SAAS.Manage.Core.Org /// 角色 /// [SugarTable("bpa_roles")] - public class BPA_Roles:IBaseEntity + public class BPA_Roles:IBaseEntity, IGroupId { /// /// 角色名称 diff --git a/BPA.SAAS.Manage.Core/Org/BPA_Users.cs b/BPA.SAAS.Manage.Core/Org/BPA_Users.cs index f602b99..353eb78 100644 --- a/BPA.SAAS.Manage.Core/Org/BPA_Users.cs +++ b/BPA.SAAS.Manage.Core/Org/BPA_Users.cs @@ -1,4 +1,5 @@ -using BPA.SAAS.Manage.Core.Base; +using BPA.SAAS.Manage.Comm.Enum; +using BPA.SAAS.Manage.Core.Base; using SqlSugar; using System; using System.Collections.Generic; @@ -9,7 +10,7 @@ using System.Threading.Tasks; namespace BPA.SAAS.Manage.Core.Org { [SugarTable("bpa_users")] - public class BPA_Users: IBaseEntity + public class BPA_Users: IBaseEntity, IGroupId { /// /// 用户名称 @@ -39,5 +40,10 @@ namespace BPA.SAAS.Manage.Core.Org /// 加盟商id /// public string GroupId { get; set; } + /// + /// 状态 【正常 停用】默认 正常 + /// + [SugarColumn(ColumnDataType = "int", ColumnDescription = "状态", IsNullable = false)] + public CommonStatus Status { get; set; } = CommonStatus.ENABLE; } }