入库申请,新增条码打印功能
This commit is contained in:
@@ -328,6 +328,7 @@ namespace Tnb.WarehouseMgr
|
||||
catch (Exception ex)
|
||||
{
|
||||
tcs.SetException(ex);
|
||||
throw ex;
|
||||
Logger.Error("条码打印时出现错误", ex);
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Tnb.WarehouseMgr
|
||||
.InnerJoin<WmsDistaskH>((a, b, c) => b.location_code == c.endlocation_code || b.location_code == c.startlocation_code)
|
||||
.Where(whereExpable.ToExpression())
|
||||
.WhereIF(!SqlFunc.IsNullOrEmpty(input.sourceName) && SqlFunc.StartsWith("DT-R", input.sourceName), (a, b, c) => c.startpoint_code == input.sourceName)
|
||||
//.WhereIF(!SqlFunc.IsNullOrEmpty(input.sourceName) && SqlFunc.StartsWith("DT-C", input.sourceName), (a, b, c) => c.endpoint_code == input.sourceName)
|
||||
.WhereIF(!SqlFunc.IsNullOrEmpty(input.sourceName) && SqlFunc.StartsWith("DT-C", input.sourceName), (a, b, c) => c.endpoint_code == input.sourceName)
|
||||
.Select((a, b, c) => new WmsElevatorH
|
||||
{
|
||||
bill_code = c.bill_code,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
@@ -87,7 +88,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
[HttpPost]
|
||||
public async Task BarCodePrint(BarCodePrintInput input)
|
||||
public async Task<dynamic> BarCodePrint(BarCodePrintInput input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
@@ -98,9 +99,10 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
throw new ArgumentException($"parameter {nameof(input.BillIds)} not be null or zero");
|
||||
}
|
||||
|
||||
List<string> barcodes = new();
|
||||
try
|
||||
{
|
||||
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
if (_dicBillCodes.Count < 1)
|
||||
@@ -111,6 +113,7 @@ namespace Tnb.WarehouseMgr
|
||||
List<WmsInstockD> inStockDetails = await _db.Queryable<WmsInstockD>().Where(it => input.BillIds.Contains(it.bill_id)).ToListAsync();
|
||||
if (inStockDetails?.Count > 0)
|
||||
{
|
||||
|
||||
List<WmsTempCode> wmsTempCodes = new();
|
||||
for (int i = 0; i < inStockDetails.Count; i++)
|
||||
{
|
||||
@@ -152,20 +155,71 @@ namespace Tnb.WarehouseMgr
|
||||
wmsTempCodes.Add(barCode);
|
||||
}
|
||||
}
|
||||
int row = await _db.Insertable(wmsTempCodes).ExecuteCommandAsync();
|
||||
if (row > 0)
|
||||
int row = 0;
|
||||
List<(string requireId, string barcode)> multi = wmsTempCodes.Select(x => (x.require_id, x.barcode)).ToList();
|
||||
var printedTempCodes = await _db.Queryable<WmsTempCode>().Where(it => multi.Select(x => x.requireId).Contains(it.require_id) && multi.Select(x => x.barcode).Contains(it.barcode)).ToListAsync();
|
||||
if (printedTempCodes?.Count > 0)
|
||||
{
|
||||
_ = await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { print_status = WmsWareHouseConst.BARCODE_PRINT_STATUS_COMPLETE_ID }).Where(it => input.BillIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
var instocks = await _db.Queryable<WmsInstockH>().Where(it => it.print_status == WmsWareHouseConst.BARCODE_PRINT_STATUS_COMPLETE_ID && printedTempCodes.Select(x => x.require_id).Contains(it.id)).ToListAsync();
|
||||
if (instocks?.Count > 0)
|
||||
{
|
||||
wmsTempCodes = wmsTempCodes.Except(printedTempCodes, new CustomEqualityComparer()).ToList();
|
||||
}
|
||||
if (wmsTempCodes?.Count > 0)
|
||||
row = await _db.Insertable(wmsTempCodes).ExecuteCommandAsync();
|
||||
wmsTempCodes = wmsTempCodes.Concat(printedTempCodes).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
row = await _db.Insertable(wmsTempCodes).ExecuteCommandAsync();
|
||||
}
|
||||
_ = await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { print_status = WmsWareHouseConst.BARCODE_PRINT_STATUS_COMPLETE_ID }).Where(it => input.BillIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
barcodes = wmsTempCodes?.Select(x => x.barcode).ToList() ?? Enumerable.Empty<string>().ToList();
|
||||
|
||||
}
|
||||
if (barcodes?.Count > 0)
|
||||
{
|
||||
base.BarCodePrint(barcodes, 1);
|
||||
}
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
}
|
||||
return barcodes;
|
||||
}
|
||||
/* /// <summary>
|
||||
/// 条码打印
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[HttpPost]
|
||||
public Task BarCodePrint()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (barcodes?.Count > 0)
|
||||
{
|
||||
base.BarCodePrint(barcodes, 1);
|
||||
barcodes.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AppFriendlyException("没有可打印的条码", 500);
|
||||
}
|
||||
}
|
||||
catch (AppFriendlyException ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new AppFriendlyException("打印失败", 500);
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}*/
|
||||
|
||||
|
||||
private Task<WmsTempCode> CreateInstock(WmsInstockD detail, int no)
|
||||
{
|
||||
@@ -177,8 +231,8 @@ namespace Tnb.WarehouseMgr
|
||||
material_code = detail.material_code,
|
||||
barcode = code,
|
||||
code_batch = detail.code_batch,
|
||||
material_specification= detail.material_specification,
|
||||
container_no =detail.container_no,
|
||||
material_specification = detail.material_specification,
|
||||
container_no = detail.container_no,
|
||||
codeqty = detail.pr_qty!.Value,
|
||||
unit_id = detail.unit_id,
|
||||
is_lock = 0,
|
||||
@@ -463,7 +517,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
//生成载具条码记录
|
||||
List<WmsCarryCode> carryCodes = preTaskUpInput.PreTaskHandleCodes.Adapt<List<WmsCarryCode>>();
|
||||
|
||||
|
||||
carryCodes.ForEach(x =>
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
@@ -538,4 +592,22 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomEqualityComparer : EqualityComparer<WmsTempCode>
|
||||
{
|
||||
public bool Equals(WmsTempCode? x, WmsTempCode? y)
|
||||
{
|
||||
// 判断两个对象是否相等的逻辑
|
||||
return x?.barcode == y?.barcode && x?.require_id == y?.require_id;
|
||||
}
|
||||
|
||||
public int GetHashCode([DisallowNull] WmsTempCode obj)
|
||||
{
|
||||
// 使用多个属性来计算哈希码
|
||||
int hashCode = obj.barcode?.GetHashCode() ?? 0;
|
||||
hashCode = (hashCode * 397) ^ obj.require_id.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"Cache": {
|
||||
"CacheType": "RedisCache", //MemoryCache
|
||||
"ip": "192.168.11.109",
|
||||
"ip": "localhost",
|
||||
"port": 6379,
|
||||
"password": "05jWEoJa8v",
|
||||
"RedisConnectionString": "{0}:{1},password={2}, poolsize=500,ssl=false,defaultDatabase=0"
|
||||
|
||||
Reference in New Issue
Block a user