Compare commits
No commits in common. "master" and "master_sxs_new" have entirely different histories.
master
...
master_sxs
1807
langguanApi.xml
1807
langguanApi.xml
File diff suppressed because it is too large
Load Diff
|
|
@ -1,12 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"isRoot": true,
|
"isRoot": true,
|
||||||
"tools": {
|
"tools": {}
|
||||||
"dotnet-ef": {
|
|
||||||
"version": "8.0.7",
|
|
||||||
"commands": [
|
|
||||||
"dotnet-ef"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -12,10 +12,6 @@ namespace langguanApi.Common
|
||||||
public class CacheManager
|
public class CacheManager
|
||||||
{
|
{
|
||||||
private readonly IDatabase _redisDatabase;
|
private readonly IDatabase _redisDatabase;
|
||||||
/// <summary>
|
|
||||||
/// 构造函数
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="redisHelper"></param>
|
|
||||||
public CacheManager(RedisHelper redisHelper)
|
public CacheManager(RedisHelper redisHelper)
|
||||||
{
|
{
|
||||||
_redisDatabase = redisHelper._database;
|
_redisDatabase = redisHelper._database;
|
||||||
|
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
namespace langguanApi.Common.Gps
|
|
||||||
{
|
|
||||||
public class MessageHeader
|
|
||||||
{
|
|
||||||
public ushort MessageId { get; set; }
|
|
||||||
public ushort MessageBodyProperty { get; set; }
|
|
||||||
public string TerminalId { get; set; }
|
|
||||||
public ushort MessageSerialNumber { get; set; }
|
|
||||||
}
|
|
||||||
public class TerminalRegisterMessage
|
|
||||||
{
|
|
||||||
public ushort ProvinceId { get; set; }
|
|
||||||
public ushort CityId { get; set; }
|
|
||||||
public byte[] ManufacturerId { get; set; }
|
|
||||||
public byte[] TerminalType { get; set; }
|
|
||||||
public byte[] TerminalId { get; set; }
|
|
||||||
public byte LicensePlateColor { get; set; }
|
|
||||||
public string LicensePlate { get; set; }
|
|
||||||
}
|
|
||||||
public class LocationReportMessage
|
|
||||||
{
|
|
||||||
public uint AlarmFlag { get; set; }
|
|
||||||
public uint Status { get; set; }
|
|
||||||
public uint Latitude { get; set; }
|
|
||||||
public uint Longitude { get; set; }
|
|
||||||
public ushort Altitude { get; set; }
|
|
||||||
public ushort Speed { get; set; }
|
|
||||||
public ushort Direction { get; set; }
|
|
||||||
public DateTime Time { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,110 +0,0 @@
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace langguanApi.Common.Gps
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// gps 协议解析器
|
|
||||||
/// </summary>
|
|
||||||
public class ProtocolParser
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 解析消息头
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
/// <param name="offset"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static MessageHeader ParseHeader(byte[] data, ref int offset)
|
|
||||||
{
|
|
||||||
var header = new MessageHeader
|
|
||||||
{
|
|
||||||
MessageId = BitConverter.ToUInt16(data, offset),
|
|
||||||
MessageBodyProperty = BitConverter.ToUInt16(data, offset + 2),
|
|
||||||
TerminalId = Encoding.ASCII.GetString(data, offset + 4, 6),
|
|
||||||
MessageSerialNumber = BitConverter.ToUInt16(data, offset + 10)
|
|
||||||
};
|
|
||||||
|
|
||||||
offset += 12;
|
|
||||||
return header;
|
|
||||||
}
|
|
||||||
public struct Position
|
|
||||||
{
|
|
||||||
public double Latitude;
|
|
||||||
public double Longitude;
|
|
||||||
public double Altitude;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 解析位置信息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static Position ParsePosition(byte[] data)
|
|
||||||
{
|
|
||||||
// 根据协议中的位置信息的偏移量和长度进行解析
|
|
||||||
int positionOffset = 21; // 位置信息在数据中的偏移量
|
|
||||||
int latitudeOffset = positionOffset + 0;
|
|
||||||
int longitudeOffset = positionOffset + 8;
|
|
||||||
int altitudeOffset = positionOffset + 16;
|
|
||||||
|
|
||||||
double latitude = BitConverter.ToDouble(data, latitudeOffset);
|
|
||||||
double longitude = BitConverter.ToDouble(data, longitudeOffset);
|
|
||||||
double altitude = BitConverter.ToDouble(data, altitudeOffset);
|
|
||||||
|
|
||||||
return new Position
|
|
||||||
{
|
|
||||||
Latitude = latitude,
|
|
||||||
Longitude = longitude,
|
|
||||||
Altitude = altitude
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 解析终端注册消息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
/// <param name="offset"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static TerminalRegisterMessage ParseTerminalRegisterMessage(byte[] data, ref int offset)
|
|
||||||
{
|
|
||||||
var message = new TerminalRegisterMessage
|
|
||||||
{
|
|
||||||
ProvinceId = BitConverter.ToUInt16(data, offset),
|
|
||||||
CityId = BitConverter.ToUInt16(data, offset + 2),
|
|
||||||
ManufacturerId = data.Skip(offset + 4).Take(5).ToArray(),
|
|
||||||
TerminalType = data.Skip(offset + 9).Take(8).ToArray(),
|
|
||||||
TerminalId = data.Skip(offset + 17).Take(7).ToArray(),
|
|
||||||
LicensePlateColor = data[offset + 24],
|
|
||||||
LicensePlate = Encoding.ASCII.GetString(data, offset + 25, data.Length - offset - 25)
|
|
||||||
};
|
|
||||||
|
|
||||||
offset += 25 + message.LicensePlate.Length;
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 解析位置上报消息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
/// <param name="offset"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static LocationReportMessage ParseLocationReportMessage(byte[] data, ref int offset)
|
|
||||||
{
|
|
||||||
var message = new LocationReportMessage
|
|
||||||
{
|
|
||||||
AlarmFlag = BitConverter.ToUInt32(data, offset),
|
|
||||||
Status = BitConverter.ToUInt32(data, offset + 4),
|
|
||||||
Latitude = BitConverter.ToUInt32(data, offset + 8),
|
|
||||||
Longitude = BitConverter.ToUInt32(data, offset + 12),
|
|
||||||
Altitude = BitConverter.ToUInt16(data, offset + 16),
|
|
||||||
Speed = BitConverter.ToUInt16(data, offset + 18),
|
|
||||||
Direction = BitConverter.ToUInt16(data, offset + 20),
|
|
||||||
Time = DateTime.ParseExact(
|
|
||||||
Encoding.ASCII.GetString(data, offset + 22, 6),
|
|
||||||
"yyMMddHHmmss",
|
|
||||||
null
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
offset += 28;
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
||||||
using Amazon.Runtime;
|
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
|
|
||||||
namespace langguanApi.Common.Proxy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// http
|
|
||||||
/// </summary>
|
|
||||||
[ServiceInjection(InjectionType.Singleton)]
|
|
||||||
public class HttpProxy
|
|
||||||
{
|
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
|
||||||
/// <summary>
|
|
||||||
/// 构造函数
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="httpClientFactory"></param>
|
|
||||||
public HttpProxy(IHttpClientFactory httpClientFactory)
|
|
||||||
{
|
|
||||||
_httpClientFactory = httpClientFactory;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 获取数据
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="parameters"></param>
|
|
||||||
/// <param name="requestUri"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
/// <exception cref="Exception"></exception>
|
|
||||||
public async Task<T> Get<T>(Dictionary<string, string> parameters, string requestUri)
|
|
||||||
{
|
|
||||||
//从工厂获取请求对象
|
|
||||||
var client = _httpClientFactory.CreateClient("httpreq");
|
|
||||||
if (parameters != null)
|
|
||||||
{
|
|
||||||
var strParam = string.Join("&", parameters.Select(o => o.Key + "=" + o.Value));
|
|
||||||
requestUri = string.Concat(requestUri, '?', strParam);
|
|
||||||
}
|
|
||||||
client.BaseAddress = new Uri(requestUri);
|
|
||||||
var resp = await client.GetAsync(requestUri);
|
|
||||||
if (resp.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
var content = await resp.Content.ReadAsStringAsync();
|
|
||||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(content);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine($"请求失败,状态码:{resp.StatusCode},请求地址 {requestUri}");
|
|
||||||
return default(T);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// post数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="requestUri"></param>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<T> PostData<T>(object data, string requestUri)
|
|
||||||
{
|
|
||||||
StringContent content = null;
|
|
||||||
var client = _httpClientFactory.CreateClient();
|
|
||||||
client.BaseAddress = new Uri(requestUri);
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
string json = Newtonsoft.Json.JsonConvert.SerializeObject(data);
|
|
||||||
content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
|
|
||||||
}
|
|
||||||
var response = await client.PostAsync(requestUri, content);
|
|
||||||
if (response.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
var result = await response.Content.ReadAsStringAsync();
|
|
||||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine($"请求失败,状态码:{response.StatusCode},请求地址 {requestUri}");
|
|
||||||
return default(T);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -9,9 +9,6 @@ namespace langguanApi.Common.Redis
|
||||||
/// sub
|
/// sub
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ISubscriber _subscriber;
|
public ISubscriber _subscriber;
|
||||||
/// <summary>
|
|
||||||
/// 构造函数
|
|
||||||
/// </summary>
|
|
||||||
public RedisHelper()
|
public RedisHelper()
|
||||||
{
|
{
|
||||||
// var con = RedisOptions.Default.GetConnect();
|
// var con = RedisOptions.Default.GetConnect();
|
||||||
|
|
|
||||||
|
|
@ -8,29 +8,8 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string Weather = "weather";
|
public static string Weather = "weather";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缓存ARI数据
|
|
||||||
/// </summary>
|
|
||||||
public static string AriQuality = "arqulaty";
|
|
||||||
/// <summary>
|
|
||||||
/// 首页趋势数据
|
|
||||||
/// </summary>
|
|
||||||
public static string Trend = "tred";
|
|
||||||
/// <summary>
|
|
||||||
/// 缓存今日数据
|
|
||||||
/// </summary>
|
|
||||||
public static string Today = "today";
|
|
||||||
/// <summary>
|
|
||||||
/// 缓存清洁数据
|
/// 缓存清洁数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string CleanData = "cleandata";
|
public static string CleanData = "cleandata";
|
||||||
/// <summary>
|
|
||||||
/// redis缓存key
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static string GetBatchid(string key)
|
|
||||||
{
|
|
||||||
return $"batchtid_{key}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
using Microsoft.AspNetCore.SignalR;
|
|
||||||
using Newtonsoft.Json.Serialization;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace langguanApi.Common.WebSocket
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 客户端push消息
|
|
||||||
/// </summary>
|
|
||||||
[ServiceInjection(InjectionType.Singleton)]
|
|
||||||
public class PushService
|
|
||||||
{
|
|
||||||
private readonly IHubContext<SocketHub> _hubContext;
|
|
||||||
/// <summary>
|
|
||||||
/// 构造函数
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hubContext"></param>
|
|
||||||
public PushService(IHubContext<SocketHub> hubContext)
|
|
||||||
{
|
|
||||||
_hubContext = hubContext;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 全部消息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task SendMessageToAll(object message)
|
|
||||||
{
|
|
||||||
var settings = new JsonSerializerSettings
|
|
||||||
{
|
|
||||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
|
||||||
};
|
|
||||||
Console.WriteLine($"gps 推送数据:{JsonConvert.SerializeObject(message, settings)}");
|
|
||||||
var data = JsonConvert.SerializeObject(message, settings);
|
|
||||||
await _hubContext.Clients.All.SendAsync("ReceiveMessage", data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
using Microsoft.AspNetCore.SignalR;
|
|
||||||
using Newtonsoft.Json.Serialization;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
|
|
||||||
namespace langguanApi.Common.WebSocket
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// socket
|
|
||||||
/// </summary>
|
|
||||||
[ServiceInjection(InjectionType.Singleton)]
|
|
||||||
public class SocketHub : Hub
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// // 客户端连接事件
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override async Task OnConnectedAsync()
|
|
||||||
{
|
|
||||||
var msg = JsonConvert.SerializeObject(new { msgType = "info", data = "hello" });
|
|
||||||
// 发送消息给连接的客户端
|
|
||||||
await Clients.Caller.SendAsync("ReceiveMessage", msg);
|
|
||||||
await base.OnConnectedAsync();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// // 自定义方法,用于向客户端推送消息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task SendMessageToClient(object message)
|
|
||||||
{
|
|
||||||
// 发送消息给所有客户端
|
|
||||||
var connId = this.Context.ConnectionId;
|
|
||||||
var msg = JsonConvert.SerializeObject(message);
|
|
||||||
await this.Clients.All.SendAsync("ReceiveMessage", msg);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 向指定用户发送
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user"></param>
|
|
||||||
/// <param name="message"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task SendMessageToUser(string user, object message)
|
|
||||||
{
|
|
||||||
var settings = new JsonSerializerSettings
|
|
||||||
{
|
|
||||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
|
||||||
};
|
|
||||||
var msg = JsonConvert.SerializeObject(message, settings);
|
|
||||||
await Clients.All.SendAsync("ReceiveMessage", user, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
using langguanApi.Common.Proxy;
|
|
||||||
using langguanApi.Model;
|
|
||||||
using langguanApi.Model.Dto;
|
|
||||||
using langguanApi.Service;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace langguanApi.Controllers
|
|
||||||
{
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class AlertController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly AlertService _alertService;
|
|
||||||
|
|
||||||
public AlertController(AlertService alertService, HttpProxy httpProxy, IConfiguration configuration)
|
|
||||||
{
|
|
||||||
_alertService = alertService;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// export data 默认最近7天数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="start"></param>
|
|
||||||
/// <param name="end"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("export")]
|
|
||||||
public async Task<IActionResult> export(DateTime? start, DateTime? end)
|
|
||||||
{
|
|
||||||
start = start.HasValue ? start.Value.Date : DateTime.Now.AddDays(-7);
|
|
||||||
end = end.HasValue ? end.Value.Date.AddDays(1) : DateTime.Now.Date.AddDays(1);
|
|
||||||
|
|
||||||
var alerts = await _alertService.ExportData(start, end);
|
|
||||||
return File(alerts, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
||||||
$"{start.Value.ToString("yyyy-MM-dd")}-{end.Value.ToString("yyyy-MM-dd")}_设备报警.xlsx");
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// add alert
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("TestAdd")]
|
|
||||||
public async Task<IActionResult> TestAdd(AddAlertDto input)
|
|
||||||
{
|
|
||||||
var result = await _alertService.Add(input);
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -75,17 +75,6 @@ namespace langguanApi.Controllers
|
||||||
return Ok(new ApiResult() { code = 0, data = result });
|
return Ok(new ApiResult() { code = 0, data = result });
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 取设备及数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet]
|
|
||||||
public async Task<IActionResult> GetDeviceAndData(string Id)
|
|
||||||
{
|
|
||||||
var result = await _deviceService.GetDeviceAndData(Id);
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 取设备类型集合
|
/// 取设备类型集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|
@ -104,7 +93,7 @@ namespace langguanApi.Controllers
|
||||||
/// <param name="deviceType"></param>
|
/// <param name="deviceType"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> GetListByDeviceType(string key = "", int pageSize = 10, int current = 1, int deviceType = 1)
|
public async Task<IActionResult> GetListByDeviceType(string key="", int pageSize = 10, int current = 1, int deviceType = 1)
|
||||||
{
|
{
|
||||||
var result = await _deviceService.GetDeviceListByTypes(key, pageSize, current, deviceType);
|
var result = await _deviceService.GetDeviceListByTypes(key, pageSize, current, deviceType);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
using langguanApi.Service;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace langguanApi.Controllers
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 环境治理页面接口
|
|
||||||
/// </summary>
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class EnvGovController : ControllerBase
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 环境治理服务
|
|
||||||
/// </summary>
|
|
||||||
private readonly EnvGovService _envGovService;
|
|
||||||
/// <summary>
|
|
||||||
/// 构造函数
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="envGovService"></param>
|
|
||||||
public EnvGovController(EnvGovService envGovService)
|
|
||||||
{
|
|
||||||
_envGovService = envGovService;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 获取设备状态数据
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("DeviceStatu")]
|
|
||||||
public async Task<IActionResult> GetEnvGovData(string deviceId)
|
|
||||||
{
|
|
||||||
var data = await _envGovService.DeviceStatu(deviceId);
|
|
||||||
return Ok(data);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 环境治理首页
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("Index")]
|
|
||||||
public async Task<IActionResult> IndexView()
|
|
||||||
{
|
|
||||||
var result = await _envGovService.IndexView();
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -9,10 +9,7 @@ namespace langguanApi.Controllers
|
||||||
public class HJ212Controller : ControllerBase
|
public class HJ212Controller : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly Hj212Service _hj212Service;
|
private readonly Hj212Service _hj212Service;
|
||||||
/// <summary>
|
|
||||||
/// 构造函数
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hj212Service"></param>
|
|
||||||
public HJ212Controller(Hj212Service hj212Service)
|
public HJ212Controller(Hj212Service hj212Service)
|
||||||
{
|
{
|
||||||
_hj212Service = hj212Service;
|
_hj212Service = hj212Service;
|
||||||
|
|
@ -23,22 +20,11 @@ namespace langguanApi.Controllers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mn"></param>
|
/// <param name="mn"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("get")]
|
[HttpGet]
|
||||||
public async Task<IActionResult> Get(string mn)
|
public async Task<IActionResult> Get(string mn)
|
||||||
{
|
{
|
||||||
var resul = await _hj212Service.GetViewByDeviceMn(mn);
|
var resul = await _hj212Service.GetViewByDeviceMn(mn);
|
||||||
return Ok(resul);
|
return Ok(resul);
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 新加tsp
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hJ212"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("addtsp")]
|
|
||||||
public async Task<IActionResult> Addtsp(Model.HJ212 hJ212)
|
|
||||||
{
|
|
||||||
await _hj212Service.Add(hJ212, null);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,9 @@
|
||||||
using JT808.Protocol.MessageBody;
|
using langguanApi.Model;
|
||||||
using JT808.Protocol;
|
|
||||||
using langguanApi.Model;
|
|
||||||
using langguanApi.Service;
|
using langguanApi.Service;
|
||||||
using langguanApi.Service.HJ212;
|
using langguanApi.Service.HJ212;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Org.BouncyCastle.Utilities;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JT808.Protocol.Extensions;
|
|
||||||
using static langguanApi.Service.WeatherService;
|
|
||||||
using langguanApi.Common.Gps;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using static langguanApi.Common.Gps.ProtocolParser;
|
|
||||||
|
|
||||||
namespace langguanApi.Controllers
|
namespace langguanApi.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -31,7 +23,7 @@ namespace langguanApi.Controllers
|
||||||
[HttpGet("view")]
|
[HttpGet("view")]
|
||||||
public async Task<IActionResult> View()
|
public async Task<IActionResult> View()
|
||||||
{
|
{
|
||||||
return Ok(await _homeService.View());
|
return Ok( await _homeService.View() );
|
||||||
|
|
||||||
}
|
}
|
||||||
[HttpGet("test")]
|
[HttpGet("test")]
|
||||||
|
|
@ -43,160 +35,11 @@ namespace langguanApi.Controllers
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<IActionResult> test(int num = 1, string key = "")
|
public async Task<IActionResult> test(int num = 1, string key = "")
|
||||||
{
|
{
|
||||||
// 示例数据(需替换为实际接收到的协议数据)
|
|
||||||
string hexData = "787811010868120321167279808D3202001AB12F0D0A";
|
|
||||||
byte[] loginPacket = BuildLoginPacket("123456789012345"); // 替换为实际的IMEI
|
|
||||||
|
|
||||||
// Console.WriteLine("经度:" + lon + " 纬度:" + lat);
|
|
||||||
|
|
||||||
// string rawText = "数据报:##0250QN=20240424224800000;ST=22;CN=2011;PW=123456;MN=LGYC022024690001;Flag=5;CP=&&DataTime=20240424224800;a34001-Rtd=356.2";
|
// string rawText = "数据报:##0250QN=20240424224800000;ST=22;CN=2011;PW=123456;MN=LGYC022024690001;Flag=5;CP=&&DataTime=20240424224800;a34001-Rtd=356.2";
|
||||||
//NetPackage netPackage = NetPackage.Parse(rawText, null);
|
//NetPackage netPackage = NetPackage.Parse(rawText, null);
|
||||||
//((NetServer)Server).RaiseReceivedData(this, netPackage, rawText);
|
//((NetServer)Server).RaiseReceivedData(this, netPackage, rawText);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
public static Position? ParsePosition(byte[] data)
|
|
||||||
{
|
|
||||||
// 根据协议中的位置信息的偏移量和长度进行解析
|
|
||||||
int positionOffset = 21; // 位置信息在数据中的偏移量
|
|
||||||
int latitudeOffset = positionOffset + 0;
|
|
||||||
int longitudeOffset = positionOffset + 4;
|
|
||||||
int altitudeOffset = positionOffset + 8;
|
|
||||||
|
|
||||||
// 检查数组长度是否足够长
|
|
||||||
if (data.Length < altitudeOffset + 2)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Data array is not long enough to contain position information.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析纬度(单位:百万分之一度)
|
|
||||||
int rawLatitude = BitConverter.ToInt32(data, latitudeOffset);
|
|
||||||
double latitude = rawLatitude / 1000000.0;
|
|
||||||
|
|
||||||
// 解析经度(单位:百万分之一度)
|
|
||||||
int rawLongitude = BitConverter.ToInt32(data, longitudeOffset);
|
|
||||||
double longitude = rawLongitude / 1000000.0;
|
|
||||||
|
|
||||||
// 解析高度(单位:米)
|
|
||||||
int rawAltitude = BitConverter.ToInt16(data, altitudeOffset);
|
|
||||||
double altitude = rawAltitude;
|
|
||||||
|
|
||||||
return new Position
|
|
||||||
{
|
|
||||||
Latitude = latitude,
|
|
||||||
Longitude = longitude,
|
|
||||||
Altitude = altitude
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static byte[] BuildLoginPacket(string imei)
|
|
||||||
{
|
|
||||||
using (MemoryStream ms = new MemoryStream())
|
|
||||||
{
|
|
||||||
BinaryWriter writer = new BinaryWriter(ms);
|
|
||||||
|
|
||||||
writer.Write(new byte[] { 0x78, 0x78 }); // 起始位
|
|
||||||
writer.Write((byte)0x0D); // 包长度
|
|
||||||
writer.Write((byte)0x01); // 协议号
|
|
||||||
|
|
||||||
byte[] imeiBytes = Encoding.ASCII.GetBytes(imei);
|
|
||||||
writer.Write(imeiBytes);
|
|
||||||
|
|
||||||
writer.Write((short)0x0001); // 信息序列号
|
|
||||||
|
|
||||||
byte[] content = ms.ToArray();
|
|
||||||
short crc = CalculateCRC(content, 2, content.Length - 2);
|
|
||||||
writer.Write(crc); // 错误校验
|
|
||||||
|
|
||||||
writer.Write(new byte[] { 0x0D, 0x0A }); // 停止位
|
|
||||||
|
|
||||||
return ms.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static short CalculateCRC(byte[] data, int start, int length)
|
|
||||||
{
|
|
||||||
// CRC计算方法(参考协议中的CRC-ITU算法)
|
|
||||||
ushort crc = 0xFFFF;
|
|
||||||
|
|
||||||
for (int i = start; i < start + length; i++)
|
|
||||||
{
|
|
||||||
crc = (ushort)(crc ^ (data[i] << 8));
|
|
||||||
|
|
||||||
for (int j = 0; j < 8; j++)
|
|
||||||
{
|
|
||||||
if ((crc & 0x8000) != 0)
|
|
||||||
{
|
|
||||||
crc = (ushort)((crc << 1) ^ 0x1021);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
crc <<= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (short)crc;
|
|
||||||
}
|
|
||||||
static void ParseServerResponse(byte[] data, int length)
|
|
||||||
{
|
|
||||||
if (length < 10) // 根据协议响应包最小长度
|
|
||||||
{
|
|
||||||
Console.WriteLine("响应包长度错误");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data[0] == 0x78 && data[1] == 0x78)
|
|
||||||
{
|
|
||||||
Console.WriteLine("起始位正确");
|
|
||||||
|
|
||||||
byte protocolNumber = data[3];
|
|
||||||
if (protocolNumber == 0x01)
|
|
||||||
{
|
|
||||||
Console.WriteLine("协议号正确: 登录信息包响应");
|
|
||||||
|
|
||||||
byte[] sequenceNumber = new byte[2];
|
|
||||||
Array.Copy(data, 4, sequenceNumber, 0, 2);
|
|
||||||
Console.WriteLine($"信息序列号: {BitConverter.ToString(sequenceNumber)}");
|
|
||||||
|
|
||||||
byte[] crc = new byte[2];
|
|
||||||
Array.Copy(data, length - 4, crc, 0, 2);
|
|
||||||
Console.WriteLine($"CRC: {BitConverter.ToString(crc)}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void ParseLocationPacket(byte[] data, int length)
|
|
||||||
{
|
|
||||||
if (length < 16) // 根据协议位置数据包最小长度
|
|
||||||
{
|
|
||||||
Console.WriteLine("位置数据包长度错误");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data[0] == 0x78 && data[1] == 0x78)
|
|
||||||
{
|
|
||||||
Console.WriteLine("起始位正确");
|
|
||||||
|
|
||||||
byte protocolNumber = data[3];
|
|
||||||
if (protocolNumber == 0x12) // 位置数据包协议号
|
|
||||||
{
|
|
||||||
Console.WriteLine("协议号正确: 位置数据包");
|
|
||||||
|
|
||||||
int latitude = (data[5] & 0xFF) << 24 | (data[6] & 0xFF) << 16 | (data[7] & 0xFF) << 8 | (data[8] & 0xFF);
|
|
||||||
int longitude = (data[9] & 0xFF) << 24 | (data[10] & 0xFF) << 16 | (data[11] & 0xFF) << 8 | (data[12] & 0xFF);
|
|
||||||
|
|
||||||
double lat = latitude / 1800000.0;
|
|
||||||
double lon = longitude / 1800000.0;
|
|
||||||
|
|
||||||
Console.WriteLine($"纬度: {lat}, 经度: {lon}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct Position
|
|
||||||
{
|
|
||||||
public double Latitude;
|
|
||||||
public double Longitude;
|
|
||||||
public double Altitude;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using langguanApi.Model;
|
using langguanApi.Model;
|
||||||
using langguanApi.Model.Entity;
|
|
||||||
using langguanApi.Service;
|
using langguanApi.Service;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -24,40 +23,19 @@ namespace langguanApi.Controllers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("list")]
|
[HttpGet("list")]
|
||||||
public async Task<IActionResult> list([FromQuery] reqpage input)
|
public async Task<IActionResult> list([FromQuery]reqpage input)
|
||||||
{
|
{
|
||||||
var result = await _ledgerService.GetPage(input);
|
var result = await _ledgerService.GetPage(input);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a new ledger
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("add")]
|
|
||||||
public async Task<IActionResult> add(AddLedgerDto input)
|
|
||||||
{
|
|
||||||
await _ledgerService.AddLedger(input);
|
|
||||||
return Ok(new ApiResult { code = 0 });
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 头部统计
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("HeaderCount")]
|
|
||||||
public async Task<IActionResult> HeaderCount()
|
|
||||||
{
|
|
||||||
var result = await _ledgerService.HeaderCount();
|
|
||||||
return Ok(new ApiResult { code = 0, data = result });
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Export all ledgers
|
/// Export all ledgers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="start"></param>
|
/// <param name="start"></param>
|
||||||
/// <param name="end"></param>
|
/// <param name="end"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("export")]
|
[HttpGet("export")]
|
||||||
public async Task<IActionResult> Export(DateTime? start, DateTime? end)
|
public async Task<IActionResult> Export(DateTime start, DateTime end)
|
||||||
{
|
{
|
||||||
var result = await _ledgerService.Export(start, end);
|
var result = await _ledgerService.Export(start, end);
|
||||||
return File(result, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "台账.xlsx");
|
return File(result, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "台账.xlsx");
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,12 @@ namespace langguanApi.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取菜单列表
|
/// 获取菜单列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("list")]
|
[HttpGet("list")]
|
||||||
public async Task<IActionResult> List()
|
public async Task<IActionResult> List([FromQuery] reqpage input)
|
||||||
{
|
{
|
||||||
var result = await _menuService.GetMenuTree();
|
var result = await _menuService.Pager(input);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -56,13 +57,13 @@ namespace langguanApi.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除菜单
|
/// 删除菜单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ids"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete("remove")]
|
[HttpDelete("DeleteMenu")]
|
||||||
public async Task<IActionResult> DeleteMenu(IEnumerable<string> ids)
|
public async Task<IActionResult> DeleteMenu(string id)
|
||||||
{
|
{
|
||||||
await _menuService.BatchRemoveAsync(ids);
|
var result = await _menuService.DeleteMenu(id);
|
||||||
return Ok(new ApiResult());
|
return Ok(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,14 +54,11 @@ namespace langguanApi.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取组织工序和设备信息
|
/// 获取组织工序和设备信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="OrganizedType">1 有组织 2 无组织</param>
|
|
||||||
/// <param name="DeviceType">0=全部,1=voc,2=cems</param>
|
|
||||||
/// <param name="OrgId"> 组织id</param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("listanddevice")]
|
[HttpGet("listanddevice")]
|
||||||
public async Task<IActionResult> ListAndDevice(int OrganizedType = 1, int DeviceType = 0, string OrgId = "")
|
public async Task<IActionResult> ListAndDevice(int OrganizedType = 1)
|
||||||
{
|
{
|
||||||
var result = await _organizedService.ListAndDevice(OrganizedType, DeviceType, OrgId);
|
var result = await _organizedService.ListAndDevice(OrganizedType);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
using langguanApi.Model.Dto;
|
|
||||||
using langguanApi.Service;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace langguanApi.Controllers
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 接收数据
|
|
||||||
/// </summary>
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class ReceiveController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly ReceiveDataService _receiveService;
|
|
||||||
/// <summary>
|
|
||||||
/// 接收数据
|
|
||||||
public ReceiveController(ReceiveDataService receiveService)
|
|
||||||
{
|
|
||||||
_receiveService = receiveService;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 接收数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("receive")]
|
|
||||||
public async Task<IActionResult> Post([FromBody] ReceiveDto input)
|
|
||||||
{
|
|
||||||
var result = await _receiveService.ReceiveData(input);
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -72,7 +72,7 @@ namespace langguanApi.Controllers
|
||||||
[HttpGet("list")]
|
[HttpGet("list")]
|
||||||
public async Task<IActionResult> List([FromQuery] reqpage input)
|
public async Task<IActionResult> List([FromQuery] reqpage input)
|
||||||
{
|
{
|
||||||
var roles = await _roleService.GetPage(input);
|
var roles = await _roleService.GetPager(input);
|
||||||
return Ok(roles);
|
return Ok(roles);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
using langguanApi.Service;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace langguanApi.Controllers
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 统计数据控制器
|
|
||||||
/// </summary>
|
|
||||||
[Route("api/[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class StatisticsController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly StatisticsService _statisticsService;
|
|
||||||
/// <summary>
|
|
||||||
/// 构造函数
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="statisticsService"></param>
|
|
||||||
public StatisticsController(StatisticsService statisticsService)
|
|
||||||
{
|
|
||||||
_statisticsService = statisticsService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取统计数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="type">1,VOC,2CEM</param>
|
|
||||||
/// <param name="Organized">工序列表</param>
|
|
||||||
/// <param name="deviceId">deviceId</param>
|
|
||||||
/// <param name="startTime">startTime</param>
|
|
||||||
/// <param name="endTime">endTime</param>
|
|
||||||
/// <param name=""></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("huanbao")]
|
|
||||||
public async Task<IActionResult> huanbao(int type, int Organized, string deviceId, DateTime startTime, DateTime endTime, int pageIndex = 1, int pageSize = 10)
|
|
||||||
{
|
|
||||||
var result = await _statisticsService.GetStatistics(type, Organized, deviceId, startTime, endTime, pageIndex, pageSize);
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 导出统计数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="type"></param>
|
|
||||||
/// <param name="Organized"></param>
|
|
||||||
/// <param name="deviceId"></param>
|
|
||||||
/// <param name="startTime"></param>
|
|
||||||
/// <param name="endTime"></param>
|
|
||||||
/// <param name="pageIndex"></param>
|
|
||||||
/// <param name="pageSize"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("exporthuanbao")]
|
|
||||||
public async Task<IActionResult> export(int type, int Organized, string deviceId, DateTime startTime, DateTime endTime, int pageIndex = 1, int pageSize = 10)
|
|
||||||
{
|
|
||||||
var result = await _statisticsService.GetStatistics(type, Organized, deviceId, startTime, endTime, pageIndex, pageSize);
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -13,16 +13,12 @@ namespace langguanApi.Controllers
|
||||||
public class TransportController : ControllerBase
|
public class TransportController : ControllerBase
|
||||||
{
|
{
|
||||||
private TransportService _transportService;
|
private TransportService _transportService;
|
||||||
private WasherService _washerService;
|
public TransportController(TransportService transportService)
|
||||||
private TruckScalesService _truckScalesService;
|
|
||||||
public TransportController(TransportService transportService, WasherService washerService, TruckScalesService truckScalesService)
|
|
||||||
{
|
{
|
||||||
_transportService = transportService;
|
_transportService = transportService;
|
||||||
_washerService = washerService;
|
|
||||||
_truckScalesService = truckScalesService;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清洁运输:获取门禁数据和详情
|
/// 获取清洁运输列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|
@ -42,81 +38,5 @@ namespace langguanApi.Controllers
|
||||||
var result = await _transportService.GetCount();
|
var result = await _transportService.GetCount();
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 新增门禁
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("add")]
|
|
||||||
public async Task<IActionResult> Add(AddTransport input)
|
|
||||||
{
|
|
||||||
await _transportService.addTransport(input);
|
|
||||||
return Ok(new ApiResult() { code = 0 });
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 洗车机
|
|
||||||
/// <summary>
|
|
||||||
/// 推送洗车机列表(洗车机列表和洗车机记录组合在一起)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("addwasherlist")]
|
|
||||||
public async Task<IActionResult> AddWasherList([FromBody] List<AddWasher> input)
|
|
||||||
{
|
|
||||||
await _washerService.addWasher(input);
|
|
||||||
return Ok(new ApiResult() { code = 0 });
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 洗车机:获取洗车机列表和右侧洗车状态等数据,默认右侧显示第一条的记录
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("washerList")]
|
|
||||||
public async Task<IActionResult> WasherList()
|
|
||||||
{
|
|
||||||
var result = await _washerService.getWasherList();
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 洗车机:获取历史记录 和导出历史记录
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("washerhistorylist")]
|
|
||||||
public async Task<IActionResult> WasherHistoryList([FromQuery] transportReqPage input)
|
|
||||||
{
|
|
||||||
var result = await _washerService.WasherHistoryList(input);
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 地磅
|
|
||||||
/// <summary>
|
|
||||||
/// 推送地磅列表
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("addruckscaleslist")]
|
|
||||||
public async Task<IActionResult> AddRuckScalesList([FromBody] List<AddTruckScalesDto> input)
|
|
||||||
{
|
|
||||||
await _truckScalesService.AddTruckScalesList(input);
|
|
||||||
return Ok(new ApiResult() { code = 0 });
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 清洁运输
|
|
||||||
/// <summary>
|
|
||||||
/// 清洁运输:获取清洁运输列表和饼图比例数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="reqPage"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("gettransport")]
|
|
||||||
public async Task<IActionResult> GetTransport([FromQuery] transportReqPage reqPage)
|
|
||||||
{
|
|
||||||
var result = await _transportService.GetTransport(reqPage);
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,14 @@ namespace langguanApi.Controllers
|
||||||
[HttpPost("login")]
|
[HttpPost("login")]
|
||||||
public async Task<IActionResult> Login([FromBody] UserLogin user)
|
public async Task<IActionResult> Login([FromBody] UserLogin user)
|
||||||
{
|
{
|
||||||
var result = await _userService.login(user.Username, user.Password);
|
var result = _userService.login(user.Username, user.Password);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
return Ok(new ApiResult() { data = result });
|
return Ok(result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Ok(new ApiResult() { code = -1, msg = "用户名或密码错误" });
|
return BadRequest(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -58,17 +58,29 @@ namespace langguanApi.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 用户管理相关接口
|
#region 用户管理相关接口
|
||||||
///// <summary>
|
/// <summary>
|
||||||
///// 获取用户列表
|
///新增用户
|
||||||
///// </summary>
|
/// </summary>
|
||||||
///// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
///// <returns></returns>
|
/// <returns></returns>
|
||||||
//[HttpGet("GetUserList")]
|
[HttpPost("AddUser")]
|
||||||
//public async Task<IActionResult> GetUserList([FromQuery] UserQueryDto input)
|
public async Task<IActionResult> AddUser([FromBody] UserDto input)
|
||||||
//{
|
{
|
||||||
// var result = await _userService.GetUserList(input);
|
var result = await _userService.AddUser(input);
|
||||||
// return Ok(result);
|
return Ok(result);
|
||||||
//}
|
}
|
||||||
|
//获取用户列表
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("GetUserList")]
|
||||||
|
public async Task<IActionResult> GetUserList([FromQuery] UserQueryDto input)
|
||||||
|
{
|
||||||
|
var result = await _userService.GetUserList(input);
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
//根据用户Id获取用户信息
|
//根据用户Id获取用户信息
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据用户Id获取用户信息
|
/// 根据用户Id获取用户信息
|
||||||
|
|
@ -81,6 +93,7 @@ namespace langguanApi.Controllers
|
||||||
var result = await _userService.GetUserById(userId);
|
var result = await _userService.GetUserById(userId);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
//修改用户信息
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修改用户信息
|
/// 修改用户信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,10 @@ namespace langguanApi.Extensions
|
||||||
{
|
{
|
||||||
// services.AddSingleton<MQTTService>();
|
// services.AddSingleton<MQTTService>();
|
||||||
services.AddTransient<HJ212SocketServer>();
|
services.AddTransient<HJ212SocketServer>();
|
||||||
services.AddSingleton<GpsService>(); // gps协议
|
|
||||||
services.AddTransient<PingService>();
|
services.AddTransient<PingService>();
|
||||||
|
|
||||||
IServiceProvider serviceProvider = services.BuildServiceProvider();
|
IServiceProvider serviceProvider = services.BuildServiceProvider();
|
||||||
_ = serviceProvider.GetService<HJ212SocketServer>().Start();
|
_ = serviceProvider.GetService<HJ212SocketServer>().Start();
|
||||||
_ = serviceProvider.GetService<GpsService>().Start();
|
|
||||||
serviceProvider.GetService<PingService>().CreatTask();
|
serviceProvider.GetService<PingService>().CreatTask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using langguanApi.Service;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
|
||||||
namespace langguanApi.Middleware
|
namespace langguanApi.Middleware
|
||||||
|
|
@ -9,40 +8,32 @@ namespace langguanApi.Middleware
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 日志
|
/// 日志
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LogService _logger;
|
public ILogger _logger;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构参
|
/// 构参
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logService"></param>
|
/// <param name="loggerFactory"></param>
|
||||||
public CustomerExceptionFilter(LogService logService)
|
public CustomerExceptionFilter(ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
_logger = logService;
|
_logger = loggerFactory.CreateLogger<CustomerExceptionFilter>();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 重写
|
/// 重写
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task OnExceptionAsync(ExceptionContext context)
|
public Task OnExceptionAsync(ExceptionContext context)
|
||||||
{
|
{
|
||||||
if (context.ExceptionHandled == false)
|
if (context.ExceptionHandled == false)
|
||||||
{
|
{
|
||||||
var json = new { code = -1, msg = context.Exception.Message, data = context.Exception.Data };
|
var json = new { cdoe = -1, msg = context.Exception.Message, data = context.Exception.Data };
|
||||||
context.HttpContext.Response.StatusCode = 400;
|
context.HttpContext.Response.StatusCode = 400;
|
||||||
context.Result = new JsonResult(json);
|
context.Result = new JsonResult(json);
|
||||||
}
|
}
|
||||||
await _logger.addLog(new Model.Entity.LogEntity()
|
_logger.LogError($"请求出现异常,地址:{context.HttpContext?.Request?.Path},请求方式:{context.HttpContext.Request.Method},异常信息:{context.Exception.Message}");
|
||||||
{
|
|
||||||
Path = context.HttpContext.Request.Path,
|
|
||||||
msg = context.Exception.Message,
|
|
||||||
Level = "Error"
|
|
||||||
});
|
|
||||||
Console.WriteLine($"请求出现异常,地址:{context.HttpContext?.Request?.Path}," +
|
|
||||||
$"请求方式:{context.HttpContext.Request.Method},异常信息:{context.Exception.Message}");
|
|
||||||
|
|
||||||
//记录异常已经处理
|
//记录异常已经处理
|
||||||
context.ExceptionHandled = true;
|
context.ExceptionHandled = true;
|
||||||
// return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,4 @@
|
||||||
public string AlertType { get; set; }
|
public string AlertType { get; set; }
|
||||||
public string AlertContent { get; set; }
|
public string AlertContent { get; set; }
|
||||||
}
|
}
|
||||||
public class AddAlertDto
|
|
||||||
{
|
|
||||||
public string DeviceId { get; set; }
|
|
||||||
public string DeviceMn { get; set; }
|
|
||||||
public string deviceName { get; set; }
|
|
||||||
public string DeviceType { get; set; }
|
|
||||||
public string DeviceStatus { get; set; }
|
|
||||||
public string AlertType { get; set; }
|
|
||||||
public string AlertContent { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,104 +0,0 @@
|
||||||
namespace langguanApi.Model
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 清洁运输展示信息
|
|
||||||
/// </summary>
|
|
||||||
public class CleanTransportationDto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌号
|
|
||||||
/// </summary>
|
|
||||||
public string CarNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌颜色
|
|
||||||
/// </summary>
|
|
||||||
public string CarColor { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 运输量
|
|
||||||
/// </summary>
|
|
||||||
public double Weight { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 通过时间
|
|
||||||
/// </summary>
|
|
||||||
public string Time { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌类型
|
|
||||||
/// </summary>
|
|
||||||
public string CarType { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 排放类型
|
|
||||||
/// </summary>
|
|
||||||
public string Effluent { get; set; }
|
|
||||||
}
|
|
||||||
public class CleanTransportationAllDto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 清洁运输总记录
|
|
||||||
/// </summary>
|
|
||||||
public List<CleanTransportationDto> cleans { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 国五百分比
|
|
||||||
/// </summary>
|
|
||||||
public string V5Percent { get; set; } = "0";
|
|
||||||
/// <summary>
|
|
||||||
/// 国五比例数量
|
|
||||||
/// </summary>
|
|
||||||
public double V5Numer { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 国五运输量百分比
|
|
||||||
/// </summary>
|
|
||||||
public string V5WeightPercent { get; set; } = "0";
|
|
||||||
/// <summary>
|
|
||||||
/// 国五运输量比例
|
|
||||||
/// </summary>
|
|
||||||
public double V5WeightNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 国六百分比
|
|
||||||
/// </summary>
|
|
||||||
public string V6Percent { get; set; } = "0";
|
|
||||||
/// <summary>
|
|
||||||
/// 国六运输量
|
|
||||||
/// </summary>
|
|
||||||
public double V6Number { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 国六运输量百分比
|
|
||||||
/// </summary>
|
|
||||||
public string V6WeightPercent { get; set; } = "0";
|
|
||||||
/// <summary>
|
|
||||||
/// 国六运输量
|
|
||||||
/// </summary>
|
|
||||||
public double V6WeightNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 电动百分比
|
|
||||||
/// </summary>
|
|
||||||
public string ElectricPrecent { get; set; } = "0";
|
|
||||||
/// <summary>
|
|
||||||
/// 电动运输量
|
|
||||||
/// </summary>
|
|
||||||
public double ElectricNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 电动运输量百分比
|
|
||||||
/// </summary>
|
|
||||||
public string ElectricWeightPrecent { get; set; } = "0";
|
|
||||||
/// <summary>
|
|
||||||
/// 电动运输量
|
|
||||||
/// </summary>
|
|
||||||
public double ElectricWeightNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 其他百分比
|
|
||||||
/// </summary>
|
|
||||||
public string OtherPrecent { get; set; } = "0";
|
|
||||||
/// <summary>
|
|
||||||
/// 其他运输量
|
|
||||||
/// </summary>
|
|
||||||
public double OtherNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 其他运输量百分比
|
|
||||||
/// </summary>
|
|
||||||
public string OtherWeightPrecent { get; set; } = "0";
|
|
||||||
/// <summary>
|
|
||||||
/// 其他运输量
|
|
||||||
/// </summary>
|
|
||||||
public double OtherWeightNumber { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string OrgId { get; set; }
|
public string OrgId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设备类型,1 voc,2 cems,3,tsp,4 video,5微站
|
/// 设备类型,1 voc,2 cems,3,tsp,4 video
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int DeviceType { get; set; }
|
public int DeviceType { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -43,7 +43,5 @@
|
||||||
public string OrgId { get; set; }
|
public string OrgId { get; set; }
|
||||||
public int DeviceType { get; set; }
|
public int DeviceType { get; set; }
|
||||||
public string VideoUrl { get; set; }
|
public string VideoUrl { get; set; }
|
||||||
public double lng { get; set; }
|
|
||||||
public double lat { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,11 +62,7 @@ namespace langguanApi.Model.Dto
|
||||||
for (int j = 0; j < d_6.Length; j++)
|
for (int j = 0; j < d_6.Length; j++)
|
||||||
{
|
{
|
||||||
string[] d_7 = d_6[j].Split(new char[] { '=' });
|
string[] d_7 = d_6[j].Split(new char[] { '=' });
|
||||||
//兼容设备厂家不规范的命名,会有重复的CP名称
|
CP.Add(d_7[0].Replace("-RTD", ""), d_7[1]);
|
||||||
if (!CP.ContainsKey(d_7[0].Replace("-RTD", "")))
|
|
||||||
{
|
|
||||||
CP.Add(d_7[0].Replace("-RTD", "").Replace("-COU", "_Cou"), d_7[1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CRC = data_0[2];
|
CRC = data_0[2];
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
namespace langguanApi.Model.Dto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 接收dto
|
|
||||||
/// </summary>
|
|
||||||
public class ReceiveDto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 数据类型,1 门禁 ,2,tsp,3 地磅,
|
|
||||||
/// </summary>
|
|
||||||
public int dataType { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 数据内容 json格式
|
|
||||||
/// </summary>
|
|
||||||
public string content { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
||||||
namespace langguanApi.Model.Dto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// RespModel
|
|
||||||
/// </summary>
|
|
||||||
public class RespModel<T>
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 状态码
|
|
||||||
/// </summary>
|
|
||||||
public int code { get; set; }
|
|
||||||
public T data { get; set; }
|
|
||||||
public string msg { get; set; }
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 在线
|
|
||||||
/// </summary>
|
|
||||||
public class Rate
|
|
||||||
{
|
|
||||||
public string key { get; set; }
|
|
||||||
public double val { get; set; }
|
|
||||||
}
|
|
||||||
public class alarmList
|
|
||||||
{
|
|
||||||
public List<alarm> List { get; set; }
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 报警信息
|
|
||||||
/// </summary>
|
|
||||||
public class alarm
|
|
||||||
{
|
|
||||||
public string DeviceName { get; set; }
|
|
||||||
public string AlarmName { get; set; }
|
|
||||||
public string Time { get; set; }
|
|
||||||
}
|
|
||||||
public class devceList
|
|
||||||
{
|
|
||||||
public List<Devce> List { get; set; }
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 设备列表
|
|
||||||
/// </summary>
|
|
||||||
public class Devce
|
|
||||||
{
|
|
||||||
public string DeviceName { get; set; }
|
|
||||||
public string DeviceID { get; set; }
|
|
||||||
public string GroupID { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 设备类型 1雾炮 2雾桩 3干雾
|
|
||||||
/// </summary>
|
|
||||||
public int DeviceType { get; set; }
|
|
||||||
public double Lon { get; set; }
|
|
||||||
public double Lat { get; set; }
|
|
||||||
public List<Devlogs> RunLog { get; set; }
|
|
||||||
public double CurrentAngel { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 日志
|
|
||||||
/// </summary>
|
|
||||||
public class Devlogs
|
|
||||||
{
|
|
||||||
public string Time { get; set; }
|
|
||||||
public string Text { get; set; }
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 设备状态
|
|
||||||
/// </summary>
|
|
||||||
public class DeviceStatu
|
|
||||||
{
|
|
||||||
public string DeviceID { get; set; }
|
|
||||||
public string DeviceName { get; set; }
|
|
||||||
public double ElecInfo { get; set; }
|
|
||||||
public double WaterFlow { get; set; }
|
|
||||||
public double Pressure { get; set; }
|
|
||||||
public long RunTime { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
namespace langguanApi.Model.Entity
|
|
||||||
{
|
|
||||||
public class Detection : BaseModel
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// deviceId
|
|
||||||
/// </summary>
|
|
||||||
public string DeviceId { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// deviceName
|
|
||||||
/// </summary>
|
|
||||||
public string DeviceName { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// organizedName
|
|
||||||
/// </summary>
|
|
||||||
public string OrganizedName { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// keyword
|
|
||||||
/// </summary>
|
|
||||||
public string keyword { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// standard
|
|
||||||
/// </summary>
|
|
||||||
public string Standard { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// deviceValue
|
|
||||||
/// </summary>
|
|
||||||
public string deviceValue { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
namespace langguanApi.Model.Entity
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// //GPS历史信息
|
|
||||||
/// </summary>
|
|
||||||
public class GpsHistory : BaseModel
|
|
||||||
{
|
|
||||||
public string DeviceId { get; set; }
|
|
||||||
public string Lat { get; set; }
|
|
||||||
public string Lon { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 批次ID
|
|
||||||
/// </summary>
|
|
||||||
public long BatchId { get; set; }
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// GPSDTO
|
|
||||||
/// </summary>
|
|
||||||
public class GpsHistoryDTO
|
|
||||||
{
|
|
||||||
public string DeviceId { get; set; }
|
|
||||||
public string Lat { get; set; }
|
|
||||||
public string Lon { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -11,18 +11,10 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime InTime { get; set; }
|
public DateTime InTime { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 进出场时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime Time { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 出场日期
|
/// 出场日期
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime OutTime { get; set; }
|
public DateTime OutTime { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 进场方向
|
|
||||||
/// </summary>
|
|
||||||
public int EntryDirection { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车型
|
/// 车型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CarModel { get; set; }
|
public string CarModel { get; set; }
|
||||||
|
|
@ -34,101 +26,6 @@
|
||||||
/// 国几排放量
|
/// 国几排放量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Emissions { get; set; }
|
public string Emissions { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// 车牌颜色
|
|
||||||
/// </summary>
|
|
||||||
public int CarColor { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌类型
|
|
||||||
/// </summary>
|
|
||||||
public string CarType { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// base64图片 出入场图片 url
|
|
||||||
/// </summary>
|
|
||||||
public string EntryExitPictureUrl { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// vin
|
|
||||||
/// </summary>
|
|
||||||
public string VIN { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 发动机号
|
|
||||||
/// </summary>
|
|
||||||
public string EngineNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 注册日期
|
|
||||||
/// </summary>
|
|
||||||
public string RegistrationDate { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// base64图片 驾驶证图片 url
|
|
||||||
/// </summary>
|
|
||||||
public string DriverLicenseUrl { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 驾驶人姓名
|
|
||||||
/// </summary>
|
|
||||||
public string DriverName { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 有效期限
|
|
||||||
/// </summary>
|
|
||||||
public string ValidityPeriod { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 三方系统入参
|
|
||||||
/// </summary>
|
|
||||||
public class AddLedgerDto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌号
|
|
||||||
/// </summary>
|
|
||||||
public string CarNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 进场方向
|
|
||||||
/// </summary>
|
|
||||||
public int EntryDirection{ get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 出入场时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime Time { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 排放等级
|
|
||||||
/// </summary>
|
|
||||||
public string EmissionLevel { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌颜色
|
|
||||||
/// </summary>
|
|
||||||
public int CarColor { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌类型
|
|
||||||
/// </summary>
|
|
||||||
public string CarType { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// base64图片 出入场图片 url
|
|
||||||
/// </summary>
|
|
||||||
public string EntryExitPictureUrl { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// vin
|
|
||||||
/// </summary>
|
|
||||||
public string VIN { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 发动机号
|
|
||||||
/// </summary>
|
|
||||||
public string EngineNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 注册日期
|
|
||||||
/// </summary>
|
|
||||||
public string RegistrationDate { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// base64图片 驾驶证图片 url
|
|
||||||
/// </summary>
|
|
||||||
public string DriverLicenseUrl { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 驾驶人姓名
|
|
||||||
/// </summary>
|
|
||||||
public string DriverName { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 有效期限
|
|
||||||
/// </summary>
|
|
||||||
public string ValidityPeriod { get; set; }
|
|
||||||
}
|
}
|
||||||
public class LedgerDTO
|
public class LedgerDTO
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
namespace langguanApi.Model.Entity
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 日志实体类
|
|
||||||
/// </summary>
|
|
||||||
public class LogEntity : BaseModel
|
|
||||||
{
|
|
||||||
public string Path { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 日志等级
|
|
||||||
/// </summary>
|
|
||||||
public string Level { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 日志内容
|
|
||||||
/// </summary>
|
|
||||||
public string msg { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
namespace langguanApi.Model.Entity
|
||||||
|
|
||||||
namespace langguanApi.Model.Entity
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 菜单实体类
|
/// 菜单实体类
|
||||||
|
|
@ -20,7 +18,7 @@ namespace langguanApi.Model.Entity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Sort { get; set; }
|
public int Sort { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 父菜单ID,一级菜单为"0"
|
/// 父菜单ID,一级菜单为null
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ParentId { get; set; }
|
public string ParentId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +43,6 @@ namespace langguanApi.Model.Entity
|
||||||
}
|
}
|
||||||
public class UpdateMenuDto : AddMenuDto
|
public class UpdateMenuDto : AddMenuDto
|
||||||
{
|
{
|
||||||
[Required]
|
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
}
|
}
|
||||||
public class MenuTreeDto
|
public class MenuTreeDto
|
||||||
|
|
|
||||||
|
|
@ -51,30 +51,16 @@ namespace langguanApi.Model.Entity
|
||||||
/// 邮箱
|
/// 邮箱
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// 手机号
|
|
||||||
/// </summary>
|
|
||||||
public string Phone { get; set; }
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新用户DTO
|
/// 更新用户DTO
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UpdateDto : AddDto
|
public class UpdateDto:AddDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户id
|
/// 用户id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
}
|
}
|
||||||
public class UserViewModel : UserEntity
|
|
||||||
{
|
|
||||||
public string RoleName { get; set; }
|
|
||||||
}
|
|
||||||
public class UserAnMenusViewModel
|
|
||||||
{
|
|
||||||
public UserEntity UserInfo { get; set; }
|
|
||||||
public string RoleName { get; set; }
|
|
||||||
public List<MenuTreeDto> Menus { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -416,23 +416,6 @@
|
||||||
a34040,
|
a34040,
|
||||||
a99010,
|
a99010,
|
||||||
a99049,
|
a99049,
|
||||||
|
|
||||||
LA,
|
|
||||||
a99054,
|
|
||||||
a25003_Cou,
|
|
||||||
a25005_Cou,
|
|
||||||
a25007_Cou,
|
|
||||||
a25002_Cou,
|
|
||||||
a24088_Cou,
|
|
||||||
a24087_Cou,
|
|
||||||
a05002_Cou,
|
|
||||||
a00000_Cou,
|
|
||||||
a34013_Cou,
|
|
||||||
a21002_Cou,
|
|
||||||
a21026_Cou,
|
|
||||||
a21002_ZsRtd,
|
|
||||||
a21026_ZsRtd,
|
|
||||||
a34013_ZsRtd,
|
|
||||||
//a99051,
|
//a99051,
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,6 @@ namespace langguanApi.Model
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string deviceMN { get; set; }
|
public string deviceMN { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CN=2031是日数据,CN=2051是分钟数据,CN=2061是小时数据,
|
|
||||||
/// </summary>
|
|
||||||
public int CN { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// CEMS(ST=31)VOC(ST=27)
|
|
||||||
/// </summary>
|
|
||||||
public int ST { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// PM2.5浓度
|
/// PM2.5浓度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double a34004 { get; set; }
|
public double a34004 { get; set; }
|
||||||
|
|
@ -50,123 +42,6 @@ namespace langguanApi.Model
|
||||||
/// 风向
|
/// 风向
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double a01008 { get; set; }
|
public double a01008 { get; set; }
|
||||||
|
|
||||||
#region CEMS
|
|
||||||
/// <summary>
|
|
||||||
/// 颗粒物(mg/m³)是烟尘
|
|
||||||
/// </summary>
|
|
||||||
public double a34013 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 颗粒物折算(mg/m³)
|
|
||||||
/// </summary>
|
|
||||||
public double a34013_ZsRtd { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 烟气温度(°C)
|
|
||||||
/// </summary>
|
|
||||||
public double a01012 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 烟气湿度(%)
|
|
||||||
/// </summary>
|
|
||||||
public double a01014 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 烟气压力 (kPa)
|
|
||||||
/// </summary>
|
|
||||||
public double a01013 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 烟气流速(m/s)
|
|
||||||
/// </summary>
|
|
||||||
public double a01011 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 二氧化硫折算(mg/m³)
|
|
||||||
/// </summary>
|
|
||||||
public double a21026_ZsRtd { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 氮氧化物(mg/m³)
|
|
||||||
/// </summary>
|
|
||||||
public double a21002 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 氮氧化物折算(mg/m³)
|
|
||||||
/// </summary>
|
|
||||||
public double a21002_ZsRtd { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// SO2总量(mg/m³)
|
|
||||||
/// </summary>
|
|
||||||
public double a21026_Cou { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// NOX总量(mg/m3)
|
|
||||||
/// </summary>
|
|
||||||
public double a21002_Cou { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 烟尘总量(mg/m3)
|
|
||||||
/// </summary>
|
|
||||||
public double a34013_Cou { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 流量总量(mg/m3)
|
|
||||||
/// </summary>
|
|
||||||
public double a00000_Cou { get; set; }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region VOC
|
|
||||||
/// <summary>
|
|
||||||
/// 总烃 是碳氢化合物(mg/m3)
|
|
||||||
/// </summary>
|
|
||||||
public double a24087 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 甲烷(ng/m³)
|
|
||||||
/// </summary>
|
|
||||||
public double a05002 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 非甲烷总烃(mg/m³)
|
|
||||||
/// </summary>
|
|
||||||
public double a24088 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 苯(mg/m³)
|
|
||||||
/// </summary>
|
|
||||||
public double a25002 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 甲苯(mg/m³)
|
|
||||||
/// </summary>
|
|
||||||
public double a25003 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 二甲苯(mg/m³)
|
|
||||||
/// </summary>
|
|
||||||
public double a25005 { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 氧(%)
|
|
||||||
/// </summary>
|
|
||||||
public double a19001 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 流量(m3/s) 是废气
|
|
||||||
/// </summary>
|
|
||||||
public double a00000 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 甲烷总量
|
|
||||||
/// </summary>
|
|
||||||
public double a05002_Cou { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 总烃(碳氢化合物 mg/m3)
|
|
||||||
/// </summary>
|
|
||||||
public double a24087_Cou { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 非甲烷总烃
|
|
||||||
/// </summary>
|
|
||||||
public double a24088_Cou { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 苯
|
|
||||||
/// </summary>
|
|
||||||
public double a25002_Cou { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
///二 甲苯
|
|
||||||
/// </summary>
|
|
||||||
public double a25005_Cou { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
///甲苯
|
|
||||||
/// </summary>
|
|
||||||
public double a25003_Cou { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public double lat { get; set; }
|
public double lat { get; set; }
|
||||||
public double lng { get; set; }
|
public double lng { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,4 @@
|
||||||
{
|
{
|
||||||
public string key { get; set; } = "";
|
public string key { get; set; } = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class transportReqPage : ReqPaing
|
|
||||||
{
|
|
||||||
//开始时间
|
|
||||||
public string startTime { get; set; } = "";
|
|
||||||
//结束时间
|
|
||||||
public string endTime { get; set; } = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,11 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TransportType { get; set; }
|
public int TransportType { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 排放标准(0-7是国1-7,D:电动 X:无排放阶段)
|
/// 位置
|
||||||
|
/// </summary>
|
||||||
|
public string Address { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 排放标准
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string effluent { get; set; }
|
public string effluent { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -26,148 +30,5 @@
|
||||||
/// 注册日期
|
/// 注册日期
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime Registered { get; set; }
|
public DateTime Registered { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// 货物类型
|
|
||||||
/// </summary>
|
|
||||||
public string Goods { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌颜色
|
|
||||||
/// </summary>
|
|
||||||
public int CarColor { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌类型
|
|
||||||
/// </summary>
|
|
||||||
public string CarType { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// base64图片 出入场图片 url
|
|
||||||
/// </summary>
|
|
||||||
public string EntryExitPictureUrl { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 发动机号
|
|
||||||
/// </summary>
|
|
||||||
public string EngineNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 注册日期
|
|
||||||
/// </summary>
|
|
||||||
public string RegistrationDate { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// base64图片 驾驶证图片 url
|
|
||||||
/// </summary>
|
|
||||||
public string DriverLicenseUrl { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 驾驶人姓名
|
|
||||||
/// </summary>
|
|
||||||
public string DriverName { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 有效期限
|
|
||||||
/// </summary>
|
|
||||||
public string ValidityPeriod { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 出入场时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime Time { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
public class AddTransport
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌号
|
|
||||||
/// </summary>
|
|
||||||
public string CarNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 进场方向
|
|
||||||
/// </summary>
|
|
||||||
public int EntryDirection { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 出入场时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime Time { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 排放等级
|
|
||||||
/// </summary>
|
|
||||||
public string EmissionLevel { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌颜色
|
|
||||||
/// </summary>
|
|
||||||
public int CarColor { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌类型
|
|
||||||
/// </summary>
|
|
||||||
public string CarType { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// base64图片 出入场图片 url
|
|
||||||
/// </summary>
|
|
||||||
public string EntryExitPictureUrl { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// vin
|
|
||||||
/// </summary>
|
|
||||||
public string VIN { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 发动机号
|
|
||||||
/// </summary>
|
|
||||||
public string EngineNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 注册日期
|
|
||||||
/// </summary>
|
|
||||||
public string RegistrationDate { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// base64图片 驾驶证图片 url
|
|
||||||
/// </summary>
|
|
||||||
public string DriverLicenseUrl { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 驾驶人姓名
|
|
||||||
/// </summary>
|
|
||||||
public string DriverName { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 有效期限
|
|
||||||
/// </summary>
|
|
||||||
public string ValidityPeriod { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TransportDto : Transport
|
|
||||||
{
|
|
||||||
public string CarColorString { get; set; }
|
|
||||||
|
|
||||||
public string TransportTypeString { get; set; }
|
|
||||||
|
|
||||||
public string TimeString { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 排放标准(0-7是国1-7,D:电动 X:无排放阶段)
|
|
||||||
/// </summary>
|
|
||||||
public string EmissionLevelString(string sort)
|
|
||||||
{
|
|
||||||
switch (sort)
|
|
||||||
{
|
|
||||||
case "1":
|
|
||||||
return "国I";
|
|
||||||
case "2":
|
|
||||||
return "国II";
|
|
||||||
case "3":
|
|
||||||
return "国III";
|
|
||||||
case "4":
|
|
||||||
return "国IV";
|
|
||||||
case "5":
|
|
||||||
return "国V";
|
|
||||||
case "6":
|
|
||||||
return "国VI";
|
|
||||||
case "7":
|
|
||||||
return "国VII";
|
|
||||||
case "D":
|
|
||||||
return "电动";
|
|
||||||
default:
|
|
||||||
return "无排放阶段";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public enum CarColor
|
|
||||||
{
|
|
||||||
蓝色 = 1,
|
|
||||||
绿色 = 2,
|
|
||||||
黄色 = 3,
|
|
||||||
白色 = 4,
|
|
||||||
黑色 = 5,
|
|
||||||
黄绿 = 6
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
namespace langguanApi.Model
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 地磅
|
|
||||||
/// </summary>
|
|
||||||
public class TruckScales :BaseModel
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 重量
|
|
||||||
/// </summary>
|
|
||||||
public double Weight { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 货物类型
|
|
||||||
/// </summary>
|
|
||||||
public string GoodsType { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌
|
|
||||||
/// </summary>
|
|
||||||
public string CarNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 时间
|
|
||||||
/// </summary>
|
|
||||||
public string DTime { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
public class AddTruckScalesDto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 重量
|
|
||||||
/// </summary>
|
|
||||||
public string Weight { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 货物类型
|
|
||||||
/// </summary>
|
|
||||||
public string GoodsType { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 车牌
|
|
||||||
/// </summary>
|
|
||||||
public string CarNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 时间
|
|
||||||
/// </summary>
|
|
||||||
public string DTime { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,220 +0,0 @@
|
||||||
namespace langguanApi.Model
|
|
||||||
{
|
|
||||||
public class Washer : BaseModel
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 洗车机名称(Name)
|
|
||||||
/// </summary>
|
|
||||||
public string Name { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 设备状态(EquipmentStatus,0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public int EquipmentStatus { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 运行状态(RunStatus,0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public int RunStatus { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 水压报警(WPAlarm 0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public int WPAlarm { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 相序报警(PSAlarm0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public int PSAlarm { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 故障报警(FaultAlarm 0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public int FaultAlarm { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 冲洗压力
|
|
||||||
/// </summary>
|
|
||||||
public double RinsePressure { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 冲洗电流
|
|
||||||
/// </summary>
|
|
||||||
public double RinseCurrent { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 冲洗电压(RinseVoltage 单位V)
|
|
||||||
/// </summary>
|
|
||||||
public double RinseVoltage { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 水流量(Discharge 单位T)
|
|
||||||
/// </summary>
|
|
||||||
public double Discharge { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 电量(Electricity KW/H)
|
|
||||||
/// </summary>
|
|
||||||
public double Electricity { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 电流(Current A)
|
|
||||||
/// </summary>
|
|
||||||
public double Current { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 水压(WaterPressure MPa)
|
|
||||||
/// </summary>
|
|
||||||
public double WaterPressure { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 运行时间(RunTime)
|
|
||||||
/// </summary>
|
|
||||||
public string RunTime { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 清洗记录时间(RecodeTime)
|
|
||||||
/// </summary>
|
|
||||||
public string RecodeTime { get; set; }
|
|
||||||
//车牌号(CarNumber)
|
|
||||||
public string CarNumber { get; set; }
|
|
||||||
//清洗时间(Time 单位s)
|
|
||||||
public int Time { get; set; }
|
|
||||||
//设备状态(State 0表示异常,1表示正常)
|
|
||||||
public int State { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 洗车机编码
|
|
||||||
/// </summary>
|
|
||||||
public string EquipmentId { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class AddWasher
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 洗车机名称(Name)
|
|
||||||
/// </summary>
|
|
||||||
public string Name { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 设备状态(EquipmentStatus,0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public int EquipmentStatus { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 运行状态(RunStatus,0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public int RunStatus { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 水压报警(WPAlarm 0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public int WPAlarm { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 相序报警(PSAlarm0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public int PSAlarm { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 故障报警(FaultAlarm 0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public int FaultAlarm { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 冲洗压力
|
|
||||||
/// </summary>
|
|
||||||
public double RinsePressure { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 冲洗电流
|
|
||||||
/// </summary>
|
|
||||||
public double RinseCurrent { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 冲洗电压(RinseVoltage 单位V)
|
|
||||||
/// </summary>
|
|
||||||
public double RinseVoltage { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 水流量(Discharge 单位T)
|
|
||||||
/// </summary>
|
|
||||||
public double Discharge { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 电量(Electricity KW/H)
|
|
||||||
/// </summary>
|
|
||||||
public double Electricity { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 电流(Current A)
|
|
||||||
/// </summary>
|
|
||||||
public double Current { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 水压(WaterPressure MPa)
|
|
||||||
/// </summary>
|
|
||||||
public double WaterPressure { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 运行时间(RunTime)
|
|
||||||
/// </summary>
|
|
||||||
public string RunTime { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 清洗记录时间(RecodeTime)
|
|
||||||
/// </summary>
|
|
||||||
public string RecodeTime { get; set; }
|
|
||||||
//车牌号(CarNumber)
|
|
||||||
public string CarNumber { get; set; }
|
|
||||||
//清洗时间(Time 单位s)
|
|
||||||
public int Time { get; set; }
|
|
||||||
//设备状态(State 0表示异常,1表示正常)
|
|
||||||
public int State { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 洗车机编码
|
|
||||||
/// </summary>
|
|
||||||
public string EquipmentId { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取洗车机
|
|
||||||
/// </summary>
|
|
||||||
public class GetWasherDto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 洗车机名称(Name)
|
|
||||||
/// </summary>
|
|
||||||
public string Name { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 设备状态(EquipmentStatus,0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public string EquipmentStatusString { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 运行状态(RunStatus,0表示异常,1表示正常)
|
|
||||||
/// </summary>
|
|
||||||
public string RunStatusString { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 冲洗压力
|
|
||||||
/// </summary>
|
|
||||||
public double RinsePressure { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 冲洗电流
|
|
||||||
/// </summary>
|
|
||||||
public double RinseCurrent { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 冲洗电压(RinseVoltage 单位V)
|
|
||||||
/// </summary>
|
|
||||||
public double RinseVoltage { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 洗车机编码
|
|
||||||
/// </summary>
|
|
||||||
public string EquipmentId { get; set; }
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 添加洗车机历史
|
|
||||||
/// </summary>
|
|
||||||
public class WasherHistoryDto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 洗车机编码
|
|
||||||
/// </summary>
|
|
||||||
public string EquipmentId { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 运行时间(RunTime)
|
|
||||||
/// </summary>
|
|
||||||
public string RunTime { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 清洗记录时间(RecodeTime)
|
|
||||||
/// </summary>
|
|
||||||
public string RecodeTime { get; set; }
|
|
||||||
//车牌号(CarNumber)
|
|
||||||
public string CarNumber { get; set; }
|
|
||||||
//清洗时间(Time 单位s)
|
|
||||||
public int Time { get; set; }
|
|
||||||
|
|
||||||
//设备名称(Name)
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
//设备状态(State 0表示异常,1表示正常)
|
|
||||||
public string StateString { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +1,9 @@
|
||||||
using langguanApi.Common.Redis;
|
using langguanApi.Common.Redis;
|
||||||
using langguanApi.Common.WebSocket;
|
|
||||||
using langguanApi.Extensions;
|
using langguanApi.Extensions;
|
||||||
using langguanApi.Extensions.AutoDI;
|
using langguanApi.Extensions.AutoDI;
|
||||||
using langguanApi.Middleware;
|
using langguanApi.Middleware;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
@ -20,11 +16,8 @@ builder.Services.AddControllers(options =>
|
||||||
options.Filters.Add<CustomerExceptionFilter>();
|
options.Filters.Add<CustomerExceptionFilter>();
|
||||||
}).AddNewtonsoftJson(option =>
|
}).AddNewtonsoftJson(option =>
|
||||||
{
|
{
|
||||||
|
|
||||||
option.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
|
option.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
|
||||||
option.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
option.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
||||||
//驼峰
|
|
||||||
option.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
|
|
||||||
|
|
||||||
}).AddJsonOptions(option =>
|
}).AddJsonOptions(option =>
|
||||||
{
|
{
|
||||||
|
|
@ -46,8 +39,7 @@ builder.Services.AddSwaggerGen(
|
||||||
});
|
});
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
//websocket
|
|
||||||
builder.Services.AddSignalR();
|
|
||||||
//redis
|
//redis
|
||||||
var redisoptions = builder.Configuration.GetSection("Redis").Get<RedisOptions>();
|
var redisoptions = builder.Configuration.GetSection("Redis").Get<RedisOptions>();
|
||||||
if (redisoptions != null)
|
if (redisoptions != null)
|
||||||
|
|
@ -61,14 +53,10 @@ if (redisoptions != null)
|
||||||
options.Key = redisoptions.Key;
|
options.Key = redisoptions.Key;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//自动注入
|
//自动注入
|
||||||
builder.Services.ServicesAutoInjectionExtension();
|
builder.Services.ServicesAutoInjectionExtension();
|
||||||
builder.Services.AddSocketService();
|
builder.Services.AddSocketService();
|
||||||
builder.Services.AddHttpClient();
|
builder.Services.AddHttpClient();
|
||||||
builder.Services.AddHttpClient("httpreq", m => { }).ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
|
|
||||||
{
|
|
||||||
ServerCertificateCustomValidationCallback = (m, c, ch, e) => true
|
|
||||||
});
|
|
||||||
//cross domain
|
//cross domain
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
|
|
@ -82,13 +70,6 @@ builder.Services.AddCors(options =>
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
ServiceLocator.Instance = app.Services;
|
ServiceLocator.Instance = app.Services;
|
||||||
app.UseRouting();
|
|
||||||
//执行匹配的端点
|
|
||||||
app.UseEndpoints(endpoints =>
|
|
||||||
{
|
|
||||||
endpoints.MapHub<SocketHub>("/notification");
|
|
||||||
endpoints.MapControllers();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
|
|
@ -102,47 +83,13 @@ app.UseSwaggerUI();
|
||||||
app.UseCors("CorsPolicy");
|
app.UseCors("CorsPolicy");
|
||||||
//app.UseAuthorization();
|
//app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//if (!await GetNowTimeAsync())
|
|
||||||
//{
|
|
||||||
// Console.WriteLine("当前时间不在可运行时间范围内,请联系供应商。");
|
|
||||||
// Environment.Exit(0);
|
|
||||||
//}
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//获取当前时间是否在可运行时间范围内
|
|
||||||
static async Task<bool> GetNowTimeAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime startTime = DateTime.Parse("2024-09-01");
|
|
||||||
//从公网上获取当前时间
|
|
||||||
var url = "http://www.worldtimeapi.org/api/ip";
|
|
||||||
var myClient = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true });
|
|
||||||
var response = await myClient.GetStringAsync(url);
|
|
||||||
var time = JObject.Parse(response)["datetime"].ToString();
|
|
||||||
var now = DateTime.Parse(time);
|
|
||||||
Console.WriteLine($"当前时间:{now},过期时间:{startTime.AddDays(365)},距离过期时间还有:{(startTime.AddDays(365) - now).Days} 天");
|
|
||||||
return startTime.AddDays(365) > now ? true : false;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 暂存服务
|
/// 暂存服务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ServiceLocator
|
public static class ServiceLocator
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 服务容器
|
|
||||||
/// </summary>
|
|
||||||
public static IServiceProvider Instance { get; set; }
|
public static IServiceProvider Instance { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
using langguanApi.Common.Proxy;
|
using langguanApi.Extensions.AutoDI;
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
using langguanApi.Model;
|
using langguanApi.Model;
|
||||||
using langguanApi.Model.Dto;
|
using langguanApi.Model.Dto;
|
||||||
using langguanApi.Model.Entity;
|
|
||||||
using Mapster;
|
|
||||||
using Npoi.Mapper;
|
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
namespace langguanApi.Service
|
namespace langguanApi.Service
|
||||||
|
|
@ -12,24 +8,19 @@ namespace langguanApi.Service
|
||||||
[ServiceInjection(InjectionType.Transient)]
|
[ServiceInjection(InjectionType.Transient)]
|
||||||
public class AlertService : BaseService<Alert>
|
public class AlertService : BaseService<Alert>
|
||||||
{
|
{
|
||||||
private readonly HttpProxy _httpProxy;
|
public AlertService(IConfiguration config) : base(config, nameof(Alert))
|
||||||
private readonly IConfiguration _configuration;
|
|
||||||
public AlertService(IConfiguration config, HttpProxy httpProxy) : base(config, nameof(Alert))
|
|
||||||
{
|
{
|
||||||
_httpProxy = httpProxy;
|
|
||||||
_configuration = config;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新加
|
/// 新加
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ApiResult> Add(AddAlertDto input)
|
public async Task<ApiResult> Add(Alert input)
|
||||||
{
|
{
|
||||||
if (input != null)
|
if (input != null)
|
||||||
{
|
{
|
||||||
var entity = input.Adapt<Alert>();
|
await base.CreateAsync(input);
|
||||||
await base.CreateAsync(entity);
|
|
||||||
return new ApiResult { code = 0, msg = "" };
|
return new ApiResult { code = 0, msg = "" };
|
||||||
}
|
}
|
||||||
return new ApiResult { code = -1, msg = "" }; ;
|
return new ApiResult { code = -1, msg = "" }; ;
|
||||||
|
|
@ -38,67 +29,10 @@ namespace langguanApi.Service
|
||||||
/// 首页数据,最近7天的
|
/// 首页数据,最近7天的
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<List<alarm>> IndexData(int num = 50)
|
public async Task<object> IndexData()
|
||||||
{
|
{
|
||||||
Expression<Func<Alert, bool>> exp = filter => filter.IsDelete == false;
|
Expression<Func<Alert, bool>> exp = filter => filter.CreateDateTime >= DateTime.Now.AddDays(-7) && filter.IsDelete == false;
|
||||||
return (await base.GetListWithExp(exp))
|
return (await base.GetListWithExp(exp)).OrderByDescending(s => s.CreateDateTime);
|
||||||
.OrderByDescending(s => s.CreateDateTime)
|
|
||||||
.Take(num)
|
|
||||||
.Select(s => new alarm
|
|
||||||
{
|
|
||||||
AlarmName = s.deviceName,
|
|
||||||
DeviceName = s.deviceName,
|
|
||||||
Time = s.CreateDateTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
///导出数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="start"></param>
|
|
||||||
/// <param name="end"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<byte[]> ExportData(DateTime? start, DateTime? end)
|
|
||||||
{
|
|
||||||
Expression<Func<Alert, bool>> exp = filter => filter.CreateDateTime >= start
|
|
||||||
&& filter.CreateDateTime <= end && filter.IsDelete == false;
|
|
||||||
List<Alert> result = new List<Alert>();
|
|
||||||
//获取接口报警数据
|
|
||||||
Dictionary<string, string> dic = new Dictionary<string, string>() { };
|
|
||||||
dic.Add("BeginTime", start.Value.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
dic.Add("EndTime", end.Value.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
var AlermResp = await _httpProxy.Get<RespModel<alarmList>>(dic, _configuration.GetValue<string>("Apis:AlertUrl"));
|
|
||||||
if (AlermResp.code == 0)
|
|
||||||
{
|
|
||||||
var romte = AlermResp.data.List.Select(s => new Alert
|
|
||||||
{
|
|
||||||
AlertContent = s.AlarmName,
|
|
||||||
deviceName = s.DeviceName,
|
|
||||||
CreateDateTime = DateTime.Parse(s.Time)
|
|
||||||
}).ToList();
|
|
||||||
if (romte.Any())
|
|
||||||
{
|
|
||||||
result.AddRange(romte);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var list = (await base.GetListWithExp(exp)).OrderByDescending(s => s.CreateDateTime).ToList();
|
|
||||||
if (list.Any())
|
|
||||||
{
|
|
||||||
result.AddRange(list);
|
|
||||||
}
|
|
||||||
if (result.Any())
|
|
||||||
{
|
|
||||||
result = result.OrderByDescending(s => s.CreateDateTime).ToList();
|
|
||||||
var mapper = new Mapper();
|
|
||||||
mapper.Map<Alert>("报警开始时间", s => s.CreateDateTime)
|
|
||||||
.Map<Alert>("设备名称", s => s.deviceName)
|
|
||||||
// .Map<Alert>("工序", s => s.)
|
|
||||||
.Map<Alert>("内容", s => s.AlertContent)
|
|
||||||
.Format<Alert>("yyyy-MM-dd HH:mm:ss", s => s.CreateDateTime);
|
|
||||||
MemoryStream stream = new MemoryStream();
|
|
||||||
mapper.Save(stream, result, sheetName: "sheet1", leaveOpen: true);
|
|
||||||
return stream.ToArray();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分页取数据
|
/// 分页取数据
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
using langguanApi.Model;
|
using langguanApi.Model;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using MongoDB.Bson;
|
|
||||||
using MongoDB.Driver;
|
using MongoDB.Driver;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
|
@ -186,27 +184,16 @@ namespace langguanApi.Service
|
||||||
{
|
{
|
||||||
FilterDefinition<T> filters = Builders<T>.Filter.Where(filter);
|
FilterDefinition<T> filters = Builders<T>.Filter.Where(filter);
|
||||||
return await _collection.Find(filters).ToListAsync();
|
return await _collection.Find(filters).ToListAsync();
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// filter查找 流式数据
|
/// filterdefinition
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<List<T>> FindListyFilter(FilterDefinition<T> filter)
|
public async Task<List<T>> FindListyFilter(FilterDefinition<T> filter)
|
||||||
{
|
{
|
||||||
List<T> result = new List<T>();
|
return await _collection.Find(filter).ToListAsync();
|
||||||
var cursor = await _collection.FindAsync(filter);
|
|
||||||
while (await cursor.MoveNextAsync())
|
|
||||||
{
|
|
||||||
var batch = cursor.Current;
|
|
||||||
foreach (var document in batch)
|
|
||||||
{
|
|
||||||
result.Add(document);
|
|
||||||
// Console.WriteLine(document.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否存在
|
/// 是否存在
|
||||||
|
|
@ -237,29 +224,5 @@ namespace langguanApi.Service
|
||||||
data = new { total, items }
|
data = new { total, items }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 分页取数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="req"></param>
|
|
||||||
/// <param name="exp"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<Tuple<long, List<T>>> GetListByPage(ReqPaing req, Expression<Func<T, bool>> exp = null)
|
|
||||||
{
|
|
||||||
req.pageSize = req.pageSize == 0 ? 10 : req.pageSize;
|
|
||||||
var query = await GetListWithExp(exp);
|
|
||||||
var total = query.Count();
|
|
||||||
var items = query.OrderByDescending(s => s.CreateDateTime)
|
|
||||||
.Skip(req.pageSize * (req.current - 1)).Take(req.pageSize).ToList();
|
|
||||||
return new Tuple<long, List<T>>(total, items);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 聚合查询
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pipeline"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<List<BsonDocument>> GetGroupedResultsAsync(BsonDocument[] pipeline)
|
|
||||||
{
|
|
||||||
return await _collection.Aggregate<BsonDocument>(pipeline).ToListAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
using langguanApi.Model;
|
|
||||||
using langguanApi.Model.Entity;
|
|
||||||
using Npoi.Mapper;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
|
||||||
{
|
|
||||||
[ServiceInjection(InjectionType.Transient)]
|
|
||||||
public class DetectionService : BaseService<Detection>
|
|
||||||
{
|
|
||||||
public DetectionService(IConfiguration config) : base(config, nameof(Detection))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// //获取最新的数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="num"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<object> GetIndexData(int num = 50)
|
|
||||||
{
|
|
||||||
Expression<Func<Detection, bool>> exp = filter => true;
|
|
||||||
var result = (await GetListWithExp(exp)).OrderByDescending(s => s.CreateDateTime).Take(num).ToList();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 导出数据
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<byte[]> Export(DateTime start, DateTime end)
|
|
||||||
{
|
|
||||||
Expression<Func<Detection, bool>> exp = filter => filter.CreateDateTime >= start && filter.CreateDateTime <= end;
|
|
||||||
var result = (await GetListWithExp(exp)).OrderBy(s => s.CreateDateTime).ToList();
|
|
||||||
var mapper = new Mapper();
|
|
||||||
mapper.Map<Detection>("时间", s => s.CreateDateTime.ToString("yyyy-MM-dd HH:mm:ss"))
|
|
||||||
.Map<Detection>("工序", s => s.OrganizedName)
|
|
||||||
.Map<Detection>("设备名称", s => s.DeviceName)
|
|
||||||
.Map<Detection>("项目", s => s.keyword)
|
|
||||||
.Map<Detection>("检测值", s => s.deviceValue)
|
|
||||||
.Format<Detection>("yyyy-MM-dd HH:mm:ss", s => s.CreateDateTime);
|
|
||||||
MemoryStream stream = new MemoryStream();
|
|
||||||
mapper.Save(stream, result.ToList(), sheetName: "sheet1", leaveOpen: true);
|
|
||||||
return stream.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -29,37 +29,6 @@ namespace langguanApi.Service
|
||||||
await base.CreateAsync(entity);
|
await base.CreateAsync(entity);
|
||||||
return new ApiResult { code = 0, msg = "" };
|
return new ApiResult { code = 0, msg = "" };
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 取设备及数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<ApiResult> GetDeviceAndData(string id)
|
|
||||||
{
|
|
||||||
var entity = await base.GetAsync(id);
|
|
||||||
if (entity == null)
|
|
||||||
{
|
|
||||||
return new ApiResult { code = 1, msg = "设备不存在" };
|
|
||||||
}
|
|
||||||
var _service = ServiceLocator.Instance.GetService<Hj212Service>();
|
|
||||||
if (_service == null)
|
|
||||||
{
|
|
||||||
return new ApiResult
|
|
||||||
{
|
|
||||||
code = 0,
|
|
||||||
msg = "",
|
|
||||||
data = new
|
|
||||||
{
|
|
||||||
device = entity,
|
|
||||||
items = await _service.GetViewByDeviceMn(entity.deviceMN)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
// var items = await _hj212Service.GetViewByDeviceMn(entity.deviceMN);
|
|
||||||
return new ApiResult { code = 0, msg = "", data = new { device = entity, items = "" } };
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否存在
|
/// 是否存在
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
using IceCoffee.Common.Templates;
|
|
||||||
using langguanApi.Common.Proxy;
|
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
using langguanApi.Model;
|
|
||||||
using langguanApi.Model.Dto;
|
|
||||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
|
||||||
using Microsoft.OpenApi.Writers;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 环境治理页面Service
|
|
||||||
/// </summary>
|
|
||||||
[ServiceInjection(InjectionType.Transient)]
|
|
||||||
public class EnvGovService
|
|
||||||
{
|
|
||||||
private HttpProxy _httpProxy;
|
|
||||||
private readonly IConfiguration _configuration;
|
|
||||||
|
|
||||||
public EnvGovService(HttpProxy httpProxy, IConfiguration configuration)
|
|
||||||
{
|
|
||||||
_httpProxy = httpProxy;
|
|
||||||
_configuration = configuration;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 首页数据
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<ApiResult> IndexView()
|
|
||||||
{
|
|
||||||
var url = _configuration.GetValue<string>("Apis:DeviceList");
|
|
||||||
var deviceResp = await _httpProxy.Get<RespModel<devceList>>(null, url);
|
|
||||||
var deviceList = deviceResp.data.List.GroupBy(g => g.GroupID)
|
|
||||||
.Select(s => new
|
|
||||||
{
|
|
||||||
group = s.Key,
|
|
||||||
items = new
|
|
||||||
{
|
|
||||||
devices = s.ToList().GroupBy(m => m.DeviceType)
|
|
||||||
.Select(o => new
|
|
||||||
{
|
|
||||||
devicetype = ConvertDeviceType(o.Key),
|
|
||||||
items = o.ToList()
|
|
||||||
.Select(d => new
|
|
||||||
{
|
|
||||||
d.DeviceID,
|
|
||||||
d.DeviceName,
|
|
||||||
d.Lon,
|
|
||||||
d.Lat,
|
|
||||||
d.CurrentAngel,
|
|
||||||
d.RunLog
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return new ApiResult
|
|
||||||
{
|
|
||||||
code = deviceResp.code,
|
|
||||||
msg = deviceResp.msg,
|
|
||||||
data = deviceList
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 转换设备类型
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="deviceType"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private string ConvertDeviceType(int deviceType)
|
|
||||||
{
|
|
||||||
switch (deviceType)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return "雾炮";
|
|
||||||
case 2:
|
|
||||||
return "雾桩";
|
|
||||||
case 3:
|
|
||||||
return "干雾";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 获取设备状态
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="deviceId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<ApiResult> DeviceStatu(string deviceId)
|
|
||||||
{
|
|
||||||
var url = _configuration.GetValue<string>("Apis:DeviceStatu");
|
|
||||||
var deviceStatuResp = await _httpProxy.Get<RespModel<List<DeviceStatu>>>(null, url);
|
|
||||||
var result = deviceStatuResp.data.Where(s => s.DeviceID == deviceId).FirstOrDefault();
|
|
||||||
return new ApiResult
|
|
||||||
{
|
|
||||||
//接口返回错误,暂时注释
|
|
||||||
// code = deviceStatuResp.code,
|
|
||||||
code = 0,
|
|
||||||
msg = deviceStatuResp.msg,
|
|
||||||
data = result
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,145 +0,0 @@
|
||||||
using IceCoffee.FastSocket.Tcp;
|
|
||||||
using langguanApi.Model.Dto;
|
|
||||||
using langguanApi.Model;
|
|
||||||
using langguanApi.Service.HJ212;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
using JT808.Protocol;
|
|
||||||
using Org.BouncyCastle.Utilities;
|
|
||||||
using LogicExtensions;
|
|
||||||
using JT808.Protocol.Enums;
|
|
||||||
using JT808.Protocol.MessageBody;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
|
||||||
{
|
|
||||||
public class Gps808SocketServer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 缓冲器
|
|
||||||
/// </summary>
|
|
||||||
private byte[] result = new byte[1024];
|
|
||||||
/// <summary>
|
|
||||||
/// 最大连接数
|
|
||||||
/// </summary>
|
|
||||||
private int maxClientCount;
|
|
||||||
/// <summary>
|
|
||||||
/// 服务IP地址
|
|
||||||
/// </summary>
|
|
||||||
private string ip;
|
|
||||||
/// <summary>
|
|
||||||
/// 服务端口号
|
|
||||||
/// </summary>
|
|
||||||
private int port => 5002;
|
|
||||||
// 编码
|
|
||||||
// private string code;
|
|
||||||
/// <summary>
|
|
||||||
/// 客户端列表
|
|
||||||
/// </summary>
|
|
||||||
private List<Socket> ClientSockets;
|
|
||||||
/// <summary>
|
|
||||||
/// IP终端
|
|
||||||
/// </summary>
|
|
||||||
private IPEndPoint ipEndPoint;
|
|
||||||
/// <summary>
|
|
||||||
/// 服务端Socket
|
|
||||||
/// </summary>
|
|
||||||
private Socket ServerSocket;
|
|
||||||
private static NetServer server;
|
|
||||||
private static IceCoffee.FastSocket.Tcp.TcpClient client;
|
|
||||||
/// <summary>
|
|
||||||
/// 启动服务
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task Start()
|
|
||||||
{
|
|
||||||
ip = IPAddress.Any.ToString();
|
|
||||||
server = new NetServer(ip, port);
|
|
||||||
server.Started += OnNetServer_Started;
|
|
||||||
server.ExceptionCaught += OnNetServer_ExceptionCaught;
|
|
||||||
server.SessionStarted += OnNetServer_SessionStarted;
|
|
||||||
server.SessionClosed += OnNetServer_SessionClosed;
|
|
||||||
server.ReceivedData += OnNetServer_ReceivedData;
|
|
||||||
server.SendData += OnNetServer_SendData;
|
|
||||||
server.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void OnNetServer_Started()
|
|
||||||
{
|
|
||||||
Console.WriteLine($"开始监听gps: {ip}:{port}");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnNetServer_SendData(NetSession session, NetPackage netPackage, string rawText)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"发送给gps: {session.RemoteIPEndPoint}: {rawText}");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnNetServer_SessionClosed(TcpSession session)
|
|
||||||
{
|
|
||||||
Console.WriteLine("会话关闭gps: " + session.RemoteIPEndPoint + ", 当前会话总数: " + server.SessionCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnNetServer_SessionStarted(TcpSession session)
|
|
||||||
{
|
|
||||||
Console.WriteLine("会话开始gps: " + session.RemoteIPEndPoint + ", 当前会话总数: " + server.SessionCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void OnNetServer_ReceivedData(TcpSession session, NetPackage netPackage, string rawText)
|
|
||||||
{
|
|
||||||
Console.WriteLine("收到自gps: " + session.RemoteIPEndPoint + ": " + rawText);
|
|
||||||
byte[] bytes = rawText.ToBytes();
|
|
||||||
//2.将数组反序列化
|
|
||||||
// var jT808Package =new JT808Serializer.Deserialize(bytes.AsSpan());
|
|
||||||
//3.解析数据
|
|
||||||
var jT808Package = new JT808Serializer().Deserialize(bytes);
|
|
||||||
//4.数据包体
|
|
||||||
JT808_0x0200 jT808_0x0200 = (JT808_0x0200)jT808Package.Bodies;
|
|
||||||
var lon = jT808_0x0200.Lat;
|
|
||||||
var lat= jT808_0x0200.Lng;
|
|
||||||
Console.WriteLine("经度:" + lon + " 纬度:" + lat);
|
|
||||||
//4.处理数据
|
|
||||||
//5.返回数据
|
|
||||||
//6.发送数据
|
|
||||||
// st 27 =voc,st=31 cems, st=32,tsp, st=22 微站
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnNetServer_ExceptionCaught(Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Error in NetServer gps" + ex);
|
|
||||||
}
|
|
||||||
byte[] CallCRC(byte[] data)
|
|
||||||
{
|
|
||||||
string ccc = Convert.ToString(getCrc(data), 16).PadLeft(4, '0');
|
|
||||||
return Encoding.ASCII.GetBytes(ccc.ToUpper());
|
|
||||||
}
|
|
||||||
private int getCrc(byte[] data)
|
|
||||||
{
|
|
||||||
int high;
|
|
||||||
int flag;
|
|
||||||
|
|
||||||
// 16位寄存器,所有数位均为1
|
|
||||||
int wcrc = 0xffff;
|
|
||||||
for (int i = 0; i < data.Length; i++)
|
|
||||||
{
|
|
||||||
// 16 位寄存器的高位字节
|
|
||||||
high = wcrc >> 8;
|
|
||||||
// 取被校验串的一个字节与 16 位寄存器的高位字节进行“异或”运算
|
|
||||||
wcrc = high ^ data[i];
|
|
||||||
|
|
||||||
for (int j = 0; j < 8; j++)
|
|
||||||
{
|
|
||||||
flag = wcrc & 0x0001;
|
|
||||||
// 把这个 16 寄存器向右移一位
|
|
||||||
wcrc = wcrc >> 1;
|
|
||||||
// 若向右(标记位)移出的数位是 1,则生成多项式 1010 0000 0000 0001 和这个寄存器进行“异或”运算
|
|
||||||
if (flag == 1)
|
|
||||||
wcrc ^= 0xa001;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return wcrc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
using langguanApi.Common.Redis;
|
|
||||||
using langguanApi.Common.WebSocket;
|
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
using langguanApi.Model.Entity;
|
|
||||||
using Mapster;
|
|
||||||
using StackExchange.Redis;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
|
||||||
{
|
|
||||||
[ServiceInjection(InjectionType.Transient)]
|
|
||||||
public class GpsHistoryService : BaseService<GpsHistory>
|
|
||||||
{
|
|
||||||
private readonly PushService _pushService;
|
|
||||||
private IDatabase _redis;
|
|
||||||
private IConfiguration _config;
|
|
||||||
public GpsHistoryService(IConfiguration config, PushService pushService,
|
|
||||||
RedisHelper redisHelper) : base(config, nameof(Model.Entity.GpsHistory))
|
|
||||||
{
|
|
||||||
_pushService = pushService;
|
|
||||||
_redis = redisHelper._database;
|
|
||||||
_config = config;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 新加gps历史记录
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task AddGpsHistory(GpsHistoryDTO input)
|
|
||||||
{
|
|
||||||
var entity = input.Adapt<GpsHistory>();
|
|
||||||
var redisKey = RedisKeylist.GetBatchid(entity.DeviceId);
|
|
||||||
///如果redis中不存在该设备的批次号,则生成一个批次号
|
|
||||||
if (!await _redis.KeyExistsAsync(redisKey))
|
|
||||||
{
|
|
||||||
int time = _config.GetValue<int>("BatchId");
|
|
||||||
long utc = DateTime.UtcNow.Ticks;
|
|
||||||
await _redis.StringSetAsync(redisKey, utc, TimeSpan.FromMinutes(time));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//如果存在了,就把批次号延期30分钟
|
|
||||||
await _redis.KeyExpireAsync(redisKey, TimeSpan.FromMinutes(30));
|
|
||||||
}
|
|
||||||
entity.BatchId = (long)await _redis.StringGetAsync(redisKey);
|
|
||||||
await base.CreateAsync(entity);
|
|
||||||
await _pushService.SendMessageToAll(new
|
|
||||||
{
|
|
||||||
entity.Lat,
|
|
||||||
entity.DeviceId,
|
|
||||||
entity.Lon,
|
|
||||||
entity.BatchId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
using langguanApi.Model.Entity;
|
|
||||||
using MongoDB.Bson.IO;
|
|
||||||
using Org.BouncyCastle.Utilities.Net;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Text;
|
|
||||||
using IPAddress = System.Net.IPAddress;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
|
||||||
{
|
|
||||||
|
|
||||||
public class GpsService
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 缓冲器
|
|
||||||
/// </summary>
|
|
||||||
private byte[] result = new byte[1024];
|
|
||||||
private int port => 5002;
|
|
||||||
/// <summary>
|
|
||||||
/// 启动GPS服务
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task Start()
|
|
||||||
{
|
|
||||||
// 创建本地IP地址和TCP端口号
|
|
||||||
// 定义监听地址和端口
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// 定义监听地址和端口
|
|
||||||
IPAddress ipAddress = IPAddress.Any; // 使用本地所有可用的 IP 地址
|
|
||||||
|
|
||||||
// 创建 TcpListener 实例
|
|
||||||
TcpListener listener = new TcpListener(ipAddress, port);
|
|
||||||
// 开始监听
|
|
||||||
listener.Start();
|
|
||||||
Console.WriteLine($" gps Listening on {ipAddress}:{port}...");
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
// 接受客户端连接
|
|
||||||
TcpClient client = await listener.AcceptTcpClientAsync();
|
|
||||||
// 处理客户端连接
|
|
||||||
_ = Task.Run(() => HandleClientAsync(client));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"GPS error:{ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 发送GPS数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task HandleClientAsync(TcpClient client)
|
|
||||||
{
|
|
||||||
|
|
||||||
string receivedData = string.Empty;
|
|
||||||
using (NetworkStream stream = client.GetStream())
|
|
||||||
{
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int bytesRead;
|
|
||||||
|
|
||||||
// 持续读取数据直到客户端断开连接
|
|
||||||
while ((bytesRead = await stream.ReadAsync(buffer, 0, buffer.Length)) != 0)
|
|
||||||
{
|
|
||||||
// 将字节数据转换为字符串
|
|
||||||
receivedData = Encoding.UTF8.GetString(buffer, 0, bytesRead);
|
|
||||||
Console.WriteLine($" gps Received: {receivedData}");
|
|
||||||
|
|
||||||
|
|
||||||
var json = Newtonsoft.Json.JsonConvert.DeserializeObject<GpsHistoryDTO>(receivedData);
|
|
||||||
var _service = ServiceLocator.Instance.GetService<GpsHistoryService>();
|
|
||||||
await _service.AddGpsHistory(json);
|
|
||||||
// 发送响应给客户端
|
|
||||||
string response = "Data received";
|
|
||||||
byte[] responseData = Encoding.UTF8.GetBytes(response);
|
|
||||||
await stream.WriteAsync(responseData, 0, responseData.Length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// client.Close();
|
|
||||||
Console.WriteLine("Client disconnected.");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +1,6 @@
|
||||||
using IceCoffee.FastSocket.Tcp;
|
using IceCoffee.FastSocket.Tcp;
|
||||||
using JT808.Protocol;
|
|
||||||
using JT808.Protocol.Extensions;
|
|
||||||
using JT808.Protocol.MessageBody;
|
|
||||||
using langguanApi.Common.Gps;
|
|
||||||
using langguanApi.Model;
|
using langguanApi.Model;
|
||||||
using Npoi.Mapper;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using static langguanApi.Common.Gps.ProtocolParser;
|
|
||||||
|
|
||||||
namespace langguanApi.Service.HJ212
|
namespace langguanApi.Service.HJ212
|
||||||
{
|
{
|
||||||
|
|
@ -38,12 +31,11 @@ namespace langguanApi.Service.HJ212
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void OnReceived()
|
protected override void OnReceived()
|
||||||
{
|
{
|
||||||
|
if (ReadBuffer.IndexOf(35) != 0L)// '#'
|
||||||
//if (ReadBuffer.IndexOf(35) != 0L)// '#'
|
{
|
||||||
//{
|
return;
|
||||||
// return;
|
// throw new Exception("异常TCP连接 IP: " + RemoteIPEndPoint);
|
||||||
// // throw new Exception("异常TCP连接 IP: " + RemoteIPEndPoint);
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
string rawText = null;
|
string rawText = null;
|
||||||
while (ReadBuffer.CanReadLine)
|
while (ReadBuffer.CanReadLine)
|
||||||
|
|
@ -51,40 +43,6 @@ namespace langguanApi.Service.HJ212
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
byte[] data = ReadBuffer.ReadLine();
|
byte[] data = ReadBuffer.ReadLine();
|
||||||
//Console.WriteLine($"原始数据:{data}----------");
|
|
||||||
//Console.WriteLine($"原始数据HexString:{data.ToHexString()}--------------------");
|
|
||||||
//Console.WriteLine($"原始数据ASCII:{Encoding.ASCII.GetString(data)}-");
|
|
||||||
|
|
||||||
//Position position = ParsePosition(data);
|
|
||||||
|
|
||||||
//Console.WriteLine($"Latitude: {position.Latitude}");
|
|
||||||
//Console.WriteLine($"Longitude: {position.Longitude}");
|
|
||||||
//Console.WriteLine($"Altitude: {position.Altitude}");
|
|
||||||
//int offset = 0;
|
|
||||||
//// 解析消息头
|
|
||||||
//var header = ProtocolParser.ParseHeader(data, ref offset);
|
|
||||||
//Console.WriteLine($"Message ID: {header.MessageId}, Terminal ID: {header.TerminalId}");
|
|
||||||
|
|
||||||
//// 解析终端注册消息
|
|
||||||
//var registerMessage = ProtocolParser.ParseTerminalRegisterMessage(data, ref offset);
|
|
||||||
//Console.WriteLine($"Province ID: {registerMessage.ProvinceId}, City ID: {registerMessage.CityId}");
|
|
||||||
//Console.WriteLine($"License Plate: {registerMessage.LicensePlate}");
|
|
||||||
|
|
||||||
// offset = 0;
|
|
||||||
//// 解析位置信息汇报消息
|
|
||||||
//var locationReportMessage = ProtocolParser.ParseLocationReportMessage(data, ref offset);
|
|
||||||
//Console.WriteLine($"Latitude: {locationReportMessage.Latitude}, Longitude: {locationReportMessage.Longitude}");
|
|
||||||
//Console.WriteLine($"Speed: {locationReportMessage.Speed}, Time: {locationReportMessage.Time}");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//var jT808Package = new JT808Serializer().Deserialize(data);
|
|
||||||
////4.数据包体
|
|
||||||
//JT808_0x0200 jT808_0x0200 = (JT808_0x0200)jT808Package.Bodies;
|
|
||||||
//var lon = jT808_0x0200.Lat;
|
|
||||||
//var lat = jT808_0x0200.Lng;
|
|
||||||
//Console.WriteLine("经度:" + lon + " 纬度:" + lat);
|
|
||||||
rawText = Encoding.UTF8.GetString(data);
|
rawText = Encoding.UTF8.GetString(data);
|
||||||
NetPackage netPackage = NetPackage.Parse(rawText, GetUnpackCache);
|
NetPackage netPackage = NetPackage.Parse(rawText, GetUnpackCache);
|
||||||
((NetServer)Server).RaiseReceivedData(this, netPackage, rawText);
|
((NetServer)Server).RaiseReceivedData(this, netPackage, rawText);
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,9 @@ namespace langguanApi.Service
|
||||||
public class HJ212SocketServer
|
public class HJ212SocketServer
|
||||||
{
|
{
|
||||||
private Hj212Service _hj212Service;
|
private Hj212Service _hj212Service;
|
||||||
private DeviceService _deviceService;
|
public HJ212SocketServer(Hj212Service hj212Service)
|
||||||
public HJ212SocketServer(Hj212Service hj212Service, DeviceService deviceService)
|
|
||||||
{
|
{
|
||||||
_hj212Service = hj212Service;
|
_hj212Service = hj212Service;
|
||||||
_deviceService = deviceService;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缓冲器
|
/// 缓冲器
|
||||||
|
|
@ -68,8 +66,6 @@ namespace langguanApi.Service
|
||||||
server.SendData += OnNetServer_SendData;
|
server.SendData += OnNetServer_SendData;
|
||||||
server.Start();
|
server.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OnNetServer_Started()
|
private void OnNetServer_Started()
|
||||||
{
|
{
|
||||||
Console.WriteLine($"开始监听: {ip}:{port}");
|
Console.WriteLine($"开始监听: {ip}:{port}");
|
||||||
|
|
@ -94,49 +90,15 @@ namespace langguanApi.Service
|
||||||
{
|
{
|
||||||
Console.WriteLine("收到自: " + session.RemoteIPEndPoint + ": " + rawText);
|
Console.WriteLine("收到自: " + session.RemoteIPEndPoint + ": " + rawText);
|
||||||
HJ212_2017 hj = new HJ212_2017();
|
HJ212_2017 hj = new HJ212_2017();
|
||||||
// st 27 =voc,st=31 cems, st=32,tsp, st=22 微站
|
|
||||||
if (hj.DecodeData(rawText))
|
if (hj.DecodeData(rawText))
|
||||||
{
|
{
|
||||||
var body = JsonConvert.SerializeObject(hj.CP);
|
var body = JsonConvert.SerializeObject(hj.CP);
|
||||||
|
|
||||||
Console.WriteLine("解析成功: " + body);
|
|
||||||
var entity = JsonConvert.DeserializeObject<Model.HJ212>(body);
|
var entity = JsonConvert.DeserializeObject<Model.HJ212>(body);
|
||||||
entity.deviceMN = hj.DATA_HEAD["MN"];
|
entity.deviceMN = hj.DATA_HEAD["MN"];
|
||||||
entity.ST = int.Parse(hj.DATA_HEAD["ST"]);
|
|
||||||
entity.CN = int.Parse(hj.DATA_HEAD["CN"]);
|
|
||||||
int deviceType = SetDeviceType(hj.DATA_HEAD["ST"]);
|
|
||||||
if (entity.a34001 > 0 && deviceType == 3)
|
|
||||||
{
|
|
||||||
deviceType = 5;
|
|
||||||
}
|
|
||||||
await _deviceService.Add(new DeviceAddDto
|
|
||||||
{
|
|
||||||
deviceMN = hj.DATA_HEAD["MN"],
|
|
||||||
DeviceType = deviceType,
|
|
||||||
Ip = session.RemoteIPEndPoint.ToString(),
|
|
||||||
});
|
|
||||||
//校验通过,开始入库
|
//校验通过,开始入库
|
||||||
await _hj212Service.Add(entity, session.RemoteIPEndPoint.ToString());
|
await _hj212Service.Add(entity, session.RemoteIPEndPoint.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 设置设备类型
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="st"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private int SetDeviceType(string st)
|
|
||||||
{
|
|
||||||
//st 27 =voc,st=31 cems, st=22,微站,( st=22&&a34001>0 tsp)
|
|
||||||
//1 voc,2 cems,3,tsp,4 video
|
|
||||||
switch (st)
|
|
||||||
{
|
|
||||||
case "27": return 1;
|
|
||||||
case "31": return 2;
|
|
||||||
case "22": return 3;
|
|
||||||
// case "33": return 4;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
private void OnNetServer_ExceptionCaught(Exception ex)
|
private void OnNetServer_ExceptionCaught(Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Error in NetServer" + ex);
|
Console.WriteLine("Error in NetServer" + ex);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,7 @@
|
||||||
using langguanApi.Extensions.AutoDI;
|
using langguanApi.Extensions.AutoDI;
|
||||||
using langguanApi.Model;
|
using langguanApi.Model;
|
||||||
using langguanApi.Model.Dto;
|
using langguanApi.Model.Dto;
|
||||||
using MongoDB.Bson;
|
|
||||||
using MongoDB.Driver;
|
|
||||||
using NPOI.HSSF.Record;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
namespace langguanApi.Service
|
||||||
{
|
{
|
||||||
|
|
@ -19,147 +14,6 @@ namespace langguanApi.Service
|
||||||
_deviceSerive = deviceSerive;
|
_deviceSerive = deviceSerive;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 首页数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="day"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<object> GetIndexData(int day = 7)
|
|
||||||
{
|
|
||||||
var now = DateTime.UtcNow; // 获取当前时间(UTC)
|
|
||||||
var sevenDaysAgo = now.AddDays(-2); // 计算 7 天前的时间
|
|
||||||
var pipeline = new[]
|
|
||||||
{
|
|
||||||
new BsonDocument("$match", new BsonDocument
|
|
||||||
{
|
|
||||||
{ "CreateDateTime", new BsonDocument { { "$gte", sevenDaysAgo }, { "$lt", now } } }
|
|
||||||
}),
|
|
||||||
new BsonDocument("$project", new BsonDocument
|
|
||||||
{
|
|
||||||
{ "date", new BsonDocument("$dateToString", new BsonDocument { { "format", "%m-%d" }, { "date", "$CreateDateTime" } }) },
|
|
||||||
{ "a34001", 1 },
|
|
||||||
{ "a34002", 1 },
|
|
||||||
{ "a34004", 1 }
|
|
||||||
}),
|
|
||||||
new BsonDocument("$group", new BsonDocument
|
|
||||||
{
|
|
||||||
{ "_id", "$date" },
|
|
||||||
{ "a34001", new BsonDocument("$sum", "$a34001") },
|
|
||||||
{ "a34002", new BsonDocument("$sum", "$a34002") },
|
|
||||||
{ "a34004", new BsonDocument("$sum", "$a34004") }
|
|
||||||
}),
|
|
||||||
new BsonDocument("$sort", new BsonDocument { { "_id", 1 } }) // 按日期排序
|
|
||||||
};
|
|
||||||
|
|
||||||
var temp = await base.GetGroupedResultsAsync(pipeline);
|
|
||||||
List<object> result = new List<object>();
|
|
||||||
foreach (var item in temp)
|
|
||||||
{
|
|
||||||
result.Add(new
|
|
||||||
{
|
|
||||||
date = item["_id"].ToString(),
|
|
||||||
a34001 = Math.Round(item["a34001"].ToDouble(), 2),
|
|
||||||
a34002 = Math.Round(item["a34002"].ToDouble(), 2),
|
|
||||||
a34004 = Math.Round(item["a34004"].ToDouble(), 2)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 今日排放数据
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<object> GetTodayData()
|
|
||||||
{
|
|
||||||
|
|
||||||
// Expression<Func<Model.HJ212, bool>> exp = filter => filter.CreateDateTime >= DateTime.Now.AddDays(-7);
|
|
||||||
// CN = 2031是日数据
|
|
||||||
var dateFilter = BuildFilter(DateTime.Now.Date);
|
|
||||||
// 构建查询
|
|
||||||
var conditionFilter = Builders<Model.HJ212>.Filter.Or(
|
|
||||||
Builders<Model.HJ212>.Filter.Eq(x => x.ST, 31),
|
|
||||||
Builders<Model.HJ212>.Filter.And(
|
|
||||||
Builders<Model.HJ212>.Filter.Eq(x => x.ST, 27),
|
|
||||||
Builders<Model.HJ212>.Filter.Eq(x => x.CN, 2031)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
var finalFilter = Builders<Model.HJ212>.Filter.And(dateFilter, conditionFilter);
|
|
||||||
var result = await base.FindListyFilter(finalFilter);
|
|
||||||
// 过滤掉voc设备
|
|
||||||
var voc = result.Where(s => s.ST == 31).ToList().Select(s => s.a05002_Cou +
|
|
||||||
s.a24087_Cou +
|
|
||||||
s.a24088_Cou +
|
|
||||||
s.a25002_Cou +
|
|
||||||
s.a25003_Cou +
|
|
||||||
s.a25005_Cou +
|
|
||||||
s.a00000_Cou).Sum();
|
|
||||||
var cems = result.Where(s => s.ST == 27).ToList().Select(s => s.a21002_Cou +
|
|
||||||
s.a21026_Cou +
|
|
||||||
s.a34013_Cou +
|
|
||||||
s.a00000_Cou).Sum();
|
|
||||||
return new
|
|
||||||
{
|
|
||||||
today = new { voc, cems },
|
|
||||||
week = await GetWeekData()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 一周之内的排放数据
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<object> GetWeekData()
|
|
||||||
{
|
|
||||||
// Expression<Func<Model.HJ212, bool>> exp = filter => filter.CreateDateTime >= DateTime.Now.AddDays(-7);
|
|
||||||
// CN = 2031是日数据
|
|
||||||
var dateFilter = Builders<Model.HJ212>.Filter.Gte(x => x.CreateDateTime, DateTime.Now.AddDays(-7));
|
|
||||||
|
|
||||||
// 构建查询
|
|
||||||
var conditionFilter = Builders<Model.HJ212>.Filter.Or(
|
|
||||||
Builders<Model.HJ212>.Filter.Eq(x => x.ST, 31),
|
|
||||||
Builders<Model.HJ212>.Filter.And(
|
|
||||||
Builders<Model.HJ212>.Filter.Eq(x => x.ST, 27),
|
|
||||||
Builders<Model.HJ212>.Filter.Eq(x => x.CN, 2031)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
// 组合过滤器(先按时间,再按其他条件)
|
|
||||||
var finalFilter = Builders<Model.HJ212>.Filter.And(dateFilter, conditionFilter);
|
|
||||||
var result = await base.FindListyFilter(finalFilter);
|
|
||||||
////a21026_Cou,a21002_Cou,a34013_Cou
|
|
||||||
var cems = result.Where(s => s.ST == 31).Select(s => new
|
|
||||||
{
|
|
||||||
s.a21002_Cou,
|
|
||||||
s.a21026_Cou,
|
|
||||||
s.a34013_Cou,
|
|
||||||
s.a00000_Cou,
|
|
||||||
date = s.CreateDateTime.ToString("MM-dd")
|
|
||||||
}).GroupBy(g => g.date).Select(s => new
|
|
||||||
{
|
|
||||||
s.Key,
|
|
||||||
value = Math.Round(s.Sum(t => t.a21002_Cou + t.a21026_Cou + t.a34013_Cou + t.a00000_Cou))
|
|
||||||
});
|
|
||||||
//voc
|
|
||||||
var voc = result.Where(s => s.ST == 27).Select(s => new
|
|
||||||
{
|
|
||||||
s.a05002_Cou,
|
|
||||||
s.a24087_Cou,
|
|
||||||
s.a24088_Cou,
|
|
||||||
s.a25002_Cou,
|
|
||||||
s.a25003_Cou,
|
|
||||||
s.a25005_Cou,
|
|
||||||
s.a00000_Cou,
|
|
||||||
date = s.CreateDateTime.ToString("MM-dd")
|
|
||||||
}).GroupBy(g => g.date).Select(s => new
|
|
||||||
{
|
|
||||||
s.Key,
|
|
||||||
value = Math.Round(s.Sum(t => t.a05002_Cou + t.a24087_Cou + t.a24088_Cou + t.a25002_Cou + t.a25005_Cou + t.a00000_Cou))
|
|
||||||
});
|
|
||||||
return new { voc, cems };
|
|
||||||
}
|
|
||||||
private FilterDefinition<Model.HJ212> BuildFilter(DateTime end)
|
|
||||||
{
|
|
||||||
return Builders<Model.HJ212>.Filter.Gte(x => x.CreateDateTime, end);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 新加数据
|
/// 新加数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hJ212"></param>
|
/// <param name="hJ212"></param>
|
||||||
|
|
@ -167,18 +21,14 @@ namespace langguanApi.Service
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task Add(Model.HJ212 hJ212, string deviceIp)
|
public async Task Add(Model.HJ212 hJ212, string deviceIp)
|
||||||
{
|
{
|
||||||
////判断设备类型 tsp 会有经纬度数据
|
//先判断当前设备是否存在
|
||||||
// int deviceType = 1;//设备类型为1 =voc
|
await _deviceSerive.Add(new DeviceAddDto()
|
||||||
|
{
|
||||||
////先判断当前设备是否存在
|
deviceMN = hJ212.deviceMN,
|
||||||
//await _deviceSerive.Add(new DeviceAddDto()
|
Ip = deviceIp,
|
||||||
//{
|
lat = hJ212.lat,
|
||||||
// deviceMN = hJ212.deviceMN,
|
lng = hJ212.lng,
|
||||||
// Ip = deviceIp,
|
});
|
||||||
// lat = hJ212.lat,
|
|
||||||
// lng = hJ212.lng,
|
|
||||||
// DeviceType = deviceType
|
|
||||||
//});
|
|
||||||
await base.CreateAsync(hJ212);
|
await base.CreateAsync(hJ212);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -186,7 +36,7 @@ namespace langguanApi.Service
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hours"></param>
|
/// <param name="hours"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<List<Model.HJ212>> GetViewTop(int hours = -5)
|
public async Task<List<Model.HJ212>> GetViewTop(int hours = -10)
|
||||||
{
|
{
|
||||||
var date = DateTime.Now.AddHours(-8).AddHours(hours);
|
var date = DateTime.Now.AddHours(-8).AddHours(hours);
|
||||||
Expression<Func<Model.HJ212, bool>> exp = filter => filter.CreateDateTime >= date;
|
Expression<Func<Model.HJ212, bool>> exp = filter => filter.CreateDateTime >= date;
|
||||||
|
|
@ -199,7 +49,7 @@ namespace langguanApi.Service
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="deviceMn"></param>
|
/// <param name="deviceMn"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<object> GetViewByDeviceMn(string deviceMn)
|
public async Task<object>GetViewByDeviceMn(string deviceMn)
|
||||||
{
|
{
|
||||||
Expression<Func<Model.HJ212, bool>> exp = filter => filter.deviceMN == deviceMn;
|
Expression<Func<Model.HJ212, bool>> exp = filter => filter.deviceMN == deviceMn;
|
||||||
var result = (await base.GetListWithExp(exp)).OrderByDescending(s => s.CreateDateTime).Take(60).ToList();
|
var result = (await base.GetListWithExp(exp)).OrderByDescending(s => s.CreateDateTime).Take(60).ToList();
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,6 @@ using langguanApi.Common;
|
||||||
using langguanApi.Extensions.AutoDI;
|
using langguanApi.Extensions.AutoDI;
|
||||||
using langguanApi.Model;
|
using langguanApi.Model;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using langguanApi.Common.Proxy;
|
|
||||||
using langguanApi.Model.Dto;
|
|
||||||
using Npoi.Mapper;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
namespace langguanApi.Service
|
||||||
{
|
{
|
||||||
|
|
@ -21,8 +18,6 @@ namespace langguanApi.Service
|
||||||
private CacheManager _cacheManager;
|
private CacheManager _cacheManager;
|
||||||
private readonly WeatherService _weatherService;
|
private readonly WeatherService _weatherService;
|
||||||
private readonly AlertService _alertService;
|
private readonly AlertService _alertService;
|
||||||
private readonly DetectionService _detectionService;
|
|
||||||
private HttpProxy _httpProxy;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// HomeService
|
/// HomeService
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -30,8 +25,7 @@ namespace langguanApi.Service
|
||||||
/// <param name="hj212Service"></param>
|
/// <param name="hj212Service"></param>
|
||||||
public HomeService(DeviceService device, Hj212Service hj212Service,
|
public HomeService(DeviceService device, Hj212Service hj212Service,
|
||||||
IConfiguration configuration, CacheManager cacheManager,
|
IConfiguration configuration, CacheManager cacheManager,
|
||||||
WeatherService weatherService, AlertService alertService,
|
WeatherService weatherService, AlertService alertService)
|
||||||
DetectionService detectionService, HttpProxy httpProxy)
|
|
||||||
{
|
{
|
||||||
_deviceService = device;
|
_deviceService = device;
|
||||||
_hj212Service = hj212Service;
|
_hj212Service = hj212Service;
|
||||||
|
|
@ -39,8 +33,6 @@ namespace langguanApi.Service
|
||||||
_cacheManager = cacheManager;
|
_cacheManager = cacheManager;
|
||||||
_weatherService = weatherService;
|
_weatherService = weatherService;
|
||||||
_alertService = alertService;
|
_alertService = alertService;
|
||||||
_detectionService = detectionService;
|
|
||||||
_httpProxy = httpProxy;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// view
|
/// view
|
||||||
|
|
@ -48,49 +40,21 @@ namespace langguanApi.Service
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ApiResult> View()
|
public async Task<ApiResult> View()
|
||||||
{
|
{
|
||||||
Expression<Func<Device, bool>> exp = x => x.IsDelete == false && x.lng > 0 && x.lat > 0;
|
var devices = await _deviceService.GetAsync();
|
||||||
var devices = (await _deviceService.GetListWithExp(exp)).ToList();
|
var ariQuality = "";
|
||||||
var cleanData = new
|
var cleanData = new
|
||||||
{
|
{
|
||||||
Yesterday = 0.8,
|
Yesterday = 0.8,
|
||||||
LastWeek = 0.6,
|
LastWeek = 0.6,
|
||||||
};
|
};
|
||||||
// 首页热力图
|
|
||||||
var hotmap = new { };
|
Expression<Func<Model.HJ212, bool>> filter = exp => true;
|
||||||
// 首页设备报警数据
|
var Realtime = await _hj212Service.Realtime();
|
||||||
|
var getViewTop = await _hj212Service.GetViewTop();
|
||||||
var alerts = await _alertService.IndexData();
|
var alerts = await _alertService.IndexData();
|
||||||
// 首页设备检测数据
|
|
||||||
var detections = await _detectionService.GetIndexData();
|
|
||||||
// 获取天气信息,缓存1小时,如果不存在,则调用WeatherService获取
|
// 获取天气信息,缓存1小时,如果不存在,则调用WeatherService获取
|
||||||
Func<Task<object>> getWeatherFunc = async () => await _weatherService.GetWeather();
|
Func<Task<object>> getWeatherFunc = async () => await _weatherService.GetWeather();
|
||||||
var weather = await _cacheManager.GetConvertVale(RedisKeylist.Weather, getWeatherFunc, 60 * 60 * 24 * 30);
|
var weather = await _cacheManager.GetConvertVale(RedisKeylist.Weather, getWeatherFunc, 60 * 60);
|
||||||
// 获取空气质量,缓存2小时,如果不存在,则调用WeatherService获取
|
|
||||||
Func<Task<object>> getAriQualityFunc = async () => await _weatherService.GetAirQuality();
|
|
||||||
var ariQuality = await _cacheManager.GetConvertVale(RedisKeylist.AriQuality, getAriQualityFunc, 60 * 60 * 24 * 30);
|
|
||||||
Func<Task<object>> getTrendFunc = async () => await _hj212Service.GetIndexData();
|
|
||||||
var trend = await _cacheManager.GetConvertVale(RedisKeylist.Trend, getTrendFunc, 60 * 60 * 24 * 30);
|
|
||||||
// 获取远程接口污染物排放率
|
|
||||||
var rateResp = await _httpProxy.Get<RespModel<List<Rate>>>(null, _configuration.GetValue<string>("Apis:RateUrl"));
|
|
||||||
var rate = rateResp.data.ToList().Take(6);
|
|
||||||
rate.ForEach(x => x.val = Math.Round(x.val / 100, 2));
|
|
||||||
var AlermResp = await _httpProxy.Get<RespModel<alarmList>>(null, _configuration.GetValue<string>("Apis:AlertUrl"));
|
|
||||||
if (AlermResp.code == 0 && AlermResp.data.List.Any())
|
|
||||||
{
|
|
||||||
alerts.AddRange(AlermResp.data.List);
|
|
||||||
}
|
|
||||||
// alerts += await _httpProxy.Get<string>(null, _configuration.GetValue<string>("Apis:AlertUrl"));
|
|
||||||
// alerts += await _httpProxy.Get<string>(null, _configuration.GetValue<string>("Apis:RateUrl"));
|
|
||||||
|
|
||||||
//首页清洁运输比例
|
|
||||||
var cleaData = new
|
|
||||||
{
|
|
||||||
yesterday = 0.8,
|
|
||||||
lastWeek = 0.6
|
|
||||||
};
|
|
||||||
// var today1 = await _hj212Service.GetTodayData();
|
|
||||||
Func<Task<object>> getTodayFunc = async () => await _hj212Service.GetTodayData();
|
|
||||||
var today = await _cacheManager.GetConvertVale(RedisKeylist.Today, getTodayFunc, 60 * 60 * 24 * 1);
|
|
||||||
|
|
||||||
return new ApiResult
|
return new ApiResult
|
||||||
{
|
{
|
||||||
code = 0,
|
code = 0,
|
||||||
|
|
@ -105,18 +69,12 @@ namespace langguanApi.Service
|
||||||
},
|
},
|
||||||
title = _configuration.GetValue<string>("Home:Title"),
|
title = _configuration.GetValue<string>("Home:Title"),
|
||||||
},
|
},
|
||||||
|
|
||||||
devices,
|
devices,
|
||||||
hotmap,
|
|
||||||
weather,
|
|
||||||
ariQuality,
|
ariQuality,
|
||||||
rate,
|
Realtime,
|
||||||
trend,
|
getViewTop,
|
||||||
alerts,
|
weather,
|
||||||
cleanData,
|
alerts
|
||||||
today,
|
|
||||||
getViewTop = "",
|
|
||||||
detections
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using MathNet.Numerics.Distributions;
|
||||||
using Npoi.Mapper;
|
using Npoi.Mapper;
|
||||||
using Org.BouncyCastle.Asn1.IsisMtt.X509;
|
using Org.BouncyCastle.Asn1.IsisMtt.X509;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
namespace langguanApi.Service
|
||||||
{
|
{
|
||||||
|
|
@ -24,41 +23,33 @@ namespace langguanApi.Service
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task AddLedger(AddLedgerDto input)
|
public async Task AddLedger(LedgerDTO input)
|
||||||
{
|
{
|
||||||
var enity = input.Adapt<Ledger>();
|
var enity = input.Adapt<Ledger>();
|
||||||
enity.CarNum = input.CarNumber;
|
|
||||||
enity.Emissions = input.EmissionLevel;
|
|
||||||
await base.CreateAsync(enity);
|
await base.CreateAsync(enity);
|
||||||
}
|
}
|
||||||
public async Task<object> HeaderCount()
|
|
||||||
{
|
|
||||||
return new { t1 = 100, t2 = 200, t3 = 300, t4 = 400 };
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 导出数据
|
/// 导出数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="start"></param>
|
/// <param name="start"></param>
|
||||||
/// <param name="end"></param>
|
/// <param name="end"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<byte[]> Export(DateTime? start, DateTime? end)
|
public async Task<byte[]> Export(DateTime start, DateTime end)
|
||||||
{
|
{
|
||||||
start = start.HasValue ? start.Value : DateTime.Now.AddDays(-7);
|
|
||||||
end = end.HasValue ? end : DateTime.Now.AddDays(1);
|
|
||||||
Expression<Func<Ledger, bool>> exp = filter =>
|
Expression<Func<Ledger, bool>> exp = filter =>
|
||||||
filter.CreateDateTime >= start.Value && filter.CreateDateTime <= end.Value && filter.IsDelete == false;
|
filter.CreateDateTime >= start && filter.CreateDateTime <= end && filter.IsDelete == false;
|
||||||
var list = (await base.GetListWithExp(exp)).ToList();
|
var list = await base.GetListWithExp(exp);
|
||||||
var mapper = new Mapper();
|
var mapper = new Mapper();
|
||||||
mapper.Map<Ledger>("进出场时间", s => s.Time)
|
mapper.Map<Ledger>("进场时间", s => s.InTime)
|
||||||
.Map<Ledger>("车牌号", s => s.CarNum)
|
.Map<Ledger>("车牌号", s => s.CarNum)
|
||||||
.Map<Ledger>("车型", s => s.CarModel)
|
.Map<Ledger>("车型", s => s.CarModel)
|
||||||
.Map<Ledger>("是否新能源", s => s.NewCar)
|
.Map<Ledger>("新能源", s => s.NewCar ? "是" : "否")
|
||||||
.Map<Ledger>("燃油车", s => s.Emissions)
|
.Map<Ledger>("燃油车", s => s.Emissions)
|
||||||
.Map<Ledger>("出厂日间 ", s => s.OutTime)
|
.Map<Ledger>("出厂日间 ", s => s.OutTime)
|
||||||
.Format<Ledger>("yyyy-MM-dd HH:mm:ss", s => s.InTime)
|
.Format<Ledger>("yyyy-MM-dd HH:mm:ss", s => s.InTime)
|
||||||
.Format<Ledger>("yyyy-MM-dd HH:mm:ss", s => s.OutTime);
|
.Format<Ledger>("yyyy-MM-dd HH:mm:ss", s => s.OutTime);
|
||||||
MemoryStream stream = new MemoryStream();
|
MemoryStream stream = new MemoryStream();
|
||||||
mapper.Save(stream, list, sheetName: "sheet1", leaveOpen: true);
|
mapper.Save(stream, list.ToList(), sheetName: "sheet1", leaveOpen: true);
|
||||||
return stream.ToArray();
|
return stream.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
using langguanApi.Common.Proxy;
|
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
using langguanApi.Model;
|
|
||||||
using langguanApi.Model.Entity;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 日志服务
|
|
||||||
/// </summary>
|
|
||||||
[ServiceInjection(InjectionType.Transient)]
|
|
||||||
public class LogService : BaseService<LogEntity>
|
|
||||||
{
|
|
||||||
private readonly IConfiguration _configuration;
|
|
||||||
/// <summary>
|
|
||||||
/// 日志服务
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="config"></param>
|
|
||||||
public LogService(IConfiguration config) : base(config, nameof(LogEntity))
|
|
||||||
{
|
|
||||||
_configuration = config;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 添加日志
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="log"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task addLog(LogEntity log)
|
|
||||||
{
|
|
||||||
await base.CreateAsync(log);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -27,9 +27,26 @@ namespace langguanApi.Service
|
||||||
/// <param name="menu">菜单实体</param>
|
/// <param name="menu">菜单实体</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ApiResult> AddMenu(AddMenuDto menu)
|
public async Task<ApiResult> AddMenu(AddMenuDto menu)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var entity = menu.Adapt<Menu>();
|
var entity = menu.Adapt<Menu>();
|
||||||
await base.CreateAsync(entity);
|
await base.CreateAsync(entity);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
_logger.LogError($"新增菜单出现异常,请求参数:{Newtonsoft.Json.JsonConvert.SerializeObject(menu)}," +
|
||||||
|
$"请求接口:'api/Menu/AddMenu'," +
|
||||||
|
$"异常信息:{ex.Message}," +
|
||||||
|
$"异常位置:{ex.StackTrace}"
|
||||||
|
);
|
||||||
|
return new ApiResult { code = 1, msg = "保存菜单失败", data = false };
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"新增菜单参数:menu:{Newtonsoft.Json.JsonConvert.SerializeObject(menu)}");
|
||||||
|
}
|
||||||
return new ApiResult { code = 0, msg = "保存菜单信息成功", data = true };
|
return new ApiResult { code = 0, msg = "保存菜单信息成功", data = true };
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -39,27 +56,44 @@ namespace langguanApi.Service
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ApiResult> UpdateMenu(UpdateMenuDto menu)
|
public async Task<ApiResult> UpdateMenu(UpdateMenuDto menu)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(menu.Id))
|
||||||
|
{
|
||||||
|
return new ApiResult() { code = 0, data = false, msg = "更新菜单失败,Id不能为空" };
|
||||||
|
}
|
||||||
var entity = menu.Adapt<Menu>();
|
var entity = menu.Adapt<Menu>();
|
||||||
await base.UpdateAsync(entity.Id, entity);
|
await base.UpdateAsync(entity.Id, entity);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
_logger.LogError($"修改菜单出现异常,请求参数:{Newtonsoft.Json.JsonConvert.SerializeObject(menu)}," +
|
||||||
|
$"请求接口:'api/Menu/UpdateMenu'," +
|
||||||
|
$"异常信息:{ex.Message}," +
|
||||||
|
$"异常位置:{ex.StackTrace}"
|
||||||
|
);
|
||||||
|
return new ApiResult { code = 1, msg = "保存菜单失败", data = false };
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"修改菜单参数:menu:{Newtonsoft.Json.JsonConvert.SerializeObject(menu)}");
|
||||||
|
}
|
||||||
return new ApiResult() { code = 0, data = true, msg = "更新菜单成功" };
|
return new ApiResult() { code = 0, data = true, msg = "更新菜单成功" };
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取菜单树
|
/// 获取菜单树
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ApiResult> GetMenuTree()
|
public async Task<ApiResult> Pager(reqpage input)
|
||||||
{
|
|
||||||
var result = await GetMenuTreeList();
|
|
||||||
return new ApiResult() { data = result };
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 获取菜单树
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<List<MenuTreeDto>> GetMenuTreeList()
|
|
||||||
{
|
{
|
||||||
List<MenuTreeDto> dto = new List<MenuTreeDto>();
|
List<MenuTreeDto> dto = new List<MenuTreeDto>();
|
||||||
var MenuList = await GetChildList("0");
|
try
|
||||||
|
{
|
||||||
|
var MenuList = await GetChildList("0");//获取跟节点
|
||||||
|
if (MenuList.Any())
|
||||||
|
{
|
||||||
foreach (var item in MenuList)
|
foreach (var item in MenuList)
|
||||||
{
|
{
|
||||||
dto.Add(new MenuTreeDto()
|
dto.Add(new MenuTreeDto()
|
||||||
|
|
@ -72,7 +106,49 @@ namespace langguanApi.Service
|
||||||
Children = await GetChildList(item.Id)
|
Children = await GetChildList(item.Id)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return dto;
|
//筛选数据
|
||||||
|
if (!string.IsNullOrEmpty(input.key))
|
||||||
|
{
|
||||||
|
if (dto.Exists(p => p.Name == input.key) ||
|
||||||
|
dto.Exists(p => p.Children.Exists(c => c.Name == input.key)) ||
|
||||||
|
dto.Exists(p => p.ParentName == input.key))
|
||||||
|
{
|
||||||
|
if (dto.Exists(p => p.Name == input.key))
|
||||||
|
{
|
||||||
|
dto = dto.Where(p => p.Name == input.key).ToList();
|
||||||
|
}
|
||||||
|
else if (dto.Exists(p => p.Children.Exists(c => c.Name == input.key)))
|
||||||
|
{
|
||||||
|
dto = dto.SelectMany(p => p.Children).Where(p => p.Name == input.key).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dto = dto.SelectMany(p => p.Children).Where(p => p.ParentName == input.key).ToList();
|
||||||
|
}
|
||||||
|
return new ApiResult() { code = 0, data = dto, msg = "获取菜单列表" };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new ApiResult() { code = 0, data = null, msg = "获取菜单列表不存在" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
_logger.LogError($"获取菜单列表出现异常,请求参数:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}," +
|
||||||
|
$"请求接口:'api/Menu/Pager'," +
|
||||||
|
$"异常信息:{ex.Message}," +
|
||||||
|
$"异常位置:{ex.StackTrace}"
|
||||||
|
);
|
||||||
|
return new ApiResult { code = 1, msg = "获取菜单列表失败", data = false };
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"获取菜单列表参数:menu:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}");
|
||||||
|
}
|
||||||
|
return new ApiResult() { code = 0, data = dto, msg = "获取菜单列表" };
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 递归获取子菜单列表
|
/// 递归获取子菜单列表
|
||||||
|
|
@ -82,10 +158,13 @@ namespace langguanApi.Service
|
||||||
public async Task<List<MenuTreeDto>> GetChildList(string parentId)
|
public async Task<List<MenuTreeDto>> GetChildList(string parentId)
|
||||||
{
|
{
|
||||||
Expression<Func<Menu, bool>> exp = filter => filter.IsDelete == false && filter.ParentId == parentId;
|
Expression<Func<Menu, bool>> exp = filter => filter.IsDelete == false && filter.ParentId == parentId;
|
||||||
|
Expression<Func<Menu, bool>> expDataSource = filter => filter.IsDelete;
|
||||||
var list = (await GetListWithExp(exp))
|
var list = (await GetListWithExp(exp))
|
||||||
.OrderBy(x => x.Sort)
|
.OrderBy(x => x.Sort)
|
||||||
.ToList().Adapt<List<MenuTreeDto>>();
|
.ToList().Adapt<List<MenuTreeDto>>();
|
||||||
var DataSourceList = (await GetAsync()).ToList();//拿到所有数据源,筛选结果
|
var DataSourceList = (await GetAsync())
|
||||||
|
.OrderBy(x => x.Sort)
|
||||||
|
.ToList();//拿到所有数据源,筛选结果
|
||||||
foreach (var item in list)
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
item.Children = await GetChildList(item.Id);
|
item.Children = await GetChildList(item.Id);
|
||||||
|
|
@ -96,11 +175,13 @@ namespace langguanApi.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 作废菜单 (废弃,不做处理)
|
/// 作废菜单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">当前菜单id</param>
|
/// <param name="id">当前菜单id</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ApiResult> DeleteMenu(string id)
|
public async Task<ApiResult> DeleteMenu(string id)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var entity = await base.GetAsync(id);
|
var entity = await base.GetAsync(id);
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
|
|
@ -109,6 +190,21 @@ namespace langguanApi.Service
|
||||||
}
|
}
|
||||||
entity.IsDelete = true;
|
entity.IsDelete = true;
|
||||||
await base.UpdateAsync(id, entity);
|
await base.UpdateAsync(id, entity);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
_logger.LogError($"删除菜单出现异常,请求参数:{Newtonsoft.Json.JsonConvert.SerializeObject(id)}," +
|
||||||
|
$"请求接口:'api/Menu/DeleteMenu'," +
|
||||||
|
$"异常信息:{ex.Message}," +
|
||||||
|
$"异常位置:{ex.StackTrace}"
|
||||||
|
);
|
||||||
|
return new ApiResult { code = 1, msg = "删除菜单失败", data = false };
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"删除菜单参数:menuId:{id}");
|
||||||
|
}
|
||||||
return new ApiResult() { code = 0, data = true, msg = "删除菜单成功" };
|
return new ApiResult() { code = 0, data = true, msg = "删除菜单成功" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using langguanApi.Extensions;
|
using langguanApi.Extensions.AutoDI;
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
using langguanApi.Model;
|
using langguanApi.Model;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
|
@ -63,28 +62,13 @@ namespace langguanApi.Service
|
||||||
/// ListAndDevice
|
/// ListAndDevice
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="OrganizedType">1,有组织,2无组织</param>
|
/// <param name="OrganizedType">1,有组织,2无组织</param>
|
||||||
/// <param name="DeviceType">1,voc,2cems</param>
|
|
||||||
/// <param name="OrgId">组织Id</param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ApiResult> ListAndDevice(int OrganizedType, int DeviceType, string OrgId)
|
public async Task<ApiResult> ListAndDevice(int OrganizedType = 1)
|
||||||
{
|
{
|
||||||
Expression<Func<Organized, bool>> exp = filter => filter.OrganizedType == OrganizedType && filter.IsDelete == false;
|
Expression<Func<Organized, bool>> exp = filter => filter.OrganizedType == OrganizedType && filter.IsDelete == false;
|
||||||
if (!string.IsNullOrEmpty(OrgId))
|
|
||||||
{
|
|
||||||
exp = exp.And(filter => filter.Id == OrgId);
|
|
||||||
}
|
|
||||||
var result = (await base.GetListWithExp(exp)).OrderByDescending(x => x.Order).ToList();
|
var result = (await base.GetListWithExp(exp)).OrderByDescending(x => x.Order).ToList();
|
||||||
List<OrganizedByDeviceDto> list = new List<OrganizedByDeviceDto>();
|
List<OrganizedByDeviceDto> list = new List<OrganizedByDeviceDto>();
|
||||||
Expression<Func<Device, bool>> deviceExp = filter => filter.IsDelete == false;
|
var devices = await _deviceService.GetDeviceByOrgids(result.Select(s => s.Id));
|
||||||
if (DeviceType > 0)
|
|
||||||
{
|
|
||||||
deviceExp = deviceExp.And(filter => filter.DeviceType == DeviceType);
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(OrgId))
|
|
||||||
{
|
|
||||||
deviceExp = deviceExp.And(filter => filter.OrgId == OrgId);
|
|
||||||
}
|
|
||||||
var devices = (await _deviceService.GetListWithExp(deviceExp)).ToList();
|
|
||||||
foreach (var item in result)
|
foreach (var item in result)
|
||||||
{
|
{
|
||||||
list.Add(new OrganizedByDeviceDto
|
list.Add(new OrganizedByDeviceDto
|
||||||
|
|
@ -105,9 +89,7 @@ namespace langguanApi.Service
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ApiResult> List(int OrganizedType = 1)
|
public async Task<ApiResult> List(int OrganizedType = 1)
|
||||||
{
|
{
|
||||||
List<OrganizedByDeviceDto> dto = new List<OrganizedByDeviceDto>();
|
Expression<Func<Organized, bool>> exp = filter => filter.OrganizedType == OrganizedType && filter.IsDelete == false;
|
||||||
Expression<Func<Organized, bool>> exp = filter => filter.OrganizedType == OrganizedType
|
|
||||||
&& filter.IsDelete == false;
|
|
||||||
var result = (await base.GetListWithExp(exp)).OrderByDescending(x => x.Order).ToList();
|
var result = (await base.GetListWithExp(exp)).OrderByDescending(x => x.Order).ToList();
|
||||||
return new ApiResult() { code = 0, data = result };
|
return new ApiResult() { code = 0, data = result };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace langguanApi.Service
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async void CreatTask()
|
public void CreatTask()
|
||||||
{
|
{
|
||||||
//5分钟执行一次
|
//5分钟执行一次
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
|
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
using langguanApi.Model;
|
|
||||||
using langguanApi.Model.Dto;
|
|
||||||
using langguanApi.Model.Entity;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
|
||||||
{
|
|
||||||
[ServiceInjection(InjectionType.Transient)]
|
|
||||||
/// <summary>
|
|
||||||
/// 接收数据服务
|
|
||||||
/// </summary>
|
|
||||||
public class ReceiveDataService
|
|
||||||
{
|
|
||||||
public ReceiveDataService()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 接收数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="jsonData"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<ApiResult> ReceiveData(ReceiveDto jsonData)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//TODO: 接收到数据后处理数据类型,1 门禁 ,2,tsp,3 地磅,
|
|
||||||
switch (jsonData.dataType)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
//TODO: 1门禁
|
|
||||||
var accessData = JsonConvert.DeserializeObject<AddTransport>(jsonData.content);
|
|
||||||
var _transportservice = ServiceLocator.Instance.GetService<TransportService>();
|
|
||||||
await _transportservice.addTransport(accessData);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
//TODO: 2 tsp
|
|
||||||
var LedgerData = JsonConvert.DeserializeObject<Model.HJ212>(jsonData.content);
|
|
||||||
var _service = ServiceLocator.Instance.GetService<Hj212Service>();
|
|
||||||
await _service.Add(LedgerData, null);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
//TODO: 3 地磅
|
|
||||||
var truckScalesData = JsonConvert.DeserializeObject<AddTruckScalesDto>(jsonData.content);
|
|
||||||
var _TruckScalesService = ServiceLocator.Instance.GetService<TruckScalesService>();
|
|
||||||
await _TruckScalesService.AddTruckScales(truckScalesData);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
//TODO: 4 地磅
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return new ApiResult() { code = 1, msg = ex.Message };
|
|
||||||
}
|
|
||||||
return new ApiResult() { code = 0, msg = "success" };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
using langguanApi.Model;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Statistics service
|
|
||||||
/// </summary>
|
|
||||||
public class StatisticsService
|
|
||||||
{
|
|
||||||
private Hj212Service _hj212Service;
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hj212Service"></param>
|
|
||||||
public StatisticsService(Hj212Service hj212Service)
|
|
||||||
{
|
|
||||||
_hj212Service = hj212Service;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get statistics
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="type"></param>
|
|
||||||
/// <param name="Organized"></param>
|
|
||||||
/// <param name="deviceId"></param>
|
|
||||||
/// <param name="startTime"></param>
|
|
||||||
/// <param name="endTime"></param>
|
|
||||||
/// <param name="pageIndex"></param>
|
|
||||||
/// <param name="pageSize"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<ApiResult> GetStatistics(int type, int Organized, string deviceId, DateTime? startTime, DateTime? endTime, int pageIndex = 1, int pageSize = 10)
|
|
||||||
{
|
|
||||||
var result = await GetData(type, Organized, deviceId, startTime, endTime, pageIndex, pageSize);
|
|
||||||
return new ApiResult()
|
|
||||||
{
|
|
||||||
code = 0,
|
|
||||||
msg = "success",
|
|
||||||
data = new
|
|
||||||
{
|
|
||||||
items = result.Item2,
|
|
||||||
total = result.Item1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public async Task<ApiResult> ExportGetStatistics(int type, int Organized, string deviceId, DateTime? startTime, DateTime? endTime, int pageIndex = 1, int pageSize = 10)
|
|
||||||
{
|
|
||||||
var result = await GetData(type, Organized, deviceId, startTime, endTime, pageIndex, pageSize);
|
|
||||||
var items = result.Item2;
|
|
||||||
return new ApiResult()
|
|
||||||
{
|
|
||||||
code = 0,
|
|
||||||
msg = "success",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
private async Task<Tuple<long, List<Model.HJ212>>> GetData(int type, int Organized, string deviceId, DateTime? startTime, DateTime? endTime, int pageIndex = 1, int pageSize = 10)
|
|
||||||
{
|
|
||||||
endTime = endTime ?? DateTime.Now;
|
|
||||||
startTime = startTime ?? DateTime.Now.AddDays(-7);
|
|
||||||
Expression<Func<Model.HJ212, bool>> exp = filter =>
|
|
||||||
filter.CreateDateTime >= startTime && filter.CreateDateTime <= endTime && filter.Id == deviceId;
|
|
||||||
ReqPaing reqPaing = new ReqPaing()
|
|
||||||
{
|
|
||||||
pageSize = pageSize,
|
|
||||||
current = pageIndex
|
|
||||||
};
|
|
||||||
return await _hj212Service.GetListByPage(reqPaing, exp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using langguanApi.Extensions.AutoDI;
|
using langguanApi.Extensions.AutoDI;
|
||||||
using langguanApi.Model;
|
using langguanApi.Model;
|
||||||
using Mapster;
|
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
namespace langguanApi.Service
|
namespace langguanApi.Service
|
||||||
|
|
@ -11,23 +10,17 @@ namespace langguanApi.Service
|
||||||
[ServiceInjection(InjectionType.Transient)]
|
[ServiceInjection(InjectionType.Transient)]
|
||||||
public class TransportService : BaseService<Transport>
|
public class TransportService : BaseService<Transport>
|
||||||
{
|
{
|
||||||
private TruckScalesService _truckScalesService;
|
public TransportService(IConfiguration config) : base(config, nameof(Transport))
|
||||||
public TransportService(IConfiguration config, TruckScalesService truckScalesService) : base(config, nameof(Transport))
|
|
||||||
{
|
{
|
||||||
_truckScalesService = truckScalesService;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增运输
|
/// 新增运输
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="transport"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<Transport> addTransport(AddTransport input)
|
public async Task<Transport> addTransport(Transport transport)
|
||||||
{
|
{
|
||||||
var entity = input.Adapt<Transport>();
|
return await base.CreateAsync(transport);
|
||||||
entity.effluent = input.EmissionLevel;
|
|
||||||
entity.imgUrl=input.EntryExitPictureUrl;
|
|
||||||
entity.TransportType = input.EntryDirection;
|
|
||||||
return await base.CreateAsync(entity);
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 首页统计
|
/// 首页统计
|
||||||
|
|
@ -46,21 +39,11 @@ namespace langguanApi.Service
|
||||||
public async Task<object> GetPage(reqpage input)
|
public async Task<object> GetPage(reqpage input)
|
||||||
{
|
{
|
||||||
Expression<Func<Transport, bool>> exp = filter => filter.CarNumber.Contains(input.key) && filter.IsDelete == false;
|
Expression<Func<Transport, bool>> exp = filter => filter.CarNumber.Contains(input.key) && filter.IsDelete == false;
|
||||||
var list = await base.GetListWithExp(exp);
|
return await base.GetPager(new ReqPaing()
|
||||||
var result = new List<TransportDto>();
|
|
||||||
if (list.Any())
|
|
||||||
{
|
{
|
||||||
foreach (var item in list)
|
pageSize = input.pageSize,
|
||||||
{
|
current = input.current
|
||||||
var entity = item.Adapt<TransportDto>();
|
}, exp);
|
||||||
entity.CarColorString = GetColorString(item.CarColor);
|
|
||||||
entity.TransportTypeString = item.TransportType == 1 ? "进场" : "出场";
|
|
||||||
entity.TimeString = item.Time.ToString("yyyy-MM-dd HH:mm:ss");
|
|
||||||
entity.effluent = GetEffluentString(item.effluent);
|
|
||||||
result.Add(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.Skip(input.current - 1).Take(input.pageSize);
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取清洁运输统计数字
|
/// 获取清洁运输统计数字
|
||||||
|
|
@ -84,132 +67,5 @@ namespace langguanApi.Service
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 获取清洁运输趋势列表(门禁和地磅组合,地磅获取总重量,后期会用地磅重量-车辆车辆)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<object> GetTransport(transportReqPage input)
|
|
||||||
{
|
|
||||||
var result = new CleanTransportationAllDto();
|
|
||||||
result.cleans = new List<CleanTransportationDto>();
|
|
||||||
//获取门禁数据
|
|
||||||
Expression<Func<Transport, bool>> exp = filter => filter.TransportType == 1 && filter.IsDelete == false;
|
|
||||||
var list = (await base.GetListWithExp(exp)).ToList();
|
|
||||||
//获取地磅数据
|
|
||||||
var TruckScaleslist = _truckScalesService.GetTruckScalesList().Result;
|
|
||||||
//合并数据
|
|
||||||
foreach (var item in TruckScaleslist)
|
|
||||||
{
|
|
||||||
var transport = list.FirstOrDefault(p => p.CarNumber == item.CarNumber);
|
|
||||||
if (transport != null)
|
|
||||||
{
|
|
||||||
result.cleans.Add(new CleanTransportationDto()
|
|
||||||
{
|
|
||||||
CarColor = GetColorString(transport.CarColor),
|
|
||||||
CarNumber = transport.CarNumber,
|
|
||||||
CarType = transport.CarType,
|
|
||||||
Time = transport.Time.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
||||||
Weight = item.Weight,
|
|
||||||
Effluent = GetEffluentString(transport.effluent)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (result.cleans.Any())
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(input.startTime))
|
|
||||||
{
|
|
||||||
//c#集合筛选大于开始时间的数据
|
|
||||||
result.cleans = result.cleans.Where(p => DateTime.Parse(p.Time) >= DateTime.Parse(input.startTime)).ToList();
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrWhiteSpace(input.endTime))
|
|
||||||
{
|
|
||||||
result.cleans = result.cleans.Where(p => DateTime.Parse(p.Time) <= DateTime.Parse(input.endTime)).ToList();
|
|
||||||
}
|
|
||||||
result.cleans = result.cleans.Skip(input.current - 1).Take(input.pageSize).ToList();
|
|
||||||
}
|
|
||||||
if (result.cleans.Any())
|
|
||||||
{
|
|
||||||
result.V5Percent =((double)result.cleans.Count(p => p.Effluent == "国五") / result.cleans.Count()).ToString();
|
|
||||||
result.V5Numer = (double)result.cleans.Count(p => p.Effluent == "国五");
|
|
||||||
result.V5WeightPercent = (result.cleans.Where(p => p.Effluent == "国五").Sum(p=>p.Weight) / result.cleans.Sum(p=>p.Weight)).ToString("0.00");
|
|
||||||
result.V5WeightNumber = result.cleans.Where(p => p.Effluent == "国五").Sum(p => p.Weight);
|
|
||||||
result.V6Percent = ((double)result.cleans.Count(p => p.Effluent == "国六") / result.cleans.Count()).ToString("0.00");
|
|
||||||
result.V6Number = (double)result.cleans.Count(p => p.Effluent == "国六");
|
|
||||||
result.V6WeightPercent = (result.cleans.Where(p => p.Effluent == "国六").Sum(p => p.Weight) / result.cleans.Sum(p => p.Weight)).ToString("0.00");
|
|
||||||
result.V6WeightNumber = result.cleans.Where(p => p.Effluent == "国六").Sum(p => p.Weight);
|
|
||||||
result.ElectricPrecent = ((double)result.cleans.Count(p => p.Effluent == "电动") / result.cleans.Count()).ToString("0.00");
|
|
||||||
result.ElectricNumber = (double)result.cleans.Count(p => p.Effluent == "电动");
|
|
||||||
result.ElectricWeightPrecent = (result.cleans.Where(p => p.Effluent == "电动").Sum(p => p.Weight) / result.cleans.Sum(p => p.Weight)).ToString("0.00");
|
|
||||||
result.ElectricWeightNumber = result.cleans.Where(p => p.Effluent == "电动").Sum(p => p.Weight);
|
|
||||||
result.OtherPrecent = ((double)result.cleans.Count(p => p.Effluent != "电动" && p.Effluent != "国五" && p.Effluent != "国六") / result.cleans.Count()).ToString("0.00");
|
|
||||||
result.OtherNumber = (double)result.cleans.Count(p => p.Effluent != "电动" && p.Effluent != "国五" && p.Effluent != "国六");
|
|
||||||
result.OtherWeightPrecent = (result.cleans.Where(p => p.Effluent != "电动" && p.Effluent != "国五" && p.Effluent != "国六").Sum(p => p.Weight) / result.cleans.Sum(p => p.Weight)).ToString("0.00");
|
|
||||||
result.OtherWeightNumber = (double)result.cleans.Where(p => p.Effluent != "电动" && p.Effluent != "国五" && p.Effluent != "国六").Sum(p => p.Weight);
|
|
||||||
}
|
|
||||||
return new ApiResult()
|
|
||||||
{
|
|
||||||
code = 0,
|
|
||||||
data = new { total=result.cleans.Count, item=result }
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取车辆颜色
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public string GetColorString(int color)
|
|
||||||
{
|
|
||||||
switch (color)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return CarColor.蓝色.ToString();
|
|
||||||
case 2:
|
|
||||||
return CarColor.绿色.ToString();
|
|
||||||
case 3:
|
|
||||||
return CarColor.黄色.ToString();
|
|
||||||
case 4:
|
|
||||||
return CarColor.白色.ToString();
|
|
||||||
case 5:
|
|
||||||
return CarColor.黑色.ToString();
|
|
||||||
case 6:
|
|
||||||
return CarColor.黄绿.ToString();
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 排放标准(0-7是国1-7,D:电动 X:无排放阶段)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="effluent"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
|
|
||||||
public string GetEffluentString(string effluent)
|
|
||||||
{
|
|
||||||
switch (effluent)
|
|
||||||
{
|
|
||||||
case "1":
|
|
||||||
return "国一";
|
|
||||||
case "2":
|
|
||||||
return "国二";
|
|
||||||
case "3":
|
|
||||||
return "国三";
|
|
||||||
case "4":
|
|
||||||
return "国四";
|
|
||||||
case "5":
|
|
||||||
return "国五";
|
|
||||||
case "6":
|
|
||||||
return "国六";
|
|
||||||
case "D":
|
|
||||||
return "电动";
|
|
||||||
case "X":
|
|
||||||
return "无排放阶段";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
using langguanApi.Model;
|
|
||||||
using Mapster;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 地磅服务
|
|
||||||
/// </summary>
|
|
||||||
[ServiceInjection(InjectionType.Transient)]
|
|
||||||
public class TruckScalesService : BaseService<TruckScales>
|
|
||||||
{
|
|
||||||
public TruckScalesService(IConfiguration config) : base(config, nameof(TruckScales))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 新加
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task AddTruckScalesList(List<AddTruckScalesDto> input)
|
|
||||||
{
|
|
||||||
var list = input.Adapt<List<TruckScales>>();
|
|
||||||
if (list.Any())
|
|
||||||
{
|
|
||||||
await base.CreateManyAsync(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 新加
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task AddTruckScales(AddTruckScalesDto input)
|
|
||||||
{
|
|
||||||
var list = input.Adapt<TruckScales>();
|
|
||||||
await base.CreateAsync(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取地磅集合
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ids"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<List<TruckScales>> GetTruckScalesList()
|
|
||||||
{
|
|
||||||
Expression<Func<TruckScales, bool>> exp = filter => filter.IsDelete == false;
|
|
||||||
var list = (await base.GetListWithExp(exp)).ToList();
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -19,15 +19,10 @@ namespace langguanApi.Service
|
||||||
{
|
{
|
||||||
private ILogger<UserService> _logger;
|
private ILogger<UserService> _logger;
|
||||||
private RoleService _roleService;
|
private RoleService _roleService;
|
||||||
private RoleMenuServie _roleMenuServie;
|
public UserService(IConfiguration config, ILogger<UserService> logger, RoleService roleService) : base(config, nameof(UserEntity).Replace("Entity", ""))
|
||||||
private MenuService _menuService;
|
|
||||||
public UserService(IConfiguration config, ILogger<UserService> logger,
|
|
||||||
RoleService roleService, RoleMenuServie roleMenuServie, MenuService menuService) : base(config, nameof(UserEntity).Replace("Entity", ""))
|
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_roleService = roleService;
|
_roleService = roleService;
|
||||||
_roleMenuServie = roleMenuServie;
|
|
||||||
_menuService = menuService;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 登录
|
/// 登录
|
||||||
|
|
@ -35,23 +30,12 @@ namespace langguanApi.Service
|
||||||
/// <param name="username"></param>
|
/// <param name="username"></param>
|
||||||
/// <param name="password"></param>
|
/// <param name="password"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<UserAnMenusViewModel> login(string username, string password)
|
public async Task<UserEntity> login(string username, string password)
|
||||||
{
|
{
|
||||||
Expression<Func<UserEntity, bool>> exp = filter =>
|
Expression<Func<UserEntity, bool>> exp = filter =>
|
||||||
filter.Username == username && filter.Password == StringHelper.MD5Encrypt32(password);
|
filter.Username == username && filter.Password == StringHelper.MD5Encrypt32(password);
|
||||||
var userEntity = (await base.GetListWithExp(exp)).FirstOrDefault();
|
var list = await base.GetListWithExp(exp);
|
||||||
if (userEntity != null)
|
return list.FirstOrDefault();
|
||||||
{
|
|
||||||
var menuIds = await _roleMenuServie.GetByRoleId(userEntity.RoleId);
|
|
||||||
var menus = await _menuService.GetMenuTreeList();
|
|
||||||
return new UserAnMenusViewModel()
|
|
||||||
{
|
|
||||||
UserInfo = userEntity,
|
|
||||||
RoleName = (await _roleService.GetAsync(userEntity.RoleId))?.RoleName,
|
|
||||||
Menus = menus
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据用户名获取用户信息
|
/// 根据用户名获取用户信息
|
||||||
|
|
@ -98,20 +82,11 @@ namespace langguanApi.Service
|
||||||
{
|
{
|
||||||
exp = filter => filter.Username.Contains(input.key) || filter.Phone.Contains(input.key) || filter.Email.Contains(input.key);
|
exp = filter => filter.Username.Contains(input.key) || filter.Phone.Contains(input.key) || filter.Email.Contains(input.key);
|
||||||
}
|
}
|
||||||
List<UserViewModel> views = new List<UserViewModel>();
|
return await base.GetPager(new ReqPaing()
|
||||||
var result = await base.GetListByPage(input, exp);
|
|
||||||
var UserRoleList = await _roleService.GetRoleListByIds(result.Item2.Select(s => s.RoleId).ToList());
|
|
||||||
foreach (var item in result.Item2)
|
|
||||||
{
|
{
|
||||||
var view = item.Adapt<UserViewModel>();
|
pageSize = input.pageSize,
|
||||||
view.RoleName = UserRoleList.FirstOrDefault(s => s.Id == item.RoleId)?.RoleName;
|
current = input.current
|
||||||
views.Add(view);
|
}, exp);
|
||||||
}
|
|
||||||
return new ApiResult()
|
|
||||||
{
|
|
||||||
code = 0,
|
|
||||||
data = new { total = result.Item1, items = views }
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 用户管理
|
#region 用户管理
|
||||||
|
|
@ -127,6 +102,63 @@ namespace langguanApi.Service
|
||||||
return await base.Exist(exp);
|
return await base.Exist(exp);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
///新增用户
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">新增用户dto</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<ApiResult> AddUser(UserDto input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
#region 校验参数
|
||||||
|
if (string.IsNullOrEmpty(input.Username))
|
||||||
|
{
|
||||||
|
return new ApiResult { code = 1, msg = "用户名非空" };
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(input.Tel))
|
||||||
|
{
|
||||||
|
return new ApiResult { code = 1, msg = "手机号非空" };
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(input.Email))
|
||||||
|
{
|
||||||
|
return new ApiResult { code = 1, msg = "邮箱非空" };
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(input.RoleId))
|
||||||
|
{
|
||||||
|
return new ApiResult { code = 1, msg = "角色不能为空" };
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 组织数据
|
||||||
|
var entity = input.Adapt<UserEntity>();
|
||||||
|
entity.Phone = input.Tel;
|
||||||
|
if (!string.IsNullOrEmpty(input.Password))
|
||||||
|
{
|
||||||
|
entity.Password = StringHelper.MD5Encrypt32(input.Password);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 保存数据
|
||||||
|
if (entity != null && string.IsNullOrEmpty(entity.Id))
|
||||||
|
{
|
||||||
|
await base.CreateAsync(entity);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError($"新增用户出现异常,请求参数:user:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}," +
|
||||||
|
$"请求接口:'api/User/AddUser'," +
|
||||||
|
$"异常信息:{ex.Message}," +
|
||||||
|
$"异常位置:{ex.StackTrace}"
|
||||||
|
);
|
||||||
|
return new ApiResult { code = 1, msg = "保存用户信息失败" };
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"新增用户参数:user:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}");
|
||||||
|
}
|
||||||
|
return new ApiResult { code = 0, msg = "保存用户信息成功" };
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// 获取用户列表
|
/// 获取用户列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
|
|
@ -134,12 +166,13 @@ namespace langguanApi.Service
|
||||||
public async Task<ApiResult> GetUserList(UserQueryDto input)
|
public async Task<ApiResult> GetUserList(UserQueryDto input)
|
||||||
{
|
{
|
||||||
List<UserDetailDto> list = new List<UserDetailDto>();
|
List<UserDetailDto> list = new List<UserDetailDto>();
|
||||||
|
try
|
||||||
|
{
|
||||||
#region 组织查询条件
|
#region 组织查询条件
|
||||||
Expression<Func<UserEntity, bool>> exp = filter => filter.IsDelete == false;
|
Expression<Func<UserEntity, bool>> exp = filter => filter.IsDelete == false;
|
||||||
if (!string.IsNullOrEmpty(input.key))
|
if (!string.IsNullOrEmpty(input.key))
|
||||||
{
|
{
|
||||||
exp = filter => filter.Username.Contains(input.key) || filter.Phone.Contains(input.key) || filter.Email.Contains(input.key);
|
exp = filter => filter.Username.Contains(input.key)|| filter.Phone.Contains(input.key)|| filter.Email.Contains(input.key);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region 获取数据
|
#region 获取数据
|
||||||
|
|
@ -168,7 +201,21 @@ namespace langguanApi.Service
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
return new ApiResult { code = 0, data = list, msg = "获取信息成功" };
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError($"获取用户列表出现异常,请求参数:userQuery:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}," +
|
||||||
|
$"请求接口:'api/User/GetUserList'," +
|
||||||
|
$"异常信息:{ex.Message}," +
|
||||||
|
$"异常位置:{ex.StackTrace}"
|
||||||
|
);
|
||||||
|
return new ApiResult { code = 1, msg = "获取用户列表失败" };
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"获取用户列表参数:userQuery:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}");
|
||||||
|
}
|
||||||
|
return new ApiResult { code = 0, data = list,msg="获取信息成功" };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -179,7 +226,8 @@ namespace langguanApi.Service
|
||||||
public async Task<ApiResult> GetUserById(string userId)
|
public async Task<ApiResult> GetUserById(string userId)
|
||||||
{
|
{
|
||||||
UserDetailDto userDetail = null;
|
UserDetailDto userDetail = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
#region 校验数据
|
#region 校验数据
|
||||||
if (string.IsNullOrEmpty(userId))
|
if (string.IsNullOrEmpty(userId))
|
||||||
{
|
{
|
||||||
|
|
@ -209,6 +257,20 @@ namespace langguanApi.Service
|
||||||
Tel = user.Phone
|
Tel = user.Phone
|
||||||
};
|
};
|
||||||
#endregion
|
#endregion
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError($"获取用户信息出现异常,请求参数:userId:{userId}," +
|
||||||
|
$"请求接口:'api/User/GetUserById'," +
|
||||||
|
$"异常信息:{ex.Message}," +
|
||||||
|
$"异常位置:{ex.StackTrace}"
|
||||||
|
);
|
||||||
|
return new ApiResult { code = 1, msg = "获取用户信息失败" };
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"获取用户信息参数:userId:{userId}");
|
||||||
|
}
|
||||||
return new ApiResult { code = 0, data = userDetail };
|
return new ApiResult { code = 0, data = userDetail };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,7 +278,8 @@ namespace langguanApi.Service
|
||||||
//更新用户信息方法
|
//更新用户信息方法
|
||||||
public async Task<ApiResult> UpdateUser(UserDto input)
|
public async Task<ApiResult> UpdateUser(UserDto input)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
#region 校验参数
|
#region 校验参数
|
||||||
if (string.IsNullOrEmpty(input.Id))
|
if (string.IsNullOrEmpty(input.Id))
|
||||||
{
|
{
|
||||||
|
|
@ -250,6 +313,20 @@ namespace langguanApi.Service
|
||||||
#region 更新数据
|
#region 更新数据
|
||||||
await base.UpdateAsync(input.Id, userEntity);//更新用户信息
|
await base.UpdateAsync(input.Id, userEntity);//更新用户信息
|
||||||
#endregion
|
#endregion
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError($"更新用户信息出现异常,请求参数:user:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}," +
|
||||||
|
$"请求接口:'api/User/UpdateUser'," +
|
||||||
|
$"异常信息:{ex.Message}," +
|
||||||
|
$"异常位置:{ex.StackTrace}"
|
||||||
|
);
|
||||||
|
return new ApiResult { code = 1, msg = "更新用户信息失败" };
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"更新用户信息参数:user:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}");
|
||||||
|
}
|
||||||
return new ApiResult { code = 0, msg = "更新用户信息成功" };
|
return new ApiResult { code = 0, msg = "更新用户信息成功" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -260,7 +337,8 @@ namespace langguanApi.Service
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ApiResult> DeleteUser(string userId)
|
public async Task<ApiResult> DeleteUser(string userId)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
#region 校验数据
|
#region 校验数据
|
||||||
if (string.IsNullOrEmpty(userId))
|
if (string.IsNullOrEmpty(userId))
|
||||||
{
|
{
|
||||||
|
|
@ -276,6 +354,20 @@ namespace langguanApi.Service
|
||||||
user.IsDelete = true;
|
user.IsDelete = true;
|
||||||
await base.UpdateAsync(userId, user);//更新用户信息
|
await base.UpdateAsync(userId, user);//更新用户信息
|
||||||
#endregion
|
#endregion
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError($"删除用户信息出现异常,请求参数:userId:{userId}," +
|
||||||
|
$"请求接口:'api/User/DeleteUser'," +
|
||||||
|
$"异常信息:{ex.Message}," +
|
||||||
|
$"异常位置:{ex.StackTrace}"
|
||||||
|
);
|
||||||
|
return new ApiResult { code = 1, msg = "删除用户信息失败" };
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"删除用户信息参数:userId:{userId}");
|
||||||
|
}
|
||||||
return new ApiResult { code = 0, msg = "删除用户信息成功" };
|
return new ApiResult { code = 0, msg = "删除用户信息成功" };
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -1,105 +0,0 @@
|
||||||
using langguanApi.Extensions;
|
|
||||||
using langguanApi.Extensions.AutoDI;
|
|
||||||
using langguanApi.Model;
|
|
||||||
using langguanApi.Model.Entity;
|
|
||||||
using Mapster;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
|
||||||
{
|
|
||||||
[ServiceInjection(InjectionType.Transient)]
|
|
||||||
public class WasherService : BaseService<Washer>
|
|
||||||
{
|
|
||||||
public WasherService(IConfiguration config) : base(config, nameof(Washer))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 新增洗车机
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task addWasher(List<AddWasher> input)
|
|
||||||
{
|
|
||||||
List<Washer> result = new List<Washer>();
|
|
||||||
foreach (var item in input)
|
|
||||||
{
|
|
||||||
var entity = item.Adapt<Washer>();
|
|
||||||
result.Add(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
await base.CreateManyAsync(result);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 获取洗车机列表
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<object> getWasherList()
|
|
||||||
{
|
|
||||||
Expression<Func<Washer, bool>> exp = filter => filter.IsDelete == false;
|
|
||||||
var result = (await base.GetListWithExp(exp)).OrderByDescending(p=>p.CreateDateTime).ToList();
|
|
||||||
var washerResult = new List<GetWasherDto>();//转化成需要的数据
|
|
||||||
foreach (var item in result)
|
|
||||||
{
|
|
||||||
var entity = item.Adapt<GetWasherDto>();
|
|
||||||
entity.EquipmentStatusString = item.EquipmentStatus == 0 ? "异常" : "正常";
|
|
||||||
entity.RunStatusString = item.RunStatus == 0 ? "停止" : "运行";
|
|
||||||
washerResult.Add(entity);
|
|
||||||
}
|
|
||||||
return new ApiResult()
|
|
||||||
{
|
|
||||||
code = 0,
|
|
||||||
data = new
|
|
||||||
{
|
|
||||||
total = washerResult.Count,
|
|
||||||
item = washerResult
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 获取洗车机历史记录(起始时间和结束时间非空,根据起始时间和结束时间筛选数据,如果为空,默认获取30条数据)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<object> WasherHistoryList(transportReqPage input)
|
|
||||||
{
|
|
||||||
Expression<Func<Washer, bool>> exp = filter => filter.IsDelete == false;
|
|
||||||
var result = (await base.GetListWithExp(exp)).ToList();
|
|
||||||
var washerHistroyResult = new List<WasherHistoryDto>();//转化成需要的数据
|
|
||||||
foreach (var item in result)
|
|
||||||
{
|
|
||||||
var entity = item.Adapt<WasherHistoryDto>();
|
|
||||||
entity.StateString = item.State == 0 ? "停止" : "运行";
|
|
||||||
washerHistroyResult.Add(entity);
|
|
||||||
}
|
|
||||||
if (washerHistroyResult.Any())
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(input.startTime))
|
|
||||||
{
|
|
||||||
washerHistroyResult = washerHistroyResult.Where(p => Convert.ToDateTime(p.Time) >= Convert.ToDateTime(input.startTime)).ToList();
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrWhiteSpace(input.endTime))
|
|
||||||
{
|
|
||||||
washerHistroyResult = washerHistroyResult.Where(p => Convert.ToDateTime(p.Time) <= Convert.ToDateTime(input.endTime)).ToList();
|
|
||||||
}
|
|
||||||
if (string.IsNullOrWhiteSpace(input.startTime) && string.IsNullOrWhiteSpace(input.endTime))
|
|
||||||
{
|
|
||||||
washerHistroyResult = washerHistroyResult.OrderByDescending(p => p.Time).Take(30).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new ApiResult()
|
|
||||||
{
|
|
||||||
code = 0,
|
|
||||||
data = new
|
|
||||||
{
|
|
||||||
total=washerHistroyResult.Count,
|
|
||||||
item= washerHistroyResult
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
using langguanApi.Extensions.AutoDI;
|
using langguanApi.Extensions.AutoDI;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace langguanApi.Service
|
namespace langguanApi.Service
|
||||||
{
|
{
|
||||||
|
|
@ -16,7 +14,7 @@ namespace langguanApi.Service
|
||||||
{
|
{
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_logger = logger;
|
_logger=logger;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 爬气象局的天气数据%
|
/// 爬气象局的天气数据%
|
||||||
|
|
@ -52,202 +50,6 @@ namespace langguanApi.Service
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 爬空气质量数据
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<object> GetAirQuality()
|
|
||||||
{
|
|
||||||
var client = _httpClientFactory.CreateClient();
|
|
||||||
var resp = await client.GetAsync(_configuration.GetSection("AirQuality").Value);
|
|
||||||
if (resp.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
var data = await resp.Content.ReadAsStringAsync();
|
|
||||||
var air = JsonConvert.DeserializeObject<AirQuality>(data);
|
|
||||||
return Convert2QualityList(air);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
private List<Quality> Convert2QualityList(AirQuality airQuality)
|
|
||||||
{
|
|
||||||
Type modelType = typeof(AirQuality);
|
|
||||||
List<Quality> qualityList = new List<Quality>();
|
|
||||||
PropertyInfo[] PropertyList = modelType.GetProperties();
|
|
||||||
foreach (PropertyInfo item in PropertyList)
|
|
||||||
{
|
|
||||||
Quality quality = new Quality();
|
|
||||||
object value = item.GetValue(airQuality, null);
|
|
||||||
if (value != null)
|
|
||||||
{
|
|
||||||
var tuple = GetStandard(item.Name, value.ToString());
|
|
||||||
quality.key = tuple.Item1;
|
|
||||||
quality.val = value.ToString();
|
|
||||||
quality.standard = tuple.Item2;
|
|
||||||
quality.level = tuple.Item3;
|
|
||||||
qualityList.Add(quality);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return qualityList;
|
|
||||||
}
|
|
||||||
private Tuple<string, string, string> GetStandard(string key, string value)
|
|
||||||
{
|
|
||||||
string standard = "";
|
|
||||||
string keyword = "";
|
|
||||||
string level = "";
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case "CO":
|
|
||||||
keyword = "一氧化碳";
|
|
||||||
standard = "4 mg/m3";
|
|
||||||
if (double.Parse(value) > 4)
|
|
||||||
{
|
|
||||||
level = "差";
|
|
||||||
}
|
|
||||||
else if (double.Parse(value) == 4)
|
|
||||||
{
|
|
||||||
level = "持平";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
level = "优";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "NO2":
|
|
||||||
keyword = "二氧化氮";
|
|
||||||
standard = "40μg/m3";
|
|
||||||
if (double.Parse(value) >= 40)
|
|
||||||
{
|
|
||||||
level = "差";
|
|
||||||
}
|
|
||||||
else if (double.Parse(value) == 150)
|
|
||||||
{
|
|
||||||
level = "持平";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
level = "优";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "O3":
|
|
||||||
keyword = "臭氧";
|
|
||||||
standard = "160μg/L";
|
|
||||||
if (double.Parse(value) > 160)
|
|
||||||
{
|
|
||||||
level = "差";
|
|
||||||
}
|
|
||||||
else if (double.Parse(value) == 160)
|
|
||||||
{
|
|
||||||
level = "持平";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
level = "优";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "PM10":
|
|
||||||
keyword = "PM10";
|
|
||||||
standard = "10mg/m3";
|
|
||||||
if (double.Parse(value) > 10)
|
|
||||||
{
|
|
||||||
level = "差";
|
|
||||||
}
|
|
||||||
else if (double.Parse(value) == 10)
|
|
||||||
{
|
|
||||||
level = "持平";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
level = "优";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "PM2_5":
|
|
||||||
|
|
||||||
keyword = "PM2.5";
|
|
||||||
standard = "8mg/m3";
|
|
||||||
if (double.Parse(value) > 8)
|
|
||||||
{
|
|
||||||
level = "差";
|
|
||||||
}
|
|
||||||
else if (double.Parse(value) == 8)
|
|
||||||
{
|
|
||||||
level = "持平";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
level = "优";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "SO2":
|
|
||||||
keyword = "二氧化硫";
|
|
||||||
standard = "15μg/m3";
|
|
||||||
if (double.Parse(value) >= 15)
|
|
||||||
{
|
|
||||||
level = "优";
|
|
||||||
}
|
|
||||||
else if (double.Parse(value) >= 35)
|
|
||||||
{
|
|
||||||
level = "中";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
level = "差";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return new Tuple<string, string, string>(keyword, standard, level);
|
|
||||||
}
|
|
||||||
public class Quality
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 空气质量key
|
|
||||||
/// </summary>
|
|
||||||
public string key { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 空气质量指数数值
|
|
||||||
/// </summary>
|
|
||||||
public string val { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 空气质量指数级别
|
|
||||||
/// </summary>
|
|
||||||
public string level { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 空气质量指数标准
|
|
||||||
/// </summary>
|
|
||||||
public string standard { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 空气质量数据
|
|
||||||
/// </summary>
|
|
||||||
public class AirQuality
|
|
||||||
{
|
|
||||||
// public string Area { get; set; }
|
|
||||||
// public int CityCode { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 一氧化碳
|
|
||||||
/// </summary>
|
|
||||||
public string CO { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 二氧化氮
|
|
||||||
/// </summary>
|
|
||||||
public string NO2 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 臭氧
|
|
||||||
/// </summary>
|
|
||||||
public string O3 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// PM10
|
|
||||||
/// </summary>
|
|
||||||
public string PM10 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// PM25
|
|
||||||
/// </summary>
|
|
||||||
public string PM2_5 { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 二氧化硫
|
|
||||||
/// </summary>
|
|
||||||
public string SO2 { get; set; }
|
|
||||||
}
|
|
||||||
public class Location
|
public class Location
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -15,21 +15,12 @@
|
||||||
"Key": "tdss",
|
"Key": "tdss",
|
||||||
"Index": 5
|
"Index": 5
|
||||||
},
|
},
|
||||||
"Weather": "https://weather.cma.cn/api/now/54475", //天气预报地址,中国气象
|
"Weather": "https://weather.cma.cn/api/now/54511", //天气预报地址,中国气象
|
||||||
"AirQuality": "https://air.cnemc.cn:18007/CityData/GetAQIDataPublishLiveInfo?cityCode=210800", //空气质量API地址
|
|
||||||
"Apis": {
|
|
||||||
"RateUrl": "https://mock.apipark.cn/m1/4687001-0-default/DustApi/DeviceOnlineRate", //首页设备在线率API地址
|
|
||||||
"AlertUrl": "https://mock.apipark.cn/m1/4687001-0-default/DustApi/DeviceHistoryAlarm", //首页设报警API地址
|
|
||||||
"DeviceList": "https://mock.apipark.cn/m1/4687001-0-default/DustApi/GetDeviceList", //环境治理 API地址
|
|
||||||
"DeviceStatu": "https://mock.apipark.cn/m1/4687001-0-default/DustApi/GetDeviceStatu" //设备明细 API地址
|
|
||||||
|
|
||||||
},
|
|
||||||
"Home": {
|
"Home": {
|
||||||
"Title": "朋义矿场",
|
"Title": "鄂托克旗新航焦化有限公司",
|
||||||
"Center": {
|
"Center": {
|
||||||
"lat": 40.718429,
|
"lat": 39.4716613,
|
||||||
"lon": 122.548834
|
"lon": 107.1413332
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"BatchId": 30 //批次号间隔时间30分钟
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,10 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="IceCoffee.FastSocket" Version="1.0.3" />
|
<PackageReference Include="IceCoffee.FastSocket" Version="1.0.3" />
|
||||||
<PackageReference Include="JT808" Version="2.6.8" />
|
|
||||||
<PackageReference Include="Mapster" Version="7.4.0" />
|
<PackageReference Include="Mapster" Version="7.4.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.27" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.27" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="6.0.33" />
|
<PackageReference Include="MongoDB.Bson" Version="2.23.1" />
|
||||||
<PackageReference Include="MongoDB.Bson" Version="2.27.0" />
|
<PackageReference Include="MongoDB.Driver" Version="2.23.1" />
|
||||||
<PackageReference Include="MongoDB.Driver" Version="2.27.0" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Npoi.Mapper" Version="6.2.1" />
|
<PackageReference Include="Npoi.Mapper" Version="6.2.1" />
|
||||||
<PackageReference Include="StackExchange.Redis" Version="2.7.33" />
|
<PackageReference Include="StackExchange.Redis" Version="2.7.33" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue