From 6d9829c889a826d39cbc911ef5d01825edd1bffc Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 26 六月 2025 16:33:29 +0800
Subject: [PATCH] 添加设备交互日志

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |  351 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 293 insertions(+), 58 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 263ca5b..bc247f5 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"
@@ -17,6 +17,7 @@
 
 using AutoMapper;
 using MailKit.Search;
+using Newtonsoft.Json;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
 using SqlSugar;
 using System;
@@ -29,6 +30,7 @@
 using System.Text;
 using System.Threading.Tasks;
 using System.Transactions;
+using WIDESEA_Common.StockEnum;
 using WIDESEA_Common.TaskEnum;
 using WIDESEA_Core;
 using WIDESEA_Core.BaseRepository;
@@ -37,6 +39,7 @@
 using WIDESEA_Core.Helper;
 using WIDESEA_DTO.Inbound;
 using WIDESEA_DTO.Stock;
+using WIDESEA_DTO.WCSInfo;
 using WIDESEA_IBasicRepository;
 using WIDESEA_IBasicService;
 using WIDESEA_IInboundService;
@@ -48,6 +51,7 @@
 using WIDESEA_ITaskInfoRepository;
 using WIDESEA_ITaskInfoService;
 using WIDESEA_Model.Models;
+using WIDESEA_OutboundRepository;
 using WIDESEA_TaskInfoRepository;
 using WIDESEAWCS_DTO.WCSInfo;
 
@@ -247,6 +251,72 @@
 
             return WebResponseContent.Instance.OK();
         }
+        public WebResponseContent ModifyBarcode(string barcode, string newBarcode)
+        {
+            WebResponseContent webResponseContent = new WebResponseContent();
+            try
+            {
+                Dt_Task? dt_Task = BaseDal.QueryFirst(x => x.PalletCode == barcode);
+                if (dt_Task == null) throw new Exception($"鏈壘鍒版墭鐩樺彿涓恒�恵barcode}銆戠殑浠诲姟锛�");
+                if (TaskEnumHelper.GetTaskTypeGroup(dt_Task.TaskType) != TaskTypeGroup.InboundGroup)
+                    throw new Exception($"鍙彲淇敼鍏ュ簱浠诲姟,濡傞渶淇敼鍏朵粬浠诲姟绫诲瀷璇疯仈绯荤鐞嗗憳锛�");
+                var stock = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == newBarcode);
+                if (stock != null) throw new Exception($"鎵樼洏鍙枫�恵newBarcode}銆戝凡瀛樺湪搴撳瓨淇℃伅锛�");
+                stock = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == barcode);
+                if (stock == null) throw new Exception($"鎵樼洏鍙枫�恵barcode}銆戞湭鎵惧埌搴撳瓨淇℃伅锛�");
+                stock.PalletCode = newBarcode;
+                dt_Task.PalletCode = newBarcode;
+                Db.Ado.BeginTran();
+                WMSTaskDTO wMSTaskDTOs = _mapper.Map<WMSTaskDTO>(dt_Task);
+                var ResultData = HttpHelper.PostAsync(WCSInterfaceAddress.ModifyBarcode, 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);
+                BaseDal.UpdateData(dt_Task);
+                _stockService.StockInfoService.Repository.UpdateData(stock);
+                Db.Ado.CommitTran();
+                webResponseContent.OK();
+            }
+            catch (Exception ex)
+            {
+                Db.Ado.RollbackTran();
+                webResponseContent.Error(ex.Message);
+            }
+            return webResponseContent;
+        }
+        public WebResponseContent CancelTask(WMSTaskDTO WMStask)
+        {
+            WebResponseContent webResponseContent = new WebResponseContent();
+            try
+            {
+                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == WMStask.TaskNum && x.TaskType == WMStask.TaskType);
+                if (task == null) return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�");
+                Dt_StockInfo? _StockInfo = _stockService.StockInfoService.GetStockByPalletCode(task.PalletCode);
+                if (_StockInfo != null)
+                {
+                    Dt_StockInfoDetail? detail = _StockInfo.Details.FirstOrDefault();
+                    if (detail != null)
+                    {
+                        Dt_InboundOrder dt_InboundOrder = _inboundService.InbounOrderService.GetInboundOrder(detail.OrderNo);
+                        Dt_InboundOrderDetail? inboundOrderDetail = dt_InboundOrder.Details.FirstOrDefault(x => x.BatchNo == detail.BatchNo);
+                        if (inboundOrderDetail != null)
+                        {
+                            inboundOrderDetail.ReceiptQuantity--;
+                            _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail);
+                        }
+                        _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(_StockInfo.Details, OperateType.AGV鍒犻櫎);
+                    }
+                    _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(_StockInfo, OperateType.AGV鍒犻櫎);
+                }
+                BaseDal.DeleteAndMoveIntoHty(task, /*App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 :*/ OperateType.AGV鍒犻櫎);
+            }
+            catch (Exception ex)
+            {
+                webResponseContent.Error(ex.Message);
+            }
+            return webResponseContent;
+        }
         /// <summary>
         /// 鍚屾浠诲姟鐘舵��
         /// </summary>
@@ -260,30 +330,48 @@
             {
                 Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == WMStask.TaskNum && x.TaskType == WMStask.TaskType);
                 if (task == null) return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�");
-                if (task.TaskType == (int)TaskTypeEnum.Inbound)
+                if (TaskEnumHelper.GetTaskTypeGroup(task.TaskType) == TaskTypeGroup.InboundGroup)
                 {
                     int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>();
-                    if (WMStask.TaskState != nextStatus) return WebResponseContent.Instance.Error($"璇ヤ换鍔$姸鎬佹湁璇�,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟鐘舵��:銆恵task.TaskState}銆�");
+                    //if (WMStask.TaskState != nextStatus) return WebResponseContent.Instance.Error($"璇ヤ换鍔$姸鎬佹湁璇�,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟鐘舵��:銆恵task.TaskState}銆�");
                     //task.TaskState = nextStatus;
                     task.TaskState = TaskInStatusEnum.InFinish.ObjToInt();
                     content = UpdateTaskStatusInFinish(task);
                 }
-                else if (task.TaskType == (int)TaskTypeEnum.Outbound)
+                else if (TaskEnumHelper.GetTaskTypeGroup(task.TaskType) == TaskTypeGroup.OutbondGroup)
                 {
-                    int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskOutStatusEnum>();
-                    if (WMStask.TaskState != nextStatus) return WebResponseContent.Instance.Error($"璇ヤ换鍔$姸鎬佹湁璇�,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟鐘舵��:銆恵task.TaskState}銆�");
-                    task.TaskState = nextStatus;
-                    switch (nextStatus)
+                    //int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskOutStatusEnum>();
+                    //if (WMStask.TaskState != nextStatus) return WebResponseContent.Instance.Error($"璇ヤ换鍔$姸鎬佹湁璇�,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟鐘舵��:銆恵task.TaskState}銆�");
+                    //task.TaskState = nextStatus;
+                    task.TaskState = WMStask.TaskState;
+                    switch (task.TaskState)
                     {
-                        case (int)TaskOutStatusEnum.SC_OutFinish://鏇存柊璐т綅淇℃伅
+                        case (int)TaskOutStatusEnum.SC_OutFinish://鏇存柊璐т綅搴撳瓨淇℃伅
+                            UpdateTaskStatusSC_OutFinish(task);
+                            break;
+                        case (int)TaskOutStatusEnum.AGV_OutFinish:
+                            {
+                                task.CurrentAddress = WMStask.CurrentAddress;
+                                task.TargetAddress = WMStask.TargetAddress;
+                                task.NextAddress = string.Empty;
+                                UpdateData(task);
+                            }
+                            break;
+                        case (int)TaskOutStatusEnum.OutFinish:
+                            UpdateTaskStatusOutFinish(task);
                             break;
                         default:
+                            UpdateData(task);
                             break;
                     }
                 }
                 else if (task.TaskType == (int)TaskTypeEnum.Relocation)
                 {
-
+                    task.TaskState = WMStask.TaskState;
+                    if (task.TaskState == (int)WIDESEA_Core.Enums.TaskRelocationStatusEnum.SC_RelocationFinish)
+                        content = UpdateTaskStatusRelocationCarFinish(task);
+                    else
+                        content = UpdateData(task);
                 }
             }
             catch (Exception ex)
@@ -292,9 +380,155 @@
             }
             return content;
         }
-
         /// <summary>
-        /// 鏇存柊浠诲姟鐘舵�佸畬鎴�
+        /// 淇敼浠诲姟鐘舵�佷负鍫嗗灈鏈哄嚭搴撳畬鎴�
+        /// </summary>
+        /// <param name="task"></param>
+        /// <returns></returns>
+        public WebResponseContent UpdateTaskStatusSC_OutFinish(Dt_Task task)
+        {
+            try
+            {
+                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode);
+                Dt_LocationInfo Sourcelocation = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);
+                Dt_OutStockLockInfo outStockLockInfo = _outboundService.OutboundStockLockInfoService.Repository.QueryFirst(x => x.TaskNum == task.TaskNum);
+                Db.Ado.BeginTran();
+                if (stockInfo != null)
+                {
+                    _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                    _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                }
+                if (Sourcelocation != null)
+                {
+                    /*if (task.TaskType == TaskOutboundTypeEnum.Outbound.ObjToInt())*/
+                    if (BaseDal.QueryFirst(x => x.SourceAddress == task.SourceAddress && x.TaskState < TaskOutStatusEnum.SC_OutFinish.ObjToInt()) == null)
+                        Sourcelocation.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
+                    Sourcelocation.CurrentQty--;
+                    if (Sourcelocation.CurrentQty <= 0)
+                    {
+                        Sourcelocation.CurrentQty = 0;
+                        Sourcelocation.LocationStatus = LocationStatusEnum.Free.ObjToInt();
+                        Sourcelocation.EnableStatus = EnableStatusEnum.Normal.ObjToInt();
+                    }
+                    _basicService.LocationInfoService.Repository.UpdateData(Sourcelocation);
+                }
+                if (outStockLockInfo != null)
+                {
+                    outStockLockInfo.Status = OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt();
+                    _outboundService.OutboundStockLockInfoService.Repository.UpdateData(outStockLockInfo);
+                }
+                UpdateData(task);
+                Db.Ado.CommitTran();
+                return WebResponseContent.Instance.OK();
+            }
+            catch (Exception ex)
+            {
+                Db.Ado.RollbackTran();
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+        /// <summary>
+        /// 鏇存柊鍑哄簱浠诲姟鐘舵�佸畬鎴�
+        /// </summary>
+        /// <param name="task"></param>
+        /// <returns></returns>
+        public WebResponseContent UpdateTaskStatusOutFinish(Dt_Task task)
+        {
+            try
+            {
+                Db.Ado.BeginTran();
+                Dt_OutStockLockInfo? outStockLockInfo = _outboundService.OutboundStockLockInfoService.Repository.QueryFirst(x => x.TaskNum == task.TaskNum);
+                Dt_OutboundOrder? outboundOrder = null;
+                Dt_OutboundOrderDetail? outboundOrderDetail = null;
+                int overCount = 0;
+                if (outStockLockInfo != null)
+                {
+                    outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == outStockLockInfo.OrderDetailId);
+                    if (outboundOrderDetail != null)
+                    {
+                        outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == outboundOrderDetail.OrderId).Includes(x => x.Details).First();
+                        if (outboundOrder != null)
+                        {
+                            outboundOrderDetail.OverOutQuantity++;
+                            overCount = outboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count();
+                            if (outboundOrderDetail.OverOutQuantity == outboundOrderDetail.OrderQuantity)
+                            {
+                                outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
+                                overCount++;
+                            }
+                        }
+                    }
+                    outStockLockInfo.Status = OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
+                }
+                if (outboundOrder != null && outboundOrder.Details.Count == overCount)
+                {
+                    outboundOrder.OrderStatus = OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
+                    _outboundService.OutboundOrderDetailService.Repository.DeleteAndMoveIntoHty(outboundOrder.Details, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                    outboundOrder.Details = null;
+                    _outboundService.OutboundOrderService.Repository.DeleteAndMoveIntoHty(outboundOrder, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                }
+                else
+                {
+                    if (outboundOrderDetail != null)
+                        _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetail);
+                }
+                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                if (outStockLockInfo != null) _outboundService.OutboundStockLockInfoService.Repository.UpdateData(outStockLockInfo);
+                Db.Ado.CommitTran();
+                return WebResponseContent.Instance.OK();
+            }
+            catch (Exception ex)
+            {
+                Db.Ado.RollbackTran();
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+        /// <summary>
+        /// 鏇存柊绉诲簱浠诲姟鐘舵�佸畬鎴�
+        /// </summary>
+        /// <param name="task"></param>
+        /// <returns></returns>
+        public WebResponseContent UpdateTaskStatusRelocationCarFinish(Dt_Task task)
+        {
+            try
+            {
+                Dt_LocationInfo Sourcelocation = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);//璧峰璐т綅
+                Dt_LocationInfo Targetlocation = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);//鐩爣璐т綅
+                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode);//鎵樼洏搴撳瓨
+                Sourcelocation.CurrentQty--;
+                Targetlocation.CurrentQty++;
+                stockInfo.LocationCode = Targetlocation.LocationCode;
+                stockInfo.SerialNumber = Targetlocation.CurrentQty;
+                stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt();
+                if (Sourcelocation.CurrentQty == 0) Sourcelocation.LocationStatus = LocationStatusEnum.Free.ObjToInt();
+                Dt_Task _Task = BaseDal.QueryFirst(x => x.TaskNum != task.TaskNum && x.TaskType == task.TaskType && x.SourceAddress == Sourcelocation.LocationCode && x.TargetAddress == Targetlocation.LocationCode);
+                if (_Task == null)
+                {
+                    if (Targetlocation.CurrentQty == Targetlocation.MaxQty) Targetlocation.LocationStatus = LocationStatusEnum.Fullload.ObjToInt();
+                    else Targetlocation.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
+                    if (Sourcelocation.CurrentQty == 0) Sourcelocation.LocationStatus = LocationStatusEnum.Free.ObjToInt();
+                }
+                task.CurrentAddress = task.NextAddress;
+                task.NextAddress = string.Empty;
+                task.ModifyDate = DateTime.Now;
+                task.Modifier = "System";
+                Db.Ado.BeginTran();
+                _basicService.LocationInfoService.Repository.UpdateData(Sourcelocation);
+                _basicService.LocationInfoService.Repository.UpdateData(Targetlocation);
+                _stockService.StockInfoService.Repository.UpdateData(stockInfo);
+                //BaseDal.DeleteAndMoveIntoHty(task, OperateType.鑷姩瀹屾垚);
+                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                Db.Ado.CommitTran();
+                return WebResponseContent.Instance.OK();
+            }
+            catch (Exception ex)
+            {
+                Db.Ado.RollbackTran();
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+        /// <summary>
+        /// 鏇存柊鍏ュ簱浠诲姟鐘舵�佸畬鎴�
         /// </summary>
         /// <param name="WMStask"></param>
         /// <returns></returns>
@@ -312,24 +546,58 @@
                 if (stockInfo.StockStatus != StockStatusEmun.鍏ュ簱涓�.ObjToInt()) throw new Exception($"鎵樼洏[{task.PalletCode}],璇ョ粍鐩樼姸鎬佷笉鍙叆搴�");
                 Dt_StockInfoDetail stockInfoDetail = stockInfo.Details.FirstOrDefault(x => x.StockId == stockInfo.Id);
 
+                List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.Repository.LocationCodesGetStockInfos(new List<string> { stockInfo.LocationCode }).Where(x => x.StockStatus == StockStatusEmun.宸插叆搴�.ObjToInt()).ToList();
+                if (task.TaskType == TaskTypeEnum.PalletInbound.ObjToInt())
+                {
+                    stockInfo.SerialNumber = stockInfos.Count + 1;
+                    stockInfo.InDate = DateTime.Now;
+                    stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt();
+                    stockInfoDetail.Status = StockStatusEmun.宸插叆搴�.ObjToInt();
+                    locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt();
+                    task.CurrentAddress = task.NextAddress;
+                    task.NextAddress = string.Empty;
+                    Db.Ado.BeginTran();
+                    BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
+                    _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
+                    _stockService.StockInfoService.Repository.UpdateData(stockInfo);
+                    _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail);
+                    Db.Ado.CommitTran();
+                    return content;
+                }
+
+                Db.Ado.BeginTran();
                 #region 鍏ュ簱鍗�
                 Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(stockInfoDetail.OrderNo);
-                if (inboundOrder == null || inboundOrder.Details == null) throw new Exception($"鏈壘鍒版墭鐩榌{task.PalletCode}]鐨勫叆搴撳崟鏄庣粏淇℃伅");
-                Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfoDetail.BatchNo && x.MaterielCode == stockInfoDetail.MaterielCode);
-                inboundOrderDetail.OverInQuantity++;
-                inboundOrderDetail.OrderDetailStatus = inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity ? OrderDetailStatusEnum.Over.ObjToInt() : OrderDetailStatusEnum.GroupAndInbound.ObjToInt();
+                if (inboundOrder != null)
+                {
+                    Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfoDetail.BatchNo && x.MaterielCode == stockInfoDetail.MaterielCode);
+                    if (inboundOrderDetail != null)
+                        inboundOrderDetail.OrderDetailStatus = inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity ? OrderDetailStatusEnum.Over.ObjToInt() : OrderDetailStatusEnum.GroupAndInbound.ObjToInt();
 
-                if (inboundOrder.Details.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) == null)
-                {
-                    inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
+                    if (inboundOrder.Details.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) == null)
+                    {
+                        inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
+                    }
+                    else if (inboundOrder.OrderStatus == InboundStatusEnum.鏈紑濮�.ObjToInt())
+                    {
+                        inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱涓�.ObjToInt();
+                    }
+                    if (inboundOrder.OrderStatus != InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+                    {
+                        _inboundService.InbounOrderService.Repository.UpdateData(inboundOrder);
+                        if (inboundOrderDetail != null)
+                            _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail);
+                    }
+                    else
+                    {
+                        List<Dt_InboundOrderDetail> orderDetails = inboundOrder.Details;
+                        inboundOrder.Details = null;
+                        _inboundService.InbounOrderService.Repository.DeleteAndMoveIntoHty(inboundOrder, OperateType.鑷姩瀹屾垚);
+                        _inboundService.InboundOrderDetailService.Repository.DeleteAndMoveIntoHty(orderDetails, OperateType.鑷姩瀹屾垚);
+                    }
                 }
-                else if (inboundOrder.OrderStatus == InboundStatusEnum.鏈紑濮�.ObjToInt())
-                {
-                    inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱涓�.ObjToInt();
-                }
+
                 #endregion
-
-                List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.Repository.LocationCodesGetStockInfos(new List<string> { stockInfo.LocationCode }).Where(x => x.StockStatus == StockStatusEmun.宸插叆搴�.ObjToInt()).ToList();
                 stockInfo.SerialNumber = stockInfos.Count + 1;
                 stockInfo.InDate = DateTime.Now;
                 stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt();
@@ -338,48 +606,15 @@
                 locationInfo.LocationStatus = locationInfo.MaxQty - locationInfo.CurrentQty == 0 ? LocationStatusEnum.Fullload.ObjToInt() : LocationStatusEnum.InStock.ObjToInt();
                 task.CurrentAddress = task.NextAddress;
                 task.NextAddress = string.Empty;
-                Db.Ado.BeginTran();
-                #region 浠诲姟鍜屽叆搴撳崟
-                //BaseDal.UpdateData(task);
-                BaseDal.DeleteAndMoveIntoHty(task, OperateType.鑷姩瀹屾垚);
-                if (inboundOrder.OrderStatus != InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
-                {
-                    _inboundService.InbounOrderService.Repository.UpdateData(inboundOrder);
-                    _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail);
-                }
-                else
-                {
-                    _inboundService.InbounOrderService.Repository.DeleteAndMoveIntoHty(inboundOrder, OperateType.鑷姩瀹屾垚);
-                    _inboundService.InboundOrderDetailService.Repository.DeleteAndMoveIntoHty(inboundOrder.Details, OperateType.鑷姩瀹屾垚);
-                }
-                #endregion
+                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
                 _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
                 _stockService.StockInfoService.Repository.UpdateData(stockInfo);
                 _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail);
-                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
                 Db.Ado.CommitTran();
             }
             catch (Exception ex)
             {
                 Db.Ado.RollbackTran();
-                content.Error(ex.Message);
-            }
-            return content;
-        }
-        /// <summary>
-        /// 鏇存柊浠诲姟鐘舵�佹墽琛�
-        /// </summary>
-        /// <param name="WMStask"></param>
-        /// <returns></returns>
-        public WebResponseContent UpdateTaskStatusExecuting(Dt_Task task)
-        {
-            WebResponseContent content = new WebResponseContent().OK();
-            try
-            {
-
-            }
-            catch (Exception ex)
-            {
                 content.Error(ex.Message);
             }
             return content;

--
Gitblit v1.9.3