| | |
| | | /// 设备名称 |
| | | /// </summary> |
| | | public abstract string Name { get; } |
| | | public abstract string IpAddress { get; } |
| | | public abstract int Port { get; } |
| | | |
| | | /// <summary> |
| | | /// 获取当前通讯器是否已连接到PLC。 |
| | |
| | | /// <summary> |
| | | /// PLC名称 |
| | | /// </summary> |
| | | public override string IpAddress => _ipAddress; |
| | | public override int Port => _port; |
| | | public override string Name => _name; |
| | | |
| | | public override ILogNet LogNet => _logNet; |
| | |
| | | using System.Security.Policy; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | |
| | | namespace WIDESEAWCS_Core.Helper |
| | | { |
| | |
| | | } |
| | | } |
| | | string result = string.Empty; |
| | | QuartzLogger.WriteLogToFile($"MOMAPI接口", $"请求地址:【{serviceAddress}】,请求时间【{DateTime.Now}】请求参数【{JsonConvert.SerializeObject(requestJson)}】{Environment.NewLine}{Environment.NewLine}"); |
| | | |
| | | using (HttpContent httpContent = new StringContent(requestJson)) |
| | | { |
| | | httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); |
| | | using HttpClient httpClient = new HttpClient(); |
| | | httpClient.Timeout = new TimeSpan(0, 0, 120); |
| | | httpClient.Timeout = new TimeSpan(0, 0, 360); |
| | | |
| | | if (headers != null) |
| | | { |
| | |
| | | } |
| | | result = await httpClient.PostAsync(serviceAddress, httpContent).Result.Content.ReadAsStringAsync(); |
| | | } |
| | | QuartzLogger.WriteLogToFile($"MOMAPI接口", $"请求地址:【{serviceAddress}】,返回时间【{DateTime.Now}】返回参数【{JsonConvert.SerializeObject(result)}】{Environment.NewLine}{Environment.NewLine}"); |
| | | return result; |
| | | } |
| | | catch (Exception e) |
| | |
| | | string responseParam = string.Empty; |
| | | try |
| | | { |
| | | string? apiIgnore = AppSettings.GetValue("ApiLogIgnore")?.ToString(); |
| | | string[] ignoreUrls = !string.IsNullOrEmpty(apiIgnore) ? apiIgnore.Split(",") : new string[] { "get" }; |
| | | |
| | | (context.RequestServices.GetService(typeof(RequestLogModel)) as RequestLogModel).RequestDate = DateTime.Now; |
| | | try |
| | | { |
| | |
| | | |
| | | ms.Position = 0; |
| | | await ms.CopyToAsync(originalBody); |
| | | if (!(context.Request.Path.Value?.Contains("Get") ?? false)) |
| | | |
| | | if (!ignoreUrls.Any(x => context.Request.Path.Value?.ToLower().Contains(x.ToLower()) ?? false)) |
| | | { |
| | | Logger.Add(requestParam, responseParam); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 记录异常 |
| | |
| | | [assembly: System.Reflection.AssemblyCompanyAttribute("WIDESEAWCS_IProcessService")] |
| | | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] |
| | | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bfa85418f2da7b0f3570d7e44b203727c637b729")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+29aa484d06b2d4839536034bb1033d0e60334ec2")] |
| | | [assembly: System.Reflection.AssemblyProductAttribute("WIDESEAWCS_IProcessService")] |
| | | [assembly: System.Reflection.AssemblyTitleAttribute("WIDESEAWCS_IProcessService")] |
| | | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] |
| | |
| | | [assembly: System.Reflection.AssemblyCompanyAttribute("WIDESEAWCS_ITaskInfo_HtyRepository")] |
| | | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] |
| | | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bfa85418f2da7b0f3570d7e44b203727c637b729")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+29aa484d06b2d4839536034bb1033d0e60334ec2")] |
| | | [assembly: System.Reflection.AssemblyProductAttribute("WIDESEAWCS_ITaskInfo_HtyRepository")] |
| | | [assembly: System.Reflection.AssemblyTitleAttribute("WIDESEAWCS_ITaskInfo_HtyRepository")] |
| | | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] |
| | |
| | | [assembly: System.Reflection.AssemblyCompanyAttribute("WIDESEAWCS_ITaskInfo_HtyService")] |
| | | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] |
| | | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bfa85418f2da7b0f3570d7e44b203727c637b729")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+29aa484d06b2d4839536034bb1033d0e60334ec2")] |
| | | [assembly: System.Reflection.AssemblyProductAttribute("WIDESEAWCS_ITaskInfo_HtyService")] |
| | | [assembly: System.Reflection.AssemblyTitleAttribute("WIDESEAWCS_ITaskInfo_HtyService")] |
| | | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] |
| | |
| | | [assembly: System.Reflection.AssemblyCompanyAttribute("WIDESEAWCS_ProcessService")] |
| | | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] |
| | | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bfa85418f2da7b0f3570d7e44b203727c637b729")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+29aa484d06b2d4839536034bb1033d0e60334ec2")] |
| | | [assembly: System.Reflection.AssemblyProductAttribute("WIDESEAWCS_ProcessService")] |
| | | [assembly: System.Reflection.AssemblyTitleAttribute("WIDESEAWCS_ProcessService")] |
| | | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] |
| | |
| | | #endregion << 版 本 注 释 >> |
| | | |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Quartz.Spi; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using Quartz.Spi; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | //using static Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser; |
| | | |
| | | namespace WIDESEAWCS_QuartzJob |
| | | { |
| | |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_DTO.BasicInfo; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | |
| | | { |
| | | // 用于记录已经访问过的起点和终点组合,避免重复访问进入死循环 |
| | | HashSet<string> visitedRoutes = new HashSet<string>(); |
| | | return QueryNextRoutesInternal(startPosi, endPosi, visitedRoutes); |
| | | var stopwatch = Stopwatch.StartNew(); |
| | | var rasult = QueryNextRoutesInternal(startPosi, endPosi, visitedRoutes); |
| | | |
| | | stopwatch.Stop(); |
| | | var elapsed = stopwatch.ElapsedMilliseconds; |
| | | QuartzLogger.WriteLogToFile("路由查询", $"时长{elapsed},起点:{startPosi},终点{endPosi}"); |
| | | return rasult; |
| | | } |
| | | |
| | | private List<Dt_Router> QueryNextRoutesInternal(string startPosi, string endPosi, HashSet<string> visitedRoutes) |
| | |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | throw new Exception($"该路径未配置或配置错误,请检查设备路由信息,起点:【{startPosi}】,终点:【{endPosi}】"); |
| | | } |
| | | //else |
| | | //{ |
| | | // throw new Exception($"该路径未配置或配置错误,请检查设备路由信息,起点:【{startPosi}】,终点:【{endPosi}】"); |
| | | //} |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | using WIDESEAWCS_Core.Extensions; |
| | | using WIDESEAWCS_Core.Filter; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_Core.Middlewares; |
| | | using WIDESEAWCS_QuartzJob.QuartzExtensions; |
| | | using WIDESEAWCS_QuartzJob.Seed; |
| | |
| | | |
| | | var builder = WebApplication.CreateBuilder(args); |
| | | |
| | | int workerThreads = Environment.ProcessorCount * 8; |
| | | int completionThreads = Environment.ProcessorCount; |
| | | ThreadPool.SetMaxThreads(workerThreads, completionThreads); |
| | | |
| | | AppDomain.CurrentDomain.FirstChanceException += (sender, e) => |
| | | { |
| | | bool flag = e.Exception.TargetSite?.DeclaringType?.Namespace?.StartsWith("WIDESEA") == true; |
| | | |
| | | if (e.Exception is not OperationCanceledException && flag) |
| | | { |
| | | string folderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Log\\Exception"); |
| | | Exception ex = e.Exception; |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.Append("错误信息:"); |
| | | builder.Append(ex.Message); |
| | | builder.Append(Environment.NewLine); |
| | | builder.Append("错误源:"); |
| | | builder.Append(ex.Source); |
| | | builder.Append(Environment.NewLine); |
| | | builder.Append("错误堆栈:"); |
| | | builder.Append(ex.StackTrace); |
| | | builder.Append(Environment.NewLine); |
| | | builder.Append("错误类型:"); |
| | | builder.Append(ex.GetType().ToString()); |
| | | builder.Append(Environment.NewLine); |
| | | builder.Append("错误方法:"); |
| | | builder.Append(ex.TargetSite?.ToString()); |
| | | builder.Append(Environment.NewLine); |
| | | builder.Append(Environment.NewLine); |
| | | |
| | | QuartzLogger.WriteLogToFile($"Error_全局错误", builder.ToString()); |
| | | } |
| | | }; |
| | | |
| | | if (!HslCommunication.Authorization.SetAuthorizationCode("95f1611d-633c-46ea-b03a-38ede1629f74")) |
| | | { |
| | | ConsoleHelper.WriteErrorLine("授权失败!当前程序只能使用24小时!"); |
| | |
| | | { |
| | | "urls": "http://*:9290", //web服务端口,如果用IIS部署,把这个去掉 |
| | | "urls": "http://*:9291", //web服务端口,如果用IIS部署,把这个去掉 |
| | | "Logging": { |
| | | "LogLevel": { |
| | | "Default": "Information", |
| | |
| | | // 注意,http://127.0.0.1:1818 和 http://localhost:1818 是不一样的 |
| | | "IPs": "http://127.0.0.1:8080,http://localhost:8080,http://127.0.0.1:8081,http://localhost:8081" |
| | | }, |
| | | "ApiLogIgnore": "get,query,download,upload,template", |
| | | "ApiName": "WIDESEA", |
| | | "ExpMinutes": 120, |
| | | "QuartzJobAutoStart": true, |
| | |
| | | [assembly: System.Reflection.AssemblyCompanyAttribute("WIDESEAWCS_SignalR")] |
| | | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] |
| | | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bfa85418f2da7b0f3570d7e44b203727c637b729")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+29aa484d06b2d4839536034bb1033d0e60334ec2")] |
| | | [assembly: System.Reflection.AssemblyProductAttribute("WIDESEAWCS_SignalR")] |
| | | [assembly: System.Reflection.AssemblyTitleAttribute("WIDESEAWCS_SignalR")] |
| | | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] |
| | |
| | | // 设置下一个地址为第一个子位置 |
| | | task.NextAddress = routers.FirstOrDefault().ChildPosi; |
| | | } |
| | | else |
| | | { |
| | | QuartzLogger.WriteLogToFile("路由查找异常", $"起点:{item.SourceAddress},终点:{item.TargetAddress},任务号:{item.TaskNum}"); |
| | | return content.Error("未找到路由配置"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | [assembly: System.Reflection.AssemblyCompanyAttribute("WIDESEAWCS_TaskInfo_HtyRepository")] |
| | | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] |
| | | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bfa85418f2da7b0f3570d7e44b203727c637b729")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+29aa484d06b2d4839536034bb1033d0e60334ec2")] |
| | | [assembly: System.Reflection.AssemblyProductAttribute("WIDESEAWCS_TaskInfo_HtyRepository")] |
| | | [assembly: System.Reflection.AssemblyTitleAttribute("WIDESEAWCS_TaskInfo_HtyRepository")] |
| | | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] |
| | |
| | | [assembly: System.Reflection.AssemblyCompanyAttribute("WIDESEAWCS_TaskInfo_HtyService")] |
| | | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] |
| | | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bfa85418f2da7b0f3570d7e44b203727c637b729")] |
| | | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+29aa484d06b2d4839536034bb1033d0e60334ec2")] |
| | | [assembly: System.Reflection.AssemblyProductAttribute("WIDESEAWCS_TaskInfo_HtyService")] |
| | | [assembly: System.Reflection.AssemblyTitleAttribute("WIDESEAWCS_TaskInfo_HtyService")] |
| | | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] |
| | |
| | | /// </summary> |
| | | private void HandleNewTask(CommonConveyorLine_CW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode) |
| | | { |
| | | try |
| | | { |
| | | |
| | | Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode); |
| | | |
| | | if (stationManager == null) |
| | |
| | | // break; |
| | | } |
| | | |
| | | #region |
| | | //Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode); |
| | | |
| | | //if (stationManager.stationType == 8) |
| | | //{ |
| | | // var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode); |
| | | // if (task != null) |
| | | // { |
| | | // RequestInNextAddress(conveyorLine, command, childDeviceCode); |
| | | // } |
| | | //} |
| | | //else if (stationManager.stationType == 9) |
| | | //{ |
| | | // var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode); |
| | | // if (task != null) |
| | | // { |
| | | // ConveyorLineInFinish(conveyorLine, command, childDeviceCode); |
| | | // } |
| | | //} |
| | | //else if (stationManager.stationType == 1) |
| | | //{ |
| | | // if (stationManager.stationArea.Contains("GW")) |
| | | // { |
| | | // var taskGW = _taskRepository.QueryFirst(x => x.TargetAddress == childDeviceCode && x.TaskState == (int)TaskOutStatusEnum.OutFinish); |
| | | // if (taskGW != null) |
| | | // { |
| | | // command.ConveyorLineBarcode = taskGW.PalletCode; |
| | | // } |
| | | // } |
| | | // RequestWmsTask(conveyorLine, command, childDeviceCode); |
| | | //} |
| | | //else if (stationManager.stationType == 10) |
| | | //{ |
| | | // var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | // if (task != null) |
| | | // { |
| | | // RequestOutbound(conveyorLine, command, childDeviceCode); |
| | | // } |
| | | //} |
| | | //else if (stationManager.stationType == 11) |
| | | //{ |
| | | // var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode); |
| | | // if (task != null) |
| | | // { |
| | | // RequestOutNextAddress(conveyorLine, command, childDeviceCode); |
| | | // } |
| | | //} |
| | | //else if (stationManager.stationType == 12) |
| | | //{ |
| | | // var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode); |
| | | // if (task != null) |
| | | // { |
| | | // ConveyorLineOutFinish(conveyorLine, command, childDeviceCode); |
| | | // } |
| | | //} |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteInfo("HandleNewTask", $"【{ex.Message}】"); |
| | | } |
| | | } |
| | | |
| | | private void ExecuteStationAction(Dt_StationManager stationManager, CommonConveyorLine_CW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode) |
| | |
| | | AbNormalStationBZTask(conveyorLine, command, childDeviceCode); |
| | | break; |
| | | case 1: |
| | | |
| | | RequestWmsTask(conveyorLine, command, childDeviceCode, stationManager); |
| | | break; |
| | | } |
| | |
| | | using SqlSugar; |
| | | using System.ComponentModel.Design; |
| | | using System.Reflection; |
| | | using System.Reflection.Metadata; |
| | | using System.Threading; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Communicator; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.HttpContextUser; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_DTO.MOM; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_IProcessRepository; |
| | |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_SignalR; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using static Quartz.Logging.OperationName; |
| | | using ICacheService = WIDESEAWCS_Core.Caches.ICacheService; |
| | | using Platform = WIDESEAWCS_Model.Models.Platform; |
| | | |
| | |
| | | private readonly IDeviceInfoRepository _deviceInfoRepository; |
| | | private static List<string>? userTokenIds; |
| | | private static List<int>? userIds; |
| | | private static List<string> childCodeList = new List<string>(); |
| | | private static DateTime? lastUpdateTime; |
| | | |
| | | public CommonConveyorLine_CWJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository, IPlatFormRepository platFormRepository, ISys_ConfigService sys_ConfigService, IDt_StationManagerRepository stationManagerRepository, ICacheService cacheService, INoticeService noticeService, IDt_needBarcodeRepository needBarcodeRepository, IDeviceInfoRepository deviceInfoRepository) |
| | | { |
| | |
| | | CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (conveyorLine != null) |
| | | { |
| | | #region 站台方式 |
| | | |
| | | //List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode); |
| | | |
| | | //foreach (var station in stationManagers) |
| | | //{ |
| | | // ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(station.stationChildCode); |
| | | |
| | | // DeviceProtocolDetailDTO? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand_After.InteractiveSignal) && x.ProtocalDetailValue == command.InteractiveSignal.ToString()); |
| | | // if (deviceProtocolDetails != null) |
| | | // { |
| | | // MethodInfo? method = GetType().GetMethod(deviceProtocolDetails.ProtocolDetailType); |
| | | // if (method != null) |
| | | // { |
| | | // method.Invoke(this, new object[] { conveyorLine, command, station }); |
| | | // } |
| | | // } |
| | | //} |
| | | |
| | | #endregion 站台方式 |
| | | |
| | | #region 路由方式 |
| | | List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); |
| | | |
| | | if (conveyorLine.DeviceCode == "1024") |
| | | { |
| | | childDeviceCodes.Add("4000"); |
| | | } |
| | | var chunks = childDeviceCodes.Chunk(10); |
| | | |
| | | foreach (string childDeviceCode in childDeviceCodes) |
| | | { |
| | | //if (conveyorLine.DeviceCode == "1024") |
| | | //{ |
| | | // childDeviceCodes.Add("4000"); |
| | | //} |
| | | |
| | | //var options = new ParallelOptions |
| | | //{ |
| | | // MaxDegreeOfParallelism = 10 |
| | | // //MaxDegreeOfParallelism = Environment.ProcessorCount |
| | | //}; |
| | | |
| | | //{ |
| | | // SiemensS7 siemensS7 = new SiemensS7(conveyorLine.Communicator.IpAddress, conveyorLine.Communicator.Port, conveyorLine.DeviceName); |
| | | // siemensS7.Connect(); |
| | | // tasks.Add(Task.Run(() => |
| | | // { |
| | | |
| | | // })); |
| | | //} |
| | | //Parallel.For(0, childDeviceCodes.Count, options, i => |
| | | //Parallel.ForEach(childDeviceCodes, options, childDeviceCode => |
| | | var tasks = new List<Task>(); |
| | | |
| | | foreach (var item in chunks) |
| | | { |
| | | tasks.Add(Task.Run(() => |
| | | { |
| | | foreach (string childDeviceCode in item) |
| | | { |
| | | ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode); |
| | | |
| | | if (command == null) continue; |
| | | //if (command.InteractiveSignal == 0 && command.HasPallet != 1) continue; |
| | | if (command != null) |
| | | { |
| | | if (command.ConveyorLineBarcode.Trim().Contains("\0")) command.ConveyorLineBarcode = ""; |
| | | |
| | | DeviceProtocolDetailDTO? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand_After.InteractiveSignal) && x.ProtocalDetailValue == command.InteractiveSignal.ToString()); |
| | |
| | | |
| | | if (childDeviceCode == "1670" || childDeviceCode == "1666" || childDeviceCode == "1548" || childDeviceCode == "1448") |
| | | { |
| | | if (lastUpdateTime > DateTime.Now.AddMinutes(1)) |
| | | { |
| | | lastUpdateTime = DateTime.Now; |
| | | Platform platform = _platFormRepository.QueryFirst(x => x.DeviceCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); |
| | | if (platform != null) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | #region 调用事件总线通知前端 |
| | | |
| | | var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); |
| | | if (tokenInfos == null || !tokenInfos.Any()) |
| | | if (tokenInfos != null || tokenInfos.Any()) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList(); |
| | | var userIds = tokenInfos?.Select(x => x.UserId).ToList(); |
| | | |
| | |
| | | }; |
| | | _noticeService.LineData(userIds?.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, data = obj }); |
| | | |
| | | } |
| | | #endregion 调用事件总线通知前端 |
| | | } |
| | | |
| | | |
| | | } |
| | | })); |
| | | } |
| | | //Task.WaitAll(tasks.ToArray()); |
| | | |
| | | #endregion 路由方式 |
| | | } |
| | |
| | | var log = $"时间:【{DateTime.Now}】【{conveyorLine.DeviceName}】托盘号:【{command.ConveyorLineBarcode}】任务号:【{command.ConveyorLineTaskNum}】设备编码:【{childDeviceCode}】"; |
| | | ConsoleHelper.WriteSuccessLine(log); |
| | | |
| | | //_noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" }); |
| | | WriteInfo(conveyorLine.DeviceName, log); |
| | | |
| | | if (childDeviceCode == "4000") |
| | |
| | | } |
| | | else |
| | | { |
| | | if (childDeviceCode == "1039") |
| | | { |
| | | var GWTask = _taskRepository.QueryData(x => x.Roadway.Contains("GWSC2") && x.SourceAddress == "1039" && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskInStatusEnum.Line_InFinish)).ToList(); |
| | | if (GWTask.Count >= 2 && childDeviceCode == "1039" && task.Roadway.Contains("GWSC2")) |
| | | { |
| | | ConsoleHelper.WriteErrorLine($"时间:【{DateTime.Now}】托盘号:【{command.ConveyorLineBarcode}】高温二已存在【{GWTask.Count}】个任务大于2个任务不可下发"); |
| | | return; |
| | | } |
| | | } |
| | | //if (childDeviceCode == "1039") |
| | | //{ |
| | | // var GWTask = _taskRepository.QueryData(x => x.Roadway.Contains("GWSC2") && x.SourceAddress == "1039" && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskInStatusEnum.Line_InFinish)).ToList(); |
| | | // if (GWTask.Count >= 2 && childDeviceCode == "1039" && task.Roadway.Contains("GWSC2")) |
| | | // { |
| | | // ConsoleHelper.WriteErrorLine($"时间:【{DateTime.Now}】托盘号:【{command.ConveyorLineBarcode}】高温二已存在【{GWTask.Count}】个任务大于2个任务不可下发"); |
| | | // return; |
| | | // } |
| | | //} |
| | | |
| | | ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | //else |
| | | //{ |
| | | // //当前地址请求 寻找当前地址的托盘号 任务号的任务,如存在任务则重新再次写入新目标地址 |
| | | // Dt_Task currentTask = _taskService.QueryExecutingCurrentConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode); |
| | | // if (currentTask != null) |
| | | // { |
| | | // conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(currentTask.TargetAddress), childDeviceCode); |
| | | // } |
| | | //} |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | // 拼接完整的MOM接口地址(基础IP + 接口路径) |
| | | var MOMIpAddress = wmsBase + ipAddress; |
| | | |
| | | // 5. 调用MOM接口(POST异步请求,同步等待结果) |
| | | WriteInfo("入站校验", $"【{childDeviceCode}】入站校验请求参数【{trayCells.Serialize()}】"); |
| | | var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.Serialize()).Result; |
| | | |
| | | // 记录接口调用日志(请求参数、返回参数),便于问题排查 |
| | | WriteInfo("入站校验", $"【{childDeviceCode}】入站校验请求参数【{trayCells.Serialize()}】"); |
| | | WriteInfo("入站校验", ""); |
| | | WriteInfo("入站校验", $"【{childDeviceCode}】入站校验返回参数【{result}】"); |
| | | |
| | | // 6. 解析MOM接口返回结果为实体对象 |
| | |
| | | content = _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode && x.stationArea == "Call" && x.stationType == 12); |
| | | if (station == null) |
| | | { |
| | | return; |
| | | } |
| | | CommonConveyorLine_BZ? commonConveyorBZ=Storage.Devices.FirstOrDefault(x=>x.DeviceCode==station.stationPLC) as CommonConveyorLine_BZ; |
| | | if (commonConveyorBZ != null) |
| | | { |
| | |
| | | |
| | | List<string> strings = platform.Location.Split(',').ToList(); |
| | | |
| | | WriteInfo("调度执行时间记录", "【调取WMS出库接口开始时间:】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); |
| | | |
| | | var result = await HttpHelper.PostAsync(wmsIpAddress, new { Position = childDeviceCode, Tag = (int)taskType, AreaCdoe = platform.Stacker, AreaCdoes = strings, platform.ProductionLine }.Serialize()); |
| | | |
| | | WriteInfo("调度执行时间记录", "【调取WMS出库接口结束时间:】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); |
| | | WriteInfo("OCV请求返回参数", $"时间:【{DateTime.Now}】请求点位【{childDeviceCode}】返回参数【{JsonConvert.SerializeObject(result)}】"); |
| | | |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | |
| | |
| | | public WebResponseContent CreateAndSendTask(WMSTaskDTO taskDTO) |
| | | { |
| | | var content = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); |
| | | |
| | | if (content.Status) |
| | | { |
| | | Console.WriteLine($"{taskDTO.TaskType}呼叫成功"); |
| | |
| | | CommonConveyorLine_NewCW conveyorLine = (CommonConveyorLine_NewCW)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (conveyorLine != null) |
| | | { |
| | | #region 站台方式 |
| | | |
| | | //List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode); |
| | | |
| | | //foreach (var station in stationManagers) |
| | | //{ |
| | | // ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(station.stationChildCode); |
| | | |
| | | // DeviceProtocolDetailDTO? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand_After.InteractiveSignal) && x.ProtocalDetailValue == command.InteractiveSignal.ToString()); |
| | | // if (deviceProtocolDetails != null) |
| | | // { |
| | | // MethodInfo? method = GetType().GetMethod(deviceProtocolDetails.ProtocolDetailType); |
| | | // if (method != null) |
| | | // { |
| | | // method.Invoke(this, new object[] { conveyorLine, command, station }); |
| | | // } |
| | | // } |
| | | //} |
| | | |
| | | #endregion 站台方式 |
| | | |
| | | #region 路由方式 |
| | | List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); |
| | | |
| | | if (conveyorLine.DeviceCode == "1024") |
| | | { |
| | | childDeviceCodes.Add("4000"); |
| | | } |
| | | |
| | | foreach (string childDeviceCode in childDeviceCodes) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | if (childDeviceCode == "1670" || childDeviceCode == "1666" || childDeviceCode == "1548" || childDeviceCode == "1448") |
| | | { |
| | | Platform platform = _platFormRepository.QueryFirst(x => x.DeviceCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); |
| | | if (platform != null) |
| | | { |
| | | if (command.HasPallet != 1) |
| | | { |
| | | MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod); |
| | | if (method != null) |
| | | { |
| | | int count = 1; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //if (childDeviceCode == "1670" || childDeviceCode == "1666" || childDeviceCode == "1548" || childDeviceCode == "1448") |
| | | //{ |
| | | // Platform platform = _platFormRepository.QueryFirst(x => x.DeviceCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active"); |
| | | // if (platform != null) |
| | | // { |
| | | // if (command.HasPallet != 1) |
| | | // { |
| | | // MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod); |
| | | // if (method != null) |
| | | // { |
| | | // int count = 1; |
| | | // method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | // } |
| | | // } |
| | | // } |
| | | //} |
| | | |
| | | |
| | | #region 调用事件总线通知前端 |
| | |
| | | var log = $"时间:【{DateTime.Now}】【{conveyorLine.DeviceName}】托盘号:【{command.ConveyorLineBarcode}】任务号:【{command.ConveyorLineTaskNum}】设备编码:【{childDeviceCode}】"; |
| | | ConsoleHelper.WriteSuccessLine(log); |
| | | |
| | | //_noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" }); |
| | | WriteInfo(conveyorLine.DeviceName, log); |
| | | |
| | | if (task == null) |
| | |
| | | } |
| | | else |
| | | { |
| | | if (childDeviceCode == "1039") |
| | | { |
| | | var GWTask = _taskRepository.QueryData(x => x.Roadway.Contains("GWSC2") && x.SourceAddress == "1039" && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskInStatusEnum.Line_InFinish)).ToList(); |
| | | if (GWTask.Count >= 2 && childDeviceCode == "1039" && task.Roadway.Contains("GWSC2")) |
| | | { |
| | | ConsoleHelper.WriteErrorLine($"时间:【{DateTime.Now}】托盘号:【{command.ConveyorLineBarcode}】高温二已存在【{GWTask.Count}】个任务大于2个任务不可下发"); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); |
| | | |
| | | bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); |
| | |
| | | if (newTask != null) |
| | | { |
| | | ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(newTask); |
| | | //conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); |
| | | if (sendFlag) |
| | |
| | | } |
| | | } |
| | | } |
| | | //else |
| | | //{ |
| | | // //当前地址请求 寻找当前地址的托盘号 任务号的任务,如存在任务则重新再次写入新目标地址 |
| | | // Dt_Task currentTask = _taskService.QueryExecutingCurrentConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode); |
| | | // if (currentTask != null) |
| | | // { |
| | | // conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(currentTask.TargetAddress), childDeviceCode); |
| | | // } |
| | | //} |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | }; |
| | | |
| | | var MOMIpAddress = wmsBase + ipAddress; |
| | | |
| | | var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.Serialize()).Result; |
| | | WriteInfo("入站校验", $"【{childDeviceCode}】入站校验请求参数【{trayCells.Serialize()}】"); |
| | | var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.Serialize()).Result; |
| | | |
| | | WriteInfo("入站校验", ""); |
| | | WriteInfo("入站校验", $"【{childDeviceCode}】入站校验返回参数【{result}】"); |
| | | ResultTrayCellsStatus result1 = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result); |
| | |
| | | if (newTask != null) |
| | | { |
| | | ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(newTask); |
| | | //conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); |
| | | if (sendFlag) |
| | |
| | | { |
| | | ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); |
| | | taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(stationManager.stationNGChildCode); |
| | | //conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | |
| | | bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); |
| | | if (sendFlag) |
| | |
| | | var log = $"时间:【{DateTime.Now}】【{conveyorLine.DeviceName}】托盘号:【{command.ConveyorLineBarcode}】任务号:【{command.ConveyorLineTaskNum}】设备编码:【{childDeviceCode}】"; |
| | | ConsoleHelper.WriteSuccessLine(log); |
| | | |
| | | //_noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" }); |
| | | WriteInfo(conveyorLine.DeviceName, log); |
| | | |
| | | |
| | | var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode); |
| | | if (task != null) |
| | |
| | | } |
| | | } |
| | | |
| | | //conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); |
| | | if (sendFlag) |
| | | { |
| | |
| | | |
| | | List<string> strings = platform.Location.Split(',').ToList(); |
| | | |
| | | WriteInfo("调度执行时间记录", "【调取WMS出库接口开始时间:】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); |
| | | |
| | | var result = await HttpHelper.PostAsync(wmsIpAddress, new { Position = childDeviceCode, Tag = (int)taskType, AreaCdoe = platform.Stacker, AreaCdoes = strings, platform.ProductionLine }.Serialize()); |
| | | |
| | | WriteInfo("调度执行时间记录", "【调取WMS出库接口结束时间:】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); |
| | | WriteInfo("OCV请求返回参数", $"时间:【{DateTime.Now}】请求点位【{childDeviceCode}】返回参数【{JsonConvert.SerializeObject(result)}】"); |
| | | |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | |
| | |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationinfo.stationPLC); |
| | | if (device != null) |
| | | { |
| | | if (device.DeviceCode == "1024" || device.DeviceCode == "1023") |
| | | { |
| | | CommonConveyorLine_NewCW conveyorLine = (CommonConveyorLine_NewCW)device; |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(4000), stationinfo.stationChildCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 1000, stationinfo.stationChildCode); |
| | | } |
| | | else |
| | | { |
| | | CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device; |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(4000), stationinfo.stationChildCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 1000, stationinfo.stationChildCode); |
| | | } |
| | | } |
| | | WriteInfo(commonStackerCrane.DeviceName, $"【手动出库记录】任务号【{e.TaskNum}】托盘号【{task.PalletCode}】"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | if (commonStackerCrane.DeviceCode.Contains("GW") && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | |
| | | _noticeService.Logs(userTokenIds, new { commonStackerCrane.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" }); |
| | | WriteInfo(commonStackerCrane.DeviceName, log); |
| | | |
| | | task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task.TaskId); |
| | | task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task); |
| | | |
| | | if (task == null) |
| | | { |
| | |
| | | device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); |
| | | if (device != null) |
| | | { |
| | | if (device.DeviceCode == "1024" || device.DeviceCode == "1023") |
| | | { |
| | | CommonConveyorLine_NewCW conveyorLine = (CommonConveyorLine_NewCW)device; |
| | | if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device; |
| | | if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | } |
| | | else |
| | |
| | | /// <param name="deviceCode">设备代码</param> |
| | | /// <param name="excludedTaskId">要排除的任务ID</param> |
| | | /// <returns></returns> |
| | | private Dt_Task? FindAnotherOutboundTask(string deviceCode, int excludedTaskId) |
| | | private Dt_Task? FindAnotherOutboundTask(string deviceCode, Dt_Task task) |
| | | { |
| | | // 先获取所有符合条件(排除指定任务ID)的出库任务列表 |
| | | var allOutboundTasks = _taskService.QueryAllOutboundTasks(deviceCode); |
| | | var availableTasks = allOutboundTasks?.Where(t => excludedTaskId != t.TaskId && t.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup).ToList(); |
| | | var availableTasks = allOutboundTasks?.Where(t => t.TargetAddress != task.TargetAddress && t.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup).ToList(); |
| | | |
| | | if (availableTasks == null || availableTasks.Count == 0) |
| | | { |
| | |
| | | device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); |
| | | if (device != null) |
| | | { |
| | | if (device.DeviceCode == "1024" || device.DeviceCode == "1023") |
| | | { |
| | | CommonConveyorLine_NewCW conveyorLine = (CommonConveyorLine_NewCW)device; |
| | | if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用 |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device; |
| | | if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.NextAddress}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | |
| | | using Mapster; |
| | | using AngleSharp.Io; |
| | | using Mapster; |
| | | using Masuit.Tools; |
| | | using SixLabors.Fonts.Tables.AdvancedTypographic; |
| | | using SqlSugar; |
| | |
| | | using WIDESEA_DTO.WMS; |
| | | using WIDESEA_IServices; |
| | | using WIDESEA_IStoragIntegrationServices; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | |
| | |
| | | stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | await _locationRepository.UpdateDataAsync(stockInfo.LocationInfo); |
| | | } |
| | | if (position == "1670") |
| | | LogFactory.GetLog($"OCV{position}请求{productionLine}任务").Info(true, $"返回参数{JsonConvert.SerializeObject(taskDTO)}"); |
| | | |
| | | // 返回成功响应 |
| | | return content.OK(data: taskDTO); |
| | |
| | | |
| | | var result = new DtStockInfo(); |
| | | |
| | | result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | var stockInfoList = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | .Includes(x => x.LocationInfo) |
| | | .Includes(x => x.StockInfoDetails) |
| | | //.Includes(x => x.StockInfoDetails) |
| | | .Where(x => x.AreaCode == areaCode && x.OutboundTime < DateTime.Now && x.IsFull) |
| | | .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) |
| | | .WhereIF(!devices.IsNullOrEmpty(), x => devices.Contains(x.LocationInfo.RoadwayNo)) |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) |
| | | .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) |
| | | //.WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) |
| | | .OrderBy(x => x.OutboundTime) |
| | | .FirstAsync(); |
| | | .ToListAsync(); |
| | | foreach (var stock in stockInfoList) |
| | | { |
| | | var hasMatchingDetail = await _stockInfoRepository.Db.Queryable<DtStockInfoDetail>() |
| | | .Where(d => d.StockId == stock.Id && materielCodes.Contains(d.MaterielCode)) |
| | | .AnyAsync(); |
| | | |
| | | if (hasMatchingDetail) |
| | | { |
| | | result = stock; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (result.IsNullOrEmpty()) |
| | | ConsoleHelper.WriteErrorLine($"{area.AreaName}-{productionLine}查询实盘库存信息失败:未找到符合条件的数据"); |
| | |
| | | .Where(x => x.DeviceCode.Contains("CWSC")) |
| | | .ToList().Select(x => x.DeviceCode).ToList(); |
| | | |
| | | //var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | // .Where(x => areaCodes.Contains(x.AreaCode) && x.OutboundTime < DateTime.Now && x.IsFull == true) // 过滤条件 |
| | | // .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) |
| | | // .Includes(x => x.LocationInfo) |
| | | // .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) |
| | | // .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && areaId.Contains(x.LocationInfo.AreaId) && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件 |
| | | // .Includes(x => x.StockInfoDetails) |
| | | // .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) |
| | | // .OrderBy(x => x.OutboundTime) // 排序 |
| | | // .FirstAsync(); // 获取第一个元素 |
| | | |
| | | DtStockInfo stockInfo = null; |
| | | var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | .Where(x => areaCodes.Contains(x.AreaCode) && x.OutboundTime < DateTime.Now && x.IsFull == true) // 过滤条件 |
| | | .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) |
| | | .Includes(x => x.LocationInfo) |
| | | .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && areaId.Contains(x.LocationInfo.AreaId) && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件 |
| | | .Includes(x => x.StockInfoDetails) |
| | | .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode))) |
| | | .OrderBy(x => x.OutboundTime) // 排序 |
| | | .FirstAsync(); // 获取第一个元素 |
| | | .ToListAsync(); |
| | | |
| | | if (result.IsNullOrEmpty()) |
| | | foreach (var stock in result) |
| | | { |
| | | var hasMatchingDetail = await _stockInfoRepository.Db.Queryable<DtStockInfoDetail>() |
| | | .Where(d => d.StockId == stock.Id && materielCodes.Contains(d.MaterielCode)) |
| | | .AnyAsync(); |
| | | |
| | | if (hasMatchingDetail) |
| | | { |
| | | stockInfo = stock; |
| | | break; |
| | | } |
| | | } |
| | | if (stockInfo.IsNullOrEmpty()) |
| | | ConsoleHelper.WriteErrorLine($"{JsonConvert.SerializeObject(areaCodes)}-{productionLine}查询常温实盘库存信息失败:未找到符合条件的数据"); |
| | | |
| | | return result; |
| | | return stockInfo; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | .Where(x => stackers.Contains(x.DeviceCode)) |
| | | .ToList().Select(x => x.DeviceCode).ToList(); |
| | | |
| | | DtStockInfo stockInfo = null; |
| | | |
| | | var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>() |
| | | .Where(x => x.ProductionLine == station.productLine) |
| | | .Where(x => x.AreaCode == areaCode && x.IsFull == false) |
| | | .Includes(x => x.StockInfoDetails) |
| | | .Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "空托盘")) |
| | | //.Includes(x => x.StockInfoDetails) |
| | | //.Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "空托盘")) |
| | | .Includes(x => x.LocationInfo) |
| | | .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo)) |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件 |
| | | .OrderBy(x => x.CreateDate) // 排序 |
| | | .FirstAsync(); // 转换为列表 |
| | | .ToListAsync(); |
| | | |
| | | foreach (var stock in result) |
| | | { |
| | | var hasMatchingDetail = await _stockInfoRepository.Db.Queryable<DtStockInfoDetail>() |
| | | .Where(d => d.StockId == stock.Id && d.MaterielCode == "空托盘") |
| | | .AnyAsync(); |
| | | |
| | | if (hasMatchingDetail) |
| | | { |
| | | stockInfo = stock; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (result.IsNullOrEmpty()) |
| | | ConsoleHelper.WriteErrorLine($"{area}-{station.productLine}查询空盘库存信息失败:未找到符合条件的数据"); |
| | | |
| | | return result; |
| | | return stockInfo; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | { |
| | | if (firstDirectoryInfos[i].Name != "Info") |
| | | { |
| | | FileInfo[] nextFileInfos = firstDirectoryInfos[i].GetFiles(); |
| | | FileInfo[] nextFileInfos = firstDirectoryInfos[i].GetFiles().OrderByDescending(x => x.CreationTime).ToArray(); |
| | | List<object> values = new List<object>(); |
| | | for (int j = 0; j < nextFileInfos.Length; j++) |
| | | { |
| | |
| | | { |
| | | List<FileInfo> files = new List<FileInfo>(); |
| | | DirectoryInfo folder = new DirectoryInfo(AppContext.BaseDirectory + "\\Logs\\"); |
| | | DirectoryInfo[] firstDirectoryInfos = folder.GetDirectories(); |
| | | DirectoryInfo[] firstDirectoryInfos = folder.GetDirectories().OrderByDescending(x => x.CreationTime).ToArray(); |
| | | for (int i = 0; i < firstDirectoryInfos.Length; i++) |
| | | { |
| | | FileInfo[] nextFileInfos = firstDirectoryInfos[i].GetFiles(); |
| | | FileInfo[] nextFileInfos = firstDirectoryInfos[i].GetFiles().OrderByDescending(x => x.CreationTime).ToArray(); |
| | | files.AddRange(nextFileInfos); |
| | | } |
| | | if (files.Count > 0) |