From bb56b2b6f21acb7c69c02585e5bc534d2f67715f Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 27 三月 2025 17:13:35 +0800
Subject: [PATCH] WMS首页优化,WCS优化AGV和产线、输送线交互逻辑

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderService.cs |   70 +++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 0 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderService.cs"
index 8b50922..736d0c0 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderService.cs"
@@ -1,6 +1,8 @@
 锘縰sing AutoMapper;
+using Microsoft.Extensions.Options;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -13,15 +15,83 @@
 using WIDESEA_Core.Utilities;
 using WIDESEA_DTO.Inbound;
 using WIDESEA_DTO.Outbound;
+using WIDESEA_DTO.Stock;
+using WIDESEA_DTO.WCSInfo;
 using WIDESEA_IBasicService;
 using WIDESEA_IOutboundRepository;
 using WIDESEA_IOutboundService;
 using WIDESEA_IStockService;
 using WIDESEA_Model.Models;
+using WIDESEAWCS_DTO.WCSInfo;
 
 namespace WIDESEA_OutboundService
 {
     public partial class OutboundOrderService : ServiceBase<Dt_OutboundOrder, IOutboundOrderRepository>, IOutboundOrderService
     {
+        /// <summary>
+        /// 绌烘墭鍑哄簱
+        /// </summary>
+        /// <returns></returns>
+        /// <exception cref="NotImplementedException"></exception>
+        public WebResponseContent PdaOutEmpty()
+        {
+            try
+            {
+                ISugarQueryable<Dt_StockInfo> sugarQueryable1 = _dbBase.Queryable<Dt_StockInfo>();
+                ISugarQueryable<Dt_StockInfoDetail> sugarQueryable2 = _dbBase.Queryable<Dt_StockInfoDetail>();
+                List<StockViewDTO1> list = sugarQueryable1.InnerJoin(sugarQueryable2, (a, b) => a.Id == b.StockId && b.MaterielName.Contains("绌烘墭鐩�") && a.StockStatus == StockStatusEmun.宸插叆搴�.ObjToInt()).Select((a, b) => new StockViewDTO1
+                {
+                    LocationCode = a.LocationCode,
+                    PalletCode = a.PalletCode,
+                    MaterielCode = b.MaterielCode,
+                    MaterielName = b.MaterielName,
+                    InDate = a.InDate,
+                    StockId = a.Id
+                }).ToList();
+                StockViewDTO1? stockViewDTO = list.OrderByDescending(x => x.InDate).FirstOrDefault();
+                if (stockViewDTO == null) throw new Exception("鏈壘鍒板彲鍑哄簱绌烘墭");
+                Dt_LocationInfo locationInfo = _dbBase.Queryable<Dt_LocationInfo>().Where(x => x.LocationCode == stockViewDTO.LocationCode).First();
+                if (locationInfo == null) throw new Exception($"鏈壘鍒拌揣浣嶃�恵stockViewDTO.LocationCode}銆戜俊鎭�");
+                Dt_StockInfo stockInfo = _stockService.Repository.QueryFirst(a => a.Id == stockViewDTO.StockId);
+                if (stockInfo == null) throw new Exception($"鏈壘鍒扮┖鎵樺簱瀛樹俊鎭�");
+                stockInfo.StockStatus = StockStatusEmun.鍑哄簱涓�.ObjToInt();
+                Dt_Task _Task = new Dt_Task()
+                {
+                    CurrentAddress = locationInfo.LocationCode,
+                    NextAddress = "SC01",
+                    SourceAddress = locationInfo.LocationCode,
+                    SourceIsPickPlace = locationInfo.Row == 1 ? false : locationInfo.CurrentQty == locationInfo.MaxQty,
+                    TargetIsPickPlace = false,
+                    TargetAddress = "1008",
+                    CreateDate = DateTime.Now,
+                    Creater = "System",
+                    PalletCode = stockViewDTO.PalletCode,
+                    Roadway = locationInfo.RoadwayNo,
+                    OrderNo = "",
+                    TaskNum = _taskRepository.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                    TaskState = OutTaskStatusEnum.OutNew.ObjToInt(),
+                    TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(),
+                    Dispatchertime = DateTime.Now,
+                };
+                locationInfo.CurrentQty--;
+                List<WMSTaskDTO> wMSTaskDTOs = _mapper.Map<List<WMSTaskDTO>>(new List<Dt_Task>() { _Task });
+                Db.Ado.BeginTran();
+                _basicRepository.LocationInfoRepository.UpdateData(locationInfo);
+                _stockService.Repository.UpdateData(stockInfo);
+                _taskRepository.AddData(_Task);
+                var ResultData = HttpHelper.PostAsync(WCSInterfaceAddress.ReceiveTask, wMSTaskDTOs.ToJson(), headers: new Dictionary<string, string>());
+                if (ResultData.Result == null) throw new Exception($"鍚慦CS涓嬪彂绌烘墭鍑哄簱浠诲姟瓒呮椂");
+                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();
+                return WebResponseContent.Instance.OK();
+            }
+            catch (Exception ex)
+            {
+                Db.Ado.RollbackTran();
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
     }
 }

--
Gitblit v1.9.3