StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_FirstAid_Accident...

59 lines
2.3 KiB
C#

using HL_FristAidPlatform_Help;
using HL_FristAidPlatform_Models;
using SqlSugar;
using System;
using System.Linq;
namespace HL_FristAidPlatform_DataBase
{
/// <summary>
/// 重大事故统计
/// </summary>
public class T_Service_FirstAid_AccidentCensusDB : BaseDB, IT_Service_FirstAid_AccidentCensus
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 分页列表
/// </summary>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
public TableModel<AccidentCensusModel> GetPageList(string hospitalGuid, string startTime, string endTime, int pageIndex, int pageSize)
{
int total = 0;
var list = db.Queryable<T_Service_FirstAid_AlarmInfo, T_Base_AccidentInfo>
((a, b) => new JoinQueryInfos
(JoinType.Inner, a.AccidentGUID == b.GUID))
.Where((a, b) => a.HospitalGuid == hospitalGuid
&& Convert.ToDateTime(a.DispatchDatetime) >= Convert.ToDateTime(startTime)
&& Convert.ToDateTime(a.DispatchDatetime) <= Convert.ToDateTime(endTime).AddDays(1))
.OrderBy((a, b) => a.DispatchDatetime, OrderByType.Desc)
.Select((a, b) => new AccidentCensusModel()
{
DispatchNo = a.DispatchNo,
AccidentDate = a.DispatchDatetime.ToString("yyyy-MM-dd HH:mm:ss"),
AccidentName = b.ParentName,
PatientNumber = a.PatientsNumber,
ActualPatientNumber = SqlFunc.Subqueryable<T_Service_FirstAid_AlarmTaskInfo>()
.InnerJoin<T_Service_FirstAid_PatientInfo>
((task, info) => task.GUID == info.TaskGUID)
.Where(task => task.AlarmGuid == a.GUID).Count()
}).ToPageList(pageIndex, pageSize, ref total);
total = list.Count();
TableModel<AccidentCensusModel> t = new TableModel<AccidentCensusModel>();
t.Code = 0;
t.PageCount = list.Count();
t.TotalNumber = total;
t.Data = list;
t.Msg = "成功";
return t;
}
}
}