Example #1
0
        /// <summary>貨櫃離站函式</summary>
        public static PostResult DelContainer(Container m)
        {
            PostResult r = new PostResult();

            //取得此碼頭資料
            DataTable dtDockDoor         = DockDoorDataAccess.GetDockDoorList(null, m.ip, null, null, new Pages());
            DataRow   rowDoor            = dtDockDoor.Rows[0];
            string    strDockDoorID      = rowDoor["DockDoorID"].ToString();
            string    strContainerID     = rowDoor["ContainerID"].ToString();
            string    strContainerStatus = rowDoor["ContainerStatus"].ToString();
            string    strCaptionPanelIP  = rowDoor["CaptionPanelIP"].ToString();

            try
            {
                string[] StatusList = new string[] { "I", "O" };
                if (StatusList.Contains(strContainerStatus))
                {
                    //判斷裝卸載數量
                    string strNum, strTotal;
                    GetCountProcess(strDockDoorID, strContainerID, strContainerStatus, out strNum, out strTotal);
                    if (strNum == strTotal)
                    {
                        r.result = "Y";
                        r.msg    = string.Format("櫃號:{0}({1}/{2})已離廠", strContainerID, strNum, strTotal);
                    }
                    else
                    {
                        throw new Exception(string.Format("櫃號:{0}({1}/{2})尚未完成作業", strContainerID, strNum, strTotal));
                    }
                }
                else
                {
                    r.result = "Y";
                    r.msg    = string.Format("櫃號:{0}已離廠", strContainerID);
                }
            }
            catch (Exception ex)
            {
                r.result = "N";
                r.msg    = ex.Message;
            }
            finally
            {
                //清空碼頭目前停靠的貨櫃ID
                using (var db = new DataBase.DataBase(Definition.Conn))
                {
                    db.StrSQL = "UPDATE Innolux_DockDoor SET ContainerID = '', ContainerStatus = '', Alarm = '' WHERE IP = '" + m.ip + "'";
                    db.ExecuteSQL();
                }
            }

            ControlMachine(strCaptionPanelIP, r.msg, 3);
            return(r);
        }
Example #2
0
        /// <summary>清除警報</summary>
        public static void ClearAlarm(string id)
        {
            //取得指定警報中的碼頭
            DataTable dtDoor = DockDoorDataAccess.GetDockDoorList(id, null, null, null, new Pages());

            if (dtDoor.Rows.Count > 0)
            {
                DataRow row               = dtDoor.Rows[0];
                string  strIP             = row["IP"].ToString();
                string  strContainerID    = row["ContainerID"].ToString();
                string  strCaptionPanelIP = row["CaptionPanelIP"].ToString();

                //修改Reader DB,以觸發DB Trigger
                UpdateControlDB(strIP, "UPDATE alarm SET alarm='" + DateTime.Now.ToString("yyyyMMddHHmmss") + "'");

                //清除碼頭的異常狀態
                using (var db = new DataBase.DataBase(Definition.Conn))
                {
                    db.StrSQL = "UPDATE Innolux_DockDoor SET Alarm = '' WHERE DockDoorID = '" + id + "'";
                    db.ExecuteSQL();
                }

                //若有貨櫃停靠,則播放最後一次成功訊息
                if (strContainerID != "")
                {
                    using (var db = new DataBase.DataBase(Definition.Conn))
                    {
                        string strToday = DateTime.Now.ToString("yyyyMMdd");
                        db.StrSQL = "SELECT TOP 1 Msg FROM Innolux_TagLog WHERE (DockDoorID = '" + id + "') AND (Status IN ('Y','A')) AND (Msg LIKE '%" + strContainerID + "%') AND (Convert(varchar, DateTime, 112) = '" + strToday + "') ORDER BY DateTime DESC";
                        string strMsg = db.ExecuteScalar() ?? "";
                        ControlMachine(strCaptionPanelIP, strMsg, 0);
                    }
                }
                else
                {
                    ControlMachine(strCaptionPanelIP, "", 1);
                }
            }
        }
Example #3
0
        //static string DB_Prestr = "";
        /// <summary>貨櫃進站函式</summary>
        public static PostResult AddContainer(Container m)
        {
            PostResult r = new PostResult();
            string     strContainerID = "", strContainerStatus = "";

            try
            {
                //判斷是否有貨櫃標籤
                if (m.containers.Count == 0)
                {
                    throw new Exception("無貨櫃標籤");
                }
                else
                {
                    m.containers = m.containers.Select(x => x.Trim()).ToList();
                }                                                                    //貨櫃號碼去空白

                using (var db = new DataBase.DataBase(Definition.Conn))
                {
                    //檢查是否誤讀到其它貨櫃
                    for (int i = m.containers.Count - 1; i >= 0; i--)
                    {
                        string CID = m.containers[i].Substring(1);
                        db.StrSQL = "SELECT COUNT(*) FROM Innolux_DockDoor WHERE IP <> '" + m.ip + "' AND ContainerID = '" + CID + "'";
                        //ExecuteScalar 返回單行單列的結果集
                        if (db.ExecuteScalar() != "0")
                        {
                            m.containers.RemoveAt(i);
                        }
                    }

                    //判斷過濾後是否只剩一筆貨櫃ID
                    if (m.containers.Count == 1)
                    {
                        strContainerID     = m.containers[0].Substring(1);
                        strContainerStatus = GetContainerStatus(strContainerID);

                        //更新控制器貨櫃狀態
                        UpdateControlDB(m.ip, "UPDATE status SET status='" + strContainerStatus + "'");

                        r.result = strContainerStatus;
                        r.msg    = "櫃號:" + strContainerID + "已進站";
                    }
                    else
                    {
                        throw new Exception("無貨櫃標籤");
                    }
                }
            }
            catch (Exception ex)
            {
                r.result = "N";
                r.msg    = ex.Message;
            }
            finally
            {
                using (var db = new DataBase.DataBase(Definition.Conn))
                {
                    //記錄碼頭目前停靠的貨櫃ID與狀態
                    string strAlarm = (r.result == "N" ? "Y" : "");
                    db.StrSQL = "UPDATE Innolux_DockDoor SET ContainerID = '" + strContainerID + "', ContainerStatus = '" + r.result + "', Alarm = '" + strAlarm + "' WHERE IP = '" + m.ip + "'";
                    db.ExecuteSQL();
                }

                //控制語音與字幕機
                DataTable dtDockDoor        = DockDoorDataAccess.GetDockDoorList(null, m.ip, null, null, new Pages());
                DataRow   rowDoor           = dtDockDoor.Rows[0];
                string    strCaptionPanelIP = rowDoor["CaptionPanelIP"].ToString();
                ControlMachine(strCaptionPanelIP, r.msg, 0);
            }

            return(r);
        }
Example #4
0
        /// <summary>上報至客戶端系統</summary>
        public static PostResult Post(PostModel m)
        {
            PostResult r           = new PostResult();
            string     strToDay    = DateTime.Now.ToString("yyyy/MM/dd");
            DataTable  dtCheckList = new DataTable();

            //取得此碼頭資料
            DataTable dtDockDoor         = DockDoorDataAccess.GetDockDoorList(null, m.ip, null, null, new Pages());
            DataRow   rowDoor            = dtDockDoor.Rows[0];
            string    strDockDoorID      = rowDoor["DockDoorID"].ToString();
            string    strContainerID     = rowDoor["ContainerID"].ToString();
            string    strContainerStatus = rowDoor["ContainerStatus"].ToString();
            string    strCaptionPanelIP  = rowDoor["CaptionPanelIP"].ToString();
            string    strFilterRules     = rowDoor["FilterRules"].ToString();
            int       iMask    = int.Parse(rowDoor["Mask"].ToString());
            int       iMaskOut = int.Parse(rowDoor["MaskOut"].ToString());

            //去除棧板的前後空白
            foreach (var item in m.pallets)
            {
                item.pallet = item.pallet.Trim();
            }

            //記錄原始上報資料
            string strData = JsonConvert.SerializeObject(m);

            //棧板白名單過濾機制
            if (strFilterRules.Trim() != "")
            {
                string[] rules = strFilterRules.Trim().Split(',');
                m.pallets.RemoveAll(x => !rules.Contains(x.pallet.Substring(0, 2)));
            }

            //最得訊號最大值當作浮動參考值
            float maxRefer = 0;

            foreach (var item in m.pallets)
            {
                if (maxRefer < (int.Parse(item.count) * float.Parse(item.rssi)))
                {
                    maxRefer = (int.Parse(item.count) * float.Parse(item.rssi));
                }
            }

            //移除低於Mask過濾值的標籤
            if (strContainerStatus == "I")
            {
                m.pallets.RemoveAll(x => (int.Parse(x.count) * float.Parse(x.rssi)) < (maxRefer * iMask / 100));
            }
            else if (strContainerStatus == "O")
            {
                m.pallets.RemoveAll(x => (int.Parse(x.count) * float.Parse(x.rssi)) < (maxRefer * iMaskOut / 100));
            }

            float kk = (maxRefer * iMask / 100);

            try
            {
                //判斷有無棧板資訊
                if (m.pallets.Count == 0)
                {
                    throw new Exception("無載貨資訊");
                }

                using (var db = new DataBase.OracleDataBase(Definition.WMSConn))
                {
                    //過濾當天已上報的棧板
                    string strRFIDList = string.Join(",", m.pallets.Select(x => "'" + x.pallet + "'"));
                    db.StrSQL = "SELECT RFID FROM " + DB_Prestr + "WMS_RFID_OK_LIST WHERE RFID IN (" + strRFIDList + ") AND TO_CHAR(CREATION_DATE,'yyyy/MM/dd') = '" + strToDay + "'";
                    var list = db.ExecuteDataTable().AsEnumerable().Select(x => x.Field <string>("RFID"));
                    m.pallets.RemoveAll(x => list.Contains(x.pallet));

                    if (m.pallets.Count > 0)
                    {
                        //判斷貨櫃進料或出料狀態(I:收料,O:出料)
                        if (strContainerStatus == "I")
                        {
                            r = POST_IN(strDockDoorID, strContainerID, strContainerStatus, m);
                        }
                        else if (strContainerStatus == "O")
                        {
                            r = POST_OUT(strDockDoorID, strContainerID, strContainerStatus, m);
                        }
                        else
                        {
                            throw new Exception("無" + strContainerID + "貨櫃資訊");
                        }
                    }
                    else
                    {
                        throw new Exception("無載貨資訊");
                    }
                }
            }
            catch (Exception ex)
            {
                //若無讀到棧板資訊則result=0
                r.result = (ex.Message == "無載貨資訊" ? "0" : "N");
                r.msg    = ex.Message;

                if (r.result == "N")
                {
                    //逐筆新增非法資料
                    using (var db = new DataBase.OracleDataBase(Definition.WMSConn))
                    {
                        foreach (var item in m.pallets)
                        {
                            db.StrSQL = @"INSERT INTO " + DB_Prestr + "WMS_RFID_NG_LIST (DOCK_DOOR_NO, RFID, ERR_MSG) VALUES('" + strDockDoorID + "', '" + item.pallet + "', '" + ex.Message + "')";
                            db.ExecuteSQL();
                        }
                    }
                }
            }
            finally
            {
                if (strContainerStatus == "I")
                {
                    AddTagLog(strDockDoorID, iMask, m, r, strData);
                }
                else if (strContainerStatus == "O")
                {
                    AddTagLog(strDockDoorID, iMaskOut, m, r, strData);
                }

                //若有正常回應,則控制字幕機
                string[] strs = new string[] { "Y", "A", "N" };
                if (strs.Contains(r.result))
                {
                    ControlMachine(strCaptionPanelIP, r.msg, 0);
                }
            }

            return(r);
        }