From c77fd31e1423c3cc486162502c1793bbfba3a853 Mon Sep 17 00:00:00 2001
From: ljh <1192263352@qq.com>
Date: Mon, 15 Jul 2024 11:04:27 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9D=A1=E7=A0=81=E6=9B=BF?=
=?UTF-8?q?=E6=8D=A2=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Entity/PrintCodeDetail.cs | 8 +++-
.../ReportDetailTableService.cs | 48 +++++++++++++++++++
.../Service/ReportTable/ReportTableService.cs | 2 -
3 files changed, 55 insertions(+), 3 deletions(-)
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();
}
-
-
}