1
dengjunjie
2025-03-11 c455612b03e6ecac994884dde5b5f4bc4909c181
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs
@@ -1,4 +1,5 @@
using AutoMapper;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -14,12 +15,14 @@
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
{
@@ -40,6 +43,57 @@
            return Db.UpdateNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
        }
        /// <summary>
        /// ç©ºæ‰˜ç»„盘入库
        /// </summary>
        /// <param name="materielGroupDTO"></param>
        /// <returns></returns>
        public WebResponseContent PdaAddEmptyStockInfo(PdaMaterielGroupDTO materielGroupDTO)
        {
            try
            {
                #region æ·»åŠ ä¸€ä¸ªç©ºæ‰˜ç»„ç›˜ä¿¡æ¯åŠç©ºæ‰˜ä»»åŠ¡å¹¶ä¸‹å‘ç»™WCS
                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(materielGroupDTO.PalletCode);
                if (stockInfo != null) throw new Exception($"托盘号【{stockInfo.PalletCode}】已存在组盘信息");
                Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == materielGroupDTO.PalletCode && x.TaskType == TaskTypeEnum.PalletInbound.ObjToInt());
                if (task == null)
                {
                    task = new Dt_Task()
                    {
                        CurrentAddress = "",
                        NextAddress = "SC01",
                        SourceAddress = "",
                        TargetAddress = "SC01",
                        Creater = "System",
                        PalletCode = materielGroupDTO.PalletCode,
                        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();
                    _stockService.StockInfoService.AddStockEmpty(materielGroupDTO.PalletCode);
                    _taskRepository.AddData(task);
                    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();
            }
            catch (Exception ex)
            {
                Db.Ado.RollbackTran();
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        /// <summary>
        /// PDA组盘
        /// å•种物料组盘
        /// </summary>