1
huangxiaoqiang
2025-05-10 a1e23fe41d967b04a322c40a3f2d83a7633f92ec
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -3,6 +3,7 @@
using SixLabors.Fonts.Tables.AdvancedTypographic;
using SqlSugar;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using WIDESEA_Cache;
using WIDESEA_Core;
using WIDESEA_Core.Const;
@@ -352,7 +353,7 @@
        WebResponseContent content = new WebResponseContent();
        try
        {
            if (task.TaskType == (int)TaskInboundTypeEnum.InNG || task.TaskType == (int)TaskInboundTypeEnum.InQuality)
            if (task.TaskType == (int)TaskInboundTypeEnum.InNG)
            {
                task.TaskState = (int)TaskInStatusEnum.SC_InFinish;
                // 创建历史任务实例模型
@@ -419,6 +420,9 @@
            Console.WriteLine(err.Message.ToString());
            LogFactory.GetLog("任务完成").Error(true, err);
            content.Error(err.Message);
            task.ErrorMessage = err.Message;
            task.TaskState = (int)TaskInStatusEnum.SC_InExecuting;
            await BaseDal.Update(task);
        }
        return content;
    }
@@ -1646,6 +1650,28 @@
    #endregion
    #region 查询静置空闲库位
    public WebResponseContent QueryLocationFreeJZ(string RoadwayNo)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            var result = _locationRepository.QueryData(x => x.EnalbeStatus != (int)EnableEnum.Disable && x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo.Contains("JZSC"));
            LogFactory.GetLog($"静置{RoadwayNo}查询空闲库位").Info(true, $"{JsonConvert.SerializeObject(result)}");
            if (result.Count > 5)
            {
                return content.OK();
            }
            return content.Error("库位已满");
        }
        catch (Exception ex)
        {
            return content.Error(ex.Message);
        }
    }
    #endregion
    #region 大屏接口
    /// <summary>
@@ -2007,32 +2033,32 @@
            }
            #region 更新库存信息(暂时不需要)
            //if (stock.IsFull)
            //{
            //    // 查询符合条件的库存信息
            //    var stocks = _stockInfoRepository.QueryData(x => x.AreaCode == stock.AreaCode && x.ProductionLine == stock.ProductionLine && x.SpecialParameterDuration != stock.SpecialParameterDuration);
            if (stock.IsFull)
            {
                // 查询符合条件的库存信息
                var stocks = _stockInfoRepository.QueryData(x => x.AreaCode == stock.AreaCode && x.ProductionLine == stock.ProductionLine && x.SpecialParameterDuration != stock.SpecialParameterDuration);
            //    // 查询任务信息
            //    var tasks = BaseDal.QueryData(x => x.PalletCode != stock.PalletCode && x.ProductionLine == stock.ProductionLine).Select(x => x.PalletCode).ToList();
                // 查询任务信息
                var tasks = BaseDal.QueryData(x => x.PalletCode != stock.PalletCode && x.ProductionLine == stock.ProductionLine).Select(x => x.PalletCode).ToList();
            //    if (stocks != null && stocks.Count > 0)
            //    {
            //        // 过滤出需要更新的库存信息
            //        var stocksToUpdate = stocks.Where(item => !tasks.Contains(item.PalletCode)).ToList();
            //        foreach (var item in stocksToUpdate)
            //        {
            //            // 更新库存信息的特定参数
            //            item.SpecialParameterDuration = stock.SpecialParameterDuration;
            //            item.ParameterInfos = stock.ParameterInfos;
            //            item.OutboundTime = Convert.ToDateTime(item.LinedProcessFeedbackTime == null ? item.CreateDate : item.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(stock.SpecialParameterDuration));
            //        }
            //        if (stocksToUpdate.Count > 0)
            //        {
            //            // 异步更新库存信息
            //            var isUpdates = await _stockInfoRepository.UpdateDataAsync(stocksToUpdate);
            //        }
            //    }
            //}
                if (stocks != null && stocks.Count > 0)
                {
                    // 过滤出需要更新的库存信息
                    var stocksToUpdate = stocks.Where(item => !tasks.Contains(item.PalletCode)).ToList();
                    foreach (var item in stocksToUpdate)
                    {
                        // 更新库存信息的特定参数
                        item.SpecialParameterDuration = stock.SpecialParameterDuration;
                        item.ParameterInfos = stock.ParameterInfos;
                        item.OutboundTime = Convert.ToDateTime(item.LinedProcessFeedbackTime == null ? item.CreateDate : item.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(stock.SpecialParameterDuration));
                    }
                    if (stocksToUpdate.Count > 0)
                    {
                        // 异步更新库存信息
                        var isUpdates = await _stockInfoRepository.UpdateDataAsync(stocksToUpdate);
                    }
                }
            }
            #endregion
            // 添加历史任务