mes->wms入库接口代码调整

This commit is contained in:
alex
2023-07-12 14:05:31 +08:00
parent 911bf43d9a
commit afb9784735
5 changed files with 23 additions and 8 deletions

View File

@@ -242,5 +242,6 @@ namespace Tnb.WarehouseMgr.Entities.Consts
}
}

View File

@@ -127,7 +127,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// <summary>
/// 条码编号
/// </summary>
public int barcode_qty { get; set; }
public int codeqty { get; set; }
/// <summary>
/// 批次

View File

@@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
<ProjectReference Include="..\..\ProductionMgr\Tnb.ProductionMgr.Interfaces\Tnb.ProductionMgr.Interfaces.csproj" />
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
<ProjectReference Include="..\Tnb.WarehouseMgr.Interfaces\Tnb.WarehouseMgr.Interfaces.csproj" />
</ItemGroup>

View File

@@ -576,6 +576,7 @@ namespace Tnb.WarehouseMgr
catch (Exception)
{
await _db.Ado.RollbackTranAsync();
throw;
}
}

View File

@@ -20,6 +20,7 @@ using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.Common.Utils;
using Tnb.ProductionMgr.Interfaces;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Attributes;
using Tnb.WarehouseMgr.Entities.Consts;
@@ -42,13 +43,15 @@ namespace Tnb.WarehouseMgr
private readonly IUserManager _userManager;
private readonly IWareHouseService _wareHouseService;
private readonly IBillRullService _billRullService;
private readonly IPrdInstockService _prdInstockService;
private static Dictionary<string, object> _dicBillCodes = new();
public WmsInStockService(
ISqlSugarRepository<WmsInstockH> repository,
IDictionaryDataService dictionaryDataService,
IUserManager userManager,
IBillRullService billRullService,
IWareHouseService wareHouseService
IWareHouseService wareHouseService,
IPrdInstockService prdInstockService
)
{
_db = repository.AsSugarClient();
@@ -56,6 +59,7 @@ namespace Tnb.WarehouseMgr
_userManager = userManager;
_billRullService = billRullService;
_wareHouseService = wareHouseService;
_prdInstockService = prdInstockService;
}
/// <summary>
/// 根据入库申请单ID获取申请单明细信息
@@ -215,17 +219,27 @@ namespace Tnb.WarehouseMgr
}
}
await _db.Updateable(instockDetails).ExecuteCommandAsync();
var instock = await _db.Queryable<WmsInstockH>().SingleAsync(it => it.id == input.requireId);
if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock));
if (instock?.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
{
//如果是自动单据,需要回更上层系统
Dictionary<string, string> pars = new() { { nameof(WmsInstockH.source_id), instock!.source_id } };
var callBackRes = await _prdInstockService.SyncInstock(pars);
instock.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED;
await _db.Updateable(instock).UpdateColumns(it => it.sync_status).ExecuteCommandAsync();
}
var allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
{
await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
//如果是自动单据,需要回更上层系统
instock.status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
}
else
{
//任务没有结束,更新状态为工作中
await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
instock.status = WmsWareHouseConst.BILLSTATUS_ON_ID;
}
await _db.Updateable(instock).UpdateColumns(it => it.status).ExecuteCommandAsync();
}
await _db.Ado.CommitTranAsync();
@@ -293,7 +307,6 @@ namespace Tnb.WarehouseMgr
foreach (var instockcode in instockcodes!)
{
instockcode.id = SnowflakeIdHelper.NextId();
var materialId = instockcode.material_id;
var materialCode = instockcode.material_code;
var codeBatch = instockcode.code_batch;
var b = items.Find(x => x.material_code == materialCode && x.code_batch == codeBatch);
@@ -301,7 +314,7 @@ namespace Tnb.WarehouseMgr
{
var c = DeepCopyHelper<WmsInstockCode>.DeepCopy(b);
c.id = SnowflakeIdHelper.NextId();
c.bill_d_id = instockcodes.Find(x => x.material_code == materialCode && x.code_batch == codeBatch)?.id!;
c.bill_d_id = instockds?.Find(x => x.material_code == materialCode && x.code_batch == codeBatch)?.id ?? "";
c.barcode = instockcode.barcode;
c.codeqty = instockcode.codeqty;
c.is_end = 0;// 未结束
@@ -432,7 +445,6 @@ namespace Tnb.WarehouseMgr
await _db.Updateable<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCOdes.Select(x => x.bill_d_id).Contains(it.id)).ExecuteCommandAsync();
await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == instock!.id).ExecuteCommandAsync();
}
}
}
}