| | |
| | | using Tiger.Model.Sharetronic.Shelf; |
| | | using Tiger.Business.WMS.Sharetronic.Shelf; |
| | | using Tiger.Model.Entitys.MES.U9C; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using Tiger.Business.WMS.Common; |
| | | using Tiger.Model.Base; |
| | | |
| | | namespace Tiger.Business.WMS.Transaction |
| | | { |
| | |
| | | public IOut_BIZ_WMS_PREP Init(string id, string userCode, string apiHost, string orgCode) |
| | | { |
| | | base.Init(id, userCode, apiHost, orgCode); |
| | | CurPREP = new(MainDB, userCode, orgCode); |
| | | Logger.Console.Info($"Start {this.GetType().Name} Transaction[ID: {TransID}]"); |
| | | return this; |
| | | } |
| | | |
| | | #region Propertys & Variables |
| | | |
| | | private Preparation CurPREP; |
| | | #endregion |
| | | |
| | | #region Functions |
| | |
| | | var action = new ApiAction<ScanOutput>(new ScanOutput()); |
| | | try |
| | | { |
| | | if (input.SN.IsNullOrEmpty()) |
| | | |
| | | if (input.Command == "ScanOrder") |
| | | { |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L("条码不能为空"); |
| | | action.LocaleMsg = Biz.L("WMS.Default.ScanItem.SnEmptyFailure"); |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | action = await ScanOrder(input); |
| | | } |
| | | //判断扫描的是否货架 |
| | | var whUnit = await MainDB.Queryable<V_WH_UNIT>().Where(t => (t.SHELF_CODE.ToUpper() == input.SN || t.LOCATION_CODE.ToUpper() == input.SN) && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync(); |
| | | //if (string.IsNullOrEmpty(CurScanShelf?.ShelfCode)) |
| | | if (!whUnit.IsNullOrEmpty() || string.IsNullOrEmpty(CurScanShelf?.ShelfCode)) |
| | | else |
| | | { |
| | | action = await ScanShelf(input.SN, whUnit); |
| | | } |
| | | else//扫描物料并复核 |
| | | { |
| | | action = await ScanItem(input); |
| | | if (input.SN.IsNullOrEmpty()) |
| | | { |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L("条码不能为空"); |
| | | action.LocaleMsg = Biz.L("WMS.Default.ScanItem.SnEmptyFailure"); |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | //判断扫描的是否货架 |
| | | var whUnit = await MainDB.Queryable<V_WH_UNIT>().Where(t => (t.SHELF_CODE.ToUpper() == input.SN || t.LOCATION_CODE.ToUpper() == input.SN) && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync(); |
| | | //if (string.IsNullOrEmpty(CurScanShelf?.ShelfCode)) |
| | | if (!whUnit.IsNullOrEmpty() || string.IsNullOrEmpty(CurScanShelf?.ShelfCode)) |
| | | { |
| | | action = await ScanShelf(input.SN, whUnit); |
| | | } |
| | | else//扫描物料并复核 |
| | | { |
| | | action = await ScanItem(input); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.Scan.ScanException", input.SN)); |
| | | } |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 扫描下架单据号码 |
| | | /// </summary> |
| | | public async Task<ApiAction<ScanOutput>> ScanOrder(BaseInput input) |
| | | { |
| | | var action = new ApiAction<ScanOutput>(new ScanOutput()); |
| | | try |
| | | { |
| | | var inputOrder = input?.Data?.JsonToObject<BIZ_WMS_PREP>(); |
| | | if ((inputOrder?.BIZ_TYPE).IsNullOrEmpty() || (inputOrder?.SOURCE_ORDER ?? "").IsNullOrEmpty()) |
| | | { |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L($"请选择正确的备料任务类型和单号"); |
| | | action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.ScanOrder.InputOrderIsNull"); |
| | | return action; |
| | | } |
| | | if (!CurPREP.PrepOrder.IsNullOrEmpty() && inputOrder.BIZ_TYPE != CurPREP.PrepOrder.BIZ_TYPE) |
| | | { |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L($"当前备料任务[{0}]的业务类型为{1},如需切换备料业务,请退出后重新选择"); |
| | | action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.ScanOrder.BizTypeError", CurPREP.PrepOrder.ORDER_NO, CurPREP.PrepOrder.BIZ_TYPE.GetEnumDesc<BIZ_WMS_PREP.BIZ_TYPEs>()); |
| | | return action; |
| | | } |
| | | |
| | | if (CurPREP.PrepOrder.IsNullOrEmpty() || !CurPREP.PrepOrder.SourceOrders.Any(q => q.SOURCE_ORDER == inputOrder.SOURCE_ORDER)) |
| | | { |
| | | action = CurPREP.AddOrder(inputOrder.BIZ_TYPE.GetEnum<BIZ_WMS_PREP.BIZ_TYPEs>(), inputOrder.SOURCE_CODE); |
| | | } |
| | | else |
| | | { |
| | | //action.LocaleMsg = Biz.L($"当前备料任务[{0}]已包含单据[{1}],无需重复操作"); |
| | | action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.ScanOrder.Repeat", CurPREP.PrepOrder.ORDER_NO, inputOrder.SOURCE_ORDER); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | //取消当前操作 |
| | | ResetScan(); |
| | | //action.CatchExceptionWithLog(ex, $"备料任务扫描单据异常(Data: {0})"); |
| | | action.CatchExceptionWithLog(ex, Biz.L("WMS.Out_BIZ_WMS_PREP.ScanOrderException", input?.Data)); |
| | | } |
| | | return action; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | base.ResetScan(); |
| | | ResetScanInfo(); |
| | | CurPREP = new(MainDB, UserCode, OrgCode); |
| | | CurScanShelf = null; |
| | | } |
| | | |