diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index e2431145..1bc003b7 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs @@ -2390,6 +2390,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA WmsCarryH wmsCarryH = items[0]; + if (wmsCarryH.carry_status == "0") + { + LoggerFloor4DMJ2MJX.LogWarning($"【四楼待灭菌仓到灭菌线】 载具{wmsCarryH.carry_code}状态为空闲,而当前业务中载具应该为占用状态,请检查数据"); + break; + } + //锁定起点库位 await db_Floor4DMJ2MJX.Updateable().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == wmsCarryH.location_id).ExecuteCommandAsync(); //锁定终点库位 @@ -2501,6 +2507,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA LoggerFloor4MJX2MJC.LogWarning($"【四楼灭菌线到解析仓】 托盘号{carry_code}在系统中不存在"); continue; } + if (wmsCarryH.carry_status == "0") + { + LoggerFloor4DMJ2MJX.LogWarning($"【四楼灭菌线到解析仓】 载具{wmsCarryH.carry_code}状态为空闲,而当前业务中载具应该为占用状态,请检查数据"); + break; + } //锁定起点库位 await db_Floor4MJX2MJC.Updateable().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == startlocation.id).ExecuteCommandAsync(); //锁定终点库位 @@ -2634,7 +2645,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA await semaphoreSlim_CPK.WaitAsync(); WmsCarryH wmsCarryH = await db_Floor4DMC2CPK.Queryable().Where(r => r.id == wmsSterilizationInstockH.carry_id).FirstAsync(); - + if (wmsCarryH.carry_status == "0") + { + LoggerFloor4DMJ2MJX.LogWarning($"【四楼灭菌仓到成品库】 载具{wmsCarryH.carry_code}状态为空闲,而当前业务中载具应该为占用状态,请检查数据"); + break; + } if (wmsCarryH.location_id != wmsSterilizationInstockH.location_id) { LoggerFloor4DMC2CPK.LogWarning($"【四楼灭菌仓到成品库】载具{wmsCarryH.carry_code}实际位置与灭菌入库记录位置不一致"); diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs index e56c9c70..c9a653eb 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs @@ -119,7 +119,11 @@ public class ModuleConsts /// /// 模块标识-载具更换 /// - public const string MODULE_WMSCARRYREPLACE_ID = "26188532491557";//26188532491557 + public const string MODULE_WMSCARRYREPLACE_ID = "26188532491557"; + /// + /// 模块标识-盘点 + /// + public const string MODULE_WmsInventorycheck_ID = "37804588973589"; /// /// 模块标识-人工扫码入库记录 todo /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsInventorycheckSubmitInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsInventorycheckSubmitInput.cs new file mode 100644 index 00000000..607a6067 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsInventorycheckSubmitInput.cs @@ -0,0 +1,29 @@ +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 WmsInventorycheckSubmitInput + { + public string erp_line_pk { get; set; } + + public List details { get; set; } + } + + public class WmsInventorycheckSubmitDetailInput + { + public string carry_code { get; set; } + + public string material_id { get; set; } + + public string code_batch { get; set; } + + public string actual_qty { get; set; } + + public string location_id { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 53bea1a5..7ba0305c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -3140,20 +3140,37 @@ namespace Tnb.WarehouseMgr await db.Updateable() .SetColumns(x => x.carry_status == carryStatus) - .Where(x => clearCarryIds.Contains(x.id)) - .ExecuteCommandAsync(); - Logger.Information($"【TaskComplate】 更新载具状态 {JsonConvert.SerializeObject(clearCarryIds)}成功"); - - await db.Updateable() .SetColumns(x => x.is_check == isCheck) .Where(x => clearCarryIds.Contains(x.id)) .ExecuteCommandAsync(); - Logger.Information($"【TaskComplate】 更新载具检验 {JsonConvert.SerializeObject(clearCarryIds)}成功"); //await QTRK2BIP(dt, db); // require_code是任务单 //string mo_task_code = dt.require_code; } + else if (dt.biz_type ==WmsWareHouseConst.BIZTYPE_WMSMATERIALTRANSFER_ID)//长管签收 + { + //自动签收投料更新载具状态 + WmsCarryH carry = await db.Queryable().SingleAsync(x => x.id == dt.carry_id); + List clearCarryIds = new List(); + clearCarryIds.Add(carry.id); + List memberCarryIds = new List(); + if (carry.carrystd_id == WmsWareHouseConst.CARRY_ZYXCSTD_ID || + carry.carrystd_id == WmsWareHouseConst.CARRY_ZYLJSTD_ID) + { + } + else + { + memberCarryIds = await db.Queryable().Where(x=>x.carry_id==carry.id).Select(x=>x.membercarry_id).ToListAsync(); + clearCarryIds.AddRange(memberCarryIds); + } + + await db.Updateable() + .SetColumns(x => x.carry_status == carryStatus) + .SetColumns(x => x.is_check == isCheck) + .Where(x => clearCarryIds.Contains(x.id)) + .ExecuteCommandAsync(); + } else if (dt.biz_type == "erp_qtrk") { //await QTRK2BIP(dt, db); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInventorycheckService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInventorycheckService.cs new file mode 100644 index 00000000..e6939215 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInventorycheckService.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Core.Manager; +using JNPF.Common.Enums; +using JNPF.EventBus; +using JNPF.FriendlyException; +using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Npgsql; +using SqlSugar; +using Tnb.BasicData.Interfaces; +using Tnb.ProductionMgr.Interfaces; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Consts; +using Tnb.WarehouseMgr.Entities.Dto.Inputs; +using Tnb.WarehouseMgr.Entities.Entity; +using Tnb.WarehouseMgr.Entities.Enums; +using Tnb.WarehouseMgr.Interfaces; + +namespace Tnb.WarehouseMgr +{ + [OverideVisualDev(ModuleConsts.MODULE_WmsInventorycheck_ID)] + public class WmsInventorycheckService : BaseWareHouseService + { + private readonly ISqlSugarClient _db; + private readonly IDictionaryDataService _dictionaryDataService; + private readonly IUserManager _userManager; + private readonly IWareHouseService _wareHouseService; + private readonly IBillRullService _billRullService; + private readonly IPrdInstockService _prdInstockService; + private readonly IThirdApiRecordService _thirdApiRecordService; + private static Dictionary _dicBillCodes = new(); + public WmsInventorycheckService( + ISqlSugarRepository repository, + IDictionaryDataService dictionaryDataService, + IUserManager userManager, + IBillRullService billRullService, + IWareHouseService wareHouseService, + IPrdInstockService prdInstockService, + IThirdApiRecordService thirdApiRecordService, + IEventPublisher eventPublisher + ) + { + _db = repository.AsSugarClient(); + _dictionaryDataService = dictionaryDataService; + _userManager = userManager; + _billRullService = billRullService; + _wareHouseService = wareHouseService; + _thirdApiRecordService = thirdApiRecordService; + _prdInstockService = prdInstockService; + } + + /// + /// 盘点单提交 + /// + /// + /// + [HttpPost] + public async Task Submit(WmsInventorycheckSubmitInput input) + { + try + { + + + return await ToApiResult(HttpStatusCode.OK, "成功"); + } + catch (PostgresException ex) + { + Logger.LogError(ex.Message); + Logger.LogError(ex.StackTrace); + throw new AppFriendlyException($"{ex.Message}", 500); + } + catch (Exception ex) + { + Logger.LogInformation(ex.Message); + Logger.LogInformation(ex.StackTrace); + return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message); + } + } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs index a5e2f4c5..4a1d98ae 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs @@ -2606,6 +2606,8 @@ namespace Tnb.WarehouseMgr OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(moTask.workstation_id, DictConst.RegionCategoryWorkshopCode); List insertHList = new List(); List insertDList = new List(); + List insertFHList = new List(); + List insertFDList = new List(); string orgId = WmsWareHouseConst.AdministratorOrgId; // string userId = moTask.worker_id; string userId = WmsWareHouseConst.AdministratorUserId; @@ -2635,6 +2637,26 @@ namespace Tnb.WarehouseMgr org_id = orgId }; insertHList.Add(prdMaterialReceiptH); + + string feedCode = await _billRullService.GetBillNumber(CodeTemplateConst.FEEDING_CODE); + PrdFeedingH prdFeedingH = new PrdFeedingH() + { + code = feedCode, + station_id = moTask.workstation_id, + mo_task_id = moTask.id, + process_id = moTask.process_id, + // equip_id = input.equip_id, + workshop_id = workshop?.Id, + carry_id = carry.id, + workline_id = moTask.workline_id, + carry_code = carry.carry_code, + // remark = input.remark, + mbom_process_id = moTask.mbom_process_id, + create_id = userId, + create_time = DateTime.Now, + org_id = orgId + }; + insertFHList.Add(prdFeedingH); List wmsCarryCodes = await _db.Queryable().Where(x => x.carry_id == carry.id).ToListAsync(); if (wmsCarryCodes != null && wmsCarryCodes.Count > 0) @@ -2643,7 +2665,7 @@ namespace Tnb.WarehouseMgr foreach (var item in wmsCarryCodes) { - insertDList.Add(new PrdMaterialReceiptD + PrdMaterialReceiptD dItem = new PrdMaterialReceiptD { material_receipt_id = prdMaterialReceiptH.id, material_id = item.material_id, @@ -2659,6 +2681,20 @@ namespace Tnb.WarehouseMgr supplier_id = item.supplier_id, instock_time = item.instock_time, // check_conclusion = item.check_conclusion, + }; + insertDList.Add(dItem); + + insertFDList.Add(new PrdFeedingD + { + feeding_id = prdFeedingH.id, + material_receipt_detail_id = dItem?.id, + material_id = item.material_id, + num = item.codeqty, + batch = item.code_batch, + unit_id = item.unit_id, + carry_id = carry.id, + status = "0", + use_num = 0, }); } } @@ -2666,6 +2702,24 @@ namespace Tnb.WarehouseMgr { throw Oops.Bah("未找到物料明细"); } + + if (carry.carrystd_id == WmsWareHouseConst.CARRY_ZYXCSTD_ID || carry.carrystd_id == WmsWareHouseConst.CARRY_ZYLJSTD_ID) + { + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbindWithoutTran(new CarryCodeUnbindInput() + { + carry_id = carry.id + },_db); + + + if (result.code != HttpStatusCode.OK) + { + throw Oops.Bah(result.msg); + } + + //deleteCarryCodeIds.Add(carry.id); + // int row = await db.Deleteable().Where(r => r.carry_id == carry.id).ExecuteCommandAsync(); + // Log.Information($"载具{carry.id}已解绑,解绑条数{row}"); + } } @@ -2676,7 +2730,9 @@ namespace Tnb.WarehouseMgr int row1 = await _db.Insertable(insertHList).ExecuteCommandAsync(); int row2 = await _db.Insertable(insertDList).ExecuteCommandAsync(); - if (row1 <= 0 || row2 <= 0) + int row3 = await _db.Insertable(insertFHList).ExecuteCommandAsync(); + int row4 = await _db.Insertable(insertFDList).ExecuteCommandAsync(); + if (row1 <= 0 || row2 <= 0 || row3<=0 || row4<=0) { throw Oops.Bah(ErrorCode.COM1000); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs index 40e58ff2..85e33fb6 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs @@ -198,8 +198,9 @@ namespace Tnb.WarehouseMgr } await _db.Ado.BeginTranAsync(); //入库取终点 //出库起点 - InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_MJC_ID, Size = 1 }; + InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_MJC_ID, Size = 9999 }; List endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); + endLocations = endLocations.Where(r => r.location_code.Contains("MJWC-C")).ToList(); if (endLocations.Count == 0) { throw new AppFriendlyException("没有可用的入库库位", 500); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs index 49a76303..a0b40cd0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs @@ -218,11 +218,14 @@ namespace Tnb.WarehouseMgr } IEnumerable result = null; - + result = await _db.Queryable() .InnerJoin((a, b) => a.id == b.bill_d_id) .InnerJoin((a, b, c) => a.warehouse_id == c.id) - .Select((a,b,c) => new + .InnerJoin((a, b, c, d) => b.material_id == d.id) + .WhereIF(!string.IsNullOrEmpty(code_batch), (a, b, c, d) => b.code_batch.Contains(code_batch)) + .WhereIF(!string.IsNullOrEmpty(material_specification), (a, b, c, d) => b.material_specification.Contains(material_specification)) + .Select((a, b, c) => new { act_start_date = a.act_start_date, act_end_date = a.act_end_date,