| | |
| | | using System; |
| | | using MailKit.Search; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.WCSInfo; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEAWCS_DTO.WCSInfo; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | TaskState = AGVTaskStatusEnum.AGV_New.ObjToInt(), |
| | | TaskType = TaskTypeEnum.AGVCarry.ObjToInt(), |
| | | }; |
| | | cachePoint.PointStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | cachePoint.PointStatus = LocationStatusEnum.OutLock.ObjToInt(); |
| | | |
| | | _basicService.CachePointService.Repository.UpdateData(cachePoint); |
| | | Repository.AddData(task); |
| | |
| | | TaskState = AGVTaskStatusEnum.AGV_New.ObjToInt(), |
| | | TaskType = TaskTypeEnum.AGVCarry.ObjToInt(), |
| | | }; |
| | | cachePoint.PointStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | cachePoint.PointStatus = LocationStatusEnum.OutLock.ObjToInt(); |
| | | |
| | | _basicService.CachePointService.Repository.UpdateData(cachePoint); |
| | | Repository.AddData(task); |
| | |
| | | OrderNo = "", |
| | | PalletCode = startPoint + "-AGV", |
| | | Roadway = "", |
| | | SourceAddress = startPoint, |
| | | SourceAddress = startPoint, |
| | | TargetAddress = cachePoint.PointCode, |
| | | //SourceKey = 0, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | TaskState = AGVTaskStatusEnum.AGV_New.ObjToInt(), |
| | | TaskType = TaskTypeEnum.AGVCarry.ObjToInt(), |
| | | }; |
| | | cachePoint.PointStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | cachePoint.PointStatus = LocationStatusEnum.OutLock.ObjToInt(); |
| | | |
| | | _basicService.CachePointService.Repository.UpdateData(cachePoint); |
| | | Repository.AddData(task); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | /// <summary> |
| | | /// 人工ç»çå
¥åº |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent InMateriel(SaveModel saveModel) |
| | | { |
| | | WebResponseContent responseContent = new WebResponseContent(); |
| | | try |
| | | { |
| | | var palletCode = saveModel.MainData["palletCode"].ToString(); |
| | | if (string.IsNullOrEmpty(palletCode)) throw new Exception("æçå·ä¸å¯ä¸ºç©º"); |
| | | //var orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | //if (string.IsNullOrEmpty(orderNo)) throw new Exception("æ¹å·ä¸å¯ä¸ºç©º"); |
| | | var qty = saveModel.MainData["qty"].ToString(); |
| | | if (string.IsNullOrEmpty(qty)) throw new Exception("è¢æ°ä¸å¯ä¸ºç©º"); |
| | | var batchNo = saveModel.MainData["batchNo"].ToString(); |
| | | if (string.IsNullOrEmpty(batchNo)) throw new Exception("æå·ä¸å¯ä¸ºç©º"); |
| | | |
| | | #region æ¥è¯¢åºåãå
¥åºå |
| | | Dt_InventoryInfo inventoryInfo = _inventoryInfoRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (inventoryInfo != null) throw new Exception($"æçã{palletCode}ãå·²åå¨åºåä¿¡æ¯"); |
| | | Dt_InboundOrderDetail? inboundOrderDetail = _inboundService.InboundOrderDetailService.Repository.QueryFirst(x => x.BatchNo == batchNo); |
| | | if (inboundOrderDetail == null) throw new Exception($"æªæ¾å°æ¹å·ã{batchNo}ãçå
¥åºå"); |
| | | if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < qty.ObjToInt()) throw new Exception($"æ¹å·ã{batchNo}ãå¯ç»çæ°éä¸è¶³"); |
| | | Dt_InboundOrder? inboundOrder = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.Id == inboundOrderDetail.OrderId); |
| | | if (inboundOrder == null) throw new Exception($"æªæ¾å°æ¹å·ä¸ºã{batchNo}ãçå
¥åºå"); |
| | | Dt_Inventory_Batch inventory_Batch = _inventoryBatchRepository.QueryFirst(x => x.BatchNo == batchNo); |
| | | if (inventory_Batch == null) throw new Exception($"æªæ¾å°æ¹å·ä¸ºã{batchNo}ãçæ¹æ¬¡ä¿¡æ¯"); |
| | | #endregion |
| | | |
| | | #region åå»ºä»»å¡ |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | CurrentAddress = "1001", |
| | | NextAddress = "1002", |
| | | SourceAddress = "RGRK", |
| | | TargetAddress = "SC01", |
| | | Creater = "System", |
| | | PalletCode = palletCode, |
| | | Roadway = "SC01", |
| | | OrderNo = batchNo, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | TaskState = InTaskStatusEnum.AGV_InFinish.ObjToInt(), |
| | | TaskType = inboundOrder.OrderType == InOrderTypeEnum.Quality.ObjToInt() ? TaskTypeEnum.InQuality.ObjToInt() : TaskTypeEnum.Inbound.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Dispatchertime = DateTime.Now, |
| | | }; |
| | | #endregion |
| | | |
| | | #region æ·»å åºåä¿¡æ¯ãå¤çå
¥åºå |
| | | inventoryInfo = new Dt_InventoryInfo() |
| | | { |
| | | BatchNo = inventory_Batch.BatchNo, |
| | | MaterielCode = inventory_Batch.MaterielCode, |
| | | MaterielName = inventory_Batch.MaterielName, |
| | | PalletCode = palletCode, |
| | | ProductionDate = inventory_Batch.ProductionDate, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | ProductStatus = dt_Task.TaskType == TaskTypeEnum.InQuality.ObjToInt() ? ProductStatusEmun.å¾
æ£2.ObjToInt() : ProductStatusEmun.å¾
æ£1.ObjToInt(), |
| | | ShelfLife = inventory_Batch.ShelfLife, |
| | | ValidityPeriod = inventory_Batch.ValidityPeriod, |
| | | StockQuantity = qty.ObjToInt(), |
| | | BoxQuantity = (qty.ObjToInt() % 8 > 0) ? (qty.ObjToInt() / 8) + 1 : qty.ObjToInt() / 8, |
| | | Creater = "System" |
| | | }; |
| | | inboundOrder.OrderStatus = InboundStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | inboundOrderDetail.ReceiptQuantity += inventoryInfo.StockQuantity; |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | inventory_Batch.ProductStatus = inventoryInfo.ProductStatus; |
| | | #endregion |
| | | |
| | | Db.Ado.BeginTran(); |
| | | _inboundService.InbounOrderService.UpdateData(inboundOrder); |
| | | _inboundService.InboundOrderDetailService.UpdateData(inboundOrderDetail); |
| | | _inventoryInfoRepository.AddData(inventoryInfo); |
| | | _inventoryBatchRepository.UpdateData(inventory_Batch); |
| | | AddData(dt_Task); |
| | | List<WMSTaskDTO> wMSTaskDTOs = _mapper.Map<List<WMSTaskDTO>>(new List<Dt_Task> { dt_Task }); |
| | | var ResultData = HttpHelper.PostAsync(WCSInterfaceAddress.ReceiveTask, wMSTaskDTOs.ToJson(), headers: new Dictionary<string, string>()); |
| | | if (ResultData.Result == null) throw new Exception($"åWCSä¸åå
¥åºä»»å¡è¶
æ¶"); |
| | | responseContent = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result); |
| | | if (responseContent == null) throw new Exception($"ä¸åå
¥åºä»»å¡WCSæ ååº"); |
| | | if (!responseContent.Status) throw new Exception(responseContent.Message); |
| | | Db.Ado.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | responseContent.Error(ex.Message); |
| | | } |
| | | return responseContent; |
| | | } |
| | | |
| | | private Dt_CachePoint GetCachePointByStartPoint(string startPoint) |
| | | { |