Compare commits
	
		
			64 Commits
		
	
	
		
			master_sxs
			...
			master
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								 | 
						4e62761e27 | |
| 
							
							
								 | 
						6ebf202282 | |
| 
							
							
								 | 
						b19ff3677b | |
| 
							
							
								 | 
						c7d695a114 | |
| 
							
							
								 | 
						2f7bc1ba09 | |
| 
							
							
								 | 
						8ea426e33b | |
| 
							
							
								 | 
						f97fe92dac | |
| 
							
							
								 | 
						82906fd1af | |
| 
							
							
								 | 
						24ac38114c | |
| 
							
							
								
								 | 
						6fb5d1120e | |
| 
							
							
								 | 
						2b3108b270 | |
| 
							
							
								
								 | 
						bdd524a430 | |
| 
							
							
								
								 | 
						86da4194ac | |
| 
							
							
								
								 | 
						f12ae73cf4 | |
| 
							
							
								
								 | 
						101dc1fef6 | |
| 
							
							
								 | 
						b250b0a297 | |
| 
							
							
								 | 
						e076521db8 | |
| 
							
							
								 | 
						337993c243 | |
| 
							
							
								 | 
						44471ec932 | |
| 
							
							
								 | 
						3852e62f58 | |
| 
							
							
								 | 
						7420acdbad | |
| 
							
							
								 | 
						354492d6ef | |
| 
							
							
								 | 
						38f67cb7bc | |
| 
							
							
								 | 
						d4cf5fcfa0 | |
| 
							
							
								 | 
						32f9e8a1f5 | |
| 
							
							
								 | 
						fa9f138d82 | |
| 
							
							
								 | 
						ceea3b2291 | |
| 
							
							
								 | 
						772514da44 | |
| 
							
							
								 | 
						87e1822832 | |
| 
							
							
								 | 
						c68f032f59 | |
| 
							
							
								 | 
						82cf538330 | |
| 
							
							
								 | 
						bb33e69cd8 | |
| 
							
							
								 | 
						51b79bde5d | |
| 
							
							
								 | 
						e3c18ba952 | |
| 
							
							
								 | 
						bb455678cc | |
| 
							
							
								 | 
						61580ac13b | |
| 
							
							
								 | 
						54c03916a8 | |
| 
							
							
								 | 
						2dd3a1b18c | |
| 
							
							
								 | 
						db7444c365 | |
| 
							
							
								 | 
						fb11676daf | |
| 
							
							
								 | 
						cd0f8671ab | |
| 
							
							
								 | 
						6f746d9468 | |
| 
							
							
								 | 
						232dbb988e | |
| 
							
							
								 | 
						0760746448 | |
| 
							
							
								 | 
						9a2265d4ae | |
| 
							
							
								 | 
						47aef96dd5 | |
| 
							
							
								 | 
						ec4b8e389c | |
| 
							
							
								 | 
						2434aa96ff | |
| 
							
							
								 | 
						edeeaeff1c | |
| 
							
							
								 | 
						c7b4801d89 | |
| 
							
							
								 | 
						339592fd9c | |
| 
							
							
								 | 
						81f68f3a1a | |
| 
							
							
								 | 
						c0036c4b98 | |
| 
							
							
								 | 
						ecf20b76bf | |
| 
							
							
								 | 
						846c921a65 | |
| 
							
							
								 | 
						f71dac2ac2 | |
| 
							
							
								 | 
						649c2be62d | |
| 
							
							
								 | 
						5575215e79 | |
| 
							
							
								 | 
						5297e85067 | |
| 
							
							
								 | 
						27732189fd | |
| 
							
							
								 | 
						6c9a566784 | |
| 
							
							
								 | 
						1525e6df40 | |
| 
							
							
								 | 
						612f0b0f76 | |
| 
							
							
								
								 | 
						8404f5b452 | 
							
								
								
									
										1807
									
								
								langguanApi.xml
								
								
								
								
							
							
						
						
									
										1807
									
								
								langguanApi.xml
								
								
								
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,5 +1,12 @@
 | 
			
		|||
{
 | 
			
		||||
  "version": 1,
 | 
			
		||||
  "isRoot": true,
 | 
			
		||||
  "tools": {}
 | 
			
		||||
  "tools": {
 | 
			
		||||
    "dotnet-ef": {
 | 
			
		||||
      "version": "8.0.7",
 | 
			
		||||
      "commands": [
 | 
			
		||||
        "dotnet-ef"
 | 
			
		||||
      ]
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -12,6 +12,10 @@ namespace langguanApi.Common
 | 
			
		|||
    public class CacheManager
 | 
			
		||||
    {
 | 
			
		||||
        private readonly IDatabase _redisDatabase;
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 构造函数
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="redisHelper"></param>
 | 
			
		||||
        public CacheManager(RedisHelper redisHelper)
 | 
			
		||||
        {
 | 
			
		||||
            _redisDatabase = redisHelper._database;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,31 @@
 | 
			
		|||
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; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,110 @@
 | 
			
		|||
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;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,80 @@
 | 
			
		|||
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,6 +9,9 @@ namespace langguanApi.Common.Redis
 | 
			
		|||
        /// sub
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ISubscriber _subscriber;
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 构造函数
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public RedisHelper()
 | 
			
		||||
        {
 | 
			
		||||
          //  var con = RedisOptions.Default.GetConnect();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,8 +8,29 @@
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        public static string Weather = "weather";
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 缓存ARI数据
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static string AriQuality = "arqulaty";
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 首页趋势数据
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static string Trend = "tred";
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 缓存今日数据
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static string Today = "today";
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 缓存清洁数据
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static string CleanData = "cleandata";
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// redis缓存key
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="key"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public static string GetBatchid(string key)
 | 
			
		||||
        {
 | 
			
		||||
            return $"batchtid_{key}";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,39 @@
 | 
			
		|||
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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,53 @@
 | 
			
		|||
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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,48 @@
 | 
			
		|||
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,6 +75,17 @@ namespace langguanApi.Controllers
 | 
			
		|||
            return Ok(new ApiResult() { code = 0, data = result });
 | 
			
		||||
        }
 | 
			
		||||
        /// <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>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +104,7 @@ namespace langguanApi.Controllers
 | 
			
		|||
        /// <param name="deviceType"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [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);
 | 
			
		||||
            return Ok(result);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,47 @@
 | 
			
		|||
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,7 +9,10 @@ namespace langguanApi.Controllers
 | 
			
		|||
    public class HJ212Controller : ControllerBase
 | 
			
		||||
    {
 | 
			
		||||
        private readonly Hj212Service _hj212Service;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 构造函数
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="hj212Service"></param>
 | 
			
		||||
        public HJ212Controller(Hj212Service hj212Service)
 | 
			
		||||
        {
 | 
			
		||||
            _hj212Service = hj212Service;
 | 
			
		||||
| 
						 | 
				
			
			@ -20,11 +23,22 @@ namespace langguanApi.Controllers
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        /// <param name="mn"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpGet]
 | 
			
		||||
        [HttpGet("get")]
 | 
			
		||||
        public async Task<IActionResult> Get(string mn)
 | 
			
		||||
        {
 | 
			
		||||
            var resul = await _hj212Service.GetViewByDeviceMn(mn);
 | 
			
		||||
            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,9 +1,17 @@
 | 
			
		|||
using langguanApi.Model;
 | 
			
		||||
using JT808.Protocol.MessageBody;
 | 
			
		||||
using JT808.Protocol;
 | 
			
		||||
using langguanApi.Model;
 | 
			
		||||
using langguanApi.Service;
 | 
			
		||||
using langguanApi.Service.HJ212;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
using Org.BouncyCastle.Utilities;
 | 
			
		||||
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
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +31,7 @@ namespace langguanApi.Controllers
 | 
			
		|||
        [HttpGet("view")]
 | 
			
		||||
        public async Task<IActionResult> View()
 | 
			
		||||
        {
 | 
			
		||||
            return Ok( await _homeService.View() );
 | 
			
		||||
            return Ok(await _homeService.View());
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        [HttpGet("test")]
 | 
			
		||||
| 
						 | 
				
			
			@ -35,11 +43,160 @@ namespace langguanApi.Controllers
 | 
			
		|||
        /// <returns></returns>
 | 
			
		||||
        public async Task<IActionResult> test(int num = 1, string key = "")
 | 
			
		||||
        {
 | 
			
		||||
          //  string rawText = "数据报:##0250QN=20240424224800000;ST=22;CN=2011;PW=123456;MN=LGYC022024690001;Flag=5;CP=&&DataTime=20240424224800;a34001-Rtd=356.2";
 | 
			
		||||
            // 示例数据(需替换为实际接收到的协议数据)
 | 
			
		||||
            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";
 | 
			
		||||
            //NetPackage netPackage = NetPackage.Parse(rawText, null);
 | 
			
		||||
            //((NetServer)Server).RaiseReceivedData(this, netPackage, rawText);
 | 
			
		||||
            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,4 +1,5 @@
 | 
			
		|||
using langguanApi.Model;
 | 
			
		||||
using langguanApi.Model.Entity;
 | 
			
		||||
using langguanApi.Service;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
| 
						 | 
				
			
			@ -23,19 +24,40 @@ namespace langguanApi.Controllers
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpGet("list")]
 | 
			
		||||
        public async Task<IActionResult> list([FromQuery]reqpage input)
 | 
			
		||||
        public async Task<IActionResult> list([FromQuery] reqpage input)
 | 
			
		||||
        {
 | 
			
		||||
            var result = await _ledgerService.GetPage(input);
 | 
			
		||||
            return Ok(result);
 | 
			
		||||
        }
 | 
			
		||||
        /// <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
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="start"></param>
 | 
			
		||||
        /// <param name="end"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [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);
 | 
			
		||||
            return File(result, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "台账.xlsx");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,12 +24,11 @@ namespace langguanApi.Controllers
 | 
			
		|||
        /// <summary>
 | 
			
		||||
        /// 获取菜单列表
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpGet("list")]
 | 
			
		||||
        public async Task<IActionResult> List([FromQuery] reqpage input)
 | 
			
		||||
        public async Task<IActionResult> List()
 | 
			
		||||
        {
 | 
			
		||||
            var result = await _menuService.Pager(input);
 | 
			
		||||
            var result = await _menuService.GetMenuTree();
 | 
			
		||||
            return Ok(result);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -57,13 +56,13 @@ namespace langguanApi.Controllers
 | 
			
		|||
        /// <summary>
 | 
			
		||||
        /// 删除菜单
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="id"></param>
 | 
			
		||||
        /// <param name="ids"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpDelete("DeleteMenu")]
 | 
			
		||||
        public async Task<IActionResult> DeleteMenu(string id)
 | 
			
		||||
        [HttpDelete("remove")]
 | 
			
		||||
        public async Task<IActionResult> DeleteMenu(IEnumerable<string> ids)
 | 
			
		||||
        {
 | 
			
		||||
            var result = await _menuService.DeleteMenu(id);
 | 
			
		||||
            return Ok(result);
 | 
			
		||||
            await _menuService.BatchRemoveAsync(ids);
 | 
			
		||||
            return Ok(new ApiResult());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,11 +54,14 @@ namespace langguanApi.Controllers
 | 
			
		|||
        /// <summary>
 | 
			
		||||
        /// 获取组织工序和设备信息
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="OrganizedType">1 有组织 2 无组织</param>
 | 
			
		||||
        /// <param name="DeviceType">0=全部,1=voc,2=cems</param>
 | 
			
		||||
        /// <param name="OrgId"> 组织id</param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpGet("listanddevice")]
 | 
			
		||||
        public async Task<IActionResult> ListAndDevice(int OrganizedType = 1)
 | 
			
		||||
        public async Task<IActionResult> ListAndDevice(int OrganizedType = 1, int DeviceType = 0, string OrgId = "")
 | 
			
		||||
        {
 | 
			
		||||
            var result = await _organizedService.ListAndDevice(OrganizedType);
 | 
			
		||||
            var result = await _organizedService.ListAndDevice(OrganizedType, DeviceType, OrgId);
 | 
			
		||||
            return Ok(result);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
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")]
 | 
			
		||||
        public async Task<IActionResult> List([FromQuery] reqpage input)
 | 
			
		||||
        {
 | 
			
		||||
            var roles = await _roleService.GetPager(input);
 | 
			
		||||
            var roles = await _roleService.GetPage(input);
 | 
			
		||||
            return Ok(roles);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,58 @@
 | 
			
		|||
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,12 +13,16 @@ namespace langguanApi.Controllers
 | 
			
		|||
    public class TransportController : ControllerBase
 | 
			
		||||
    {
 | 
			
		||||
        private TransportService _transportService;
 | 
			
		||||
        public TransportController(TransportService transportService)
 | 
			
		||||
        private WasherService _washerService;
 | 
			
		||||
        private TruckScalesService _truckScalesService;
 | 
			
		||||
        public TransportController(TransportService transportService, WasherService washerService, TruckScalesService truckScalesService)
 | 
			
		||||
        {
 | 
			
		||||
            _transportService = transportService;
 | 
			
		||||
            _washerService = washerService;
 | 
			
		||||
            _truckScalesService = truckScalesService;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 获取清洁运输列表
 | 
			
		||||
        /// 清洁运输:获取门禁数据和详情
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
| 
						 | 
				
			
			@ -38,5 +42,81 @@ namespace langguanApi.Controllers
 | 
			
		|||
            var result = await _transportService.GetCount();
 | 
			
		||||
            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")]
 | 
			
		||||
        public async Task<IActionResult> Login([FromBody] UserLogin user)
 | 
			
		||||
        {
 | 
			
		||||
            var result = _userService.login(user.Username, user.Password);
 | 
			
		||||
            var result = await _userService.login(user.Username, user.Password);
 | 
			
		||||
            if (result != null)
 | 
			
		||||
            {
 | 
			
		||||
                return Ok(result);
 | 
			
		||||
                return Ok(new ApiResult() { data = result });
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                return BadRequest(result);
 | 
			
		||||
                return Ok(new ApiResult() { code = -1, msg = "用户名或密码错误" });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -58,29 +58,17 @@ namespace langguanApi.Controllers
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        #region  用户管理相关接口
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        ///新增用户
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost("AddUser")]
 | 
			
		||||
        public async Task<IActionResult> AddUser([FromBody] UserDto input)
 | 
			
		||||
        {
 | 
			
		||||
            var result = await _userService.AddUser(input);
 | 
			
		||||
            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);
 | 
			
		||||
        }
 | 
			
		||||
        ///// <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获取用户信息
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 根据用户Id获取用户信息
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +81,6 @@ namespace langguanApi.Controllers
 | 
			
		|||
            var result = await _userService.GetUserById(userId);
 | 
			
		||||
            return Ok(result);
 | 
			
		||||
        }
 | 
			
		||||
        //修改用户信息
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 修改用户信息
 | 
			
		||||
        /// </summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,10 +12,12 @@ namespace langguanApi.Extensions
 | 
			
		|||
        {
 | 
			
		||||
            //  services.AddSingleton<MQTTService>();
 | 
			
		||||
            services.AddTransient<HJ212SocketServer>();
 | 
			
		||||
            services.AddSingleton<GpsService>(); // gps协议
 | 
			
		||||
            services.AddTransient<PingService>();
 | 
			
		||||
 | 
			
		||||
            IServiceProvider serviceProvider = services.BuildServiceProvider();
 | 
			
		||||
            _ = serviceProvider.GetService<HJ212SocketServer>().Start();
 | 
			
		||||
            _ = serviceProvider.GetService<GpsService>().Start();
 | 
			
		||||
            serviceProvider.GetService<PingService>().CreatTask();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
using langguanApi.Service;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc.Filters;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Middleware
 | 
			
		||||
| 
						 | 
				
			
			@ -8,32 +9,40 @@ namespace langguanApi.Middleware
 | 
			
		|||
        /// <summary>
 | 
			
		||||
        /// 日志
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ILogger _logger;
 | 
			
		||||
        public LogService _logger;
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 构参
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="loggerFactory"></param>
 | 
			
		||||
        public CustomerExceptionFilter(ILoggerFactory loggerFactory)
 | 
			
		||||
        /// <param name="logService"></param>
 | 
			
		||||
        public CustomerExceptionFilter(LogService logService)
 | 
			
		||||
        {
 | 
			
		||||
            _logger = loggerFactory.CreateLogger<CustomerExceptionFilter>();
 | 
			
		||||
            _logger = logService;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 重写
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="context"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public Task OnExceptionAsync(ExceptionContext context)
 | 
			
		||||
        public async Task OnExceptionAsync(ExceptionContext context)
 | 
			
		||||
        {
 | 
			
		||||
            if (context.ExceptionHandled == false)
 | 
			
		||||
            {
 | 
			
		||||
                var json = new { cdoe = -1, msg = context.Exception.Message, data = context.Exception.Data };
 | 
			
		||||
                var json = new { code = -1, msg = context.Exception.Message, data = context.Exception.Data };
 | 
			
		||||
                context.HttpContext.Response.StatusCode = 400;
 | 
			
		||||
                context.Result = new JsonResult(json);
 | 
			
		||||
            }
 | 
			
		||||
            _logger.LogError($"请求出现异常,地址:{context.HttpContext?.Request?.Path},请求方式:{context.HttpContext.Request.Method},异常信息:{context.Exception.Message}");
 | 
			
		||||
            await _logger.addLog(new Model.Entity.LogEntity()
 | 
			
		||||
            {
 | 
			
		||||
                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;
 | 
			
		||||
            return Task.CompletedTask;
 | 
			
		||||
           // return Task.CompletedTask;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,4 +10,14 @@
 | 
			
		|||
        public string AlertType { 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; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,104 @@
 | 
			
		|||
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>
 | 
			
		||||
        public string OrgId { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 设备类型,1 voc,2 cems,3,tsp,4 video
 | 
			
		||||
        /// 设备类型,1 voc,2 cems,3,tsp,4 video,5微站
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int DeviceType { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -43,5 +43,7 @@
 | 
			
		|||
        public string OrgId { get; set; }
 | 
			
		||||
        public int DeviceType { get; set; }
 | 
			
		||||
        public string VideoUrl { get; set; }
 | 
			
		||||
        public double lng { get; set; }
 | 
			
		||||
        public double lat { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,7 +62,11 @@ namespace langguanApi.Model.Dto
 | 
			
		|||
                    for (int j = 0; j < d_6.Length; j++)
 | 
			
		||||
                    {
 | 
			
		||||
                        string[] d_7 = d_6[j].Split(new char[] { '=' });
 | 
			
		||||
                        CP.Add(d_7[0].Replace("-RTD", ""), d_7[1]);
 | 
			
		||||
                        //兼容设备厂家不规范的命名,会有重复的CP名称
 | 
			
		||||
                        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];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,17 @@
 | 
			
		|||
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; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,78 @@
 | 
			
		|||
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; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,30 @@
 | 
			
		|||
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; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,25 @@
 | 
			
		|||
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,10 +11,18 @@
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        public DateTime InTime { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 进出场时间
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DateTime Time { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 出场日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DateTime OutTime { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 进场方向
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int EntryDirection { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 车型  
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string CarModel { get; set; }
 | 
			
		||||
| 
						 | 
				
			
			@ -26,6 +34,101 @@
 | 
			
		|||
        /// 国几排放量
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        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
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,19 @@
 | 
			
		|||
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,4 +1,6 @@
 | 
			
		|||
namespace langguanApi.Model.Entity
 | 
			
		||||
using System.ComponentModel.DataAnnotations;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Model.Entity
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 菜单实体类
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +20,7 @@
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        public int Sort { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 父菜单ID,一级菜单为null
 | 
			
		||||
        /// 父菜单ID,一级菜单为"0"
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string ParentId { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -43,6 +45,7 @@
 | 
			
		|||
    }
 | 
			
		||||
    public class UpdateMenuDto : AddMenuDto
 | 
			
		||||
    {
 | 
			
		||||
        [Required]
 | 
			
		||||
        public string Id { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
    public class MenuTreeDto
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,16 +51,30 @@ namespace langguanApi.Model.Entity
 | 
			
		|||
        /// 邮箱
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Email { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 手机号
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Phone { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 更新用户DTO
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class UpdateDto:AddDto
 | 
			
		||||
    public class UpdateDto : AddDto
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 用户id
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        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,6 +416,23 @@
 | 
			
		|||
        a34040,
 | 
			
		||||
        a99010,
 | 
			
		||||
        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,
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,6 +11,14 @@ namespace langguanApi.Model
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        public string deviceMN { get; set; }
 | 
			
		||||
        /// <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浓度
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public double a34004 { get; set; }
 | 
			
		||||
| 
						 | 
				
			
			@ -42,6 +50,123 @@ namespace langguanApi.Model
 | 
			
		|||
        /// 风向
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        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 lng { get; set; }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,4 +9,12 @@
 | 
			
		|||
    {
 | 
			
		||||
        public string key { get; set; } = "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class transportReqPage : ReqPaing
 | 
			
		||||
    {
 | 
			
		||||
        //开始时间
 | 
			
		||||
        public string startTime { get; set; } = "";
 | 
			
		||||
        //结束时间
 | 
			
		||||
        public string endTime { get; set; } = "";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,11 +11,7 @@
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        public int TransportType { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 位置
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Address { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 排放标准
 | 
			
		||||
        /// 排放标准(0-7是国1-7,D:电动  X:无排放阶段)
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string effluent { get; set; }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -30,5 +26,148 @@
 | 
			
		|||
        /// 注册日期
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        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
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,47 @@
 | 
			
		|||
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; }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,220 @@
 | 
			
		|||
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,9 +1,13 @@
 | 
			
		|||
using langguanApi.Common.Redis;
 | 
			
		||||
using langguanApi.Common.WebSocket;
 | 
			
		||||
using langguanApi.Extensions;
 | 
			
		||||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using langguanApi.Middleware;
 | 
			
		||||
using Microsoft.Extensions.Configuration;
 | 
			
		||||
using Microsoft.Extensions.Options;
 | 
			
		||||
using Microsoft.OpenApi.Models;
 | 
			
		||||
using Newtonsoft.Json.Linq;
 | 
			
		||||
using System.Net;
 | 
			
		||||
using System.Text.Json;
 | 
			
		||||
 | 
			
		||||
var builder = WebApplication.CreateBuilder(args);
 | 
			
		||||
| 
						 | 
				
			
			@ -16,8 +20,11 @@ builder.Services.AddControllers(options =>
 | 
			
		|||
    options.Filters.Add<CustomerExceptionFilter>();
 | 
			
		||||
}).AddNewtonsoftJson(option =>
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    option.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
 | 
			
		||||
    option.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
 | 
			
		||||
    //驼峰
 | 
			
		||||
    option.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
 | 
			
		||||
 | 
			
		||||
}).AddJsonOptions(option =>
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +46,8 @@ builder.Services.AddSwaggerGen(
 | 
			
		|||
    });
 | 
			
		||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
 | 
			
		||||
builder.Services.AddEndpointsApiExplorer();
 | 
			
		||||
 | 
			
		||||
//websocket
 | 
			
		||||
builder.Services.AddSignalR();
 | 
			
		||||
//redis
 | 
			
		||||
var redisoptions = builder.Configuration.GetSection("Redis").Get<RedisOptions>();
 | 
			
		||||
if (redisoptions != null)
 | 
			
		||||
| 
						 | 
				
			
			@ -53,10 +61,14 @@ if (redisoptions != null)
 | 
			
		|||
        options.Key = redisoptions.Key;
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
//自动注入
 | 
			
		||||
//自动注入
 | 
			
		||||
builder.Services.ServicesAutoInjectionExtension();
 | 
			
		||||
builder.Services.AddSocketService();
 | 
			
		||||
builder.Services.AddHttpClient();
 | 
			
		||||
builder.Services.AddHttpClient("httpreq", m => { }).ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
 | 
			
		||||
{
 | 
			
		||||
    ServerCertificateCustomValidationCallback = (m, c, ch, e) => true
 | 
			
		||||
});
 | 
			
		||||
//cross domain
 | 
			
		||||
builder.Services.AddCors(options =>
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -70,6 +82,13 @@ builder.Services.AddCors(options =>
 | 
			
		|||
 | 
			
		||||
var app = builder.Build();
 | 
			
		||||
ServiceLocator.Instance = app.Services;
 | 
			
		||||
app.UseRouting();
 | 
			
		||||
//执行匹配的端点
 | 
			
		||||
app.UseEndpoints(endpoints =>
 | 
			
		||||
{
 | 
			
		||||
    endpoints.MapHub<SocketHub>("/notification");
 | 
			
		||||
    endpoints.MapControllers();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Configure the HTTP request pipeline.
 | 
			
		||||
| 
						 | 
				
			
			@ -83,13 +102,47 @@ app.UseSwaggerUI();
 | 
			
		|||
app.UseCors("CorsPolicy");
 | 
			
		||||
//app.UseAuthorization();
 | 
			
		||||
 | 
			
		||||
app.MapControllers();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
//if (!await GetNowTimeAsync())
 | 
			
		||||
//{
 | 
			
		||||
//    Console.WriteLine("当前时间不在可运行时间范围内,请联系供应商。");
 | 
			
		||||
//    Environment.Exit(0);
 | 
			
		||||
//}
 | 
			
		||||
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>
 | 
			
		||||
public static class ServiceLocator
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 服务容器
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static IServiceProvider Instance { get; set; }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,10 @@
 | 
			
		|||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using langguanApi.Common.Proxy;
 | 
			
		||||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using langguanApi.Model;
 | 
			
		||||
using langguanApi.Model.Dto;
 | 
			
		||||
using langguanApi.Model.Entity;
 | 
			
		||||
using Mapster;
 | 
			
		||||
using Npoi.Mapper;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Service
 | 
			
		||||
| 
						 | 
				
			
			@ -8,19 +12,24 @@ namespace langguanApi.Service
 | 
			
		|||
    [ServiceInjection(InjectionType.Transient)]
 | 
			
		||||
    public class AlertService : BaseService<Alert>
 | 
			
		||||
    {
 | 
			
		||||
        public AlertService(IConfiguration config) : base(config, nameof(Alert))
 | 
			
		||||
        private readonly HttpProxy _httpProxy;
 | 
			
		||||
        private readonly IConfiguration _configuration;
 | 
			
		||||
        public AlertService(IConfiguration config, HttpProxy httpProxy) : base(config, nameof(Alert))
 | 
			
		||||
        {
 | 
			
		||||
            _httpProxy = httpProxy;
 | 
			
		||||
            _configuration = config;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 新加
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> Add(Alert input)
 | 
			
		||||
        public async Task<ApiResult> Add(AddAlertDto input)
 | 
			
		||||
        {
 | 
			
		||||
            if (input != null)
 | 
			
		||||
            {
 | 
			
		||||
                await base.CreateAsync(input);
 | 
			
		||||
                var entity = input.Adapt<Alert>();
 | 
			
		||||
                await base.CreateAsync(entity);
 | 
			
		||||
                return new ApiResult { code = 0, msg = "" };
 | 
			
		||||
            }
 | 
			
		||||
            return new ApiResult { code = -1, msg = "" }; ;
 | 
			
		||||
| 
						 | 
				
			
			@ -29,10 +38,67 @@ namespace langguanApi.Service
 | 
			
		|||
        /// 首页数据,最近7天的
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<object> IndexData()
 | 
			
		||||
        public async Task<List<alarm>> IndexData(int num = 50)
 | 
			
		||||
        {
 | 
			
		||||
            Expression<Func<Alert, bool>> exp = filter => filter.CreateDateTime >= DateTime.Now.AddDays(-7) && filter.IsDelete == false;
 | 
			
		||||
            return (await base.GetListWithExp(exp)).OrderByDescending(s => s.CreateDateTime);
 | 
			
		||||
            Expression<Func<Alert, bool>> exp = filter => filter.IsDelete == false;
 | 
			
		||||
            return (await base.GetListWithExp(exp))
 | 
			
		||||
                .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>
 | 
			
		||||
        /// 分页取数据
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,8 @@
 | 
			
		|||
using langguanApi.Model;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Microsoft.AspNetCore.Mvc.RazorPages;
 | 
			
		||||
using Microsoft.Extensions.Options;
 | 
			
		||||
using MongoDB.Bson;
 | 
			
		||||
using MongoDB.Driver;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -184,16 +186,27 @@ namespace langguanApi.Service
 | 
			
		|||
        {
 | 
			
		||||
            FilterDefinition<T> filters = Builders<T>.Filter.Where(filter);
 | 
			
		||||
            return await _collection.Find(filters).ToListAsync();
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// filterdefinition
 | 
			
		||||
        /// filter查找 流式数据
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="filter"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<List<T>> FindListyFilter(FilterDefinition<T> filter)
 | 
			
		||||
        {
 | 
			
		||||
            return await _collection.Find(filter).ToListAsync();
 | 
			
		||||
            List<T> result = new List<T>();
 | 
			
		||||
            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>
 | 
			
		||||
        /// 是否存在
 | 
			
		||||
| 
						 | 
				
			
			@ -224,5 +237,29 @@ namespace langguanApi.Service
 | 
			
		|||
                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();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,47 @@
 | 
			
		|||
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,6 +29,37 @@ namespace langguanApi.Service
 | 
			
		|||
            await base.CreateAsync(entity);
 | 
			
		||||
            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>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,101 @@
 | 
			
		|||
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
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,145 @@
 | 
			
		|||
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;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,55 @@
 | 
			
		|||
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
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,88 @@
 | 
			
		|||
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,6 +1,13 @@
 | 
			
		|||
using IceCoffee.FastSocket.Tcp;
 | 
			
		||||
using JT808.Protocol;
 | 
			
		||||
using JT808.Protocol.Extensions;
 | 
			
		||||
using JT808.Protocol.MessageBody;
 | 
			
		||||
using langguanApi.Common.Gps;
 | 
			
		||||
using langguanApi.Model;
 | 
			
		||||
using Npoi.Mapper;
 | 
			
		||||
using NPOI.SS.Formula.Functions;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using static langguanApi.Common.Gps.ProtocolParser;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Service.HJ212
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -31,11 +38,12 @@ namespace langguanApi.Service.HJ212
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        protected override void OnReceived()
 | 
			
		||||
        {
 | 
			
		||||
            if (ReadBuffer.IndexOf(35) != 0L)// '#'
 | 
			
		||||
            {
 | 
			
		||||
                return;
 | 
			
		||||
                // throw new Exception("异常TCP连接 IP: " + RemoteIPEndPoint);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //if (ReadBuffer.IndexOf(35) != 0L)// '#'
 | 
			
		||||
            //{
 | 
			
		||||
            //    return;
 | 
			
		||||
            //    // throw new Exception("异常TCP连接 IP: " + RemoteIPEndPoint);
 | 
			
		||||
            //}
 | 
			
		||||
 | 
			
		||||
            string rawText = null;
 | 
			
		||||
            while (ReadBuffer.CanReadLine)
 | 
			
		||||
| 
						 | 
				
			
			@ -43,6 +51,40 @@ namespace langguanApi.Service.HJ212
 | 
			
		|||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    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);
 | 
			
		||||
                    NetPackage netPackage = NetPackage.Parse(rawText, GetUnpackCache);
 | 
			
		||||
                    ((NetServer)Server).RaiseReceivedData(this, netPackage, rawText);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,13 +10,15 @@ using langguanApi.Extensions.AutoDI;
 | 
			
		|||
 | 
			
		||||
namespace langguanApi.Service
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
    public class HJ212SocketServer
 | 
			
		||||
    {
 | 
			
		||||
        private Hj212Service _hj212Service;
 | 
			
		||||
        public HJ212SocketServer(Hj212Service hj212Service)
 | 
			
		||||
        private DeviceService _deviceService;
 | 
			
		||||
        public HJ212SocketServer(Hj212Service hj212Service, DeviceService deviceService)
 | 
			
		||||
        {
 | 
			
		||||
            _hj212Service = hj212Service;
 | 
			
		||||
            _deviceService = deviceService;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 缓冲器
 | 
			
		||||
| 
						 | 
				
			
			@ -66,6 +68,8 @@ namespace langguanApi.Service
 | 
			
		|||
            server.SendData += OnNetServer_SendData;
 | 
			
		||||
            server.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private void OnNetServer_Started()
 | 
			
		||||
        {
 | 
			
		||||
            Console.WriteLine($"开始监听: {ip}:{port}");
 | 
			
		||||
| 
						 | 
				
			
			@ -90,15 +94,49 @@ namespace langguanApi.Service
 | 
			
		|||
        {
 | 
			
		||||
            Console.WriteLine("收到自: " + session.RemoteIPEndPoint + ": " + rawText);
 | 
			
		||||
            HJ212_2017 hj = new HJ212_2017();
 | 
			
		||||
            // st 27 =voc,st=31 cems, st=32,tsp, st=22 微站
 | 
			
		||||
            if (hj.DecodeData(rawText))
 | 
			
		||||
            {
 | 
			
		||||
                var body = JsonConvert.SerializeObject(hj.CP);
 | 
			
		||||
 | 
			
		||||
                Console.WriteLine("解析成功: " + body);
 | 
			
		||||
                var entity = JsonConvert.DeserializeObject<Model.HJ212>(body);
 | 
			
		||||
                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)
 | 
			
		||||
        {
 | 
			
		||||
            Console.WriteLine("Error in NetServer" + ex);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,12 @@
 | 
			
		|||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using langguanApi.Model;
 | 
			
		||||
using langguanApi.Model.Dto;
 | 
			
		||||
using MongoDB.Bson;
 | 
			
		||||
using MongoDB.Driver;
 | 
			
		||||
using NPOI.HSSF.Record;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Text.RegularExpressions;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Service
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -14,6 +19,147 @@ namespace langguanApi.Service
 | 
			
		|||
            _deviceSerive = deviceSerive;
 | 
			
		||||
        }
 | 
			
		||||
        /// <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>
 | 
			
		||||
        /// <param name="hJ212"></param>
 | 
			
		||||
| 
						 | 
				
			
			@ -21,14 +167,18 @@ namespace langguanApi.Service
 | 
			
		|||
        /// <returns></returns>
 | 
			
		||||
        public async Task Add(Model.HJ212 hJ212, string deviceIp)
 | 
			
		||||
        {
 | 
			
		||||
            //先判断当前设备是否存在
 | 
			
		||||
            await _deviceSerive.Add(new DeviceAddDto()
 | 
			
		||||
            {
 | 
			
		||||
                deviceMN = hJ212.deviceMN,
 | 
			
		||||
                Ip = deviceIp,
 | 
			
		||||
                lat = hJ212.lat,
 | 
			
		||||
                lng = hJ212.lng,
 | 
			
		||||
            });
 | 
			
		||||
            ////判断设备类型 tsp 会有经纬度数据
 | 
			
		||||
            //  int deviceType = 1;//设备类型为1 =voc
 | 
			
		||||
 | 
			
		||||
            ////先判断当前设备是否存在
 | 
			
		||||
            //await _deviceSerive.Add(new DeviceAddDto()
 | 
			
		||||
            //{
 | 
			
		||||
            //    deviceMN = hJ212.deviceMN,
 | 
			
		||||
            //    Ip = deviceIp,
 | 
			
		||||
            //    lat = hJ212.lat,
 | 
			
		||||
            //    lng = hJ212.lng,
 | 
			
		||||
            //    DeviceType = deviceType
 | 
			
		||||
            //});
 | 
			
		||||
            await base.CreateAsync(hJ212);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +186,7 @@ namespace langguanApi.Service
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        /// <param name="hours"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<List<Model.HJ212>> GetViewTop(int hours = -10)
 | 
			
		||||
        public async Task<List<Model.HJ212>> GetViewTop(int hours = -5)
 | 
			
		||||
        {
 | 
			
		||||
            var date = DateTime.Now.AddHours(-8).AddHours(hours);
 | 
			
		||||
            Expression<Func<Model.HJ212, bool>> exp = filter => filter.CreateDateTime >= date;
 | 
			
		||||
| 
						 | 
				
			
			@ -49,7 +199,7 @@ namespace langguanApi.Service
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        /// <param name="deviceMn"></param>
 | 
			
		||||
        /// <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;
 | 
			
		||||
            var result = (await base.GetListWithExp(exp)).OrderByDescending(s => s.CreateDateTime).Take(60).ToList();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,9 @@ using langguanApi.Common;
 | 
			
		|||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using langguanApi.Model;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using langguanApi.Common.Proxy;
 | 
			
		||||
using langguanApi.Model.Dto;
 | 
			
		||||
using Npoi.Mapper;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Service
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -18,6 +21,8 @@ namespace langguanApi.Service
 | 
			
		|||
        private CacheManager _cacheManager;
 | 
			
		||||
        private readonly WeatherService _weatherService;
 | 
			
		||||
        private readonly AlertService _alertService;
 | 
			
		||||
        private readonly DetectionService _detectionService;
 | 
			
		||||
        private HttpProxy _httpProxy;
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// HomeService
 | 
			
		||||
        /// </summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +30,8 @@ namespace langguanApi.Service
 | 
			
		|||
        /// <param name="hj212Service"></param>
 | 
			
		||||
        public HomeService(DeviceService device, Hj212Service hj212Service,
 | 
			
		||||
            IConfiguration configuration, CacheManager cacheManager,
 | 
			
		||||
            WeatherService weatherService, AlertService alertService)
 | 
			
		||||
            WeatherService weatherService, AlertService alertService,
 | 
			
		||||
            DetectionService detectionService, HttpProxy httpProxy)
 | 
			
		||||
        {
 | 
			
		||||
            _deviceService = device;
 | 
			
		||||
            _hj212Service = hj212Service;
 | 
			
		||||
| 
						 | 
				
			
			@ -33,6 +39,8 @@ namespace langguanApi.Service
 | 
			
		|||
            _cacheManager = cacheManager;
 | 
			
		||||
            _weatherService = weatherService;
 | 
			
		||||
            _alertService = alertService;
 | 
			
		||||
            _detectionService = detectionService;
 | 
			
		||||
            _httpProxy = httpProxy;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// view
 | 
			
		||||
| 
						 | 
				
			
			@ -40,21 +48,49 @@ namespace langguanApi.Service
 | 
			
		|||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> View()
 | 
			
		||||
        {
 | 
			
		||||
            var devices = await _deviceService.GetAsync();
 | 
			
		||||
            var ariQuality = "";
 | 
			
		||||
            Expression<Func<Device, bool>> exp = x => x.IsDelete == false && x.lng > 0 && x.lat > 0;
 | 
			
		||||
            var devices = (await _deviceService.GetListWithExp(exp)).ToList();
 | 
			
		||||
            var cleanData = new
 | 
			
		||||
            {
 | 
			
		||||
                Yesterday = 0.8,
 | 
			
		||||
                LastWeek = 0.6,
 | 
			
		||||
            };
 | 
			
		||||
         
 | 
			
		||||
            Expression<Func<Model.HJ212, bool>> filter = exp => true;
 | 
			
		||||
            var Realtime = await _hj212Service.Realtime();
 | 
			
		||||
            var getViewTop = await _hj212Service.GetViewTop();
 | 
			
		||||
            // 首页热力图
 | 
			
		||||
            var hotmap = new { };
 | 
			
		||||
            // 首页设备报警数据
 | 
			
		||||
            var alerts = await _alertService.IndexData();
 | 
			
		||||
            // 首页设备检测数据
 | 
			
		||||
            var detections = await _detectionService.GetIndexData();
 | 
			
		||||
            // 获取天气信息,缓存1小时,如果不存在,则调用WeatherService获取
 | 
			
		||||
            Func<Task<object>> getWeatherFunc = async () => await _weatherService.GetWeather();
 | 
			
		||||
            var weather = await _cacheManager.GetConvertVale(RedisKeylist.Weather, getWeatherFunc, 60 * 60);
 | 
			
		||||
            var weather = await _cacheManager.GetConvertVale(RedisKeylist.Weather, getWeatherFunc, 60 * 60 * 24 * 30);
 | 
			
		||||
            // 获取空气质量,缓存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
 | 
			
		||||
            {
 | 
			
		||||
                code = 0,
 | 
			
		||||
| 
						 | 
				
			
			@ -69,12 +105,18 @@ namespace langguanApi.Service
 | 
			
		|||
                        },
 | 
			
		||||
                        title = _configuration.GetValue<string>("Home:Title"),
 | 
			
		||||
                    },
 | 
			
		||||
 | 
			
		||||
                    devices,
 | 
			
		||||
                    ariQuality,
 | 
			
		||||
                    Realtime,
 | 
			
		||||
                    getViewTop,
 | 
			
		||||
                    hotmap,
 | 
			
		||||
                    weather,
 | 
			
		||||
                    alerts
 | 
			
		||||
                    ariQuality,
 | 
			
		||||
                    rate,
 | 
			
		||||
                    trend,
 | 
			
		||||
                    alerts,
 | 
			
		||||
                    cleanData,
 | 
			
		||||
                    today,
 | 
			
		||||
                    getViewTop = "",
 | 
			
		||||
                    detections
 | 
			
		||||
                }
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,7 @@ using MathNet.Numerics.Distributions;
 | 
			
		|||
using Npoi.Mapper;
 | 
			
		||||
using Org.BouncyCastle.Asn1.IsisMtt.X509;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
using System.Security.Cryptography.X509Certificates;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Service
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -23,33 +24,41 @@ namespace langguanApi.Service
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task AddLedger(LedgerDTO input)
 | 
			
		||||
        public async Task AddLedger(AddLedgerDto input)
 | 
			
		||||
        {
 | 
			
		||||
            var enity = input.Adapt<Ledger>();
 | 
			
		||||
            enity.CarNum = input.CarNumber;
 | 
			
		||||
            enity.Emissions = input.EmissionLevel;
 | 
			
		||||
            await base.CreateAsync(enity);
 | 
			
		||||
        }
 | 
			
		||||
        public async Task<object> HeaderCount()
 | 
			
		||||
        {
 | 
			
		||||
            return new { t1 = 100, t2 = 200, t3 = 300, t4 = 400 };
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 导出数据
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="start"></param>
 | 
			
		||||
        /// <param name="end"></param>
 | 
			
		||||
        /// <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 =>
 | 
			
		||||
            filter.CreateDateTime >= start && filter.CreateDateTime <= end && filter.IsDelete == false;
 | 
			
		||||
            var list = await base.GetListWithExp(exp);
 | 
			
		||||
            filter.CreateDateTime >= start.Value && filter.CreateDateTime <= end.Value && filter.IsDelete == false;
 | 
			
		||||
            var list = (await base.GetListWithExp(exp)).ToList();
 | 
			
		||||
            var mapper = new Mapper();
 | 
			
		||||
            mapper.Map<Ledger>("进场时间", s => s.InTime)
 | 
			
		||||
            mapper.Map<Ledger>("进出场时间", s => s.Time)
 | 
			
		||||
            .Map<Ledger>("车牌号", s => s.CarNum)
 | 
			
		||||
            .Map<Ledger>("车型", s => s.CarModel)
 | 
			
		||||
            .Map<Ledger>("新能源", s => s.NewCar ? "是" : "否")
 | 
			
		||||
            .Map<Ledger>("是否新能源", s => s.NewCar)
 | 
			
		||||
            .Map<Ledger>("燃油车", s => s.Emissions)
 | 
			
		||||
            .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.OutTime);
 | 
			
		||||
            MemoryStream stream = new MemoryStream();
 | 
			
		||||
            mapper.Save(stream, list.ToList(), sheetName: "sheet1", leaveOpen: true);
 | 
			
		||||
            mapper.Save(stream, list, sheetName: "sheet1", leaveOpen: true);
 | 
			
		||||
            return stream.ToArray();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,33 @@
 | 
			
		|||
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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -28,25 +28,8 @@ namespace langguanApi.Service
 | 
			
		|||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> AddMenu(AddMenuDto menu)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                var entity = menu.Adapt<Menu>();
 | 
			
		||||
                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)}");
 | 
			
		||||
            }
 | 
			
		||||
            var entity = menu.Adapt<Menu>();
 | 
			
		||||
            await base.CreateAsync(entity);
 | 
			
		||||
            return new ApiResult { code = 0, msg = "保存菜单信息成功", data = true };
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -56,99 +39,40 @@ namespace langguanApi.Service
 | 
			
		|||
        /// <returns></returns>
 | 
			
		||||
        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>();
 | 
			
		||||
                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)}");
 | 
			
		||||
            }
 | 
			
		||||
            var entity = menu.Adapt<Menu>();
 | 
			
		||||
            await base.UpdateAsync(entity.Id, entity);
 | 
			
		||||
            return new ApiResult() { code = 0, data = true, msg = "更新菜单成功" };
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 获取菜单树
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> Pager(reqpage input)
 | 
			
		||||
        public async Task<ApiResult> GetMenuTree()
 | 
			
		||||
        {
 | 
			
		||||
            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>();
 | 
			
		||||
            try
 | 
			
		||||
            var MenuList = await GetChildList("0");
 | 
			
		||||
            foreach (var item in MenuList)
 | 
			
		||||
            {
 | 
			
		||||
                var MenuList = await GetChildList("0");//获取跟节点
 | 
			
		||||
                if (MenuList.Any())
 | 
			
		||||
                dto.Add(new MenuTreeDto()
 | 
			
		||||
                {
 | 
			
		||||
                    foreach (var item in MenuList)
 | 
			
		||||
                    {
 | 
			
		||||
                        dto.Add(new MenuTreeDto()
 | 
			
		||||
                        {
 | 
			
		||||
                            Id = item.Id,
 | 
			
		||||
                            Name = item.Name,
 | 
			
		||||
                            Sort = item.Sort,
 | 
			
		||||
                            ParentId = item.ParentId,
 | 
			
		||||
                            ParentName = item.ParentName,
 | 
			
		||||
                            Children = await GetChildList(item.Id)
 | 
			
		||||
                        });
 | 
			
		||||
                    }
 | 
			
		||||
                    //筛选数据
 | 
			
		||||
                    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 = "获取菜单列表不存在" };
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                    Id = item.Id,
 | 
			
		||||
                    Name = item.Name,
 | 
			
		||||
                    Sort = item.Sort,
 | 
			
		||||
                    ParentId = item.ParentId,
 | 
			
		||||
                    ParentName = item.ParentName,
 | 
			
		||||
                    Children = await GetChildList(item.Id)
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            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 = "获取菜单列表" };
 | 
			
		||||
            return dto;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 递归获取子菜单列表
 | 
			
		||||
| 
						 | 
				
			
			@ -158,13 +82,10 @@ namespace langguanApi.Service
 | 
			
		|||
        public async Task<List<MenuTreeDto>> GetChildList(string 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))
 | 
			
		||||
                .OrderBy(x => x.Sort)
 | 
			
		||||
                .ToList().Adapt<List<MenuTreeDto>>();
 | 
			
		||||
            var DataSourceList = (await GetAsync())
 | 
			
		||||
                .OrderBy(x => x.Sort)
 | 
			
		||||
                .ToList();//拿到所有数据源,筛选结果
 | 
			
		||||
            var DataSourceList = (await GetAsync()).ToList();//拿到所有数据源,筛选结果
 | 
			
		||||
            foreach (var item in list)
 | 
			
		||||
            {
 | 
			
		||||
                item.Children = await GetChildList(item.Id);
 | 
			
		||||
| 
						 | 
				
			
			@ -175,36 +96,19 @@ namespace langguanApi.Service
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 作废菜单
 | 
			
		||||
        /// 作废菜单 (废弃,不做处理)
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="id">当前菜单id</param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> DeleteMenu(string id)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            var entity = await base.GetAsync(id);
 | 
			
		||||
            if (entity == null)
 | 
			
		||||
            {
 | 
			
		||||
                var entity = await base.GetAsync(id);
 | 
			
		||||
                if (entity == null)
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult() { code = 0, data = false, msg = "删除菜单失败,Id不存在" };
 | 
			
		||||
                }
 | 
			
		||||
                entity.IsDelete = true;
 | 
			
		||||
                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 = false, msg = "删除菜单失败,Id不存在" };
 | 
			
		||||
            }
 | 
			
		||||
            entity.IsDelete = true;
 | 
			
		||||
            await base.UpdateAsync(id, entity);
 | 
			
		||||
            return new ApiResult() { code = 0, data = true, msg = "删除菜单成功" };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using langguanApi.Extensions;
 | 
			
		||||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using langguanApi.Model;
 | 
			
		||||
using Mapster;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
| 
						 | 
				
			
			@ -62,13 +63,28 @@ namespace langguanApi.Service
 | 
			
		|||
        /// ListAndDevice
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="OrganizedType">1,有组织,2无组织</param>
 | 
			
		||||
        /// <param name="DeviceType">1,voc,2cems</param>
 | 
			
		||||
        /// <param name="OrgId">组织Id</param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> ListAndDevice(int OrganizedType = 1)
 | 
			
		||||
        public async Task<ApiResult> ListAndDevice(int OrganizedType, int DeviceType, string OrgId)
 | 
			
		||||
        {
 | 
			
		||||
            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();
 | 
			
		||||
            List<OrganizedByDeviceDto> list = new List<OrganizedByDeviceDto>();
 | 
			
		||||
            var devices = await _deviceService.GetDeviceByOrgids(result.Select(s => s.Id));
 | 
			
		||||
            Expression<Func<Device, bool>> deviceExp = filter => filter.IsDelete == false;
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
                list.Add(new OrganizedByDeviceDto
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +105,9 @@ namespace langguanApi.Service
 | 
			
		|||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> List(int OrganizedType = 1)
 | 
			
		||||
        {
 | 
			
		||||
            Expression<Func<Organized, bool>> exp = filter => filter.OrganizedType == OrganizedType && filter.IsDelete == false;
 | 
			
		||||
            List<OrganizedByDeviceDto> dto = new List<OrganizedByDeviceDto>();
 | 
			
		||||
            Expression<Func<Organized, bool>> exp = filter => filter.OrganizedType == OrganizedType
 | 
			
		||||
            && filter.IsDelete == false;
 | 
			
		||||
            var result = (await base.GetListWithExp(exp)).OrderByDescending(x => x.Order).ToList();
 | 
			
		||||
            return new ApiResult() { code = 0, data = result };
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,7 @@ namespace langguanApi.Service
 | 
			
		|||
        /// <summary>
 | 
			
		||||
        /// 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void CreatTask()
 | 
			
		||||
        public async void CreatTask()
 | 
			
		||||
        {
 | 
			
		||||
            //5分钟执行一次
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,62 @@
 | 
			
		|||
 | 
			
		||||
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" };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,71 @@
 | 
			
		|||
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,5 +1,6 @@
 | 
			
		|||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using langguanApi.Model;
 | 
			
		||||
using Mapster;
 | 
			
		||||
using System.Linq.Expressions;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Service
 | 
			
		||||
| 
						 | 
				
			
			@ -10,17 +11,23 @@ namespace langguanApi.Service
 | 
			
		|||
    [ServiceInjection(InjectionType.Transient)]
 | 
			
		||||
    public class TransportService : BaseService<Transport>
 | 
			
		||||
    {
 | 
			
		||||
        public TransportService(IConfiguration config) : base(config, nameof(Transport))
 | 
			
		||||
        private TruckScalesService _truckScalesService;
 | 
			
		||||
        public TransportService(IConfiguration config, TruckScalesService truckScalesService) : base(config, nameof(Transport))
 | 
			
		||||
        {
 | 
			
		||||
            _truckScalesService = truckScalesService;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 新增运输
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="transport"></param>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<Transport> addTransport(Transport transport)
 | 
			
		||||
        public async Task<Transport> addTransport(AddTransport input)
 | 
			
		||||
        {
 | 
			
		||||
            return await base.CreateAsync(transport);
 | 
			
		||||
            var entity = input.Adapt<Transport>();
 | 
			
		||||
            entity.effluent = input.EmissionLevel;
 | 
			
		||||
            entity.imgUrl=input.EntryExitPictureUrl;
 | 
			
		||||
            entity.TransportType = input.EntryDirection;
 | 
			
		||||
            return await base.CreateAsync(entity);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 首页统计
 | 
			
		||||
| 
						 | 
				
			
			@ -39,11 +46,21 @@ namespace langguanApi.Service
 | 
			
		|||
        public async Task<object> GetPage(reqpage input)
 | 
			
		||||
        {
 | 
			
		||||
            Expression<Func<Transport, bool>> exp = filter => filter.CarNumber.Contains(input.key) && filter.IsDelete == false;
 | 
			
		||||
            return await base.GetPager(new ReqPaing()
 | 
			
		||||
            var list = await base.GetListWithExp(exp);
 | 
			
		||||
            var result = new List<TransportDto>();
 | 
			
		||||
            if (list.Any())
 | 
			
		||||
            {
 | 
			
		||||
                pageSize = input.pageSize,
 | 
			
		||||
                current = input.current
 | 
			
		||||
            }, exp);
 | 
			
		||||
                foreach (var item in list)
 | 
			
		||||
                {
 | 
			
		||||
                    var entity = item.Adapt<TransportDto>();
 | 
			
		||||
                    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>
 | 
			
		||||
        /// 获取清洁运输统计数字
 | 
			
		||||
| 
						 | 
				
			
			@ -67,5 +84,132 @@ 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 "";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,54 @@
 | 
			
		|||
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,10 +19,15 @@ namespace langguanApi.Service
 | 
			
		|||
    {
 | 
			
		||||
        private ILogger<UserService> _logger;
 | 
			
		||||
        private RoleService _roleService;
 | 
			
		||||
        public UserService(IConfiguration config, ILogger<UserService> logger, RoleService roleService) : base(config, nameof(UserEntity).Replace("Entity", ""))
 | 
			
		||||
        private RoleMenuServie _roleMenuServie;
 | 
			
		||||
        private MenuService _menuService;
 | 
			
		||||
        public UserService(IConfiguration config, ILogger<UserService> logger,
 | 
			
		||||
            RoleService roleService, RoleMenuServie roleMenuServie, MenuService menuService) : base(config, nameof(UserEntity).Replace("Entity", ""))
 | 
			
		||||
        {
 | 
			
		||||
            _logger = logger;
 | 
			
		||||
            _roleService = roleService;
 | 
			
		||||
            _roleMenuServie = roleMenuServie;
 | 
			
		||||
            _menuService = menuService;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 登录
 | 
			
		||||
| 
						 | 
				
			
			@ -30,12 +35,23 @@ namespace langguanApi.Service
 | 
			
		|||
        /// <param name="username"></param>
 | 
			
		||||
        /// <param name="password"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<UserEntity> login(string username, string password)
 | 
			
		||||
        public async Task<UserAnMenusViewModel> login(string username, string password)
 | 
			
		||||
        {
 | 
			
		||||
            Expression<Func<UserEntity, bool>> exp = filter =>
 | 
			
		||||
            filter.Username == username && filter.Password == StringHelper.MD5Encrypt32(password);
 | 
			
		||||
            var list = await base.GetListWithExp(exp);
 | 
			
		||||
            return list.FirstOrDefault();
 | 
			
		||||
            var userEntity = (await base.GetListWithExp(exp)).FirstOrDefault();
 | 
			
		||||
            if (userEntity != null)
 | 
			
		||||
            {
 | 
			
		||||
                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>
 | 
			
		||||
        /// 根据用户名获取用户信息
 | 
			
		||||
| 
						 | 
				
			
			@ -82,11 +98,20 @@ namespace langguanApi.Service
 | 
			
		|||
            {
 | 
			
		||||
                exp = filter => filter.Username.Contains(input.key) || filter.Phone.Contains(input.key) || filter.Email.Contains(input.key);
 | 
			
		||||
            }
 | 
			
		||||
            return await base.GetPager(new ReqPaing()
 | 
			
		||||
            List<UserViewModel> views = new List<UserViewModel>();
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
                pageSize = input.pageSize,
 | 
			
		||||
                current = input.current
 | 
			
		||||
            }, exp);
 | 
			
		||||
                var view = item.Adapt<UserViewModel>();
 | 
			
		||||
                view.RoleName = UserRoleList.FirstOrDefault(s => s.Id == item.RoleId)?.RoleName;
 | 
			
		||||
                views.Add(view);
 | 
			
		||||
            }
 | 
			
		||||
            return new ApiResult()
 | 
			
		||||
            {
 | 
			
		||||
                code = 0,
 | 
			
		||||
                data = new { total = result.Item1, items = views }
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #region 用户管理
 | 
			
		||||
| 
						 | 
				
			
			@ -102,63 +127,6 @@ namespace langguanApi.Service
 | 
			
		|||
            return await base.Exist(exp);
 | 
			
		||||
        }
 | 
			
		||||
        /// <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>
 | 
			
		||||
        /// <param name="input"></param>
 | 
			
		||||
| 
						 | 
				
			
			@ -166,56 +134,41 @@ namespace langguanApi.Service
 | 
			
		|||
        public async Task<ApiResult> GetUserList(UserQueryDto input)
 | 
			
		||||
        {
 | 
			
		||||
            List<UserDetailDto> list = new List<UserDetailDto>();
 | 
			
		||||
            try
 | 
			
		||||
 | 
			
		||||
            #region 组织查询条件
 | 
			
		||||
            Expression<Func<UserEntity, bool>> exp = filter => filter.IsDelete == false;
 | 
			
		||||
            if (!string.IsNullOrEmpty(input.key))
 | 
			
		||||
            {
 | 
			
		||||
                #region 组织查询条件
 | 
			
		||||
                Expression<Func<UserEntity, bool>> exp = filter => filter.IsDelete == false;
 | 
			
		||||
                if (!string.IsNullOrEmpty(input.key))
 | 
			
		||||
                {
 | 
			
		||||
                    exp = filter => filter.Username.Contains(input.key)|| filter.Phone.Contains(input.key)|| filter.Email.Contains(input.key);
 | 
			
		||||
                }
 | 
			
		||||
                #endregion
 | 
			
		||||
                #region 获取数据
 | 
			
		||||
                var result = await base.GetListWithExp(exp);//获取人员信息
 | 
			
		||||
                if (result.Count() > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    result = result.Skip((input.PageIndex - 1) * input.PageSize).Take(input.PageSize);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult { code = 0, data = null, msg = "没有用户信息" };
 | 
			
		||||
                }
 | 
			
		||||
                var roleList = await _roleService.GetRoleListByIds(result.Select(s => s.RoleId).ToList());//根据角色Id获取角色信息
 | 
			
		||||
                #endregion
 | 
			
		||||
                #region 组装返回数据
 | 
			
		||||
                foreach (var item in result)
 | 
			
		||||
                {
 | 
			
		||||
                    list.Add(new UserDetailDto
 | 
			
		||||
                    {
 | 
			
		||||
                        UserId = item.Id,
 | 
			
		||||
                        Username = item.Username,
 | 
			
		||||
                        Email = item.Email,
 | 
			
		||||
                        RoleId = item.RoleId,
 | 
			
		||||
                        RoleName = roleList.FirstOrDefault(s => s.Id == item.RoleId)?.RoleName,
 | 
			
		||||
                        Tel = item.Phone,
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
                #endregion
 | 
			
		||||
                exp = filter => filter.Username.Contains(input.key) || filter.Phone.Contains(input.key) || filter.Email.Contains(input.key);
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            #endregion
 | 
			
		||||
            #region 获取数据
 | 
			
		||||
            var result = await base.GetListWithExp(exp);//获取人员信息
 | 
			
		||||
            if (result.Count() > 0)
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogError($"获取用户列表出现异常,请求参数:userQuery:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}," +
 | 
			
		||||
                                 $"请求接口:'api/User/GetUserList'," +
 | 
			
		||||
                                 $"异常信息:{ex.Message}," +
 | 
			
		||||
                                 $"异常位置:{ex.StackTrace}"
 | 
			
		||||
                                 );
 | 
			
		||||
                return new ApiResult { code = 1, msg = "获取用户列表失败" };
 | 
			
		||||
                result = result.Skip((input.PageIndex - 1) * input.PageSize).Take(input.PageSize);
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogInformation($"获取用户列表参数:userQuery:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}");
 | 
			
		||||
                return new ApiResult { code = 0, data = null, msg = "没有用户信息" };
 | 
			
		||||
            }
 | 
			
		||||
            return new ApiResult { code = 0, data = list,msg="获取信息成功" };
 | 
			
		||||
            var roleList = await _roleService.GetRoleListByIds(result.Select(s => s.RoleId).ToList());//根据角色Id获取角色信息
 | 
			
		||||
            #endregion
 | 
			
		||||
            #region 组装返回数据
 | 
			
		||||
            foreach (var item in result)
 | 
			
		||||
            {
 | 
			
		||||
                list.Add(new UserDetailDto
 | 
			
		||||
                {
 | 
			
		||||
                    UserId = item.Id,
 | 
			
		||||
                    Username = item.Username,
 | 
			
		||||
                    Email = item.Email,
 | 
			
		||||
                    RoleId = item.RoleId,
 | 
			
		||||
                    RoleName = roleList.FirstOrDefault(s => s.Id == item.RoleId)?.RoleName,
 | 
			
		||||
                    Tel = item.Phone,
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            #endregion
 | 
			
		||||
            return new ApiResult { code = 0, data = list, msg = "获取信息成功" };
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -226,51 +179,36 @@ namespace langguanApi.Service
 | 
			
		|||
        public async Task<ApiResult> GetUserById(string userId)
 | 
			
		||||
        {
 | 
			
		||||
            UserDetailDto userDetail = null;
 | 
			
		||||
            try
 | 
			
		||||
 | 
			
		||||
            #region 校验数据
 | 
			
		||||
            if (string.IsNullOrEmpty(userId))
 | 
			
		||||
            {
 | 
			
		||||
                #region 校验数据
 | 
			
		||||
                if (string.IsNullOrEmpty(userId))
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult { code = 1, msg = "获取用户信息失败,userId非空" };
 | 
			
		||||
                }
 | 
			
		||||
                #endregion
 | 
			
		||||
                #region 获取数据
 | 
			
		||||
                var user = await base.GetAsync(userId);//根据userId获取用户信息
 | 
			
		||||
                if (user == null)
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult { code = 1, msg = "用户不存在" };
 | 
			
		||||
                }
 | 
			
		||||
                var role = await _roleService.GetRoleById(user.RoleId);//根据角色Id获取角色信息
 | 
			
		||||
                if (role == null)
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult { code = 1, msg = "角色不存在" };
 | 
			
		||||
                }
 | 
			
		||||
                #endregion
 | 
			
		||||
                #region 组织需要展示的数据
 | 
			
		||||
                userDetail = new UserDetailDto
 | 
			
		||||
                {
 | 
			
		||||
                    UserId = user.Id,
 | 
			
		||||
                    Username = user.Username,
 | 
			
		||||
                    Email = user.Email,
 | 
			
		||||
                    RoleId = user.RoleId,
 | 
			
		||||
                    RoleName = role.RoleName,
 | 
			
		||||
                    Tel = user.Phone
 | 
			
		||||
                };
 | 
			
		||||
                #endregion
 | 
			
		||||
                return new ApiResult { code = 1, msg = "获取用户信息失败,userId非空" };
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            #endregion
 | 
			
		||||
            #region 获取数据
 | 
			
		||||
            var user = await base.GetAsync(userId);//根据userId获取用户信息
 | 
			
		||||
            if (user == null)
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogError($"获取用户信息出现异常,请求参数:userId:{userId}," +
 | 
			
		||||
                $"请求接口:'api/User/GetUserById'," +
 | 
			
		||||
                $"异常信息:{ex.Message}," +
 | 
			
		||||
                $"异常位置:{ex.StackTrace}"
 | 
			
		||||
                );
 | 
			
		||||
                return new ApiResult { code = 1, msg = "获取用户信息失败" };
 | 
			
		||||
                return new ApiResult { code = 1, msg = "用户不存在" };
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            var role = await _roleService.GetRoleById(user.RoleId);//根据角色Id获取角色信息
 | 
			
		||||
            if (role == null)
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogInformation($"获取用户信息参数:userId:{userId}");
 | 
			
		||||
                return new ApiResult { code = 1, msg = "角色不存在" };
 | 
			
		||||
            }
 | 
			
		||||
            #endregion
 | 
			
		||||
            #region 组织需要展示的数据
 | 
			
		||||
            userDetail = new UserDetailDto
 | 
			
		||||
            {
 | 
			
		||||
                UserId = user.Id,
 | 
			
		||||
                Username = user.Username,
 | 
			
		||||
                Email = user.Email,
 | 
			
		||||
                RoleId = user.RoleId,
 | 
			
		||||
                RoleName = role.RoleName,
 | 
			
		||||
                Tel = user.Phone
 | 
			
		||||
            };
 | 
			
		||||
            #endregion
 | 
			
		||||
            return new ApiResult { code = 0, data = userDetail };
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -278,55 +216,40 @@ namespace langguanApi.Service
 | 
			
		|||
        //更新用户信息方法
 | 
			
		||||
        public async Task<ApiResult> UpdateUser(UserDto input)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
 | 
			
		||||
            #region 校验参数
 | 
			
		||||
            if (string.IsNullOrEmpty(input.Id))
 | 
			
		||||
            {
 | 
			
		||||
                #region 校验参数
 | 
			
		||||
                if (string.IsNullOrEmpty(input.Id))
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult { code = 1, msg = "用户Id不能为空" };
 | 
			
		||||
                }
 | 
			
		||||
                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 userEntity = input.Adapt<UserEntity>();
 | 
			
		||||
                userEntity.Phone = input.Tel;
 | 
			
		||||
                if (!string.IsNullOrEmpty(input.Password))
 | 
			
		||||
                {
 | 
			
		||||
                    userEntity.Password = StringHelper.MD5Encrypt32(input.Password);
 | 
			
		||||
                }
 | 
			
		||||
                #endregion
 | 
			
		||||
                #region 更新数据
 | 
			
		||||
                await base.UpdateAsync(input.Id, userEntity);//更新用户信息
 | 
			
		||||
                #endregion
 | 
			
		||||
                return new ApiResult { code = 1, msg = "用户Id不能为空" };
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            if (string.IsNullOrEmpty(input.Username))
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogError($"更新用户信息出现异常,请求参数:user:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}," +
 | 
			
		||||
                                 $"请求接口:'api/User/UpdateUser'," +
 | 
			
		||||
                                 $"异常信息:{ex.Message}," +
 | 
			
		||||
                                 $"异常位置:{ex.StackTrace}"
 | 
			
		||||
                                 );
 | 
			
		||||
                return new ApiResult { code = 1, msg = "更新用户信息失败" };
 | 
			
		||||
                return new ApiResult { code = 1, msg = "用户名不能为空" };
 | 
			
		||||
            }
 | 
			
		||||
            finally
 | 
			
		||||
            if (string.IsNullOrEmpty(input.Tel))
 | 
			
		||||
            {
 | 
			
		||||
                _logger.LogInformation($"更新用户信息参数:user:{Newtonsoft.Json.JsonConvert.SerializeObject(input)}");
 | 
			
		||||
                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 userEntity = input.Adapt<UserEntity>();
 | 
			
		||||
            userEntity.Phone = input.Tel;
 | 
			
		||||
            if (!string.IsNullOrEmpty(input.Password))
 | 
			
		||||
            {
 | 
			
		||||
                userEntity.Password = StringHelper.MD5Encrypt32(input.Password);
 | 
			
		||||
            }
 | 
			
		||||
            #endregion
 | 
			
		||||
            #region 更新数据
 | 
			
		||||
            await base.UpdateAsync(input.Id, userEntity);//更新用户信息
 | 
			
		||||
            #endregion
 | 
			
		||||
            return new ApiResult { code = 0, msg = "更新用户信息成功" };
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -337,37 +260,22 @@ namespace langguanApi.Service
 | 
			
		|||
        /// <returns></returns>
 | 
			
		||||
        public async Task<ApiResult> DeleteUser(string userId)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
 | 
			
		||||
            #region 校验数据
 | 
			
		||||
            if (string.IsNullOrEmpty(userId))
 | 
			
		||||
            {
 | 
			
		||||
                #region 校验数据
 | 
			
		||||
                if (string.IsNullOrEmpty(userId))
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult { code = 1, msg = "用户Id不能为空" };
 | 
			
		||||
                }
 | 
			
		||||
                #endregion
 | 
			
		||||
                #region 更新数据
 | 
			
		||||
                var user = await base.GetAsync(userId);//根据userId获取用户信息
 | 
			
		||||
                if (user == null)
 | 
			
		||||
                {
 | 
			
		||||
                    return new ApiResult { code = 1, msg = "用户不存在" };
 | 
			
		||||
                }
 | 
			
		||||
                user.IsDelete = true;
 | 
			
		||||
                await base.UpdateAsync(userId, user);//更新用户信息
 | 
			
		||||
                #endregion
 | 
			
		||||
                return new ApiResult { code = 1, msg = "用户Id不能为空" };
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            #endregion
 | 
			
		||||
            #region 更新数据
 | 
			
		||||
            var user = await base.GetAsync(userId);//根据userId获取用户信息
 | 
			
		||||
            if (user == null)
 | 
			
		||||
            {
 | 
			
		||||
                _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 = 1, msg = "用户不存在" };
 | 
			
		||||
            }
 | 
			
		||||
            user.IsDelete = true;
 | 
			
		||||
            await base.UpdateAsync(userId, user);//更新用户信息
 | 
			
		||||
            #endregion
 | 
			
		||||
            return new ApiResult { code = 0, msg = "删除用户信息成功" };
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,105 @@
 | 
			
		|||
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,5 +1,7 @@
 | 
			
		|||
using langguanApi.Extensions.AutoDI;
 | 
			
		||||
using Newtonsoft.Json;
 | 
			
		||||
using NPOI.SS.Formula.Functions;
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
 | 
			
		||||
namespace langguanApi.Service
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -14,7 +16,7 @@ namespace langguanApi.Service
 | 
			
		|||
        {
 | 
			
		||||
            _httpClientFactory = httpClientFactory;
 | 
			
		||||
            _configuration = configuration;
 | 
			
		||||
            _logger=logger;
 | 
			
		||||
            _logger = logger;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 爬气象局的天气数据%
 | 
			
		||||
| 
						 | 
				
			
			@ -50,6 +52,202 @@ namespace langguanApi.Service
 | 
			
		|||
            }
 | 
			
		||||
            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
 | 
			
		||||
        {
 | 
			
		||||
            /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,12 +15,21 @@
 | 
			
		|||
    "Key": "tdss",
 | 
			
		||||
    "Index": 5
 | 
			
		||||
  },
 | 
			
		||||
  "Weather": "https://weather.cma.cn/api/now/54511", //天气预报地址,中国气象
 | 
			
		||||
  "Weather": "https://weather.cma.cn/api/now/54475", //天气预报地址,中国气象
 | 
			
		||||
  "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": {
 | 
			
		||||
    "Title": "鄂托克旗新航焦化有限公司",
 | 
			
		||||
    "Title": "朋义矿场",
 | 
			
		||||
    "Center": {
 | 
			
		||||
      "lat": 39.4716613,
 | 
			
		||||
      "lon": 107.1413332
 | 
			
		||||
      "lat": 40.718429,
 | 
			
		||||
      "lon": 122.548834
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  },
 | 
			
		||||
  "BatchId": 30 //批次号间隔时间30分钟
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,10 +16,12 @@
 | 
			
		|||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="IceCoffee.FastSocket" Version="1.0.3" />
 | 
			
		||||
    <PackageReference Include="JT808" Version="2.6.8" />
 | 
			
		||||
    <PackageReference Include="Mapster" Version="7.4.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.27" />
 | 
			
		||||
    <PackageReference Include="MongoDB.Bson" Version="2.23.1" />
 | 
			
		||||
    <PackageReference Include="MongoDB.Driver" Version="2.23.1" />
 | 
			
		||||
    <PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="6.0.33" />
 | 
			
		||||
    <PackageReference Include="MongoDB.Bson" Version="2.27.0" />
 | 
			
		||||
    <PackageReference Include="MongoDB.Driver" Version="2.27.0" />
 | 
			
		||||
    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
 | 
			
		||||
    <PackageReference Include="Npoi.Mapper" Version="6.2.1" />
 | 
			
		||||
    <PackageReference Include="StackExchange.Redis" Version="2.7.33" />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue