/// <summary> /// 根据采购入库单,创建待处理队列数据 /// </summary> /// <param name="purchaseStockInId"></param> /// <param name="occurTime"></param> /// <returns></returns> public IEnumerable <RealTimeGrossSettlementProcessQueueInfo> CreateByPurchaseStockIn(Guid purchaseStockInId, DateTime occurTime) { List <RealTimeGrossSettlementProcessQueueInfo> result = new List <RealTimeGrossSettlementProcessQueueInfo>(); try { var purchaseStockInRecord = _storageDao.GetStorageRecord(purchaseStockInId); var purchaseStockInDetails = _storageDao.GetStorageRecordDetailListByStockId(purchaseStockInId); if (purchaseStockInRecord == null || purchaseStockInRecord.StockType != (int)StorageRecordType.BuyStockIn || purchaseStockInRecord.StockState != (int)StorageRecordState.Finished || purchaseStockInDetails == null || purchaseStockInDetails.Count == 0) { return(result); } Dictionary <Guid, int> goodsStockQuantityDict = new Dictionary <Guid, int>(); // 销售公司向物流配送公司采购时,销售公司的库存为0 if (purchaseStockInRecord.TradeBothPartiesType != (int)TradeBothPartiesType.HostingToSale) { goodsStockQuantityDict = WMSSao.GetGoodsStockQuantiyByFilialeIdGoodsIds(purchaseStockInRecord.FilialeId, purchaseStockInDetails.Select(m => m.GoodsId).Distinct()); } var lastGoodsUnitPriceDict = GetLatestListByMultiGoods(purchaseStockInRecord.FilialeId, purchaseStockInDetails.Select(m => m.GoodsId).Distinct()); foreach (var groupByGoodsId in purchaseStockInDetails.GroupBy(g => g.GoodsId)) { var item = new RealTimeGrossSettlementProcessQueueInfo { QueueId = Guid.NewGuid(), FilialeId = purchaseStockInRecord.FilialeId, GoodsId = groupByGoodsId.Key, StockQuantity = goodsStockQuantityDict.ContainsKey(groupByGoodsId.Key) ? goodsStockQuantityDict[groupByGoodsId.Key] : 0, LastGrossSettlement = lastGoodsUnitPriceDict.ContainsKey(groupByGoodsId.Key) ? lastGoodsUnitPriceDict[groupByGoodsId.Key] : null, RelatedTradeType = (int)RealTimeGrossSettlementRelatedTradeType.PurchaseStockIn, RelatedTradeNo = purchaseStockInRecord.TradeCode, GoodsQuantityInBill = groupByGoodsId.Sum(m => Math.Abs(m.Quantity)), GoodsAmountInBill = groupByGoodsId.Sum(m => Math.Abs(m.UnitPrice * m.Quantity)), OccurTime = occurTime == DateTime.MinValue ? purchaseStockInRecord.DateCreated : occurTime, CreateTime = DateTime.Now }; result.Add(item); } } catch (Exception ex) { ERP.SAL.LogCenter.LogService.LogError(string.Format("创建基于采购入库单 {0} 的即时结算价失败!", purchaseStockInId), LOG_TAG, ex); } return(result); }
/// <summary>Grid操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SemiStockGrid_OnItemCommand(object sender, GridCommandEventArgs e) { var item = e.Item as GridDataItem; if (item != null) { var dataItem = item; var stockId = new Guid(dataItem.GetDataKeyValue("StockId").ToString()); var storageInfo = _storageRecordDao.GetStorageRecord(stockId); //作废 if (e.CommandName == "Cancellation") { #region --> Cancellation var personnelInfo = CurrentSession.Personnel.Get(); if (storageInfo.StockType == (int)StorageRecordType.BorrowIn) { string description = "[借入单作废] " + personnelInfo.RealName + "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]"; var borrowLendInfo = _borrowLendDao.GetBorrowLendInfo(stockId); if (borrowLendInfo != null) { var outStorageInfo = _storageRecordDao.GetStorageRecord(borrowLendInfo.BorrowLendId); if (outStorageInfo != null) { //作废借入返回单 _storageManager.NewSetStateStorageRecord(outStorageInfo.StockId, StorageRecordState.Canceled, description); } } //作废借入单 _storageManager.NewSetStateStorageRecord(stockId, StorageRecordState.Canceled, description); //入库单作废操作记录添加 WebControl.AddOperationLog(personnelInfo.PersonnelId, personnelInfo.RealName, stockId, storageInfo.TradeCode, OperationPoint.StorageInManager.Cancel.GetBusinessInfo(), string.Empty); } else { Guid purid = _storageRecordDao.GetStorageRecord(stockId).LinkTradeID; IList <PurchasingDetailInfo> dlist = _purchasingDetail.Select(purid); var purchasingManager = new PurchasingManager(_purchasing, null, null, null, null); using (var ts = new TransactionScope(TransactionScopeOption.Required)) { if (dlist.Count > 0) { bool flag = true; if (dlist.Any(dInfo => dInfo.RealityQuantity >= 1)) { purchasingManager.PurchasingUpdate(purid, PurchasingState.PartComplete); flag = false; } if (flag) { purchasingManager.PurchasingUpdate(purid, PurchasingState.Purchasing); } } string description = "[入库作废] " + CurrentSession.Personnel.Get().RealName + "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]"; _storageManager.NewSetStateStorageRecord(stockId, StorageRecordState.Canceled, description); //入库单作废操作记录添加 WebControl.AddOperationLog(personnelInfo.PersonnelId, personnelInfo.RealName, stockId, storageInfo.TradeCode, OperationPoint.StorageInManager.Cancel.GetBusinessInfo(), string.Empty); ts.Complete(); } } #endregion } RAM.ResponseScripts.Add("setTimeout(function(){ refreshGrid(); }, " + GlobalConfig.PageAutoRefreshDelayTime + ");"); } }
/// <summary>Grid操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SemiStockGrid_OnItemCommand(object sender, GridCommandEventArgs e) { var item = e.Item as GridDataItem; if (item != null) { var dataItem = item; var stockId = new Guid(dataItem.GetDataKeyValue("StockId").ToString()); var storageInfo = _storageRecordDao.GetStorageRecord(stockId); //作废 if (e.CommandName == "Cancellation") { #region --> Cancellation var personnelInfo = CurrentSession.Personnel.Get(); if (storageInfo.StockType == (int)StorageRecordType.LendOut) { string description = "[借出单作废] " + personnelInfo.RealName + "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]"; var borrowLendInfo = _borrowLendDao.GetBorrowLendInfo(stockId); if (borrowLendInfo != null) { var outStorageInfo = _storageRecordDao.GetStorageRecord(borrowLendInfo.BorrowLendId); if (outStorageInfo != null) { //作废借出返回单 _storageManager.NewSetStateStorageRecord(outStorageInfo.StockId, StorageRecordState.Canceled, description); } } //作废借出单 _storageManager.NewSetStateStorageRecord(stockId, StorageRecordState.Canceled, description); //入库单作废操作记录添加 WebControl.AddOperationLog(personnelInfo.PersonnelId, personnelInfo.RealName, stockId, storageInfo.TradeCode, OperationPoint.StorageInManager.Cancel.GetBusinessInfo(), string.Empty); } else { string description = "[出库作废] " + CurrentSession.Personnel.Get().RealName + "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]"; _storageManager.NewSetStateStorageRecord(stockId, StorageRecordState.Canceled, description); //入库单作废操作记录添加 WebControl.AddOperationLog(personnelInfo.PersonnelId, personnelInfo.RealName, stockId, storageInfo.TradeCode, OperationPoint.StorageInManager.Cancel.GetBusinessInfo(), string.Empty); } #endregion } else if (e.CommandName == "Validation") { //售后确认 #region -->Validation StorageRecordInfo storageRecordInfo = _storageRecordDao.GetStorageRecord(stockId); var stockValidation = (CheckBox)dataItem.FindControl("CB_StockValidation"); bool stockValidationType = stockValidation.Checked; _storageRecordDao.UpdateStorageRecordDetailByStockId(stockId, stockValidationType); var personnelInfo = CurrentSession.Personnel.Get(); //出库确认添加操作记录添加 WebControl.AddOperationLog(personnelInfo.PersonnelId, personnelInfo.RealName, stockId, storageRecordInfo.TradeCode, OperationPoint.StorageOutManager.Confirm.GetBusinessInfo(), string.Empty); #endregion } RAM.ResponseScripts.Add("setTimeout(function(){ refreshGrid(); }, " + GlobalConfig.PageAutoRefreshDelayTime + ");"); } }