修改物料页面

main
ljh 2024-07-04 23:34:54 +08:00
parent 495d66bc20
commit 1e341f201e
4 changed files with 110 additions and 4 deletions

View File

@ -164,5 +164,16 @@ public class PrintCodeDetailService : IDynamicApiController, ITransient
return await _rep.GetFirstAsync(a => a.Code == productCode);
}
/// <summary>
/// 获取打印条码详情
/// </summary>
/// <param name="productCode"></param>
/// <returns></returns>
[HttpGet]
[ApiDescriptionSettings(Name = "GetByProductCodes")]
public async Task<List<PrintCodeDetail>> GetByProductCodes(string? productCode)
{
return await _rep.AsQueryable().Where(a => !a.IsDelete && a.Code.Contains(productCode)).ToListAsync();
}
}

View File

@ -387,3 +387,21 @@ public class QueryByIdReportDetailTableInput : DeleteReportDetailTableInput
{
}
/// <summary>
/// 汇报单详情更新审核状态
/// </summary>
public class UpdateStateReportDetailTableInput
{
/// <summary>
/// 主键Id
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public string[] Ids { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public string State { get; set; }
}

View File

@ -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;
/// <summary>
@ -169,6 +171,23 @@ public class ReportDetailTableService : IDynamicApiController, ITransient
}
var repeatCodes = await _codeDetailService.GetRepeat(input.CodeDatas);
var codesToKeep = new List<PrintCodeDetailOutput>();
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<ReportDetailTableOutput>().ToListAsync();
}
/// <summary>
/// 修改汇报单审核状态
/// </summary>
/// <returns></returns>
[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();
}
}
}

View File

@ -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;
/// <summary>
@ -67,7 +69,35 @@ public class ReportTableService : IDynamicApiController, ITransient
.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<ReportTableOutput>();
.LeftJoin<PrintCodeDetail>((u, detail) => u.Id == detail.ReportTableId) // 左连接的条件
.GroupBy((u, detail) => u.Id)
.Select<ReportTableOutput>((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];