private bool SSJInWareCommand(ref TransportStr si)
        {
            bool flag = false;

            if (!HsWcsReadSSJ(ref si))
            {
                flag = false;
                return(false);
            }
            si.TRAYCODE = string.Empty;

            if (si.Weight > 700)
            {
                NotifyEvent?.Invoke($"货物超重,请注意!重量为{si.Weight}");
                logWrite.WriteLog($"货物超重,请注意!重量为{si.Weight}");
                string str = $"称重重量:{Math.Floor(si.Weight)}\r货物超重,请注意!";
                if (dcsaveledstr[si.SSJID] != str)
                {
                    LedSendStr(si.SSJID, str, 2);
                }
                return(false);
            }
            if (si.Weight > 1)
            {
                flag = true;
                DataSet ds = new DataSet();
                DataTrans.D_GetInwareTask(si.SSJID);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["RESERVE3"]?.ToString() != "1")
                    {
                        DataTrans.P_UpActWeight(ds.Tables[0].Rows[0]["TASKID"].ToString().Trim(), si.Weight.ToString());
                    }
                    si.TRAYCODE = ds.Tables[0].Rows[0]["TRAYCODE"].ToString().Trim();
                    string str = $"托盘条码{ds.Tables[0].Rows[0]["TRAYCODE"].ToString().Trim()}\r物料编码{ds.Tables[0].Rows[0]["productcode"].ToString().Trim()}\r物料名称:{ds.Tables[0].Rows[0]["productname"].ToString().Trim()}\r物料批次:{ds.Tables[0].Rows[0]["lotinfo"].ToString().Trim()}\r重量/称重重量:{ds.Tables[0].Rows[0]["assignnum"].ToString().Trim()}/{Math.Floor(si.Weight)}";
                    if (dcsaveledstr[si.SSJID] != str)
                    {
                        LedSendStr(si.SSJID, str, 0);
                    }
                    else
                    {
                        flag = false;
                    }
                }
                else
                {
                    string str = $"称重重量:{Math.Floor(si.Weight).ToString()}\r";
                    if (dcsaveledstr[si.SSJID] != str)
                    {
                        LedSendStr(si.SSJID, str, 2);
                    }
                    else
                    {
                        flag = false;
                    }
                    logWrite.WriteLog($"请确定输送机{si.SSJID}是否有创建任务!");
                }
            }
            else
            {
                string str = string.Empty;
                if (dcsaveledstr[si.SSJID] != str)
                {
                    LedSendStr(si.SSJID, str, 2);
                }
            }
            return(flag);
        }
Beispiel #2
0
        /// <summary>
        /// 入库口待执行任务发送给AGV
        /// </summary>
        private void SendToAgvMsg()
        {
            while (true)
            {
                if (log.DataFileName != $"{DateTime.Now:yyyyMMdd}业务逻辑.txt")
                {
                    log = new Log("业务逻辑", @".\RGV日志\");
                }
                for (int i = 1; i <= 5; i++)
                {
                    if (i == 5)
                    {
                        //查询入口载货台
                        TransportStr rkssj = lsTransport.Find(s => s.DTYPE == "106" && s.BTID == "1");
                        if (rkssj == null)
                        {
                            continue;
                        }
                        DataSet ds = DataTrans.D_GetInwareTask(rkssj.SSJID);
                        if (ds != null && ds.Tables[0].Rows.Count > 0)
                        {
                            //查询目标巷道输送机是否空闲
                            TransportStr ts = lsTransport.Find(si => si.DTYPE == "105" && si.ALLEYID == ds.Tables[0].Rows[0]["TCARGO_ALLEY_ID"].ToString() && si.KXBZ == "1");

                            if (ts == null)
                            {
                                continue;
                            }
                            if (ds.Tables[0].Rows.Count == 1)
                            {
                                //查入库在途,在途存在,则不发目的地
                                int n = DataTrans.D_GetRkOnJobByDes(ds.Tables[0].Rows[0]["TCAGRO_ALLEY_ID"].ToString());
                                if (n > 0)
                                {
                                    continue;
                                }
                                var dessj = lsTransport.Find(t => t.ALLEYID == ds.Tables[0].Rows[0]["TCARGO_ALLEY_ID"].ToString());
                                if (dessj == null)
                                {
                                    continue;
                                }
                                string          desaddress = rkssj.VAR5;
                                string          msg        = string.Empty;
                                SendToAgvInfo   req        = ToModel(ds, PallentsInTaskType, rkssj.VAR5, dessj.VAR5);
                                SendToAgvResult result     = SendTask(req);

                                if (result.Message == "成功")
                                {
                                    string zxrwh = string.Empty;
                                    if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["TASKID"].ToString()))
                                    {
                                        zxrwh = ds.Tables[0].Rows[0]["TASKNO"].ToString();
                                    }
                                    else
                                    {
                                        zxrwh = DataTrans.D_AllotTaskno().ToString();
                                    }
                                    int m = DataTrans.D_UpdateRkSendToAgv(ds.Tables[0], zxrwh, rkssj.SSJID, ds.Tables[0].Rows[0]["TCARGO_ALLEY_ID"].ToString(), out msg);
                                    if (m > 0)
                                    {
                                        NotifyEvent?.Invoke("S", $"调度指令{ds.Tables[0].Rows[0]["Taskid"]}更新成功");
                                        log.WriteLog($"调度指令{ds.Tables[0].Rows[0]["Taskid"]}更新成功");
                                    }
                                    else
                                    {
                                        string res = string.IsNullOrEmpty(msg) ? "更新失败" : $"更新出现异常!异常信息为{msg}";
                                        NotifyEvent?.Invoke("S", $"调度指令{ds.Tables[0].Rows[0]["Taskid"]}{res}");
                                        log.WriteLog($"调度指令{ds.Tables[0].Rows[0]["Taskid"]}{res}");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        //查询入口载货台
                        var rkssj = lsTransport.Find(si => si.DTYPE == "101" && si.BTID == i.ToString());
                        var wxssj = lsTransport.Find(si => si.DTYPE == "107" && si.BTID == i.ToString());
                        if (rkssj == null || wxssj == null)
                        {
                            continue;
                        }
                        DataSet ds = DataTrans.D_GetInwareTask(rkssj.SSJID);
                        if (ds != null && ds.Tables[0].Rows.Count > 0)
                        {
                            //如果称重实际重量未更新不能给AGV下发指令
                            if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["actweight"].ToString()))
                            {
                                continue;
                            }
                            //查询目标巷道输送机是否空闲
                            var ts = lsTransport.Find(si => si.DTYPE == "105" && si.ALLEYID == ds.Tables[0].Rows[0]["TCARGO_ALLEY_ID"].ToString() && si.KXBZ == "1");
                            if (ts == null)
                            {
                                continue;
                            }
                            if (ds.Tables[0].Rows.Count == 1)
                            {
                                //查入库在途,在途存在,则不发目的地
                                int n = DataTrans.D_GetRkOnJobByDes(ds.Tables[0].Rows[0]["TCARGO_ALLEY_ID"].ToString());
                                if (n > 0)
                                {
                                    continue;
                                }
                                string          msg    = string.Empty;
                                SendToAgvInfo   req    = ToModel(ds, InTaskType, rkssj.VAR5, wxssj.VAR5);
                                SendToAgvResult result = SendTask(req);
                                if (result.Message == "成功")
                                {
                                    string zxrwh = string.Empty;
                                    if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["TASKNO"].ToString()))
                                    {
                                        zxrwh = ds.Tables[0].Rows[0]["TASKNO"].ToString();
                                    }
                                    else
                                    {
                                        zxrwh = DataTrans.D_AllotTaskno().ToString();
                                    }
                                    int m = DataTrans.D_UpdateRkSendToAgv(ds.Tables[0], zxrwh, rkssj.SSJID, ds.Tables[0].Rows[0]["TCARGO_ALLEY_ID"].ToString(), out msg);
                                    if (m > 0)
                                    {
                                        NotifyEvent?.Invoke("S", $"调度指令{ds.Tables[0].Rows[0]["Taskid"]}更新成功");
                                        log.WriteLog($"调度指令{ds.Tables[0].Rows[0]["Taskid"]}更新成功");
                                    }
                                    else
                                    {
                                        string res = string.IsNullOrEmpty(msg) ? "更新失败" : $"更新出现异常!异常信息为{msg}";
                                        NotifyEvent?.Invoke("S", $"调度指令{ds.Tables[0].Rows[0]["Taskid"]}{res}");
                                    }
                                }
                            }
                        }
                        else if (ds.Tables[0].Rows.Count > 1)
                        {
                            string[] arr     = Array.ConvertAll(ds.Tables[0].Rows.Cast <DataRow>().ToArray(), r => r["TASKID"].ToString());
                            string   taskstr = string.Join(",", arr, 0, arr.Length);
                            NotifyEvent?.Invoke("S", $"入库口{i}存在多个待执行任务,请检查并进行处理!待执行任务id{taskstr}");
                            log.WriteLog($"入库口{i}存在多个待执行任务,请检查并进行处理!待执行任务id{taskstr}");
                        }
                    }
                }
                Thread.Sleep(500);
            }
        }