From c5d1b5afe6fba96183d8a4368ea97c928440ca9e Mon Sep 17 00:00:00 2001 From: ljh Date: Sat, 13 Jul 2024 01:18:35 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=9F=E4=BA=A7=E5=8D=95?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/ProductionLine.cs | 8 +- .../Entity/ReportDetailTable.cs | 10 +- .../Entity/ReportTable.cs | 10 +- .../ProductionLine/Dto/ProductionLineInput.cs | 23 +++- .../ProductionLine/ProductionLineService.cs | 17 ++- .../Dto/ReportDetailTableInput.cs | 30 +++++- .../Dto/ReportDetailTableOutput.cs | 2 +- .../ReportDetailTableService.cs | 100 +++++++++++++----- .../ReportTable/Dto/ReportTableInput.cs | 3 +- .../Service/ReportTable/ReportTableService.cs | 3 + .../component/editDialog.vue | 4 +- .../reportDetailTable/index.vue | 12 ++- .../reportTable/component/codeDialog.vue | 10 +- 13 files changed, 179 insertions(+), 53 deletions(-) diff --git a/Admin.NET/Admin.NET.Application/Entity/ProductionLine.cs b/Admin.NET/Admin.NET.Application/Entity/ProductionLine.cs index 639a474..f402520 100644 --- a/Admin.NET/Admin.NET.Application/Entity/ProductionLine.cs +++ b/Admin.NET/Admin.NET.Application/Entity/ProductionLine.cs @@ -24,5 +24,11 @@ public class ProductionLine : EntityTenant /// [SugarColumn(ColumnName = "Remarks", ColumnDescription = "备注", Length = 64)] public string? Remarks { get; set; } - + + /// + /// 状态 + /// + [SugarColumn(ColumnName = "State", ColumnDescription = "状态", Length = 64)] + public int? State { get; set; } + } diff --git a/Admin.NET/Admin.NET.Application/Entity/ReportDetailTable.cs b/Admin.NET/Admin.NET.Application/Entity/ReportDetailTable.cs index b1a4351..2bc0011 100644 --- a/Admin.NET/Admin.NET.Application/Entity/ReportDetailTable.cs +++ b/Admin.NET/Admin.NET.Application/Entity/ReportDetailTable.cs @@ -31,12 +31,12 @@ public class ReportDetailTable : EntityTenant /// [Required] [SugarColumn(ColumnName = "State", ColumnDescription = "状态", Length = 32)] - public string State { get; set; } + public int State { get; set; } /// /// 生产类型 /// - [SugarColumn(ColumnName = "ProductType", ColumnDescription = "生产类型", Length = 32)] + [SugarColumn(ColumnName = "ProductType", ColumnDescription = "生产类型")] public string? ProductType { get; set; } /// @@ -170,4 +170,10 @@ public class ReportDetailTable : EntityTenant /// [SugarColumn(ColumnName = "UnitGroupId", ColumnDescription = "单位组ID")] public long? UnitGroupId { get; set; } + + /// + /// 生产状态 + /// + [SugarColumn(ColumnName = "ProductState", ColumnDescription = "生产状态")] + public int? ProductState { get; set; } } diff --git a/Admin.NET/Admin.NET.Application/Entity/ReportTable.cs b/Admin.NET/Admin.NET.Application/Entity/ReportTable.cs index de0eb1e..9c6ba65 100644 --- a/Admin.NET/Admin.NET.Application/Entity/ReportTable.cs +++ b/Admin.NET/Admin.NET.Application/Entity/ReportTable.cs @@ -83,7 +83,7 @@ public class ReportTable : EntityTenant /// 基本完工数量 /// [SugarColumn(ColumnName = "BaseProductCount", ColumnDescription = "基本完工数量")] - public int? BaseProductCount { get; set; } + public decimal? BaseProductCount { get; set; } /// /// 单位 @@ -102,5 +102,11 @@ public class ReportTable : EntityTenant /// [SugarColumn(ColumnName = "Name", ColumnDescription = "名称", Length = 32)] public string? Name { get; set; } - + + /// + /// 生产状态 + /// + [SugarColumn(ColumnName = "ProductState", ColumnDescription = "生产状态")] + public int? ProductState { get; set; } + } diff --git a/Admin.NET/Admin.NET.Application/Service/ProductionLine/Dto/ProductionLineInput.cs b/Admin.NET/Admin.NET.Application/Service/ProductionLine/Dto/ProductionLineInput.cs index 06b7d0f..58d9e26 100644 --- a/Admin.NET/Admin.NET.Application/Service/ProductionLine/Dto/ProductionLineInput.cs +++ b/Admin.NET/Admin.NET.Application/Service/ProductionLine/Dto/ProductionLineInput.cs @@ -125,10 +125,25 @@ namespace Admin.NET.Application; } - /// - /// 生产线主键查询输入参数 - /// - public class QueryByIdProductionLineInput : DeleteProductionLineInput + public class UpdateStateProductionLineInput + { + /// + /// 主键Id + /// + [Required(ErrorMessage = "主键Id不能为空")] + public long Id { get; set; } + + /// + /// 状态 + /// + public int State { get; set; } + + } + +/// +/// 生产线主键查询输入参数 +/// +public class QueryByIdProductionLineInput : DeleteProductionLineInput { } diff --git a/Admin.NET/Admin.NET.Application/Service/ProductionLine/ProductionLineService.cs b/Admin.NET/Admin.NET.Application/Service/ProductionLine/ProductionLineService.cs index 5889c23..e1786fd 100644 --- a/Admin.NET/Admin.NET.Application/Service/ProductionLine/ProductionLineService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ProductionLine/ProductionLineService.cs @@ -102,9 +102,20 @@ public class ProductionLineService : IDynamicApiController, ITransient return await _rep.AsQueryable().Where(a => !a.IsDelete).Select().ToListAsync(); } + /// + /// 更新生产线状态 + /// + /// + /// - - - + [HttpPost] + [ApiDescriptionSettings(Name = "UpdateState")] + public async Task UpdateState(UpdateStateProductionLineInput input) + { + var entity = await _rep.GetByIdAsync(input.Id); + if(entity==null) + entity.State = input.State; + await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + } } diff --git a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/Dto/ReportDetailTableInput.cs b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/Dto/ReportDetailTableInput.cs index 7e873ba..879e0e6 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/Dto/ReportDetailTableInput.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/Dto/ReportDetailTableInput.cs @@ -26,7 +26,7 @@ public class ReportDetailTableBaseInput /// /// 状态 /// - public virtual string State { get; set; } + public virtual int State { get; set; } /// /// 生产类型 @@ -213,7 +213,7 @@ public class ReportDetailTableInput : BasePageInput /// /// 状态 /// - public string? State { get; set; } + public int? State { get; set; } /// /// 生产类型 @@ -350,7 +350,7 @@ public class AddReportDetailTableInput : ReportDetailTableBaseInput /// 状态 /// [Required(ErrorMessage = "状态不能为空")] - public override string State { get; set; } + public override int State { get; set; } /// /// 软删除 @@ -403,5 +403,27 @@ public class UpdateStateReportDetailTableInput /// /// 是否启用 /// - public string State { get; set; } + public int State { get; set; } +} + + +/// +/// 更新生产状态输入参数 +/// +public class UpdateProductStateReportDetailTableInput +{ + /// + /// 订单号 + /// + public string OddNumber { get; set; } + + /// + /// 物料ID + /// + public long MaterialsId { get; set; } + + /// + /// 生产状态 + /// + public int ProductState { get; set; } } diff --git a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/Dto/ReportDetailTableOutput.cs b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/Dto/ReportDetailTableOutput.cs index a81603d..a184fa4 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/Dto/ReportDetailTableOutput.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/Dto/ReportDetailTableOutput.cs @@ -28,7 +28,7 @@ public class ReportDetailTableOutput /// /// 状态 /// - public string State { get; set; } + public int? State { get; set; } /// /// 生产类型 diff --git a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs index 96927d0..c21f96e 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Http; using Admin.NET.Application.Utils; using AngleSharp.Dom; using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; +using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; namespace Admin.NET.Application; /// @@ -59,7 +60,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient u.ProductName.Contains(input.SearchKey.Trim()) || u.ProductCodeNum.Contains(input.SearchKey.Trim()) || u.OddNumber.Contains(input.SearchKey.Trim()) - || u.State.Contains(input.SearchKey.Trim()) + || u.State==(input.State) || u.ProductType.Contains(input.SearchKey.Trim()) || u.ProductionLine.Contains(input.SearchKey.Trim()) || u.CodeNum.Contains(input.SearchKey.Trim()) @@ -77,7 +78,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient .WhereIF(!string.IsNullOrWhiteSpace(input.ProductName), u => u.ProductName.Contains(input.ProductName.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.ProductCodeNum), u => u.ProductCodeNum.Contains(input.ProductCodeNum.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.OddNumber), u => u.OddNumber.Contains(input.OddNumber.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.State), u => u.State.Contains(input.State.Trim())) + .WhereIF(input.State!=null, u => u.State==input.State) .WhereIF(!string.IsNullOrWhiteSpace(input.ProductType), u => u.ProductType.Contains(input.ProductType.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.ProductionLine), u => u.ProductionLine.Contains(input.ProductionLine.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.CodeNum), u => u.CodeNum.Contains(input.CodeNum.Trim())) @@ -185,10 +186,6 @@ public class ReportDetailTableService : IDynamicApiController, ITransient } } } - else - { - codesToKeep.Add(repeatCode); - } } repeatCodes = codesToKeep; if (repeatCodes != null && repeatCodes.Count > 0) @@ -227,7 +224,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient ProductType = warehousing.ProductType, ProductionLine = warehousing.ProductionLine, BaseProductCount = repeatCodes.Count, - ProductCount = repeatCodes.Count, + ProductCount = warehousing.ProductCount, Batch = warehousing.Batch, CodeNum = materials.CodeNum, Name = materials.Name, @@ -245,8 +242,8 @@ public class ReportDetailTableService : IDynamicApiController, ITransient { reprotId = report.Id; } - + Dictionary list = new Dictionary(); foreach (var item in topDatas) { @@ -259,13 +256,18 @@ public class ReportDetailTableService : IDynamicApiController, ITransient var reportTable = await _reportTableService.Detail(new QueryByIdReportTableInput { Id = upPrintCodeDetail.ReportTableId??0 }); if (reportTable.ProductType.Equals("返工生产")) { - if (!upPrintCodeDetail.Code.Contains("#")) - { - upPrintCodeDetail.Code = "#" + upPrintCodeDetail.Code; - await _codeDetailService.UpdateByEntity(upPrintCodeDetail); - } + var year = DateTime.Now.ToString("yy"); + var month = DateTime.Now.Month; + var day = DateTime.Now.Day; + int milliseconds = DateTime.Now.Millisecond; // 获取当前时间的毫秒部分(0-999) + upPrintCodeDetail.Code = "F"+ year + month + day + milliseconds + "#" + upPrintCodeDetail.Code; + await _codeDetailService.UpdateByEntity(upPrintCodeDetail); } } + + var unitRate = Convert.ToDecimal(units.Where(t => t.Name == item.PackageName).FirstOrDefault()?.Rate); + var productRate = Convert.ToDecimal(units.Where(t => t.Name == warehousing.Package).FirstOrDefault()?.Rate); + decimal unitCount = Math.Round(unitRate / productRate, 2); var detail = new AddPrintCodeDetailInput() { ReportTableId = reprotId, @@ -274,8 +276,8 @@ public class ReportDetailTableService : IDynamicApiController, ITransient ChildCount = unit.ChildUnitCount, Count = 1, Unit = item.PackageName, - BaseCount = unit.Rate, - BaseUnit = baseUnit, + BaseCount = unitCount, + BaseUnit = warehousing.Package, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName, @@ -298,8 +300,8 @@ public class ReportDetailTableService : IDynamicApiController, ITransient ChildCount = unit2.ChildUnitCount, Count = 1, Unit = child.PackageName, - BaseCount = unit2.Rate, - BaseUnit = baseUnit, + BaseCount =1, + BaseUnit = warehousing.Package, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName, @@ -324,8 +326,8 @@ public class ReportDetailTableService : IDynamicApiController, ITransient ChildCount = unit3.ChildUnitCount, Count = 1, Unit = child3.PackageName, - BaseCount = unit3.Rate, - BaseUnit = baseUnit, + BaseCount = 1, + BaseUnit = warehousing.Package, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName, @@ -351,8 +353,8 @@ public class ReportDetailTableService : IDynamicApiController, ITransient ChildCount = unit4.ChildUnitCount, Count = 1, Unit = child4.PackageName, - BaseCount = unit4.Rate, - BaseUnit = baseUnit, + BaseCount = 1, + BaseUnit = warehousing.Package, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName, @@ -378,8 +380,8 @@ public class ReportDetailTableService : IDynamicApiController, ITransient ChildCount = unit5.ChildUnitCount, Count = 1, Unit = child5.PackageName, - BaseCount = unit5.Rate, - BaseUnit = baseUnit, + BaseCount = 1, + BaseUnit = warehousing.Package, PrintCodeTime = DateTime.Now, CreateUserId = userId, CreateUserName = userName, @@ -403,7 +405,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient var item = dic.Key; var retrospect1 = new AddProductRetrospectInput() { - BaseCount = item.BaseCount, + BaseCount = (int?)(item.BaseCount), BaseUnit = baseUnit, Batch = warehousing.Batch, BusinessType = "生产任务单", @@ -427,7 +429,21 @@ public class ReportDetailTableService : IDynamicApiController, ITransient await _productRetrospect.Add(retrospect1); } - + var upReportTable = await _reportTableService.GetBySource(warehousing.Id); + var printCodeDetails = await _codeDetailService.GetByReportTableId(upReportTable.Id); + var count = printCodeDetails.Where(a => !a.IsDelete && a.Unit == a.BaseUnit).Sum(t=>t.Count); + decimal unitSumCount = 0; + foreach (var item in printCodeDetails.Where(a => !a.IsDelete && a.Unit != a.BaseUnit)) + { + var unitRate = Convert.ToDecimal(units.Where(t => t.Name == item.Unit).FirstOrDefault()?.Rate); + var productRate = Convert.ToDecimal(units.Where(t => t.Name == item.BaseUnit).FirstOrDefault()?.Rate); + decimal unitCount = Math.Round(unitRate / productRate,2); + unitSumCount += unitCount; + } + upReportTable.BaseProductCount = unitSumCount + count; + var updateReportTableInput = upReportTable.Adapt(); + await _reportTableService.Update(updateReportTableInput); + //upReportTable. //var details = await _warehouseDetails.List(); //if (details != null && details.Any(a => a.MaterialsId == warehousing.MaterialsId && a.Unit == warehousing.Unit)) //{ @@ -502,7 +518,7 @@ public class ReportDetailTableService : IDynamicApiController, ITransient [ApiDescriptionSettings(Name = "List")] public async Task> List() { - return await _rep.AsQueryable().Where(a => !a.IsDelete).Select().ToListAsync(); + return await _rep.AsQueryable().Where(a => !a.IsDelete && a.State==1).Select().ToListAsync(); } /// @@ -522,6 +538,38 @@ public class ReportDetailTableService : IDynamicApiController, ITransient } + /// + /// 更新生产状态 + /// + /// + /// + /// + + [HttpPost] + [ApiDescriptionSettings(Name = "UpdateProductState")] + public async Task UpdateProductState(UpdateProductStateReportDetailTableInput input) + { + var reportDetailTable = await _rep.AsQueryable() + .Where(t => !t.IsDelete) + .Where(t => t.OddNumber == input.OddNumber && t.MaterialsId == input.MaterialsId) + .FirstAsync(); + if (reportDetailTable != null) + { + reportDetailTable.ProductState = input.ProductState; + await _rep.AsUpdateable(reportDetailTable).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + var reportTable = await _reportTableService.GetBySource(reportDetailTable.Id); + if (reportTable != null) + { + var entity = reportTable.Adapt(); + reportTable.ProductState = input.ProductState; + if (reportTable.ProductState == 0) + { + reportTable.EndDate = DateTime.Now; + } + await _reportTableService.Update(entity); + } + } + } } diff --git a/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/ReportTableInput.cs b/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/ReportTableInput.cs index ecb5579..ef25d66 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/ReportTableInput.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/ReportTableInput.cs @@ -67,7 +67,7 @@ public class ReportTableBaseInput /// /// 基本完工数量 /// - public int? BaseProductCount { get; set; } + public decimal? BaseProductCount { get; set; } /// /// 单位 @@ -237,3 +237,4 @@ public class QueryByIdReportTableInput : DeleteReportTableInput public string? Code { get; set; } public long? SourceId { 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 b74b26e..4bc0306 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs @@ -8,6 +8,7 @@ using Nest; using Admin.NET.Application.Utils; using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; using SkiaSharp; +using AngleSharp.Dom; namespace Admin.NET.Application; /// @@ -469,5 +470,7 @@ public class ReportTableService : IDynamicApiController, ITransient var entity = input.Adapt(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); } + + } diff --git a/Web/src/views/productionCenter/reportDetailTable/component/editDialog.vue b/Web/src/views/productionCenter/reportDetailTable/component/editDialog.vue index fcba7e4..f2f4505 100644 --- a/Web/src/views/productionCenter/reportDetailTable/component/editDialog.vue +++ b/Web/src/views/productionCenter/reportDetailTable/component/editDialog.vue @@ -58,7 +58,7 @@ - + @@ -312,7 +312,7 @@ if (isValid) { let values = ruleForm.value; if (ruleForm.value.id == undefined || ruleForm.value.id == null || ruleForm.value.id == "" || ruleForm.value.id == 0) { - values.state="待审核"; + values.state="0"; await addReportDetailTable(values); } else { await updateReportDetailTable(values); diff --git a/Web/src/views/productionCenter/reportDetailTable/index.vue b/Web/src/views/productionCenter/reportDetailTable/index.vue index a12f641..2fa2675 100644 --- a/Web/src/views/productionCenter/reportDetailTable/index.vue +++ b/Web/src/views/productionCenter/reportDetailTable/index.vue @@ -73,8 +73,8 @@ 高级查询 隐藏 新增 - 审核 - 反审核 + 审核 + 反审核 @@ -104,12 +104,12 @@ - +