private Transformer ConvertCycleCountDetailToTransformer(CycleCountDetail cycleCountDetail) { Transformer transformer = TransformerHelper.ConvertItemToTransformer(cycleCountDetail.Item); transformer.Id = cycleCountDetail.Id; transformer.OrderNo = cycleCountDetail.CycleCount.Code; transformer.Qty = cycleCountDetail.Qty; return transformer; }
private IList<CycleCountDetail> ConvertResolverToCycleCountDetail(Resolver resolver) { if (resolver.Transformers == null || resolver.Transformers.Count == 0) return null; IList<CycleCountDetail> cycleCountDetailList = new List<CycleCountDetail>(); foreach (Transformer transformer in resolver.Transformers) { if (transformer.TransformerDetails != null && resolver.IsScanHu) { #region 条码 foreach (TransformerDetail transformerDetail in transformer.TransformerDetails) { if (transformerDetail.Id == 0 || (transformerDetail.HuId != null && transformerDetail.HuId.Trim() != string.Empty)) { //Hu hu = huMgr.LoadHu(transformerDetail.HuId); CycleCountDetail cycleCountDetail = new CycleCountDetail(); cycleCountDetail.Id = transformerDetail.Id; cycleCountDetail.HuId = transformerDetail.HuId; cycleCountDetail.LotNo = transformerDetail.LotNo; cycleCountDetail.Qty = transformerDetail.CurrentQty; cycleCountDetail.Item = itemMgr.LoadItem(transformerDetail.ItemCode); if (transformerDetail.StorageBinCode != null && transformerDetail.StorageBinCode.Trim() != string.Empty) cycleCountDetail.StorageBin = storageBinMgr.LoadStorageBin(transformerDetail.StorageBinCode).Code; cycleCountDetailList.Add(cycleCountDetail); } } #endregion } else { #region Item if (transformer.Id == 0 || (transformer.ItemCode != null && transformer.ItemCode.Trim() != string.Empty)) { CycleCountDetail cycleCountDetail = new CycleCountDetail(); cycleCountDetail.Id = transformer.Id; cycleCountDetail.Item = itemMgr.LoadItem(transformer.ItemCode); cycleCountDetail.Qty = transformer.CurrentQty; cycleCountDetailList.Add(cycleCountDetail); } #endregion } } return cycleCountDetailList; }
public virtual void UpdateCycleCountDetail(CycleCountDetail entity) { entityDao.UpdateCycleCountDetail(entity); }
public IList<CycleCountDetail> ReadCycleCountFromXls(Stream inputStream, User user, CycleCount cycleCount) { if (inputStream.Length == 0) throw new BusinessErrorException("Import.Stream.Empty"); //区域权限过滤 if (!user.HasPermission(cycleCount.Location.Region.Code)) { throw new BusinessErrorException("Common.Business.Error.NoPartyPermission", cycleCount.Location.Region.Code); } HSSFWorkbook workbook = new HSSFWorkbook(inputStream); Sheet sheet = workbook.GetSheetAt(0); IEnumerator rows = sheet.GetRowEnumerator(); ImportHelper.JumpRows(rows, 11); #region 列定义 int colItem = 1;//物料代码 int colUom = 3;//单位 int colQty = 4;//数量 int colHu = 5;//条码 int colBin = 6;//库格 #endregion IList<CycleCountDetail> cycleCountDetailList = new List<CycleCountDetail>(); while (rows.MoveNext()) { Row row = (HSSFRow)rows.Current; if (!this.CheckValidDataRow(row, 1, 7)) { break;//边界 } if (row.GetCell(colHu) == null) { string itemCode = string.Empty; decimal qty = 0; string uomCode = string.Empty; #region 读取数据 #region 读取物料代码 itemCode = row.GetCell(colItem) != null ? row.GetCell(colItem).StringCellValue : string.Empty; if (itemCode == null || itemCode.Trim() == string.Empty) this.ThrowCommonError(row.RowNum, colItem, row.GetCell(colItem)); var i = ( from c in cycleCountDetailList where c.HuId == null && c.Item.Code.Trim().ToUpper() == itemCode.Trim().ToUpper() select c).Count(); if (i > 0) throw new BusinessErrorException("Import.Business.Error.Duplicate", itemCode, (row.RowNum + 1).ToString(), (colItem + 1).ToString()); #endregion #region 读取数量 try { qty = Convert.ToDecimal(row.GetCell(colQty).NumericCellValue); } catch { this.ThrowCommonError(row.RowNum, colQty, row.GetCell(colQty)); } #endregion #region 读取单位 uomCode = row.GetCell(colUom) != null ? row.GetCell(colUom).StringCellValue : string.Empty; if (uomCode == null || uomCode.Trim() == string.Empty) throw new BusinessErrorException("Import.Read.Error.Empty", (row.RowNum + 1).ToString(), colUom.ToString()); #endregion #endregion #region 填充数据 Item item = itemMgr.CheckAndLoadItem(itemCode); Uom uom = uomMgr.CheckAndLoadUom(uomCode); //单位换算 if (item.Uom.Code.Trim().ToUpper() != uom.Code.Trim().ToUpper()) { qty = uomConversionMgr.ConvertUomQty(item, uom, qty, item.Uom); } CycleCountDetail cycleCountDetail = new CycleCountDetail(); cycleCountDetail.CycleCount = cycleCount; cycleCountDetail.Item = item; cycleCountDetail.Qty = qty; cycleCountDetailList.Add(cycleCountDetail); #endregion } else { string huId = string.Empty; string binCode = string.Empty; #region 读取数据 #region 读取条码 huId = row.GetCell(colHu) != null ? row.GetCell(colHu).StringCellValue : string.Empty; if (huId == null || huId.Trim() == string.Empty) throw new BusinessErrorException("Import.Read.Error.Empty", (row.RowNum + 1).ToString(), colHu.ToString()); var i = ( from c in cycleCountDetailList where c.HuId != null && c.HuId.Trim().ToUpper() == huId.Trim().ToUpper() select c).Count(); if (i > 0) throw new BusinessErrorException("Import.Business.Error.Duplicate", huId, (row.RowNum + 1).ToString(), colHu.ToString()); #endregion #region 读取库格 binCode = row.GetCell(colBin) != null ? row.GetCell(colBin).StringCellValue : null; if (cycleCount.PhyCntGroupBy == BusinessConstants.CODE_MASTER_PHYCNT_GROUPBY_BIN && (binCode == null || binCode == string.Empty)) { throw new BusinessErrorException("Import.Read.Error.Empty", (row.RowNum + 1).ToString(), colBin.ToString()); } #endregion #endregion #region 填充数据 Hu hu = huMgr.CheckAndLoadHu(huId); StorageBin bin = null; if (binCode != null && binCode.Trim() != string.Empty) { bin = storageBinMgr.CheckAndLoadStorageBin(binCode); } CycleCountDetail cycleCountDetail = new CycleCountDetail(); cycleCountDetail.CycleCount = cycleCount; cycleCountDetail.Item = hu.Item; cycleCountDetail.Qty = hu.Qty * hu.UnitQty; cycleCountDetail.HuId = hu.HuId; cycleCountDetail.LotNo = hu.LotNo; cycleCountDetail.StorageBin = bin != null ? bin.Code : null; cycleCountDetailList.Add(cycleCountDetail); #endregion } } if (cycleCountDetailList.Count == 0) throw new BusinessErrorException("Import.Result.Error.ImportNothing"); return cycleCountDetailList; }
public virtual void DeleteCycleCountDetail(CycleCountDetail entity) { entityDao.DeleteCycleCountDetail(entity); }
public virtual void CreateCycleCountDetail(CycleCountDetail entity) { entityDao.CreateCycleCountDetail(entity); }
public virtual void DeleteCycleCountDetail(CycleCountDetail entity) { Delete(entity); }
public virtual void UpdateCycleCountDetail(CycleCountDetail entity) { Update(entity); }
public virtual void CreateCycleCountDetail(CycleCountDetail entity) { Create(entity); }