Sfoglia il codice sorgente

物料管理功能和商品多属性基础功能

storemanagement
zhaoy 11 mesi fa
parent
commit
1ac822e8a0
53 ha cambiato i file con 2346 aggiunte e 13 eliminazioni
  1. +1
    -1
      BPA.SAAS.Manage.Application/Auth/AuthService.cs
  2. +133
    -0
      BPA.SAAS.Manage.Application/DataBase/BatchingServices.cs
  3. +32
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingDetailedDto.cs
  4. +82
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingInfoDto.cs
  5. +93
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingListQuery.cs
  6. +14
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingStatusDto.cs
  7. +14
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingTypeDto.cs
  8. +13
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingUintDto.cs
  9. +19
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeDto.cs
  10. +36
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeList.cs
  11. +15
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeQueryDto.cs
  12. +23
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeValueDto.cs
  13. +23
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeView.cs
  14. +23
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsBomAttributeDto.cs
  15. +102
    -0
      BPA.SAAS.Manage.Application/DataBase/GoodsAttributeServices.cs
  16. +26
    -0
      BPA.SAAS.Manage.Application/DataBase/Interface/IBatchingService.cs
  17. +59
    -0
      BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsAttributeService.cs
  18. +364
    -0
      BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs
  19. +328
    -0
      BPA.SAAS.Manage.Application/DataBase/Services/GoodsAttributeService.cs
  20. +42
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoOutput.cs
  21. +22
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoPageInput.cs
  22. +24
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Users/UserPwdDtoInput.cs
  23. +21
    -0
      BPA.SAAS.Manage.Application/Org/Dtos/Users/UserRoleDtoInput.cs
  24. +1
    -0
      BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs
  25. +1
    -0
      BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs
  26. +10
    -0
      BPA.SAAS.Manage.Application/Org/Interface/IUserService.cs
  27. +5
    -0
      BPA.SAAS.Manage.Application/Org/OrganizeServices.cs
  28. +10
    -1
      BPA.SAAS.Manage.Application/Org/RolesServices.cs
  29. +6
    -0
      BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs
  30. +6
    -0
      BPA.SAAS.Manage.Application/Org/Services/RoleService.cs
  31. +179
    -0
      BPA.SAAS.Manage.Application/Org/Services/UserService.cs
  32. +108
    -0
      BPA.SAAS.Manage.Application/Org/UserServices.cs
  33. +1
    -1
      BPA.SAAS.Manage.Application/System/Dtos/DictDataQueryDto.cs
  34. +1
    -1
      BPA.SAAS.Manage.Application/System/Services/DictDataService.cs
  35. +2
    -2
      BPA.SAAS.Manage.Core/Base/IBaseEntity.cs
  36. +16
    -0
      BPA.SAAS.Manage.Core/Base/IDeleted.cs
  37. +13
    -0
      BPA.SAAS.Manage.Core/Base/IGroupId.cs
  38. +95
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_Batching.cs
  39. +31
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_BatchingType.cs
  40. +30
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_BatchingUint.cs
  41. +45
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_Bom.cs
  42. +27
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_BomAttributeValueRe.cs
  43. +43
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_BomEntry.cs
  44. +30
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_BomTypeInfo.cs
  45. +28
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttribute.cs
  46. +29
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttributeValue.cs
  47. +29
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_GoodsBom.cs
  48. +17
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_GoodsInfo.cs
  49. +26
    -0
      BPA.SAAS.Manage.Core/DataBase/BPA_GoodsType.cs
  50. +38
    -3
      BPA.SAAS.Manage.Core/DbContext.cs
  51. +1
    -1
      BPA.SAAS.Manage.Core/Org/BPA_Organize.cs
  52. +1
    -1
      BPA.SAAS.Manage.Core/Org/BPA_Roles.cs
  53. +8
    -2
      BPA.SAAS.Manage.Core/Org/BPA_Users.cs

+ 1
- 1
BPA.SAAS.Manage.Application/Auth/AuthService.cs Vedi File

@@ -44,7 +44,7 @@ namespace BPA.SAAS.Manage.Application.Auth
//获取权限
var company = _db.Queryable<BPA_Company>().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";
}


+ 133
- 0
BPA.SAAS.Manage.Application/DataBase/BatchingServices.cs Vedi File

@@ -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;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/batching/getpage")]
public async Task<PageUtil> GetBatchingList(BatchingListQuery dto)
{
return await _batchingService.GetBatchingList(dto);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/batching/add")]
public async Task<bool> AddBatching(BatchingInfoDto dto)
{
return await _batchingService.AddBatching(dto);
}
/// <summary>
/// 修改
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/batching/update")]
public async Task<bool> UpdateBatching(BatchingInfoDto dto)
{
return await _batchingService.UpdateBatching(dto);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
[HttpPost("/api/batching/delete")]
public async Task<bool> BatchDelBatching(List<string> Ids)
{
return await _batchingService.BatchDelBatching(Ids);
}
/// <summary>
/// 物料列表
/// </summary>
/// <returns></returns>
[HttpGet("/api/batching/getbatchinglist")]
public async Task<Dictionary<string, object>> GetBatchingList()
{
return await _batchingService.GetBatchingList();
}
[HttpPost("/api/batching/updatebatchingstatus")]
public async Task<bool> UpdateBatchingStatus(BatchingStatusDto dto)
{
return await _batchingService.UpdateBatchingStatus(dto);
}
/// <summary>
/// 物料类型列表
/// </summary>
/// <returns></returns>
[HttpGet("/api/batching/getbatchingtypelist")]
public async Task<List<dynamic>> GetBatchingTypeList()
{
return await _batchingService.GetBatchingTypeList();
}
/// <summary>
/// 添加物料类型
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/batching/addbatchingtype")]
public async Task<bool> AddBatchingType(BatchingTypeDto dto)
{
return await _batchingService.AddBatchingType(dto);
}
/// <summary>
/// 删除物料类型
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/api/batching/batchtypedel")]
public async Task<bool> BatchTypeDel(string id)
{
return await _batchingService.BatchTypeDel(id);
}
/// <summary>
/// 物料单位列表
/// </summary>
/// <returns></returns>
[HttpGet("/api/batching/getbatchinguintList")]
public async Task<List<dynamic>> GetBatchingUintList()
{
return await _batchingService.GetBatchingUintList();
}
/// <summary>
/// 添加物料物料单位
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/batching/addbatchinguint")]
public async Task<bool> AddBatchingUint(BatchingUintDto dto)
{
return await _batchingService.AddBatchingUint(dto);
}
/// <summary>
/// 删除物料单位
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/api/batching/batchinguintdel")]
public async Task<bool> BatchingUintDel(string id)
{
return await _batchingService.BatchingUintDel(id);
}
}
}

+ 32
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingDetailedDto.cs Vedi File

@@ -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
{

/// <summary>
/// 物料id
/// </summary>
public string Id { get; set; }
/// <summary>
/// 单位
/// </summary>
public string PackUnit { get; set; }
/// <summary>
/// 物料编码
/// </summary>
public string PackCode { get; set; }

public string Code { get; set; }
/// <summary>
/// 换算比例
/// </summary>
public decimal Proportion { get; set; }

}
}

+ 82
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingInfoDto.cs Vedi File

@@ -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
{
/// <summary>
/// 物料id
/// </summary>
public string Id { get; set; }
/// <summary>
/// 物料名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 物料编码
/// </summary>
public string code { get; set; }
/// <summary>
/// 物料规格
/// </summary>
public string specs { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 单位
/// </summary>
public string StockUint { get; set; }
/// <summary>
/// 类型
/// </summary>
public string TypeID { get; set; }
/// <summary>
/// itemName
/// </summary>
public string itemName { get; set; }
/// <summary>
/// 状态
/// </summary>
public string Status { get; set; }
/// <summary>
/// 原料属性
/// </summary>
public string Aittribute { get; set; }
/// <summary>
/// 配料类型
/// </summary>
public string batchingType { get; set; }

/// <summary>
/// 成本价
/// </summary>
public decimal Price { get; set; }


/// <summary>
/// 出库单位
/// </summary>
public string outstockUint { get; set; }


/// <summary>
/// 换算比例
/// </summary>
public decimal proportion { get; set; }
/// <summary>
/// 净料率
/// </summary>
public decimal netrecovery { get; set; }
/// <summary>
///
/// </summary>
public List<BatchingDetailedDto> membersList { get; set; }
public string ForeignKeyRe { get; set; }
}
}

+ 93
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingListQuery.cs Vedi File

@@ -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
{
/// <summary>
/// 编号
/// </summary>
public string Id { get; set; }
/// <summary>
/// 原料编码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 商品属性 (0成品,1半成品,2,易耗品)
/// </summary>
public string Aittribute { get; set; }
/// <summary>
/// 原料名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 原料类型
/// </summary>
public string TypeID { get; set; }
/// <summary>
/// 原料类型名称
/// </summary>
public string TypeName { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateAt { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? UpdateAt { get; set; }
/// <summary>
/// 库存单位
/// </summary>
public string StockUint { get; set; }
/// <summary>
/// 库存单位名称
/// </summary>
public string StockUintName { get; set; }

/// <summary>
/// 规格属性
/// </summary>
public string Specs { get; set; }
/// <summary>
/// 状态
/// </summary>
public string Status { get; set; }
/// <summary>
///
/// </summary>
public string batchingType { get; set; }
/// <summary>
/// 成本价
/// </summary>
public decimal? Price { get; set; }
/// <summary>
/// 净料率
/// </summary>
public decimal? netrecovery { get; set; }

/// <summary>
/// 出库单位
/// </summary>
public string outstockUint { get; set; }


/// <summary>
/// 换算比例
/// </summary>
public decimal proportion { get; set; }
/// <summary>
///
/// </summary>
public List<BatchingDetailedDto> MembersList { get; set; }
public DateTime? DeleteAt { get; set; }
public string DeleteBy { get; set; }
public string ForeignKeyRe { get; set; }

}
}

+ 14
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingStatusDto.cs Vedi File

@@ -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; }
}
}

+ 14
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingTypeDto.cs Vedi File

@@ -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; }

}
}

+ 13
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/Batching/BatchingUintDto.cs Vedi File

@@ -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; }
}
}

+ 19
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeDto.cs Vedi File

@@ -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; }
/// <summary>
/// 商品小类id
/// </summary>
public string[] GoodsTypeId { get; set; }
public int Sort { get; set; }
}
}

+ 36
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeList.cs Vedi File

@@ -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; }
/// <summary>
/// 属性名称
/// </summary>
public string AttributeName { get; set; }
/// <summary>
/// 商品小类id
/// </summary>
public string GoodsTypeId { get; set; }
public int Sort { get; set; }
public List<GoodsAttributeValueList> GoodsAttributeValueList { get; set; }
}
public class GoodsAttributeValueList
{
public string GoodsAttributeValuId { get; set; }
/// <summary>
///商品属性id
/// </summary>
public string GoodsAttributeId { get; set; }
/// <summary>
/// 属性值
/// </summary>
public string AttributeValue { get; set; }
public int Sort { get; set; }
}
}

+ 15
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeQueryDto.cs Vedi File

@@ -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; }
}
}

+ 23
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeValueDto.cs Vedi File

@@ -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; }
/// <summary>
///商品属性id
/// </summary>
public string GoodsAttributeId { get; set; }
/// <summary>
/// 属性值
/// </summary>
public string AttributeValue { get; set; }
public int Sort { get; set; }
public string WaiKey { get; set; }
}
}

+ 23
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeView.cs Vedi File

@@ -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; }
/// <summary>
/// 属性名称
/// </summary>
public string AttributeName { get; set; }
/// <summary>
/// 商品小类id
/// </summary>
public string GoodsTypeId { get; set; }
public string GoodsTypeName { get; set; }
public int Sort { get; set; }
}
}

+ 23
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsBomAttributeDto.cs Vedi File

@@ -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> Mate { get; set; }
public string[] Shuxing { get; set; }
}
public class Mate
{
public string batchingId { get; set; }
public int dosage { get; set; }
}
}

+ 102
- 0
BPA.SAAS.Manage.Application/DataBase/GoodsAttributeServices.cs Vedi File

@@ -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;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/goodsattribute/getgoodsattributepage")]
public PageUtil GetGoodsAttributePageAsync(GoodsAttributeQueryDto dto)
{
return _goodsAttributeServices.GetGoodsAttributePageAsync(dto);
}
/// <summary>
/// 添加/修改
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/goodsattribute/addgoodsattribute")]
public async Task<bool> AddGoodsAttribute(GoodsAttributeDto dto)
{
return await _goodsAttributeServices.AddGoodsAttribute(dto);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
[HttpPost("/api/goodsattribute/deletegoodsattribute")]
public async Task<bool> DeleteGoodsAttribute([FromBody] string[] Ids)
{
return await _goodsAttributeServices.DeleteGoodsAttribute(Ids);
}
/// <summary>
/// 查询商品属性值列表
/// </summary>
/// <param name="goodsAttributeId"></param>
/// <returns></returns>
[HttpGet("/api/goodsattribute/getgoodsattributevalue")]
public async Task<List<BPA_GoodsAttributeValue>> GetGoodsAttributeValueAsync(string goodsAttributeId)
{
return await _goodsAttributeServices.GetGoodsAttributeValueAsync(goodsAttributeId);
}
/// <summary>
/// 添加/修改
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/goodsattribute/addgoodsattributevalue")]
public async Task<bool> AddGoodsAttributeValue(List<GoodsAttributeValueDto> dto)
{
return await _goodsAttributeServices.AddGoodsAttributeValue(dto);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/api/goodsattribute/deletegoodsattributevalue")]
public async Task<bool> DeleteGoodsAttributeValue(string id)
{
return await _goodsAttributeServices.DeleteGoodsAttributeValue(id);
}
/// <summary>
/// 根据商品id查询商品属性
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/api/goodsattribute/getbygoodsidattribute")]
public async Task<List<GoodsAttributeList>> GetByGoodsIdAttribute(string id)
{
return await _goodsAttributeServices.GetByGoodsIdAttribute(id);
}
/// <summary>
/// 添加商品配方
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/api/goodsattribute/addgoodsbomattribute")]
public async Task<bool> AddGoodsBomAttribute(GoodsBomAttributeDto dto)
{
return await _goodsAttributeServices.AddGoodsBomAttribute(dto);
}
}
}

+ 26
- 0
BPA.SAAS.Manage.Application/DataBase/Interface/IBatchingService.cs Vedi File

@@ -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<PageUtil> GetBatchingList(BatchingListQuery dto);
Task<bool> AddBatching(BatchingInfoDto dto);
Task<bool> UpdateBatching(BatchingInfoDto dto);
Task<bool> BatchDelBatching(List<string> Ids);
Task<Dictionary<string, object>> GetBatchingList();
Task<bool> UpdateBatchingStatus(BatchingStatusDto dto);
Task<List<dynamic>> GetBatchingTypeList();
Task<bool> AddBatchingType(BatchingTypeDto dto);
Task<bool> BatchTypeDel(string id);
Task<List<dynamic>> GetBatchingUintList();
Task<bool> AddBatchingUint(BatchingUintDto dto);
Task<bool> BatchingUintDel(string id);
}
}

+ 59
- 0
BPA.SAAS.Manage.Application/DataBase/Interface/IGoodsAttributeService.cs Vedi File

@@ -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
{
/// <summary>
/// 分页查询
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
PageUtil GetGoodsAttributePageAsync(GoodsAttributeQueryDto dto);
/// <summary>
/// 添加/修改
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<bool> AddGoodsAttribute(GoodsAttributeDto dto);
/// <summary>
/// 删除
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
Task<bool> DeleteGoodsAttribute(string[] Ids);
/// <summary>
/// 查询商品属性值列表
/// </summary>
/// <param name="goodsAttributeId"></param>
/// <returns></returns>
Task<List<BPA_GoodsAttributeValue>> GetGoodsAttributeValueAsync(string goodsAttributeId);
/// <summary>
/// 添加/修改
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<bool> AddGoodsAttributeValue(List<GoodsAttributeValueDto> dto);
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<bool> DeleteGoodsAttributeValue(string id);
/// <summary>
/// 根据商品id查询商品属性
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<List<GoodsAttributeList>> GetByGoodsIdAttribute(string id);
Task<bool> AddGoodsBomAttribute(GoodsBomAttributeDto dto);
Task<List<GoodsAttributeList>> GetByNameAttribute(string name);
}
}

+ 364
- 0
BPA.SAAS.Manage.Application/DataBase/Services/BatchingService.cs Vedi File

@@ -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 物料
/// <summary>
/// 分页
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<PageUtil> GetBatchingList(BatchingListQuery dto)
{
string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value;
#region 查询条件
List<IConditionalModel> conModels = new List<IConditionalModel>();
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<int> total = 0;
var res =await _db.Queryable<BPA_Batching, BPA_BatchingType, BPA_BatchingUint>((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<BPA_ProductCode>()
// .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;
}

/// <summary>
/// 添加
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddBatching(BatchingInfoDto dto)
{
var productCode = _db.Queryable<BPA_Batching>().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("添加失败");
}
}
/// <summary>
/// 修改物料信息
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> UpdateBatching(BatchingInfoDto dto)
{
var Code = _db.Queryable<BPA_Batching>().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("更新失败");
}
}

/// <summary>
/// 删除物料信息
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public async Task<bool> BatchDelBatching(List<string> Ids)
{
try
{
// 查询数据库中是否存在未删除的活动信息
var resEntitites = _db.Queryable<BPA_Batching>().In(Ids).ToList();
resEntitites.ForEach(x =>
{
x.IsDeleted = 1;
});
var res =await _db.Updateable(resEntitites).ExecuteCommandAsync();
return res>0;
}
catch (Exception)
{
throw Oops.Oh("删除失败");
}
}
/// <summary>
/// 查询所有物料信息
/// </summary>
/// <returns></returns>
public async Task<Dictionary<string, object>> GetBatchingList()
{
var res = await _db.Queryable<BPA_Batching>()
.ToDictionaryAsync(x => x.Id, x => x.Batching_Name);
return res;
}
/// <summary>
/// 更新物料状态
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> UpdateBatchingStatus(BatchingStatusDto dto)
{
try
{
// 查询数据库中是否存在未删除的活动信息
var resEntitites = _db.Queryable<BPA_Batching>().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<List<dynamic>> GetBatchingTypeList()
{
var res = await _db.Queryable<BPA_BatchingType>().Select<dynamic>(x => new
{
id = x.Id,
name=x.Name
}) .ToListAsync();
return res;
}
public async Task<bool> AddBatchingType(BatchingTypeDto dto)
{
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value;
var productCode = _db.Queryable<BPA_BatchingType>().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<bool> BatchTypeDel(string id)
{
try
{
// 查询数据库中是否存在未删除的活动信息
var resEntitites =await _db.Queryable<BPA_Batching>().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<List<dynamic>> GetBatchingUintList()
{
var res = await _db.Queryable<BPA_BatchingUint>().Select<dynamic>(x => new
{
id = x.Id,
name = x.Name
}).ToListAsync();
return res;
}
public async Task<bool> AddBatchingUint(BatchingUintDto dto)
{
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value;
var productCode = _db.Queryable<BPA_BatchingUint>().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<bool> BatchingUintDel(string id)
{
try
{
// 查询数据库中是否存在未删除的活动信息
var resEntitites = await _db.Queryable<BPA_BatchingUint>().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
}
}

+ 328
- 0
BPA.SAAS.Manage.Application/DataBase/Services/GoodsAttributeService.cs Vedi File

@@ -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; // 推荐操作
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="dto"></param>m
/// <returns></returns>
public PageUtil GetGoodsAttributePageAsync(GoodsAttributeQueryDto dto)
{
List<IConditionalModel> conModels = new List<IConditionalModel>();
string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value;
int total = new RefAsync<int>();

var res = _db.Queryable<BPA_GoodsAttribute>()
.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<BPA_GoodsType>().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;
}
/// <summary>
/// 添加/修改
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddGoodsAttribute(GoodsAttributeDto dto)
{
if (!string.IsNullOrWhiteSpace(dto.Id))
{
var resEntity = _db.Queryable<BPA_GoodsAttribute>().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;
}

}
/// <summary>
/// 删除
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public async Task<bool> DeleteGoodsAttribute(string[] Ids)
{
// 查询数据库中是否存在未删除的商品
var resEntitites = _db.Queryable<BPA_GoodsAttribute>().In(Ids).ToList();

resEntitites.ForEach(x =>
{
x.IsDeleted = 1;
});
var res =await _db.Updateable(resEntitites).ExecuteCommandAsync();
if (res > 0)
{
var resEntititesattr = _db.Queryable<BPA_GoodsAttributeValue>().In("GoodsAttributeId", Ids).ToList();
if (resEntititesattr != null)
{
resEntititesattr.ForEach(x =>
{
x.IsDeleted = 1;
});
await _db.Updateable(resEntititesattr).ExecuteCommandAsync();
}
}
return res > 0;
}
/// <summary>
/// 查询商品属性值列表
/// </summary>
/// <param name="goodsAttributeId"></param>
/// <returns></returns>
public async Task<List<BPA_GoodsAttributeValue>> GetGoodsAttributeValueAsync(string goodsAttributeId)
{
string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value;

var res =await _db.Queryable<BPA_GoodsAttributeValue>().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;
}
/// <summary>
/// 添加/修改
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddGoodsAttributeValue(List<GoodsAttributeValueDto> dto)
{
List<BPA_GoodsAttributeValue> editlist = new();
List<BPA_GoodsAttributeValue> 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<BPA_GoodsAttributeValue>().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;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<bool> DeleteGoodsAttributeValue(string id)
{
// 查询数据库中是否存在未删除的商品
var resEntitites = _db.Queryable<BPA_GoodsAttributeValue>().In(id).ToList();

resEntitites.ForEach(x =>
{
x.IsDeleted = 1;
});
var res =await _db.Updateable(resEntitites).ExecuteCommandAsync();
if (res > 0)
{

//1.查询上架商品
//2.删除上架商品
}
return res > 0;
}
/// <summary>
/// 根据商品id查询商品属性
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<List<GoodsAttributeList>> GetByGoodsIdAttribute(string id)
{
var goods=await _db.Queryable<BPA_GoodsInfo>().Where(x => x.Id == id).FirstAsync();
if (goods == null) throw Oops.Oh("商品不存在");
var goodsAttributeList = await _db.Queryable<BPA_GoodsAttribute>().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<BPA_GoodsAttributeValue>().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<List<GoodsAttributeList>> GetByNameAttribute(string name)
{
//var goods = await _db.Queryable<BPA_GoodsInfo>().Where(x => x.Id == id).FirstAsync();
//if (goods == null) throw Oops.Oh("商品不存在");
var goodsAttributeList = await _db.Queryable<BPA_GoodsAttribute>().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<BPA_GoodsAttributeValue>().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;
}
/// <summary>
/// 添加商品配方
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<bool> AddGoodsBomAttribute(GoodsBomAttributeDto dto)
{
_db.Ado.BeginTran();
try
{
string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value;
var sortMax = _db.Queryable<BPA_Bom>().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<BPA_BomEntry> 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);
}
}
}
}

+ 42
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoOutput.cs Vedi File

@@ -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; }
/// <summary>
/// 用户名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 登录账号
/// </summary>
public string Account { get; set; }
/// <summary>
/// 登录密码
/// </summary>
public string Password { get; set; }
/// <summary>
/// 手机号码
/// </summary>
public string Phone { get; set; }
/// <summary>
/// 管理员类型-超级管理员_1、管理员_2、普通账号_3
/// </summary>
public int AdminType { get; set; }
/// <summary>
/// 归属组织
/// </summary>
public string SysOrgId { get; set; }
/// <summary>
/// 企业名称
/// </summary>
public string CompanyName { get; set; }
public DateTime? CreateAt { get; set; }
}
}

+ 22
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Users/UserDtoPageInput.cs Vedi File

@@ -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
{
/// <summary>
/// 昵称
/// </summary>
public string Account { get; set; }

/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
}
}

+ 24
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Users/UserPwdDtoInput.cs Vedi File

@@ -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
{
/// <summary>
/// 账户
/// </summary>
public string Account { get; set; }
/// <summary>
/// 旧密码
/// </summary>
public string OPwd { get; set; }
/// <summary>
/// 新密码
/// </summary>
public string NPwd { get; set; }
}
}

+ 21
- 0
BPA.SAAS.Manage.Application/Org/Dtos/Users/UserRoleDtoInput.cs Vedi File

@@ -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; }
/// <summary>
/// 用户Id
/// </summary>
public string SysUserId { get; set; }
/// <summary>
/// 角色Id
/// </summary>
public string[] SysRoleId { get; set; }
}
}

+ 1
- 0
BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs Vedi File

@@ -16,5 +16,6 @@ namespace BPA.SAAS.Manage.Application.Org.Interface
Task<bool> DeleteOrg(DeleteOrgInput input);
Task<bool> UpdateOrg(UpdateOrgInput input);
Task<dynamic> GetOrgTree();
Task<Dictionary<string, object>> GetOrgList();
}
}

+ 1
- 0
BPA.SAAS.Manage.Application/Org/Interface/IRoleService.cs Vedi File

@@ -18,5 +18,6 @@ namespace BPA.SAAS.Manage.Application.Org.Interface
Task<bool> AddOrUpdateMenuRole(RoleMenuDtoInput input);
Task<bool> Disable(string Id);
Task<bool> Enable(string Id);
Task<Dictionary<string, object>> GetRole();
}
}

+ 10
- 0
BPA.SAAS.Manage.Application/Org/Interface/IUserService.cs Vedi File

@@ -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<PageUtil> UserPage(UserDtoPageInput input);
Task<bool> AddUser(UserDtoInput input);
Task<bool> UpdateUser(UserDtoInput input);
Task<bool> DeleteUser(List<string> input);
Task<bool> Enable(string Id);
Task<bool> Disable(string Id);
Task<bool> ResetPwd(string Id);
Task<bool> UpdatePwd(UserPwdDtoInput input);
Task<UserRoleDtoInput> GetUserRole(string UserId);
Task<bool> AddUserRole(UserRoleDtoInput input);
}
}

+ 5
- 0
BPA.SAAS.Manage.Application/Org/OrganizeServices.cs Vedi File

@@ -76,5 +76,10 @@ namespace BPA.SAAS.Manage.Application.Org
{
return await _organizeService.GetOrgTree();
}
[HttpGet("/api/organize/getorglist")]
public async Task<Dictionary<string, object>> GetOrgList()
{
return await _organizeService.GetOrgList();
}
}
}

+ 10
- 1
BPA.SAAS.Manage.Application/Org/RolesServices.cs Vedi File

@@ -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);
}
/// <summary>
/// 获取所有角色
/// </summary>
/// <returns></returns>
[HttpGet("/api/roles/getrole")]
public async Task<Dictionary<string, object>> GetRole()
{
return await _roleService.GetRole();
}
}
}

+ 6
- 0
BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs Vedi File

@@ -181,5 +181,11 @@ namespace BPA.SAAS.Manage.Application.Org.Services
childIdList.Add(id);
return childIdList;
}
public async Task<Dictionary<string, object>> GetOrgList()
{
var data =await _db.Queryable<BPA_Organize>()
.ToDictionaryAsync(x => x.Id, x => x.Name);
return data;
}
}
}

+ 6
- 0
BPA.SAAS.Manage.Application/Org/Services/RoleService.cs Vedi File

@@ -215,5 +215,11 @@ namespace BPA.SAAS.Manage.Application.Org.Services
var res =await _db.Updateable(resEntitites).ExecuteCommandAsync();
return res>0;
}
public async Task<Dictionary<string, object>> GetRole()
{
var res =await _db.Queryable<BPA_Roles>().Where(t => t.IsDeleted == 0 && t.Status == CommonStatus.ENABLE).ToDictionaryAsync(t => t.Id, t => t.Name);

return res;
}
}
}

+ 179
- 0
BPA.SAAS.Manage.Application/Org/Services/UserService.cs Vedi File

@@ -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;
}
/// <summary>
/// 分页
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<PageUtil> UserPage(UserDtoPageInput input)
{
RefAsync<int> total = 0;
var data =await _db.Queryable<BPA_Users>().LeftJoin<BPA_Company>((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;
}
/// <summary>
/// 新增
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> AddUser(UserDtoInput input)
{
var user = input.Adapt<BPA_Users>();
@@ -27,5 +67,144 @@ namespace BPA.SAAS.Manage.Application.Org.Services
return false;
return await _db.Insertable(user).CallEntityMethod(t => t.Create()).ExecuteCommandAsync()> 0;
}
/// <summary>
/// 修改用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> UpdateUser(UserDtoInput input)
{
var user = _db.Queryable<BPA_Users>().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;
}

/// <summary>
/// 删除
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> DeleteUser(List<string> input)
{
var resEntitites = _db.Queryable<BPA_Users>().In(input).ToList();
resEntitites.ForEach(x =>
{
x.IsDeleted = 1;
});
var res =await _db.Updateable(resEntitites).ExecuteCommandAsync();
return res > 0;
}

/// <summary>
/// 启用
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public async Task<bool> Enable(string Id)
{
var resEntitites = _db.Queryable<BPA_Users>().In(Id).ToList();
resEntitites.ForEach(x =>
{
x.Status = CommonStatus.ENABLE;
});
var res =await _db.Updateable(resEntitites).ExecuteCommandAsync();
return res>0;
}

/// <summary>
/// 禁用
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public async Task<bool> Disable(string Id)
{
var resEntitites = _db.Queryable<BPA_Users>().In(Id).ToList();
resEntitites.ForEach(x =>
{
x.Status = CommonStatus.DISABLE;
});
var res = await _db.Updateable(resEntitites).ExecuteCommandAsync();
return res > 0;
}

/// <summary>
/// 重置密码
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public async Task<bool> ResetPwd(string Id)
{
var user = _db.Queryable<BPA_Users>().First(t => t.Id == Id);

if (user == null)
return false;
string pwd = MD5Encryption.Encrypt("123456").ToLower();

return await _db.Updateable<BPA_Users>(t => t.Password == pwd).Where(t => t.Id == Id).ExecuteCommandHasChangeAsync();

}

/// <summary>
/// 变更密码
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> UpdatePwd(UserPwdDtoInput input)
{
input.NPwd = MD5Encryption.Encrypt(input.NPwd).ToLower();
input.OPwd = MD5Encryption.Encrypt(input.OPwd).ToLower();

return await _db.Updateable<BPA_Users>()
.SetColumns(t => t.Password == input.NPwd)
.Where(t => t.Password == input.OPwd)
.Where(t => t.Account == input.Account)
.ExecuteCommandHasChangeAsync();
}
/// <summary>
/// 获取当前用户的角色
/// </summary>
/// <param name="UserId"></param>
/// <returns></returns>
public async Task<UserRoleDtoInput> GetUserRole(string UserId)
{
string[] sysRoles =await _db.Queryable<BPA_UserRole>().Where(t => t.SysUserId == UserId).Select(t => t.SysRoleId).ToArrayAsync();
UserRoleDtoInput userRoleDtoInput = new UserRoleDtoInput();
userRoleDtoInput.SysUserId = UserId;
userRoleDtoInput.SysRoleId = sysRoles;
return userRoleDtoInput;
}
/// <summary>
/// 新增用户角色
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<bool> AddUserRole(UserRoleDtoInput input)
{
List<BPA_UserRole> roles = new List<BPA_UserRole>();

var dara = _db.Queryable<BPA_UserRole>().Where(x => x.SysUserId == input.SysUserId).ToList();

_db.Deleteable<BPA_UserRole>(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;

}
}
}

+ 108
- 0
BPA.SAAS.Manage.Application/Org/UserServices.cs Vedi File

@@ -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<PageUtil> UserPage(UserDtoPageInput input)
{
return await _userService.UserPage(input);
}
[HttpPost("/api/user/add")]
public async Task<bool> AddUser(UserDtoInput input)
{
return await _userService.AddUser(input);
}
[HttpPost("/api/user/update")]
public async Task<bool> UpdateUser(UserDtoInput input)
{
return await _userService.UpdateUser(input);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/user/delete")]
public async Task<bool> DeleteUser(List<string> input)
{
return await _userService.DeleteUser(input);
}
/// <summary>
/// 启用
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("/api/user/enable")]
public async Task<bool> Enable(string Id)
{
return await _userService.Enable(Id);
}
/// <summary>
/// 禁用
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("/api/user/disable")]
public async Task<bool> Disable(string Id)
{
return await _userService.Disable(Id);
}
/// <summary>
/// 重置密码
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("/api/user/resetuserpwd")]
public async Task<bool> ResetPwd(string Id)
{
return await _userService.ResetPwd(Id);
}
/// <summary>
/// 变更密码
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/user/updatepwd")]
public async Task<bool> UpdatePwd(UserPwdDtoInput input)
{
return await _userService.UpdatePwd(input);
}
/// <summary>
/// 获取当前用户的角色
/// </summary>
/// <param name="UserId"></param>
/// <returns></returns>
[HttpGet("/api/user/getuserrole")]
public async Task<UserRoleDtoInput> GetUserRole(string UserId)
{
return await _userService.GetUserRole(UserId);
}
/// <summary>
/// 新增用户角色
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/api/user/adduserrole")]
public async Task<bool> AddUserRole(UserRoleDtoInput input)
{
return await _userService.AddUserRole(input);

}
}
}

+ 1
- 1
BPA.SAAS.Manage.Application/System/Dtos/DictDataQueryDto.cs Vedi File

@@ -14,7 +14,7 @@ namespace BPA.SAAS.Manage.Application.System.Dtos
/// </summary>
public string Id { get; set; }
/// <summary>
/// 字典类型编号
/// 字典类型
/// </summary>
public string TypeId { get; set; }
/// <summary>


+ 1
- 1
BPA.SAAS.Manage.Application/System/Services/DictDataService.cs Vedi File

@@ -68,7 +68,7 @@ namespace BPA.SAAS.Manage.Application
var res =await _db.Queryable<BPA_DictData, BPA_DictType>((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(),


+ 2
- 2
BPA.SAAS.Manage.Core/Base/IBaseEntity.cs Vedi File

@@ -9,14 +9,14 @@ using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Core.Base
{
public abstract class IBaseEntity
public abstract class IBaseEntity: IDeleted
{
/// <summary>
/// 主键 Guid
/// </summary>
[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; }
/// <summary>
/// 是否删除


+ 16
- 0
BPA.SAAS.Manage.Core/Base/IDeleted.cs Vedi File

@@ -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
{
/// <summary>
/// 是否删除
/// </summary>
public int IsDeleted { get; set; }
}
}

+ 13
- 0
BPA.SAAS.Manage.Core/Base/IGroupId.cs Vedi File

@@ -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; }
}
}

+ 95
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_Batching.cs Vedi File

@@ -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
{
/// <summary>
/// 原料编码
/// </summary>
[SugarColumn(ColumnDataType = "Nvarchar(50)", IsNullable = false)]
public string Code { get; set; }
/// <summary>
/// 商品属性 (0成品,1半成品,2,易耗品)
/// </summary>
[SugarColumn(IsNullable = false)]
public int Aittribute { get; set; } = 0;
/// <summary>
/// 原料名称
/// </summary>
[SugarColumn(ColumnDataType = "Nvarchar(200)", IsNullable = false)]
public string Batching_Name { get; set; }
/// <summary>
/// 配料类型
/// </summary>
[SugarColumn(ColumnDataType = "Nvarchar(200)", IsNullable = false)]
public string Batching_Type { get; set; }
/// <summary>
/// 原料类型
/// </summary>
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)]
public string TypeID { get; set; }

/// <summary>
/// 库存单位
/// </summary>
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)]
public string StockUint { get; set; }

/// <summary>
/// 规格属性
/// </summary>
[SugarColumn(ColumnDataType = "Nvarchar(500)", IsNullable = false)]
public string Specs { get; set; }


/// <summary>
/// 成本价
/// </summary>
[SugarColumn(ColumnDataType = "decimal(10,2)", IsNullable = false)]
public decimal Price { get; set; }

/// <summary>
/// 状态 【正常 停用】默认 正常
/// </summary>
[SugarColumn(ColumnDataType = "int", ColumnDescription = "状态", IsNullable = false)]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
/// <summary>
/// 净料率
/// </summary>
[SugarColumn(ColumnDataType = "decimal(10,2)", IsNullable = false)]
public decimal netrecovery { get; set; }

/// <summary>
/// 出库单位
/// </summary>
[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)]
public string outstockUint { get; set; }


/// <summary>
/// 换算比例
/// </summary>
[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; }
/// <summary>
/// 加盟商id
/// </summary>
public string GroupId { get; set; }
}
}

+ 31
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_BatchingType.cs Vedi File

@@ -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
{
/// <summary>
/// 名称
/// </summary>

[SugarColumn(ColumnDataType = "Nvarchar(200)", IsNullable = false)]
public string Name { get; set; }

/// <summary>
/// 备注
/// </summary>
[SugarColumn(ColumnDataType = "Nvarchar(500)", IsNullable = true)]
public string Remark { get; set; }
/// <summary>
/// 加盟商id
/// </summary>
public string GroupId { get; set; }
}
}

+ 30
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_BatchingUint.cs Vedi File

@@ -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
{
/// <summary>
/// 单位名称
/// </summary>

[SugarColumn(ColumnDataType = "Nvarchar(200)", IsNullable = false)]
public string Name { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(ColumnDataType = "Nvarchar(500)", IsNullable = true)]
public string Remark { get; set; }
/// <summary>
/// 加盟商id
/// </summary>
public string GroupId { get; set; }
}
}

+ 45
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_Bom.cs Vedi File

@@ -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
{
/// <summary>
/// 配方名称
/// </summary>

[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)]
public string Name { get; set; }

/// <summary>
/// 配方编码
/// </summary>

[SugarColumn(ColumnDataType = "Nvarchar(50)", IsNullable = false)]
public string Code { get; set; }
/// <summary>
/// 1主料配方0 辅料配方
/// </summary>
public bool IsMain { get; set; }


[SugarColumn(IsOnlyIgnoreInsert = true, IsOnlyIgnoreUpdate = true)]
public int AutoKey { get; set; }
/// <summary>
/// 配方数据
/// </summary>
public string BOMInfo { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; } = 1;
public string GroupId { get; set; }
}
}

+ 27
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_BomAttributeValueRe.cs Vedi File

@@ -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
{
/// <summary>
/// 配方商品属性关系
/// </summary>
[SugarTable("bpa_bomattributevaluere")]
public class BPA_BomAttributeValueRe
{
public string Id { get; set; }
public string GoodsId { get; set; }
/// <summary>
/// 配方id
/// </summary>
public string BoomId { get; set; }
/// <summary>
/// 商品属性值id
/// </summary>
public string GoodsAttributeValueId { get; set; }
}
}

+ 43
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_BomEntry.cs Vedi File

@@ -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
{
/// <summary>
/// 物料id
/// </summary>

[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)]
public string BatchingId { get; set; }
/// <summary>
/// 物料intid
/// </summary>
public long BatchingKey { get; set; }
/// <summary>
/// 配方用量
/// </summary>
public decimal BomQty { get; set; }

/// <summary>
/// 配方id
/// </summary>
public string BomId { get; set; }
/// <summary>
/// 是否可替换
/// </summary>
public bool IsReplace { get; set; }
/// <summary>
/// 排序,小炒abc料获取
/// </summary>
public int sort { get; set; }
public string GroupId { get; set; }
}
}

+ 30
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_BomTypeInfo.cs Vedi File

@@ -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
{
/// <summary>
///
/// </summary>
public string BomId { get; set; }
/// <summary>
///
/// </summary>
public string BomTypeId { get; set; }
/// <summary>
/// 状态 【正常 停用】默认 正常
/// </summary>
[SugarColumn(ColumnDataType = "int", ColumnDescription = "状态", IsNullable = false)]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
public string GroupId { get; set; }
}
}

+ 28
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttribute.cs Vedi File

@@ -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
{
/// <summary>
/// 属性名称
/// </summary>
public string AttributeName { get; set; }
/// <summary>
/// 商品小类id
/// </summary>
public string GoodsTypeId { get; set; }
public int Sort { get; set; }
[SugarColumn(ColumnDataType = "nvarchar(64)", ColumnDescription = "GroupId", IsNullable = true)]
public string GroupId { get; set; }
}
}

+ 29
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_GoodsAttributeValue.cs Vedi File

@@ -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
{
/// <summary>
///商品属性id
/// </summary>
public string GoodsAttributeId { get; set; }
/// <summary>
/// 属性值
/// </summary>
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;
}
}

+ 29
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_GoodsBom.cs Vedi File

@@ -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
{
/// <summary>
/// 商品id
/// </summary>

[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)]
public string Goods_Id { get; set; }

/// <summary>
/// 配方id
/// </summary>

[SugarColumn(ColumnDataType = "Nvarchar(64)", IsNullable = false)]
public string BomId { get; set; }
public string GroupId { get; set; }
}
}

+ 17
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_GoodsInfo.cs Vedi File

@@ -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; }
}
}

+ 26
- 0
BPA.SAAS.Manage.Core/DataBase/BPA_GoodsType.cs Vedi File

@@ -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; }
/// <summary>
/// 状态 【正常 停用】默认 正常
/// </summary>
[SugarColumn(ColumnDataType = "int", ColumnDescription = "状态", IsNullable = false)]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
public string GroupId { get; set; }
}
}

+ 38
- 3
BPA.SAAS.Manage.Core/DbContext.cs Vedi File

@@ -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<IDeleted>(it => it.IsDeleted == 0);
if (!IsSuperAdmin())
{
//非管理员账户过滤加盟商数据
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value;
db.QueryFilter.AddTableFilter<IGroupId>(it => it.GroupId == groupId);
}
//Console.WriteLine(sql);//输出sql
Console.WriteLine($"当前SQL语句:【{sql}】,参数:【{string.Join(",", pars.Select(t => t.Value))}】");
};
});

services.AddSingleton<ISqlSugarClient>(sqlSugar);//这边是SqlSugarScope用AddSingleton
}
// <summary>
/// 判断是不是超级管理员
/// </summary>
/// <returns></returns>
private static bool IsSuperAdmin()
{
if (App.User == null) return false;
return App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value == "1";
}
}
}

+ 1
- 1
BPA.SAAS.Manage.Core/Org/BPA_Organize.cs Vedi File

@@ -13,7 +13,7 @@ namespace BPA.SAAS.Manage.Core.Org
/// 组织机构
/// </summary>
[SugarTable("bpa_organize")]
public class BPA_Organize: IBaseEntity
public class BPA_Organize: IBaseEntity, IGroupId
{
/// <summary>
/// 机构名称


+ 1
- 1
BPA.SAAS.Manage.Core/Org/BPA_Roles.cs Vedi File

@@ -13,7 +13,7 @@ namespace BPA.SAAS.Manage.Core.Org
/// 角色
/// </summary>
[SugarTable("bpa_roles")]
public class BPA_Roles:IBaseEntity
public class BPA_Roles:IBaseEntity, IGroupId
{
/// <summary>
/// 角色名称


+ 8
- 2
BPA.SAAS.Manage.Core/Org/BPA_Users.cs Vedi File

@@ -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
{
/// <summary>
/// 用户名称
@@ -39,5 +40,10 @@ namespace BPA.SAAS.Manage.Core.Org
/// 加盟商id
/// </summary>
public string GroupId { get; set; }
/// <summary>
/// 状态 【正常 停用】默认 正常
/// </summary>
[SugarColumn(ColumnDataType = "int", ColumnDescription = "状态", IsNullable = false)]
public CommonStatus Status { get; set; } = CommonStatus.ENABLE;
}
}

Caricamento…
Annulla
Salva