Пример #1
0
        /// <summary>
        /// 获取各交路下人员数量
        /// </summary>
        public InterfaceOutPut GetTrainmanJiaoLuCount(String Data)
        {
            InterfaceOutPut output = new InterfaceOutPut();

            output.result = 1;
            try
            {
                JavaScriptSerializer      javaScriptSerializer = new JavaScriptSerializer();
                InGetTrainmanJiaoLuCount  InParams             = javaScriptSerializer.Deserialize <InGetTrainmanJiaoLuCount>(Data);
                OutGetTrainmanJiaoLuCount OutParams            = new OutGetTrainmanJiaoLuCount();
                string         strSql    = @"select count(*) as nCount,strTrainmanJiaoluGUID,strTrainmanJiaoluName from VIEW_Nameplate_TrainmanInJiaolu_All 
                       where strTrainmanJiaoluGUID in (select strTrainmanJiaoluGUID from VIEW_Base_JiaoluRelation where strWorkShopGUID = @strWorkShopGUID)
                       group by strTrainmanJiaoluGUID,strTrainmanJiaoluName ";
                SqlParameter[] sqlParams = new SqlParameter[] {
                    new SqlParameter("strWorkShopGUID", InParams.WorkShopGUID)
                };
                DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql, sqlParams).Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    TrainmanJiaoluCount c = new TrainmanJiaoluCount();
                    c.nCount        = ObjectConvertClass.static_ext_int(dt.Rows[i]["nCount"]);
                    c.strJiaoLuName = dt.Rows[i]["strTrainmanJiaoluName"].ToString();
                    OutParams.SumCount.Add(c);
                }
                output.data   = OutParams;
                output.result = 0;
            }
            catch (Exception ex)
            {
                output.resultStr = ex.Message;
                LogClass.log("Interface.GetTrainmanJiaoLuCount:" + ex.Message);
                throw ex;
            }
            return(output);
        }
Пример #2
0
        /// <summary>
        /// 根据nid获取乘务员
        /// </summary>
        public InterfaceOutPut GetTrainmanByID(String Data)
        {
            InterfaceOutPut output = new InterfaceOutPut();

            output.result = 1;
            try
            {
                JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                InGetTrainmanByID    InParams             = javaScriptSerializer.Deserialize <InGetTrainmanByID>(Data);
                string         strSql    = "select top 1 * from VIEW_Org_Trainman where nid = @nid";
                SqlParameter[] sqlParams = new SqlParameter[] {
                    new SqlParameter("nid", InParams.ID)
                };
                DataTable          dt        = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql, sqlParams).Tables[0];
                OutGetTrainmanByID OutParams = new OutGetTrainmanByID();
                output.data = OutParams;
                if (dt.Rows.Count > 0)
                {
                    PSTrainman.TrainmanFromDB(OutParams.TM, dt.Rows[0], 0);
                }
                output.result = 0;
            }
            catch (Exception ex)
            {
                output.resultStr = ex.Message;
                LogClass.log("Interface.GetTrainmanByID:" + ex.Message);
                throw ex;
            }
            return(output);
        }
Пример #3
0
        /// <summary>
        /// 获取车间下各交路的人员状态分布及机组信息
        /// </summary>
        public InterfaceOutPut GetTrainmanRunStateCount(String Data)
        {
            InterfaceOutPut output = new InterfaceOutPut();

            output.result = 1;
            try
            {
                JavaScriptSerializer        javaScriptSerializer = new JavaScriptSerializer();
                InGetTrainmanRunStateCount  InParams             = javaScriptSerializer.Deserialize <InGetTrainmanRunStateCount>(Data);
                OutGetTrainmanRunStateCount OutParams            = new OutGetTrainmanRunStateCount();
                string         strSql    = @"select tm.*,p.nPlanState,  
                 (select top 1 nEventID from tab_plan_RunEvent where tm.strTrainPlanGUID = strTrainPlanGUID order by dtEventTime desc) as nEventID from 
                 (  
                 select strWorkShopGUID1,strTrainmanName1,strTrainmanNumber1, strTrainmanName2,strTrainmanNumber2,strTrainmanName3,strTrainmanNumber3, strTrainmanName4,strTrainmanNumber4,strTrainmanJiaoluName,strTrainPlanGUID from VIEW_Nameplate_Group 
                 )  
                 as tm left join tab_plan_train as p on  tm.strTrainPlanGUID = p.strTrainPlanGUID  
                 left join TAB_Org_WorkShop as w on  tm.strWorkShopGUID1 = w.strWorkShopGUID where strWorkShopGUID1 = @strWorkShopGUID order by strTrainmanjiaoluName";
                SqlParameter[] sqlParams = new SqlParameter[] {
                    new SqlParameter("strWorkShopGUID", InParams.WorkShopGUID)
                };
                DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql, sqlParams).Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    bool bFind = false;

                    for (int k = 0; k < OutParams.Sum.Count; k++)
                    {
                        if (dt.Rows[i]["strTrainmanJiaoluName"].ToString() == OutParams.Sum[k].strJiaoLuName)
                        {
                            TrainmanGroup group = new TrainmanGroup();
                            group.TrainmanName1 = dt.Rows[i]["strTrainmanName1"].ToString();
                            group.TrainmanName2 = dt.Rows[i]["strTrainmanName2"].ToString();
                            group.TrainmanName3 = dt.Rows[i]["strTrainmanName3"].ToString();
                            group.TrainmanName4 = dt.Rows[i]["strTrainmanName4"].ToString();

                            group.TrainmanNumber1 = dt.Rows[i]["strTrainmanNumber1"].ToString();
                            group.TrainmanNumber2 = dt.Rows[i]["strTrainmanNumber2"].ToString();
                            group.TrainmanNumber3 = dt.Rows[i]["strTrainmanNumber3"].ToString();
                            group.TrainmanNumber4 = dt.Rows[i]["strTrainmanNumber4"].ToString();
                            string nEvent = dt.Rows[i]["nEventID"].ToString();
                            if (nEvent == "10001")
                            {
                                group.GroupState = 5; //tsOutRoom
                                OutParams.Sum[k].nSiteCount++;
                                //Inc(TrainmanRunStateCountArray[n].nSiteCount)  ;
                            }
                            else
                            {
                                string nPlanState = dt.Rows[i]["nPlanState"].ToString();
                                if (nPlanState == "7")
                                {
                                    group.GroupState = 6;//tsRuning;
                                    OutParams.Sum[k].nRuningCount++;
                                    //Inc(TrainmanRunStateCountArray[n].nRuningCount)  ;
                                }
                                else
                                {
                                    group.GroupState = 4; //tsInRoom;
                                    OutParams.Sum[k].nLocalCount++;
                                    //Inc(TrainmanRunStateCountArray[n].nLocalCount)   ;
                                }
                            }
                            bFind = true;
                            OutParams.Sum[k].group.Add(group);
                            break;
                        }
                    }
                    if (!bFind)
                    {
                        TrainmanRunStateCount sum = new TrainmanRunStateCount();
                        sum.strJiaoLuName = dt.Rows[i]["strTrainmanJiaoluName"].ToString();
                        TrainmanGroup group = new TrainmanGroup();
                        group.TrainmanName1 = dt.Rows[i]["strTrainmanName1"].ToString();
                        group.TrainmanName2 = dt.Rows[i]["strTrainmanName2"].ToString();
                        group.TrainmanName3 = dt.Rows[i]["strTrainmanName3"].ToString();
                        group.TrainmanName4 = dt.Rows[i]["strTrainmanName4"].ToString();

                        group.TrainmanNumber1 = dt.Rows[i]["strTrainmanNumber1"].ToString();
                        group.TrainmanNumber2 = dt.Rows[i]["strTrainmanNumber2"].ToString();
                        group.TrainmanNumber3 = dt.Rows[i]["strTrainmanNumber3"].ToString();
                        group.TrainmanNumber4 = dt.Rows[i]["strTrainmanNumber4"].ToString();

                        string nEvent = dt.Rows[i]["nEventID"].ToString();
                        if (nEvent == "10001")
                        {
                            group.GroupState = 5; //tsOutRoom
                            sum.nSiteCount   = 1;
                            //Inc(TrainmanRunStateCountArray[n].nSiteCount)  ;
                        }
                        else
                        {
                            string nPlanState = dt.Rows[i]["nPlanState"].ToString();
                            if (nPlanState == "7")
                            {
                                group.GroupState = 6;//tsRuning;
                                sum.nRuningCount = 1;
                                //Inc(TrainmanRunStateCountArray[n].nRuningCount)  ;
                            }
                            else
                            {
                                group.GroupState = 4;//tsInRoom;
                                sum.nLocalCount  = 1;
                                //Inc(TrainmanRunStateCountArray[n].nLocalCount)   ;
                            }
                        }

                        sum.group.Add(group);
                        OutParams.Sum.Add(sum);
                    }
                }
                output.data   = OutParams;
                output.result = 0;
            }
            catch (Exception ex)
            {
                output.resultStr = ex.Message;
                LogClass.log("Interface.GetTrainmanRunStateCount:" + ex.Message);
                throw ex;
            }
            return(output);
        }
Пример #4
0
        /// <summary>
        /// 获取指定车间内各种请销假人员的数量
        /// </summary>
        public InterfaceOutPut GetTrainmanLeaveCount(String Data)
        {
            InterfaceOutPut output = new InterfaceOutPut();

            output.result = 1;
            try
            {
                JavaScriptSerializer     javaScriptSerializer = new JavaScriptSerializer();
                InGetTrainmanLeaveCount  InParams             = javaScriptSerializer.Deserialize <InGetTrainmanLeaveCount>(Data);
                OutGetTrainmanLeaveCount OutParams            = new OutGetTrainmanLeaveCount();
                string strSql = @"select * from TAB_LeaveMgr_LeaveType  order by strTypeGUID,strTypeName ";

                DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql).Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    EnumSum sum = new EnumSum();
                    sum.EnumCount = 0;
                    sum.EnumID    = dt.Rows[i]["strTypeGUID"].ToString();
                    sum.EnumName  = dt.Rows[i]["strTypeName"].ToString();
                    OutParams.Sum.Add(sum);
                }

                strSql = @"select strTrainmanNumber, 
                (select top 1 strLeaveTypeGUID from VIEW_LeaveMgr_AskLeaveWithTypeName where strTrainmanID=strTrainmanNumber order by dBeginTime desc) as strLeaveTypeGUID, 
                 (select top 1 strTypeName from VIEW_LeaveMgr_AskLeaveWithTypeName where strTrainmanID=strTrainmanNumber order by dBeginTime desc) as strLeaveTypeName
                 from VIEW_Org_Trainman where strWorkShopGUID=@strWorkShopGUID  
                 and nTrainmanState = 0  order by strLeaveTypeGUID,strTrainmanNumber ";
                SqlParameter[] sqlParams = new SqlParameter[] {
                    new SqlParameter("strWorkShopGUID", InParams.WorkShopGUID)
                };
                dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql, sqlParams).Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    bool bFind = false;
                    for (int k = 0; k < OutParams.Sum.Count; k++)
                    {
                        if (OutParams.Sum[k].EnumID == dt.Rows[i]["strLeaveTypeGUID"].ToString())
                        {
                            OutParams.Sum[k].EnumCount++;
                            bFind = true;
                            break;
                        }
                    }

                    if (!bFind)
                    {
                        EnumSum sum = new EnumSum();
                        sum.EnumCount = 1;
                        sum.EnumID    = dt.Rows[i]["strLeaveTypeGUID"].ToString();
                        sum.EnumName  = dt.Rows[i]["strLeaveTypeName"].ToString();
                        OutParams.Sum.Add(sum);
                    }
                }
                output.data   = OutParams;
                output.result = 0;
            }
            catch (Exception ex)
            {
                output.resultStr = ex.Message;
                LogClass.log("Interface.GetTrainmanLeaveCount:" + ex.Message);
                throw ex;
            }
            return(output);
        }
Пример #5
0
        /// <summary>
        /// 获取各状态人员数量统计信息
        /// </summary>
        public InterfaceOutPut GetTrainmanStateCount(String Data)
        {
            InterfaceOutPut output = new InterfaceOutPut();

            output.result = 1;
            try
            {
                JavaScriptSerializer     javaScriptSerializer = new JavaScriptSerializer();
                InGetTrainmanStateCount  InParams             = javaScriptSerializer.Deserialize <InGetTrainmanStateCount>(Data);
                OutGetTrainmanStateCount OutParams            = new OutGetTrainmanStateCount();
                string         strSql    = "select nTrainmanState,count(*)  as c from TAB_Org_Trainman where strWorkShopGUID = @strWorkShopGUID group by nTrainmanState order by nTrainmanState";
                SqlParameter[] sqlParams = new SqlParameter[] {
                    new SqlParameter("strWorkShopGUID", InParams.WorkShopGUID)
                };
                OutParams.SumCount.nInRoom   = 0;
                OutParams.SumCount.nNil      = 0;
                OutParams.SumCount.nNormal   = 0;
                OutParams.SumCount.nOutRoom  = 0;
                OutParams.SumCount.nPlaning  = 0;
                OutParams.SumCount.nReady    = 0;
                OutParams.SumCount.nRuning   = 0;
                OutParams.SumCount.nUnRuning = 0;

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

                foreach (DataRow dr in dt.Rows)
                {
                    switch (dr["nTrainmanState"].ToString())
                    {
                    case "0":
                    {
                        OutParams.SumCount.nUnRuning = ObjectConvertClass.static_ext_int(dr["c"]);
                        break;
                    }

                    case "1":
                    {
                        OutParams.SumCount.nReady = ObjectConvertClass.static_ext_int(dr["c"]);
                        break;
                    }

                    case "2":
                    {
                        OutParams.SumCount.nNormal = ObjectConvertClass.static_ext_int(dr["c"]);
                        break;
                    }

                    case "3":
                    {
                        OutParams.SumCount.nPlaning = ObjectConvertClass.static_ext_int(dr["c"]);
                        break;
                    }

                    case "4":
                    {
                        OutParams.SumCount.nInRoom = ObjectConvertClass.static_ext_int(dr["c"]);
                        break;
                    }

                    case "5":
                    {
                        OutParams.SumCount.nOutRoom = ObjectConvertClass.static_ext_int(dr["c"]);
                        break;
                    }

                    case "6":
                    {
                        OutParams.SumCount.nRuning = ObjectConvertClass.static_ext_int(dr["c"]);
                        break;
                    }

                    case "7":
                    {
                        OutParams.SumCount.nNil = ObjectConvertClass.static_ext_int(dr["c"]);
                        break;
                    }

                    default: break;
                    }
                }
                output.data   = OutParams;
                output.result = 0;
            }
            catch (Exception ex)
            {
                output.resultStr = ex.Message;
                LogClass.log("Interface.GetTrainmanStateCount:" + ex.Message);
                throw ex;
            }
            return(output);
        }