| | |
| | | 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); |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(productionlineDTO.Barcode); |
| | | if (stockInfo != null) throw new Exception($"æçã{productionlineDTO.Barcode}ãå·²åå¨åºåä¿¡æ¯"); |
| | | stockInfo = new Dt_StockInfo(); |
| | | stockInfo.Details = new List<Dt_StockInfoDetail>(); |
| | | #region MyRegion |
| | | string OrderNo = productionlineDTO.batchNo.Substring(0, 8);// DateTime.Now.ToString("yyMMdd"); |
| | | Dt_InboundOrder? inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(OrderNo); |
| | | if (inboundOrder == null) throw new Exception($"æªæ¾å°æ¹å·ä¸ºã{OrderNo}ãçå
¥åºå"); |
| | | //var BatchNo = string.Join("", productionlineDTO.batchNo.Except(OrderNo)); |
| | | var BatchNo = productionlineDTO.batchNo.Substring(8); |
| | | Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.Where(x => x.BatchNo == BatchNo).FirstOrDefault(); |
| | | if (inboundOrderDetail == null) throw new Exception($"æ¹å·ã{OrderNo}ãçå
¥åºåæªæ¾å°æå·ã{BatchNo}ã"); |
| | | if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < 1) throw new Exception($"æ¹å·ã{OrderNo}ãçæå·ã{BatchNo}ãå¯ç»çæ°éä¸è¶³"); |
| | | |
| | | 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, |
| | | }; |
| | | |
| | | productionlineDTO.batchNo = BatchNo; |
| | | content = _stockService.StockInfoService.AddStockInfo(ref stockInfo, ref inboundOrder, productionlineDTO); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | Db.Ado.BeginTran(); |
| | | _inboundService.InbounOrderService.UpdateDataWithDetail(inboundOrder); |
| | | _stockService.StockInfoService.AddMaterielGroup(stockInfo); |
| | | 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(), |
| | | }; |