| | |
| | | } |
| | | |
| | | //var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel"); |
| | | var outBoundMateriel = _dt_ChangeoversRepository.QueryData(x => x.Status == "1").ToList(); |
| | | //var outBoundMateriel = _dt_ChangeoversRepository.QueryData(x => x.Status == "1").ToList(); |
| | | |
| | | List<string>? materielCodes = outBoundMateriel.Count != 0 |
| | | ? outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == area.AreaCode) |
| | | .Select(x => x.MaterielCode) |
| | | .ToList() |
| | | : null; |
| | | //List<string>? materielCodes = outBoundMateriel.Count != 0 |
| | | // ? outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == area.AreaCode) |
| | | // .Select(x => x.MaterielCode) |
| | | // .ToList() |
| | | // : null; |
| | | |
| | | var result = new DtStockInfo(); |
| | | //DtStockInfo result = null; |
| | | |
| | | var stockInfoList = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | .Includes(x => x.LocationInfo) |
| | | //.Includes(x => x.StockInfoDetails) |
| | | .Where(x => x.AreaCode == areaCode && x.OutboundTime < DateTime.Now && x.IsFull) |
| | |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) |
| | | //.WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) |
| | | .OrderBy(x => x.OutboundTime) |
| | | .ToListAsync(); |
| | | foreach (var stock in stockInfoList) |
| | | { |
| | | var hasMatchingDetail = await _stockInfoRepository.Db.Queryable<DtStockInfoDetail>() |
| | | .Where(d => d.StockId == stock.Id && materielCodes.Contains(d.MaterielCode)) |
| | | .AnyAsync(); |
| | | .FirstAsync(); |
| | | //foreach (var stock in stockInfoList) |
| | | //{ |
| | | // var hasMatchingDetail = await _stockInfoRepository.Db.Queryable<DtStockInfoDetail>() |
| | | // .Where(d => d.StockId == stock.Id && materielCodes.Contains(d.MaterielCode)) |
| | | // .AnyAsync(); |
| | | |
| | | if (hasMatchingDetail) |
| | | { |
| | | result = stock; |
| | | break; |
| | | } |
| | | } |
| | | // if (hasMatchingDetail) |
| | | // { |
| | | // result = stock; |
| | | // break; |
| | | // } |
| | | //} |
| | | |
| | | if (result.IsNullOrEmpty()) |
| | | ConsoleHelper.WriteErrorLine($"{area.AreaName}-{productionLine}查询实盘库存信息失败:未找到符合条件的数据"); |
| | |
| | | ConsoleHelper.WriteErrorLine(content.ToJsonString()); |
| | | var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | if (result == null || !result.Success) return content.Error(result?.MOMMessage ?? "Deserialization error"); |
| | | |
| | | List<string> strings = station.productLine.Split(",").ToList(); |
| | | if (!result.ProductionLine.Contains(strings)) |
| | | { |
| | | ConsoleHelper.WriteErrorLine($"托盘号【{palletCode}】请求产线【{result.ProductionLine}】不允许入【{station.Roadway}】"); |
| | | return content.Error($"托盘号【{palletCode}】请求产线【{result.ProductionLine}】不允许入【{station.Roadway}】"); |
| | | } |
| | | |
| | | if (result.SerialNos.Count > 0) |
| | | { |
| | |
| | | .Where(x => x.DeviceStatus == 1.ToString() && process.Contains(x.DeviceCode)) |
| | | .Select(x => x.DeviceCode).ToListAsync(); |
| | | |
| | | var minGroup = _locationRepository.QueryData(x => deviceCode.Contains(x.RoadwayNo) && x.LocationStatus == (int)LocationEnum.Free) |
| | | var minGroup = _locationRepository.QueryData(x => deviceCode.Contains(x.RoadwayNo) && x.LocationStatus == (int)LocationEnum.Free && x.EnalbeStatus == (int)EnableEnum.Enable) |
| | | .GroupBy(x => x.RoadwayNo) |
| | | .OrderByDescending(g => g.Count()) // 根据每个组的元素数量排序 |
| | | .ToList(); // 取出数量最多的组 |
| | |
| | | foreach (var item in minGroup) |
| | | { |
| | | var number = BaseDal.QueryData(x => x.TargetAddress == item.Key).Count(); |
| | | if (item.Count() - number <= 0) |
| | | { |
| | | continue; |
| | | } |
| | | result.Add(item.Key, item.Count() - number); |
| | | } |
| | | |