| | |
| | | using Mapster; |
| | | using Masuit.Tools; |
| | | using NewLife.Log; |
| | | using SqlSugar; |
| | | using System.Text.RegularExpressions; |
| | | using WIDESEA_Cache; |
| | |
| | | } |
| | | } |
| | | |
| | | private AgingOutputDto MapToAgingOutputDto(DtStockInfo stock, ResponseEqptRunDto info = null) |
| | | private AgingOutputDto MapToAgingOutputDto(DtStockInfo stock, ResponseEqptRunDto? info = null) |
| | | { |
| | | // TODO Value值根据MOM下发的静置时间到当前时间的分钟数 |
| | | var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == stock.AreaCode); |
| | |
| | | { |
| | | isFull = respone.SpecialParameterDuration.IsNullOrEmpty(); |
| | | } |
| | | if (respone.ProductionLine == null || respone.ParameterInfos == null|| respone.ParameterInfos.IsNullOrEmpty()) |
| | | if (respone.ProductionLine == null || respone.ParameterInfos == null || respone.ParameterInfos.IsNullOrEmpty()) |
| | | { |
| | | throw new Exception($"MOM数据返回错误,产线{respone.ProductionLine},ParameterInfos{respone.ParameterInfos}"); |
| | | } |
| | |
| | | #endregion 任务完成 |
| | | |
| | | #region 请求任务入库 |
| | | |
| | | #region |
| | | |
| | | /// <summary> |
| | | /// 请求任务巷道 |
| | | /// </summary> |
| | | /// <param name="input">请求模型</param> |
| | | /// <returns>包含任务信息的响应内容</returns> |
| | | public async Task<WebResponseContent> RequestTaskAsync2(RequestTaskDto input) |
| | | { |
| | | // 创建一个WebResponseContent对象 |
| | | WebResponseContent content = new WebResponseContent(); |
| | | |
| | | try |
| | | { |
| | | // 调用BaseDal.QueryFirstAsync方法,查询任务 |
| | | var task = await BaseDal.QueryFirstAsync(x => x.PalletCode == input.PalletCode); |
| | | if (task != null) |
| | | { |
| | | //if (task.TaskState == (int)TaskInStatusEnum.InNew) |
| | | { |
| | | // 创建WMS任务 |
| | | WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | { |
| | | TaskNum = task.TaskNum.Value, |
| | | Grade = 1, |
| | | PalletCode = task.PalletCode, |
| | | RoadWay = task.Roadway, |
| | | SourceAddress = task.SourceAddress, |
| | | TargetAddress = task.Roadway, |
| | | TaskState = task.TaskState.Value, |
| | | Id = 0, |
| | | TaskType = task.TaskType, |
| | | }; |
| | | return content.OK(data: taskDTO); |
| | | } |
| | | } |
| | | |
| | | var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == input.PalletCode && x.IsFull); |
| | | if (stock != null) |
| | | { |
| | | // TODO质检回库 |
| | | } |
| | | |
| | | var area = await _areaInfoRepository.QueryFirstAsync(x => x.Spare1.Contains(input.Position)); |
| | | if (area == null) |
| | | return content.Error("改点位不在区域列表中存在"); |
| | | |
| | | // 创建一个TrayCellsStatusDto对象,并赋值 |
| | | TrayCellsStatusDto trayCells = new TrayCellsStatusDto() |
| | | { |
| | | Software = area.Spare3, |
| | | TrayBarcode = input.PalletCode, |
| | | EquipmentCode = area.Spare2, |
| | | SceneType = area.Spare4, |
| | | }; |
| | | |
| | | // 调用GetTrayCellStatusAsync方法,获取整盘电芯 |
| | | content = await GetTrayCellStatusAsync(trayCells); |
| | | // 如果状态为false,则返回content |
| | | if (!content.Status) return content; |
| | | |
| | | // 添加组盘信息 |
| | | // 将content.Data转换为ResultTrayCellsStatus对象 |
| | | var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | if (!result.Success) |
| | | return content.Error(result.MOMMessage); |
| | | |
| | | // 获取异常电芯 |
| | | List<SerialNoDto>? serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList(); |
| | | if (serialNosError.Count > 0) |
| | | { |
| | | // TODO 创建任务送至NG排出口 |
| | | var efg = _stationManagerRepository.QueryData(x => x.stationType == 1 && x.stationChildCode == input.Position && x.stationArea == area.AreaCode).ToList(); |
| | | //List<string> NGStation = input.Position == "1088" ? new List<string>() { "1020" } : new List<string>() { "JZSC01" }; |
| | | if (efg.Count <= 0) |
| | | { |
| | | throw new Exception("未找到NG入库站台配置"); |
| | | } |
| | | List<string> NGStation = efg.Select(x => x.stationNGLocation).ToList(); |
| | | if (NGStation.Count <= 0) |
| | | { |
| | | NGStation = efg.Select(x => x.stationNGChildCode).ToList(); |
| | | } |
| | | content = await CreateNewTask(input, result.ProductionLine, result.ProcessCode, NGStation, 2); |
| | | return content.Error("存在异常电芯"); |
| | | } |
| | | |
| | | if (result.SerialNos.Count <= 0) |
| | | { |
| | | // Todo 空托盘入库逻辑 |
| | | content = await RequestTrayInTaskAsync(input); |
| | | return content; |
| | | } |
| | | |
| | | var boxing = CreateBoxingInfo(result, input.PalletCode); |
| | | //Console.WriteLine(boxing.ToJsonString()); |
| | | if (boxing == null) return content.Error("组盘失败"); |
| | | |
| | | if (result.ProcessCode == "OCVB") |
| | | { |
| | | //TODO 判断需不需要去包装,不需要就去常温三 |
| | | var stationManagers = _stationManagerRepository.QueryData(x => x.stationPLC == "1018" && x.stationArea == "Cache"); |
| | | var station = stationManagers.Select(x => x.stationChildCode).ToList(); |
| | | |
| | | // 获取WCSip地址 |
| | | var configz = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | var wcsBasez = configz.Where(x => x.ConfigKey == SysConfigConst.WCSIPAddress).FirstOrDefault()?.ConfigValue; |
| | | var address = configz.Where(x => x.ConfigKey == SysConfigConst.GetStation).FirstOrDefault()?.ConfigValue; |
| | | if (wcsBasez == null || address == null) |
| | | { |
| | | throw new InvalidOperationException("WCS IP 未配置"); |
| | | } |
| | | var wcsIpAddrss = wcsBasez + address; |
| | | |
| | | var abc = HttpHelper.PostAsync(wcsIpAddrss, station.ToJsonString()).Result; |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(abc); |
| | | if (content.Data.ObjToInt() > 0) |
| | | { |
| | | // TODO 送至包装 |
| | | List<string> strings = stationManagers.Where(x => x.stationType == 0).Select(x => x.Roadway).ToList(); |
| | | content = await CreateNewTask(input, result.ProductionLine, result.ProcessCode, strings, 3); |
| | | return content; |
| | | } |
| | | else |
| | | { |
| | | var config = _configService.GetByConfigKey("SYS_InStacker", "CW3InStacker"); |
| | | var strings = config.ConfigValue.Split(',').ToList(); |
| | | // TODO 入库 |
| | | content = await CreateNewTask(input, result.ProductionLine, result.ProcessCode, strings); |
| | | if (content.Status) |
| | | await _boxingInfoRepository.AddDataNavAsync(boxing); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // TODO 获取本地料框属性与整盘电芯属性获取的值进行对比,如果一致则继续,否则返回错误信息 |
| | | //var productions = await _productionRepository.QueryDataAsync(x => result.TrayBarcodePropertys.Select(x => x.TrayBarcodeProperty).ToList().Contains(x.TrayBarcodeProperty)); |
| | | //if (productions.Count <= 0) |
| | | // return content.Error("料框属性不存在"); |
| | | |
| | | // 调用CreateBoxingInfo方法,创建组盘信息 |
| | | |
| | | //var boxing = CreateBoxingInfo(result, input.PalletCode); |
| | | ////Console.WriteLine(boxing.ToJsonString()); |
| | | //if (boxing == null) return content.Error("组盘失败"); |
| | | |
| | | // 调用GetProcessApplyAsync方法,获取工艺路线 |
| | | ProcessApplyDto process = await GetProcessApplyAsync(result); |
| | | |
| | | // 如果process为null,则返回content |
| | | if (process == null) return content; |
| | | |
| | | // 并赋值上位软件名称和设备编码 |
| | | process.Software = area.Spare3; |
| | | process.EquipmentCode = area.Spare2; |
| | | |
| | | // 调用GetProcessApplyAsync方法,获取工艺申请 |
| | | |
| | | // 调用_processApplyService.GetProcessApplyAsync方法,获取工艺申请 |
| | | content = await _processApplyService.GetProcessApplyAsync(process); |
| | | |
| | | // 如果状态为false,则返回null |
| | | if (!content.Status) return content.Error("工艺申请失败"); |
| | | |
| | | var resultProcessApply = JsonConvert.DeserializeObject<ResultProcessApply>(content.Data.ToString()); |
| | | if (!resultProcessApply.Success) return content.Error("工艺申请失败"); |
| | | |
| | | var number = resultProcessApply.ProcessInfo.Where(x => x.ProcessCode == boxing.ProcessCode).FirstOrDefault().Number.ToInt32(); |
| | | foreach (var item in resultProcessApply.ProcessInfo) |
| | | { |
| | | if (item.Number.ToInt32() == number + 1) |
| | | { |
| | | boxing.NextProcessCode = item.ProcessCode; |
| | | } |
| | | } |
| | | Console.WriteLine(); |
| | | Console.WriteLine($"当前工序:{boxing.ProcessCode}"); |
| | | Console.WriteLine($"下一工序:{boxing.NextProcessCode}"); |
| | | |
| | | Console.WriteLine(area.AreaCode + "-----------------------"); |
| | | Console.WriteLine(input.Position + "-----------------------"); |
| | | |
| | | var areaIn = string.Empty; |
| | | switch (boxing.NextProcessCode) |
| | | { |
| | | case "CH01": |
| | | areaIn = "CH001"; |
| | | break; |
| | | |
| | | case "JZ01": |
| | | areaIn = "JZ001"; |
| | | break; |
| | | |
| | | case "GW01": |
| | | areaIn = "GWSC1"; |
| | | break; |
| | | |
| | | case "CW01": |
| | | areaIn = "CWSC1"; |
| | | break; |
| | | |
| | | case "CW02": |
| | | areaIn = "CWSC2"; |
| | | break; |
| | | |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | var stationManagers = _stationManagerRepository.QueryData(x => x.stationType == 1 && x.stationChildCode == input.Position && x.stationArea.Contains(areaIn)).FirstOrDefault(); |
| | | if (stationManagers == null) |
| | | { |
| | | throw new Exception("未找到入库站台配置"); |
| | | } |
| | | List<string> strings = stationManagers.Roadway.Split(',').ToList(); |
| | | Console.WriteLine(strings.ToJsonString() + "b-----------------------"); |
| | | //// 调用CreateNewTask方法,创建新任务 |
| | | content = await CreateNewTask(input, result.ProductionLine, result.ProcessCode, strings); |
| | | if (content.Status) |
| | | { |
| | | var isBox = await _boxingInfoRepository.AddDataNavAsync(boxing); |
| | | } |
| | | //} |
| | | } |
| | | } |
| | | catch (Exception err) |
| | | { |
| | | // 如果发生异常,则调用content.Error方法,记录错误信息,并输出错误信息 |
| | | content.Error(err.Message); |
| | | Console.WriteLine(err.Message); |
| | | } |
| | | |
| | | // 返回content |
| | | return content; |
| | | } |
| | | |
| | | #endregion 请求任务入库 |
| | | |
| | | public async Task<WebResponseContent> RequestTaskAsync(RequestTaskDto input) |
| | | { |
| | |
| | | }; |
| | | } |
| | | |
| | | #endregion 外部接口方法 |
| | | #endregion 请求任务入库 |
| | | |
| | | #region 请求出库(实盘&空盘) |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | #endregion 静置异常口入库 |
| | | #endregion 外部接口方法 |
| | | |
| | | #endregion 外部接口方法 |
| | | |