diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs index 4e65aa20..7e8ba40d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs @@ -251,5 +251,15 @@ public class ModuleConsts /// 模块标识-生产入库单 /// public const string MODULE_WMSPRDINSTOCK_ID = "34467501190677"; + /// + /// 模块标识-委外收货 todo + /// + public const string MODULE_WMSOUTSOURCEORDER_ID = "MODULE_WMSOUTSOURCEORDER_ID";// + /// + /// 模块标识-原材料调拨入库 todo + /// + public const string MODULE_WMSRAWMATTRANSFERINSTOCK_ID = "MODULE_WMSRAWMATTRANSFERINSTOCK_ID";// + + } \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index e99c5955..31c6d716 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -113,6 +113,14 @@ /// 采购收料物料流水号 /// public const string WMS_PURCHASE_MAT_ENCODE = "PurchaseMat"; + /// + /// 委外收料物料流水号 + /// + public const string WMS_OUTSOURCE_MAT_ENCODE = "OutsourceMat"; + /// + /// 原材料调拨入库物料流水号 + /// + public const string WMS_TRANSFER_RAWMAT_ENCODE = "RawMatTransfer"; /// 齐套出库生成Encode /// public const string WMS_KITTINGOUTSTK_ENCODE = "WmsKittingOutStk"; @@ -395,7 +403,22 @@ /// 单据类型-生产入库单 /// public const string BILLTYPE_PRDINSTOCK_ID = "27410834411541"; - + + + /// + /// 单据类型-采购收货 + /// + public const string BILLTYPE_PURCHASE_ID = "35882440181525"; + + /// + /// 单据类型-委外收货 + /// + public const string BILLTYPE_OUTSOURCE_ID = "35882444276245"; + + /// + /// 单据类型-原材料调拨入库 + /// + public const string BILLTYPE_RAWMATTRANSFERINSTOCK_ID = "35882449537813"; /// /// 管理员Id(天益4厂管理员) /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/LocationOutput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/LocationOutput.cs index ae74e9a0..c41f30e3 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/LocationOutput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/LocationOutput.cs @@ -13,8 +13,15 @@ namespace Tnb.WarehouseMgr.Entities.Dto public int layers { get; set; } public string carry_code { get; set; } public string material_code { get; set; } + public string material_name { get; set; } public string code_batch { get; set; } public decimal num { get; set; } + /// + /// 0 空库(包括已锁定)1 空载具码垛 2 合格品 3 待检 4 让步接受 5 不合格 + /// + public int status { get; set; } + /// + public string barcode { get; set; } } public class ZsjOutput { diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceOrderD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceD.cs similarity index 96% rename from WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceOrderD.cs rename to WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceD.cs index f26f149e..f404538c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceOrderD.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceD.cs @@ -8,9 +8,9 @@ namespace Tnb.WarehouseMgr.Entities.Entity; /// 委外订单表子表 /// [SugarTable("wms_outsource_order_d")] -public partial class WmsOutsourceOrderD : BaseEntity +public partial class WmsOutsourceD : BaseEntity { - public WmsOutsourceOrderD() + public WmsOutsourceD() { id = SnowflakeIdHelper.NextId(); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceOrderH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceH.cs similarity index 95% rename from WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceOrderH.cs rename to WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceH.cs index d1bc0bac..d9dad8c0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceOrderH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsOutsourceH.cs @@ -8,14 +8,14 @@ namespace Tnb.WarehouseMgr.Entities.Entity; /// 委外订单 /// [SugarTable("wms_outsource_order_h")] -public partial class WmsOutsourceOrderH : BaseEntity +public partial class WmsOutsourceH : BaseEntity { - public WmsOutsourceOrderH() + public WmsOutsourceH() { id = SnowflakeIdHelper.NextId(); } /// - /// 采购订单号 + /// 委外订单号 /// public string? outsource_order { get; set; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs index 7d721ba0..a4211dfc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs @@ -108,4 +108,9 @@ public partial class WmsPurchaseD : BaseEntity /// [SugarColumn(IsIgnore = true)] public string? container_no { get; set; } + + /// + /// 质检结果 + /// + public string? qc_res { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsRawmatTransferinstockD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsRawmatTransferinstockD.cs new file mode 100644 index 00000000..747ec96a --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsRawmatTransferinstockD.cs @@ -0,0 +1,122 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.WarehouseMgr.Entities.Entity; + +/// +/// 原材料调拨入库表子表 +/// +[SugarTable("wms_rawmat_transferinstock_d")] +public partial class WmsRawmatTransferinstockD : BaseEntity +{ + public WmsRawmatTransferinstockD() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 主表id + /// + public string? bill_id { get; set; } + + /// + /// 物料id + /// + public string? matcode_id { get; set; } + + /// + /// 物料编号 + /// + public string? matcode { get; set; } + + /// + /// 物料描述 + /// + public string? matspecification { get; set; } + + /// + /// 单位 + /// + public string? unit { get; set; } + + /// + /// 入库数量 + /// + public decimal? qty { get; set; } + + /// + /// 实入数量 + /// + public decimal? actual_qty { get; set; } + + /// + /// 库存地点ID + /// + public string? stock_location_id { get; set; } + + /// + /// 库存地点 + /// + public string? stock_location { get; set; } + + /// + /// 批次 + /// + public string? code_batch { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + + /// + /// 扩展字段 + /// + public string? extras { get; set; } + + /// + /// 交货日期 + /// + public string? delivery_date { get; set; } + + /// + /// 净价 + /// + public string? net_price { get; set; } + + /// + /// 货币 + /// + public string? currency { get; set; } + + /// + /// 工厂 + /// + public string? factory { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// erp_line_pk + /// + public string? erp_line_pk { get; set; } + +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsRawmatTransferinstockH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsRawmatTransferinstockH.cs new file mode 100644 index 00000000..f53d0e64 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsRawmatTransferinstockH.cs @@ -0,0 +1,112 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.WarehouseMgr.Entities.Entity; + +/// +/// 原材料调拨入库 +/// +[SugarTable("wms_rawmat_transferinstock_h")] +public partial class WmsRawmatTransferinstockH : BaseEntity +{ + public WmsRawmatTransferinstockH() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 原材料调拨入库单号 + /// + public string? bill_code { get; set; } + + /// + /// 联系人 + /// + public string? contact_person { get; set; } + + /// + /// 电话 + /// + public string? tel { get; set; } + + /// + /// 出库组织id + /// + public string? outstockorg_id { get; set; } + + /// + /// 出库组织编号 + /// + public string? outstockorg_code { get; set; } + + /// + /// 出库组织名称 + /// + public string? outstockorg_name { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + + /// + /// 扩展字段 + /// + public string? extras { get; set; } + + /// + /// 时间戳 + /// + public string? time_stamp { get; set; } + + /// + /// 单据类型 + /// + public string? document_type { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + + /// + /// 流程任务Id + /// + public string? f_flowtaskid { get; set; } + + /// + /// 流程引擎Id + /// + public string? f_flowid { get; set; } + + /// + /// erp_pk + /// + public string? erp_pk { get; set; } + + /// + /// erp_bill_code + /// + public string? erp_bill_code { get; set; } + +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsTempCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsTempCode.cs index 1b4ddc83..ee0fdd64 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsTempCode.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsTempCode.cs @@ -111,5 +111,9 @@ public partial class WmsTempCode : BaseEntity /// 规格型号 /// public string? container_no { get; set; } + /// + /// 需求单据类型 + /// + public string? required_type { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs index 6360385c..497c2ca3 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs @@ -479,15 +479,18 @@ namespace Tnb.WarehouseMgr { // 排除电梯任务 其他任务取消时自动解锁起点和终点库位 - //int unlockStartRow = await _db.Updateable().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.startlocation_code).ExecuteCommandAsync(); - //if (unlockStartRow > 0) - //{ - // Logger.Information($"成功解锁起点库位{wmsDistaskH.startlocation_code}"); - //} - //else - //{ - // Logger.Information($"未成功解锁起点库位{wmsDistaskH.startlocation_code}"); - //} + if (wmsDistaskH.act_start_date == null) + { + int unlockStartRow = await _db.Updateable().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.startlocation_code).ExecuteCommandAsync(); + if (unlockStartRow > 0) + { + Logger.Information($"成功解锁起点库位{wmsDistaskH.startlocation_code}"); + } + else + { + Logger.Information($"未成功解锁起点库位{wmsDistaskH.startlocation_code}"); + } + } int unlockEndRow = await _db.Updateable().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.endlocation_code).ExecuteCommandAsync(); if (unlockEndRow > 0) @@ -502,8 +505,8 @@ namespace Tnb.WarehouseMgr int unlockCarryRow = await _db.Updateable().SetColumns(r => new WmsCarryH { is_lock = 0, - //location_id = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? WmsWareHouseConst.LOCATION_YCLBGWDRK : r.location_id, - //location_code = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? "YCLBGWDRK" : r.location_code + location_id = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? WmsWareHouseConst.LOCATION_YCLBGWDRK : r.location_id, + location_code = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? "YCLBGWDRK" : r.location_code }).Where(r => r.carry_code == wmsDistaskH.carry_code).ExecuteCommandAsync(); if (unlockCarryRow > 0) { @@ -557,15 +560,18 @@ namespace Tnb.WarehouseMgr { // 排除电梯任务 其他任务取消时自动解锁起点和终点库位 - //int unlockStartRow = await _db.Updateable().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.startlocation_code).ExecuteCommandAsync(); - //if (unlockStartRow > 0) - //{ - // Logger.Information($"成功起点解锁库位{wmsDistaskH.startlocation_code}"); - //} - //else - //{ - // Logger.Information($"未成功解锁起点库位{wmsDistaskH.startlocation_code}"); - //} + if (wmsDistaskH.act_start_date == null) + { + int unlockStartRow = await _db.Updateable().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.startlocation_code).ExecuteCommandAsync(); + if (unlockStartRow > 0) + { + Logger.Information($"成功起点解锁库位{wmsDistaskH.startlocation_code}"); + } + else + { + Logger.Information($"未成功解锁起点库位{wmsDistaskH.startlocation_code}"); + } + } int unlockEndRow = await _db.Updateable().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.endlocation_code).ExecuteCommandAsync(); if (unlockEndRow > 0) @@ -580,8 +586,8 @@ namespace Tnb.WarehouseMgr int unlockCarryRow = await _db.Updateable().SetColumns(r => new WmsCarryH { is_lock = 0, - //location_id = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? WmsWareHouseConst.LOCATION_YCLBGWDRK : wmsDistaskH.startlocation_id, - //location_code = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? "YCLBGWDRK" : wmsDistaskH.startlocation_code + location_id = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? WmsWareHouseConst.LOCATION_YCLBGWDRK : r.location_id, + location_code = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? "YCLBGWDRK" : r.location_code }).Where(r => r.carry_code == wmsDistaskH.carry_code).ExecuteCommandAsync(); if (unlockCarryRow > 0) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs index 7cfb770c..0ad98cda 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs @@ -437,7 +437,7 @@ namespace Tnb.WarehouseMgr try { await db.Ado.BeginTranAsync(); - WmsOutsourceOrderH wmsOutsourceOrderH = new WmsOutsourceOrderH(); + WmsOutsourceH wmsOutsourceOrderH = new WmsOutsourceH(); string Code = await _billRuleService.GetBillNumber("Purchase"); wmsOutsourceOrderH.outsource_order = Code; @@ -460,10 +460,10 @@ namespace Tnb.WarehouseMgr await db.Insertable(wmsOutsourceOrderH).ExecuteCommandAsync(); - List wmsOutsourceOrderDs = new List(); + List wmsOutsourceOrderDs = new List(); foreach (var detail in input.details) { - WmsOutsourceOrderD wmsOutsourceOrderD = new WmsOutsourceOrderD(); + WmsOutsourceD wmsOutsourceOrderD = new WmsOutsourceD(); wmsOutsourceOrderD.fk_wms_outsource_order_id = wmsOutsourceOrderH.id; wmsOutsourceOrderD.matcode = detail.material_code; @@ -721,6 +721,8 @@ namespace Tnb.WarehouseMgr wmsSaleH.bill_code = Code; wmsSaleH.erp_bill_code = input.bill_code; wmsSaleH.bill_type = "25103439022357";//销售出库单 + wmsSaleH.audit_status = 0; + wmsSaleH.generate_type = "1"; wmsSaleH.status = WmsWareHouseConst.BILLSTATUS_ADD_ID; wmsSaleH.warehouse_id = warehouse_outstock.id; wmsSaleH.customer_code = input.customer_code; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs b/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs index edc8da20..5b9ae3fd 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs @@ -174,10 +174,21 @@ namespace Tnb.WarehouseMgr public async Task GetYCLlocation() { List> LocationOutputss=new List>(); - var list =await _db.Queryable().Where(p=> p.wh_id == "1" && p.is_type == "0" && !p.location_code.Contains("-3")).OrderBy(p=>p.location_code).ToListAsync(); - var carrys=await _db.Queryable().ToListAsync(); - var carrycodes=await _db.Queryable().ToListAsync(); - var lastdata=string.Empty; + var list =await _db.Queryable().Where(p=> p.wh_id == "1" && p.is_type == "0" && !p.location_code.Contains("-3")) + .OrderBy(p=>p.location_code).ToListAsync(); + var carrys = await _db.Queryable().ToListAsync(); + var carrycodes = await _db.Queryable().ToListAsync(); + var mats = await _db.Queryable().ToListAsync(); + var qcresults = await _db.Queryable() + .InnerJoin((a, b) => a.barcode == b.barcode) + .InnerJoin((a, b, c) => c.id == b.require_id) + .Where((a, b, c) => !string.IsNullOrEmpty(c.qc_res)).Select((a,b,c)=>new + { + barcode = a.barcode, + qc_res = c.qc_res + }).ToListAsync(); + + var lastdata = string.Empty; List LocationOutputs = new List(); foreach (var data in list) { @@ -190,6 +201,7 @@ namespace Tnb.WarehouseMgr locationOutput.location_code = data.location_code.Replace("YCL-", ""); locationOutput.layers = data.layers; locationOutput.type = 0; + int status = 0; if (carrys.Where(p => p.location_id == data.id).Any()) { var carry= carrys.Where(p => p.location_id == data.id).First(); @@ -200,11 +212,69 @@ namespace Tnb.WarehouseMgr var carrycode = carrycodes.Where(p => p.carry_id == carry.id).First(); locationOutput.type = 2; locationOutput.material_code = carrycode.material_code; + locationOutput.barcode = carrycode.barcode; + + if (mats.Where(p => p.id == carrycode.material_id).Any()) + { + var mat = mats.Where(p => p.id == carrycode.material_id).First(); + locationOutput.material_name = mat.name; + } + locationOutput.code_batch = carrycode.code_batch; locationOutput.num = carrycode.codeqty; + + if (qcresults.Where(p => p.barcode == carrycode.barcode).Any()) + { + var qcresult = qcresults.Where(p => p.barcode == carrycode.barcode).First(); + string qc_result = qcresult.qc_res; + switch (qc_result) + { + case "await": + { + status = 3; + break; + } + case "vergeOk": + { + status = 4; + break; + } + case "no": + { + status = 5; + break; + } + case "ok": + { + status = 2; + break; + } + default: + { + status = 3; + break; + } + } + } + else + { + status = 3; + } + } + else + { + if (data.is_use == "1") + { + status = 1; + } + else + { + status = 0; + } } } lastdata = data.location_code; + locationOutput.status = status; LocationOutputs.Add(locationOutput); // 。。。。。。 @@ -243,6 +313,7 @@ namespace Tnb.WarehouseMgr if (carrycodes.Where(p => p.carry_id == carry.id).Any()) { var carrycode = carrycodes.Where(p => p.carry_id == carry.id).First(); + locationOutput.barcode = carrycode.barcode; locationOutput.type = 2; locationOutput.material_code = carrycode.material_code; locationOutput.num = carrycode.codeqty; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index a20835a2..d36b6cb1 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -3218,6 +3218,7 @@ namespace Tnb.WarehouseMgr { try { + await s_floor2CreatePretask.WaitAsync(); List wmsCarryCodes = _db.Queryable().Where(r => r.carry_id == rackid).ToList(); int move_num = 6; @@ -3225,17 +3226,16 @@ namespace Tnb.WarehouseMgr BasLocation startLocation = null; int index = 0; + await _db.Ado.BeginTranAsync(); foreach (WmsCarryD wmsCarryD in wmsCarryCodes) { - await s_floor2CreatePretask.WaitAsync(); //入库取终点 //出库起点 InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID, Size = 1 }; List endLocations = await InStockStrategy(inStockStrategyInput); if (endLocations.Count == 0) { - Logger.LogWarning("没有可用的入库库位"); - continue; + throw new Exception("没有可用的入库库位"); } // 每6个重新获取一次起点 @@ -3256,8 +3256,7 @@ namespace Tnb.WarehouseMgr bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, endLocation); if (!isMatch) { - Logger.LogWarning("库位与载具规格不匹配"); - continue; + throw new Exception("库位与载具规格不匹配"); } CommonCreatePretaskInput commonCreatePretaskInput = new CommonCreatePretaskInput(); @@ -3293,25 +3292,26 @@ namespace Tnb.WarehouseMgr await _db.Updateable().SetColumns(it => it.is_lock == 1).Where(r => r.id == endLocations[0].id).ExecuteCommandAsync(); await _db.Updateable().SetColumns(it => it.task_nums == it.task_nums + 1).Where(r => r.id == startLocation.id).ExecuteCommandAsync(); - Entities.Dto.Outputs.Result res = await CommonCreatePretask(commonCreatePretaskInput); + Entities.Dto.Outputs.Result res = await CommonCreatePretask(commonCreatePretaskInput, _db); if (res.code == JNPF.Common.Enums.HttpStatusCode.OK) { } else { - Logger.LogInformation($"【二楼kiva把料架送到下升降机后生成中储仓入库任务】 未成功生成预任务 起点{startLocation.location_code} 终点{endLocation.location_code} 料箱 {wmsCarryD.membercarry_code}"); + throw new Exception($"【二楼kiva把料架送到下升降机后生成中储仓入库任务】 未成功生成预任务 起点{startLocation.location_code} 终点{endLocation.location_code} 料箱 {wmsCarryD.membercarry_code}"); } index++; - s_floor2CreatePretask.Release(); } + await _db.Ado.CommitTranAsync(); return true; } catch(Exception ex) { Logger.LogInformation($"【二楼kiva把料架送到下升降机后生成中储仓入库任务】:{ex}"); s_floor2CreatePretask.Release(); + await _db.Ado.RollbackTranAsync(); return false; } finally diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index fb481876..fa462e07 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -176,6 +176,12 @@ namespace Tnb.WarehouseMgr throw new Exception($"托盘{input.carrycode}已绑定物料!"); } + var WmsTempCodes = await _db.Queryable().Where(it => input.details.Select(r => r.barcode).Contains(it.barcode)).ToListAsync(); + if (WmsTempCodes.DistinctBy(r => r.required_type).Count() == 1) + { + throw new Exception($"不能绑定多个不同类型单据打印的条码!:{string.Join(',', WmsTempCodes.DistinctBy(r => r.required_type))}"); + } + List WmsCarryCodes = new List(); foreach (var detail in input.details) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutsourceService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutsourceService.cs new file mode 100644 index 00000000..9e45c5c9 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutsourceService.cs @@ -0,0 +1,157 @@ +using System.Text; +using System.Text.RegularExpressions; +using JNPF.Common.Contracts; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Enums; +using JNPF.Common.Extension; +using JNPF.Common.Security; +using JNPF.FriendlyException; +using JNPF.Logging; +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 Npgsql; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.Common.Utils; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Consts; +using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Dto.Inputs; +using Tnb.WarehouseMgr.Entities.Dto.Outputs; +using Tnb.WarehouseMgr.Entities.Entity; +using Tnb.WarehouseMgr.Entities.Enums; +using Tnb.WarehouseMgr.Interfaces; + +namespace Tnb.WarehouseMgr +{ + /// + /// 委外收货订单 + /// + [OverideVisualDev(ModuleConsts.MODULE_WMSOUTSOURCEORDER_ID)] + public class WmsOutsourceService : BaseWareHouseService + { + private readonly ISqlSugarClient _db; + private readonly IUserManager _userManager; + private readonly IBillRullService _billRullService; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + public WmsOutsourceService( + ISqlSugarRepository repository, + IUserManager userManager, + IBillRullService billRullService, + IRunService runService, + IVisualDevService visualDevService) + { + _db = repository.AsSugarClient(); + _userManager = userManager; + _billRullService = billRullService; + _runService = runService; + _visualDevService = visualDevService; + } + + public override async Task ModifyAsync(WareHouseUpInput input) + { + if (input == null) + { + throw new ArgumentNullException(nameof(input)); + } + + //if (!isOk) + //{ + // throw Oops.Oh(ErrorCode.COM1001); + //} + } + + [HttpPost] + public async Task BarCodePrint(BarCodeInput input) + { + if (input == null) + { + throw new AppFriendlyException(nameof(input), 500); + } + List barcodes = new(); + try + { + await _db.Ado.BeginTranAsync(); + if (_db.Queryable().Where(it => input.BillId == it.require_id).Any()) + { + throw new AppFriendlyException("条码已生成", 500); + }; + WmsOutsourceD WmsOutsourceD = await _db.Queryable().Where(it => input.BillId == it.id).FirstAsync(); + WmsOutsourceH WmsOutsourceH = await _db.Queryable().Where(it => WmsOutsourceD.fk_wms_outsource_order_id == it.id).FirstAsync(); + + if (WmsOutsourceD.actual_quantity == 0) + { + throw new AppFriendlyException("到货数量为0,没有物料可以打印", 500); + }; + + List wmsTempCodes = new(); + decimal? minPacking = (await _db.Queryable().FirstAsync(it => it.id == WmsOutsourceD.matcode_id))?.minpacking; + if (!minPacking.HasValue || minPacking.Value <= 0) + { + throw new AppFriendlyException($"物料{WmsOutsourceD.matcode} {WmsOutsourceD.matcode_id} 包装数量为空或者等于0,无法打印!", 500); + }; + int codeNum = 0; + + if (minPacking.HasValue && minPacking.Value > 0) + { + int mod = (int)(WmsOutsourceD.actual_quantity % minPacking.Value); + codeNum = (int)(mod > 0 ? (WmsOutsourceD.actual_quantity / minPacking.Value) + 1 : WmsOutsourceD.actual_quantity / minPacking.Value); + + 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 watercode = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_OUTSOURCE_MAT_ENCODE); + + string code = $"WWSH{watercode}"; + WmsTempCode barCode = new() + { + material_id = WmsOutsourceD.matcode_id, + material_code = WmsOutsourceD.matcode, + barcode = code, + code_batch = WmsOutsourceD.code_batch, + material_specification = WmsOutsourceD.matspecification, + codeqty = minPacking, + unit_id = WmsOutsourceD.unit, + is_lock = 0, + is_end = 0, + require_id = WmsOutsourceD.id, + require_code = WmsOutsourceH.outsource_order, + create_id = _userManager.UserId, + create_time = DateTime.Now, + required_type = WmsWareHouseConst.BILLTYPE_OUTSOURCE_ID + }; + if (index == codeNum) + barCode.codeqty = mod == 0 ? minPacking : mod; + wmsTempCodes.Add(barCode); + } + await _db.Insertable(wmsTempCodes).ExecuteCommandAsync(); + } + await _db.Ado.CommitTranAsync(); + barcodes.AddRange(wmsTempCodes.Select(p => p.barcode).ToList()); + if (barcodes?.Count > 0) + { + var ip = _db.Queryable().Where(p => p.key == "printerip").FirstAsync().Result.value; + base.BarCodePrint(barcodes, 1, ip); + } + } + + + catch (Exception ex) + { + Logger.LogError($"【BarCodePrint】" + ex.Message); + Logger.LogError($"【BarCodePrint】" + ex.StackTrace); + await _db.Ado.RollbackTranAsync(); + throw; + } + } + } +} \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index 53bf3388..ef9b17b5 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -63,6 +63,19 @@ namespace Tnb.WarehouseMgr return await Task.FromResult(sss); } + public override async Task ModifyAsync(WareHouseUpInput input) + { + if (input == null) + { + throw new ArgumentNullException(nameof(input)); + } + + //if (!isOk) + //{ + // throw Oops.Oh(ErrorCode.COM1001); + //} + } + /// /// 采购收货 /// @@ -284,6 +297,7 @@ namespace Tnb.WarehouseMgr throw new AppFriendlyException("条码已生成", 500); }; WmsPurchaseD WmsPurchaseD = await _db.Queryable().Where(it => input.BillId == it.id).FirstAsync(); + WmsPurchaseH WmsPurchaseH = await _db.Queryable().Where(it => WmsPurchaseD.bill_id == it.id).FirstAsync(); if (WmsPurchaseD.purchase_arriveqty == 0) { @@ -324,9 +338,10 @@ namespace Tnb.WarehouseMgr is_lock = 0, is_end = 0, require_id = WmsPurchaseD.id, - require_code = WmsPurchaseD.id, + require_code = WmsPurchaseH.bill_code, create_id = _userManager.UserId, - create_time = DateTime.Now + create_time = DateTime.Now, + required_type = WmsWareHouseConst.BILLTYPE_PURCHASE_ID }; if (index == codeNum) barCode.codeqty = mod == 0 ? minPacking : mod; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatTransferinstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatTransferinstockService.cs new file mode 100644 index 00000000..5697026c --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatTransferinstockService.cs @@ -0,0 +1,158 @@ +using System.Text; +using System.Text.RegularExpressions; +using JNPF.Common.Contracts; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Enums; +using JNPF.Common.Extension; +using JNPF.Common.Security; +using JNPF.FriendlyException; +using JNPF.Logging; +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 Npgsql; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.Common.Utils; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Consts; +using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Dto.Inputs; +using Tnb.WarehouseMgr.Entities.Dto.Outputs; +using Tnb.WarehouseMgr.Entities.Entity; +using Tnb.WarehouseMgr.Entities.Enums; +using Tnb.WarehouseMgr.Interfaces; + +namespace Tnb.WarehouseMgr +{ + /// + /// 原材料调拨入库单 + /// + [OverideVisualDev(ModuleConsts.MODULE_WMSRAWMATTRANSFERINSTOCK_ID)] + public class WmsRawmatTransferinstockService : BaseWareHouseService + { + private readonly ISqlSugarClient _db; + private readonly IUserManager _userManager; + private readonly IBillRullService _billRullService; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + public WmsRawmatTransferinstockService( + ISqlSugarRepository repository, + IUserManager userManager, + IBillRullService billRullService, + IRunService runService, + IVisualDevService visualDevService) + { + _db = repository.AsSugarClient(); + _userManager = userManager; + _billRullService = billRullService; + _runService = runService; + _visualDevService = visualDevService; + } + + public override async Task ModifyAsync(WareHouseUpInput input) + { + if (input == null) + { + throw new ArgumentNullException(nameof(input)); + } + + //if (!isOk) + //{ + // throw Oops.Oh(ErrorCode.COM1001); + //} + } + + [HttpPost] + public async Task BarCodePrint(BarCodeInput input) + { + if (input == null) + { + throw new AppFriendlyException(nameof(input), 500); + } + List barcodes = new(); + try + { + await _db.Ado.BeginTranAsync(); + if (_db.Queryable().Where(it => input.BillId == it.require_id).Any()) + { + throw new AppFriendlyException("条码已生成", 500); + }; + WmsRawmatTransferinstockD WmsRawmatTransferinstockD = await _db.Queryable().Where(it => input.BillId == it.id).FirstAsync(); + WmsRawmatTransferinstockH WmsRawmatTransferinstockH = await _db.Queryable().Where(it => WmsRawmatTransferinstockD.bill_id == it.id).FirstAsync(); + + if (WmsRawmatTransferinstockD.actual_qty == 0) + { + throw new AppFriendlyException("到货数量为0,没有物料可以打印", 500); + }; + + List wmsTempCodes = new(); + decimal? minPacking = (await _db.Queryable().FirstAsync(it => it.id == WmsRawmatTransferinstockD.matcode_id))?.minpacking; + if (!minPacking.HasValue || minPacking.Value <= 0) + { + throw new AppFriendlyException($"物料{WmsRawmatTransferinstockD.matcode} {WmsRawmatTransferinstockD.matcode_id} 包装数量为空或者等于0,无法打印!", 500); + }; + int codeNum = 0; + + if (minPacking.HasValue && minPacking.Value > 0) + { + int mod = (int)(WmsRawmatTransferinstockD.actual_qty % minPacking.Value); + codeNum = (int)(mod > 0 ? (WmsRawmatTransferinstockD.actual_qty / minPacking.Value) + 1 : WmsRawmatTransferinstockD.actual_qty / minPacking.Value); + + 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 watercode = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_TRANSFER_RAWMAT_ENCODE); + + string code = $"YCLDBRK{watercode}"; + WmsTempCode barCode = new() + { + material_id = WmsRawmatTransferinstockD.matcode_id, + material_code = WmsRawmatTransferinstockD.matcode, + barcode = code, + code_batch = WmsRawmatTransferinstockD.code_batch, + material_specification = WmsRawmatTransferinstockD.matspecification, + codeqty = minPacking, + unit_id = WmsRawmatTransferinstockD.unit, + is_lock = 0, + is_end = 0, + require_id = WmsRawmatTransferinstockD.id, + require_code = WmsRawmatTransferinstockH.bill_code, + create_id = _userManager.UserId, + create_time = DateTime.Now, + required_type = WmsWareHouseConst.BILLTYPE_RAWMATTRANSFERINSTOCK_ID + }; + if (index == codeNum) + barCode.codeqty = mod == 0 ? minPacking : mod; + wmsTempCodes.Add(barCode); + } + await _db.Insertable(wmsTempCodes).ExecuteCommandAsync(); + } + await _db.Ado.CommitTranAsync(); + barcodes.AddRange(wmsTempCodes.Select(p => p.barcode).ToList()); + if (barcodes?.Count > 0) + { + var ip = _db.Queryable().Where(p => p.key == "printerip").FirstAsync().Result.value; + base.BarCodePrint(barcodes, 1, ip); + } + } + + + catch (Exception ex) + { + Logger.LogError($"【BarCodePrint】" + ex.Message); + Logger.LogError($"【BarCodePrint】" + ex.StackTrace); + await _db.Ado.RollbackTranAsync(); + throw; + } + } + + } +} \ No newline at end of file