| | |
| | | /Code Management/.vs/Code Management/CopilotIndices/17.12.31.40377/CodeChunks.db-wal |
| | | /Code Management/.vs/Code Management/CopilotIndices/17.12.31.40377/SemanticSymbols.db-wal |
| | | /Code Management/.vs/slnx.sqlite |
| | | /Code Management/.vs/Code Management/v17/.wsuo |
| | | /Code Management/.vs/Code Management/v17/workspaceFileList.bin |
| | | /Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json |
| | | /Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/copilot-chat/bef6627e/sessions/0fd52b0d-b36f-4668-871f-5e1c1d23e2e3 |
| | | /Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/copilot-chat/bef6627e/sessions/82695646-a5cf-44a5-803d-fe8b5ff11fef |
| | | /Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json |
| | |
| | | var basePath = AppContext.BaseDirectory; |
| | | var cacheType = new List<Type>(); |
| | | |
| | | builder.RegisterType<LogAOP>(); |
| | | cacheType.Add(typeof(LogAOP)); |
| | | //builder.RegisterType<LogAOP>(); |
| | | //cacheType.Add(typeof(LogAOP)); |
| | | |
| | | builder.RegisterGeneric(typeof(RepositoryBase<>)).As(typeof(IRepository<>)).InstancePerDependency();//注册仓储 |
| | | builder.RegisterGeneric(typeof(ServiceBase<,>)).As(typeof(IService<>)).InstancePerDependency();//注册服务 |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 在控制台输出 |
| | | /// </summary> |
| | | /// <param name="str">文本</param> |
| | | /// <param name="color">前颜色</param> |
| | | public static void WriteColorLine(object str, ConsoleColor color) |
| | | { |
| | | lock (_objLock) |
| | | { |
| | | ConsoleColor currentForeColor = Console.ForegroundColor; |
| | | Console.ForegroundColor = color; |
| | | Console.WriteLine(str); |
| | | Console.ForegroundColor = currentForeColor; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 打印错误信息 |
| | | /// </summary> |
| | | /// <param name="str">待打印的字符串</param> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// 检测站台是否有货 |
| | | /// </summary> |
| | | /// <param name="deviceChildCode"></param> |
| | | /// <returns></returns> |
| | |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检测站台是否有货 |
| | | /// </summary> |
| | | /// <param name="deviceChildCode"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public bool IsOccupiedx(string deviceChildCode) |
| | | { |
| | | if (Communicator.IsConnected) |
| | | { |
| | | var device = _deviceProDTOs.Where(x => x.DeviceChildCode == deviceChildCode && x.DeviceProParamName == "InteractiveSignal").FirstOrDefault(); |
| | | |
| | | object readStatus = Communicator.ReadAsObj(device.DeviceProAddress, device.DeviceDataType); |
| | | |
| | | //todo 协议明细信息未获取到时抛出异常 |
| | | if (readStatus.ToString() != "2") |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | //todo 通讯未连接时抛出异常 |
| | | return false; |
| | | } |
| | | |
| | | public void Dispose() |
| | | { |
| | | _heartStatr = false; |
| | |
| | | switch (typeCode) |
| | | { |
| | | case TypeCode.Boolean: |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToBoolean(deviceProtocolDetail.ProtocalDetailValue)); |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToBoolean(deviceProtocolDetail.ProtocalDetailValue)); |
| | | break; |
| | | case TypeCode.Byte: |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToByte(deviceProtocolDetail.ProtocalDetailValue)); |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToByte(deviceProtocolDetail.ProtocalDetailValue)); |
| | | break; |
| | | case TypeCode.Int16: |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToInt16(deviceProtocolDetail.ProtocalDetailValue)); |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToInt16(deviceProtocolDetail.ProtocalDetailValue)); |
| | | break; |
| | | case TypeCode.Int32: |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToInt32(deviceProtocolDetail.ProtocalDetailValue)); |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToInt32(deviceProtocolDetail.ProtocalDetailValue)); |
| | | break; |
| | | case TypeCode.UInt16: |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToUInt16(deviceProtocolDetail.ProtocalDetailValue)); |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToUInt16(deviceProtocolDetail.ProtocalDetailValue)); |
| | | break; |
| | | case TypeCode.UInt32: |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 500, 10 * 6000, Convert.ToUInt32(deviceProtocolDetail.ProtocalDetailValue)); |
| | | operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToUInt32(deviceProtocolDetail.ProtocalDetailValue)); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_TaskInfoRepository; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | |
| | | BaseDal.DeleteData(task); |
| | | _taskHtyRepository.AddData(task_Hty); |
| | | } |
| | | |
| | | |
| | | if (task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) |
| | | { |
| | | content = StackCraneTaskCompleted(task.TaskNum); |
| | | return content; |
| | | } |
| | | |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) |
| | | { |
| | |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DeviceBase; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_SignalR; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | |
| | | [DisallowConcurrentExecution] |
| | | public partial class CommonConveyorLineJob : JobBase, IJob |
| | | { |
| | | public readonly ITaskService _taskService; |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskRepository _taskRepository; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly IRouterService _routerService; |
| | |
| | | private readonly IDt_StationManagerRepository _stationManagerRepository; |
| | | private readonly ICacheService _cacheService; |
| | | private readonly INoticeService _noticeService; |
| | | private readonly IDeviceInfoRepository _deviceInfoRepository; |
| | | |
| | | private static List<string>? userTokenIds; |
| | | private static List<int>? userIds; |
| | | |
| | | |
| | | public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository, IPlatFormRepository platFormRepository, ISys_ConfigService sys_ConfigService, IDt_StationManagerService stationManagerService, IDt_StationManagerRepository stationManagerRepository, ICacheService cacheService, INoticeService noticeService) |
| | | public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository, IPlatFormRepository platFormRepository, ISys_ConfigService sys_ConfigService, IDt_StationManagerService stationManagerService, IDt_StationManagerRepository stationManagerRepository, ICacheService cacheService, INoticeService noticeService, IDeviceInfoRepository deviceInfoRepository) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | |
| | | _stationManagerRepository = stationManagerRepository; |
| | | _cacheService = cacheService; |
| | | _noticeService = noticeService; |
| | | _deviceInfoRepository = deviceInfoRepository; |
| | | } |
| | | |
| | | public async Task Execute(IJobExecutionContext context) |
| | | { |
| | | string jobName = context.JobDetail.Key.Name; |
| | | //if (MemoryLockManager.TryAcquireLock(jobName)) |
| | | //{ |
| | | try |
| | | { |
| | | // 从JobDataMap中获取传递的参数 |
| | |
| | | { |
| | | // 查询所有子设备的位置 |
| | | List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); |
| | | |
| | | // 并行处理每个子设备 |
| | | var tasks = childDeviceCodes.Select(childDeviceCode => ProcessDeviceAsync(conveyorLine, childDeviceCode)).ToList(); |
| | | await Task.WhenAll(tasks); |
| | | |
| | | |
| | | // 获取所有站点管理器 |
| | | List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode); |
| | |
| | | // 输出警告信息 |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{station.stationChildCode}】空托盘请求扫码入库"); |
| | | // 处理入库请求 |
| | | NGRequestTaskInbound(conveyorLine, command, station.stationChildCode, 0, station.stationLocation); |
| | | NGRequestTaskInbound(conveyorLine, command, station, 0); |
| | | } |
| | | else |
| | | { |
| | |
| | | // 输出异常信息 |
| | | Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); |
| | | } |
| | | // finally |
| | | // { |
| | | // MemoryLockManager.ReleaseLock(jobName); |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // ConsoleHelper.WriteErrorLine($"[CommonConveyorLineJob]【{jobName}】任务已被锁定,无法处理"); |
| | | // } |
| | | return; |
| | | } |
| | | |
| | | private Task ProcessDeviceAsync(CommonConveyorLine conveyorLine, string childDeviceCode) |
| | | { |
| | | // 读取任务命令和设备命令 |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(childDeviceCode); |
| | | ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(childDeviceCode, "DeviceCommand"); |
| | | if (command != null && commandWrite != null) |
| | | try |
| | | { |
| | | |
| | | #region 调用事件总线通知前端 |
| | | |
| | | // 获取缓存中的用户信息 |
| | | if (userTokenIds == null && userIds == null) |
| | | // 读取任务命令和设备命令 |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(childDeviceCode); |
| | | ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(childDeviceCode, "DeviceCommand"); |
| | | if (command != null && commandWrite != null) |
| | | { |
| | | #region 调用事件总线通知前端 |
| | | |
| | | // 获取缓存中的用户信息 |
| | | var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); |
| | | if (tokenInfos != null && tokenInfos.Any()) |
| | | { |
| | |
| | | // 发送通知 |
| | | _noticeService.LineData(userIds.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, childDeviceCode, data = obj }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // 构造通知数据 |
| | | object obj = new |
| | | |
| | | #endregion 调用事件总线通知前端 |
| | | |
| | | // 将交互信号转换为布尔数组 |
| | | var writeInteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | var structs = BitConverter.GetBytes(writeInteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | // 获取设备协议详情 |
| | | List<DeviceProtocolDetailDTO>? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.Where(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)).ToList(); |
| | | |
| | | if (deviceProtocolDetails != null) |
| | | { |
| | | command, |
| | | commandWrite |
| | | }; |
| | | // 发送通知 |
| | | _noticeService.LineData(userIds.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, childDeviceCode, data = obj }); |
| | | } |
| | | |
| | | #endregion 调用事件总线通知前端 |
| | | |
| | | // 将交互信号转换为布尔数组 |
| | | var writeInteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | var structs = BitConverter.GetBytes(writeInteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | // 获取设备协议详情 |
| | | List<DeviceProtocolDetailDTO>? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.Where(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)).ToList(); |
| | | |
| | | if (deviceProtocolDetails != null) |
| | | { |
| | | foreach (var item in deviceProtocolDetails) |
| | | { |
| | | int itemValue = item.ProtocalDetailValue.ObjToInt(); |
| | | if (structs[itemValue] == true) |
| | | foreach (var item in deviceProtocolDetails) |
| | | { |
| | | // 获取处理方法 |
| | | MethodInfo? method = GetType().GetMethod(item.ProtocolDetailType); |
| | | if (method != null) |
| | | int itemValue = item.ProtocalDetailValue.ObjToInt(); |
| | | if (structs[itemValue] == true) |
| | | { |
| | | command.InteractiveSignal = writeInteractiveSignal; |
| | | // 调用处理方法 |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, itemValue }); |
| | | // 获取处理方法 |
| | | MethodInfo? method = GetType().GetMethod(item.ProtocolDetailType); |
| | | if (method != null) |
| | | { |
| | | command.InteractiveSignal = writeInteractiveSignal; |
| | | // 调用处理方法 |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, itemValue }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // 发送完成信号 |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, itemValue, false); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // 发送完成信号 |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, itemValue, false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 查询平台信息 |
| | | Platform platform = _platFormRepository.QueryFirst(x => x.PLCCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); |
| | | if (platform != null && !string.IsNullOrEmpty(platform.Location)) |
| | | { |
| | | var strings = platform.Location.Split(',').ToList(); |
| | | foreach (var ite in strings) |
| | | // 查询平台信息 |
| | | Platform platform = _platFormRepository.QueryFirst(x => x.PLCCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); |
| | | if (platform != null && !string.IsNullOrEmpty(platform.Location)) |
| | | { |
| | | // 读取任务命令 |
| | | ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(ite); |
| | | if (command1.InteractiveSignal != 2) |
| | | var strings = platform.Location.Split(',').ToList(); |
| | | foreach (var ite in strings) |
| | | { |
| | | command.InteractiveSignal = writeInteractiveSignal; |
| | | int count = strings.Count; |
| | | // 获取处理方法 |
| | | MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod); |
| | | if (method != null) |
| | | // 读取任务命令 |
| | | ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(ite); |
| | | if (command1.InteractiveSignal != 2) |
| | | { |
| | | command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | // 调用处理方法 |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | }; |
| | | command.InteractiveSignal = writeInteractiveSignal; |
| | | int count = strings.Count; |
| | | // 获取处理方法 |
| | | MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod); |
| | | if (method != null) |
| | | { |
| | | command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | // 调用处理方法 |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | }; |
| | | } |
| | | } |
| | | } |
| | | //if (conveyorLine.DeviceCode == "1001") |
| | | //{ |
| | | // ConsoleHelper.WriteSuccessLine("ProcessDeviceAsync方法结束时间:" + DateTime.Now.ToString("G") + $"点位:{childDeviceCode}"); |
| | | //} |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | | return Task.CompletedTask; |
| | |
| | | /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param> |
| | | public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue) |
| | | { |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线入库完成"); |
| | | var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null && task.TaskState != (int)TaskInStatusEnum.Line_InFinish) |
| | | try |
| | | { |
| | | if (command.Barcode == task.PalletCode && childDeviceCode == task.NextAddress) |
| | | |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线入库完成"); |
| | | var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null && task.TaskState != (int)TaskInStatusEnum.Line_InFinish) |
| | | { |
| | | //conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, "1000", childDeviceCode); |
| | | |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线入库完成,下一目标地址【等待分配货位,并写入1000】"); |
| | | |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | |
| | | if (task.TaskType == (int)TaskInboundTypeEnum.InNG) |
| | | if (command.Barcode == task.PalletCode && childDeviceCode == task.NextAddress) |
| | | { |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); |
| | | //conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, "1000", childDeviceCode); |
| | | |
| | | var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.SourceAddress); |
| | | task.CurrentAddress = station.stationLocation; |
| | | task.NextAddress = station.stationNGLocation; |
| | | task.TargetAddress = task.NextAddress; |
| | | task.TaskState = nextStatus; |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | _taskRepository.UpdateData(task); |
| | | } |
| | | else |
| | | { |
| | | WebResponseContent content = _taskService.UpdateTaskStatusToNext(task); |
| | | Console.Out.WriteLine(content.ToJsonString()); |
| | | ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线入库完成,下一目标地址【等待分配货位,并写入1000】"); |
| | | |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | |
| | | if (task.TaskType == (int)TaskInboundTypeEnum.InNG) |
| | | { |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); |
| | | |
| | | var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.SourceAddress); |
| | | task.CurrentAddress = station.stationLocation; |
| | | task.NextAddress = station.stationNGLocation; |
| | | task.TargetAddress = task.NextAddress; |
| | | task.TaskState = nextStatus; |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | _taskRepository.UpdateData(task); |
| | | } |
| | | else |
| | | { |
| | | WebResponseContent content = _taskService.UpdateTaskStatusToNext(task); |
| | | Console.Out.WriteLine(content.ToJsonString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param> |
| | | public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue) |
| | | { |
| | | // 查询输送线任务,根据输送线设备和子设备代码获取任务信息 |
| | | var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | |
| | | // 输出成功信息,包括输送线名称、任务号、托盘条码和子设备代码,以及任务信息 |
| | | ConsoleHelper.WriteSuccessLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线请求出库,task{task.ToJsonString()}"); |
| | | |
| | | // 如果任务不为空,则执行以下操作 |
| | | if (task != null) |
| | | try |
| | | { |
| | | // 获取任务的下一目标地址 |
| | | var next = task.NextAddress; |
| | | |
| | | // 将任务命令映射到当前任务 |
| | | var taskCommand = MapTaskCommand(task, command); |
| | | // 查询输送线任务,根据输送线设备和子设备代码获取任务信息 |
| | | var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | |
| | | // 恢复任务的下一目标地址 |
| | | task.NextAddress = next; |
| | | // 输出成功信息,包括输送线名称、任务号、托盘条码和子设备代码,以及任务信息 |
| | | ConsoleHelper.WriteSuccessLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线请求出库,task{task.ToJsonString()}"); |
| | | |
| | | // 输出成功信息,包括输送线名称、任务号、托盘条码、子设备代码和下一目标地址 |
| | | ConsoleHelper.WriteSuccessLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线请求出库,下一目标地址【{taskCommand.TargetAddress}】"); |
| | | |
| | | // 向输送线发送命令 |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | // 完成输送线发送任务,并更新任务状态 |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | |
| | | // 更新任务状态到下一个状态 |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | |
| | | // 如果任务的目标地址是"1020-1",则再次更新任务状态到下一个状态 |
| | | if (task.TargetAddress == "1020-1") |
| | | // 如果任务不为空,则执行以下操作 |
| | | if (task != null) |
| | | { |
| | | // 获取任务的下一目标地址 |
| | | var next = task.NextAddress; |
| | | |
| | | // 将任务命令映射到当前任务 |
| | | var taskCommand = MapTaskCommand(task, command); |
| | | |
| | | // 恢复任务的下一目标地址 |
| | | task.NextAddress = next; |
| | | |
| | | // 输出成功信息,包括输送线名称、任务号、托盘条码、子设备代码和下一目标地址 |
| | | ConsoleHelper.WriteSuccessLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线请求出库,下一目标地址【{taskCommand.TargetAddress}】"); |
| | | |
| | | // 向输送线发送命令 |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | // 完成输送线发送任务,并更新任务状态 |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | |
| | | // 更新任务状态到下一个状态 |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | |
| | | // 如果任务的目标地址是"1020-1",则再次更新任务状态到下一个状态 |
| | | if (task.TargetAddress == "1020-1") |
| | | { |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue) |
| | | { |
| | | // 打印成功信息,表示托盘已到达指定输送线并完成出库 |
| | | ConsoleHelper.WriteSuccessLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线出库完成"); |
| | | |
| | | // 查询正在执行的输送线任务 |
| | | var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | |
| | | // 如果任务存在 |
| | | if (task != null) |
| | | try |
| | | { |
| | | // 如果任务中的托盘条码与命令中的托盘条码一致 |
| | | if (command.Barcode == task.PalletCode) |
| | | |
| | | // 打印成功信息,表示托盘已到达指定输送线并完成出库 |
| | | ConsoleHelper.WriteSuccessLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线出库完成"); |
| | | |
| | | // 查询正在执行的输送线任务 |
| | | var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | |
| | | // 如果任务存在 |
| | | if (task != null) |
| | | { |
| | | // 创建一个空的WebResponseContent对象 |
| | | WebResponseContent content = new WebResponseContent(); |
| | | |
| | | // 保存任务的下一目标地址 |
| | | var next = task.NextAddress; |
| | | // 将任务映射为命令 |
| | | var taskCommand = MapTaskCommand(task, command); |
| | | // 恢复任务的下一目标地址 |
| | | task.NextAddress = next; |
| | | |
| | | // 如果任务的托盘条码与命令中的托盘条码不一致或者任务备注为"NG" |
| | | if (task.PalletCode != command.Barcode || task.Remark == "NG") |
| | | // 如果任务中的托盘条码与命令中的托盘条码一致 |
| | | if (command.Barcode == task.PalletCode) |
| | | { |
| | | // 查询目标地址的容量 |
| | | var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == task.TargetAddress).Capacity; |
| | | // 设置命令的目标地址为NG地址 |
| | | taskCommand.TargetAddress = NGAddress; |
| | | // 创建一个空的WebResponseContent对象 |
| | | WebResponseContent content = new WebResponseContent(); |
| | | |
| | | // 保存任务的下一目标地址 |
| | | var next = task.NextAddress; |
| | | // 将任务映射为命令 |
| | | var taskCommand = MapTaskCommand(task, command); |
| | | // 恢复任务的下一目标地址 |
| | | task.NextAddress = next; |
| | | |
| | | // 如果任务的托盘条码与命令中的托盘条码不一致或者任务备注为"NG" |
| | | if (task.PalletCode != command.Barcode || task.Remark == "NG") |
| | | { |
| | | // 查询目标地址的容量 |
| | | var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == task.TargetAddress).Capacity; |
| | | // 设置命令的目标地址为NG地址 |
| | | taskCommand.TargetAddress = NGAddress; |
| | | } |
| | | else |
| | | { |
| | | // 设置命令的目标地址为1000 |
| | | taskCommand.TargetAddress = 1000; |
| | | } |
| | | |
| | | // 打印成功信息,表示托盘已到达指定输送线并完成出库,下一目标地址已确定 |
| | | ConsoleHelper.WriteSuccessLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线出库完成,下一目标地址【{taskCommand.TargetAddress}】"); |
| | | // 发送命令到输送线 |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | // 完成输送线发送 |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | // 更新任务状态到下一个状态 |
| | | content = _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | else |
| | | { |
| | | // 设置命令的目标地址为1000 |
| | | taskCommand.TargetAddress = 1000; |
| | | // 查询目标地址的容量 |
| | | var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == task.TargetAddress).Capacity; |
| | | // 打印成功信息,表示托盘已到达指定输送线并完成出库,下一目标地址已确定 |
| | | ConsoleHelper.WriteSuccessLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线出库完成,下一目标地址【{NGAddress}】"); |
| | | // 设置输送线的目标地址为NG地址 |
| | | conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, NGAddress, childDeviceCode); |
| | | // 完成输送线发送 |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | // 更新任务状态到下一个状态 |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | // 打印成功信息,表示托盘已到达指定输送线并完成出库,下一目标地址已确定 |
| | | ConsoleHelper.WriteSuccessLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线出库完成,下一目标地址【{taskCommand.TargetAddress}】"); |
| | | // 发送命令到输送线 |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | // 完成输送线发送 |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | // 更新任务状态到下一个状态 |
| | | content = _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | else |
| | | { |
| | | // 查询目标地址的容量 |
| | | var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == task.TargetAddress).Capacity; |
| | | // 打印成功信息,表示托盘已到达指定输送线并完成出库,下一目标地址已确定 |
| | | ConsoleHelper.WriteSuccessLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线出库完成,下一目标地址【{NGAddress}】"); |
| | | // 设置输送线的目标地址为NG地址 |
| | | conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, NGAddress, childDeviceCode); |
| | | // 完成输送线发送 |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | // 更新任务状态到下一个状态 |
| | | _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | else |
| | | taskOutboundTypeEnum = TaskOutboundTypeEnum.Outbound; |
| | | // 调用检查并创建任务的方法 |
| | | await CheckAndCreateTask(taskOutboundTypeEnum, childDeviceCode, index, platform.Stacker, platform); |
| | | await CheckAndCreateTask(taskOutboundTypeEnum, childDeviceCode, index, platform); |
| | | } |
| | | catch (Exception) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 检查任务并创建新任务 |
| | | /// </summary> |
| | | private async Task CheckAndCreateTask(TaskOutboundTypeEnum taskType, string childDeviceCode, int index, string roadWay, Platform platform) |
| | | private async Task CheckAndCreateTask(TaskOutboundTypeEnum taskType, string childDeviceCode, int index, Platform platform) |
| | | { |
| | | // 查询数据库中已有的任务 |
| | | var tasks = _taskRepository.QueryData(x => x.TaskType == (int)taskType && x.TargetAddress == childDeviceCode); |
| | |
| | | } |
| | | var wmsIpAddress = wmsBase + requestTrayOutTask; |
| | | |
| | | var device = _deviceInfoRepository.QueryData(x => x.DeviceStatus == "1" && x.DeviceRemark == platform.Id.ToString()); |
| | | var deviceCode = device.Select(x => x.DeviceCode).ToList(); |
| | | |
| | | // 发送HTTP POST请求获取任务数据 |
| | | var result = await HttpHelper.PostAsync(wmsIpAddress, new { position = childDeviceCode, tag = (int)taskType, areaCdoe = roadWay, platform.ProductionLine }.ToJsonString()); |
| | | var result = await HttpHelper.PostAsync(wmsIpAddress, new { position = childDeviceCode, tag = (int)taskType, areaCdoe = platform.Stacker, AreaCdoes = deviceCode, platform.ProductionLine }.ToJsonString()); |
| | | // 解析返回的JSON数据 |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | |
| | |
| | | |
| | | #region 设备NG口入库 |
| | | |
| | | public void NGRequestTaskInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue, string TargetAddress) |
| | | public void NGRequestTaskInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, Dt_StationManager stationManager, int ProtocalDetailValue) |
| | | { |
| | | var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.MOMIP_BASE)?.ConfigValue; |
| | |
| | | { |
| | | throw new InvalidOperationException("MOM IP 未配置"); |
| | | } |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode); |
| | | TrayCellsStatusDto trayCells = new TrayCellsStatusDto() |
| | | { |
| | | Software = "WMS", |
| | |
| | | var MOMIpAddress = wmsBase + ipAddress; |
| | | |
| | | var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.ToJsonString()).Result; |
| | | WriteInfo("入站校验", $"【{childDeviceCode}】入站校验请求参数【{trayCells.ToJsonString()}】"); |
| | | WriteInfo("入站校验", $"【{stationManager.stationChildCode}】入站校验请求参数【{trayCells.ToJsonString()}】"); |
| | | WriteInfo("入站校验", ""); |
| | | WriteInfo("入站校验", $"【{childDeviceCode}】入站校验返回参数【{result}】"); |
| | | WriteInfo("入站校验", $"【{stationManager.stationChildCode}】入站校验返回参数【{result}】"); |
| | | ResultTrayCellsStatus result1 = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result); |
| | | |
| | | if (result1.Success) |
| | | { |
| | | |
| | | var serialNosError = result1.SerialNos.Where(x => x.SerialNoStatus != 1).ToList(); |
| | | if (serialNosError.Count > 0) |
| | | { |
| | |
| | | |
| | | if (result1.SerialNos.Count <= 0) |
| | | { |
| | | // 空托盘入库逻辑 |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | TargetAddress = TargetAddress, |
| | | PalletCode = command.Barcode, |
| | | NextAddress = TargetAddress, |
| | | TaskNum = 0 |
| | | }; |
| | | |
| | | var next = dt_Task.NextAddress; |
| | | var taskCommand = MapTaskCommand(dt_Task, command); |
| | | dt_Task.NextAddress = next; |
| | | conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, stationManager.stationLocation, stationManager.stationChildCode); |
| | | |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | ConveyorLineSendFinish(conveyorLine, stationManager.stationChildCode, ProtocalDetailValue, true); |
| | | } |
| | | else |
| | | { |
| | | conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, 1000, childDeviceCode); |
| | | conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, 1000, stationManager.stationChildCode); |
| | | |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | ConveyorLineSendFinish(conveyorLine, stationManager.stationChildCode, ProtocalDetailValue, true); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | ConsoleHelper.WriteErrorLine(result1.MOMMessage); |
| | | } |
| | | } |
| | | |
| | |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_SignalR; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | |
| | | taskOutboundTypeEnum = TaskOutboundTypeEnum.OutTray; |
| | | else |
| | | taskOutboundTypeEnum = TaskOutboundTypeEnum.Outbound; |
| | | await CheckAndCreateTask(taskOutboundTypeEnum, childDeviceCode, index, platform.Stacker, platform); |
| | | await CheckAndCreateTask(taskOutboundTypeEnum, childDeviceCode, index, platform); |
| | | } |
| | | catch (Exception) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 检查任务并创建新任务 |
| | | /// </summary> |
| | | private async Task CheckAndCreateTask(TaskOutboundTypeEnum taskType, string childDeviceCode, int index, string roadWay, Platform platform) |
| | | private async Task CheckAndCreateTask(TaskOutboundTypeEnum taskType, string childDeviceCode, int index, Platform platform) |
| | | { |
| | | var tasks = _taskRepository.QueryData(x => x.TaskType == (int)taskType && x.TargetAddress == childDeviceCode); |
| | | if (tasks.Count < index) |
| | |
| | | } |
| | | var wmsIpAddress = wmsBase + requestTrayOutTask; |
| | | |
| | | |
| | | var device = _deviceInfoRepository.QueryData(x => x.DeviceStatus == "1" && x.DeviceRemark == platform.Id.ToString()); |
| | | var deviceCode = device.Select(x => x.DeviceCode).ToList(); |
| | | List<string> strings = platform.Location.Split(',').ToList(); |
| | | |
| | | var result = await HttpHelper.PostAsync(wmsIpAddress, new { Position = childDeviceCode, Tag = (int)taskType, AreaCdoe = roadWay, AreaCdoes = strings, platform.ProductionLine }.ToJsonString()); |
| | | var result = await HttpHelper.PostAsync(wmsIpAddress, new { Position = childDeviceCode, Tag = (int)taskType, AreaCdoe = platform.Stacker, AreaCdoes = strings, platform.ProductionLine }.ToJsonString()); |
| | | //var result = await HttpHelper.PostAsync("http://localhost:5000/api/Task/RequestTrayOutTaskAsync", dynamic.ToJsonString()); |
| | | |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | |
| | | using Mapster; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Text; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core.Caches; |
| | |
| | | StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); |
| | | if (stackerCraneTaskCommand != null) |
| | | { |
| | | bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); |
| | | if (sendFlag) |
| | | var taskNum = commonStackerCrane.GetValue<StackerCraneDBName, int>(StackerCraneDBName.TaskNum); |
| | | var taskBarCode = commonStackerCrane.GetValue<StackerCraneDBName, string>(StackerCraneDBName.Barcode); |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】堆垛机任务号:【{taskNum}】,堆垛机托盘号:【{taskBarCode}】,任务任务号:【{task.TaskNum}】任务托盘号:【{task.PalletCode}】", ConsoleColor.DarkBlue); |
| | | if (taskNum == 0 && taskBarCode != task.PalletCode) |
| | | { |
| | | commonStackerCrane.LastTaskType = task.TaskType; |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】任务号为【{0}】,托盘号不一致可以下发任务", ConsoleColor.DarkBlue); |
| | | bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); |
| | | if (sendFlag) |
| | | { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.AppendLine(); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】堆垛机状态:【{commonStackerCrane.StackerCraneStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】手自动状态:【{commonStackerCrane.StackerCraneAutoStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】作业状态:【{commonStackerCrane.StackerCraneWorkStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】下发任务成功,【{JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}】"); |
| | | builder.AppendLine($"时间:【{DateTime.Now}】"); |
| | | builder.AppendLine(); |
| | | ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue); |
| | | commonStackerCrane.LastTaskType = task.TaskType; |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】任务号不为【{0}】,或者托盘号一致不可以下发任务", ConsoleColor.DarkBlue); |
| | | } |
| | | } |
| | | } |
| | |
| | | CommonStackerCrane? commonStackerCrane = sender as CommonStackerCrane; |
| | | if (commonStackerCrane != null) |
| | | { |
| | | //var x = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType); |
| | | //if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) |
| | | if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) |
| | | { |
| | | //Console.Out.WriteLine("TaskCompleted" + e.TaskNum); |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】任务完成,任务号:【{e.TaskNum}】", ConsoleColor.Blue); |
| | |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | //if (conveyorLine.IsOccupied(router.ChildPosi))//出库站台未被占用 |
| | | if (conveyorLine.IsOccupiedx(router.ChildPosi))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | |
| | | /// 托盘号 |
| | | /// </summary> |
| | | Barcode, |
| | | |
| | | /// <summary> |
| | | /// 启动命令 |
| | | /// </summary> |
| | | StartCommand, |
| | | |
| | | /// <summary> |
| | | /// 消防命令 |
| | | /// </summary> |
| | | FireCommand, |
| | | } |
| | | } |
| | |
| | | //需要从远程绑定数据源的字典编号,如果字典数据源的查询结果较多,请在onInit中将字典编号添加进来 |
| | | //只对自定sql有效 |
| | | remoteKeys: [], |
| | | columnIndex: false, //2020.11.01是否显示行号 |
| | | columnIndex: true, //2020.11.01是否显示行号 |
| | | ck: true, //2020.11.01是否显示checkbox |
| | | continueAdd: false, //2021.04.11新建时是否可以连续新建操作 |
| | | continueAddName: '保存后继续添加', //2021.04.11按钮名称 |
| | |
| | | name: 'Dt_AreaInfo', |
| | | component: () => import('@/views/widesea_wms/basicinfo/Dt_AreaInfo.vue'), |
| | | meta: { |
| | | keepAlive: false |
| | | keepAlive: true |
| | | } |
| | | }, |
| | | { |
| | |
| | | name: 'Dt_LocationInfo', |
| | | component: () => import('@/views/widesea_wms/basicinfo/Dt_LocationInfo.vue'), |
| | | meta: { |
| | | keepAlive: false |
| | | keepAlive: true |
| | | } |
| | | }, |
| | | { |
| | |
| | | name: 'Dt_Task', |
| | | component: () => import('@/views/widesea_wms/taskinfo/Dt_Task.vue'), |
| | | meta: { |
| | | keepAlive: false |
| | | keepAlive: true |
| | | } |
| | | },{ |
| | | path: '/Dt_Task_Hty', |
| | | name: 'Dt_Task_Hty', |
| | | component: () => import('@/views/widesea_wms/taskinfo/Dt_Task_Hty.vue'), |
| | | meta: { |
| | | keepAlive: false |
| | | keepAlive: true |
| | | } |
| | | }, |
| | | // { |
| | |
| | | |
| | | private static void LogRequestParameters(Dictionary<string, object> parameters,string url = "") |
| | | { |
| | | LogFactory.GetLog("API接口").Info(true, "url:" + url + "请求参数: " + JsonConvert.SerializeObject(parameters)); |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.Append(Environment.NewLine); |
| | | builder.Append("---------------------------------------------"); |
| | | builder.Append(Environment.NewLine); |
| | | builder.Append("url:" + url + "请求参数: " + JsonConvert.SerializeObject(parameters)); |
| | | LogFactory.GetLog("API接口").Info(true, builder); |
| | | } |
| | | |
| | | private static void LogResponseParameters(string responseBody, string url = "") |
| | | { |
| | | LogFactory.GetLog("API接口").Info(true, "url:" + url + "响应参数: " + responseBody); |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.Append(Environment.NewLine); |
| | | builder.Append("url:" + url + "响应参数: " + responseBody); |
| | | builder.Append(Environment.NewLine); |
| | | builder.Append("---------------------------------------------"); |
| | | builder.Append(Environment.NewLine); |
| | | LogFactory.GetLog("API接口").Info(true, builder); |
| | | } |
| | | |
| | | private static IEnumerable<KeyValuePair<string, string>> ConvertToKeyValuePairs(Dictionary<string, object> parameters) |
| | |
| | | Task<bool> UpdateDataAsync(List<TEntity> listEntity); |
| | | |
| | | /// <summary> |
| | | /// 导航更新数据(只支持2级) |
| | | /// </summary> |
| | | /// <param name="Entity"></param> |
| | | /// <returns></returns> |
| | | Task<bool> UpdateDataNavAsync(TEntity Entity); |
| | | |
| | | /// <summary> |
| | | /// 导航更新数据(只支持2级) |
| | | /// </summary> |
| | | /// <param name="Entity"></param> |
| | | /// <returns></returns> |
| | | bool UpdateDataNav(TEntity Entity); |
| | | |
| | | /// <summary> |
| | | /// 指定列更新数据 |
| | | /// </summary> |
| | | /// <param name="entity"></param> |
| | |
| | | return _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderBy(orderByModels).ToList(); |
| | | } |
| | | |
| | | public Task<bool> UpdateDataNavAsync(TEntity Entity) |
| | | { |
| | | return _db.UpdateNav(Entity).IncludesAllFirstLayer().ExecuteCommandAsync(); |
| | | } |
| | | |
| | | public bool UpdateDataNav(TEntity Entity) |
| | | { |
| | | return _db.UpdateNav(Entity).IncludesAllFirstLayer().ExecuteCommand(); |
| | | } |
| | | |
| | | //List<TResult> QueryMuch<T, T2, T3, TResult>( |
| | | // Expression<Func<T, T2, T3, object[]>> joinExpression, |
| | | // Expression<Func<T, T2, T3, TResult>> selectExpression, |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.ComponentModel; |
| | | |
| | | namespace WIDESEA_Core.Enums |
| | | { |
| | |
| | | NotAllow = 2 |
| | | } |
| | | |
| | | public enum LocationType |
| | | { |
| | | /// <summary> |
| | | /// 单深货位 |
| | | /// </summary> |
| | | [Description("单深货位")] |
| | | Single = 1, |
| | | |
| | | /// <summary> |
| | | /// 双深货位 |
| | | /// </summary> |
| | | [Description("双深货位")] |
| | | Double = 2 |
| | | } |
| | | |
| | | #region 任务类型 |
| | | |
| | | /// <summary> |
| | | /// 任务类型 |
| | | /// 任务类型 |
| | | /// </summary> |
| | | |
| | | public enum TaskInboundTypeEnum |
| | |
| | | /// NG出库 |
| | | /// </summary> |
| | | [Description("NG出库")] |
| | | OutNG =105, |
| | | OutNG = 105, |
| | | |
| | | /// <summary> |
| | | /// 直接出库 |
| | |
| | | public enum TaskOtherTypeEnum |
| | | { |
| | | } |
| | | |
| | | public enum TaskTypeEnum |
| | | { |
| | | /// <summary> |
| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core.Seed; |
| | | |
| | | namespace WIDESEA_Core.Helper |
| | | { |
| | |
| | | //用单例模式 |
| | | public static SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig() |
| | | { |
| | | ConnectionString = "Data Source=.;Initial Catalog=WIDESEAWCS_TEST;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",//连接符字串 |
| | | ConnectionString = DBContext.GetMainConnectionDb().Connection, |
| | | DbType = DbType.SqlServer,//数据库类型 |
| | | IsAutoCloseConnection = true //不设成true要手动close |
| | | }, |
| | |
| | | { |
| | | // 使用 myScopedService 执行任务 |
| | | |
| | | //await DBSeed.SeedAsync(_dbContext, _webRootPath); |
| | | await DBSeed.SeedAsync(_dbContext, _webRootPath); |
| | | |
| | | //多租户 同步 |
| | | //await DBSeed.TenantSeedAsync(_dbContext); |
| | |
| | | public interface IProcessApplyService : IDependency |
| | | { |
| | | Task<WebResponseContent> GetProcessApplyAsync(ProcessApplyDto input); |
| | | |
| | | /// <summary> |
| | | /// 补录入库数据 |
| | | /// </summary> |
| | | /// <param name="palletCode">托盘号</param> |
| | | /// <param name="areaID">区域主键</param> |
| | | /// <returns></returns> |
| | | Task<WebResponseContent> StockInDataBackfillInterfaceAsync(string palletCode, int areaID); |
| | | } |
| | |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.MOM; |
| | | using WIDESEA_IBusinessesRepository; |
| | | using WIDESEA_IServices; |
| | | using WIDESEA_IStorageBasicRepository; |
| | | using WIDESEA_IStorageTaskRepository; |
| | | using WIDESEA_IStoragIntegrationServices; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_StoragIntegrationServices; |
| | | |
| | |
| | | { |
| | | private readonly LogFactory LogFactory = new LogFactory(); |
| | | private readonly ISys_ConfigService _configService; |
| | | private readonly IDt_AreaInfoRepository _areaInfoRepository; |
| | | private readonly ICellStateService _cellStateService; |
| | | private readonly IStockInfoRepository _stockInfoRepository; |
| | | private readonly IAgingInOrOutInputService _gingInOrOutInputService; |
| | | |
| | | public ProcessApplyService(ISys_ConfigService configRepository) |
| | | public ProcessApplyService(ISys_ConfigService configRepository, IDt_AreaInfoRepository areaInfoRepository, ICellStateService cellStateService, IDt_TaskRepository taskRepository, IStockInfoRepository stockInfoRepository, IAgingInOrOutInputService gingInOrOutInputService) |
| | | { |
| | | _configService = configRepository; |
| | | _areaInfoRepository = areaInfoRepository; |
| | | _cellStateService = cellStateService; |
| | | _stockInfoRepository = stockInfoRepository; |
| | | _gingInOrOutInputService = gingInOrOutInputService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 补录出库数据 |
| | | /// </summary> |
| | | /// <param name="palletCode"></param> |
| | | /// <returns></returns> |
| | | public async Task<WebResponseContent> StockOutDataBackfillInterfaceAsync(string palletCode, int areaID) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var area = _areaInfoRepository.QueryFirst(x => x.AreaID == areaID); |
| | | var trayCells = new TrayCellsStatusDto() |
| | | { |
| | | Software = area.Spare3, |
| | | TrayBarcode = palletCode, |
| | | EquipmentCode = area.Spare2, |
| | | SceneType = area.Spare4 |
| | | }; |
| | | content = await _cellStateService.GetTrayCellStatusAsync(trayCells); |
| | | if (!content.Status) return content; |
| | | |
| | | var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | if (result.SerialNos.Count > 0) |
| | | { |
| | | var stockHty = await SqlSugarHelper.Db.Queryable<DtStockInfo>().IncludesAllFirstLayer().FirstAsync(); |
| | | if (stockHty != null) |
| | | { |
| | | var parameterInfo = JsonConvert.DeserializeObject<List<ParameterInfo>>(stockHty.ParameterInfos).FirstOrDefault(y => y.Description.Contains("时间")); |
| | | if (parameterInfo == null) throw new Exception(""); |
| | | |
| | | var outHours = (DateTime.Now - (stockHty.LinedProcessFeedbackTime == null ? stockHty.ModifyDate.Value : stockHty.LinedProcessFeedbackTime.ToDateTime())).TotalHours; |
| | | var isNG = outHours > parameterInfo.LowerSpecificationsLimit.ToDouble() && outHours < parameterInfo.UpperSpecificationsLimit.ToDouble(); |
| | | |
| | | var defectCode = string.Empty; |
| | | if (!isNG) defectCode = "TQCK"; |
| | | var outputDto = new AgingOutputDto |
| | | { |
| | | OpFlag = 1, |
| | | Software = area.Spare3, |
| | | EquipmentCode = area.Spare2, |
| | | TrayBarcode = palletCode, |
| | | SerialNos = result.SerialNos.Select(x => new SerialNoOutDto |
| | | { |
| | | SlotNo = x.PositionNo, |
| | | SerialNo = x.SerialNo, |
| | | SerialNoResult = true, //isNG, |
| | | ParameterInfo = new List<ParameterInfoOutput> { |
| | | new ParameterInfoOutput() { |
| | | Value = outHours.ToString(), |
| | | ParameterCode =parameterInfo.ParameterCode, |
| | | ParameterDesc = parameterInfo.Description, |
| | | ParameterResult = "OK", //isNG.ToString(), |
| | | TargetValue = parameterInfo.TargetValue, |
| | | LowerLomit = parameterInfo.LowerSpecificationsLimit, |
| | | UpperLimit = parameterInfo.UpperSpecificationsLimit, |
| | | DefectCode = defectCode, |
| | | UOMCode = parameterInfo.UOMCode, |
| | | } |
| | | } |
| | | }).ToList() |
| | | }; |
| | | content = await _gingInOrOutInputService.GetOCVOutputAsync(outputDto); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | content.Error("电芯数据为空"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 补录入库数据 |
| | | /// </summary> |
| | | /// <param name="palletCode"></param> |
| | | /// <param name="areaID"></param> |
| | | /// <returns></returns> |
| | | public async Task<WebResponseContent> StockInDataBackfillInterfaceAsync(string palletCode, int areaID) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var area = _areaInfoRepository.QueryFirst(x => x.AreaID == areaID); |
| | | var trayCells = new TrayCellsStatusDto() |
| | | { |
| | | Software = area.Spare3, |
| | | TrayBarcode = palletCode, |
| | | EquipmentCode = area.Spare2, |
| | | SceneType = area.Spare4 |
| | | }; |
| | | content = await _cellStateService.GetTrayCellStatusAsync(trayCells); |
| | | if (!content.Status) return content; |
| | | |
| | | var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | if (result.SerialNos.Count > 0 && result.Success) |
| | | { |
| | | var stockInfo = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode); |
| | | if (stockInfo != null) |
| | | { |
| | | stockInfo.IsFull = true; |
| | | stockInfo.StockInfoDetails = result.SerialNos.Select(serialNoObj => new DtStockInfoDetail |
| | | { |
| | | SerialNumber = serialNoObj.SerialNo, |
| | | OrderNo = serialNoObj.PositionNo.ToString(), |
| | | Status = serialNoObj.SerialNoStatus, |
| | | MaterielCode = result.BindCode, |
| | | Remark = result.TrayBarcodePropertys.ToJsonString(), |
| | | }).ToList(); |
| | | stockInfo.Remark = stockInfo.StockInfoDetails.Count().ToString(); |
| | | |
| | | // 处理请求参数 |
| | | AgingInputDto agingInputDto = new AgingInputDto() |
| | | { |
| | | SerialNos = stockInfo.StockInfoDetails |
| | | .Select(item => new SerialNoInDto { SerialNo = item.SerialNumber, PositionNo = item.OrderNo }) |
| | | .ToList(), |
| | | TrayBarcode = palletCode, |
| | | OpFlag = 1, |
| | | EquipmentCode = area.Spare2, |
| | | Software = area.Spare3 |
| | | }; |
| | | |
| | | content = _gingInOrOutInputService.GetOCVInputAsync(agingInputDto).Result; |
| | | var respone = JsonConvert.DeserializeObject<ResponeAgingInputDto>(content.Data.ToString()); |
| | | |
| | | stockInfo.LinedProcessFeedbackTime = respone.LinedProcessFeedbackTime; |
| | | stockInfo.SpecialParameterDuration = respone.SpecialParameterDuration; |
| | | //2024年11月16日:新增字段计算应出库时间 |
| | | stockInfo.OutboundTime = Convert.ToDateTime(respone.LinedProcessFeedbackTime == null ? DateTime.Now : respone.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(respone.SpecialParameterDuration)); |
| | | stockInfo.ProductionLine = respone.ProductionLine; |
| | | stockInfo.ParameterInfos = respone.ParameterInfos.ToJsonString(); |
| | | stockInfo.StockStatus = 1; |
| | | |
| | | var isResult = await _stockInfoRepository.UpdateDataNavAsync(stockInfo); |
| | | if (isResult) |
| | | content.OK("更新数据成功"); |
| | | else |
| | | content.Error("更新数据失败"); |
| | | } |
| | | else |
| | | { |
| | | content.Error("未找到库存"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | |
| | | using Mapster; |
| | | using AngleSharp.Dom; |
| | | using Mapster; |
| | | using Masuit.Tools; |
| | | using SixLabors.Fonts.Tables.AdvancedTypographic; |
| | | using System.Diagnostics; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core.Const; |
| | |
| | | using WIDESEA_DTO.WMS; |
| | | using WIDESEA_IServices; |
| | | using WIDESEA_IStoragIntegrationServices; |
| | | using WIDESEA_StoragIntegrationServices; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | |
| | | namespace WIDESEA_StorageTaskServices; |
| | |
| | | { |
| | | if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | #region 老版本 |
| | | //var process = await SqlSugarHelper.Db.Queryable<Dt_EquipmentProcess>() |
| | | // .FirstAsync(x => x.EquipmentName == task.Roadway); |
| | | //var info = JsonConvert.DeserializeObject<ResponseEqptRunDto>(process.ProcessValue); |
| | | if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB") //非分容库区与当前工序是OCVB均上报MOM出入站 |
| | | //if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB") //非分容库区与当前工序是OCVB均上报MOM出入站 |
| | | //{ |
| | | // var agingOutputDto = MapToAgingOutputDto(stock); |
| | | // content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto); |
| | | // //ValidateResponse(content); |
| | | // var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString()); |
| | | // if (!result.Success || !agingOutputDto.SerialNos[0].SerialNoResult) |
| | | // { |
| | | // if (result.MessageCode == "E10001") |
| | | // { |
| | | // var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == stock.AreaCode); |
| | | // if (area == null) |
| | | // { |
| | | // throw new Exception("未找到对应的库区信息"); |
| | | // } |
| | | // var trayCells = new TrayCellsStatusDto() |
| | | // { |
| | | // Software = area.Spare3, |
| | | // TrayBarcode = task.PalletCode, |
| | | // EquipmentCode = area.Spare2, |
| | | // SceneType = area.Spare4 |
| | | // }; |
| | | // content = await _cellStateService.GetTrayCellStatusAsync(trayCells); |
| | | // if (!content.Status) return content; |
| | | |
| | | // var ResultTray = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | // if (ResultTray.SerialNos.Count > 0) |
| | | // { |
| | | // var parameterInfo = JsonConvert.DeserializeObject<List<ParameterInfo>>(stock.ParameterInfos).FirstOrDefault(y => y.Description.Contains("时间")); |
| | | // if (parameterInfo == null) throw new Exception(""); |
| | | |
| | | // var outHours = (DateTime.Now - (stock.LinedProcessFeedbackTime == null ? stock.CreateDate : stock.LinedProcessFeedbackTime.ToDateTime())).TotalHours; |
| | | |
| | | // var isNG = outHours > parameterInfo.LowerSpecificationsLimit.ToDouble() && outHours < parameterInfo.UpperSpecificationsLimit.ToDouble(); |
| | | |
| | | // var defectCode = string.Empty; |
| | | // if (!isNG) defectCode = "TQCK"; |
| | | // var outputDto = new AgingOutputDto |
| | | // { |
| | | // OpFlag = 1, |
| | | // Software = area.Spare3, |
| | | // EquipmentCode = area.Spare2, |
| | | // TrayBarcode = stock.PalletCode, |
| | | // SerialNos = ResultTray.SerialNos.Select(x => new SerialNoOutDto |
| | | // { |
| | | // SlotNo = x.PositionNo, |
| | | // SerialNo = x.SerialNo, |
| | | // SerialNoResult = true, //isNG, |
| | | // ParameterInfo = new List<ParameterInfoOutput> { |
| | | // new ParameterInfoOutput() { |
| | | // Value = outHours.ToString(), |
| | | // ParameterCode =parameterInfo.ParameterCode, |
| | | // ParameterDesc = parameterInfo.Description, |
| | | // ParameterResult = "OK", //isNG.ToString(), |
| | | // TargetValue = parameterInfo.TargetValue, |
| | | // LowerLomit = parameterInfo.LowerSpecificationsLimit, |
| | | // UpperLimit = parameterInfo.UpperSpecificationsLimit, |
| | | // DefectCode = defectCode, |
| | | // UOMCode = parameterInfo.UOMCode, |
| | | // } |
| | | // } |
| | | // }).ToList() |
| | | // }; |
| | | |
| | | // content = await _agingInOrOutInputService.GetOCVOutputAsync(outputDto); |
| | | // result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString()); |
| | | // if (!result.Success) |
| | | // task.Remark = "NG"; |
| | | // } |
| | | // } |
| | | // else |
| | | // task.Remark = "NG"; |
| | | // } |
| | | //} |
| | | #endregion 老版本 |
| | | |
| | | if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | var agingOutputDto = MapToAgingOutputDto(stock); |
| | | content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto); |
| | | //ValidateResponse(content); |
| | | var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString()); |
| | | if (!result.Success || !agingOutputDto.SerialNos[0].SerialNoResult) |
| | | if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB") |
| | | { |
| | | task.Remark = "NG"; |
| | | var agingOutputDto = MapToAgingOutputDto(stock); |
| | | content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto); |
| | | |
| | | var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString()); |
| | | task.Remark = result.Success ? null : "NG"; |
| | | |
| | | if (!result.Success && result.MessageCode == "E10001") |
| | | { |
| | | await HandleOutBoundError(stock, task); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | // 更新库存状态和任务状态 |
| | | (var loc, var tas) = UpdateStockAndTaskStatus(stock, task); |
| | | var taskHty = task.Adapt<Dt_Task_Hty>(); |
| | | //taskHty.FinishTime = DateTime.Now; |
| | | taskHty.FinishTime = DateTime.Now; |
| | | |
| | | DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>(); |
| | | stockInfo_Hty.ModifyDate = DateTime.Now; |
| | | |
| | | // 事务处理 |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | |
| | | { |
| | | await DeleteStockInfoAsync(stock.Id); |
| | | await DeleteStockInfoDetailsAsync(stock.StockInfoDetails); |
| | | await AddStockInfoHtyAsync(stockInfo_Hty); |
| | | } |
| | | await UpdateLocationAsync(loc); |
| | | //if (task.Roadway.Contains("FR") || task.Roadway.Contains("GW") || task.TaskType == (int)TaskOutboundTypeEnum.OutTray) //如果是分容或高温出库 将任务删除 |
| | | await DeleteTaskAsync(task.TaskId); |
| | | await AddTaskHtyAsync(taskHty); |
| | | }); |
| | |
| | | }; |
| | | } |
| | | |
| | | private void ValidateResponse(WebResponseContent content) |
| | | { |
| | | } |
| | | |
| | | private (DtLocationInfo, Dt_Task) UpdateStockAndTaskStatus(DtStockInfo stock, Dt_Task task) |
| | | { |
| | | var location = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway); |
| | |
| | | if (!isStockUpdated) |
| | | { |
| | | throw new Exception("库存信息更新失败"); |
| | | } |
| | | } |
| | | |
| | | private async Task AddStockInfoHtyAsync(DtStockInfo_Hty dtStock) |
| | | { |
| | | var isStockAdd = await SqlSugarHelper.Db.InsertNav(dtStock).IncludesAllFirstLayer().ExecuteCommandAsync(); |
| | | if (!isStockAdd) |
| | | { |
| | | throw new Exception("库存历史信息添加失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception err) |
| | | { |
| | | throw; |
| | | return content.Error(err.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | // 根据托盘类型查询库存信息 |
| | | DtStockInfo stockInfo = tag == (int)TaskOutboundTypeEnum.Outbound |
| | | ? areaCodes == null ? await QueryStockInfoForRealTrayAsync(areaCode, productionLine) : await QueryStockInfoForRealTrayCWAsync(areaCodes, productionLine) |
| | | ? areaCode != "CWSC1" ? await QueryStockInfoForRealTrayAsync(areaCode, areaCodes, productionLine) : await QueryStockInfoForRealTrayCWAsync(areaCodes, productionLine) |
| | | : await QueryStockInfoForEmptyTrayAsync(areaCode); |
| | | |
| | | if (stockInfo == null) |
| | |
| | | /// <summary> |
| | | /// 查询实盘库存信息 |
| | | /// </summary> |
| | | private async Task<DtStockInfo> QueryStockInfoForRealTrayAsync(string areaCode, string productionLine) |
| | | private async Task<DtStockInfo> QueryStockInfoForRealTrayAsync(string areaCode, List<string> devices, string productionLine) |
| | | { |
| | | var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode); |
| | | |
| | |
| | | .Includes(x => x.StockInfoDetails) // 预加载StockInfoDetails |
| | | .Where(x => x.AreaCode == areaCode && x.OutboundTime < DateTime.Now && x.IsFull == true) // 过滤条件 |
| | | .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // 过滤条件 |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件 |
| | | .WhereIF(!devices.IsNullOrEmpty(), x => devices.Contains(x.LocationInfo.RoadwayNo)) |
| | | .OrderBy(x => x.OutboundTime) // 排序 |
| | | .FirstAsync(); // 获取第一个元素 |
| | | |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询实盘库存信息 |
| | | /// 查询常温实盘库存信息 |
| | | /// </summary> |
| | | private async Task<DtStockInfo> QueryStockInfoForRealTrayCWAsync(List<string> areaCodes, string productionLine) |
| | | { |
| | |
| | | .Includes(x => x.StockInfoDetails) // 预加载StockInfoDetails |
| | | .Where(x => areaCodes.Contains(x.AreaCode) && x.OutboundTime < DateTime.Now && x.IsFull == true) // 过滤条件 |
| | | .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // 过滤条件 |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件 |
| | | .OrderBy(x => x.OutboundTime) // 排序 |
| | | .FirstAsync(); // 获取第一个元素 |
| | | |
| | |
| | | .Includes(x => x.StockInfoDetails) // 预加载StockInfoDetails |
| | | .Where(x => x.AreaCode == areaCode && x.IsFull == false) |
| | | .Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "空托盘")) |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // 过滤条件 |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件 |
| | | .OrderBy(x => x.CreateDate) // 排序 |
| | | .FirstAsync(); // 转换为列表 |
| | | |
| | |
| | | { |
| | | return new Dt_Task |
| | | { |
| | | Grade = 1, |
| | | Grade = tag == 104 ? 2 : 1, |
| | | Roadway = stockInfo.LocationInfo.RoadwayNo, |
| | | TargetAddress = position, |
| | | Dispatchertime = DateTime.Now, |
| | |
| | | return new WMSTaskDTO |
| | | { |
| | | TaskNum = task.TaskNum.Value, |
| | | Grade = 1, |
| | | Grade = task.Grade.Value, |
| | | PalletCode = task.PalletCode, |
| | | RoadWay = task.Roadway, |
| | | SourceAddress = task.SourceAddress, |
| | |
| | | |
| | | public async Task<WebResponseContent> CreateAndSendInboundTask(string palletCode, string position) |
| | | { |
| | | #region |
| | | //WebResponseContent content = new WebResponseContent(); |
| | | //try |
| | | //{ |
| | | // // 查询库存信息 |
| | | // var stockInfo = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == palletCode); |
| | | // if (stockInfo == null) |
| | | // { |
| | | // var taskOld = BaseDal.QueryFirst(x => x.PalletCode == palletCode); |
| | | // if (!taskOld.IsNullOrEmpty()) |
| | | // {// 创建WMS任务 |
| | | // WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | // { |
| | | // TaskNum = taskOld.TaskNum.Value, |
| | | // Grade = 1, |
| | | // PalletCode = taskOld.PalletCode, |
| | | // RoadWay = taskOld.Roadway, |
| | | // SourceAddress = taskOld.CurrentAddress, |
| | | // TargetAddress = taskOld.TargetAddress, |
| | | // TaskState = taskOld.TaskState.Value, |
| | | // Id = 0, |
| | | // TaskType = taskOld.TaskType, |
| | | // }; |
| | | // return content.OK(data: taskDTO); |
| | | // } |
| | | // var area = _areaInfoRepository.QueryFirst(x => x.AreaID == 2); |
| | | // var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == position); |
| | | // TrayCellsStatusDto trayCells = CreateTrayCellsStatusDto(area, palletCode); |
| | | // content = await GetTrayCellStatusAsync(trayCells); |
| | | // if (!content.Status) return content; |
| | | |
| | | // ConsoleHelper.WriteErrorLine(content.ToJsonString()); |
| | | // var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | // if (!result.Success) return content.Error(result.MOMMessage); |
| | | |
| | | // if (result.SerialNos.Count > 0) |
| | | // { |
| | | // var boxing = CreateBoxingInfo(result, palletCode); |
| | | // if (boxing == null) return content.Error("组盘失败"); |
| | | |
| | | // // 获取工艺路线 |
| | | // ProcessApplyDto process = await GetProcessApplyAsync(result); |
| | | // // 赋值上位软件名称和设备编码 |
| | | // process.Software = area.Spare3; |
| | | // process.EquipmentCode = area.Spare2; |
| | | // content = await _processApplyService.GetProcessApplyAsync(process); |
| | | // 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.Contains(boxing.ProcessCode)).FirstOrDefault().Number.ToInt32(); |
| | | // foreach (var item in resultProcessApply.ProcessInfo) |
| | | // { |
| | | // if (item.Number.ToInt32() == number + 1) |
| | | // { |
| | | // boxing.NextProcessCode = item.ProcessCode; |
| | | // } |
| | | // } |
| | | // var location = await GetLocationDistributeAsync(station.Roadway); |
| | | |
| | | // ConsoleHelper.WriteErrorLine(location.ToJsonString()); |
| | | |
| | | // // 创建新任务实例 |
| | | // var task = new Dt_Task |
| | | // { |
| | | // CurrentAddress = station.stationLocation, |
| | | // Grade = 1, |
| | | // Roadway = station.Roadway, |
| | | // TargetAddress = location.LocationCode, |
| | | // Dispatchertime = DateTime.Now, |
| | | // MaterialNo = "", |
| | | // NextAddress = location.LocationCode, |
| | | // OrderNo = null, |
| | | // PalletCode = palletCode, |
| | | // SourceAddress = position, |
| | | // TaskState = (int)TaskInStatusEnum.Line_InFinish, |
| | | // TaskType = (int)TaskInboundTypeEnum.Inbound, |
| | | // TaskNum = await BaseDal.GetTaskNo(), |
| | | // Creater = "Systeam" |
| | | // }; |
| | | |
| | | // // 创建WMS任务 |
| | | // WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | // { |
| | | // TaskNum = task.TaskNum.Value, |
| | | // Grade = 1, |
| | | // PalletCode = task.PalletCode, |
| | | // RoadWay = task.Roadway, |
| | | // SourceAddress = task.SourceAddress, |
| | | // TargetAddress = task.TargetAddress, |
| | | // TaskState = task.TaskState.Value, |
| | | // Id = 0, |
| | | // TaskType = task.TaskType, |
| | | // }; |
| | | |
| | | // await _unitOfWorkManage.UseTranAsync(async () => |
| | | // { |
| | | // // 添加任务到数据库 |
| | | // await BaseDal.AddDataAsync(task); |
| | | // // 更新库存位置状态为不可用 |
| | | // location.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | // await _locationRepository.UpdateDataAsync(location); |
| | | // await _boxingInfoRepository.AddDataNavAsync(boxing); |
| | | // }); |
| | | |
| | | // content.OK(data: taskDTO); |
| | | // } |
| | | // else |
| | | // content.Error(result.MOMMessage); |
| | | // } |
| | | // else |
| | | // { |
| | | // // TODO质检回库 |
| | | // var area = _areaInfoRepository.QueryFirst(x => x.AreaID == 2); |
| | | // } |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // content.Error(ex.Message); |
| | | //} |
| | | //return content; |
| | | #endregion |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | |
| | | if (stockInfo == null) |
| | | { |
| | | var taskOld = BaseDal.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (!taskOld.IsNullOrEmpty()) |
| | | {// 创建WMS任务 |
| | | WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | { |
| | | TaskNum = taskOld.TaskNum.Value, |
| | | Grade = 1, |
| | | PalletCode = taskOld.PalletCode, |
| | | RoadWay = taskOld.Roadway, |
| | | SourceAddress = taskOld.CurrentAddress, |
| | | TargetAddress = taskOld.TargetAddress, |
| | | TaskState = taskOld.TaskState.Value, |
| | | Id = 0, |
| | | TaskType = taskOld.TaskType, |
| | | }; |
| | | if (taskOld != null) |
| | | { |
| | | // 创建WMS任务 |
| | | WMSTaskDTO taskDTO = CreateWMSTaskDTO(taskOld); |
| | | return content.OK(data: taskDTO); |
| | | } |
| | | var area = _areaInfoRepository.QueryFirst(x => x.AreaID == 2); |
| | |
| | | |
| | | ConsoleHelper.WriteErrorLine(content.ToJsonString()); |
| | | var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | if (result == null || !result.Success) return content.Error(result?.MOMMessage ?? "Deserialization error"); |
| | | |
| | | if (result.SerialNos.Count > 0) |
| | | { |
| | | var boxing = CreateBoxingInfo(result, palletCode); |
| | | if (boxing == null) return content.Error("组盘失败"); |
| | | |
| | | // 获取工艺路线 |
| | | ProcessApplyDto process = await GetProcessApplyAsync(result); |
| | | // 赋值上位软件名称和设备编码 |
| | | process.Software = area.Spare3; |
| | | process.EquipmentCode = area.Spare2; |
| | | |
| | | content = await _processApplyService.GetProcessApplyAsync(process); |
| | | if (!content.Status) return content.Error("工艺申请失败"); |
| | | |
| | | var resultProcessApply = JsonConvert.DeserializeObject<ResultProcessApply>(content.Data.ToString()) as ResultProcessApply; |
| | | if (resultProcessApply == null || !resultProcessApply.Success) return content.Error("工艺申请失败"); |
| | | |
| | | var number = resultProcessApply.ProcessInfo.Where(x => x.ProcessCode.Contains(boxing.ProcessCode)).FirstOrDefault()?.Number.ToInt32() ?? 0; |
| | | foreach (var item in resultProcessApply.ProcessInfo) |
| | | { |
| | | if (item.Number.ToInt32() == number + 1) |
| | | { |
| | | boxing.NextProcessCode = item.ProcessCode; |
| | | } |
| | | } |
| | | var location = await GetLocationDistributeAsync(station.Roadway); |
| | | |
| | | ConsoleHelper.WriteErrorLine(location.ToJsonString()); |
| | | |
| | | // 创建新任务实例 |
| | | var task = new Dt_Task |
| | | { |
| | |
| | | }; |
| | | |
| | | // 创建WMS任务 |
| | | WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | { |
| | | TaskNum = task.TaskNum.Value, |
| | | Grade = 1, |
| | | PalletCode = task.PalletCode, |
| | | RoadWay = task.Roadway, |
| | | SourceAddress = task.SourceAddress, |
| | | TargetAddress = task.TargetAddress, |
| | | TaskState = task.TaskState.Value, |
| | | Id = 0, |
| | | TaskType = task.TaskType, |
| | | }; |
| | | WMSTaskDTO taskDTO = CreateWMSTaskDTO(task); |
| | | |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | | { |
| | | // 添加任务到数据库 |
| | | await BaseDal.AddDataAsync(task); |
| | | // 更新库存位置状态为不可用 |
| | | location.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | location.LocationStatus = (int)LocationEnum.Lock; |
| | | await _locationRepository.UpdateDataAsync(location); |
| | | await _boxingInfoRepository.AddDataNavAsync(boxing); |
| | | }); |
| | | |
| | | content.OK(data: taskDTO); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 更详细的日志记录,可使用日志框架替换 Console.WriteLine |
| | | Console.WriteLine($"Error in CreateAndSendInboundTask: {ex.Message}"); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | |
| | | private WMSTaskDTO CreateWMSTaskDTO(object source) |
| | | { |
| | | if (source is Dt_Task taskOld) |
| | | { |
| | | return new WMSTaskDTO() |
| | | { |
| | | TaskNum = taskOld.TaskNum.Value, |
| | | Grade = 1, |
| | | PalletCode = taskOld.PalletCode, |
| | | RoadWay = taskOld.Roadway, |
| | | SourceAddress = taskOld.CurrentAddress, |
| | | TargetAddress = taskOld.TargetAddress, |
| | | TaskState = taskOld.TaskState.Value, |
| | | Id = 0, |
| | | TaskType = taskOld.TaskType, |
| | | }; |
| | | } |
| | | else if (source is Dt_Task task) |
| | | { |
| | | return new WMSTaskDTO() |
| | | { |
| | | TaskNum = task.TaskNum.Value, |
| | | Grade = 1, |
| | | PalletCode = task.PalletCode, |
| | | RoadWay = task.Roadway, |
| | | SourceAddress = task.SourceAddress, |
| | | TargetAddress = task.TargetAddress, |
| | | TaskState = task.TaskState.Value, |
| | | Id = 0, |
| | | TaskType = task.TaskType, |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | throw new ArgumentException("Invalid source object type for WMSTaskDTO creation."); |
| | | } |
| | | } |
| | | |
| | | #endregion 静置异常口入库 |
| | |
| | | public async Task<bool> Delete(List<int> ids) |
| | | { |
| | | return await BaseDal.Delete(ids); |
| | | } |
| | | |
| | | public override WebResponseContent DeleteData(object[] key) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | // 创建历史任务实例模型 |
| | | try |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key[0])); |
| | | if (task == null) |
| | | { |
| | | return content.Error("未找到任务信息!"); |
| | | } |
| | | var taskHtyNG = CreateHistoricalTask(task, true); |
| | | |
| | | // 执行数据库事务 |
| | | |
| | | // 添加历史任务 |
| | | var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0; |
| | | |
| | | // 删除任务数据 |
| | | var isTaskDelete = BaseDal.Delete(task.TaskId); |
| | | |
| | | return content.OK("删除成功!"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error("删除任务异常:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | private Dt_Task_Hty CreateHistoricalTask(Dt_Task task) |
| | | private Dt_Task_Hty CreateHistoricalTask(Dt_Task task, bool isHand = false) |
| | | { |
| | | // 更新任务状态 |
| | | task.TaskState = TaskOutStatusEnum.OutFinish.ObjToInt(); |
| | |
| | | var taskHty = _mapper.Map<Dt_Task_Hty>(task); |
| | | taskHty.FinishTime = DateTime.Now; |
| | | taskHty.TaskId = 0; |
| | | taskHty.OperateType = (int)OperateTypeEnum.自动完成; |
| | | taskHty.OperateType = isHand ? (int)OperateTypeEnum.人工删除 : (int)OperateTypeEnum.自动完成; |
| | | taskHty.SourceId = task.TaskId; |
| | | taskHty.TaskState = TaskOutStatusEnum.OutFinish.ObjToInt(); |
| | | return taskHty; |
| | |
| | | var content = new WebResponseContent(); |
| | | |
| | | // 获取目标地址和更新任务状态 |
| | | |
| | | |
| | | input.Position = Regex.Replace(input.Position, @"-(\d+)", ""); |
| | | if (Convert.ToInt32(input.Position) > 1999) |
| | |
| | | return content; |
| | | } |
| | | |
| | | |
| | | private static readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); |
| | | /// <summary> |
| | | /// 查找货位 |
| | | /// </summary> |
| | |
| | | { |
| | | #region 获取货位 |
| | | |
| | | await _semaphore.WaitAsync(); |
| | | try |
| | | { |
| | | List<DtLocationInfo> locations; |
| | | if (IsFull) |
| | | { |
| | | locations = await _locationRepository.QueryDataAsync(x => x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo == roadWay); |
| | | locations = await _locationRepository.QueryDataAsync(x => x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo == roadWay && x.EnalbeStatus == (int)EnableEnum.Enable); |
| | | } |
| | | else |
| | | { |
| | | locations = await _locationRepository.QueryDataAsync(x => x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo == roadWay /*&& x.LocationType ==*/); |
| | | locations = await _locationRepository.QueryDataAsync(x => x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo == roadWay && x.EnalbeStatus == (int)EnableEnum.Enable); |
| | | } |
| | | |
| | | if (locations == null) |
| | |
| | | { |
| | | Console.WriteLine(err.Message.ToString()); |
| | | return null; |
| | | } |
| | | finally |
| | | { |
| | | _semaphore.Release(); |
| | | } |
| | | |
| | | #endregion 获取货位 |
| | |
| | | return minRoadwayNo; |
| | | } |
| | | |
| | | // 新的出库错误处理逻辑 |
| | | private async Task HandleOutBoundError(DtStockInfo stock, Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == stock.AreaCode); |
| | | if (area == null) |
| | | { |
| | | throw new Exception("未找到对应的库区信息"); |
| | | } |
| | | |
| | | var trayCells = new TrayCellsStatusDto |
| | | { |
| | | Software = area.Spare3, |
| | | TrayBarcode = task.PalletCode, |
| | | EquipmentCode = area.Spare2, |
| | | SceneType = area.Spare4 |
| | | }; |
| | | |
| | | content = await _cellStateService.GetTrayCellStatusAsync(trayCells); |
| | | if (!content.Status) return; |
| | | |
| | | var ResultTray = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | if (ResultTray.SerialNos.Count > 0) |
| | | { |
| | | var parameterInfo = GetParameterInfo(stock); |
| | | |
| | | var outHours = CalculateOutHours(stock); |
| | | var isNG = outHours > parameterInfo.LowerSpecificationsLimit.ToDouble() |
| | | && outHours < parameterInfo.UpperSpecificationsLimit.ToDouble(); |
| | | |
| | | var defectCode = !isNG ? "TQCK" : string.Empty; |
| | | |
| | | var outputDto = CreateAgingOutputDto(area, stock, ResultTray, parameterInfo, outHours, defectCode); |
| | | content = await _agingInOrOutInputService.GetOCVOutputAsync(outputDto); |
| | | |
| | | var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString()); |
| | | if (!result.Success) |
| | | task.Remark = "NG"; |
| | | } |
| | | } |
| | | |
| | | // 计算出库小时的方法 |
| | | private double CalculateOutHours(DtStockInfo stock) => |
| | | (DateTime.Now - Convert.ToDateTime(stock.LinedProcessFeedbackTime ?? stock.CreateDate.ToString())).TotalHours; |
| | | |
| | | // 生成 AgingOutputDto 的封装方法 |
| | | private AgingOutputDto CreateAgingOutputDto(Dt_AreaInfo area, DtStockInfo stock, ResultTrayCellsStatus resultTray, |
| | | ParameterInfo parameterInfo, double outHours, string defectCode) |
| | | { |
| | | return new AgingOutputDto |
| | | { |
| | | OpFlag = 1, |
| | | Software = area.Spare3, |
| | | EquipmentCode = area.Spare2, |
| | | TrayBarcode = stock.PalletCode, |
| | | SerialNos = resultTray.SerialNos.Select(x => new SerialNoOutDto |
| | | { |
| | | SlotNo = x.PositionNo, |
| | | SerialNo = x.SerialNo, |
| | | SerialNoResult = true, |
| | | ParameterInfo = new List<ParameterInfoOutput> |
| | | { |
| | | new ParameterInfoOutput |
| | | { |
| | | Value = outHours.ToString(), |
| | | ParameterCode = parameterInfo.ParameterCode, |
| | | ParameterDesc = parameterInfo.Description, |
| | | ParameterResult = "OK", |
| | | TargetValue = parameterInfo.TargetValue, |
| | | LowerLomit = parameterInfo.LowerSpecificationsLimit, |
| | | UpperLimit = parameterInfo.UpperSpecificationsLimit, |
| | | DefectCode = defectCode, |
| | | } |
| | | } |
| | | }).ToList() |
| | | }; |
| | | } |
| | | |
| | | // 获取参数信息的辅助方法 |
| | | private ParameterInfo GetParameterInfo(DtStockInfo stock) => |
| | | JsonConvert.DeserializeObject<List<ParameterInfo>>(stock.ParameterInfos) |
| | | .FirstOrDefault(y => y.Description.Contains("时间")); |
| | | |
| | | #endregion 任务请求方法 |
| | | |
| | | #endregion private 内部方法 |
| | |
| | | { |
| | | return await _processApplyService.GetProcessApplyAsync(input); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 补录入库数据 |
| | | /// </summary> |
| | | /// <param name="palletCode">托盘号</param> |
| | | /// <param name="areaID">区域主键</param> |
| | | /// <returns></returns> |
| | | [HttpPost("StockInDataBack")] |
| | | public async Task<WebResponseContent> StockInDataBackfillInterfaceAsync(string palletCode, int areaID) |
| | | { |
| | | return await _processApplyService.StockInDataBackfillInterfaceAsync(palletCode, areaID); |
| | | } |
| | | } |