Esempio n. 1
0
        /// <summary>
        /// 获取人员计划,只获取计划简略信息及人员信息
        /// </summary>
        /// <param name="planid"></param>
        /// <param name="Plan"></param>
        /// <returns></returns>
        public static Boolean GetTrainmanBrief(string planid, TrainmanPlan Plan)
        {
            string sql = @"select top 1 * from VIEW_Plan_Trainman where strTrainPlanGUID = @planid";

            SqlParameter[] sqlparam = { new SqlParameter("@planid", planid) };
            DataTable      dt       = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, sql, sqlparam).Tables[0];

            if (dt.Rows.Count == 0)
            {
                return(false);
            }
            else
            {
                Plan.trainPlan.planID         = dt.Rows[0]["strTrainPlanGUID"].ToString();
                Plan.trainPlan.lastArriveTime = Convert.ToDateTime(dt.Rows[0]["dtlastArriveTime"]);
                Plan.trainPlan.startTime      = Convert.ToDateTime(dt.Rows[0]["dtStartTime"]);
                Plan.trainPlan.createTime     = Convert.ToDateTime(dt.Rows[0]["dtCreateTime"]);

                Plan.tmGUID1 = dt.Rows[0]["strTrainmanGUID1"].ToString();
                Plan.tmGUID2 = dt.Rows[0]["strTrainmanGUID2"].ToString();
                Plan.tmGUID3 = dt.Rows[0]["strTrainmanGUID3"].ToString();
                Plan.tmGUID4 = dt.Rows[0]["strTrainmanGUID4"].ToString();

                Plan.tmid1 = dt.Rows[0]["strTrainmanNumber1"].ToString();
                Plan.tmid2 = dt.Rows[0]["strTrainmanNumber2"].ToString();
                Plan.tmid3 = dt.Rows[0]["strTrainmanNumber3"].ToString();
                Plan.tmid4 = dt.Rows[0]["strTrainmanNumber4"].ToString();

                Plan.tmname1 = dt.Rows[0]["strTrainmanName1"].ToString();
                Plan.tmname2 = dt.Rows[0]["strTrainmanName2"].ToString();
                Plan.tmname3 = dt.Rows[0]["strTrainmanName3"].ToString();
                Plan.tmname4 = dt.Rows[0]["strTrainmanName4"].ToString();

                return(true);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 根据人员工号及事件时间获取出勤计划,取事件时间向前3天至当前时间的最后一条计划
        /// </summary>
        /// <param name="tmid"></param>
        /// <param name="eventTime"></param>
        /// <param name="Plan"></param>
        /// <returns></returns>
        public static Boolean GetTrainPlanBriefByRange(string tmid, DateTime eventTime, TrainmanPlan Plan, out int tmindex)
        {
            tmindex = 1;

            string sql = @"select top 1 * from VIEW_Plan_Trainman 
                    where dtStartTime > DATEADD (Day,-3,@eventTime) and dtStartTime < @eventTime  and nPlanState >= 4 
                    and  ((strTrainmanNumber1 = @tmid) or 
                    (strTrainmanNumber2 = @tmid) or 
                    (strTrainmanNumber3 = @tmid) or 
                    (strTrainmanNumber4 = @tmid)) order by dtStartTime desc";

            SqlParameter[] sqlParams =
            {
                new SqlParameter("@eventTime", eventTime),
                new SqlParameter("@tmid",      tmid)
            };

            DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, sql, sqlParams).Tables[0];

            if (dt.Rows.Count == 0)
            {
                return(false);
            }
            else
            {
                Plan.trainPlan.planID         = dt.Rows[0]["strTrainPlanGUID"].ToString();
                Plan.trainPlan.lastArriveTime = DataTypeConvert.ToDateTime(dt.Rows[0]["dtlastArriveTime"]);
                Plan.trainPlan.startTime      = DataTypeConvert.ToDateTime(dt.Rows[0]["dtStartTime"]);
                Plan.trainPlan.createTime     = DataTypeConvert.ToDateTime(dt.Rows[0]["dtCreateTime"]);

                Plan.tmGUID1 = dt.Rows[0]["strTrainmanGUID1"].ToString();
                Plan.tmGUID2 = dt.Rows[0]["strTrainmanGUID2"].ToString();
                Plan.tmGUID3 = dt.Rows[0]["strTrainmanGUID3"].ToString();
                Plan.tmGUID4 = dt.Rows[0]["strTrainmanGUID4"].ToString();

                Plan.tmid1 = dt.Rows[0]["strTrainmanNumber1"].ToString();
                Plan.tmid2 = dt.Rows[0]["strTrainmanNumber2"].ToString();
                Plan.tmid3 = dt.Rows[0]["strTrainmanNumber3"].ToString();
                Plan.tmid4 = dt.Rows[0]["strTrainmanNumber4"].ToString();

                Plan.tmname1 = dt.Rows[0]["strTrainmanName1"].ToString();
                Plan.tmname2 = dt.Rows[0]["strTrainmanName2"].ToString();
                Plan.tmname3 = dt.Rows[0]["strTrainmanName3"].ToString();
                Plan.tmname4 = dt.Rows[0]["strTrainmanName4"].ToString();

                if (Plan.tmid1 == tmid)
                {
                    tmindex = 1;
                }
                else
                if (Plan.tmid2 == tmid)
                {
                    tmindex = 2;
                }
                else
                if (Plan.tmid3 == tmid)
                {
                    tmindex = 3;
                }

                return(true);
            }
        }
Esempio n. 3
0
        public void SubmitInOutRoomEvent(SubmitInOutRoom Rec, int EventID)
        {
            int    tmindex;
            int    ErrCode   = 0;
            string ErrInfo   = "";
            string eventGUID = Guid.NewGuid().ToString();

            TrainmanPlan plan     = new TrainmanPlan();
            Trainman     trainman = new Trainman();



            if (DBPlan.GetTrainPlanBriefByRange(Rec.tmid, Rec.etime, plan, out tmindex))
            {
                if (DBDictionary.GetTrainman(Rec.tmid, trainman))
                {
                    SubmitTrainmanEvent(Rec, EventID, plan, tmindex, ref ErrInfo, ref ErrCode, ref eventGUID);

                    SubmitInOutRoomRecord(plan.trainPlan.planID, Rec, tmindex, EventID, trainman);
                }
                else
                {
                    ErrCode = 1;
                    ErrInfo = string.Format("没有找到工号为[{0}]的乘务员!", Rec.tmid);
                }
            }
            else
            {
                ErrCode = 1;
                ErrInfo = "没有指定乘务员的计划或机组信息";
            }


            if (ErrCode == 0)
            {
                ErrInfo = "添加成功";
            }



            EventParam eventParam = new EventParam();

            eventParam.eventGUID    = eventGUID;
            eventParam.eventID      = EventID;
            eventParam.ntmis        = Convert.ToInt32(Rec.stmis);
            eventParam.submitRemark = ErrInfo;
            eventParam.submitResult = ErrCode;
            eventParam.strResult    = Rec.strResult.ResultToString();
            eventParam.nresult      = Rec.nresult;
            eventParam.tmid         = Rec.tmid;
            eventParam.etime        = Rec.etime;

            eventParam.strTrainType    = Rec.strTrainType;
            eventParam.strTrainNum     = Rec.strTrainNum;
            eventParam.strCheCi        = Rec.strCheCi;
            eventParam.nLoginType      = Rec.nLoginType;
            eventParam.PhotoID         = Rec.PhotoID;
            eventParam.IsLackOfRest    = Rec.IsLackOfRest;
            eventParam.LackReason      = Rec.LackReason;
            eventParam.ShenHeNumber    = Rec.ShenHeNumber;
            eventParam.ShenHeName      = Rec.ShenHeName;
            eventParam.ShenHeLoginType = Rec.ShenHeLoginType;
            eventParam.ShenHePhotoID   = Rec.ShenHePhotoID;
            eventParam.InRoomTime      = Rec.strResult.InRoomTime;

            //向TAB_Plan_RunEvent_Site中插入数据
            SubmitEventLog(eventParam);
        }
Esempio n. 4
0
        private Boolean SubmitTrainmanEvent(SubmitInOutRoom Rec, int EventID, TrainmanPlan plan, int tmindex,
                                            ref string ErrInfo, ref int ErrCode, ref string eventGUID)
        {
            ErrCode = 0;
            ErrInfo = "";

            RsRunEvent rsEvent = new RsRunEvent();

            if (Rec.tmid == string.Empty)
            {
                ErrCode = 1;
                return(false);
            }

            if (Rec.etime > plan.trainPlan.lastArriveTime)
            {
                ErrCode = 3;
                ErrInfo = "超时被丢弃";
                return(false);
            }

            string tmid1;
            string tmid2;

            //如果已经存在对应计划的事件,则更新事件人员
            if (GetRunEventOfPlan(plan.trainPlan.planID, eteOutRoom, rsEvent))
            {
                tmid1 = rsEvent.strTrainmanNumber1;

                tmid2 = rsEvent.strTrainmanNumber2;

                eventGUID = rsEvent.strRunEventGUID;

                DateTime tempTime = rsEvent.dtEventTime;

                if (Rec.etime > tempTime)
                {
                    tempTime = Rec.etime;
                }

                if (tmindex == 1)
                {
                    tmid1 = Rec.tmid;
                }
                if (tmindex == 2)
                {
                    tmid2 = Rec.tmid;
                }


                UpdateEventTrainman(rsEvent.strRunEventGUID, tmid1, tmid2, tempTime, Rec.strResult.ResultToString());
                return(true);
            }
            else
            {
                tmid1 = "";
                tmid2 = "";

                if (tmindex == 1)
                {
                    tmid1 = Rec.tmid;
                }
                if (tmindex == 2)
                {
                    tmid2 = Rec.tmid;
                }


                rsEvent.strRunEventGUID    = eventGUID;
                rsEvent.nEventID           = EventID;
                rsEvent.strTrainPlanGUID   = plan.trainPlan.planID;
                rsEvent.dtEventTime        = Rec.etime;
                rsEvent.nTMIS              = Convert.ToInt32(Rec.stmis);
                rsEvent.strGroupGUID       = plan.trainPlan.planID;
                rsEvent.strTrainmanNumber1 = tmid1;
                rsEvent.strTrainmanNumber2 = tmid2;
                rsEvent.nResultID          = Rec.nresult;
                rsEvent.strResult          = Rec.strResult.ResultToString();



                AddRunEvent(rsEvent);

                return(true);
            }
        }