From cfb3f2c7e9cde8cc2eb2a19263d0802c0c5410a3 Mon Sep 17 00:00:00 2001
From: zhanghonglin <zhanghonglin@hnkhzn.com>
Date: 星期一, 06 四月 2026 15:41:04 +0800
Subject: [PATCH] mes接口

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |  149 +++++++++++++++++++++++--------------------------
 1 files changed, 70 insertions(+), 79 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index aa3cb9d..fca3355 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -8,6 +8,7 @@
 using System.Threading.Tasks;
 using Newtonsoft.Json;
 using WIDESEA_Common.LocationEnum;
+using WIDESEA_Common.OutboundOrder;
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Common.TaskEnum;
 using WIDESEA_Common.Warehouse;
@@ -22,7 +23,9 @@
 using WIDESEA_IStockService;
 using WIDESEA_Model.Models;
 using WIDESEA_Model.Models.Basic;
+using WIDESEA_Model.Models.Outbound;
 using WIDESEA_Model.Models.Stock;
+using WIDESEA_Model.View;
 using WIDESEAWCS_DTO.Stock;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models.TaskInfo;
@@ -44,10 +47,13 @@
         private readonly IRepository<Dt_StockInfoDetail> _IStockInfoDetailRepository;
         private readonly IRepository<Dt_StockInfo_hty> _IStockInfohtyRepository;
         private readonly IRepository<Dt_StockInfoDetail_Hty> _IStockInfoDetailHtyRepository;
+        private readonly IRepository<Dt_StockInfos> _IStockInfosRepository;
+        private readonly IRepository<Dt_FillingOrder> _FillingOrderRepository;
+        private readonly IRepository<Dt_OutboundOrder> _OutboundOrderRepository;
         //WCS婊℃《鍑哄簱淇″彿
         private static bool kk = false;
 
-        public TaskService(IRepository<Dt_Task> BaseDal, ILocationInfoService ILocationInfoService, IRepository<Dt_StockInfoDetail> IStockInfoDetailRepository, IRepository<Dt_StockInfo_hty> IStockInfohtyRepository, IRepository<Dt_StockInfoDetail_Hty> IStockInfoDetailHtyRepository, IRepository<Dt_Outstockinfo> IOutstockinfoService, IStockService IStockService, IRepository<Dt_Warehouse> WarehouseService, IRepository<Dt_Outstockinfo> OutstockinfoRepository, ILocationInfoService LocationInfoService, IRepository<Dt_StockInfo> StockInfoRepository, IRepository<Dt_LocationInfo> LocationInfoRepository, IRepository<Dt_Task_Hty> Task_HtyRepository, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
+        public TaskService(IRepository<Dt_Task> BaseDal, IRepository<Dt_OutboundOrder> OutboundOrderRepository, IRepository<Dt_FillingOrder> FillingOrderRepository, IRepository<Dt_StockInfos> IStockInfosRepository, ILocationInfoService ILocationInfoService, IRepository<Dt_StockInfoDetail> IStockInfoDetailRepository, IRepository<Dt_StockInfo_hty> IStockInfohtyRepository, IRepository<Dt_StockInfoDetail_Hty> IStockInfoDetailHtyRepository, IRepository<Dt_Outstockinfo> IOutstockinfoService, IStockService IStockService, IRepository<Dt_Warehouse> WarehouseService, IRepository<Dt_Outstockinfo> OutstockinfoRepository, ILocationInfoService LocationInfoService, IRepository<Dt_StockInfo> StockInfoRepository, IRepository<Dt_LocationInfo> LocationInfoRepository, IRepository<Dt_Task_Hty> Task_HtyRepository, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
         {
             _LocationInfoService = LocationInfoService;
             _unitOfWorkManage = unitOfWorkManage;
@@ -62,22 +68,20 @@
             _IStockInfoDetailRepository = IStockInfoDetailRepository;
             _IStockInfohtyRepository = IStockInfohtyRepository;
             _IStockInfoDetailHtyRepository = IStockInfoDetailHtyRepository;
+            _IStockInfosRepository = IStockInfosRepository;
+            _FillingOrderRepository = FillingOrderRepository;
+            _OutboundOrderRepository = OutboundOrderRepository;
         }
 
         public IRepository<Dt_Task> Repository => BaseDal;
 
 
         //娴嬭瘯
-        public WebResponseContent ceshi()
+        public string ceshi()
         {
             WebResponseContent content = new WebResponseContent();
-            string mes = AppSettings.Get("MSE");
-            if (!string.IsNullOrEmpty(mes))
-            {
-                string k = "";
-                HttpHelper.Get($"{mes}+{k}");
-            }
-                return content;
+            Dt_LocationInfo locations = _LocationInfoService.AllotLocationInfo(2);
+            return "123";
         }
 
 
@@ -119,67 +123,25 @@
             WebResponseContent content = new WebResponseContent();
             Dt_Task task = new Dt_Task();
             List<Dt_StockInfoDetail> stockInfoDetail = new List<Dt_StockInfoDetail>();
-            List<MESSockInfo> MESSocks = new List<MESSockInfo>();
+            //List<MESSockInfo> MESSocks = new List<MESSockInfo>();
 
             string materielDetailedid = stock.MaterialCode1 + DateTime.Now.ToString("mmss").ObjToInt();
-
-            //鍘籑ES鏌ヨ鐗╂枡缂栧彿璇︾粏淇℃伅
-            int h = 0;
-            string mes = AppSettings.Get("MSE");
-            if (!string.IsNullOrEmpty(mes))
-            {
-                if (stock.MaterialCode1 != null && !stock.MaterialCode1.Equals(""))
-                {
-                    MESSocks[0] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode1}"));
-                    stockInfoDetail[0].MaterielCode = stock.MaterialCode1;
-                }
-                if (stock.MaterialCode2 != null && !stock.MaterialCode2.Equals(""))
-                {
-                    MESSocks[1] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode2}"));
-                    h++;
-                    stockInfoDetail[1].MaterielCode = stock.MaterialCode2;
-                }
-                if (stock.MaterialCode3 != null && !stock.MaterialCode3.Equals(""))
-                {
-                    MESSocks[2] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode3}"));
-                    h++;
-                    stockInfoDetail[2].MaterielCode = stock.MaterialCode3;
-                }
-                if (stock.MaterialCode4 != null && !stock.MaterialCode4.Equals(""))
-                {
-                    MESSocks[3] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode4}"));
-                    h++;
-                    stockInfoDetail[3].MaterielCode = stock.MaterialCode4;
-                }
-            }
-            //瀛樺偍鐗╂枡缂栧彿璇︾粏淇℃伅
-            for(int m = 0; m <= h; m++)
-            {
-                stockInfoDetail[m].MaterielDetailedid = materielDetailedid;
-                stockInfoDetail[m].BarcodeType = MESSocks[m].BarcodeType;
-                stockInfoDetail[m].AuxQty = MESSocks[m].AuxQty;
-                stockInfoDetail[m].Quantity = MESSocks[m].Quantity;
-                stockInfoDetail[m].MaxQty = MESSocks[m].MaxQty;
-                stockInfoDetail[m].BarWeight = MESSocks[m].BarWeight;
-                stockInfoDetail[m].PackageQty = MESSocks[m].PackageQty;
-                stockInfoDetail[m].QuantityIn = MESSocks[m].QuantityIn;
-                stockInfoDetail[m].QuantityOut = MESSocks[m].QuantityOut;
-                stockInfoDetail[m].Status = MESSocks[m].Status;
-                stockInfoDetail[m].Materialld = MESSocks[m].Materialld;
-                stockInfoDetail[m].BatchNum = MESSocks[m].BatchNum;
-                stockInfoDetail[m].CreateEmpld = MESSocks[m].CreateEmpld;
-                stockInfoDetail[m].Taskld = MESSocks[m].Taskld;
-                stockInfoDetail[m].TaskSubld = MESSocks[m].TaskSubld;
-            }
-
+            string kk = stock.MaterialCode1.Replace("X", "");
             //鍖哄垎璐у尯
             int k = 1;
-            Dt_Warehouse warehouse = _WarehouseRepository.QueryFirst(x => x.MaterialName == "");
-            if (warehouse.MaterialType == (int)WarehouseTypeEnum.Food)
+            //鏌ヨ鐗╂枡浜岀淮缂栫爜
+            Dt_FillingOrder FillingOrder = _FillingOrderRepository.QueryFirst(x => x.BarCode == kk);
+            if (FillingOrder == null)
+            {
+                LogLock.OutLogAOP("鎺ュ彛鏃ュ織", new string[] { "婊℃《鍏ュ簱浠诲姟鐢熸垚", $"{"浜岀淮鐮佹煡璇㈠紓甯�"}" });
+                content.Message = "浜岀淮鐮佹煡璇㈠紓甯�";
+                return content;
+            }
+            if (FillingOrder.WarehouseType.Equals("椋熷搧鍖�"))
             {
                 k = 2;
             }
-            else if (warehouse.MaterialType == (int)WarehouseTypeEnum.Industry)
+            else if (FillingOrder.WarehouseType.Equals("宸ヤ笟鍖�"))
             {
                 k = 3;
             }
@@ -197,7 +159,7 @@
             stockInfo.MaterielCode3 = stock.MaterialCode3;
             stockInfo.MaterielCode4 = stock.MaterialCode4;
             stockInfo.MaterielDetailedid = materielDetailedid;
-            stockInfo.StockType = (int)StockTypeEmun.姘�;
+            stockInfo.MaterielName = FillingOrder.MaterialName;
             //鍒涘缓鐗╂枡璇︾粏淇℃伅
 
             //鍒ゅ畾鍏ュ簱妯″紡
@@ -311,7 +273,7 @@
                 taskhty.Grade = task.Grade;
                 taskhty.Remark = task.Remark;
                 taskhty.TaskType = task.TaskType;
-                taskhty.TaskState = task.TaskState;
+                taskhty.TaskState = (int)TaskStatusEnum.Task_Finish;
 
                 //寮�濮嬫暟鎹簱浜嬪姟
                 _unitOfWorkManage.BeginTran();
@@ -377,7 +339,7 @@
                 stockInfo_Hty.MaterielDetailedid = stockInfo.MaterielDetailedid;
                 List<Dt_StockInfoDetail_Hty> stockInfoDetail_Hty = new List<Dt_StockInfoDetail_Hty>();
                 int k = stockInfoDetail.Count() - 1;
-                for(int i = 0; i <= k; i++)
+                for (int i = 0; i <= k; i++)
                 {
                     stockInfoDetail_Hty[i].MaterielCode = stockInfoDetail[i].MaterielCode;
                     stockInfoDetail_Hty[i].MaterielDetailedid = stockInfoDetail[i].MaterielDetailedid;
@@ -422,7 +384,7 @@
                 _unitOfWorkManage.CommitTran();
             }
             //鐩存帴鍑哄簱
-            else if(task.TaskType == (int)TaskTypeEnum.OutDirect)
+            else if (task.TaskType == (int)TaskTypeEnum.OutDirect)
             {
                 //鍒犻櫎搴撳瓨淇℃伅
                 Dt_StockInfo stockInfo = _StockInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress);
@@ -536,6 +498,10 @@
             Dt_Task task = new Dt_Task();
             //鍑哄簱鍒嗛厤鐗╂枡
             Dt_LocationInfo locations = _LocationInfoService.AllotStock(1);
+            if (locations == null)
+            {
+                return content;
+            }
             locations.LocationStatus = (int)LocationStatusEnum.Lock;
 
             task.SourceAddress = locations.LocationCode;
@@ -562,31 +528,39 @@
         }
 
         //鏍规嵁鏁伴噺鍜岀绫讳笅鍙戞弧妗跺嚭搴撲换鍔�
-        public WebResponseContent ArtificialTask(int Num, int Type)
+        public WebResponseContent ArtificialTask(int Num, string Types)
         {
             WebResponseContent content = new WebResponseContent();
             List<Dt_Task> tasks = new List<Dt_Task>();
             List<Dt_LocationInfo> LocationInfo = new List<Dt_LocationInfo>();
             List<Dt_StockInfo> StockInfo = new List<Dt_StockInfo>();
 
-            if (Num > 0 && Type > 0 && kk == true)
+            if (Num > 0 && !Types.Equals("") && Types != null && kk == true)
             {
                 Dt_Outstockinfo outstockinfo = _OutstockinfoRepository.QueryFirst(x => x.Id == 1);
                 //婊�
                 if (outstockinfo.BigOrLittle == 1)
                 {
                     //鑾峰彇骞堕攣瀹氱墿鏂�
-                    StockInfo = _IStockService.PriorityBig(Num, Type);
+                    StockInfo = _IStockService.PriorityBig(Num, Types);
+                    if (StockInfo == null || StockInfo.Count <= 0)
+                    {
+                        StockInfo = _IStockService.PriorityLittle(Num, Types);
+                    }
                 }
                 //娈�
                 else
                 {
                     //鑾峰彇骞堕攣瀹氱墿鏂�
-                    StockInfo = _IStockService.PriorityLittle(Num, Type);
+                    StockInfo = _IStockService.PriorityLittle(Num, Types);
+                    if (StockInfo == null || StockInfo.Count <= 0)
+                    {
+                        StockInfo = _IStockService.PriorityBig(Num, Types);
+                    }
                 }
 
                 //鍒涘缓浠诲姟
-                if (StockInfo != null)
+                if (StockInfo != null && StockInfo.Count > 0)
                 {
                     //鑾峰彇骞堕攣瀹氳揣浣�
                     LocationInfo = _ILocationInfoService.StockLockLocation(StockInfo);
@@ -595,7 +569,7 @@
                 }
                 else
                 {
-                    return WebResponseContent.Instance.Error($"鐗╂枡涓嶈冻");
+                    return content.Error("鐗╂枡涓嶈冻");
                 }
 
                 //寮�濮嬫暟鎹簱浜嬪姟
@@ -614,7 +588,8 @@
             }
             else
             {
-                LogLock.OutLogAOP("鎺ュ彛鏃ュ織", new string[] { "涓嬪彂鏁伴噺銆佺绫绘垨淇″彿寮傚父"});
+                LogLock.OutLogAOP("鎺ュ彛鏃ュ織", new string[] { "涓嬪彂鏁伴噺銆佺绫绘垨淇″彿寮傚父" });
+                return content.Error("涓嬪彂鏁伴噺銆佺绫绘垨淇″彿寮傚父");
             }
             return content;
         }
@@ -762,19 +737,20 @@
         }
 
         //澶у睆鐢佃鏌ヨ浠诲姟
-        public List<Dt_Task_Hty> selectTask()
+        public List<Dt_Task> selectTask()
         {
-            List<Dt_Task_Hty> task = new List<Dt_Task_Hty>();
-            task = _Task_HtyRepository.QueryData().OrderByDescending(t => t.CreateDate).ToList();
+            List<Dt_Task> task = new List<Dt_Task>();
+            task = BaseDal.QueryData().OrderByDescending(t => t.CreateDate).ToList();
             return task;
         }
 
         //WCS婊℃《鍑哄簱淇″彿
         public WebResponseContent WCSSignal(int k)
         {
-            WebResponseContent content=new WebResponseContent();
+            WebResponseContent content = new WebResponseContent();
             //鍙互鍑�
-            if (k == 1) {
+            if (k == 1)
+            {
                 kk = true;
             }
             //涓嶅彲浠ュ嚭
@@ -785,5 +761,20 @@
 
             return content;
         }
+
+        //鎵ц璁㈠崟
+        public string ExecuteOrder(int k)
+        {
+            WebResponseContent content = new WebResponseContent();
+            Dt_OutboundOrder OutboundOrder = _OutboundOrderRepository.QueryFirst(x => x.Id == k);
+            //涓嬪彂浠诲姟
+            content = ArtificialTask(OutboundOrder.num, OutboundOrder.MaterielName);
+            if (content.Message == null || content.Message.Equals(""))
+            {
+                OutboundOrder.BoundOrderStatue = (int)OutboundOrderEnum.Execute;
+                _OutboundOrderRepository.UpdateData(OutboundOrder);
+            }
+            return content.Message;
+        }
     }
 }

--
Gitblit v1.9.3