| | |
| | | using Tiger.Business.WMS.Sharetronic.Shelf; |
| | | //using Microsoft.IdentityModel.Tokens; |
| | | using Tiger.Model.MES.Yada; |
| | | using static IronPython.Modules.PythonThread; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | |
| | | namespace Tiger.Business.WMS.Transaction |
| | | { |
| | |
| | | { |
| | | public IIn_Default Init(string id, string userCode, string apiHost, string orgCode) |
| | | { |
| | | base.Init(id, apiHost, userCode, orgCode); |
| | | base.Init(id, userCode, apiHost, orgCode); |
| | | Logger.Console.Info($"Start {this.GetType().Name} Transaction[ID: {TransID}]"); |
| | | return this; |
| | | } |
| | |
| | | catch (Exception ex) |
| | | { |
| | | //取消当前操作 |
| | | ResetScan(); |
| | | ResetTrans(); |
| | | //action.CatchExceptionWithLog(ex, $"扫描[{input.SN}]异常"); |
| | | action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.Scan.ScanException", input.SN)); |
| | | } |
| | |
| | | if (CurInvItem.IsNullOrEmpty()) |
| | | { |
| | | //解析条码 |
| | | Result<IInventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true); |
| | | Result<IInventory> result = GetInventory(input.SN, input.AuthOption, true); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | action.IsSuccessed = false; |
| | | action.LocaleMsg = result.LocaleMsg; |
| | | return action; |
| | | } |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | var inv = result.Data as Inventory; |
| | | |
| | | //验证条码是否正确 |
| | |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L("状态[{0}]异常,请重新扫描"); |
| | | action.LocaleMsg = Biz.L("WMS.Default.ScanItem.StatusException", string.Join(',', inv.StatusList.Select(q => q.GetDesc()))); |
| | | return action; |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | //物料验证 |
| | | if (inv.ItemInfo.IsNullOrEmpty() || inv.ItemInfo.IS_ACTIVE == "N") |
| | |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L("物料编码[{0}]不存在或者该物料未启用"); |
| | | action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ItemCodeNotExistsOrNotActive", inv.ItemInfo?.ITEM_CODE.IsNullOrEmpty(inv.Barcode.ItemCode)); |
| | | return action; |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | |
| | | if (inv.Items.Count == 0) |
| | | { |
| | | List<WMS_ITEM_HIS> ItemHistorys = new List<WMS_ITEM_HIS>(); |
| | | WMS_ITEM Item; |
| | | WMS_ITEM_PKG ItemPkgs; |
| | | |
| | | Item = new() |
| | | var newItem = new WMS_ITEM() |
| | | { |
| | | SN = inv.Barcode.SN, |
| | | ITEM_CODE = inv.Barcode.ItemCode, |
| | |
| | | UNIT = inv.Barcode.Unit, |
| | | }; |
| | | |
| | | WMS_ITEM_HIS his = new(Item, $"标准上架入库"); |
| | | ItemHistorys.Add(his); |
| | | ItemPkgs = new() |
| | | WMS_ITEM_HIS his = new(newItem, $"标准上架入库"); |
| | | var newPkg = new WMS_ITEM_PKG() |
| | | { |
| | | SN = inv.Barcode.SN, |
| | | AUTH_ORG = input.AuthOption.CurOrg, |
| | |
| | | |
| | | var noExt = inv.Items.Where(q => !inv.ItemsExt.Any(s => s.SN == q.SN)).ToList(); |
| | | //扩展表不存在时新建 |
| | | foreach (var item in noExt) |
| | | foreach (var ext in noExt) |
| | | { |
| | | inv.ItemsExt.Add(new() |
| | | { |
| | | SN = item.SN, |
| | | SN = ext.SN, |
| | | META_SN = inv.Barcode.MetaSn, |
| | | QR_CODE = inv.Barcode.MetaSn |
| | | }); |
| | | } |
| | | |
| | | inv.Items.Add(Item); |
| | | inv.Items.Add(newItem); |
| | | inv.History.Add(his); |
| | | inv.Packages.Add(ItemPkgs); |
| | | inv.Packages.Add(newPkg); |
| | | } |
| | | //雅达不从条码上更新数量 |
| | | //else if (inv.Items.Count == 1) |
| | |
| | | { |
| | | var item = CurInvItem.Items.First(q => q.SN == qty.Code); |
| | | item.QTY = qty.WhQty; |
| | | item.SUPP_LOTNO = qty.Segment7; |
| | | item.SUPP_LOTNO = CurInvItem.Barcode.LotNo; |
| | | } |
| | | action.Data.Data = CurInvItem.Items.Select(q => new { q.SN, q.QTY }); |
| | | action.Data.Command = Command = "ComfirmQty"; |
| | | //action.LocaleMsg = Biz.L("请确认条码[{0}]的数量是否正确"); |
| | | action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ComfirmQty", input.SN); |
| | | return action; |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | } |
| | | |
| | |
| | | action.Data.Data = CurInvItem.Items.Select(q => new { q.SN, q.QTY }); |
| | | action.Data.Command = Command = "ComfirmQty"; |
| | | //action.LocaleMsg = Biz.L("数量不能小于等于零,请重新确认条码[{0}]的数量"); |
| | | action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmQty", input.SN); |
| | | return action; |
| | | action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmQty", input.SN); |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | action.IsSuccessed = false; |
| | | action.LocaleMsg = Biz.L(shelfApiResult.GetData<string>()); |
| | | return action; |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | var reaultShelf = shelfApiResult.GetData<ShelfChangeModel>(); |
| | | |
| | |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L($"货架[{0}]中不存在id为[{1}]的储位,请先维护货架信息"); |
| | | action.LocaleMsg = Biz.L("WMS.Default.ScanItem.LocationNotExistsInShelf", CurScanShelf.Shelf.SHELF_CODE, reaultShelf.ledAddr); |
| | | return action; |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | var locationData = MainDB.Queryable<WMS_ITEM>().Where(q => q.LOCATION_ID == nLocation.ID).First(); |
| | | if (!locationData.IsNullOrEmpty()) |
| | |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L("储位[{0}]已存有物料[{1}],请检查系统库存信息"); |
| | | action.LocaleMsg = Biz.L($"WMS.Default.ScanShelf.ItemAlreadyExistsInLocation", nLocation.LOCATION_CODE, locationData.SN); |
| | | return action; |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | CurScanShelf.LocationCode = nLocation.LOCATION_CODE; |
| | | } |
| | |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L("请输入或扫描有效的货架/储位码"); |
| | | action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfCanNotEmpty"); |
| | | return action; |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | |
| | | nLocation = await MainDB.Queryable<WMS_LOCATION>().Where(t => t.LOCATION_CODE == CurScanShelf.LocationCode && t.AUTH_ORG == OrgCode).FirstAsync(); |
| | |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L("储位[{0}]只能存放一个物料"); |
| | | action.LocaleMsg = Biz.L("WMS.Default.ScanItem.LocationSingleFailure", nLocation.LOCATION_CODE); |
| | | ResetScan(); |
| | | return action; |
| | | ResetTrans(); |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | |
| | | //执行上架数据处理 |
| | | foreach (var item in CurInvItem.Items) |
| | | { |
| | | item.TRANS_CODE = "In_Default"; |
| | | item.TRANS_NO = $"In_Default_{DateTime.Now:yyyyMMdd}"; |
| | | } |
| | | foreach (var item in CurInvItem.Packages) |
| | | { |
| | | item.TRANS_CODE = "In_Default"; |
| | | item.TRANS_NO = $"In_Default_{DateTime.Now:yyyyMMdd}"; |
| | |
| | | { |
| | | action.IsSuccessed = false; |
| | | action.LocaleMsg = putonResult.LocaleMsg; |
| | | ResetScan(); |
| | | return action; |
| | | ResetTrans(); |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | |
| | | //完成所有处理后使用事务保存数据 |
| | |
| | | catch (Exception ex) |
| | | { |
| | | //取消当前操作 |
| | | ResetScan(); |
| | | ResetTrans(); |
| | | //action.CatchExceptionWithLog(ex, $"扫描条码[{input.SN}]复核异常"); |
| | | action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", input.SN)); |
| | | } |
| | | return action; |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | catch (Exception ex) |
| | | { |
| | | //取消当前操作 |
| | | ResetScan(); |
| | | ResetTrans(); |
| | | //action.CatchExceptionWithLog(ex, $"扫描货架/储位[{0}]异常"); |
| | | action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanShelf.ScanException", Code)); |
| | | } |
| | |
| | | /// 完成所有处理后使用事务保存数据 |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <param name="locale"></param> |
| | | /// <param name="doAfterSave"></param> |
| | | /// <returns></returns> |
| | | public ApiAction<ScanOutput> DoIfFinish(ApiAction<ScanOutput> action, string locale) |
| | | public ApiAction<ScanOutput> DoIfFinish(ApiAction<ScanOutput> action, string locale, Action doAfterSave = null) |
| | | { |
| | | //保存数据库 |
| | | SaveCommitListToDB(); |
| | | |
| | | //保存数据成功后执行 |
| | | doAfterSave?.Invoke(); |
| | | |
| | | // 返回数据 |
| | | action.Data.Data = new DefaultInStoreOutput |
| | |
| | | |
| | | //重置扫码信息 |
| | | ResetScanInfo(); |
| | | return action; |
| | | return SetOutPutMqttMsg(action, locale); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 重置当前操作,有需要则重写此方法 |
| | | /// 重置事务数据,有需要则重写此方法 |
| | | /// </summary> |
| | | public override void ResetScan() |
| | | public override void ResetTrans() |
| | | { |
| | | base.ResetScan(); |
| | | base.ResetTrans(); |
| | | ResetScanInfo(); |
| | | CurScanShelf = null; |
| | | } |