diff --git a/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs b/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs
index de90bbc..402d0c5 100644
--- a/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs
+++ b/Admin.NET/Admin.NET.Application/Entity/PrintCodeDetail.cs
@@ -108,5 +108,11 @@ public class PrintCodeDetail : EntityBase
///
[SugarColumn(ColumnName = "MaterialsId", ColumnDescription = "物料ID")]
public long? MaterialsId { get; set; }
-
+
+ ///
+ /// 状态
+ ///
+
+ [SugarColumn(ColumnName = "State", ColumnDescription = "状态")]
+ 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 251fb0b..8d85799 100644
--- a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs
+++ b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs
@@ -581,5 +581,53 @@ public class ReportDetailTableService : IDynamicApiController, ITransient
}
}
+ ///
+ /// 替换条码
+ ///
+ ///
+ ///
+ [HttpPost]
+ [ApiDescriptionSettings(Name = "ReplaceCode")]
+ public async Task ReplaceCode(ReportDetailTableReplaceDto input)
+ {
+ var codeDetail = await _codeDetailService.GetByProductCode(input.OldCodeName);
+ if (codeDetail == null)
+ {
+ throw Oops.Oh($"条码不存在");
+ }
+ if (codeDetail.State != 1)
+ {
+ throw Oops.Oh($"条码状态必须是生产状态");
+ }
+ if (codeDetail.Unit != input.Unit)
+ {
+ throw Oops.Oh($"条码单位不一致",codeDetail.Unit);
+ }
+ var newCodeDetail = await _codeDetailService.GetByProductCode(input.NewCodeName);
+ if (newCodeDetail != null)
+ {
+ var reportTable = await _reportTableService.Detail(new QueryByIdReportTableInput { Id = newCodeDetail.ReportTableId ?? 0 });
+ if (reportTable.ProductType.Equals("返工生产"))
+ {
+ var year = DateTime.Now.ToString("yy");
+ var month = DateTime.Now.Month;
+ var day = DateTime.Now.Day;
+ int milliseconds = DateTime.Now.Millisecond; // 获取当前时间的毫秒部分(0-999)
+ newCodeDetail.Code = "F" + year + month + day + milliseconds + "#" + newCodeDetail.Code;
+ await _codeDetailService.UpdateByEntity(newCodeDetail);
+ codeDetail.Code = input.NewCodeName;
+ await _codeDetailService.UpdateByEntity(codeDetail);
+ }
+ else
+ {
+ throw Oops.Oh($"替换条码重复");
+ }
+ }
+ else
+ {
+ codeDetail.Code = input.NewCodeName;
+ await _codeDetailService.UpdateByEntity(codeDetail);
+ }
+ }
}
diff --git a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs
index 4bc0306..de75e46 100644
--- a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs
+++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs
@@ -470,7 +470,5 @@ public class ReportTableService : IDynamicApiController, ITransient
var entity = input.Adapt();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
-
-
}