From c95029139c278f0d2980e6d67cab42f5331e8d06 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期五, 05 十二月 2025 08:35:04 +0800
Subject: [PATCH] 提交

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |  295 ++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 171 insertions(+), 124 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index cc02019..c72a941 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -84,6 +84,7 @@
         private readonly IRecordService _recordService;
         private readonly IAllocateService _allocateService;
         private readonly IInvokeMESService _invokeMESService;
+        private readonly ITask_HtyService _task_HtyService;
         public IRepository<Dt_Task> Repository => BaseDal;
 
         private Dictionary<string, SqlSugar.OrderByType> _taskOrderBy = new()
@@ -103,7 +104,7 @@
 
         public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList();
 
-        public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IMaterialUnitService materialUnitService) : base(BaseDal)
+        public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IMaterialUnitService materialUnitService, ITask_HtyService task_HtyService) : base(BaseDal)
         {
             _mapper = mapper;
             _unitOfWorkManage = unitOfWorkManage;
@@ -126,8 +127,21 @@
             _allocateOrderDetailRepository = allocateOrderDetailRepository;
             _allocateOrderRepository = allocateOrderRepository;
             _materialUnitService = materialUnitService;
+            _task_HtyService = task_HtyService;
         }
 
+        public async Task TaskStatusChange(string taskNum,TaskStatusEnum taskStatusEnum)
+        {
+            if (int.TryParse(taskNum, out var newTaskNum))
+            {
+                await Db.Updateable<Dt_Task>().SetColumns(it => new Dt_Task {
+                        TaskStatus = taskStatusEnum.ObjToInt()
+                    })
+                    .Where(it => it.TaskNum == newTaskNum)
+                    .ExecuteCommandAsync();
+            }
+              
+        }
 
         /// <summary>
         /// 
@@ -276,8 +290,12 @@
 
             task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
 
-            BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
-
+            //  BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+            var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐鍒犻櫎);
+            if (!result)
+            {
+                await Db.Deleteable(task).ExecuteCommandAsync();
+            }
             _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
 
             _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, WIDESEA_Common.StockEnum.StockChangeType.MaterielGroup);
@@ -325,8 +343,8 @@
                                }).ToList();
                             allocatefeedmodel.Details = groupedData;
 
-                            var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
-                            if (result != null && result.code == 200)
+                            var feedbackresult = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
+                            if (feedbackresult != null && feedbackresult.code == 200)
                             {
                                 _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
                                 .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
@@ -381,8 +399,8 @@
                                }).ToList();
                             allocatefeedmodel.Details = groupedData;
 
-                            var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
-                            if (result != null && result.code == 200)
+                            var feedbackresult = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
+                            if (feedbackresult != null && feedbackresult.code == 200)
                             {
                                 _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
                                 .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
@@ -429,8 +447,8 @@
                                }).ToList();
                             feedmodel.details = groupedData;
 
-                            var result = await _invokeMESService.FeedbackInbound(feedmodel);
-                            if (result != null && result.code == 200)
+                            var feedbackresult = await _invokeMESService.FeedbackInbound(feedmodel);
+                            if (feedbackresult != null && feedbackresult.code == 200)
                             {
                                 _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
                                 .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
@@ -536,8 +554,12 @@
                 var outboundOrder = _outboundOrderService.Db.Queryable<Dt_OutboundOrder>().First(x => x.OrderNo == task.OrderNo);
 
                 task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
-                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
-
+                // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+                var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐鍒犻櫎);
+                if (!result)
+                {
+                    await Db.Deleteable(task).ExecuteCommandAsync();
+                }
                 _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforelocationStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
 
 
@@ -645,14 +667,18 @@
                     locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                 }
 
-                _locationInfoService.Repository.UpdateData(locationInfo);                       
+                _locationInfoService.Repository.UpdateData(locationInfo);
 
                 task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
 
                 // 鍒犻櫎浠诲姟璁板綍
-                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
-                BaseDal.DeleteData(task);
-
+                //BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+                //BaseDal.DeleteData(task);
+                var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐鍒犻櫎);
+                if (!result)
+                {
+                    await Db.Deleteable(task).ExecuteCommandAsync();
+                }
                 // 璁板綍璐т綅鐘舵�佸彉鏇�
                 _locationStatusChangeRecordService.AddLocationStatusChangeRecord(
                     locationInfo,
@@ -749,7 +775,7 @@
                         await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
                             .SetColumns(it => new Dt_OutboundOrderDetail
                             {
-                                LockQuantity = currentLockQty, 
+                                LockQuantity = currentLockQty,
                             })
                             .Where(it => it.Id == detailId)
                             .ExecuteCommandAsync();
@@ -831,17 +857,17 @@
                 int newStatus = orderDetail.OrderDetailStatus;
 
                 // 鏍规嵁瀹為檯鏋氫妇鍊艰皟鏁�
-                // 1. 妫�鏌ユ槸鍚﹀凡瀹屾垚锛堝凡鍑哄簱鏁伴噺 >= 闇�姹傛暟閲忥級
+                //  妫�鏌ユ槸鍚﹀凡瀹屾垚锛堝凡鍑哄簱鏁伴噺 >= 闇�姹傛暟閲忥級
                 if (orderDetail.OverOutQuantity >= orderDetail.NeedOutQuantity)
                 {
                     newStatus = (int)OrderDetailStatusEnum.Over; // 宸插畬鎴�
                 }
-                // 2. 妫�鏌ユ槸鍚︽湁閮ㄥ垎鍑哄簱鎴栨湁閿佸畾鏁伴噺
+                //  妫�鏌ユ槸鍚︽湁閮ㄥ垎鍑哄簱鎴栨湁閿佸畾鏁伴噺
                 else if (orderDetail.OverOutQuantity > 0 || orderDetail.LockQuantity > 0)
                 {
                     newStatus = (int)OrderDetailStatusEnum.Outbound; // 閮ㄥ垎瀹屾垚/杩涜涓�
                 }
-                // 3. 鍚﹀垯涓烘柊璁㈠崟
+                // 鍚﹀垯涓烘柊璁㈠崟
                 else
                 {
                     newStatus = (int)OrderDetailStatusEnum.New; // 鏂板缓
@@ -853,7 +879,7 @@
                     await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
                         .SetColumns(it => new Dt_OutboundOrderDetail
                         {
-                            OrderDetailStatus = newStatus, 
+                            OrderDetailStatus = newStatus,
                         })
                         .Where(it => it.Id == orderDetail.Id)
                         .ExecuteCommandAsync();
@@ -940,7 +966,7 @@
                         .SetColumns(x => new Dt_OutboundOrder
                         {
                             OrderStatus = newStatus,
-                            Operator = App.User.UserName, 
+                            Operator = App.User.UserName,
                         })
                         .Where(x => x.OrderNo == orderNo)
                         .ExecuteCommandAsync();
@@ -1049,52 +1075,55 @@
                                 MaterialCode = detail.MaterielCode,
                                 LineNo = detail.lineNo,
                                 WarehouseCode = detail.WarehouseCode,
-                                Qty =0,
+                                Qty = 0,
                                 Unit = detail.BarcodeUnit,
                                 Barcodes = new List<BarcodeInfo>()
                             };
                             foreach (var item in detailLocks)
                             {
-                                var barModel = new BarcodeInfo
+                                if (item.PickedQty > 0)
                                 {
-                                    Barcode = item.CurrentBarcode,
-                                    SupplyCode = item.SupplyCode,
-                                    BatchNo = item.BatchNo,
-                                    Unit = detail.BarcodeUnit,
-                                    Qty = 0
-                                };
-                                // 鍗曚綅涓嶄竴鑷存椂杞崲
-                                if (detail.BarcodeUnit != detail.Unit)
-                                {
-                                    var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, detail.Unit, detail.BarcodeUnit);
-                                    barModel.Unit = convertResult.Unit;
-                                    barModel.Qty = convertResult.Quantity;
+                                    var barModel = new BarcodeInfo
+                                    {
+                                        Barcode = item.CurrentBarcode,
+                                        SupplyCode = item.SupplyCode,
+                                        BatchNo = item.BatchNo,
+                                        Unit = detail.BarcodeUnit,
+                                        Qty = 0
+                                    };
+                                    // 鍗曚綅涓嶄竴鑷存椂杞崲
+                                    if (detail.BarcodeUnit != detail.Unit)
+                                    {
+                                        var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, detail.Unit, detail.BarcodeUnit);
+                                        barModel.Unit = convertResult.Unit;
+                                        barModel.Qty = convertResult.Quantity;
+                                    }
+                                    else
+                                    {
+                                        barModel.Qty = item.PickedQty;
+                                    }
+                                    detailModel.Qty += barModel.Qty;
+                                    detailModel.Barcodes.Add(barModel);
                                 }
-                                else
-                                {
-                                    barModel.Qty = item.PickedQty;
-                                }
-                                detailModel.Qty += barModel.Qty;
-                                detailModel.Barcodes.Add(barModel);
+
+
+                                allocatefeedmodel.Details.Add(detailModel);
                             }
 
+                            var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
+                            if (result != null && result.code == 200)
+                            {
+                                await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+                                       .SetColumns(x => x.ReturnToMESStatus == 1)
+                                       .Where(x => x.OrderId == outboundOrder.Id).ExecuteCommandAsync();
 
-                            allocatefeedmodel.Details.Add(detailModel);
-                        }
-
-                        var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
-                        if (result != null && result.code == 200)
-                        {
-                            await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
-                                   .SetColumns(x => x.ReturnToMESStatus == 1)
-                                   .Where(x => x.OrderId == outboundOrder.Id).ExecuteCommandAsync();
-
-                            await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
-                                  .SetColumns(x => new Dt_OutboundOrder
-                                  {
-                                      ReturnToMESStatus = 1,
-                                      Operator = App.User.UserName,
-                                  }).Where(x => x.OrderNo == orderNo).ExecuteCommandAsync();
+                                await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+                                      .SetColumns(x => new Dt_OutboundOrder
+                                      {
+                                          ReturnToMESStatus = 1,
+                                          Operator = App.User.UserName,
+                                      }).Where(x => x.OrderNo == orderNo).ExecuteCommandAsync();
+                            }
                         }
                     }
                     else if (outboundOrder.OrderType == OutOrderTypeEnum.ReCheck.ObjToInt())
@@ -1103,81 +1132,90 @@
                     }
                     else
                     {
-                        var feedmodel = new FeedbackOutboundRequestModel
+                        if (outboundOrder != null && outboundOrder.IsBatch == 0)
                         {
-                            reqCode = Guid.NewGuid().ToString(),
-                            reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
-                            business_type = outboundOrder.BusinessType,
-                            factoryArea = outboundOrder.FactoryArea,
-                            operationType = 1,
-                            Operator = outboundOrder.Operator,
-                            orderNo = outboundOrder.UpperOrderNo,
-                            documentsNO = outboundOrder.OrderNo,
-                            status = outboundOrder.OrderStatus,
-                            details = new List<FeedbackOutboundDetailsModel>()
-                        };
-
-
-                        foreach (var detail in orderDetails)
-                        {
-                            // 鑾峰彇璇ユ槑缁嗗搴旂殑鏉$爜淇℃伅锛堜粠閿佸畾璁板綍锛�
-                            var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
-                                .Where(x => x.OrderNo == orderNo &&
-                                           x.OrderDetailId == detail.Id &&
-                                           (x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴� || x.Status == (int)OutLockStockStatusEnum.宸插洖搴�))
-                                .ToListAsync();
-
-                            var detailModel = new FeedbackOutboundDetailsModel
+                            var feedmodel = new FeedbackOutboundRequestModel
                             {
-                                materialCode = detail.MaterielCode,
-                                lineNo = detail.lineNo, // 娉ㄦ剰锛氳繖閲屽彲鑳介渶瑕佽皟鏁村瓧娈靛悕
-                                warehouseCode = detail.WarehouseCode,
-                                qty = 0,
-                                currentDeliveryQty =0,
-                                unit = detail.Unit,
-                                barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>()
+                                reqCode = Guid.NewGuid().ToString(),
+                                reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                                business_type = outboundOrder.BusinessType,
+                                factoryArea = outboundOrder.FactoryArea,
+                                operationType = 1,
+                                Operator = outboundOrder.Operator,
+                                orderNo = outboundOrder.UpperOrderNo,
+                                documentsNO = outboundOrder.OrderNo,
+                                status = outboundOrder.OrderStatus,
+                                details = new List<FeedbackOutboundDetailsModel>()
                             };
-                            foreach (var item in detailLocks)
+                            foreach (var detail in orderDetails)
                             {
-                                var barModel = new WIDESEA_DTO.Outbound.BarcodesModel
+                                // 鑾峰彇璇ユ槑缁嗗搴旂殑鏉$爜淇℃伅锛堜粠閿佸畾璁板綍锛�
+                                var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+                                    .Where(x => x.OrderNo == orderNo &&
+                                               x.OrderDetailId == detail.Id &&
+                                               (x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴� || x.Status == (int)OutLockStockStatusEnum.宸插洖搴�))
+                                    .ToListAsync();
+
+                                var detailModel = new FeedbackOutboundDetailsModel
                                 {
-                                    barcode = item.CurrentBarcode,
-                                    supplyCode = item.SupplyCode,
-                                    batchNo = item.BatchNo,
-                                    unit = detail.BarcodeUnit,
-                                    qty = item.PickedQty
+                                    materialCode = detail.MaterielCode,
+                                    lineNo = detail.lineNo, // 娉ㄦ剰锛氳繖閲屽彲鑳介渶瑕佽皟鏁村瓧娈靛悕
+                                    warehouseCode = detail.WarehouseCode,
+                                    qty = 0,
+                                    currentDeliveryQty = 0,
+                                    unit = detail.Unit,
+                                    barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>()
                                 };
-                                // 鍗曚綅涓嶄竴鑷存椂杞崲
-                                if (detail.BarcodeUnit != detail.Unit)
+                                foreach (var item in detailLocks)
                                 {
-                                    var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, detail.Unit, detail.BarcodeUnit);
-                                    barModel.unit = convertResult.Unit;
-                                    barModel.qty = convertResult.Quantity;
+                                    if (item.PickedQty > 0)
+                                    {
+                                        var barModel = new WIDESEA_DTO.Outbound.BarcodesModel
+                                        {
+                                            barcode = item.CurrentBarcode,
+                                            supplyCode = item.SupplyCode,
+                                            batchNo = item.BatchNo,
+                                            unit = item.BarcodeUnit,
+                                            qty = item.PickedQty
+                                        };
+                                        // 鍗曚綅涓嶄竴鑷存椂杞崲
+                                        if (detail.BarcodeUnit != detail.Unit)
+                                        {
+                                            var convertResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.PickedQty, detail.Unit, detail.BarcodeUnit);
+                                            barModel.unit = convertResult.Unit;
+                                            barModel.qty = convertResult.Quantity;
+                                        }
+                                        else
+                                        {
+                                            barModel.qty = item.PickedQty;
+                                        }
+                                        detailModel.qty += barModel.qty;
+                                        detailModel.currentDeliveryQty += barModel.qty;
+                                        detailModel.barcodes.Add(barModel);
+                                    }
                                 }
-                                else
-                                {
-                                    barModel.qty = item.PickedQty;
-                                }
-
-                                    detailModel.qty += barModel.qty;
-                                detailModel.currentDeliveryQty += barModel.qty;
-                                detailModel.barcodes.Add(barModel);
+                                feedmodel.details.Add(detailModel);
                             }
-                            feedmodel.details.Add(detailModel);
-                        }
-                        var result = await _invokeMESService.FeedbackOutbound(feedmodel);
-                        if (result != null && result.code == 200)
-                        {
-                            await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
-                                .SetColumns(x => x.ReturnToMESStatus == 1)
-                                .Where(x => x.OrderId == outboundOrder.Id)
-                                .ExecuteCommandAsync();
 
-                            await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
-                                .SetColumns(x => x.ReturnToMESStatus == 1)
-                                .Where(x => x.OrderNo == orderNo)
-                                .ExecuteCommandAsync();
+                            var result = await _invokeMESService.FeedbackOutbound(feedmodel);
+                            if (result != null && result.code == 200)
+                            {
+                                await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+                                    .SetColumns(x => x.ReturnToMESStatus == 1)
+                                    .Where(x => x.OrderId == outboundOrder.Id)
+                                    .ExecuteCommandAsync();
+
+                                await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+                                    .SetColumns(x => x.ReturnToMESStatus == 1)
+                                    .Where(x => x.OrderNo == orderNo)
+                                    .ExecuteCommandAsync();
+                            }
                         }
+                        else if (outboundOrder != null && outboundOrder.IsBatch == 1)
+                        {
+                            await _invokeMESService.BatchOrderFeedbackToMes(new List<string>() { outboundOrder.OrderNo }, 2);
+                        }
+
                     }
                 }
             }
@@ -1215,9 +1253,18 @@
 
 
                 task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
-                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
-                _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
-                //_stockRepository.Db.Deleteable(stockInfo).ExecuteCommand();
+                // BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+                var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐鍒犻櫎);
+                if (!result)
+                {
+                    await Db.Deleteable(task).ExecuteCommandAsync();
+                }
+
+                var stockresult = _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+                if (!stockresult)
+                { 
+                    _stockRepository.Db.Deleteable(stockInfo).ExecuteCommand();
+                }
                 _stockService.StockInfoService.DeleteData(stockInfo);
                 _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum);
 

--
Gitblit v1.9.3