diff --git a/Admin.NET/Admin.NET.Application/Admin.NET.Application.csproj b/Admin.NET/Admin.NET.Application/Admin.NET.Application.csproj index 9a9113b..e58a2ca 100644 --- a/Admin.NET/Admin.NET.Application/Admin.NET.Application.csproj +++ b/Admin.NET/Admin.NET.Application/Admin.NET.Application.csproj @@ -80,4 +80,8 @@ + + + + diff --git a/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs b/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs index f10d66b..0a887da 100644 --- a/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs +++ b/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs @@ -91,4 +91,10 @@ public class PrintCodeDetail : EntityBase [SugarColumn(ColumnName = "WarehouseID", ColumnDescription = "仓库ID")] public long? WarehouseID { get; set; } + /// + /// 父节点ID + /// + [SugarColumn(ColumnName = "FatherId", ColumnDescription = "父节点ID")] + public long? FatherId { get; set; } + } diff --git a/Admin.NET/Admin.NET.Application/Entity/SysUnit.cs b/Admin.NET/Admin.NET.Application/Entity/SysUnit.cs index d49fcd9..d054868 100644 --- a/Admin.NET/Admin.NET.Application/Entity/SysUnit.cs +++ b/Admin.NET/Admin.NET.Application/Entity/SysUnit.cs @@ -7,7 +7,6 @@ namespace Admin.NET.Application.Entity; [SugarTable("SysUnit","单位")] public class SysUnit : EntityTenant { - /// /// 创建者部门Id /// @@ -83,4 +82,10 @@ public class SysUnit : EntityTenant [SugarColumn(ColumnName = "GroupUnitId", ColumnDescription = "单位组ID")] public long? GroupUnitId { get; set; } + /// + /// 子单位数量 + /// + [SugarColumn(ColumnName = "ChildUnitCount", ColumnDescription = "子单位数量")] + public int ChildUnitCount { get; set; } + } diff --git a/Admin.NET/Admin.NET.Application/SeedData/PrintCodeDetailSeedData.cs b/Admin.NET/Admin.NET.Application/SeedData/PrintCodeDetailSeedData.cs deleted file mode 100644 index 78ef0b5..0000000 --- a/Admin.NET/Admin.NET.Application/SeedData/PrintCodeDetailSeedData.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Admin.NET.Core; -using Admin.NET.Application.Entity; - -namespace Admin.NET.Application.SeedData; - -/// -/// 打印条码详情 表种子数据 -/// -public class PrintCodeDetailSeedData: ISqlSugarEntitySeedData -{ - /// - /// 种子数据 - /// - /// - public IEnumerable HasData() - { - string recordsJSON = @" - [] - "; - List records = Newtonsoft.Json.JsonConvert.DeserializeObject>(recordsJSON); - - // 后处理数据的特殊字段 - //for (int i = 0; i < records.Count; i++) { } - - return records; - } -} \ No newline at end of file diff --git a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailDto.cs b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailDto.cs index 282d7b1..d26cc0d 100644 --- a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailDto.cs +++ b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailDto.cs @@ -65,6 +65,11 @@ public class PrintCodeDetailDto /// public long? WarehouseID { get; set; } + /// + /// 父节点ID + /// + public long? FatherId { get; set; } + /// /// 打码时间 /// diff --git a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailInput.cs b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailInput.cs index 2cf811a..bc359ab 100644 --- a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailInput.cs +++ b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailInput.cs @@ -48,21 +48,25 @@ public class PrintCodeDetailBaseInput /// public virtual int? ChildCount { get; set; } - /// /// 打印单ID /// - public long? TempListId { get; set; } + public virtual long? TempListId { get; set; } /// /// 汇报单ID /// - public long? ReportTableId { get; set; } + public virtual long? ReportTableId { get; set; } + + /// + /// 父节点ID + /// + public virtual long? FatherId { get; set; } /// /// 仓库ID /// - public long? WarehouseID { get; set; } + public virtual long? WarehouseID { get; set; } /// /// 打码时间 @@ -166,6 +170,21 @@ public class PrintCodeDetailInput : BasePageInput /// public int? ChildCount { get; set; } + + /// + /// 打印单ID + /// + public long? TempListId { get; set; } + + /// + /// 汇报单ID + /// + public long? ReportTableId { get; set; } + + /// + /// 父节点ID + /// + public long? FatherId { get; set; } /// /// 打码时间 /// diff --git a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailOutput.cs b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailOutput.cs index a9c7e05..0e2b06f 100644 --- a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailOutput.cs +++ b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/Dto/PrintCodeDetailOutput.cs @@ -65,6 +65,11 @@ public class PrintCodeDetailOutput /// public long? WarehouseID { get; set; } + /// + /// 父节点ID + /// + public long? FatherId { get; set; } + /// /// 打码时间 /// diff --git a/Admin.NET/Admin.NET.Application/Service/PrintData/PrintDataService.cs b/Admin.NET/Admin.NET.Application/Service/PrintData/PrintDataService.cs index 616e576..3d8b5f4 100644 --- a/Admin.NET/Admin.NET.Application/Service/PrintData/PrintDataService.cs +++ b/Admin.NET/Admin.NET.Application/Service/PrintData/PrintDataService.cs @@ -110,7 +110,7 @@ public class PrintDataService : IDynamicApiController, ITransient return await GetPrintDatas(input.CodeHead, input.CodeType, input.Count); } - private async Task> GetPrintDatas(string codeName,string codeType,int count) + public async Task> GetPrintDatas(string codeName,string codeType,int count) { var result = new List(); if (string.IsNullOrEmpty(codeName)) diff --git a/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/PrintCodeTreeData.cs b/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/PrintCodeTreeData.cs new file mode 100644 index 0000000..08fc496 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/PrintCodeTreeData.cs @@ -0,0 +1,49 @@ +namespace Admin.NET.Application; + +/// +/// 汇报单输出参数 +/// +public class PrintCodeTreeData +{ + /// + /// 条码 + /// + public string? Code { get; set; } + + /// + /// 上级码 + /// + public string? FatherCode { get; set; } + + /// + /// 条码类型 + /// + public string? CodeName { get; set; } + + /// + /// 数量 + /// + public int? Count { get; set; } + + /// + /// 单位 + /// + public string? Unit { get; set; } + + /// + /// 基本数量 + /// + public int? BaseCount { get; set; } + + /// + /// 基本单位 + /// + public string? BaseUnit { get; set; } + + /// + /// 子码数 + /// + public int? ChildCount { get; set; } + + public List Children { get; set; } +} diff --git a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs index 5cd8870..3680a72 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs @@ -17,13 +17,15 @@ public class ReportTableService : IDynamicApiController, ITransient private readonly PrintCodeDetailService _codeDetailService; private readonly ReportDetailTableService _reportDetailTable; private readonly UserManager _userManager; + private readonly PrintDataService _printDataService; public ReportTableService(SqlSugarRepository rep, UserManager userManager, SysUnitService repUnit, SysUnitGroupService repUnitGroup, PrintCodeDetailService codeDetailService, - ReportDetailTableService reportDetailTable) + ReportDetailTableService reportDetailTable, + PrintDataService printDataService) { _rep = rep; _repUnit = repUnit; @@ -31,6 +33,7 @@ public class ReportTableService : IDynamicApiController, ITransient _codeDetailService = codeDetailService; _reportDetailTable = reportDetailTable; _userManager = userManager; + _printDataService = printDataService; } /// @@ -176,9 +179,10 @@ public class ReportTableService : IDynamicApiController, ITransient /// /// [HttpPost] - [ApiDescriptionSettings(Name = "AddReport")] - public async Task AddPrintList(AddReportContext input) + [ApiDescriptionSettings(Name = "AddPrintList")] + public async Task> AddPrintList(AddReportContext input) { + var result = new List(); var unitGroup = await _repUnitGroup.Detail(new QueryByIdSysUnitGroupInput() { Id = input.UnitGroupId }); if (unitGroup == null) { @@ -196,45 +200,66 @@ public class ReportTableService : IDynamicApiController, ITransient var newReport = new AddReportTableInput() { CreateTime = DateTime.Now, IsDelete = false, OddNumber = DateTime.Now.ToString("yyyyMMddhhmmss"), State = 1 }; var addReport = await Add(newReport); var others = units.FindAll(a => a.Rate < unit.Rate).OrderBy(a => a.Rate).ToList(); - int toltalCount = 1; - foreach (var other in others) - { - toltalCount *= other.Rate.ToInt(); - } + others.Reverse(); + int toltalCount = unit.Rate.ToInt(); + var baseUnit = others.Count > 0 ? others.LastOrDefault().Name : unit.Name; + var userId = _userManager.UserId; + var userName = _userManager.RealName; + List tempUnits = new List(); + tempUnits.AddRange(others); foreach (var item in input.PrintDatas) { var code = string.IsNullOrEmpty(item.BarCode) ? item.QrCode : item.BarCode; var codeType = string.IsNullOrEmpty(item.BarCode) ? "二维码" : "条码"; - var detail = new AddPrintCodeDetailInput() { TempListId = addReport, Code = code, CodeName = codeType, Count = 1, Unit = unit.Name, BaseCount = toltalCount, BaseUnit = others.FirstOrDefault()?.Name, PrintCodeTime = DateTime.Now, CreateUserId = _userManager.UserId, CreateUserName = _userManager.RealName }; - if (others.Count>0) - { - detail.ChildCount = others.LastOrDefault().Rate; - } + var detail = new AddPrintCodeDetailInput() { TempListId = addReport, Code = code, CodeName = codeType, ChildCount = unit.ChildUnitCount, Count = 1, Unit = unit.Name, BaseCount = toltalCount, BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName }; var detailId = await _codeDetailService.Add(detail); - - for (int i = 0; i < others.Count; i++) + var treeData1 = detail.Adapt(); + if (others.Count < 1) { - var current = others[i]; - int count = current.Rate.ToInt(); - if (i < others.Count - 1) + result.Add(treeData1); + continue; + } + treeData1.Children = new List(); + var currUnit = tempUnits.FirstOrDefault(); + var printDatas = await _printDataService.GetPrintDatas(currUnit.Name, codeType, currUnit.ChildUnitCount); + foreach (var dt in printDatas) + { + var code2 = string.IsNullOrEmpty(dt.BarCode) ? dt.QrCode : dt.BarCode; + var detail2 = new AddPrintCodeDetailInput() { TempListId = addReport, FatherCode = code, FatherId = detailId, Code = code2, ChildCount = currUnit.ChildUnitCount, CodeName = codeType, Count = 1, Unit = currUnit.Name, BaseCount = currUnit.Rate, BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName }; + var detailId2 = await _codeDetailService.Add(detail2); + var treeData2 = detail2.Adapt(); + if (tempUnits.Count > 1) { - var ends = others.Skip(i + 1).ToList(); - if (ends.Count>0) + treeData2.Children = new List(); + var currUnit3 = tempUnits[1]; + var printDatas3 = await _printDataService.GetPrintDatas(currUnit3.Name, codeType, currUnit3.ChildUnitCount); + foreach (var dt3 in printDatas3) { - foreach (var ss in ends) + var code3 = string.IsNullOrEmpty(dt3.BarCode) ? dt3.QrCode : dt3.BarCode; + var detail3 = new AddPrintCodeDetailInput() { TempListId = addReport, FatherCode = code2, FatherId = detailId2, Code = code3, ChildCount = currUnit3.ChildUnitCount, CodeName = codeType, Count = 1, Unit = currUnit3.Name, BaseCount = currUnit3.Rate, BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName }; + var detailId3 = await _codeDetailService.Add(detail3); + var treeData3 = detail3.Adapt(); + if (tempUnits.Count > 2) { - count /= ss.Rate.ToInt(); + treeData3.Children = new List(); + var currUnit4 = tempUnits[2]; + var printDatas4 = await _printDataService.GetPrintDatas(currUnit4.Name, codeType, currUnit4.ChildUnitCount); + foreach (var dt4 in printDatas4) + { + var code4 = string.IsNullOrEmpty(dt4.BarCode) ? dt4.QrCode : dt4.BarCode; + var detail4 = new AddPrintCodeDetailInput() { TempListId = addReport, FatherCode = code3, FatherId = detailId3, Code = code4, ChildCount = currUnit4.ChildUnitCount, CodeName = codeType, Count = 1, Unit = currUnit4.Name, BaseCount = currUnit4.Rate, BaseUnit = baseUnit, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName }; + var treeData4 = detail4.Adapt(); + treeData3.Children.Add(treeData4); + } } + treeData2.Children.Add(treeData3); } } - - + treeData1.Children.Add(treeData2); } - + result.Add(treeData1); } - - var entity = input.Adapt(); - await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + return result; } } diff --git a/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitDto.cs b/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitDto.cs index 2e49580..0445144 100644 --- a/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitDto.cs +++ b/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitDto.cs @@ -1,113 +1,117 @@ namespace Admin.NET.Application; +/// +/// 单位输出参数 +/// +public class SysUnitDto +{ /// - /// 单位输出参数 + /// 主键Id /// - public class SysUnitDto - { - /// - /// 主键Id - /// - public long Id { get; set; } - - /// - /// 租户Id - /// - public long? TenantId { get; set; } - - /// - /// 创建时间 - /// - public DateTime? CreateTime { get; set; } - - /// - /// 更新时间 - /// - public DateTime? UpdateTime { get; set; } - - /// - /// 创建者Id - /// - public long? CreateUserId { get; set; } - - /// - /// 创建者姓名 - /// - public string? CreateUserName { get; set; } - - /// - /// 修改者Id - /// - public long? UpdateUserId { get; set; } - - /// - /// 修改者姓名 - /// - public string? UpdateUserName { get; set; } - - /// - /// 创建者部门Id - /// - public long? CreateOrgId { get; set; } - - /// - /// 创建者部门名称 - /// - public string? CreateOrgName { get; set; } - - /// - /// 软删除 - /// - public bool IsDelete { get; set; } - - /// - /// 名称 - /// - public string Name { get; set; } - - /// - /// 编码 - /// - public string CodeNum { get; set; } - - /// - /// 是否启用 - /// - public bool IsEnable { get; set; } - - /// - /// 代码 - /// - public string? Code { get; set; } - - /// - /// 换算率 - /// - public int? Rate { get; set; } - - /// - /// 作为基本单位 - /// - public bool? IsBaseUnit { get; set; } - - /// - /// 精度 - /// - public int? Accuracy { get; set; } - - /// - /// 外部编码 - /// - public string? ExternalNumber { get; set; } - - /// - /// 备注 - /// - public string? Remarks { get; set; } - - /// - /// 单位组ID - /// - public long? GroupUnitId { get; set; } - - } + public long Id { get; set; } + + /// + /// 租户Id + /// + public long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 更新时间 + /// + public DateTime? UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public long? CreateUserId { get; set; } + + /// + /// 创建者姓名 + /// + public string? CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public long? UpdateUserId { get; set; } + + /// + /// 修改者姓名 + /// + public string? UpdateUserName { get; set; } + + /// + /// 创建者部门Id + /// + public long? CreateOrgId { get; set; } + + /// + /// 创建者部门名称 + /// + public string? CreateOrgName { get; set; } + + /// + /// 软删除 + /// + public bool IsDelete { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 编码 + /// + public string CodeNum { get; set; } + + /// + /// 是否启用 + /// + public bool IsEnable { get; set; } + + /// + /// 代码 + /// + public string? Code { get; set; } + + /// + /// 换算率 + /// + public int? Rate { get; set; } + + /// + /// 作为基本单位 + /// + public bool? IsBaseUnit { get; set; } + + /// + /// 精度 + /// + public int? Accuracy { get; set; } + + /// + /// 外部编码 + /// + public string? ExternalNumber { get; set; } + + /// + /// 备注 + /// + public string? Remarks { get; set; } + + /// + /// 单位组ID + /// + public long? GroupUnitId { get; set; } + /// + /// 子单位数量 + /// + public int ChildUnitCount { get; set; } + +} diff --git a/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitInput.cs b/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitInput.cs index 343ab46..7d8213f 100644 --- a/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitInput.cs +++ b/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitInput.cs @@ -3,216 +3,224 @@ using System.ComponentModel.DataAnnotations; namespace Admin.NET.Application; +/// +/// 单位基础输入参数 +/// +public class SysUnitBaseInput +{ /// - /// 单位基础输入参数 + /// 租户Id /// - public class SysUnitBaseInput - { - /// - /// 租户Id - /// - public virtual long? TenantId { get; set; } - - /// - /// 创建时间 - /// - public virtual DateTime? CreateTime { get; set; } - - /// - /// 更新时间 - /// - public virtual DateTime? UpdateTime { get; set; } - - /// - /// 创建者Id - /// - public virtual long? CreateUserId { get; set; } - - /// - /// 创建者姓名 - /// - public virtual string? CreateUserName { get; set; } - - /// - /// 修改者Id - /// - public virtual long? UpdateUserId { get; set; } - - /// - /// 修改者姓名 - /// - public virtual string? UpdateUserName { get; set; } - - /// - /// 创建者部门Id - /// - public virtual long? CreateOrgId { get; set; } - - /// - /// 创建者部门名称 - /// - public virtual string? CreateOrgName { get; set; } - - /// - /// 软删除 - /// - public virtual bool IsDelete { get; set; } - - /// - /// 名称 - /// - public virtual string Name { get; set; } - - /// - /// 编码 - /// - public virtual string CodeNum { get; set; } - - /// - /// 是否启用 - /// - public virtual bool IsEnable { get; set; } - - /// - /// 代码 - /// - public virtual string? Code { get; set; } - - /// - /// 换算率 - /// - public virtual int? Rate { get; set; } - - /// - /// 作为基本单位 - /// - public virtual bool? IsBaseUnit { get; set; } - - /// - /// 精度 - /// - public virtual int? Accuracy { get; set; } - - /// - /// 外部编码 - /// - public virtual string? ExternalNumber { get; set; } - - /// - /// 备注 - /// - public virtual string? Remarks { get; set; } - - /// - /// 单位组ID - /// - public virtual long? GroupUnitId { get; set; } - - } + public virtual long? TenantId { get; set; } /// - /// 单位分页查询输入参数 + /// 创建时间 /// - public class SysUnitInput : BasePageInput - { - /// - /// 关键字查询 - /// - public string? SearchKey { get; set; } - - /// - /// 创建者部门名称 - /// - public string? CreateOrgName { get; set; } - - /// - /// 名称 - /// - public string? Name { get; set; } - - /// - /// 编码 - /// - public string? CodeNum { get; set; } - - /// - /// 是否启用 - /// - public bool? IsEnable { get; set; } - - /// - /// 代码 - /// - public string? Code { get; set; } - - - /// - /// 外部编码 - /// - public string? ExternalNumber { get; set; } - - /// - /// 单位组ID - /// - public long? GroupUnitId { get; set; } - - } + public virtual DateTime? CreateTime { get; set; } /// - /// 单位增加输入参数 + /// 更新时间 /// - public class AddSysUnitInput : SysUnitBaseInput - { - /// - /// 软删除 - /// - [Required(ErrorMessage = "软删除不能为空")] - public override bool IsDelete { get; set; } - - /// - /// 名称 - /// - [Required(ErrorMessage = "名称不能为空")] - public override string Name { get; set; } - - /// - /// 编码 - /// - [Required(ErrorMessage = "编码不能为空")] - public override string CodeNum { get; set; } - - /// - /// 是否启用 - /// - [Required(ErrorMessage = "是否启用不能为空")] - public override bool IsEnable { get; set; } - - } + public virtual DateTime? UpdateTime { get; set; } /// - /// 单位删除输入参数 + /// 创建者Id /// - public class DeleteSysUnitInput : BaseIdInput - { - } + public virtual long? CreateUserId { get; set; } /// - /// 单位更新输入参数 + /// 创建者姓名 /// - public class UpdateSysUnitInput : SysUnitBaseInput - { - /// - /// 主键Id - /// - [Required(ErrorMessage = "主键Id不能为空")] - public long Id { get; set; } - - } + public virtual string? CreateUserName { get; set; } /// - /// 单位主键查询输入参数 + /// 修改者Id /// - public class QueryByIdSysUnitInput : DeleteSysUnitInput - { + public virtual long? UpdateUserId { get; set; } - } + /// + /// 修改者姓名 + /// + public virtual string? UpdateUserName { get; set; } + + /// + /// 创建者部门Id + /// + public virtual long? CreateOrgId { get; set; } + + /// + /// 创建者部门名称 + /// + public virtual string? CreateOrgName { get; set; } + + /// + /// 软删除 + /// + public virtual bool IsDelete { get; set; } + + /// + /// 名称 + /// + public virtual string Name { get; set; } + + /// + /// 编码 + /// + public virtual string CodeNum { get; set; } + + /// + /// 是否启用 + /// + public virtual bool IsEnable { get; set; } + + /// + /// 代码 + /// + public virtual string? Code { get; set; } + + /// + /// 换算率 + /// + public virtual int? Rate { get; set; } + + /// + /// 作为基本单位 + /// + public virtual bool? IsBaseUnit { get; set; } + + /// + /// 精度 + /// + public virtual int? Accuracy { get; set; } + + /// + /// 外部编码 + /// + public virtual string? ExternalNumber { get; set; } + + /// + /// 备注 + /// + public virtual string? Remarks { get; set; } + + /// + /// 单位组ID + /// + public virtual long? GroupUnitId { get; set; } + /// + /// 子单位数量 + /// + public virtual int ChildUnitCount { get; set; } +} + +/// +/// 单位分页查询输入参数 +/// +public class SysUnitInput : BasePageInput +{ + /// + /// 关键字查询 + /// + public string? SearchKey { get; set; } + + /// + /// 创建者部门名称 + /// + public string? CreateOrgName { get; set; } + + /// + /// 名称 + /// + public string? Name { get; set; } + + /// + /// 编码 + /// + public string? CodeNum { get; set; } + + /// + /// 是否启用 + /// + public bool? IsEnable { get; set; } + + /// + /// 代码 + /// + public string? Code { get; set; } + + + /// + /// 外部编码 + /// + public string? ExternalNumber { get; set; } + + /// + /// 单位组ID + /// + public long? GroupUnitId { get; set; } + + /// + /// 子单位数量 + /// + public int ChildUnitCount { get; set; } + +} + +/// +/// 单位增加输入参数 +/// +public class AddSysUnitInput : SysUnitBaseInput +{ + /// + /// 软删除 + /// + [Required(ErrorMessage = "软删除不能为空")] + public override bool IsDelete { get; set; } + + /// + /// 名称 + /// + [Required(ErrorMessage = "名称不能为空")] + public override string Name { get; set; } + + /// + /// 编码 + /// + [Required(ErrorMessage = "编码不能为空")] + public override string CodeNum { get; set; } + + /// + /// 是否启用 + /// + [Required(ErrorMessage = "是否启用不能为空")] + public override bool IsEnable { get; set; } + +} + +/// +/// 单位删除输入参数 +/// +public class DeleteSysUnitInput : BaseIdInput +{ +} + +/// +/// 单位更新输入参数 +/// +public class UpdateSysUnitInput : SysUnitBaseInput +{ + /// + /// 主键Id + /// + [Required(ErrorMessage = "主键Id不能为空")] + public long Id { get; set; } + +} + +/// +/// 单位主键查询输入参数 +/// +public class QueryByIdSysUnitInput : DeleteSysUnitInput +{ + +} diff --git a/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitOutput.cs b/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitOutput.cs index 540f0aa..7b39af4 100644 --- a/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitOutput.cs +++ b/Admin.NET/Admin.NET.Application/Service/SysUnit/Dto/SysUnitOutput.cs @@ -9,107 +9,112 @@ public class SysUnitOutput /// 主键Id /// public long Id { get; set; } - + /// /// 租户Id /// public long? TenantId { get; set; } - + /// /// 创建时间 /// public DateTime? CreateTime { get; set; } - + /// /// 更新时间 /// public DateTime? UpdateTime { get; set; } - + /// /// 创建者Id /// public long? CreateUserId { get; set; } - + /// /// 创建者姓名 /// public string? CreateUserName { get; set; } - + /// /// 修改者Id /// public long? UpdateUserId { get; set; } - + /// /// 修改者姓名 /// public string? UpdateUserName { get; set; } - + /// /// 创建者部门Id /// public long? CreateOrgId { get; set; } - + /// /// 创建者部门名称 /// public string? CreateOrgName { get; set; } - + /// /// 软删除 /// public bool IsDelete { get; set; } - + /// /// 名称 /// public string Name { get; set; } - + /// /// 编码 /// public string CodeNum { get; set; } - + /// /// 是否启用 /// public bool IsEnable { get; set; } - + /// /// 代码 /// public string? Code { get; set; } - + /// /// 换算率 /// public int? Rate { get; set; } - + /// /// 作为基本单位 /// public bool? IsBaseUnit { get; set; } - + /// /// 精度 /// public int? Accuracy { get; set; } - + /// /// 外部编码 /// public string? ExternalNumber { get; set; } - + /// /// 备注 /// public string? Remarks { get; set; } - + /// /// 单位组ID /// public long? GroupUnitId { get; set; } - - } - + + /// + /// 子单位数量 + /// + public int ChildUnitCount { get; set; } + +} + diff --git a/Admin.NET/Admin.NET.Application/Service/SysUnit/SysUnitService.cs b/Admin.NET/Admin.NET.Application/Service/SysUnit/SysUnitService.cs index 9b06328..61907ae 100644 --- a/Admin.NET/Admin.NET.Application/Service/SysUnit/SysUnitService.cs +++ b/Admin.NET/Admin.NET.Application/Service/SysUnit/SysUnitService.cs @@ -115,7 +115,7 @@ public class SysUnitService : IDynamicApiController, ITransient [ApiDescriptionSettings(Name = "List")] public async Task> ListByGroupId(long unitGroupId) { - return await _rep.AsQueryable().WhereIF(unitGroupId > 0, u => u.GroupUnitId == unitGroupId).Where(a => !a.IsDelete).Select().ToListAsync(); + return await _rep.AsQueryable().WhereIF(unitGroupId > 0, u => u.GroupUnitId == unitGroupId && !u.IsDelete).OrderBy(a => a.Rate).Select().ToListAsync(); } diff --git a/Admin.NET/Admin.NET.Application/Utils/TreeData.cs b/Admin.NET/Admin.NET.Application/Utils/TreeData.cs new file mode 100644 index 0000000..fccbb96 --- /dev/null +++ b/Admin.NET/Admin.NET.Application/Utils/TreeData.cs @@ -0,0 +1,22 @@ +namespace Admin.NET.Application; + +/// +/// 打印条码树形数据 +/// +public class TreeData +{ + /// + /// 主键Id + /// + public long Id { get; set; } + + /// + /// 名称 + /// + public string Label { get; set; } + + public List Children { get; set; } + +} + + diff --git a/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs b/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs index 819d197..d7cb021 100644 --- a/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs +++ b/Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs @@ -330,10 +330,18 @@ public static class SqlSugarSetup var entityInfo = dbProvider.EntityMaintenance.GetEntityInfo(entityType); if (entityInfo.Columns.Any(u => u.IsPrimarykey)) { - // 按主键进行批量增加和更新 - var storage = dbProvider.StorageableByObject(seedData.ToList()).ToStorage(); - storage.AsInsertable.ExecuteCommand(); - storage.AsUpdateable.ExecuteCommand(); + try + { + // 按主键进行批量增加和更新 + var storage = dbProvider.StorageableByObject(seedData.ToList()).ToStorage(); + storage.AsInsertable.ExecuteCommand(); + storage.AsUpdateable.ExecuteCommand(); + } + catch (Exception ex) + { + + } + } else { diff --git a/Web/src/api-services/models/add-sys-unit-input.ts b/Web/src/api-services/models/add-sys-unit-input.ts index 0ae7759..2ad2fa4 100644 --- a/Web/src/api-services/models/add-sys-unit-input.ts +++ b/Web/src/api-services/models/add-sys-unit-input.ts @@ -148,6 +148,14 @@ export interface AddSysUnitInput { */ groupUnitId?: number | null; + /** + * 子单位数量 + * + * @type {number} + * @memberof AddSysUnitInput + */ + childUnitCount?: number | null; + /** * 软删除 * diff --git a/Web/src/api-services/models/sys-unit-input.ts b/Web/src/api-services/models/sys-unit-input.ts index bb2f808..07aa2b5 100644 --- a/Web/src/api-services/models/sys-unit-input.ts +++ b/Web/src/api-services/models/sys-unit-input.ts @@ -123,4 +123,12 @@ export interface SysUnitInput { * @memberof SysUnitInput */ groupUnitId?: number | null; + + /** + * 子单位数量 + * + * @type {number} + * @memberof SysUnitInput + */ + childUnitCount?: number | null; } diff --git a/Web/src/api-services/models/sys-unit-output.ts b/Web/src/api-services/models/sys-unit-output.ts index 588b8b1..ae3f735 100644 --- a/Web/src/api-services/models/sys-unit-output.ts +++ b/Web/src/api-services/models/sys-unit-output.ts @@ -187,4 +187,12 @@ export interface SysUnitOutput { * @memberof SysUnitOutput */ groupUnitId?: number | null; + + /** + * 子单位数量 + * + * @type {number} + * @memberof SysUnitOutput + */ + childUnitCount?: number | null; } diff --git a/Web/src/api-services/models/sys-unit.ts b/Web/src/api-services/models/sys-unit.ts index 717e67c..20db621 100644 --- a/Web/src/api-services/models/sys-unit.ts +++ b/Web/src/api-services/models/sys-unit.ts @@ -187,4 +187,12 @@ export interface SysUnit { * @memberof SysUnit */ groupUnitId?: number | null; + + /** + * 子单位数量 + * + * @type {number} + * @memberof SysUnit + */ + childUnitCount?: number | null; } diff --git a/Web/src/api/main/materials.ts b/Web/src/api/main/materials.ts new file mode 100644 index 0000000..3b58048 --- /dev/null +++ b/Web/src/api/main/materials.ts @@ -0,0 +1,50 @@ +import request from '/@/utils/request'; +enum Api { + AddMaterials = '/api/materials/add', + DeleteMaterials = '/api/materials/delete', + UpdateMaterials = '/api/materials/update', + PageMaterials = '/api/materials/page', + DetailMaterials = '/api/materials/detail', +} + +// 增加物料 +export const addMaterials = (params?: any) => + request({ + url: Api.AddMaterials, + method: 'post', + data: params, + }); + +// 删除物料 +export const deleteMaterials = (params?: any) => + request({ + url: Api.DeleteMaterials, + method: 'post', + data: params, + }); + +// 编辑物料 +export const updateMaterials = (params?: any) => + request({ + url: Api.UpdateMaterials, + method: 'post', + data: params, + }); + +// 分页查询物料 +export const pageMaterials = (params?: any) => + request({ + url: Api.PageMaterials, + method: 'post', + data: params, + }); + +// 详情物料 +export const detailMaterials = (id: any) => + request({ + url: Api.DetailMaterials, + method: 'get', + data: { id }, + }); + + diff --git a/Web/src/views/basics-date/matter/component/editOpenAccess.vue b/Web/src/views/basics-date/matter/component/editOpenAccess.vue index a1b7ec3..05cbf10 100644 --- a/Web/src/views/basics-date/matter/component/editOpenAccess.vue +++ b/Web/src/views/basics-date/matter/component/editOpenAccess.vue @@ -232,7 +232,7 @@ const state = reactive({ const openDialog = async (row: any) => { ruleFormRef.value?.resetFields(); //state.selectedTabName = '0'; // 重置为第一个 tab 页 - //state.ruleForm = JSON.parse(JSON.stringify(row)); + //let rowData = JSON.parse(JSON.stringify(row)); if (row.id != undefined) { state.matterFrom=row; //var resRole = await getAPI(MaterialsApi).apiMaterialsDetailGet(row.id); diff --git a/Web/src/views/basics-date/matter/index.vue b/Web/src/views/basics-date/matter/index.vue index 1b7ff00..f4a2dd8 100644 --- a/Web/src/views/basics-date/matter/index.vue +++ b/Web/src/views/basics-date/matter/index.vue @@ -1,327 +1,215 @@ - - - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/Web/src/views/basics-date/matter/index222.ts b/Web/src/views/basics-date/matter/index222.ts new file mode 100644 index 0000000..1b7ff00 --- /dev/null +++ b/Web/src/views/basics-date/matter/index222.ts @@ -0,0 +1,327 @@ + + + + + + \ No newline at end of file diff --git a/Web/src/views/basics-date/unit/index.vue b/Web/src/views/basics-date/unit/index.vue index f084158..9d4a85d 100644 --- a/Web/src/views/basics-date/unit/index.vue +++ b/Web/src/views/basics-date/unit/index.vue @@ -13,7 +13,6 @@ - @@ -26,14 +25,12 @@
-
单位组
- 新增 @@ -47,7 +44,7 @@ - + +