128 lines
6.4 KiB
C#
128 lines
6.4 KiB
C#
|
using HL_FristAidPlatform_Help;
|
|||
|
using HL_FristAidPlatform_IDataBase;
|
|||
|
using HL_FristAidPlatform_Models;
|
|||
|
using SqlSugar;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace HL_FristAidPlatform_DataBase
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 车辆暂调用恢复调用流水记录
|
|||
|
/// </summary>
|
|||
|
public class T_Service_FirstAid_VehicleCallRunningDB : BaseDB, IT_Service_FirstAid_VehicleCallRunning
|
|||
|
{
|
|||
|
public SqlSugarClient db = GetClient();
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 车辆暂停流水记录
|
|||
|
/// </summary>
|
|||
|
/// <param name="guid">医院guid</param>
|
|||
|
/// <param name="hospitalGuid">站guid</param>
|
|||
|
/// <param name="time1"></param>
|
|||
|
/// <param name="time2"></param>
|
|||
|
/// <param name="vehicleGuid">车辆guid</param>
|
|||
|
/// <param name="vehicleGuid">pageIndex</param>
|
|||
|
/// <param name="vehicleGuid">pageSize</param>
|
|||
|
/// <returns></returns>
|
|||
|
public TableModel<VehicleCallRunningModel> GetList(string guid, string hospitalGuid, string time1, string time2, string vehicleGuid, int pageIndex, int pageSize)
|
|||
|
{
|
|||
|
int total = 0;
|
|||
|
List<VehicleCallRunningModel> list = new List<VehicleCallRunningModel>();
|
|||
|
var hospital = db.Queryable<T_Base_Hospital>().Where(it => it.GUID == guid).First();
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(hospital.ParentGUID))//总站或调度中心
|
|||
|
{
|
|||
|
list = db.Queryable<T_Service_FirstAid_VehicleCallRunning, T_Service_FirstAid_AlarmTaskInfo, T_Service_FirstAid_AlarmInfo, T_Base_Hospital, T_Base_Ambulance, T_SYS_User, T_SYS_User>(
|
|||
|
(a, b, c, d, e, h, i) => new JoinQueryInfos(
|
|||
|
JoinType.Inner, a.TaskGUID == b.GUID,
|
|||
|
JoinType.Inner, b.AlarmGuid == c.GUID,
|
|||
|
JoinType.Inner, c.HospitalGuid == d.GUID,
|
|||
|
JoinType.Inner, b.VehicleGUID == e.GUID,
|
|||
|
JoinType.Inner, a.UserId == h.ID,
|
|||
|
JoinType.Left, a.RUserId == i.ID))
|
|||
|
.Where((a, b, c, d, e) => c.CallHospitalGuid == guid)
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(hospitalGuid), (a, b, c, d, e) => c.HospitalGuid == hospitalGuid)
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(time1), (a, b, c, d, e) => a.PauseTime >= Convert.ToDateTime(time1))
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(time2), (a, b, c, d, e) => a.PauseTime <= Convert.ToDateTime(time2).AddDays(1))
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(vehicleGuid), (a, b, c, d, e) => b.VehicleGUID == vehicleGuid)
|
|||
|
.OrderBy((a, b, c, d, e, h) => a.Reason, OrderByType.Asc)
|
|||
|
.Select((a, b, c, d, e, h, i) => new VehicleCallRunningModel()
|
|||
|
{
|
|||
|
HospitalName = d.Name,
|
|||
|
PlateNumber = e.PlateNumber,
|
|||
|
PauseTime = a.PauseTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
|||
|
Reson = a.Reason,
|
|||
|
UserName = h.FullName,
|
|||
|
RecoveryTime = Convert.ToDateTime(a.RecoveryTime).ToString("yyyy-MM-dd HH:mm:ss"),
|
|||
|
RUserName = i.FullName
|
|||
|
}).ToPageList(pageIndex, pageSize, ref total);
|
|||
|
}
|
|||
|
else //分站
|
|||
|
{
|
|||
|
list = db.Queryable<T_Service_FirstAid_VehicleCallRunning, T_Service_FirstAid_AlarmTaskInfo, T_Service_FirstAid_AlarmInfo, T_Base_Hospital, T_Base_Ambulance, T_SYS_User, T_SYS_User>(
|
|||
|
(a, b, c, d, e, h, i) => new JoinQueryInfos(
|
|||
|
JoinType.Inner, a.TaskGUID == b.GUID,
|
|||
|
JoinType.Inner, b.AlarmGuid == c.GUID,
|
|||
|
JoinType.Inner, c.HospitalGuid == d.GUID,
|
|||
|
JoinType.Inner, b.VehicleGUID == e.GUID,
|
|||
|
JoinType.Inner, a.UserId == h.ID,
|
|||
|
JoinType.Left, a.RUserId == i.ID))
|
|||
|
.Where((a, b, c, d, e) => c.HospitalGuid == guid)
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(hospitalGuid), (a, b, c, d, e) => c.HospitalGuid == hospitalGuid)
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(time1), (a, b, c, d, e) => a.PauseTime >= Convert.ToDateTime(time1))
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(time2), (a, b, c, d, e) => a.PauseTime <= Convert.ToDateTime(time2).AddDays(1))
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(vehicleGuid), (a, b, c, d, e) => b.VehicleGUID == vehicleGuid)
|
|||
|
.OrderBy((a, b, c, d, e, h) => a.Reason, OrderByType.Asc)
|
|||
|
.Select((a, b, c, d, e, h, i) => new VehicleCallRunningModel()
|
|||
|
{
|
|||
|
HospitalName = d.Name,
|
|||
|
PlateNumber = e.PlateNumber,
|
|||
|
PauseTime = a.PauseTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
|||
|
Reson = a.Reason,
|
|||
|
UserName = h.FullName,
|
|||
|
RecoveryTime = Convert.ToDateTime(a.RecoveryTime).ToString("yyyy-MM-dd HH:mm:ss"),
|
|||
|
RUserName = i.FullName
|
|||
|
}).ToPageList(pageIndex, pageSize, ref total);
|
|||
|
}
|
|||
|
total = list.Count();
|
|||
|
TableModel<VehicleCallRunningModel> t = new TableModel<VehicleCallRunningModel>();
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = list.Count();
|
|||
|
t.TotalNumber = total;
|
|||
|
t.Data = list;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
|
|||
|
public T_Service_FirstAid_VehicleCallRunning GetByTaskGUID(string guid)
|
|||
|
{
|
|||
|
return db.Queryable<T_Service_FirstAid_VehicleCallRunning>().Where(it => it.TaskGUID == guid && it.DeleteFlag == 0).First();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 保存暂停流水记录
|
|||
|
/// </summary>
|
|||
|
/// <param name="model"></param>
|
|||
|
public bool SaveVehicleCallRunning(T_Service_FirstAid_VehicleCallRunning model)
|
|||
|
{
|
|||
|
if (!SqlFunc.IsNullOrEmpty(model.GUID))
|
|||
|
{
|
|||
|
model.RecoveryTime = DateTime.Now;
|
|||
|
return db.Updateable(model).UpdateColumns(it => new
|
|||
|
{
|
|||
|
it.RecoveryTime,
|
|||
|
it.RUserId
|
|||
|
}).ExecuteCommand() == 1 ? true : false;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
model.GUID = Guid.NewGuid().ToString();
|
|||
|
return db.Insertable(model).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand() == 1 ? true : false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|