From 1e341f201e24613334963590be2bc1a242550720 Mon Sep 17 00:00:00 2001
From: ljh <1192263352@qq.com>
Date: Thu, 4 Jul 2024 23:34:54 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=A9=E6=96=99=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../PrintCodeDetail/PrintCodeDetailService.cs | 11 +++++
.../Dto/ReportDetailTableInput.cs | 18 +++++++
.../ReportDetailTableService.cs | 49 ++++++++++++++++++-
.../Service/ReportTable/ReportTableService.cs | 36 ++++++++++++--
4 files changed, 110 insertions(+), 4 deletions(-)
diff --git a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs
index 32e2f8d..6ca0c7f 100644
--- a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs
+++ b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs
@@ -164,5 +164,16 @@ public class PrintCodeDetailService : IDynamicApiController, ITransient
return await _rep.GetFirstAsync(a => a.Code == productCode);
}
+ ///
+ /// 获取打印条码详情
+ ///
+ ///
+ ///
+ [HttpGet]
+ [ApiDescriptionSettings(Name = "GetByProductCodes")]
+ public async Task> GetByProductCodes(string? productCode)
+ {
+ return await _rep.AsQueryable().Where(a => !a.IsDelete && a.Code.Contains(productCode)).ToListAsync();
+ }
}
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 0cc8082..7e873ba 100644
--- a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/Dto/ReportDetailTableInput.cs
+++ b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/Dto/ReportDetailTableInput.cs
@@ -387,3 +387,21 @@ public class QueryByIdReportDetailTableInput : DeleteReportDetailTableInput
{
}
+
+
+///
+/// 汇报单详情更新审核状态
+///
+public class UpdateStateReportDetailTableInput
+{
+ ///
+ /// 主键Id
+ ///
+ [Required(ErrorMessage = "主键Id不能为空")]
+ public string[] Ids { get; set; }
+
+ ///
+ /// 是否启用
+ ///
+ public string 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 e7ba1f9..9298cb9 100644
--- a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs
+++ b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs
@@ -3,6 +3,8 @@ using Admin.NET.Application.Const;
using Admin.NET.Application.Entity;
using Microsoft.AspNetCore.Http;
using Admin.NET.Application.Utils;
+using AngleSharp.Dom;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
namespace Admin.NET.Application;
///
@@ -169,6 +171,23 @@ public class ReportDetailTableService : IDynamicApiController, ITransient
}
var repeatCodes = await _codeDetailService.GetRepeat(input.CodeDatas);
+ var codesToKeep = new List();
+ foreach (var repeatCode in repeatCodes)
+ {
+ if (repeatCode.ReportTableId > 0)
+ {
+ var reportTable = await _reportTableService.Detail(new QueryByIdReportTableInput { Id = repeatCode.ReportTableId ?? 0 });
+ if (string.IsNullOrWhiteSpace(reportTable.ProductType) || reportTable.ProductType.Equals("普通生产"))
+ {
+ codesToKeep.Add(repeatCode);
+ }
+ }
+ else
+ {
+ codesToKeep.Add(repeatCode);
+ }
+ }
+ repeatCodes = codesToKeep;
if (repeatCodes!=null&&repeatCodes.Count>0)
{
var repeats = repeatCodes.ConvertAll(a => a.Code).Distinct();
@@ -230,7 +249,19 @@ public class ReportDetailTableService : IDynamicApiController, ITransient
var code = CodeHelper.GetCode(item.BarCode, item.QrCode);
var codeType = string.IsNullOrEmpty(item.BarCode) ? "二维码" : "条码";
var unit = units.Find(a => a.Name == item.PackageName);
-
+ var reportTable = await _reportTableService.Detail(new QueryByIdReportTableInput { Id = reprotId });
+ if (reportTable.ProductType.Equals("返工生产"))
+ {
+ var upPrintCodeDetails = await _codeDetailService.GetByProductCodes(code);
+ foreach (var upPrintCodeDetail in upPrintCodeDetails)
+ {
+ if (!upPrintCodeDetail.Code.Contains("#"))
+ {
+ upPrintCodeDetail.Code = new string('#', (upPrintCodeDetails.Where(t=>t.Code.Contains("#")).Count())+1)+upPrintCodeDetail.Code;
+ await _codeDetailService.UpdateByEntity(upPrintCodeDetail);
+ }
+ }
+ }
var detail = new AddPrintCodeDetailInput()
{
ReportTableId = reprotId,
@@ -460,6 +491,22 @@ public class ReportDetailTableService : IDynamicApiController, ITransient
return await _rep.AsQueryable().Where(a => !a.IsDelete).Select().ToListAsync();
}
+ ///
+ /// 修改汇报单审核状态
+ ///
+ ///
+ [HttpPost]
+ [ApiDescriptionSettings(Name = "UpdateState")]
+ public async Task UpdateState(UpdateStateReportDetailTableInput input)
+ {
+ foreach (var id in input.Ids)
+ {
+ var entity = await _rep.GetByIdAsync(id);
+ entity.State = input.State;
+ await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
+ }
+
+ }
}
diff --git a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs
index 357be0c..c399b40 100644
--- a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs
+++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs
@@ -6,6 +6,8 @@ using Admin.NET.Application.Service.ReportTable.Dto;
using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionRequest.Types;
using Nest;
using Admin.NET.Application.Utils;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
+using SkiaSharp;
namespace Admin.NET.Application;
///
@@ -61,14 +63,42 @@ public class ReportTableService : IDynamicApiController, ITransient
|| u.Remarks.Contains(input.SearchKey.Trim())
)
.WhereIF(!string.IsNullOrWhiteSpace(input.OddNumber), u => u.OddNumber.Contains(input.OddNumber.Trim()))
- .WhereIF(input.State>0, u => u.State == input.State)
+ .WhereIF(input.State > 0, 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()))
.WhereIF(!string.IsNullOrWhiteSpace(input.SourceNumber), u => u.SourceNumber.Contains(input.SourceNumber.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.Remarks), u => u.Remarks.Contains(input.Remarks.Trim()))
- .Select();
- if(input.StartDateRange != null && input.StartDateRange.Count >0)
+ .LeftJoin((u, detail) => u.Id == detail.ReportTableId) // 左连接的条件
+ .GroupBy((u, detail) => u.Id)
+ .Select((u, detail) => new ReportTableOutput
+ {
+ Id = u.Id,
+ OddNumber = u.OddNumber,
+ StartDate = u.StartDate,
+ State = u.State,
+ ProductType = u.ProductType,
+ ProductionLine = u.ProductionLine,
+ CodeNum = u.CodeNum,
+ SourceNumber = u.SourceNumber,
+ SourceId = u.SourceId,
+ MaterialsId = u.MaterialsId,
+ ProductCount = SqlFunc.AggregateSum(detail.Count),
+ BaseProductCount = u.BaseProductCount,
+ Unit = u.Unit,
+ Batch = u.Batch,
+ Name = u.Name,
+ Remarks = u.Remarks,
+ TenantId = u.TenantId,
+ CreateTime = u.CreateTime,
+ UpdateTime = u.UpdateTime,
+ CreateUserId = u.CreateUserId,
+ CreateUserName = u.CreateUserName,
+ UpdateUserId = u.UpdateUserId,
+ UpdateUserName = u.UpdateUserName,
+ IsDelete = u.IsDelete
+ });
+ if (input.StartDateRange != null && input.StartDateRange.Count >0)
{
DateTime? start= input.StartDateRange[0];
query = query.WhereIF(start.HasValue, u => u.StartDate > start);