物料接口修改
parent
3ba0674c6b
commit
34f2970365
|
@ -129,6 +129,11 @@ public class Materials : EntityTenant
|
|||
[SugarColumn(ColumnName = "PackagId", ColumnDescription = "包装关系ID")]
|
||||
public long? PackagId { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToOne, nameof(Id))]
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public List<PackageInfoOutput> PackageInfos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推广ID
|
||||
/// </summary>
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
using Admin.NET.Core;
|
||||
namespace Admin.NET.Application.Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系
|
||||
/// </summary>
|
||||
[SugarTable("PackageInfo","包装关系")]
|
||||
public class PackageInfo : EntityTenant
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
/// </summary>
|
||||
[Required]
|
||||
[SugarColumn(ColumnName = "MaterialsId", ColumnDescription = "物料Id")]
|
||||
public long MaterialsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
[Required]
|
||||
[SugarColumn(ColumnName = "IsEnable", ColumnDescription = "是否启用")]
|
||||
public bool IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码类型编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CodeTypeNum", ColumnDescription = "条码类型编码", Length = 32)]
|
||||
public string? CodeTypeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "CodeType", ColumnDescription = "条码类型", Length = 32)]
|
||||
public string? CodeType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "PackageName", ColumnDescription = "包装关系名称", Length = 32)]
|
||||
public string? PackageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "UnitId", ColumnDescription = "单位Id")]
|
||||
public long? UnitId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Unit", ColumnDescription = "单位名称", Length = 32)]
|
||||
public string? Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位组Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "UnitGroupId", ColumnDescription = "单位组Id")]
|
||||
public long? UnitGroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品数量
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "ProductCount", ColumnDescription = "产品数量", Length = 32)]
|
||||
public string? ProductCount { get; set; }
|
||||
|
||||
}
|
|
@ -3,189 +3,259 @@ using System.ComponentModel.DataAnnotations;
|
|||
|
||||
namespace Admin.NET.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 物料基础输入参数
|
||||
/// <summary>
|
||||
/// 物料基础输入参数
|
||||
/// </summary>
|
||||
public class MaterialsBaseInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public class MaterialsBaseInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public virtual string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
public virtual long Classify { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public virtual string? CodeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 别名
|
||||
/// </summary>
|
||||
public virtual string? AliasName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 助记码
|
||||
/// </summary>
|
||||
public virtual string? SimpleNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格型号
|
||||
/// </summary>
|
||||
public virtual string? Specifications { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可用状态
|
||||
/// </summary>
|
||||
public virtual bool IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public virtual string? Remarks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 租户Id
|
||||
/// </summary>
|
||||
public virtual long? TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public virtual DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public virtual DateTime? UpdateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者Id
|
||||
/// </summary>
|
||||
public virtual long? CreateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者姓名
|
||||
/// </summary>
|
||||
public virtual string? CreateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改者Id
|
||||
/// </summary>
|
||||
public virtual long? UpdateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改者姓名
|
||||
/// </summary>
|
||||
public virtual string? UpdateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 软删除
|
||||
/// </summary>
|
||||
public virtual bool IsDelete { get; set; }
|
||||
|
||||
}
|
||||
public virtual string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料分页查询输入参数
|
||||
/// 分类
|
||||
/// </summary>
|
||||
public class MaterialsInput : BasePageInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 关键字查询
|
||||
/// </summary>
|
||||
public string? SearchKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
public long? Classify { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public string? CodeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 别名
|
||||
/// </summary>
|
||||
public string? AliasName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 助记码
|
||||
/// </summary>
|
||||
public string? SimpleNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格型号
|
||||
/// </summary>
|
||||
public string? Specifications { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可用状态
|
||||
/// </summary>
|
||||
public bool? IsEnable { get; set; }
|
||||
|
||||
}
|
||||
public virtual long Classify { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料增加输入参数
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public class AddMaterialsInput : MaterialsBaseInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "分类不能为空")]
|
||||
public override long Classify { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可用状态
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "可用状态不能为空")]
|
||||
public override bool IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 软删除
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "软删除不能为空")]
|
||||
public override bool IsDelete { get; set; }
|
||||
|
||||
}
|
||||
public virtual string? CodeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料删除输入参数
|
||||
/// 别名
|
||||
/// </summary>
|
||||
public class DeleteMaterialsInput : BaseIdInput
|
||||
{
|
||||
}
|
||||
public virtual string? AliasName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料更新输入参数
|
||||
/// 助记码
|
||||
/// </summary>
|
||||
public class UpdateMaterialsInput : MaterialsBaseInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "主键Id不能为空")]
|
||||
public long Id { get; set; }
|
||||
|
||||
}
|
||||
public virtual string? SimpleNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料主键查询输入参数
|
||||
/// 规格型号
|
||||
/// </summary>
|
||||
public class QueryByIdMaterialsInput : DeleteMaterialsInput
|
||||
{
|
||||
public virtual string? Specifications { get; set; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 可用状态
|
||||
/// </summary>
|
||||
public virtual bool IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 品牌
|
||||
/// </summary>
|
||||
public virtual string? Brand { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 保质期
|
||||
/// </summary>
|
||||
public virtual int? ShelfLife { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 保质期单位
|
||||
/// </summary>
|
||||
public virtual string? ShelfLifeUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 统一零售价
|
||||
/// </summary>
|
||||
public virtual decimal? Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条形码
|
||||
/// </summary>
|
||||
public virtual string? BarCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位组ID
|
||||
/// </summary>
|
||||
public virtual long? UnitGroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 基本单位
|
||||
/// </summary>
|
||||
public virtual string? Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产单位
|
||||
/// </summary>
|
||||
public virtual string? ProductUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 采购单位
|
||||
/// </summary>
|
||||
public virtual string? ProcureUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库存单位
|
||||
/// </summary>
|
||||
public virtual string? InventoryUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 销售单位
|
||||
/// </summary>
|
||||
public virtual string? SaleUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分销单位
|
||||
/// </summary>
|
||||
public virtual string? RetailStoreUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系ID
|
||||
/// </summary>
|
||||
//public virtual long? PackagId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推广ID
|
||||
/// </summary>
|
||||
public virtual long? PromotionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public virtual string? Remarks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 租户Id
|
||||
/// </summary>
|
||||
public virtual long? TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public virtual DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public virtual DateTime? UpdateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者Id
|
||||
/// </summary>
|
||||
public virtual long? CreateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者姓名
|
||||
/// </summary>
|
||||
public virtual string? CreateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改者Id
|
||||
/// </summary>
|
||||
public virtual long? UpdateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改者姓名
|
||||
/// </summary>
|
||||
public virtual string? UpdateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 软删除
|
||||
/// </summary>
|
||||
public virtual bool IsDelete { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料分页查询输入参数
|
||||
/// </summary>
|
||||
public class MaterialsInput : BasePageInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 关键字查询
|
||||
/// </summary>
|
||||
public string? SearchKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
public long? Classify { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public string? CodeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 别名
|
||||
/// </summary>
|
||||
public string? AliasName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 助记码
|
||||
/// </summary>
|
||||
public string? SimpleNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格型号
|
||||
/// </summary>
|
||||
public string? Specifications { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可用状态
|
||||
/// </summary>
|
||||
public bool? IsEnable { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料增加输入参数
|
||||
/// </summary>
|
||||
public class AddMaterialsInput : MaterialsBaseInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "分类不能为空")]
|
||||
public override long Classify { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可用状态
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "可用状态不能为空")]
|
||||
public override bool IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 软删除
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "软删除不能为空")]
|
||||
public override bool IsDelete { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料删除输入参数
|
||||
/// </summary>
|
||||
public class DeleteMaterialsInput : BaseIdInput
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料更新输入参数
|
||||
/// </summary>
|
||||
public class UpdateMaterialsInput : MaterialsBaseInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "主键Id不能为空")]
|
||||
public long Id { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料主键查询输入参数
|
||||
/// </summary>
|
||||
public class QueryByIdMaterialsInput : DeleteMaterialsInput
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -10,9 +10,18 @@ namespace Admin.NET.Application;
|
|||
public class MaterialsService : IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly SqlSugarRepository<Materials> _rep;
|
||||
public MaterialsService(SqlSugarRepository<Materials> rep)
|
||||
private readonly SysUnitService _repUnit;
|
||||
private readonly SysUnitGroupService _repUnitGroup;
|
||||
private readonly PackageInfoService _repPackage;
|
||||
public MaterialsService(SqlSugarRepository<Materials> rep,
|
||||
PackageInfoService repPackage,
|
||||
SysUnitService repUnit,
|
||||
SysUnitGroupService repUnitGroup)
|
||||
{
|
||||
_rep = rep;
|
||||
_repPackage = repPackage;
|
||||
_repUnit = repUnit;
|
||||
_repUnitGroup = repUnitGroup;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -92,7 +101,13 @@ public class MaterialsService : IDynamicApiController, ITransient
|
|||
[ApiDescriptionSettings(Name = "Detail")]
|
||||
public async Task<Materials> Detail([FromQuery] QueryByIdMaterialsInput input)
|
||||
{
|
||||
return await _rep.GetFirstAsync(u => u.Id == input.Id);
|
||||
//return await _rep.GetFirstAsync(u => u.Id == input.Id);
|
||||
var model = await _rep.GetFirstAsync(u => u.Id == input.Id);
|
||||
if (model != null)
|
||||
{
|
||||
model.PackageInfos = await GetPackageList(input.Id);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -107,7 +122,34 @@ public class MaterialsService : IDynamicApiController, ITransient
|
|||
return await _rep.AsQueryable().Select<MaterialsOutput>().ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料
|
||||
/// </summary>
|
||||
/// <param name="materialsId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[ApiDescriptionSettings(Name = "GetById")]
|
||||
public async Task<Materials> GetById(long materialsId)
|
||||
{
|
||||
var model = await _rep.GetFirstAsync(u => u.Id == materialsId);
|
||||
if (model!=null)
|
||||
{
|
||||
model.PackageInfos = await GetPackageList(materialsId);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取包装关系列表
|
||||
/// </summary>
|
||||
/// <param name="materialsId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[ApiDescriptionSettings(Name = "PackageList")]
|
||||
public async Task<List<PackageInfoOutput>> GetPackageList(long materialsId)
|
||||
{
|
||||
return await _repPackage.List(materialsId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
namespace Admin.NET.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系输出参数
|
||||
/// </summary>
|
||||
public class PackageInfoDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
/// </summary>
|
||||
public long MaterialsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码类型编码
|
||||
/// </summary>
|
||||
public string? CodeTypeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码类型
|
||||
/// </summary>
|
||||
public string? CodeType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系名称
|
||||
/// </summary>
|
||||
public string? PackageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位Id
|
||||
/// </summary>
|
||||
public long? UnitId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位组Id
|
||||
/// </summary>
|
||||
public long? UnitGroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品数量
|
||||
/// </summary>
|
||||
public string? ProductCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 租户Id
|
||||
/// </summary>
|
||||
public long? TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者Id
|
||||
/// </summary>
|
||||
public long? CreateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者姓名
|
||||
/// </summary>
|
||||
public string? CreateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改者Id
|
||||
/// </summary>
|
||||
public long? UpdateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改者姓名
|
||||
/// </summary>
|
||||
public string? UpdateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 软删除
|
||||
/// </summary>
|
||||
public bool IsDelete { get; set; }
|
||||
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
using Admin.NET.Core;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Admin.NET.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系基础输入参数
|
||||
/// </summary>
|
||||
public class PackageInfoBaseInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
/// </summary>
|
||||
public virtual long MaterialsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public virtual bool IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码类型编码
|
||||
/// </summary>
|
||||
public virtual string? CodeTypeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码类型
|
||||
/// </summary>
|
||||
public virtual string? CodeType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系名称
|
||||
/// </summary>
|
||||
public virtual string? PackageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位Id
|
||||
/// </summary>
|
||||
public virtual long? UnitId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位组Id
|
||||
/// </summary>
|
||||
public virtual long? UnitGroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品数量
|
||||
/// </summary>
|
||||
public virtual string? ProductCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 租户Id
|
||||
/// </summary>
|
||||
public virtual long? TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public virtual DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public virtual DateTime? UpdateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者Id
|
||||
/// </summary>
|
||||
public virtual long? CreateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者姓名
|
||||
/// </summary>
|
||||
public virtual string? CreateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改者Id
|
||||
/// </summary>
|
||||
public virtual long? UpdateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改者姓名
|
||||
/// </summary>
|
||||
public virtual string? UpdateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 软删除
|
||||
/// </summary>
|
||||
public virtual bool IsDelete { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系分页查询输入参数
|
||||
/// </summary>
|
||||
public class PackageInfoInput : BasePageInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 关键字查询
|
||||
/// </summary>
|
||||
public string? SearchKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
/// </summary>
|
||||
public long? MaterialsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool? IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码类型编码
|
||||
/// </summary>
|
||||
public string? CodeTypeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码类型
|
||||
/// </summary>
|
||||
public string? CodeType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系名称
|
||||
/// </summary>
|
||||
public string? PackageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位Id
|
||||
/// </summary>
|
||||
public long? UnitId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位组Id
|
||||
/// </summary>
|
||||
public long? UnitGroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品数量
|
||||
/// </summary>
|
||||
public string? ProductCount { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系增加输入参数
|
||||
/// </summary>
|
||||
public class AddPackageInfoInput : PackageInfoBaseInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "物料Id不能为空")]
|
||||
public override long MaterialsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "是否启用不能为空")]
|
||||
public override bool IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 软删除
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "软删除不能为空")]
|
||||
public override bool IsDelete { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系删除输入参数
|
||||
/// </summary>
|
||||
public class DeletePackageInfoInput : BaseIdInput
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系更新输入参数
|
||||
/// </summary>
|
||||
public class UpdatePackageInfoInput : PackageInfoBaseInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "主键Id不能为空")]
|
||||
public long Id { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系主键查询输入参数
|
||||
/// </summary>
|
||||
public class QueryByIdPackageInfoInput : DeletePackageInfoInput
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
namespace Admin.NET.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系输出参数
|
||||
/// </summary>
|
||||
public class PackageInfoOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
/// </summary>
|
||||
public long MaterialsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码类型编码
|
||||
/// </summary>
|
||||
public string? CodeTypeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码类型
|
||||
/// </summary>
|
||||
public string? CodeType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 包装关系名称
|
||||
/// </summary>
|
||||
public string? PackageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位Id
|
||||
/// </summary>
|
||||
public long? UnitId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string? Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位组Id
|
||||
/// </summary>
|
||||
public long? UnitGroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品数量
|
||||
/// </summary>
|
||||
public string? ProductCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 租户Id
|
||||
/// </summary>
|
||||
public long? TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者Id
|
||||
/// </summary>
|
||||
public long? CreateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建者姓名
|
||||
/// </summary>
|
||||
public string? CreateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改者Id
|
||||
/// </summary>
|
||||
public long? UpdateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改者姓名
|
||||
/// </summary>
|
||||
public string? UpdateUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 软删除
|
||||
/// </summary>
|
||||
public bool IsDelete { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
using Admin.NET.Core.Service;
|
||||
using Admin.NET.Application.Const;
|
||||
using Admin.NET.Application.Entity;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
namespace Admin.NET.Application;
|
||||
/// <summary>
|
||||
/// 包装关系服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)]
|
||||
public class PackageInfoService : IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly SqlSugarRepository<PackageInfo> _rep;
|
||||
private readonly SysUnitService _unitService;
|
||||
public PackageInfoService(SqlSugarRepository<PackageInfo> rep, SysUnitService unitService)
|
||||
{
|
||||
_rep = rep;
|
||||
_unitService = unitService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询包装关系
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ApiDescriptionSettings(Name = "Page")]
|
||||
public async Task<SqlSugarPagedList<PackageInfoOutput>> Page(PackageInfoInput input)
|
||||
{
|
||||
var query = _rep.AsQueryable()
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u =>
|
||||
u.CodeTypeNum.Contains(input.SearchKey.Trim())
|
||||
|| u.CodeType.Contains(input.SearchKey.Trim())
|
||||
|| u.PackageName.Contains(input.SearchKey.Trim())
|
||||
|| u.ProductCount.Contains(input.SearchKey.Trim())
|
||||
)
|
||||
.WhereIF(input.MaterialsId>0, u => u.MaterialsId == input.MaterialsId)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.CodeTypeNum), u => u.CodeTypeNum.Contains(input.CodeTypeNum.Trim()))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.CodeType), u => u.CodeType.Contains(input.CodeType.Trim()))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.PackageName), u => u.PackageName.Contains(input.PackageName.Trim()))
|
||||
.WhereIF(input.UnitId>0, u => u.UnitId == input.UnitId)
|
||||
.WhereIF(input.UnitGroupId>0, u => u.UnitGroupId == input.UnitGroupId)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.ProductCount), u => u.ProductCount.Contains(input.ProductCount.Trim()))
|
||||
.Select<PackageInfoOutput>();
|
||||
return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加包装关系
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ApiDescriptionSettings(Name = "Add")]
|
||||
public async Task<long> Add(AddPackageInfoInput input)
|
||||
{
|
||||
var entity = input.Adapt<PackageInfo>();
|
||||
await _rep.InsertAsync(entity);
|
||||
return entity.Id;
|
||||
}
|
||||
/// <summary>
|
||||
/// 增加包装关系
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ApiDescriptionSettings(Name = "AddEntity")]
|
||||
public async Task<PackageInfo> AddEntity(AddPackageInfoInput input)
|
||||
{
|
||||
var entity = input.Adapt<PackageInfo>();
|
||||
await _rep.InsertAsync(entity);
|
||||
return entity;
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除包装关系
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ApiDescriptionSettings(Name = "Delete")]
|
||||
public async Task Delete(DeletePackageInfoInput input)
|
||||
{
|
||||
var entity = await _rep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002);
|
||||
await _rep.FakeDeleteAsync(entity); //假删除
|
||||
//await _rep.DeleteAsync(entity); //真删除
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新包装关系
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ApiDescriptionSettings(Name = "Update")]
|
||||
public async Task Update(UpdatePackageInfoInput input)
|
||||
{
|
||||
var entity = input.Adapt<PackageInfo>();
|
||||
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取包装关系
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[ApiDescriptionSettings(Name = "Detail")]
|
||||
public async Task<PackageInfo> Detail([FromQuery] QueryByIdPackageInfoInput input)
|
||||
{
|
||||
return await _rep.GetFirstAsync(u => u.Id == input.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取包装关系列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[ApiDescriptionSettings(Name = "List")]
|
||||
public async Task<List<PackageInfoOutput>> List(long materialsId)
|
||||
{
|
||||
var list = await _rep.AsQueryable().Where(u => u.MaterialsId == materialsId)?.Select<PackageInfoOutput>().ToListAsync();
|
||||
if (list != null && list.Count > 5)
|
||||
{
|
||||
var units = await _unitService.List();
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.Unit = units.Find(a => a.Id == item.UnitId)?.Name;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = new List<PackageInfo>();
|
||||
var newList = new List<AddPackageInfoInput>();
|
||||
newList.Add(new AddPackageInfoInput() { IsEnable = true, CodeTypeNum = "BT30", CodeType = "垛", PackageName = "垛", MaterialsId = materialsId });
|
||||
newList.Add(new AddPackageInfoInput() { IsEnable = true, CodeTypeNum = "BT25", CodeType = "层", PackageName = "层", MaterialsId = materialsId });
|
||||
newList.Add(new AddPackageInfoInput() { IsEnable = true, CodeTypeNum = "BT20", CodeType = "箱", PackageName = "箱", MaterialsId = materialsId });
|
||||
newList.Add(new AddPackageInfoInput() { IsEnable = true, CodeTypeNum = "BT15", CodeType = "套", PackageName = "套", MaterialsId = materialsId });
|
||||
newList.Add(new AddPackageInfoInput() { IsEnable = true, CodeTypeNum = "BT10", CodeType = "袋", PackageName = "袋", MaterialsId = materialsId });
|
||||
newList.Add(new AddPackageInfoInput() { IsEnable = true, CodeTypeNum = "BT00", CodeType = "个", PackageName = "个", MaterialsId = materialsId });
|
||||
foreach (var item in newList)
|
||||
{
|
||||
await Add(item);
|
||||
}
|
||||
return await _rep.AsQueryable().Where(u => u.MaterialsId == materialsId)?.Select<PackageInfoOutput>().ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue