| | |
| | | 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 |
| | | { |
| | |
| | | OrderNo = "", |
| | | PalletCode = startPoint + "-AGV", |
| | | Roadway = "", |
| | | SourceAddress = startPoint, |
| | | SourceAddress = startPoint, |
| | | TargetAddress = cachePoint.PointCode, |
| | | //SourceKey = 0, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | |
| | | 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 batchNo = saveModel.MainData["batchNo"].ToString(); |
| | | if (string.IsNullOrEmpty(batchNo)) throw new Exception("æå·ä¸å¯ä¸ºç©º"); |
| | | |
| | | #region æ¥è¯¢åºåãå
¥åºå |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(palletCode); |
| | | if (stockInfo != null) throw new Exception($"æçã{palletCode}ãå·²åå¨åºåä¿¡æ¯"); |
| | | stockInfo = new Dt_StockInfo(); |
| | | stockInfo.Details = new List<Dt_StockInfoDetail>(); |
| | | Dt_InboundOrder? inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(orderNo); |
| | | if (inboundOrder == null) throw new Exception($"æªæ¾å°æ¹å·ä¸ºã{orderNo}ãçå
¥åºå"); |
| | | 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}ãå¯ç»çæ°éä¸è¶³"); |
| | | #endregion |
| | | |
| | | #region åå»ºä»»å¡ |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | CurrentAddress = "1001", |
| | | NextAddress = "1002", |
| | | SourceAddress = "RGRK", |
| | | TargetAddress = "SC01", |
| | | Creater = "System", |
| | | PalletCode = palletCode, |
| | | Roadway = "SC01", |
| | | OrderNo = orderNo + batchNo, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | TaskState = InTaskStatusEnum.AGV_InFinish.ObjToInt(), |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Dispatchertime = DateTime.Now, |
| | | }; |
| | | #endregion |
| | | |
| | | #region æ·»å åºåä¿¡æ¯ãå¤çå
¥åºå |
| | | inboundOrderDetail.ReceiptQuantity++; |
| | | inboundOrderDetail.OrderDetailStatus = inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity ? OrderDetailStatusEnum.Over.ObjToInt() : OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | if (inboundOrder.Details.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) == null) |
| | | { |
| | | inboundOrder.OrderStatus = InboundStatusEnum.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | else if (inboundOrder.OrderStatus == InboundStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | inboundOrder.OrderStatus = InboundStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | } |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | Status = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | OrderNo = inboundOrder.OrderNo, |
| | | StockId = stockInfo.Id != 0 ? stockInfo.Id : 0, |
| | | MaterielName = inboundOrderDetail.MaterielName, |
| | | MaterielCode = inboundOrderDetail.MaterielCode, |
| | | BatchNo = inboundOrderDetail.BatchNo, |
| | | StockQuantity = 1, |
| | | SerialNumber = "", |
| | | Creater = "System" |
| | | }; |
| | | if (stockInfo.Id == 0) |
| | | { |
| | | stockInfo.PalletCode = palletCode; |
| | | stockInfo.StockStatus = StockStatusEmun.ç»çæå.ObjToInt(); |
| | | stockInfo.Creater = "System"; |
| | | stockInfo.Remark = "人工ç»çå
¥åº"; |
| | | } |
| | | stockInfo.Details.Add(stockInfoDetail); |
| | | #endregion |
| | | |
| | | Db.Ado.BeginTran(); |
| | | _inboundService.InbounOrderService.UpdateDataWithDetail(inboundOrder); |
| | | _stockService.StockInfoService.AddMaterielGroup(stockInfo); |
| | | 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) |
| | | { |