using Infrastructure;
using Infrastructure.Utilities.Excel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.ServiceApp.DroneSsnydManage;
using OpenAuth.App.ServiceApp.DroneSsnydManage.Export;
using OpenAuth.App.ServiceApp.DroneSsnydManage.Request;
using OpenAuth.Repository.Domain;
namespace OpenAuth.WebApi.Controllers.ServiceControllers
{
///
/// 批后监管--项目信息
///
[Route("api/[controller]/[action]")]
[ApiController]
public class DroneSsnyController : ControllerBase
{
DroneSsnyApp droneSsnyApp;
public DroneSsnyController(DroneSsnyApp droneSsnyApp)
{
this.droneSsnyApp = droneSsnyApp;
}
///
/// 到期预警
///
/// 项目名称
/// 县
/// 镇
/// 项目编号
/// 项目用途
///
///
///
[HttpGet]
[AllowAnonymous]
public Response>> TimeoutWarning(string xiangmumc, string countyid, string streetid,
string xiangmuno, string xiangmuyt,
int page, int limit)
{
var response = new Response>>();
try
{
response.Result =
droneSsnyApp.TimeoutWarning(xiangmumc, countyid, streetid, xiangmuno, xiangmuyt, page, limit);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 超期报警
///
/// 项目名称
/// 县
/// 镇
/// 项目编号
/// 项目用途
///
///
///
[HttpGet]
public Response>> TimeOutAlarmList(string xiangmumc, string countyid, string streetid,
string xiangmuno, string xiangmuyt,
int page, int limit)
{
var response = new Response>>();
try
{
response.Result =
droneSsnyApp.TimeOutAlarmList(xiangmumc, countyid, streetid, xiangmuno, xiangmuyt, page, limit);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 历史项目
///
///
///
[HttpGet]
public Response>> HistoryProject([FromQuery] DroneSsnyAppPageReq req)
{
var response = new Response>>();
try
{
response.Result = droneSsnyApp.HistoryProject(req);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 项目变更列表
///
///
///
[HttpGet]
public Response>> ProjectChange([FromQuery] DroneSsnyAppPageReq req)
{
var response = new Response>>();
try
{
response.Result = droneSsnyApp.ProjectChange(req);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 监管信息列表
///
///
///
[HttpGet]
public async Task>>> ProjectSupervise(
[FromQuery] DroneSsnydRcjgPageReq req)
{
var response = new Response>>();
try
{
response.Result = await droneSsnyApp.ProjectSupervise(req);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 项目维护
///
///
///
[HttpPost]
public async Task> ProjectMaintain(DroneSsnydEditReq req)
{
var response = new Response();
try
{
await droneSsnyApp.ProjectMaintain(req);
response.Result = true;
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 编号维护
///
///
///
///
[HttpPost]
public async Task> MaintainNumber(string id, string newXiangmuNo)
{
var response = new Response();
try
{
await droneSsnyApp.MaintainNumber(id, newXiangmuNo);
response.Result = true;
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 名称维护
///
///
///
///
[HttpPost]
public async Task> MaintainXianmuName(string id, string newXiangmuName)
{
var response = new Response();
try
{
await droneSsnyApp.MaintainXianmuName(id, newXiangmuName);
response.Result = true;
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 项目续期
///
///
///
///
[HttpPost]
public async Task> ProjectRenewal(string id, DateTime newEndTime)
{
var response = new Response();
try
{
await droneSsnyApp.ProjectRenewal(id, newEndTime);
response.Result = true;
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 停止生产
///
///
///
[HttpPost]
public async Task> CloseProject(string id)
{
var response = new Response();
try
{
await droneSsnyApp.CloseProject(id);
response.Result = true;
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
// 项目移交
///
/// 项目移交
///
///
///
///
[HttpPost]
public async Task> ProjectHandover(ProjectHandoverReq req)
{
var response = new Response();
try
{
await droneSsnyApp.ProjectHandover(req);
response.Result = true;
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 项目详情
///
///
///
[HttpGet]
public Response ProjectDetail(string id)
{
var response = new Response();
try
{
response.Result = droneSsnyApp.ProjectDetail(id);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 历史项目导出
///
///
///
[HttpGet]
public IActionResult HistoryProjectExport([FromQuery] DroneSnnyAppReq req)
{
var data = droneSsnyApp.HistoryProjectList(req);
var x = ExcelExporter.ExportToExcel(data, "历史项目");
return File(x.Result.ToArray(),
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"历史项目导出" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx");
}
///
/// 项目变更导出
///
///
///
[HttpGet]
public IActionResult ProjectChangeExport([FromQuery] DroneSnnyAppReq req)
{
var data = droneSsnyApp.ProjectChangeExport(req);
var x = ExcelExporter.ExportToExcel(data, "项目变更");
return File(x.Result.ToArray(),
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"项目变更导出" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx");
}
#region 预警报警导出
///
/// 超期预警数据导出
///
///
///
[HttpPost]
public IActionResult TimeoutWarningExport([FromQuery] TimeOutReq import)
{
var data = new Response();
List headers = null;
headers = new List
{
//"项目编号", "项目名称", "乡镇", "村庄", "权利人", "行政区划", "备案编号", "项目开始时间", "项目结束时间", "项目当前用途", "设施农业申请用地面积", "生产设施用地",
//"辅助设施用地", "下发时间", "项目状态"
"项目编号", "项目名称", "乡镇", "村庄", "权利人", "联系方式","行政区划", "备案编号","备案日期","项目状态", "项目开始时间", "项目结束时间", "设施农业类型","建筑结构", "设施农业申请用地面积(公顷)", "生产设施用地(公顷)", "辅助设施用地(公顷)"
};
var response = droneSsnyApp.TimeoutWarningExport(import.xiangmumc, import.countyid, import.streetid,
import.xiangmuno, import.xiangmuyt);
if (response.Count > 0)
{
var excelRes = droneSsnyApp.ListToExcel(response, headers);
if (excelRes.Code == 200)
{
return File(excelRes.Result.ToArray(),
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"超期预警" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
}
else
{
data.Code = excelRes.Code;
data.Message = excelRes.Message;
}
}
else
{
data.Code = 300;
data.Message = "暂无数据";
}
return Ok(data);
}
///
/// 超期报警数据导出
///
///
///
[HttpPost]
public IActionResult TimeoutAlarmExport([FromQuery] TimeOutReq import)
{
var data = new Response();
List headers = null;
headers = new List
{
"项目编号", "项目名称", "乡镇", "村庄", "权利人", "联系方式","行政区划", "备案编号","备案日期","项目状态", "项目开始时间", "项目结束时间", "设施农业类型","建筑结构", "设施农业申请用地面积(公顷)", "生产设施用地(公顷)", "辅助设施用地(公顷)"
};
var response = droneSsnyApp.TimeOutAlarmExport(import.xiangmumc, import.countyid, import.streetid,
import.xiangmuno, import.xiangmuyt);
if (response.Count > 0)
{
var excelRes = droneSsnyApp.ListToExcel(response, headers);
if (excelRes.Code == 200)
{
return File(excelRes.Result.ToArray(),
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"超期报警" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
}
else
{
data.Code = excelRes.Code;
data.Message = "导出失败";
}
}
else
{
data.Code = 300;
data.Message = "暂无数据";
}
return Ok(data);
}
#endregion
#region 项目列表 及导出
///
/// 项目列表
///
/// 项目名称
/// 县
/// 镇
/// 项目编号
/// 核查开始时间
/// 核查结束时间
/// 项目用途
/// 项目状态
///
///
///
[HttpGet]
public Response>> GetDronssnydList(string xiangmumc, string countyid, string streetid,int? status,
string xiangmuno, DateTime? hechatimebegin, DateTime? hechatimeend, string xiangmuyt,
int page, int limit)
{
var response = new Response>>();
try
{
response.Result =
droneSsnyApp.GetDronssnydList(xiangmumc, countyid, streetid, xiangmuno, hechatimebegin, hechatimeend, xiangmuyt, status,page, limit);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 项目列表导出
///
///
///
[HttpPost]
public IActionResult GetDronssnydExport([FromQuery] DroneSsny import)
{
var data = new Response();
List headers = null;
headers = new List
{
"项目编号", "项目名称", "乡镇", "村庄", "权利人", "联系方式","行政区划", "备案编号","备案日期","项目状态", "项目开始时间", "项目结束时间", "设施农业类型","建筑结构", "设施农业申请用地面积(公顷)", "生产设施用地(公顷)", "辅助设施用地(公顷)"
};
var response = droneSsnyApp.GetDronssnydExportList(import.xiangmumc, import.countyid, import.streetid,
import.xiangmuno, import.hechatimebegin,import.hechatimeend,import.xiangmuyt,import.status);
if (response.Count > 0)
{
var excelRes = droneSsnyApp.ListToExcel(response, headers);
if (excelRes.Code == 200)
{
return File(excelRes.Result.ToArray(),
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"项目列表" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
}
else
{
data.Code = excelRes.Code;
data.Message = "导出失败";
}
}
else
{
data.Code = 300;
data.Message = "暂无数据";
}
return Ok(data);
}
#endregion
#region 预警问题列表
///
/// 预警问题列表
///
/// 项目名称
/// 县
/// 镇
/// 项目编号
/// 项目用途
/// 项目状态
///
///
///
[HttpGet]
public Response>> GetWentiDronssnydList(string xiangmumc, string countyid, string streetid, int? status,
string xiangmuno, string xiangmuyt,
int page, int limit)
{
var response = new Response>>();
try
{
response.Result =
droneSsnyApp.GetWentiDronssnydList(xiangmumc, countyid, streetid, xiangmuno, xiangmuyt, status, page, limit);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
///
/// 预警问题列表导出
///
///
///
[HttpPost]
public IActionResult GetWentiDronssnydExport([FromQuery] DroneSsny import)
{
var data = new Response();
List headers = null;
headers = new List
{
"项目编号", "项目名称", "乡镇", "村庄", "权利人", "联系方式","行政区划", "备案编号","备案日期","项目状态", "项目开始时间", "项目结束时间", "设施农业类型","建筑结构", "设施农业申请用地面积(公顷)", "生产设施用地(公顷)", "辅助设施用地(公顷)"
};
var response = droneSsnyApp.GetWentiDronssnydexport(import.xiangmumc, import.countyid, import.streetid,
import.xiangmuno, import.xiangmuyt, import.status);
if (response.Count > 0)
{
var excelRes = droneSsnyApp.ListWentiToExcel(response, headers);
if (excelRes.Code == 200)
{
return File(excelRes.Result.ToArray(),
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"预警问题列表" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
}
else
{
data.Code = excelRes.Code;
data.Message = "导出失败";
}
}
else
{
data.Code = 300;
data.Message = "暂无数据";
}
return Ok(data);
}
#endregion
#region 项目审核
///
/// 项目审核列表
///
/// 县
/// 镇
/// 项目编号
///
///
///
[HttpGet]
public Response>> GetDronssnydShenheList(string countyid, string streetid,
string xiangmuno,int page, int limit)
{
var response = new Response>>();
try
{
response.Result =
droneSsnyApp.GetDronssnydShenheList(countyid, streetid, xiangmuno, page, limit);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
#endregion
}
}