新增条码替换接口

main
ljh 2024-07-15 11:04:27 +08:00
parent 7e7390ff2b
commit c77fd31e14
3 changed files with 55 additions and 3 deletions

View File

@ -108,5 +108,11 @@ public class PrintCodeDetail : EntityBase
/// </summary> /// </summary>
[SugarColumn(ColumnName = "MaterialsId", ColumnDescription = "物料ID")] [SugarColumn(ColumnName = "MaterialsId", ColumnDescription = "物料ID")]
public long? MaterialsId { get; set; } public long? MaterialsId { get; set; }
/// <summary>
/// 状态
/// </summary>
[SugarColumn(ColumnName = "State", ColumnDescription = "状态")]
public int? State { get; set; }
} }

View File

@ -581,5 +581,53 @@ public class ReportDetailTableService : IDynamicApiController, ITransient
} }
} }
/// <summary>
/// 替换条码
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[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);
}
}
} }

View File

@ -470,7 +470,5 @@ public class ReportTableService : IDynamicApiController, ITransient
var entity = input.Adapt<ReportTable>(); var entity = input.Adapt<ReportTable>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
} }
} }