挂单查询
This commit is contained in:
@@ -222,34 +222,42 @@ public class ShuWenController : ApiController
|
||||
[Route("api/shuwen/download")]
|
||||
public HttpResponseMessage DownloadShuWenWord(int? activitynum)
|
||||
{
|
||||
var data = _db.ShuWen.Where(a => a.ActivityNum == activitynum).FirstOrDefault();
|
||||
if (data == null)
|
||||
try
|
||||
{
|
||||
//return;
|
||||
}
|
||||
string json = data.ShuWenList;
|
||||
string ActivityName = _db.activities.Where(a => a.num == data.ActivityNum).FirstOrDefault().subject;
|
||||
if (json == null)
|
||||
{
|
||||
//return;
|
||||
}
|
||||
string fileName = $"疏文名單_{DateTime.Now:yyyyMMddHHmmss}.docx";
|
||||
|
||||
var stream = new MemoryStream();
|
||||
GenerateShuWenWord_OpenXml(json, stream, ActivityName);
|
||||
stream.Position = 0;
|
||||
var response = new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new StreamContent(stream)
|
||||
};
|
||||
response.Content.Headers.ContentType =
|
||||
new System.Net.Http.Headers.MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||
response.Content.Headers.ContentDisposition =
|
||||
new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
|
||||
var data = _db.ShuWen.Where(a => a.ActivityNum == activitynum).FirstOrDefault();
|
||||
if (data == null)
|
||||
{
|
||||
FileName = fileName
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "活動編號不能為空");
|
||||
}
|
||||
string json = data.ShuWenList;
|
||||
string ActivityName = _db.activities.Where(a => a.num == data.ActivityNum).FirstOrDefault().subject;
|
||||
if (json == null)
|
||||
{
|
||||
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "疏文列表为空,无法生成 Word");
|
||||
}
|
||||
string fileName = $"疏文名單_{DateTime.Now:yyyyMMddHHmmss}.docx";
|
||||
|
||||
var stream = new MemoryStream();
|
||||
GenerateShuWenWord_OpenXml(json, stream, ActivityName);
|
||||
stream.Position = 0;
|
||||
var response = new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new StreamContent(stream)
|
||||
};
|
||||
return response;
|
||||
response.Content.Headers.ContentType =
|
||||
new System.Net.Http.Headers.MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||
response.Content.Headers.ContentDisposition =
|
||||
new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
|
||||
{
|
||||
FileName = fileName
|
||||
};
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void GenerateShuWenWord_OpenXml(string json, Stream outputStream, string ActivityName ="")
|
||||
|
||||
@@ -105,8 +105,9 @@ public class regionController : ApiController
|
||||
.Where(s => s.TargetUuid == bed.Uuid
|
||||
&& s.IsDeleted == false
|
||||
&& (s.ScheduleDate == null
|
||||
|| (s.ScheduleDate >= startDate && s.ScheduleDate <= endDate)))
|
||||
|| (s.ScheduleDate >= startDate)))
|
||||
.Where(s => s.GuaDanOrderGuest.StatusCode != "403" && s.GuaDanOrderGuest.StatusCode != "404")
|
||||
.OrderByDescending(a => a.ScheduleDate)
|
||||
.Select(s => new
|
||||
{
|
||||
s.Uuid,
|
||||
|
||||
@@ -29,8 +29,33 @@ public class guadanGuestQueryController: ApiController
|
||||
{
|
||||
query = query.Where(guest => guest.followers.u_name.Contains(search.SearchName));
|
||||
}
|
||||
var data = await query.ToListAsync();
|
||||
var data1 = data.Select(a => new
|
||||
if(search.searchCheckInDate != null)
|
||||
{
|
||||
query = query.Where(guest => guest.CheckInAt == search.searchCheckInDate);
|
||||
}
|
||||
if(search.searchCheckInDateStart != null)
|
||||
{
|
||||
query = query.Where(guest => guest.CheckInAt >= search.searchCheckInDateStart);
|
||||
}
|
||||
if (search.searchCheckInDateEnd != null)
|
||||
{
|
||||
query = query.Where(guest => guest.CheckInAt <= search.searchCheckInDateEnd);
|
||||
}
|
||||
if (search.searchCheckOutDateStart != null)
|
||||
{
|
||||
query = query.Where(guest => guest.CheckOutAt >= search.searchCheckOutDateStart);
|
||||
}
|
||||
if (search.searchCheckOutDateEnd != null)
|
||||
{
|
||||
query = query.Where(guest => guest.CheckOutAt <= search.searchCheckOutDateEnd);
|
||||
}
|
||||
var totalCount = await query.CountAsync();
|
||||
var pagedData = await query
|
||||
.OrderByDescending(a => a.CheckInAt) // 可根据需要排序
|
||||
.Skip((search.Page - 1) * search.PageSize)
|
||||
.Take(search.PageSize)
|
||||
.ToListAsync();
|
||||
var data1 = pagedData.Select(a => new
|
||||
{
|
||||
name = a.followers != null ? a.followers.u_name : null,
|
||||
checkindate = a.CheckInAt,
|
||||
@@ -41,9 +66,8 @@ public class guadanGuestQueryController: ApiController
|
||||
return Ok(new
|
||||
{
|
||||
items = data1,
|
||||
total = data1.Count(),
|
||||
total = totalCount,
|
||||
});
|
||||
|
||||
}
|
||||
public string GetRoomAndBedString(RegionRoomBed bed)
|
||||
{
|
||||
@@ -66,5 +90,13 @@ public class guadanGuestQueryController: ApiController
|
||||
public class SearchGuestModel
|
||||
{
|
||||
public string SearchName = null;
|
||||
public int Page = 1;
|
||||
public int PageSize = 10;
|
||||
public DateTime? searchCheckInDateStart = null;//入住日期的开始
|
||||
public DateTime? searchCheckInDateEnd = null;//入住日期的结束
|
||||
public DateTime? searchCheckOutDateStart = null;//退房日期的开始
|
||||
public DateTime? searchCheckOutDateEnd = null;//退房日期的结束
|
||||
public DateTime? searchCheckInDate = null;
|
||||
public DateTime? searchCheckOutDate = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user