/// <summary> /// 更新出车信息数据 /// </summary> /// <param name="Data"></param> /// <param name="VehicleNo"></param> /// <returns></returns> public static ParameterSql GetUpadateCCXXBSql(DispatchVehicleData Data) { ParameterSql sqlpar = new ParameterSql(); //20151210 修改人:朱星汉 修改内容:添加车辆信息状态字段 sqlpar.StrSql = "update CCXXB set CCLX=:CCLX,SJ=:SJ,SCYS=:SCYS,SCHS=:SCHS,SCDJG=:SCDJG,PCSJ=:PCSJ,CCDD=:CCDD,CCSJ=:CCSJ,DDXCSJ=:DDXCSJ,SCSJ=:SCSJ,DDSJ=:DDSJ,WCSJ=:WCSJ,FZSJ=:FZSJ,CCYS=:CCYS,LTYS=:LTYS,XCYS=:XCYS,ZTYS=:ZTYS,ZHS=:ZHS,XSLC=:XSLC,TSSJ=:TSSJ,TSYY=:TSYY,TSSJSJ=:TSSJSJ,CLID=:CLID,SDXXSJ=:SDXXSJ,SWYY=:SWYY,ZT=:ZT,CCCC=:CCCC where LSH=:LSH and CS=:CS and CLBH=:CLBH "; OracleParameter[] par = { new OracleParameter(":LSH", GetString(Data.DealRecordID)), new OracleParameter(":CLBH", GetString(Data.VehicleCode)), new OracleParameter(":CS", GetString(Data.Times)), new OracleParameter(":CCLX", GetString(Data.DispatchVehicleType)), new OracleParameter(":SJ", GetString(Data.Driver)), new OracleParameter(":SCYS", GetString(Data.Doctor)), new OracleParameter(":SCHS", GetString(Data.Nurse)), new OracleParameter(":SCDJG", GetString(Data.StretcherPerson)), new OracleParameter(":PCSJ", GetDateTime(Data.DispatchVehicleTime)), new OracleParameter(":CCDD", GetString(Data.StartoffAddress)), new OracleParameter(":CCSJ", GetDateTime(Data.StartoffTime)), new OracleParameter(":DDXCSJ", GetDateTime(Data.ArriveSceneTime)), new OracleParameter(":SCSJ", GetDateTime(Data.GetInVehicleTime)), new OracleParameter(":DDSJ", GetDateTime(Data.ArriveDestinationTime)), new OracleParameter(":WCSJ", GetDateTime(Data.FinishTaskTime)), new OracleParameter(":FZSJ", GetDateTime(Data.ReturnParkTime)), new OracleParameter(":CCYS", GetNumber(Data.StartoffUseTime)), new OracleParameter(":LTYS", GetNumber(Data.ArriveSceneUseTime)), new OracleParameter(":XCYS", GetNumber(Data.SceneUseTime)), new OracleParameter(":ZTYS", GetNumber(Data.AarriveDestinationUseTime)), new OracleParameter(":ZHS", GetNumber(Data.TotalUseTime)), new OracleParameter(":XSLC", GetNumber(Data.SteerMileage)), new OracleParameter(":TSSJ", GetString(Data.SpecialEvent)), new OracleParameter(":TSYY", GetString(Data.SpecialReason)), new OracleParameter(":TSSJSJ", GetDateTime(Data.SpecialEventTime)), new OracleParameter(":CLID", GetString(Data.VehicleID)), new OracleParameter(":SDXXSJ", GetDateTime(Data.ReceiveTaskTime)), new OracleParameter(":SWYY", GetString(Data.AcceptHospital)), new OracleParameter(":ZT", GetString(Data.VehicleZT)), //20160106 修改人:朱星汉 修改内容:添加出车车次(CCCC)字段 new OracleParameter(":CCCC", GetString(Data.VehicleCCCC)), }; sqlpar.OrclPar = par; return(sqlpar); }
/// <summary> /// 是否已成功插入出车信息表数据 /// </summary> /// <param name="DispatchVehicle"></param> /// <param name="UnitCode"></param> /// <param name="strLcoalLSH"></param> /// <param name="strLocalCLBH"></param> /// <param name="strLocalCS"></param> /// <returns></returns> private bool hasInsertedDispatchVehicleRecord(DispatchVehicleData DispatchVehicle, string UnitCode, string strLcoalLSH, ref string strLocalCLBH, ref string strLocalCS) { bool result = false; try { //选取对应的虚拟车辆 string sql = "select clbh from (select clbh,0 as zt from clxxb where ssdw= (select DWMC from dwxxb where dwbh='" + UnitCode + "') and (clzt = '任务完成' or clzt='待命') union select clbh,1 as zt from clxxb where ssdw=(select DWMC from dwxxb where dwbh='" + UnitCode + "')and clzt<>'待命' and clzt<>'任务完成')a order by a.zt"; object obj = DB120Help.GetSingle(sql); if (obj != null) { strLocalCLBH = obj.ToString(); //在本地库选取对应的车次 sql = "select nvl(max(cs),'00') from ccxxb where lsh ='" + strLcoalLSH + "'"; obj = DB120Help.GetSingle(sql); strLocalCS = (int.Parse(obj.ToString()) + 1).ToString("00"); //将取出对应的本地流水号,车次,车辆编号已经本身的业务信息插入本地库,同时插入后将对应的主键在联网信息表中进行关联 DispatchVehicle.VehicleCode = strLocalCLBH; DispatchVehicle.DealRecordID = strLcoalLSH; DispatchVehicle.Times = strLocalCS; LogHelper.WriteLog("新增CCXXB,LSH:" + strLcoalLSH + ",CLBH:" + strLocalCLBH + ",CS:" + strLocalCS); ParameterSql parSql = SyncDataSql.GetAddCCXXBSql(DispatchVehicle); int i = DB120Help.ExecuteSql(parSql.StrSql, parSql.OrclPar); if (i > 0) { result = true; } } else { LogHelper.WriteLog("本地库没有" + UnitCode + "的车辆"); } } catch (Exception ex) { LOG.LogHelper.WriteLog("", ex); } return(result); }
/// <summary> /// 出车信息上报 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void HandleDispatchVehicleData(string message) { try { DispatchVehicleData DispatchVehicle = (DispatchVehicleData)XmlUtil.Deserialize(typeof(DispatchVehicleData), message); IDataExchangeDataAccess Data = DataAccess.DataExchangeDataAccess(); Data.DispatchVehicleDataRespExchange += new EventHandler <DataExchangeRespEventArgs>(Data_DispatchVehicleDataRespExchange); List <DispatchVehicleData> DataList = new List <DispatchVehicleData>(); DataList.Add(DispatchVehicle); Data.InsertDispatchVehicleData(DataList, ServerClient.UnitXZBM); //同步联网调度单的出车信息到市120本地库中 ISyncData syncData = LocalDataAccess.SyncDataAccess(); syncData.DispatchVehicleDataRespExchange += new EventHandler <SyncDataRespEventArgs>(Data_DispatchVehicleDataRespSync); syncData.SyncDispatchVehicleData(DispatchVehicle, ServerClient.UnitCode); } catch (Exception ex) { LogHelper.WriteLog("", ex); } }
/// <summary> /// 同步出车信息数据 /// </summary> public void SyncDispatchVehicleData(DispatchVehicleData DispatchVehicle, string UnitCode) { try { string strLcoalLSH = ""; string strTargetLSH = DispatchVehicle.DealRecordID; string strTargetCS = DispatchVehicle.Times; string strTargetCLBH = DispatchVehicle.VehicleCode; if (IsLWDD(DispatchVehicle.DealRecordID, UnitCode, ref strLcoalLSH)) { LogHelper.WriteLog("联网单需要更新CCXX,LSH:" + strLcoalLSH); CheckDispatchRecord(strLcoalLSH, DispatchVehicle.DispatchVehicleTime, UnitCode); CheckHJQY(strLcoalLSH, UnitCode); string strLocalCS = ""; string strLocalCLBH = ""; if (HasVehicleMatchRecord(DispatchVehicle.DealRecordID, DispatchVehicle.VehicleCode, DispatchVehicle.Times, UnitCode, ref strLocalCS, ref strLocalCLBH)) { LogHelper.WriteLog("进入HasVehicleMatchRecord=true,LSH:" + strLcoalLSH); string sql = "select * from ccxxb where lsh = '" + strLcoalLSH + "' and cs = '" + strLocalCS + "' and clbh = '" + strLocalCLBH + "'"; object obj = DB120Help.GetSingle(sql); //如果已经存在记录更新当前出车信息 if (obj != null) { DispatchVehicle.VehicleCode = strLocalCLBH; DispatchVehicle.DealRecordID = strLcoalLSH; DispatchVehicle.Times = strLocalCS; LogHelper.WriteLog("更新CCXXB,LSH:" + strLcoalLSH + ",CLBH:" + strLocalCLBH + ",CS:" + strLocalCS); ParameterSql parSql = SyncDataSql.GetUpadateCCXXBSql(DispatchVehicle); int i = DB120Help.ExecuteSql(parSql.StrSql, parSql.OrclPar); if (i == 0) { LogHelper.WriteLog("车辆信息数据更新本地库失败本地流水号:" + strLcoalLSH + " 车次:" + strLocalCS + " 车辆编号:" + strLocalCLBH); } else //成功更新车辆信息表中的车辆状态 { sql = "update clxxb set clzt ='" + DispatchVehicle.VehicleZT + "' where clbh= '" + strLocalCLBH + "'"; i = DB120Help.ExecuteSql(sql); if (i != 0) { LogHelper.WriteLog("车辆状态更新成功 车辆编号:" + strLocalCLBH); } DispatchVehicleDataResp Data = new DispatchVehicleDataResp(); Data.CommandID = DispatchVehicle.CommandID + "Resp"; Data.DealRecordID = strTargetLSH; Data.VehicleCode = strTargetCLBH; Data.Times = strTargetCS; Data.Result = 1; ExchangeDataResp(Data); } } } //未在联网信息关联表关联主键 需要插入记录,同时虚拟该车的车辆 else { LogHelper.WriteLog("进入HasVehicleMatchRecord=false,LSH:" + strLcoalLSH); strTargetLSH = DispatchVehicle.DealRecordID; strTargetCS = DispatchVehicle.Times; strTargetCLBH = DispatchVehicle.VehicleCode; if (hasInsertedDispatchVehicleRecord(DispatchVehicle, UnitCode, strLcoalLSH, ref strLocalCLBH, ref strLocalCS)) { //成功更新车辆信息表中的车辆状态 string sql = "update clxxb set clzt ='" + DispatchVehicle.VehicleZT + "' where clbh= '" + strLocalCLBH + "'"; int i = DB120Help.ExecuteSql(sql); if (i != 0) { LogHelper.WriteLog("车辆状态更新成功 车辆编号:" + strLocalCLBH); } //主键关联 sql = "insert into LWCLTBDYB (locallsh,localCS,localCLBH,TargetLSH,TargetCS,TargetCLBH,TargetDWBH) values ('" + strLcoalLSH + "','" + strLocalCS + "','" + strLocalCLBH + "','" + strTargetLSH + "','" + strTargetCS + "','" + strTargetCLBH + "','" + UnitCode + "')"; i = DB120Help.ExecuteSql(sql); if (i > 0) { LogHelper.WriteLog("车辆信息表主键关联成功本地流水号:" + strLcoalLSH + " 车次:" + strLocalCS + " 车辆编号:" + strLocalCLBH + " 关联的流水号:" + strTargetLSH + " 车次:" + strTargetCS + " 车辆编号:" + strTargetCLBH); } else { LogHelper.WriteLog("车辆信息表主键关联失败本地流水号:" + strLcoalLSH + " 车次:" + strLocalCS + " 车辆编号:" + strLocalCLBH + " 关联的流水号:" + strTargetLSH + " 车次:" + strTargetCS + " 车辆编号:" + strTargetCLBH); } DispatchVehicleDataResp Data = new DispatchVehicleDataResp(); Data.CommandID = DispatchVehicle.CommandID + "Resp"; Data.DealRecordID = strTargetLSH; Data.VehicleCode = strTargetCLBH; Data.Times = strTargetCS; Data.Result = 1; ExchangeDataResp(Data); } } } //非联网单直接更新不需要重发消息 else { DispatchVehicleDataResp Data = new DispatchVehicleDataResp(); Data.CommandID = DispatchVehicle.CommandID + "Resp"; Data.DealRecordID = strTargetLSH; Data.VehicleCode = strTargetCLBH; Data.Times = strTargetCS; Data.Result = 1; ExchangeDataResp(Data); } } catch (Exception ex) { DispatchVehicleDataResp Data = new DispatchVehicleDataResp(); Data.CommandID = DispatchVehicle.CommandID + "Resp"; Data.DealRecordID = DispatchVehicle.DealRecordID; Data.VehicleCode = DispatchVehicle.VehicleCode; Data.Times = DispatchVehicle.Times; Data.Result = 0; Data.FailtureReason = ex.Message; ExchangeDataResp(Data); LogHelper.WriteLog("", ex); } }