diff --git a/BasicData/Tnb.BasicData/BasMbomService.cs b/BasicData/Tnb.BasicData/BasMbomService.cs index 787c8bbf..4183e0d3 100644 --- a/BasicData/Tnb.BasicData/BasMbomService.cs +++ b/BasicData/Tnb.BasicData/BasMbomService.cs @@ -26,7 +26,7 @@ namespace Tnb.BasicData [OverideVisualDev(ModelId)] public class BasMbomService : IBasMbomService, IOverideVisualDevService, IDynamicApiController, ITransient { - public const string ModelId = "25574817510421"; + public const string ModelId = "27204627275029"; private readonly ISqlSugarRepository _repository; private readonly DataBaseManager _dbManager; private readonly IDictionaryDataService _dictionaryDataService; diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptNewInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptNewInput.cs new file mode 100644 index 00000000..452fc14a --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MaterialReceiptNewInput.cs @@ -0,0 +1,27 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class MaterialReceiptNewInput + { + /// + /// 工位id + /// + public string station_id { get; set; } = string.Empty; + + /// + /// 任务单id + /// + public string? mo_task_id { get; set; } + + /// + /// 设备id + /// + public string? equip_id { get; set; } + + /// + /// 二维码信息 + /// + public string? carry_code { get; set; } + + public List>? details { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs index a2a6b049..cfc83410 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs @@ -98,6 +98,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// Nullable:True /// public int icmo_qty { get; set; } + + /// + /// 工位 + /// + public string? station { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs index 1763bbe3..8128efe1 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs @@ -78,5 +78,39 @@ public partial class PrdReport : BaseEntity /// 生产任务量 /// public int? icmo_qty { get; set; } + + /// + /// 批次 + /// + public string? batch { get; set; } + + /// + /// 设备id + /// + public string? equip_id { get; set; } + /// + /// 工位id + /// + public string? station { get; set; } + + /// + /// 生产bom工序id + /// + public string? mbom_process_id { get; set; } + + /// + /// 状态 0 未入库 1 已入库 + /// + public int status { get; set; } + + /// + /// 物料id + /// + public string? material_id { get; set; } + + /// + /// 物料单位 + /// + public string? unit_id { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs index 0cbfd649..c719944a 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs @@ -14,5 +14,12 @@ namespace Tnb.ProductionMgr.Interfaces /// /// public Task SaveData(MaterialReceiptInput input); + + /// + /// 保存数据 + /// + /// + /// + public Task SaveDataNew(MaterialReceiptNewInput input); } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index e45e0109..9e5a8039 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -4,6 +4,7 @@ using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Interfaces.System; using Microsoft.AspNetCore.Mvc; using Microsoft.ClearScript.Util.Web; @@ -13,6 +14,8 @@ using Tnb.ProductionMgr.Entities; using Tnb.ProductionMgr.Entities.Dto; using Tnb.ProductionMgr.Interfaces; using Tnb.ProductionMgr.Entities.Consts; +using Tnb.WarehouseMgr; +using Tnb.WarehouseMgr.Entities; namespace Tnb.ProductionMgr { @@ -26,16 +29,20 @@ namespace Tnb.ProductionMgr private readonly ISqlSugarRepository _repository; private readonly IUserManager _userManager; private readonly IBillRullService _billRullService; + private readonly WmsSignForDeliveryService _wmsSignForDeliveryService; + public PrdFeedingService( ISqlSugarRepository repository, IBillRullService billRullService, + WmsSignForDeliveryService wmsSignForDeliveryService, IUserManager userManager ) { _repository = repository; _userManager = userManager; + _wmsSignForDeliveryService = _wmsSignForDeliveryService; _billRullService = billRullService; } @@ -132,6 +139,131 @@ namespace Tnb.ProductionMgr await db.Insertable(list).ExecuteCommandAsync(); }); + + if (result.IsSuccess) + { + //签收后调用载具签收接口 + await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput() + { + org_id = _userManager.GetUserInfo().Result.organizeId, + create_id = _userManager.UserId, + carry_code = input.carry_code ?? "", + }); + } + + if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage); + return result.IsSuccess ? "签收成功" : result.ErrorMessage; + } + + [HttpPost] + public async Task SaveDataNew(MaterialReceiptNewInput input) + { + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + var moTask = await db.Queryable().FirstAsync(x => x.id == input.mo_task_id); + var parentMoTask = await db.Queryable().FirstAsync(x => x.id == moTask.parent_id); + var carry = await db.Queryable().SingleAsync(x => x.carry_code == input.carry_code); + var workline = await db.Queryable().SingleAsync(x => x.Id == parentMoTask.workline_id); + var workshop = await db.Queryable().SingleAsync(x=>x.Id==workline.ParentId); + var inputMaterials = await db.Queryable() + .Where(x => x.mbom_id == moTask.bom_id && x.mbom_process_id == moTask.mbom_process_id) + .Select(x=>x.material_id) + .ToListAsync(); + + + + string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE); + PrdFeedingH prdFeedingH = new PrdFeedingH() + { + code = code, + station_id = input.station_id, + mo_task_id = input.mo_task_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 = input.carry_code, + // remark = input.remark, + mbom_process_id = moTask.mbom_process_id, + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId + }; + + List list = new List(); + if (input.details != null && input.details.Count > 0) + { + foreach (var item in input.details) + { + if(!inputMaterials.Contains(item["material_id"])) + throw new Exception("该物料不是生产bom投入物料,不能签收"); + + var detail = await db.Queryable() + .Where(x => x.carry_id == carry.id && x.is_all_feeding == 0).FirstAsync(); + decimal num = Convert.ToDecimal(item["num"]); + list.Add(new PrdFeedingD + { + feeding_id = prdFeedingH.id, + material_receipt_detail_id = detail?.id, + material_id = item["material_id"], + num = num, + batch = item["batch"], + unit_id = item["unit_id"], + carry_id = carry.id, + status = "0", + use_num = 0, + }); + + if (detail != null) + { + if(detail.feeding_num + num > detail.num) + { + throw new Exception("投料数量不能大于签收数量"); + }else if (detail.feeding_num + num == detail.num) + { + await db.Updateable() + .SetColumns(x => x.feeding_num == x.feeding_num + num) + .SetColumns(x => x.is_all_feeding == 1) + .Where(x => x.id == detail.id) + .ExecuteCommandAsync(); + } + else + { + await db.Updateable() + .SetColumns(x => x.feeding_num == x.feeding_num + num) + .Where(x => x.id == detail.id) + .ExecuteCommandAsync(); + } + } + else + { + throw new Exception("没有签收单,无法投料"); + } + } + } + else + { + throw new Exception("没有签收物料"); + } + + + await db.Insertable(prdFeedingH).ExecuteCommandAsync(); + await db.Insertable(list).ExecuteCommandAsync(); + + }); + + if (result.IsSuccess) + { + //签收后调用载具签收接口 + await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput() + { + org_id = _userManager.GetUserInfo().Result.organizeId, + create_id = _userManager.UserId, + carry_code = input.carry_code ?? "", + }); + } if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage); return result.IsSuccess ? "签收成功" : result.ErrorMessage; diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index e19f083e..5e8a2a63 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -11,7 +11,7 @@ using Tnb.ProductionMgr.Interfaces; namespace Tnb.ProductionMgr { /// - /// mes入库申请 + /// mes生产入库申请 /// [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] [Route("api/[area]/[controller]/[action]")] diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 4ac5daf9..f73b3872 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -141,7 +141,7 @@ namespace Tnb.ProductionMgr { eqp_id = b.id, eqp_code = b.code, - eqp_type_code = SqlFunc.Subqueryable().Where(iit => iit.id == b.equip_type_id).Select(iit => iit.code), + eqp_type_code = SqlFunc.Subqueryable().Where(iit => iit.id == b.equip_type_id).Select(iit => iit.name), eqp_machine_num = b.eqp_machine_num, tonnage = b.tonnage, task_list_qty = SqlFunc.Subqueryable().Where(x => x.eqp_id == b.id).Count(), @@ -1254,16 +1254,24 @@ namespace Tnb.ProductionMgr { var row = -1; var report = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id); + var prdMoTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id); report = input.Adapt(); report.id = SnowflakeIdHelper.NextId(); report.reported_qty = input.reported_qty; report.create_id = _userManager.UserId; report.create_time = DateTime.Now; - + report.batch = input.mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString(); + report.equip_id = prdMoTask.eqp_id; + report.mbom_process_id = prdMoTask.mbom_process_id; + report.station = input.station; + report.status = 0; + report.material_id = prdMoTask.material_id; + report.unit_id = prdMoTask.unit_id; + row = await db.Insertable(report).ExecuteCommandAsync(); - var prdMoTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id); + if (prdMoTask.reported_work_qty == null) { await db.Updateable() diff --git a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj index 6316cd83..832c4f03 100644 --- a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj +++ b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj @@ -15,6 +15,7 @@ + diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs index 0afd2d19..e9d315a5 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs @@ -34,10 +34,12 @@ namespace Tnb.WarehouseMgr var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList(); foreach (var serviceType in serviceTypes) { - var callerName = serviceType.GetCustomAttribute()?.Name; - if (!callerName.IsNullOrEmpty()) + var callerName = serviceType.GetCustomAttribute()?.Name ?? string.Empty; + if (callerName.IsNullOrEmpty() && !serviceType.IsNull()) { - _stroageMap[callerName!] = (IWHStorageService)Activator.CreateInstance(serviceType)!; + var obj = Activator.CreateInstance(serviceType) as IWHStorageService; + if (obj == null) continue; + _stroageMap[callerName] = obj; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index bb4e1fd1..ae11f831 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -251,14 +251,13 @@ namespace Tnb.WarehouseMgr { var moveNum = itGroup.First().move_num; var items = itGroup.Adapt>(); - - items.ForEach(x => SnowflakeIdHelper.NextId()); items.ForEach(x => { + x.id = SnowflakeIdHelper.NextId(); x.status = WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID; x.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_TASK_EXECUTE_ENCODE).GetAwaiter().GetResult(); }); - var areaPreTasks = itGroup.ToList(); + if (moveNum == 1) { items.ForEach(x => @@ -269,6 +268,7 @@ namespace Tnb.WarehouseMgr } else if (moveNum > 1) { + var areaPreTasks = itGroup.ToList(); //搬运数量==预任务数,可以生成任务执行,为任务链 if (moveNum == areaPreTasks.Count) { @@ -296,7 +296,7 @@ namespace Tnb.WarehouseMgr { var curPreTaskCodes = preTaskCodes.FindAll(x => x.bill_id == disTask.pretask_id); var curDisTaskCodes = curPreTaskCodes.Adapt>(); - curPreTaskCodes.ForEach(x => + curDisTaskCodes.ForEach(x => { x.id = SnowflakeIdHelper.NextId(); x.bill_id = disTask.id; @@ -387,15 +387,16 @@ namespace Tnb.WarehouseMgr await _db.Updateable().SetColumns(it => new WmsDistaskH { status = WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID }).Where(it => input.disTaskIds.Contains(it.id)).ExecuteCommandAsync(); //清空载具库位数据 - var carryIds = await _db.Queryable().Where(it => input.disTaskIds.Contains(it.id)).Select(it => it.carry_id).ToListAsync(); - if (carryIds?.Count > 0) + var carryAndLocIds = await _db.Queryable().Where(it => input.disTaskIds.Contains(it.id)).Select(it => new { it.carry_id, it.startlocation_id }).ToListAsync(); + if (carryAndLocIds?.Count > 0) { + var carryIds = carryAndLocIds.Select(x => x.carry_id).ToList(); await _db.Updateable().SetColumns(it => new WmsCarryH { location_id = null, location_code = null }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync(); } - var startLocationIds = await _db.Queryable().Where(it => input.disTaskIds.Contains(it.id)).Select(it => it.startlocation_id).ToListAsync(); //更新起始库位,状态改为空闲、锁定状态,未锁定 - if (startLocationIds?.Count > 0) + if (carryAndLocIds?.Count > 0) { + var startLocationIds = carryAndLocIds.Select(x => x.startlocation_id).ToList(); await _db.Updateable().SetColumns(it => new BasLocation { is_use = ((int)EnumCarryStatus.空闲).ToString(), is_lock = 0 }).Where(it => startLocationIds.Contains(it.id)).ExecuteCommandAsync(); } @@ -440,13 +441,11 @@ namespace Tnb.WarehouseMgr var loc = await _db.Queryable().SingleAsync(it => it.id == multiList[i].endlocation_id); await _db.Updateable().SetColumns(it => new WmsCarryCode { warehouse_id = loc.wh_id, location_id = multiList[i].endlocation_id, location_code = multiList[i].endlocation_code }).Where(it => it.id == multiList[i].carry_id).ExecuteCommandAsync(); } - } } //更新库位信息,使用状态为 使用,锁定状态为未锁定 if (disTasks?.Count > 0) { - var destLocIds = disTasks.Select(it => it.endlocation_id).ToList(); var multis = disTasks.Select(it => (it.endlocation_id, it.carry_status)).ToList(); for (int i = 0; i < multis.Count; i++) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index bc7caca0..5219afc2 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -150,7 +150,7 @@ namespace Tnb.WarehouseMgr carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch }) .Select(x => { - WmsCarryMat? carryMat = x.FirstOrDefault()!; + WmsCarryMat? carryMat = x.FirstOrDefault(); carryMat.need_qty = x.Sum(d => d.need_qty); return carryMat; }) @@ -505,7 +505,7 @@ namespace Tnb.WarehouseMgr { outstockDs.ForEach(x => x.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID); await _db.Updateable(outstockDs).UpdateColumns(it => it.line_status).ExecuteCommandAsync(); - await _db.Updateable().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it=>it.id == outstock.id).ExecuteCommandAsync(); + await _db.Updateable().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == outstock.id).ExecuteCommandAsync(); GenPreTaskUpInput genPreTaskAfterUpInput = new(); genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList(); genPreTaskAfterUpInput.LocationIds = new HashSet(locIds).ToList(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs index a2c1a441..d1f52154 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs @@ -99,34 +99,37 @@ namespace Tnb.WarehouseMgr { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) + if (points?.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); if (points?.Count > 0) { - if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => { var sPoint = it.FirstOrDefault(); var ePoint = it.LastOrDefault(); - WmsPretaskH preTask = new(); - preTask.org_id = _userManager.User.OrganizeId; - preTask.startlocation_id = sPoint?.location_id!; - preTask.startlocation_code = sPoint?.location_code!; - preTask.endlocation_id = ePoint?.location_id!; - preTask.endlocation_code = ePoint?.location_code!; - preTask.start_floor = sPoint?.floor.ToString(); - preTask.end_floor = ePoint?.floor.ToString(); - preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); - preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; - preTask.biz_type = input.data[nameof(WmsPretaskH.biz_type)]?.ToString()!; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; - preTask.carry_id = input.data[nameof(preTask.carry_id)]?.ToString()!; - preTask.carry_code = input.data[nameof(preTask.carry_code)]?.ToString()!; - preTask.area_id = sPoint?.area_id!; - preTask.area_code = it.Key; - preTask.require_id = input.data[nameof(WmsHandleH.require_id)].ToString(); - preTask.require_code = input.data[nameof(WmsHandleH.require_code)]?.ToString()!; - preTask.create_id = _userManager.UserId; - preTask.create_time = DateTime.Now; + WmsPretaskH preTask = new() + { + org_id = _userManager.User.OrganizeId, + startlocation_id = sPoint?.location_id ?? "", + startlocation_code = sPoint?.location_code ?? "", + endlocation_id = ePoint?.location_id ?? "", + endlocation_code = ePoint?.location_code ?? "", + start_floor = sPoint?.floor.ToString(), + end_floor = ePoint?.floor.ToString(), + bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(), + status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID, + biz_type = input.data[nameof(WmsPretaskH.biz_type)]?.ToString() ?? "", + task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID, + carry_id = input.data[nameof(preTask.carry_id)]?.ToString() ?? "", + carry_code = input.data[nameof(preTask.carry_code)]?.ToString() ?? "", + area_id = sPoint?.area_id ?? "", + area_code = it.Key, + require_id = input.data[nameof(WmsHandleH.require_id)].ToString(), + require_code = input.data[nameof(WmsHandleH.require_code)]?.ToString(), + create_id = _userManager.UserId, + create_time = DateTime.Now, + }; + return preTask; }).ToList(); //生成预任务条码信息 @@ -221,7 +224,6 @@ namespace Tnb.WarehouseMgr { foreach (var jo in jArr.Children()) { - var materialId = jo.Value(nameof(WmsInstockCode.material_id)); var materialCode = jo.Value(nameof(WmsInstockCode.material_code)); var codeBatch = jo.Value(nameof(WmsInstockCode.code_batch)); var b = items.Find(x => x.material_code == materialCode && x.code_batch == codeBatch); @@ -229,7 +231,7 @@ namespace Tnb.WarehouseMgr { var c = DeepCopyHelper.DeepCopy(b); c.id = SnowflakeIdHelper.NextId(); - c.bill_d_id = instockDetails.Find(x => x.material_code == materialCode && x.code_batch == codeBatch)?.id!; + c.bill_d_id = b.id; c.barcode = jo.Value(nameof(WmsInstockCode.barcode))!; c.codeqty = jo.Value(nameof(WmsInstockCode.codeqty)); instockCOdes.Add(c); @@ -297,7 +299,7 @@ namespace Tnb.WarehouseMgr } } await _db.Updateable(instockDetails).ExecuteCommandAsync(); - var allInstockDetails = await _db.Queryable().Where(it=>it.bill_id ==input.requireId).ToListAsync(); + var allInstockDetails = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) { await _db.Updateable().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index cfc398cd..7b5c05af 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -21,6 +21,7 @@ using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; using Tnb.WarehouseMgr.Entities.Enums; using Tnb.WarehouseMgr.Interfaces; +using UAParser; namespace Tnb.WarehouseMgr { @@ -69,11 +70,19 @@ namespace Tnb.WarehouseMgr List carryMats = new(); List carryCodes = new(); List carryIds = new(); + + var whereExpr = Expressionable.Create() + .And((a, b, c) => a.is_lock == 0) + .And((a, b, c) => !string.IsNullOrEmpty(a.location_id)) + .And((a, b, c) => a.status == (int)EnumCarryStatus.占用); foreach (var os in setSortingDList) { + whereExpr.And((a, b, c) => b.material_id == os.material_id) + .And((a, b, c) => c.wh_id == os.warehouse_id) + .AndIF(!string.IsNullOrEmpty(os.code_batch), (a, b, c) => b.code_batch == os.code_batch); + var carryCodesPart = await _db.Queryable().InnerJoin((a, b) => a.id == b.carry_id).InnerJoin((a, b, c) => a.location_id == c.id) - .Where((a, b, c) => b.material_id == os.material_id && a.is_lock == 0 && !string.IsNullOrEmpty(a.location_id) && a.status == (int)EnumCarryStatus.占用 && c.wh_id == os.warehouse_id) - .WhereIF(!string.IsNullOrEmpty(os.code_batch), (a, b) => b.code_batch == os.code_batch) + .Where(whereExpr.ToExpression()) .Select() .ToListAsync(); if (carryCodesPart?.Count > 0) @@ -158,7 +167,7 @@ namespace Tnb.WarehouseMgr pretaskCodes.AddRange(curPreTaskCodes); } await _wareHouseService.GenPreTask(preTasks, pretaskCodes); - await _db.Updateable().SetColumns(it => new WmsSetsortingH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).ExecuteCommandAsync(); + await _db.Updateable().SetColumns(it => new WmsSetsortingH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it=> it.id == singleSorting.id).ExecuteCommandAsync(); GenPreTaskUpInput genPreTaskAfterUpInput = new(); genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList(); genPreTaskAfterUpInput.LocationIds = new HashSet(locIds).ToList();