| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using Magicodes.IE.Core; |
| | | using MailKit.Search; |
| | | using System; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_DTO.WCSInfo; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEAWCS_DTO.WCSInfo; |
| | | using WIDESEA_Core.Helper; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | (bool, string) result = CheckRequestInbound(productionlineDTO.Station, productionlineDTO.TrayBarcode, false); |
| | | if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2); |
| | | var task = BaseDal.QueryFirst(x => x.PalletCode == productionlineDTO.TrayBarcode); |
| | | if (task != null && task.TaskType == TaskTypeEnum.Inbound.ObjToInt()) |
| | | return content.OK(data: task); |
| | | #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() |
| | | { |
| | | 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, |
| | | }; |
| | | |
| | | 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 |
| | | |
| | | #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) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | |
| | | 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(), |
| | | }; |