/// <summary>
        /// 5号车号识别
        /// </summary>
        /// <param name="carNumber">车号</param>
        /// <param name="carDate">时间</param>
        /// <param name="direction">方向</param>
        /// <param name="carmodel">车型</param>
        /// <returns></returns>
        public static bool CarSpot5Data(Action <string, eOutputType> output, CmcsTrainRecognition trainPass)
        {
            CmcsTransport transport = Dbers.GetInstance().SelfDber.Entity <CmcsTransport>("where TransportNo='" + trainPass.CarNumber + "' and InfactoryTime>=to_date('" + DateTime.Now.Date.AddDays(-1) + "','yyyy/mm/dd HH24:MI:SS') order by InfactoryTime desc");

            if (transport == null)
            {
                return(false);
            }

            if (trainPass.Direction == "进厂" && transport.InfactoryTime > DateTime.MinValue)
            {
                if (trainPass.OrderNum == 2)                //处理牵车太靠近 两节车都识别到车号 后面一节车顶掉前一节车
                {
                    try
                    {
                        CmcsTrainRecognition lastentity = Dbers.GetInstance().SelfDber.Entity <CmcsTrainRecognition>("where CrossTime=:CrossTime and OrderNum=1 and DataFlag=1 order by CrossTime", new { CrossTime = trainPass.CrossTime });
                        if (lastentity != null)
                        {
                            CarInfoMutual mutual = DcDbers.GetInstance().TurnCarWeighterMutualDber.Entity <CarInfoMutual>("where CarNumber=:CarNumber and CreateDate>=:CreateDate", new { CarNumber = lastentity.CarNumber, CreateDate = DateTime.Now.AddDays(-1) });
                            if (mutual == null || mutual.SuttleWeight == 0)
                            {
                                return(false);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        output("处理连续车号:" + ex.Message, eOutputType.Error);
                    }
                }
                CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_TrunOver_2, eSignalDataName.当前车号.ToString(), trainPass.CarNumber);

                //插入车辆信息至翻车衡交互数据库
                if (InsertCarToTurnCarWeighter("#2", transport))
                {
                    output(string.Format("向{0}插入一条数据", GlobalVars.MachineCode_TrunOver_2), eOutputType.Normal);
                }

                //更改翻车状态
                if (TurnTransportPosition(trainPass.CarNumber))
                {
                    output(string.Format("{0}更改为已翻车", trainPass.CarNumber), eOutputType.Normal);
                }
                return(true);
            }
            else if (trainPass.Direction == "出厂")
            {
                CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_TrunOver_2, eSignalDataName.当前车号.ToString(), string.Empty);
                //更改翻车状态
                if (UnTurnTransportPosition(trainPass.CarNumber))
                {
                    output(string.Format("{0}更改为未翻车", trainPass.CarNumber), eOutputType.Normal);
                }
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// 1号车号识别
        /// </summary>
        /// <param name="carNumber">车号</param>
        /// <param name="carDate">时间</param>
        /// <param name="direction">方向</param>
        /// <param name="infactoryordernumber">顺序号</param>
        /// <param name="carmodel">车型</param>
        /// <returns></returns>
        public static bool CarSpot1Data(Action <string, eOutputType> output, CmcsTrainRecognition trainPass)
        {
            int res = 0;

            if (trainPass.Direction == "进厂")
            {
                CmcsTrainWeightRecord transportOver = Dbers.GetInstance().SelfDber.Entity <CmcsTrainWeightRecord>(" where TrainNumber='" + trainPass.CarNumber + "' and IsTurnover='已翻' and ArriveTime>=to_date('" + DateTime.Now.Date.AddDays(-2) + "','yyyy/mm/dd HH24:MI:SS')");
                CmcsTrainWeightRecord transport     = Dbers.GetInstance().SelfDber.Entity <CmcsTrainWeightRecord>(" where TrainNumber='" + trainPass.CarNumber + "' and IsTurnover='未翻' and ArriveTime>=to_date('" + DateTime.Now.Date.AddDays(-2) + "','yyyy/mm/dd HH24:MI:SS')");
                if (transport == null)
                {
                    // 此判断是过滤车辆出厂后立马进厂合并不同轨道车辆的情况,时间相差几分钟
                    if (transportOver != null)
                    {
                        return(true);
                    }

                    res += Dbers.GetInstance().SelfDber.Insert(new CmcsTrainWeightRecord()
                    {
                        PKID         = trainPass.Id,
                        TrainNumber  = trainPass.CarNumber,
                        ArriveTime   = trainPass.CrossTime,
                        TrainType    = trainPass.CarModel,
                        IsTurnover   = "未翻",
                        MachineCode  = trainPass.MachineCode,
                        DataFlag     = 0,
                        TicketWeight = (decimal)CommonDAO.GetInstance().GetTrainRateLoadByTrainType(trainPass.CarModel),
                        OrderNumber  = trainPass.OrderNum,
                        GrossTime    = trainPass.CrossTime,
                        SkinTime     = trainPass.CrossTime,
                        LeaveTime    = trainPass.CrossTime,
                        UnloadTime   = trainPass.CrossTime,
                    });
                    return(true);
                }
            }
            else if (trainPass.Direction == "出厂")
            {
                CmcsTrainWeightRecord trainRecord = Dbers.GetInstance().SelfDber.Entity <CmcsTrainWeightRecord>("where TrainNumber=:TrainNumber order by ArriveTime desc", new { TrainNumber = trainPass.CarNumber });
                if (trainRecord != null)
                {
                    trainRecord.LeaveTime = trainPass.CrossTime;
                    Dbers.GetInstance().SelfDber.Update(trainRecord);

                    CmcsTransport transport = Dbers.GetInstance().SelfDber.Entity <CmcsTransport>("where PKID=:PKID order by InfactoryTime desc", new { PKID = trainPass.Id });
                    if (transport != null)
                    {
                        transport.OutfactoryTime = trainPass.CrossTime;
                        Dbers.GetInstance().SelfDber.Update(transport);
                    }
                }
                //移除定位信息
                RemoveTransportPosition(trainPass.CarNumber);
                return(true);
            }
            output(string.Format("向{0}翻车衡发送数据{1}条", trainPass.MachineCode, res), eOutputType.Normal);
            return(false);
        }
        /// <summary>
        /// 2号车号识别
        /// </summary>
        /// <param name="carNumber">车号</param>
        /// <param name="carDate">时间</param>
        /// <param name="direction">方向</param>
        /// <param name="infactoryordernumber">顺序号</param>
        /// <param name="carmodel">车型</param>
        /// <returns></returns>
        public static bool CarSpot2Data(Action <string, eOutputType> output, CmcsTrainRecognition trainPass)
        {
            if (trainPass == null)
            {
                return(false);
            }

            if (trainPass.Direction == "进厂")
            {
                CmcsTrainCarriagePass transport = Dbers.GetInstance().SelfDber.Entity <CmcsTrainCarriagePass>("where TrainNumber='" + trainPass.CarNumber + "' and PassTime>=to_date('" + DateTime.Now.Date.AddDays(-1) + "','yyyy/mm/dd HH24:MI:SS') order by PassTime desc");
                if (transport == null)
                {
                    transport             = new CmcsTrainCarriagePass();
                    transport.TrainNumber = trainPass.CarNumber;
                    transport.CarModel    = trainPass.CarModel;
                    transport.MachineCode = trainPass.MachineCode;
                    transport.PassTime    = trainPass.CrossTime;
                    transport.Direction   = trainPass.Direction;
                    transport.OrderNum    = trainPass.OrderNum;
                    transport.DataFlag    = 0;
                    transport.PKID        = trainPass.Id;
                    Dbers.GetInstance().SelfDber.Insert(transport);
                }
                else
                {
                    transport.MachineCode = trainPass.MachineCode;
                    Dbers.GetInstance().SelfDber.Update(transport);
                }

                CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_HCJXCYJ_1, eSignalDataName.当前车号.ToString(), trainPass.CarNumber);

                // 插入定位信息
                if (InsertTransportPosition("#2", trainPass.CarNumber))
                {
                    output(string.Format("#2轨道插入定位信息;{0}车号识别 车号:{1}", trainPass.MachineCode, trainPass.CarNumber), eOutputType.Normal);
                    return(true);
                }
            }
            else if (trainPass.Direction == "出厂")
            {
                CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_HCJXCYJ_2, eSignalDataName.当前车号.ToString(), string.Empty);
                // 移除定位信息
                if (RemoveTransportPosition(trainPass.CarNumber))
                {
                    output(string.Format("#2轨道移除定位信息;{0}车号识别 车号:{1}", trainPass.MachineCode, trainPass.CarNumber), eOutputType.Normal);
                    return(true);
                }
            }

            return(false);
        }
Beispiel #4
0
        private void superGridControl1_DataBindingComplete(object sender, GridDataBindingCompleteEventArgs e)
        {
            foreach (GridRow item in e.GridPanel.Rows)
            {
                try
                {
                    CmcsTrainRecognition CmcsTrainRecognition = item.DataItem as CmcsTrainRecognition;

                    item.Cells["cellMACHINECODE"].Value = "#" + CmcsTrainRecognition.MACHINECODE + "翻车机";
                }
                catch (Exception)
                {
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// 同步车号识别数据
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public void SyncTrainRecognitionInfo(Action <string, eOutputType> output)
        {
            CmcsTrainRecognition train = Dbers.GetInstance().SelfDber.Entity <CmcsTrainRecognition>("where Status=0 and MachineCode=1 order by CrossTime desc");

            CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_Recognition_1, eSignalDataName.当前车号.ToString(), train != null ? train.CarNumber : "");

            CmcsTrainRecognition train2 = Dbers.GetInstance().SelfDber.Entity <CmcsTrainRecognition>("where Status=0 and MachineCode=2 order by CrossTime desc");

            CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_Recognition_2, eSignalDataName.当前车号.ToString(), train2 != null ? train2.CarNumber : "");

            int CrossNumber = Dbers.GetInstance().SelfDber.Count <CmcsTrainRecognition>("where CrossTime>=:CrossTime and MachineCode=1 order by CrossTime desc", new { CrossTime = DateTime.Now.Date });

            CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_Recognition_1, eSignalDataName.当日已过车数.ToString(), CrossNumber.ToString());

            int CrossNumber2 = Dbers.GetInstance().SelfDber.Count <CmcsTrainRecognition>("where CrossTime>=:CrossTime and MachineCode=2 order by CrossTime desc", new { CrossTime = DateTime.Now.Date });

            CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_Recognition_2, eSignalDataName.当日已过车数.ToString(), CrossNumber2.ToString());

            if (train != null)
            {
                CmcsTrainWeightRecord trainWeight = Dbers.GetInstance().SelfDber.Entity <CmcsTrainWeightRecord>("where TrainNumber=:TrainNumber and GrossTime<:GrossTime and GrossWeight=0 order by GrossTime desc", new { TrainNumber = train.CarNumber, GrossTime = train.CrossTime });
                CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_Recognition_2, eSignalDataName.当前记录Id.ToString(), trainWeight != null ? trainWeight.PKID : "");
            }
            if (train2 != null)
            {
                CmcsTrainWeightRecord trainWeight2 = Dbers.GetInstance().SelfDber.Entity <CmcsTrainWeightRecord>("where TrainNumber=:TrainNumber and GrossTime<:GrossTime and GrossWeight=0 order by GrossTime desc", new { TrainNumber = train2.CarNumber, GrossTime = train2.CrossTime });
                CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_Recognition_2, eSignalDataName.当前记录Id.ToString(), trainWeight2 != null ? trainWeight2.PKID : "");
            }

            //入场总车数
            int WeightTotal = CommonDAO.GetInstance().SelfDber.Count <CmcsTrainWeightRecord>("where ArriveTime>=:ArriveTime", new { ArriveTime = DateTime.Now.Date });
            //翻车总车数
            int GrossTotal = CommonDAO.GetInstance().SelfDber.Count <CmcsTrainRecognition>("where CrossTime>=:CrossTime ", new { CrossTime = DateTime.Now.Date });

            //待翻车数
            CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_TrunOver, eSignalDataName.当日待翻车数.ToString(), (WeightTotal - GrossTotal).ToString());

            //检测火车入场时间
            IList <CmcsTrainWeightRecord> list = CommonDAO.GetInstance().SelfDber.Entities <CmcsTrainWeightRecord>("where ArriveTime>=:ArriveTime", new { ArriveTime = DateTime.Now.Date });

            if (list != null)
            {
                IList <CmcsTrainWeightRecord> list_over = list.Where(a => (DateTime.Now - a.ArriveTime).Hours > CommonDAO.GetInstance().GetCommonAppletConfigInt32("火车入场最长时间")).ToList();
                if (list_over != null && list_over.Count > 0)
                {
                    string msgContent = string.Empty;
                    if (list_over.Count < 6)
                    {
                        msgContent = "火车入场超时:";
                        IList <string> TrainNumbers = list_over.Select(a => a.TrainNumber).ToList();
                        foreach (string item in TrainNumbers)
                        {
                            msgContent += item + ",";
                        }
                        msgContent = msgContent.TrimEnd(',');
                    }
                    else
                    {
                        msgContent = string.Format("火车入场:{0}节车厢超时,请到火车入场列表查看", list_over.Count);
                    }
                    CommonDAO.GetInstance().SaveSysMessage("轨道衡", msgContent);
                }
            }
        }