分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-06-25 27a86a8a1da0366d64df907b713ab8f1753714f8
添加VK4、VK5的通信处理逻辑(VK4、VK5)开发完成
已修改4个文件
已添加1个文件
346 ■■■■ 文件已修改
代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/equipment/info_interaction.cs 192 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/One_two_unitJob.cs 138 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK4Job.cs 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK5Job.cs 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/大屏/src/views/centerRight4.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Common/equipment/info_interaction.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using WIDESEA_Comm.LogInfo;
using WIDESEA_Core.EFDbContext;
using WIDESEA_WCS.IRepositories;
using WIDESEA_WCS.Repositories;
using WIDESEA_WCS.WCSClient;
using WIDESEA_WMS.IRepositories;
using WIDESEA_WMS.Repositories;
using static WIDESEA_Comm.Wheel_trace;
using static WIDESEA_WCS.GantryDB;
namespace WIDESEA_WCS
{
    public class info_interaction
    {
        /// <summary>
        /// è½¦è½®å‚数交互
        /// </summary>
        /// <param name="client"></param>
        public static void wheeldata(PLCClient client)
        {
            VOLContext context = new VOLContext();
            Idt_geometry_dataRepository geometry_DataRepository = new dt_geometry_dataRepository(context);
            var groups = client.itemGroups.Where(x => x.opratortype == "wheeldata").OrderBy(x => x.Methods).ThenBy(x => x.name).GroupBy(x => x.Methods).ToList();
            foreach (var key in groups)
            {
                try
                {
                    DBItemGroup group = key.FirstOrDefault(x => x.name == "oi_on");
                    if (group != null)
                    {
                        var oi_on = DBExtension.Read(group, client);
                        if (Convert.ToByte(oi_on) == 1)
                        {
                            var o_wp_type = DBExtension.Read(key.FirstOrDefault(x => x.name == "o_wp_type"), client);
                            var geometry = geometry_DataRepository.Find(x => x.TypeId == Convert.ToInt32(o_wp_type)).FirstOrDefault();
                            if (geometry == null)
                            {
                                client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)2);//状态
                                client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//申请复位
                                throw new Exception($"{key.Key}未找到类型{o_wp_type}的车轮参数\n写入辊道信息:i_status:2,oi_on:0");
                            }
                            else
                            {
                                client.Write(key.FirstOrDefault(x => x.name == "i_parameter_a").dbAddress, (float)geometry.a);//车轮参数a
                                client.Write(key.FirstOrDefault(x => x.name == "i_parameter_b").dbAddress, (float)geometry.b);//车轮参数b
                                client.Write(key.FirstOrDefault(x => x.name == "i_parameter_c").dbAddress, (float)geometry.c);//车轮参数c
                                client.Write(key.FirstOrDefault(x => x.name == "i_parameter_d").dbAddress, (float)geometry.d);//车轮参数d
                                client.Write(key.FirstOrDefault(x => x.name == "i_parameter_e").dbAddress, (float)geometry.e);//车轮参数e
                                client.Write(key.FirstOrDefault(x => x.name == "i_parameter_f").dbAddress, (float)geometry.f);//车轮参数f
                                client.Write(key.FirstOrDefault(x => x.name == "i_parameter_g").dbAddress, (float)geometry.g);//车轮参数g
                                client.Write(key.FirstOrDefault(x => x.name == "i_parameter_h").dbAddress, (float)geometry.h);//车轮参数h
                                client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)1);//状态
                                client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//申请复位
                                #region æ—¥å¿—记录
                                WriteLog.Write_Log(key.Key + "辊道", "申请查询车轮信息", "", $"读取辊道信息:\n轮型ID:{o_wp_type}\n\n写入辊道信息:\ni_status:1" + $"\n" +
                                    $"a:{(float)geometry.a}\n" +
                                    $"b:{(float)geometry.b}\n" +
                                    $"c:{(float)geometry.c}\n" +
                                    $"d:{(float)geometry.d}\n" +
                                    $"e:{(float)geometry.e}\n" +
                                    $"f:{(float)geometry.f}\n" +
                                    $"g:{(float)geometry.g}\n" +
                                    $"h:{(float)geometry.h}\n" +
                                    $"oi_on:0");
                                #endregion
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteLog.Write_Log(key.Key + "辊道", "申请查询车轮信息", "", ex.Message);
                }
            }
        }
        /// <summary>
        /// æ‰«ç æžª
        /// </summary>
        /// <param name="client"></param>
        public static void scan(PLCClient client)
        {
            VOLContext context = new VOLContext();
            Idt_geometry_dataRepository geometry_DataRepository = new dt_geometry_dataRepository(context);
            IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
            var groups = client.itemGroups.Where(x => x.opratortype == "scan").OrderBy(x => x.Methods).ThenBy(x => x.name).GroupBy(x => x.Methods).ToList();
            foreach (var key in groups)
            {
                try
                {
                    DBItemGroup group = key.FirstOrDefault(x => x.name == "oi_on");
                    if (group != null)
                    {
                        var oi_on = DBExtension.Read(group, client);
                        if (Convert.ToByte(oi_on) == 1)
                        {
                            var o_wp_type = DBExtension.Read(key.FirstOrDefault(x => x.name == "o_wp_type"), client);
                            var o_wp_id = DBExtension.Read(key.FirstOrDefault(x => x.name == "o_wp_id"), client);
                            var geometry = geometry_DataRepository.Find(x => x.TypeId == Convert.ToInt32(o_wp_type)).FirstOrDefault();
                            if (geometry == null)
                            {
                                client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)2);//状态
                                client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//申请复位
                                throw new Exception($"{key.Key}未找到类型{o_wp_type}的车轮参数\n写入辊道信息:i_status:2,oi_on:0");
                            }
                            var Work = workinfoRepository.Find(x => x.SN == o_wp_id && x.processCode == "17").OrderByDescending(x => x.CreateTime).FirstOrDefault();
                            if (Work == null)
                            {
                                client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)3);//状态
                                client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//申请复位
                                throw new Exception($"{key.Key}未找到SN:{o_wp_id}的工单信息\n写入辊道信息:i_status:3,oi_on:0");
                            }
                            client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)1);//状态
                            client.Write(key.FirstOrDefault(x => x.name == "i_direction").dbAddress, (byte)2);//去向默认写2
                            client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//申请复位
                            WriteLog.Write_Log(key.Key + "辊道", "扫码枪", "", "写入辊道信息:\ni_status:1,i_direction:2,oi_on:0");
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteLog.Write_Log(key.Key + "辊道", "扫码枪", "", ex.Message);
                }
            }
        }
        /// <summary>
        /// è´´æ ‡æœºäº¤äº’
        /// </summary>
        /// <param name="client"></param>
        public static void labeller(PLCClient client)
        {
            VOLContext context = new VOLContext();
            Idt_geometry_dataRepository geometry_DataRepository = new dt_geometry_dataRepository(context);
            IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
            var groups = client.itemGroups.Where(x => x.opratortype == "labeller").OrderBy(x => x.Methods).ThenBy(x => x.name).GroupBy(x => x.Methods).ToList();
            foreach (var key in groups)
            {
                try
                {
                    DBItemGroup group = key.FirstOrDefault(x => x.name == "oi_on");
                    if (group != null)
                    {
                        var oi_on = DBExtension.Read(group, client);
                        if (Convert.ToByte(oi_on) == 1)
                        {
                            var o_wp_id = DBExtension.Read(key.FirstOrDefault(x => x.name == "o_wp_id"), client);
                            if (string.IsNullOrEmpty(o_wp_id.ToString()))
                            {
                                var Work = workinfoRepository.Find(x => x.SN == o_wp_id && x.processCode == "17").OrderByDescending(x => x.CreateTime).FirstOrDefault();
                                if (Work == null)
                                {
                                    client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)2);//状态
                                    client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//申请复位
                                    throw new Exception($"{key.Key}未找到SN:{o_wp_id}的工单信息\n写入辊道信息:i_status:2,oi_on:0");
                                }
                                client.Write(key.FirstOrDefault(x => x.name == "i_job_id").dbAddress, Work.jobID);//工单编号
                                client.Write(key.FirstOrDefault(x => x.name == "i_heat_id").dbAddress, Work.heatID);//炉代号
                                client.Write(key.FirstOrDefault(x => x.name == "i_billet_id").dbAddress, Work.billetID.ToString());//钢坯号
                                client.Write(key.FirstOrDefault(x => x.name == "i_batch_id").dbAddress, Work.heatBatchID);//热处理批次
                                client.Write(key.FirstOrDefault(x => x.name == "i_drawing_id").dbAddress, Work.drawingNo);//图号
                                client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)1);//状态
                                client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//申请复位
                                WriteLog.Write_Log(key.Key + "辊道", "贴标机", "SN号:" + o_wp_id.ToString(),
                                    $"写入辊道信息:\n" +
                                    $"i_job_id:{Work.jobID}\n" +
                                    $"i_heat_id:{Work.heatID}\n" +
                                    $"i_billet_id:{Work.billetID}\n" +
                                    $"i_batch_id:{Work.heatBatchID}\n" +
                                    $"i_drawing_id:{Work.drawingNo}\n" +
                                    $"i_status:{(byte)1}\n" +
                                    $"oi_on:{(byte)0}");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteLog.Write_Log(key.Key + "辊道", "贴标机", "", ex.Message);
                }
            }
        }
    }
}
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/One_two_unitJob.cs
@@ -105,61 +105,133 @@
            VOLContext context = new VOLContext();
            Idt_plcinfodetailRepository repository = new dt_plcinfodetailRepository(context);
            List<dt_plcinfodetail> plcinfodetail = new List<dt_plcinfodetail>();
            for (int i = 1; i <= 1; i++)
            string name = "VK5";
            for (int i = 1; i <= 2; i++)
            {
                dt_plcinfodetail dt_Plcinfodetail1 = new dt_plcinfodetail()
                {
                    plcdetail_id = Guid.NewGuid(),
                    plcdetail_iotype = "VK5",
                    plcdetail_db = "DB630",
                    plcdetail_value = ((i - 1 + 28 + 10 + 10) * 24).ToString(),
                    plcdetail_valtype = "string",
                    plcdetail_len = 20,
                    plcdetail_name = "R_wheel_SN",
                    plcdetail_opratortype = "wheel",
                    plcdetail_remark = "读取车轮SN号",
                    plcdetail_number = "机械手3",
                    plcdetail_iotype = name,
                    plcdetail_db = "DB603",
                    plcdetail_value = (0 + (i - 1) * 144).ToString(),
                    plcdetail_valtype = "byte",
                    plcdetail_name = "oi_on",
                    plcdetail_opratortype = "labeller",
                    plcdetail_remark = "申请",
                    plcdetail_number = i + "单元",
                };
                plcinfodetail.Add(dt_Plcinfodetail1);
                dt_plcinfodetail dt_Plcinfodetail2 = new dt_plcinfodetail()
                {
                    plcdetail_id = Guid.NewGuid(),
                    plcdetail_iotype = "VK5",
                    plcdetail_db = "DB630",
                    plcdetail_value = (20 + (i - 1 + 28 + 10 + 10) * 24).ToString(),
                    plcdetail_valtype = "int16",
                    plcdetail_name = "R_wheel_type",
                    plcdetail_opratortype = "wheel",
                    plcdetail_remark = "读取车轮类型",
                    plcdetail_number = "机械手3",
                    plcdetail_iotype = name,
                    plcdetail_db = "DB603",
                    plcdetail_value = (2 + (i - 1) * 144).ToString(),
                    plcdetail_len = 20,
                    plcdetail_valtype = "string",
                    plcdetail_name = "o_wp_id",
                    plcdetail_opratortype = "labeller",
                    plcdetail_remark = "车轮SN号",
                    plcdetail_number = i + "单元",
                };
                plcinfodetail.Add(dt_Plcinfodetail2);
                dt_plcinfodetail dt_Plcinfodetail3 = new dt_plcinfodetail()
                {
                    plcdetail_id = Guid.NewGuid(),
                    plcdetail_iotype = "VK5",
                    plcdetail_db = "DB630",
                    plcdetail_value = (22 + (i - 1 + 28 + 10 + 10) * 24).ToString(),
                    plcdetail_valtype = "byte",
                    plcdetail_name = "R_part_status",
                    plcdetail_opratortype = "wheel",
                    plcdetail_remark = "读取车轮状态",
                    plcdetail_number = "机械手3",
                    plcdetail_iotype = name,
                    plcdetail_db = "DB603",
                    plcdetail_value = (24 + (i - 1) * 144).ToString(),
                    plcdetail_len = 20,
                    plcdetail_valtype = "string",
                    plcdetail_name = "i_job_id",
                    plcdetail_opratortype = "labeller",
                    plcdetail_remark = "工单编号",
                    plcdetail_number = i + "单元",
                };
                plcinfodetail.Add(dt_Plcinfodetail3);
                dt_plcinfodetail dt_Plcinfodetail4 = new dt_plcinfodetail()
                {
                    plcdetail_id = Guid.NewGuid(),
                    plcdetail_iotype = "VK5",
                    plcdetail_db = "DB630",
                    plcdetail_value = (23 + (i - 1 + 28 + 10 + 10) * 24).ToString(),
                    plcdetail_iotype = name,
                    plcdetail_db = "DB603",
                    plcdetail_value = (22 + (i - 1) * 144).ToString(),
                    plcdetail_valtype = "byte",
                    plcdetail_name = "R_part_process",
                    plcdetail_opratortype = "wheel",
                    plcdetail_remark = "读取车轮工艺",
                    plcdetail_number = "机械手3",
                    plcdetail_name = "i_status",
                    plcdetail_opratortype = "labeller",
                    plcdetail_remark = "状态",
                    plcdetail_number = i + "单元",
                };
                plcinfodetail.Add(dt_Plcinfodetail4);
                dt_plcinfodetail dt_Plcinfodetail5 = new dt_plcinfodetail()
                {
                    plcdetail_id = Guid.NewGuid(),
                    plcdetail_iotype = name,
                    plcdetail_db = "DB603",
                    plcdetail_value = (44 + (i - 1) * 144).ToString(),
                    plcdetail_len = 20,
                    plcdetail_valtype = "string",
                    plcdetail_name = "i_heat_id",
                    plcdetail_opratortype = "labeller",
                    plcdetail_remark = "炉代号",
                    plcdetail_number = i + "单元",
                };
                plcinfodetail.Add(dt_Plcinfodetail5);
                dt_plcinfodetail dt_Plcinfodetail6 = new dt_plcinfodetail()
                {
                    plcdetail_id = Guid.NewGuid(),
                    plcdetail_iotype = name,
                    plcdetail_db = "DB603",
                    plcdetail_value = (64 + (i - 1) * 144).ToString(),
                    plcdetail_len = 20,
                    plcdetail_valtype = "string",
                    plcdetail_name = "i_billet_id",
                    plcdetail_opratortype = "labeller",
                    plcdetail_remark = "钢坯号",
                    plcdetail_number = i + "单元",
                };
                plcinfodetail.Add(dt_Plcinfodetail6);
                dt_plcinfodetail dt_Plcinfodetail7 = new dt_plcinfodetail()
                {
                    plcdetail_id = Guid.NewGuid(),
                    plcdetail_iotype = name,
                    plcdetail_db = "DB603",
                    plcdetail_value = (84 + (i - 1) * 144).ToString(),
                    plcdetail_len = 20,
                    plcdetail_valtype = "string",
                    plcdetail_name = "i_batch_id",
                    plcdetail_opratortype = "labeller",
                    plcdetail_remark = "热处理批次",
                    plcdetail_number = i + "单元",
                };
                plcinfodetail.Add(dt_Plcinfodetail7);
                dt_plcinfodetail dt_Plcinfodetail8 = new dt_plcinfodetail()
                {
                    plcdetail_id = Guid.NewGuid(),
                    plcdetail_iotype = name,
                    plcdetail_db = "DB603",
                    plcdetail_value = (104 + (i - 1) * 144).ToString(),
                    plcdetail_len = 20,
                    plcdetail_valtype = "string",
                    plcdetail_name = "i_drawing_id",
                    plcdetail_opratortype = "labeller",
                    plcdetail_remark = "图号",
                    plcdetail_number = i + "单元",
                };
                plcinfodetail.Add(dt_Plcinfodetail8);
                dt_plcinfodetail dt_Plcinfodetail9 = new dt_plcinfodetail()
                {
                    plcdetail_id = Guid.NewGuid(),
                    plcdetail_iotype = name,
                    plcdetail_db = "DB603",
                    plcdetail_value = (124 + (i - 1) * 144).ToString(),
                    plcdetail_len = 20,
                    plcdetail_valtype = "string",
                    plcdetail_name = "i_wheel_type",
                    plcdetail_opratortype = "labeller",
                    plcdetail_remark = "i_wheel_type",
                    plcdetail_number = i + "单元",
                };
                plcinfodetail.Add(dt_Plcinfodetail9);
            }
            repository.AddRange(plcinfodetail, true);
        }
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK4Job.cs
@@ -39,7 +39,12 @@
                client.Connect();
                return;
            }
            #region MyRegion
            #region ä¿¡æ¯äº¤äº’
            info_interaction.wheeldata(client);
            info_interaction.scan(client);
            info_interaction.labeller(client);
            #endregion
            #region è½¦è½®ä¿¡æ¯è¿½æº¯
            Wheel_info_trace.Wheel_online(client);
            Wheel_info_trace.Wheel_machine(client);
            Wheel_info_trace.Wheel_offline(client);
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK5Job.cs
@@ -35,7 +35,12 @@
                client.Connect();
                return;
            }
            #region MyRegion
            #region ä¿¡æ¯äº¤äº’
            info_interaction.wheeldata(client);
            info_interaction.scan(client);
            info_interaction.labeller(client);
            #endregion
            #region è½¦è½®ä¿¡æ¯è¿½æº¯
            Wheel_info_trace.Wheel_online(client);
            Wheel_info_trace.Wheel_machine(client);
            Wheel_info_trace.Wheel_offline(client);
´úÂë¹ÜÀí/´óÆÁ/src/views/centerRight4.vue
@@ -68,7 +68,7 @@
            oddRowBGC: '#0f1325', //奇数行
            evenRowBGC: '#171c33', //偶数行
            index: true,
            columnWidth: [50,130,100,60,200],
            columnWidth: [50,130,100,60,270],
            align: ['center'],
          }
      }).catch((x)=>{