写这个长篇的目的,前文已经说过。就这个目的而言,这里会更多的讲项目中存在的风险和应对,假如你正在做项目或者打算从事软件项目管理,可以一起交流讨论一下。
目录
小娇的离去
管人的大忌
理解甲方的立场
时刻表的诞生
未完待续。。。
小娇的离去
上文说的是女员工,自从这个项目以后,从我的角度而言,也不存在女员工的问题了。只是每次回想起来“小娇”的事情,总感觉有点儿耿耿于怀,都说有了第一次,就会有第二次,个人而言,却没有第二次了。
记得那年春节前的一天,领导找到我,项目已经进行了4个月,但是进度始终落后于预期,即使肖博士来了以后,依然没有更多的改善。那天是为春节后的推进做决策,领导和肖博士都认为,一定要有人为进度的事情负责。
当时的气氛很紧张,压迫感让我做出了一个错误决定,让“小娇”离开团队,本来以为是可以到其他项目组去,没想到最后的决定竟然是辞退她,最终领导还要求我去通知她。
事已至此,佩服“小娇”当时的冷静,背井离乡来上海的她,没有多说什么,只是默默的听,后来QQ上联系过几次,但后来就杳无音讯了。
此事过后,肖博士还曾经引用过一句名言给与评价:始乱终弃。也是后来查了以后才知道这个成语的含义,总觉得哪里不是很恰当。
管人的大忌
但这个事情还是引起了连锁反应,在此之前,先要解决另外一个棘手的问题,小光和小魏两名员工。
他们虽然进公司的时间分前后,而且并非在同一个部门,但不知道为什么会进入到这个项目组。说到这里,要给项目经理们提个醒:在组建团队的时候,一定要有自己的话语权。
小魏的资历比较老一些,据说项目经验也比较丰富,并不是与客户沟通的经验,是开发的经验比较丰富。项目经理一定要详细了解成员的背景,我当时并没有认真对待,自身也是缺乏经验的,看过前文的,都知道,团队的组建也不是我负责的。
小光跟我以前不认识,只是为这个项目,大家才呆在一起了。他比我年轻,接触的新东西不少,每次开会,都会提出很多观点,这是好的方面。
但随着时间的推移,发现小光和小魏的关系不错,平时吃饭工作都坐在一起,尤其是在讨论问题的时候,竟然会出奇的一致!乃至到最后,他们俩的意见,竟然能够左右整个项目组。包括“会海”这么有个性的人,对他们的意见也不怎么在明面上反对。
如果他俩能够全身心的投入项目,是件非常好的事情。但发展到最后,两个人一边上班,一边嗑瓜子,其他人敢怒不敢言。我开始也犯了一个错误,没有搞个个击破,而是在大家面前直接批评了他们,犯了管人的大忌。
后来的项目里,每次发现不对,都是先单独出去批评,保留一分做人的情面。没有再犯上面的错误。
也是因为这个错误,导致最后不得不向领导打报告,申请调两个人中的一人到其他部门,避免他们联合起来对付我,从而影响整个项目的进度,毕竟在肖博士来之前,没有人可以替代我,这一点,无论领导还是老板都给与我极大的信任。
朝中有人好做官。这一点,也是项目经理必须要牢记的一点。有时候宁肯做普通员工,也不能做项目经理。
理解甲方的立场
甲方的“松工”也一直支持我的工作。作为甲方的代表,他其实可以向总经理直接汇报的。由于这个项目,也是总经理负责的项目,所以也是非常信任“松工”的。也因此他也有更多的难处,尤其是在项目初期,我们一直无法提供给客户看到明显的进展,因为承受了很大的压力。
“松工”年纪比我们都大,据说做过基层的工作,所以业务流程上的问题,他很熟悉。记得有一次,我把跟“松工”确认过的业务流程,开发原型以后,界面与实际部门的员工进行确认,没想到这个家伙说“松工”说的不对,以至于代码逻辑全部推翻重来。
为此我去埋怨“松工”,他也很生气,“为了你们能够尽快推进,有些事情我拍板,将来我会负责推进使用,他们一句话,你们就改,为什么?”
因为这件事,我吸取了教训,在今后的沟通协调中,尽量和松工一起到业务部门交流,避免双方的不一致,给项目带来无谓的返工。同时,每天都挤出时间跟“松工”汇报当天项目组的进展,让“松工”及时了解项目组的情况。在后面的开发过程中,在用人做事方面,得到了“松工”无私的帮助,也是这个项目最后能够完工的重要基石。
项目经理一定要站在甲方的立场思考问题,同时积极为甲方利益考虑,避免埋头苦干结果把自己埋进去。
时刻表的诞生
前文中的系统功能里,当时有个非常基础,且又非常复杂的模块,时刻表。
现在无线通讯发达了,GPS的技术应用,使得车辆的位置不再是问题。但在当年只有铁皮路牌和时刻表的年代,一张合适的时刻表,耗费了项目组大量的精力实现。
UI就不再这里展示了,把时刻表的字段及类型方面的代码贴一下,按照命名规则大概能够猜出来是什么意思。
internal void InitVars() {this.columnId = this.Columns["Id"];this.columnRouteCode = this.Columns["RouteCode"];this.columnRouteName = this.Columns["RouteName"];this.columnRouteBirth = this.Columns["RouteBirth"];this.columnRouteProperty = this.Columns["RouteProperty"];this.columnStartStopBoard = this.Columns["StartStopBoard"];this.columnEndStopBoard = this.Columns["EndStopBoard"];this.columnPassByDesc = this.Columns["PassByDesc"];this.columnPlanDistance = this.Columns["PlanDistance"];this.columnRealDistance = this.Columns["RealDistance"];this.columnStopNumber = this.Columns["StopNumber"];this.columnAverageInterval = this.Columns["AverageInterval"];this.columnFormerClass = this.Columns["FormerClass"];this.columnOverdutyClass = this.Columns["OverdutyClass"];this.columnSingleTime = this.Columns["SingleTime"];this.columnRateCode = this.Columns["RateCode"];this.columnBusCompanyCode = this.Columns["BusCompanyCode"];this.columnCircleDesc = this.Columns["CircleDesc"];this.columnAlongLineDesc = this.Columns["AlongLineDesc"];this.columnAttemperType = this.Columns["AttemperType"];this.columnParentRouteCode = this.Columns["ParentRouteCode"];}private void InitClass() {this.columnId = new DataColumn("Id", typeof(int), null, System.Data.MappingType.Element);this.Columns.Add(this.columnId);this.columnRouteCode = new DataColumn("RouteCode", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnRouteCode);this.columnRouteName = new DataColumn("RouteName", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnRouteName);this.columnRouteBirth = new DataColumn("RouteBirth", typeof(System.DateTime), null, System.Data.MappingType.Element);this.Columns.Add(this.columnRouteBirth);this.columnRouteProperty = new DataColumn("RouteProperty", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnRouteProperty);this.columnStartStopBoard = new DataColumn("StartStopBoard", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnStartStopBoard);this.columnEndStopBoard = new DataColumn("EndStopBoard", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnEndStopBoard);this.columnPassByDesc = new DataColumn("PassByDesc", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnPassByDesc);this.columnPlanDistance = new DataColumn("PlanDistance", typeof(System.Double), null, System.Data.MappingType.Element);this.Columns.Add(this.columnPlanDistance);this.columnRealDistance = new DataColumn("RealDistance", typeof(System.Double), null, System.Data.MappingType.Element);this.Columns.Add(this.columnRealDistance);this.columnStopNumber = new DataColumn("StopNumber", typeof(int), null, System.Data.MappingType.Element);this.Columns.Add(this.columnStopNumber);this.columnAverageInterval = new DataColumn("AverageInterval", typeof(System.Double), null, System.Data.MappingType.Element);this.Columns.Add(this.columnAverageInterval);this.columnFormerClass = new DataColumn("FormerClass", typeof(int), null, System.Data.MappingType.Element);this.Columns.Add(this.columnFormerClass);this.columnOverdutyClass = new DataColumn("OverdutyClass", typeof(int), null, System.Data.MappingType.Element);this.Columns.Add(this.columnOverdutyClass);this.columnSingleTime = new DataColumn("SingleTime", typeof(System.Double), null, System.Data.MappingType.Element);this.Columns.Add(this.columnSingleTime);this.columnRateCode = new DataColumn("RateCode", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnRateCode);this.columnBusCompanyCode = new DataColumn("BusCompanyCode", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnBusCompanyCode);this.columnCircleDesc = new DataColumn("CircleDesc", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnCircleDesc);this.columnAlongLineDesc = new DataColumn("AlongLineDesc", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnAlongLineDesc);this.columnAttemperType = new DataColumn("AttemperType", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnAttemperType);this.columnParentRouteCode = new DataColumn("ParentRouteCode", typeof(string), null, System.Data.MappingType.Element);this.Columns.Add(this.columnParentRouteCode);this.Constraints.Add(new UniqueConstraint("Constraint1", new DataColumn[] {this.columnId}, true));this.columnId.AutoIncrement = true;this.columnId.AllowDBNull = false;this.columnId.ReadOnly = true;this.columnId.Unique = true;this.columnRouteCode.AllowDBNull = false;this.columnRouteName.AllowDBNull = false;this.columnRouteBirth.AllowDBNull = false;this.columnRouteProperty.AllowDBNull = false;}
下面的代码是自动生成一个时刻表的代码核心逻辑,根据排版、始发时间、到站时间、空驶情况,最终自动生成的时刻表,会展示在界面上,供营运人员进行手工的微调。
public bool AutoCreateGoWorkFlowRecord(string timetableid,string stop1,int stop1outNullDrivetime,int stop1inNullDrivetime,string stop2,int stop2outNullDrivetime,int stop2inNullDrivetime,int RegualMaintainTimeLength,int difflunchtime,int nonRegualMaintainTimeLength,bool useoldtime, System.Windows.Forms.ProgressBar showbar){//System.Wind OleDbDataReader reader;OleDbDataReader reader2;OleDbDataReader reader3;OleDbDataReader reader4;OleDbDataReader reader5;OleDbDataReader reader6;int barnum=0;int barmaxnum=0;string ssql;//ssql="select id from RouteBoard where TimeTableID='" + timetableid.Trim() +"' and RouteBoardName='" +routeboardname.Trim() +"'";//取得新添加班次的路牌ssql="select count(*) from TimeTableRecord a where a.timetableid='"+ timetableid+"' and a.RouteBoardCode not in ( select RouteBoardCode from GoWorkFlow ) group by a.RouteBoardCode ";reader =this.GetReader (ssql);reader.Read ();barmaxnum=Convert.ToInt32 ( reader.GetValue(0).ToString ());ssql="select a.RouteBoardCode from TimeTableRecord a where a.timetableid='"+ timetableid+"' and a.RouteBoardCode not in ( select RouteBoardCode from GoWorkFlow ) group by a.RouteBoardCode ";reader =this.GetReader (ssql);ssql="update TimeTableRecord set begintime ='1900-01-01 '+convert(char(10), begintime,108) where convert(char(10), begintime,20)>'1900-01-02' and DATEPART(hh, begintime)>='03' and timetableid="+ timetableid +" and routeboardcode in (select id from routeboard where allnight='0')";this.GetReader (ssql);showbar.Maximum =barmaxnum*2+1;try{//遍历路牌while (reader.Read () ){barnum++;string routeboardcode="";string beginstop="";string endstop="";string WorkFlowType="";string cbeginstop="";string cendstop="";bool stopflag=false;DateTime CheckInTime=DateTime.Now ; //报到时间DateTime CheckOutTime=DateTime.Now ;//出场时间DateTime GoOutTime=DateTime.Now ; //离场时间DateTime ArriveTime=DateTime.Now ; //回场时间DateTime begintime=DateTime.Now ; DateTime endtime=DateTime.Now ;DateTime lunchtime= Convert.ToDateTime("1900-01-01 0:00:00") ;double RunningTimeLength=0;double CheckInNullDriveMileage=0;double CheckInNullDriveTimeLength=0;double CheckoutNullDriveMileage=0;double CheckoutNullDriveTimeLength=0;double LunchTimeLength=difflunchtime;double WorkTimeLength=0;int nowdifflunchtime=0;double spanNullDriveMileage=0;double SpannullDriveTimeLength=0;TimeSpan difftime;routeboardcode=reader.GetValue(0).ToString ();//判断接落班类型ssql="select count(*) from VIEWAllClass where RouteBoardCode='"+routeboardcode.Trim () + "' and (backflag=1 or StopFlag=1)";reader2 =this.GetReader (ssql);reader2.Read ();if( Convert.ToInt32(reader2.GetValue(0))<2)// 全天{WorkFlowType="229003";//得到起始班次ssql="select top 1 BeginStopBoard,BeginTime,BoardName from VIEWAllClass left outer join tbstopboard on VIEWAllClass.BeginStopBoard=tbstopboard.BoardCode where RouteBoardCode='"+routeboardcode.Trim () + "' order by BeginTime";reader3 =this.GetReader (ssql);reader3.Read ();beginstop=reader3.GetValue(0).ToString ();begintime=Convert.ToDateTime( reader3.GetValue(1).ToString ());cbeginstop=reader3.GetValue (2).ToString (); ssql=" select EndStopBoard,EndTime, backflag,StopFlag,LunchFalg,BoardName from VIEWAllClass left outer join tbstopboard on VIEWAllClass.EndStopBoard=tbstopboard.BoardCode where RouteBoardCode='"+ routeboardcode.Trim () + "' and (backflag=1 or StopFlag=1 or LunchFalg=1)";reader3 =this.GetReader (ssql);nowdifflunchtime=0;while(reader3.Read ()){//吃饭时间//lunchtime=0;if(reader3.GetValue(4).ToString ()=="1"){int intdifflunchtime=difflunchtime;if(useoldtime==true){//都得原始吃饭时间try{ssql="select * from lunchtimetable where timetableid="+timetableid +" and workflowtype="+WorkFlowType+" and routeboardcode="+routeboardcode;reader5 =this.GetReader (ssql);reader5.Read ();if(Convert.ToInt32 (reader5.GetValue(3).ToString ())!=0){intdifflunchtime=Convert.ToInt32 (reader5.GetValue(3).ToString ()); }}catch{}}lunchtime =Convert.ToDateTime( reader3.GetValue(1).ToString ()).AddMinutes(-intdifflunchtime );nowdifflunchtime=intdifflunchtime;}//回场else{endstop = reader3.GetValue(0).ToString ();endtime = Convert.ToDateTime(reader3.GetValue(1).ToString ());cendstop=reader3.GetValue(5).ToString () ;//回场场时间ssql="select b.boardname,a.span,a.distance,a.DirectionType from tbhavetorun a left outer join tbstopboard b on a.stopboardcode=b.boardcode where a.mark=0 and a.routeid in (select distinct routecode from VIEWRouteTimeTable where timetableid= "+ timetableid +") ";reader4=this.GetReader (ssql);stop1inNullDrivetime=0;CheckInNullDriveMileage =0;while(reader4.Read ()){if(reader4.GetValue(0).ToString()== cendstop.Trim ()){if(stop1inNullDrivetime==0){stop1inNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckInNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}else{if(reader4.GetValue(3).ToString().Trim()=="202002"){stop1inNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckInNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}}}}ArriveTime=endtime .AddMinutes(stop1inNullDrivetime );CheckInNullDriveTimeLength=stop1inNullDrivetime;// //离场时间GoOutTime=ArriveTime.AddMinutes (RegualMaintainTimeLength);}//出场时间ssql="select b.boardname,a.span,a.distance ,a.DirectionType from tbhavetorun a left outer join tbstopboard b on a.stopboardcode=b.boardcode where a.mark=0 and a.routeid in (select distinct routecode from VIEWRouteTimeTable where timetableid= "+ timetableid +") ";reader4=this.GetReader (ssql);stop1outNullDrivetime=0;CheckoutNullDriveMileage=0;while(reader4.Read ()){if(reader4.GetValue(0).ToString()== cbeginstop.Trim ()){if(stop1outNullDrivetime==0){stop1outNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckoutNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}else{if(reader4.GetValue(3).ToString().Trim ()=="202001"){stop1outNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckoutNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}}}}int intstop1outNullDrivetime=-stop1outNullDrivetime;CheckOutTime=begintime.AddMinutes(intstop1outNullDrivetime);CheckoutNullDriveTimeLength=stop1outNullDrivetime;//报道时间int intRegualMaintainTimeLength=-RegualMaintainTimeLength;CheckInTime=CheckOutTime.AddMinutes (intRegualMaintainTimeLength);}//跨路线公里,时间spanNullDriveMileage=0;SpannullDriveTimeLength=0;ssql=" select sum(NullMileage),sum(Nulltime) from VIEWAllClass left outer join tbstopboard on VIEWAllClass.EndStopBoard=tbstopboard.BoardCode where VIEWAllClass.TimeTableID="+timetableid +" and RouteBoardCode='"+ routeboardcode.Trim () + "' and spanflag=1";reader6 =this.GetReader (ssql);reader6.Read ();if(reader6.GetValue(0)!=DBNull.Value){spanNullDriveMileage=Convert.ToDouble (reader6.GetValue(0).ToString ());}if(reader6.GetValue(1)!=DBNull.Value){SpannullDriveTimeLength =Convert.ToDouble (reader6.GetValue(1).ToString ());}//营运时间WorkTimeLength=0;RunningTimeLength=0;difftime= GoOutTime-CheckInTime;if(difftime.TotalMinutes<0){GoOutTime=GoOutTime.AddDays (1);difftime= GoOutTime-CheckInTime;}WorkTimeLength=Convert.ToDouble(difftime.TotalMinutes)-Math.Abs (nowdifflunchtime);RunningTimeLength=WorkTimeLength-2*RegualMaintainTimeLength-stop1outNullDrivetime-stop1inNullDrivetime ;int MaintainTimeLength=2*RegualMaintainTimeLength;ssql="insert into GoWorkFlow(TimeTableID,RouteBoardCode,WorkFlowType,CheckOutTime,CheckInTime,ArriveTime,GoOutTime,LunchTime,CheckOutDirection,CheckInDirection,LunchTimeLength,RegualMaintainTimeLength,RunningTimeLength,CheckInNullDriveTimeLength,CheckoutNullDriveTimeLength,CheckoutNullDriveMileage,CheckInNullDriveMileage,WrokTimeLength,SpannullDriveMileage,SpannullDriveTimeLength)" +" values('" + timetableid + "','" + routeboardcode + "','" + WorkFlowType + " ','" + CheckOutTime+ "','"+ CheckInTime +"','"+ArriveTime +"','"+GoOutTime + "','" + lunchtime + "','" +beginstop + "','"+ endstop +"',"+ nowdifflunchtime +"," + MaintainTimeLength +","+RunningTimeLength +"," +CheckInNullDriveTimeLength+","+CheckoutNullDriveTimeLength +","+CheckoutNullDriveMileage +","+CheckInNullDriveMileage+","+WorkTimeLength+","+spanNullDriveMileage+","+SpannullDriveTimeLength +")";this.GetReader (ssql);}else //上下午{string firstbacktime;ssql="select EndTime from VIEWAllClass where RouteBoardCode='"+ routeboardcode.Trim ()+"' and (backflag=1 or StopFlag=1) order by BeginTime";reader3 =this.GetReader (ssql);reader3.Read ();firstbacktime=Convert.ToDateTime(reader3.GetValue(0).ToString ()).ToString() ;//上午WorkFlowType="229001";//得到起始班次ssql="select top 1 BeginStopBoard,BeginTime,BoardName from VIEWAllClass left outer join tbstopboard on VIEWAllClass.BeginStopBoard=tbstopboard.BoardCode where RouteBoardCode='"+routeboardcode.Trim () + "' order by BeginTime";reader3 =this.GetReader (ssql);reader3.Read ();beginstop=reader3.GetValue(0).ToString ();begintime=Convert.ToDateTime( reader3.GetValue(1).ToString ());cbeginstop =reader3.GetValue(2).ToString ();//得到上午回场时间ssql=" select EndStopBoard ,EndTime, backflag,StopFlag,LunchFalg,BoardName from VIEWAllClass left outer join tbstopboard on VIEWAllClass.EndStopBoard=tbstopboard.BoardCode where RouteBoardCode='"+ routeboardcode.Trim ()+"' and (backflag=1 or StopFlag=1 or LunchFalg=1) and BeginTime<='" + firstbacktime +"' ";reader3 =this.GetReader (ssql);nowdifflunchtime=0;while(reader3.Read ()){//吃饭时间//lunchtime=0;if(reader3.GetValue(4).ToString ()=="1"){int intdifflunchtime=difflunchtime;//都得原始吃饭时间if(useoldtime==true){try{ssql="select * from lunchtimetable where timetableid="+timetableid +" and workflowtype="+WorkFlowType+" and routeboardcode="+routeboardcode;reader5 =this.GetReader (ssql);reader5.Read ();if(Convert.ToInt32 (reader5.GetValue(3).ToString ())!=0){intdifflunchtime=Convert.ToInt32 (reader5.GetValue(3).ToString ()); }} catch{}}lunchtime =Convert.ToDateTime( reader3.GetValue(1).ToString ()).AddMinutes(-intdifflunchtime );nowdifflunchtime=intdifflunchtime;}//回场else {endstop = reader3.GetValue(0).ToString ();endtime = Convert.ToDateTime(reader3.GetValue(1).ToString ());cendstop= reader3.GetValue(5).ToString ();//回场场时间stop1inNullDrivetime=0;CheckInNullDriveMileage =0;if(reader3.GetValue(2).ToString ()=="1")//回场{stopflag=false;ssql="select b.boardname,a.span,a.distance ,a.DirectionType from tbhavetorun a left outer join tbstopboard b on a.stopboardcode=b.boardcode where a.mark=0 and a.routeid in (select distinct routecode from VIEWRouteTimeTable where timetableid= "+ timetableid +") ";reader4=this.GetReader (ssql);stop1inNullDrivetime=0;while(reader4.Read ()){if(reader4.GetValue(0).ToString()== cendstop.Trim ()){if(stop1inNullDrivetime==0){stop1inNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckInNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}else{if(reader4.GetValue(3).ToString().Trim ()=="202002"){stop1inNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckInNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}}}}}else//站停{stopflag=true; }ArriveTime=endtime .AddMinutes(stop1inNullDrivetime );CheckInNullDriveTimeLength=stop1inNullDrivetime;//离场时间GoOutTime=ArriveTime;}//出场时间stop1outNullDrivetime=0;CheckoutNullDriveMileage=0;ssql="select b.boardname,a.span,a.distance ,a.DirectionType from tbhavetorun a left outer join tbstopboard b on a.stopboardcode=b.boardcode where a.mark=0 and a.routeid in (select distinct routecode from VIEWRouteTimeTable where timetableid= "+ timetableid +") ";reader4=this.GetReader (ssql);stop1outNullDrivetime=0;while(reader4.Read ()){if(reader4.GetValue(0).ToString()== cbeginstop.Trim ()){if(stop1outNullDrivetime==0){stop1outNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckoutNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}else{if(reader4.GetValue(3).ToString().Trim ()=="202001"){stop1outNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckoutNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}}}}int intstop1outNullDrivetime=-stop1outNullDrivetime;CheckOutTime=begintime.AddMinutes(intstop1outNullDrivetime);CheckoutNullDriveTimeLength=stop1outNullDrivetime;//报道时间int intRegualMaintainTimeLength=-RegualMaintainTimeLength;CheckInTime=CheckOutTime.AddMinutes (intRegualMaintainTimeLength);}//跨路线公里,时间spanNullDriveMileage=0;SpannullDriveTimeLength=0;ssql=" select sum(NullMileage),sum(Nulltime) from VIEWAllClass left outer join tbstopboard on VIEWAllClass.EndStopBoard=tbstopboard.BoardCode where VIEWAllClass.TimeTableID="+timetableid +" and RouteBoardCode='"+ routeboardcode.Trim () + "' and spanflag=1 and BeginTime<='" + firstbacktime +"' ";reader6=this.GetReader (ssql);reader6.Read ();if(reader6.GetValue(0)!=DBNull.Value){spanNullDriveMileage=Convert.ToDouble (reader6.GetValue(0).ToString ());}if(reader6.GetValue(1)!=DBNull.Value){SpannullDriveTimeLength =Convert.ToDouble (reader6.GetValue(1).ToString ());}//营运时间,工时WorkTimeLength=0;RunningTimeLength=0;difftime= GoOutTime-CheckInTime;if(difftime.TotalMinutes<0){GoOutTime=GoOutTime.AddDays (1);difftime= GoOutTime-CheckInTime;}WorkTimeLength=Convert.ToDouble(difftime.TotalMinutes)-Math.Abs (nowdifflunchtime);RunningTimeLength=WorkTimeLength-RegualMaintainTimeLength-stop1outNullDrivetime-stop1inNullDrivetime ;int MaintainTimeLength=RegualMaintainTimeLength;ssql="insert into GoWorkFlow(TimeTableID,RouteBoardCode,WorkFlowType,CheckOutTime,CheckInTime,ArriveTime,GoOutTime,LunchTime,CheckOutDirection,CheckInDirection,LunchTimeLength,RegualMaintainTimeLength,RunningTimeLength,CheckInNullDriveTimeLength,CheckoutNullDriveTimeLength,CheckoutNullDriveMileage,CheckInNullDriveMileage,WrokTimeLength,SpannullDriveMileage,SpannullDriveTimeLength)" +" values('" + timetableid + "','" + routeboardcode + "','" + WorkFlowType + " ','" + CheckOutTime+ "','"+ CheckInTime +"','"+ArriveTime +"','"+GoOutTime + "','" + lunchtime + "','" +beginstop + "','"+ endstop +"',"+ nowdifflunchtime +"," + MaintainTimeLength +","+RunningTimeLength +"," +CheckInNullDriveTimeLength+","+CheckoutNullDriveTimeLength +","+CheckoutNullDriveMileage +","+CheckInNullDriveMileage+","+WorkTimeLength+ ","+spanNullDriveMileage+","+SpannullDriveTimeLength +")";this.GetReader (ssql);//下午WorkFlowType="229002";//得到起始班次ssql="select top 1 BeginStopBoard ,BeginTime ,BoardName from VIEWAllClass left outer join tbstopboard on VIEWAllClass.BeginStopBoard=tbstopboard.BoardCode where RouteBoardCode='"+routeboardcode.Trim () + "' and BeginTime>='" + firstbacktime +"' order by BeginTime";reader3 =this.GetReader (ssql);reader3.Read ();beginstop=reader3.GetValue(0).ToString ();begintime=Convert.ToDateTime( reader3.GetValue(1).ToString ());cbeginstop= reader3.GetValue(2).ToString ();//得到下午回场时间ssql=" select EndStopBoard ,EndTime, backflag,StopFlag,LunchFalg,BoardName from VIEWAllClass left outer join tbstopboard on VIEWAllClass.EndStopBoard=tbstopboard.BoardCode where RouteBoardCode='"+ routeboardcode.Trim ()+"' and (backflag=1 or StopFlag=1 or LunchFalg=1) and BeginTime>'" + firstbacktime +"' ";reader3 =this.GetReader (ssql);//lunchtime=0;nowdifflunchtime=0;while(reader3.Read ()){//吃饭时间if(reader3.GetValue(4).ToString ()=="1"){int intdifflunchtime=difflunchtime;//都得原始吃饭时间if(useoldtime==true ){try{ssql="select * from lunchtimetable where timetableid="+timetableid +" and workflowtype="+WorkFlowType+" and routeboardcode="+routeboardcode;reader5 =this.GetReader (ssql);reader5.Read ();if(Convert.ToInt32 (reader5.GetValue(3).ToString ())!=0){intdifflunchtime=Convert.ToInt32 (reader5.GetValue(3).ToString ()); }}catch{}}lunchtime =Convert.ToDateTime( reader3.GetValue(1).ToString ()).AddMinutes(-intdifflunchtime );nowdifflunchtime=intdifflunchtime ;}//回场else{endstop = reader3.GetValue(0).ToString ();endtime = Convert.ToDateTime(reader3.GetValue(1).ToString ());cendstop= reader3.GetValue(5).ToString ();//回场场时间stop1inNullDrivetime=0;CheckInNullDriveMileage =0;ssql="select b.boardname,a.span,a.distance ,a.DirectionType from tbhavetorun a left outer join tbstopboard b on a.stopboardcode=b.boardcode where a.mark=0 and a.routeid in (select distinct routecode from VIEWRouteTimeTable where timetableid="+timetableid +" ) ";reader4=this.GetReader (ssql);stop1inNullDrivetime=0;while(reader4.Read ()){if(reader4.GetValue(0).ToString()== cendstop.Trim ()){if(stop1inNullDrivetime==0){stop1inNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckInNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}else{if(reader4.GetValue(3).ToString().Trim ()=="202002"){stop1inNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckInNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}}}}ArriveTime=endtime .AddMinutes(stop1inNullDrivetime );CheckInNullDriveTimeLength=stop1inNullDrivetime;//离场时间GoOutTime=ArriveTime.AddMinutes (RegualMaintainTimeLength);}//出场时间stop1outNullDrivetime=0;CheckoutNullDriveMileage =0;if(stopflag==false ){ssql="select b.boardname,a.span,a.distance,a.DirectionType from tbhavetorun a left outer join tbstopboard b on a.stopboardcode=b.boardcode where a.mark=0 and a.routeid in (select distinct routecode from VIEWRouteTimeTable where timetableid= "+ timetableid +") ";reader4=this.GetReader (ssql);stop1outNullDrivetime=0;while(reader4.Read ()){if(reader4.GetValue(0).ToString()== cbeginstop.Trim ()){if(stop1outNullDrivetime==0){stop1outNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckoutNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}else{if(reader4.GetValue(3).ToString().Trim ()=="202001"){stop1outNullDrivetime=Convert.ToInt32(reader4.GetValue(1).ToString ());CheckoutNullDriveMileage =Convert.ToDouble(reader4.GetValue (2).ToString ());}}}}}int intstop1outNullDrivetime=-stop1outNullDrivetime;CheckOutTime=begintime.AddMinutes(intstop1outNullDrivetime);CheckoutNullDriveTimeLength=stop1outNullDrivetime;//报道时间int intRegualMaintainTimeLength=-nonRegualMaintainTimeLength ;CheckInTime=CheckOutTime.AddMinutes (intRegualMaintainTimeLength);}//跨路线公里,时间spanNullDriveMileage=0;SpannullDriveTimeLength=0;ssql=" select sum(NullMileage),sum(Nulltime) from VIEWAllClass left outer join tbstopboard on VIEWAllClass.EndStopBoard=tbstopboard.BoardCode where VIEWAllClass.TimeTableID="+timetableid +" and RouteBoardCode='"+ routeboardcode.Trim () + "' and spanflag=1 and BeginTime>'" + firstbacktime +"' ";reader6=this.GetReader (ssql);reader6.Read (); if( reader6.GetValue(0)!=DBNull.Value ){spanNullDriveMileage=Convert.ToDouble (reader6.GetValue(0).ToString ());}if( reader6.GetValue(1)!=DBNull.Value){SpannullDriveTimeLength =Convert.ToDouble (reader6.GetValue(1).ToString ());}//营运时间//营运时间WorkTimeLength=0;RunningTimeLength=0;difftime= GoOutTime-CheckInTime;if(difftime.TotalMinutes<0){GoOutTime=GoOutTime.AddDays (1);difftime= GoOutTime-CheckInTime;}WorkTimeLength=Convert.ToDouble(difftime.TotalMinutes)-Math.Abs (nowdifflunchtime);RunningTimeLength=WorkTimeLength-RegualMaintainTimeLength-nonRegualMaintainTimeLength-stop1outNullDrivetime-stop1inNullDrivetime ;MaintainTimeLength=RegualMaintainTimeLength+nonRegualMaintainTimeLength;ssql="insert into GoWorkFlow(TimeTableID,RouteBoardCode,WorkFlowType,CheckOutTime,CheckInTime,ArriveTime,GoOutTime,LunchTime,CheckOutDirection,CheckInDirection,LunchTimeLength,RegualMaintainTimeLength,RunningTimeLength,CheckInNullDriveTimeLength,CheckoutNullDriveTimeLength,CheckoutNullDriveMileage,CheckInNullDriveMileage,WrokTimeLength,SpannullDriveMileage,SpannullDriveTimeLength)" +" values('" + timetableid + "','" + routeboardcode + "','" + WorkFlowType + " ','" + CheckOutTime+ "','"+ CheckInTime +"','"+ArriveTime +"','"+GoOutTime + "','" + lunchtime + "','" +beginstop + "','"+ endstop +"',"+ nowdifflunchtime +"," + MaintainTimeLength +","+RunningTimeLength +"," +CheckInNullDriveTimeLength+","+CheckoutNullDriveTimeLength +","+CheckoutNullDriveMileage +","+CheckInNullDriveMileage+","+WorkTimeLength+","+spanNullDriveMileage+","+SpannullDriveTimeLength +")";this.GetReader (ssql);}showbar.Value =barnum ;showbar.Refresh ();}return true;}