调拨订单同步生成原材料/成品调拨出库 物料签收接口

This commit is contained in:
2024-08-16 18:50:17 +08:00
parent ebddefa01b
commit ea222f0baa
20 changed files with 896 additions and 224 deletions

View File

@@ -13,6 +13,5 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
public string? create_id { get; set; }
public string? carry_code { get; set; }
public string? startlocation_code { get; set; }
public string? warehouse_id { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
{
public class CarryCodeUnbindCodeInput
{
public string? carry_code_id { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tnb.WarehouseMgr.Entities.Consts;
namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
{
public class MaterialSignInput
{
public string? org { get; set; } = WmsWareHouseConst.AdministratorOrgId;
public string? create_id { get; set; }
public string? carry_code { get; set; }
public List<MaterialSignDetailInput> details { get; set; }
}
public class MaterialSignDetailInput
{
public string? carry_code_id { get; set; }
public decimal sign_qty { get; set; }
}
}

View File

@@ -255,3 +255,115 @@ public partial class WmsCarryStockReportCode
}
/// <summary>
/// 载具库存报表
/// </summary>
public partial class WmsCarryStockReportExcel
{
public int index { get; set; }
///// <summary>
///// 所属组织
///// </summary>
//public string? 组织 { get; set; }
///// <summary>
///// 载具ID
///// </summary>
//public string? carry_id { get; set; }
/// <summary>
/// 载具编码
/// </summary>
public string? carry_code { get; set; }
/// <summary>
/// 载具名称
/// </summary>
public string? carry_name { get; set; }
/// <summary>
/// 仓库名称
/// </summary>
public string? warehouse_name { get; set; }
/// <summary>
/// 库位编码
/// </summary>
public string? location_code { get; set; }
/// <summary>
/// 库位名称
/// </summary>
public string? location_name { get; set; }
/// <summary>
/// 载具状态
/// </summary>
public string? carry_status { get; set; }
/// <summary>
/// 库位状态
/// </summary>
public string? location_status { get; set; }
/// <summary>
/// 载具类型
/// </summary>
public string? carry_type { get; set; }
/// <summary>
/// 入库时间
/// </summary>
public string? instock_time { get; set; }
///// <summary>
///// 物料ID
///// </summary>
//public string? material_id { get; set; }
/// <summary>
/// 物料编号
/// </summary>
public string? material_code { get; set; }
/// <summary>
/// 物料名称
/// </summary>
public string? material_name { get; set; }
/// <summary>
/// 条码编号
/// </summary>
public string? barcode { get; set; }
/// <summary>
/// 批次
/// </summary>
public string? code_batch { get; set; }
/// <summary>
/// 条码数量
/// </summary>
public decimal? qty { get; set; }
/// <summary>
/// 单位
/// </summary>
public string? unit { get; set; }
///// <summary>
///// 操作用户
///// </summary>
//public string? 创建用户 { get; set; }
/// <summary>
/// 绑定时间
/// </summary>
public string? bind_time { get; set; }
}

View File

@@ -72,11 +72,11 @@ public partial class WmsMaterialSignD : BaseEntity<string>
/// <summary>
/// 条码数量
/// </summary>
public string? qty { get; set; }
public decimal? qty { get; set; }
/// <summary>
/// 签收数量
/// </summary>
public string? sign_qty { get; set; }
public decimal? sign_qty { get; set; }
}

View File

@@ -45,13 +45,13 @@ public partial class WmsMaterialSignH : BaseEntity<string>
public string? carry_code { get; set; }
/// <summary>
/// 签收业务
/// 签收仓库id
/// </summary>
public string? business { get; set; }
public string? warehouse_sign_id { get; set; }
/// <summary>
/// 回库预任务
/// 回库仓库id
/// </summary>
public string? pretask_code { get; set; }
public string? warehouse_instock_id { get; set; }
}

View File

@@ -89,4 +89,14 @@ public partial class WmsRawmatTransferoutstockD : BaseEntity<string>
/// </summary>
public string? warehouse_code { get; set; }
/// <summary>
/// erp_line_pk
/// </summary>
public string? erp_line_pk { get; set; }
/// <summary>
/// erp行号
/// </summary>
public string? lineno { get; set; }
}

View File

@@ -114,4 +114,14 @@ public partial class WmsRawmatTransferoutstockH : BaseEntity<string>
/// </summary>
public string? warehouse_code { get; set; }
/// <summary>
/// erp_pk
/// </summary>
public string? erp_pk { get; set; }
/// <summary>
/// 调拨订单id
/// </summary>
public string? transfer_order_id { get; set; }
}

View File

@@ -134,4 +134,14 @@ public partial class WmsTransferOutstockD : BaseEntity<string>
/// </summary>
public string? warehouse_code { get; set; }
/// <summary>
/// erp_line_pk
/// </summary>
public string? erp_line_pk { get; set; }
/// <summary>
/// erp行号
/// </summary>
public string? lineno { get; set; }
}

View File

@@ -99,4 +99,13 @@ public partial class WmsTransferOutstockH : BaseEntity<string>
/// </summary>
public string? warehouse_code { get; set; }
/// <summary>
/// erp_pk
/// </summary>
public string? erp_pk { get; set; }
/// <summary>
/// 调拨订单id
/// </summary>
public string? transfer_order_id { get; set; }
}

View File

@@ -12,5 +12,8 @@ namespace Tnb.WarehouseMgr.Interfaces
{
Task<Result> CarryUnbind(CarryBindInput input, ISqlSugarClient dbConn = null);
Task<Result> CarryCodeUnbind(CarryCodeUnbindInput input, ISqlSugarClient dbConn = null);
Task<Result> CarryCodeUnbindCode(CarryCodeUnbindCodeInput input, ISqlSugarClient dbConn = null);
}
}

View File

@@ -1047,22 +1047,68 @@ namespace Tnb.WarehouseMgr
if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_YCL_ID)
{
WmsRawmatTransferoutstockH wmsRawmatTransferoutstockH = new WmsRawmatTransferoutstockH();
string code = await _billRuleService.GetBillNumber("WmsRawmatTransferoutstockH");
wmsRawmatTransferoutstockH.bill_code = code;
wmsRawmatTransferoutstockH.create_id = WmsWareHouseConst.ErpUserId;
wmsRawmatTransferoutstockH.create_time = DateTime.Now;
wmsRawmatTransferoutstockH.biller = input.biller;
wmsRawmatTransferoutstockH.dept_code = input.dept_code;
wmsRawmatTransferoutstockH.warehouse_code = warehouse_outstock.whcode;
wmsRawmatTransferoutstockH.erp_pk = input.erp_pk;
wmsRawmatTransferoutstockH.transfer_order_id = wmsTransferOrderH.bill_code;
List<WmsRawmatTransferoutstockD> wmsRawmatTransferoutstockDs = new List <WmsRawmatTransferoutstockD>();
foreach (var detail in input.details)
{
WmsRawmatTransferoutstockD wmsRawmatTransferoutstockD = new WmsRawmatTransferoutstockD();
wmsRawmatTransferoutstockD.bill_id = wmsRawmatTransferoutstockH.id;
wmsRawmatTransferoutstockD.unit = detail.unit_code;
var erpExtendField = await db.Queryable<ErpExtendField>().InnerJoin<DictionaryDataEntity>((a, b) => a.table_id == b.Id).Where((a, b) => a.cunitid == detail.unit_code).Select((a, b) => b).FirstAsync();
if (erpExtendField != null)
{
wmsRawmatTransferoutstockD.unit = erpExtendField.EnCode;
}
else
{
_LoggerErp2Mes.LogWarning($@"【TransferOrder】表体明细中单位{detail.unit_code}在wms系统中未找到");
throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到", 500);
}
List<WmsRawmatTransferoutstockD> wmsRawmatTransferoutstockD = new List <WmsRawmatTransferoutstockD>();
wmsRawmatTransferoutstockD.qty = detail.qty;
wmsRawmatTransferoutstockD.code_batch = detail.code_batch;
wmsRawmatTransferoutstockD.erp_line_pk = detail.erp_line_pk;
wmsRawmatTransferoutstockD.create_id = WmsWareHouseConst.ErpUserId;
wmsRawmatTransferoutstockD.create_time = DateTime.Now;
wmsRawmatTransferoutstockD.lineno = detail.lineno;
var material = await db.Queryable<BasMaterial>().Where(p => p.code == detail.material_code).FirstAsync();
if (material != null)
{
wmsRawmatTransferoutstockD.matcode_id = material.id;
wmsRawmatTransferoutstockD.matcode = material.code;
wmsRawmatTransferoutstockD.matspecification = material.material_specification;
}
wmsRawmatTransferoutstockDs.Add(wmsRawmatTransferoutstockD);
}
await db.Insertable(wmsRawmatTransferoutstockH).ExecuteCommandAsync();
await db.Insertable(wmsRawmatTransferoutstockD).ExecuteCommandAsync();
await db.Insertable(wmsRawmatTransferoutstockDs).ExecuteCommandAsync();
}
else if(warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_CP_ID)
{
WmsTransferInstockH wmsTransferInstockH = new WmsTransferInstockH();
WmsTransferOutstockH wmsTransferOutstockH = new WmsTransferOutstockH();
string code = await _billRuleService.GetBillNumber("WmsTransferOutstockH");
wmsTransferOutstockH.bill_code = code;
wmsTransferOutstockH.create_id = WmsWareHouseConst.ErpUserId;
wmsTransferOutstockH.create_time = DateTime.Now;
wmsTransferOutstockH.warehouse_code = warehouse_outstock.whcode;
wmsTransferOutstockH.erp_pk = input.erp_pk;
wmsTransferOutstockH.transfer_order_id = wmsTransferOrderH.bill_code;
List<WmsTransferOutstockD> wmsTransferOutstockDs = new List<WmsTransferOutstockD>();
List<WmsTransferInstockD> wmsTransferInstockD = new List<WmsTransferInstockD>();
await db.Insertable(wmsTransferInstockH).ExecuteCommandAsync();
await db.Insertable(wmsTransferInstockD).ExecuteCommandAsync();
await db.Insertable(wmsTransferOutstockH).ExecuteCommandAsync();
await db.Insertable(wmsTransferOutstockDs).ExecuteCommandAsync();
}
await db.Ado.CommitTranAsync();

View File

@@ -88,7 +88,6 @@ namespace Tnb.WarehouseMgr
public static SemaphoreSlim s_floor2CreatePretask = new(1);
public static SemaphoreSlim s_taskCommonCreatePretask = new(1);
public static SemaphoreSlim s_taskGenPreTask = new(1);
public static SemaphoreSlim s_GenTaskExecute = new(1);
public Func<string, int, Task> AddUnExecuteTask { get; set; }

View File

@@ -36,13 +36,15 @@ namespace Tnb.WarehouseMgr
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
private readonly IWareHouseService _wareHouseService;
public WmsArtificialInstockService(
ISqlSugarRepository<WmsCarryH> repository,
IUserManager userManager,
IBillRullService billRullService,
IRunService runService,
IVisualDevService visualDevService,
IWmsPDAScanInStockService wmsPDAScanInStock)
IWmsPDAScanInStockService wmsPDAScanInStock,
IWareHouseService wareHouseService)
{
_db = repository.AsSugarClient();
_userManager = userManager;
@@ -50,6 +52,7 @@ namespace Tnb.WarehouseMgr
_runService = runService;
_visualDevService = visualDevService;
_wmsPDAScanInStock = wmsPDAScanInStock;
_wareHouseService = wareHouseService;
}
@@ -95,51 +98,65 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException($"【ArtificialInstock】载具{input.carry_code}未绑定物料", 500);
}
BasLocation carrryLoc = await _db.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
if (carrryLoc != null && carrryLoc.is_type == "0")
BasLocation carryLoc = await _db.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
if (carryLoc != null && carryLoc.is_type == "0")
{
throw new Exception($"托盘{wmsCarryH.carry_code}在存储库位中,不能绑定!");
}
switch (input.warehouse_id)
switch (carryLoc.wh_id)
{
case WmsWareHouseConst.WAREHOUSE_YCL_ID:
{
var WmsCarryCode = _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == wmsCarryH.id).OrderByDescending(it => it.id).First();
if (WmsCarryCode != null)
await _wareHouseService.s_taskExecuteSemaphore_YCLInstock.WaitAsync();
try
{
VisualDevModelDataCrInput input2 = new VisualDevModelDataCrInput();
input2.data = new Dictionary<string, object>();
input2.data.Add("barcode", input.carry_code);
input2.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量
input2.data.Add("material_code", WmsCarryCode.material_code);
input2.data.Add("extras", input.startlocation_code);//location_code
input2.data.Add("warehouse_id", "1");//TEST
input2.data.Add("bill_code", "");//采购收货单号
input2.data.Add("code_batch", WmsCarryCode.code_batch!);//批次
input2.data.Add("material_specification", WmsCarryCode.material_specification!);//规格型号
input2.data.Add("container_no", WmsCarryCode.container_no!);//箱号
input2.data.Add("material_id", WmsCarryCode.material_id);
input2.data.Add("物料条码", WmsCarryCode.barcode);
input2.data.Add("id", null);
_wmsPDAScanInStock.ScanInStockByRedis(input2, _db).Wait();
WmsArtificialInstock wmsArtificialInstock = new WmsArtificialInstock();
wmsArtificialInstock.carry_id = wmsCarryH.id;
wmsArtificialInstock.carry_code = wmsCarryH.carry_code;
wmsArtificialInstock.org_id = input.org;
wmsArtificialInstock.create_id = input.create_id;
wmsArtificialInstock.create_time = DateTime.Now;
wmsArtificialInstock.location_id = startlocationn.id;
wmsArtificialInstock.location_code = startlocationn.location_code;
wmsArtificialInstock.warehouse_id = input.warehouse_id;
await _db.Insertable(wmsArtificialInstock).ExecuteCommandAsync();
var WmsCarryCode = _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == wmsCarryH.id).OrderByDescending(it => it.id).First();
if (WmsCarryCode != null)
{
VisualDevModelDataCrInput input2 = new VisualDevModelDataCrInput();
input2.data = new Dictionary<string, object>();
input2.data.Add("barcode", input.carry_code);
input2.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量
input2.data.Add("material_code", WmsCarryCode.material_code);
input2.data.Add("extras", input.startlocation_code);//location_code
input2.data.Add("warehouse_id", "1");//TEST
input2.data.Add("bill_code", "");//采购收货单号
input2.data.Add("code_batch", WmsCarryCode.code_batch!);//批次
input2.data.Add("material_specification", WmsCarryCode.material_specification!);//规格型号
input2.data.Add("container_no", WmsCarryCode.container_no!);//箱号
input2.data.Add("material_id", WmsCarryCode.material_id);
input2.data.Add("物料条码", WmsCarryCode.barcode);
input2.data.Add("id", null);
_wmsPDAScanInStock.ScanInStockByRedis(input2, _db).Wait();
WmsArtificialInstock wmsArtificialInstock = new WmsArtificialInstock();
wmsArtificialInstock.carry_id = wmsCarryH.id;
wmsArtificialInstock.carry_code = wmsCarryH.carry_code;
wmsArtificialInstock.org_id = input.org;
wmsArtificialInstock.create_id = input.create_id;
wmsArtificialInstock.create_time = DateTime.Now;
wmsArtificialInstock.location_id = startlocationn.id;
wmsArtificialInstock.location_code = startlocationn.location_code;
wmsArtificialInstock.warehouse_id = carryLoc.wh_id;
await _db.Insertable(wmsArtificialInstock).ExecuteCommandAsync();
}
else
{
throw new AppFriendlyException($"【ArtificialInstock】载具 {input.carry_code} 未绑定物料条码!", 500);
}
}
else
catch
{
throw new AppFriendlyException($"【ArtificialInstock】载具 {input.carry_code} 未绑定物料条码!", 500);
throw;
}
finally
{
_wareHouseService.s_taskExecuteSemaphore_YCLInstock.Release();
}
break;
}
}

View File

@@ -188,5 +188,144 @@ namespace Tnb.WarehouseMgr
};
return PageResult<WmsCarryStockReportH>.SqlSugarPageResult(pagedList);
}
[HttpPost, AllowAnonymous]
public async Task<dynamic> CarryStockExcel(CarryStockInput input)
{
var warehouse_id = "";
var carry_code = "";
var material_code = "";
if (!input.queryJson.IsNullOrWhiteSpace())
{
warehouse_id = JObject.Parse(input.queryJson).Value<string>(nameof(WmsCarryCode.warehouse_id));
carry_code = JObject.Parse(input.queryJson).Value<string>(nameof(WmsCarryCode.carry_code));
material_code = JObject.Parse(input.queryJson).Value<string>(nameof(WmsCarryCode.material_code));
}
List<WmsCarryStockReport> items = await _db.Queryable<BasLocation>()
.LeftJoin<WmsCarryH>((a, b) => b.location_id == a.id)
.InnerJoin<BasWarehouse>((a, b, c) => a.wh_id == c.id)
.LeftJoin<WmsCarrystd>((a, b, c, d) => d.id == b.carrystd_id)
.LeftJoin<WmsCarryCode>((a, b, c, d, e) => e.carry_id == b.id)
.LeftJoin<BasMaterial>((a, b, c, d, e, f) => f.id == e.material_id)
.Where((a, b, c, d, e) => a.is_type == ((int)EnumLocationType.).ToString() && a.is_use == "1"
&& ((!string.IsNullOrEmpty(b.carry_code) && b.carry_status != "0" && b.carry_status != "6") || string.IsNullOrEmpty(b.carry_code)))
.WhereIF(!string.IsNullOrEmpty(warehouse_id), (a, b, c, d) => c.id == warehouse_id)
.WhereIF(!string.IsNullOrEmpty(carry_code), (a, b, c, d) => b.carry_code.Contains(carry_code))
.WhereIF(!string.IsNullOrEmpty(material_code), (a, b, c, d, e, f) => e.material_code.Contains(material_code))
.OrderByDescending((a, b, c, d, e, f) => b.carry_code)
.Select((a, b, c, d, e, f) => new WmsCarryStockReport
{
warehouse_name = c.whname,
carry_id = b.id,
carry_code = string.IsNullOrEmpty(b.carry_code) ? "空托盘堆垛" : b.carry_code,
carry_name = string.IsNullOrEmpty(b.carry_code) ? "空托盘堆垛" : b.carry_name,
carry_status = b.is_lock == 1 ? "锁定" : "未锁定",
carry_type = d.carrystd_name,
location_code = a.location_code,
location_name = a.location_name,
location_status = a.is_lock == 1 ? "锁定" : "未锁定",
instock_time = b.instock_time != null ? b.instock_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
barcode = e.barcode,
code_batch = e.code_batch,
qty = e.codeqty,
material_id = e.material_id,
material_code = e.material_code,
material_name = f.name,
unit = e.unit_id,
creator = e.create_id,
bind_time = e.create_time != null ? e.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
})
.OrderBy((a) => a.location_code)
.ToListAsync();
// 料架
List<WmsCarryStockReport> items_LJ = await _db.Queryable<BasLocation>()
.LeftJoin<WmsCarryH>((a, b) => b.location_id == a.id)
.InnerJoin<BasWarehouse>((a, b, c) => a.wh_id == c.id)
.InnerJoin<WmsCarrystd>((a, b, c, d) => d.id == b.carrystd_id)
.InnerJoin<WmsCarryD>((a, b, c, d, e) => e.carry_id == b.id)
.InnerJoin<WmsCarryCode>((a, b, c, d, e, f) => f.carry_id == e.membercarry_id)
.InnerJoin<BasMaterial>((a, b, c, d, e, f, g) => g.id == f.material_id)
.InnerJoin<WmsCarryH>((a, b, c, d, e, f, g, h) => h.id == e.membercarry_id)
.Where((a, b, c, d, e) => a.is_type == ((int)EnumLocationType.).ToString() && a.is_use == "1" && b.carry_status != "0" && b.carry_status != "6")
.WhereIF(!string.IsNullOrEmpty(warehouse_id), (a, b, c, d) => c.id == warehouse_id)
.WhereIF(!string.IsNullOrEmpty(carry_code), (a, b, c, d, e, f, g, h) => b.carry_code.Contains(carry_code) || h.carry_code.Contains(carry_code))
.WhereIF(!string.IsNullOrEmpty(material_code), (a, b, c, d, e, f, g) => g.code.Contains(material_code))
.Select((a, b, c, d, e, f, g, h) => new WmsCarryStockReport
{
warehouse_name = c.whname,
carry_id = b.id,
carry_code = b.carry_code,
carry_name = b.carry_name,
membercarry_code = h.carry_code,
membercarry_name = h.carry_name,
carry_status = b.is_lock == 1 ? "锁定" : "未锁定",
carry_type = d.carrystd_name,
location_code = a.location_code,
location_name = a.location_name,
location_status = a.is_lock == 1 ? "锁定" : "未锁定",
instock_time = b.instock_time != null ? b.instock_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
barcode = f.barcode,
code_batch = f.code_batch,
qty = f.codeqty,
material_id = f.material_id,
material_code = f.material_code,
material_name = g.name,
unit = f.unit_id,
creator = f.create_id,
bind_time = f.create_time != null ? f.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
})
.OrderBy((a) => a.location_code)
.ToListAsync();
items.AddRange(items_LJ);
// d.carrystd_name != "料架"
List<WmsCarryStockReportExcel> wmsCarryStockReportExcels = new List<WmsCarryStockReportExcel>();
int index = 0;
items.ForEach(x =>
{
index++;
WmsCarryStockReportExcel wmsCarryStockReportCode = x.Adapt<WmsCarryStockReportExcel>();
wmsCarryStockReportCode.index = index;
//wmsCarryStockReportCode.carry_id = x.carry_id;
wmsCarryStockReportCode.carry_code = !string.IsNullOrEmpty(x.membercarry_code) ? x.membercarry_code : x.carry_code;
wmsCarryStockReportCode.carry_name = !string.IsNullOrEmpty(x.membercarry_name) ? x.membercarry_name : x.carry_name;
//wmsCarryStockReportCode.material_id = x.material_id;
wmsCarryStockReportCode.material_code = x.material_code;
wmsCarryStockReportCode.material_name = x.material_name;
wmsCarryStockReportCode.barcode = x.barcode;
wmsCarryStockReportCode.code_batch = x.code_batch;
wmsCarryStockReportCode.qty = x.qty;
wmsCarryStockReportCode.unit = x.unit;
//wmsCarryStockReportCode.创建用户 = x.操作用户;
wmsCarryStockReportCode.bind_time = x.bind_time;
wmsCarryStockReportExcels.Add(wmsCarryStockReportCode);
});
int rowIndex = 0;
List<WmsCarryStockReportExcel> pages = wmsCarryStockReportExcels.Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).ToList();
pages.ForEach(page => { rowIndex++; page.index = rowIndex; });
SqlSugarPagedList<WmsCarryStockReportExcel> pagedList = new()
{
list = pages,
pagination = new()
{
CurrentPage = input.currentPage,
PageSize = input.pageSize,
Total = wmsCarryStockReportExcels.Count()
}
};
return PageResult<WmsCarryStockReportExcel>.SqlSugarPageResult(pagedList);
}
}
}

View File

@@ -247,5 +247,45 @@ namespace Tnb.WarehouseMgr
}
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, "成功");
}
public async Task<Result> CarryCodeUnbindCode(CarryCodeUnbindCodeInput input, ISqlSugarClient dbConn = null)
{
bool isOk = false;
var db = _db;
if (dbConn != null)
db = dbConn;
try
{
if (input == null)
{
throw new ArgumentNullException(nameof(input));
}
if (!string.IsNullOrEmpty(input.carry_code_id))
{
int row = await db.Deleteable<WmsCarryCode>().Where(r => r.id == input.carry_code_id).ExecuteCommandAsync();
isOk = row > 0;
Logger.LogInformation($"【CarryCodeUnbind】载具物料明细{input.carry_code_id}已解绑,解绑条数{row}");
//if (!isOk)
//{
// throw Oops.Oh(ErrorCode.COM1001);
//}
}
else
{
throw new AppFriendlyException("载具物料明细不能为空", 500);
}
}
catch (Exception ex)
{
Logger.LogError($"【CarryCodeUnbind】 {ex.Message}");
Logger.LogError($"【CarryCodeUnbind】 {ex.StackTrace}");
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, "成功");
}
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using Aop.Api.Domain;
@@ -18,6 +19,7 @@ using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Entity;
using Tnb.WarehouseMgr.Interfaces;
@@ -36,13 +38,17 @@ namespace Tnb.WarehouseMgr
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
private readonly IWmsCarryUnbindService _wmsCarryUnbindService;
private readonly IWareHouseService _wareHouseService;
public WmsMaterialSignHService(
ISqlSugarRepository<WmsCarryH> repository,
IUserManager userManager,
IBillRullService billRullService,
IRunService runService,
IVisualDevService visualDevService,
IWmsPDAScanInStockService wmsPDAScanInStock)
IWmsPDAScanInStockService wmsPDAScanInStock,
IWmsCarryUnbindService wmsCarryUnbindService,
IWareHouseService wareHouseService)
{
_db = repository.AsSugarClient();
_userManager = userManager;
@@ -50,8 +56,172 @@ namespace Tnb.WarehouseMgr
_runService = runService;
_visualDevService = visualDevService;
_wmsPDAScanInStock = wmsPDAScanInStock;
_wmsCarryUnbindService = wmsCarryUnbindService;
_wareHouseService = wareHouseService;
}
/// <summary>
/// 物料签收
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="AppFriendlyException"></exception>
[HttpPost]
public async Task MaterialSign(MaterialSignInput input)
{
try
{
if (input == null)
{
throw new ArgumentNullException(nameof(input));
}
await _db.Ado.BeginTranAsync();
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.carry_code == input.carry_code).FirstAsync();
if (wmsCarryH == null)
{
throw new AppFriendlyException($"【MaterialSign】载具{input.carry_code}不存在", 500);
}
if (wmsCarryH.is_lock == 1)
{
throw new AppFriendlyException($"【MaterialSign】载具{input.carry_code}已锁定", 500);
}
if (wmsCarryH.carry_status != "1")
{
throw new AppFriendlyException($"【MaterialSign】载具{input.carry_code}未绑定物料", 500);
}
if (string.IsNullOrEmpty(wmsCarryH.location_id))
{
throw new AppFriendlyException($"【MaterialSign】载具{input.carry_code}当前库位为空,无法签收", 500);
}
List<WmsCarryCode> wmsCarryCodes = _db.Queryable<WmsCarryCode>().Where(r => r.carry_id == wmsCarryH.id).ToList();
WmsMaterialSignH wmsMaterialSignH = new WmsMaterialSignH();
wmsMaterialSignH.create_id = input.create_id;
wmsMaterialSignH.create_time = DateTime.Now;
wmsMaterialSignH.carry_id = wmsCarryH.id;
wmsMaterialSignH.carry_code = wmsCarryH.carry_code;
List<WmsMaterialSignD> wmsMaterialSignDs = new List<WmsMaterialSignD>();
foreach (var item in input.details)
{
if (item.sign_qty < 0)
{
throw new AppFriendlyException($"【MaterialSign】载具{input.carry_code}签收数量不能为空", 500);
}
WmsCarryCode wmsCarryCode = wmsCarryCodes.Where(r => r.id == item.carry_code_id).First();
if (wmsCarryCode == null)
{
throw new AppFriendlyException($"【MaterialSign】载具{input.carry_code} 载具物料明细id {item.carry_code_id}不存在", 500);
}
if (item.sign_qty > wmsCarryCode.codeqty)
{
throw new AppFriendlyException($"【MaterialSign】载具{input.carry_code}签收数量{item.sign_qty}超过了可签收数量{wmsCarryCode.codeqty}", 500);
}
WmsMaterialSignD wmsMaterialSignD = new WmsMaterialSignD();
wmsMaterialSignD.bill_id = wmsMaterialSignH.id;
wmsMaterialSignD.create_id = input.create_id;
wmsMaterialSignD.create_time = DateTime.Now;
wmsMaterialSignD.barcode = wmsCarryCode.barcode;
wmsMaterialSignD.material_id = wmsCarryCode.material_id;
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().Where(r => r.code == wmsCarryCode.material_code).FirstAsync();
if (basMaterial == null)
{
throw new AppFriendlyException($"【MaterialSign】物料{wmsCarryCode.material_code} 基础资料不存在", 500);
}
wmsMaterialSignD.material_code = basMaterial.code;
wmsMaterialSignD.material_name = basMaterial.name;
wmsMaterialSignD.material_specification = basMaterial.material_specification;
wmsMaterialSignD.code_batch = wmsCarryCode.code_batch;
wmsMaterialSignD.qty = wmsCarryCode.codeqty;
wmsMaterialSignD.sign_qty = item.sign_qty;
wmsMaterialSignDs.Add(wmsMaterialSignD);
wmsCarryCode.codeqty = wmsCarryCode.codeqty - item.sign_qty;
if (wmsCarryCode.codeqty == 0)
{
CarryCodeUnbindCodeInput carryCodeUnbindCodeInput = new CarryCodeUnbindCodeInput();
await _wmsCarryUnbindService.CarryCodeUnbindCode(carryCodeUnbindCodeInput, _db);
wmsCarryCodes.Remove(wmsCarryCode);
await _db.Updateable<WmsTempCode>().SetColumns(r => r.codeqty == wmsCarryCode.codeqty - item.sign_qty)
.Where(r => r.barcode == wmsCarryCode.barcode).ExecuteCommandAsync();
}
}
BasLocation carryLoc = await _db.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
if (carryLoc != null && carryLoc.is_type == "0")
{
throw new Exception($"托盘{wmsCarryH.carry_code}在存储库位中,不能签收!");
}
switch (carryLoc.wh_id)
{
case WmsWareHouseConst.WAREHOUSE_YCL_ID:
{
await _db.Updateable(wmsCarryCodes).ExecuteCommandAsync();
await _wareHouseService.s_taskExecuteSemaphore_YCLInstock.WaitAsync();
wmsMaterialSignH.warehouse_sign_id = WmsWareHouseConst.WAREHOUSE_YCL_ID;
wmsMaterialSignH.warehouse_instock_id = WmsWareHouseConst.WAREHOUSE_YCL_ID;
try
{
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1, AvoidBusyPassage = true, Region_id = WmsWareHouseConst.REGION_YCLCache_ID };
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
if (endLocations.Count == 0)
{
throw new AppFriendlyException("没有可以回库的库位", 500);
}
CommonCreatePretaskInput commonCreatePretaskInput = new CommonCreatePretaskInput();
commonCreatePretaskInput.startlocation_id = carryLoc.location_code;
commonCreatePretaskInput.endlocation_id = endLocations[0].id;
commonCreatePretaskInput.carry_id = wmsCarryH.id;
commonCreatePretaskInput.carry_code = wmsCarryH.carry_code;
commonCreatePretaskInput.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID;
commonCreatePretaskInput.isExcuteMission = false;
commonCreatePretaskInput.moduleConsts = ModuleConsts.MODULE_WMSEMPTYINSTOCK_ID;
Logger.LogInformation($"【MaterialSign】 开始生成原材料仓回库任务 起点{carryLoc.location_code} 终点{endLocations[0].location_code} 托盘 {wmsCarryH.carry_code}");
Entities.Dto.Outputs.Result res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput, _db);
if (res.code == HttpStatusCode.OK)
{
}
}
catch (Exception ex)
{
throw;
}
finally
{
_wareHouseService.s_taskExecuteSemaphore_YCLInstock.Release();
}
break;
}
}
await _db.Updateable(wmsMaterialSignH).ExecuteCommandAsync();
await _db.Updateable(wmsMaterialSignDs).ExecuteCommandAsync();
await _db.Ado.CommitTranAsync();
}
catch (Exception ex)
{
Logger.LogError($"【MaterialSign】 {ex.Message}");
Logger.LogError($"【MaterialSign】 {ex.StackTrace}");
await _db.Ado.RollbackTranAsync();
throw new AppFriendlyException($"【MaterialSign】物料签收失败 {ex.Message}", 500);
}
}
}
}

View File

@@ -12,12 +12,15 @@ using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Interfaces;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Entity;
using Tnb.WarehouseMgr.Interfaces;
@@ -36,13 +39,15 @@ namespace Tnb.WarehouseMgr
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
private readonly IWareHouseService _wareHouseService;
public WmsRawmatTransferoutstockService(
ISqlSugarRepository<WmsCarryH> repository,
IUserManager userManager,
IBillRullService billRullService,
IRunService runService,
IVisualDevService visualDevService,
IWmsPDAScanInStockService wmsPDAScanInStock)
IWmsPDAScanInStockService wmsPDAScanInStock,
IWareHouseService wareHouseService)
{
_db = repository.AsSugarClient();
_userManager = userManager;
@@ -50,109 +55,218 @@ namespace Tnb.WarehouseMgr
_runService = runService;
_visualDevService = visualDevService;
_wmsPDAScanInStock = wmsPDAScanInStock;
_wareHouseService = wareHouseService;
}
public override async Task ModifyAsync(WareHouseUpInput input)
{
if (input == null)
{
throw new ArgumentNullException(nameof(input));
}
}
/// <summary>
/// 人工扫码入库
/// 获取物料库存
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="AppFriendlyException"></exception>
[HttpPost]
public async Task ArtificialInstock(ArtificialInstockInput input)
[HttpPost, NonUnify, AllowAnonymous]
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> MaterialInventory(MaterialTransferGetMaterialInventoryInput input)
{
try
{
if (input == null)
if (input.palletCount <= 0)
{
throw new ArgumentNullException(nameof(input));
throw new AppFriendlyException("托盘数必须大于0", 500);
}
if (string.IsNullOrEmpty(input.material_id))
{
throw new AppFriendlyException("物料id不可为空", 500);
}
if (string.IsNullOrEmpty(input.code_batch))
{
throw new AppFriendlyException("批号不可为空", 500);
}
OutStockStrategyQuery outStockStrategyInput = new()
{
warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID,
material_id = input.material_id,
code_batch = input.code_batch,
Size = input.palletCount,
Region_id = WmsWareHouseConst.REGION_Purchase_ID,
PolicyCode = WmsWareHouseConst.POLICY_YCLOUTSTOCK,
AvoidBusyPassage = true
};
List<WmsCarryH> items = await _wareHouseService.OutStockStrategy(outStockStrategyInput);
decimal qty = _db.Queryable<WmsCarryCode>().Where(r => items.Select(a => a.id).Contains(r.carry_id) && r.material_id == input.material_id && r.code_batch == input.code_batch).Sum(r => r.codeqty);
JObject keyValuePairs = new JObject();
keyValuePairs["realPalletCount"] = items.Count;
keyValuePairs["realInvQty"] = qty;
return await ToApiResult(HttpStatusCode.OK, "成功", keyValuePairs);
}
catch (Exception ex)
{
await _db.Ado.RollbackTranAsync();
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
}
}
/// <summary>
/// 按托下发(到集中供料或外协)
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="AppFriendlyException"></exception>
[HttpPost, NonUnify, AllowAnonymous]
public async Task<Entities.Dto.Outputs.Result> Distribute(MaterialTransferDistributeInput input)
{
try
{
await _s_taskExecuteSemaphore_YCLOutstock.WaitAsync();
if (string.IsNullOrEmpty(input.source_id))
{
throw new AppFriendlyException("来源单据id不可为空", 500);
}
if (input.palletCount <= 0)
{
throw new AppFriendlyException("托盘数必须大于0", 500);
}
if (input.qty <= 0)
{
throw new AppFriendlyException("数量必须大于0", 500);
}
if (string.IsNullOrEmpty(input.code_batch))
{
throw new AppFriendlyException("批号不可为空", 500);
}
WmsMaterialTransferD wmsMaterialTransferD = await _db.Queryable<WmsMaterialTransferD>().FirstAsync(it => it.id == input.source_id);
WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable<WmsMaterialTransfer>().FirstAsync(it => it.id == wmsMaterialTransferD.bill_id);
if (wmsMaterialTransferD.yxfqty >= wmsMaterialTransferD.qty)
{
throw new AppFriendlyException("已下发数量已达到转库数量", 500);
}
await _db.Ado.BeginTranAsync();
BasLocation startlocationn = await _db.Queryable<BasLocation>().Where(r => r.location_code == input.startlocation_code).FirstAsync();
if (startlocationn == null)
OutStockStrategyQuery outStockStrategyInput = new()
{
throw new AppFriendlyException($"【ArtificialInstock】库位{input.startlocation_code}不存在", 500);
}
if (startlocationn.is_lock == 1)
warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID,
material_id = wmsMaterialTransferD.material_id,
code_batch = input.code_batch,
Size = input.palletCount,
Region_id = WmsWareHouseConst.REGION_Purchase_ID,
PolicyCode = WmsWareHouseConst.POLICY_YCLOUTSTOCK,
AvoidBusyPassage = true
};
List<WmsCarryH> items = await _wareHouseService.OutStockStrategy(outStockStrategyInput);
if (items.Count == 0)
{
throw new AppFriendlyException($"【ArtificialInstock】库位{input.startlocation_code}已锁定", 500);
}
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.carry_code == input.carry_code).FirstAsync();
if (wmsCarryH == null)
{
throw new AppFriendlyException($"【ArtificialInstock】载具{input.carry_code}不存在", 500);
}
if (wmsCarryH.is_lock == 1)
{
throw new AppFriendlyException($"【ArtificialInstock】载具{input.carry_code}已锁定", 500);
}
if (wmsCarryH.carry_status != "1")
{
throw new AppFriendlyException($"【ArtificialInstock】载具{input.carry_code}未绑定物料", 500);
throw new AppFriendlyException($@"没有可以出库的载具", 500);
}
BasLocation carrryLoc = await _db.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
if (carrryLoc != null && carrryLoc.is_type == "0")
decimal qty = _db.Queryable<WmsCarryCode>().Where(r => items.Select(a => a.id).Contains(r.carry_id) && r.material_id == wmsMaterialTransferD.material_id && r.code_batch == input.code_batch).Sum(r => r.codeqty);
// 暂定PDA上查询到的物料批次和库存数量与提交时获取的不一致时需要前台重新获取库存接口
if (input.palletCount != items.Count || input.qty != qty)
{
throw new Exception($"托盘{wmsCarryH.carry_code}在存储库位中,不能绑定!");
throw new AppFriendlyException($@"当前实际托盘数量为{input.palletCount} 实际库存数量为{qty},与前台数据不一致,请重新获取库存", HttpStatusCode.InternalServerError);
}
switch (input.warehouse_id)
List<BasLocation> endLocations = new List<BasLocation>();
// 集中供料区三工位
if (wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_JZGL_ID)
{
case WmsWareHouseConst.WAREHOUSE_YCL_ID:
{
var WmsCarryCode = _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == wmsCarryH.id).OrderByDescending(it => it.id).First();
if (WmsCarryCode != null)
{
VisualDevModelDataCrInput input2 = new VisualDevModelDataCrInput();
input2.data = new Dictionary<string, object>();
input2.data.Add("barcode", input.carry_code);
input2.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量
input2.data.Add("material_code", WmsCarryCode.material_code);
input2.data.Add("extras", input.startlocation_code);//location_code
input2.data.Add("warehouse_id", "1");//TEST
input2.data.Add("bill_code", "");//采购收货单号
input2.data.Add("code_batch", WmsCarryCode.code_batch!);//批次
input2.data.Add("material_specification", WmsCarryCode.material_specification!);//规格型号
input2.data.Add("container_no", WmsCarryCode.container_no!);//箱号
input2.data.Add("material_id", WmsCarryCode.material_id);
input2.data.Add("物料条码", WmsCarryCode.barcode);
input2.data.Add("id", null);
_wmsPDAScanInStock.ScanInStockByRedis(input2, _db).Wait();
WmsArtificialInstock wmsArtificialInstock = new WmsArtificialInstock();
wmsArtificialInstock.carry_id = wmsCarryH.id;
wmsArtificialInstock.carry_code = wmsCarryH.carry_code;
wmsArtificialInstock.org_id = input.org;
wmsArtificialInstock.create_id = input.create_id;
wmsArtificialInstock.create_time = DateTime.Now;
wmsArtificialInstock.location_id = startlocationn.id;
wmsArtificialInstock.location_code = startlocationn.location_code;
wmsArtificialInstock.warehouse_id = input.warehouse_id;
await _db.Insertable(wmsArtificialInstock).ExecuteCommandAsync();
}
else
{
throw new AppFriendlyException($"【ArtificialInstock】载具 {input.carry_code} 未绑定物料条码!", 500);
}
break;
}
// 根据三工位任务数平均分配任务 暂定
endLocations = _db.Queryable<BasLocation>().Where(r => _wareHouseService.GetFloor1GLSGWOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0")
.OrderBy("is_lock, task_nums, location_code").ToList();
}
// 中储仓三工位
else if (wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZC_ID)
{
// 根据三工位任务数平均分配任务 暂定
endLocations = _db.Queryable<BasLocation>().Where(r => _wareHouseService.GetFloor1WXSGWOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0")
.OrderBy("is_lock, task_nums, location_code").ToList();
}
if (endLocations.Count() < input.palletCount)
{
throw new AppFriendlyException($@"可用的终点库位数量为{endLocations.Count()}个 下发数量为{input.palletCount}个 请检查终点库位的锁定和占用状态", 500);
}
foreach (var wmsCarryH in items)
{
BasLocation startLocation = await _db.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
BasLocation endLocation = null;
// 集中供料区三工位
if (wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_JZGL_ID)
{
// 根据三工位任务数平均分配任务 暂定
endLocation = await _db.Queryable<BasLocation>().Where(r => _wareHouseService.GetFloor1GLSGWOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync();
}
// 中储仓三工位
else if (wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZC_ID)
{
// 根据三工位任务数平均分配任务 暂定
endLocation = await _db.Queryable<BasLocation>().Where(r => _wareHouseService.GetFloor1WXSGWOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync();
}
if (endLocation == null)
{
throw new AppFriendlyException($@"没有可用的终点库位!请检查终点库位的锁定和占用状态", 500);
}
CommonCreatePretaskInput commonCreatePretaskInput = new CommonCreatePretaskInput();
commonCreatePretaskInput.startlocation_id = startLocation.id;
commonCreatePretaskInput.endlocation_id = endLocation.id;
commonCreatePretaskInput.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WMSMATERIALTRANSFER_ID;
commonCreatePretaskInput.source_id = input.source_id;
commonCreatePretaskInput.carry_id = wmsCarryH.id;
commonCreatePretaskInput.carry_code = wmsCarryH.carry_code;
commonCreatePretaskInput.isExcuteMission = false;
Entities.Dto.Outputs.Result res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput, _db);
if (res.code != HttpStatusCode.OK)
{
Logger.LogInformation($@"生成预任务失败");
throw new AppFriendlyException($@"生成预任务失败", 500);
}
}
// 更新子表已下发数量
await _db.Updateable<WmsMaterialTransferD>().SetColumns(r => r.yxfqty == r.yxfqty + input.qty).Where(r => r.id == input.source_id).ExecuteCommandAsync();
await _db.Ado.CommitTranAsync();
}
catch (Exception ex)
{
Logger.LogError($"【ArtificialInstock】 {ex.Message}");
Logger.LogError($"【ArtificialInstock】 {ex.StackTrace}");
await _db.Ado.RollbackTranAsync();
throw new AppFriendlyException($"【ArtificialInstock】人工扫码入库失败 {ex.Message}", 500);
Logger.LogError("【Distribute】" + ex.Message);
Logger.LogError("【Distribute】" + ex.StackTrace);
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
}
finally
{
_ = _s_taskExecuteSemaphore_YCLOutstock.Release();
InvokeGenPretaskExcute();
}
return await ToApiResult(HttpStatusCode.OK, "成功");
}
}

View File

@@ -53,107 +53,5 @@ namespace Tnb.WarehouseMgr
}
/// <summary>
/// 人工扫码入库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="AppFriendlyException"></exception>
[HttpPost]
public async Task ArtificialInstock(ArtificialInstockInput input)
{
try
{
if (input == null)
{
throw new ArgumentNullException(nameof(input));
}
await _db.Ado.BeginTranAsync();
BasLocation startlocationn = await _db.Queryable<BasLocation>().Where(r => r.location_code == input.startlocation_code).FirstAsync();
if (startlocationn == null)
{
throw new AppFriendlyException($"【ArtificialInstock】库位{input.startlocation_code}不存在", 500);
}
if (startlocationn.is_lock == 1)
{
throw new AppFriendlyException($"【ArtificialInstock】库位{input.startlocation_code}已锁定", 500);
}
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.carry_code == input.carry_code).FirstAsync();
if (wmsCarryH == null)
{
throw new AppFriendlyException($"【ArtificialInstock】载具{input.carry_code}不存在", 500);
}
if (wmsCarryH.is_lock == 1)
{
throw new AppFriendlyException($"【ArtificialInstock】载具{input.carry_code}已锁定", 500);
}
if (wmsCarryH.carry_status != "1")
{
throw new AppFriendlyException($"【ArtificialInstock】载具{input.carry_code}未绑定物料", 500);
}
BasLocation carrryLoc = await _db.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
if (carrryLoc != null && carrryLoc.is_type == "0")
{
throw new Exception($"托盘{wmsCarryH.carry_code}在存储库位中,不能绑定!");
}
switch (input.warehouse_id)
{
case WmsWareHouseConst.WAREHOUSE_YCL_ID:
{
var WmsCarryCode = _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == wmsCarryH.id).OrderByDescending(it => it.id).First();
if (WmsCarryCode != null)
{
VisualDevModelDataCrInput input2 = new VisualDevModelDataCrInput();
input2.data = new Dictionary<string, object>();
input2.data.Add("barcode", input.carry_code);
input2.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量
input2.data.Add("material_code", WmsCarryCode.material_code);
input2.data.Add("extras", input.startlocation_code);//location_code
input2.data.Add("warehouse_id", "1");//TEST
input2.data.Add("bill_code", "");//采购收货单号
input2.data.Add("code_batch", WmsCarryCode.code_batch!);//批次
input2.data.Add("material_specification", WmsCarryCode.material_specification!);//规格型号
input2.data.Add("container_no", WmsCarryCode.container_no!);//箱号
input2.data.Add("material_id", WmsCarryCode.material_id);
input2.data.Add("物料条码", WmsCarryCode.barcode);
input2.data.Add("id", null);
_wmsPDAScanInStock.ScanInStockByRedis(input2, _db).Wait();
WmsArtificialInstock wmsArtificialInstock = new WmsArtificialInstock();
wmsArtificialInstock.carry_id = wmsCarryH.id;
wmsArtificialInstock.carry_code = wmsCarryH.carry_code;
wmsArtificialInstock.org_id = input.org;
wmsArtificialInstock.create_id = input.create_id;
wmsArtificialInstock.create_time = DateTime.Now;
wmsArtificialInstock.location_id = startlocationn.id;
wmsArtificialInstock.location_code = startlocationn.location_code;
wmsArtificialInstock.warehouse_id = input.warehouse_id;
await _db.Insertable(wmsArtificialInstock).ExecuteCommandAsync();
}
else
{
throw new AppFriendlyException($"【ArtificialInstock】载具 {input.carry_code} 未绑定物料条码!", 500);
}
break;
}
}
await _db.Ado.CommitTranAsync();
}
catch (Exception ex)
{
Logger.LogError($"【ArtificialInstock】 {ex.Message}");
Logger.LogError($"【ArtificialInstock】 {ex.StackTrace}");
await _db.Ado.RollbackTranAsync();
throw new AppFriendlyException($"【ArtificialInstock】人工扫码入库失败 {ex.Message}", 500);
}
}
}
}

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Core.Manager;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Interfaces;
using SqlSugar;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
{
/// <summary>
/// 成品调拨出库
/// </summary>
[OverideVisualDev(ModuleConsts.MODULE_WmsArtificialInstock_ID)]
public class WmsTransferOutstockService : BaseWareHouseService
{
private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager;
private readonly IBillRullService _billRullService;
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
private readonly IWareHouseService _wareHouseService;
public WmsTransferOutstockService(
ISqlSugarRepository<WmsCarryH> repository,
IUserManager userManager,
IBillRullService billRullService,
IRunService runService,
IVisualDevService visualDevService,
IWmsPDAScanInStockService wmsPDAScanInStock,
IWareHouseService wareHouseService)
{
_db = repository.AsSugarClient();
_userManager = userManager;
_billRullService = billRullService;
_runService = runService;
_visualDevService = visualDevService;
_wmsPDAScanInStock = wmsPDAScanInStock;
_wareHouseService = wareHouseService;
}
public override async Task ModifyAsync(WareHouseUpInput input)
{
if (input == null)
{
throw new ArgumentNullException(nameof(input));
}
//if (!isOk)
//{
// throw Oops.Oh(ErrorCode.COM1001);
//}
}
}
}