You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
245 lines
9.3 KiB
245 lines
9.3 KiB
using Elight.Entity; |
|
using Elight.Logic; |
|
using Elight.Utility; |
|
using Elight.Utility.Code; |
|
using Elight.Utility.Extensions; |
|
using Microsoft.AspNetCore.Authorization; |
|
using Microsoft.AspNetCore.Mvc; |
|
using SqlSugar; |
|
|
|
namespace _24Hour.Controllers.Common |
|
{ |
|
/// <summary> |
|
/// 远程接待 |
|
/// </summary> |
|
[Authorize] |
|
[ApiController] |
|
[Route("api/reception")] |
|
public class ReservationController : Controller |
|
{ |
|
#region Identity |
|
private readonly SqlSugarClient _db;//数据库 |
|
private readonly WriteSysLog _logs;//操作日志 |
|
App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户 |
|
private readonly ILogger<LoginController> _logger;//日志 |
|
Result result = new Result(); |
|
public ReservationController(ILogger<LoginController> logger, SqlSugarClient db, WriteSysLog logs, User user) |
|
{ |
|
_logger = logger; |
|
_db = db; |
|
_logs = logs; |
|
_userdata = user.Userdata(); |
|
} |
|
|
|
#endregion |
|
|
|
|
|
#region 预约接待管理 |
|
/// <summary> |
|
/// app---预约接待分页查询 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("QueryReceptionapp")] |
|
public async Task<Result> QueryReceptionapp(App_ReceptionInput Reception) |
|
{ |
|
var Receptionlist = new List<App_ReceptionModel>(); |
|
//获取工作台信息 |
|
var app_staging = await _db.Queryable<StagingModel>().Where(w => w.IsDelete == 0).ToListAsync(); |
|
//查询预约接待记录 |
|
var list = await _db.Queryable<App_ReceptionModel>() |
|
.WhereIF(!string.IsNullOrEmpty(Reception.matter), q => q.matter.Contains(Reception.matter)) |
|
.WhereIF(!string.IsNullOrEmpty(Reception.meetwitname), q => q.meetwitname.Contains(Reception.meetwitname)) |
|
.WhereIF(Reception.state != null, q => q.state == Reception.state) |
|
.Where(q => q.IsDeleted == 0&&q.createuserId==_userdata.Id).ToPageListAsync(Reception.PageIndex, Reception.PageSize); |
|
list.ForEach(q => |
|
{ |
|
var data = app_staging.Where(a => a.Id == q.reservationId).FirstOrDefault(); |
|
if (data != null) |
|
{ |
|
q.reservationId = data.title; |
|
Receptionlist.Add(q); |
|
} |
|
}); |
|
var data = new QueryResult<App_ReceptionModel>(Reception, Receptionlist.OrderByDescending(q => q.creationtime).ToList()); |
|
result.IsSucceed = true; |
|
result.result = data; |
|
return result; |
|
} |
|
|
|
|
|
/// <summary> |
|
/// 预约接待分页查询 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("QueryReception")] |
|
public async Task<Result> QueryReception(App_ReceptionInput Reception) |
|
{ |
|
RefAsync<int> totalNumber = 0;//总数据 |
|
var Receptionlist = new List<App_ReceptionModel>(); |
|
//获取工作台信息 |
|
var app_staging = await _db.Queryable<StagingModel>().Where(w => w.IsDelete == 0).ToListAsync(); |
|
//查询预约接待记录 |
|
var list = await _db.Queryable<App_ReceptionModel>() |
|
.WhereIF(!string.IsNullOrEmpty(Reception.matter), q => q.matter.Contains(Reception.matter)) |
|
.WhereIF(!string.IsNullOrEmpty(Reception.meetwitname), q => q.meetwitname.Contains(Reception.meetwitname)) |
|
.WhereIF(!string.IsNullOrEmpty(Reception.phone), q => q.phone.Contains(Reception.phone)) |
|
.WhereIF(Reception.state != null, q => q.state == Reception.state) |
|
.WhereIF(Reception.StartTime != null && Reception.EndTime != null, q => q.sttime >= Reception.StartTime && q.sttime < Reception.EndTime.Value.AddDays(1)) |
|
.Where(q => q.IsDeleted == 0&&q.unitId==_userdata.unitCode).ToPageListAsync(Reception.PageIndex, Reception.PageSize, totalNumber); |
|
Reception.RowsCount = totalNumber; |
|
list.ForEach(q => |
|
{ |
|
var data = app_staging.Where(a => a.Id == q.reservationId).FirstOrDefault(); |
|
if (data != null) |
|
{ |
|
q.reservationId = data.title; |
|
Receptionlist.Add(q); |
|
} |
|
}); |
|
var data = new QueryResult<App_ReceptionModel>(Reception, Receptionlist.OrderByDescending(q => q.creationtime).ToList()); |
|
result.IsSucceed = true; |
|
result.result = data; |
|
return result; |
|
} |
|
/// <summary> |
|
/// 添加预约接待 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("AddReception")] |
|
public async Task<Result> AddReception(App_ReceptionModel Receptiondata) |
|
{ |
|
try |
|
{ |
|
_db.BeginTran(); |
|
Receptiondata.Id = Guid.NewGuid().ToString(); |
|
Receptiondata.createuserId = _userdata.Id.ToString(); |
|
Receptiondata.createusername = _userdata.name; |
|
var num = await _db.Insertable(Receptiondata).ExecuteCommandAsync(); |
|
_db.CommitTran(); |
|
if (num > 0) |
|
{ |
|
result.IsSucceed = true; |
|
result.result = "添加成功"; |
|
} |
|
} |
|
catch (System.Exception ex) |
|
{ |
|
_db.RollbackTran(); |
|
result.IsSucceed = false; |
|
result.Message = ex.Message; |
|
} |
|
_logs.WriteSysLogadd("远程接待", "添加预约接待信息", result,_db); |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 修改预约接待 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("UpdateReception")] |
|
public async Task<Result> UpdateReception(App_ReceptionModel Receptiondata) |
|
{ |
|
try |
|
{ |
|
_db.BeginTran(); |
|
var num = await _db.Updateable(Receptiondata).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); |
|
_db.CommitTran(); |
|
if (num > 0) |
|
{ |
|
result.IsSucceed = true; |
|
result.result = "修改成功"; |
|
} |
|
} |
|
catch (System.Exception ex) |
|
{ |
|
_db.RollbackTran(); |
|
result.IsSucceed = false; |
|
result.Message = ex.Message; |
|
} |
|
_logs.WriteSysLogadd("远程接待", "修改预约接待", result,_db); |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 删除预约接待 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("DeleteReception")] |
|
public async Task<Result> DeleteReception(CurrencyDelete Currency) |
|
{ |
|
try |
|
{ |
|
_db.BeginTran(); |
|
var Receptionlist = await _db.Queryable<App_ReceptionModel>().In(q => q.Id, Currency.id).ToListAsync(); |
|
Receptionlist.ForEach(q => |
|
{ |
|
q.IsDeleted = 1; |
|
}); |
|
var num = await _db.Updateable(Receptionlist).ExecuteCommandAsync(); |
|
_db.CommitTran(); |
|
if (num > 0) |
|
{ |
|
result.IsSucceed = true; |
|
result.result = "删除成功"; |
|
} |
|
} |
|
catch (System.Exception ex) |
|
{ |
|
_db.RollbackTran(); |
|
result.IsSucceed = false; |
|
result.Message = ex.Message; |
|
} |
|
_logs.WriteSysLogadd("远程接待", "删除预约接待", result,_db); |
|
return result; |
|
} |
|
|
|
|
|
/// <summary> |
|
/// 办理预约接待 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("UpdateReception_state")] |
|
public async Task<Result> UpdateReception_state(Commonpage Commonpagedata) |
|
{ |
|
try |
|
{ |
|
var Receptionlist = await _db.Queryable<App_ReceptionModel>().Where(q =>q.Id== Commonpagedata.Id).ToListAsync(); |
|
Receptionlist.ForEach(q => { |
|
q.state = (int)Commonpagedata.state; |
|
q.acceptancetime = DateTime.Now; |
|
if (Commonpagedata.reason.NotNull()) |
|
q.reason = Commonpagedata.reason; |
|
}); |
|
_db.BeginTran(); |
|
var num = await _db.Updateable(Receptionlist).ExecuteCommandAsync(); |
|
_db.CommitTran(); |
|
if (num > 0) |
|
{ |
|
result.IsSucceed = true; |
|
result.result = "办理成功"; |
|
} |
|
} |
|
catch (System.Exception ex) |
|
{ |
|
_db.RollbackTran(); |
|
result.IsSucceed = false; |
|
result.Message = ex.Message; |
|
} |
|
_logs.WriteSysLogadd("远程接待", "办理预约接待", result,_db); |
|
return result; |
|
} |
|
#endregion |
|
} |
|
}
|
|
|