dengjunjie
2025-03-12 f43b7df8400f4fcffc9f19dca0888d61e2b33d5f
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs
@@ -47,43 +47,43 @@
        /// </summary>
        /// <param name="materielGroupDTO"></param>
        /// <returns></returns>
        public WebResponseContent PdaAddEmptyStockInfo(PdaMaterielGroupDTO materielGroupDTO)
        public WebResponseContent PdaAddEmptyStockInfo(string barcode)
        {
            try
            {
                #region æ·»åŠ ä¸€ä¸ªç©ºæ‰˜ç»„ç›˜ä¿¡æ¯åŠç©ºæ‰˜ä»»åŠ¡å¹¶ä¸‹å‘ç»™WCS
                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(materielGroupDTO.PalletCode);
                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(barcode);
                if (stockInfo != null) throw new Exception($"托盘号【{stockInfo.PalletCode}】已存在组盘信息");
                Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == materielGroupDTO.PalletCode && x.TaskType == TaskTypeEnum.PalletInbound.ObjToInt());
                Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == barcode && x.TaskType == TaskTypeEnum.PalletInbound.ObjToInt());
                if (task == null)
                {
                    task = new Dt_Task()
                    {
                        CurrentAddress = "",
                        CurrentAddress = "1001",
                        NextAddress = "SC01",
                        SourceAddress = "",
                        SourceAddress = "1001",
                        TargetAddress = "SC01",
                        Creater = "System",
                        PalletCode = materielGroupDTO.PalletCode,
                        PalletCode = barcode,
                        Roadway = "SC01",
                        OrderNo = DateTime.Now.ToString("yyMMdd"),
                        TaskNum = _taskRepository.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                        TaskState = InTaskStatusEnum.InNew.ObjToInt(),
                        TaskState = InTaskStatusEnum.AGV_InFinish.ObjToInt(),
                        TaskType = TaskTypeEnum.PalletInbound.ObjToInt(),
                        CreateDate = DateTime.Now,
                        Dispatchertime = DateTime.Now,
                    };
                    Db.Ado.BeginTran();
                    _stockService.StockInfoService.AddStockEmpty(materielGroupDTO.PalletCode);
                    _stockService.StockInfoService.AddStockEmpty(barcode);
                    _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下发空托入库任务超时");
                    WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result);
                    if (content == null) throw new Exception($"下发空托入库任务WCS无响应");
                    if (!content.Status) throw new Exception(content.Message);
                    Db.Ado.CommitTran();
                }
                List<WMSTaskDTO> wMSTaskDTOs = _mapper.Map<List<WMSTaskDTO>>(task);
                var ResultData = HttpHelper.PostAsync(WCSInterfaceAddress.ReceiveTask, wMSTaskDTOs.ToJson(), headers: new Dictionary<string, string>());
                if (ResultData.Result == null) throw new Exception($"向WCS下发空托入库任务超时");
                WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result);
                if (content == null) throw new Exception($"下发空托入库任务WCS无响应");
                if (!content.Status) throw new Exception(content.Message);
                #endregion
                return WebResponseContent.Instance.OK();
            }