DataMaintenance
commit
5b6e9421bb
|
|
@ -1,40 +1,38 @@
|
|||
using OpenAuth.App.BaseApp.Base;
|
||||
using OpenAuth.Repository.Domain.DataMaintenance;
|
||||
using OpenAuth.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.WebSockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenAuth.App.Interface;
|
||||
using SqlSugar;
|
||||
using OpenAuth.Repository.Domain.FireManagement;
|
||||
using Hopetry.App.SugarModel.CommonModel;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.ServiceApp.FireManagement.Request;
|
||||
using Yitter.IdGenerator;
|
||||
using OpenAuth.App.Const;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.App.ServiceApp.FireManagement.Response;
|
||||
using DocumentFormat.OpenXml.EMMA;
|
||||
using OpenAuth.App.Response;
|
||||
using NPOI.SS.Formula.PTG;
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using StackExchange.Redis;
|
||||
using OpenAuth.App.BaseApp.Base;
|
||||
using OpenAuth.App.Const;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.ServiceApp.FireManagement.Request;
|
||||
using OpenAuth.App.ServiceApp.FireManagement.Response;
|
||||
using OpenAuth.Repository;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.Repository.Domain.FireManagement;
|
||||
using SqlSugar;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp.FireManagement
|
||||
{
|
||||
public class FireManagementApp : SqlSugarBaseApp<FmFireclueTask, SugarDbContext>
|
||||
{
|
||||
public FireManagementApp(ISugarUnitOfWork<SugarDbContext> unitWork,
|
||||
private ClientWebSocket _socket;
|
||||
private IConfiguration _configuration;
|
||||
|
||||
public FireManagementApp( IConfiguration configuration,ISugarUnitOfWork<SugarDbContext> unitWork,
|
||||
ISimpleClient<FmFireclueTask> repository, IAuth auth) : base(unitWork, repository, auth)
|
||||
{
|
||||
_auth = auth;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下发防火线索任务
|
||||
/// </summary>
|
||||
|
|
@ -539,35 +537,99 @@ namespace OpenAuth.App.ServiceApp.FireManagement
|
|||
}
|
||||
}
|
||||
|
||||
//根据类型获取位置信息
|
||||
public async Task<Response<List<UserOnLineTypeResp>>> GetPointByUserType(string unitname, int type)
|
||||
/// <summary>
|
||||
/// 添加实时坐标
|
||||
/// </summary>
|
||||
/// <param name="userPoint"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Response<bool>> AddPointAsync(FmUserPoint userPoint)
|
||||
{
|
||||
using (var db = base.UnitWork.CreateContext())
|
||||
var respose = new Response<bool>();
|
||||
using var db = Repository.AsSugarClient();
|
||||
if (userPoint != null)
|
||||
{
|
||||
var userpoint = await db.FmUserPoint.AsQueryable()
|
||||
.LeftJoin<SysUser>((a, b) => a.CreateId == b.Id)
|
||||
.LeftJoin<SysUserRole>((a, b, c) => b.Id == c.UserId)
|
||||
.LeftJoin<SysRole>((a, b, c, d) => c.RoleId == d.Id)
|
||||
.Where((a, b, c, d) => d.Name == "护林员")
|
||||
.Where((a, b, c, d) => a.CreateTime.AddMinutes(2) > DateTime.Now)
|
||||
.WhereIF(!string.IsNullOrEmpty(unitname), (a, b, c, d) => b.UnitName.Contains(unitname))
|
||||
.Select((a, b, c, d) => new UserOnLineTypeResp
|
||||
{
|
||||
CreateId = a.CreateId.ToString(),
|
||||
Name = b.Name,
|
||||
Lat = a.Lat,
|
||||
Lng = a.Lng,
|
||||
CreateTime = a.CreateTime,
|
||||
Phone = b.Account,
|
||||
Type = d.Name,
|
||||
UnitName = b.UnitName == null ? "" : b.UnitName
|
||||
}).ToListAsync();
|
||||
userPoint.Id = YitIdHelper.NextId();
|
||||
userPoint.CreateTime = DateTime.Now;
|
||||
var userPointHistory = userPoint.MapTo<FmUserPointHistory>();
|
||||
|
||||
return new Response<List<UserOnLineTypeResp>>
|
||||
var oldinfo = await db.Queryable<FmUserPoint>().Where(r => r.CreateId == userPoint.CreateId)
|
||||
.FirstAsync();
|
||||
|
||||
//上线弹窗
|
||||
if (oldinfo == null || (oldinfo != null && oldinfo.CreateTime.AddMinutes(2) < DateTime.Now))
|
||||
{
|
||||
Result = userpoint
|
||||
var user = await db.Queryable<SysUser>().Where(r => r.Id == userPoint.CreateId)
|
||||
.FirstAsync();
|
||||
if (user != null)
|
||||
{
|
||||
await db.Insertable(new FmOnOffLine
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
IdentifyId = user.Id,
|
||||
OnOffTime = DateTime.Now,
|
||||
Name = user.Name,
|
||||
Type = true
|
||||
}).ExecuteCommandAsync();
|
||||
|
||||
WebSocketModel wsModel1 = new WebSocketModel
|
||||
{
|
||||
Module = "上线",
|
||||
Data = user.Name
|
||||
};
|
||||
sendsocket(wsModel1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (oldinfo != null)
|
||||
{
|
||||
oldinfo.Lat = userPoint.Lat;
|
||||
oldinfo.Lng = userPoint.Lng;
|
||||
oldinfo.CreateTime = userPoint.CreateTime;
|
||||
oldinfo.Intype = userPoint.Intype;
|
||||
await db.Updateable(oldinfo).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Insertable(userPoint).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await db.Insertable(userPointHistory).SplitTable().ExecuteCommandAsync();
|
||||
respose.Code = 200;
|
||||
respose.Result = true;
|
||||
respose.Message = "添加成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
respose.Code = 500;
|
||||
respose.Result = false;
|
||||
respose.Message = "添加失败";
|
||||
}
|
||||
|
||||
return respose;
|
||||
}
|
||||
|
||||
public async Task sendsocket(WebSocketModel wsModel1)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_socket == null || _socket.State != WebSocketState.Open)
|
||||
{
|
||||
string ws = _configuration.GetSection("WebSocket").Value;
|
||||
_socket = new ClientWebSocket();
|
||||
await _socket.ConnectAsync(new Uri(ws), CancellationToken.None);
|
||||
}
|
||||
|
||||
byte[] data = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(wsModel1));
|
||||
await _socket.SendAsync(new ArraySegment<byte>(data), WebSocketMessageType.Text,
|
||||
true, CancellationToken.None);
|
||||
await _socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing connection",
|
||||
CancellationToken.None);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
using SqlSugar;
|
||||
|
||||
namespace OpenAuth.Repository.Domain.FireManagement
|
||||
{
|
||||
/// <summary>
|
||||
/// 上下线记录
|
||||
/// </summary>
|
||||
[SugarTable("fm_onoffline")]
|
||||
public class FmOnOffLine
|
||||
{
|
||||
/// <summary>
|
||||
/// id 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人员id或者对讲机account
|
||||
/// </summary>
|
||||
public long IdentifyId { get; set; }
|
||||
/// <summary>
|
||||
/// 上下线时间
|
||||
/// </summary>
|
||||
public DateTime OnOffTime { get; set; }
|
||||
/// <summary>
|
||||
/// 人员姓名或者对讲机account
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// 山下线标识 true上线,false下线
|
||||
/// </summary>
|
||||
public bool Type { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -41,11 +41,11 @@ namespace OpenAuth.Repository.Domain.FireManagement
|
|||
/// <summary>
|
||||
/// 是否置顶
|
||||
/// </summary>
|
||||
public int top { get; set; }
|
||||
public int Top { get; set; }
|
||||
/// <summary>
|
||||
/// 是否是联系人
|
||||
/// </summary>
|
||||
public int iscontacts { get; set; }
|
||||
public int IsContacts { get; set; }
|
||||
/// <summary>
|
||||
/// 是否在巡查范围之内0-不是 1-是
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Hopetry.App.SugarModel.CommonModel
|
||||
{
|
||||
public class WebSocketModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 平台,费县-平邑
|
||||
/// </summary>
|
||||
public string AreaName { get; set; }
|
||||
/// <summary>
|
||||
/// 模块名,无人机飞行数据还是火情数据
|
||||
/// </summary>
|
||||
public string Module { get; set; }
|
||||
/// <summary>
|
||||
/// 数据
|
||||
/// </summary>
|
||||
public dynamic Data { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,10 @@
|
|||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using Infrastructure;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using OpenAuth.App.ServiceApp.FireManagement;
|
||||
using OpenAuth.App.ServiceApp.FireManagement.Request;
|
||||
using OpenAuth.App.ServiceApp.FireManagement.Response;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.Repository.Domain.FireManagement;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
namespace OpenAuth.WebApi.Controllers.ServiceControllers.FireManagement
|
||||
{
|
||||
|
|
@ -355,27 +349,18 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers.FireManagement
|
|||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据类型获取位置信息
|
||||
/// 添加人员坐标点
|
||||
/// </summary>
|
||||
/// <param name="unitname"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="info">坐标点</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public async Task<Response<List<UserOnLineTypeResp>>> GetPointByUserType(string unitname, int type)
|
||||
public async Task<Response<bool>> AddPoint(FmUserPoint info)
|
||||
{
|
||||
Response<List<UserOnLineTypeResp>> response = new Response<List<UserOnLineTypeResp>>();
|
||||
try
|
||||
{
|
||||
return await _app.GetPointByUserType(unitname, type);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
return response;
|
||||
return await _app.AddPointAsync(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue