| | |
| | | .ToList().Select(x => x.DeviceCode).ToList(); |
| | | |
| | | var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | .Where(x => x.ProductionLine == station.productLine) |
| | | .WhereIF(!station.Roadway.Contains("JZSC"), x => x.ProductionLine == station.productLine) |
| | | .Where(x => x.AreaCode == areaCode && x.IsFull == false) |
| | | .Includes(x=>x.StockInfoDetails) |
| | | .Includes(x => x.StockInfoDetails) |
| | | .Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "空托盘")) |
| | | .Includes(x=>x.LocationInfo) |
| | | .Includes(x => x.LocationInfo) |
| | | .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) // 过滤条件 |
| | | .OrderBy(x => x.CreateDate) // 排序 |
| | |
| | | { |
| | | return new Dt_Task |
| | | { |
| | | Grade = tag == 104 ? (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC") ? 1 : 2) : (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC") ? 2 : 1), |
| | | Grade = tag == 104 ? (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC")|| stockInfo.LocationInfo.RoadwayNo.Contains("JZSC") ? 1 : 2) : (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC") || stockInfo.LocationInfo.RoadwayNo.Contains("JZSC") ? 2 : 1), |
| | | Roadway = stockInfo.LocationInfo.RoadwayNo, |
| | | TargetAddress = position, |
| | | Dispatchertime = DateTime.Now, |
| | |
| | | { |
| | | 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 > 0) |
| | | if (result.Count > 5) |
| | | { |
| | | return content.OK(); |
| | | } |
| | |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 获取货位状态 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent GetStockQuantity() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var location = _locationRepository.Db.Queryable<DtLocationInfo>().ToList(); |
| | | |
| | | return content.OK(data: location); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent Getproductionvolume() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var now = DateTime.Now; |
| | | var startOfDay = new DateTime(now.Year, now.Month, now.Day); |
| | | var endOfDay1 = startOfDay.AddDays(-7); |
| | | var taskHty = _task_HtyRepository.Db.Queryable<Dt_Task_Hty>().Where(it => it.CreateDate > endOfDay1).ToList(); |
| | | return content.OK(data: taskHty); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | public WebResponseContent Getoutput() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var now = DateTime.Now; |
| | | var firstDayOfYear = new DateTime(now.Year, 1, 1); |
| | | var taskHty = _task_HtyRepository.Db.Queryable<Dt_Task_Hty>().Where(it => it.CreateDate > firstDayOfYear&&it.TaskType==100).ToList(); |
| | | return content.OK(data: taskHty); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | public WebResponseContent GetTimeout() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var now = DateTime.Now; |
| | | // 使用Subtract方法 |
| | | var threeHoursAgo = now.Subtract(TimeSpan.FromHours(3)); |
| | | |
| | | List<DtStockInfo> dtStocks = _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | .Where(x => x.OutboundTime < threeHoursAgo).ToList(); |
| | | return content.OK1(total1: dtStocks.Count, data: dtStocks); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | public WebResponseContent Getproductionstatistics() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var now = DateTime.Now; |
| | | var thirtyDaysAgo = now.AddDays(-30); |
| | | var roadwayMappings = new Dictionary<string, string> { |
| | | { "JZ", "静置库" }, |
| | | { "CH", "陈化库" }, |
| | | { "FR", "分容库" }, |
| | | { "GW", "高温库" }, |
| | | { "CW", "常温库" } |
| | | }; |
| | | |
| | | var roadwayKeys = roadwayMappings.Keys.ToArray(); |
| | | |
| | | var taskHty = _task_HtyRepository.Db.Queryable<Dt_Task_Hty>() |
| | | .Where(it => |
| | | it.CreateDate >= thirtyDaysAgo && |
| | | it.CreateDate <= now && |
| | | it.TaskType == 100 && |
| | | roadwayKeys.Any(rk => it.Roadway.Contains(rk))) |
| | | .ToList() |
| | | .Select(t => new { |
| | | OriginalRoadway = t.Roadway, |
| | | MatchedKey = roadwayKeys.FirstOrDefault(rk => t.Roadway.Contains(rk)), |
| | | CreateDate = t.CreateDate |
| | | }) |
| | | .Where(t => t.MatchedKey != null) |
| | | .GroupBy(t => new { |
| | | RoadwayKey = t.MatchedKey, |
| | | Date = t.CreateDate.Date, |
| | | Hour = t.CreateDate.Hour |
| | | }) |
| | | .OrderByDescending(group => group.Key.Date) |
| | | .ThenByDescending(group => group.Key.Hour) |
| | | .Select(group => new { |
| | | Hour = $"{group.Key.Date:yyyy/M/d} {group.Key.Hour}:00", |
| | | Count = group.Count(), |
| | | Roadway = roadwayMappings[group.Key.RoadwayKey] // 映射为中文名称 |
| | | }) |
| | | .ToList(); |
| | | return content.OK1(total1: taskHty.Count, data: taskHty); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | #endregion 外部接口方法 |
| | | |
| | | #region 内部调用方法 |
| | |
| | | // 创建历史任务实例模型 |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key[0])); |
| | | if (task == null) |
| | | foreach (var item in key) |
| | | { |
| | | return content.Error("未找到任务信息!"); |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key)); |
| | | if (task == null) |
| | | { |
| | | return content.Error("未找到任务信息!"); |
| | | } |
| | | var taskHtyNG = CreateHistoricalTask(task, true); |
| | | |
| | | // 执行数据库事务 |
| | | |
| | | // 添加历史任务 |
| | | var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0; |
| | | |
| | | // 删除任务数据 |
| | | var isTaskDelete = BaseDal.Delete(task.TaskId); |
| | | } |
| | | var taskHtyNG = CreateHistoricalTask(task, true); |
| | | |
| | | // 执行数据库事务 |
| | | |
| | | // 添加历史任务 |
| | | var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0; |
| | | |
| | | // 删除任务数据 |
| | | var isTaskDelete = BaseDal.Delete(task.TaskId); |
| | | |
| | | return content.OK("删除成功!"); |
| | | } |
| | |
| | | } |
| | | |
| | | #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 |
| | | |
| | | // 添加历史任务 |