wangxinhui
2024-12-26 78b99e5348592a29ca1393a5e13db619cc4eba56
入壳设备增加
已修改5个文件
已添加7个文件
1085 ■■■■■ 文件已修改
DB/林洋SQL.sql 补丁 | 查看 | 原始文档 | blame | 历史
wcs-server-hbf/WIDESEA_WCS/Config/铝壳缓存架.json 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobRK_1209.cs 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/heartbeatRKJob.cs 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wcs-server-hbf/WIDESEA_WCS/Jobs/RGV/AluminumCaseJob.cs 174 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wcs-server-hbf/WIDESEA_WCS/JobsPart/AGV/UpdateAgvTaskText.cs 106 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/AGV/AgvAndEquiWork_JLM.cs 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/AGV/heartbeatRK.cs 322 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/RKSB_DownTask.cs 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/RKSB_UPTask.cs 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
入壳机信号.png 补丁 | 查看 | 原始文档 | blame | 历史
林洋程序包.zip 补丁 | 查看 | 原始文档 | blame | 历史
DB/ÁÖÑóSQL.sql
Binary files differ
wcs-server-hbf/WIDESEA_WCS/Config/ÂÁ¿Ç»º´æ¼Ü.json
@@ -37,44 +37,44 @@
        "RPLCDB": [ "x=2;8700", "x=2;8701", "x=2;8702", "x=2;8703", "x=2;8704" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
        "WPLCDB": [ "0", "1", "2" ] //黄灯,绿灯,红灯
      },
      {
        "HCJName": "铝盒缓存架9",
        "HCJCode": "1F-LKHCJ9",
        "RPLCDB": [ "x=2;8705", "x=2;8706", "x=2;8707", "x=2;8708", "x=2;8709" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
        "WPLCDB": [ "3", "4", "5" ] //黄灯,绿灯,红灯
      },
      {
        "HCJName": "铝盒缓存架8",
        "HCJCode": "1F-LKHCJ8",
        "RPLCDB": [ "x=2;8710", "x=2;8711", "x=2;8712", "x=2;8713", "x=2;8714" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
        "WPLCDB": [ "6", "7", "8" ] //黄灯,绿灯,红灯
      },
      //{
      //  "HCJName": "铝盒缓存架9",
      //  "HCJCode": "1F-LKHCJ9",
      //  "RPLCDB": [ "x=2;8705", "x=2;8706", "x=2;8707", "x=2;8708", "x=2;8709" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
      //  "WPLCDB": [ "3", "4", "5" ] //黄灯,绿灯,红灯
      //},
      //{
      //  "HCJName": "铝盒缓存架8",
      //  "HCJCode": "1F-LKHCJ8",
      //  "RPLCDB": [ "x=2;8710", "x=2;8711", "x=2;8712", "x=2;8713", "x=2;8714" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
      //  "WPLCDB": [ "6", "7", "8" ] //黄灯,绿灯,红灯
      //},
      {
        "HCJName": "一楼隔膜库3缓存柜6",
        "HCJCode": "1F-LKHCJ3-6",
        "RPLCDB": [ "x=2;8715", "x=2;8716", "x=2;8717", "x=2;8718", "x=2;8719" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
        "WPLCDB": [ "9", "10", "11" ] //黄灯,绿灯,红灯
      },
      {
        "HCJName": "一楼隔膜库3缓存柜4",
        "HCJCode": "1F-LKHCJ3-4",
        "RPLCDB": [ "x=2;8720", "x=2;8721", "x=2;8722", "x=2;8723", "x=2;8724" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
        "WPLCDB": [ "12", "13", "14" ] //黄灯,绿灯,红灯
      },
      {
        "HCJName": "一楼隔膜库3缓存柜2",
        "HCJCode": "1F-LKHCJ3-2",
        "RPLCDB": [ "x=2;8725", "x=2;8726", "x=2;8727", "x=2;8728", "x=2;8729" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
        "WPLCDB": [ "15", "16", "17" ] //黄灯,绿灯,红灯
      },
      {
        "HCJName": "一楼隔膜库3缓存柜8",
        "HCJCode": "1F-LKHCJ3-8",
        "RPLCDB": [ "x=2;8730", "x=2;8731", "x=2;8800", "x=2;8801", "x=2;8802" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
        "WPLCDB": [ "18", "19", "20" ] //黄灯,绿灯,红灯
      },
      //{
      //  "HCJName": "一楼隔膜库3缓存柜6",
      //  "HCJCode": "1F-LKHCJ3-6",
      //  "RPLCDB": [ "x=2;8715", "x=2;8716", "x=2;8717", "x=2;8718", "x=2;8719" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
      //  "WPLCDB": [ "9", "10", "11" ] //黄灯,绿灯,红灯
      //},
      //{
      //  "HCJName": "一楼隔膜库3缓存柜4",
      //  "HCJCode": "1F-LKHCJ3-4",
      //  "RPLCDB": [ "x=2;8720", "x=2;8721", "x=2;8722", "x=2;8723", "x=2;8724" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
      //  "WPLCDB": [ "12", "13", "14" ] //黄灯,绿灯,红灯
      //},
      //{
      //  "HCJName": "一楼隔膜库3缓存柜2",
      //  "HCJCode": "1F-LKHCJ3-2",
      //  "RPLCDB": [ "x=2;8725", "x=2;8726", "x=2;8727", "x=2;8728", "x=2;8729" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
      //  "WPLCDB": [ "15", "16", "17" ] //黄灯,绿灯,红灯
      //},
      //{
      //  "HCJName": "一楼隔膜库3缓存柜8",
      //  "HCJCode": "1F-LKHCJ3-8",
      //  "RPLCDB": [ "x=2;8730", "x=2;8731", "x=2;8800", "x=2;8801", "x=2;8802" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
      //  "WPLCDB": [ "18", "19", "20" ] //黄灯,绿灯,红灯
      //},
      {
        "HCJName": "一楼隔膜库3缓存柜7",
        "HCJCode": "1F-LKHCJ3-7",
@@ -140,8 +140,31 @@
        "HCJCode": "1F-LKHCJ1",
        "RPLCDB": [ "x=2;8921", "x=2;8922", "x=2;8923", "x=2;8924", "x=2;8925" ], //黄色按钮,绿色按钮,红色按钮,托盘光电,物料光电
        "WPLCDB": [ "8019", "8020", "8021" ] //黄灯,绿灯,红灯
      },
      {
        "HCJName": "入壳缓存架1",
        "HCJCode": "RKHCJ1",
        "RPLCDB": [ "x=2;8600", "x=2;8601", "x=2;8602" ], //按钮,托盘光电,物料光电
        "WPLCDB": [ "s=2;2", "s=2;1", "s=2;0" ]  //黄灯,绿灯,红灯
      },
      {
        "HCJName": "入壳缓存架2",
        "HCJCode": "RKHCJ2",
        "RPLCDB": [ "x=2;8603", "x=2;8604", "x=2;8605" ], //按钮,托盘光电,物料光电
        "WPLCDB": [ "s=2;5", "s=2;4", "s=2;3" ] //黄灯,绿灯,红灯
      },
      {
        "HCJName": "入壳缓存架3",
        "HCJCode": "RKHCJ3",
        "RPLCDB": [ "x=2;8606", "x=2;8607", "x=2;8608" ], //按钮,托盘光电,物料光电
        "WPLCDB": [ "s=2;8", "s=2;7", "s=2;6" ] //黄灯,绿灯,红灯
      },
      {
        "HCJName": "入壳缓存架4",
        "HCJCode": "RKHCJ4",
        "RPLCDB": [ "x=2;8609", "x=2;8610", "x=2;8611" ], //按钮,托盘光电,物料光电
        "WPLCDB": [ "s=2;11", "s=2;10", "s=2;9" ] //黄灯,绿灯,红灯
      }
    ]
  }
wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobRK_1209.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,52 @@
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using WIDESEA_Common.Tools;
namespace WIDESEA_WCS
{
    /// <summary>
    /// å…¥å£³æœºä¸Šä¸‹æ–™è°ƒåº¦
    /// </summary>
    [DisallowConcurrentExecution]
    public class JobRK_1209 : IJob
    {
        private static int lockObj1 = 0;
        public Task Execute(IJobExecutionContext context)
        {
            if (lockObj1 == 0)
            {
                try
                {
                    lockObj1 = 1;
                    Task task = Task.Run(() =>
                    {
                        while (true)
                        {
                            try
                            {
                                WriteLog.GetLog().Write($"开始时间:{DateTime.Now} --------------", $"入壳机上下料调度");
                                StackerExecutor.RKSB_UpTask();    //入壳机上料任务
                                StackerExecutor.RKSB_DownTask();  //入壳机下料任务
                                WriteLog.GetLog().Write($"结束时间:{DateTime.Now} --------------", $"入壳机上下料调度");
                            }
                            catch { }
                            Thread.Sleep(200);
                        }
                    });
                }
                catch (Exception ex)
                {
                    lockObj1 = 0;
                    throw new Exception(ex.Message);
                }
            }
            return Task.CompletedTask;
        }
    }
}
wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/heartbeatRKJob.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,35 @@
using Quartz;
using System;
using System.Threading.Tasks;
using WIDESEA_Common.Tools;
using WIDESEA_WCS.Jobs;
using WIDESEA_WCS.SchedulerExecute.AGV;
namespace WIDESEA_WCS
{
    [DisallowConcurrentExecution]
    public class heartbeatRKJob : JobBase, IJob
    {
        public Task Execute(IJobExecutionContext context)
        {
            try
            {
                var executeLog = ExecuteJob(context, () => Run(context));
            }
            catch (Exception)
            {
            }
            return Task.FromResult(string.Empty);
        }
        public string Run(IJobExecutionContext context)
        {
            try
            {
                heartbeatRK.heartbeatWork();//入壳机设备和AGV交互
            }
            catch (Exception) { }
            return "";
        }
    }
}
wcs-server-hbf/WIDESEA_WCS/Jobs/RGV/AluminumCaseJob.cs
@@ -445,6 +445,42 @@
                doorState_1f_cx += 30;
           
            }
            //入壳缓存架
            double comErr_rk = 9450.0;//是否掉线
            double doorCode_rk = 9452.0;//缓存架ID
            double doorState_rk = 9474.0;//缓存架物料状态(1:空位,2:空托盘,3:满托盘)
            var dt_stationinfo_rk = freeDB.Select<dt_stationinfo>().Where(d => d.stationType == "入壳缓存架").OrderBy(t => t.sort).ToList();
            foreach (var item in dt_stationinfo_rk)
            {
                if (item.connect == true)
                {
                    //掉线
                }
                else
                {
                    if (item.tpgd == true && item.wlgd == true)
                    {
                        OperateResult W_HCJ_FullState = agvzzplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1003." + doorState_rk, Convert.ToInt16(3));
                    }
                    else if (item.tpgd == true && item.wlgd == false)
                    {
                        OperateResult W_HCJ_FullState = agvzzplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1003." + doorState_rk, Convert.ToInt16(2));
                    }
                    else
                    {
                        OperateResult W_HCJ_FullState = agvzzplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1003." + doorState_rk, Convert.ToInt16(1));
                    }
                }
                OperateResult W_HCJ_StationCode = agvzzplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1003." + doorCode_rk, item.stationCode.ToString());
                OperateResult W_HCJ_ComErr = agvzzplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1003." + comErr_rk, item.connect);
                comErr_1f_cx += 30;
                doorCode_1f_cx += 30;
                doorState_1f_cx += 30;
            }
        }
        private void agvtaskAdd(string agv_remark, string begin, string end,bool communi)
@@ -641,7 +677,7 @@
                        t.LampYellow
                    }).ExecuteAffrows();
                }
                else if (stationList.HCJCenterName == "铝壳缓存架一楼")
                else if (stationList.HCJCenterName == "铝壳缓存架一楼" && !item.HCJName.Contains("入壳缓存架"))
                {
                    string ButtonResetDB = item.RPLCDB[0];  //复位按钮(黄色)信号点位
                    string ButtonEnsureDB = item.RPLCDB[1];//确认按钮(绿色)信号点位
@@ -820,6 +856,142 @@
                        t.LampYellow
                    }).ExecuteAffrows();
                }
                else if (stationList.HCJCenterName == "铝壳缓存架一楼" && item.HCJName.Contains("入壳缓存架"))
                {
                    string ButtonEnsureDB = item.RPLCDB[0];//确认按钮(绿色)信号点位
                    string tpgdstateDB = item.RPLCDB[1];//托盘光电状态信号点位
                    string wlgdstateDB = item.RPLCDB[2];//物料光电状态信号点位
                    ////确认按钮(绿色)
                    OperateResult<bool> R_TBR_XT = ModbusPLCClient.ReadBool(ButtonEnsureDB);
                    WriteLog.GetLog().Write($"{item.HCJName}缓存架,连接{R_TBR_XT.IsSuccess}", "入壳缓存架");
                    if (!R_TBR_XT.IsSuccess)
                    {
                        //Console.WriteLine($"-{ModbusPLCClient.IpAddress}---{station.stationCode}----{ButtonEnsureDB}--------false--{R_TBR_XT.Message}----------------");
                        station.connect = true;
                        var stationoff = freeDB.Update(station).UpdateColumns(t => new
                        {
                            t.connect
                        }).ExecuteAffrows();
                        continue;
                    }
                    bool ButtonEnsure = ModbusPLCClient.ReadBool(ButtonEnsureDB).Content;
                    //托盘光电状态
                    bool pgdstate = ModbusPLCClient.ReadBool(tpgdstateDB).Content;
                    //物料光电状态
                    bool wlgdstate = ModbusPLCClient.ReadBool(wlgdstateDB).Content;
                    //根据读到的PLC信息,轮询更新数据库信息
                    station.getLastTime = DateTime.Now;
                    station.greenbutton = ButtonEnsure;
                    station.tpgd = pgdstate;
                    station.wlgd = wlgdstate;
                    string LampYellowDB = item.WPLCDB[0];//黄灯信号点位
                    string LampGreenDB = item.WPLCDB[1];//绿灯信号点位
                    string LampRedDB = item.WPLCDB[2];//红灯信号点位
                    //货架存在任务任务时
                    if (station.task)
                    {
                        if (station.LampYellow)
                        {
                            ModbusPLCClient.Write(LampYellowDB, false); //黄灯
                            ModbusPLCClient.Write(LampRedDB, false); //红灯
                            ModbusPLCClient.Write(LampGreenDB, false); //绿灯
                                                                       // Console.WriteLine($"{station.stationCode}---亮---{DateTime.Now}");
                            station.LampRed = false;
                            station.LampYellow = false;
                            station.LampGreen = false;
                        }
                        else
                        {
                            ModbusPLCClient.Write(LampYellowDB, true); //黄灯
                            ModbusPLCClient.Write(LampRedDB, false); //红灯
                            ModbusPLCClient.Write(LampGreenDB, false); //绿灯
                                                                       // Console.WriteLine($"{station.stationCode}---灭---{DateTime.Now}");
                            station.LampRed = false;
                            station.LampYellow = true;
                            station.LampGreen = false;
                        }
                    }
                    else
                    {
                        //当有人按下绿色按钮时:
                        //将缓存架的灯光亮绿灯
                        if (ButtonEnsure && pgdstate && wlgdstate)
                        {
                            DateTime date = DateTime.Now;
                            DateTime time2 = station.greenbuttontime;
                            Double STAMP = (date - time2).TotalSeconds;
                            if (STAMP > 4)
                            {
                                if (station.LampGreen)
                                {
                                    ModbusPLCClient.Write(LampGreenDB, false); //绿灯
                                    station.LampGreen = false;
                                }
                                else
                                {
                                    ModbusPLCClient.Write(LampGreenDB, true); //绿灯
                                    station.LampGreen = true;
                                }
                                //ModbusPLCClient.Write(LampRedDB, false); //红灯
                                ModbusPLCClient.Write(LampYellowDB, false); //黄灯
                                //station.LampRed = false;
                                station.LampYellow = false;
                                station.greenbuttontime = DateTime.Now;
                            }
                        }
                        else if (station.LampGreen && (!pgdstate || !wlgdstate))
                        {
                            ModbusPLCClient.Write(LampRedDB, false); //红灯
                            ModbusPLCClient.Write(LampYellowDB, false); //黄灯
                            ModbusPLCClient.Write(LampGreenDB, false); //绿灯
                            station.LampRed = false;
                            station.LampYellow = false;
                            station.LampGreen = false;
                        }
                        //检测托盘光电有料,但未按确认按钮,亮黄灯
                        else if (!station.LampGreen && pgdstate)
                        {
                            // ModbusPLCClient.Write(LampRedDB, false); //红灯
                            ModbusPLCClient.Write(LampYellowDB, true); //黄灯
                            ModbusPLCClient.Write(LampGreenDB, false); //绿灯
                                                                       // station.LampRed = false;
                            station.LampYellow = true;
                            station.LampGreen = false;
                        }
                        else if (!station.LampGreen && !pgdstate && !wlgdstate)
                        {
                            ModbusPLCClient.Write(LampRedDB, false); //红灯
                            ModbusPLCClient.Write(LampYellowDB, false); //黄灯
                            ModbusPLCClient.Write(LampGreenDB, false); //绿灯
                            station.LampRed = false;
                            station.LampYellow = false;
                            station.LampGreen = false;
                        }
                    }
                    station.connect = false;
                    var executeAffrows = freeDB.Update(station).UpdateColumns(t => new
                    {
                        t.connect,
                        t.getLastTime,
                        t.greenbutton,
                        t.tpgd,
                        t.wlgd,
                        t.LampRed,
                        t.LampGreen,
                        t.LampYellow
                    }).ExecuteAffrows();
                }
            }
        }
wcs-server-hbf/WIDESEA_WCS/JobsPart/AGV/UpdateAgvTaskText.cs
@@ -211,6 +211,20 @@
                                    WriteLog.GetLog().Write($"任务号:{agvTask.agv_tasknum},内容:终点地址:{dt_Stationinfo.stationCode},货位修改失败", $"货位修改失败");
                                }
                            }
                            else if (agvTask.agv_remark.Contains("入壳上料任务"))
                            {
                                dt_stationinfo dt_Stationinfo = stationinfoRepository.FindFirst(d => d.stationCode == agvTask.agv_fromaddress);
                                if (dt_Stationinfo == null)
                                {
                                    return;
                                }
                                dt_Stationinfo.task = false;
                                int a = stationinfoRepository.Update(dt_Stationinfo, x => new { x.task }, true);
                                if (a == 0)
                                {
                                    WriteLog.GetLog().Write($"任务号:{agvTask.agv_tasknum},内容:终点地址:{dt_Stationinfo.stationCode},货位修改失败", $"货位修改失败");
                                }
                            }
                            #endregion
                            plcClient.WriteValue(TaskDBName.taskFbInteractiveW.ToString(), 1);
                            for (int i = 0; i < 5; i++)
@@ -276,19 +290,22 @@
                                if (agvTask.agv_fromaddress.Contains("HCJ"))
                                {
                                    base_ware_location location = locationRepository.FindFirst(x => x.upper_code == agvTask.agv_fromaddress);
                                    if (!agvTask.agv_remark.Contains("切卷上料回空"))
                                    if (location != null)
                                    {
                                        location.geartype = "暂无";
                                    }
                                    location.update_time = DateTime.Now;
                                    location.logic_col = 0;
                                    location.task = 2;
                                    location.logic_row = "0";
                                        if (!agvTask.agv_remark.Contains("切卷上料回空"))
                                        {
                                            location.geartype = "暂无";
                                        }
                                        location.update_time = DateTime.Now;
                                        location.logic_col = 0;
                                        location.task = 2;
                                        location.logic_row = "0";
                                    int a = locationRepository.Update(location, x => new { x.logic_col, x.task, x.logic_row, x.update_time, x.geartype }, true);
                                    if (a == 0)
                                    {
                                        WriteLog.GetLog().Write($"任务号:{agvTask.agv_tasknum},内容:终点地址:{location.upper_code},货位修改失败", $"货位修改失败");
                                        int a = locationRepository.Update(location, x => new { x.logic_col, x.task, x.logic_row, x.update_time, x.geartype }, true);
                                        if (a == 0)
                                        {
                                            WriteLog.GetLog().Write($"任务号:{agvTask.agv_tasknum},内容:终点地址:{location.upper_code},货位修改失败", $"货位修改失败");
                                        }
                                    }
                                }
                            }
@@ -583,6 +600,20 @@
                                }
                            }
                            else if (agvTask.agv_remark.Contains("入壳下料任务"))
                            {
                                dt_stationinfo dt_Stationinfo = stationinfoRepository.FindFirst(d => d.stationCode == agvTask.agv_toaddress);
                                if (dt_Stationinfo == null)
                                {
                                    return;
                                }
                                dt_Stationinfo.task = false;
                                int a = stationinfoRepository.Update(dt_Stationinfo, x => new { x.task }, true);
                                if (a == 0)
                                {
                                    WriteLog.GetLog().Write($"任务号:{agvTask.agv_tasknum},内容:终点地址:{dt_Stationinfo.stationCode},货位修改失败", $"货位修改失败");
                                }
                            }
                            #endregion
                            plcClient.WriteValue(TaskDBName.taskFbInteractiveW.ToString(), 1);
                            for (int i = 0; i < 5; i++)
@@ -691,22 +722,57 @@
                                }
                            }
                            else if (agvTask.agv_remark.Contains("入壳下料任务"))
                            {
                                dt_stationinfo dt_Stationinfo = stationinfoRepository.FindFirst(d => d.stationCode == agvTask.agv_toaddress);
                                if (dt_Stationinfo != null)
                                {
                                    dt_Stationinfo.task = false;
                                    int a = stationinfoRepository.Update(dt_Stationinfo, x => new { x.task }, true);
                                    if (a == 0)
                                    {
                                        WriteLog.GetLog().Write($"任务号:{agvTask.agv_tasknum},内容:终点地址:{dt_Stationinfo.stationCode},货位修改失败", $"货位修改失败");
                                    }
                                }
                            }
                            else
                            {
                                base_ware_location location = locationRepository.FindFirst(x => x.upper_code == agvTask.agv_toaddress);
                                location.logic_col = 0;
                                location.logic_row = "0";
                                location.task = 2;
                                locationRepository.Update(location, x => new { x.logic_col, x.logic_row, x.task }, true);
                                if (location!=null)
                                {
                                    location.logic_col = 0;
                                    location.logic_row = "0";
                                    location.task = 2;
                                    locationRepository.Update(location, x => new { x.logic_col, x.logic_row, x.task }, true);
                                }
                            }
                        }
                        else if (agvTask.agv_toaddress.Contains("SB") && agvTask.agv_fromaddress.Contains("HCJ"))
                        {
                            base_ware_location location = locationRepository.FindFirst(x => x.upper_code == agvTask.agv_fromaddress);
                            location.logic_col = 0;
                            location.logic_row = "0";
                            location.task = 2;
                            locationRepository.Update(location, x => new { x.logic_col, x.logic_row, x.task }, true);
                            if (agvTask.agv_remark.Contains("入壳上料任务"))
                            {
                                dt_stationinfo dt_Stationinfo = stationinfoRepository.FindFirst(d => d.stationCode == agvTask.agv_fromaddress);
                                if (dt_Stationinfo != null)
                                {
                                    dt_Stationinfo.task = false;
                                    int a = stationinfoRepository.Update(dt_Stationinfo, x => new { x.task }, true);
                                    if (a == 0)
                                    {
                                        WriteLog.GetLog().Write($"任务号:{agvTask.agv_tasknum},内容:终点地址:{dt_Stationinfo.stationCode},货位修改失败", $"货位修改失败");
                                    }
                                }
                            }
                            else
                            {
                                base_ware_location location = locationRepository.FindFirst(x => x.upper_code == agvTask.agv_fromaddress);
                                if (location != null)
                                {
                                    location.logic_col = 0;
                                    location.logic_row = "0";
                                    location.task = 2;
                                    locationRepository.Update(location, x => new { x.logic_col, x.logic_row, x.task }, true);
                                }
                            }
                        }
                        else if (agvTask.agv_toaddress.Contains("HCJ") && agvTask.agv_fromaddress.Contains("HCJ"))
                        {
wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/AGV/AgvAndEquiWork_JLM.cs
@@ -2,10 +2,12 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using WIDESEA_Common;
using WIDESEA_Common.Tools;
using WIDESEA_Core.Utilities;
using WIDESEA_Services.Services;
using WIDESEA_WCS.WCSClient;
using static FreeSql.Internal.GlobalFilter;
namespace WIDESEA_WCS.SchedulerExecute.AGV
{
@@ -17,12 +19,18 @@
        public static void AgvAndEquiWork_JLM()
        {
            PLCClient agvjrplc = WCSService.Clients.Find(v => v.PLCName == "组装AGV调度");
            PLCClient oiplc1F = WCSService.Clients.Find(v => v.PLCName == PLCConst.PLCName1FLKHCJ);
            #region æ— çº¿io模块 104卷绕中控 å¼€é—¨ä¿¡å·ä¼ é€’
            int comErr = 0;//自动门掉线  "拆包间卷帘门139", "涂布正负极卷帘门142",
            double doorCode = 2.0; //自动门ID
            double doorState = 24.0;//自动门状态,1门关到位,2 é—¨å¼€åˆ°ä½ï¼Œ3门未到位
            double doorOpen = 26.0; //自动门控制开
            int RKErr = 450;//自动门掉线
            double RKCode = 452.0; //自动门ID
            double RKState = 474.0;//自动门状态,1门关到位,2 é—¨å¼€åˆ°ä½ï¼Œ3门未到位
            double RKOpen = 476.0; //自动门控制开
            try
            {
                if (agvjrplc == null)
@@ -113,6 +121,54 @@
                    doorState += 30;
                    doorOpen += 30;
                }
                //入壳卷帘门 24/12/12新增
                OperateResult<bool> R_RKOpen = agvjrplc.SiemensPLCClient.SiemensS7NetClient.ReadBool("DB1004." + RKOpen);
                if (!R_RKOpen.IsSuccess)
                {
                    return;
                }
                //AGV请求开门
                if (R_RKOpen.Content)
                {
                    OperateResult RKOpenJLM = oiplc1F.ModbusPLCClient.ModbusTcpNetClient.Write("s=2;12",true);
                    if (RKOpenJLM.IsSuccess)
                    {
                        OperateResult<bool> JLMOpen = oiplc1F.ModbusPLCClient.ModbusTcpNetClient.ReadBool("x=2;8612");
                        if (JLMOpen.Content)//开门到位
                        {
                            OperateResult W_stationDockSteps = agvjrplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1004." + (RKState), 2);
                        }
                        else//门未到位
                        {
                            OperateResult W_stationDockSteps = agvjrplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1004." + (RKState), 3);
                        }
                    }
                    else
                    {
                        OperateResult W_stationDockSteps = agvjrplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1004." + (RKErr), true);
                    }
                }
                else
                {
                    //AGV不给开门信号的时候 æ–­å¼€å¼€é—¨ä¿¡å·
                    OperateResult RKOpenJLM = oiplc1F.ModbusPLCClient.ModbusTcpNetClient.Write("s=2;12", false);
                    if (RKOpenJLM.IsSuccess)
                    {
                        OperateResult<bool> JLMOpen = oiplc1F.ModbusPLCClient.ModbusTcpNetClient.ReadBool("x=2;8613");
                        if (JLMOpen.Content)//关门到位
                        {
                            OperateResult W_stationDockSteps = agvjrplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1004." + (RKState), 1);
                        }
                        else//门未到位
                        {
                            OperateResult W_stationDockSteps = agvjrplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1004." + (RKState), 3);
                        }
                    }
                    else
                    {
                        OperateResult W_stationDockSteps = agvjrplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1004." + (RKErr), true);
                    }
                }
            }
            catch (Exception ex)
            {
wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/AGV/heartbeatRK.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,322 @@
using HslCommunication;
using NetTaste;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using WIDESEA_Common.Tools;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Services.IRepositories;
using WIDESEA_Services.Repositories;
using WIDESEA_WCS.WCSClient;
namespace WIDESEA_WCS.SchedulerExecute.AGV
{
    public partial class heartbeatRK
    {
        private static int lockObj1 = 0;
        public static void heartbeatWork()
        {
            if (lockObj1 == 0)
            {
                lockObj1 = 1;
                {
                    string rksb = "入壳机1";
                    //心跳
                    Task.Run(() =>
                    {
                        while (true)
                        {
                            try
                            {
                                Thread.Sleep(200);
                                if (WCSService.Clients == null)
                                {
                                    continue;
                                }
                                PLCClient rkplc = WCSService.Clients.Find(v => v.PLCName == rksb);
                                if (rkplc == null)
                                {
                                    continue;
                                }
                                PLCClient agvplc = WCSService.Clients.Find(v => v.PLCName == "组装AGV调度");
                                if (agvplc == null)
                                {
                                    continue;
                                }
                                #region å…¥å£³æœºä¸€å·å¿ƒè·³
                                WriteLog.GetLog().Write($"--------------{rksb}心跳传递开始,时间:{DateTime.Now}--------------{Environment.NewLine}", $"{rksb}心跳传递");
                                // è¯»å–入壳机1号设备心跳
                                bool R_RK1_XT =Convert.ToBoolean(rkplc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5300").Content);
                                // å…¥å£³æœº1号设备心跳—写入—》组装AGV调度心跳
                                OperateResult W_AGV_XT = agvplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1002.3600.0", R_RK1_XT);
                                // è¯»å–组装AGV调度心跳
                                OperateResult<bool> R_AGV_XT = agvplc.SiemensPLCClient.SiemensS7NetClient.ReadBool("DB1002.3700.0");
                                Int16 readValue = Convert.ToInt16(R_AGV_XT.Content);
                                // ç»„装AGV调度—写入—》入壳机1号设备心跳
                                OperateResult W_RK1_XT = rkplc.ModbusPLCClient.ModbusTcpNetClient.Write("5300", readValue);
                                WriteLog.GetLog().Write($"--------------{rksb}心跳传递结束,时间:{DateTime.Now}--------------{Environment.NewLine}", $"{rksb}心跳传递");
                                #endregion
                            }
                            catch (Exception ex) { }
                        }
                    });
                    //上料口
                    Task.Run(() =>
                    {
                        while (true)
                        {
                            try
                            {
                                if (WCSService.Clients == null)
                                {
                                    continue;
                                }
                                PLCClient rkplc = WCSService.Clients.Find(v => v.PLCName == rksb);
                                if (rkplc == null)
                                {
                                    continue;
                                }
                                PLCClient agvplcZZ = WCSService.Clients.Find(v => v.PLCName == "组装AGV调度");
                                if (agvplcZZ == null)
                                {
                                    continue;
                                }
                                #region ä¸Šæ–™å£
                                WriteLog.GetLog().Write($"{rksb}上料口信息传递开始,时间:{DateTime.Now} --------------{Environment.NewLine}", $"{rksb}上料口信息传递");
                                //入壳机1号报警
                                bool GYC_RBJ =Convert.ToBoolean(rkplc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5302").Content);
                                // AGV获取入壳机1号报警信号
                                OperateResult AGVC_WBJ = agvplcZZ.SiemensPLCClient.SiemensS7NetClient.Write("DB1002.3692", GYC_RBJ);
                                // AGV报警信号
                                OperateResult<bool> AGVC_RBJ = agvplcZZ.SiemensPLCClient.SiemensS7NetClient.ReadBool("DB1002.3792");
                                Int16 RBJ = Convert.ToInt16(AGVC_RBJ.Content);
                                //入壳机1号获取AGV报警信号
                                OperateResult GFC_WBJ = rkplc.ModbusPLCClient.ModbusTcpNetClient.Write("5304", RBJ);
                                //读取agv上料口逻辑
                                OperateResult<Int16> R_up_bzR = agvplcZZ.SiemensPLCClient.SiemensS7NetClient.ReadInt16("DB1002.3790");
                                //写入入壳机1号上料口对接流程步骤
                                OperateResult W_ProcessStep_up = rkplc.ModbusPLCClient.ModbusTcpNetClient.Write("5307", R_up_bzR.Content);
                                //读取入壳机1号步序
                                OperateResult<Int16> R_ProcessSteps_up = rkplc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5306");
                                //将步序写入agv
                                OperateResult W_stationDockSteps_up = agvplcZZ.SiemensPLCClient.SiemensS7NetClient.Write("DB1002.3690", R_ProcessSteps_up.Content);
                                WriteLog.GetLog().Write($"{rksb}上料口信息传递结束,时间:{DateTime.Now}--------------{Environment.NewLine}", $"{rksb}上料口信息传递");
                                #endregion
                            }
                            catch (Exception ex)
                            {
                            }
                            Thread.Sleep(200);
                        }
                    });
                    //下料口
                    Task.Run(() =>
                    {
                        while (true)
                        {
                            try
                            {
                                if (WCSService.Clients == null)
                                {
                                    continue;
                                }
                                PLCClient rkplc = WCSService.Clients.Find(v => v.PLCName == rksb);
                                if (rkplc == null)
                                {
                                    continue;
                                }
                                PLCClient agvplc = WCSService.Clients.Find(v => v.PLCName == "组装AGV调度");
                                if (agvplc == null)
                                {
                                    continue;
                                }
                                #region ä¸‹æ–™å£
                                //入壳机1号口报警
                                WriteLog.GetLog().Write($"{rksb}下料口信息传递开始,时间:{DateTime.Now}--------------{Environment.NewLine}", $"{rksb}下料口信息传递");
                                //入壳机1号报警
                                bool GYC_RBJ = Convert.ToBoolean(rkplc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5302").Content);
                                // AGV获取入壳机1号报警信号
                                OperateResult AGV_WBJ = agvplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1002.3892", GYC_RBJ);
                                // AGV报警信号
                                OperateResult<bool> AGV_RBJ = agvplc.SiemensPLCClient.SiemensS7NetClient.ReadBool("DB1002.3992");
                                int RBJ = Convert.ToInt32(AGV_RBJ.Content);
                                //入壳机1号获取AGV报警信号
                                OperateResult GFC_WBJ = rkplc.ModbusPLCClient.ModbusTcpNetClient.Write("5304", RBJ);
                                // è¯»å–agv下料口请求进入
                                OperateResult<Int16> R_Down1_bzR = agvplc.SiemensPLCClient.SiemensS7NetClient.ReadInt16("DB1002.3990");
                                // å†™å…¥å…¥å£³æœº1号下料口AGV请求进入
                                OperateResult W_ProcessSteps1 = rkplc.ModbusPLCClient.ModbusTcpNetClient.Write("5309", R_Down1_bzR.Content);
                                // è¯»å–入壳机1号下料口是否允许AGV请求进入
                                OperateResult<Int16> R_ProcessSteps1 = rkplc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5308");
                                OperateResult W_stationDockSteps1 = agvplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1002.3890", R_ProcessSteps1.Content);
                                WriteLog.GetLog().Write($"{rksb}下料口信息传递结束,时间:{DateTime.Now}--------------{Environment.NewLine}", $"{rksb}下料口信息传递");
                                #endregion
                            }
                            catch (Exception ex) { }
                            Thread.Sleep(200);
                        }
                    });
                }
                {
                    string rksb = "入壳机2";
                    //心跳
                    Task.Run(() =>
                    {
                        while (true)
                        {
                            try
                            {
                                Thread.Sleep(200);
                                if (WCSService.Clients == null)
                                {
                                    continue;
                                }
                                PLCClient rkplc = WCSService.Clients.Find(v => v.PLCName == rksb);
                                if (rkplc == null)
                                {
                                    continue;
                                }
                                PLCClient agvplc = WCSService.Clients.Find(v => v.PLCName == "组装AGV调度");
                                if (agvplc == null)
                                {
                                    continue;
                                }
                                #region å…¥å£³æœºäºŒå·å¿ƒè·³
                                WriteLog.GetLog().Write($"--------------{rksb}心跳传递开始,时间:{DateTime.Now} --------------{Environment.NewLine}", $"{rksb}心跳传递");
                                // è¯»å–入壳机2号设备心跳
                                bool R_RK2_XT = Convert.ToBoolean(rkplc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5300").Content);
                                // å…¥å£³æœº2号设备心跳—写入—》组装AGV调度心跳
                                OperateResult W_AGV_XT = agvplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1002.4000.0", R_RK2_XT);
                                // è¯»å–组装AGV调度心跳
                                OperateResult<bool> R_AGV_XT = agvplc.SiemensPLCClient.SiemensS7NetClient.ReadBool("DB1002.4100.0");
                                Int16 readValue = Convert.ToInt16(R_AGV_XT.Content);
                                // ç»„装AGV调度—写入—》入壳机2号设备心跳
                                OperateResult W_RK2_XT = rkplc.ModbusPLCClient.ModbusTcpNetClient.Write("5300", readValue);
                                WriteLog.GetLog().Write($"--------------{rksb}心跳传递结束,时间:{DateTime.Now} --------------{Environment.NewLine}", $"{rksb}心跳传递");
                                #endregion
                            }
                            catch (Exception ex) { }
                        }
                    });
                    //上料口
                    Task.Run(() =>
                    {
                        while (true)
                        {
                            try
                            {
                                if (WCSService.Clients == null)
                                {
                                    continue;
                                }
                                PLCClient rkplc = WCSService.Clients.Find(v => v.PLCName == rksb);
                                if (rkplc == null)
                                {
                                    continue;
                                }
                                PLCClient agvplcZZ = WCSService.Clients.Find(v => v.PLCName == "组装AGV调度");
                                if (agvplcZZ == null)
                                {
                                    continue;
                                }
                                #region ä¸Šæ–™å£
                                WriteLog.GetLog().Write($"-------------- {rksb}上料口信息传递开始,时间:{DateTime.Now} --------------{Environment.NewLine}", $"{rksb}上料口信息传递");
                                //入壳机2号报警
                                bool GYC_RBJ = Convert.ToBoolean(rkplc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5302").Content);
                                // AGV获取入壳机2号报警信号
                                OperateResult AGVC_WBJ = agvplcZZ.SiemensPLCClient.SiemensS7NetClient.Write("DB1002.4092", GYC_RBJ);
                                // AGV报警信号
                                OperateResult<bool> AGVC_RBJ = agvplcZZ.SiemensPLCClient.SiemensS7NetClient.ReadBool("DB1002.4192");
                                Int16 RBJ = Convert.ToInt16(AGVC_RBJ.Content);
                                //入壳机2号获取AGV报警信号
                                OperateResult GFC_WBJ = rkplc.ModbusPLCClient.ModbusTcpNetClient.Write("5304", RBJ);
                                //读取agv上料口逻辑
                                OperateResult<Int16> R_up_bzR = agvplcZZ.SiemensPLCClient.SiemensS7NetClient.ReadInt16("DB1002.4190");
                                //写入入壳机2号上料口对接流程步骤
                                OperateResult W_ProcessStep_up = rkplc.ModbusPLCClient.ModbusTcpNetClient.Write("5307", R_up_bzR.Content);
                                //读取入壳机2号步序
                                OperateResult<Int16> R_ProcessSteps_up = rkplc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5306");
                                //将步序写入agv
                                OperateResult W_stationDockSteps_up = agvplcZZ.SiemensPLCClient.SiemensS7NetClient.Write("DB1002.4090", R_ProcessSteps_up.Content);
                                WriteLog.GetLog().Write($"-------------- {rksb}上料口信息传递结束,时间:{DateTime.Now} -------------- {Environment.NewLine}", $"{rksb}上料口信息传递");
                                #endregion
                            }
                            catch (Exception ex)
                            {
                            }
                            Thread.Sleep(200);
                        }
                    });
                    //下料口
                    Task.Run(() =>
                    {
                        while (true)
                        {
                            try
                            {
                                if (WCSService.Clients == null)
                                {
                                    continue;
                                }
                                PLCClient rkplc = WCSService.Clients.Find(v => v.PLCName == rksb);
                                if (rkplc == null)
                                {
                                    continue;
                                }
                                PLCClient agvplc = WCSService.Clients.Find(v => v.PLCName == "组装AGV调度");
                                if (agvplc == null)
                                {
                                    continue;
                                }
                                #region ä¸‹æ–™å£
                                WriteLog.GetLog().Write($"{rksb}下料口信息传递开始,时间:{DateTime.Now} --------------{Environment.NewLine}", $"{rksb}下料口信息传递");
                                //入壳机2号报警
                                bool GYC_RBJ = Convert.ToBoolean(rkplc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5302").Content);
                                // AGV获取入壳机2号报警信号
                                OperateResult AGV_WBJ = agvplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1002.4292", GYC_RBJ);
                                // AGV报警信号
                                OperateResult<bool> AGV_RBJ = agvplc.SiemensPLCClient.SiemensS7NetClient.ReadBool("DB1002.4392");
                                int RBJ = Convert.ToInt32(AGV_RBJ.Content);
                                //入壳机2号获取AGV报警信号
                                OperateResult GFC_WBJ = rkplc.ModbusPLCClient.ModbusTcpNetClient.Write("5304", RBJ);
                                // è¯»å–agv下料口请求进入
                                OperateResult<Int16> R_Down1_bzR = agvplc.SiemensPLCClient.SiemensS7NetClient.ReadInt16("DB1002.4390");
                                // å†™å…¥å…¥å£³æœº2号下料口AGV请求进入
                                OperateResult W_ProcessSteps1 = rkplc.ModbusPLCClient.ModbusTcpNetClient.Write("5309", R_Down1_bzR.Content);
                                // è¯»å–入壳机2号下料口是否允许AGV请求进入
                                OperateResult<Int16> R_ProcessSteps1 = rkplc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5308");
                                OperateResult W_stationDockSteps1 = agvplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1002.4290", R_ProcessSteps1.Content);
                                WriteLog.GetLog().Write($"{rksb}下料口信息传递结束,时间:{DateTime.Now} --------------{Environment.NewLine}", $"{rksb}下料口信息传递");
                                #endregion
                            }
                            catch (Exception ex) { }
                            Thread.Sleep(200);
                        }
                    });
                }
            }
        }
    }
}
wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/RKSB_DownTask.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,128 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using WIDESEA_Common;
using WIDESEA_Common.LoctionEnum;
using WIDESEA_Common.Tools;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.Utilities;
using WIDESEA_Entity.DomainModels;
using WIDESEA_Services.IRepositories;
using WIDESEA_Services.Repositories;
using WIDESEA_WCS.WCSClient;
namespace WIDESEA_WCS
{
    public partial class StackerExecutor
    {
        private static int _readRKSB_Down = 0;
        /// <summary>
        /// è´Ÿæžæ¶‚布下料工作逻辑
        /// </summary>
        /// <param name="client"></param>
        public static void RKSB_DownTask()
        {
            if (Interlocked.Exchange(ref _readRKSB_Down, 1) == 0)
            {
                Task.Run(() =>
                {
                    try
                    {
                        VOLContext Context = new VOLContext();
                        Ibase_ware_locationRepository locRepository = new base_ware_locationRepository(Context);
                        Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
                        Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
                        List<string> RKSBS = new List<string> { "入壳机1", "入壳机2" };
                        //循环处理涂布设备下料请求
                        foreach (var RKSB in RKSBS)
                        {
                            if (WCSService.Clients == null)
                            {
                                return;
                            }
                            PLCClient plc = WCSService.Clients.Find(v => v.PLCName == RKSB);
                            if (plc == null)
                            {
                                continue;
                            }
                            string SB_Up_Location = "XL-RKSB" + RKSB.Replace("入壳机", "");//拼接入壳下料口
                            string equipType = "RKSB" + RKSB.Replace("入壳机", "");//设备
                            //获取当前入壳设备是否有下料AGV任务
                            var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == SB_Up_Location);
                            //有结束本次循环
                            if (SBtask != null) { continue; }
                            //获取当前设备的下料请求
                            int requestRKDown = plc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5308").Content;
                            if (requestRKDown==4)
                            {
                                #region è®°å½•下料请求信号
                                WriteLog.GetLog().Write($"{plc.PLCName}下料请求:{requestRKDown}---{DateTime.Now}", $"入壳机下料请求");
                                #endregion
                                //找到对应缓存架货位,并确认空框
                                dt_stationinfo location = stationinfoRepository.Find(x => x.area == equipType && x.tpgd == false
                                && x.wlgd == false && x.task == false).OrderBy(x => x.greenbuttontime).FirstOrDefault();
                                if (location != null)
                                {
                                    WebResponseContent content = new WebResponseContent();
                                    locRepository.DbContextBeginTransaction(() =>
                                    {
                                        //生成涂布机下料任务
                                        dt_agvtask agvtask = new dt_agvtask()
                                        {
                                            agv_id = Guid.NewGuid(),
                                            agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
                                            agv_fromaddress = SB_Up_Location,//以设备起点
                                            agv_toaddress = location.stationCode,
                                            agv_code = "组装AGV调度",
                                            agv_remark = "入壳下料任务",
                                            agv_taskstate = AGVTaskStateEnum.Create.ToString(),
                                            agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(),
                                            agv_worktype = 1,//工作类型
                                            agv_materielid = "",
                                            agv_qty = 1,
                                            agv_createtime = DateTime.Now,
                                            agv_grade = 0,//任务优先级
                                            agv_userid = "WCS",
                                            agv_barcode = "",
                                        };
                                        location.task = true;
                                        var entry = locRepository.DbContext.ChangeTracker.Entries<base_ware_location>().FirstOrDefault();
                                        if (entry != null)
                                        {
                                            entry.State = EntityState.Detached;
                                        }
                                        int x = locRepository.Update(location, d => new { d.task}, true);
                                        if (x == 1)
                                        {
                                            agvRepository.Add(agvtask, true);
                                            return content.OK();
                                        }
                                        else
                                        {
                                            return content.Error();
                                        }
                                    });
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        WriteLog.GetLog().Write($"入壳机下料:{DateTime.Now} --------------{ex}", $"入壳机下料调度Error");
                    }
                    finally
                    {
                        Interlocked.Exchange(ref _readRKSB_Down, 0);
                    }
                });
            }
        }
    }
}
wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/RKSB_UPTask.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,115 @@
using Microsoft.CodeAnalysis;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using WIDESEA_Common;
using WIDESEA_Common.LoctionEnum;
using WIDESEA_Common.Tools;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Entity.DomainModels;
using WIDESEA_Services.IRepositories;
using WIDESEA_Services.Repositories;
using WIDESEA_WCS.WCSClient;
namespace WIDESEA_WCS
{
    public partial class StackerExecutor
    {
        private static int _readRKSB_Up = 0;
        /// <summary>
        /// å…¥å£³æœºä¸Šæ–™
        /// </summary>
        /// <param name="client"></param>
        public static void RKSB_UpTask()
        {
            if (Interlocked.Exchange(ref _readRKSB_Up, 1) == 0)
            {
                Task.Run(() =>
                {
                    try
                    {
                        VOLContext Context = new VOLContext();
                        Ibase_ware_locationRepository locRepository = new base_ware_locationRepository(Context);
                        Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
                        Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
                        List<string> RKSBS = new List<string> { "入壳机1", "入壳机2"};
                        //循环处理入壳机设备上料请求
                        foreach (var RKSB in RKSBS)
                        {
                            if (WCSService.Clients == null)
                            {
                                return;
                            }
                            PLCClient plc = WCSService.Clients.Find(v => v.PLCName == RKSB);
                            if (plc == null)
                            {
                                continue;
                            }
                            string SB_Up_Location = "SL-RKSB" + RKSB.Replace("入壳机", "");//拼接入壳上料口
                            string equipType = "RKSB" + RKSB.Replace("入壳机", "");//设备
                            //获取当前入壳设备是否有上料AGV任务
                            var SBtask = agvRepository.FindFirst(f => f.agv_toaddress == SB_Up_Location);
                            //有结束本次循环
                            if (SBtask != null) { continue; }
                            //获取当前设备的上料请求
                            int requestRKUP = plc.ModbusPLCClient.ModbusTcpNetClient.ReadInt16("5306").Content;
                            if (requestRKUP==4)
                            {
                                //找到对应缓存架货位,并确认有料
                                dt_stationinfo location = stationinfoRepository.Find(x=>x.area== equipType && x.greenbutton == true
                                && x.tpgd == true && x.wlgd == true && x.task == false).OrderBy(x=>x.greenbuttontime).FirstOrDefault();
                                if (location != null)
                                {
                                    #region è®°å½•上料请求信号
                                    WriteLog.GetLog().Write($"{plc.PLCName}上料请求:{requestRKUP}---{DateTime.Now}", $"入壳机上料请求");
                                    #endregion
                                    //生成入壳机上料任务
                                    dt_agvtask agvtask = new dt_agvtask()
                                    {
                                        agv_id = Guid.NewGuid(),
                                        agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
                                        agv_fromaddress = location.stationCode,
                                        agv_toaddress = SB_Up_Location,
                                        agv_code = "组装AGV调度",
                                        agv_remark = "入壳上料任务",
                                        agv_taskstate = AGVTaskStateEnum.Create.ToString(),
                                        agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(),
                                        agv_worktype = 1,//工作类型
                                        agv_materielid = "",
                                        agv_qty = 1,
                                        agv_createtime = DateTime.Now,
                                        agv_grade = 0,//任务优先级
                                        agv_userid = "WCS",
                                        agv_barcode = "",
                                    };
                                    location.task = true;
                                    int changeCount = locRepository.Update(location, d => new { d.task }, true);
                                    if (changeCount == 1)
                                    {
                                        agvRepository.Add(agvtask, true);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        WriteLog.GetLog().Write($"入壳机上料:{DateTime.Now} --------------{ex}", $"入壳机上料调度Error");
                    }
                    finally
                    {
                        Interlocked.Exchange(ref _readRKSB_Up, 0);
                    }
                });
            }
        }
    }
}
Èë¿Ç»úÐźÅ.png
ÁÖÑó³ÌÐò°ü.zip
Binary files differ