xu.lu 2 years ago
parent
commit
5955a8fb89

+ 7 - 0
ZT_1C.sln

@@ -29,6 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.WorkEngineering", "成
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.Service", "盘条库\WCS.Service\WCS.Service.csproj", "{247D1380-BCE8-47FD-B1C2-D78FB3F0F37D}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.Service", "成品库\WCS.Service\WCS.Service.csproj", "{D66408CF-5827-43A5-91D0-A6EEA2B45A70}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -67,6 +69,10 @@ Global
 		{247D1380-BCE8-47FD-B1C2-D78FB3F0F37D}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{247D1380-BCE8-47FD-B1C2-D78FB3F0F37D}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{247D1380-BCE8-47FD-B1C2-D78FB3F0F37D}.Release|Any CPU.Build.0 = Release|Any CPU
+		{D66408CF-5827-43A5-91D0-A6EEA2B45A70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{D66408CF-5827-43A5-91D0-A6EEA2B45A70}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D66408CF-5827-43A5-91D0-A6EEA2B45A70}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{D66408CF-5827-43A5-91D0-A6EEA2B45A70}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -80,6 +86,7 @@ Global
 		{8F9D2518-A6AA-4F32-94DE-0BCA0DDDA1D9} = {12AEE966-FB30-4F0E-9F65-6E7CB3446DBB}
 		{067B3D90-C0A0-40F5-AA4D-0ABAB61EA536} = {576557C6-7A26-48B3-92A4-DCDF4C538B53}
 		{247D1380-BCE8-47FD-B1C2-D78FB3F0F37D} = {12AEE966-FB30-4F0E-9F65-6E7CB3446DBB}
+		{D66408CF-5827-43A5-91D0-A6EEA2B45A70} = {576557C6-7A26-48B3-92A4-DCDF4C538B53}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {C75EF4BD-59B3-4F79-A380-6D452ADFB53E}

+ 21 - 0
成品库/WCS.Service/AppSettings.cs

@@ -0,0 +1,21 @@
+namespace WCS.Service
+{
+    /// <summary>
+    /// 程序设置
+    /// </summary>
+    public class AppSettings
+    {
+        /// <summary>
+        /// 配置信息
+        /// </summary>
+        public static IConfiguration Config { get; private set; }
+
+        /// <summary>
+        /// 静态构造函数
+        /// </summary>
+        static AppSettings()
+        {
+            Config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build();
+        }
+    }
+}

+ 29 - 0
成品库/WCS.Service/PLCAccessors/PLCAccessorsCreater.cs

@@ -0,0 +1,29 @@
+using WCS.Core;
+using PLCType = WCS.Core.PLCType;
+
+namespace WCS.Service.PLCAccessors
+{
+    /// <summary>
+    ///  PLC访问器创建者
+    /// </summary>
+    public class PLCAccessorsCreater : IPLCAccessorCreater
+    {
+        /// <summary>
+        ///  创建PLC访问器
+        /// </summary>
+        /// <param name="data">PLC信息</param>
+        /// <returns></returns>
+        /// <exception cref="Exception"> </exception>
+        public IPLCAccessor Create(PLCInfo data)
+        {
+            switch (data.Type)
+            {
+                case PLCType.Siemens:
+                    return new SiemensS7PLC(data.IP, data.Port, data.Rack, data.Slot);
+
+                default:
+                    return new VitrualRedisPLC(data, "127.0.0.1,database=1,prefix=Sorting:");
+            }
+        }
+    }
+}

+ 59 - 0
成品库/WCS.Service/PLCAccessors/SiemensS7PLC.cs

@@ -0,0 +1,59 @@
+using PlcSiemens.O;
+using PlcSiemens.Protocol.Common;
+using ServiceCenter;
+using ServiceCenter.Virtual_PLC;
+using WCS.Core;
+
+namespace WCS.Service.PLCAccessors
+{
+    public class SiemensS7PLC : IPLCAccessor
+    {
+        private SimenssPlc plc;
+
+        public SiemensS7PLC(string ip, int port, int rack, int slot)
+        {
+            plc = new SimenssPlc(ip, rack, slot);
+            plc.Connect();
+        }
+
+        public byte[] ReadBytes(ushort db, ushort address, ushort length)
+        {
+            if (ServiceHub.Any(SystemMode.虚拟plc))
+            {
+                return PlcData.Read(new PLCData { IP = plc.IP, DB = db, Length = length, DataLength = length });
+            }
+            bool isN = false;
+            if (!plc.Connected)
+            {
+
+                 isN = plc.Connect();
+
+            }
+
+
+            var res = plc.ReadArea(AreaType.DB, db, address, length, DataType.Byte);
+            if (res == null)
+            {
+                throw new Exception("读取DB块数据失败");
+            }
+
+            return res.Data;
+        }
+
+        public void WriteBytes(ushort db, ushort address, byte[] data)
+        {
+            if (ServiceHub.Any(SystemMode.虚拟plc))
+            {
+                PlcData.Write(new PLCData { IP = plc.IP, DB = db }, address, data);
+            }
+            else
+            {
+                if (!plc.Connected)
+                    plc.Connect();
+                var res = plc.WriteArea(AreaType.DB, db, address, (ushort)data.Length, DataType.Byte, data);
+                if (!res)
+                    throw new Exception("写入DB块数据失败");
+            }
+        }
+    }
+}

+ 69 - 0
成品库/WCS.Service/Program.cs

@@ -0,0 +1,69 @@
+using Microsoft.AspNetCore.Hosting;
+using ServiceCenter.Redis;
+using ServiceCenter.WebApi;
+using System.Runtime.InteropServices;
+
+namespace WCS.Service
+{
+    public class Program
+    {
+        public static void Main(string[] args)
+        {
+            #region 接入Redis
+
+            RedisHub.CreateContext(AppSettings.Config.GetConnectionString("Redis"), "default", true);
+
+            #endregion 接入Redis
+
+            //互斥锁检测
+            var mutexName = RedisHub.Default.Check("Mutex") ?? throw new Exception("请在Redis中配置互斥量值");
+
+            using var mt = new Mutex(true, mutexName);
+            if (mt.WaitOne())
+            {
+                CreateHostBuilder(args).Build().Run(); mt.ReleaseMutex();
+            }
+            else
+            {
+                Console.WriteLine("请勿重复运行");
+                //InfoLog.INFO_INIT("请勿重复运行");
+                Task.Delay(2000).Wait();
+            }
+        }
+
+        /// <summary>
+        /// 创建一个主机构建器
+        /// </summary>
+        /// <param name="args"></param>
+        /// <returns></returns>
+        public static IHostBuilder CreateHostBuilder(string[] args)
+        {
+            //是否是win平台
+            var isWin = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+            Console.WriteLine($"win:{isWin}");
+            if (isWin)
+            {
+                var useUrls = RedisHub.Default.Check("UseUrls") ?? throw new Exception("请在Redis中配置网络访问端口");
+                //"http://*:8080"
+                return Host.CreateDefaultBuilder(args)
+                    .UseWindowsService()//win
+                    .ConfigureWebHostDefaults(web => //网络访问配置
+                    {
+                        web.UseUrls(useUrls); //设备访问端口
+                        web.UseStartup<Startup>(); //调用启动服务
+                    })
+                    .ConfigureServices((_, services) =>
+                    {
+                        services.AddHostedService<Worker>();
+                        services.AddHttpClient();
+                    });
+            }
+            return Host.CreateDefaultBuilder(args)
+                .UseSystemd()//linux
+                .ConfigureServices((_, services) =>
+                {
+                    services.AddHostedService<Worker>();
+                });
+        }
+    }
+}

+ 11 - 0
成品库/WCS.Service/Properties/launchSettings.json

@@ -0,0 +1,11 @@
+{
+  "profiles": {
+    "WCS.Service": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "environmentVariables": {
+        "DOTNET_ENVIRONMENT": "Development"
+      }
+    }
+  }
+}

+ 36 - 0
成品库/WCS.Service/WCS.Service.csproj

@@ -0,0 +1,36 @@
+<Project Sdk="Microsoft.NET.Sdk.Worker">
+
+  <PropertyGroup>
+    <TargetFramework>net7.0</TargetFramework>
+    <Nullable>enable</Nullable>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <UserSecretsId>dotnet-WCS.Service-ee485c84-3250-46d0-8109-1d37d3b27230</UserSecretsId>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+    <NoWarn>1701;1702;8602;8616;8618;8625;8600;8603;8714;1591</NoWarn>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+    <NoWarn>1701;1702;8602;8616;8618;8625;8600;8603;8714;1591</NoWarn>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <Compile Remove="Logs\**" />
+    <Content Remove="Logs\**" />
+    <EmbeddedResource Remove="Logs\**" />
+    <None Remove="Logs\**" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="MessagePack" Version="2.5.108" />
+    <PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
+    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.5" />
+    <PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="7.0.0" />
+    <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\WCS.WorkEngineering\WCS.WorkEngineering.csproj" />
+  </ItemGroup>
+</Project>

+ 156 - 0
成品库/WCS.Service/Worker.cs

@@ -0,0 +1,156 @@
+using Newtonsoft.Json;
+using PlcSiemens.Core.Extension;
+using ServiceCenter;
+using ServiceCenter.Logs;
+using ServiceCenter.Redis;
+using ServiceCenter.SqlSugars;
+using SqlSugar;
+using System.Text;
+using WCS.Core;
+using WCS.Entity;
+using WCS.WorkEngineering;
+
+namespace WCS.Service
+{
+    /// <summary>
+    /// 工作服务
+    /// </summary>
+    public class Worker : BackgroundService
+    {
+        /// <summary>
+        /// 记录器
+        /// </summary>
+        private readonly ILogger<Worker> _logger;
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="logger">记录器</param>
+        public Worker(ILogger<Worker> logger)
+        {
+            _logger = logger;
+        }
+
+        public static readonly string WcsDlog = "WCSDlog";
+        public static readonly string Wcsdb = "WCSDB";
+
+        /// <summary>
+        ///  执行
+        /// </summary>
+        /// <param name="stoppingToken">停止令牌</param>
+        /// <returns></returns>
+        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
+        {
+            if (stoppingToken.IsCancellationRequested)
+                return;
+
+            #region 启用日志
+
+            //var logConfigText = RedisHub.Default.Check("LogConfigText") ?? throw new Exception("请在Redis中配置log4net相关内容");
+            //var logConfig = JsonConvert.DeserializeObject<LogConfig>(logConfigText);
+            //LogHub.SetConfigInfo(logConfig!);
+
+            #endregion 启用日志
+
+            _logger.LogInformation("WCS开始启动");
+            Configs.ProtocolProxyBaseType = typeof(ProtocolProxy);
+            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+            Configs.StringEncoding = Encoding.UTF8;
+            var warehouseName = RedisHub.Default.Check("WarehouseName") ?? throw new Exception("请在Redis中配置仓库名称");
+            if (string.IsNullOrEmpty(warehouseName)) throw new Exception("请在Redis中配置仓库名称");
+            ServiceHub.SetWarehouseName(warehouseName);
+
+            #region 初始化数据库连接
+
+            var dbConnectionStrings = RedisHub.Default.Check("DbConnectionStrings") ?? throw new Exception("请在Redis中配置数据库连接相关内容");
+            ServiceHub.DbConnectionStrings = JsonConvert.DeserializeObject<List<DataBaseConnectionString>>(dbConnectionStrings);
+            if (ServiceHub.DbConnectionStrings != null)
+            {
+                if (ServiceHub.DbConnectionStrings.All(v => v.Key != Wcsdb)) throw new Exception("请在DbConnectionStrings中配置WCS基础数据库连接字符串");
+                if (ServiceHub.DbConnectionStrings.All(v => v.Key == Wcsdb && !v.IsDefault)) throw new Exception("请在DbConnectionStrings中配置WCS基础数据库为默认数据库");
+                // if (ServiceHub.DbConnectionStrings.All(v => v.Key != WcsDlog)) throw new Exception("请在DbConnectionStrings中配置WCS日志数据库连接字符串");
+            }
+
+            //设置连接信息
+            List<ConnectionConfig> connectionConfigs = new List<ConnectionConfig>();
+            foreach (var connectionString in ServiceHub.DbConnectionStrings!)
+            {
+                connectionConfigs.Add(new ConnectionConfig()
+                {
+                    ConfigId = connectionString.Key,
+                    ConnectionString = connectionString.ConnectionString,//连接符字串
+                    DbType = connectionString.DbType,//数据库类型
+                    IsAutoCloseConnection = true,//不设成true要手动close
+                });
+            };
+            SqlSugarHelper.SetDb(new SqlSugarScope(connectionConfigs));
+
+            //初始化数据库
+            SqlSugarHelper.Do(db =>
+            {
+                foreach (var connectionString in ServiceHub.DbConnectionStrings!)
+                {
+                    var _db = db.Connect.GetConnectionScope(connectionString.Key);
+                    switch (connectionString.Key)
+                    {
+                        case "WCSDB"://WCS基本数据库
+                            SqlSugarHelper.SetDefault(connectionString.Key);
+                            _db.CodeFirst.InitTables(typeof(WCS_PlcData));
+                            _db.CodeFirst.InitTables(typeof(WCS_TaskInfo));
+                            _db.CodeFirst.InitTables(typeof(WCS_TaskDtl));
+                            _db.CodeFirst.InitTables(typeof(WCS_TaskOld));
+                            _db.CodeFirst.InitTables(typeof(WCS_AgvTaskInfo));
+
+                            break;
+
+                        case "WCSDlog"://WCS日志数据库
+                            //SqlSugarHelper.SetDefault(connectionString.Key);
+                            //_db.CodeFirst.InitTables(typeof(w));
+                            //_db.CodeFirst.InitTables(typeof(WCS_TaskInfo));
+                            //_db.CodeFirst.InitTables(typeof(WCS_TaskDtl));
+                            //_db.CodeFirst.InitTables(typeof(WCS_TaskOld));
+                            //_db.CodeFirst.InitTables(typeof(WCS_AgvTaskInfo));
+                            break;
+
+                        default: //其他库
+                            break;
+                    };
+                };
+            });
+
+            #endregion 初始化数据库连接
+
+         
+
+            #region 初始化设备信息
+
+            WorkStart.InitializeDeviceInfo();
+
+            #endregion 初始化设备信息
+
+            #region 初始化PLC访问器及PLC读取协议
+
+            //创建PLC访问器
+            Configs.PLCAccessorCreater = new PLCAccessors.PLCAccessorsCreater();
+
+            try
+            {
+                #region 唤醒所有的世界
+
+                World.StartAll();
+
+                #endregion 唤醒所有的世界
+
+                _logger.LogInformation("WCS启动成功");
+            }
+            catch (Exception ex)
+            {
+                _logger.LogError("WCS启动失败{0}", ex.Message);
+            }
+
+            #endregion 初始化PLC访问器及PLC读取协议
+
+            LogHub.init();
+        }
+    }
+}

+ 29 - 0
成品库/WCS.Service/Worlds/initWorld.cs

@@ -0,0 +1,29 @@
+using WCS.Core;
+
+namespace WCS.Service.Worlds
+{
+    public class initWorld : World
+    {
+        protected override int Interval => 300;
+
+        protected override IEnumerable<string> GetChannelMsg(Channel channel)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void OnError(Channel channel, Exception exception)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void OnInternalLog(Channel channel, string msg)
+        {
+            throw new NotImplementedException();
+        }
+
+        protected override void OnLog(Channel channel, object logObj)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 8 - 0
成品库/WCS.Service/appsettings.Development.json

@@ -0,0 +1,8 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.Hosting.Lifetime": "Information"
+    }
+  }
+}

+ 12 - 0
成品库/WCS.Service/appsettings.json

@@ -0,0 +1,12 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft": "Warning",
+      "Microsoft.Hosting.Lifetime": "Information"
+    }
+  },
+  "ConnectionStrings": {
+    "Redis": "127.0.0.1,database=0,password=7166766,prefix=Pt:"
+  }
+}

+ 1 - 1
成品库/WCS.WorkEngineering/Extensions/DeviceExtension.cs

@@ -229,7 +229,7 @@ namespace WCS.WorkEngineering.Extensions
         出库 = 1L << 7,
 
         巷道口 = 1L << 8,
-        RGV口 = 1L << 9,
+        出货口 = 1L << 9,
         AGV口 = 1L << 10,
 
         直轨 = 1L << 11,

+ 31 - 32
成品库/WCS.WorkEngineering/Systems/出库分配目标地址.cs

@@ -1,4 +1,5 @@
 using ServiceCenter.Extensions;
+using ServiceCenter.Logs;
 using ServiceCenter.SqlSugars;
 using System;
 using System.Collections.Generic;
@@ -29,48 +30,46 @@ namespace WCS.WorkEngineering.Systems
         List<Station> devs = new List<Station>();
         public 出库分配目标地址()
         {
-            devs = Device.All.Where(v => v.HasFlag(DeviceFlags.出口)).Select(v => new Station(v, this.World)).ToList();            
+            devs = Device.All.Where(v => v.HasFlag(DeviceFlags.出口)).Select(v => new Station(v, this.World)).ToList();            
         }
 
         public override void Do(Device<IStation520, IStation521, IStation523> obj)
         {
-            //if (obj.Entity.Code == "8273" && obj.Data2.Request == 1 && obj.Data.GoodsEnd != 8271)
-            //{
-            //    obj.Data.TaskNumber = obj.Data2.TaskNumber;
-            //    obj.Data.GoodsEnd = 8271;
-            //    obj.Data.VoucherNo ++;
-            //}
-            //return;
+            WCS_TaskInfo task = null;
+            if (obj.Data2.TaskNumber <= 0)
+                return;
+            if (!obj.Data3.Status.HasFlag(StationStatus.PH_Status) || !obj.Data3.Status.HasFlag(StationStatus.OT_Status))
+                return;
+            if (obj.Data2.Request != 1)
+                return;
 
-            //if (obj.Data2.TaskNumber <= 0)
-            //    return;
-            //if (!obj.Data3.Status.HasFlag(StationStatus.PH_Status))
-            //    return;
-            ////if (obj.Data2.GoodsEnd.ToString() != obj.Entity.Code)
-            ////    return;            
-            //SqlSugarHelper.Do(_db =>
-            //{
-            //    var db = _db.Default;
-            //    //找到对应任务
-            //    var taskInfo = db.Queryable<WCS_TaskOld>().SplitTable(tabs => tabs.Take(2)).Where(v => v.ID == obj.Data2.TaskNumber && v.Type == TaskType.OutDepot && v.WorkBench == "8278").First();
-            //    //taskInfo.WorkBench = "8278";
-            //    //db.Default.Updateable(taskInfo).SplitTable().ExecuteCommand();
+            SqlSugarHelper.Do(db =>
+            {
+                //var db = _db.Default;
+                //找到对应任务
+                var taskInfo = db.Default.Queryable<WCS_TaskInfo>().First(v => v.ID == obj.Data2.TaskNumber);
+                if(taskInfo == null) throw new KnownException($"未找到对应WCS任务{obj.Data2.TaskNumber}", LogLevelEnum.High);
+                if (taskInfo.AddrTo == obj.Entity.Code && taskInfo.Type == TaskType.OutDepot)
+                {
+                    taskInfo.Status = Entity.TaskStatus.Finish;
+                    taskInfo.EditTime = DateTime.Now;
+                    taskInfo.EedTime = DateTime.Now;
+                }
+                db.Default.Updateable(taskInfo).ExecuteCommand();
+                taskInfo.AddWCS_TASK_DTL(db, obj.Entity.Code, taskInfo.AddrNext, $"出库任务完成");
+                task = taskInfo;
+                taskInfo.CompleteOrCancelTasks(db);
+                WmsApi.CompleteTask(task.ID);
 
-            //    //未找到对应任务
-            //    if (taskInfo == null)
-            //    {
-            //        throw new Exception($"未找到可用任务");
-            //    }
-
-            //    obj.Data.TaskNumber = obj.Data2.TaskNumber;
-            //    obj.Data.GoodsEnd = 8278;
-            //    obj.Data.VoucherNo++;
-            //});                       
+                obj.Data.TaskNumber = obj.Data2.TaskNumber;
+                obj.Data.GoodsEnd = 8278;
+                obj.Data.VoucherNo++;
+            });
         }
 
         public override bool Select(Device dev)
         {
-            return new string[] { "8263", "8257", "8269" }.Contains(dev.Code);
+            return dev.HasFlag(DeviceFlags.出货口);
         }
     }
 }

+ 1 - 6
成品库/WCS.WorkEngineering/Systems/堆垛机.cs

@@ -81,12 +81,7 @@ namespace WCS.WorkEngineering.Systems
                     if (task.Status != Entity.TaskStatus.StackerExecution) throw new KnownException($"任务{task.ID}状态是{task.Status.GetDescription()}.堆垛机完成任务需要对应任务状态处于堆垛机执行中", LogLevelEnum.High);
 
                     #endregion 获取完成任务
-
-                    if (task.Type == TaskType.EnterDepot)
-                    {
-                        
-                    }
-
+                   
                     //根据任务类型做不同的处理
                     switch (task.Type)
                     {                        

+ 7 - 7
成品库/WCS.WorkEngineering/WebApi/Controllers/WmsApi.cs

@@ -18,7 +18,7 @@ namespace WCS.WorkEngineering.WebApi.Controllers
     {
         private static string _WMSUrl = null!;
         private static string _wareHouseId = null!;
-        private static string wmsUrl = "http://10.30.43.158:8089/api/Cp/WCS_InTaskInfo";
+        private static string wmsUrl = "http://10.30.43.158:8089";
         /// <summary>
         ///  WMS URL
         /// </summary>
@@ -87,7 +87,7 @@ namespace WCS.WorkEngineering.WebApi.Controllers
         /// <exception cref="Exception"></exception>
         public static SRes<string> GetTunnelPriorityList(int wcsTaskNum)
         {
-            var res = APICaller.CallApi2<SRes<string>>("http://10.30.43.158:8089/api/Cp/GetTunnelPriorityList", new GetTunnelPriorityListRequest
+            var res = APICaller.CallApi2<SRes<string>>(wmsUrl + "/api/Cp/GetTunnelPriorityList", new GetTunnelPriorityListRequest
             {
                 TaskNum = wcsTaskNum,
             });
@@ -109,7 +109,7 @@ namespace WCS.WorkEngineering.WebApi.Controllers
         /// <exception cref="Exception"></exception>
         public static SRes<ApplyStockInLocResponse> GetLocalIn(int wcsTaskNum, string tunnel, string device)
         {
-            var res = APICaller.CallApi2<SRes<ApplyStockInLocResponse>>("http://10.30.43.158:8089/api/Cp/ApplyStockInLoc", new ApplyStockInLocRequest
+            var res = APICaller.CallApi2<SRes<ApplyStockInLocResponse>>(wmsUrl + "/api/Cp/ApplyStockInLoc", new ApplyStockInLocRequest
             {
                 TaskNum = wcsTaskNum,
                 TunnelNum = tunnel.GetLastDigit(),
@@ -130,7 +130,7 @@ namespace WCS.WorkEngineering.WebApi.Controllers
         /// <exception cref="KnownException"></exception>
         public static SRes<int> SrmPickOutCompleted(int taskNum)
         {
-            var res = APICaller.CallApi2<SRes<int>>("http://10.30.43.158:8089/api/Cp/SrmPickOutCompleted", new SrmPickOutCompletedRequest
+            var res = APICaller.CallApi2<SRes<int>>(wmsUrl + "/api/Cp/SrmPickOutCompleted", new SrmPickOutCompletedRequest
             {
                 TaskNum = taskNum,
             });
@@ -208,7 +208,7 @@ namespace WCS.WorkEngineering.WebApi.Controllers
         /// <exception cref="KnownException"></exception>
         public static SRes<int> CompleteTask(int taskNo)
         {
-            var res = APICaller.CallApi2<SRes<int>>("http://10.30.43.158:8089/api/Cp/CompleteTask", new CompleteTaskRequest
+            var res = APICaller.CallApi2<SRes<int>>(wmsUrl + "/api/Cp/CompleteTask", new CompleteTaskRequest
             {
                 TaskNum = taskNo,
                 OperationType = Models.WMS.Request.CompleteTask.自动完成,
@@ -229,7 +229,7 @@ namespace WCS.WorkEngineering.WebApi.Controllers
         /// <exception cref="KnownException"></exception>
         public static SRes<AddWcsMoveTaskResponse> AddWcsMoveTask(int taskNo)
         {
-            var res = APICaller.CallApi2<SRes<AddWcsMoveTaskResponse>>("http://10.30.43.158:8089/api/Cp/AddWcsMoveTask", new CompleteTaskRequest
+            var res = APICaller.CallApi2<SRes<AddWcsMoveTaskResponse>>(wmsUrl + "/api/Cp/AddWcsMoveTask", new CompleteTaskRequest
             {
                 TaskNum = taskNo,
             });
@@ -304,7 +304,7 @@ namespace WCS.WorkEngineering.WebApi.Controllers
         /// <exception cref="KnownException"></exception>
         public static SRes CarryTaskInfo(List<int> taskNo, int state)
         {
-            var res = APICaller.CallApi2<SRes>(WMSUrl + "/api/Hj/CarryTaskInfo", new CancelTaskVerifyRequest
+            var res = APICaller.CallApi2<SRes>(WMSUrl + "/api/Pt/CarryTaskInfo", new CancelTaskVerifyRequest
             {
                 TaskNo = taskNo,
                 State = state

+ 3 - 2
成品库/WCS.WorkEngineering/WorkStart.cs

@@ -204,8 +204,9 @@ namespace WCS.WorkEngineering
                 { DeviceFlags.入库, new List<string>() { "8271", "8272", "8273", "8274", "8275", "8250", "8249", "8246", "8244", "8243"} },
                 { DeviceFlags.出库, new List<string>() { "8271", "8272", "8273", "8274", "8275" } },
                 { DeviceFlags.扫码, new List<string>() {"8277"} },
-                { DeviceFlags.出库口, new List<string>() { "8271","8272", "8273", "8274", "8275" } }
-            };
+                { DeviceFlags.出库口, new List<string>() { "8271","8272", "8273", "8274", "8275" } },
+                { DeviceFlags.出货口, new List<string>() { "8263", "8257", "8269" } }
+        };
 
             devices.ForEach(item =>
             {

+ 24 - 2
盘条库/WCS.WorkEngineering/Systems/AgvSystems.cs

@@ -192,8 +192,30 @@ namespace WCS.WorkEngineering.Systems
                                         {
                                             agv.Status = AGVTaskStatus.Complete2;
                                             db.Default.Updateable(agv).SplitTable().ExecuteCommand();
-                                            taskInfo.AddWCS_TASK_DTL(db, "agv", $"允许AGV任务{agv.ID}在站台{agv.Station}取货");
-                                            AgvApi.ContinueTask(agv.AgvID, agv.Station);
+                                            string startPos = "";
+                                            if (taskInfo.AddrFrom == "1021"  || taskInfo.AddrFrom == "1022" || taskInfo.AddrFrom == "1023" || taskInfo.AddrFrom == "1024")
+                                            {
+                                                startPos = "PT" + taskInfo.AddrFrom;
+                                            }
+                                            //else if (taskInfo.AddrFrom == "1022")
+                                            //{
+                                            //    startPos = "2002";
+                                            //}
+                                            //else if (taskInfo.AddrFrom == "1023")
+                                            //{
+                                            //    startPos = "2003";
+                                            //}
+                                            //else if (taskInfo.AddrFrom == "1024")
+                                            //{
+                                            //    startPos = "2004";
+                                            //}
+                                            else
+                                            {
+                                                startPos = taskInfo.AddrFrom;
+                                            }
+
+                                            taskInfo.AddWCS_TASK_DTL(db, "agv", $"允许AGV任务{agv.ID}在站台{startPos}取货");
+                                            AgvApi.ContinueTask(agv.AgvID, startPos);
                                         }
                                         else if (agv.AgvStatus == AGVTaskStatus.Complete3)
                                         {

+ 43 - 15
盘条库/WCS.WorkEngineering/Systems/NoInteractionSystems.cs

@@ -206,27 +206,32 @@ namespace WCS.WorkEngineering.Systems
                                     string startPos = "";
                                     if (agv.WorkShop == 1)
                                     {
-                                        if (wcs.AddrFrom == "1021")
+                                        if (wcs.AddrFrom == "1021" || wcs.AddrFrom == "1022" || wcs.AddrFrom == "1023" || wcs.AddrFrom == "1024")
                                         {
-                                            startPos = "2001";
-                                        }
-                                        else if (wcs.AddrFrom == "1022")
-                                        {
-                                            startPos = "2002";
-                                        }
-                                        else if (wcs.AddrFrom == "1023")
-                                        {
-                                            startPos = "2003";
-                                        }
-                                        else if (wcs.AddrFrom == "1024")
-                                        {
-                                            startPos = "2004";
+                                            startPos = "PT" + wcs.AddrFrom;
                                         }
+                                        //else if (wcs.AddrFrom == "1022")
+                                        //{
+                                        //    startPos = "2002";
+                                        //}
+                                        //else if (wcs.AddrFrom == "1023")
+                                        //{
+                                        //    startPos = "2003";
+                                        //}
+                                        //else if (wcs.AddrFrom == "1024")
+                                        //{
+                                        //    startPos = "2004";
+                                        //}
                                         else
                                         {
                                             startPos = wcs.AddrFrom;
                                         }
                                     }
+                                    else
+                                    {
+                                        startPos = wcs.AddrFrom;
+                                    }
+                                    
                                     var res = AgvApi.盘条入库(startPos, agv.Position,"1001","PT", Guid.NewGuid().ToString().Replace("-", ""), "1");
                                     agv.Status = AGVTaskStatus.Confirm;
                                     agv.AgvID = res.data;
@@ -262,10 +267,33 @@ namespace WCS.WorkEngineering.Systems
                                     }
                                     else if (agv.WorkShop == 333)
                                     {
+                                        string startPos = "";
+                                        
                                         //获取对应wcs任务
                                         var wcs = db.Default.Queryable<WCS_TaskInfo>().Where(t => t.AgvTaskID == agv.ID && t.Status == Entity.TaskStatus.WaitingToExecute).First();
                                         if (wcs == null) throw new Exception($"未找到对应的WCS任务");
-                                        var res = AgvApi.搬运_wmsStart("PT", agv.Station, agv.Position, Guid.NewGuid().ToString().Replace("-", ""), "1");
+
+                                        if (wcs.AddrFrom == "1021" || wcs.AddrFrom == "1022" || wcs.AddrFrom == "1023" || wcs.AddrFrom == "1024")
+                                        {
+                                            startPos = "PT" + wcs.AddrFrom;
+                                        }
+                                        //else if (wcs.AddrFrom == "1022")
+                                        //{
+                                        //    startPos = "2002";
+                                        //}
+                                        //else if (wcs.AddrFrom == "1023")
+                                        //{
+                                        //    startPos = "2003";
+                                        //}
+                                        //else if (wcs.AddrFrom == "1024")
+                                        //{
+                                        //    startPos = "2004";
+                                        //}
+                                        else
+                                        {
+                                            startPos = wcs.AddrFrom;
+                                        }
+                                        var res = AgvApi.搬运_wmsStart("PT", startPos, agv.Position, Guid.NewGuid().ToString().Replace("-", ""), "1");
                                         agv.Status = AGVTaskStatus.Confirm;
                                         agv.AgvID = res.data;
                                         db.Default.Updateable(agv).SplitTable().ExecuteCommand();

+ 2 - 1
盘条库/WCS.WorkEngineering/Systems/一楼入库巷道分配处理系统.cs

@@ -68,6 +68,7 @@ namespace WCS.WorkEngineering.Systems
                     var barcode = bardata.Content.Trim().Split('\0')[0];
            
                     if(string.IsNullOrEmpty(barcode)) throw new KnownException($"条码为空,请检查", LogLevelEnum.High);
+                    if (!barcode.StartsWith("PT") && !barcode.StartsWith("Test")) throw new KnownException($"条码{barcode}无法识别", LogLevelEnum.High);
                     //根据agv任务找到对应wcs任务并赋值
                     if (db.Queryable<WCS_AgvTaskInfo>().SplitTable().Count(v => v.AgvStatus == AGVTaskStatus.RequestOrPermission1 && v.Status != AGVTaskStatus.Complete1 && v.Position == obj.Entity.Code) > 1)
                     {
@@ -76,7 +77,7 @@ namespace WCS.WorkEngineering.Systems
                     var agvTask = db.Queryable<WCS_AgvTaskInfo>().SplitTable().First(v => v.AgvStatus == AGVTaskStatus.RequestOrPermission1 && v.Status != AGVTaskStatus.Complete1 && v.Position == obj.Entity.Code);
                     if (agvTask == null) throw new KnownException($"未找到对应agv任务,条码{barcode}", LogLevelEnum.High);
                     taskInfo = db.Queryable<WCS_TaskInfo>().First(v => v.AgvTaskID == agvTask.ID) ?? throw new KnownException($"未找到agv任务{agvTask.ID}对应WCS任务", LogLevelEnum.High);
-                    if(taskInfo.BarCode != barcode) throw new KnownException($"条码读取有误,请检查条码", LogLevelEnum.High);
+                    if (taskInfo.BarCode.StartsWith("PT") && taskInfo.BarCode != barcode) throw new KnownException($"条码读取有误,请检查条码", LogLevelEnum.High);
                     taskInfo.BarCode = barcode;
 
                     //分配巷道,agv目标站台

+ 1 - 1
盘条库/WCS.WorkEngineering/WorkStart.cs

@@ -174,7 +174,7 @@ namespace WCS.WorkEngineering
                 { DeviceFlags.入库, new List<string>() { "1001", "1003", "1005", "1007", "1009", "1011","1013","1015" } },
                 { DeviceFlags.出库, new List<string>() { "1002", "1004", "1006", "1008", "1010", "1012","1014","1016" } },
                 //{ DeviceFlags.扫码, new List<string>() { "1017", "1018" } },
-                { DeviceFlags.一楼出库口, new List<string>() { "1002", "1004" } },//  "1006", "1008", "1010", "1012", "1014", "1016" } },                
+                { DeviceFlags.一楼出库口, new List<string>() { "1002", "1004" , "1006", "1008" } },//  "1006", "1008", "1010", "1012", "1014", "1016" } },                
                 { DeviceFlags.一楼入库口, new List<string>() { "1001", "1003", "1005","1007"} },//,"1009","1011","1013","1015" } },
                 { DeviceFlags.一楼出入库口, new List<string>() { "1001", "1003", "1005","1007"} },//,"1009","1011","1013","1015" } },
                 { DeviceFlags.检测门, new List<string>() { "1017", "1018" } },