mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-06 09:16:39 +08:00
添加库存管理,入库、出库,收款、回款接口
This commit is contained in:
@@ -249,6 +249,18 @@
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.Receipt(Yi.Framework.DtoModel.ERP.Purchase.ReceiptInput)">
|
||||
<summary>
|
||||
收获
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.Collection(Yi.Framework.DtoModel.ERP.Purchase.CollectionInput)">
|
||||
<summary>
|
||||
回款?????甲方主动给乙方钱,乙方给货物。应该不叫回款。。。。想想叫啥优雅的名字
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseDetailsController.PageList(Yi.Framework.DtoModel.ERP.PurchaseDetails.PurchaseDetailsGetListInput,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
分页查
|
||||
@@ -283,6 +295,49 @@
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockController.PageList(Yi.Framework.DtoModel.ERP.Stock.StockGetListInput,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
分页查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockController.GetById(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockController.InputStock(Yi.Framework.DtoModel.ERP.Stock.StockCreateUpdateInput)">
|
||||
<summary>
|
||||
入库
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockController.OutputStock(Yi.Framework.DtoModel.ERP.Stock.StockCreateUpdateInput)">
|
||||
<summary>
|
||||
出库
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockDetailsController.PageList(Yi.Framework.DtoModel.ERP.StockDetails.StockDetailsGetListInput,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
分页查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockDetailsController.GetById(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.StockDetailsController.Del(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
删
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.SupplierController.GetList">
|
||||
<summary>
|
||||
全查
|
||||
|
||||
@@ -79,5 +79,25 @@ namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
await _purchaseService.DeleteAsync(ids);
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 收获
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Receipt(ReceiptInput input)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回款?????甲方主动给乙方钱,乙方给货物。应该不叫回款。。。。想想叫啥优雅的名字
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Collection(CollectionInput input)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.Stock;
|
||||
using Yi.Framework.Interface.ERP;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class StockController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<StockController> _logger;
|
||||
private readonly IStockService _stockService;
|
||||
public StockController(ILogger<StockController> logger, IStockService stockService)
|
||||
{
|
||||
_logger = logger;
|
||||
_stockService = stockService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] StockGetListInput input, [FromQuery] PageParModel page)
|
||||
{
|
||||
var result = await _stockService.PageListAsync(input, page);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetById(long id)
|
||||
{
|
||||
var result = await _stockService.GetByIdAsync(id);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 入库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> InputStock(StockCreateUpdateInput input)
|
||||
{
|
||||
var result = await _stockService.InputStockAsync(input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 出库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> OutputStock(StockCreateUpdateInput input)
|
||||
{
|
||||
var result = await _stockService.OutputStockAsync(input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.StockDetails;
|
||||
using Yi.Framework.Interface.ERP;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class StockDetailsController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<StockDetailsController> _logger;
|
||||
private readonly IStockDetailsService _stockDetailsService;
|
||||
public StockDetailsController(ILogger<StockDetailsController> logger, IStockDetailsService stockDetailsService)
|
||||
{
|
||||
_logger = logger;
|
||||
_stockDetailsService = stockDetailsService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] StockDetailsGetListInput input, [FromQuery] PageParModel page)
|
||||
{
|
||||
var result = await _stockDetailsService.PageListAsync(input, page);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetById(long id)
|
||||
{
|
||||
var result = await _stockDetailsService.GetByIdAsync(id);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<Result> Del(List<long> ids)
|
||||
{
|
||||
await _stockDetailsService.DeleteAsync(ids);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.Purchase
|
||||
{
|
||||
/// <summary>
|
||||
/// 回款
|
||||
/// </summary>
|
||||
public class CollectionInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 采购订单id
|
||||
/// </summary>
|
||||
public long PurchaseId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///回款钱
|
||||
/// </summary>
|
||||
public float CollectionMoney { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.Purchase
|
||||
{
|
||||
/// <summary>
|
||||
/// 收货
|
||||
/// </summary>
|
||||
public class ReceiptInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 采购订单id
|
||||
/// </summary>
|
||||
public long PurchaseId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class ReceiptDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单子表id
|
||||
/// </summary>
|
||||
public long PurchaseDatilesId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 收货数量
|
||||
/// </summary>
|
||||
public long Number { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.Stock.ConstConfig
|
||||
{
|
||||
public class StockConst
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.ERP.Entitys;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.Stock.MapperConfig
|
||||
{
|
||||
public class SuppliERProfile:Profile
|
||||
{
|
||||
public SuppliERProfile()
|
||||
{
|
||||
CreateMap<StockCreateUpdateInput, StockEntity>();
|
||||
CreateMap<StockEntity, StockGetListOutput>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.Stock
|
||||
{
|
||||
public class StockCreateUpdateInput : EntityDto<long>
|
||||
{
|
||||
public long WarehouseId { get; set; }
|
||||
public long MaterialId { get; set; }
|
||||
public long Number { get; set; }
|
||||
public string? Quality { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.Stock
|
||||
{
|
||||
public class StockGetListInput
|
||||
{
|
||||
|
||||
public long Number { get; set; }
|
||||
public string? Quality { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.Stock
|
||||
{
|
||||
public class StockGetListOutput: EntityDto<long>
|
||||
{
|
||||
public string MaterialName { get; set; } = string.Empty;
|
||||
public string UnitName { get; set; } = string.Empty;
|
||||
public string WarehouseName { get; set; } = string.Empty;
|
||||
public long Number { get; set; }
|
||||
public string? Quality { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.StockDetails.ConstConfig
|
||||
{
|
||||
public class StockDetailsConst
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.ERP.Entitys;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.StockDetails.MapperConfig
|
||||
{
|
||||
public class SuppliERProfile:Profile
|
||||
{
|
||||
public SuppliERProfile()
|
||||
{
|
||||
CreateMap<StockDetailsCreateUpdateInput, StockDetailsEntity>();
|
||||
CreateMap<StockDetailsEntity, StockDetailsGetListOutput>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
using Yi.Framework.Model.ERP.Entitys;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.StockDetails
|
||||
{
|
||||
public class StockDetailsCreateUpdateInput : EntityDto<long>
|
||||
{
|
||||
public long WarehouseId { get; set; }
|
||||
public long MaterialId { get; set; }
|
||||
public long Number { get; set; }
|
||||
public string? Quality { get; set; }
|
||||
public StockDetailsTypeEnum StockDetailsType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
using Yi.Framework.Model.ERP.Entitys;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.StockDetails
|
||||
{
|
||||
public class StockDetailsGetListInput
|
||||
{
|
||||
public long WarehouseName { get; set; }
|
||||
public long MaterialName { get; set; }
|
||||
public string? Quality { get; set; }
|
||||
public StockDetailsTypeEnum StockDetailsType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
using Yi.Framework.Model.ERP.Entitys;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.StockDetails
|
||||
{
|
||||
public class StockDetailsGetListOutput: EntityDto<long>
|
||||
{
|
||||
public long WarehouseName { get; set; }
|
||||
public long MaterialName { get; set; }
|
||||
public long Number { get; set; }
|
||||
public string? Quality { get; set; }
|
||||
public DateTime StockDetailsTime { get; set; }
|
||||
public StockDetailsTypeEnum StockDetailsType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.StockDetails;
|
||||
using Yi.Framework.Interface.Base.Crud;
|
||||
|
||||
namespace Yi.Framework.Interface.ERP
|
||||
{
|
||||
public interface IStockDetailsService : ICrudAppService<StockDetailsGetListOutput, long, StockDetailsCreateUpdateInput>
|
||||
{
|
||||
Task<PageModel<List<StockDetailsGetListOutput>>> PageListAsync(StockDetailsGetListInput input, PageParModel page);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.Stock;
|
||||
using Yi.Framework.Interface.Base.Crud;
|
||||
|
||||
namespace Yi.Framework.Interface.ERP
|
||||
{
|
||||
public interface IStockService : ICrudAppService<StockGetListOutput, long, StockCreateUpdateInput>
|
||||
{
|
||||
Task<PageModel<List<StockGetListOutput>>> PageListAsync(StockGetListInput input, PageParModel page);
|
||||
|
||||
/// <summary>
|
||||
/// Èë¿â
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<StockGetListOutput> InputStockAsync(StockCreateUpdateInput input);
|
||||
|
||||
/// <summary>
|
||||
/// ³ö¿â
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<StockGetListOutput> OutputStockAsync(StockCreateUpdateInput input);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
|
||||
namespace Yi.Framework.Model.ERP.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 库存明细,像这种记录型的表,需要进行冗余字段保存历史记录
|
||||
/// </summary>
|
||||
[SugarTable("StockDetails")]
|
||||
public class StockDetailsEntity : IEntity<long>, IMultiTenant
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 租户id
|
||||
/// </summary>
|
||||
public Guid? TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库存id
|
||||
/// </summary>
|
||||
public long StockId { get; set; }
|
||||
/// <summary>
|
||||
/// 仓库id
|
||||
/// </summary>
|
||||
public long WarehouseId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仓库名称
|
||||
/// </summary>
|
||||
public string WarehouseName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 物料id
|
||||
/// </summary>
|
||||
public long MaterialId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string MaterialName { get; set; }=string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public long Number { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 品质
|
||||
/// </summary>
|
||||
public string? Quality { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 入库或者出库时间
|
||||
/// </summary>
|
||||
public DateTime StockDetailsTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 明细类别
|
||||
/// </summary>
|
||||
public StockDetailsTypeEnum StockDetailsType { get; set; }
|
||||
}
|
||||
public enum StockDetailsTypeEnum
|
||||
{
|
||||
Input = 0,//入库
|
||||
Output = 1//出库
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
|
||||
namespace Yi.Framework.Model.ERP.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 库存
|
||||
/// </summary>
|
||||
[SugarTable("Stock")]
|
||||
public class StockEntity : IEntity<long>, IMultiTenant
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 租户id
|
||||
/// </summary>
|
||||
public Guid? TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仓库id
|
||||
/// </summary>
|
||||
public long WarehouseId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料id
|
||||
/// </summary>
|
||||
public long MaterialId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public long Number { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 品质
|
||||
/// </summary>
|
||||
public string? Quality { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -31,14 +31,14 @@ namespace Yi.Framework.Service.Base.Crud
|
||||
public IRepository<TEntity> Repository { get; set; }
|
||||
|
||||
|
||||
public async Task<List<TGetListOutputDto>> GetListAsync()
|
||||
public virtual async Task<List<TGetListOutputDto>> GetListAsync()
|
||||
{
|
||||
var entitys = await Repository.GetListAsync();
|
||||
var entityDtos = await MapToGetListOutputDtosAsync(entitys);
|
||||
return entityDtos;
|
||||
}
|
||||
|
||||
public async Task<TGetOutputDto> GetByIdAsync(TKey id)
|
||||
public virtual async Task<TGetOutputDto> GetByIdAsync(TKey id)
|
||||
{
|
||||
var entity = await GetEntityByIdAsync(id);
|
||||
if (entity is null)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using AutoMapper;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.StockDetails;
|
||||
using Yi.Framework.Interface.ERP;
|
||||
using Yi.Framework.Model.ERP.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service.Base.Crud;
|
||||
|
||||
namespace Yi.Framework.Service.ERP
|
||||
{
|
||||
public class StockDetailsService : CrudAppService<StockDetailsEntity, StockDetailsGetListOutput, long, StockDetailsCreateUpdateInput>, IStockDetailsService
|
||||
{
|
||||
public async Task<PageModel<List<StockDetailsGetListOutput>>> PageListAsync(StockDetailsGetListInput input, PageParModel page)
|
||||
{
|
||||
RefAsync<int> totalNumber = 0;
|
||||
var data = await Repository._DbQueryable
|
||||
.Where(u => u.StockDetailsType == input.StockDetailsType)
|
||||
.WhereIF(page.StartTime is not null && page.EndTime is not null, u => u.StockDetailsTime >= page.StartTime && u.StockDetailsTime <= page.EndTime)
|
||||
.ToPageListAsync(page.PageNum, page.PageSize, totalNumber);
|
||||
return new PageModel<List<StockDetailsGetListOutput>> { Total = totalNumber.Value, Data = await MapToGetListOutputDtosAsync(data) };
|
||||
}
|
||||
}
|
||||
}
|
||||
188
Yi.Framework.Net6/Yi.Framework.Service/ERP/StockService.cs
Normal file
188
Yi.Framework.Net6/Yi.Framework.Service/ERP/StockService.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
using AutoMapper;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Exceptions;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.Stock;
|
||||
using Yi.Framework.Interface.ERP;
|
||||
using Yi.Framework.Model.ERP.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service.Base.Crud;
|
||||
|
||||
namespace Yi.Framework.Service.ERP
|
||||
{
|
||||
public class StockService : CrudAppService<StockEntity, StockGetListOutput, long, StockCreateUpdateInput>, IStockService
|
||||
{
|
||||
private IRepository<StockDetailsEntity> _detailsRepository;
|
||||
private ISugarUnitOfWork<UnitOfWork> _unitOfWork;
|
||||
public StockService(IRepository<StockDetailsEntity> detailsRepository, ISugarUnitOfWork<UnitOfWork> unitOfWork)
|
||||
{
|
||||
_detailsRepository = detailsRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
public async Task<PageModel<List<StockGetListOutput>>> PageListAsync(StockGetListInput input, PageParModel page)
|
||||
{
|
||||
RefAsync<int> totalNumber = 0;
|
||||
var data = await Repository._DbQueryable
|
||||
.LeftJoin<WarehouseEntity>((stock, warehouse) => stock.WarehouseId == warehouse.Id)
|
||||
.LeftJoin<MaterialEntity>((stock, warehouse, material) => stock.MaterialId == material.Id)
|
||||
.Select((stock, warehouse, material) => new StockGetListOutput
|
||||
{
|
||||
MaterialName = material.Name,
|
||||
WarehouseName = warehouse.Name,
|
||||
UnitName = material.UnitName
|
||||
}, true)
|
||||
.ToPageListAsync(page.PageNum, page.PageSize, totalNumber);
|
||||
return new PageModel<List<StockGetListOutput>> { Total = totalNumber.Value, Data = data };
|
||||
}
|
||||
|
||||
public override async Task<StockGetListOutput> GetByIdAsync(long id)
|
||||
{
|
||||
return await Repository._DbQueryable
|
||||
.LeftJoin<WarehouseEntity>((stock, warehouse) => stock.WarehouseId == warehouse.Id)
|
||||
.LeftJoin<MaterialEntity>((stock, warehouse, material) => stock.MaterialId == material.Id)
|
||||
.Select((stock, warehouse, material) => new StockGetListOutput
|
||||
{
|
||||
MaterialName = material.Name,
|
||||
WarehouseName = warehouse.Name,
|
||||
UnitName = material.UnitName
|
||||
}, true)
|
||||
.FirstAsync(stock => stock.Id==id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 入库操作,需要工作单元事务操作
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<StockGetListOutput> InputStockAsync(StockCreateUpdateInput input)
|
||||
{
|
||||
StockGetListOutput result = new();
|
||||
using (var uow = _unitOfWork.CreateContext())
|
||||
{
|
||||
var entity = await MapToEntityAsync(input);
|
||||
//先判断是否存在该物料,如果存在,直接添加数量
|
||||
var entityData = await Repository.GetFirstAsync(u => u.MaterialId == entity.MaterialId);
|
||||
if (entityData is not null)
|
||||
{
|
||||
entityData.Number += input.Number;
|
||||
await Repository.UpdateIgnoreNullAsync(entityData);
|
||||
}
|
||||
//添加一条库存数据
|
||||
else
|
||||
{
|
||||
await Repository.InsertReturnSnowflakeIdAsync(entity);
|
||||
}
|
||||
|
||||
result = await Repository._DbQueryable
|
||||
.LeftJoin<WarehouseEntity>((stock, warehouse) => stock.WarehouseId == warehouse.Id)
|
||||
.LeftJoin<MaterialEntity>((stock, warehouse, material) => stock.MaterialId == material.Id)
|
||||
.Select((stock, warehouse, material) => new StockGetListOutput
|
||||
{
|
||||
MaterialName = material.Name,
|
||||
WarehouseName = warehouse.Name,
|
||||
UnitName = material.UnitName
|
||||
}, true).FirstAsync();
|
||||
|
||||
//还需要进行入库明细的插入
|
||||
StockDetailsEntity stockDetailsEntity = new();
|
||||
stockDetailsEntity.StockId = result.Id;
|
||||
stockDetailsEntity.WarehouseId = input.WarehouseId;
|
||||
stockDetailsEntity.MaterialId = input.MaterialId;
|
||||
stockDetailsEntity.WarehouseName = result.WarehouseName;
|
||||
stockDetailsEntity.MaterialName = result.MaterialName;
|
||||
stockDetailsEntity.StockDetailsTime = DateTime.Now;
|
||||
stockDetailsEntity.Quality = input.Quality;
|
||||
stockDetailsEntity.Number = input.Number;
|
||||
stockDetailsEntity.StockDetailsType = StockDetailsTypeEnum.Input;
|
||||
|
||||
await _detailsRepository.InsertReturnSnowflakeIdAsync(stockDetailsEntity);
|
||||
|
||||
uow.Commit();
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 出库操作,需要工作单元事务操作
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<StockGetListOutput> OutputStockAsync(StockCreateUpdateInput input)
|
||||
{
|
||||
StockGetListOutput result = new();
|
||||
using (var uow = _unitOfWork.CreateContext())
|
||||
{
|
||||
var entity = await Repository.GetByIdAsync(input.Id);
|
||||
|
||||
if (entity is null)
|
||||
{
|
||||
throw new ApplicationException("出库失败,该库存不存在");
|
||||
}
|
||||
|
||||
|
||||
//先判断是否存在该物料,如果存在,直接减去数量,如果减完数量=0,直接删除该条数据,如果小于零,库存不足
|
||||
var entityData = await Repository.GetFirstAsync(u => u.MaterialId == entity.MaterialId);
|
||||
if (entityData is not null)
|
||||
{
|
||||
entityData.Number -= input.Number;
|
||||
|
||||
if (entityData.Number < 0)
|
||||
{
|
||||
throw new UserFriendlyException("库存不足");
|
||||
}
|
||||
else if (entityData.Number == 0)
|
||||
{
|
||||
await Repository.DeleteAsync(u => u.MaterialId == input.MaterialId);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Repository.UpdateIgnoreNullAsync(entityData);
|
||||
}
|
||||
|
||||
}
|
||||
//不存在该物料
|
||||
else
|
||||
{
|
||||
throw new UserFriendlyException("库存未发现该物料");
|
||||
}
|
||||
result = await Repository._DbQueryable
|
||||
.LeftJoin<WarehouseEntity>((stock, warehouse) => stock.WarehouseId == warehouse.Id)
|
||||
.LeftJoin<MaterialEntity>((stock, warehouse, material) => stock.MaterialId == material.Id)
|
||||
.Select((stock, warehouse, material) => new StockGetListOutput
|
||||
{
|
||||
MaterialName = material.Name,
|
||||
WarehouseName = warehouse.Name,
|
||||
UnitName = material.UnitName
|
||||
}, true).FirstAsync();
|
||||
|
||||
//还需要进行入库明细的插入
|
||||
StockDetailsEntity stockDetailsEntity = new();
|
||||
stockDetailsEntity.StockId = result.Id;
|
||||
stockDetailsEntity.WarehouseId = input.WarehouseId;
|
||||
stockDetailsEntity.MaterialId = input.MaterialId;
|
||||
stockDetailsEntity.WarehouseName = result.WarehouseName;
|
||||
stockDetailsEntity.MaterialName = result.MaterialName;
|
||||
stockDetailsEntity.StockDetailsTime = DateTime.Now;
|
||||
stockDetailsEntity.Quality = input.Quality;
|
||||
stockDetailsEntity.Number = input.Number;
|
||||
stockDetailsEntity.StockDetailsType = StockDetailsTypeEnum.Output;
|
||||
await _detailsRepository.InsertReturnSnowflakeIdAsync(stockDetailsEntity);
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,15 +13,15 @@ foreach (var entityName in entityNames)
|
||||
{
|
||||
templateFactory.CreateTemplateProviders((option) =>
|
||||
{
|
||||
//option.Add(new ServceTemplateProvider(modelName, entityName));
|
||||
//option.Add(new IServceTemplateProvider(modelName, entityName));
|
||||
//option.Add(new CreateUpdateInputTemplateProvider(modelName, entityName));
|
||||
//option.Add(new GetListOutputTemplateProvider(modelName, entityName));
|
||||
//option.Add(new GetListInputTemplateProvider(modelName, entityName));
|
||||
//option.Add(new ConstTemplateProvider(modelName, entityName));
|
||||
//option.Add(new ProfileTemplateProvider(modelName, entityName));
|
||||
option.Add(new ServceTemplateProvider(modelName, entityName));
|
||||
option.Add(new IServceTemplateProvider(modelName, entityName));
|
||||
option.Add(new CreateUpdateInputTemplateProvider(modelName, entityName));
|
||||
option.Add(new GetListOutputTemplateProvider(modelName, entityName));
|
||||
option.Add(new GetListInputTemplateProvider(modelName, entityName));
|
||||
option.Add(new ConstTemplateProvider(modelName, entityName));
|
||||
option.Add(new ProfileTemplateProvider(modelName, entityName));
|
||||
option.Add(new ControllerTemplateProvider(modelName, entityName));
|
||||
//option.Add(new ApiTemplateProvider(modelName, entityName));
|
||||
option.Add(new ApiTemplateProvider(modelName, entityName));
|
||||
});
|
||||
//开始构建模板
|
||||
templateFactory.BuildTemplate();
|
||||
|
||||
Reference in New Issue
Block a user