站点管理
parent
ca4ad048e7
commit
5c3a4d3bc6
|
|
@ -106,7 +106,7 @@ namespace OpenAuth.App.ServiceApp.FireManagement
|
|||
Accumulate = SqlFunc.Subqueryable<FmEnteringInfo>().Where(b => b.SiteId == r.Id).Count(),
|
||||
}).FirstAsync();
|
||||
var userinfo = await db.FmSiteUser.AsQueryable()
|
||||
.LeftJoin<SysUser>((a, b) => a.SiteUserId == b.Id).Select<dynamic>((a, b) => new
|
||||
.LeftJoin<SysUser>((a, b) => a.SiteUserId == b.Id.ToString()).Select<dynamic>((a, b) => new
|
||||
{
|
||||
Id = a.Id,
|
||||
SiteUserId = a.SiteUserId,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,684 @@
|
|||
using DocumentFormat.OpenXml.Office2021.DocumentTasks;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Infrastructure;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using OpenAuth.App.BaseApp.Base;
|
||||
using OpenAuth.App.Common;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.App.ServiceApp.FireManagement.Response;
|
||||
using OpenAuth.App.ServiceApp.FmFireSiteManage.Response;
|
||||
using OpenAuth.Repository;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.Repository.Domain.FireManagement;
|
||||
using Org.BouncyCastle.Ocsp;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.WebSockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp.FmFireSiteManage
|
||||
{
|
||||
public class FmFireSiteApp : SqlSugarBaseApp<FmSiteInfo, SugarDbContext>
|
||||
{
|
||||
private ClientWebSocket _socket;
|
||||
private IConfiguration _configuration;
|
||||
IOptions<KikvisionConfig> _options;
|
||||
IOptions<KikvisionConfig2> _options2;
|
||||
IOptions<JPushClientConfig> _jpoptions;
|
||||
|
||||
public FmFireSiteApp(IConfiguration configuration, IOptions<KikvisionConfig> options, IOptions<KikvisionConfig2> options2,
|
||||
IOptions<JPushClientConfig> jpoptions, ISugarUnitOfWork<SugarDbContext> unitWork,
|
||||
ISimpleClient<FmSiteInfo> repository, IAuth auth) : base(unitWork, repository, auth)
|
||||
{
|
||||
_auth = auth;
|
||||
_options = options;
|
||||
_options2 = options2;
|
||||
_configuration = configuration;
|
||||
_jpoptions = jpoptions;
|
||||
}
|
||||
|
||||
#region 站点管理
|
||||
/// <summary>
|
||||
/// 查询所有站点
|
||||
/// </summary>
|
||||
/// <param name="siteName"></param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Response<PageInfo<List<FmSiteInfo>>>> LoadAllSite(string siteName, int pageIndex, int pageSize, int state)
|
||||
{
|
||||
var currentUser = _auth.GetCurrentUser();
|
||||
using (var db = base.UnitWork.CreateContext())
|
||||
{
|
||||
RefAsync<int> totalNumber = 0;
|
||||
var list = await db.FmSiteInfo.AsQueryable()
|
||||
.WhereIF(state != 3, (a) => a.State == state)
|
||||
.WhereIF(!string.IsNullOrEmpty(siteName), (a) => a.SiteName.Contains(siteName))
|
||||
.Select((a) => new FmSiteInfo
|
||||
{
|
||||
Id = a.Id.SelectAll(),
|
||||
})
|
||||
.OrderByDescending(a => a.CreateTime)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalNumber);
|
||||
return new Response<PageInfo<List<FmSiteInfo>>>
|
||||
{
|
||||
Result = new PageInfo<List<FmSiteInfo>> { Items = list, Total = totalNumber }
|
||||
};
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 导出所有站点
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MemoryStream ExportSite(int state)
|
||||
{
|
||||
var currentUser = _auth.GetCurrentUser();
|
||||
using (var db = base.UnitWork.CreateContext())
|
||||
{
|
||||
List<FmSiteInfo> list = new List<FmSiteInfo>();
|
||||
list = db.FmSiteInfo.AsQueryable()
|
||||
.WhereIF(state != 3, (a) => a.State == state)
|
||||
.Select((a) => new FmSiteInfo
|
||||
{
|
||||
Id = a.Id.SelectAll(),
|
||||
})
|
||||
.OrderByDescending(a => a.CreateTime)
|
||||
.ToList();
|
||||
|
||||
//根目录
|
||||
var root = AppDomain.CurrentDomain.BaseDirectory;
|
||||
//Execl 文件
|
||||
var execlPath = "ExportFiles/ExportInterphoneInfo.xlsx";
|
||||
|
||||
using (FileStream fs = new FileStream($"{root}{execlPath}", FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
var workBook = new XSSFWorkbook(fs);
|
||||
|
||||
#region
|
||||
|
||||
var sheet = workBook.GetSheetAt(0);
|
||||
|
||||
var columnWidth = 20 * 256; // 一个字符等于 256 个单位
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
sheet.SetColumnWidth(i, columnWidth);
|
||||
}
|
||||
var row1 = sheet.CreateRow(0);
|
||||
row1.Height = 30 * 20;
|
||||
row1.CreateCell(0).SetCellValue("站点名称");
|
||||
row1.CreateCell(1).SetCellValue("站点地址");
|
||||
row1.CreateCell(2).SetCellValue("审核状态");
|
||||
row1.CreateCell(3).SetCellValue("负责人");
|
||||
row1.CreateCell(4).SetCellValue("负责人电话");
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
var num = i + 1;
|
||||
var row = sheet.CreateRow(num);
|
||||
row.Height = 30 * 20;
|
||||
row.CreateCell(0).SetCellValue(list[i].SiteName == null ? "" : list[i].SiteName);
|
||||
row.CreateCell(1).SetCellValue(list[i].SiteAddress == null ? "" : list[i].SiteAddress);
|
||||
row.CreateCell(2).SetCellValue(list[i].State == 0 ? "未审核" : (list[i].State == 1 ? "审核通过" : "审核未通过"));
|
||||
row.CreateCell(3).SetCellValue(list[i].Director == null ? "" : list[i].Director);
|
||||
row.CreateCell(4).SetCellValue(list[i].Phone == null ? "" : list[i].Phone);
|
||||
}
|
||||
#endregion
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
workBook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 站点审核
|
||||
/// </summary>
|
||||
/// <param name="siteId">站点id</param>
|
||||
/// <param name="state"></param>
|
||||
/// <param name="content"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Response<bool>> AuditSite(long siteId, int state, string content)
|
||||
{
|
||||
using (var db = base.UnitWork.CreateContext())
|
||||
{
|
||||
var model = db.FmSiteInfo.AsQueryable().First(r => r.Id == siteId);
|
||||
if (model == null)
|
||||
{
|
||||
throw new Exception("未查询到站点");
|
||||
}
|
||||
else
|
||||
{
|
||||
model.AuditTime = DateTime.Now;
|
||||
model.State = state;
|
||||
model.StateContent = content;
|
||||
var flag = await db.FmSiteInfo.UpdateAsync(model);
|
||||
if (db.Commit() && flag)
|
||||
{
|
||||
return new Response<bool> { Result = true, Message = "审核成功" };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Response<bool> { Result = false, Message = "审核失败" };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 站点管理
|
||||
/// <summary>
|
||||
/// 获取站点管理人员及消息接收人员
|
||||
/// </summary>
|
||||
/// <param name="siteId"></param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Response<PageInfo<List<SiteUserRes>>>> LoadSiteUser(long siteId, long roleid, int pageIndex, int pageSize)
|
||||
{
|
||||
using (var db = base.UnitWork.CreateContext())
|
||||
{
|
||||
RefAsync<int> totalNumber = 0;
|
||||
var list = await db.FmSiteUser.AsQueryable()
|
||||
.LeftJoin<SysUser>((a, b) => a.SiteUserId == b.Id.ToString())
|
||||
.LeftJoin<SysUserRole>((a, b, c) => a.SiteUserId == c.UserId.ToString())
|
||||
.Where((a, b, c) => c.RoleId == roleid && a.SiteId == siteId)
|
||||
.Select((a, b) => new SiteUserRes()
|
||||
{
|
||||
Id = a.Id,
|
||||
Name = b.Name,
|
||||
SiteId = a.SiteId,
|
||||
SiteUserId = a.SiteUserId,
|
||||
UserRole = a.UserRole,
|
||||
Account = b.Account
|
||||
}).ToPageListAsync(pageIndex, pageSize, totalNumber);
|
||||
|
||||
return new Response<PageInfo<List<SiteUserRes>>>
|
||||
{
|
||||
Result = new PageInfo<List<SiteUserRes>> { Items = list, Total = totalNumber }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取林场所有管理员
|
||||
/// </summary>
|
||||
/// <param name="roleid">角色id(传林场管理员角色id)</param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <returns></returns>
|
||||
public TableData LoadSiteAllUser(long roleid, int pageIndex, int pageSize)
|
||||
{
|
||||
TableData data = new TableData();
|
||||
using (var db = base.UnitWork.CreateContext())
|
||||
{
|
||||
int totalCount = 0;
|
||||
var list = db.User.AsQueryable()
|
||||
.LeftJoin<SysUserRole>((a, r) => a.Id == r.UserId)
|
||||
.Where((a, r) => r.RoleId == roleid)
|
||||
.Select((a) => (dynamic)new
|
||||
{
|
||||
a.Id,
|
||||
a.Name,
|
||||
a.Account
|
||||
})
|
||||
.ToPageList(pageIndex, pageSize, ref totalCount);
|
||||
data.data = list;
|
||||
data.count = totalCount;
|
||||
data.code = 200;
|
||||
data.msg = "请求成功";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取站点列表
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public TableData LoadSiteByUserId(string userId, int pageIndex, int pageSize)
|
||||
{
|
||||
TableData data = new TableData();
|
||||
using (var db = base.UnitWork.CreateContext())
|
||||
{
|
||||
//查询user的所有场地
|
||||
var siteids = db.FmSiteUser.AsQueryable().Where(a => a.SiteUserId == userId).Select(a => a.SiteId).ToList();
|
||||
var startTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
|
||||
var endTime = DateTime.Now;
|
||||
int totalCount = 0;
|
||||
var list = db.FmSiteInfo.AsQueryable()
|
||||
//.LeftJoin<FmEnteringInfo>((a, b) => a.Id == b.SiteId)
|
||||
.Where((a) => siteids.Contains(a.Id))
|
||||
//.Where((a, b) => b.InTime >= startTime && b.InTime <= endTime)
|
||||
//.GroupBy((a, b) => a.Id)
|
||||
.Select((a) => (dynamic)new
|
||||
{
|
||||
Id = a.Id.SelectAll(),
|
||||
incount = SqlFunc.Subqueryable<FmEnteringInfo>().Where(r => r.SiteId == a.Id && r.InTime >= startTime && r.InTime <= endTime).Count(),
|
||||
}).ToPageList(pageIndex, pageSize, ref totalCount);
|
||||
data.data = list;
|
||||
data.count = totalCount;
|
||||
data.code = 200;
|
||||
data.msg = "请求成功";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 站点注册
|
||||
/// </summary>
|
||||
/// <param name="FmSiteInfo">站点信息</param>
|
||||
/// <returns></returns>
|
||||
public async Task<Response<bool>> AddSite(FmSiteInfo fmSite)
|
||||
{
|
||||
if (fmSite != null)
|
||||
{
|
||||
fmSite.CreateTime = DateTime.Now;
|
||||
fmSite.State = 0;
|
||||
using (var db = base.UnitWork.CreateContext())
|
||||
{
|
||||
if (db.FmSiteInfo.AsQueryable().Any(a => a.SiteName == fmSite.SiteName))
|
||||
{
|
||||
throw new Exception("该站点名称已被注册");
|
||||
}
|
||||
else
|
||||
{
|
||||
fmSite.Id = YitIdHelper.NextId();
|
||||
fmSite.AuditTime = fmSite.CreateTime;
|
||||
if (fmSite.State != 1)
|
||||
{
|
||||
fmSite.State = 0;
|
||||
}
|
||||
|
||||
fmSite.SiteUser.ForEach(a =>
|
||||
{
|
||||
a.Id = YitIdHelper.NextId();
|
||||
a.SiteId = fmSite.Id;
|
||||
});
|
||||
FmSiteUser sugar_SiteUser = new FmSiteUser();
|
||||
sugar_SiteUser.Id = YitIdHelper.NextId();
|
||||
sugar_SiteUser.SiteId = fmSite.Id;
|
||||
sugar_SiteUser.SiteUserId = fmSite.CreateUserId;
|
||||
sugar_SiteUser.UserRole = 1;
|
||||
fmSite.SiteUser.Add(sugar_SiteUser);
|
||||
await db.FmSiteInfo.InsertAsync(fmSite);
|
||||
await db.FmSiteUser.InsertRangeAsync(fmSite.SiteUser);
|
||||
if (db.Commit())
|
||||
{
|
||||
return new Response<bool> { Result = true, Message = "操作成功" };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Response<bool> { Result = false, Message = "操作失败" };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("提交数据为空");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 站点编辑
|
||||
/// </summary>
|
||||
/// <param name="fmSite">站点编辑</param>
|
||||
/// <returns></returns>
|
||||
public async Task<Response<bool>> EditSite(FmSiteInfo fmSite)
|
||||
{
|
||||
if (fmSite != null)
|
||||
{
|
||||
using (var db = base.UnitWork.CreateContext())
|
||||
{
|
||||
if (fmSite.SiteUser != null)
|
||||
{
|
||||
fmSite.SiteUser.ForEach(a =>
|
||||
{
|
||||
a.Id = YitIdHelper.NextId();
|
||||
a.SiteId = fmSite.Id;
|
||||
});
|
||||
await db.FmSiteUser.DeleteAsync(r => r.SiteId == fmSite.Id);
|
||||
await db.FmSiteUser.InsertRangeAsync(fmSite.SiteUser);
|
||||
}
|
||||
// Update the fmSite object
|
||||
await db.FmSiteInfo.UpdateAsync(fmSite);
|
||||
|
||||
if (db.Commit())
|
||||
{
|
||||
return new Response<bool> { Result = true, Message = "操作成功" };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Response<bool> { Result = false, Message = "操作失败" };
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("提交数据为空");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取站点详情
|
||||
/// </summary>
|
||||
/// <param name="siteId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Response<FmSiteRes>> GetSiteInfo(long siteId)
|
||||
{
|
||||
TableData data = new TableData();
|
||||
using (var db = base.UnitWork.CreateContext())
|
||||
{
|
||||
var info = await db.FmSiteInfo.AsQueryable()
|
||||
.Where((a) => a.Id == siteId)
|
||||
.Select((a) => new FmSiteRes
|
||||
{
|
||||
Id = a.Id.SelectAll(),
|
||||
Accumulate = SqlFunc.Subqueryable<FmEnteringInfo>().Where(r => r.SiteId == a.Id).Count(),
|
||||
}).FirstAsync();
|
||||
var inf = await db.FmSiteUser.AsQueryable()
|
||||
.LeftJoin<SysUser>((a, b) => a.SiteUserId == b.Id.ToString())
|
||||
.Where(a => a.SiteId == siteId)
|
||||
.Select((a, b) => new FmSiteUser()
|
||||
{
|
||||
Id = a.Id,
|
||||
SiteUserId = a.SiteUserId,
|
||||
SiteId = a.SiteId,
|
||||
UserRole = a.UserRole,
|
||||
Name = b.Name,
|
||||
Phone = b.Account
|
||||
}).ToListAsync();
|
||||
info.SiteUser = inf;
|
||||
return new Response<FmSiteRes> { Result = info };
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
//#region 进山人员管理
|
||||
///// <summary>
|
||||
///// 进出山类型
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public TableData InTypes()
|
||||
//{
|
||||
// List<EnumItem> list = new List<EnumItem>();
|
||||
|
||||
// foreach (var e in Enum.GetValues(typeof(InType)))
|
||||
// {
|
||||
// list.Add(new EnumItem
|
||||
// {
|
||||
// Value = Convert.ToInt32(e),
|
||||
// Descprtion = ((InType)e).GetDescription()
|
||||
// });
|
||||
// }
|
||||
// return new TableData
|
||||
// {
|
||||
// code = 200,
|
||||
// count = list.Count,
|
||||
// data = list.OrderBy(a => a.Value),
|
||||
// msg = "success"
|
||||
// };
|
||||
//}
|
||||
///// <summary>
|
||||
///// 获取进出山人员信息
|
||||
///// </summary>
|
||||
///// <param name="userName"></param>
|
||||
///// <param name="cardNo"></param>
|
||||
///// <param name="siteId"></param>
|
||||
///// <param name="pageIndex"></param>
|
||||
///// <param name="pageSize"></param>
|
||||
///// <returns></returns>
|
||||
//// This code is a method that loads in user data from a database. It takes in seven parameters: userName, cardNo, siteId, pageIndex, pageSize, startTime, and endTime
|
||||
//// It then creates a TableData object and sets the startTime and endTime to the current date and time if the year is 0001. It then uses the SqlSugarOper class to query
|
||||
//// the FmEnteringInfo, SysUser, and FmSiteInfo tables. It filters the results based on the parameters passed in and selects certain fields from the tables.
|
||||
//// It then orders the results by InTime in descending order and maps the InType field to its description. Finally, it returns the TableData object with the filtered
|
||||
//// results and the total count of the results.
|
||||
//public TableData LoadInUser(string userName, string cardNo, long siteId, int pageIndex, int pageSize, DateTime startTime, DateTime endTime)
|
||||
//{
|
||||
// var currentUser = _auth.GetCurrentUser();
|
||||
// TableData data = new TableData();
|
||||
// if (startTime.Year == 0001)
|
||||
// {
|
||||
// startTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
|
||||
// endTime = DateTime.Now;
|
||||
// }
|
||||
// using (var db = SqlSugarOper.GetInstance(_configuration))
|
||||
// {
|
||||
// int totalCount = 0;
|
||||
// //获取当前用户的乡镇信息
|
||||
// var currentAreaUser = db.Queryable<Sugar_ForestryUser>().Where(r => r.UserId == currentUser.User.Id && r.UserRole == 1).ToList();
|
||||
|
||||
// if (currentAreaUser.Count > 0)
|
||||
// {
|
||||
// var areaid = currentAreaUser.Select(r => r.AreaId);
|
||||
// var areaids = db.Queryable<Sugar_GridInfo>()
|
||||
// .Where(r => areaid.Contains(r.PId) || areaid.Contains(r.Id))
|
||||
// .Select(r => r.Id).ToList();
|
||||
// var fuser = db.Queryable<Sugar_ForestryUser>()
|
||||
// .Where((a) => areaids.Contains(a.AreaId))
|
||||
// .Select(r => r.UserId).ToList();
|
||||
// var site = db.Queryable<FmSiteUser>()
|
||||
// .Where(r => fuser.Contains(r.SiteUserId))
|
||||
// .Select(r => r.SiteId).ToList();
|
||||
// var list = db.Queryable<FmEnteringInfo>()
|
||||
// .LeftJoin<SysUser>((a, b) => a.CreateUserId == b.Id)
|
||||
// .LeftJoin<FmSiteInfo>((a, b, c) => a.SiteId == c.Id)
|
||||
// .WhereIF(siteId != 0, (a, b, c) => a.SiteId == siteId)
|
||||
// .WhereIF(!string.IsNullOrEmpty(userName), (a, b, c) => a.UserName.Contains(userName))
|
||||
// .WhereIF(!string.IsNullOrEmpty(cardNo), (a, b, c) => a.CardNo == cardNo)
|
||||
// .Where((a, b, c) => a.InTime >= startTime && a.InTime <= endTime)
|
||||
// .Where((a, b, c) => site.Contains(a.SiteId))
|
||||
// .Select((a, b, c) => new EnteringInfoResp()
|
||||
// {
|
||||
// Id = a.Id,
|
||||
// UserName = a.UserName,
|
||||
// InType = a.InType,
|
||||
// Phone = a.Phone,
|
||||
// InTime = a.InTime,
|
||||
// SiteName = c.SiteName,
|
||||
// CardNo = a.CardNo,
|
||||
// UserAddress = a.UserAddress,
|
||||
// Name = b.Name,
|
||||
// OutTime = a.OutTime,
|
||||
// Reason = a.Reason,
|
||||
// RegistrationType = a.RegistrationType,
|
||||
// ProjectName = a.ProjectName
|
||||
// })
|
||||
// .OrderBy((a) => a.InTime, OrderByType.Desc)//倒序
|
||||
// .Mapper(it => it.InTypeName = ((InType)it.InType).GetDescription())
|
||||
// .Mapper(it => it.RegistrationTypeName = ((RegistrationType)it.RegistrationType).GetDescription())
|
||||
// .ToPageList(pageIndex, pageSize, ref totalCount);
|
||||
// data.data = list;
|
||||
// data.count = totalCount;
|
||||
// data.code = 200;
|
||||
// data.msg = "请求成功";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var list = db.Queryable<FmEnteringInfo>()
|
||||
// .LeftJoin<SysUser>((a, b) => a.CreateUserId == b.Id)
|
||||
// .LeftJoin<FmSiteInfo>((a, b, c) => a.SiteId == c.Id)
|
||||
// .WhereIF(siteId != 0, (a, b, c) => a.SiteId == siteId)
|
||||
// .WhereIF(!string.IsNullOrEmpty(userName), (a, b, c) => a.UserName.Contains(userName))
|
||||
// .WhereIF(!string.IsNullOrEmpty(cardNo), (a, b, c) => a.CardNo == cardNo)
|
||||
// .Where((a, b, c) => a.InTime >= startTime && a.InTime <= endTime)
|
||||
// .Select((a, b, c) => new EnteringInfoResp()
|
||||
// {
|
||||
// Id = a.Id,
|
||||
// UserName = a.UserName,
|
||||
// InType = a.InType,
|
||||
// Phone = a.Phone,
|
||||
// InTime = a.InTime,
|
||||
// SiteName = c.SiteName,
|
||||
// CardNo = a.CardNo,
|
||||
// UserAddress = a.UserAddress,
|
||||
// Name = b.Name,
|
||||
// OutTime = a.OutTime,
|
||||
// Reason = a.Reason,
|
||||
// RegistrationType = a.RegistrationType,
|
||||
// ProjectName = a.ProjectName
|
||||
// })
|
||||
// .OrderBy((a) => a.InTime, OrderByType.Desc)//倒序
|
||||
// .Mapper(it => it.InTypeName = ((InType)it.InType).GetDescription())
|
||||
// .Mapper(it => it.RegistrationTypeName = ((RegistrationType)it.RegistrationType).GetDescription())
|
||||
// .ToPageList(pageIndex, pageSize, ref totalCount);
|
||||
// data.data = list;
|
||||
// data.count = totalCount;
|
||||
// data.code = 200;
|
||||
// data.msg = "请求成功";
|
||||
// }
|
||||
|
||||
// }
|
||||
// return data;
|
||||
//}
|
||||
///// <summary>
|
||||
///// 导出进出山人员信息
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public MemoryStream ExportInUser(long siteId, DateTime startTime, DateTime endTime)
|
||||
//{
|
||||
// var currentUser = _auth.GetCurrentUser();
|
||||
// if (startTime.Year == 0001)
|
||||
// {
|
||||
// startTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
|
||||
// endTime = DateTime.Now;
|
||||
// }
|
||||
// using (var db = SqlSugarOper.GetInstance(_configuration))
|
||||
// {
|
||||
// List<EnteringInfoResp> list = new List<EnteringInfoResp>();
|
||||
// //获取当前用户的乡镇信息
|
||||
// var currentAreaUser = db.Queryable<Sugar_ForestryUser>().Where(r => r.UserId == currentUser.User.Id).ToList();
|
||||
|
||||
// if (currentAreaUser.Count > 0)
|
||||
// {
|
||||
// var areaid = currentAreaUser.Select(r => r.AreaId);
|
||||
// var areaids = db.Queryable<Sugar_GridInfo>()
|
||||
// .Where(r => areaid.Contains(r.PId) || areaid.Contains(r.Id))
|
||||
// .Select(r => r.Id).ToList();
|
||||
// var fuser = db.Queryable<Sugar_ForestryUser>()
|
||||
// .Where((a) => areaids.Contains(a.AreaId))
|
||||
// .Select(r => r.UserId).ToList();
|
||||
// var site = db.Queryable<FmSiteUser>()
|
||||
// .Where(r => fuser.Contains(r.SiteUserId))
|
||||
// .Select(r => r.SiteId).ToList();
|
||||
// list = db.Queryable<FmEnteringInfo>()
|
||||
// .LeftJoin<SysUser>((a, b) => a.CreateUserId == b.Id)
|
||||
// .LeftJoin<FmSiteInfo>((a, b, c) => a.SiteId == c.Id)
|
||||
// .WhereIF(siteId != 0, (a, b, c) => a.SiteId == siteId)
|
||||
// .Where((a, b, c) => a.InTime >= startTime && a.InTime <= endTime)
|
||||
// .Where((a, b, c) => site.Contains(a.SiteId))
|
||||
// .Select((a, b, c) => new EnteringInfoResp()
|
||||
// {
|
||||
// Id = a.Id,
|
||||
// UserName = a.UserName,
|
||||
// InType = a.InType,
|
||||
// Phone = a.Phone,
|
||||
// InTime = a.InTime,
|
||||
// SiteName = c.SiteName,
|
||||
// CardNo = a.CardNo,
|
||||
// UserAddress = a.UserAddress,
|
||||
// Name = b.Name,
|
||||
// OutTime = a.OutTime,
|
||||
// Reason = a.Reason,
|
||||
// RegistrationType = a.RegistrationType,
|
||||
// ProjectName = a.ProjectName
|
||||
// })
|
||||
// .OrderBy((a) => a.InTime, OrderByType.Desc)//倒序
|
||||
// .Mapper(it => it.InTypeName = ((InType)it.InType).GetDescription())
|
||||
// .Mapper(it => it.RegistrationTypeName = ((RegistrationType)it.RegistrationType).GetDescription())
|
||||
// .ToList();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// list = db.Queryable<FmEnteringInfo>()
|
||||
// .LeftJoin<SysUser>((a, b) => a.CreateUserId == b.Id)
|
||||
// .LeftJoin<FmSiteInfo>((a, b, c) => a.SiteId == c.Id)
|
||||
// .WhereIF(siteId != 0, (a, b, c) => a.SiteId == siteId)
|
||||
// .Where((a, b, c) => a.InTime >= startTime && a.InTime <= endTime)
|
||||
// .Select((a, b, c) => new EnteringInfoResp()
|
||||
// {
|
||||
// Id = a.Id,
|
||||
// UserName = a.UserName,
|
||||
// InType = a.InType,
|
||||
// Phone = a.Phone,
|
||||
// InTime = a.InTime,
|
||||
// SiteName = c.SiteName,
|
||||
// CardNo = a.CardNo,
|
||||
// UserAddress = a.UserAddress,
|
||||
// Name = b.Name,
|
||||
// OutTime = a.OutTime,
|
||||
// Reason = a.Reason,
|
||||
// RegistrationType = a.RegistrationType,
|
||||
// ProjectName = a.ProjectName
|
||||
// })
|
||||
// .OrderBy((a) => a.InTime, OrderByType.Desc)//倒序
|
||||
// .Mapper(it => it.InTypeName = ((InType)it.InType).GetDescription())
|
||||
// .Mapper(it => it.RegistrationTypeName = ((RegistrationType)it.RegistrationType).GetDescription())
|
||||
// .ToList();
|
||||
// }
|
||||
|
||||
|
||||
// //根目录
|
||||
// var root = AppDomain.CurrentDomain.BaseDirectory;
|
||||
// //Execl 文件
|
||||
// var execlPath = "ExportFiles/ExportInterphoneInfo.xlsx";
|
||||
|
||||
// using (FileStream fs = new FileStream($"{root}{execlPath}", FileMode.Open, FileAccess.Read))
|
||||
// {
|
||||
// var workBook = new XSSFWorkbook(fs);
|
||||
|
||||
// #region
|
||||
|
||||
// var sheet = workBook.GetSheetAt(0);
|
||||
|
||||
// var columnWidth = 20 * 256; // 一个字符等于 256 个单位
|
||||
// for (int i = 0; i < list.Count; i++)
|
||||
// {
|
||||
// sheet.SetColumnWidth(i, columnWidth);
|
||||
// }
|
||||
// var row1 = sheet.CreateRow(0);
|
||||
// row1.Height = 30 * 20;
|
||||
// row1.CreateCell(0).SetCellValue("人员姓名");
|
||||
// row1.CreateCell(1).SetCellValue("身份证号");
|
||||
// row1.CreateCell(2).SetCellValue("电话");
|
||||
// row1.CreateCell(3).SetCellValue("登记类型");
|
||||
// row1.CreateCell(4).SetCellValue("进山时间");
|
||||
// row1.CreateCell(5).SetCellValue("出山时间");
|
||||
// row1.CreateCell(6).SetCellValue("防火站点");
|
||||
// row1.CreateCell(7).SetCellValue("登记方式");
|
||||
// row1.CreateCell(8).SetCellValue("进山原因");
|
||||
|
||||
// for (int i = 0; i < list.Count; i++)
|
||||
// {
|
||||
// var num = i + 1;
|
||||
// var row = sheet.CreateRow(num);
|
||||
// row.Height = 30 * 20;
|
||||
// row.CreateCell(0).SetCellValue(list[i].UserName == null ? "" : list[i].UserName);
|
||||
// row.CreateCell(1).SetCellValue(list[i].CardNo == null ? "" : list[i].CardNo);
|
||||
// row.CreateCell(2).SetCellValue(list[i].Phone == null ? "" : list[i].Phone);
|
||||
// row.CreateCell(3).SetCellValue(list[i].RegistrationTypeName == null ? "" : list[i].RegistrationTypeName);
|
||||
// row.CreateCell(4).SetCellValue(list[i].InTime == null ? "" : list[i].InTime.ToString());
|
||||
// row.CreateCell(5).SetCellValue(list[i].OutTime == null ? "" : list[i].OutTime.ToString());
|
||||
// row.CreateCell(6).SetCellValue(list[i].SiteName == null ? "" : list[i].SiteName);
|
||||
// row.CreateCell(7).SetCellValue(list[i].InTypeName == null ? "" : list[i].InTypeName);
|
||||
// row.CreateCell(8).SetCellValue(list[i].Reason == null ? "" : list[i].Reason);
|
||||
// }
|
||||
// #endregion
|
||||
// MemoryStream ms = new MemoryStream();
|
||||
|
||||
// workBook.Write(ms);
|
||||
// return ms;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
//#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using OpenAuth.Repository.Domain.FireManagement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp.FmFireSiteManage.Response
|
||||
{
|
||||
public class FmSiteRes:FmSiteInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 累计进山人次
|
||||
/// </summary>
|
||||
public int Accumulate { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
using OpenAuth.Repository.Domain.FireManagement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp.FmFireSiteManage.Response
|
||||
{
|
||||
public class SiteUserRes:FmSiteUser
|
||||
{
|
||||
/// <summary>
|
||||
/// Desc:用户登录帐号
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string Account { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ namespace OpenAuth.Repository.Domain.FireManagement
|
|||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public long SiteUserId { get; set; }
|
||||
public string SiteUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:人员角色(1-管理员,2-消息接受者)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,205 @@
|
|||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.App.ServiceApp.FireManagement;
|
||||
using OpenAuth.App.ServiceApp.FireManagement.Request;
|
||||
using OpenAuth.App.ServiceApp.FmFireSiteManage;
|
||||
using OpenAuth.App.ServiceApp.FmFireSiteManage.Response;
|
||||
using OpenAuth.Repository.Domain.FireManagement;
|
||||
|
||||
namespace OpenAuth.WebApi.Controllers.ServiceControllers.FireManagement
|
||||
{
|
||||
/// <summary>
|
||||
/// 防火站点管理模块
|
||||
/// </summary>
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class FmFireSiteController : ControllerBase
|
||||
{
|
||||
private readonly FmFireSiteApp _app;
|
||||
|
||||
public FmFireSiteController(FmFireSiteApp app)
|
||||
{
|
||||
_app = app;
|
||||
}
|
||||
|
||||
#region 站点管理
|
||||
/// <summary>
|
||||
/// 查询所有站点
|
||||
/// </summary>
|
||||
/// <param name="siteName">站点名称</param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="state">状态(0-未审核,1-审核通过,2-未通过)</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<PageInfo<List<FmSiteInfo>>>> LoadAllSite(string siteName, int pageIndex, int pageSize, int state)
|
||||
{
|
||||
Response<PageInfo<List<FmSiteInfo>>> response = new Response<PageInfo<List<FmSiteInfo>>>();
|
||||
try
|
||||
{
|
||||
return await _app.LoadAllSite(siteName,pageIndex,pageSize,state);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
/// <summary>
|
||||
/// 导出所有站点
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult ExportSite(int state)
|
||||
{
|
||||
var ms = _app.ExportSite(state);
|
||||
ms.Position = 0;
|
||||
return File(ms, "application/octet-stream",
|
||||
$"站点{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 站点审核
|
||||
/// </summary>
|
||||
/// <param name="siteId">站点id</param>
|
||||
/// <param name="state">要修改的状态</param>
|
||||
/// <param name="content">审核说明</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Response<bool>> AuditSite(long siteId, int state, string content)
|
||||
{
|
||||
Response<bool> response = new();
|
||||
try
|
||||
{
|
||||
return await _app.AuditSite(siteId,state,content);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取站点管理人员及消息接收人员
|
||||
/// </summary>
|
||||
/// <param name="siteId">站点id</param>
|
||||
/// <param name="roleid">角色id(站点管理人员角色的id)</param>
|
||||
/// <param name="pageIndex">页码</param>
|
||||
/// <param name="pageSize">页面大小</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<PageInfo<List<SiteUserRes>>>> LoadSiteUser(long siteId, long roleid, int pageIndex, int pageSize)
|
||||
{
|
||||
Response<PageInfo<List<SiteUserRes>>> response = new Response<PageInfo<List<SiteUserRes>>>();
|
||||
try
|
||||
{
|
||||
return await _app.LoadSiteUser(siteId, roleid,pageIndex, pageSize);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有站点管理人员
|
||||
/// </summary>
|
||||
/// <param name="roleid">角色id(站点管理人员角色id)</param>
|
||||
/// <param name="pageIndex">页码</param>
|
||||
/// <param name="pageSize">页面大小</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public TableData LoadSiteAllUser(long roleid, int pageIndex, int pageSize)
|
||||
{
|
||||
return _app.LoadSiteAllUser(roleid,pageIndex, pageSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据管理员获取站点列表
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public TableData LoadSiteByUserId(string userId, int pageIndex, int pageSize)
|
||||
{
|
||||
return _app.LoadSiteByUserId(userId, pageIndex, pageSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册站点信息
|
||||
/// </summary>
|
||||
/// <param name="fmSite">站点数据</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public async Task<Response<bool>> AddSiteInfo(FmSiteInfo fmSite)
|
||||
{
|
||||
Response<bool> response = new();
|
||||
try
|
||||
{
|
||||
return await _app.AddSite(fmSite);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 站点编辑
|
||||
/// </summary>
|
||||
/// <param name="fmSite">站点编辑</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public async Task<Response<bool>> EditSiteInfo(FmSiteInfo fmSite)
|
||||
{
|
||||
Response<bool> response = new();
|
||||
try
|
||||
{
|
||||
return await _app.EditSite(fmSite);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取站点详情
|
||||
/// </summary>
|
||||
/// <param name="siteId">站点id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Response<FmSiteRes>> GetSiteInfo(long siteId)
|
||||
{
|
||||
Response<FmSiteRes> response = new Response<FmSiteRes>();
|
||||
try
|
||||
{
|
||||
return await _app.GetSiteInfo(siteId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue