wanshenmean
2025-04-16 29f20b28392d212c04c0c40a512894f8622cfa53
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -20,6 +20,7 @@
    /// <returns>包含任务信息的响应内容</returns>
    public async Task<WebResponseContent> RequestInTask(RequestTaskDto input)
    {
        Console.WriteLine($"{JsonConvert.SerializeObject(input)}");
        // 创建一个WebResponseContent对象
        WebResponseContent content = new WebResponseContent();
        try
@@ -562,6 +563,12 @@
                Creater = "System",
                ProductionLine = stockInfo.ProductionLine,
            };
            var location = _locationRepository.QueryFirst(x => x.Id == stockInfo.LocationId);
            if (location == null) return null;
            location.LocationStatus = (int)LocationEnum.InStockDisable;
            _locationRepository.UpdateData(location);
            return task;
        }
        catch (Exception ex)
@@ -609,7 +616,7 @@
    {
        try
        {
            //if (stationManager.stationType == 15) throw new Exception("");
            if (stationManager.stationType != 15) throw new Exception("");
            // 创建一个TrayCellsStatusDto对象,并赋值
            TrayCellsStatusDto trayCells = new TrayCellsStatusDto()
@@ -972,17 +979,17 @@
            .ToList().Select(x => x.DeviceCode).ToList();
        var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>()
                                .IncludesAllFirstLayer().Where(x => x.ProductionLine == productLine)
                                .Where(x => x.AreaCode == areaCode && x.IsFull == false)
                                .Where(x => x.StockInfoDetails != null && x.StockInfoDetails.Any(y => y.MaterielCode == "空托盘"))
                                .WhereIF(!deviceCode.IsNullOrEmpty(), x => x.LocationInfo != null && deviceCode.Contains(x.LocationInfo.RoadwayNo))
                                .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件
                                .Includes(x => x.LocationInfo)
                                .Includes(x => x.StockInfoDetails)
                                .Where(x => x.AreaCode == areaCode && x.IsFull == false && x.ProductionLine == productLine)
                                .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo))
                                .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件
                                .Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "空托盘"))
                                .OrderBy(x => x.CreateDate) // 排序
                                .FirstAsync();
        if (result.IsNullOrEmpty())
            ConsoleHelper.WriteColorLine($"常温{productLine}空托盘库存不足", ConsoleColor.Red);
        return result;
    }
@@ -1012,24 +1019,24 @@
                .Where(x => x.DeviceCode.Contains("CWSC")) // 过滤条件
                .ToList().Select(x => x.DeviceCode).ToList();
            // 修改后的查询代码
            var stockInfo = await _stockInfoRepository.Db.Queryable<DtStockInfo>()
                                .IncludesAllFirstLayer()
                                .Includes(x => x.LocationInfo)
                                .Includes(x => x.StockInfoDetails)
                                .Where(x => x.ProductionLine == station.productLine)
                                .Where(x => x.AreaCode == "CWSC3" && x.IsFull == true)
                                // 增加对 LocationInfo 的空值检查
                                .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock)
                                .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock)
                                // 增加对 LocationInfo 的空值检查
                                .WhereIF(!deviceCode.IsNullOrEmpty(), x => x.LocationInfo != null && deviceCode.Contains(x.LocationInfo.RoadwayNo))
                                .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo))
                                .OrderBy(x => x.OutboundTime)
                                .FirstAsync();
            if (stockInfo.IsNullOrEmpty()) throw new Exception($"库内{station.productLine}无满足条件的库存可出库");
            if (stockInfo.IsNullOrEmpty()) throw new Exception($"CWSC3库内{station.productLine}无满足条件的库存可出库");
            DtLocationInfo locationInfo = _locationRepository.QueryFirst(x => x.AreaId == 5 && x.LocationCode == stockInfo.LocationCode);
            Dt_StationManager OutStation = _stationManagerRepository.QueryFirst(x => x.stationPLC == "1016" && x.stationType == 10 && x.Roadway == locationInfo.RoadwayNo && x.stationStatus == "1");
            Dt_StationManager OutStation = _stationManagerRepository.QueryFirst(x => x.stationPLC == "1005" && x.stationType == 10 && x.Roadway == locationInfo.RoadwayNo && x.stationStatus == "1");
            // 创建新任务实例
            var task = new Dt_Task
@@ -1059,7 +1066,6 @@
            BaseDal.AddData(task);
            stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable;
            _locationRepository.UpdateData(stockInfo.LocationInfo);
            _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(stockInfo.LocationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum);