/// <summary> /// 获取XingYe同步数据 /// </summary> /// <param name="model">XingYe</param> /// <returns></returns> /// <remarks>2013-9-27 杨浩 添加</remarks> public Result <string> GetData(CBXingYeSyncLog model) { var easModel = new Hyt.Model.Generated.XingYeSyncLog { SysNo = model.SysNo, Data = model.Data, DataMd5 = model.DataMd5 }; var iType = (接口类型)(model.InterfaceType); var result = new Result <string> { }; switch (iType) { case 接口类型.配送员借货还货: var borrow = model.Data.ToObject <BorrowInfoWraper>(); result = XingYeCore.OtherIssueBillFacade(borrow.Model, borrow.Type, borrow.Description, "", model.DataMd5, true, true, true); break; case 接口类型.销售出库退货: //var sale = model.Data.ToObject<SaleInfoWraper>(); result = XingYeCore.SaleIssueBillFacade(easModel, false, true, true, true); break; case 接口类型.收款单据导入: var receiving = model.Data.ToObject <ReceivingInfoWraper>(); result = XingYeCore.ReceivingBillFacade(0, receiving.Model, receiving.ReceivingType, receiving.Customer, receiving.Description, "", model.DataMd5, true, true, true); break; } return(result); }
/// <summary> /// 还货 /// </summary> /// <param name="model">还货明细</param> /// <param name="description">单据摘要</param> /// <param name="flowIdentify"></param> /// <returns></returns> /// <remarks>2013-9-27 杨浩 添加</remarks> public Result Return(List <BorrowInfo> model, string description, string flowIdentify) { var result = XingYeCore.OtherIssueBillFacade(model, 借货状态.还货, description, flowIdentify); return(result); }
/// <summary> /// 重新同步数据 /// </summary> /// <param name="sysNo">Eas同步系统编号</param> /// <param name="isSave">销售出库单是否传保存状态</param> /// <returns></returns> /// <remarks>2013-9-27 杨浩 添加</remarks> public Result Resynchronization(int sysNo, bool isSave = false) { //string key = "Hyt.EasLog." + sysNo; lock (_lockThis) { //判断是否有锁 if (_synclist.Contains(sysNo)) { return new Result { Status = false, Message = "正在同步,请稍后再试..." } } ; //加锁 _synclist.Add(sysNo); } var model = Hyt.DataAccess.Sys.IXingYeDao.Instance.GetEntity(sysNo); if (model.Status == (int)步状态.成功) { return(new Result { Message = "此信息已同步成功!", Status = false }); } //收款单 bool isFull = false; int warehouseSysNo = 0; // var iType = (接口类型)(model.InterfaceType); var result = new Result <string> { }; var watch = new Stopwatch(); watch.Start(); switch (iType) { case 接口类型.配送员借货还货: var borrow = model.Data.ToObject <BorrowInfoWraper>(); result = XingYeCore.OtherIssueBillFacade(borrow.Model, borrow.Type, borrow.Description, model.FlowIdentify, model.DataMd5, true); break; case 接口类型.销售出库退货: //var sale = model.Data.ToObject<SaleInfoWraper>(); result = XingYeCore.SaleIssueBillFacade(model, isSave, true); break; case 接口类型.采购入库退货: result = XingYeCore.PurchaseIssueBillFacade(model, isSave, true); break; case 接口类型.调拨单据导入: result = XingYeCore.TransferStocXingYesueBillFacade(model, isSave, true); break; case 接口类型.收款单据导入: #region 收款单据导入 var receiving = model.Data.ToObject <ReceivingInfoWraper>(); if (model.Message.StartsWith(EasConstant.Information)) { isFull = true; foreach (var item in receiving.Model) { if (item.WarehouseSysNo == 0) { int orderSysNo = 0; int.TryParse(item.OrderSysNo, out orderSysNo); var wh = IOutStockDao.Instance.GetWhStockOutListByOrderID(orderSysNo, true); if (wh != null && wh.Count > 0) { item.Remark = ""; item.WarehouseSysNo = wh.FirstOrDefault().WarehouseSysNo; warehouseSysNo = item.WarehouseSysNo; var warehouse = IWhWarehouseDao.Instance.GetWarehouse(warehouseSysNo); //地区仓库 if (warehouse != null) { item.WarehouseNumber = warehouse.ErpCode; } } } var oraganization = IOrganizationDao.Instance.GetOrganization(item.WarehouseSysNo); if (oraganization != null) { item.OrganizationCode = oraganization.Code; } if (item.PayeeAccount != EasConstant.PayeeAccount && string.IsNullOrEmpty(item.PayeeAccount)) { var pa = IFnReceiptTitleAssociationDao.Instance.GetList(item.WarehouseSysNo, PaymentType.现金) .OrderByDescending(m => m.IsDefault) .FirstOrDefault(); if (pa != null) { item.PayeeAccount = pa.EasReceiptCode; } } } } result = XingYeCore.ReceivingBillFacade(model.SysNo, receiving.Model, receiving.ReceivingType, receiving.Customer, receiving.Description, model.FlowIdentify, model.DataMd5, true); break; #endregion } watch.Stop(); if (result.Status || result.StatusCode == "105")// || result.StatusCode == "9999" || result.Message.Contains("当前单据已经同步成功")) { model.Status = (int)步状态.成功; model.VoucherNo = result.Data; model.Message = "同步成功"; //消息特殊处理:销售出库单,外部系统id:1e65059916eb765b4b7d17496589c904,已经同步过,对应EAS单据ID为:XSCK2014052905193353,请不要重复同步... if (result.StatusCode == "105" && !string.IsNullOrEmpty(result.Message)) { var reg = new Regex(@"XSCK(\d*)"); var m = reg.Match(result.Message); model.VoucherNo = m.Value; } //消息特殊处理:当前单据已经同步成功,XingYe单据号为:XSCK2014081907917302 else if (!string.IsNullOrEmpty(result.Message) && result.Message.Contains("单据重复")) { Regex reg = new Regex(@"XSCK(\d*)"); var m = reg.Match(result.Message); model.VoucherNo = m.Value; } } else { model.Status = (int)步状态.失败; model.Message = result.Message; } model.SyncNumber = model.SyncNumber + 1; model.StatusCode = result.StatusCode; model.ElapsedTime = (int)watch.ElapsedMilliseconds; model.LastsyncTime = DateTime.Now; model.LastupdateDate = DateTime.Now; model.LastupdateBy = Hyt.Model.SystemPredefined.User.SystemUser; //收款单资料不全,重新读取并更新 if (isFull && warehouseSysNo != 0) { model.WarehouseSysNo = warehouseSysNo; } Hyt.DataAccess.Sys.IXingYeDao.Instance.Update(model); _synclist.Remove(sysNo); return(result); }