diff --git a/ZR.Service/mes/wms/WmOutOrderService.cs b/ZR.Service/mes/wms/WmOutOrderService.cs index 29d953a0..1f17c5b3 100644 --- a/ZR.Service/mes/wms/WmOutOrderService.cs +++ b/ZR.Service/mes/wms/WmOutOrderService.cs @@ -446,8 +446,11 @@ namespace ZR.Service.mes.wms { foreach (var item in doMaterialOut.PatchCode) { - //TODO 保证 同一出货单下 同一物料下最早批次 + /* + * + * #region 保证 同一出货单下 同一物料下最早批次 // 取出同一出货单下 同一物料下 未满箱的最早批次 + string short_patch = item.Split("_")[0]; WmOutOrderPlan plan_item = Context.Queryable() .Where(it => it.FkOutOrderId == shipnumber) @@ -467,58 +470,47 @@ namespace ZR.Service.mes.wms } if (plan_earliest.Id == plan_item.Id) { + #endregion + + + */ - // TODO 每次出库要出库计划累加 - Context.Updateable() + // TODO 每次出库要出库计划累加 + + Context.Updateable() .SetColumns(it => it.ReceivedPackNum == it.ReceivedPackNum + 1) .Where(it => it.FkOutOrderId == shipnumber) .Where(it => it.Patchcode == item) .ExecuteCommand(); - WmGoodsOutRecord record = new WmGoodsOutRecord(); - record.Id = SnowFlakeSingle.Instance.NextId().ToString(); - - WmGoodsNowProduction nowProduction = Context.Queryable() - .Where(it => it.PackageCodeClient == item).First(); - - if (nowProduction != null) - { - record.FkNowProductionId = nowProduction.Id; - record.PackageCodeClient = nowProduction.PackageCodeClient; - record.PackageCode = nowProduction.PackageCode; - record.PackageCodeOriginal = nowProduction.PackageCodeOriginal; - record.LocationCode = nowProduction.LocationCode; - record.Partnumber = nowProduction.Partnumber; - record.GoodsNumLogic = nowProduction.GoodsNumLogic; - record.GoodsNumAction = nowProduction.GoodsNumAction; - record.EntryWarehouseTime = nowProduction.EntryWarehouseTime; - record.OutTime = DateTime.Now; - record.CreatedTime = DateTime.Now; - record.CreatedBy = Createby; - record.FkOutOrderId = shipnumber; - sum_insert = Context.Insertable(record).ExecuteCommand(); - sum_delete += Context.Deleteable() - .Where(it => it.PackageCodeClient == item) - .ExecuteCommand(); - } - - - } - else - { - // 不在最早批次内 - return (200, 200); - - } + WmGoodsOutRecord record = new WmGoodsOutRecord(); + record.Id = SnowFlakeSingle.Instance.NextId().ToString(); + WmGoodsNowProduction nowProduction = Context.Queryable() + .Where(it => it.PackageCodeClient == item).First(); + if (nowProduction != null) + { + record.FkNowProductionId = nowProduction.Id; + record.PackageCodeClient = nowProduction.PackageCodeClient; + record.PackageCode = nowProduction.PackageCode; + record.PackageCodeOriginal = nowProduction.PackageCodeOriginal; + record.LocationCode = nowProduction.LocationCode; + record.Partnumber = nowProduction.Partnumber; + record.GoodsNumLogic = nowProduction.GoodsNumLogic; + record.GoodsNumAction = nowProduction.GoodsNumAction; + record.EntryWarehouseTime = nowProduction.EntryWarehouseTime; + record.OutTime = DateTime.Now; + record.CreatedTime = DateTime.Now; + record.CreatedBy = Createby; + record.FkOutOrderId = shipnumber; + sum_insert = Context.Insertable(record).ExecuteCommand(); + sum_delete += Context.Deleteable() + .Where(it => it.PackageCodeClient == item) + .ExecuteCommand(); } - - - - } } return (sum_delete, sum_insert); @@ -600,13 +592,44 @@ namespace ZR.Service.mes.wms // 4.获取出库单号对应的出库计划 List orderPlans = Generate_outorderplan(shipment_num); // 5.配对是否符合出库条件 - foreach (var orderPlan in orderPlans) + //foreach (var orderPlan in orderPlans) + //{ + // // 存在匹配条件: 箱标签批次号包含计划短批次号 + // if (orderPlan != null && resultionPackage.PatchCode.Contains(orderPlan.Patchcode_short)) + // { + // return "ok"; + // } + //} + // 5. 确保出最早批次 + string short_path = resultionPackage.PatchCode.Split('_')[0]; + + WmOutOrderPlan plan_item = Context.Queryable() + .Where(it => it.FkOutOrderId == shipment_num) + .Where(it => it.Patchcode == short_path) + .OrderBy(it => it.Outorder) + .First(); + + if (plan_item != null) { - // 存在匹配条件: 箱标签批次号包含计划短批次号 - if (orderPlan != null && resultionPackage.PatchCode.Contains(orderPlan.Patchcode_short)) + var plan_earliest = Context.Queryable() + .Where(it => it.FkOutOrderId == shipment_num) + .Where(it => it.MaterialCode == plan_item.MaterialCode) + .Where(it => it.PackageNum > it.ReceivedPackNum) + .OrderBy(it => it.Outorder) + .First(); + //已经出库完成,没有可以出库的了 + if (plan_earliest == null) + { + return "此物料已经全部出库完成,无法继续出库"; + } + if (plan_earliest.Id == plan_item.Id) { return "ok"; } + else + { + return "不是此物料最早批次,无法出库"; + } } // 6 .还差一个 数量超过要出库的箱子 return "此箱标签不可出库,批次号不在出库单计划内!请检查出库单计划!";