Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	OpenAuth.App/ServiceApp/DroneSsnydManage/DroneSsnyApp.cs
#	OpenAuth.WebApi/Controllers/ServiceControllers/DroneSsnyController.cs
dev
陈伟 2025-05-22 14:36:51 +08:00
commit 37bb2f1fd5
5 changed files with 421 additions and 19 deletions

View File

@ -501,5 +501,7 @@ namespace Infrastructure.Helpers.Excel
}
#endregion
}
}

View File

@ -6,6 +6,12 @@ using OpenAuth.App.ServiceApp.DroneSsnydManage.Request;
using OpenAuth.Repository;
using OpenAuth.Repository.Domain;
using SqlSugar;
using Infrastructure;
using DocumentFormat.OpenXml.Spreadsheet;
using NPOI.SS.Formula.Functions;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using Newtonsoft.Json.Linq;
namespace OpenAuth.App.ServiceApp.DroneSsnydManage
{
@ -29,12 +35,12 @@ namespace OpenAuth.App.ServiceApp.DroneSsnydManage
var endTime = DateTime.Now.AddMonths(2);
var list = base.Repository.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(xiangmumc), a => a.xiangmu_name.Contains(xiangmumc))
.WhereIF(!string.IsNullOrEmpty(countyid), a => a.countyid == countyid)
.WhereIF(!string.IsNullOrEmpty(streetid), a => a.streetid == streetid)
.Where(a => a.end_time <= endTime && a.end_time > DateTime.Now)
.OrderBy(a => a.end_time, OrderByType.Desc)
.ToPageList(pageIndex, pageSize, ref totalCount);
.WhereIF(!string.IsNullOrEmpty(xiangmumc), a => a.xiangmu_name.Contains(xiangmumc))
.WhereIF(!string.IsNullOrEmpty(countyid), a => a.countyid == countyid)
.WhereIF(!string.IsNullOrEmpty(streetid), a => a.streetid == streetid)
.Where(a => a.end_time <= endTime && a.end_time > DateTime.Now)
.OrderBy(a => a.end_time, OrderByType.Desc)
.ToPageList(pageIndex, pageSize, ref totalCount);
return new PageInfo<List<DroneSsnyd>>
{
@ -43,6 +49,8 @@ namespace OpenAuth.App.ServiceApp.DroneSsnydManage
};
}
/// <summary>
/// 超期报警
/// </summary>
@ -56,12 +64,12 @@ namespace OpenAuth.App.ServiceApp.DroneSsnydManage
var endTime = DateTime.Now;
var list = base.Repository.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(xiangmumc), a => a.xiangmu_name.Contains(xiangmumc))
.WhereIF(!string.IsNullOrEmpty(countyid), a => a.countyid == countyid)
.WhereIF(!string.IsNullOrEmpty(streetid), a => a.streetid == streetid)
.Where(a => a.end_time < endTime)
.OrderBy(a => a.end_time, OrderByType.Desc)
.ToPageList(pageIndex, pageSize, ref totalCount);
.WhereIF(!string.IsNullOrEmpty(xiangmumc), a => a.xiangmu_name.Contains(xiangmumc))
.WhereIF(!string.IsNullOrEmpty(countyid), a => a.countyid == countyid)
.WhereIF(!string.IsNullOrEmpty(streetid), a => a.streetid == streetid)
.Where(a => a.end_time < endTime)
.OrderBy(a => a.end_time, OrderByType.Desc)
.ToPageList(pageIndex, pageSize, ref totalCount);
return new PageInfo<List<DroneSsnyd>>
{
@ -170,5 +178,223 @@ namespace OpenAuth.App.ServiceApp.DroneSsnydManage
.ToList();
return list;
}
#region 导出
//超期预警
public List<DroneSsnyd> TimeoutWarningExport(string xiangmumc, string countyid, string streetid)
{
var endTime = DateTime.Now.AddMonths(2);
var list = base.Repository.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(xiangmumc), a => a.xiangmu_name.Contains(xiangmumc))
.WhereIF(!string.IsNullOrEmpty(countyid), a => a.countyid == countyid)
.WhereIF(!string.IsNullOrEmpty(streetid), a => a.streetid == streetid)
.Where(a => a.end_time <= endTime && a.end_time > DateTime.Now)
.OrderBy(a => a.end_time, OrderByType.Desc)
.ToList();
return list;
}
/// <summary>
/// 超期报警
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
public List<DroneSsnyd> TimeOutAlarmExport(string xiangmumc, string countyid, string streetid)
{
var endTime = DateTime.Now;
var list = base.Repository.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(xiangmumc), a => a.xiangmu_name.Contains(xiangmumc))
.WhereIF(!string.IsNullOrEmpty(countyid), a => a.countyid == countyid)
.WhereIF(!string.IsNullOrEmpty(streetid), a => a.streetid == streetid)
.Where(a => a.end_time < endTime)
.OrderBy(a => a.end_time, OrderByType.Desc)
.ToList();
return list;
}
/// <summary>
/// 导出
/// </summary>
/// <param name="list"></param>
/// <param name="headers"></param>
/// <returns></returns>
public Response<MemoryStream> ListToExcel(List<DroneSsnyd> list, List<string> headers)
{
Response<MemoryStream> response = new Response<MemoryStream>();
try
{
HSSFWorkbook workbook = new HSSFWorkbook();
ISheet sheet = workbook.CreateSheet();
#region 内容样式
IFont font1 = workbook.CreateFont(); //创建一个字体样式对象
font1.FontName = "Microsoft YaHei"; //和excel里面的字体对应
//font1.Boldweight = short.MaxValue;//字体加粗
font1.FontHeightInPoints = 12; //字体大小
ICellStyle style = workbook.CreateCellStyle(); //创建样式对象
style.BorderBottom = BorderStyle.Thin;
style.BorderLeft = BorderStyle.Thin;
style.BorderRight = BorderStyle.Thin;
style.BorderTop = BorderStyle.Thin;
style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
style.VerticalAlignment = VerticalAlignment.Center;
style.SetFont(font1); //将字体样式赋给样式对象
style.WrapText = true;
#endregion
#region 标题样式
IFont font = workbook.CreateFont(); //创建一个字体样式对象
font.FontName = "Microsoft YaHei"; //和excel里面的字体对应
font.Boldweight = (short)FontBoldWeight.Bold; //字体加粗
font.FontHeightInPoints = 12; //字体大小
ICellStyle style1 = workbook.CreateCellStyle(); //创建样式对象
style1.BorderBottom = BorderStyle.Thin;
style1.BorderLeft = BorderStyle.Thin;
style1.BorderRight = BorderStyle.Thin;
style1.BorderTop = BorderStyle.Thin;
style1.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
style1.VerticalAlignment = VerticalAlignment.Center;
style1.SetFont(font); //将字体样式赋给样式对象
#endregion
#region 创建表头
IRow rowHeader = sheet.CreateRow(0);
rowHeader.Height = 20 * 30;
for (int i = 0; i < headers.Count; i++)
{
var header = headers[i];
rowHeader.CreateCell(i);
rowHeader.Cells[i].CellStyle = style1;
rowHeader.Cells[i].SetCellValue(header);
if (i == 0)
{
sheet.SetColumnWidth(0, 20 * 200);
}
else
{
sheet.SetColumnWidth(i, 20 * 350);
}
}
#endregion
#region 填充数据
for (int i = 0; i < list.Count; i++) //循环数据
{
var item = list[i];
IRow dataRow = sheet.CreateRow(i + 1);
//dataRow.Height = 20 * 20;
var type = item.GetType();
var props = type.GetProperties();
for (int j = 0; j < headers.Count; j++)
{
dataRow.CreateCell(j);
dataRow.Cells[j].CellStyle = style;
}
dataRow.Cells[0].SetCellValue(item.xiangmu_no);
dataRow.Cells[1].SetCellValue(item.xiangmu_name);
dataRow.Cells[2].SetCellValue(item.streetname);
dataRow.Cells[3].SetCellValue(item.communityname);
dataRow.Cells[4].SetCellValue(item.quanliren);
dataRow.Cells[5].SetCellValue(item.xingzhengquhua);
dataRow.Cells[6].SetCellValue(item.beian_no);
dataRow.Cells[7].SetCellValue(item.start_time.ToString());
dataRow.Cells[8].SetCellValue(item.end_time.ToString());
dataRow.Cells[9].SetCellValue(item.xiangmu_yt);
if (item.shenqing_area != null)
{
dataRow.Cells[10].SetCellValue(item.shenqing_area.ToString());
}
else
{
dataRow.Cells[10].SetCellValue("0.00");
}
if (item.shengchan_area != null)
{
dataRow.Cells[11].SetCellValue(item.shenqing_area.ToString());
}
else
{
dataRow.Cells[11].SetCellValue("0.00");
}
if (item.fuzhu_area != null)
{
dataRow.Cells[12].SetCellValue(item.fuzhu_area.ToString());
}
else
{
dataRow.Cells[12].SetCellValue("0.00");
}
dataRow.Cells[13].SetCellValue(item.xiafatime.ToString());
if (item.handle_status_id != null)
{
StatusType status = (StatusType)item.handle_status_id;
dataRow.Cells[14].SetCellValue(status.ToString());
}
else
{
dataRow.Cells[14].SetCellValue("--");
}
}
#endregion
response.Result = new MemoryStream();
workbook.Write(response.Result);
workbook = null;
response.Result.Close();
response.Result.Dispose();
response.Code = 200;
response.Message = "获取成功";
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.Message;
}
return response;
}
#endregion
#region 项目列表
/// <summary>
/// 到期预警
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
public PageInfo<List<DroneSsnyd>> GetDronssnydList(string xiangmumc, string countyid, string streetid, int pageIndex, int pageSize)
{
int totalCount = 0;
var list = base.Repository.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(xiangmumc), a => a.xiangmu_name.Contains(xiangmumc))
.WhereIF(!string.IsNullOrEmpty(countyid), a => a.countyid == countyid)
.WhereIF(!string.IsNullOrEmpty(streetid), a => a.streetid == streetid)
.OrderBy(a => a.end_time, OrderByType.Desc)
.ToPageList(pageIndex, pageSize, ref totalCount);
return new PageInfo<List<DroneSsnyd>>
{
Items = list,
Total = totalCount
};
}
#endregion
}
}

View File

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenAuth.App.ServiceApp.DroneSsnydManage.Request
{
public enum StatusType
{
/// <summary>
/// 待接收
/// </summary>
[Description("待接收")]
= 0,
/// <summary>
/// 待填报
/// </summary>
[Description("待填报")]
= 1,
/// <summary>
/// 填报县级审核
/// </summary>
[Description("填报县级审核")]
= 2,
/// <summary>
/// 填报市级审核
/// </summary>
[Description("填报市级审核")]
= 3,
/// <summary>
/// 待整改
/// </summary>
[Description("待整改")]
= 4,
/// <summary>
/// 整改县级审核
/// </summary>
[Description("整改县级审核")]
= 5,
/// <summary>
/// 整改市级审核
/// </summary>
[Description("整改市级审核")]
= 6,
/// <summary>
/// 已归档
/// </summary>
[Description("已归档")]
= 7,
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenAuth.App.ServiceApp.DroneSsnydManage.Request
{
public class TimeOutReq
{
public string xiangmumc { get; set; }
public string countyid { get; set; }
public string streetid { get; set; }
}
}

View File

@ -1,6 +1,11 @@
using Infrastructure;
using DocumentFormat.OpenXml.Math;
using DocumentFormat.OpenXml.Spreadsheet;
using Infrastructure;
using Infrastructure.Utilities.Excel;
using Infrastructure.Helpers.Excel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula.Functions;
using OpenAuth.App.ServiceApp.DroneSsnydManage;
using OpenAuth.App.ServiceApp.DroneSsnydManage.Request;
using OpenAuth.Repository.Domain;
@ -31,13 +36,12 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
/// <param name="pageSize"></param>
/// <returns></returns>
[HttpGet]
public Response<PageInfo<List<DroneSsnyd>>> TimeoutWarning(string xiangmumc, string countyid, string streetid,
int page, int limit)
public Response<PageInfo<List<DroneSsnyd>>> TimeoutWarning(string xiangmumc, string countyid, string streetid, int page, int limit)
{
var response = new Response<PageInfo<List<DroneSsnyd>>>();
try
{
response.Result = droneSsnyApp.TimeoutWarning(xiangmumc, countyid, streetid, page, limit);
response.Result = droneSsnyApp.TimeoutWarning(xiangmumc, countyid, streetid,page, limit);
}
catch (Exception ex)
{
@ -58,8 +62,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
/// <param name="pageSize"></param>
/// <returns></returns>
[HttpGet]
public Response<PageInfo<List<DroneSsnyd>>> TimeOutAlarmList(string xiangmumc, string countyid, string streetid,
int page, int limit)
public Response<PageInfo<List<DroneSsnyd>>> TimeOutAlarmList(string xiangmumc, string countyid,string streetid,int page, int limit)
{
var response = new Response<PageInfo<List<DroneSsnyd>>>();
try
@ -74,7 +77,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
return response;
}
/// <summary>
/// 历史项目
/// </summary>
@ -148,5 +151,108 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"项目变更导出" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx");
}
#region 预警报警导出
/// <summary>
/// 超期预警数据导出
/// </summary>
/// <param name="import"></param>
/// <returns></returns>
[HttpPost]
public IActionResult TimeoutWarningExport([FromQuery] TimeOutReq import)
{
var data = new Response();
List<string> headers = null;
headers = new List<string> { "项目编号", "项目名称", "乡镇", "村庄", "权利人", "行政区划", "备案编号", "项目开始时间", "项目结束时间", "项目当前用途", "设施农业申请用地面积", "生产设施用地", "辅助设施用地","下发时间","项目状态"};
var response = droneSsnyApp.TimeoutWarningExport(import.xiangmumc, import.countyid, import.streetid);
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);
}
/// <summary>
/// 超期报警数据导出
/// </summary>
/// <param name="import"></param>
/// <returns></returns>
[HttpPost]
public IActionResult TimeoutAlarmExport([FromQuery] TimeOutReq import)
{
var data = new Response();
List<string> headers = null;
headers = new List<string> { "项目编号", "项目名称", "乡镇", "村庄", "权利人", "行政区划", "备案编号", "项目开始时间", "项目结束时间", "项目当前用途", "设施农业申请用地面积", "生产设施用地", "辅助设施用地", "下发时间", "项目状态" };
var response = droneSsnyApp.TimeOutAlarmExport(import.xiangmumc, import.countyid, import.streetid);
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 项目列表
/// <summary>
/// 项目列表
/// </summary>
/// <param name="xiangmumc">项目名称</param>
/// <param name="countyid">县</param>
/// <param name="streetid">镇</param>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public Response<PageInfo<List<DroneSsnyd>>> GetDronssnydList(string xiangmumc, string countyid, string streetid, int page, int limit)
{
var response = new Response<PageInfo<List<DroneSsnyd>>>();
try
{
response.Result = droneSsnyApp.GetDronssnydList(xiangmumc, countyid, streetid, page, limit);
}
catch (Exception ex)
{
response.Code = 500;
response.Message = ex.InnerException?.Message ?? ex.Message;
}
return response;
}
#endregion
}
}