dengjunjie
2025-04-19 9e579eda4601ed7b492b9d19a24e8146f6ebdf8d
ÏîÄ¿´úÂë/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
{
@@ -35,6 +38,64 @@
        {
            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组盘
        /// å•种物料组盘