using Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.BaseApp.Base;
using OpenAuth.App.Response;
using OpenAuth.App.ServiceApp.FireManagement;
using OpenAuth.App.ServiceApp.FireManagement.Request;
using OpenAuth.App.ServiceApp.FireManagement.Response;
using OpenAuth.Repository.Domain.FireManagement;
namespace OpenAuth.WebApi.Controllers.ServiceControllers.FireManagement
{
///
/// 防火管理模块
///
[Route("api/[controller]/[action]")]
[ApiController]
public class FireManagementController : ControllerBase
{
private readonly FireManagementApp _app;
public FireManagementController(FireManagementApp app)
{
_app = app;
}
///
/// 下发防火线索任务
///
/// 防火任信息
///
[HttpPost]
public async Task> IssuedFireClueTask(FmFireclueTask info)
{
Response response = new Response();
try
{
return await _app.IssuedFireClueTask(info);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 查询接收人员
///
///
///
[HttpGet]
public async Task>> LoadFireClueUser(string username, string unitname)
{
Response> response = new Response>();
try
{
return await _app.LoadFireClueUser(username, unitname);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 查询任务列表
///
///
///
[HttpGet]
public async Task>> GetTaskList()
{
Response> response = new Response>();
try
{
return await _app.GetTaskList();
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 删除任务
///
///
///
[HttpPost]
public async Task> DeleteTask(long id)
{
Response response = new Response();
try
{
return await _app.DeleteTask(id);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 查询人员单位信息
///
///
[HttpGet]
public async Task>> GetUserUnit()
{
Response> response = new Response>();
try
{
return await _app.GetUserUnit();
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
#region 人员单位管理
///
/// 添加人员单位
///
///
///
[HttpPost]
public async Task> AddUserUnit(FmUserUnit info)
{
Response response = new Response();
try
{
return await _app.AddUserUnit(info);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 编辑人员单位
///
///
///
[HttpPost]
public async Task> EditUserUnit(FmUserUnit info)
{
Response response = new Response();
try
{
return await _app.EditUserUnit(info);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 删除人员单位
///
///
///
[HttpPost]
public async Task> DeleteUserUnit(long id)
{
Response response = new Response();
try
{
return await _app.DeleteUserUnit(id);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 获取单条人员单位
///
///
///
[HttpGet]
public async Task> LoadUserUnitById(long id)
{
Response response = new Response();
try
{
return await _app.LoadUserUnitById(id);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 人员单位信息导入
///
///
///
[HttpPost]
public Response FireUserUnitUpload(IFormFileCollection formFiles)
{
Response response = new Response();
try
{
return _app.FireUserUnitUpload(formFiles);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
#endregion
#region 火情线索
///
/// 添加火情线索
///
///
///
[HttpPost]
public async Task> AddFireClueInfo(FmFireclueInfo info)
{
Response response = new Response();
try
{
return await _app.AddFireClueInfo(info);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 查询火情线索
///
///
[HttpGet]
public async Task> LoadClueInfoById(long id)
{
Response response = new Response();
try
{
return await _app.LoadClueInfoById(id);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 查询火情日志
///
///
///
[HttpGet]
[AllowAnonymous]
public async Task>> GetFireClueLog(long id)
{
Response> response = new Response>();
try
{
return await _app.GetFireClueLog(id);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 获取火情信息和摄像机信息
///
///
///
[HttpGet]
public async Task> LoadClueWithInfoById(long id)
{
Response response = new Response();
try
{
return await _app.LoadClueWithInfoById(id);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 查询火情线索列表
///
///
[HttpGet]
public async Task>> GetFireClueList()
{
Response> response = new Response>();
try
{
return await _app.GetFireClueList();
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 修改火情线索状态
///
///
///
///
[HttpPost]
[AllowAnonymous]
public async Task> UpdatFireStateById(long id, int state)
{
Response response = new Response();
try
{
return await _app.UpdatFireState(id, state);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 按日期统计火情线索
///
/// 1-月,2-年
///
[HttpGet]
public async Task>> GetFireClueStatistics(int type)
{
Response> response = new Response>();
try
{
return await _app.GetFireClueStatistics(type);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 按状态统计火情线索
///
/// 1-日,2-月,3-年
///
[HttpGet]
public async Task>> GetFireClueStatisticsByState(int type)
{
Response> response = new Response>();
try
{
return await _app.GetFireClueStatisticsByState(type);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 按等级统计火情线索
///
/// 1-日,2-月,3-年
///
[HttpGet]
public async Task>> GetFireClueStatisticsByDegreeType(int type)
{
Response> response = new Response>();
try
{
return await _app.GetFireClueStatisticsByDegreeType(type);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
#endregion
///
/// 在线情况
///
///
///
[HttpPost]
public async Task>> GetPointUserOnLine(UserOnLineReq pageReq)
{
Response> response = new Response>();
try
{
return await _app.GetPointUserOnLine(pageReq);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 添加人员坐标点
///
/// 坐标点
///
[HttpPost]
public async Task> AddPoint(FmUserPoint info)
{
return await _app.AddPointAsync(info);
}
///
/// 地图标绘保存
///
///
///
[HttpPost]
[AllowAnonymous]
public async Task> SaveMapPlotting(MapPlottingReq req)
{
if (string.IsNullOrEmpty(req.Title))
{
return new Response() { Code = 500, Message = "标题不能为空" };
}
if (string.IsNullOrEmpty(req.Description))
{
return new Response() { Code = 500, Message = "描述不能为空" };
}
return await _app.SaveMapPlotting(req);
}
///
/// 地图村绘列表
///
///
///
[HttpGet]
[AllowAnonymous]
public async Task>> GetMapPlotting([FromQuery] PageReq req)
{
return await _app.GetMapPlotting(req);
}
///
/// 查询人员上报的线索
///
///
///
///
///
///
[HttpGet]
[AllowAnonymous]
public async Task>>> LoadFireClueInfoByUserId(int pageIndex, int state, int pageSize, string userid)
{
return await _app.LoadFireClueInfoByUserId(pageIndex, state, pageSize, userid);
}
///
/// 获取视频流
///
///
///
[HttpGet]
[AllowAnonymous]
public string GetPreviewURLs(string deviceCode,string protocol)
{
try
{
return _app.GetPreviewURLs(deviceCode, protocol);
}
catch (Exception ex)
{
return ex.Message.ToString();
}
}
#region 人员类型统计查询
[HttpGet]
[AllowAnonymous]
public async Task> GetUserTypeStatistics()
{
Response response = new Response();
try
{
return await _app.GetUserTypeStatistics();
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
#endregion
#region 获取物资相关接口
///
/// 查询全部营房信息
///
///
[HttpGet]
[AllowAnonymous]
public Response> GetAllYingFang()
{
Response> response = new Response>();
try
{
response.Result = _app.GetAllYingFang();
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 物资储备点
///
/// 物资名称
///
///
[HttpGet]
[AllowAnonymous]
public TableData Loadwuzichubei(string wuzi, string areaname)
{
return _app.Loadwuzichubei(wuzi, areaname);
}
#endregion
}
}