| | |
| | | return stockInfo; |
| | | } |
| | | /// <summary> |
| | | /// æ·»å 空æçç»çä¿¡æ¯ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent AddStockEmpty(string palletCode) |
| | | { |
| | | try |
| | | { |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == "Empty000"); |
| | | if (materielInfo == null) throw new Exception($"æªæ¾å°ç©ºæçä¿¡æ¯,ç©æç¼å·ãEmpty000ã"); |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletCode = palletCode, |
| | | StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(), |
| | | Creater = "System", |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | Status = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(), |
| | | OrderNo = DateTime.Now.ToString("yyMMdd"), |
| | | StockId = stockInfo.Id != 0 ? stockInfo.Id : 0, |
| | | MaterielName = materielInfo.MaterielName, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | BatchNo = DateTime.Now.ToString("yyMMdd") + "E", |
| | | StockQuantity = 1, |
| | | SerialNumber = "", |
| | | Creater = "System" |
| | | }; |
| | | stockInfo.Details.Add(stockInfoDetail); |
| | | AddMaterielGroup(stockInfo); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// æ·»å ç»ç/åºåä¿¡æ¯ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | |
| | | { |
| | | //Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materielCode); |
| | | //if (materielInfo == null) throw new Exception($"æªæ¾å°ç©æä¿¡æ¯"); |
| | | return BaseDal.QueryTabs<Dt_StockInfo, Dt_StockInfoDetail, StockSelectViewDTO>((a, b) => a.Id == b.StockId, (a, b) => new StockSelectViewDTO |
| | | int i = 1; |
| | | List<StockSelectViewDTO> stockSelectViewDTOs = new List<StockSelectViewDTO>(); |
| | | var StockSelectViewDTOs = BaseDal.QueryTabs<Dt_StockInfo, Dt_StockInfoDetail, StockSelectViewDTO>((a, b) => a.Id == b.StockId, (a, b) => new StockSelectViewDTO |
| | | { |
| | | LocationCode = a.LocationCode, |
| | | MaterielCode = b.MaterielCode, |
| | | MaterielName = b.MaterielName, |
| | | PalletCode = a.PalletCode, |
| | | OrderNo = b.OrderNo, |
| | | InDate = a.InDate, |
| | | //UseableQuantity = b.StockQuantity - b.OutboundQuantity |
| | | UseableQuantity = b.StockQuantity, |
| | | BatchNo = b.BatchNo, |
| | | }, a => a.StockStatus == StockStatusEmun.å·²å
¥åº.ObjToInt(), b => b.Status == StockStatusEmun.å·²å
¥åº.ObjToInt() && b.MaterielCode == materielCode, x => true).GroupBy(x => x.LocationCode).Select(x => new StockSelectViewDTO |
| | | }, a => a.StockStatus == StockStatusEmun.å·²å
¥åº.ObjToInt(), b => b.Status == StockStatusEmun.å·²å
¥åº.ObjToInt() && b.MaterielCode == materielCode, x => true).GroupBy(x => x.OrderNo).ToList(); |
| | | foreach (var item in StockSelectViewDTOs) |
| | | { |
| | | LocationCode = x.FirstOrDefault()?.LocationCode ?? "", |
| | | MaterielCode = x.FirstOrDefault()?.MaterielCode ?? "", |
| | | MaterielName = x.FirstOrDefault()?.MaterielName ?? "", |
| | | PalletCode = string.Join(",", x.Select(x => x.PalletCode).ToList()), |
| | | //UseableQuantity = x.Sum(x => x.UseableQuantity) |
| | | UseableQuantity = x.Sum(x => x.UseableQuantity), |
| | | BatchNo = x.FirstOrDefault()?.BatchNo ?? "" |
| | | }).ToList(); |
| | | stockSelectViewDTOs.AddRange(item.GroupBy(x => x.BatchNo).Select(x => new StockSelectViewDTO |
| | | { |
| | | Id = i++, |
| | | LocationCode = x.FirstOrDefault()?.LocationCode ?? "", |
| | | MaterielCode = x.FirstOrDefault()?.MaterielCode ?? "", |
| | | MaterielName = x.FirstOrDefault()?.MaterielName ?? "", |
| | | PalletCode = string.Join(",", x.Select(x => x.PalletCode).ToList()), |
| | | UseableQuantity = x.Sum(x => x.UseableQuantity), |
| | | InDate = x.OrderByDescending(x => x.InDate).First().InDate, |
| | | OrderNo = item.Key, |
| | | BatchNo = x.Key |
| | | })); |
| | | |
| | | } |
| | | //.Select(x => new StockSelectViewDTO |
| | | //{ |
| | | // LocationCode = x.FirstOrDefault()?.LocationCode ?? "", |
| | | // MaterielCode = x.FirstOrDefault()?.MaterielCode ?? "", |
| | | // MaterielName = x.FirstOrDefault()?.MaterielName ?? "", |
| | | // PalletCode = //string.Join(",", x.Select(x => x.PalletCode).ToList()), |
| | | // //UseableQuantity = x.Sum(x => x.UseableQuantity) |
| | | // UseableQuantity = x.Sum(x => x.UseableQuantity), |
| | | // OrderNo = x.First().OrderNo, |
| | | // BatchNo = x.FirstOrDefault()?.BatchNo ?? "" |
| | | //}).ToList(); |
| | | return stockSelectViewDTOs; |
| | | } |
| | | catch (Exception ex) |
| | | { |