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.
249 lines
9.0 KiB
249 lines
9.0 KiB
using Elight.Entity; |
|
using Elight.Logic; |
|
using Elight.Utility; |
|
using Elight.Utility.Code; |
|
using Microsoft.AspNetCore.Authorization; |
|
using Microsoft.AspNetCore.Mvc; |
|
using SqlSugar; |
|
|
|
namespace _24Hour.Controllers.Common |
|
{ |
|
/// <summary> |
|
/// 远程会见 |
|
/// </summary> |
|
[Authorize] |
|
[ApiController] |
|
[Route("api/Remote")] |
|
public class RemoteController : 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 RemoteController(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("QueryRemoteuser")] |
|
public async Task<Result> QueryRemoteuser(App_RemoteInput Remotedata) |
|
{ |
|
var Receptionlist = new List<App_RemoteModel>(); |
|
//查询远程会见记录 |
|
var list = await _db.Queryable<App_RemoteModel>() |
|
.WhereIF(Remotedata.Code != null, q => q.Code.Contains(Remotedata.Code)) |
|
.WhereIF(Remotedata.name != null, q => q.name.Contains(Remotedata.name)) |
|
.WhereIF(Remotedata.meetwitname != null, q => q.meetwitname.Contains(Remotedata.meetwitname)) |
|
.WhereIF(Remotedata.state != null, q => q.state == Remotedata.state) |
|
.Where(q => q.IsDeleted == 0 && q.unitId == _userdata.unitCode).ToPageListAsync(Remotedata.PageIndex, Remotedata.PageSize); |
|
var data = new QueryResult<App_RemoteModel>(Remotedata, list.OrderByDescending(q => q.creationtime).ToList()); |
|
result.IsSucceed = true; |
|
result.result = data; |
|
return result; |
|
} |
|
|
|
/// <summary> |
|
/// 远程会见分页查询 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("QueryRemote")] |
|
public async Task<Result> QueryRemote(App_RemoteInput Remotedata) |
|
{ |
|
var Receptionlist = new List<App_RemoteModel>(); |
|
//查询远程会见记录 |
|
var list = await _db.Queryable<App_RemoteModel>() |
|
.WhereIF(Remotedata.Code != null, q => q.Code.Contains(Remotedata.Code)) |
|
.WhereIF(Remotedata.name != null, q => q.name.Contains(Remotedata.name)) |
|
.WhereIF(Remotedata.meetwitname != null, q => q.meetwitname.Contains(Remotedata.meetwitname)) |
|
.WhereIF(Remotedata.state != null, q => q.state == Remotedata.state) |
|
.Where(q => q.IsDeleted == 0).ToPageListAsync(Remotedata.PageIndex, Remotedata.PageSize); |
|
var data = new QueryResult<App_RemoteModel>(Remotedata, list.OrderByDescending(q => q.creationtime).ToList()); |
|
result.IsSucceed = true; |
|
result.result = data; |
|
return result; |
|
} |
|
/// <summary> |
|
/// 添加远程会见 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("AddRemote")] |
|
public async Task<Result> AddRemote(App_RemoteModel Remotedata) |
|
{ |
|
try |
|
{ |
|
_db.BeginTran(); |
|
Remotedata.Id = Guid.NewGuid().ToString(); |
|
//Remotedata.unitId = _userdata.unitCode.ToString(); |
|
Remotedata.createuserId = _userdata.Id.ToString(); |
|
Remotedata.createusername = _userdata.name; |
|
var num = await _db.Insertable(Remotedata).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("UpdateRemote")] |
|
public async Task<Result> UpdateRemote(App_RemoteModel Remotedata) |
|
{ |
|
try |
|
{ |
|
_db.BeginTran(); |
|
var num = await _db.Updateable(Remotedata).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("DeleteRemote")] |
|
public async Task<Result> DeleteRemote(CurrencyDelete Currency) |
|
{ |
|
try |
|
{ |
|
_db.BeginTran(); |
|
var Receptionlist = await _db.Queryable<App_RemoteModel>().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("UpdateRemote_state")] |
|
public async Task<Result> UpdateRemote_state(CurrencyDelete Currency) |
|
{ |
|
try |
|
{ |
|
var Receptionlist = await _db.Queryable<App_RemoteModel>().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; |
|
} |
|
|
|
|
|
/// <summary> |
|
/// 取消远程会见 |
|
/// </summary> |
|
/// <param name="info"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("Updatecancellation_state")] |
|
public async Task<Result> Updatecancellation_state(CurrencyDelete Currency) |
|
{ |
|
try |
|
{ |
|
var Receptionlist = await _db.Queryable<App_RemoteModel>().Where(q => Currency.id.Contains(q.Id)).ToListAsync(); |
|
Receptionlist.ForEach(q => { q.state = 2; }); |
|
_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 |
|
} |
|
}
|
|
|