wanshenmean
2025-03-24 eaf30f88591d78699fdacf489e4aa45ac6775272
更新项目配置和业务逻辑

- 更新 .gitignore,添加对 *.txt 文件的忽略规则。
- 在 CommonConveyorLine_AfterJob.cs 中注释掉对 `need` 和 `proAddress` 的查询,调整请求空托盘的条件。
- 在 CommonConveyorLine_GWJob.cs 中注释掉与 `command` 相关的代码,保留最终读取。
- 在 CommonStackerStationCraneJob.cs 中修改对 `conveyorLine` 和 `stationManager` 的处理,增加协议地址检查和写入信号功能。
- 在 IDt_TaskService.cs 中添加 `QueryStockInfoForRealTrayJZAsync` 方法声明。
- 在 NotifyFinishTest.cs 中修改 `location` 查询条件,增加库位状态检查。
- 在 Dt_TaskService.cs 中实现 `QueryStockInfoForRealTrayJZAsync` 方法,增加设备和库位状态过滤。
- 在 TaskController.cs 中添加 `QueryStockInfoForRealTrayJZAsync` 方法的路由和实现。
- 更新 FolderProfile.pubxml.user 的发布历史记录。
- 修改 appsettings.json 中的数据库连接字符串为本地地址。
已修改11个文件
184 ■■■■ 文件已修改
.gitignore 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs 88 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/NotifyFinishTest.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/RequestInTaskAsync.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Properties/PublishProfiles/FolderProfile.pubxml.user 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -55168,3 +55168,4 @@
/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/bin/Debug/net6.0/publish/runtimes/linux-arm/native/libSkiaSharp.so
/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/bin/Debug/net6.0/publish/runtimes/linux-arm/native/libSystem.IO.Ports.Native.so
/项目资料/项目图纸/前段线体点位图/08三楼输送布局点位图1107.dwl2
*.txt
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_After/CommonConveyorLine_AfterJob.cs
@@ -184,18 +184,18 @@
            if (stationInfo.stationType != 7) return;
            var taskNew = _taskRepository.QueryData(x => x.TaskType == (int)TaskOutboundTypeEnum.OutTray);
            var need = _needBarcodeRepository.QueryFirst(x => x.toArea == stationInfo.stationChildCode && x.productLine == stationInfo.productLine);
            //var need = _needBarcodeRepository.QueryFirst(x => x.toArea == stationInfo.stationChildCode && x.productLine == stationInfo.productLine);
            //var cache = command.Reserved5;
            var proAddress = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationInfo.stationChildCode).Where(x => x.DeviceProParamName == ConveyorLineDBName_After.Reserve5.ToString()).FirstOrDefault().DeviceProAddress;
            //var proAddress = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationInfo.stationChildCode).Where(x => x.DeviceProParamName == ConveyorLineDBName_After.Reserve5.ToString()).FirstOrDefault().DeviceProAddress;
            var cache = Convert.ToInt16(conveyorLine.ReadValue(ConveyorLineDBName_After.Reserve5, stationInfo.stationChildCode));
            ConsoleHelper.WriteColorLine($"已经有{taskNew.Count}个任务,可以放{cache}个空托盘", ConsoleColor.DarkCyan);
            if (taskNew.Count + 2 < cache)   //不存在空框出库任务 则请求WMS出空库
            if (taskNew.Count + 1 <= cache)   //不存在空框出库任务 则请求WMS出空库
            {
                //ConsoleHelper.WriteWarningLine("请求空托盘");
                if (_taskService.RequestTask(command.ConveyorLineBarcode, stationInfo).Result.Status)
                {
                    need.inLineNum += 1;
                    _needBarcodeRepository.UpdateData(need);
                    //need.inLineNum += 1;
                    //_needBarcodeRepository.UpdateData(need);
                }
            }
        }
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
@@ -120,19 +120,19 @@
                    List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
                    foreach (string childDeviceCode in childDeviceCodes)
                    {
                        ConveyorLineTaskCommand_After command = null;
                        if (childDeviceCode == "2236")
                        {
                            var stationPLC = _stationManagerRepository.QueryFirst(x => x.stationType == 1 && x.stationChildCode == childDeviceCode).stationPLC;
                            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationPLC);
                            CommonConveyorLine_After conveyorLine1 = (CommonConveyorLine_After)device;
                            command = conveyorLine1.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
                        }
                        else
                        {
                            command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
                        }
                        //ConveyorLineTaskCommand_After command = null;
                        //if (childDeviceCode == "2236")
                        //{
                        //    var stationPLC = _stationManagerRepository.QueryFirst(x => x.stationType == 1 && x.stationChildCode == childDeviceCode).stationPLC;
                        //    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationPLC);
                        //    CommonConveyorLine_After conveyorLine1 = (CommonConveyorLine_After)device;
                        //    command = conveyorLine1.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
                        //}
                        //else
                        //{
                        //    command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
                        //}
                        ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
                        if (command == null) continue;
                        if (command.ConveyorLineBarcode.Trim().Contains("\0")) command.ConveyorLineBarcode = "";
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs
@@ -152,22 +152,41 @@
                    if (content.Status)
                    {
                        var task = content.Data as Dt_Task;
                        Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationLocation == task.TargetAddress);
                        IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC);
                        if (device != null)
                        if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound && task.TargetAddress == "001-000-001")
                        {
                            CommonConveyorLine_After conveyorLine = (CommonConveyorLine_After)device;
                            var proAddress = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationManager.stationChildCode).Where(x => x.DeviceProParamName == ConveyorLineDBName_After.InteractiveSignal.ToString()).FirstOrDefault().DeviceProAddress;
                            string? address = proAddress;
                            if (!proAddress.Contains(".0"))
                            Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationLocation == task.TargetAddress);
                            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC);
                            if (device != null)
                            {
                                address = proAddress + ".0";
                                str = $"写入完成,给线体写入下降信号";
                                WriteInfo(commonStackerCrane.DeviceName, str);
                                ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue);
                                // 获取输送线对象
                                CommonConveyorLine_After conveyorLine = (CommonConveyorLine_After)device;
                                // 获取协议地址
                                var proAddress = conveyorLine.DeviceProDTOs
                                    .FirstOrDefault(x => x.DeviceChildCode == stationManager.stationChildCode && x.DeviceProParamName == ConveyorLineDBName_After.InteractiveSignal.ToString())
                                    ?.DeviceProAddress;
                                if (proAddress == null)
                                {
                                    str = "未找到协议地址";
                                    WriteInfo(commonStackerCrane.DeviceName, str);
                                    ConsoleHelper.WriteColorLine(str, ConsoleColor.Red);
                                    return;
                                }
                                string address = proAddress.Contains(".0") ? proAddress : proAddress + ".0";
                                // 写入 false 信号
                                WriteSignal(conveyorLine, address, false, commonStackerCrane.DeviceName);
                            }
                            conveyorLine.Communicator.Write(str, false);
                        }
                        else
                        {
                            _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.NextAddress}】对应的通讯对象,无法清除出库站台顶升状态");
                            else
                            {
                                _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.NextAddress}】对应的通讯对象,无法清除出库站台顶升状态");
                            }
                        }
                    }
                }
@@ -211,7 +230,7 @@
            if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            {
                if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
                if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound && task.TargetAddress == "001-000-001")
                {
                    Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationLocation == task.TargetAddress);
                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC);
@@ -361,5 +380,46 @@
            return stackerCraneTaskCommand;
        }
        /// <summary>
        /// 写入信号并验证写入结果
        /// </summary>
        /// <param name="conveyorLine">输送线对象</param>
        /// <param name="address">协议地址</param>
        /// <param name="signal">信号值</param>
        /// <param name="deviceName">设备名称</param>
        void WriteSignal(CommonConveyorLine_After conveyorLine, string address, bool signal, string deviceName)
        {
            string str = string.Empty;
            // 写入信号
            conveyorLine.Communicator.Write(address, signal);
            // 验证写入结果,最多重试5次
            for (int i = 0; i < 5; i++)
            {
                var isWrite = conveyorLine.Communicator.Read<bool>(address);
                if (isWrite == signal)
                {
                    break;
                }
                conveyorLine.Communicator.Write(address, signal);
            }
            // 最终验证写入结果
            var finalWrite = conveyorLine.Communicator.Read<bool>(address);
            if (finalWrite == signal)
            {
                str = $"{address}-写入{signal}成功";
                ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue);
                WriteInfo(deviceName, str);
            }
            else
            {
                str = $"{address}-写入{signal}失败";
                ConsoleHelper.WriteColorLine(str, ConsoleColor.Red);
                WriteInfo(deviceName, str);
            }
        }
    }
}
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStorageTaskService/Task/IDt_TaskService.cs
@@ -228,4 +228,6 @@
    /// <returns></returns>
    Task<WebResponseContent> SetEmptyOutbyInToOutOneAsync(RequestTaskDto request);
    Task<WebResponseContent> QueryStockInfoForRealTrayJZAsync(string ProductLine);
}
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/NotifyFinishTest.cs
@@ -34,9 +34,9 @@
                if (string.IsNullOrEmpty(result?.PalletBarcode))
                    throw new Exception("上传托盘号为空");
                var location = _locationRepository.QueryFirst(x => x.AreaId == result.LocationArea && x.LocationCode == result.LocationID);
                var location = _locationRepository.QueryFirst(x => x.AreaId == result.LocationArea && x.LocationCode == result.LocationID && x.EnalbeStatus == 1);
                if (location == null) throw new Exception("未知库位");
                if (location == null) throw new Exception("未知库位或库位锁定");
                if (_taskRepository.QueryFirst(x => x.SourceAddress == result.LocationID && x.Roadway == location.RoadwayNo) != null)
                {
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1571,6 +1571,40 @@
    #endregion 外部接口方法
    #region  静置查询实托
    public async Task<WebResponseContent> QueryStockInfoForRealTrayJZAsync(string ProductLine)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            var deviceCode = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>()
                .Where(x => x.DeviceStatus == "1")
                .Where(x => x.DeviceCode.Contains("JZSC"))
                .ToList().Select(x => x.DeviceCode).ToList();
            var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>()
                .Where(x=> x.IsFull == true) // 过滤条件
                .WhereIF(!ProductLine.IsNullOrEmpty(), x => x.ProductionLine == ProductLine)
                .Includes(x => x.LocationInfo)
                .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo))
                .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId==2 && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 过滤条件
                .Includes(x => x.StockInfoDetails)
                .OrderBy(x => x.OutboundTime) // 排序
                .FirstAsync();
            if (result.IsNullOrEmpty())
                content.Error();
            else
                content.OK();
        }
        catch (Exception ex)
        {
            return content.Error(ex.Message);
        }
        return content;
    }
    #endregion
    #endregion 外部接口方法
    #region 内部调用方法
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/RequestInTaskAsync.cs
@@ -149,6 +149,7 @@
            if (item.Number.ToInt32() == number + 1)
            {
                boxing.NextProcessCode = item.ProcessCode;
                break;
            }
        }
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs
@@ -215,4 +215,16 @@
    {
        return await Service.SetEmptyOutbyInToOutOneAsync(input);
    }
    /// <summary>
    /// 静置查询实托
    /// </summary>
    /// <param name="ProductLine">产线</param>
    /// <returns></returns>
    [HttpPost, AllowAnonymous, Route("QueryStockInfoForRealTrayJZAsync")]
    [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5秒节流
    public async Task<WebResponseContent> QueryStockInfoForRealTrayJZAsync(string ProductLine)
    {
        return await Service.QueryStockInfoForRealTrayJZAsync(ProductLine);
    }
}
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -5,7 +5,7 @@
<Project>
  <PropertyGroup>
    <_PublishTargetUrl>D:\Git\BaiBuSanlou\CodeManagement\WMS\WIDESEA_WMSServer\WIDESEA_WMSServer\bin\Debug\net6.0\publish\</_PublishTargetUrl>
    <History>True|2025-03-22T08:16:20.5712808Z||;True|2025-03-22T15:56:49.6683132+08:00||;True|2025-03-22T15:52:31.0442028+08:00||;True|2025-03-22T14:58:24.6661971+08:00||;True|2025-03-22T14:31:25.6401220+08:00||;True|2025-03-17T22:20:55.9814492+08:00||;True|2025-03-17T20:18:58.8930513+08:00||;True|2025-03-15T14:49:54.7776092+08:00||;True|2025-03-04T14:56:36.8156516+08:00||;True|2025-03-04T14:03:01.4762153+08:00||;True|2025-03-01T13:25:40.8549456+08:00||;True|2025-03-01T12:40:52.0649831+08:00||;True|2025-03-01T11:33:13.7154636+08:00||;True|2025-02-28T16:49:28.9187049+08:00||;True|2025-02-28T16:43:17.5832178+08:00||;True|2025-02-28T16:09:20.8077956+08:00||;True|2025-02-27T13:41:44.5879735+08:00||;True|2025-02-21T10:33:09.7726538+08:00||;True|2025-02-20T23:51:32.1400389+08:00||;True|2025-02-20T23:43:38.4536482+08:00||;True|2025-02-18T15:09:13.0567844+08:00||;True|2025-02-18T10:30:45.6690625+08:00||;True|2025-02-17T00:17:57.1953767+08:00||;True|2025-02-17T00:08:49.8489825+08:00||;True|2025-02-17T00:00:57.5511029+08:00||;True|2025-02-15T14:45:50.0466371+08:00||;True|2025-02-15T14:26:18.9252196+08:00||;True|2025-02-15T14:22:56.6840183+08:00||;True|2025-02-15T13:37:28.7588867+08:00||;True|2025-02-15T13:11:23.1821094+08:00||;True|2025-02-14T14:03:21.8968201+08:00||;True|2025-02-10T16:52:59.9322253+08:00||;</History>
    <History>True|2025-03-24T07:27:15.6778099Z||;True|2025-03-23T18:45:49.3752329+08:00||;True|2025-03-23T18:11:49.6069594+08:00||;True|2025-03-22T16:16:20.5712808+08:00||;True|2025-03-22T15:56:49.6683132+08:00||;True|2025-03-22T15:52:31.0442028+08:00||;True|2025-03-22T14:58:24.6661971+08:00||;True|2025-03-22T14:31:25.6401220+08:00||;True|2025-03-17T22:20:55.9814492+08:00||;True|2025-03-17T20:18:58.8930513+08:00||;True|2025-03-15T14:49:54.7776092+08:00||;True|2025-03-04T14:56:36.8156516+08:00||;True|2025-03-04T14:03:01.4762153+08:00||;True|2025-03-01T13:25:40.8549456+08:00||;True|2025-03-01T12:40:52.0649831+08:00||;True|2025-03-01T11:33:13.7154636+08:00||;True|2025-02-28T16:49:28.9187049+08:00||;True|2025-02-28T16:43:17.5832178+08:00||;True|2025-02-28T16:09:20.8077956+08:00||;True|2025-02-27T13:41:44.5879735+08:00||;True|2025-02-21T10:33:09.7726538+08:00||;True|2025-02-20T23:51:32.1400389+08:00||;True|2025-02-20T23:43:38.4536482+08:00||;True|2025-02-18T15:09:13.0567844+08:00||;True|2025-02-18T10:30:45.6690625+08:00||;True|2025-02-17T00:17:57.1953767+08:00||;True|2025-02-17T00:08:49.8489825+08:00||;True|2025-02-17T00:00:57.5511029+08:00||;True|2025-02-15T14:45:50.0466371+08:00||;True|2025-02-15T14:26:18.9252196+08:00||;True|2025-02-15T14:22:56.6840183+08:00||;True|2025-02-15T13:37:28.7588867+08:00||;True|2025-02-15T13:11:23.1821094+08:00||;True|2025-02-14T14:03:21.8968201+08:00||;True|2025-02-10T16:52:59.9322253+08:00||;</History>
    <LastFailureDetails />
  </PropertyGroup>
</Project>
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json
@@ -9,8 +9,8 @@
  "urls": "http://*:5000",
  "MainDB": "DB_WIDESEA", //当前项目的主库,所对应的连接字符串的Enabled必须为true
  //连接字符串
  "ConnectionString": "Data Source=192.168.90.253;Initial Catalog=WIDESEA_WMSDB3F;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
  "ConnectionStringWCS": "Data Source=192.168.90.253;Initial Catalog=WIDESEA_WCSDB3F;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
  "ConnectionString": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WMS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
  "ConnectionStringWCS": "Data Source=127.0.0.1;Initial Catalog=WIDESEA_WCS2F08;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
  //跨域
  "Cors": {
    "PolicyName": "CorsIpAccess", //策略名称