This commit is contained in:
qianjiawei
2023-12-25 17:31:50 +08:00
parent 7ede7e4f08
commit 7244fab4ac
7 changed files with 49 additions and 19 deletions

View File

@@ -394,7 +394,7 @@ namespace Tnb.ProductionMgr
input.outstockDs = new List<MESWmsOutstockDInput>();
BasLocation location = await db.Queryable<BasLocation>().Where(x => x.location_code == materialOutstockInput.location_code).FirstAsync();
if (location == null) throw Oops.Bah("未找到库位");
if (location == null) throw new AppFriendlyException("未找到库位", 500);
string locationId = location.id;
PrdOutstockH prdOutstockH = new()
@@ -448,7 +448,8 @@ namespace Tnb.ProductionMgr
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
if (authResponse.code != 200)
{
throw Oops.Bah(authResponse.msg);
throw new AppFriendlyException(authResponse.msg, 500);
}
else
{
@@ -491,7 +492,8 @@ namespace Tnb.ProductionMgr
if (!result.IsSuccess)
{
throw Oops.Bah(result.ErrorMessage);
throw new AppFriendlyException(result.ErrorMessage, 500);
}
}
@@ -499,9 +501,8 @@ namespace Tnb.ProductionMgr
}
catch (Exception e)
{
Console.WriteLine(e);
Log.Error(e.Message);
throw Oops.Bah(e.Message);
throw new AppFriendlyException(e.Message, 500);
}
}
}

View File

@@ -191,7 +191,7 @@ namespace Tnb.ProductionMgr
{
// Readtimer = new Timer(GetRedisData, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
// CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
// Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)

View File

@@ -292,7 +292,7 @@ namespace Tnb.WarehouseMgr
{
if (input.barCodes == null || input.barCodes.Count < 1) throw new ArgumentNullException(nameof(input.barCodes));
input.barCodes = input.barCodes.OrderBy(o => o).ToList();
base.BarCodePrint(input.barCodes, input.copies);
base.BarCodePrint(input.barCodes, input.copies,"");
}
}
}

View File

@@ -179,7 +179,7 @@ namespace Tnb.WarehouseMgr
}
if (barcodes?.Count > 0)
{
base.BarCodePrint(barcodes, 1);
base.BarCodePrint(barcodes, 1,"");
}
await _db.Ado.CommitTranAsync();
}

View File

@@ -865,8 +865,8 @@ namespace Tnb.WarehouseMgr
x.id = SnowflakeIdHelper.NextId();
x.bill_id = input.requireId;
x.bill_d_id = billDId!;
x.org_id = _userManager.User.OrganizeId;
x.create_id = _userManager.UserId;
x.org_id = _userManager.User == null?"": _userManager.User.OrganizeId;
x.create_id = _userManager.UserId== null ? "":_userManager.UserId;
x.create_time = DateTime.Now;
});
_ = await _db.Insertable(outStockCodes).ExecuteCommandAsync();

View File

@@ -7,6 +7,7 @@ using JNPF.FriendlyException;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.ProductionMgr.Interfaces;
@@ -355,15 +356,15 @@ namespace Tnb.WarehouseMgr
WmsCarryH? carry = null;
BasLocation? loc = null;
string? carryCode = null;
if (input.data.ContainsKey(nameof(WmsInstockCode.barcode)))
{
item = input.data.Adapt<WmsInstockCode>();
if (item.codeqty == 0)
{
throw new AppFriendlyException("请输入入库数量", 500);
}
carryCode = item.barcode;
carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.carry_code == carryCode);
if (carry == null)
@@ -384,9 +385,9 @@ namespace Tnb.WarehouseMgr
}
}
var whId = input.data.ContainsKey(nameof(WmsPurchaseH.warehouse_id)) ? input.data[nameof(WmsPurchaseH.warehouse_id)] : null;
var whId = input.data.ContainsKey(nameof(WmsPurchaseH.warehouse_id)) ? input.data[nameof(WmsPurchaseH.warehouse_id)] : "1";
var billCode = input.data.ContainsKey(nameof(WmsPurchaseH.bill_code)) ? input.data[nameof(WmsPurchaseH.bill_code)] : null;
WmsInstockH instock = new()
{
id = SnowflakeIdHelper.NextId(),
@@ -442,7 +443,7 @@ namespace Tnb.WarehouseMgr
}
}
WmsInstockCode? instockCode = null;
if (mat != null)
@@ -474,11 +475,11 @@ namespace Tnb.WarehouseMgr
{
_ = await _db.Insertable(instockCode).ExecuteCommandAsync();
}
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1 };
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
WmsPointH sPoint = new();
WmsPointH ePoint = new();
if (endLocations?.Count > 0)
{
BasLocation eloc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
@@ -491,7 +492,7 @@ namespace Tnb.WarehouseMgr
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
}
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == loc.id);
if (sPoint != null && ePoint != null)
{
List<WmsPointH> points = new List<WmsPointH>();
@@ -508,11 +509,12 @@ namespace Tnb.WarehouseMgr
points.Add(sPoint);
points.Add(ePoint);
}
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0)
{
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{
WmsPointH? sPoint = it.FirstOrDefault();
@@ -620,9 +622,36 @@ namespace Tnb.WarehouseMgr
}
finally
{
_ = InvokeGenPretaskExcute();
}
return Task.FromResult(true);
}
[HttpPost]
public async Task test(string code)
{
var carry_code = code;//从数采读取载具
WmsCarryH? carry = _db.Queryable<WmsCarryH>().Single(it => it.carry_code == carry_code);
if (carry != null)
{
var WmsCarryCode = _db.Queryable<WmsCarryCode>().Single(it => it.carry_id == carry.id);
var loc= _db.Queryable<BasLocation>().Single(it => it.id == carry.location_id);
VisualDevModelDataCrInput input = new VisualDevModelDataCrInput();
input.data = new Dictionary<string, object>();
input.data.Add("barcode", carry_code);
input.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量
input.data.Add("material_code", WmsCarryCode.material_code);
input.data.Add("extras", loc.location_code!);//location_code
input.data.Add("warehouse_id", WmsCarryCode.warehouse_id!);
input.data.Add("bill_code", "");//采购收货单号
input.data.Add("code_batch", WmsCarryCode.code_batch!);//批次
input.data.Add("material_specification", WmsCarryCode.material_specification!);//规格型号
input.data.Add("container_no", WmsCarryCode.container_no!);//箱号
input.data.Add("material_id", WmsCarryCode.material_id);
input.data.Add("id", null);
await ScanInStockByRedis(input);
}
}
}
}

View File

@@ -179,7 +179,7 @@ namespace Tnb.WarehouseMgr
for (int j = 0; j < codeNum; j++)
{
int index = j + 1;
string code = $"{WmsPurchaseD.material_code}{WmsPurchaseD.code_batch}{index.ToString().PadLeft(4, '0')}";
string code = $"{WmsPurchaseD.material_code}-{WmsPurchaseD.code_batch}-{index.ToString().PadLeft(4, '0')}";
WmsTempCode barCode = new()
{
material_id = WmsPurchaseD.material_id,