分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-03-14 73a926018601d9a5a5a3d3f4c051537f45a8eff4
优化代码逻辑
已修改26个文件
已添加5个文件
60962 ■■■■■ 文件已修改
.gitignore 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Client/src/api/http.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_Core/UserManager/UserContext.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask_hty.cs 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/AGVandGantry.cs 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs 284 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/GantryJob.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/OutboundTask.cs 195 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/ReplaceTray.cs 121 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/VV_DispatchService.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WebApi/appsettings.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Client/src/api/http.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Client/src/views/widesea_wms/system/dt_stationinfo.vue 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask_hty.cs 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WMS_Server/WIDESEA_WebApi/appsettings.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/DB/DeleteOldRecords.sql 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/DB/T-SQL.sql 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/DB/dbo.sql 59991 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/DB/创建存储过程.sql 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/通信协议/新增设备协议/太重交互-库口状态_V1.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -19,3 +19,4 @@
代码管理/PCS/WCS_Server/WIDESEA_System/WIDESEA_System.csproj
代码管理/PCS/WCS_Server/WIDESEA_System/WIDESEA_System.csproj
*.csproj
/代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/存储过程/StoredProcedure.cs
´úÂë¹ÜÀí/PCS/WCS_Client/src/api/http.js
@@ -15,11 +15,11 @@
    axios.defaults.baseURL = 'http://127.0.0.1:8099/';
}
else if (process.env.NODE_ENV == 'debug') {
    axios.defaults.baseURL = 'http://127.0.0.1:8099/';
    axios.defaults.baseURL = 'http://192.168.12.101:8099/';
}
else if (process.env.NODE_ENV == 'production') {
    axios.defaults.baseURL = 'http://127.0.0.1:8099/';
    axios.defaults.baseURL = 'http://192.168.12.101:8099/';
}
if (!axios.defaults.baseURL.endsWith('/')) {
    axios.defaults.baseURL+="/";
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_Core/UserManager/UserContext.cs
@@ -357,12 +357,16 @@
                    ?? Context.User.FindFirstValue(ClaimTypes.NameIdentifier)).GetInt();
            }
        }
        /// <summary>
        /// è´¦å·
        /// </summary>
        public string UserName
        {
            get { return UserInfo.UserName; }
        }
        /// <summary>
        /// å§“名
        /// </summary>
        public string UserTrueName
        {
            get { return UserInfo.UserTrueName; }
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_Entity/DomainModels/System/dt_inventory.cs
@@ -46,11 +46,11 @@
        /// <summary>
        ///熔炼炉号
        /// </summary>
        [Display(Name = "熔炼炉号")]
        [MaxLength(255)]
        [Column(TypeName = "varchar(255)")]
        [Editable(true)]
        public string HearthNumber { get; set; }
        //[Display(Name = "熔炼炉号")]
        //[MaxLength(255)]
        //[Column(TypeName = "varchar(255)")]
        //[Editable(true)]
        //public string HearthNumber { get; set; }
        /// <summary>
        ///炉代号
@@ -97,13 +97,17 @@
        /// <summary>
        ///ID
        /// </summary>
        //[Key]
        //[Display(Name = "ID")]
        //[Column(TypeName = "int")]
        //[Editable(true)]
        //[Required(AllowEmptyStrings = false)]
        //public int ID { get; set; }
        [Key]
        [Display(Name = "ID")]
        [Column(TypeName = "int")]
        [Editable(true)]
        [Column(TypeName = "uniqueidentifier")]
        [Required(AllowEmptyStrings = false)]
        public int ID { get; set; }
        public Guid ID { get; set; }
        /// <summary>
        ///货位编号
        /// </summary>
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs
@@ -57,12 +57,22 @@
        /// <summary>
        ///AGV编号
        /// </summary>
        [Display(Name = "AGV编号")]
        //[Display(Name = "AGV编号")]
        //[MaxLength(50)]
        //[Column(TypeName = "nvarchar(50)")]
        //[Editable(true)]
        //[Required(AllowEmptyStrings = false)]
        //public string agv_code { get; set; }
        /// <summary>
        ///托盘状态
        /// </summary>
        [Display(Name = "托盘状态")]
        [MaxLength(50)]
        [Column(TypeName = "nvarchar(50)")]
        [Editable(true)]
        [Required(AllowEmptyStrings = false)]
        public string agv_code { get; set; }
        //[Required(AllowEmptyStrings = false)]
        public string agv_TrayStatus { get; set; }
        /// <summary>
        ///任务状态
@@ -75,7 +85,7 @@
        public string agv_taskstate { get; set; }
        /// <summary>
        ///AGV工作类型
        ///工单类型/AGV工作类型
        /// </summary>
        [Display(Name = "AGV工作类型")]
        [Column(TypeName = "int")]
@@ -146,7 +156,7 @@
        public string agv_remark { get; set; }
        /// <summary>
        ///任务等级
        ///任务等级0、暂缓1、正常2、加急
        /// </summary>
        [Display(Name = "任务等级")]
        [Column(TypeName = "int")]
@@ -163,14 +173,14 @@
        public string agv_userid { get; set; }
        /// <summary>
        ///托盘码
        ///托盘类型/托盘码
        /// </summary>
        [Display(Name = "托盘码")]
        [MaxLength(30)]
        [Column(TypeName = "nvarchar(30)")]
        [Editable(true)]
        //[Required(AllowEmptyStrings = false)]//不能为空
        public string agv_barcode { get; set; }
        public string agv_Traytype { get; set; }
        /// <summary>
        ///物料码
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask_hty.cs
@@ -174,24 +174,33 @@
        public string agv_userid { get; set; }
        /// <summary>
        ///托盘码
        ///托盘类型/托盘码
        /// </summary>
        [Display(Name = "托盘码")]
        [MaxLength(30)]
        [Column(TypeName = "nvarchar(30)")]
        [Editable(true)]
        [Required(AllowEmptyStrings = false)]
        public string agv_barcode { get; set; }
        //[Required(AllowEmptyStrings = false)]
        public string agv_Traytype { get; set; }
        /// <summary>
        ///AGV编号
        /// </summary>
        [Display(Name = "AGV编号")]
        //[Display(Name = "AGV编号")]
        //[MaxLength(50)]
        //[Column(TypeName = "nvarchar(50)")]
        //[Editable(true)]
        //[Required(AllowEmptyStrings = false)]
        //public string agv_code { get; set; }
        /// <summary>
        ///托盘状态
        /// </summary>
        [Display(Name = "托盘状态")]
        [MaxLength(50)]
        [Column(TypeName = "nvarchar(50)")]
        [Editable(true)]
        [Required(AllowEmptyStrings = false)]
        public string agv_code { get; set; }
        //[Required(AllowEmptyStrings = false)]
        public string agv_TrayStatus { get; set; }
        /// <summary>
        ///AGV工作类型
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Common/AGVandGantry.cs
@@ -4,6 +4,8 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using WIDESEA_Comm.LogInfo;
using WIDESEA_Core.BaseProvider;
using WIDESEA_Core.FreeDB;
using WIDESEA_Entity.DomainModels;
@@ -30,6 +32,9 @@
                if (Gantry_client == null) throw new Exception("桁架调度服务未开启!");
                if (!Gantry_client.IsConnected) throw new Exception("与桁架连接超时!");
                var Gantryplc = FreeDB.Select<dt_plcinfohead>().Where(x => x.plcinfo_name == Gantry_client.PLCName).First();
                var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "链条机");
                if (Pipeline_client == null) throw new Exception("链条机调度服务未开启!");
                if (!Pipeline_client.IsConnected) throw new Exception("与链条机连接超时!");
                List<string> numbers = new List<string>() { "1单元防呆", "2单元防呆", "3单元防呆", "上料区防呆" };
                var details = FreeDB.Select<dt_plcinfodetail>().Where(x => x.plcdetail_iotype == Gantryplc.plcinfo_iotyep && x.plcdetail_number == numbers[requestin.AreaNr - 1]).ToList();
                if (MethodName == "AGVRequestin")//请求进入区域
@@ -38,6 +43,10 @@
                    Gantry_client.WriteByOrder("W_AGV_Request_In", true, numbers[requestin.AreaNr - 1]);//申请进入区域
                    var Release = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Release_In").First(), Gantry_client);//允许进入区域
                    var Gantry_Out_of_Area = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Gantry_Out_of_Area").First(), Gantry_client);//桁架不在该区域
                    #region æ—¥å¿—记录
                    WriteDBLog.Success("AGV请求进入区域", $"写入桁架信息:\n区域号:{requestin.AreaNr}\n申请进入区域:true" +
                        $"\n\n读取桁架信息:\n允许进入区域:{Release}\n桁架不在该区域:{Gantry_Out_of_Area}", "AGV");
                    #endregion
                    if (!Release) throw new Exception("桁架未允许进入!");
                    if (!Gantry_Out_of_Area) throw new Exception("桁架在区域内!");
                }
@@ -46,16 +55,26 @@
                    Gantry_client.WriteByOrder("W_AreaNr", (Int16)requestin.AreaNr, numbers[requestin.AreaNr - 1]);//区域号
                    if (requestin.Type == 1)
                    {
                        Pipeline_client.WriteByOrder("W_AGV_Entering", (Int16)1, numbers[requestin.AreaNr - 1]);//光栅屏蔽
                        Gantry_client.WriteByOrder("W_AGV_Leaving", false, numbers[requestin.AreaNr - 1]);//正在离开
                        Gantry_client.WriteByOrder("W_AGV_Entering", true, numbers[requestin.AreaNr - 1]);//正在进入
                        var Area_Occupied_by_AGV = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Area_Occupied_by_AGV").First(), Gantry_client);//桁架反馈AGV占位信号
                        #region æ—¥å¿—记录
                        WriteDBLog.Success("AGV正在进入区域", $"写入桁架信息:\n区域号:{requestin.AreaNr}\n正在离开:false\n正在进入:true\n光栅屏蔽:1" +
                            $"\n\n读取桁架信息:\n反馈AGV占位信号:{Area_Occupied_by_AGV}", "AGV");
                        #endregion
                        if (!Area_Occupied_by_AGV) throw new Exception("桁架未反馈AGV占位信号");
                    }
                    else if (requestin.Type == 2)
                    {
                        Pipeline_client.WriteByOrder("W_AGV_Entering", (Int16)2, numbers[requestin.AreaNr - 1]);//光栅启用
                        Gantry_client.WriteByOrder("W_AGV_Entering", false, numbers[requestin.AreaNr - 1]);//正在进入
                        Gantry_client.WriteByOrder("W_AGV_Leaving", true, numbers[requestin.AreaNr - 1]);//正在离开
                        var Area_Occupied_by_AGV = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Area_Occupied_by_AGV").First(), Gantry_client);//桁架反馈AGV占位信号
                        #region æ—¥å¿—记录
                        WriteDBLog.Success("AGV正在离开区域", $"写入桁架信息:\n区域号:{requestin.AreaNr}\n正在进入:false\n正在离开:true\n光栅屏蔽:2" +
                            $"\n\n读取桁架信息:\n反馈AGV离开信号:{!Area_Occupied_by_AGV}", "AGV");
                        #endregion
                        if (Area_Occupied_by_AGV) throw new Exception("桁架未反馈AGV离开信号");
                    }
                }
@@ -63,10 +82,16 @@
                {
                    Gantry_client.WriteByOrder("W_AreaNr", (Int16)requestin.AreaNr, numbers[requestin.AreaNr - 1]);//区域号
                    Gantry_client.WriteByOrder("W_AGV_OUT_OF_Area", requestin.OUTOFArea == 1 ? true : false, numbers[requestin.AreaNr - 1]);//AGV不在该区域
                    #region æ—¥å¿—记录
                    WriteDBLog.Success("AGV不在区域内", $"写入桁架信息:\n区域号:{requestin.AreaNr}\nAGV不在该区域:{(requestin.OUTOFArea == 1 ? true : false)}", "AGV");
                    #endregion
                }
                else if (MethodName == "GantryOutofArea")//桁架不在区域内
                {
                    var Gantry_Out_of_Area = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Gantry_Out_of_Area").First(), Gantry_client);//桁架不在该区域
                    #region æ—¥å¿—记录
                    WriteDBLog.Success("桁架不在区域内", $"读取桁架信息:\n区域号:{requestin.AreaNr}\n桁架不在该区域:{Gantry_Out_of_Area}", "AGV");
                    #endregion
                    if (!Gantry_Out_of_Area) throw new Exception("桁架在区域内!");
                }
                respone.success = 1;
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs
@@ -1,11 +1,14 @@
using StackExchange.Redis;
using FreeSql.Internal.Model;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm;
using WIDESEA_Comm.LogInfo;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.FreeDB;
using WIDESEA_WCS.IRepositories;
using WIDESEA_WCS.Repositories;
using WIDESEA_WCS.WCSClient;
@@ -15,20 +18,26 @@
{
    public class Gantry
    {
        static VOLContext Context = new VOLContext();
        Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context);
        Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context);
        Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context);
        Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context);
        Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
        Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context);
        Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context);
        Idt_patternRepository patternRepository = new dt_patternRepository(Context);
        //FreeDB freeDB = new FreeDB();
        //static VOLContext Context = new VOLContext();
        //Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context);
        //Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context);
        //Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context);
        //Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context);
        ////Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
        //Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context);
        //Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context);
        //Idt_patternRepository patternRepository = new dt_patternRepository(Context);
        #region æŸ¥è¯¢è½¦è½®æ•°æ®
        public void QueryWheeldata(PLCClient client)
        {
            try
            {
                VOLContext Context = new VOLContext();
                Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context);
                Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context);
                Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context);
                Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context);
                var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName);
                List<string> names = new List<string>() { "1单元辊道下料查询车轮", "2单元辊道下料查询车轮", "3单元辊道下料查询车轮", "辊道上料查询车轮" };
                foreach (string name in names)
@@ -47,6 +56,9 @@
                                //1-找到数据,2-未找到工件类型数据
                                client.WriteByOrder("W_i_status", (byte)2, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Error(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到机加工车轮信息", "PCS");
                                #endregion
                            }
                            else
                            {
@@ -61,6 +73,10 @@
                                client.WriteByOrder("W_i_parameter_g", (float)geometry.g, name);
                                client.WriteByOrder("W_i_parameter_h", (float)geometry.h, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Success(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\na:{(float)geometry.a}\nb:{(float)geometry.b}\nc:{(float)geometry.c}\n" +
                                    $"d:{(float)geometry.d}\ne:{(float)geometry.e}\nf:{(float)geometry.f}\ng:{(float)geometry.g}\nh:{(float)geometry.h}\nR_oi_on:0", "PCS");
                                #endregion
                            }
                        }
                        else
@@ -70,6 +86,9 @@
                            {
                                client.WriteByOrder("W_i_status", (byte)2, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Error(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到检测线车轮信息", "PCS");
                                #endregion
                            }
                            else
                            {
@@ -83,6 +102,10 @@
                                client.WriteByOrder("W_i_parameter_g", (float)geometry.g, name);
                                client.WriteByOrder("W_i_parameter_h", (float)geometry.h, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Success(name, $"读取桁架信息:\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\na:{(float)geometry.a}\nb:{(float)geometry.b}\nc:{(float)geometry.c}\n" +
                                    $"d:{(float)geometry.d}\ne:{(float)geometry.e}\nf:{(float)geometry.f}\ng:{(float)geometry.g}\nh:{(float)geometry.h}\nR_oi_on:0", "PCS");
                                #endregion
                            }
                        }
@@ -101,21 +124,51 @@
        {
            try
            {
                VOLContext Context = new VOLContext();
                Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context);
                Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context);
                Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context);
                Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context);
                Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context);
                Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context);
                Idt_patternRepository patternRepository = new dt_patternRepository(Context);
                var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName);
                List<string> names = new List<string>() { "1单元辊道下料查询订单", "2单元辊道下料查询订单", "3单元辊道下料查询订单", "辊道上料查询订单" };
                foreach (string name in names)
                {
                    var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList();
                    var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on").First(), client);
                    //var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on" && x.plcdetail_number == name).First(), client);
                    if ((byte)on == 1)
                    {
                        //var wp_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_id").First(), client).ToString();
                        var wp_id = client.ReadByOrder<string>("R_o_wp_id", name);
                        if (string.IsNullOrEmpty(wp_id))
                        {
                            #region æ—¥å¿—记录
                            client.WriteByOrder("W_i_status", (byte)2, name);
                            client.WriteByOrder("R_oi_on", (byte)0, name);
                            WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n车轮SN号为空", "PCS");
                            #endregion
                            continue;
                        }
                        var wp_type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_type").First(), client);
                        var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == wp_id);
                        #region æµ‹è¯•使用
                        if (mes_Detail == null)
                        {
                            mes_Detail = mes_DetailRepository.FindFirst(x => x.jobID == (name == "3单元辊道下料查询订单" ? "01180127004-2" : "01180127004-1"));
                            mes_Detail.SN = wp_id;
                            mes_DetailRepository.Update(mes_Detail, true);
                        }
                        #endregion
                        if (mes_Detail == null)
                        {
                            client.WriteByOrder("W_i_status", (byte)2, name);
                            client.WriteByOrder("R_oi_on", (byte)0, name);
                            #region æ—¥å¿—记录
                            WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到工单详情", "PCS");
                            #endregion
                            continue;
                        }
                        var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID);
@@ -123,6 +176,9 @@
                        {
                            client.WriteByOrder("W_i_status", (byte)2, name);
                            client.WriteByOrder("R_oi_on", (byte)0, name);
                            #region æ—¥å¿—记录
                            WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到工单头表", "PCS");
                            #endregion
                            continue;
                        }
@@ -134,16 +190,21 @@
                            {
                                client.WriteByOrder("W_i_status", (byte)4, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n\n写入桁架信息:\nW_i_status:4\nR_oi_on:0\n\n手动入库模式未选择库区", "PCS");
                                #endregion
                                continue;
                            }
                            var wp_type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_type").First(), client);
                            //var geometry = dataRepository.FindFirst(x => x.TypeId == (Int32)wp_type);
                            var geometry = dataRepository.FindFirst(x => x.Description == mes_Head.drawingNo);
                            var geometry = dataRepository.Find(x => x.Description == mes_Head.drawingNo && x.TypeId == (Int32)wp_type).FirstOrDefault();
                            if (geometry == null)
                            {
                                //1-好,允许加工,2-不在列表中,3-不加工车轮类型,4-手动入库模式人工未选择库区
                                client.WriteByOrder("W_i_status", (byte)2, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到机加工车轮信息", "PCS");
                                #endregion
                                continue;
                            }
                            else
@@ -159,22 +220,30 @@
                                //屏蔽工艺(屏蔽视觉检测/屏蔽涂油)
                                //if (name != "辊道上料查询车轮")
                                //{
                                client.WriteByOrder("W_i_skip_op_SJ1", mes_Head.skip_op_1, name);//屏蔽视觉检测设备1
                                client.WriteByOrder("W_i_skip_op_SJ2", mes_Head.skip_op_2, name);//屏蔽视觉检测设备2
                                client.WriteByOrder("W_i_skip_op_SJ1", name == "3单元辊道下料查询订单" ? true : mes_Head.skip_op_1, name);//屏蔽视觉检测设备1
                                client.WriteByOrder("W_i_skip_op_SJ2", name == "3单元辊道下料查询订单" ? true : mes_Head.skip_op_2, name);//屏蔽视觉检测设备2
                                client.WriteByOrder("W_i_skip_op_LT", mes_Head.skip_op_3, name);//屏蔽链条机
                                //}
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Success(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" +
                                    $"\nW_i_job_id:{mes_Detail.jobID}\nW_i_drawing_id:{mes_Head.drawingNo}\nW_i_heat_id:{mes_Detail.heatID}\nW_i_batch_id:{mes_Detail.heatBatchID}" +
                                    $"\nW_i_skip_op_SJ1:{(name == "3单元辊道下料查询订单" ? true : mes_Head.skip_op_1)}\nW_i_skip_op_SJ2:{(name == "3单元辊道下料查询订单" ? true : mes_Head.skip_op_2)}" +
                                    $"\nW_i_skip_op_LT:{mes_Head.skip_op_3}\nR_oi_on:0", "PCS");
                                #endregion
                            }
                        }
                        else
                        {
                            var geometry = dataRepository.FindFirst(x => x.Description == mes_Head.drawingNo);
                            var geometry = detectionlineRepository.Find(x => x.Description == mes_Head.drawingNo && x.TypeId == (Int32)wp_type).FirstOrDefault();
                            if (geometry == null)
                            {
                                //1-好,允许加工,2-不在列表中,3-不加工车轮类型,4-手动入库模式人工未选择库区
                                client.WriteByOrder("W_i_status", (byte)2, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:2\nR_oi_on:0\n\n未查询到检测线车轮信息", "PCS");
                                #endregion
                                continue;
                            }
                            else
@@ -187,6 +256,10 @@
                                //client.WriteByOrder("W_i_sourceheat", "", name);
                                client.WriteByOrder("W_i_batch_id", mes_Detail.heatBatchID, name);
                                client.WriteByOrder("R_oi_on", (byte)0, name);
                                #region æ—¥å¿—记录
                                WriteDBLog.Success(name, $"读取桁架信息:\n车轮SN:{wp_id}\n轮型ID:{wp_type}\n\n写入桁架信息:\nW_i_status:1" + $"\nW_i_job_id:{mes_Detail.jobID}" +
                                    $"\nW_i_drawing_id:{mes_Head.drawingNo}\nW_i_heat_id:{mes_Detail.heatID}\nW_i_batch_id:{mes_Detail.heatBatchID}\nR_oi_on:0", "PCS");
                                #endregion
                            }
                        }
@@ -207,15 +280,85 @@
        {
            try
            {
                VOLContext Context = new VOLContext();
                Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context);
                Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context);
                Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
                Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context);
                Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context);
                Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context);
                Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context);
                Idt_patternRepository patternRepository = new dt_patternRepository(Context);
                var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName);
                var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "链条机");
                if (Pipeline_client == null) throw new Exception("链条机调度服务未开启!");
                if (!Pipeline_client.IsConnected) throw new Exception("与链条机连接超时!");
                var Pipelineplc = repository.FindFirst(x => x.plcinfo_name == Pipeline_client.PLCName);
                List<string> names = new List<string>() { "1单元下料区", "2单元下料区", "3单元下料区" };
                foreach (string name in names)
                {
                    var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList();
                    var Wheel_Type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_Type").First(), client);//车轮类型
                    var Wheel_id = client.ReadByOrder<string>("R_Wheel_id", name);//车轮SN号
                    if (string.IsNullOrEmpty(Wheel_id)) continue;
                    //var Wheel_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_id").First(), client).ToString();
                    var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_id);
                    if (mes_Detail == null)
                    {
                        #region æ—¥å¿—记录
                        WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{Wheel_id}\n\n未查询到工单详情", "PCS");
                        #endregion
                        continue;
                    }
                    var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID);
                    if (mes_Head == null)
                    {
                        #region æ—¥å¿—记录
                        WriteDBLog.Error(name, $"读取桁架信息:\n车轮SN:{Wheel_id}\n\n未查询到工单头表", "PCS");
                        #endregion
                        continue;
                    }
                    var finished = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_load_finished").First(), client);//放料完成
                    var updatefinished = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Storage_update").First(), client);//货位状态更新
                    if (!finished && updatefinished)
                    {
                        client.WriteByOrder("W_Storage_update", false, name);//货位状态更新
                        #region æ—¥å¿—记录
                        WriteDBLog.Success(name + "货位状态更新复位", $"读取桁架信息:\n车轮SN:{Wheel_id}\n轮型ID:{Wheel_Type}\n\n写入桁架信息:\nW_Storage_update:false", "PCS");
                        #endregion
                    }
                    if (finished && !updatefinished)
                    {
                        var AreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_AreaNr").First(), client);
                        var areaCode = PipelineJob.area_code(name);   //根据下料口单元名获取区域代码
                        var station = stationinfoRepository.FindFirst(x => x.area == areaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == AreaNr.ToString());  //此处有问题 ä¸çŸ¥é“是结尾为1的哪个下料口
                        station.quantity++;    //todo æ­¤å¤„数量不会增加  ä½†æ˜¯æ›´æ–°å®žä½“影响报错 æ˜Žæ—¥æµ‹è¯•
                        if (station.quantity > 5)
                            throw new Exception($"下料位信息更新失败!下料位车轮数量大于5:{station.stationCode}");
                        //station.bindSN = station.bindSN == string.Empty ? Wheel_id : station.bindSN + "," + Wheel_id;
                        station.bindSN = string.IsNullOrEmpty(station.bindSN) ? Wheel_id : station.bindSN + "," + Wheel_id;
                        if (station.quantity == 1)
                        {
                            station.stationType = mes_Head.drawingNo;
                            station.Number = mes_Head.jobID;
                            station.heatNumber = mes_Detail.heatID;
                            station.tray_status = "StrogeTray";
                        }
                        var count = stationinfoRepository.Update(station, true);
                        if (count < 1)
                            throw new Exception($"下料位信息更新失败!下料位编号:{station.stationCode}");
                        client.WriteByOrder("W_Storage_update", true, name);//货位状态更新
                        client.WriteByOrder("W_Enabl_Load", false, name);//是否允许
                        #region æ—¥å¿—记录
                        WriteDBLog.Success(name + "放料完成", $"读取桁架信息:\n车轮SN:{Wheel_id}\n轮型ID:{Wheel_Type}\n下料位号:{AreaNr}" +
                            $"\n\n写入桁架信息:\nW_Storage_update:true" + $"\nW_Enabl_Load:false", "PCS");
                        #endregion
                    }
                    var Request = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Request_Load").First(), client);
                    if (!Request) continue;
@@ -225,18 +368,27 @@
                    var NGStation = "X01001003";
                    if (name == "2单元下料区") NGStation = "X02001003";
                    if (name == "3单元下料区") NGStation = "X03001002";
                    foreach (var station in Stations)
                    foreach (var station in Stations)     //任何一个下料位为空或禁用时,都会停止桁架
                    {
                        if (!station.enable || station.location_state == LocationStateEnum.Empty.ToString())
                            client.WriteByOrder("W_Enabl_Load", false, name);//信号为false桁架停止进入
                    }
                    var Wheel_Type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_Type").First(), client);//车轮类型
                    var Wheel_id = client.ReadByOrder<string>("R_Wheel_id", name);//车轮SN号
                    //var Wheel_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_id").First(), client).ToString();
                    var mes_Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_id);
                    var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == mes_Detail.jobID);
                    //var currentAreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Are00aNr").First(), client);
                    //var currentAreaCode = PipelineJob.area_code(name);   //根据下料口单元名获取区域代码
                    //var currentStation = stationinfoRepository.FindFirst(x => x.area == currentAreaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == currentAreaNr.ToString());
                    //if (!currentStation.enable || currentStation.location_state == LocationStateEnum.Empty.ToString())
                    //    client.WriteByOrder("W_Enabl_Load", false, name);//信号为false桁架停止进入
                    var wheel = PipelineJob.QueryMateriel(mes_Head.drawingNo);
                    if (wheel == null)
                    {
                        #region æ—¥å¿—记录
                        WriteDBLog.Error(name, $"未查询到车轮信息!", "PCS");
                        #endregion
                        continue;
                    }
                    var PartStatus = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok
                    if ((Int16)PartStatus == 1)
@@ -256,31 +408,54 @@
                            Stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault();
                        if (Stationinfo != null)
                        {
                            #region æ‰˜ç›˜ç±»åž‹ä¸ä¸€è‡´éœ€æ›´æ¢æ‰˜ç›˜
                            if (Stationinfo.tray_type != (wheel.e < 1100 ? "SmallTray" : "LargeTray"))
                            {
                                Stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
                                Stationinfo.tray_type = Stationinfo.tray_type == "SmallTray" ? "SmallTray/LargeTray" : "LargeTray/SmallTray";
                                Stationinfo.remark = "托盘类型不一致需更换托盘";
                                stationinfoRepository.Update(Stationinfo, true);
                                continue;
                            }
                            #endregion
                            var Pipelinedetails = plcRepository.Find(x => x.plcdetail_iotype == Pipelineplc.plcinfo_iotyep && x.plcdetail_number == Stationinfo.stationCode).ToList();
                            var PalletSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_PalletSignal").First(), Pipeline_client);//读取托盘信号:1:有,2无
                            //var MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), Pipeline_client);//读取货物信号:1:有,2无
                            //var Wheel_id = client.ReadByOrder<string>("R_Wheel_id", name);
                            if (PalletSignal == 1)
                            {
                                var SNS = Stationinfo.bindSN.Split(",");
                                List<string> list = new List<string>();
                                foreach (var SN in SNS)
                                if (Stationinfo.bindSN != null)
                                {
                                    if (!string.IsNullOrEmpty(SN))
                                        list.Add(SN);
                                    var SNS = Stationinfo.bindSN.Split(",");
                                    foreach (var SN in SNS)
                                    {
                                        if (!string.IsNullOrEmpty(SN))
                                            list.Add(SN);
                                    }
                                }
                                //缓存架上车轮数量与SN号数量不一致
                                if (list.Count != Stationinfo.quantity)
                                {
                                    Stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
                                    Stationinfo.remark = "车轮数量与SN号数量不一致";
                                    stationinfoRepository.Update(Stationinfo, true);
                                    continue;
                                    //写入桁架报警信号
                                    throw new Exception("下料位车轮数量与SN号数量不一致,下料位编号:" + Stationinfo.stationCode);
                                    //throw new Exception("下料位车轮数量与SN号数量不一致,下料位编号:" + Stationinfo.stationCode);
                                }
                                var area = Convert.ToInt16(Stationinfo.stationCode.Substring(Stationinfo.stationCode.Length - 1, 1));
                                client.WriteByOrder("W_AreaNr", (Int16)area, name);//区域货位号
                                client.WriteByOrder("W_IndexNr", (Int16)(Stationinfo.quantity + 1), name);//托盘上的第几个车轮
                                client.WriteByOrder("W_Storage_Type", (Int16)1, name);//托盘类型1-横放;2-竖放(暂时只有横放托盘)
                                client.WriteByOrder("W_Enabl_Load", true, name);//是否允许
                                #region æ—¥å¿—记录
                                WriteDBLog.Success(name + "放料申请", $"读取桁架信息:\n车轮SN:{Wheel_id}\n轮型ID:{Wheel_Type}\n车轮状态:OK" +
                                    $"\n读取托盘光电信号:{PalletSignal}" +
                                    $"\n\n写入桁架信息:\n下料位号:{area}\n第几个车轮:{(Stationinfo.quantity + 1)}\n托盘类型:1\nW_Enabl_Load:true", "PCS");
                                #endregion
                                return;
                            }
                        }
@@ -296,32 +471,54 @@
                        && x.tray_type == (wheel.e < 1100 ? "SmallTray" : "LargeTray")
                        && x.Number == mes_Detail.jobID
                        && x.heatNumber == mes_Detail.heatID).FirstOrDefault();
                        if (Stationinfo == null)
                            Stationinfo = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault();
                        if (Stationinfo != null)
                        {
                            #region æ‰˜ç›˜ç±»åž‹ä¸ä¸€è‡´éœ€æ›´æ¢æ‰˜ç›˜
                            if (Stationinfo.tray_type != (wheel.e < 1100 ? "SmallTray" : "LargeTray"))
                            {
                                Stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
                                Stationinfo.tray_type = Stationinfo.tray_type == "SmallTray" ? "SmallTray/LargeTray" : "LargeTray/SmallTray";
                                Stationinfo.remark = "托盘类型不一致需更换托盘";
                                stationinfoRepository.Update(Stationinfo, true);
                            }
                            #endregion
                            var Pipelinedetails = plcRepository.Find(x => x.plcdetail_iotype == Pipelineplc.plcinfo_iotyep && x.plcdetail_number == Stationinfo.stationCode).ToList();
                            var PalletSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读取托盘信号:1:有,2无
                            var PalletSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_PalletSignal").First(), Pipeline_client);//读取托盘信号:1:有,2无
                            if (PalletSignal == 1)
                            {
                                var SNS = Stationinfo.bindSN.Split(",");
                                List<string> list = new List<string>();
                                foreach (var SN in SNS)
                                if (Stationinfo.bindSN != null)
                                {
                                    if (!string.IsNullOrEmpty(SN))
                                        list.Add(SN);
                                    foreach (var SN in SNS)
                                    {
                                        if (!string.IsNullOrEmpty(SN))
                                            list.Add(SN);
                                    }
                                }
                                //缓存架上车轮数量与SN号数量不一致
                                if (list.Count != Stationinfo.quantity)
                                {
                                    Stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
                                    Stationinfo.remark = "车轮数量与SN号数量不一致";
                                    stationinfoRepository.Update(Stationinfo, true);
                                    continue;
                                    //写入桁架报警信号
                                    throw new Exception("下料位车轮数量与SN号数量不一致,下料位编号:" + Stationinfo.stationCode);
                                    //throw new Exception("下料位车轮数量与SN号数量不一致,下料位编号:" + Stationinfo.stationCode);
                                }
                                var area = Convert.ToInt16(Stationinfo.stationCode.Substring(Stationinfo.stationCode.Length - 1, 1));
                                client.WriteByOrder("W_AreaNr", (Int16)area, name);//区域货位号
                                client.WriteByOrder("W_IndexNr", (Int16)(Stationinfo.quantity + 1), name);//托盘上的第几个车轮
                                client.WriteByOrder("W_Storage_Type", (Int16)1, name);//托盘类型1-横放;2-竖放(暂时只有横放托盘)
                                client.WriteByOrder("W_Enabl_Load", true, name);//是否允许
                                #region æ—¥å¿—记录
                                WriteDBLog.Success(name + "放料申请", $"读取桁架信息:\n车轮SN:{Wheel_id}\n轮型ID:{Wheel_Type}\n车轮状态:NG" +
                                    $"\n读取托盘光电信号:{PalletSignal}" +
                                    $"\n\n写入桁架信息:\n下料位号:{area}\n第几个车轮:{(Stationinfo.quantity + 1)}\n托盘类型:1\nW_Enabl_Load:true", "PCS");
                                #endregion
                                return;
                            }
                        }
@@ -348,28 +545,7 @@
                    //    StationCodes = new List<string>() { "X03001001", "X03001002" };
                    #endregion
                    var finished = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_load_finished").First(), client);//放料完成
                    var updatefinished = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Storage_update").First(), client);//货位状态更新
                    if (!finished && updatefinished)
                        client.WriteByOrder("W_Storage_update", false, name);//货位状态更新
                    if (finished && !updatefinished)
                    {
                        var AreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_AreaNr").First(), client);
                        var station = stationinfoRepository.FindFirst(x => x.stationCode.Substring(x.stationCode.Length - 1, 1) == AreaNr.ToString());
                        station.quantity = station.quantity++;
                        station.bindSN = station.bindSN == string.Empty ? Wheel_id : station.bindSN + "," + Wheel_id;
                        if (station.quantity == 0)
                        {
                            station.stationType = mes_Head.drawingNo;
                            station.Number = mes_Head.jobID;
                            station.heatNumber = mes_Detail.heatID;
                        }
                        var count = stationinfoRepository.Update(station);
                        if (count < 1)
                            throw new Exception($"下料位信息更新失败!下料位编号:{station.stationCode}");
                        client.WriteByOrder("W_Storage_update", true, name);//货位状态更新
                        client.WriteByOrder("W_Enabl_Load", false, name);//是否允许
                    }
                    #region
                    //for (int i = 0; i < StationCodes.Count - 1; i++)
                    //{
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs
@@ -33,10 +33,11 @@
            //throw new NotImplementedException();
            //Creation.HCJCreation();
            //Creation.PLCinfodetail();
            //StationTask.CreateTask();
            //OutboundTask.CreateOutboundTask();
            //ReplaceTray.a();
            StationTask.CreateTask();
            OutboundTask.CreateOutboundTask();
            ReplaceTray.ReplaceTrayTask();
            RestockHCJ.HCJGetBarcode();
        }
    }
}
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/GantryJob.cs
@@ -42,8 +42,8 @@
                return;
            }
            Gantry gantry = new Gantry();
            gantry.QueryWheeldata(client);
            gantry.QueryOrder(client);
            gantry.QueryWheeldata(client);
            gantry.Layofflevel(client);
        }
    }
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs
@@ -90,7 +90,7 @@
                //缓存架未启用禁止桁架进入
                foreach (var station in Stations)
                {
                    if (!station.enable)
                    if (!station.enable || station.location_state != LocationStateEnum.Stroge.ToString())
                        Gantry_client.WriteByOrder("W_RequestUnload", false, number);//信号为false桁架停止进入
                }
@@ -108,9 +108,14 @@
                    if (list.Count != Station.quantity)
                    {
                        Station.location_state = LocationStateEnum.Abnormal.ToString();
                        Station.remark = "车轮数量与SN号数量不一致";
                        stationinfoRepository.Update(Station, true);
                        Gantry_client.WriteByOrder("W_RequestUnload", false, number);//信号为false桁架停止进入
                        throw new Exception("上料位车轮数量与SN号数量不一致,上料位编号:" + Station.stationCode);
                        #region æ—¥å¿—记录
                        WriteDBLog.Error("上料区", $"写入桁架信息:\nW_RequestUnload:false\n\n{Station.stationCode}车轮数量与SN号数量不一致", "PCS");
                        #endregion
                        return;
                        //throw new Exception("上料位车轮数量与SN号数量不一致,上料位编号:" + Station.stationCode);
                    }
                    var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == Station.stationCode).ToList();
                    var PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读取托盘信号:1:有,2无
@@ -124,6 +129,11 @@
                        Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)Convert.ToInt16(QueryMateriel(Station.stationType).TypeId), number);//车轮类型
                        Gantry_client.WriteByOrder("W_Wheel_id", SNS[SNS.Length - 1], number);//车轮SN号
                        Gantry_client.WriteByOrder("W_RequestUnload", true, number);
                        #region æ—¥å¿—记录
                        WriteDBLog.Success("上料区申请", $"读取托盘光电信号:{PalletSignal}\n读取第一个车轮光电信号:{MaterialSignal}\n\n" +
                            $"写入桁架信息:\n区域货位号:{area}\n托盘上的第几个车轮:{SNS.Length}\n托盘类型:{1}\n车轮类型:{QueryMateriel(Station.stationType).TypeId}" +
                            $"\n车轮SN号:{SNS[SNS.Length - 1]}\nW_RequestUnload:true", "PCS");
                        #endregion
                    }
                    else
                    {
@@ -140,9 +150,12 @@
                        if (!Date_Vaild)//信息有误,记录日志
                        {
                            Station.location_state = LocationStateEnum.Abnormal.ToString();
                            Station.remark = $"未查询到SN号:{SNS[SNS.Length - 1]}的订单";
                            stationinfoRepository.Update(Station, true);
                            Gantry_client.WriteByOrder("W_RequestUnload", false, number);//信号为false桁架停止进入
                            throw new Exception($"未查询到SN号:{SNS[SNS.Length - 1]}的订单,上料位编号:{Station.stationCode}");
                            //throw new Exception($"未查询到SN号:{SNS[SNS.Length - 1]}的订单,上料位编号:{Station.stationCode}");
                            WriteDBLog.Error("上料区信息查询", $"写入桁架信息:\nW_RequestUnload:false\n\n{Station.stationCode}未查询到SN号:{SNS[SNS.Length - 1]}的订单", "PCS");
                            return;
                        }
                    }
                    var finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client);//夹取完成
@@ -162,9 +175,16 @@
                        }
                        var count = stationinfoRepository.Update(Station, true);
                        if (count < 1)
                            throw new Exception($"上料位信息更新失败!上料位编号:{Station.stationCode}");
                        {
                            WriteDBLog.Error("取料完成", $"上料位信息更新失败!上料位编号:{Station.stationCode}", "PCS");
                            //throw new Exception($"上料位信息更新失败!上料位编号:{Station.stationCode}");
                            return;
                        }
                        Gantry_client.WriteByOrder("W_Storage_update", true, number);//货位状态更新
                        Gantry_client.WriteByOrder("W_RequestUnload", false, number);//信号为false桁架停止进入
                        #region æ—¥å¿—记录
                        WriteDBLog.Success("取料完成", $"写入桁架信息:\n货位状态更新:{true}\nW_RequestUnload:{false}", "PCS");
                        #endregion
                        //finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client);
                        //while (finished)
                        //{
@@ -176,6 +196,8 @@
                    //    Gantry_client.WriteByOrder("W_Storage_update", false, number);//货位状态更新
                }
                else
                    Gantry_client.WriteByOrder("W_RequestUnload", false, number);//信号为false桁架停止进入
            }
            catch (Exception ex)
            {
@@ -197,13 +219,13 @@
            return Newsn;
        }
        public static dt_geometry_data QueryMateriel(string type)
        {
        {
            VOLContext Context = new VOLContext();
            Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context);
            var materielinfo = dataRepository.FindFirst(x => x.Description == type);
            var materielinfo = dataRepository.Find(x => x.Description == type).OrderBy(x => x.TypeId).FirstOrDefault();
            return materielinfo;
        }
        public static string QueryMateriel(int  typeId)
        public static string QueryMateriel(int typeId)
        {
            VOLContext Context = new VOLContext();
            Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context);
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/OutboundTask.cs
@@ -31,53 +31,162 @@
                var mes_heads = freeDB.Select<dt_mes_head>().Where(x => x.processCode == "28").OrderBy(x => x.expectedStartTime).ToList();
                foreach (var mes_head in mes_heads)
                {
                    //var inventorys = freeDB.Select<dt_inventory>().Where(x => x.FigureNumber == mes_head.drawingNo).OrderBy.ToList();
                    var station = stationinfoRepository.Find(x => x.stationType == mes_head.drawingNo && x.line != x.line).OrderBy(x => x.line).ThenByDescending(x => x.column).FirstOrDefault();
                    bool ok = false;
                    List<string> list = new List<string>();
                    if (station != null && station.location_state == LocationStateEnum.Stroge.ToString() && station.enable)
                    #region æ ¹æ®åº“存入库时间最晚查询
                    var inventory = freeDB.Select<dt_inventory>().Where(x => x.FigureNumber == mes_head.drawingNo).OrderByDescending(x => x.OnlineTime).First();
                    if (inventory != null)
                    {
                        var SNS = station.bindSN.Split(",");
                        foreach (var SN in SNS)
                        var Station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault();
                        if (Station != null)
                        {
                            if (!string.IsNullOrEmpty(SN))
                                list.Add(SN);
                            var stationinfo = stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.enable).OrderByDescending(x => x.column).FirstOrDefault();
                            if (stationinfo != null)
                            {
                                if (stationinfo.bindSN == null)
                                    throw new Exception(stationinfo.stationCode + "车轮SN号信息异常!");
                                List<string> lists = new List<string>();
                                var SNS = stationinfo.bindSN.Split(",");
                                foreach (var SN in SNS)
                                {
                                    if (!string.IsNullOrEmpty(SN))
                                        lists.Add(SN);
                                }
                                foreach (var item in lists)
                                {
                                    if (freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mes_head.jobID && x.SN == item).Any())
                                    {
                                        dt_agvtask agvtask = new dt_agvtask()
                                        {
                                            agv_fromaddress = stationinfo.stationCode,
                                            agv_id = Guid.NewGuid(),
                                            agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                                            agv_grade = 1,
                                            agv_createtime = DateTime.Now,
                                            agv_taskstate = "Queue",
                                            agv_materielid = stationinfo.stationType,
                                            agv_qty = stationinfo.quantity,
                                            agv_tasktype = "TaskType_Outbound",
                                            agv_toaddress = "",
                                            agv_userid = "系统",
                                            bindSN = stationinfo.bindSN,
                                            agv_worktype = Convert.ToInt32(mes_head.processCode),
                                            agv_materbarcode = mes_head.materialCode,
                                            agv_Traytype = stationinfo.tray_type,
                                            agv_TrayStatus = stationinfo.tray_status
                                        };
                                        dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository);
                                        if (TargetLocation != null)
                                        {
                                            agvtask.agv_taskstate = "Create";
                                            agvtask.agv_toaddress = TargetLocation.stationCode;
                                            TargetLocation.location_state = LocationStateEnum.Busy.ToString();
                                            freeDB.Update(TargetLocation);
                                        }
                                        freeDB.Add(agvtask);
                                        return;
                                    }
                                }
                            }
                            stationinfo = stationinfoRepository.Find(x => x.stationType == mes_head.drawingNo && x.line != Station.line).OrderBy(x => x.line).ThenByDescending(x => x.column).FirstOrDefault();
                            if (stationinfo != null && stationinfo.enable)
                            {
                                if (stationinfo.bindSN == null)
                                    throw new Exception(stationinfo.stationCode + "车轮SN号信息异常!");
                                List<string> lists = new List<string>();
                                var SNS = stationinfo.bindSN.Split(",");
                                foreach (var SN in SNS)
                                {
                                    if (!string.IsNullOrEmpty(SN))
                                        lists.Add(SN);
                                }
                                foreach (var item in lists)
                                {
                                    if (freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mes_head.jobID && x.SN == item).Any())
                                    {
                                        dt_agvtask agvtask = new dt_agvtask()
                                        {
                                            agv_fromaddress = stationinfo.stationCode,
                                            agv_id = Guid.NewGuid(),
                                            agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                                            agv_grade = 1,
                                            agv_createtime = DateTime.Now,
                                            agv_taskstate = "Queue",
                                            agv_materielid = stationinfo.stationType,
                                            agv_qty = stationinfo.quantity,
                                            agv_tasktype = "TaskType_Outbound",
                                            agv_toaddress = "",
                                            agv_userid = "系统",
                                            bindSN = stationinfo.bindSN,
                                            agv_worktype = Convert.ToInt32(mes_head.processCode),
                                            agv_materbarcode = mes_head.materialCode,
                                            agv_Traytype = stationinfo.tray_type,
                                            agv_TrayStatus = stationinfo.tray_status
                                        };
                                        dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository);
                                        if (TargetLocation != null)
                                        {
                                            agvtask.agv_taskstate = "Create";
                                            agvtask.agv_toaddress = TargetLocation.stationCode;
                                            TargetLocation.location_state = LocationStateEnum.Busy.ToString();
                                            freeDB.Update(TargetLocation);
                                        }
                                        freeDB.Add(agvtask);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    foreach (var SN in list)
                    {
                        if (ok = freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mes_head.jobID && x.SN == SN).Any()) continue;
                    }
                    if (ok)
                    {
                        dt_agvtask agvtask = new dt_agvtask()
                        {
                            agv_fromaddress = station.stationCode,
                            agv_id = Guid.NewGuid(),
                            agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                            agv_grade = 1,
                            agv_createtime = DateTime.Now,
                            agv_taskstate = "Queue",
                            agv_materielid = station.stationType,
                            agv_qty = station.quantity,
                            agv_tasktype = "TaskType_Outbound",
                            agv_toaddress = "",
                            agv_userid = "系统",
                            bindSN = station.bindSN,
                            agv_worktype = Convert.ToInt32(mes_head.processCode),
                            agv_materbarcode = mes_head.materialCode,
                            agv_barcode = station.tray_type
                        };
                        dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository);
                        if (TargetLocation != null)
                        {
                            agvtask.agv_taskstate = "Create";
                            agvtask.agv_toaddress = TargetLocation.stationCode;
                            TargetLocation.location_state = LocationStateEnum.Busy.ToString();
                            freeDB.Update(TargetLocation);
                        }
                        freeDB.Add(agvtask);
                    }
                    #endregion
                    #region MyRegion
                    //var station = stationinfoRepository.Find(x => x.stationType == mes_head.drawingNo && x.line != x.line).OrderBy(x => x.line).ThenByDescending(x => x.column).FirstOrDefault();
                    //bool ok = false;
                    //List<string> list = new List<string>();
                    //if (station != null && station.location_state == LocationStateEnum.Stroge.ToString() && station.enable)
                    //{
                    //    var SNS = station.bindSN.Split(",");
                    //    foreach (var SN in SNS)
                    //    {
                    //        if (!string.IsNullOrEmpty(SN))
                    //            list.Add(SN);
                    //    }
                    //}
                    //foreach (var SN in list)
                    //{
                    //    if (ok = freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mes_head.jobID && x.SN == SN).Any()) continue;
                    //}
                    //if (ok)
                    //{
                    //    dt_agvtask agvtask = new dt_agvtask()
                    //    {
                    //        agv_fromaddress = station.stationCode,
                    //        agv_id = Guid.NewGuid(),
                    //        agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                    //        agv_grade = 1,
                    //        agv_createtime = DateTime.Now,
                    //        agv_taskstate = "Queue",
                    //        agv_materielid = station.stationType,
                    //        agv_qty = station.quantity,
                    //        agv_tasktype = "TaskType_Outbound",
                    //        agv_toaddress = "",
                    //        agv_userid = "系统",
                    //        bindSN = station.bindSN,
                    //        agv_worktype = Convert.ToInt32(mes_head.processCode),
                    //        agv_materbarcode = mes_head.materialCode,
                    //        agv_barcode = station.tray_type
                    //    };
                    //    dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository);
                    //    if (TargetLocation != null)
                    //    {
                    //        agvtask.agv_taskstate = "Create";
                    //        agvtask.agv_toaddress = TargetLocation.stationCode;
                    //        TargetLocation.location_state = LocationStateEnum.Busy.ToString();
                    //        freeDB.Update(TargetLocation);
                    //    }
                    //    freeDB.Add(agvtask);
                    //}
                    #endregion
                }
            }
            catch (Exception)
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/ReplaceTray.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,121 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm;
using WIDESEA_Comm.TaskNo;
using WIDESEA_Core.FreeDB;
using WIDESEA_Entity.DomainModels;
using WIDESEA_WCS.JobsPart.Common.存储过程;
using static FreeSql.Internal.GlobalFilter;
using static System.Collections.Specialized.BitVector32;
namespace WIDESEA_WCS.JobsPart.Common
{
    public class ReplaceTray
    {
        static FreeDB freeDB = new FreeDB();
        public static void a()
        {
            var mes_Detail = freeDB.Select<dt_mes_detail>().Where(x => x.SN == "1202956016").First();
            var mes_Head = freeDB.Select<dt_mes_head>().Where(x => x.jobID == mes_Detail.jobID).First();
            dt_inventory inventory = new dt_inventory()
            {
                SN = mes_Detail.SN,
                Name = mes_Head.productName,
                FigureNumber = mes_Head.drawingNo,
                area = "2",
                HeatNumber = mes_Detail.heatID,
                BilletNumber = mes_Detail.billetID,
                OnlineTime = DateTime.Now,
                Operator = "AGV",
                stationCode = "B01001001",
                jobID = mes_Detail.jobID,
                ID = Guid.NewGuid(),
                remark=""
            };
            StoredProcedure.EXEC( inventory,"");
        }
        /// <summary>
        /// åˆ›å»ºæ›´æ¢æ‰˜ç›˜ä»»åŠ¡
        /// </summary>
        public static void ReplaceTrayTask()
        {
            try
            {
                var stations = freeDB.Select<dt_stationinfo>().Where(x => x.stationCode.Contains("X") && x.location_state == LocationStateEnum.Abnormal.ToString() && (x.tray_type == "SmallTray/LargeTray" || x.tray_type == "LargeTray/SmallTray")).ToList();
                foreach (var station in stations)
                {
                    var types = station.tray_type.Split('/');
                    var area = types[0] == "SmallTray" ? "11" : "10";
                    //找1库区的空托位
                    var EmptyStation = freeDB.Select<dt_stationinfo>().Where(x => x.area == area && x.stationCode.Contains("A") && x.location_state == "Empty" && x.enable)
                        .OrderBy(x => x.column).OrderByDescending(x => x.line).First();
                    if (EmptyStation == null)
                        EmptyStation = freeDB.Select<dt_stationinfo>().Where(x => x.area == area && x.stationCode.Contains("C") && x.location_state == "Empty" && x.enable)
                        .OrderBy(x => x.line).OrderBy(x => x.column).First();
                    if (EmptyStation != null)
                    {
                        dt_agvtask agvtask = new dt_agvtask()
                        {
                            agv_fromaddress = station.stationCode,
                            agv_id = Guid.NewGuid(),
                            agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                            agv_grade = 2,
                            agv_createtime = DateTime.Now,
                            agv_taskstate = "Create",
                            //agv_materielid = station.stationType,
                            agv_qty = 1,
                            agv_tasktype = "TaskType_EmptyPallet",
                            agv_toaddress = EmptyStation.stationCode,
                            agv_userid = "系统",
                            agv_TrayStatus = station.tray_status,
                            //bindSN = station.bindSN,
                            //agv_worktype = Convert.ToInt32(mesinfo.processCode),
                            //agv_materbarcode = mesinfo.materialCode,
                            agv_Traytype = types[0]
                        };
                        freeDB.Add(agvtask);
                        CreatePartQueue(agvtask, types[1]);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// åˆ›å»ºå®Œæ•´çš„补空托任务
        /// </summary>
        /// <param name="agvtask"></param>
        public static void CreatePartQueue(dt_agvtask agvtask, string type = "")
        {
            if (agvtask.agv_fromaddress.Contains("X"))
            {
                dt_agvtask taskPart = new dt_agvtask()
                {
                    agv_fromaddress = "",
                    agv_id = Guid.NewGuid(),
                    agv_tasknum = agvtask.agv_tasknum + "_1",
                    agv_grade = 2,
                    agv_createtime = DateTime.Now,
                    agv_taskstate = "Queue",
                    agv_qty = 1,
                    agv_tasktype = "TaskType_EmptyPallet",
                    agv_toaddress = agvtask.agv_fromaddress,
                    agv_userid = "系统",
                    agv_TrayStatus = agvtask.agv_TrayStatus,
                    agv_Traytype = type
                };
                freeDB.Add(taskPart);
            }
        }
    }
}
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm;
using WIDESEA_Core.FreeDB;
using WIDESEA_Entity.DomainModels;
namespace WIDESEA_WCS.JobsPart.Common
{
    public class RestockHCJ
    {
        static FreeDB freeDB = new FreeDB();
        public static Dictionary<string, List<string>> areaForList;
        public RestockHCJ()
        {
            if (areaForList == null || areaForList.Count == 0)
            {
                areaForList = new Dictionary<string, List<string>>();
                var stationList = freeDB.Select<dt_stationinfo>().Where(x => true).ToList();
                areaForList.Add("下料区", stationList.Where(x => x.stationCode.Contains("X")).Select(x => x.stationCode).ToList());
            }
        }
        /// <summary>
        /// æ›´æ–°è¡¥ç©ºæ‰˜ä»»åŠ¡
        /// </summary>
        public static void HCJGetBarcode()
        {
            var tasks = freeDB.Select<dt_agvtask>().Where(x => x.agv_taskstate == "Queue").ToList();
            foreach (var task in tasks)
            {
                if (task.agv_tasktype == "TaskType_EmptyPallet")//空托任务
                {
                    if (task.agv_fromaddress == "")
                    {
                        var area = task.agv_Traytype == "SmallTray" ? "11" : "10";
                        //找1库区的空托位
                        var EmptyStation = freeDB.Select<dt_stationinfo>().Where(x => x.area == area && x.stationCode.Contains("A") && x.location_state == LocationStateEnum.Stroge.ToString() && x.enable)
                            .OrderByDescending(x => x.column).OrderBy(x => x.line).First();
                        if (EmptyStation == null)
                            EmptyStation = freeDB.Select<dt_stationinfo>().Where(x => x.area == area && x.stationCode.Contains("C") && x.location_state == LocationStateEnum.Stroge.ToString() && x.enable)
                            .OrderBy(x => x.line).OrderByDescending(x => x.column).First();
                        if (EmptyStation != null)
                        {
                            task.agv_fromaddress = EmptyStation.stationCode;
                            task.agv_taskstate = "Create";
                            freeDB.Update(task);
                        }
                    }
                }
            }
        }
    }
}
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs
@@ -29,7 +29,7 @@
                Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
                Idt_WorkinfoRepository workinfoRepository = new dt_WorkinfoRepository(context);
                List<dt_stationinfo> stationinfos = stationinfoRepository.Find(x => x.stationCode.Contains('X'));
                List<dt_stationinfo> stationinfos = freeDB.Select<dt_stationinfo>().Where(x => x.stationCode.Contains("X") && x.quantity > 0 && !string.IsNullOrEmpty(x.stationType)).ToList();
                foreach (var item in stationinfos)
                {
@@ -70,7 +70,8 @@
                                    bindSN = item.bindSN,
                                    agv_worktype = Convert.ToInt32(mesinfo.processCode),
                                    agv_materbarcode = mesinfo.materialCode,
                                    agv_barcode=item.tray_type
                                    agv_Traytype = item.tray_type,
                                    agv_TrayStatus = item.tray_status
                                };
                                freeDB.Add(agvtask);
@@ -101,7 +102,8 @@
                                    bindSN = item.bindSN,
                                    agv_worktype = Convert.ToInt32(mesinfo.processCode),
                                    agv_materbarcode = mesinfo.materialCode,
                                    agv_barcode=item.tray_type
                                    agv_Traytype = item.tray_type,
                                    agv_TrayStatus = item.tray_status
                                };
                                freeDB.Add(agvtask);
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/VV_DispatchService.cs
@@ -69,13 +69,13 @@
                    {
                        if (cooRes.Status)
                        {
                            WriteDBLog.Success($"开启服务", new { æ•°æ® = "服务启动成功!" }, "PCS", UserContext.Current.UserTrueName);
                            WriteDBLog.Success($"开启服务", new { æ•°æ® = "服务启动成功!" }, "PCS", UserContext.Current.UserName);
                            return webResponse.OK("服务启动成功!");
                        }
                        else
                        {
                            //返回PLC异常
                            WriteDBLog.Error($"开启服务", new { æ•°æ® = cooRes }, "PCS", UserContext.Current.UserTrueName);
                            WriteDBLog.Error($"开启服务", new { æ•°æ® = cooRes }, "PCS", UserContext.Current.UserName);
                            return cooRes;
                        }
                    }
@@ -83,7 +83,7 @@
                    {
                        //调度启动失败,关闭全部
                        //WriteLog.Write_Log("服务", "服务", "启动服务\n[调度异常]" + startRes.Message);
                        WriteDBLog.Error($"开启服务", new { æ•°æ® = startRes.Message }, "PCS", UserContext.Current.UserTrueName);
                        WriteDBLog.Error($"开启服务", new { æ•°æ® = startRes.Message }, "PCS", UserContext.Current.UserName);
                        return startRes;
                    }
                }
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs
@@ -192,7 +192,7 @@
            else if (typeof(DataType) == typeof(string))//字符串
            {
                var str = GetContent(siemensPLCClient.ReadString(item.dbAddress, (ushort)item.dataLen), item).ToString();
                str = str.Replace("\0", "")?.Replace("\\", "")?.Replace("\u0014", "")?.Replace("?\u0006", "");
                str = str.Replace("\0", "")?.Replace("\\", "")?.Replace("\u0014", "")?.Replace("?\u0006", "")?.Replace("\n","")?.Trim();
                return (DataType)(str as object);
            }
            else
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WebApi/appsettings.json
@@ -37,7 +37,7 @@
  },
  //================跨域请求 (CORS)配置(2019-12-20新增),
  //================.netcore3.1必须配置此属性,多个url用豆号隔开,url为vue站点的地址,可以将发布后的地址也同时配置上
  "CorsUrls": "http://localhost:8081,http://localhost:8080,http://localhost:7080,http://localhost:9980,http://127.0.0.1:9980,http://localhost:9990,http://www.volcore.xyz",
  "CorsUrls": "http://localhost:8081,http://localhost:8080,http://localhost:7080,http://localhost:9980,http://127.0.0.1:9980,http://192.168.12.101:8099,http://localhost:9990,http://www.volcore.xyz",
  "ExpMinutes": "120", //JWT有效期(分钟=默认120),
  "CreateMember": { //对表插入数据时,需要记录创建人/创建时间/创建日期,配置UserIdField/UserNameField/DateField分别为对应数据库的创建人CreateID,创建人Creator,创建时间CreateDate字段(新建数据时,由框架默认完成给这几个字段赋值,字段区分大小写)或可手动调用T.SetCreateDefaultVal()完成设置创建人/创建时间/创建日期
    //如果表的主键是GUID,界面查询时默认会用到DateField对应的实体(数据库)字段进行排序
´úÂë¹ÜÀí/WMS/WMS_Client/src/api/http.js
@@ -15,11 +15,11 @@
    axios.defaults.baseURL = 'http://127.0.0.1:8098/';
}
else if (process.env.NODE_ENV == 'debug') {
    axios.defaults.baseURL = 'http://127.0.0.1:8098/';
    axios.defaults.baseURL = 'http://192.168.12.101:8098/';
}
else if (process.env.NODE_ENV == 'production') {
    axios.defaults.baseURL = 'http://127.0.0.1:8098/';
    axios.defaults.baseURL = 'http://192.168.12.101:8098/';
}
if (!axios.defaults.baseURL.endsWith('/')) {
    axios.defaults.baseURL+="/";
´úÂë¹ÜÀí/WMS/WMS_Client/src/views/widesea_wms/system/dt_stationinfo.vue
@@ -44,19 +44,19 @@
                       {field:'stationCode',title:'缓存架编号',type:'string',width:110,align:'left',sort:true},
                       {field:'stationType',title:'图号',type:'string',bind:{ key:'materielinfos',data:[]},width:110,align:'left'},
                       {field:'area',title:'区域',type:'string',bind:{ key:'area_name',data:[]},width:110,require:true,align:'left'},
                       {field:'enable',title:'是否启用',type:'bool',bind:{ key:'status',data:[]},width:110,require:true,align:'left'},
                       {field:'location_state',title:'货位状态',type:'string',bind:{ key:'location_states',data:[]},width:220,align:'left'},
                       {field:'enable',title:'是否启用',type:'bool',bind:{ key:'status',data:[]},width:80,require:true,align:'left'},
                       {field:'location_state',title:'货位状态',type:'string',bind:{ key:'location_states',data:[]},width:80,align:'left'},
                    //    {field:'lastUpdateTime',title:'最后状态改变时间',type:'datetime',width:150,align:'left',sort:true},
                       {field:'quantity',title:'车轮数量',type:'int',width:80,align:'left'},
                       {field:'bindSN',title:'车轮SN号',type:'string',width:220,align:'left'},
                       {field:'tray_status',title:'托盘状态',type:'string',bind:{ key:'tray_status',data:[]},width:110,align:'left'},
                       {field:'tray_type',title:'托盘类型',type:'string',bind:{ key:'tray_types',data:[]},width:110,align:'left'},
                       {field:'tray_status',title:'托盘状态',type:'string',bind:{ key:'tray_status',data:[]},width:80,align:'left'},
                       {field:'tray_type',title:'托盘类型',type:'string',bind:{ key:'tray_types',data:[]},width:120,align:'left'},
                    //    {field:'line',title:'行',type:'int',width:80,align:'left'},
                    //    {field:'column',title:'列',type:'int',width:80,align:'left'},
                    {field:'heatNumber',title:'炉号',type:'int',width:80,align:'left'},
                    //    {field:'zj',title:'主键',type:'int',width:80,hidden:true,require:true,align:'left'},
                       {field:'Number',title:'工单编号',type:'string',width:220,align:'left'},
                       {field:'remark',title:'备注',type:'string',width:120,align:'left'}]);
                       {field:'remark',title:'备注',type:'string',width:220,align:'left'}]);
            const detail = ref({
                cnName: "#detailCnName",
                table: "#detailTable",
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask.cs
@@ -57,12 +57,21 @@
        /// <summary>
        ///AGV编号
        /// </summary>
        [Display(Name = "AGV编号")]
        //[Display(Name = "AGV编号")]
        //[MaxLength(50)]
        //[Column(TypeName = "nvarchar(50)")]
        //[Editable(true)]
        //[Required(AllowEmptyStrings = false)]
        //public string agv_code { get; set; }
        /// <summary>
        ///托盘状态
        /// </summary>
        [Display(Name = "托盘状态")]
        [MaxLength(50)]
        [Column(TypeName = "nvarchar(50)")]
        [Editable(true)]
        [Required(AllowEmptyStrings = false)]
        public string agv_code { get; set; }
        //[Required(AllowEmptyStrings = false)]
        public string agv_TrayStatus { get; set; }
        /// <summary>
        ///任务状态
@@ -163,14 +172,14 @@
        public string agv_userid { get; set; }
        /// <summary>
        ///托盘码
        ///托盘类型/托盘码
        /// </summary>
        [Display(Name = "托盘码")]
        [MaxLength(30)]
        [Column(TypeName = "nvarchar(30)")]
        [Editable(true)]
        //[Required(AllowEmptyStrings = false)]//不能为空
        public string agv_barcode { get; set; }
        public string agv_Traytype { get; set; }
        /// <summary>
        ///物料码
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_Entity/DomainModels/Taskinfo/dt_agvtask_hty.cs
@@ -174,24 +174,33 @@
        public string agv_userid { get; set; }
        /// <summary>
        ///托盘码
        ///托盘类型/托盘码
        /// </summary>
        [Display(Name = "托盘码")]
        [MaxLength(30)]
        [Column(TypeName = "nvarchar(30)")]
        [Editable(true)]
        //[Required(AllowEmptyStrings = false)]
        public string agv_barcode { get; set; }
        public string agv_Traytype { get; set; }
        /// <summary>
        ///AGV编号
        /// </summary>
        [Display(Name = "AGV编号")]
        //[Display(Name = "AGV编号")]
        //[MaxLength(50)]
        //[Column(TypeName = "nvarchar(50)")]
        //[Editable(true)]
        ////[Required(AllowEmptyStrings = false)]
        //public string agv_code { get; set; }
        /// <summary>
        ///托盘状态
        /// </summary>
        [Display(Name = "托盘状态")]
        [MaxLength(50)]
        [Column(TypeName = "nvarchar(50)")]
        [Editable(true)]
        //[Required(AllowEmptyStrings = false)]
        public string agv_code { get; set; }
        public string agv_TrayStatus { get; set; }
        /// <summary>
        ///工单类型
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs
@@ -62,7 +62,7 @@
                    requestTask.Material = agv_task.agv_materielid;
                    requestTask.Grade = agv_task.agv_grade;
                    requestTask.Quantity = agv_task.agv_qty;
                    requestTask.TrayType = agv_task.agv_barcode.Contains("Small") ? 1 : 2;//
                    requestTask.TrayType = agv_task.agv_Traytype.Contains("Small") ? 1 : 2;//
                    requestTask.TaskType = agv_task.agv_tasktype.Contains("TaskType_EmptyPallet") ? 2 : 1;//
                    requestTask.A = Materiel.a;
                    requestTask.B = Materiel.b;
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask.cs
@@ -49,8 +49,8 @@
                agv_completedate = DateTime.Now,
                agv_grade = task.agv_grade,
                agv_userid = task.agv_userid,
                agv_barcode = task.agv_barcode,
                agv_code = task.agv_code,
                agv_Traytype = task.agv_Traytype,
                agv_TrayStatus = task.agv_TrayStatus,
                agv_worktype = task.agv_worktype,
                agv_remark = task.agv_remark,
                bindSN = task.bindSN,
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs
@@ -80,7 +80,8 @@
                agvtask.agv_fromaddress = fromaddress;
                agvtask.agv_toaddress = toaddress;
                agvtask.agv_tasknum = IdenxManager.GetTaskNo("KH-");
                agvtask.agv_code = "AGV";
                agvtask.agv_TrayStatus = station1.tray_status;
                agvtask.agv_Traytype = station1.tray_type;
                agvtask.agv_taskstate = AGVTaskStateEnum.Create.ToString();
                agvtask.agv_tasktype = tasktype;
                agvtask.agv_worktype = worktype;//工作类型
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WebApi/appsettings.json
@@ -37,7 +37,7 @@
  },
  //================跨域请求 (CORS)配置(2019-12-20新增),
  //================.netcore3.1必须配置此属性,多个url用豆号隔开,url为vue站点的地址,可以将发布后的地址也同时配置上
  "CorsUrls": "http://localhost:8081,http://localhost:8080,http://localhost:7080,http://localhost:9980,http://127.0.0.1:9980,http://localhost:9990,http://www.volcore.xyz",
  "CorsUrls": "http://localhost:8081,http://localhost:8080,http://localhost:7080,http://localhost:9980,http://192.168.12.101:8081,http://127.0.0.1:9980,http://localhost:9990,http://www.volcore.xyz",
  "ExpMinutes": "120", //JWT有效期(分钟=默认120),
  "CreateMember": { //对表插入数据时,需要记录创建人/创建时间/创建日期,配置UserIdField/UserNameField/DateField分别为对应数据库的创建人CreateID,创建人Creator,创建时间CreateDate字段(新建数据时,由框架默认完成给这几个字段赋值,字段区分大小写)或可手动调用T.SetCreateDefaultVal()完成设置创建人/创建时间/创建日期
    //如果表的主键是GUID,界面查询时默认会用到DateField对应的实体(数据库)字段进行排序
ÏîÄ¿×ÊÁÏ/DB/DeleteOldRecords.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,11 @@
-- å­˜å‚¨è¿‡ç¨‹
CREATE PROCEDURE DeleteOldRecords
    @MonthsAgo INT
AS
BEGIN
    DECLARE @CutOffDate DATE = DATEADD(MONTH, -@MonthsAgo, GETDATE());
    DELETE FROM dt_log_pcs
    WHERE [createtime ] < @CutOffDate;
END
GO
ÏîÄ¿×ÊÁÏ/DB/T-SQL.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
-- åˆ é™¤6个月之前的PCS系统日志数据
DECLARE @MonthsAgo INT = 6;
DECLARE @CurrentDate DATE = GETDATE();
DECLARE @CutOffDate DATE = DATEADD(MONTH, -@MonthsAgo, @CurrentDate);
-- åˆ é™¤æ“ä½œ
DELETE FROM dt_log_pcs
WHERE [createtime ] < @CutOffDate;
ÏîÄ¿×ÊÁÏ/DB/dbo.sql
ÎļþÌ«´ó
ÏîÄ¿×ÊÁÏ/DB/´´½¨´æ´¢¹ý³Ì.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,66 @@
-- åˆ›å»ºåˆ é™¤çš„存储过程
CREATE PROCEDURE DeleteInterfacerecord    --存储过程名称
    @MonthsAgo INT    --存储过程参数
AS
BEGIN
    DECLARE @CutOffDate DATE = DATEADD(MONTH, -@MonthsAgo, GETDATE()); --声明参数
    DELETE FROM dt_Interfacerecord    --数据库表名
    WHERE interface_createtime < @CutOffDate; --判断条件的列名
END
GO
--    åˆ›å»ºæ·»åŠ çš„å­˜å‚¨è¿‡ç¨‹
CREATE PROCEDURE Add_inventory
    @SN NVARCHAR(255),
    @Name NVARCHAR(255),
        @FigureNumber NVARCHAR(255),
    @area NVARCHAR(15),
        @HeatNumber NVARCHAR(50),
    @BilletNumber INT,
        @OnlineTime datetime,
    @Operator NVARCHAR(50),
        @stationCode NVARCHAR(30),
    @jobID NVARCHAR(255),
        @ID uniqueidentifier,
    @remark NVARCHAR(max)
AS
BEGIN
    INSERT INTO dt_inventory (SN, Name,FigureNumber,area,HeatNumber,BilletNumber,OnlineTime,Operator,remark,stationCode,jobID,ID)
    VALUES (@SN, @Name,@FigureNumber,@area,@HeatNumber,@BilletNumber,@OnlineTime,@Operator,@remark,@stationCode,@jobID,@ID)
    -- è¿”回新插入的用户ID
    --SELECT SCOPE_IDENTITY() AS NewUserID;
END
GO
-- åˆ é™¤åä¸º YourProcedureName çš„存储过程
--IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Add_inventory]') AND type in (N'P', N'PC'))
--DROP PROCEDURE [dbo].Add_inventory;
-- æŸ¥è¯¢æ‰€æœ‰å­˜å‚¨è¿‡ç¨‹
--SELECT * FROM information_schema.Routines WHERE ROUTINE_TYPE = 'PROCEDURE';
--执行不需要参数的存储过程
--EXEC DeleteInterfacerecord
--执行带参数的存储过程
--EXEC DeleteInterfacerecord @MonthsAgo = 6
--使用sp_executesql存储过程,这种方法可以提供额外的参数声明和类型检查:
--DECLARE @Param1 NVARCHAR(100) = 'Value1', @Param2 INT = 123
--EXEC sp_executesql
--    N'EXEC YourProcedureName @Param1, @Param2',
--    N'@Param1 NVARCHAR(100), @Param2 INT',
--    @Param1, @Param2
--直接在应用程序代码中调用存储过程,例如在C#中使用ADO.NET:
--using (SqlConnection conn = new SqlConnection(connectionString))
--{
--    SqlCommand cmd = new SqlCommand("YourProcedureName", conn);
--    cmd.CommandType = CommandType.StoredProcedure;
--    cmd.Parameters.AddWithValue("@Param1", "Value1");
--    cmd.Parameters.AddWithValue("@Param2", 123);
--    conn.Open();
--    cmd.ExecuteNonQuery();
--}
ÏîÄ¿×ÊÁÏ/ͨÐÅЭÒé/ÐÂÔöÉ豸ЭÒé/Ì«ÖØ½»»¥-¿â¿Ú״̬_V1.xlsx
Binary files differ