2024-05-25 10:46:26 +00:00
|
|
|
|
using Admin.NET.Core.Service;
|
|
|
|
|
using Admin.NET.Application.Const;
|
|
|
|
|
using Admin.NET.Application.Entity;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2024-06-24 10:21:52 +00:00
|
|
|
|
using Admin.NET.Application.Utils;
|
|
|
|
|
|
2024-05-25 10:46:26 +00:00
|
|
|
|
namespace Admin.NET.Application;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 汇报单详情服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)]
|
|
|
|
|
public class ReportDetailTableService : IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<ReportDetailTable> _rep;
|
2024-06-07 11:13:15 +00:00
|
|
|
|
//private readonly WarehouseDetailsService _warehouseDetails;
|
|
|
|
|
//private readonly MaterialClassifyService _materialClassifyService;
|
|
|
|
|
//private readonly WarehousingStatisticsService _warehousingStatisticsService;
|
2024-06-12 10:10:50 +00:00
|
|
|
|
private readonly MaterialsService _materialsService;
|
|
|
|
|
private readonly SysUnitService _sysUnitService;
|
2024-05-30 10:18:10 +00:00
|
|
|
|
private readonly PrintCodeDetailService _codeDetailService;
|
2024-06-07 11:13:15 +00:00
|
|
|
|
private readonly ProductRetrospectService _productRetrospect;
|
2024-06-12 10:10:50 +00:00
|
|
|
|
private readonly ReportTableService _reportTableService;
|
2024-06-07 11:13:15 +00:00
|
|
|
|
private readonly UserManager _userManager;
|
2024-06-12 10:10:50 +00:00
|
|
|
|
//private readonly ProductWarehousingService _productWarehousing;
|
2024-06-07 11:13:15 +00:00
|
|
|
|
public ReportDetailTableService(SqlSugarRepository<ReportDetailTable> rep,
|
|
|
|
|
UserManager userManager,
|
|
|
|
|
MaterialsService materialsService,
|
|
|
|
|
SysUnitService sysUnitService,
|
|
|
|
|
PrintCodeDetailService codeDetailService,
|
2024-06-12 10:10:50 +00:00
|
|
|
|
ReportTableService reportTableService,
|
2024-06-07 11:13:15 +00:00
|
|
|
|
ProductRetrospectService productRetrospect)
|
2024-05-25 10:46:26 +00:00
|
|
|
|
{
|
|
|
|
|
_rep = rep;
|
2024-06-07 11:13:15 +00:00
|
|
|
|
_userManager = userManager;
|
|
|
|
|
_materialsService = materialsService;
|
|
|
|
|
_sysUnitService = sysUnitService;
|
2024-05-30 10:18:10 +00:00
|
|
|
|
_codeDetailService = codeDetailService;
|
2024-06-07 11:13:15 +00:00
|
|
|
|
_productRetrospect = productRetrospect;
|
2024-06-12 10:10:50 +00:00
|
|
|
|
_reportTableService = reportTableService;
|
2024-06-07 11:13:15 +00:00
|
|
|
|
//_warehouseDetails = warehouseDetails;
|
|
|
|
|
//_materialClassifyService = materialClassifyService;
|
|
|
|
|
//_warehousingStatisticsService = warehousingStatisticsService;
|
|
|
|
|
//_productWarehousing = productWarehousing;
|
2024-05-25 10:46:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页查询汇报单详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Page")]
|
|
|
|
|
public async Task<SqlSugarPagedList<ReportDetailTableOutput>> Page(ReportDetailTableInput input)
|
|
|
|
|
{
|
|
|
|
|
var query = _rep.AsQueryable().Where(a => !a.IsDelete)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u =>
|
|
|
|
|
u.ProductName.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.ProductCodeNum.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.OddNumber.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.State.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.ProductType.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.ProductionLine.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.CodeNum.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.SourceNumber.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.Specifications.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.Unit.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.BaseUnit.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.Batch.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.Package.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.TeamGroup.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.Operator.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.SourceOddNumber.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.Remarks.Contains(input.SearchKey.Trim())
|
|
|
|
|
)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.ProductName), u => u.ProductName.Contains(input.ProductName.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.ProductCodeNum), u => u.ProductCodeNum.Contains(input.ProductCodeNum.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.OddNumber), u => u.OddNumber.Contains(input.OddNumber.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.State), u => u.State.Contains(input.State.Trim()))
|
|
|
|
|
.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.Specifications), u => u.Specifications.Contains(input.Specifications.Trim()))
|
|
|
|
|
.WhereIF(input.ProductCount>0, u => u.ProductCount == input.ProductCount)
|
|
|
|
|
.WhereIF(input.PutWarehouse>0, u => u.PutWarehouse == input.PutWarehouse)
|
|
|
|
|
.WhereIF(input.BaseProductCount>0, u => u.BaseProductCount == input.BaseProductCount)
|
|
|
|
|
.WhereIF(input.BasePutWarehouse>0, u => u.BasePutWarehouse == input.BasePutWarehouse)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Unit), u => u.Unit.Contains(input.Unit.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.BaseUnit), u => u.BaseUnit.Contains(input.BaseUnit.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Batch), u => u.Batch.Contains(input.Batch.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Package), u => u.Package.Contains(input.Package.Trim()))
|
|
|
|
|
.WhereIF(input.PackageCount>0, u => u.PackageCount == input.PackageCount)
|
|
|
|
|
.WhereIF(input.GatherFalseCount>0, u => u.GatherFalseCount == input.GatherFalseCount)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TeamGroup), u => u.TeamGroup.Contains(input.TeamGroup.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Operator), u => u.Operator.Contains(input.Operator.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SourceOddNumber), u => u.SourceOddNumber.Contains(input.SourceOddNumber.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Remarks), u => u.Remarks.Contains(input.Remarks.Trim()))
|
|
|
|
|
.Select<ReportDetailTableOutput>();
|
|
|
|
|
if(input.ProductDateRange != null && input.ProductDateRange.Count >0)
|
|
|
|
|
{
|
|
|
|
|
DateTime? start= input.ProductDateRange[0];
|
|
|
|
|
query = query.WhereIF(start.HasValue, u => u.ProductDate > start);
|
|
|
|
|
if (input.ProductDateRange.Count >1 && input.ProductDateRange[1].HasValue)
|
|
|
|
|
{
|
|
|
|
|
var end = input.ProductDateRange[1].Value.AddDays(1);
|
|
|
|
|
query = query.Where(u => u.ProductDate < end);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(input.EndDateRange != null && input.EndDateRange.Count >0)
|
|
|
|
|
{
|
|
|
|
|
DateTime? start= input.EndDateRange[0];
|
|
|
|
|
query = query.WhereIF(start.HasValue, u => u.EndDate > start);
|
|
|
|
|
if (input.EndDateRange.Count >1 && input.EndDateRange[1].HasValue)
|
|
|
|
|
{
|
|
|
|
|
var end = input.EndDateRange[1].Value.AddDays(1);
|
|
|
|
|
query = query.Where(u => u.EndDate < end);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加汇报单详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Add")]
|
|
|
|
|
public async Task<long> Add(AddReportDetailTableInput input)
|
|
|
|
|
{
|
2024-06-07 11:13:15 +00:00
|
|
|
|
var entity = input.Adapt<ReportDetailTable>();
|
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
|
if (input.UpdateUserId > 0)
|
2024-05-30 10:18:10 +00:00
|
|
|
|
{
|
2024-06-07 11:13:15 +00:00
|
|
|
|
var details = await _codeDetailService.List();
|
|
|
|
|
if (details == null || details.Count < 1)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
var printDetails = details.FindAll(a => a.TempListId == input.UpdateUserId);
|
|
|
|
|
if (printDetails.Count < 1)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < printDetails.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var item = printDetails[i];
|
|
|
|
|
item.ReportTableId = entity.Id;
|
|
|
|
|
var ent = item.Adapt<PrintCodeDetail>();
|
|
|
|
|
await _codeDetailService.UpdateByEntity(ent);
|
|
|
|
|
}
|
2024-05-30 10:18:10 +00:00
|
|
|
|
}
|
2024-06-07 11:13:15 +00:00
|
|
|
|
return entity.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生产任务单关联
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "ProductionTask")]
|
|
|
|
|
public async Task ProductionTask(AddProductCodeInput input)
|
|
|
|
|
{
|
|
|
|
|
if (input == null || input.WarehousingTableId == null || input.CodeDatas == null || input.CodeDatas.Count == 0)
|
2024-05-30 10:18:10 +00:00
|
|
|
|
{
|
2024-06-07 11:13:15 +00:00
|
|
|
|
throw Oops.Oh(ErrorCodeEnum.xg1002);
|
2024-05-30 10:18:10 +00:00
|
|
|
|
}
|
2024-06-12 10:10:50 +00:00
|
|
|
|
|
|
|
|
|
var repeatCodes = await _codeDetailService.GetRepeat(input.CodeDatas);
|
|
|
|
|
if (repeatCodes!=null&&repeatCodes.Count>0)
|
|
|
|
|
{
|
|
|
|
|
var repeats = repeatCodes.ConvertAll(a => a.Code).Distinct();
|
|
|
|
|
throw Oops.Oh($"条码重复:{string.Join("、", repeats)}");
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-07 11:13:15 +00:00
|
|
|
|
var warehousing = await Detail(new QueryByIdReportDetailTableInput() { Id = input.WarehousingTableId.Value });
|
|
|
|
|
if (warehousing == null)
|
2024-05-30 10:18:10 +00:00
|
|
|
|
{
|
2024-06-07 11:13:15 +00:00
|
|
|
|
throw Oops.Oh(ErrorCodeEnum.xg1002);
|
2024-05-30 10:18:10 +00:00
|
|
|
|
}
|
2024-06-07 11:13:15 +00:00
|
|
|
|
var materials = await _materialsService.GetById(warehousing.MaterialsId);
|
|
|
|
|
if (materials == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh(ErrorCodeEnum.xg1002);
|
|
|
|
|
}
|
|
|
|
|
var units = await _sysUnitService.ListByGroupId(materials.UnitGroupId);
|
2024-06-12 10:10:50 +00:00
|
|
|
|
var baseUnit = units.FirstOrDefault().Name;
|
2024-06-07 11:13:15 +00:00
|
|
|
|
var userId = _userManager.UserId;
|
|
|
|
|
var userName = _userManager.RealName;
|
|
|
|
|
var topDatas = input.CodeDatas.FindAll(a => string.IsNullOrEmpty(a.FatherCode));
|
2024-07-02 03:23:29 +00:00
|
|
|
|
long reprotId = 0;
|
|
|
|
|
var report = await _reportTableService.GetBySource(input.WarehousingTableId);
|
|
|
|
|
if (report == null)
|
|
|
|
|
{
|
|
|
|
|
var newReport = new AddReportTableInput()
|
|
|
|
|
{
|
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
|
IsDelete = false,
|
|
|
|
|
OddNumber = warehousing.OddNumber,
|
|
|
|
|
State = 0,
|
|
|
|
|
MaterialsId = warehousing.MaterialsId,
|
|
|
|
|
SourceId = input.WarehousingTableId,
|
|
|
|
|
ProductType = warehousing.ProductType,
|
|
|
|
|
ProductionLine = warehousing.ProductionLine,
|
|
|
|
|
BaseProductCount = repeatCodes.Count,
|
|
|
|
|
ProductCount = repeatCodes.Count,
|
|
|
|
|
Batch = warehousing.Batch,
|
|
|
|
|
CodeNum = materials.CodeNum,
|
|
|
|
|
Name = materials.Name,
|
|
|
|
|
CreateUserId = userId,
|
|
|
|
|
CreateUserName = userName,
|
|
|
|
|
StartDate = DateTime.Now,
|
|
|
|
|
SourceNumber = warehousing.SourceNumber,
|
|
|
|
|
Unit = warehousing.Unit,
|
|
|
|
|
Remarks = warehousing.Remarks
|
|
|
|
|
};
|
|
|
|
|
reprotId = await _reportTableService.Add(newReport);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
reprotId = report.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-06-07 11:13:15 +00:00
|
|
|
|
Dictionary<AddPrintCodeDetailInput, long> list = new Dictionary<AddPrintCodeDetailInput, long>();
|
|
|
|
|
foreach (var item in topDatas)
|
|
|
|
|
{
|
2024-06-24 10:21:52 +00:00
|
|
|
|
var code = CodeHelper.GetCode(item.BarCode, item.QrCode);
|
2024-06-07 11:13:15 +00:00
|
|
|
|
var codeType = string.IsNullOrEmpty(item.BarCode) ? "二维码" : "条码";
|
|
|
|
|
var unit = units.Find(a => a.Name == item.PackageName);
|
|
|
|
|
|
|
|
|
|
var detail = new AddPrintCodeDetailInput()
|
|
|
|
|
{
|
2024-07-02 03:23:29 +00:00
|
|
|
|
ReportTableId = reprotId,
|
2024-06-07 11:13:15 +00:00
|
|
|
|
Code = code,
|
|
|
|
|
CodeName = codeType,
|
|
|
|
|
ChildCount = unit.ChildUnitCount,
|
|
|
|
|
Count = 1,
|
|
|
|
|
Unit = item.PackageName,
|
|
|
|
|
BaseCount = unit.Rate,
|
|
|
|
|
BaseUnit = baseUnit,
|
|
|
|
|
PrintCodeTime = DateTime.Now,
|
|
|
|
|
CreateUserId = userId,
|
|
|
|
|
CreateUserName = userName
|
|
|
|
|
};
|
|
|
|
|
var detailId = await _codeDetailService.Add(detail);
|
|
|
|
|
list.Add(detail, detailId);
|
|
|
|
|
|
|
|
|
|
var childs = input.CodeDatas.FindAll(a => a.FatherCode == code);
|
|
|
|
|
foreach (var child in childs)
|
|
|
|
|
{
|
2024-06-24 10:21:52 +00:00
|
|
|
|
var code2 = CodeHelper.GetCode(child.BarCode, child.QrCode);
|
2024-06-07 11:13:15 +00:00
|
|
|
|
var unit2 = units.Find(a => a.Name == child.PackageName);
|
|
|
|
|
var detail2 = new AddPrintCodeDetailInput()
|
|
|
|
|
{
|
2024-07-02 03:23:29 +00:00
|
|
|
|
ReportTableId = reprotId,
|
2024-06-07 11:13:15 +00:00
|
|
|
|
Code = code2,
|
|
|
|
|
CodeName = codeType,
|
|
|
|
|
ChildCount = unit2.ChildUnitCount,
|
|
|
|
|
Count = 1,
|
|
|
|
|
Unit = child.PackageName,
|
|
|
|
|
BaseCount = unit2.Rate,
|
|
|
|
|
BaseUnit = baseUnit,
|
|
|
|
|
PrintCodeTime = DateTime.Now,
|
|
|
|
|
CreateUserId = userId,
|
|
|
|
|
CreateUserName = userName,
|
|
|
|
|
FatherCode = code,
|
|
|
|
|
FatherId = detailId
|
|
|
|
|
};
|
|
|
|
|
var detailId2 = await _codeDetailService.Add(detail2);
|
|
|
|
|
list.Add(detail2, detailId2);
|
|
|
|
|
|
|
|
|
|
var childs3 = input.CodeDatas.FindAll(a => a.FatherCode == code2);
|
2024-06-12 10:10:50 +00:00
|
|
|
|
foreach (var child3 in childs3)
|
2024-06-07 11:13:15 +00:00
|
|
|
|
{
|
2024-06-24 10:21:52 +00:00
|
|
|
|
var code3 = CodeHelper.GetCode(child3.BarCode, child3.QrCode);
|
2024-06-07 11:13:15 +00:00
|
|
|
|
var unit3 = units.Find(a => a.Name == child3.PackageName);
|
|
|
|
|
var detail3 = new AddPrintCodeDetailInput()
|
|
|
|
|
{
|
2024-07-02 03:23:29 +00:00
|
|
|
|
ReportTableId = reprotId,
|
2024-06-07 11:13:15 +00:00
|
|
|
|
Code = code3,
|
|
|
|
|
CodeName = codeType,
|
|
|
|
|
ChildCount = unit3.ChildUnitCount,
|
|
|
|
|
Count = 1,
|
|
|
|
|
Unit = child3.PackageName,
|
|
|
|
|
BaseCount = unit3.Rate,
|
|
|
|
|
BaseUnit = baseUnit,
|
|
|
|
|
PrintCodeTime = DateTime.Now,
|
|
|
|
|
CreateUserId = userId,
|
|
|
|
|
CreateUserName = userName,
|
|
|
|
|
FatherCode = code2,
|
|
|
|
|
FatherId = detailId2
|
|
|
|
|
};
|
|
|
|
|
var detailId3 = await _codeDetailService.Add(detail3);
|
|
|
|
|
list.Add(detail3, detailId3);
|
|
|
|
|
if (input.CodeDatas.Any(a => a.FatherCode == code3))
|
|
|
|
|
{
|
|
|
|
|
var childs4 = input.CodeDatas.FindAll(a => a.FatherCode == code3);
|
2024-06-12 10:10:50 +00:00
|
|
|
|
foreach (var child4 in childs4)
|
2024-06-07 11:13:15 +00:00
|
|
|
|
{
|
2024-06-24 10:21:52 +00:00
|
|
|
|
var code4 = CodeHelper.GetCode(child4.BarCode, child4.QrCode);
|
2024-06-07 11:13:15 +00:00
|
|
|
|
var unit4 = units.Find(a => a.Name == child4.PackageName);
|
|
|
|
|
var detail4 = new AddPrintCodeDetailInput()
|
|
|
|
|
{
|
2024-07-02 03:23:29 +00:00
|
|
|
|
ReportTableId = reprotId,
|
2024-06-07 11:13:15 +00:00
|
|
|
|
Code = code4,
|
|
|
|
|
CodeName = codeType,
|
|
|
|
|
ChildCount = unit4.ChildUnitCount,
|
|
|
|
|
Count = 1,
|
|
|
|
|
Unit = child4.PackageName,
|
|
|
|
|
BaseCount = unit4.Rate,
|
|
|
|
|
BaseUnit = baseUnit,
|
|
|
|
|
PrintCodeTime = DateTime.Now,
|
|
|
|
|
CreateUserId = userId,
|
|
|
|
|
CreateUserName = userName,
|
|
|
|
|
FatherCode = code3,
|
|
|
|
|
FatherId = detailId3
|
|
|
|
|
};
|
|
|
|
|
var detailId4 = await _codeDetailService.Add(detail4);
|
|
|
|
|
list.Add(detail4, detailId4);
|
|
|
|
|
if (input.CodeDatas.Any(a => a.FatherCode == code4))
|
|
|
|
|
{
|
|
|
|
|
var childs5 = input.CodeDatas.FindAll(a => a.FatherCode == code4);
|
2024-06-12 10:10:50 +00:00
|
|
|
|
foreach (var child5 in childs5)
|
2024-06-07 11:13:15 +00:00
|
|
|
|
{
|
2024-06-24 10:21:52 +00:00
|
|
|
|
var code5 = CodeHelper.GetCode(child5.BarCode, child5.QrCode);
|
2024-06-07 11:13:15 +00:00
|
|
|
|
var unit5 = units.Find(a => a.Name == child5.PackageName);
|
|
|
|
|
var detail5 = new AddPrintCodeDetailInput()
|
|
|
|
|
{
|
2024-07-02 03:23:29 +00:00
|
|
|
|
ReportTableId = reprotId,
|
2024-06-07 11:13:15 +00:00
|
|
|
|
Code = code5,
|
|
|
|
|
CodeName = codeType,
|
|
|
|
|
ChildCount = unit5.ChildUnitCount,
|
|
|
|
|
Count = 1,
|
|
|
|
|
Unit = child5.PackageName,
|
|
|
|
|
BaseCount = unit5.Rate,
|
|
|
|
|
BaseUnit = baseUnit,
|
|
|
|
|
PrintCodeTime = DateTime.Now,
|
|
|
|
|
CreateUserId = userId,
|
|
|
|
|
CreateUserName = userName,
|
|
|
|
|
FatherCode = code4,
|
|
|
|
|
FatherId = detailId4
|
|
|
|
|
};
|
|
|
|
|
var detailId5 = await _codeDetailService.Add(detail5);
|
|
|
|
|
list.Add(detail5, detailId5);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var dic in list)
|
|
|
|
|
{
|
|
|
|
|
var item = dic.Key;
|
|
|
|
|
var retrospect1 = new AddProductRetrospectInput()
|
|
|
|
|
{
|
|
|
|
|
BaseCount = item.BaseCount,
|
|
|
|
|
BaseUnit = baseUnit,
|
|
|
|
|
Batch = warehousing.Batch,
|
|
|
|
|
BusinessType = "生产任务单",
|
|
|
|
|
CodeType = item.CodeName,
|
|
|
|
|
Department = warehousing.ProductionLine,
|
|
|
|
|
//WarehouseID = input.WarehouseId,
|
|
|
|
|
WarehousingDate = DateTime.Now,
|
|
|
|
|
Count = 1,
|
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
|
ScanCodeTime = DateTime.Now,
|
|
|
|
|
CreateUserId = userId,
|
|
|
|
|
CreateUserName = userName,
|
|
|
|
|
MaterialsId = dic.Value,
|
|
|
|
|
OddNumber = warehousing.OddNumber,
|
|
|
|
|
Receipt = "汇报单",
|
|
|
|
|
SourceId = warehousing.Id,
|
|
|
|
|
Unit = item.Unit,
|
|
|
|
|
Name = materials.Name,
|
|
|
|
|
Code = item.Code
|
|
|
|
|
};//Destination = warehousing.Supplier,
|
|
|
|
|
await _productRetrospect.Add(retrospect1);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-02 03:23:29 +00:00
|
|
|
|
|
2024-06-07 11:13:15 +00:00
|
|
|
|
//var details = await _warehouseDetails.List();
|
|
|
|
|
//if (details != null && details.Any(a => a.MaterialsId == warehousing.MaterialsId && a.Unit == warehousing.Unit))
|
|
|
|
|
//{
|
|
|
|
|
// var unit = units.Find(a => a.Name == warehousing.Unit);
|
|
|
|
|
// var detail = details.Find(a => a.MaterialsId == warehousing.MaterialsId && a.Unit == warehousing.Unit);
|
|
|
|
|
// detail.Count += warehousing.Count;
|
|
|
|
|
// if (unit != null)
|
|
|
|
|
// {
|
|
|
|
|
// detail.BaseCount = detail.Count * unit.Rate;
|
|
|
|
|
// }
|
|
|
|
|
// await _warehouseDetails.UpdateByEntity(detail.Adapt<WarehouseDetails>());
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// var newEnt = warehousing.Adapt<AddWarehouseDetailsInput>();
|
|
|
|
|
// newEnt.SourceId = warehousing.Id;
|
|
|
|
|
// var addId = await _warehouseDetails.Add(newEnt);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//var newDetail = warehousing.Adapt<AddWarehousingStatisticsInput>();
|
|
|
|
|
//newDetail.SourceId = warehousing.Id;
|
|
|
|
|
//await _warehousingStatisticsService.Add(newDetail);
|
|
|
|
|
|
2024-05-25 10:46:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-06 10:22:07 +00:00
|
|
|
|
|
2024-05-25 10:46:26 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除汇报单详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Delete")]
|
|
|
|
|
public async Task Delete(DeleteReportDetailTableInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = await _rep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002);
|
|
|
|
|
await _rep.FakeDeleteAsync(entity); //假删除
|
|
|
|
|
//await _rep.DeleteAsync(entity); //真删除
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新汇报单详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Update")]
|
|
|
|
|
public async Task Update(UpdateReportDetailTableInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<ReportDetailTable>();
|
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取汇报单详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Detail")]
|
|
|
|
|
public async Task<ReportDetailTable> Detail([FromQuery] QueryByIdReportDetailTableInput input)
|
|
|
|
|
{
|
|
|
|
|
return await _rep.GetFirstAsync(u => u.Id == input.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取汇报单详情列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[ApiDescriptionSettings(Name = "List")]
|
|
|
|
|
public async Task<List<ReportDetailTableOutput>> List()
|
|
|
|
|
{
|
|
|
|
|
return await _rep.AsQueryable().Where(a => !a.IsDelete).Select<ReportDetailTableOutput>().ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|