| | |
| | | using AutoMapper; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | using WIDESEA_Core.Utilities; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_DTO.WCSInfo; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundRepository; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_ITaskInfoRepository; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEAWCS_DTO.WCSInfo; |
| | | |
| | | namespace WIDESEA_InboundService |
| | | { |
| | |
| | | { |
| | | return BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).First(x => x.OrderNo == inboundOrderNo); |
| | | } |
| | | public bool UpdateDataWithDetail(Dt_InboundOrder inboundOrder) |
| | | { |
| | | return Db.UpdateNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | } |
| | | /// <summary> |
| | | /// 空æç»çå
¥åº |
| | | /// </summary> |
| | | /// <param name="materielGroupDTO"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent PdaAddEmptyStockInfo(string barcode, string station) |
| | | { |
| | | try |
| | | { |
| | | #region æ·»å ä¸ä¸ªç©ºæç»çä¿¡æ¯å空æä»»å¡å¹¶ä¸åç»WCS |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(barcode); |
| | | if (stockInfo != null) throw new Exception($"æçå·ã{stockInfo.PalletCode}ãå·²åå¨ç»çä¿¡æ¯"); |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == barcode && x.TaskType == TaskTypeEnum.PalletInbound.ObjToInt()); |
| | | if (task == null) |
| | | { |
| | | task = new Dt_Task() |
| | | { |
| | | CurrentAddress = station, |
| | | NextAddress = "1001", |
| | | SourceAddress = station, |
| | | TargetAddress = "SC01", |
| | | Creater = "System", |
| | | PalletCode = barcode, |
| | | Roadway = "SC01", |
| | | OrderNo = DateTime.Now.ToString("yyMMdd"), |
| | | TaskNum = _taskRepository.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | TaskState = InTaskStatusEnum.InNew.ObjToInt(), |
| | | TaskType = TaskTypeEnum.PalletInbound.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Dispatchertime = DateTime.Now, |
| | | }; |
| | | Db.Ado.BeginTran(); |
| | | WebResponseContent content = _stockService.StockInfoService.AddStockEmpty(barcode); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | _taskRepository.AddData(task); |
| | | List<WMSTaskDTO> wMSTaskDTOs = _mapper.Map<List<WMSTaskDTO>>(new List<Dt_Task> { task }); |
| | | var ResultData = HttpHelper.PostAsync(WCSInterfaceAddress.ReceiveTask, wMSTaskDTOs.ToJson(), headers: new Dictionary<string, string>()); |
| | | if (ResultData.Result == null) throw new Exception($"åWCSä¸å空æå
¥åºä»»å¡è¶
æ¶"); |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result); |
| | | if (content == null) throw new Exception($"ä¸å空æå
¥åºä»»å¡WCSæ ååº"); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | Db.Ado.CommitTran(); |
| | | } |
| | | else |
| | | throw new Exception($"æçå·ã{barcode}ãå·²åå¨ä»»å¡"); |
| | | #endregion |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// PDAç»ç |
| | | /// åç§ç©æç»ç |
| | |
| | | public WebResponseContent PdaAddStockInfo(PdaMaterielGroupDTO pdaMaterielGroupDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | WebResponseContent.Instance.OK(); |
| | | try |
| | | { |
| | | Dt_MaterielInfo materielInfo = _basicService.MaterielInfoService.GetMaterielInfo(pdaMaterielGroupDTO.MaterielCode); |
| | |
| | | stockInfoDetail.StockQuantity += pdaMaterielGroupDTO.ReceiptQuantity; |
| | | stockInfoDetail.SerialNumber = $"{inboundOrder.OrderNo} | {materielInfo.MaterielCode} | {pdaMaterielGroupDTO.BatchNo} | {(int)stockInfoDetail.StockQuantity}"; |
| | | } |
| | | |
| | | |
| | | |
| | | Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.Where(x => materielInfo.MaterielCode == x.MaterielCode && x.BatchNo == pdaMaterielGroupDTO.BatchNo).FirstOrDefault();//订å详æ
|
| | | |
| | | inboundOrderDetail.ReceiptQuantity += pdaMaterielGroupDTO.ReceiptQuantity; |
| | | 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) |
| | |
| | | { |
| | | return (false, "已䏿¶çæçä¸è½å次ç»ç", materielGroupDTO); |
| | | } |
| | | if (stockInfo != null) |
| | | { |
| | | return (false, "å·²ç»ççæçä¸è½å次ç»ç", materielGroupDTO); |
| | | } |
| | | if (materielInfo == null) |
| | | { |
| | | return (false, "æç©æä¿¡æ¯æªå½å
¥ï¼è¯·å½å
¥ç©æä¿¡æ¯", materielGroupDTO); |
| | |
| | | { |
| | | return (false, "ç©æææ¹æ¬¡å·æè¯¯", materielGroupDTO); |
| | | } |
| | | if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < materielGroupDTO.ReceiptQuantity) |
| | | if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < 1) |
| | | { |
| | | return (false, "æç©æè¶
åºåæ®æ°é", materielGroupDTO); |
| | | //return (false, "æç©æè¶
åºåæ®æ°é", materielGroupDTO); |
| | | return (false, "ç»çè¶
åºåæ®æ°é", materielGroupDTO); |
| | | } |
| | | return (true, "æå", inboundOrderDetail); |
| | | } |
| | |
| | | return (true, "æå", materielGroupDTO); |
| | | } |
| | | |
| | | public WebResponseContent QueryOrderInfo(int pageNo, string orderNo) |
| | | public WebResponseContent QueryOrderInfo(int pageNo, string orderNo, int orderType) |
| | | { |
| | | if (string.IsNullOrEmpty(orderNo)) |
| | | { |
| | | object obj = Repository.QueryPage(x => true, pageNo, 10, new Dictionary<string, OrderByType> { { nameof(Dt_InboundOrder.CreateDate), OrderByType.Desc } }).Rows.Select(x => new |
| | | object obj = Repository.QueryPage(x => x.OrderType == orderType, pageNo, 10, new Dictionary<string, OrderByType> { { nameof(Dt_InboundOrder.CreateDate), OrderByType.Desc } }).Rows.Select(x => new |
| | | { |
| | | x.OrderNo, |
| | | x.UpperOrderNo, |
| | |
| | | } |
| | | else |
| | | { |
| | | object obj = Repository.QueryPage(x => x.OrderNo == orderNo, pageNo, 10, new Dictionary<string, OrderByType> { { nameof(Dt_InboundOrder.CreateDate), OrderByType.Desc } }).Rows.Select(x => new |
| | | object obj = Repository.QueryPage(x => x.OrderNo.Contains(orderNo), pageNo, 10, new Dictionary<string, OrderByType> { { nameof(Dt_InboundOrder.CreateDate), OrderByType.Desc } }).Rows.Select(x => new |
| | | { |
| | | x.OrderNo, |
| | | x.UpperOrderNo, |
| | |
| | | return WebResponseContent.Instance.OK(data: obj); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent QueryOrderDetailInfo(int pageNo, string orderNo) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | Dt_InboundOrder inboundOrder = GetInboundOrder(orderNo); |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details; |
| | | content.OK(data: inboundOrderDetails); |
| | | return content; |
| | | } |
| | | } |
| | | } |