| | |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; |
| | | using SixLabors.Fonts.Tables.AdvancedTypographic; |
| | | using System.Diagnostics; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.MOM; |
| | |
| | | } |
| | | } |
| | | |
| | | //if (input.area != 3) |
| | | //{ |
| | | // if (input.PalletCode == null || input.PalletCode.Trim() == "") |
| | | // return content.Error("托盘条码为空"); |
| | | //} |
| | | //创建一个TrayCellsStatusDto对象,并赋值 |
| | | //TrayCellsStatusDto trayCells = new TrayCellsStatusDto() |
| | | //{ |
| | |
| | | |
| | | if (stationinfo == null) throw new Exception("未知站台"); |
| | | |
| | | |
| | | if (stationinfo.stationType != 7) |
| | | { |
| | | if (input.PalletCode == null || input.PalletCode.Trim() == "") |
| | | return content.Error($"【{stationinfo.remark}】托盘条码为空"); |
| | | } |
| | | var task = await CreateNewTaskByStation(input, stationinfo); |
| | | |
| | | // 创建新任务实例 |
| | |
| | | }; |
| | | content.OK(data: taskDTO); |
| | | |
| | | |
| | | |
| | | } |
| | | else |
| | | content.Error("添加任务失败"); |
| | |
| | | case 1: |
| | | task = await CreateInTaskAsync(input, stationManager); break; |
| | | //case 2: |
| | | //case 3: //异常排出给WCS处理 |
| | | case 3: //异常排出给WCS处理 |
| | | //case 4: |
| | | case 5: |
| | | task = await CreateInToOutTaskAsync(input, stationManager); break; |
| | |
| | | #region 直接出库任务 |
| | | private async Task<Dt_Task> CreateInToOutTaskAsync(RequestTaskDto input, Dt_StationManager stationManager) |
| | | { |
| | | if (stationManager.stationType != 5) throw new Exception("错误的调取"); |
| | | //if (stationManager.stationType != 5) throw new Exception("错误的调取"); |
| | | |
| | | |
| | | input.EquiCodeMOM = "24MEJQ11-1006-1"; |
| | | |
| | | // 创建一个TrayCellsStatusDto对象,并赋值 |
| | | TrayCellsStatusDto trayCells = new TrayCellsStatusDto() |
| | | { |
| | | Software = "WMS", |
| | | TrayBarcode = input.PalletCode, |
| | | //EquipmentCode = "EQ_CWJZ01" |
| | | EquipmentCode = input.EquiCodeMOM |
| | | }; |
| | | |
| | | // 调用GetTrayCellStatusAsync方法,获取整盘电芯 |
| | | WebResponseContent content = await GetTrayCellStatusAsync(trayCells); |
| | | // 如果状态为false,则返回content |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | |
| | | // 添加组盘信息 |
| | | // 将content.Data转换为ResultTrayCellsStatus对象 |
| | | var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | if (result.SerialNos.Count <= 0) |
| | | { |
| | | ConsoleHelper.WriteErrorLine(result.MOMMessage); |
| | | if (stationManager.stationType != 3) |
| | | { |
| | | var taskNG = new Dt_Task |
| | | { |
| | | CurrentAddress = input.Position, |
| | | Grade = 1, |
| | | Roadway = input.Roadways, |
| | | TargetAddress = stationManager.stationNGLocation, |
| | | Dispatchertime = DateTime.Now, |
| | | MaterialNo = "", |
| | | NextAddress = stationManager.stationNGChildCode, |
| | | OrderNo = null, |
| | | PalletCode = input.PalletCode, |
| | | SourceAddress = stationManager.stationLocation, |
| | | TaskState = (int)TaskInStatusEnum.Line_InFinish, |
| | | TaskType = (int)TaskOutboundTypeEnum.InToOut, |
| | | TaskNum = await BaseDal.GetTaskNo(), |
| | | Creater = "Systeam" |
| | | }; |
| | | return taskNG; |
| | | } |
| | | } |
| | | |
| | | // 处理异常电芯情况 |
| | | var serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1).ToList(); |
| | | if (serialNosError.Count > 0) |
| | | { |
| | | if (stationManager.stationType != 3) |
| | | { |
| | | var taskNG = new Dt_Task |
| | | { |
| | | CurrentAddress = input.Position, |
| | | Grade = 1, |
| | | Roadway = input.Roadways, |
| | | TargetAddress = stationManager.stationNGLocation, |
| | | Dispatchertime = DateTime.Now, |
| | | MaterialNo = "", |
| | | NextAddress = stationManager.stationNGChildCode, |
| | | OrderNo = null, |
| | | PalletCode = input.PalletCode, |
| | | SourceAddress = stationManager.stationLocation, |
| | | TaskState = (int)TaskInStatusEnum.Line_InFinish, |
| | | TaskType = (int)TaskOutboundTypeEnum.OutNG, |
| | | TaskNum = await BaseDal.GetTaskNo(), |
| | | Creater = "Systeam" |
| | | }; |
| | | return taskNG; |
| | | } |
| | | } |
| | | |
| | | var targetStation = _stationManagerRepository.QueryFirst(x => x.stationPLC == stationManager.stationPLC && x.Roadway == stationManager.Roadway && x.stationType == 2); |
| | | |
| | |
| | | // 添加组盘信息 |
| | | // 将content.Data转换为ResultTrayCellsStatus对象 |
| | | var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | if (result.SerialNos.Count <= 0) throw new Exception(result.MOMMessage); |
| | | if (result.SerialNos.Count <= 0) |
| | | { |
| | | ConsoleHelper.WriteErrorLine(result.MOMMessage); |
| | | var taskNG = new Dt_Task |
| | | { |
| | | CurrentAddress = input.Position, |
| | | Grade = 1, |
| | | Roadway = input.Roadways, |
| | | TargetAddress = stationManager.stationNGLocation, |
| | | Dispatchertime = DateTime.Now, |
| | | MaterialNo = "", |
| | | NextAddress = stationManager.stationNGChildCode, |
| | | OrderNo = null, |
| | | PalletCode = input.PalletCode, |
| | | SourceAddress = stationManager.stationLocation, |
| | | TaskState = (int)TaskInStatusEnum.Line_InFinish, |
| | | TaskType = (int)TaskOutboundTypeEnum.InToOut, |
| | | TaskNum = await BaseDal.GetTaskNo(), |
| | | Creater = "Systeam" |
| | | }; |
| | | return taskNG; |
| | | } |
| | | |
| | | //Console.WriteLine(result); |
| | | //// TODO 获取本地料框属性与整盘电芯属性获取的值进行对比,如果一致则继续,否则返回错误信息 |
| | |
| | | TaskNum = await BaseDal.GetTaskNo(), |
| | | Creater = "Systeam" |
| | | }; |
| | | |
| | | ConsoleHelper.WriteSuccessLine($"修改前:" + locationInfo.LocationStatus.ToString()); |
| | | locationInfo.LocationStatus = (int)LocationEnum.FreeDisable; |
| | | ConsoleHelper.WriteSuccessLine($"修改后:" + locationInfo.LocationStatus.ToString()); |
| | | await UpdateLocationAsync(locationInfo); |
| | | |
| | | return task; |
| | |
| | | } |
| | | else |
| | | { |
| | | locations = await _locationRepository.QueryDataAsync(x => x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo == requestTask.Roadways && x.EnalbeStatus == 1 && x.LocationType == 1); |
| | | locations = await _locationRepository.QueryDataAsync(x => x.LocationStatus == (int)LocationEnum.Distribute && x.RoadwayNo == requestTask.Roadways && x.EnalbeStatus == 1 && x.LocationType == 1); |
| | | } |
| | | |
| | | if (locations == null) |
| | |
| | | MaterialNo = "", |
| | | NextAddress = input.Roadways, |
| | | OrderNo = null, |
| | | PalletCode = input.PalletCode, |
| | | PalletCode = stockinfo.PalletCode, |
| | | SourceAddress = stockinfo.LocationCode, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | TaskType = (int)TaskOutboundTypeEnum.OutTray, |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region 常温补空托盘至分容 |
| | | |
| | | public async Task<WebResponseContent> GetFROutTrayToCW(RequestTaskDto taskDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == taskDTO.Position); |
| | | var locations = _locationRepository.QueryData(x => x.RoadwayNo == station.Roadway && x.LocationStatus == (int)LocationEnum.Free && x.LocationType == 1); |
| | | |
| | | if (locations.Count > 10) |
| | | { |
| | | ConsoleHelper.WriteColorLine(locations.Count.ToString(), ConsoleColor.Blue); |
| | | |
| | | var location = locations.OrderBy(x => x.Layer).ThenBy(x => x.Column).ThenBy(x => x.Row).FirstOrDefault(); |
| | | |
| | | var stockInfo = await QueryStockInfoForEmptyTrayAsync("CWSC1", new List<string>()); |
| | | |
| | | if (stockInfo != null) |
| | | { |
| | | var task = CreateTask(stockInfo, taskDTO.Position, (int)TaskOutboundTypeEnum.OutTray); |
| | | |
| | | // 创建任务DTO |
| | | WMSTaskDTO wmsTask = CreateTaskDTO(task); |
| | | |
| | | // 更新库存位置状态为不可用 |
| | | stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | location.LocationStatus = (int)LocationEnum.Distribute; |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | | { |
| | | await BaseDal.AddDataAsync(task); |
| | | await _locationRepository.UpdateDataAsync(stockInfo.LocationInfo); |
| | | await _locationRepository.UpdateDataAsync(location); |
| | | }); |
| | | |
| | | // 返回成功响应 |
| | | return content.OK(data: wmsTask); |
| | | } |
| | | else |
| | | content.Error("常温空托盘数量不足"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | } |