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.
201 lines
7.1 KiB
201 lines
7.1 KiB
2 years ago
|
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
|
||
|
{
|
||
|
[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>
|
||
|
/// 预约接待分页查询
|
||
|
/// </summary>
|
||
|
/// <param name="info"></param>
|
||
|
/// <returns></returns>
|
||
|
[HttpPost]
|
||
|
[Route("QueryReception")]
|
||
|
public async Task<Result> QueryReception(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.depart), q => q.depart.Contains(Reception.depart))
|
||
|
.WhereIF(!string.IsNullOrEmpty(Reception.createusername), q => q.createusername.Contains(Reception.createusername))
|
||
|
.WhereIF(!string.IsNullOrEmpty(Reception.receptionId), q => q.receptionId.Contains(Reception.receptionId))
|
||
|
.WhereIF(Reception.state != null, q => q.state == Reception.state)
|
||
|
.Where(q => q.IsDelete == 0).ToPageListAsync(Reception.PageIndex, Reception.PageSize);
|
||
|
list.ForEach(q =>
|
||
|
{
|
||
|
var data = app_staging.Where(a => a.Id == q.receptionId).First();
|
||
|
if (data != null)
|
||
|
{
|
||
|
q.receptionId = 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.IsDelete = 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(CurrencyDelete Currency)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
var Receptionlist = await _db.Queryable<App_ReceptionModel>().Where(q => Currency.id.Contains(q.Id)).ToListAsync();
|
||
|
Receptionlist.ForEach(q => { q.state = 1; });
|
||
|
_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
|
||
|
}
|
||
|
}
|