Przeglądaj źródła

摄像设备推送车辆信息接口

yinyafei 2 lat temu
rodzic
commit
309019c09f

+ 115 - 0
PMS.NetCore/PMS.NetCore/Controllers/AlarmInfoPlateController.cs

@@ -0,0 +1,115 @@
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Utils;
+
+namespace PMS.NetCore.Controllers
+{
+    /// <summary>
+    /// 车牌识别一体机推送车辆信息
+    /// </summary>
+    [Produces("application/json;charset=UTF-8")]
+    [Route("api/AlarmInfoPlate")]
+    [ApiController]
+    public class AlarmInfoPlateController : BaseController
+    {
+
+        /// <summary>
+        /// 客户关系
+        /// </summary>
+        public AlarmInfoPlateController()
+        {
+            logger = NLog.LogManager.GetCurrentClassLogger();
+        }
+
+        /// <summary>
+        /// 推送车辆进出信息
+        /// </summary>
+        /// <param name="caiInOrOutInfo">进出车辆信息</param>
+        /// <returns></returns>
+        [AllowAnonymous]
+        [HttpPost]
+        [Route("CarInOrOut")]
+        public JsonResult CarInOrOut([FromBody] CaiInOrOut caiInOrOutInfo)
+        {
+            var response = new Response_AlarmInfoPlate();
+            //logger.Info($"【Fdc_pm_ownerAdd】dto:{JsonConvert.SerializeObject(list)}");
+            try
+            {
+                string serialno = caiInOrOutInfo.AlarmInfoPlate.Serialno;
+                string license = caiInOrOutInfo.AlarmInfoPlate.Result.PlateResult.License;
+                //var errmsg = "";
+
+                //var manager = new fdc_pm_ownerManager();
+                //foreach (var dto in list)
+                //{
+
+                //}
+                //if (errmsg != "")
+                //{
+                //    return Json(errmsg);
+                //}
+
+                //去除重复的业主主键
+                //var list1 = list.Where((x, i) => list.FindIndex(z => z.ownerid == x.ownerid) == i).ToList();
+                //var list2 = new List<string>();
+                //var owneridMsg = "";
+                //foreach (var dto in list1)
+                //{
+                //    var index = list.IndexOf(dto);
+                //    var entity = manager.GetById(dto.ownerid);
+                //    if (entity != null)
+                //    {
+                //        owneridMsg += $"第{index + 1}条数据{dto.ownerid }业主编码已存在;";
+                //        list2.Add(dto.ownerid);
+                //    }
+
+                //}
+                //if(owneridMsg.IsNotNullAndEmpty())
+                //{
+                //    return Json(owneridMsg);
+                ////}
+                //for (int i = list1.Count - 1; i >= 0; i--)
+                //{
+                //    var entity = manager.GetById(list1[i].ownerid);
+                //    if (entity != null)
+                //    {
+                //        list1.Remove(list1[i]);
+                //    }
+                //}
+
+                //int row = 0;
+                //if (list1.Count > 0)
+                //{
+                //    //批量插入
+                //    row = manager.Db.Insertable(list1).ExecuteCommand();
+                //}
+                //else
+                //{
+                //    row = 1;
+                //}
+
+
+
+                //logger.Info($"【Fdc_pm_ownerAdd】row:{row}");
+
+
+                response.info = "Ok";
+                response.channelNum = "license";
+                return Json(response);
+
+            }
+            catch (Exception ex)
+            {
+                logger.Error(ex);
+
+                response.info = "Ok";
+                response.channelNum = "0";
+                return Json(response);
+            }
+        }
+
+    }
+}

+ 2 - 1
PMS.NetCore/PMS.NetCore/Filter/TokenAuthorize.cs

@@ -45,7 +45,8 @@ namespace PMS.NetCore.Filter
             {
                 //获取token
                 //object tokenobj = context.ActionArguments["token"];//前端地址栏参数传参
-                var token = context.HttpContext.Request.Headers["Authorization"].ToString();//前端写在header里面获取的
+                //var token = context.HttpContext.Request.Headers["Authorization"].ToString();//前端写在header里面获取的
+                var token ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiJhZG1pbiIsIm5iZiI6MTY0NjQ2NDM4NSwiZXhwIjoxNjQ2NTAwMzg1LCJpc3MiOiJsdXRhbyIsImF1ZCI6InByb3BlcnR5TXMifQ.qb2ZswGnKmCKMrNGGGR2pm2kBqeTsXM4vyvd4T0Bgjg";//前端写在header里面获取的
                 logger.Info($"Authorization token:{token}");
                 if (token.IsNullOrEmpty())
                 {

+ 17 - 0
PMS.NetCore/PMS.NetCore/PMS.NetCore.xml

@@ -4,6 +4,23 @@
         <name>PMS.NetCore</name>
     </assembly>
     <members>
+        <member name="T:PMS.NetCore.Controllers.AlarmInfoPlateController">
+            <summary>
+            车牌识别一体机推送车辆信息
+            </summary>
+        </member>
+        <member name="M:PMS.NetCore.Controllers.AlarmInfoPlateController.#ctor">
+            <summary>
+            客户关系
+            </summary>
+        </member>
+        <member name="M:PMS.NetCore.Controllers.AlarmInfoPlateController.CarInOrOut(Utils.CaiInOrOut)">
+            <summary>
+            推送车辆进出信息
+            </summary>
+            <param name="caiInOrOutInfo">进出车辆信息</param>
+            <returns></returns>
+        </member>
         <member name="M:PMS.NetCore.Controllers.BaseController.SetCookies(System.String,System.String,System.Int32)">
             <summary>
             设置本地cookie

+ 12 - 12
PMS.NetCore/PMS.NetCore/Startup.cs

@@ -170,18 +170,18 @@ namespace PMS.NetCore
                 {
                     app.UseDeveloperExceptionPage();
                 }
-                //启用静态资源(无参默认wwwroot文件夹)
-                //app.UseStaticFiles();
-                logger.Info($"root:{AppDomain.CurrentDomain.BaseDirectory}uploadimg");
-                //自定义资源
-                app.UseStaticFiles(new StaticFileOptions
-                {
-                    //资源所在的绝对路径。
-                    FileProvider = new PhysicalFileProvider(AppDomain.CurrentDomain.BaseDirectory + "uploadimg"),
+                ////启用静态资源(无参默认wwwroot文件夹)
+                ////app.UseStaticFiles();
+                //logger.Info($"root:{AppDomain.CurrentDomain.BaseDirectory}uploadimg");
+                ////自定义资源
+                //app.UseStaticFiles(new StaticFileOptions
+                //{
+                //    //资源所在的绝对路径。
+                //    FileProvider = new PhysicalFileProvider(AppDomain.CurrentDomain.BaseDirectory + "uploadimg"),
                     
-                    //表示访问路径,必须'/'开头
-                    RequestPath = "/uploadimg"
-                }) ;
+                //    //表示访问路径,必须'/'开头
+                //    RequestPath = "/uploadimg"
+                //}) ;
 
                 app.UseHttpsRedirection();
 
@@ -195,7 +195,7 @@ namespace PMS.NetCore
                     endpoints.MapControllers();
                 });
                 app.UseSwagger();
-                if (isIIS == false)     //若不是IIS部署
+                if (isIIS)     //若不是IIS部署
                 {
                     logger.Info($"isIIS:{isIIS}");
 

+ 332 - 0
PMS.NetCore/Utils/CaiInOrOut.cs

@@ -0,0 +1,332 @@
+using Newtonsoft.Json;
+using System.Collections.Generic;
+
+namespace Utils
+{
+    public class CaiInOrOut
+    {
+        public CaiInOrOut()
+        {
+        }
+
+        /// <summary>
+        /// 车牌识别结果
+        /// </summary>
+        [JsonProperty("AlarmInfoPlate")]
+        public AlarmInfoPlate AlarmInfoPlate { get; set; }
+    }
+
+    /// <summary>
+    /// 车牌识别结果
+    /// </summary>
+    public class AlarmInfoPlate
+    {
+
+        public AlarmInfoPlate() { }
+        /// <summary>
+        /// 默认通道号
+        /// </summary>
+        [JsonProperty("channel")]
+        public int Channel { get; set; }
+
+
+        /// <summary>
+        /// 设备名称
+        /// </summary>
+        [JsonProperty("deviceName")]
+        public string DeviceName { get; set; }
+
+
+        /// <summary>
+        /// 设备 ip 地址
+        /// </summary>
+        [JsonProperty("ipaddr")]
+        public string Ipaddr { get; set; }
+
+        /// <summary>
+        /// 实际数据
+        /// </summary>
+        [JsonProperty("result")]
+        public Result Result { get; set; }
+
+        /// <summary>
+        /// 设备序列号
+        /// </summary>
+        [JsonProperty("serialno")]
+        public string Serialno { get; set; }
+
+
+        [JsonProperty("user_data")]
+        public string User_data { get; set; }
+
+
+
+    }
+
+    /// <summary>
+    /// 实际数据
+    /// </summary>
+    public class Result
+    {
+
+        public Result() { }
+
+        /// <summary>
+        /// 车牌识别结果信息
+        /// </summary>
+        [JsonProperty("PlateResult")]
+        public PlateResult PlateResult { get; set; }
+    }
+
+    /// <summary>
+    /// 车牌识别结果信息
+    /// </summary>
+    public class PlateResult
+    {
+        public PlateResult() { }
+
+        /// <summary>
+        /// 亮度评价
+        /// </summary>
+        [JsonProperty("bright")]
+        public int Bright { get; set; }
+
+        /// <summary>
+        /// 车身亮度
+        /// </summary>
+        [JsonProperty("carBright")]
+        public int CarBright { get; set; }
+
+        /// <summary>
+        /// 车身颜色
+        /// </summary>
+        [JsonProperty("carColor")]
+        public int CarColor { get; set; }
+
+        /// <summary>
+        /// 车牌颜色 0:未知、1:蓝色、2:黄色、3:白色、4:黑 色、5:绿色
+        /// </summary>
+        [JsonProperty("colorType")]
+        public int ColorType { get; set; }
+
+
+        [JsonProperty("colorValue")]
+        public int ColorValue { get; set; }
+
+        /// <summary>
+        /// 识别结果可信度 1-100
+        /// </summary>
+        [JsonProperty("confidence")]
+        public int Confidence { get; set; }
+
+
+        /// <summary>
+        /// 车的行进方向,0:未知,1:左,2:右,3:上, 4:下
+        /// </summary>
+        [JsonProperty("direction")]
+        public int Direction { get; set; }
+
+
+        [JsonProperty("gioouts")]
+        public List< Gioouts> Gioouts { get; set; }
+
+        /// <summary>
+        /// 识别车牌小图片内容经过 base64 后的字符串
+        /// </summary>
+        [JsonProperty("imageFragmentFile")]
+        public string ImageFragmentFile { get; set; }
+
+
+        /// <summary>
+        /// 识别小图片内容长度,注意不是 base64 后的长度
+        /// </summary>
+        [JsonProperty("imageFragmentFileLen")]
+        public int ImageFragmentFileLen { get; set; }
+
+
+        /// <summary>
+        /// 设备离线状态,0:在线,1:离线
+        /// </summary>
+        [JsonProperty("isoffline")]
+        public int Isoffline { get; set; }
+
+        /// <summary>
+        /// 车牌号字符串,如“京 AAAAAA”
+        /// </summary>
+        [JsonProperty("license")]
+        public string License { get; set; }
+
+
+        [JsonProperty("license_ext_type")]
+        public int License_ext_type { get; set; }
+
+        /// <summary>
+        /// 车牌在图片中位置
+        /// </summary>
+        [JsonProperty("location")]
+        public Location Location { get; set; }
+
+        /// <summary>
+        /// 识别结果车牌 ID
+        /// </summary>
+        [JsonProperty("plateid")]
+        public int Plateid { get; set; }
+
+
+        /// <summary>
+        /// 识别结果对应帧的时间戳
+        /// </summary>
+        [JsonProperty("timeStamp")]
+        public TimeStamp TimeStamp { get; set; }
+
+        /// <summary>
+        /// 识别所用时间
+        /// </summary>
+        [JsonProperty("timeUsed")]
+        public int TimeUsed { get; set; }
+
+
+
+        /// <summary>
+        /// 当前结果的触发类型:1:自动触发类型、2:外部输入触 发(IO 输入)、4:软件触发(SDK)、8:虚拟线圈触发
+        /// </summary>
+        [JsonProperty("triggerType")]
+        public int TriggerType { get; set; }
+
+        /// <summary>
+        /// 车牌类型 0:未知车牌:、1:蓝牌小汽车、2::黑牌小汽车、 3:单排黄牌、4:双排黄牌、
+        /// 5:警车车牌、6:武警车 牌、7:个性化车牌、8:单排军车牌、9:双排军车牌、1 0:使馆车牌、
+        /// 11:香港进出中国大陆车牌、12:农用车牌、13:教练车牌、14:澳门进出中国大陆车牌、
+        /// 15:双 层武警车牌、16:武警总队车牌、17:双层武警总队车牌、 18:民航车牌、19:新能源车牌
+        /// </summary>
+        [JsonProperty("type")]
+        public int Type { get; set; }
+
+
+
+    }
+
+    public class Gioouts
+    {
+        public Gioouts() { }
+
+
+        /// <summary>
+        /// IO OUT 序号
+        /// </summary>
+        [JsonProperty("ionum")]
+        public string Ionum { get; set; }
+
+        /// <summary>
+        /// 开闸类型:HTTP_IO_OUT_STATUS
+        /// </summary>
+        [JsonProperty("Ctrltype")]
+        public string ctrltype { get; set; }
+    }
+    /// <summary>
+    /// 车牌在图片中位置
+    /// </summary>
+    public class Location
+    {
+        public Location() { }
+
+        /// <summary>
+        /// 位置为矩形区域;left\right\top\bottom:车牌在图片中位 置
+        /// </summary>
+        [JsonProperty("RECT")]
+        public RECT RECT { get; set; }
+    }
+
+    /// <summary>
+    /// 位置为矩形区域;left\right\top\bottom:车牌在图片中位 置
+    /// </summary>
+    public class RECT
+    {
+        public RECT() { }
+
+        [JsonProperty("bottom")]
+        public int Bottom { get; set; }
+
+
+        [JsonProperty("left")]
+        public int Left { get; set; }
+
+
+        [JsonProperty("right")]
+        public int Right { get; set; }
+
+
+        [JsonProperty("top")]
+        public int Top { get; set; }
+    }
+
+    /// <summary>
+    /// 识别结果对应帧的时间戳
+    /// </summary>
+    public class TimeStamp
+    {
+
+        public TimeStamp() { }
+        /// <summary>
+        /// 时间戳结构体类型
+        /// </summary>
+        [JsonProperty("Timeval")]
+        public Timeval Timeval { get; set; }
+    }
+
+    /// <summary>
+    /// 时间戳结构体类型
+    /// </summary>
+    public class Timeval
+    {
+        public Timeval() { }
+
+        /// <summary>
+        /// 时间,天
+        /// </summary>
+        [JsonProperty("decday")]
+        public int Decday { get; set; }
+
+        /// <summary>
+        /// 时间,小时
+        /// </summary>
+        [JsonProperty("dechour")]
+        public int Dechour { get; set; }
+
+        /// <summary>
+        /// 时间,分钟
+        /// </summary>
+        [JsonProperty("decmin")]
+        public int Decmin { get; set; }
+
+        /// <summary>
+        /// 时间,月
+        /// </summary>
+        [JsonProperty("decmon")]
+        public int Decmon { get; set; }
+
+        /// <summary>
+        /// 时间,秒
+        /// </summary>
+        [JsonProperty("decsec")]
+        public int Decsec { get; set; }
+
+        /// <summary>
+        /// 时间,年
+        /// </summary>
+        [JsonProperty("decyear")]
+        public int Decyear { get; set; }
+
+        /// <summary>
+        /// 从 1970 年 1 月 1 日到对应帧的秒
+        /// </summary>
+        [JsonProperty("sec")]
+        public int Sec { get; set; }
+
+        /// <summary>
+        /// 从 1970 年 1 月 1 日到对应帧的毫秒
+        /// </summary>
+        [JsonProperty("usec")]
+        public int Usec { get; set; }
+    }
+}

+ 45 - 0
PMS.NetCore/Utils/Response_AlarmInfoPlate.cs

@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Utils
+{
+    public class Response_AlarmInfoPlate
+    {
+        /// <summary>
+        /// OK 开闸
+        /// </summary>
+        public string info { get; set; }
+
+        /// <summary>
+        /// 端口号
+        /// </summary>
+        public string channelNum
+        {
+            get;
+            set;
+        }
+
+        /// <summary>
+        /// 串口数据
+        /// </summary>
+        public List<SerialData> serialData
+        {
+            get;
+            set;
+        }
+    }
+
+    /// <summary>
+    /// 串口数据
+    /// </summary>
+    public class SerialData
+    {
+        public string serialChannel { get; set; }
+
+        public string data { get; set; }
+
+        public int dataLen { get; set; }
+    }
+
+}