| | |
| | | using Magicodes.IE.Core; |
| | | using MailKit.Search; |
| | | using System; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core; |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | switch (productionlineDTO.traytype) |
| | | #region MyRegion |
| | | Dt_InventoryInfo inventoryInfo = _inventoryInfoRepository.QueryFirst(x => x.PalletCode == productionlineDTO.Barcode); |
| | | if (inventoryInfo != null) throw new Exception($"æçã{productionlineDTO.Barcode}ãå·²åå¨åºåä¿¡æ¯"); |
| | | Dt_InboundOrderDetail inboundOrderDetail = _inboundService.InboundOrderDetailService.Repository.QueryFirst(x => x.BatchNo == productionlineDTO.batchNo); |
| | | if (inboundOrderDetail == null) throw new Exception($"æªæ¾å°æ¹å·ã{productionlineDTO.batchNo}ãçå
¥åºå"); |
| | | if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < 1) throw new Exception($"æ¹å·ã{productionlineDTO.batchNo}ãçå¯ç»çæ°éä¸è¶³"); |
| | | Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.Id == inboundOrderDetail.OrderId); |
| | | if (inboundOrder == null) throw new Exception($"æªæ¾å°æ¹å·ä¸ºã{productionlineDTO.batchNo}ãçå
¥åºå"); |
| | | var materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == inboundOrderDetail.MaterielCode); |
| | | if (materielInfo == null) throw new Exception($"æªæ¾å°ç©æä¿¡æ¯,ç©æç¼ç ã{inboundOrderDetail.MaterielCode}ã"); |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | case 1://æ¾ç©ºæ |
| | | case 3://æ¾ç©ºç |
| | | //case 5://æ¾æ»¡ç |
| | | { |
| | | //æ¥æ¾ç©æææåºå |
| | | var stockInfos = _stockService.StockInfoService.Repository.GetStockInfos(productionlineDTO.traytype.ToString()); |
| | | //æ¥æ¾å
å
¥ç©æè´§ä½æåå
¥åºç©æ |
| | | var stockInfo = stockInfos.Where(x => x.LocationCode == stockInfos.OrderBy(x => x.InDate).FirstOrDefault()?.LocationCode).OrderByDescending(x => x.InDate).FirstOrDefault(); |
| | | if (stockInfo == null) throw new Exception($"æ ç©æç¼å·ã{productionlineDTO.traytype}ãçåºå"); |
| | | var location = _basicService.LocationInfoService.GetLocation(stockInfo.LocationCode); |
| | | #region çæåºåºä»»å¡ |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | CurrentAddress = stockInfo.LocationCode, |
| | | NextAddress = "SC01", |
| | | SourceAddress = stockInfo.LocationCode, |
| | | TargetAddress = productionlineDTO.stationCode, |
| | | Creater = "System", |
| | | PalletCode = stockInfo.PalletCode, |
| | | OrderNo = null, |
| | | Roadway = "SC01", |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | TaskState = OutTaskStatusEnum.OutNew.ObjToInt(), |
| | | TaskType = productionlineDTO.traytype == 1 ? TaskTypeEnum.PalletOutbound.ObjToInt() : TaskTypeEnum.PalletFillOutbound.ObjToInt(), |
| | | IsPickPlace = location.MaxQty - location.CurrentQty == 0, |
| | | CreateDate = DateTime.Now, |
| | | Dispatchertime = DateTime.Now, |
| | | }; |
| | | #endregion |
| | | location.CurrentQty--; |
| | | location.LocationStatus = LocationStatusEnum.Outbounding.ObjToInt(); |
| | | stockInfo.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | stockInfo.Details.FirstOrDefault().Status = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | CurrentAddress = productionlineDTO.stationCode, |
| | | NextAddress = "SC01", |
| | | SourceAddress = productionlineDTO.stationCode, |
| | | TargetAddress = "SC01", |
| | | Creater = "System", |
| | | PalletCode = productionlineDTO.Barcode, |
| | | Roadway = "SC01", |
| | | OrderNo = productionlineDTO.batchNo,// inboundOrder.OrderNo, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | TaskState = InTaskStatusEnum.InNew.ObjToInt(), |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Dispatchertime = DateTime.Now, |
| | | }; |
| | | |
| | | Db.Ado.BeginTran(); |
| | | AddData(dt_Task); |
| | | _basicService.LocationInfoService.UpdateData(location); |
| | | _stockService.StockInfoService.Repository.UpdateDataWithDetail(stockInfo); |
| | | content.OK(data: dt_Task); |
| | | Db.Ado.CommitTran(); |
| | | } |
| | | break; |
| | | case 2://å空æ |
| | | case 4://åæ»¡ç |
| | | case 6://å空ç |
| | | { |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(productionlineDTO.Barcode); |
| | | if (stockInfo != null) throw new Exception($"æçã{productionlineDTO.Barcode}ãå·²åå¨åºåä¿¡æ¯"); |
| | | productionlineDTO.QtySum = Array.ConvertAll(productionlineDTO.productQty.Split(","), s => decimal.Parse(s)).Sum();//å
¥åºæ»æ° |
| | | stockInfo = new Dt_StockInfo(); |
| | | stockInfo.Details = new List<Dt_StockInfoDetail>(); |
| | | Dt_InboundOrder inboundOrder = null; |
| | | #region çæå
¥åºä»»å¡ |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | CurrentAddress = productionlineDTO.stationCode, |
| | | NextAddress = "SC01", |
| | | SourceAddress = productionlineDTO.stationCode, |
| | | TargetAddress = "SC01", |
| | | Creater = "System", |
| | | PalletCode = productionlineDTO.Barcode, |
| | | Roadway = "SC01", |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | TaskState = InTaskStatusEnum.InNew.ObjToInt(), |
| | | TaskType = productionlineDTO.traytype == 2 ? TaskTypeEnum.PalletInbound.ObjToInt() : TaskTypeEnum.PalletReturnInbound.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Dispatchertime = DateTime.Now, |
| | | }; |
| | | #endregion |
| | | if (productionlineDTO.traytype == 4) |
| | | { |
| | | var OrderNo = productionlineDTO.batchNo.Split('T')[0]; |
| | | inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(OrderNo); |
| | | if (inboundOrder == null) throw new Exception($"æªæ¾å°å
¥åºåã{OrderNo}ã"); |
| | | Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == productionlineDTO.batchNo); |
| | | if (inboundOrderDetail == null) throw new Exception($"æªæ¾å°æ¹å·ã{productionlineDTO.batchNo}ãçå
¥åºè¯¦æ
"); |
| | | if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < 1) throw new Exception($"æ¹å·ã{productionlineDTO.batchNo}ãç»çæ°éè¶
åº"); |
| | | var productionDate = DateTime.Now.ToString("yyyy-MM-dd"); |
| | | var validityPeriod = DateTime.Now.AddDays(materielInfo.Validity).ToString("yyyy-MM-dd");//å 天 |
| | | //var validityPeriod = DateTime.Now.AddMonths(materielInfo.Validity).ToString("yyyy-MM-dd");//å æ |
| | | //var validityPeriod = DateTime.Now.AddYears(materielInfo.Validity).ToString("yyyy-MM-dd");//å å¹´ |
| | | #region åºå |
| | | inventoryInfo = new Dt_InventoryInfo() |
| | | { |
| | | BatchNo = productionlineDTO.batchNo, |
| | | MaterielCode = inboundOrderDetail.MaterielCode, |
| | | MaterielName = inboundOrderDetail.MaterielName, |
| | | PalletCode = productionlineDTO.Barcode, |
| | | ProductionDate = productionDate, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | ProductStatus = ProductStatusEmun.å¾
æ£1.ObjToInt(), |
| | | ShelfLife = materielInfo.Validity, |
| | | ValidityPeriod = validityPeriod, |
| | | Creater = "System" |
| | | }; |
| | | #endregion |
| | | |
| | | dt_Task.OrderNo = OrderNo; |
| | | dt_Task.TaskType = TaskTypeEnum.Inbound.ObjToInt(); |
| | | } |
| | | content = _stockService.StockInfoService.AddStockInfo(ref stockInfo, ref inboundOrder, productionlineDTO); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | Db.Ado.BeginTran(); |
| | | if (inboundOrder != null) _inboundService.InbounOrderService.UpdateDataWithDetail(inboundOrder); |
| | | _stockService.StockInfoService.AddMaterielGroup(stockInfo); |
| | | AddData(dt_Task); |
| | | content.OK(data: dt_Task); |
| | | Db.Ado.CommitTran(); |
| | | } |
| | | break; |
| | | default: |
| | | throw new Exception("æªå®ä¹æçç±»å"); |
| | | } |
| | | #region å
¥åºå |
| | | inboundOrder.OrderStatus = InboundStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | var Item1 = _inboundService.InboundOrderDetailService.GetBoxStockQuantity(inboundOrderDetail); |
| | | inventoryInfo.StockQuantity = Item1.StockQuantity; |
| | | inventoryInfo.BoxQuantity = Item1.BoxQuantity; |
| | | inboundOrderDetail.ReceiptQuantity = inboundOrderDetail.ReceiptQuantity + Item1.StockQuantity; |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | #endregion |
| | | |
| | | Db.Ado.BeginTran(); |
| | | _inboundService.InbounOrderService.UpdateData(inboundOrder); |
| | | _inboundService.InboundOrderDetailService.UpdateData(inboundOrderDetail); |
| | | _inventoryInfoRepository.AddData(inventoryInfo); |
| | | AddData(dt_Task); |
| | | content.OK(data: dt_Task); |
| | | Db.Ado.CommitTran(); |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | PalletCode = lineDTO.Barcode, |
| | | OrderNo = StockInfoDetails.Count() == 1 ? StockInfoDetails.First().OrderNo : null, |
| | | Roadway = "SC01", |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | TaskState = InTaskStatusEnum.InNew.ObjToInt(), |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | }; |