| | |
| | | using System.Diagnostics; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Tiger.Business.WMS.Extensions; |
| | | using Tiger.Business.WMS.Transaction; |
| | | using Tiger.IBusiness; |
| | | using Tiger.Model; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using Tiger.Model.Extensions; |
| | | |
| | | namespace Tiger.Business.WMS.Common |
| | | { |
| | | |
| | | /// <summary> |
| | | /// 备料任务单据 |
| | | /// </summary> |
| | |
| | | |
| | | #region Propertys & Variables |
| | | private static object AddOrderLock { get; } = new object(); |
| | | private static object AddBatchLock { get; } = new object(); |
| | | public DbClient MainDB { get; set; } |
| | | public string UserCode { get; set; } |
| | | public string OrgCode { get; set; } |
| | | public BIZ_WMS_PREP Order { get; set; } |
| | | public BIZ_WMS_PREP.BIZ_TYPEs BizType => Order.BIZ_TYPE.GetEnum<BIZ_WMS_PREP.BIZ_TYPEs>(); |
| | | public SuggestOption Option { get; set; } |
| | | #endregion Propertys & Variables |
| | | |
| | | #region Functions |
| | |
| | | }; |
| | | } |
| | | } |
| | | //合并发料只适用于包装车间工单发料,雅达包装车间编码:1002310010030758 |
| | | else if (Order.WS_CODE != "1002310010030758") |
| | | { |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L("备料任务[{0}]不是包装车间工单发料,无法合并单据发料"); |
| | | action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.AddOrder.PrepNot1002310010030758", Order.ORDER_NO); |
| | | return action; |
| | | } |
| | | |
| | | if (!src.IsNullOrEmpty() && src.ORDER_NO != Order.ORDER_NO) |
| | | { |
| | | action.IsSuccessed = false; |
| | |
| | | action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.AddOrder.NoFound", orderNo, src.ORDER_NO, Order.ORDER_NO); |
| | | return action; |
| | | } |
| | | |
| | | // 查询单据明细,并合并到备料单的备料明细中 |
| | | var dtls = bizType.GetPickList(orderNo); |
| | | |
| | | // 查询单据明细,并合并到备料单的备料明细中 |
| | | var dtls = bizType.GetPickList(orderNo); |
| | | if (dtls.Sum(q => q.QTY_ACT_REQ) <= 0) |
| | | { |
| | | action.IsSuccessed = false; |
| | |
| | | action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.AddOrder.NoNeedPrep", orderNo); |
| | | return action; |
| | | } |
| | | //合并发料只适用于包装车间工单发料 |
| | | if (src.IsNullOrEmpty() && Order.BIZ_TYPE == BIZ_WMS_PREP.BIZ_TYPEs.WorkOrder.GetValue()) |
| | | { |
| | | var wo = Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == orderNo).First(); |
| | | //雅达包装车间编码:1002310010030758 |
| | | if (wo?.WS_CODE == "1002310010030758") |
| | | { |
| | | Order.WS_CODE = wo.WS_CODE; |
| | | } |
| | | else |
| | | { |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L("单据[{0}]不是包装车间工单,无法合并单据发料"); |
| | | action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.AddOrder.WoNot1002310010030758", orderNo); |
| | | return action; |
| | | } |
| | | } |
| | | |
| | | Order.SourceOrders = Order.SourceOrders ?? new(); |
| | | Order.SourceDetails = Order.SourceDetails ?? new(); |
| | | Order.Details = Order.Details ?? new(); |
| | | Order.Batchs = Order.Batchs ?? new(); |
| | | Order.SnList = Order.SnList ?? new(); |
| | | var srcOrder = new BIZ_WMS_PREP_SRC() |
| | | { |
| | |
| | | var srcInfo = Order.SourceOrders.Select(q => new { q.SOURCE_CODE, q.SOURCE_ORDER }).DistinctBy(q => q.SOURCE_ORDER).OrderBy(q => q.SOURCE_ORDER); |
| | | Order.SOURCE_CODE = string.Join(",", srcInfo.Select(q => q.SOURCE_CODE)); |
| | | Order.SOURCE_ORDER = string.Join(",", srcInfo.Select(q => q.SOURCE_ORDER)); |
| | | if (Order.CurBatch.IsNullOrEmpty()) |
| | | { |
| | | var bacth = new BIZ_WMS_PREP_BTH() |
| | | { |
| | | AUTH_ORG = OrgCode, |
| | | ORDER_NO = Order.ORDER_NO, |
| | | BATCH = Order.Batchs.Max(q => q.BATCH) + 1, |
| | | PREP_MODE = BIZ_WMS_PREP_BTH.PREP_MODEs.Whole.GetValue(), |
| | | DLVY_MODE = BIZ_WMS_PREP_BTH.DLVY_MODEs.Supply.GetValue(), |
| | | STATUS = BIZ_WMS_PREP_BTH.STATUSs.WaitPick.GetValue(), |
| | | CALL_TIME = DateTime.Now, |
| | | PRIORITY = 4, |
| | | }; |
| | | bacth.PLAN_TIME = bacth.CALL_TIME.AddHours(1); |
| | | Order.Batchs.Add(bacth); |
| | | } |
| | | |
| | | |
| | | //使用统一的事务DB对象 |
| | | var db = Biz.Db; |
| | | var dbTran = db.UseTran(() => |
| | | { |
| | | var o = db.Storageable(Order, UserCode).WhereColumns(t => new { t.ORDER_NO, t.GHOST_ROW }).ToStorage(); |
| | | o.AsInsertable.ExecuteCommand(); |
| | | o.AsUpdateable.IgnoreColumns(q => q.ID).UpdateColumns(q => new { q.SOURCE_CODE, q.SOURCE_ORDER, q.UPDATE_TIME, q.UPDATE_USER }).ExecuteCommand(); |
| | | o.AsUpdateable.IgnoreColumns(q => q.ID).UpdateColumns(q => new { q.WS_CODE, q.SOURCE_CODE, q.SOURCE_ORDER, q.UPDATE_TIME, q.UPDATE_USER }).ExecuteCommand(); |
| | | db.Storageable(Order.SourceOrders, UserCode).WhereColumns(t => new { t.ORDER_NO, t.SOURCE_ORDER, t.GHOST_ROW }).ToStorage().AsInsertable.ExecuteCommand(); |
| | | db.Storageable(Order.SourceDetails, UserCode).WhereColumns(t => new { t.ORDER_NO, t.ITEM_CODE, t.GHOST_ROW }).ToStorage().AsInsertable.ExecuteCommand(); |
| | | var d = db.Storageable(Order.Details, UserCode).WhereColumns(t => new { t.ORDER_NO, t.ITEM_CODE, t.GHOST_ROW }).ToStorage(); |
| | | d.AsInsertable.ExecuteCommand(); |
| | | d.AsUpdateable.IgnoreColumns(q => q.ID).UpdateColumns(q => new { q.QTY_REQ, q.UPDATE_TIME, q.UPDATE_USER }).ExecuteCommand(); |
| | | db.Storageable(Order.Batchs, UserCode).WhereColumns(t => new { t.ORDER_NO, t.BATCH, t.GHOST_ROW }).ToStorage().AsInsertable.ExecuteCommand(); |
| | | }); |
| | | if (dbTran.IsSuccess) |
| | | { |