using HL_FristAidPlatform_Help; using HL_FristAidPlatform_IDataBase; using HL_FristAidPlatform_Models; using SqlSugar; using System; namespace HL_FristAidPlatform_DataBase { public class HandoverService : BaseDB, IHandoverService { public SqlSugarClient db = GetClient(); /// /// 车辆交接 /// /// /// /// public bool HandoverTran(DriverHandoverModel model) { try { db.Ado.BeginTran(); db.Updateable().SetColumns(it => new T_Service_FirstAid_AlarmTaskInfo() { HandoverOfDoctorTime = DateTime.Now, IsHandoverOfDoctor = 1, TaskState = 8, HandoverTime = DateTime.Now }).Where(it => it.GUID == model.TaskGUID).ExecuteCommand(); var info = db.Queryable().Where(i => i.GUID == model.TaskGUID).First(); T_Service_FirstAid_DriverHandover handover = new T_Service_FirstAid_DriverHandover(); handover.GUID = Guid.NewGuid().ToString(); handover.DriverGUID = info.DriverGUID; handover.AlarmTaskGUID = model.TaskGUID; handover.HandoverTime = DateTime.Now; handover.CreationID = model.UserId; db.Insertable(handover).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand(); db.Updateable().SetColumns(it => new T_Base_Ambulance() { State = 1 }).Where(it => it.GUID == info.VehicleGUID).ExecuteCommand(); db.Updateable().SetColumns(it => new T_SYS_User() { State = 1, VehicleGUID = "" }).Where(it => it.VehicleGUID == info.VehicleGUID).ExecuteCommand(); db.Ado.CommitTran(); return true; } catch (Exception ex) { db.Ado.RollbackTran(); Help.WriteErrorLog("院前:车辆交接(DoctorHandoverTran)", ex.ToString()); return false; } } } }