pan
2025-11-18 ca881f5c16de3e6e63c4bd07f65d362cbac18c20
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -16,6 +16,7 @@
#endregion << ç‰ˆ æœ¬ æ³¨ é‡Š >>
using AutoMapper;
using Dm.filter;
using MailKit.Search;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
@@ -119,6 +120,7 @@
            try
            {
                Dt_Task task;
                if (int.TryParse(taskNum, out var newTaskNum))
                {
                    task = BaseDal.QueryFirst(x => x.TaskNum == newTaskNum);
@@ -131,6 +133,7 @@
                {
                    return WebResponseContent.Instance.Error("未找到任务信息");
                }
                _logger.LogInformation($"TaskService TaskCompleted: {JsonConvert.SerializeObject(task)} , {task.TaskType} ");
                MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted");
                if (methodInfo != null)
@@ -145,6 +148,7 @@
            }
            catch (Exception ex)
            {
                _logger.LogError($"TaskService TaskCompleted:  {ex.Message} ");
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
@@ -305,18 +309,25 @@
            _locationInfoService.Repository.UpdateData(locationInfo);
            var outloks = _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>().Where(x => x.TaskNum == task.TaskNum).ToList();
            outloks.ForEach(o =>
            {
                o.Status = OutLockStockStatusEnum.已出库.ObjToInt();
            });
            _outStockLockInfoService.Db.Updateable(outloks).ExecuteCommand();
            var locationCodes = outloks.Select(it => it.LocationCode).Distinct().ToList();
            var stockids = outloks.Select(x => x.StockId).ToList();
            _stockService.StockInfoService.Db.Updateable<Dt_StockInfo>()
                                  .SetColumns(it => new Dt_StockInfo
                                  {
                                      StockStatus = StockStatusEmun.出库锁定.ObjToInt()
                                  })
                                  .Where(it => stockids.Contains(it.Id))
                                  .ExecuteCommand();
            //_stockRepository.Db.Updateable<Dt_StockInfo>()
            //  .SetColumns(it => new Dt_StockInfo { StockStatus = StockStatusEmun.})
            //  .Where(it => locationCodes.Contains(it.LocationCode))
            //  .ExecuteCommand();
            _stockService.StockInfoDetailService.Db.Updateable<Dt_StockInfoDetail>()
                                  .SetColumns(it => new Dt_StockInfoDetail
                                  {
                                      Status = StockStatusEmun.出库锁定.ObjToInt()
                                  })
                                  .Where(it => stockids.Contains( it.StockId))
                                  .ExecuteCommand();
            return WebResponseContent.Instance.OK();
@@ -376,10 +387,48 @@
            }
        }
        public  WebResponseContent InPickTaskCompleted(Dt_Task task)
        public WebResponseContent InPickTaskCompleted(Dt_Task task)
        {
            _logger.LogInformation($"TaskService  InPickTaskCompleted: {task.TaskNum}");
            //查库存
            Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == task.PalletCode).First();
            if (stockInfo == null)
            {
                return WebResponseContent.Instance.Error($"未找到托盘对应的组盘信息");
            }
            if (stockInfo.Details.Count == 0 && stockInfo.PalletType != PalletTypeEnum.Empty.ObjToInt())
            {
                return WebResponseContent.Instance.Error($"未找到该托盘库存明细信息");
            }
            //查货位
            Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
            if (locationInfo == null)
            {
                return WebResponseContent.Instance.Error($"未找到对应的终点货位信息");
            }
            stockInfo.LocationCode = task.TargetAddress;
            stockInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt();
            stockInfo.Details.ForEach(x =>
            {
                x.Status = StockStatusEmun.入库完成.ObjToInt();
            });
            _stockService.StockInfoService.Repository.UpdateData(stockInfo);
            _stockService.StockInfoDetailService.Repository.UpdateData(stockInfo.Details);
            if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt())
            {
                locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt();
            }
            else
            {
                locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
            }
            _locationInfoService.Repository.UpdateData(locationInfo);
            task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
            BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
            return WebResponseContent.Instance.OK();
        }
@@ -421,6 +470,7 @@
            }
            catch (Exception ex)
            {
                _logger.LogError($"TaskService OutEmptyTaskCompleted:  {ex.Message} ");
                return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message));
            }
        }